Skip to content

@robota-sdk/agent-transport-http SPEC

Scope

HTTP transport adapter for exposing InteractiveSession over REST API. Built on Hono for Cloudflare Workers + Node.js + AWS Lambda compatibility.

Boundaries

  • Does NOT own InteractiveSession — imported from @robota-sdk/agent-sdk
  • Does NOT own SystemCommandExecutor — imported from @robota-sdk/agent-sdk
  • Does NOT own Session, tools, providers — those are SDK internals
  • OWNS: HTTP route definitions, SSE streaming, request/response serialization

Architecture

Client (browser, curl, etc.)
  ↓ HTTP
Hono Router (agent-transport-http)
  ├── POST /submit       → session.submit(prompt) → SSE stream
  ├── POST /command      → commandExecutor.execute() → JSON
  ├── POST /abort        → session.abort() → JSON
  ├── POST /cancel-queue → session.cancelQueue() → JSON
  ├── GET  /messages     → session.getMessages() → JSON
  ├── GET  /context      → session.getContextState() → JSON
  ├── GET  /executing    → isExecuting → JSON
  └── GET  /pending      → pendingPrompt → JSON

InteractiveSession (agent-sdk)

Session (agent-sessions) → Core

Public API Surface

createAgentRoutes(options)

Factory function that returns a Hono app with all routes configured.

typescript
import { createAgentRoutes } from '@robota-sdk/agent-transport-http';
import { InteractiveSession, SystemCommandExecutor } from '@robota-sdk/agent-sdk';

const routes = createAgentRoutes({
  sessionFactory: (req) => interactiveSession,
  commandExecutor,
});

// Mount on existing Hono app
app.route('/agent', routes);

// Or use standalone
export default routes; // Cloudflare Workers

Session Factory

The sessionFactory callback receives the HTTP request context and returns an InteractiveSession. This allows per-request session resolution (e.g., by auth token, session ID).

Endpoints

MethodPathRequest BodyResponseDescription
POST/submit{ prompt: string }SSE streamSubmit prompt, stream events
POST/command{ name: string, args: string }ICommandResult JSONExecute system command
POST/abort{ ok: true }Abort current execution
POST/cancel-queue{ ok: true }Cancel queued prompt
GET/messagesTUniversalMessage[] JSONGet message history
GET/contextIContextWindowState JSONGet context window state
GET/executing{ executing: boolean } JSONCheck if executing
GET/pending{ pending: string|null } JSONGet pending queued prompt

SSE Event Types (POST /submit)

EventDataDescription
text_delta{ delta: string }Streaming text chunk
tool_startIToolStateTool execution began
tool_endIToolStateTool execution finished
thinking{ isThinking: boolean }Execution state changed
completeIExecutionResultPrompt completed
interruptedIExecutionResultExecution was aborted
error{ message: string }Execution error

Dependencies

  • @robota-sdk/agent-sdk (InteractiveSession, SystemCommandExecutor)
  • hono (HTTP framework)

Released under the MIT License.