@abelxiaoxing/cadence 1.8.3 → 2.0.0
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/README.md +324 -111
- package/THIRD_PARTY_NOTICES.md +15 -0
- package/agents/design-explorer.md +14 -26
- package/agents/diagnosis-worker.md +14 -25
- package/agents/implementation-worker.md +16 -35
- package/config/.env.example +2 -5
- package/config/workflow-task.example.json +7 -0
- package/docs/remote-access.md +60 -0
- package/docs/reuse-and-distribution.md +44 -0
- package/docs/service-management.md +108 -0
- package/licenses/bundled-web.txt +6245 -0
- package/licenses/pi-web-ui-MIT.txt +21 -0
- package/licenses/pi-web-ui-reuse.md +22 -0
- package/package.json +94 -21
- package/src/index.ts +22 -1807
- package/src/native-build.ts +6 -0
- package/src/native-client.ts +103 -0
- package/src/native-export.ts +58 -0
- package/src/native-history.ts +359 -0
- package/src/operator-cli.mjs +453 -1937
- package/src/plan-proposal.ts +87 -0
- package/src/sdk-worker.mjs +549 -0
- package/src/service/contracts/active.ts +82 -0
- package/src/service/contracts/budget.ts +148 -0
- package/src/service/contracts/build.ts +67 -0
- package/src/service/contracts/capture.ts +48 -0
- package/src/service/contracts/core.ts +33 -0
- package/src/service/contracts/current.ts +261 -0
- package/src/service/contracts/domain.ts +68 -0
- package/src/service/contracts/history.ts +2245 -0
- package/src/service/contracts/models.ts +139 -0
- package/src/service/coordination.ts +862 -0
- package/src/service/private-files.ts +204 -0
- package/src/service-cli.mjs +5592 -0
- package/src/service-client.ts +747 -0
- package/src/service-contract.ts +245 -0
- package/src/service-host.mjs +22382 -0
- package/src/service-http-client.ts +425 -0
- package/src/service-wire.ts +372 -0
- package/src/task-shell.ts +1045 -0
- package/src/task-store.ts +479 -0
- package/src/task-types.ts +184 -0
- package/src/verification-diagnostics.ts +29 -72
- package/src/worker-capture.mjs +1197 -0
- package/src/worker-public.mjs +1753 -0
- package/src/worker-redaction.mjs +608 -0
- package/src/worker-tools.mjs +202 -0
- package/web/dist/assets/KaTeX_AMS-Regular.ttf +0 -0
- package/web/dist/assets/KaTeX_AMS-Regular.woff +0 -0
- package/web/dist/assets/KaTeX_AMS-Regular.woff2 +0 -0
- package/web/dist/assets/KaTeX_Caligraphic-Bold.ttf +0 -0
- package/web/dist/assets/KaTeX_Caligraphic-Bold.woff +0 -0
- package/web/dist/assets/KaTeX_Caligraphic-Bold.woff2 +0 -0
- package/web/dist/assets/KaTeX_Caligraphic-Regular.ttf +0 -0
- package/web/dist/assets/KaTeX_Caligraphic-Regular.woff +0 -0
- package/web/dist/assets/KaTeX_Caligraphic-Regular.woff2 +0 -0
- package/web/dist/assets/KaTeX_Fraktur-Bold.ttf +0 -0
- package/web/dist/assets/KaTeX_Fraktur-Bold.woff +0 -0
- package/web/dist/assets/KaTeX_Fraktur-Bold.woff2 +0 -0
- package/web/dist/assets/KaTeX_Fraktur-Regular.ttf +0 -0
- package/web/dist/assets/KaTeX_Fraktur-Regular.woff +0 -0
- package/web/dist/assets/KaTeX_Fraktur-Regular.woff2 +0 -0
- package/web/dist/assets/KaTeX_Main-Bold.ttf +0 -0
- package/web/dist/assets/KaTeX_Main-Bold.woff +0 -0
- package/web/dist/assets/KaTeX_Main-Bold.woff2 +0 -0
- package/web/dist/assets/KaTeX_Main-BoldItalic.ttf +0 -0
- package/web/dist/assets/KaTeX_Main-BoldItalic.woff +0 -0
- package/web/dist/assets/KaTeX_Main-BoldItalic.woff2 +0 -0
- package/web/dist/assets/KaTeX_Main-Italic.ttf +0 -0
- package/web/dist/assets/KaTeX_Main-Italic.woff +0 -0
- package/web/dist/assets/KaTeX_Main-Italic.woff2 +0 -0
- package/web/dist/assets/KaTeX_Main-Regular.ttf +0 -0
- package/web/dist/assets/KaTeX_Main-Regular.woff +0 -0
- package/web/dist/assets/KaTeX_Main-Regular.woff2 +0 -0
- package/web/dist/assets/KaTeX_Math-BoldItalic.ttf +0 -0
- package/web/dist/assets/KaTeX_Math-BoldItalic.woff +0 -0
- package/web/dist/assets/KaTeX_Math-BoldItalic.woff2 +0 -0
- package/web/dist/assets/KaTeX_Math-Italic.ttf +0 -0
- package/web/dist/assets/KaTeX_Math-Italic.woff +0 -0
- package/web/dist/assets/KaTeX_Math-Italic.woff2 +0 -0
- package/web/dist/assets/KaTeX_SansSerif-Bold.ttf +0 -0
- package/web/dist/assets/KaTeX_SansSerif-Bold.woff +0 -0
- package/web/dist/assets/KaTeX_SansSerif-Bold.woff2 +0 -0
- package/web/dist/assets/KaTeX_SansSerif-Italic.ttf +0 -0
- package/web/dist/assets/KaTeX_SansSerif-Italic.woff +0 -0
- package/web/dist/assets/KaTeX_SansSerif-Italic.woff2 +0 -0
- package/web/dist/assets/KaTeX_SansSerif-Regular.ttf +0 -0
- package/web/dist/assets/KaTeX_SansSerif-Regular.woff +0 -0
- package/web/dist/assets/KaTeX_SansSerif-Regular.woff2 +0 -0
- package/web/dist/assets/KaTeX_Script-Regular.ttf +0 -0
- package/web/dist/assets/KaTeX_Script-Regular.woff +0 -0
- package/web/dist/assets/KaTeX_Script-Regular.woff2 +0 -0
- package/web/dist/assets/KaTeX_Size1-Regular.ttf +0 -0
- package/web/dist/assets/KaTeX_Size1-Regular.woff +0 -0
- package/web/dist/assets/KaTeX_Size1-Regular.woff2 +0 -0
- package/web/dist/assets/KaTeX_Size2-Regular.ttf +0 -0
- package/web/dist/assets/KaTeX_Size2-Regular.woff +0 -0
- package/web/dist/assets/KaTeX_Size2-Regular.woff2 +0 -0
- package/web/dist/assets/KaTeX_Size3-Regular.ttf +0 -0
- package/web/dist/assets/KaTeX_Size3-Regular.woff +0 -0
- package/web/dist/assets/KaTeX_Size3-Regular.woff2 +0 -0
- package/web/dist/assets/KaTeX_Size4-Regular.ttf +0 -0
- package/web/dist/assets/KaTeX_Size4-Regular.woff +0 -0
- package/web/dist/assets/KaTeX_Size4-Regular.woff2 +0 -0
- package/web/dist/assets/KaTeX_Typewriter-Regular.ttf +0 -0
- package/web/dist/assets/KaTeX_Typewriter-Regular.woff +0 -0
- package/web/dist/assets/KaTeX_Typewriter-Regular.woff2 +0 -0
- package/web/dist/assets/cadence.css +2 -0
- package/web/dist/assets/cadence.js +7 -0
- package/web/dist/assets/markdown.js +296 -0
- package/web/dist/assets/react.js +9 -0
- package/web/dist/assets/rolldown-runtime.js +1 -0
- package/web/dist/assets/timeline-client.js +41 -0
- package/web/dist/assets/vis-timeline.css +1274 -0
- package/web/dist/assets/vis-timeline.js +32 -0
- package/web/dist/index.html +18 -0
- package/web/dist/manifest.json +505 -0
- package/config/plan-draft.example.json +0 -125
- package/config/plan-draft.multiple-tasks.example.json +0 -375
- package/config/plan-draft.quick.example.json +0 -78
- package/config/routes.example.json +0 -39
- package/prompts/abel-design.md +0 -382
- package/prompts/abel-diagnose.md +0 -71
- package/prompts/abel-implement.md +0 -284
- package/prompts/abel-init.md +0 -52
- package/src/activation.ts +0 -44
- package/src/activity-contracts.ts +0 -82
- package/src/agent-registry.ts +0 -53
- package/src/apply-transaction.ts +0 -1437
- package/src/artifact-store.ts +0 -213
- package/src/build-windows-job.mjs +0 -95
- package/src/candidate-artifact.ts +0 -143
- package/src/candidate-patch.ts +0 -271
- package/src/candidate-workspace.ts +0 -80
- package/src/canonical.ts +0 -16
- package/src/change-contract-schema.ts +0 -191
- package/src/change-contract.ts +0 -324
- package/src/change-verification.ts +0 -1617
- package/src/child-budget.ts +0 -58
- package/src/child-model.ts +0 -142
- package/src/child-session.ts +0 -640
- package/src/contracts.ts +0 -2476
- package/src/control-contracts.ts +0 -382
- package/src/delivery-compiler.ts +0 -1805
- package/src/delivery-revision.ts +0 -42
- package/src/design-control.ts +0 -1299
- package/src/design-diagnostics.ts +0 -181
- package/src/design-journal.ts +0 -1773
- package/src/directory-sync.ts +0 -36
- package/src/durable-contracts.ts +0 -231
- package/src/durable-workflow.ts +0 -978
- package/src/evidence-draft.ts +0 -122
- package/src/execution-profile.ts +0 -64
- package/src/execution-retention.ts +0 -77
- package/src/file-snapshot.ts +0 -163
- package/src/implement-continuation.ts +0 -559
- package/src/implement-graph.ts +0 -690
- package/src/implement-plan.ts +0 -72
- package/src/install-config.d.mts +0 -6
- package/src/isolation-backend.ts +0 -353
- package/src/model-source.ts +0 -22
- package/src/openspec-cli.ts +0 -494
- package/src/operator-cli-entry.mjs +0 -24
- package/src/operator-tools.ts +0 -309
- package/src/package-candidate.ts +0 -227
- package/src/package-delivery.ts +0 -486
- package/src/package-state.ts +0 -320
- package/src/package-verification.ts +0 -635
- package/src/package-workflow.ts +0 -342
- package/src/packet-runtime.ts +0 -570
- package/src/parent-provider.ts +0 -375
- package/src/phase-execution.ts +0 -2259
- package/src/pi-adapter.ts +0 -19
- package/src/plan-draft-summary.ts +0 -527
- package/src/plan-draft.ts +0 -502
- package/src/remove-path.ts +0 -32
- package/src/route-policy.ts +0 -545
- package/src/run-state.ts +0 -420
- package/src/run-store.ts +0 -1179
- package/src/safe-path.ts +0 -77
- package/src/scoped-grep-worker.mjs +0 -23
- package/src/scoped-tools.ts +0 -775
- package/src/single-task-draft.ts +0 -142
- package/src/sqlite-schema.ts +0 -171
- package/src/state-root.ts +0 -215
- package/src/storage-schema.ts +0 -360
- package/src/subagent-activity.ts +0 -1417
- package/src/submit-tool.ts +0 -950
- package/src/task-ledger.ts +0 -1338
- package/src/transport-budget.ts +0 -52
- package/src/verification-capability.ts +0 -1191
- package/src/verification-environment-io.ts +0 -389
- package/src/verification-environment.ts +0 -162
- package/src/verification-identity.ts +0 -77
- package/src/verification-scan.ts +0 -64
- package/src/windows-job-backend.ts +0 -419
- package/src/windows-job.c +0 -149
- package/src/worker-broker.ts +0 -806
- package/src/workflow-engine.ts +0 -28
- package/src/workflow-policy.ts +0 -1679
- package/src/workflow-recovery-policy.ts +0 -97
- package/src/workflow-scheduling.ts +0 -105
- package/src/workflow-state-machine.ts +0 -4355
- package/src/workflow-status.ts +0 -576
- package/src/workspace-io-entry.mjs +0 -76
- package/src/workspace-io-worker.mjs +0 -1312
- package/src/workspace-io.ts +0 -89
- package/src/workspace-store.ts +0 -634
package/src/operator-tools.ts
DELETED
|
@@ -1,309 +0,0 @@
|
|
|
1
|
-
import { spawnSync } from "node:child_process";
|
|
2
|
-
import { lstatSync, readdirSync, readFileSync, realpathSync } from "node:fs";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import { DatabaseSync } from "node:sqlite";
|
|
5
|
-
import { executionProfile } from "./execution-profile.ts";
|
|
6
|
-
import { resolveOpenSpecInvocation } from "./openspec-cli.ts";
|
|
7
|
-
import { resolveStateRoot } from "./state-root.ts";
|
|
8
|
-
import { requestBounds } from "./transport-budget.ts";
|
|
9
|
-
import { validateVerificationAdapterCapability } from "./verification-capability.ts";
|
|
10
|
-
import { probeWindowsJob } from "./windows-job-backend.ts";
|
|
11
|
-
|
|
12
|
-
export interface DoctorCheck {
|
|
13
|
-
name: string;
|
|
14
|
-
ok: boolean;
|
|
15
|
-
detail: string;
|
|
16
|
-
nextStep?: string;
|
|
17
|
-
}
|
|
18
|
-
const PACKAGE_LOCKS = {
|
|
19
|
-
bun: ["bun.lock", "bun.lockb"],
|
|
20
|
-
npm: ["package-lock.json", "npm-shrinkwrap.json"],
|
|
21
|
-
pnpm: ["pnpm-lock.yaml"],
|
|
22
|
-
yarn: ["yarn.lock"],
|
|
23
|
-
} as const;
|
|
24
|
-
type PackageManager = keyof typeof PACKAGE_LOCKS;
|
|
25
|
-
|
|
26
|
-
function packageManagerSelection(root: string, declaration: unknown) {
|
|
27
|
-
const managers = Object.keys(PACKAGE_LOCKS) as PackageManager[];
|
|
28
|
-
const lockfiles = managers.flatMap((manager) =>
|
|
29
|
-
PACKAGE_LOCKS[manager].filter((file) =>
|
|
30
|
-
lstatSync(path.join(root, file), { throwIfNoEntry: false })?.isFile(),
|
|
31
|
-
),
|
|
32
|
-
);
|
|
33
|
-
const inferred = managers.filter((manager) =>
|
|
34
|
-
PACKAGE_LOCKS[manager].some((file) => lockfiles.includes(file)),
|
|
35
|
-
);
|
|
36
|
-
const declared =
|
|
37
|
-
typeof declaration === "string"
|
|
38
|
-
? managers.find((manager) =>
|
|
39
|
-
new RegExp(
|
|
40
|
-
`^${manager}@[0-9]+\\.[0-9]+\\.[0-9]+(?:[-+][a-z0-9._+-]+)?$`,
|
|
41
|
-
"iu",
|
|
42
|
-
).test(declaration),
|
|
43
|
-
)
|
|
44
|
-
: undefined;
|
|
45
|
-
const selectedPackageManager =
|
|
46
|
-
declaration !== undefined
|
|
47
|
-
? (declared ?? null)
|
|
48
|
-
: inferred.length === 1
|
|
49
|
-
? (inferred[0] ?? null)
|
|
50
|
-
: inferred.length > 1
|
|
51
|
-
? null
|
|
52
|
-
: "npm";
|
|
53
|
-
const selectionSource =
|
|
54
|
-
declaration !== undefined
|
|
55
|
-
? declared
|
|
56
|
-
? "package.json"
|
|
57
|
-
: "invalid-declaration"
|
|
58
|
-
: inferred.length === 1
|
|
59
|
-
? "lockfile"
|
|
60
|
-
: inferred.length > 1
|
|
61
|
-
? "ambiguous"
|
|
62
|
-
: "default";
|
|
63
|
-
return {
|
|
64
|
-
selectedPackageManager,
|
|
65
|
-
selectionSource,
|
|
66
|
-
lockfiles,
|
|
67
|
-
ambiguousLockfiles: inferred.length > 1,
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export function inspectConsumer(root: string) {
|
|
72
|
-
root = realpathSync(root);
|
|
73
|
-
const checks: DoctorCheck[] = [];
|
|
74
|
-
const check = (name: string, action: () => string, nextStep: string) => {
|
|
75
|
-
try {
|
|
76
|
-
checks.push({ name, ok: true, detail: action() });
|
|
77
|
-
} catch (error) {
|
|
78
|
-
checks.push({
|
|
79
|
-
name,
|
|
80
|
-
ok: false,
|
|
81
|
-
detail: error instanceof Error ? error.message : "unavailable",
|
|
82
|
-
nextStep,
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
check(
|
|
87
|
-
"node",
|
|
88
|
-
() => {
|
|
89
|
-
if (
|
|
90
|
-
Number(process.versions.node.split(".")[0]) < 22 ||
|
|
91
|
-
(Number(process.versions.node.split(".")[0]) === 22 &&
|
|
92
|
-
Number(process.versions.node.split(".")[1]) < 13)
|
|
93
|
-
)
|
|
94
|
-
throw new Error("Node 22.13+ required");
|
|
95
|
-
return process.versions.node;
|
|
96
|
-
},
|
|
97
|
-
"Install Node >=22.13.",
|
|
98
|
-
);
|
|
99
|
-
check(
|
|
100
|
-
"git",
|
|
101
|
-
() => {
|
|
102
|
-
const result = spawnSync("git", ["rev-parse", "--show-toplevel"], {
|
|
103
|
-
cwd: root,
|
|
104
|
-
encoding: "utf8",
|
|
105
|
-
timeout: 5000,
|
|
106
|
-
maxBuffer: 65536,
|
|
107
|
-
});
|
|
108
|
-
if (result.status !== 0) throw new Error("git-repository-unavailable");
|
|
109
|
-
return result.stdout.trim();
|
|
110
|
-
},
|
|
111
|
-
"Install Git and initialize the consumer repository.",
|
|
112
|
-
);
|
|
113
|
-
check(
|
|
114
|
-
"openspec",
|
|
115
|
-
() => {
|
|
116
|
-
resolveOpenSpecInvocation(root);
|
|
117
|
-
return "resolved (protocol not executed)";
|
|
118
|
-
},
|
|
119
|
-
"Install @fission-ai/openspec@1.5.0, or configure ABEL_OPENSPEC_PACKAGE_ROOT / ABEL_OPENSPEC_NODE before launching the host.",
|
|
120
|
-
);
|
|
121
|
-
check(
|
|
122
|
-
"execution",
|
|
123
|
-
() => {
|
|
124
|
-
const profile = executionProfile();
|
|
125
|
-
if (profile.mode === "host-trusted") {
|
|
126
|
-
if (!probeWindowsJob(profile.windowsHelperPath ?? ""))
|
|
127
|
-
throw new Error("windows-job-backend-unavailable");
|
|
128
|
-
return "host-trusted: Windows x64 Job probe passed; host files/network accessible";
|
|
129
|
-
}
|
|
130
|
-
if (process.platform !== "linux")
|
|
131
|
-
throw new Error("linux-pid-isolation-required");
|
|
132
|
-
|
|
133
|
-
const result = spawnSync(
|
|
134
|
-
profile.bwrapPath,
|
|
135
|
-
[
|
|
136
|
-
"--ro-bind",
|
|
137
|
-
"/",
|
|
138
|
-
"/",
|
|
139
|
-
profile.mode === "local-trusted" ? "--unshare-pid" : "--unshare-all",
|
|
140
|
-
"--",
|
|
141
|
-
"/bin/true",
|
|
142
|
-
],
|
|
143
|
-
{ timeout: 5000, encoding: "utf8", maxBuffer: 65536 },
|
|
144
|
-
);
|
|
145
|
-
if (result.status !== 0) throw new Error("bubblewrap-probe-failed");
|
|
146
|
-
return `${profile.mode}: Bubblewrap PID namespace probe passed`;
|
|
147
|
-
},
|
|
148
|
-
"On Linux install/enable Bubblewrap; set ABEL_BWRAP_PATH for a custom install. Trusted Linux projects may explicitly set ABEL_EXECUTION_MODE=local-trusted; Windows x64 trusted projects may explicitly select ABEL_EXECUTION_MODE=host-trusted and install the matching native Job helper (ABEL_WINDOWS_JOB_HELPER).",
|
|
149
|
-
);
|
|
150
|
-
check(
|
|
151
|
-
"request-budgets",
|
|
152
|
-
() => JSON.stringify(requestBounds()),
|
|
153
|
-
"Set ABEL_FIRST_PROGRESS_MS and ABEL_STREAM_IDLE_MS to positive milliseconds <=1200000.",
|
|
154
|
-
);
|
|
155
|
-
check(
|
|
156
|
-
"state-root",
|
|
157
|
-
() =>
|
|
158
|
-
resolveStateRoot({
|
|
159
|
-
consumerRoot: root,
|
|
160
|
-
xdgStateHome: process.env.XDG_STATE_HOME,
|
|
161
|
-
}).rootDir,
|
|
162
|
-
"Use an absolute repository-external XDG_STATE_HOME.",
|
|
163
|
-
);
|
|
164
|
-
check(
|
|
165
|
-
"workspace-dependencies",
|
|
166
|
-
() => {
|
|
167
|
-
const dependencies = path.join(root, "node_modules");
|
|
168
|
-
if (!lstatSync(dependencies, { throwIfNoEntry: false }))
|
|
169
|
-
return "no node_modules; prepare dependencies before verification";
|
|
170
|
-
const names = readdirSync(dependencies).flatMap((name) =>
|
|
171
|
-
name.startsWith("@") &&
|
|
172
|
-
lstatSync(path.join(dependencies, name)).isDirectory()
|
|
173
|
-
? readdirSync(path.join(dependencies, name)).map(
|
|
174
|
-
(child) => `${name}/${child}`,
|
|
175
|
-
)
|
|
176
|
-
: [name],
|
|
177
|
-
);
|
|
178
|
-
if (names.length > 20_000) throw new Error("dependency-view-too-large");
|
|
179
|
-
let links = 0;
|
|
180
|
-
for (const name of names) {
|
|
181
|
-
const file = path.join(dependencies, name);
|
|
182
|
-
if (!lstatSync(file).isSymbolicLink()) continue;
|
|
183
|
-
const resolved = realpathSync(file);
|
|
184
|
-
const relative = path.relative(root, resolved);
|
|
185
|
-
if (
|
|
186
|
-
relative === ".." ||
|
|
187
|
-
relative.startsWith(`..${path.sep}`) ||
|
|
188
|
-
path.isAbsolute(relative)
|
|
189
|
-
)
|
|
190
|
-
throw new Error("dependency-link-outside-consumer");
|
|
191
|
-
if (!resolved.startsWith(`${dependencies}${path.sep}`)) links++;
|
|
192
|
-
}
|
|
193
|
-
return `${links} repository workspace link(s); their targets must be included in the candidate baseline`;
|
|
194
|
-
},
|
|
195
|
-
"Repair dangling/external workspace links and ensure local package sources are tracked or admitted in the candidate.",
|
|
196
|
-
);
|
|
197
|
-
const manifest = path.join(root, "package.json");
|
|
198
|
-
let selection = packageManagerSelection(root, undefined);
|
|
199
|
-
if (lstatSync(manifest, { throwIfNoEntry: false })?.isFile()) {
|
|
200
|
-
check(
|
|
201
|
-
"manifest",
|
|
202
|
-
() => {
|
|
203
|
-
const parsed = JSON.parse(readFileSync(manifest, "utf8"));
|
|
204
|
-
if (!parsed || typeof parsed !== "object")
|
|
205
|
-
throw new Error("manifest-invalid");
|
|
206
|
-
return (
|
|
207
|
-
Object.keys(parsed.scripts ?? {}).join(", ") || "no package scripts"
|
|
208
|
-
);
|
|
209
|
-
},
|
|
210
|
-
"Repair package.json.",
|
|
211
|
-
);
|
|
212
|
-
const parsed = (() => {
|
|
213
|
-
try {
|
|
214
|
-
const value = JSON.parse(readFileSync(manifest, "utf8"));
|
|
215
|
-
return value && typeof value === "object" && !Array.isArray(value)
|
|
216
|
-
? value
|
|
217
|
-
: {};
|
|
218
|
-
} catch {
|
|
219
|
-
return {};
|
|
220
|
-
}
|
|
221
|
-
})();
|
|
222
|
-
selection = packageManagerSelection(root, parsed.packageManager);
|
|
223
|
-
check(
|
|
224
|
-
"package-manager",
|
|
225
|
-
() => {
|
|
226
|
-
if (!selection.selectedPackageManager)
|
|
227
|
-
throw new Error(`package-manager-${selection.selectionSource}`);
|
|
228
|
-
return `${selection.selectedPackageManager} (${selection.selectionSource})`;
|
|
229
|
-
},
|
|
230
|
-
"Declare the intended packageManager in package.json; doctor does not read private plans, install runners or remove lockfiles.",
|
|
231
|
-
);
|
|
232
|
-
for (const script of ["test", "check", "build"].filter(
|
|
233
|
-
(name) => typeof parsed.scripts?.[name] === "string",
|
|
234
|
-
)) {
|
|
235
|
-
check(
|
|
236
|
-
`script:${script}`,
|
|
237
|
-
() => {
|
|
238
|
-
const manager = selection.selectedPackageManager;
|
|
239
|
-
if (!manager)
|
|
240
|
-
throw new Error(`package-manager-${selection.selectionSource}`);
|
|
241
|
-
const result = validateVerificationAdapterCapability(root, {
|
|
242
|
-
kind: "package-script",
|
|
243
|
-
id: `doctor-${script}`,
|
|
244
|
-
packageManager: manager,
|
|
245
|
-
script,
|
|
246
|
-
command: parsed.scripts[script],
|
|
247
|
-
args: [],
|
|
248
|
-
classification: "expected-green",
|
|
249
|
-
});
|
|
250
|
-
if (!result.ok)
|
|
251
|
-
throw new Error(`${manager}:${result.diagnostic.code}`);
|
|
252
|
-
return "statically admitted; tests not executed";
|
|
253
|
-
},
|
|
254
|
-
"Check the runner, installed dependencies and execution configuration; this probe does not execute your tests.",
|
|
255
|
-
);
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
return { root, ...selection, ok: checks.every((entry) => entry.ok), checks };
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
/** Bounded metadata traversal, no symlink following and no automatic deletion. */
|
|
262
|
-
export function storageUsage(root: string, maximum = 100_000) {
|
|
263
|
-
let entries = 0;
|
|
264
|
-
let bytes = 0;
|
|
265
|
-
let truncated = false;
|
|
266
|
-
const visit = (file: string) => {
|
|
267
|
-
if (entries >= maximum) {
|
|
268
|
-
truncated = true;
|
|
269
|
-
return;
|
|
270
|
-
}
|
|
271
|
-
const stat = lstatSync(file, { throwIfNoEntry: false });
|
|
272
|
-
if (!stat) return;
|
|
273
|
-
entries++;
|
|
274
|
-
if (stat.isFile()) bytes += stat.size;
|
|
275
|
-
else if (stat.isDirectory())
|
|
276
|
-
for (const name of readdirSync(file)) {
|
|
277
|
-
visit(path.join(file, name));
|
|
278
|
-
if (truncated) break;
|
|
279
|
-
}
|
|
280
|
-
};
|
|
281
|
-
visit(root);
|
|
282
|
-
return { entries, bytes, truncated };
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
export function inspectRuns(root: string) {
|
|
286
|
-
const state = resolveStateRoot({
|
|
287
|
-
consumerRoot: root,
|
|
288
|
-
xdgStateHome: process.env.XDG_STATE_HOME,
|
|
289
|
-
});
|
|
290
|
-
const usage = storageUsage(state.rootDir);
|
|
291
|
-
if (!lstatSync(state.databasePath, { throwIfNoEntry: false }))
|
|
292
|
-
return { stateRoot: state.rootDir, usage, runs: [], truncated: false };
|
|
293
|
-
const db = new DatabaseSync(state.databasePath, { readOnly: true });
|
|
294
|
-
try {
|
|
295
|
-
const rows = db
|
|
296
|
-
.prepare(
|
|
297
|
-
"SELECT run_id, stage, change_name, state, sequence FROM runs ORDER BY run_id LIMIT 1001",
|
|
298
|
-
)
|
|
299
|
-
.all();
|
|
300
|
-
return {
|
|
301
|
-
stateRoot: state.rootDir,
|
|
302
|
-
usage,
|
|
303
|
-
runs: rows.slice(0, 1000),
|
|
304
|
-
truncated: rows.length > 1000,
|
|
305
|
-
};
|
|
306
|
-
} finally {
|
|
307
|
-
db.close();
|
|
308
|
-
}
|
|
309
|
-
}
|
package/src/package-candidate.ts
DELETED
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
import { createHash } from "node:crypto";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import { runChildSession } from "./child-session.ts";
|
|
4
|
-
import type { VerificationFailureSummary } from "./contracts.ts";
|
|
5
|
-
import { LIMITS } from "./contracts.ts";
|
|
6
|
-
import type { DurableWorkflowEngineOptions } from "./durable-contracts.ts";
|
|
7
|
-
import type { ParentModelSource } from "./model-source.ts";
|
|
8
|
-
import { runtimeForWorkerRoute } from "./parent-provider.ts";
|
|
9
|
-
import type { WorkerRoutePolicy } from "./route-policy.ts";
|
|
10
|
-
import { isSafeRegularFile } from "./safe-path.ts";
|
|
11
|
-
import {
|
|
12
|
-
classifyCandidateContextRequest,
|
|
13
|
-
permitsContextRead,
|
|
14
|
-
} from "./submit-tool.ts";
|
|
15
|
-
import { transportFailureError } from "./transport-budget.ts";
|
|
16
|
-
import type { DurableCandidateProposal } from "./workflow-policy.ts";
|
|
17
|
-
|
|
18
|
-
function childRequestId(
|
|
19
|
-
operationId: string,
|
|
20
|
-
taskId: string,
|
|
21
|
-
phase: string,
|
|
22
|
-
): string {
|
|
23
|
-
return `child-${createHash("sha256").update(`${operationId}\0${taskId}\0${phase}`).digest("hex").slice(0, 40)}`;
|
|
24
|
-
}
|
|
25
|
-
export async function proposePackageCandidate(
|
|
26
|
-
input: Parameters<DurableWorkflowEngineOptions["proposeCandidate"]>[0],
|
|
27
|
-
context: ParentModelSource | undefined,
|
|
28
|
-
implementationAgent: { content: string },
|
|
29
|
-
verificationDiagnostics: VerificationFailureSummary[] = [],
|
|
30
|
-
): Promise<DurableCandidateProposal> {
|
|
31
|
-
if (!context) {
|
|
32
|
-
return { kind: "paused", code: "parent-context-unavailable" };
|
|
33
|
-
}
|
|
34
|
-
const phaseRuntime = await runtimeForWorkerRoute(
|
|
35
|
-
input.route as WorkerRoutePolicy,
|
|
36
|
-
context,
|
|
37
|
-
input.signal,
|
|
38
|
-
process.env,
|
|
39
|
-
);
|
|
40
|
-
if (!phaseRuntime.ok) {
|
|
41
|
-
if (phaseRuntime.failure.kind === "cancelled") {
|
|
42
|
-
return { kind: "operation-cancelled", code: "cancelled" };
|
|
43
|
-
}
|
|
44
|
-
throw new Error(phaseRuntime.failure.code);
|
|
45
|
-
}
|
|
46
|
-
const phase = input.task.phases[input.phase];
|
|
47
|
-
if (!phase) {
|
|
48
|
-
return { kind: "paused", code: "task-phase-unavailable" };
|
|
49
|
-
}
|
|
50
|
-
const taskPhases = Object.values(input.task.phases);
|
|
51
|
-
const executionBoundary = input.artifactCorrection
|
|
52
|
-
? {
|
|
53
|
-
read: [
|
|
54
|
-
...new Set(
|
|
55
|
-
taskPhases.flatMap((boundary) => [
|
|
56
|
-
...boundary.read,
|
|
57
|
-
...boundary.write,
|
|
58
|
-
...boundary.delete,
|
|
59
|
-
]),
|
|
60
|
-
),
|
|
61
|
-
].sort(),
|
|
62
|
-
write: [
|
|
63
|
-
...new Set(taskPhases.flatMap((boundary) => boundary.write)),
|
|
64
|
-
].sort(),
|
|
65
|
-
delete: [
|
|
66
|
-
...new Set(taskPhases.flatMap((boundary) => boundary.delete)),
|
|
67
|
-
].sort(),
|
|
68
|
-
}
|
|
69
|
-
: {
|
|
70
|
-
read: [
|
|
71
|
-
...new Set(
|
|
72
|
-
taskPhases.flatMap((boundary) => [
|
|
73
|
-
...boundary.read,
|
|
74
|
-
...boundary.write,
|
|
75
|
-
...boundary.delete,
|
|
76
|
-
]),
|
|
77
|
-
),
|
|
78
|
-
].sort(),
|
|
79
|
-
write: [...phase.write],
|
|
80
|
-
delete: [...phase.delete],
|
|
81
|
-
};
|
|
82
|
-
executionBoundary.read = [
|
|
83
|
-
...new Set([
|
|
84
|
-
...executionBoundary.read,
|
|
85
|
-
...(input.contextReadPaths ?? []).filter(
|
|
86
|
-
(relative) =>
|
|
87
|
-
permitsContextRead(relative, input.task.roots) &&
|
|
88
|
-
isSafeRegularFile(input.workspaceRoot, relative),
|
|
89
|
-
),
|
|
90
|
-
]),
|
|
91
|
-
].sort();
|
|
92
|
-
const phaseContract = {
|
|
93
|
-
verificationDiagnostics,
|
|
94
|
-
candidateId: input.candidateArtifact.identity.candidateId,
|
|
95
|
-
taskId: input.taskId,
|
|
96
|
-
phase: input.phase,
|
|
97
|
-
readSet: executionBoundary.read,
|
|
98
|
-
writeSet: executionBoundary.write,
|
|
99
|
-
deleteSet: executionBoundary.delete,
|
|
100
|
-
verification: structuredClone(phase.verification),
|
|
101
|
-
agentsImpact: input.task.agents.impact,
|
|
102
|
-
agentsTarget: input.task.agents.target ?? null,
|
|
103
|
-
agentsManagedOnly: true,
|
|
104
|
-
agentsWriteAllowed: false,
|
|
105
|
-
impactClosure: structuredClone(input.task.impactClosure),
|
|
106
|
-
...(input.artifactCorrection
|
|
107
|
-
? { artifactCorrection: structuredClone(input.artifactCorrection) }
|
|
108
|
-
: {}),
|
|
109
|
-
...(input.contextRequest
|
|
110
|
-
? { requestedContext: structuredClone(input.contextRequest) }
|
|
111
|
-
: {}),
|
|
112
|
-
...(input.recoveryFeedback
|
|
113
|
-
? { recoveryFeedback: structuredClone(input.recoveryFeedback) }
|
|
114
|
-
: {}),
|
|
115
|
-
...(input.repair
|
|
116
|
-
? {
|
|
117
|
-
repair: {
|
|
118
|
-
attempt: input.repair.attempt,
|
|
119
|
-
attribution: input.repair.attribution,
|
|
120
|
-
failureIdentities: [...input.repair.failureIdentities],
|
|
121
|
-
verification: structuredClone(input.task.repairVerification),
|
|
122
|
-
inBoundaryOnly: true,
|
|
123
|
-
},
|
|
124
|
-
}
|
|
125
|
-
: {}),
|
|
126
|
-
};
|
|
127
|
-
const child = await runChildSession({
|
|
128
|
-
cwd: input.workspaceRoot,
|
|
129
|
-
modelRuntime: phaseRuntime.modelRuntime,
|
|
130
|
-
model: phaseRuntime.model,
|
|
131
|
-
systemPrompt: [
|
|
132
|
-
implementationAgent.content,
|
|
133
|
-
input.task.objective,
|
|
134
|
-
input.task.context.agents,
|
|
135
|
-
input.task.context.contract,
|
|
136
|
-
"Use recoveryFeedback to change the failing approach. For compact-patch, prefer exact replace operations and omit unchanged bodies; submit one complete atomic patch. Never repeat an unchanged failing submission or weaken verification to obtain a pass.",
|
|
137
|
-
`<phase-contract>${JSON.stringify(phaseContract)}</phase-contract>`,
|
|
138
|
-
].join("\n\n"),
|
|
139
|
-
requestId: childRequestId(input.operationId, input.taskId, input.phase),
|
|
140
|
-
taskId: input.taskId,
|
|
141
|
-
role: "implementation-worker",
|
|
142
|
-
phase: input.phase,
|
|
143
|
-
output: "diff",
|
|
144
|
-
roots: input.task.roots.map((root) =>
|
|
145
|
-
path.resolve(input.workspaceRoot, root),
|
|
146
|
-
),
|
|
147
|
-
allowedPaths: [
|
|
148
|
-
...new Set([
|
|
149
|
-
...executionBoundary.read,
|
|
150
|
-
...executionBoundary.write,
|
|
151
|
-
...executionBoundary.delete,
|
|
152
|
-
]),
|
|
153
|
-
],
|
|
154
|
-
timeoutMs: LIMITS.phaseTimeoutMs,
|
|
155
|
-
signal: input.signal,
|
|
156
|
-
ledgerProjection: input.ledgerProjection,
|
|
157
|
-
candidateArtifact: input.candidateArtifact,
|
|
158
|
-
onStreamStart: input.onRequestStart,
|
|
159
|
-
onStreamHeaders: input.onHeaders,
|
|
160
|
-
onStreamProgress: input.onProgress,
|
|
161
|
-
});
|
|
162
|
-
if (!child.ok) {
|
|
163
|
-
if (child.failure.kind === "transport") {
|
|
164
|
-
throw transportFailureError(child.failure.code);
|
|
165
|
-
}
|
|
166
|
-
if (child.failure.kind === "cancelled") {
|
|
167
|
-
return { kind: "operation-cancelled", code: "cancelled" };
|
|
168
|
-
}
|
|
169
|
-
if (child.failure.kind === "approval-boundary") {
|
|
170
|
-
return { kind: "approval-needed", code: child.failure.code };
|
|
171
|
-
}
|
|
172
|
-
if (child.failure.kind === "execution-limit") {
|
|
173
|
-
return { kind: "paused", code: "needs-task-split" };
|
|
174
|
-
}
|
|
175
|
-
if (child.failure.kind === "result-limit") {
|
|
176
|
-
return { kind: "retryable", code: "needs-task-split" };
|
|
177
|
-
}
|
|
178
|
-
const attemptDiagnostic = {
|
|
179
|
-
finalCategory: child.classification.finalCategory,
|
|
180
|
-
submitAttempts: child.classification.attempts,
|
|
181
|
-
schema: child.classification.schema,
|
|
182
|
-
identityMismatch: Object.entries(child.classification.identity)
|
|
183
|
-
.filter(([, matches]) => !matches)
|
|
184
|
-
.map(([dimension]) => dimension),
|
|
185
|
-
};
|
|
186
|
-
return child.failure.kind === "environment" ||
|
|
187
|
-
child.failure.kind === "verification-adapter"
|
|
188
|
-
? { kind: "paused", code: child.failure.code, attemptDiagnostic }
|
|
189
|
-
: { kind: "retryable", code: child.failure.code, attemptDiagnostic };
|
|
190
|
-
}
|
|
191
|
-
const result = child.result;
|
|
192
|
-
if (result.kind === "context-request") {
|
|
193
|
-
return classifyCandidateContextRequest(result, {
|
|
194
|
-
phase: input.phase,
|
|
195
|
-
contextReadRoots: input.task.roots,
|
|
196
|
-
readPaths: phase.read,
|
|
197
|
-
writePaths: phase.write,
|
|
198
|
-
deletePaths: phase.delete,
|
|
199
|
-
taskPaths: [
|
|
200
|
-
...new Set(
|
|
201
|
-
Object.values(input.task.phases).flatMap((boundary) => [
|
|
202
|
-
...boundary.read,
|
|
203
|
-
...boundary.write,
|
|
204
|
-
...boundary.delete,
|
|
205
|
-
]),
|
|
206
|
-
),
|
|
207
|
-
],
|
|
208
|
-
redWritePaths: input.task.phases.red.write,
|
|
209
|
-
agents: {
|
|
210
|
-
impact: input.task.agents.impact,
|
|
211
|
-
...(input.task.agents.target
|
|
212
|
-
? { target: input.task.agents.target }
|
|
213
|
-
: {}),
|
|
214
|
-
},
|
|
215
|
-
});
|
|
216
|
-
}
|
|
217
|
-
if (result.kind !== "sealed-candidate") {
|
|
218
|
-
return { kind: "retryable", code: "candidate-diff-invalid" };
|
|
219
|
-
}
|
|
220
|
-
return {
|
|
221
|
-
kind: "sealed-candidate",
|
|
222
|
-
candidateId: result.candidateId,
|
|
223
|
-
artifactHash: result.artifactHash,
|
|
224
|
-
bytes: result.bytes,
|
|
225
|
-
paths: [...result.paths],
|
|
226
|
-
};
|
|
227
|
-
}
|