summaryrefslogtreecommitdiffhomepage
path: root/packages/cli/src/args.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/args.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/args.ts')
-rw-r--r--packages/cli/src/args.ts23
1 files changed, 23 insertions, 0 deletions
diff --git a/packages/cli/src/args.ts b/packages/cli/src/args.ts
index ecf6e2e..ac5dd4a 100644
--- a/packages/cli/src/args.ts
+++ b/packages/cli/src/args.ts
@@ -47,6 +47,7 @@ export type ParsedCommand =
readonly cwd?: string;
readonly reasoningEffort?: ReasoningEffort;
}
+ | { readonly kind: "stop"; readonly server: string; readonly conversationId: string }
| { readonly kind: "help" }
| { readonly kind: "error"; readonly message: string };
@@ -131,6 +132,28 @@ export function parseArgs(argv: readonly string[], opts: ParseOpts): ParsedComma
return { kind: "compact", server, conversationId };
}
+ if (first === "stop") {
+ let server = opts.defaultServer;
+ let conversationId: string | undefined;
+ for (let i = 1; i < argv.length; i++) {
+ const arg = argv[i] as string;
+ if (arg === "--server") {
+ if (i + 1 >= argv.length) return { kind: "error", message: "--server requires a value" };
+ server = argv[++i] as string;
+ } else if (arg.startsWith("--")) {
+ return { kind: "error", message: `Unknown flag: ${arg}` };
+ } else if (conversationId !== undefined) {
+ return { kind: "error", message: `Unexpected argument for 'stop': ${arg}` };
+ } else {
+ conversationId = arg;
+ }
+ }
+ if (conversationId === undefined) {
+ return { kind: "error", message: "'stop' requires a conversation id" };
+ }
+ return { kind: "stop", server, conversationId };
+ }
+
if (first === "read") {
let server = opts.defaultServer;
let conversationId: string | undefined;