summaryrefslogtreecommitdiffhomepage
path: root/packages/transport-http/src/extension.ts
diff options
context:
space:
mode:
authorAdam Malczewski <[email protected]>2026-06-11 12:45:21 +0900
committerAdam Malczewski <[email protected]>2026-06-11 12:45:21 +0900
commit27fd0be36b2f6395249de5aacc86e41fe4e0207f (patch)
tree67ae766c1985344878d6a2e71da18834fa73e47d /packages/transport-http/src/extension.ts
parentc2b4c05d91fa88b8d02c055a0e15c22abd8e21f3 (diff)
downloaddispatch-27fd0be36b2f6395249de5aacc86e41fe4e0207f.tar.gz
dispatch-27fd0be36b2f6395249de5aacc86e41fe4e0207f.zip
feat(cache-warming): manual POST /chat/warm trigger endpoint
A frontend 'warm now' button (and fast tests) can trigger a warm on demand instead of waiting for the automatic timer. - transport-contract: WarmRequest / WarmResponse wire types - transport-http: POST /chat/warm → cacheWarmHandle.warm(); 200 with cachePct, 409 when the conversation is generating, 400 on missing conversationId Live-verified vs claude haiku: seed turn cacheWrite=6799 → POST /chat/warm returns cacheReadTokens=6799 cachePct=100 (100% hit). 760 vitest + 109 bun green.
Diffstat (limited to 'packages/transport-http/src/extension.ts')
-rw-r--r--packages/transport-http/src/extension.ts12
1 files changed, 11 insertions, 1 deletions
diff --git a/packages/transport-http/src/extension.ts b/packages/transport-http/src/extension.ts
index 4abd7aa..5274033 100644
--- a/packages/transport-http/src/extension.ts
+++ b/packages/transport-http/src/extension.ts
@@ -1,6 +1,7 @@
import type { Extension, HostAPI, Manifest } from "@dispatch/kernel";
import { createApp } from "./app.js";
import {
+ cacheWarmHandle,
conversationStoreHandle,
credentialStoreHandle,
sessionOrchestratorHandle,
@@ -16,7 +17,14 @@ export const manifest: Manifest = {
dependsOn: ["conversation-store", "credential-store", "session-orchestrator", "throughput-store"],
capabilities: { network: true },
contributes: {
- routes: ["/chat", "/conversations/:id", "/health", "/models", "/metrics/throughput"],
+ routes: [
+ "/chat",
+ "/chat/warm",
+ "/conversations/:id",
+ "/health",
+ "/models",
+ "/metrics/throughput",
+ ],
},
activation: "eager",
};
@@ -36,6 +44,7 @@ export function createTransportHttpExtension(): Extension & {
const orchestrator = host.getService(sessionOrchestratorHandle);
const credentialStore = host.getService(credentialStoreHandle);
const throughputStore = host.getService(throughputStoreHandle);
+ const warmService = host.getService(cacheWarmHandle);
const logger = host.logger;
const app = createApp({
@@ -43,6 +52,7 @@ export function createTransportHttpExtension(): Extension & {
orchestrator,
credentialStore,
throughputStore,
+ warmService,
logger,
});