Skip to content

HTTP Transport

Expose InteractiveSession over REST API using Hono.

Basic Setup

typescript
import { InteractiveSession } from '@robota-sdk/agent-sdk';
import { createHttpTransport } from '@robota-sdk/agent-transport-http';
import { serve } from '@hono/node-server';

const session = new InteractiveSession({ cwd: process.cwd(), provider });

const transport = createHttpTransport();
session.attachTransport(transport);
await transport.start();

serve({ fetch: transport.getApp().fetch, port: 3000 });

Endpoints

MethodPathDescription
POST/submitSubmit prompt, stream events via SSE
POST/commandExecute system command
POST/abortAbort current execution
POST/cancel-queueCancel queued prompt
GET/messagesGet message history
GET/contextGet context window state
GET/executingCheck if executing
GET/pendingGet pending queued prompt

SSE Events (POST /submit)

bash
curl -X POST http://localhost:3000/submit \
  -H "Content-Type: application/json" \
  -d '{"prompt": "Explain this project"}'

Events: text_delta, tool_start, tool_end, thinking, complete, interrupted, error.

Advanced: Session Factory

For per-request sessions (e.g., multi-tenant):

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

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

Released under the MIT License.