@hearsay-tools/squawk 0.18.0-pr3694.6745 → 0.18.0-pr3695.6789
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ci-wait/controller.d.ts +4 -4
- package/dist/ci-wait/tools.d.ts +4 -4
- package/dist/contract/index.d.ts +1 -0
- package/dist/contract/index.js +36 -4
- package/dist/contract/own-lookup.d.ts +5 -0
- package/dist/contract/run-predicates.d.ts +28 -1
- package/dist/contract/runs.d.ts +34 -3
- package/dist/core/agent-runner.d.ts +11 -0
- package/dist/core/agent-runner.js.map +1 -1
- package/dist/core/claude-cli-runner.d.ts +6 -0
- package/dist/core/claude-forked-command.d.ts +36 -0
- package/dist/core/claude-forked-command.js +65 -0
- package/dist/core/claude-forked-command.js.map +1 -0
- package/dist/core/claude-ui-mapper.d.ts +2 -1
- package/dist/core/claude-ui-mapper.js +17 -1
- package/dist/core/claude-ui-mapper.js.map +1 -1
- package/dist/core/codex-app-server-runner.d.ts +6 -0
- package/dist/core/cursor-print-runner.d.ts +6 -0
- package/dist/core/cursor-runner.d.ts +6 -0
- package/dist/core/managed-session.js +3 -0
- package/dist/core/managed-session.js.map +1 -1
- package/dist/core/omp-runner.d.ts +6 -0
- package/dist/core/opencode-server-runner.d.ts +6 -0
- package/dist/core/opencode-server-runner.js +26 -43
- package/dist/core/opencode-server-runner.js.map +1 -1
- package/dist/core/opencode-session-error.d.ts +9 -0
- package/dist/core/opencode-session-error.js +45 -0
- package/dist/core/opencode-session-error.js.map +1 -1
- package/dist/core/own-lookup.d.ts +1 -5
- package/dist/core/own-lookup.js +1 -7
- package/dist/core/own-lookup.js.map +1 -1
- package/dist/core/pi-runner.d.ts +6 -0
- package/dist/core/runner-facts.d.ts +73 -0
- package/dist/core/runner-facts.js +66 -0
- package/dist/core/runner-facts.js.map +1 -1
- package/dist/delegation/conversations.d.ts +10 -2
- package/dist/delegation/execution-identity.d.ts +13 -5
- package/dist/delegation/execution-identity.js +23 -9
- package/dist/delegation/execution-identity.js.map +1 -1
- package/dist/delegation/routes.d.ts +83 -83
- package/dist/delegation/transport.d.ts +11 -11
- package/dist/runs/legacy-run-rows.d.ts +8 -0
- package/dist/runs/legacy-run-rows.js +19 -0
- package/dist/runs/legacy-run-rows.js.map +1 -1
- package/dist/runs/outcome-commit.d.ts +4 -1
- package/dist/runs/outcome-commit.js +8 -2
- package/dist/runs/outcome-commit.js.map +1 -1
- package/dist/runs/run-exits.d.ts +1370 -51
- package/dist/runs/run-exits.js +18 -7
- package/dist/runs/run-exits.js.map +1 -1
- package/dist/runs/store.d.ts +16 -4
- package/dist/runs/store.js +4 -4
- package/dist/runs/store.js.map +1 -1
- package/dist/serve-boot.js +1 -0
- package/dist/serve-boot.js.map +1 -1
- package/dist/server/open-in-targets.js +5 -4
- package/dist/server/open-in-targets.js.map +1 -1
- package/dist/server/provider-auth-runtime.js +2 -1
- package/dist/server/provider-auth-runtime.js.map +1 -1
- package/dist/server/server.d.ts +90 -18
- package/dist/server/server.js +4 -7
- package/dist/server/server.js.map +1 -1
- package/dist/workflows/continuation-admission.d.ts +12 -2
- package/dist/workflows/continuation-admission.js +12 -7
- package/dist/workflows/continuation-admission.js.map +1 -1
- package/dist/workflows/execution-account.js +4 -3
- package/dist/workflows/execution-account.js.map +1 -1
- package/dist/workflows/outcome-batches.d.ts +3 -2
- package/dist/workflows/outcome-batches.js +4 -3
- package/dist/workflows/outcome-batches.js.map +1 -1
- package/dist/workflows/run/auto-resume.d.ts +9 -8
- package/dist/workflows/run/auto-resume.js +17 -27
- package/dist/workflows/run/auto-resume.js.map +1 -1
- package/dist/workflows/run/completion-gate.js +1 -1
- package/dist/workflows/run/completion-gate.js.map +1 -1
- package/dist/workflows/run/compose.d.ts +3 -0
- package/dist/workflows/run/compose.js +16 -13
- package/dist/workflows/run/compose.js.map +1 -1
- package/dist/workflows/run/continuation-acceptance.js +2 -1
- package/dist/workflows/run/continuation-acceptance.js.map +1 -1
- package/dist/workflows/run/continuation-session.js +7 -4
- package/dist/workflows/run/continuation-session.js.map +1 -1
- package/dist/workflows/run/family-reconciler.d.ts +4 -5
- package/dist/workflows/run/family-reconciler.js +9 -19
- package/dist/workflows/run/family-reconciler.js.map +1 -1
- package/dist/workflows/run/human-waits.d.ts +19 -1
- package/dist/workflows/run/human-waits.js +48 -3
- package/dist/workflows/run/human-waits.js.map +1 -1
- package/dist/workflows/run/inbox-claims.d.ts +3 -4
- package/dist/workflows/run/inbox-claims.js +7 -17
- package/dist/workflows/run/inbox-claims.js.map +1 -1
- package/dist/workflows/run/input-delivery.d.ts +9 -1
- package/dist/workflows/run/input-delivery.js +23 -22
- package/dist/workflows/run/input-delivery.js.map +1 -1
- package/dist/workflows/run/input-receipts.d.ts +10 -4
- package/dist/workflows/run/input-receipts.js +5 -4
- package/dist/workflows/run/input-receipts.js.map +1 -1
- package/dist/workflows/run/input-timers.js +3 -2
- package/dist/workflows/run/input-timers.js.map +1 -1
- package/dist/workflows/run/launch-read-resolver.d.ts +7 -2
- package/dist/workflows/run/launch-read-resolver.js +34 -12
- package/dist/workflows/run/launch-read-resolver.js.map +1 -1
- package/dist/workflows/run/live-session-state.d.ts +3 -0
- package/dist/workflows/run/live-session-state.js +3 -0
- package/dist/workflows/run/live-session-state.js.map +1 -1
- package/dist/workflows/run/liveness-timers.d.ts +101 -0
- package/dist/workflows/run/liveness-timers.js +132 -0
- package/dist/workflows/run/liveness-timers.js.map +1 -0
- package/dist/workflows/run/queued-revival.js +2 -1
- package/dist/workflows/run/queued-revival.js.map +1 -1
- package/dist/workflows/run/run-memory.d.ts +11 -3
- package/dist/workflows/run/run-memory.js +34 -8
- package/dist/workflows/run/run-memory.js.map +1 -1
- package/dist/workflows/run/run-settlement.d.ts +9 -4
- package/dist/workflows/run/run-settlement.js +25 -12
- package/dist/workflows/run/run-settlement.js.map +1 -1
- package/dist/workflows/run/session-events.d.ts +4 -2
- package/dist/workflows/run/session-events.js +3 -2
- package/dist/workflows/run/session-events.js.map +1 -1
- package/dist/workflows/run/squawk-tools.js +2 -0
- package/dist/workflows/run/squawk-tools.js.map +1 -1
- package/dist/workflows/run/step-loop.d.ts +2 -2
- package/dist/workflows/run/step-loop.js +8 -3
- package/dist/workflows/run/step-loop.js.map +1 -1
- package/dist/workflows/run/subagent-waits.d.ts +16 -6
- package/dist/workflows/run/subagent-waits.js +51 -33
- package/dist/workflows/run/subagent-waits.js.map +1 -1
- package/dist/workflows/run/turn-nudges.d.ts +3 -1
- package/dist/workflows/run/turn-nudges.js +9 -6
- package/dist/workflows/run/turn-nudges.js.map +1 -1
- package/dist/workflows/run/turn-settler.d.ts +10 -3
- package/dist/workflows/run/turn-settler.js +20 -6
- package/dist/workflows/run/turn-settler.js.map +1 -1
- package/dist/workflows/run/wait-engine.d.ts +5 -1
- package/dist/workflows/run/wait-kinds.d.ts +0 -1
- package/dist/workflows/run/wait-kinds.js +0 -1
- package/dist/workflows/run/wait-kinds.js.map +1 -1
- package/dist/workflows/run/wait-registry.js +5 -4
- package/dist/workflows/run/wait-registry.js.map +1 -1
- package/dist/workflows/run/wake-retries.d.ts +5 -7
- package/dist/workflows/run/wake-retries.js +17 -42
- package/dist/workflows/run/wake-retries.js.map +1 -1
- package/dist/workflows/run/worker-executions.js +2 -0
- package/dist/workflows/run/worker-executions.js.map +1 -1
- package/dist/workflows/run/workflow-position.d.ts +1 -0
- package/dist/workflows/run/workflow-position.js +1 -0
- package/dist/workflows/run/workflow-position.js.map +1 -1
- package/dist/workflows/run-scheduling.d.ts +4 -1
- package/dist/workflows/run-scheduling.js +10 -1
- package/dist/workflows/run-scheduling.js.map +1 -1
- package/dist/workflows/run-states.js +8 -3
- package/dist/workflows/run-states.js.map +1 -1
- package/dist/workflows/run.js +9 -2
- package/dist/workflows/run.js.map +1 -1
- package/package.json +4 -4
- package/scripts/mock-ask-answer.d.mts +2 -0
- package/scripts/mock-opencode-questions.d.mts +14 -0
- package/scripts/mock-pi-rpc.mjs +9 -4
- package/web/dist/assets/{activity-motion-CUzVP7gT.js → activity-motion-ankV4z_y.js} +1 -1
- package/web/dist/assets/{activity-route-0ROUTr1a.js → activity-route-C7Lo4d_1.js} +1 -1
- package/web/dist/assets/{agent-accounts-DZ09bN5r.js → agent-accounts-BAUPVmTO.js} +1 -1
- package/web/dist/assets/attention-C6XIgMqB.js +1 -0
- package/web/dist/assets/{commit-diff-panel-RBA24xW5.js → commit-diff-panel-Cmqi-EvU.js} +1 -1
- package/web/dist/assets/{diff-CH0TjhQy.js → diff-BawymO3F.js} +2 -2
- package/web/dist/assets/{diff-view-DqXPL8v1.js → diff-view-DHx_pu8b.js} +1 -1
- package/web/dist/assets/{file-preview-BypYekVF.js → file-preview-DV7f2pOk.js} +1 -1
- package/web/dist/assets/git-toolbar-BrVfyYBr.js +1 -0
- package/web/dist/assets/{github-C1R3Qa4P.js → github-DVXWmfeu.js} +1 -1
- package/web/dist/assets/{global-activity-route-CeYmrWlT.js → global-activity-route-ybR1xgLf.js} +1 -1
- package/web/dist/assets/index-Dc_KmL4Z.js +17 -0
- package/web/dist/assets/{preview-pane-connected-STXteQlp.js → preview-pane-connected-CT7tXifI.js} +1 -1
- package/web/dist/assets/{project-router-oKsNlPN6.js → project-router-CbWELZZ9.js} +1 -1
- package/web/dist/assets/project-scope-context-p1OpXpSJ.js +4 -0
- package/web/dist/assets/{prompt-template-menu-Hf-vIJsD.js → prompt-template-menu-Ct3m86h1.js} +1 -1
- package/web/dist/assets/{queries-B8cOyvJb.js → queries-BAUtqJph.js} +1 -1
- package/web/dist/assets/{reference-chip-DF8_H2mk.js → reference-chip-B2B-Ky7w.js} +1 -1
- package/web/dist/assets/{repo-git-6YFcqvNX.js → repo-git-DRONt4_i.js} +1 -1
- package/web/dist/assets/{report-reader-N8B6-mlQ.js → report-reader-BF8rmJRD.js} +1 -1
- package/web/dist/assets/{reports-BhM_F8B5.js → reports-Bv91XlcP.js} +1 -1
- package/web/dist/assets/{run-header-BYHFOzwF.js → run-header-CvJ84kr2.js} +1 -1
- package/web/dist/assets/{skills-DRDyj2YM.js → skills-Ceg2Y9LM.js} +1 -1
- package/web/dist/assets/{tab-link-Buy1fRFO.js → tab-link-CT5gqdai.js} +1 -1
- package/web/dist/assets/{task-changes-Ba1leUPJ.js → task-changes-BplRsiSs.js} +1 -1
- package/web/dist/assets/{task-commits-CUbq4G2X.js → task-commits-CYLy-lg-.js} +1 -1
- package/web/dist/assets/{task-files-BJ8IXjGI.js → task-files-COYxL8mg.js} +1 -1
- package/web/dist/assets/task-github-item-DAD__wEa.js +1 -0
- package/web/dist/assets/task-thread-CTEobEyX.js +9 -0
- package/web/dist/assets/{thread-state-CsaxcoEZ.js → thread-state-CpdUCQVd.js} +1 -1
- package/web/dist/assets/use-desktop-Bok38AjX.js +1 -0
- package/web/dist/assets/use-hand-to-agent-state-DiBEjj2Y.js +1 -0
- package/web/dist/assets/{useInfiniteQuery-Yn58_Fkn.js → useInfiniteQuery-DD7iZHIJ.js} +1 -1
- package/web/dist/assets/useQuery-DVAeyc_X.js +1 -0
- package/web/dist/assets/{workflows-B3yrsmsn.js → workflows-Cq6Fg1ZT.js} +1 -1
- package/web/dist/assets/{ws-DbXGHAke.js → ws-CqtLOaJ8.js} +1 -1
- package/web/dist/index.html +12 -12
- package/web/dist/assets/attention-BF8NA1XM.js +0 -1
- package/web/dist/assets/git-toolbar-hahKbaoQ.js +0 -1
- package/web/dist/assets/index-DBisqC5w.js +0 -17
- package/web/dist/assets/project-scope-context-BBVJVcJp.js +0 -4
- package/web/dist/assets/task-github-item-CD5__oCU.js +0 -1
- package/web/dist/assets/task-thread-CfbOaO07.js +0 -9
- package/web/dist/assets/use-desktop-pkHtYT0R.js +0 -1
- package/web/dist/assets/use-hand-to-agent-state-4f2twx6H.js +0 -1
- package/web/dist/assets/useQuery-C1xFF0nd.js +0 -1
|
@@ -638,6 +638,10 @@ export declare function ciToolRoutes(capabilities: Map<string, Capability>): imp
|
|
|
638
638
|
};
|
|
639
639
|
} | {
|
|
640
640
|
output: {
|
|
641
|
+
ok: false;
|
|
642
|
+
code: "automations_off" | "conflict" | "invalid_request" | "not_found" | "unavailable";
|
|
643
|
+
message: string;
|
|
644
|
+
} | {
|
|
641
645
|
ok: true;
|
|
642
646
|
task: {
|
|
643
647
|
id: string;
|
|
@@ -649,10 +653,6 @@ export declare function ciToolRoutes(capabilities: Map<string, Capability>): imp
|
|
|
649
653
|
url?: string | undefined;
|
|
650
654
|
};
|
|
651
655
|
note: string;
|
|
652
|
-
} | {
|
|
653
|
-
ok: false;
|
|
654
|
-
code: "automations_off" | "conflict" | "invalid_request" | "not_found" | "unavailable";
|
|
655
|
-
message: string;
|
|
656
656
|
};
|
|
657
657
|
outputFormat: "json";
|
|
658
658
|
status: import("hono/utils/http-status").ContentfulStatusCode;
|
package/dist/ci-wait/tools.d.ts
CHANGED
|
@@ -248,10 +248,6 @@ export declare function invokeScheduleTaskTool(input: unknown): Promise<{
|
|
|
248
248
|
}[];
|
|
249
249
|
isError: boolean;
|
|
250
250
|
details: {
|
|
251
|
-
ok: false;
|
|
252
|
-
code: "automations_off" | "conflict" | "invalid_request" | "not_found" | "unavailable";
|
|
253
|
-
message: string;
|
|
254
|
-
} | {
|
|
255
251
|
ok: true;
|
|
256
252
|
task: {
|
|
257
253
|
id: string;
|
|
@@ -263,6 +259,10 @@ export declare function invokeScheduleTaskTool(input: unknown): Promise<{
|
|
|
263
259
|
url?: string | undefined;
|
|
264
260
|
};
|
|
265
261
|
note: string;
|
|
262
|
+
} | {
|
|
263
|
+
ok: false;
|
|
264
|
+
code: "automations_off" | "conflict" | "invalid_request" | "not_found" | "unavailable";
|
|
265
|
+
message: string;
|
|
266
266
|
};
|
|
267
267
|
}>;
|
|
268
268
|
export declare function invokeScheduledTasksTool(input: unknown): Promise<{
|
package/dist/contract/index.d.ts
CHANGED
|
@@ -45,6 +45,7 @@ export * from './live-coordination.ts';
|
|
|
45
45
|
export * from './workspace-events.ts';
|
|
46
46
|
export * from './permissions.ts';
|
|
47
47
|
export * from './defined.ts';
|
|
48
|
+
export * from './own-lookup.ts';
|
|
48
49
|
export * from './tool-display.ts';
|
|
49
50
|
export * from './version.ts';
|
|
50
51
|
export * from './active-provider.ts';
|
package/dist/contract/index.js
CHANGED
|
@@ -2524,7 +2524,11 @@ var stepStateSchema = z20.object({
|
|
|
2524
2524
|
profileId: z20.string().optional(),
|
|
2525
2525
|
costUsd: z20.number().optional(),
|
|
2526
2526
|
/** Explicit provenance for engine-generated continuation steps. */
|
|
2527
|
-
synthetic: z20.literal("continuation").optional()
|
|
2527
|
+
synthetic: z20.literal("continuation").optional(),
|
|
2528
|
+
/** On a `synthetic` continuation: the workflow step it continues, recorded once at admission
|
|
2529
|
+
* (ADR 0064). It names the step a later Continue of this session runs as, never the workflow
|
|
2530
|
+
* position. Absent on steps saved before it; those resolve to the chain's last agent step. */
|
|
2531
|
+
continuesStepId: z20.string().optional()
|
|
2528
2532
|
});
|
|
2529
2533
|
var diffStatSchema = z20.object({
|
|
2530
2534
|
adds: z20.number(),
|
|
@@ -2581,6 +2585,7 @@ var runPullRequestSchema = z20.object({
|
|
|
2581
2585
|
url: z20.string().regex(/^https?:\/\/github\.com\/[a-z0-9_.-]+\/[a-z0-9_.-]+\/pull\/\d+\/?(?:[?#][^\s]*)?$/i).optional(),
|
|
2582
2586
|
source: z20.enum(["declared", "created"])
|
|
2583
2587
|
}).refine((entry) => entry.url === void 0 || Number(/\/pull\/(\d+)/i.exec(entry.url)?.[1]) === entry.number, { message: "PR URL and number must agree" });
|
|
2588
|
+
var workflowCursorSchema = z20.object({ stepId: z20.string(), mode: z20.enum(["resume", "start"]) });
|
|
2584
2589
|
var runRecordSchema = z20.object({
|
|
2585
2590
|
id: z20.string(),
|
|
2586
2591
|
title: z20.string(),
|
|
@@ -2598,8 +2603,10 @@ var runRecordSchema = z20.object({
|
|
|
2598
2603
|
stopping: z20.boolean().optional(),
|
|
2599
2604
|
/** Opening Continue message, retained until its first completed turn for crash recovery. */
|
|
2600
2605
|
continuationMessage: continuationMessageSchema.optional(),
|
|
2601
|
-
/**
|
|
2602
|
-
|
|
2606
|
+
/** The workflow step the run goes on from (ADR 0064): `resume` continues that step's session (a
|
|
2607
|
+
* failed attempt awaiting CI recovery or a provider retry), `start` runs it after a Continue
|
|
2608
|
+
* completed the step before it. Only the run exits write it (`runs/run-exits.ts`). */
|
|
2609
|
+
workflowCursor: workflowCursorSchema.optional(),
|
|
2603
2610
|
/** The last turn carried a malformed explicit structured question. */
|
|
2604
2611
|
invalidAsk: z20.boolean().optional(),
|
|
2605
2612
|
/** Owned-run authority; absence is legacy, invalid is explicitly quarantined. */
|
|
@@ -4573,6 +4580,21 @@ var scheduledTasksAnswerSchema = z29.union([
|
|
|
4573
4580
|
]);
|
|
4574
4581
|
|
|
4575
4582
|
// ../contract/src/run-predicates.ts
|
|
4583
|
+
function latestSessionStep(steps, except) {
|
|
4584
|
+
let latest;
|
|
4585
|
+
for (const step of steps) {
|
|
4586
|
+
if (!step.sessionId || step.id === except) continue;
|
|
4587
|
+
if (!latest || !step.startedAt || !latest.startedAt || step.startedAt >= latest.startedAt) latest = step;
|
|
4588
|
+
}
|
|
4589
|
+
return latest;
|
|
4590
|
+
}
|
|
4591
|
+
function sessionRunner(step, run) {
|
|
4592
|
+
return step?.backend ?? run?.runner ?? "claude";
|
|
4593
|
+
}
|
|
4594
|
+
function latestSession(run) {
|
|
4595
|
+
const step = latestSessionStep(run.steps);
|
|
4596
|
+
return { sessionId: step?.sessionId, backend: sessionRunner(step, run), profileId: step?.profileId };
|
|
4597
|
+
}
|
|
4576
4598
|
var LIVE_STATUSES = /* @__PURE__ */ new Set(["queued", "running", "waiting"]);
|
|
4577
4599
|
function isLiveStatus(status) {
|
|
4578
4600
|
return LIVE_STATUSES.has(status);
|
|
@@ -5103,6 +5125,11 @@ function defined(value) {
|
|
|
5103
5125
|
return Object.fromEntries(Object.entries(value).filter(([, entry]) => entry !== void 0));
|
|
5104
5126
|
}
|
|
5105
5127
|
|
|
5128
|
+
// ../contract/src/own-lookup.ts
|
|
5129
|
+
function ownLookup(table, key) {
|
|
5130
|
+
return typeof key === "string" && Object.hasOwn(table, key) ? table[key] : void 0;
|
|
5131
|
+
}
|
|
5132
|
+
|
|
5106
5133
|
// ../contract/src/tool-display.ts
|
|
5107
5134
|
var MAX_LABEL = 120;
|
|
5108
5135
|
function isRecord(value) {
|
|
@@ -5345,7 +5372,7 @@ function imageMimeType(path) {
|
|
|
5345
5372
|
const name = path.slice(path.lastIndexOf("/") + 1);
|
|
5346
5373
|
const dot = name.lastIndexOf(".");
|
|
5347
5374
|
if (dot <= 0) return null;
|
|
5348
|
-
return IMAGE_MIME
|
|
5375
|
+
return ownLookup(IMAGE_MIME, name.slice(dot + 1).toLowerCase()) ?? null;
|
|
5349
5376
|
}
|
|
5350
5377
|
var OS_OPENABLE_EXT = /* @__PURE__ */ new Set(["png", "jpg", "jpeg", "gif", "webp", "bmp", "ico", "avif"]);
|
|
5351
5378
|
function isOsOpenableImage(path) {
|
|
@@ -6220,6 +6247,8 @@ export {
|
|
|
6220
6247
|
isUsageLimitHold,
|
|
6221
6248
|
isValidTimeZone,
|
|
6222
6249
|
isoWeekday,
|
|
6250
|
+
latestSession,
|
|
6251
|
+
latestSessionStep,
|
|
6223
6252
|
liveDemandSchema,
|
|
6224
6253
|
liveEntrySchema,
|
|
6225
6254
|
liveRunBatchResponseSchema,
|
|
@@ -6266,6 +6295,7 @@ export {
|
|
|
6266
6295
|
openTargetSchema,
|
|
6267
6296
|
openTargetsResponseSchema,
|
|
6268
6297
|
openWaitSchema,
|
|
6298
|
+
ownLookup,
|
|
6269
6299
|
ownerInputSchema,
|
|
6270
6300
|
ownerOutputSchema,
|
|
6271
6301
|
parentFileRefusal,
|
|
@@ -6429,6 +6459,7 @@ export {
|
|
|
6429
6459
|
selectAgentProfileSchema,
|
|
6430
6460
|
sendAgentReportInputSchema,
|
|
6431
6461
|
sendAgentReportResponseSchema,
|
|
6462
|
+
sessionRunner,
|
|
6432
6463
|
sessionTransportSchema,
|
|
6433
6464
|
setAgentConfigInputSchema,
|
|
6434
6465
|
setAgentConfigSchema,
|
|
@@ -6559,6 +6590,7 @@ export {
|
|
|
6559
6590
|
workerWorkspaceSchema,
|
|
6560
6591
|
workersAllowed,
|
|
6561
6592
|
workersWaitingLabel,
|
|
6593
|
+
workflowCursorSchema,
|
|
6562
6594
|
workflowDefSchema,
|
|
6563
6595
|
workflowFileSchema,
|
|
6564
6596
|
workflowLoadIssueSchema,
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Look a wire string up in a plain-object table by own keys only. A plain index returns
|
|
3
|
+
* `Object.prototype` members for keys such as `toString`, `constructor` or `__proto__`.
|
|
4
|
+
*/
|
|
5
|
+
export declare function ownLookup<V>(table: Readonly<Record<string, V>>, key: unknown): V | undefined;
|
|
@@ -1,4 +1,31 @@
|
|
|
1
|
-
import { type ArchiveFinishedScope, type RunRecord } from './runs.ts';
|
|
1
|
+
import { type ArchiveFinishedScope, type RunRecord, type StepState } from './runs.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Facts about a run that the store, the server, the engine and the cockpit all decide on, each
|
|
4
|
+
* defined once here so that no reader restates one in its own code (hearsay-tools/cezarion#1496).
|
|
5
|
+
* Each takes the record, never a bare status, so no caller can miss a usage-limit hold
|
|
6
|
+
* (hearsay-tools/cezarion#1434). `isUsageLimitHold` lives in `usage-limit-hold.ts`; `waits.ts` re-exports it.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* The step holding the run's latest agent session: of the steps with a session id, the one that
|
|
10
|
+
* started last. A Continue appends its synthetic step, so array order is not time order: a
|
|
11
|
+
* workflow step that ran after a continuation sits before it (hearsay-tools/squawk#3024). A step
|
|
12
|
+
* saved without a start time keeps its array position against its neighbours. `except` leaves out
|
|
13
|
+
* one step, such as the Continue's own.
|
|
14
|
+
*/
|
|
15
|
+
export declare function latestSessionStep<S extends Pick<StepState, 'id' | 'sessionId' | 'startedAt'>>(steps: readonly S[], except?: string): S | undefined;
|
|
16
|
+
/** The runner that owns a step's session. A step saved before backend affinity belongs to the
|
|
17
|
+
* run's runner, and a run with none to Claude. */
|
|
18
|
+
export declare function sessionRunner(step: Pick<StepState, 'backend'> | undefined, run: Pick<RunRecord, 'runner'> | undefined): NonNullable<RunRecord['runner']>;
|
|
19
|
+
/** The latest session's id, the runner that owns it (`sessionRunner`) and the account it was opened
|
|
20
|
+
* under. Every step with a session counts, with or without a saved backend. */
|
|
21
|
+
export declare function latestSession(run: {
|
|
22
|
+
steps: readonly Pick<StepState, 'id' | 'sessionId' | 'startedAt' | 'backend' | 'profileId'>[];
|
|
23
|
+
runner?: RunRecord['runner'];
|
|
24
|
+
}): {
|
|
25
|
+
sessionId: string | undefined;
|
|
26
|
+
backend: NonNullable<RunRecord['runner']>;
|
|
27
|
+
profileId: string | undefined;
|
|
28
|
+
};
|
|
2
29
|
/** Status-only live predicate: queued, running or waiting. */
|
|
3
30
|
export declare function isLiveStatus(status: string): boolean;
|
|
4
31
|
type OwnershipInput = Pick<RunRecord, 'status'> & Partial<Pick<RunRecord, 'autoResumeAt'>>;
|
package/dist/contract/runs.d.ts
CHANGED
|
@@ -106,6 +106,7 @@ export declare const stepStateSchema: z.ZodObject<{
|
|
|
106
106
|
profileId: z.ZodOptional<z.ZodString>;
|
|
107
107
|
costUsd: z.ZodOptional<z.ZodNumber>;
|
|
108
108
|
synthetic: z.ZodOptional<z.ZodLiteral<"continuation">>;
|
|
109
|
+
continuesStepId: z.ZodOptional<z.ZodString>;
|
|
109
110
|
}, z.core.$strip>;
|
|
110
111
|
export type StepState = z.infer<typeof stepStateSchema>;
|
|
111
112
|
/** Aggregate diff numbers of a run's worktree vs its base (#389). */
|
|
@@ -194,6 +195,15 @@ export declare const runPullRequestSchema: z.ZodObject<{
|
|
|
194
195
|
}>;
|
|
195
196
|
}, z.core.$strip>;
|
|
196
197
|
export type RunPullRequest = z.infer<typeof runPullRequestSchema>;
|
|
198
|
+
/** The workflow step a run goes on from, and how (ADR 0064). */
|
|
199
|
+
export declare const workflowCursorSchema: z.ZodObject<{
|
|
200
|
+
stepId: z.ZodString;
|
|
201
|
+
mode: z.ZodEnum<{
|
|
202
|
+
resume: "resume";
|
|
203
|
+
start: "start";
|
|
204
|
+
}>;
|
|
205
|
+
}, z.core.$strip>;
|
|
206
|
+
export type WorkflowCursor = z.infer<typeof workflowCursorSchema>;
|
|
197
207
|
export declare const runRecordSchema: z.ZodObject<{
|
|
198
208
|
archiveWhenDone: z.ZodOptional<z.ZodBoolean>;
|
|
199
209
|
autoMergePr: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -235,7 +245,13 @@ export declare const runRecordSchema: z.ZodObject<{
|
|
|
235
245
|
restarted: z.ZodOptional<z.ZodLiteral<true>>;
|
|
236
246
|
}, z.core.$strip>>;
|
|
237
247
|
}, z.core.$strip>>;
|
|
238
|
-
|
|
248
|
+
workflowCursor: z.ZodOptional<z.ZodObject<{
|
|
249
|
+
stepId: z.ZodString;
|
|
250
|
+
mode: z.ZodEnum<{
|
|
251
|
+
resume: "resume";
|
|
252
|
+
start: "start";
|
|
253
|
+
}>;
|
|
254
|
+
}, z.core.$strip>>;
|
|
239
255
|
invalidAsk: z.ZodOptional<z.ZodBoolean>;
|
|
240
256
|
delegation: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
241
257
|
role: z.ZodLiteral<"root">;
|
|
@@ -2074,6 +2090,7 @@ export declare const runRecordSchema: z.ZodObject<{
|
|
|
2074
2090
|
profileId: z.ZodOptional<z.ZodString>;
|
|
2075
2091
|
costUsd: z.ZodOptional<z.ZodNumber>;
|
|
2076
2092
|
synthetic: z.ZodOptional<z.ZodLiteral<"continuation">>;
|
|
2093
|
+
continuesStepId: z.ZodOptional<z.ZodString>;
|
|
2077
2094
|
}, z.core.$strip>>;
|
|
2078
2095
|
workflowDef: z.ZodOptional<z.ZodObject<{
|
|
2079
2096
|
name: z.ZodString;
|
|
@@ -2170,7 +2187,13 @@ export declare const apiRunSchema: z.ZodObject<{
|
|
|
2170
2187
|
restarted: z.ZodOptional<z.ZodLiteral<true>>;
|
|
2171
2188
|
}, z.core.$strip>>;
|
|
2172
2189
|
}, z.core.$strip>>;
|
|
2173
|
-
|
|
2190
|
+
workflowCursor: z.ZodOptional<z.ZodObject<{
|
|
2191
|
+
stepId: z.ZodString;
|
|
2192
|
+
mode: z.ZodEnum<{
|
|
2193
|
+
resume: "resume";
|
|
2194
|
+
start: "start";
|
|
2195
|
+
}>;
|
|
2196
|
+
}, z.core.$strip>>;
|
|
2174
2197
|
invalidAsk: z.ZodOptional<z.ZodBoolean>;
|
|
2175
2198
|
delegation: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
2176
2199
|
role: z.ZodLiteral<"root">;
|
|
@@ -4009,6 +4032,7 @@ export declare const apiRunSchema: z.ZodObject<{
|
|
|
4009
4032
|
profileId: z.ZodOptional<z.ZodString>;
|
|
4010
4033
|
costUsd: z.ZodOptional<z.ZodNumber>;
|
|
4011
4034
|
synthetic: z.ZodOptional<z.ZodLiteral<"continuation">>;
|
|
4035
|
+
continuesStepId: z.ZodOptional<z.ZodString>;
|
|
4012
4036
|
}, z.core.$strip>>;
|
|
4013
4037
|
workflowDef: z.ZodOptional<z.ZodObject<{
|
|
4014
4038
|
name: z.ZodString;
|
|
@@ -4880,7 +4904,13 @@ export declare const createRunResponseSchema: z.ZodObject<{
|
|
|
4880
4904
|
restarted: z.ZodOptional<z.ZodLiteral<true>>;
|
|
4881
4905
|
}, z.core.$strip>>;
|
|
4882
4906
|
}, z.core.$strip>>;
|
|
4883
|
-
|
|
4907
|
+
workflowCursor: z.ZodOptional<z.ZodObject<{
|
|
4908
|
+
stepId: z.ZodString;
|
|
4909
|
+
mode: z.ZodEnum<{
|
|
4910
|
+
resume: "resume";
|
|
4911
|
+
start: "start";
|
|
4912
|
+
}>;
|
|
4913
|
+
}, z.core.$strip>>;
|
|
4884
4914
|
invalidAsk: z.ZodOptional<z.ZodBoolean>;
|
|
4885
4915
|
delegation: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
4886
4916
|
role: z.ZodLiteral<"root">;
|
|
@@ -6719,6 +6749,7 @@ export declare const createRunResponseSchema: z.ZodObject<{
|
|
|
6719
6749
|
profileId: z.ZodOptional<z.ZodString>;
|
|
6720
6750
|
costUsd: z.ZodOptional<z.ZodNumber>;
|
|
6721
6751
|
synthetic: z.ZodOptional<z.ZodLiteral<"continuation">>;
|
|
6752
|
+
continuesStepId: z.ZodOptional<z.ZodString>;
|
|
6722
6753
|
}, z.core.$strip>>;
|
|
6723
6754
|
workflowDef: z.ZodOptional<z.ZodObject<{
|
|
6724
6755
|
name: z.ZodString;
|
|
@@ -340,6 +340,17 @@ export interface AgentSession {
|
|
|
340
340
|
heldHumanInputCount?(): number;
|
|
341
341
|
/** Graceful close: end input, then a SIGTERM→SIGKILL watchdog. */
|
|
342
342
|
end(): void;
|
|
343
|
+
/**
|
|
344
|
+
* The close after an accepted done (hearsay-tools/squawk#1680). Exactly the runners whose facts
|
|
345
|
+
* row declares `nativePermission: 'after-turn'` implement it. `open` reads false at once, so the
|
|
346
|
+
* session takes no input. It stays up `AUTO_END_DELAY_MS` for a permission request the wire raises
|
|
347
|
+
* after the turn ended; such a request still reaches `respondPermission`, and the session ends once
|
|
348
|
+
* none is pending and the turn it reopened has ended. Every other runner closes with `end()`.
|
|
349
|
+
*/
|
|
350
|
+
endWhenQuiet?(): void;
|
|
351
|
+
/** True from `endWhenQuiet` until the session ends: closed to input, still live for its late
|
|
352
|
+
* permission request and for a human Finish or Stop. */
|
|
353
|
+
readonly closingQuietly?: boolean;
|
|
343
354
|
/** Hard stop (used by cancel). */
|
|
344
355
|
interrupt(): void;
|
|
345
356
|
/** True while the session still accepts messages. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-runner.js","sourceRoot":"","sources":["../../src/core/agent-runner.ts"],"names":[],"mappings":"AAAA;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("./agent-runner.ts").SpecFieldSupport>>;
|
|
31
31
|
readonly systemPromptOnResume: "resent";
|
|
32
32
|
readonly facts: {
|
|
33
|
+
readonly childWork: 'nested';
|
|
34
|
+
readonly hookEvents: 'reported';
|
|
35
|
+
readonly nativePermission: 'none';
|
|
36
|
+
readonly transport: 'stdio';
|
|
37
|
+
readonly humanPromptHold: 'none';
|
|
33
38
|
readonly inputDelivery: {
|
|
34
39
|
readonly mode: 'steer';
|
|
35
40
|
readonly consumption: 'observable';
|
|
@@ -44,6 +49,7 @@ export declare class ClaudeCliRunner implements AgentRunner {
|
|
|
44
49
|
readonly costReport: 'cumulative';
|
|
45
50
|
readonly sessionIdSource: 'launch';
|
|
46
51
|
readonly claudeModelAliases: true;
|
|
52
|
+
readonly turnStart: 'on-write';
|
|
47
53
|
};
|
|
48
54
|
readonly inputDelivery: InputDelivery;
|
|
49
55
|
private readonly bin;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed forked commands (hearsay-tools/squawk#1315). A typed `/name` command whose skill has
|
|
3
|
+
* `context: fork` runs a subagent with no spawn call: its `task_started` carries no tool_use_id
|
|
4
|
+
* and arrives before `init`, and its children name a synthetic parent, `forked-command-<name>`.
|
|
5
|
+
* The first child mints one root task item for the fork, so the fork's work nests under it in
|
|
6
|
+
* the same turn. The item stays running until the turn ends: Claude reports the task completed
|
|
7
|
+
* before its children run.
|
|
8
|
+
*/
|
|
9
|
+
import type { UiEvent, UiToolItem } from './ui-events.ts';
|
|
10
|
+
interface ForkedCommandStart {
|
|
11
|
+
readonly description?: string | undefined;
|
|
12
|
+
readonly subagentType?: string | undefined;
|
|
13
|
+
}
|
|
14
|
+
/** The slice of the Claude mapper state that tracks typed forked commands. */
|
|
15
|
+
export interface ForkedCommandState {
|
|
16
|
+
/** Claude's task id → the `task_started` of a typed forked command. Its children name the
|
|
17
|
+
* task in `agent_id`. Cleared when the turn ends. */
|
|
18
|
+
readonly forkedCommandStarts: ReadonlyMap<string, ForkedCommandStart>;
|
|
19
|
+
/** Typed forked commands open in this turn, keyed by the wire parent id their children carry. */
|
|
20
|
+
readonly openForkedCommands: ReadonlyMap<string, UiToolItem>;
|
|
21
|
+
/** Every fork item id minted in this session: a command typed again gets a fresh item id, so
|
|
22
|
+
* each fork nests in its own turn and never overwrites another fork's item. */
|
|
23
|
+
readonly forkedCommandIds: ReadonlySet<string>;
|
|
24
|
+
}
|
|
25
|
+
export declare function withForkedCommandStart<S extends ForkedCommandState>(msg: Record<string, unknown>, state: S): S;
|
|
26
|
+
/** The fork item's start, and the message re-parented under its item id, for a forked command's
|
|
27
|
+
* child; undefined for any other message. */
|
|
28
|
+
export declare function adoptForkedCommand<S extends ForkedCommandState>(msg: Record<string, unknown>, state: S): {
|
|
29
|
+
events: UiEvent[];
|
|
30
|
+
state: S;
|
|
31
|
+
msg: Record<string, unknown>;
|
|
32
|
+
} | undefined;
|
|
33
|
+
/** The turn's end settles every fork it opened: failed when the turn did not end normally
|
|
34
|
+
* (an error or the turn cap), else completed. */
|
|
35
|
+
export declare function completeForkedCommands(state: ForkedCommandState, turnFailed: boolean): UiEvent[];
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed forked commands (hearsay-tools/squawk#1315). A typed `/name` command whose skill has
|
|
3
|
+
* `context: fork` runs a subagent with no spawn call: its `task_started` carries no tool_use_id
|
|
4
|
+
* and arrives before `init`, and its children name a synthetic parent, `forked-command-<name>`.
|
|
5
|
+
* The first child mints one root task item for the fork, so the fork's work nests under it in
|
|
6
|
+
* the same turn. The item stays running until the turn ends: Claude reports the task completed
|
|
7
|
+
* before its children run.
|
|
8
|
+
*/
|
|
9
|
+
const FORKED_COMMAND_PREFIX = 'forked-command-';
|
|
10
|
+
export function withForkedCommandStart(msg, state) {
|
|
11
|
+
const taskId = str(msg.task_id);
|
|
12
|
+
if (taskId === undefined)
|
|
13
|
+
return state;
|
|
14
|
+
const start = { description: str(msg.description), subagentType: str(msg.subagent_type) };
|
|
15
|
+
return { ...state, forkedCommandStarts: new Map(state.forkedCommandStarts).set(taskId, start) };
|
|
16
|
+
}
|
|
17
|
+
/** The fork item's start, and the message re-parented under its item id, for a forked command's
|
|
18
|
+
* child; undefined for any other message. */
|
|
19
|
+
export function adoptForkedCommand(msg, state) {
|
|
20
|
+
const wireId = str(msg.parent_tool_use_id);
|
|
21
|
+
if (wireId === undefined || !wireId.startsWith(FORKED_COMMAND_PREFIX))
|
|
22
|
+
return undefined;
|
|
23
|
+
const open = state.openForkedCommands.get(wireId);
|
|
24
|
+
if (open)
|
|
25
|
+
return { events: [], state, msg: { ...msg, parent_tool_use_id: open.id } };
|
|
26
|
+
const item = startForkedCommandItem(wireId, state, str(msg.agent_id));
|
|
27
|
+
const next = {
|
|
28
|
+
...state,
|
|
29
|
+
openForkedCommands: new Map(state.openForkedCommands).set(wireId, item),
|
|
30
|
+
forkedCommandIds: new Set(state.forkedCommandIds).add(item.id),
|
|
31
|
+
};
|
|
32
|
+
return { events: [{ type: 'item.started', item }], state: next, msg: { ...msg, parent_tool_use_id: item.id } };
|
|
33
|
+
}
|
|
34
|
+
/** The wire id, or the first free `<wire id>-<n>`: a suffixed id can equal another command's
|
|
35
|
+
* wire id (`/review` typed twice, then `/review-2`), so every minted id is checked. */
|
|
36
|
+
function freeForkItemId(wireId, minted) {
|
|
37
|
+
let id = wireId;
|
|
38
|
+
for (let n = 2; minted.has(id); n += 1)
|
|
39
|
+
id = `${wireId}-${n}`;
|
|
40
|
+
return id;
|
|
41
|
+
}
|
|
42
|
+
function startForkedCommandItem(wireId, state, taskId) {
|
|
43
|
+
const start = taskId === undefined ? undefined : state.forkedCommandStarts.get(taskId);
|
|
44
|
+
const item = {
|
|
45
|
+
kind: 'tool',
|
|
46
|
+
id: freeForkItemId(wireId, state.forkedCommandIds),
|
|
47
|
+
name: 'Skill',
|
|
48
|
+
toolKind: 'task',
|
|
49
|
+
title: start?.description ?? `/${wireId.slice(FORKED_COMMAND_PREFIX.length)}`,
|
|
50
|
+
status: 'running',
|
|
51
|
+
};
|
|
52
|
+
if (start?.subagentType !== undefined)
|
|
53
|
+
item.input = { subagent_type: start.subagentType };
|
|
54
|
+
return item;
|
|
55
|
+
}
|
|
56
|
+
/** The turn's end settles every fork it opened: failed when the turn did not end normally
|
|
57
|
+
* (an error or the turn cap), else completed. */
|
|
58
|
+
export function completeForkedCommands(state, turnFailed) {
|
|
59
|
+
const status = turnFailed ? 'failed' : 'completed';
|
|
60
|
+
return [...state.openForkedCommands.values()].map((open) => ({ type: 'item.completed', item: { ...open, status } }));
|
|
61
|
+
}
|
|
62
|
+
function str(value) {
|
|
63
|
+
return typeof value === 'string' && value !== '' ? value : undefined;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=claude-forked-command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claude-forked-command.js","sourceRoot":"","sources":["../../src/core/claude-forked-command.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,MAAM,qBAAqB,GAAG,iBAAiB,CAAC;AAmBhD,MAAM,UAAU,sBAAsB,CAA+B,GAA4B,EAAE,KAAQ;IACzG,MAAM,MAAM,GAAG,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAChC,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IACvC,MAAM,KAAK,GAAuB,EAAE,WAAW,EAAE,GAAG,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,YAAY,EAAE,GAAG,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC;IAC9G,OAAO,EAAE,GAAG,KAAK,EAAE,mBAAmB,EAAE,IAAI,GAAG,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC;AAClG,CAAC;AAED;8CAC8C;AAC9C,MAAM,UAAU,kBAAkB,CAChC,GAA4B,EAC5B,KA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CAAC,CAAC,SAAS,CAAC;AACvE,CAAC"}
|
|
@@ -24,7 +24,8 @@
|
|
|
24
24
|
* the two id spaces then drift silently — updates land on the wrong row.
|
|
25
25
|
*/
|
|
26
26
|
import type { PlanEntry, PlanStatus, UiEvent, UiToolItem } from './ui-events.ts';
|
|
27
|
-
|
|
27
|
+
import { type ForkedCommandState } from './claude-forked-command.ts';
|
|
28
|
+
export interface ClaudeUiMapperState extends ForkedCommandState {
|
|
28
29
|
/** Used when `system/init` lacks `session_id` (the dry-run mock does). */
|
|
29
30
|
readonly fallbackSessionId?: string | undefined;
|
|
30
31
|
/** True once `system/init` produced `session.started`. */
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
import { hookEventName, isVisibleHookItem } from './hook-items.js';
|
|
27
27
|
import { editWriteKey } from './edit-write-key.js';
|
|
28
28
|
import { toolDisplay } from '../contract/index.js';
|
|
29
|
+
import { adoptForkedCommand, completeForkedCommands, withForkedCommandStart, } from './claude-forked-command.js';
|
|
29
30
|
export function createClaudeUiState(opts = {}) {
|
|
30
31
|
return {
|
|
31
32
|
fallbackSessionId: opts.fallbackSessionId,
|
|
@@ -41,6 +42,9 @@ export function createClaudeUiState(opts = {}) {
|
|
|
41
42
|
backgroundTasks: new Map(),
|
|
42
43
|
backgroundTaskIds: new Map(),
|
|
43
44
|
endedBackgroundTasks: new Set(),
|
|
45
|
+
forkedCommandStarts: new Map(),
|
|
46
|
+
openForkedCommands: new Map(),
|
|
47
|
+
forkedCommandIds: new Set(),
|
|
44
48
|
};
|
|
45
49
|
}
|
|
46
50
|
/**
|
|
@@ -61,6 +65,13 @@ export function claudeTurnStarted(state) {
|
|
|
61
65
|
export function mapClaudeMessage(msg, state) {
|
|
62
66
|
if (!isRecord(msg))
|
|
63
67
|
return { events: [], state };
|
|
68
|
+
const fork = adoptForkedCommand(msg, state);
|
|
69
|
+
if (!fork)
|
|
70
|
+
return mapWireMessage(msg, state);
|
|
71
|
+
const mapped = mapWireMessage(fork.msg, fork.state);
|
|
72
|
+
return { events: [...fork.events, ...mapped.events], state: mapped.state };
|
|
73
|
+
}
|
|
74
|
+
function mapWireMessage(msg, state) {
|
|
64
75
|
switch (msg.type) {
|
|
65
76
|
case 'system':
|
|
66
77
|
if (msg.subtype === 'init')
|
|
@@ -221,7 +232,9 @@ function withBackgroundTask(state, item, taskId) {
|
|
|
221
232
|
}
|
|
222
233
|
function mapTaskStarted(msg, state) {
|
|
223
234
|
const toolUseId = str(msg.tool_use_id);
|
|
224
|
-
|
|
235
|
+
if (toolUseId === undefined)
|
|
236
|
+
return { events: [], state: withForkedCommandStart(msg, state) };
|
|
237
|
+
const open = state.openTools.get(toolUseId);
|
|
225
238
|
if (msg.is_backgrounded !== true || !open || !isRootTask(open) || open.background)
|
|
226
239
|
return { events: [], state };
|
|
227
240
|
const item = { ...open, background: true };
|
|
@@ -663,6 +676,7 @@ function mapResult(msg, state) {
|
|
|
663
676
|
itemSeq = fallback.itemSeq;
|
|
664
677
|
let turnSeq = state.turnSeq;
|
|
665
678
|
const turnId = state.currentTurnId ?? `turn_${++turnSeq}`;
|
|
679
|
+
events.push(...completeForkedCommands(state, resultStopReason(msg) !== 'end_turn'));
|
|
666
680
|
events.push(...completeTurnEvents(msg, turnId));
|
|
667
681
|
return {
|
|
668
682
|
events,
|
|
@@ -671,6 +685,8 @@ function mapResult(msg, state) {
|
|
|
671
685
|
itemSeq,
|
|
672
686
|
turnSeq,
|
|
673
687
|
currentTurnId: null,
|
|
688
|
+
forkedCommandStarts: new Map(),
|
|
689
|
+
openForkedCommands: new Map(),
|
|
674
690
|
openTools: denials.openTools ?? state.openTools,
|
|
675
691
|
sawAssistantText: fallback.sawAssistantText,
|
|
676
692
|
},
|