@hearsay-tools/squawk 0.18.0-pr3689.6749 → 0.18.0-pr3689.6771
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/contract/index.d.ts +2 -0
- package/dist/contract/index.js +80 -4
- package/dist/contract/own-lookup.d.ts +5 -0
- package/dist/contract/runner-facts.d.ts +91 -0
- package/dist/contract/runs.d.ts +31 -4
- 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/opencode-server-runner.js +5 -0
- package/dist/core/opencode-server-runner.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/runner-cli.d.ts +31 -0
- package/dist/core/runner-cli.js +40 -0
- package/dist/core/runner-cli.js.map +1 -0
- package/dist/core/runner-model-catalog.js +2 -9
- package/dist/core/runner-model-catalog.js.map +1 -1
- package/dist/delegation/conversations.d.ts +8 -2
- package/dist/delegation/execution-identity.js +2 -1
- package/dist/delegation/execution-identity.js.map +1 -1
- package/dist/delegation/routes.d.ts +16 -16
- 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/run-exits.d.ts +1366 -51
- package/dist/runs/run-exits.js +18 -7
- package/dist/runs/run-exits.js.map +1 -1
- package/dist/runs/store.d.ts +11 -2
- 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/checkout.d.ts +1 -1
- package/dist/server/open-in-targets.d.ts +1 -1
- package/dist/server/open-in-targets.js +5 -12
- package/dist/server/open-in-targets.js.map +1 -1
- package/dist/server/provider-action-gate.js +3 -10
- package/dist/server/provider-action-gate.js.map +1 -1
- package/dist/server/reports-api.d.ts +2 -2
- package/dist/server/server.d.ts +300 -253
- package/dist/server/server.js +33 -68
- package/dist/server/server.js.map +1 -1
- package/dist/workflows/continuation-admission.d.ts +4 -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/compose.d.ts +3 -0
- package/dist/workflows/run/compose.js +13 -12
- package/dist/workflows/run/compose.js.map +1 -1
- package/dist/workflows/run/continuation-session.js +2 -0
- 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/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 +3 -1
- package/dist/workflows/run/input-delivery.js +14 -15
- package/dist/workflows/run/input-delivery.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 +4 -1
- package/dist/workflows/run/launch-read-resolver.js +24 -9
- package/dist/workflows/run/launch-read-resolver.js.map +1 -1
- package/dist/workflows/run/liveness-timers.d.ts +97 -0
- package/dist/workflows/run/liveness-timers.js +130 -0
- package/dist/workflows/run/liveness-timers.js.map +1 -0
- 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/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 +3 -5
- package/dist/workflows/run/subagent-waits.js +13 -32
- 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 +3 -1
- package/dist/workflows/run/turn-settler.js +7 -4
- package/dist/workflows/run/turn-settler.js.map +1 -1
- package/dist/workflows/run/wait-engine.d.ts +4 -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 +5 -2
- 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/web/dist/assets/{activity-motion-DMp6Uo_E.js → activity-motion-gOopdagH.js} +1 -1
- package/web/dist/assets/{activity-route-D04JxCzp.js → activity-route-D7bDtXpW.js} +1 -1
- package/web/dist/assets/agent-accounts-otlDWnij.js +18 -0
- package/web/dist/assets/attention-CVI366xV.js +1 -0
- package/web/dist/assets/{commit-diff-panel-Din879JP.js → commit-diff-panel-iQf0Rlcx.js} +1 -1
- package/web/dist/assets/{diff-Btt23N3M.js → diff-DQfcliZC.js} +2 -2
- package/web/dist/assets/{diff-view-CfWaBIJu.js → diff-view-BbM-71Cs.js} +1 -1
- package/web/dist/assets/{file-preview-DcznUbkx.js → file-preview-DgU8vo8k.js} +1 -1
- package/web/dist/assets/{git-toolbar-DUnmDIe8.js → git-toolbar-C8agvpYS.js} +1 -1
- package/web/dist/assets/{github-C6OOf2Jp.js → github-hXmxAXmA.js} +1 -1
- package/web/dist/assets/{global-activity-route-ko4iBoc3.js → global-activity-route-D_r1ImUh.js} +1 -1
- package/web/dist/assets/index-tN02NX7A.js +17 -0
- package/web/dist/assets/{preview-pane-connected-gIoE5-9m.js → preview-pane-connected-D__9JwyU.js} +1 -1
- package/web/dist/assets/{project-router-oKsNlPN6.js → project-router-WQWd3UUn.js} +1 -1
- package/web/dist/assets/project-scope-context-bgdvGX9z.js +4 -0
- package/web/dist/assets/{prompt-template-menu-C3d8Xkvo.js → prompt-template-menu-BJfUg1uF.js} +1 -1
- package/web/dist/assets/queries-BJM44umy.js +1 -0
- package/web/dist/assets/{reference-chip-BliLpdSz.js → reference-chip-vraIzoEF.js} +1 -1
- package/web/dist/assets/{repo-git-DGrhzyWR.js → repo-git-B4qZq37d.js} +1 -1
- package/web/dist/assets/{report-reader-C2yXiPa9.js → report-reader-Djix-ICM.js} +1 -1
- package/web/dist/assets/{reports-mmONzYgk.js → reports-Do-dkavq.js} +1 -1
- package/web/dist/assets/run-header-Di9LaKQs.js +2 -0
- package/web/dist/assets/{skills-N0vkndca.js → skills-CPnIvFnR.js} +1 -1
- package/web/dist/assets/{tab-link-Buy1fRFO.js → tab-link-DiNYVlpl.js} +1 -1
- package/web/dist/assets/{task-changes-BhvqWHW7.js → task-changes-CW7NzgL5.js} +1 -1
- package/web/dist/assets/{task-commits-RGVmBirX.js → task-commits-Bkwi7o1B.js} +1 -1
- package/web/dist/assets/{task-files-B-W_PC8S.js → task-files-geRzIszC.js} +1 -1
- package/web/dist/assets/{task-github-item-csNEiMBa.js → task-github-item-UbCCP2Ud.js} +1 -1
- package/web/dist/assets/task-thread-CkiEiypn.js +9 -0
- package/web/dist/assets/{thread-state-DeDb0lsY.js → thread-state-CajkV5Ft.js} +1 -1
- package/web/dist/assets/{use-desktop-jIeTPw3K.js → use-desktop-Ct4lvA3b.js} +1 -1
- package/web/dist/assets/{use-hand-to-agent-state-CIysCyMM.js → use-hand-to-agent-state-Cnxq_2F6.js} +1 -1
- package/web/dist/assets/{useInfiniteQuery-Yn58_Fkn.js → useInfiniteQuery-s3lTx_YX.js} +1 -1
- package/web/dist/assets/useQuery-C0ee1rw5.js +1 -0
- package/web/dist/assets/workflows-Csr2hbks.js +7 -0
- package/web/dist/assets/{ws-DbXGHAke.js → ws-WW6DrfbT.js} +1 -1
- package/web/dist/index.html +12 -12
- package/web/dist/assets/agent-accounts-C48RdN3o.js +0 -18
- package/web/dist/assets/attention-BF8NA1XM.js +0 -1
- package/web/dist/assets/index-C3YyGC-J.js +0 -17
- package/web/dist/assets/project-scope-context-BBVJVcJp.js +0 -4
- package/web/dist/assets/queries-Be8VyHam.js +0 -1
- package/web/dist/assets/run-header-Cin11tct.js +0 -2
- package/web/dist/assets/task-thread-B23Uq5iQ.js +0 -9
- package/web/dist/assets/useQuery-C1xFF0nd.js +0 -1
- package/web/dist/assets/workflows-k0YtC-LB.js +0 -7
|
@@ -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/contract/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export * from './pending-ask.ts';
|
|
|
8
8
|
export * from './delegation.ts';
|
|
9
9
|
export * from './effort.ts';
|
|
10
10
|
export * from './health.ts';
|
|
11
|
+
export * from './runner-facts.ts';
|
|
11
12
|
export * from './runs.ts';
|
|
12
13
|
export * from './task-options.ts';
|
|
13
14
|
export * from './run-labels.ts';
|
|
@@ -44,6 +45,7 @@ export * from './live-coordination.ts';
|
|
|
44
45
|
export * from './workspace-events.ts';
|
|
45
46
|
export * from './permissions.ts';
|
|
46
47
|
export * from './defined.ts';
|
|
48
|
+
export * from './own-lookup.ts';
|
|
47
49
|
export * from './tool-display.ts';
|
|
48
50
|
export * from './version.ts';
|
|
49
51
|
export * from './active-provider.ts';
|
package/dist/contract/index.js
CHANGED
|
@@ -1115,6 +1115,67 @@ var healthResponseSchema = z12.object({
|
|
|
1115
1115
|
bootProject: z12.string()
|
|
1116
1116
|
});
|
|
1117
1117
|
|
|
1118
|
+
// ../contract/src/runner-facts.ts
|
|
1119
|
+
var RUNNER_COCKPIT_FACTS = {
|
|
1120
|
+
claude: {
|
|
1121
|
+
displayName: "Claude Code",
|
|
1122
|
+
modelListName: "Claude",
|
|
1123
|
+
modelCatalogDelivery: "on-request",
|
|
1124
|
+
effortLevels: "catalog-or-generic",
|
|
1125
|
+
modelIdScope: "own",
|
|
1126
|
+
inputMode: "steer"
|
|
1127
|
+
},
|
|
1128
|
+
codex: {
|
|
1129
|
+
displayName: "Codex",
|
|
1130
|
+
modelListName: "Codex",
|
|
1131
|
+
modelCatalogDelivery: "on-request",
|
|
1132
|
+
effortLevels: "catalog-or-generic",
|
|
1133
|
+
modelIdScope: "own",
|
|
1134
|
+
inputMode: "steer"
|
|
1135
|
+
},
|
|
1136
|
+
opencode: {
|
|
1137
|
+
displayName: "OpenCode",
|
|
1138
|
+
modelListName: "OpenCode",
|
|
1139
|
+
modelCatalogDelivery: "on-request",
|
|
1140
|
+
effortLevels: "catalog-or-generic",
|
|
1141
|
+
modelIdScope: "provider-spanning",
|
|
1142
|
+
inputMode: "steer"
|
|
1143
|
+
},
|
|
1144
|
+
pi: {
|
|
1145
|
+
displayName: "pi",
|
|
1146
|
+
modelListName: "Pi",
|
|
1147
|
+
modelCatalogDelivery: "on-request",
|
|
1148
|
+
effortLevels: "catalog-or-generic",
|
|
1149
|
+
modelIdScope: "provider-spanning",
|
|
1150
|
+
inputMode: "steer"
|
|
1151
|
+
},
|
|
1152
|
+
cursor: {
|
|
1153
|
+
displayName: "Cursor",
|
|
1154
|
+
modelListName: "Cursor",
|
|
1155
|
+
modelCatalogDelivery: "pushed",
|
|
1156
|
+
effortLevels: "catalog-only",
|
|
1157
|
+
modelIdScope: "any-provider",
|
|
1158
|
+
inputMode: "boundary"
|
|
1159
|
+
},
|
|
1160
|
+
omp: {
|
|
1161
|
+
displayName: "OMP",
|
|
1162
|
+
modelListName: "OMP",
|
|
1163
|
+
modelCatalogDelivery: "on-request",
|
|
1164
|
+
effortLevels: "catalog-or-generic",
|
|
1165
|
+
modelIdScope: "provider-spanning",
|
|
1166
|
+
inputMode: "steer"
|
|
1167
|
+
}
|
|
1168
|
+
};
|
|
1169
|
+
function runnerDisplayName(runner) {
|
|
1170
|
+
return RUNNER_COCKPIT_FACTS[runner].displayName;
|
|
1171
|
+
}
|
|
1172
|
+
function runnerModelListName(runner) {
|
|
1173
|
+
return RUNNER_COCKPIT_FACTS[runner].modelListName;
|
|
1174
|
+
}
|
|
1175
|
+
function cockpitRunnersWhere(matches) {
|
|
1176
|
+
return Object.keys(RUNNER_COCKPIT_FACTS).filter((runner) => matches(RUNNER_COCKPIT_FACTS[runner]));
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1118
1179
|
// ../contract/src/runs.ts
|
|
1119
1180
|
import { z as z20 } from "zod";
|
|
1120
1181
|
|
|
@@ -2520,6 +2581,7 @@ var runPullRequestSchema = z20.object({
|
|
|
2520
2581
|
url: z20.string().regex(/^https?:\/\/github\.com\/[a-z0-9_.-]+\/[a-z0-9_.-]+\/pull\/\d+\/?(?:[?#][^\s]*)?$/i).optional(),
|
|
2521
2582
|
source: z20.enum(["declared", "created"])
|
|
2522
2583
|
}).refine((entry) => entry.url === void 0 || Number(/\/pull\/(\d+)/i.exec(entry.url)?.[1]) === entry.number, { message: "PR URL and number must agree" });
|
|
2584
|
+
var workflowCursorSchema = z20.object({ stepId: z20.string(), mode: z20.enum(["resume", "start"]) });
|
|
2523
2585
|
var runRecordSchema = z20.object({
|
|
2524
2586
|
id: z20.string(),
|
|
2525
2587
|
title: z20.string(),
|
|
@@ -2537,8 +2599,10 @@ var runRecordSchema = z20.object({
|
|
|
2537
2599
|
stopping: z20.boolean().optional(),
|
|
2538
2600
|
/** Opening Continue message, retained until its first completed turn for crash recovery. */
|
|
2539
2601
|
continuationMessage: continuationMessageSchema.optional(),
|
|
2540
|
-
/**
|
|
2541
|
-
|
|
2602
|
+
/** The workflow step the run goes on from (ADR 0064): `resume` continues that step's session (a
|
|
2603
|
+
* failed attempt awaiting CI recovery or a provider retry), `start` runs it after a Continue
|
|
2604
|
+
* completed the step before it. Only the run exits write it (`runs/run-exits.ts`). */
|
|
2605
|
+
workflowCursor: workflowCursorSchema.optional(),
|
|
2542
2606
|
/** The last turn carried a malformed explicit structured question. */
|
|
2543
2607
|
invalidAsk: z20.boolean().optional(),
|
|
2544
2608
|
/** Owned-run authority; absence is legacy, invalid is explicitly quarantined. */
|
|
@@ -2739,7 +2803,8 @@ var apiRunSchema = runRecordSchema.extend({
|
|
|
2739
2803
|
/** Read-only GET /runs/:id verdict: null permits Finish, a string explains refusal.
|
|
2740
2804
|
* Absent on lists, stored records and mutation responses; absence is not permission. */
|
|
2741
2805
|
finishBlocked: z20.string().nullable().optional(),
|
|
2742
|
-
/**
|
|
2806
|
+
/** The server's take-over command for the run's latest session, with the executable the server
|
|
2807
|
+
* resolves. Absent without a session or for an id the server refuses. Never persisted. */
|
|
2743
2808
|
cliResumeCommand: z20.string().optional(),
|
|
2744
2809
|
usage: processUsageSchema.optional()
|
|
2745
2810
|
});
|
|
@@ -5041,6 +5106,11 @@ function defined(value) {
|
|
|
5041
5106
|
return Object.fromEntries(Object.entries(value).filter(([, entry]) => entry !== void 0));
|
|
5042
5107
|
}
|
|
5043
5108
|
|
|
5109
|
+
// ../contract/src/own-lookup.ts
|
|
5110
|
+
function ownLookup(table, key) {
|
|
5111
|
+
return typeof key === "string" && Object.hasOwn(table, key) ? table[key] : void 0;
|
|
5112
|
+
}
|
|
5113
|
+
|
|
5044
5114
|
// ../contract/src/tool-display.ts
|
|
5045
5115
|
var MAX_LABEL = 120;
|
|
5046
5116
|
function isRecord(value) {
|
|
@@ -5283,7 +5353,7 @@ function imageMimeType(path) {
|
|
|
5283
5353
|
const name = path.slice(path.lastIndexOf("/") + 1);
|
|
5284
5354
|
const dot = name.lastIndexOf(".");
|
|
5285
5355
|
if (dot <= 0) return null;
|
|
5286
|
-
return IMAGE_MIME
|
|
5356
|
+
return ownLookup(IMAGE_MIME, name.slice(dot + 1).toLowerCase()) ?? null;
|
|
5287
5357
|
}
|
|
5288
5358
|
var OS_OPENABLE_EXT = /* @__PURE__ */ new Set(["png", "jpg", "jpeg", "gif", "webp", "bmp", "ico", "avif"]);
|
|
5289
5359
|
function isOsOpenableImage(path) {
|
|
@@ -5870,6 +5940,7 @@ export {
|
|
|
5870
5940
|
RENEW_MS,
|
|
5871
5941
|
REPORTS_QUERY_MAX,
|
|
5872
5942
|
RETENTION_RUN_RULE,
|
|
5943
|
+
RUNNER_COCKPIT_FACTS,
|
|
5873
5944
|
RUNS_SEARCH_PER_PROJECT_MAX,
|
|
5874
5945
|
RUN_HISTORY_PAGE_ITEMS,
|
|
5875
5946
|
RUN_SEARCH_FIELDS,
|
|
@@ -6016,6 +6087,7 @@ export {
|
|
|
6016
6087
|
ciWaitRequestSchema,
|
|
6017
6088
|
ciWaitResultSchema,
|
|
6018
6089
|
ciWaitSchema,
|
|
6090
|
+
cockpitRunnersWhere,
|
|
6019
6091
|
commitQuerySchema,
|
|
6020
6092
|
completionActionSchema,
|
|
6021
6093
|
completionControlsShape,
|
|
@@ -6202,6 +6274,7 @@ export {
|
|
|
6202
6274
|
openTargetSchema,
|
|
6203
6275
|
openTargetsResponseSchema,
|
|
6204
6276
|
openWaitSchema,
|
|
6277
|
+
ownLookup,
|
|
6205
6278
|
ownerInputSchema,
|
|
6206
6279
|
ownerOutputSchema,
|
|
6207
6280
|
parentFileRefusal,
|
|
@@ -6341,7 +6414,9 @@ export {
|
|
|
6341
6414
|
runWorktreeSetupSchema,
|
|
6342
6415
|
rungNeedsYou,
|
|
6343
6416
|
runnerDiscoversModels,
|
|
6417
|
+
runnerDisplayName,
|
|
6344
6418
|
runnerModelCatalogResponseSchema,
|
|
6419
|
+
runnerModelListName,
|
|
6345
6420
|
runnerModelOptionSchema,
|
|
6346
6421
|
runnerModelsSchema,
|
|
6347
6422
|
runnerSchema,
|
|
@@ -6493,6 +6568,7 @@ export {
|
|
|
6493
6568
|
workerWorkspaceSchema,
|
|
6494
6569
|
workersAllowed,
|
|
6495
6570
|
workersWaitingLabel,
|
|
6571
|
+
workflowCursorSchema,
|
|
6496
6572
|
workflowDefSchema,
|
|
6497
6573
|
workflowFileSchema,
|
|
6498
6574
|
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;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import type { Runner } from './runner.ts';
|
|
2
|
+
/**
|
|
3
|
+
* What the cockpit and the server both need to know about one runner, declared once per runner
|
|
4
|
+
* id (hearsay-tools/squawk#3642). Shared code reads a row instead of comparing runner ids, so a
|
|
5
|
+
* new runner needs one new row and no new branch. The server's own wire facts live in
|
|
6
|
+
* `RUNNER_FACTS` (`packages/cezar/src/core/runner-facts.ts`); its test checks that the two agree
|
|
7
|
+
* where they state the same fact.
|
|
8
|
+
*/
|
|
9
|
+
export interface CockpitRunnerFacts {
|
|
10
|
+
/** The runner's name on provider, account and conversation surfaces and in server messages. */
|
|
11
|
+
readonly displayName: string;
|
|
12
|
+
/** The runner's name in model discovery messages and in the model picker's status line. */
|
|
13
|
+
readonly modelListName: string;
|
|
14
|
+
/**
|
|
15
|
+
* `pushed`: the server refreshes the model catalog in the background, serves the cached copy on
|
|
16
|
+
* request and pushes each change on the `models:<runner>` topic. `on-request`: each request
|
|
17
|
+
* discovers the catalog, through the server's short cache.
|
|
18
|
+
*/
|
|
19
|
+
readonly modelCatalogDelivery: 'pushed' | 'on-request';
|
|
20
|
+
/**
|
|
21
|
+
* `catalog-only`: the effort levels come only from the runner's own discovered catalog; without
|
|
22
|
+
* them the picker offers only auto. `catalog-or-generic`: without catalog levels the picker
|
|
23
|
+
* offers every generic level.
|
|
24
|
+
*/
|
|
25
|
+
readonly effortLevels: 'catalog-only' | 'catalog-or-generic';
|
|
26
|
+
/**
|
|
27
|
+
* Which model ids the runner serves. `own`: its own provider's ids, so another runner's known
|
|
28
|
+
* preset conflicts with it. `provider-spanning`: `provider/model` ids of every configured
|
|
29
|
+
* provider, so an id it lists belongs to no runner alone. `any-provider`: bare ids of every
|
|
30
|
+
* provider, so no id conflicts with it.
|
|
31
|
+
*/
|
|
32
|
+
readonly modelIdScope: 'own' | 'provider-spanning' | 'any-provider';
|
|
33
|
+
/** `steer`: input reaches the agent during its turn. `boundary`: input waits for the turn to end. */
|
|
34
|
+
readonly inputMode: 'steer' | 'boundary';
|
|
35
|
+
}
|
|
36
|
+
export declare const RUNNER_COCKPIT_FACTS: {
|
|
37
|
+
readonly claude: {
|
|
38
|
+
readonly displayName: 'Claude Code';
|
|
39
|
+
readonly modelListName: 'Claude';
|
|
40
|
+
readonly modelCatalogDelivery: 'on-request';
|
|
41
|
+
readonly effortLevels: 'catalog-or-generic';
|
|
42
|
+
readonly modelIdScope: 'own';
|
|
43
|
+
readonly inputMode: 'steer';
|
|
44
|
+
};
|
|
45
|
+
readonly codex: {
|
|
46
|
+
readonly displayName: 'Codex';
|
|
47
|
+
readonly modelListName: 'Codex';
|
|
48
|
+
readonly modelCatalogDelivery: 'on-request';
|
|
49
|
+
readonly effortLevels: 'catalog-or-generic';
|
|
50
|
+
readonly modelIdScope: 'own';
|
|
51
|
+
readonly inputMode: 'steer';
|
|
52
|
+
};
|
|
53
|
+
readonly opencode: {
|
|
54
|
+
readonly displayName: 'OpenCode';
|
|
55
|
+
readonly modelListName: 'OpenCode';
|
|
56
|
+
readonly modelCatalogDelivery: 'on-request';
|
|
57
|
+
readonly effortLevels: 'catalog-or-generic';
|
|
58
|
+
readonly modelIdScope: 'provider-spanning';
|
|
59
|
+
readonly inputMode: 'steer';
|
|
60
|
+
};
|
|
61
|
+
readonly pi: {
|
|
62
|
+
readonly displayName: 'pi';
|
|
63
|
+
readonly modelListName: 'Pi';
|
|
64
|
+
readonly modelCatalogDelivery: 'on-request';
|
|
65
|
+
readonly effortLevels: 'catalog-or-generic';
|
|
66
|
+
readonly modelIdScope: 'provider-spanning';
|
|
67
|
+
readonly inputMode: 'steer';
|
|
68
|
+
};
|
|
69
|
+
readonly cursor: {
|
|
70
|
+
readonly displayName: 'Cursor';
|
|
71
|
+
readonly modelListName: 'Cursor';
|
|
72
|
+
readonly modelCatalogDelivery: 'pushed';
|
|
73
|
+
readonly effortLevels: 'catalog-only';
|
|
74
|
+
readonly modelIdScope: 'any-provider';
|
|
75
|
+
readonly inputMode: 'boundary';
|
|
76
|
+
};
|
|
77
|
+
readonly omp: {
|
|
78
|
+
readonly displayName: 'OMP';
|
|
79
|
+
readonly modelListName: 'OMP';
|
|
80
|
+
readonly modelCatalogDelivery: 'on-request';
|
|
81
|
+
readonly effortLevels: 'catalog-or-generic';
|
|
82
|
+
readonly modelIdScope: 'provider-spanning';
|
|
83
|
+
readonly inputMode: 'steer';
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
/** The display name of a runner. */
|
|
87
|
+
export declare function runnerDisplayName(runner: Runner): string;
|
|
88
|
+
/** The runner's name in model discovery messages. */
|
|
89
|
+
export declare function runnerModelListName(runner: Runner): string;
|
|
90
|
+
/** The runners whose cockpit facts match, in the table's order. */
|
|
91
|
+
export declare function cockpitRunnersWhere(matches: (facts: CockpitRunnerFacts) => boolean): Runner[];
|
package/dist/contract/runs.d.ts
CHANGED
|
@@ -194,6 +194,15 @@ export declare const runPullRequestSchema: z.ZodObject<{
|
|
|
194
194
|
}>;
|
|
195
195
|
}, z.core.$strip>;
|
|
196
196
|
export type RunPullRequest = z.infer<typeof runPullRequestSchema>;
|
|
197
|
+
/** The workflow step a run goes on from, and how (ADR 0064). */
|
|
198
|
+
export declare const workflowCursorSchema: z.ZodObject<{
|
|
199
|
+
stepId: z.ZodString;
|
|
200
|
+
mode: z.ZodEnum<{
|
|
201
|
+
resume: "resume";
|
|
202
|
+
start: "start";
|
|
203
|
+
}>;
|
|
204
|
+
}, z.core.$strip>;
|
|
205
|
+
export type WorkflowCursor = z.infer<typeof workflowCursorSchema>;
|
|
197
206
|
export declare const runRecordSchema: z.ZodObject<{
|
|
198
207
|
archiveWhenDone: z.ZodOptional<z.ZodBoolean>;
|
|
199
208
|
autoMergePr: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -235,7 +244,13 @@ export declare const runRecordSchema: z.ZodObject<{
|
|
|
235
244
|
restarted: z.ZodOptional<z.ZodLiteral<true>>;
|
|
236
245
|
}, z.core.$strip>>;
|
|
237
246
|
}, z.core.$strip>>;
|
|
238
|
-
|
|
247
|
+
workflowCursor: z.ZodOptional<z.ZodObject<{
|
|
248
|
+
stepId: z.ZodString;
|
|
249
|
+
mode: z.ZodEnum<{
|
|
250
|
+
resume: "resume";
|
|
251
|
+
start: "start";
|
|
252
|
+
}>;
|
|
253
|
+
}, z.core.$strip>>;
|
|
239
254
|
invalidAsk: z.ZodOptional<z.ZodBoolean>;
|
|
240
255
|
delegation: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
241
256
|
role: z.ZodLiteral<"root">;
|
|
@@ -2126,7 +2141,7 @@ export type RunRecord = z.infer<typeof runRecordSchema>;
|
|
|
2126
2141
|
/**
|
|
2127
2142
|
* What `GET /runs` and `GET /runs/:id` answer: the stored record plus host-derived fields.
|
|
2128
2143
|
* The live `usage` sample is absent for finished runs and wherever `ps` yields nothing.
|
|
2129
|
-
*
|
|
2144
|
+
* The take-over command uses the server's executable override. Finish eligibility is computed
|
|
2130
2145
|
* only for detail reads. These fields are never persisted or attached by mutation routes.
|
|
2131
2146
|
*/
|
|
2132
2147
|
export declare const apiRunSchema: z.ZodObject<{
|
|
@@ -2170,7 +2185,13 @@ export declare const apiRunSchema: z.ZodObject<{
|
|
|
2170
2185
|
restarted: z.ZodOptional<z.ZodLiteral<true>>;
|
|
2171
2186
|
}, z.core.$strip>>;
|
|
2172
2187
|
}, z.core.$strip>>;
|
|
2173
|
-
|
|
2188
|
+
workflowCursor: z.ZodOptional<z.ZodObject<{
|
|
2189
|
+
stepId: z.ZodString;
|
|
2190
|
+
mode: z.ZodEnum<{
|
|
2191
|
+
resume: "resume";
|
|
2192
|
+
start: "start";
|
|
2193
|
+
}>;
|
|
2194
|
+
}, z.core.$strip>>;
|
|
2174
2195
|
invalidAsk: z.ZodOptional<z.ZodBoolean>;
|
|
2175
2196
|
delegation: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
2176
2197
|
role: z.ZodLiteral<"root">;
|
|
@@ -4880,7 +4901,13 @@ export declare const createRunResponseSchema: z.ZodObject<{
|
|
|
4880
4901
|
restarted: z.ZodOptional<z.ZodLiteral<true>>;
|
|
4881
4902
|
}, z.core.$strip>>;
|
|
4882
4903
|
}, z.core.$strip>>;
|
|
4883
|
-
|
|
4904
|
+
workflowCursor: z.ZodOptional<z.ZodObject<{
|
|
4905
|
+
stepId: z.ZodString;
|
|
4906
|
+
mode: z.ZodEnum<{
|
|
4907
|
+
resume: "resume";
|
|
4908
|
+
start: "start";
|
|
4909
|
+
}>;
|
|
4910
|
+
}, z.core.$strip>>;
|
|
4884
4911
|
invalidAsk: z.ZodOptional<z.ZodBoolean>;
|
|
4885
4912
|
delegation: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
4886
4913
|
role: z.ZodLiteral<"root">;
|
|
@@ -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":"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"}
|
|
@@ -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
|
},
|