express

The Express adapter creates HTTP applications from agent runtimes using Express.js.

Installation

bun add @regent/express express
npm install @regent/express express

Basic Usage

import { createAgent } from '@regent/core';
import { http } from '@regent/http';
import { createAgentApp } from '@regent/express';
import { z } from 'zod';

const agent = await createAgent({
  name: 'my-agent',
  version: '1.0.0',
})
  .use(http())
  .addEntrypoint({
    key: 'echo',
    input: z.object({ text: z.string() }),
    handler: async ({ input }) => ({
      output: { echoed: input.text },
    }),
  })
  .build();

const { app, addEntrypoint } = await createAgentApp(agent);

app.listen(3000, () => {
  console.log('Agent running on port 3000');
});

API Reference

createAgentApp()

Creates an Express application from an AgentRuntime.

Requirements: Runtime must have HTTP extension enabled via .use(http())

CreateAgentAppOptions

Return Value

Routes

Method
Path
Description

GET

/health

Health check

GET

/entrypoints

List entrypoints

GET

/.well-known/agent.json

Agent manifest

GET

/.well-known/agent-card.json

Agent card

GET

/favicon.svg

Favicon

GET

/

Landing page (if enabled)

POST

/entrypoints/{key}/invoke

Invoke entrypoint

POST

/entrypoints/{key}/stream

Stream entrypoint

POST

/tasks

Create task

GET

/tasks

List tasks

GET

/tasks/{taskId}

Get task

POST

/tasks/{taskId}/cancel

Cancel task

GET

/tasks/{taskId}/subscribe

Subscribe to task (SSE)

Middleware Hooks

Dynamic Entrypoints

Payment Integration

withPayments()

Request/Response Conversion

The adapter converts between Express and Fetch API formats:

Exports

Last updated