summaryrefslogtreecommitdiffhomepage
path: root/packages/cli/src/http.ts
diff options
context:
space:
mode:
authorAdam Malczewski <[email protected]>2026-06-22 02:53:20 +0900
committerAdam Malczewski <[email protected]>2026-06-22 02:53:20 +0900
commit20db60b0705ab65b6ade67ff614d347e13dc9803 (patch)
tree02361b6b94d6a397355b42e7208b1c3ba39fb692 /packages/cli/src/http.ts
parentd233842752d32659bba6f0e47b536e50d03145aa (diff)
downloaddispatch-20db60b0705ab65b6ade67ff614d347e13dc9803.tar.gz
dispatch-20db60b0705ab65b6ade67ff614d347e13dc9803.zip
feat: stop generation mid-turn (POST /conversations/:id/stop)
Add stopTurn to the orchestrator: aborts the in-flight turn's AbortController without changing conversation status. The turn seals normally (finishReason: 'aborted'), partial messages are persisted, and the conversation transitions active → idle via the normal settle path. Distinct from closeConversation which marks the conversation closed. - POST /conversations/:id/stop endpoint - dispatch stop <id> CLI command - FE handoff: frontend-stop-generation-handoff.md
Diffstat (limited to 'packages/cli/src/http.ts')
-rw-r--r--packages/cli/src/http.ts20
1 files changed, 20 insertions, 0 deletions
diff --git a/packages/cli/src/http.ts b/packages/cli/src/http.ts
index 585c678..42fcfec 100644
--- a/packages/cli/src/http.ts
+++ b/packages/cli/src/http.ts
@@ -204,6 +204,26 @@ export async function compactConversation(
return (await res.json()) as CompactResponse;
}
+interface StopTurnOpts {
+ readonly server: string;
+ readonly conversationId: string;
+}
+
+export async function stopTurn(
+ deps: FetchDeps,
+ opts: StopTurnOpts,
+): Promise<{ conversationId: string; abortedTurn: boolean }> {
+ const url = `${opts.server}/conversations/${encodeURIComponent(opts.conversationId)}/stop`;
+ const res = await deps.fetchImpl(url, { method: "POST" });
+
+ if (!res.ok) {
+ const body = await res.text();
+ throw new Error(`POST /conversations/:id/stop failed with status ${res.status}: ${body}`);
+ }
+
+ return (await res.json()) as { conversationId: string; abortedTurn: boolean };
+}
+
/**
* The outcome of short-ID resolution: either the full conversation id to use,
* or a human-readable error describing why resolution failed.