http

The HTTP extension adds HTTP protocol support to agents, including request handling, Server-Sent Events (SSE) streaming, and landing page rendering.

Installation

bun add @regent/http

Basic Usage

import { createAgent } from '@regent/core';
import { http } from '@regent/http';

const agent = await createAgent({
  name: 'my-agent',
  version: '1.0.0',
})
  .use(http())
  .build();

API Reference

http(options?)

Creates the HTTP extension.

HttpExtensionOptions

Example:

HTTP Handlers

When the HTTP extension is used, agent.handlers provides:

Framework adapters use these handlers to create routes.

Endpoints

Endpoint
Method
Description

/

GET

Landing page (if enabled)

/.well-known/agent.json

GET

Agent Card manifest

/health

GET

Health check

/entrypoints

GET

List available entrypoints

/entrypoints/:key/invoke

POST

Invoke an entrypoint

/entrypoints/:key/stream

POST

Stream from an entrypoint

/tasks

POST

Create a new task

/tasks

GET

List tasks

/tasks/:id

GET

Get task by ID

/tasks/:id/cancel

POST

Cancel a task

/tasks/:id/subscribe

GET

Subscribe to task updates (SSE)

/favicon.ico

GET

Favicon (if enabled)

Request/Response Format

Invoke Request

Invoke Response

Stream Request

Stream Response (SSE)

SSE Streaming

createSSEStream

Create a Server-Sent Events stream:

SSE Types

Stream Envelope Types

StreamRunStartEnvelope

StreamDeltaEnvelope

StreamTextEnvelope

StreamAssetEnvelope

StreamControlEnvelope

StreamErrorEnvelope

StreamRunEndEnvelope

StreamPushEnvelope

Envelopes used with emit() callback (excludes run-start and run-end):

Invoke Handler

InvokeResult

Utility Functions

normalizeOrigin

Normalizes the origin from a request, handling reverse proxy headers:

Exports

Last updated