diff options
| author | Adam Malczewski <[email protected]> | 2026-06-05 21:20:12 +0900 |
|---|---|---|
| committer | Adam Malczewski <[email protected]> | 2026-06-05 21:20:12 +0900 |
| commit | 7fb3269c698ae583ea7997ce206c4ae252fd3218 (patch) | |
| tree | 247d03408ecccd633290ea56b1b08811ebe460ec /packages/transport-http/src/app.ts | |
| parent | 4283d1f8a0bc3953e65962a2364c903d0015f047 (diff) | |
| download | dispatch-7fb3269c698ae583ea7997ce206c4ae252fd3218.tar.gz dispatch-7fb3269c698ae583ea7997ce206c4ae252fd3218.zip | |
feat(backend): credential-store + model selection/catalog (GET /models) + per-turn cwd through orchestrator/transport/host-bin
Diffstat (limited to 'packages/transport-http/src/app.ts')
| -rw-r--r-- | packages/transport-http/src/app.ts | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/packages/transport-http/src/app.ts b/packages/transport-http/src/app.ts index e1e954c..d5492ce 100644 --- a/packages/transport-http/src/app.ts +++ b/packages/transport-http/src/app.ts @@ -1,10 +1,12 @@ import type { AgentEvent } from "@dispatch/kernel"; +import type { ModelsResponse } from "@dispatch/transport-contract"; import { Hono } from "hono"; import { isParseError, parseChatBody, serializeEventLine } from "./logic.js"; -import type { SessionOrchestrator } from "./seam.js"; +import type { CredentialStore, SessionOrchestrator } from "./seam.js"; export interface CreateServerOptions { readonly orchestrator: SessionOrchestrator; + readonly credentialStore: CredentialStore; readonly generateId?: () => string; } @@ -14,6 +16,16 @@ export function createApp(opts: CreateServerOptions): Hono { app.get("/health", (c) => c.json({ ok: true })); + app.get("/models", async (c) => { + try { + const models = await opts.credentialStore.listCatalog(); + const body: ModelsResponse = { models }; + return c.json(body, 200); + } catch { + return c.json({ error: "Failed to retrieve model catalog" }, 502); + } + }); + app.post("/chat", async (c) => { let body: unknown; try { @@ -27,21 +39,25 @@ export function createApp(opts: CreateServerOptions): Hono { return c.json({ error: result.error }, 400); } - const { conversationId, message } = result; + const { conversationId, message, model, cwd } = result; const events: AgentEvent[] = []; let resolveStream: () => void; const streamReady = new Promise<void>((resolve) => { resolveStream = resolve; }); + const orchestratorInput: Parameters<SessionOrchestrator["handleMessage"]>[0] = { + conversationId, + text: message, + onEvent: (event) => { + events.push(event); + }, + ...(model !== undefined ? { modelName: model } : {}), + ...(cwd !== undefined ? { cwd } : {}), + }; + const orchestratorPromise = opts.orchestrator - .handleMessage({ - conversationId, - text: message, - onEvent: (event) => { - events.push(event); - }, - }) + .handleMessage(orchestratorInput) .then(() => { resolveStream(); }) |
