summaryrefslogtreecommitdiffhomepage
path: root/packages/transport-http/src/app.ts
diff options
context:
space:
mode:
authorAdam Malczewski <[email protected]>2026-06-05 21:20:12 +0900
committerAdam Malczewski <[email protected]>2026-06-05 21:20:12 +0900
commit7fb3269c698ae583ea7997ce206c4ae252fd3218 (patch)
tree247d03408ecccd633290ea56b1b08811ebe460ec /packages/transport-http/src/app.ts
parent4283d1f8a0bc3953e65962a2364c903d0015f047 (diff)
downloaddispatch-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.ts34
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();
})