@hearsay-tools/squawk 0.18.0-pr3552.6420 → 0.18.0-pr3554.6439.2
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/tools.d.ts +4 -4
- package/dist/contract/index.js +6 -3
- package/dist/contract/repo.d.ts +2 -0
- package/dist/contract/run-predicates.d.ts +3 -1
- package/dist/delegation/family-end.d.ts +9 -0
- package/dist/delegation/family-end.js +108 -0
- package/dist/delegation/family-end.js.map +1 -0
- package/dist/delegation/routes.d.ts +11 -11
- package/dist/delegation/transport.d.ts +75 -75
- package/dist/delegation/workspace-record.d.ts +7 -0
- package/dist/delegation/workspace-record.js +24 -1
- package/dist/delegation/workspace-record.js.map +1 -1
- package/dist/delegation/workspace-removal.js +56 -13
- package/dist/delegation/workspace-removal.js.map +1 -1
- package/dist/runs/branch-owners.d.ts +30 -0
- package/dist/runs/branch-owners.js +81 -0
- package/dist/runs/branch-owners.js.map +1 -0
- package/dist/runs/retention.d.ts +24 -15
- package/dist/runs/retention.js +57 -39
- package/dist/runs/retention.js.map +1 -1
- package/dist/runs/run-database.d.ts +1 -0
- package/dist/runs/run-database.js +3 -4
- package/dist/runs/run-database.js.map +1 -1
- package/dist/runs/run-row.d.ts +3 -0
- package/dist/runs/run-row.js +5 -0
- package/dist/runs/run-row.js.map +1 -1
- package/dist/runs/store.d.ts +7 -17
- package/dist/runs/store.js +22 -38
- package/dist/runs/store.js.map +1 -1
- package/dist/server/activity-routes.d.ts +23 -23
- package/dist/server/project-context.d.ts +9 -2
- package/dist/server/project-context.js +24 -5
- package/dist/server/project-context.js.map +1 -1
- package/dist/server/repo-branch-sweep.d.ts +23 -1
- package/dist/server/repo-branch-sweep.js +9 -1
- package/dist/server/repo-branch-sweep.js.map +1 -1
- package/dist/server/repo-branches.d.ts +12 -0
- package/dist/server/repo-branches.js +86 -10
- package/dist/server/repo-branches.js.map +1 -1
- package/dist/server/server.d.ts +36 -34
- package/dist/server/server.js +1 -1
- package/dist/server/server.js.map +1 -1
- package/dist/server/start-server.js +2 -2
- package/dist/server/start-server.js.map +1 -1
- package/dist/workflows/continuation-admission.d.ts +72 -72
- package/dist/workflows/run/maintenance-claims.js +7 -2
- package/dist/workflows/run/maintenance-claims.js.map +1 -1
- package/dist/workflows/run/wait-engine.d.ts +72 -72
- package/package.json +4 -4
- package/web/dist/assets/{activity-motion-u7cCOvIh.js → activity-motion-BeswQRe1.js} +1 -1
- package/web/dist/assets/{activity-route-BthlzLJS.js → activity-route-su3KawLr.js} +1 -1
- package/web/dist/assets/{agent-accounts-CbqP0u9A.js → agent-accounts-DseqHuGY.js} +1 -1
- package/web/dist/assets/attention-DlfFfWoj.js +1 -0
- package/web/dist/assets/{commit-diff-panel-B1FnfuXx.js → commit-diff-panel-DmhrguZk.js} +1 -1
- package/web/dist/assets/{diff-DwhVa59f.js → diff-DDwr1gUX.js} +2 -2
- package/web/dist/assets/{diff-view-C4JhxweA.js → diff-view-BNL7l7Vp.js} +1 -1
- package/web/dist/assets/{file-preview-xqxo9aYs.js → file-preview-Cm1jWwBy.js} +1 -1
- package/web/dist/assets/{git-toolbar-B5EhJG95.js → git-toolbar-Dya9briW.js} +1 -1
- package/web/dist/assets/{github-CGvl-B9Z.js → github-wWGhoE3O.js} +1 -1
- package/web/dist/assets/{global-activity-route-n_BdJZWx.js → global-activity-route-DpQr_eU9.js} +1 -1
- package/web/dist/assets/{index-O1VoICYw.js → index-DYx21hr3.js} +4 -4
- package/web/dist/assets/{preview-pane-connected-OWg6VXKi.js → preview-pane-connected-DSStovll.js} +1 -1
- package/web/dist/assets/{project-router-Coo_s3l-.js → project-router-uJ3SkX70.js} +1 -1
- package/web/dist/assets/{project-scope-context-WiGQMFsB.js → project-scope-context-X6-LgbYE.js} +1 -1
- package/web/dist/assets/{prompt-template-menu-Ch7UoIKH.js → prompt-template-menu-D5T9W-K3.js} +1 -1
- package/web/dist/assets/{queries-BLvbAnL8.js → queries-00V5jnAV.js} +1 -1
- package/web/dist/assets/{reference-chip-P6ytqWNt.js → reference-chip-AZWOlSRV.js} +1 -1
- package/web/dist/assets/{repo-git-ZeZnpwuR.js → repo-git-DJPSn50o.js} +1 -1
- package/web/dist/assets/{report-reader-D_uzPRmR.js → report-reader-kzlovTso.js} +1 -1
- package/web/dist/assets/{reports-C49_pROg.js → reports-Ds7nog_M.js} +1 -1
- package/web/dist/assets/{run-header-BR1PGTJB.js → run-header-skVwUvR-.js} +1 -1
- package/web/dist/assets/{skills-BHpdpRR-.js → skills-BJPLRZL5.js} +1 -1
- package/web/dist/assets/{tab-link-CONf2d_z.js → tab-link-h4IjTsRH.js} +1 -1
- package/web/dist/assets/{task-changes-DqcCJDTC.js → task-changes-Db3dmYAT.js} +1 -1
- package/web/dist/assets/{task-commits-Jmpz5NtV.js → task-commits-D4HdW5xE.js} +1 -1
- package/web/dist/assets/{task-files-BFSteFDh.js → task-files-sdaEBCfr.js} +1 -1
- package/web/dist/assets/{task-github-item-CIno99eX.js → task-github-item-DyZdbhco.js} +1 -1
- package/web/dist/assets/{task-thread-BKkxwKd_.js → task-thread-QKAKHYiJ.js} +1 -1
- package/web/dist/assets/{thread-state-Bwt_th_-.js → thread-state-hhRCETQT.js} +1 -1
- package/web/dist/assets/{use-desktop-CW-Femww.js → use-desktop-C3yCutND.js} +1 -1
- package/web/dist/assets/{use-hand-to-agent-state-XV1UwyxH.js → use-hand-to-agent-state-wGtVosbN.js} +1 -1
- package/web/dist/assets/{useInfiniteQuery-BgLdxmcZ.js → useInfiniteQuery-BcY0ra-k.js} +1 -1
- package/web/dist/assets/useQuery-C96hAjNV.js +1 -0
- package/web/dist/assets/{workflows-DUCROjgb.js → workflows-DRO8PcD-.js} +1 -1
- package/web/dist/assets/{ws-8bmD25V4.js → ws-BD6s7UXb.js} +1 -1
- package/web/dist/index.html +12 -12
- package/web/dist/assets/attention-CCx8Iagl.js +0 -1
- package/web/dist/assets/useQuery-CY8bJTYi.js +0 -1
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.js
CHANGED
|
@@ -3319,7 +3319,9 @@ var repoBranchEntrySchema = z21.object({
|
|
|
3319
3319
|
pr: z21.object({ number: z21.number(), url: z21.string(), state: branchPrStateSchema }).nullable(),
|
|
3320
3320
|
/** Why a branch that might be merged is kept: present only when GitHub did not return its full
|
|
3321
3321
|
* PR history, so no merged PR could be ruled in. */
|
|
3322
|
-
keptReason: z21.string().optional()
|
|
3322
|
+
keptReason: z21.string().optional(),
|
|
3323
|
+
/** The parent task of a worker's branch (hearsay-tools/squawk#911). Absent for any other run. */
|
|
3324
|
+
parentRunId: z21.string().optional()
|
|
3323
3325
|
});
|
|
3324
3326
|
var repoBranchesResponseSchema = z21.object({
|
|
3325
3327
|
base: z21.string(),
|
|
@@ -4653,7 +4655,8 @@ function isUnread(run) {
|
|
|
4653
4655
|
return run.seenAt === void 0 || run.seenAt < finishedAt;
|
|
4654
4656
|
}
|
|
4655
4657
|
function isRetentionCandidate(run) {
|
|
4656
|
-
|
|
4658
|
+
const settled = run.status === "done" || run.status === "failed" || run.status === "cancelled";
|
|
4659
|
+
return settled && (!run.delegation || run.delegation.role === "root") && !run.pinned;
|
|
4657
4660
|
}
|
|
4658
4661
|
function hasReferencedRun(run) {
|
|
4659
4662
|
return run.referencedPullRequestUrl !== void 0 || run.referencedIssueUrl !== void 0;
|
|
@@ -4667,7 +4670,7 @@ var SWEEPABLE_RUN_RULE = {
|
|
|
4667
4670
|
matches: isSweepable
|
|
4668
4671
|
};
|
|
4669
4672
|
var RETENTION_RUN_RULE = {
|
|
4670
|
-
sql: "id IN (SELECT value FROM json_each(?)) AND status
|
|
4673
|
+
sql: "id IN (SELECT value FROM json_each(?)) AND status IN ('done', 'failed', 'cancelled') AND parent_run_id IS NULL AND json_extract(summary, '$.delegation.role') IS NOT 'worker' AND json_extract(summary, '$.delegation.role') IS NOT 'invalid' AND json_extract(summary, '$.pinned') IS NOT 1",
|
|
4671
4674
|
matches: isRetentionCandidate
|
|
4672
4675
|
};
|
|
4673
4676
|
var REFERENCED_RUN_RULE = {
|
package/dist/contract/repo.d.ts
CHANGED
|
@@ -182,6 +182,7 @@ export declare const repoBranchEntrySchema: z.ZodObject<{
|
|
|
182
182
|
}>;
|
|
183
183
|
}, z.core.$strip>>;
|
|
184
184
|
keptReason: z.ZodOptional<z.ZodString>;
|
|
185
|
+
parentRunId: z.ZodOptional<z.ZodString>;
|
|
185
186
|
}, z.core.$strip>;
|
|
186
187
|
export type RepoBranchEntry = z.infer<typeof repoBranchEntrySchema>;
|
|
187
188
|
/**
|
|
@@ -236,6 +237,7 @@ export declare const repoBranchesResponseSchema: z.ZodObject<{
|
|
|
236
237
|
}>;
|
|
237
238
|
}, z.core.$strip>>;
|
|
238
239
|
keptReason: z.ZodOptional<z.ZodString>;
|
|
240
|
+
parentRunId: z.ZodOptional<z.ZodString>;
|
|
239
241
|
}, z.core.$strip>>;
|
|
240
242
|
counts: z.ZodObject<{
|
|
241
243
|
notLanded: z.ZodNumber;
|
|
@@ -63,7 +63,9 @@ export declare function canBeUnread(run: ReadStateInput): boolean;
|
|
|
63
63
|
* (`toISOString()` → trailing `Z`), so `<` on the strings is `<` on the instants.
|
|
64
64
|
*/
|
|
65
65
|
export declare function isUnread(run: ReadStateInput): boolean;
|
|
66
|
-
/** History retention
|
|
66
|
+
/** History retention archives a settled, unpinned task with its whole worker family. A task at
|
|
67
|
+
* `review` stays, and so do a worker (it leaves with its root) and an invalid record. The store
|
|
68
|
+
* also keeps a family while any member is live (hearsay-tools/squawk#777). */
|
|
67
69
|
export declare function isRetentionCandidate(run: Pick<RunRecord, 'status' | 'delegation' | 'pinned'>): boolean;
|
|
68
70
|
/** Whether a record names a referenced PR or issue; repository scoping remains separate. */
|
|
69
71
|
export declare function hasReferencedRun(run: Pick<RunRecord, 'referencedPullRequestUrl' | 'referencedIssueUrl'>): boolean;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { RunRecord, RunStore } from '../runs/store.ts';
|
|
2
|
+
export type FamilyEndStore = Pick<RunStore, 'getRun' | 'listWorkersOf' | 'commitDelegation' | 'readWorkerExecution' | 'workerResourcesSafe' | 'sourceDataDir' | 'unavailable'>;
|
|
3
|
+
/** A settled worker whose family has ended, with no member live, no destroy recorded and its
|
|
4
|
+
* directory gone. */
|
|
5
|
+
export declare function endedWorkerBranch(run: RunRecord, store: Pick<FamilyEndStore, 'getRun' | 'listWorkersOf'>): boolean;
|
|
6
|
+
/** Release the branch of every ended worker family in `repoRoot`. `claim` holds the worker's run
|
|
7
|
+
* against Continue and other cleanup for the removal, or returns null when it is in use. `signal`
|
|
8
|
+
* stops the step before its next workspace. Returns the worker ids whose branch went. */
|
|
9
|
+
export declare function releaseEndedWorkerBranches(repoRoot: string, store: FamilyEndStore, claim: (runId: string) => (() => void) | null, signal?: AbortSignal): Promise<string[]>;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The branch step of the family-end rule (hearsay-tools/squawk#911; the case table is in
|
|
3
|
+
* .ai/specs/2026-07-18-worktree-retention.md § Family end). Once a worker's family has ended and
|
|
4
|
+
* retention has reclaimed its clean directory, the owned-workspace removal deletes the worker's
|
|
5
|
+
* branch through its compare-and-swap, which deletes nothing while the branch holds commits that
|
|
6
|
+
* no other ref keeps. A deleted branch completes the worker's destroy, so the parent's slot is
|
|
7
|
+
* free again. A receipt whose run this project no longer has gets the same removal, after its
|
|
8
|
+
* directory is reclaimed if clean. The branch sweep runs this step. Never throws.
|
|
9
|
+
*/
|
|
10
|
+
import { existsSync, realpathSync } from 'node:fs';
|
|
11
|
+
import { join } from 'node:path';
|
|
12
|
+
import { projectPaths } from '../project-paths.js';
|
|
13
|
+
import { cleanupSafety, workerFamilyEnded } from '../runs/retention.js';
|
|
14
|
+
import { isLiveRecord } from '../runs/run-row.js';
|
|
15
|
+
import { ownedWorkspaceReceipts } from './workspace-record.js';
|
|
16
|
+
import { releaseThenRemoveWorktree } from '../git-worktree-release.js';
|
|
17
|
+
import { releaseThenRemoveOwnedWorkspace } from './owned-workspace-release.js';
|
|
18
|
+
import { inspectGeneration } from './process-liveness.js';
|
|
19
|
+
const SETTLED = new Set(['done', 'failed', 'cancelled', 'review']);
|
|
20
|
+
/** A settled worker whose family has ended, with no member live, no destroy recorded and its
|
|
21
|
+
* directory gone. */
|
|
22
|
+
export function endedWorkerBranch(run, store) {
|
|
23
|
+
if (run.delegation?.role !== 'worker' || run.delegation.destroy || isLiveRecord(run) || !SETTLED.has(run.status))
|
|
24
|
+
return false;
|
|
25
|
+
return workerFamilyEnded(run, (id) => store.getRun(id)) && !existsSync(run.delegation.workspace.path) &&
|
|
26
|
+
!store.listWorkersOf(run.delegation.parentRunId).some(isLiveRecord);
|
|
27
|
+
}
|
|
28
|
+
/** Release the branch of every ended worker family in `repoRoot`. `claim` holds the worker's run
|
|
29
|
+
* against Continue and other cleanup for the removal, or returns null when it is in use. `signal`
|
|
30
|
+
* stops the step before its next workspace. Returns the worker ids whose branch went. */
|
|
31
|
+
export async function releaseEndedWorkerBranches(repoRoot, store, claim, signal) {
|
|
32
|
+
// Without its runs every receipt would look orphaned.
|
|
33
|
+
if (store.unavailable)
|
|
34
|
+
return [];
|
|
35
|
+
const released = [];
|
|
36
|
+
for (const { workspace, cleaned } of await ownedWorkspaceReceipts(repoRoot).catch(() => [])) {
|
|
37
|
+
if (signal?.aborted)
|
|
38
|
+
break;
|
|
39
|
+
const run = store.getRun(workspace.ownerRunId);
|
|
40
|
+
const due = run
|
|
41
|
+
? endedWorkerBranch(run, store) && JSON.stringify(run.delegation?.role === 'worker' && run.delegation.workspace) === JSON.stringify(workspace)
|
|
42
|
+
: !cleaned && inProject(repoRoot, workspace) && await reclaimOrphanDirectory(repoRoot, store, workspace);
|
|
43
|
+
if (due && await releaseBranch(repoRoot, store, workspace, run, claim))
|
|
44
|
+
released.push(workspace.ownerRunId);
|
|
45
|
+
}
|
|
46
|
+
return released;
|
|
47
|
+
}
|
|
48
|
+
/** Receipts live in the repository's shared Git directory: another checkout's are not this
|
|
49
|
+
* project's, and the read-only fallback directory's are left alone. */
|
|
50
|
+
function inProject(repoRoot, workspace) {
|
|
51
|
+
try {
|
|
52
|
+
return workspace.path === join(projectPaths(realpathSync(repoRoot)).write, 'worktrees', workspace.ownerRunId);
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/** An orphan receipt's directory goes as an archived worker's does: only when it is clean, and only
|
|
59
|
+
* while still no run owns it and no process works in it. True once the directory is gone. */
|
|
60
|
+
async function reclaimOrphanDirectory(repoRoot, store, workspace) {
|
|
61
|
+
if (!existsSync(workspace.path))
|
|
62
|
+
return true;
|
|
63
|
+
const assertOrphan = () => {
|
|
64
|
+
if (store.getRun(workspace.ownerRunId))
|
|
65
|
+
throw new Error('The receipt has a run');
|
|
66
|
+
if (inspectGeneration({ paths: [workspace.path] }).liveness !== 'gone')
|
|
67
|
+
throw new Error('A process may hold the directory');
|
|
68
|
+
};
|
|
69
|
+
try {
|
|
70
|
+
assertOrphan();
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
await releaseThenRemoveWorktree({}, workspace.ownerRunId, repoRoot, workspace.path, undefined, { reclaimOwnedDirectory: true, onlyClean: true, assertCurrent: assertOrphan });
|
|
76
|
+
return !existsSync(workspace.path);
|
|
77
|
+
}
|
|
78
|
+
async function releaseBranch(repoRoot, store, workspace, run, claim) {
|
|
79
|
+
const release = run ? claim(run.id) : () => undefined;
|
|
80
|
+
if (!release)
|
|
81
|
+
return false;
|
|
82
|
+
try {
|
|
83
|
+
const safe = run ? cleanupSafety(repoRoot, store, run) : () => undefined;
|
|
84
|
+
// Rechecked before every destructive step: the run is still an ended worker (or still absent).
|
|
85
|
+
const assertCurrent = () => {
|
|
86
|
+
const current = store.getRun(workspace.ownerRunId);
|
|
87
|
+
if (run ? !current || !endedWorkerBranch(current, store) : current)
|
|
88
|
+
throw new Error('Worker changed');
|
|
89
|
+
safe();
|
|
90
|
+
};
|
|
91
|
+
const result = await releaseThenRemoveOwnedWorkspace({}, repoRoot, workspace, assertCurrent, assertCurrent);
|
|
92
|
+
if (result.state !== 'complete')
|
|
93
|
+
return false;
|
|
94
|
+
const current = run && store.getRun(run.id);
|
|
95
|
+
if (current?.delegation?.role === 'worker' && !current.delegation.destroy) {
|
|
96
|
+
store.commitDelegation([{ id: current.id, delegation: { ...current.delegation,
|
|
97
|
+
destroy: { requestedAt: new Date().toISOString(), phase: 'complete', remaining: [] } } }]);
|
|
98
|
+
}
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
catch {
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
finally {
|
|
105
|
+
release();
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=family-end.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"family-end.js","sourceRoot":"","sources":["../../src/delegation/family-end.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C/F,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;YAAS,CAAC;QACT,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC"}
|
|
@@ -82,17 +82,6 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
82
82
|
"/discover": {
|
|
83
83
|
$post: {
|
|
84
84
|
output: {
|
|
85
|
-
runner: "claude" | "codex" | "cursor" | "omp" | "opencode" | "pi";
|
|
86
|
-
models: {
|
|
87
|
-
id: string;
|
|
88
|
-
label: string;
|
|
89
|
-
description: string;
|
|
90
|
-
effortLevels?: ("high" | "low" | "max" | "medium" | "xhigh")[] | undefined;
|
|
91
|
-
}[];
|
|
92
|
-
source: "cache" | "live" | "unavailable";
|
|
93
|
-
stale: boolean;
|
|
94
|
-
reason?: string | undefined;
|
|
95
|
-
} | {
|
|
96
85
|
scope: "host-default-account";
|
|
97
86
|
runners: {
|
|
98
87
|
status: "connected" | "disconnected" | "not-installed" | "unknown";
|
|
@@ -113,6 +102,17 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
113
102
|
reason?: string | undefined;
|
|
114
103
|
}[];
|
|
115
104
|
nextOffset?: number | undefined;
|
|
105
|
+
} | {
|
|
106
|
+
runner: "claude" | "codex" | "cursor" | "omp" | "opencode" | "pi";
|
|
107
|
+
models: {
|
|
108
|
+
id: string;
|
|
109
|
+
label: string;
|
|
110
|
+
description: string;
|
|
111
|
+
effortLevels?: ("high" | "low" | "max" | "medium" | "xhigh")[] | undefined;
|
|
112
|
+
}[];
|
|
113
|
+
source: "cache" | "live" | "unavailable";
|
|
114
|
+
stale: boolean;
|
|
115
|
+
reason?: string | undefined;
|
|
116
116
|
};
|
|
117
117
|
outputFormat: "json";
|
|
118
118
|
status: 200;
|
|
@@ -2,18 +2,6 @@ import type { DelegationRoutes } from './routes.ts';
|
|
|
2
2
|
export declare function createDelegationApp(routes: DelegationRoutes): import("hono/hono-base").HonoBase<import("hono/types").BlankEnv, import("hono/types").BlankSchema | import("hono/types").MergeSchemaPath<{
|
|
3
3
|
"/list": {
|
|
4
4
|
$get: {
|
|
5
|
-
output: {
|
|
6
|
-
error: string;
|
|
7
|
-
code?: "invalid_input" | undefined;
|
|
8
|
-
};
|
|
9
|
-
outputFormat: "json";
|
|
10
|
-
status: 400;
|
|
11
|
-
input: {
|
|
12
|
-
query: {
|
|
13
|
-
offset?: string | undefined;
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
} | {
|
|
17
5
|
output: {
|
|
18
6
|
workers: {
|
|
19
7
|
workerId: string;
|
|
@@ -51,21 +39,24 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
|
|
|
51
39
|
offset?: string | undefined;
|
|
52
40
|
};
|
|
53
41
|
};
|
|
42
|
+
} | {
|
|
43
|
+
output: {
|
|
44
|
+
error: string;
|
|
45
|
+
code?: "invalid_input" | undefined;
|
|
46
|
+
};
|
|
47
|
+
outputFormat: "json";
|
|
48
|
+
status: 400;
|
|
49
|
+
input: {
|
|
50
|
+
query: {
|
|
51
|
+
offset?: string | undefined;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
54
|
};
|
|
55
55
|
};
|
|
56
56
|
} & {
|
|
57
57
|
"/discover": {
|
|
58
58
|
$post: {
|
|
59
59
|
output: {
|
|
60
|
-
scope: "host-default-account";
|
|
61
|
-
runners: {
|
|
62
|
-
status: "connected" | "disconnected" | "not-installed" | "unknown";
|
|
63
|
-
enabled?: boolean | undefined;
|
|
64
|
-
hint?: string | undefined;
|
|
65
|
-
authFailureId?: string | undefined;
|
|
66
|
-
runner: "claude" | "codex" | "cursor" | "omp" | "opencode" | "pi";
|
|
67
|
-
}[];
|
|
68
|
-
} | {
|
|
69
60
|
tasks: {
|
|
70
61
|
id: string;
|
|
71
62
|
title: string;
|
|
@@ -77,6 +68,15 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
|
|
|
77
68
|
reason?: string | undefined;
|
|
78
69
|
}[];
|
|
79
70
|
nextOffset?: number | undefined;
|
|
71
|
+
} | {
|
|
72
|
+
scope: "host-default-account";
|
|
73
|
+
runners: {
|
|
74
|
+
status: "connected" | "disconnected" | "not-installed" | "unknown";
|
|
75
|
+
enabled?: boolean | undefined;
|
|
76
|
+
hint?: string | undefined;
|
|
77
|
+
authFailureId?: string | undefined;
|
|
78
|
+
runner: "claude" | "codex" | "cursor" | "omp" | "opencode" | "pi";
|
|
79
|
+
}[];
|
|
80
80
|
} | {
|
|
81
81
|
runner: "claude" | "codex" | "cursor" | "omp" | "opencode" | "pi";
|
|
82
82
|
models: {
|
|
@@ -196,13 +196,13 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
|
|
|
196
196
|
status: 200;
|
|
197
197
|
input: {
|
|
198
198
|
json: {
|
|
199
|
-
workerIds: string[];
|
|
200
|
-
timeoutSeconds?: number | undefined;
|
|
201
|
-
mode?: "all" | "any" | "one" | undefined;
|
|
202
|
-
} | {
|
|
203
199
|
requestIds: string[];
|
|
204
200
|
mode?: "all" | "any" | "one" | undefined;
|
|
205
201
|
timeoutSeconds?: number | undefined;
|
|
202
|
+
} | {
|
|
203
|
+
workerIds: string[];
|
|
204
|
+
timeoutSeconds?: number | undefined;
|
|
205
|
+
mode?: "all" | "any" | "one" | undefined;
|
|
206
206
|
} | {
|
|
207
207
|
peerIds: string[];
|
|
208
208
|
timeoutSeconds?: number | undefined;
|
|
@@ -588,18 +588,6 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
|
|
|
588
588
|
} & {
|
|
589
589
|
"/:workerId": {
|
|
590
590
|
$get: {
|
|
591
|
-
output: {
|
|
592
|
-
error: string;
|
|
593
|
-
code?: "invalid_input" | undefined;
|
|
594
|
-
};
|
|
595
|
-
outputFormat: "json";
|
|
596
|
-
status: 400;
|
|
597
|
-
input: {
|
|
598
|
-
param: {
|
|
599
|
-
workerId: string;
|
|
600
|
-
};
|
|
601
|
-
};
|
|
602
|
-
} | {
|
|
603
591
|
output: {
|
|
604
592
|
workerId: string;
|
|
605
593
|
parentRunId: string;
|
|
@@ -703,11 +691,7 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
|
|
|
703
691
|
workerId: string;
|
|
704
692
|
};
|
|
705
693
|
};
|
|
706
|
-
}
|
|
707
|
-
};
|
|
708
|
-
} & {
|
|
709
|
-
"/:workerId/collect": {
|
|
710
|
-
$post: {
|
|
694
|
+
} | {
|
|
711
695
|
output: {
|
|
712
696
|
error: string;
|
|
713
697
|
code?: "invalid_input" | undefined;
|
|
@@ -718,10 +702,12 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
|
|
|
718
702
|
param: {
|
|
719
703
|
workerId: string;
|
|
720
704
|
};
|
|
721
|
-
} & {
|
|
722
|
-
json: Record<string, never>;
|
|
723
705
|
};
|
|
724
|
-
}
|
|
706
|
+
};
|
|
707
|
+
};
|
|
708
|
+
} & {
|
|
709
|
+
"/:workerId/collect": {
|
|
710
|
+
$post: {
|
|
725
711
|
output: {
|
|
726
712
|
workerId: string;
|
|
727
713
|
parentRunId: string;
|
|
@@ -823,11 +809,7 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
|
|
|
823
809
|
} & {
|
|
824
810
|
json: Record<string, never>;
|
|
825
811
|
};
|
|
826
|
-
}
|
|
827
|
-
};
|
|
828
|
-
} & {
|
|
829
|
-
"/:workerId/steer": {
|
|
830
|
-
$post: {
|
|
812
|
+
} | {
|
|
831
813
|
output: {
|
|
832
814
|
error: string;
|
|
833
815
|
code?: "invalid_input" | undefined;
|
|
@@ -839,11 +821,13 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
|
|
|
839
821
|
workerId: string;
|
|
840
822
|
};
|
|
841
823
|
} & {
|
|
842
|
-
json:
|
|
843
|
-
text: string;
|
|
844
|
-
};
|
|
824
|
+
json: Record<string, never>;
|
|
845
825
|
};
|
|
846
|
-
}
|
|
826
|
+
};
|
|
827
|
+
};
|
|
828
|
+
} & {
|
|
829
|
+
"/:workerId/steer": {
|
|
830
|
+
$post: {
|
|
847
831
|
output: {
|
|
848
832
|
workerId: string;
|
|
849
833
|
state: "delivered" | "queued";
|
|
@@ -859,11 +843,7 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
|
|
|
859
843
|
text: string;
|
|
860
844
|
};
|
|
861
845
|
};
|
|
862
|
-
}
|
|
863
|
-
};
|
|
864
|
-
} & {
|
|
865
|
-
"/:workerId/stop": {
|
|
866
|
-
$post: {
|
|
846
|
+
} | {
|
|
867
847
|
output: {
|
|
868
848
|
error: string;
|
|
869
849
|
code?: "invalid_input" | undefined;
|
|
@@ -875,9 +855,15 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
|
|
|
875
855
|
workerId: string;
|
|
876
856
|
};
|
|
877
857
|
} & {
|
|
878
|
-
json:
|
|
858
|
+
json: {
|
|
859
|
+
text: string;
|
|
860
|
+
};
|
|
879
861
|
};
|
|
880
|
-
}
|
|
862
|
+
};
|
|
863
|
+
};
|
|
864
|
+
} & {
|
|
865
|
+
"/:workerId/stop": {
|
|
866
|
+
$post: {
|
|
881
867
|
output: {
|
|
882
868
|
workerId: string;
|
|
883
869
|
state: "stopping" | "terminated";
|
|
@@ -891,11 +877,7 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
|
|
|
891
877
|
} & {
|
|
892
878
|
json: Record<string, never>;
|
|
893
879
|
};
|
|
894
|
-
}
|
|
895
|
-
};
|
|
896
|
-
} & {
|
|
897
|
-
"/:workerId/destroy": {
|
|
898
|
-
$post: {
|
|
880
|
+
} | {
|
|
899
881
|
output: {
|
|
900
882
|
error: string;
|
|
901
883
|
code?: "invalid_input" | undefined;
|
|
@@ -909,7 +891,11 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
|
|
|
909
891
|
} & {
|
|
910
892
|
json: Record<string, never>;
|
|
911
893
|
};
|
|
912
|
-
}
|
|
894
|
+
};
|
|
895
|
+
};
|
|
896
|
+
} & {
|
|
897
|
+
"/:workerId/destroy": {
|
|
898
|
+
$post: {
|
|
913
899
|
output: {
|
|
914
900
|
workerId: string;
|
|
915
901
|
state: "complete" | "incomplete";
|
|
@@ -932,6 +918,20 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
|
|
|
932
918
|
} & {
|
|
933
919
|
json: Record<string, never>;
|
|
934
920
|
};
|
|
921
|
+
} | {
|
|
922
|
+
output: {
|
|
923
|
+
error: string;
|
|
924
|
+
code?: "invalid_input" | undefined;
|
|
925
|
+
};
|
|
926
|
+
outputFormat: "json";
|
|
927
|
+
status: 400;
|
|
928
|
+
input: {
|
|
929
|
+
param: {
|
|
930
|
+
workerId: string;
|
|
931
|
+
};
|
|
932
|
+
} & {
|
|
933
|
+
json: Record<string, never>;
|
|
934
|
+
};
|
|
935
935
|
} | {
|
|
936
936
|
output: {
|
|
937
937
|
workerId: string;
|
|
@@ -961,11 +961,13 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
|
|
|
961
961
|
"/:workerId/diff": {
|
|
962
962
|
$get: {
|
|
963
963
|
output: {
|
|
964
|
-
|
|
965
|
-
|
|
964
|
+
workerId: string;
|
|
965
|
+
baselineSha: string;
|
|
966
|
+
diff: string;
|
|
967
|
+
truncated: boolean;
|
|
966
968
|
};
|
|
967
969
|
outputFormat: "json";
|
|
968
|
-
status:
|
|
970
|
+
status: 200;
|
|
969
971
|
input: {
|
|
970
972
|
param: {
|
|
971
973
|
workerId: string;
|
|
@@ -973,13 +975,11 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
|
|
|
973
975
|
};
|
|
974
976
|
} | {
|
|
975
977
|
output: {
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
diff: string;
|
|
979
|
-
truncated: boolean;
|
|
978
|
+
error: string;
|
|
979
|
+
code?: "invalid_input" | undefined;
|
|
980
980
|
};
|
|
981
981
|
outputFormat: "json";
|
|
982
|
-
status:
|
|
982
|
+
status: 400;
|
|
983
983
|
input: {
|
|
984
984
|
param: {
|
|
985
985
|
workerId: string;
|
|
@@ -43,6 +43,7 @@ export declare const cleanupSchema: z.ZodObject<{
|
|
|
43
43
|
prepared: "prepared";
|
|
44
44
|
"worktree-removed": "worktree-removed";
|
|
45
45
|
}>;
|
|
46
|
+
forced: z.ZodOptional<z.ZodLiteral<true>>;
|
|
46
47
|
}, z.core.$strict>;
|
|
47
48
|
export type Cleanup = z.infer<typeof cleanupSchema>;
|
|
48
49
|
export declare const hash: (content: Buffer) => string;
|
|
@@ -53,6 +54,12 @@ export declare function receiptLocation(repoRoot: string, workspace: WorkerWorks
|
|
|
53
54
|
/** The receipt and cleanup checkpoint files in the repository's shared receipt directory, checked
|
|
54
55
|
* as `receiptLocation` checks it; none when it does not exist. The project migration rewrites them. */
|
|
55
56
|
export declare function ownedWorkspaceRecordFiles(repoRoot: string): Promise<string[]>;
|
|
57
|
+
/** Each readable receipt's workspace, and whether its cleanup checkpoint says the removal completed.
|
|
58
|
+
* An unreadable record is skipped: only an explicit destroy acts on it. */
|
|
59
|
+
export declare function ownedWorkspaceReceipts(repoRoot: string): Promise<Array<{
|
|
60
|
+
workspace: WorkerWorkspace;
|
|
61
|
+
cleaned: boolean;
|
|
62
|
+
}>>;
|
|
56
63
|
/** One receipt or cleanup checkpoint, read with the identity-file checks. */
|
|
57
64
|
export declare function readOwnedWorkspaceRecord(path: string): Promise<string>;
|
|
58
65
|
/** Replace one receipt or cleanup checkpoint atomically and privately, as cleanup checkpoints are. */
|
|
@@ -15,8 +15,11 @@ export const RECEIPT_CAP = 16_384;
|
|
|
15
15
|
const fileIdentitySchema = z.object({ dev: z.number(), ino: z.number(), birthtimeMs: z.number() }).strict();
|
|
16
16
|
const branchIdentitySchema = z.object({ file: fileIdentitySchema, prefixBytes: z.number().int().min(1).max(4096), prefixHash: z.string().length(64) }).strict();
|
|
17
17
|
const receiptSchema = z.object({ workspace: workerWorkspaceSchema, gitDir: z.string().min(1), branchIdentity: branchIdentitySchema.optional() }).strict();
|
|
18
|
+
// `forced`: the destroy that wrote it removed the present checkout, so its branch goes at `sha`
|
|
19
|
+
// whatever it holds (hearsay-tools/squawk#911); without it, every attempt proves no work is lost.
|
|
18
20
|
export const cleanupSchema = z.object({ workspace: workerWorkspaceSchema, gitDir: z.string(), sha: workerWorkspaceSchema.shape.baselineSha,
|
|
19
|
-
logFile: fileIdentitySchema, logHash: z.string().length(64), phase: z.enum(['prepared', 'worktree-removed', 'complete'])
|
|
21
|
+
logFile: fileIdentitySchema, logHash: z.string().length(64), phase: z.enum(['prepared', 'worktree-removed', 'complete']),
|
|
22
|
+
forced: z.literal(true).optional() }).strict();
|
|
20
23
|
export const hash = (content) => createHash('sha256').update(content).digest('hex');
|
|
21
24
|
export async function replaceIdentityFile(path, content, assertCurrent) {
|
|
22
25
|
assertCurrent?.();
|
|
@@ -56,6 +59,26 @@ export async function ownedWorkspaceRecordFiles(repoRoot) {
|
|
|
56
59
|
return [];
|
|
57
60
|
return (await readdir(dir)).filter(name => name.endsWith('.json')).sort().map(name => join(dir, name));
|
|
58
61
|
}
|
|
62
|
+
/** Each readable receipt's workspace, and whether its cleanup checkpoint says the removal completed.
|
|
63
|
+
* An unreadable record is skipped: only an explicit destroy acts on it. */
|
|
64
|
+
export async function ownedWorkspaceReceipts(repoRoot) {
|
|
65
|
+
const receipts = [];
|
|
66
|
+
for (const path of await ownedWorkspaceRecordFiles(repoRoot)) {
|
|
67
|
+
if (path.endsWith('.cleanup.json'))
|
|
68
|
+
continue;
|
|
69
|
+
try {
|
|
70
|
+
const receipt = await readReceipt(path);
|
|
71
|
+
if (!receipt)
|
|
72
|
+
continue;
|
|
73
|
+
const checkpoint = path.replace(/\.json$/, '.cleanup.json');
|
|
74
|
+
const cleaned = await exists(checkpoint) &&
|
|
75
|
+
cleanupSchema.parse(JSON.parse(await readIdentityFile(checkpoint, RECEIPT_CAP))).phase === 'complete';
|
|
76
|
+
receipts.push({ workspace: receipt.workspace, cleaned });
|
|
77
|
+
}
|
|
78
|
+
catch { /* unreadable */ }
|
|
79
|
+
}
|
|
80
|
+
return receipts;
|
|
81
|
+
}
|
|
59
82
|
/** One receipt or cleanup checkpoint, read with the identity-file checks. */
|
|
60
83
|
export function readOwnedWorkspaceRecord(path) {
|
|
61
84
|
return readIdentityFile(path, RECEIPT_CAP);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workspace-record.js","sourceRoot":"","sources":["../../src/delegation/workspace-record.ts"],"names":[],"mappings":"AAAA,wIAAwI;AACxI,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,WAAW,IAAI,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AAEhF,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAE9D,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC;AAClC,0EAA0E;AAC1E,gEAAgE;AAChE,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC;AAC5G,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,kBAAkB,EAAE,WAAW,EA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