@anyswarm/core 0.5.1 → 0.6.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/AGENTS.md +20 -5
- package/README.md +69 -55
- package/dist/examples/README.md +138 -77
- package/dist/examples/authoring/README.md +4 -4
- package/dist/examples/autoresearch/README.md +108 -16
- package/dist/examples/autoresearch/REQUIREMENTS.zh.md +13 -12
- package/dist/examples/autoresearch/config.d.ts +48 -5
- package/dist/examples/autoresearch/config.js +57 -23
- package/dist/examples/autoresearch/demo.d.ts +12 -4
- package/dist/examples/autoresearch/demo.js +65 -22
- package/dist/examples/autoresearch/eject.json +2 -0
- package/dist/examples/autoresearch/frontiercs2-config.d.ts +2 -0
- package/dist/examples/autoresearch/frontiercs2-config.js +14 -0
- package/dist/examples/autoresearch/frontiercs2.d.ts +18 -1
- package/dist/examples/autoresearch/frontiercs2.js +71 -14
- package/dist/examples/autoresearch/prepare-demo.d.ts +1 -0
- package/dist/examples/autoresearch/prepare-demo.js +46 -0
- package/dist/examples/autoresearch/prepare.d.ts +105 -53
- package/dist/examples/autoresearch/prepare.js +126 -57
- package/dist/examples/autoresearch/project.d.ts +6 -95
- package/dist/examples/autoresearch/project.js +131 -45
- package/dist/examples/autoresearch/research-service.d.ts +16 -1
- package/dist/examples/autoresearch/research-service.js +84 -44
- package/dist/examples/code/README.md +25 -17
- package/dist/examples/code/REQUIREMENTS.zh.md +3 -3
- package/dist/examples/code/config.d.ts +1 -0
- package/dist/examples/first-harness/AGENTS.md +25 -0
- package/dist/examples/first-harness/README.md +136 -0
- package/dist/examples/first-harness/config.d.ts +9 -8
- package/dist/examples/first-harness/config.js +33 -26
- package/dist/examples/first-harness/eject.json +14 -0
- package/dist/examples/first-harness/handoff.js +3 -3
- package/dist/examples/first-harness/harness.d.ts +14 -18
- package/dist/examples/first-harness/harness.js +102 -77
- package/dist/examples/first-harness/input/README.md +7 -0
- package/dist/examples/first-harness/session.js +2 -1
- package/dist/examples/first-harness/tsconfig.json +2 -1
- package/dist/examples/harness-session/README.md +4 -4
- package/dist/examples/lead-worker/README.md +1 -1
- package/dist/examples/lead-worker/project-config.d.ts +1 -0
- package/dist/examples/messages/README.md +2 -2
- package/dist/examples/notes/README.md +5 -5
- package/dist/examples/notes/config.d.ts +1 -0
- package/dist/examples/parallel-swarm/AGENTS.md +32 -0
- package/dist/examples/parallel-swarm/README.md +136 -0
- package/dist/examples/parallel-swarm/board-service.js +25 -8
- package/dist/examples/parallel-swarm/board.d.ts +31 -1
- package/dist/examples/parallel-swarm/board.js +98 -13
- package/dist/examples/parallel-swarm/config.d.ts +11 -0
- package/dist/examples/parallel-swarm/config.js +39 -0
- package/dist/examples/parallel-swarm/eject.json +5 -0
- package/dist/examples/parallel-swarm/harness.d.ts +26 -20
- package/dist/examples/parallel-swarm/harness.js +77 -76
- package/dist/examples/parallel-swarm/report.d.ts +12 -0
- package/dist/examples/parallel-swarm/report.js +30 -0
- package/dist/examples/peermesh/README.md +1 -1
- package/dist/examples/peermesh/project-config.d.ts +1 -0
- package/dist/examples/services/agent-control/README.md +1 -1
- package/dist/examples/services/mathlib-search/README.md +1 -1
- package/dist/examples/services/mcp-managed/README.md +1 -1
- package/dist/examples/services/persistent-board/README.md +6 -3
- package/dist/examples/subagents/AGENTS.md +35 -0
- package/dist/examples/subagents/README.md +129 -93
- package/dist/examples/subagents/config.d.ts +2 -10
- package/dist/examples/subagents/config.js +9 -16
- package/dist/examples/subagents/eject.json +17 -0
- package/dist/examples/subagents/handoff-config.d.ts +41 -0
- package/dist/examples/subagents/handoff-config.js +13 -0
- package/dist/examples/subagents/model.d.ts +3 -0
- package/dist/examples/subagents/model.js +19 -0
- package/dist/examples/substrate/README.md +12 -6
- package/dist/examples/substrate/config.d.ts +1 -0
- package/dist/examples/substrate/project-config.d.ts +1 -0
- package/dist/examples/super/README.md +34 -22
- package/dist/examples/super/actions.d.ts +1 -1
- package/dist/examples/super/actions.js +11 -11
- package/dist/examples/super/config.js +3 -3
- package/dist/examples/super/eject.json +1 -1
- package/dist/examples/super/location.js +1 -1
- package/dist/examples/super/operator.d.ts +1 -0
- package/dist/examples/super/operator.js +31 -0
- package/dist/examples/super/project.d.ts +0 -107
- package/dist/examples/super/project.js +1 -3
- package/dist/examples/taskpool/README.md +1 -1
- package/dist/examples/taskpool/config.d.ts +1 -0
- package/dist/examples/taskpool/deploy/service-hosts/service-authority-snapshot.d.ts +4 -4
- package/dist/scripts/anyswarm-arguments.d.ts +7 -25
- package/dist/scripts/anyswarm-arguments.js +69 -97
- package/dist/scripts/anyswarm-eject.js +1 -1
- package/dist/scripts/anyswarm-harnesses.d.ts +0 -1
- package/dist/scripts/anyswarm-harnesses.js +1 -22
- package/dist/scripts/anyswarm-installation.d.ts +7 -40
- package/dist/scripts/anyswarm-installation.js +17 -291
- package/dist/scripts/anyswarm-launch.d.ts +6 -36
- package/dist/scripts/anyswarm-launch.js +32 -81
- package/dist/scripts/anyswarm-progress.d.ts +6 -0
- package/dist/scripts/anyswarm-progress.js +133 -0
- package/dist/scripts/anyswarm-project.d.ts +1 -9
- package/dist/scripts/anyswarm-project.js +40 -127
- package/dist/scripts/anyswarm-source-runner.js +9 -41
- package/dist/scripts/anyswarm.js +6 -26
- package/dist/scripts/build-provenance.json +1 -1
- package/dist/scripts/generate-architecture-coverage.js +1 -1
- package/dist/scripts/generate-architecture-prompts.js +18 -10
- package/dist/scripts/local-environment.d.ts +13 -7
- package/dist/scripts/local-environment.js +73 -21
- package/dist/scripts/local-setup.d.ts +3 -0
- package/dist/scripts/local-setup.js +153 -118
- package/dist/scripts/pack-release.js +31 -4
- package/dist/src/core/index.js +1 -1
- package/dist/src/core/sandbox/opensandbox-backend.js +10 -4
- package/dist/src/core/sandbox/sandbox-connection.d.ts +9 -2
- package/dist/src/core/sandbox/sandbox-connection.js +22 -7
- package/dist/src/core/worker-image.js +1 -1
- package/dist/src/harness/project-harness.d.ts +1 -0
- package/dist/src/harness/project-harness.js +5 -4
- package/dist/src/harness/project-rpc-client.js +19 -0
- package/dist/src/harness/project-runtime.js +3 -1
- package/dist/src/harness/typescript-loader.d.ts +2 -0
- package/dist/src/harness/typescript-loader.js +26 -8
- package/dist/src/trace-viewer/command.mjs +6 -3
- package/dist/src/trace-viewer/public/app.js +239 -59
- package/dist/src/trace-viewer/public/index.html +5 -0
- package/dist/src/trace-viewer/public/style.css +22 -0
- package/dist/src/trace-viewer/reader.mjs +242 -26
- package/dist/src/trace-viewer/run-root.d.mts +1 -0
- package/dist/src/trace-viewer/run-root.mjs +7 -0
- package/dist/src/trace-viewer/server.mjs +3 -1
- package/docs/INDEX.md +11 -9
- package/docs/architecture/04-services.md +1 -1
- package/docs/architecture/06-observability-experiments.md +21 -7
- package/docs/architecture/07-run-configuration.md +118 -19
- package/docs/architecture/08-prompts.md +21 -2
- package/docs/architecture/10-service-api-reference.md +12 -5
- package/docs/architecture/12-code-coverage.md +157 -115
- package/docs/architecture/15-core-runtime.md +1 -1
- package/docs/architecture/16-pi-opensandbox-backend.md +2 -0
- package/docs/architecture/17-harness-reporting.md +79 -1
- package/docs/architecture/22-website.md +52 -20
- package/docs/architecture/23-project-harness.md +109 -37
- package/docs/architecture/26-code.md +20 -5
- package/docs/architecture/27-personal.md +23 -8
- package/docs/architecture/28-autoresearch.md +18 -12
- package/docs/architecture/INDEX.md +1 -2
- package/docs/architecture/prompts/11-first-sdk-harness.md +9 -9
- package/docs/architecture/prompts/16-parallel-swarm.md +46 -13
- package/docs/architecture/prompts/22-autoresearch.md +9 -2
- package/docs/architecture/prompts/source-manifest.json +76 -52
- package/docs/architecture/source-map.json +445 -105
- package/docs/designs/core-harness/01-core.md +2 -2
- package/docs/designs/core-harness/06-project-harness.md +3 -3
- package/docs/designs/core-harness/README.md +2 -2
- package/docs/en/agents.md +1 -1
- package/docs/en/autoresearch.md +41 -0
- package/docs/en/blog/100b-tokens.md +157 -0
- package/docs/en/build-your-harness.md +47 -22
- package/docs/en/changelog.md +29 -1
- package/docs/en/first-harness.md +40 -32
- package/docs/en/harnesses/index.md +23 -23
- package/docs/en/harnesses/lead-worker.md +1 -1
- package/docs/en/harnesses/peermesh.md +2 -2
- package/docs/en/harnesses/subagents.md +10 -31
- package/docs/en/harnesses/substrate.md +4 -4
- package/docs/en/harnesses/taskpool.md +2 -2
- package/docs/en/latest.md +30 -5
- package/docs/en/overview.md +22 -22
- package/docs/en/quickstart.md +69 -56
- package/docs/en/reference/api.md +1 -1
- package/docs/en/reference/cli.md +47 -85
- package/docs/en/sandbox.md +3 -3
- package/docs/en/trace-viewer.md +32 -12
- package/docs/operations/trace-viewer.md +26 -11
- package/docs/third-party-notices.md +0 -1
- package/docs/workflows/development.md +160 -118
- package/docs/workflows/release-and-docs-versioning.md +207 -54
- package/docs/workflows/release-cli-acceptance.md +162 -0
- package/docs/zh/agents.md +1 -1
- package/docs/zh/autoresearch.md +41 -0
- package/docs/zh/blog/100b-tokens.md +102 -0
- package/docs/zh/build-your-harness.md +48 -23
- package/docs/zh/changelog.md +29 -1
- package/docs/zh/first-harness.md +43 -35
- package/docs/zh/harnesses/index.md +23 -23
- package/docs/zh/harnesses/lead-worker.md +1 -1
- package/docs/zh/harnesses/peermesh.md +2 -2
- package/docs/zh/harnesses/subagents.md +10 -31
- package/docs/zh/harnesses/substrate.md +4 -4
- package/docs/zh/harnesses/taskpool.md +2 -2
- package/docs/zh/latest.md +30 -5
- package/docs/zh/overview.md +23 -23
- package/docs/zh/quickstart.md +66 -57
- package/docs/zh/reference/api.md +1 -1
- package/docs/zh/reference/cli.md +19 -79
- package/docs/zh/sandbox.md +3 -3
- package/docs/zh/trace-viewer.md +32 -12
- package/examples/README.md +138 -77
- package/examples/authoring/README.md +4 -4
- package/examples/autoresearch/README.md +108 -16
- package/examples/autoresearch/REQUIREMENTS.zh.md +13 -12
- package/examples/autoresearch/config.ts +64 -25
- package/examples/autoresearch/demo.ts +75 -22
- package/examples/autoresearch/eject.json +2 -0
- package/examples/autoresearch/frontiercs2-config.ts +15 -0
- package/examples/autoresearch/frontiercs2.ts +64 -11
- package/examples/autoresearch/prepare-demo.ts +44 -0
- package/examples/autoresearch/prepare.ts +134 -60
- package/examples/autoresearch/project.ts +120 -44
- package/examples/autoresearch/research-service.ts +91 -41
- package/examples/code/README.md +25 -17
- package/examples/code/REQUIREMENTS.zh.md +3 -3
- package/examples/first-harness/AGENTS.md +25 -0
- package/examples/first-harness/README.md +136 -0
- package/examples/first-harness/config.ts +41 -27
- package/examples/first-harness/eject.json +14 -0
- package/examples/first-harness/handoff.ts +3 -3
- package/examples/first-harness/harness.ts +104 -72
- package/examples/first-harness/input/README.md +7 -0
- package/examples/first-harness/session.ts +2 -1
- package/examples/first-harness/tsconfig.json +2 -1
- package/examples/harness-session/README.md +4 -4
- package/examples/lead-worker/README.md +1 -1
- package/examples/messages/README.md +2 -2
- package/examples/notes/README.md +5 -5
- package/examples/parallel-swarm/AGENTS.md +32 -0
- package/examples/parallel-swarm/README.md +136 -0
- package/examples/parallel-swarm/board-service.ts +28 -9
- package/examples/parallel-swarm/board.ts +107 -13
- package/examples/parallel-swarm/config.ts +47 -0
- package/examples/parallel-swarm/eject.json +5 -0
- package/examples/parallel-swarm/harness.ts +83 -71
- package/examples/parallel-swarm/report.ts +33 -0
- package/examples/peermesh/README.md +1 -1
- package/examples/services/agent-control/README.md +1 -1
- package/examples/services/mathlib-search/README.md +1 -1
- package/examples/services/mcp-managed/README.md +1 -1
- package/examples/services/persistent-board/README.md +6 -3
- package/examples/subagents/AGENTS.md +35 -0
- package/examples/subagents/README.md +129 -93
- package/examples/subagents/config.ts +9 -15
- package/examples/subagents/eject.json +17 -0
- package/examples/subagents/handoff-config.ts +14 -0
- package/examples/subagents/model.ts +20 -0
- package/examples/substrate/README.md +12 -6
- package/examples/super/README.md +34 -22
- package/examples/super/actions.ts +11 -11
- package/examples/super/config.ts +3 -3
- package/examples/super/eject.json +1 -1
- package/examples/super/location.ts +1 -1
- package/examples/super/operator.ts +28 -0
- package/examples/super/project.ts +1 -3
- package/examples/taskpool/README.md +1 -1
- package/npm-shrinkwrap.development.json +46 -1538
- package/npm-shrinkwrap.json +10 -43
- package/package.development.json +3 -6
- package/package.json +3 -5
- package/scripts/anyswarm-arguments.ts +67 -96
- package/scripts/anyswarm-eject.ts +1 -1
- package/scripts/anyswarm-harnesses.ts +1 -18
- package/scripts/anyswarm-installation.ts +18 -294
- package/scripts/anyswarm-launch.ts +30 -102
- package/scripts/anyswarm-progress.ts +125 -0
- package/scripts/anyswarm-project.ts +31 -123
- package/scripts/anyswarm-source-runner.ts +9 -36
- package/scripts/anyswarm.ts +4 -24
- package/scripts/generate-architecture-coverage.ts +1 -1
- package/scripts/generate-architecture-prompts.ts +21 -10
- package/scripts/local-environment.ts +79 -21
- package/scripts/local-setup.ts +150 -105
- package/scripts/pack-release.ts +28 -4
- package/src/core/index.ts +1 -1
- package/src/core/sandbox/opensandbox-backend.ts +10 -4
- package/src/core/sandbox/sandbox-connection.ts +22 -7
- package/src/core/worker-image.ts +1 -1
- package/src/harness/project-harness.ts +5 -4
- package/src/harness/project-rpc-client.ts +23 -0
- package/src/harness/project-runtime.ts +2 -1
- package/src/harness/typescript-loader.ts +28 -8
- package/src/trace-viewer/command.mjs +6 -3
- package/src/trace-viewer/public/app.js +239 -59
- package/src/trace-viewer/public/index.html +5 -0
- package/src/trace-viewer/public/style.css +22 -0
- package/src/trace-viewer/reader.mjs +242 -26
- package/src/trace-viewer/run-root.d.mts +1 -0
- package/src/trace-viewer/run-root.mjs +7 -0
- package/src/trace-viewer/server.mjs +3 -1
- package/dist/scripts/anyswarm-applications.d.ts +0 -19
- package/dist/scripts/anyswarm-applications.js +0 -19
- package/dist/scripts/anyswarm-tui-config.d.ts +0 -36
- package/dist/scripts/anyswarm-tui-config.js +0 -189
- package/dist/scripts/anyswarm-tui-session.d.ts +0 -66
- package/dist/scripts/anyswarm-tui-session.js +0 -304
- package/dist/scripts/anyswarm-tui-terminal.d.ts +0 -41
- package/dist/scripts/anyswarm-tui-terminal.js +0 -154
- package/dist/scripts/anyswarm-tui.d.ts +0 -2
- package/dist/scripts/anyswarm-tui.js +0 -1012
- package/docs/architecture/25-foreground-tui.md +0 -51
- package/scripts/anyswarm-applications.ts +0 -39
- package/scripts/anyswarm-tui-config.ts +0 -174
- package/scripts/anyswarm-tui-session.ts +0 -295
- package/scripts/anyswarm-tui-terminal.ts +0 -147
- package/scripts/anyswarm-tui.ts +0 -912
|
@@ -40,7 +40,7 @@ const compareTimeline = (left, right) => {
|
|
|
40
40
|
const a = timelineStart(left);
|
|
41
41
|
const b = timelineStart(right);
|
|
42
42
|
if (!Number.isFinite(a) || !Number.isFinite(b)) return Number(Number.isFinite(a)) - Number(Number.isFinite(b));
|
|
43
|
-
return a - b || left.id.localeCompare(right.id);
|
|
43
|
+
return a - b || (left.kind === "research" && right.kind === "research" ? (left.sequence ?? 0) - (right.sequence ?? 0) : 0) || left.id.localeCompare(right.id);
|
|
44
44
|
};
|
|
45
45
|
const missing = (error) => error.code === "ENOENT" || error.code === "ENOTDIR";
|
|
46
46
|
const identity = (record) =>
|
|
@@ -140,7 +140,29 @@ async function readVerifiedFile(handle, stat, digest, expectedSize, offset = 0,
|
|
|
140
140
|
}
|
|
141
141
|
if (hash.digest("hex") !== digest ||
|
|
142
142
|
fileStatSignature(await handle.stat({ bigint: true })) !== fileStatSignature(stat)) return;
|
|
143
|
-
return {
|
|
143
|
+
return { content, total };
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** The caller supplies up to three lookahead bytes to finish a UTF-8 character. */
|
|
147
|
+
export function utf8FilePage(bytes, limit) {
|
|
148
|
+
let end = Math.min(bytes.length, limit);
|
|
149
|
+
const continuation = byte => (byte & 0xc0) === 0x80;
|
|
150
|
+
if (end < bytes.length && continuation(bytes[end])) {
|
|
151
|
+
let start = end;
|
|
152
|
+
while (start > Math.max(0, end - 3) && continuation(bytes[start])) start--;
|
|
153
|
+
const lead = bytes[start];
|
|
154
|
+
const width = lead >= 0xc2 && lead <= 0xdf ? 2
|
|
155
|
+
: lead >= 0xe0 && lead <= 0xef ? 3
|
|
156
|
+
: lead >= 0xf0 && lead <= 0xf4 ? 4 : 0;
|
|
157
|
+
if (start < end && start + width > end && start + width <= bytes.length &&
|
|
158
|
+
bytes.subarray(start + 1, start + width).every(continuation)) {
|
|
159
|
+
end = start || width;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return {
|
|
163
|
+
text: new TextDecoder("utf-8", { ignoreBOM: true }).decode(bytes.subarray(0, end)),
|
|
164
|
+
bytesRead: end,
|
|
165
|
+
};
|
|
144
166
|
}
|
|
145
167
|
|
|
146
168
|
function fileSourceIdentity(path, stat) {
|
|
@@ -216,6 +238,48 @@ async function readJSON(root, path) {
|
|
|
216
238
|
}
|
|
217
239
|
}
|
|
218
240
|
|
|
241
|
+
function validProjectReport(report, directory) {
|
|
242
|
+
return report && report.runId === basename(directory) &&
|
|
243
|
+
report.harness?.apiVersion === 1 && typeof report.harness.id === "string" &&
|
|
244
|
+
report.harness.id.length > 0 && ["completed", "failed", "cancelled"].includes(report.outcome);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
function projectRuntimeId(report) {
|
|
248
|
+
const values = [report.result?.runtimeId, report.cleanup?.receipt?.runtimeId]
|
|
249
|
+
.filter(value => value !== undefined);
|
|
250
|
+
if (!values.length || values.some(value => typeof value !== "string" || !value)) return undefined;
|
|
251
|
+
return new Set(values).size === 1 ? values[0] : undefined;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
function projectSummary({ id, report, linkedRuntime, runtimeGap }) {
|
|
255
|
+
const result = report.result;
|
|
256
|
+
const output = typeof result?.business === "string" ? result.business : result?.business?.output;
|
|
257
|
+
const cleanup = ["complete", "pending"].includes(report.cleanup?.status) ? report.cleanup.status : "unknown";
|
|
258
|
+
return {
|
|
259
|
+
id, kind: "harness", runId: report.runId, harness: report.harness.id,
|
|
260
|
+
label: report.harness.id, status: report.outcome, cleanup,
|
|
261
|
+
outcome: {
|
|
262
|
+
status: report.outcome, report: "project-run.json",
|
|
263
|
+
...(typeof report.reason === "string" ? { reason: report.reason } : {}),
|
|
264
|
+
...(Object.hasOwn(report, "result") ? { result } : {}),
|
|
265
|
+
...(Object.hasOwn(report, "failure") ? { failure: report.failure } : {}),
|
|
266
|
+
...(Object.hasOwn(report, "artifacts") ? { artifacts: report.artifacts } : {}),
|
|
267
|
+
...(typeof output === "string" ? { output } : {}),
|
|
268
|
+
},
|
|
269
|
+
export: report.export ?? { status: "not-recorded" },
|
|
270
|
+
verification: {
|
|
271
|
+
artifactVerification: result?.artifactVerification ?? result?.report?.artifactVerification ?? { status: "not-recorded" },
|
|
272
|
+
acceptance: report.acceptance ?? { status: "not-recorded" },
|
|
273
|
+
},
|
|
274
|
+
pendingResources: report.cleanup,
|
|
275
|
+
...(linkedRuntime ? { linkedRuntime } : {}),
|
|
276
|
+
files: [{ path: "project-run.json", kind: "harness", label: "Harness Run report" }],
|
|
277
|
+
// Empty evidence collections preserve API compatibility, not zero-runtime metrics.
|
|
278
|
+
agents: [], members: [], spans: [], points: [], relations: [], serviceStates: [],
|
|
279
|
+
gaps: linkedRuntime ? [] : [{ kind: "runtime-not-associated", message: runtimeGap }],
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
|
|
219
283
|
async function readProjectOutcome(root, runtimeDirectory, runtimeId) {
|
|
220
284
|
const projectDirectory = dirname(runtimeDirectory);
|
|
221
285
|
if (!inside(root, projectDirectory) || typeof runtimeId !== "string")
|
|
@@ -230,13 +294,9 @@ async function readProjectOutcome(root, runtimeDirectory, runtimeId) {
|
|
|
230
294
|
return undefined;
|
|
231
295
|
throw error;
|
|
232
296
|
}
|
|
233
|
-
if (!report
|
|
234
|
-
report.harness?.apiVersion !== 1 ||
|
|
235
|
-
!["completed", "failed", "cancelled"].includes(report.outcome))
|
|
236
|
-
return undefined;
|
|
297
|
+
if (!validProjectReport(report, projectDirectory)) return undefined;
|
|
237
298
|
const result = report.result;
|
|
238
|
-
|
|
239
|
-
if ((result?.runtimeId ?? receipt?.runtimeId) !== runtimeId) return undefined;
|
|
299
|
+
if (projectRuntimeId(report) !== runtimeId) return undefined;
|
|
240
300
|
|
|
241
301
|
const output = typeof result?.business === "string" ? result.business : result?.business?.output;
|
|
242
302
|
const businessFailure = result?.businessFailure?.message ?? report.failure?.message;
|
|
@@ -249,6 +309,10 @@ async function readProjectOutcome(root, runtimeDirectory, runtimeId) {
|
|
|
249
309
|
outcome: {
|
|
250
310
|
status: report.outcome,
|
|
251
311
|
report: name,
|
|
312
|
+
...(typeof report.reason === "string" ? { reason: report.reason } : {}),
|
|
313
|
+
...(Object.hasOwn(report, "result") ? { result } : {}),
|
|
314
|
+
...(Object.hasOwn(report, "failure") ? { failure: report.failure } : {}),
|
|
315
|
+
...(Object.hasOwn(report, "artifacts") ? { artifacts: report.artifacts } : {}),
|
|
252
316
|
...(typeof output === "string" ? { output: output.slice(0, 4000) } : {}),
|
|
253
317
|
...(typeof businessFailure === "string" ? { businessFailure: businessFailure.slice(0, 1000) } : {}),
|
|
254
318
|
...(["complete", "pending"].includes(cleanup) ? { cleanup } : {}),
|
|
@@ -368,6 +432,7 @@ class RunIndex {
|
|
|
368
432
|
this.gapKeys = new Set();
|
|
369
433
|
this.spans = [];
|
|
370
434
|
this.researchPoints = [];
|
|
435
|
+
this.researchCandidates = new Map();
|
|
371
436
|
this.inputObservations = [];
|
|
372
437
|
this.sessionToolResults = [];
|
|
373
438
|
this.relations = [];
|
|
@@ -523,11 +588,23 @@ class RunIndex {
|
|
|
523
588
|
if (kind === "research") {
|
|
524
589
|
if (agent && record.operation === "peer.ready" && typeof record.label === "string")
|
|
525
590
|
agent.label = searchName(record.label) ?? agent.label;
|
|
591
|
+
const sha256 = recordedSha256(record.sha256);
|
|
592
|
+
const candidate = typeof record.candidate === "string" && /^candidate-[1-9][0-9]*$/.test(record.candidate) ? record.candidate : undefined;
|
|
593
|
+
const basedOn = typeof record.basedOn === "string" && /^candidate-[1-9][0-9]*$/.test(record.basedOn) ? record.basedOn : undefined;
|
|
594
|
+
const sequence = Number.isSafeInteger(record.seq) ? record.seq : undefined;
|
|
595
|
+
Object.assign(event, { candidate, sha256, basedOn, basedOnSha256: recordedSha256(record.basedOnSha256), sequence });
|
|
596
|
+
if (/\.(?:unknown|failed)$/.test(record.operation ?? "")) event.status = "failed";
|
|
597
|
+
if (candidate && sha256 && ["candidate.queued", "candidate.built-on"].includes(record.operation) &&
|
|
598
|
+
Number.isSafeInteger(record.bytes) && record.bytes > 0 && record.bytes <= 1024 * 1024) {
|
|
599
|
+
this.researchCandidates.set(candidate, {
|
|
600
|
+
path: `candidates/${candidate}.patch`, kind: "artifact", bytes: record.bytes, sha256, agentId,
|
|
601
|
+
});
|
|
602
|
+
}
|
|
526
603
|
this.researchPoints.push({
|
|
527
|
-
id: event.id, agentId, kind, label: event.label, time: event.time,
|
|
528
|
-
detail: [
|
|
604
|
+
id: event.id, agentId, kind, label: event.label, time: event.time, sequence,
|
|
605
|
+
detail: [candidate, sha256, basedOn, record.basedOnSha256, record.detail, typeof record.score === "number" ? String(record.score) : undefined]
|
|
529
606
|
.filter(value => typeof value === "string").join(" · ").slice(0, 540),
|
|
530
|
-
status:
|
|
607
|
+
status: event.status, evidenceIds: [event.id],
|
|
531
608
|
});
|
|
532
609
|
}
|
|
533
610
|
if (record.type === "spawn" && agent) {
|
|
@@ -1105,7 +1182,8 @@ class RunIndex {
|
|
|
1105
1182
|
const report = await readJSON(this.path, "runtime.json");
|
|
1106
1183
|
if (!report) throw failure("Run runtime.json is missing", 404);
|
|
1107
1184
|
this.report = report;
|
|
1108
|
-
this.project =
|
|
1185
|
+
this.project = this.projectAllowed === false ? undefined :
|
|
1186
|
+
await readProjectOutcome(this.root, this.path, report.runtimeId);
|
|
1109
1187
|
const schema = report.config?.schemaVersion ?? report.schemaVersion ?? 1;
|
|
1110
1188
|
if (schema !== 1)
|
|
1111
1189
|
this.gap(
|
|
@@ -1171,6 +1249,7 @@ class RunIndex {
|
|
|
1171
1249
|
for (const [path, file] of this.files) {
|
|
1172
1250
|
if (file.kind === "artifact" || file.kind === "session") this.files.delete(path);
|
|
1173
1251
|
}
|
|
1252
|
+
for (const file of this.researchCandidates.values()) this.files.set(file.path, { ...file });
|
|
1174
1253
|
for (const agent of this.agents.values()) {
|
|
1175
1254
|
for (const kind of ["session", "artifacts"]) {
|
|
1176
1255
|
const manifestPath = `${agent.id}/${kind}/manifest.json`;
|
|
@@ -1358,7 +1437,7 @@ class RunIndex {
|
|
|
1358
1437
|
return [event.label, event.kind, event.type, event.agentId, agent?.label,
|
|
1359
1438
|
agent?.profile, event.requestId, event.inputId, event.operationId,
|
|
1360
1439
|
event.service && `${event.service}.${event.operation ?? ""}`,
|
|
1361
|
-
event.toolName, event.model]
|
|
1440
|
+
event.toolName, event.model, event.candidate, event.sha256, event.basedOn, event.basedOnSha256]
|
|
1362
1441
|
.map((value) => searchName(value) ?? "").join(" ").toLowerCase().includes(needle);
|
|
1363
1442
|
};
|
|
1364
1443
|
}
|
|
@@ -1604,21 +1683,62 @@ class RunIndex {
|
|
|
1604
1683
|
}
|
|
1605
1684
|
|
|
1606
1685
|
export async function createTraceReader({ root }) {
|
|
1607
|
-
const
|
|
1686
|
+
const requestedRoot = resolve(root);
|
|
1687
|
+
let rootPath = requestedRoot;
|
|
1688
|
+
let rootStatus = "missing";
|
|
1608
1689
|
const runs = new Map();
|
|
1690
|
+
const reports = new Map();
|
|
1691
|
+
const reportDirectories = new Map();
|
|
1609
1692
|
const indexes = new Map();
|
|
1610
|
-
|
|
1693
|
+
let discovery;
|
|
1694
|
+
async function scan() {
|
|
1695
|
+
try {
|
|
1696
|
+
const canonical = await realpath(requestedRoot);
|
|
1697
|
+
if (!(await lstat(canonical)).isDirectory()) throw failure("Trace root must be a directory");
|
|
1698
|
+
if (canonical !== rootPath) indexes.clear();
|
|
1699
|
+
rootPath = canonical;
|
|
1700
|
+
rootStatus = "ready";
|
|
1701
|
+
} catch (error) {
|
|
1702
|
+
if (error.code === "ENOENT") {
|
|
1703
|
+
rootPath = requestedRoot;
|
|
1704
|
+
rootStatus = "missing";
|
|
1705
|
+
runs.clear(); reports.clear(); reportDirectories.clear(); indexes.clear();
|
|
1706
|
+
return;
|
|
1707
|
+
}
|
|
1708
|
+
if (["EACCES", "EPERM"].includes(error.code)) throw failure("Cannot read the Trace root: " + requestedRoot, 403);
|
|
1709
|
+
throw error;
|
|
1710
|
+
}
|
|
1611
1711
|
const found = new Map();
|
|
1712
|
+
const foundReports = new Map();
|
|
1612
1713
|
async function visit(path, depth) {
|
|
1613
|
-
if (depth > 5 || found.size >= 10000) return;
|
|
1714
|
+
if (depth > 5 || found.size + foundReports.size >= 10000) return;
|
|
1614
1715
|
let entries;
|
|
1615
1716
|
try {
|
|
1616
1717
|
entries = await readdir(path, { withFileTypes: true });
|
|
1617
1718
|
} catch (error) {
|
|
1719
|
+
if (path === rootPath) {
|
|
1720
|
+
if (missing(error)) { rootStatus = "missing"; return; }
|
|
1721
|
+
if (["EACCES", "EPERM"].includes(error.code)) throw failure("Cannot read the Trace root: " + rootPath, 403);
|
|
1722
|
+
}
|
|
1618
1723
|
if (missing(error) || ["EACCES", "EPERM"].includes(error.code)) return;
|
|
1619
1724
|
throw error;
|
|
1620
1725
|
}
|
|
1726
|
+
if (entries.some(entry => entry.name === "project-run.json" && entry.isFile())) {
|
|
1727
|
+
try {
|
|
1728
|
+
const report = await readJSON(rootPath, relative(rootPath, join(path, "project-run.json")));
|
|
1729
|
+
if (validProjectReport(report, path)) {
|
|
1730
|
+
// Runtime IDs remain relative paths. A leading slash makes this new
|
|
1731
|
+
// report namespace unambiguous even when names overlap below a root.
|
|
1732
|
+
const location = relative(rootPath, path).split(sep).join("/");
|
|
1733
|
+
const id = location ? "/harness/" + location : "/harness";
|
|
1734
|
+
foundReports.set(id, { id, path, report });
|
|
1735
|
+
}
|
|
1736
|
+
} catch (error) {
|
|
1737
|
+
if (!(error instanceof SyntaxError) && !error.status && !["EACCES", "EPERM"].includes(error.code)) throw error;
|
|
1738
|
+
}
|
|
1739
|
+
}
|
|
1621
1740
|
if (
|
|
1741
|
+
found.size + foundReports.size < 10000 &&
|
|
1622
1742
|
entries.some((entry) => entry.name === "runtime.json" && entry.isFile())
|
|
1623
1743
|
) {
|
|
1624
1744
|
found.set(
|
|
@@ -1639,21 +1759,71 @@ export async function createTraceReader({ root }) {
|
|
|
1639
1759
|
}
|
|
1640
1760
|
}
|
|
1641
1761
|
await visit(rootPath, 0);
|
|
1762
|
+
const runtimeIds = new Map();
|
|
1763
|
+
for (const [id, path] of found) {
|
|
1764
|
+
try {
|
|
1765
|
+
const runtimeId = (await readJSON(path, "runtime.json"))?.runtimeId;
|
|
1766
|
+
if (typeof runtimeId === "string") {
|
|
1767
|
+
if (!runtimeIds.has(runtimeId)) runtimeIds.set(runtimeId, []);
|
|
1768
|
+
runtimeIds.get(runtimeId).push({ id, runtimeId, path });
|
|
1769
|
+
}
|
|
1770
|
+
} catch {
|
|
1771
|
+
// Runtime list entries retain their own unreadable status below.
|
|
1772
|
+
}
|
|
1773
|
+
}
|
|
1774
|
+
for (const entry of foundReports.values()) {
|
|
1775
|
+
const runtimeId = projectRuntimeId(entry.report);
|
|
1776
|
+
const matches = runtimeIds.get(runtimeId);
|
|
1777
|
+
if (matches?.length === 1 && dirname(matches[0].path) === entry.path) {
|
|
1778
|
+
const { id, runtimeId } = matches[0];
|
|
1779
|
+
entry.linkedRuntime = { id, runtimeId };
|
|
1780
|
+
} else if (!runtimeId) {
|
|
1781
|
+
const hasIdentity = entry.report.result?.runtimeId !== undefined || entry.report.cleanup?.receipt?.runtimeId !== undefined;
|
|
1782
|
+
entry.runtimeGap = hasIdentity
|
|
1783
|
+
? "The Harness report contains invalid or conflicting Runtime identities"
|
|
1784
|
+
: "No Runtime identity was recorded in this Harness report";
|
|
1785
|
+
} else if (matches?.length > 1) {
|
|
1786
|
+
entry.runtimeGap = "Multiple Runtime records share the identity recorded in this Harness report";
|
|
1787
|
+
} else if (matches?.length === 1) {
|
|
1788
|
+
entry.runtimeGap = "The matching Runtime is not recorded directly under this Harness Run";
|
|
1789
|
+
} else {
|
|
1790
|
+
entry.runtimeGap = "No Runtime record found for the identity recorded in this Harness report";
|
|
1791
|
+
}
|
|
1792
|
+
}
|
|
1642
1793
|
runs.clear();
|
|
1643
1794
|
for (const [id, path] of found) runs.set(id, path);
|
|
1795
|
+
reports.clear(); reportDirectories.clear();
|
|
1796
|
+
for (const [id, entry] of foundReports) {
|
|
1797
|
+
reports.set(id, entry);
|
|
1798
|
+
reportDirectories.set(entry.path, entry);
|
|
1799
|
+
}
|
|
1800
|
+
}
|
|
1801
|
+
function discover() {
|
|
1802
|
+
if (!discovery) discovery = scan().finally(() => { discovery = undefined; });
|
|
1803
|
+
return discovery;
|
|
1644
1804
|
}
|
|
1645
1805
|
await discover();
|
|
1646
|
-
async function index(id) {
|
|
1647
|
-
if (!runs.has(id)) await discover();
|
|
1806
|
+
async function index(id, refreshDiscovery = false) {
|
|
1807
|
+
if (refreshDiscovery || reports.has(id) || !runs.has(id)) await discover();
|
|
1808
|
+
const project = reports.get(id);
|
|
1809
|
+
if (project) return {
|
|
1810
|
+
kind: "harness", path: project.path,
|
|
1811
|
+
summary: () => projectSummary(project),
|
|
1812
|
+
files: new Map([["project-run.json", { path: "project-run.json", kind: "harness" }]]),
|
|
1813
|
+
sources: new Map(),
|
|
1814
|
+
};
|
|
1648
1815
|
const path = runs.get(id);
|
|
1649
1816
|
if (!path)
|
|
1650
1817
|
throw failure("Run was not found under the configured root", 404);
|
|
1651
1818
|
if (!indexes.has(id)) indexes.set(id, new RunIndex(path, id, rootPath));
|
|
1652
1819
|
const current = indexes.get(id);
|
|
1820
|
+
current.projectAllowed = reportDirectories.get(dirname(path))?.linkedRuntime?.id === id;
|
|
1653
1821
|
await current.update();
|
|
1654
1822
|
return current;
|
|
1655
1823
|
}
|
|
1656
1824
|
return {
|
|
1825
|
+
get root() { return rootPath; },
|
|
1826
|
+
get rootStatus() { return rootStatus; },
|
|
1657
1827
|
async listRuns() {
|
|
1658
1828
|
await discover();
|
|
1659
1829
|
const result = [];
|
|
@@ -1675,16 +1845,35 @@ export async function createTraceReader({ root }) {
|
|
|
1675
1845
|
result.push({ id, status: "unreadable", error: error.message });
|
|
1676
1846
|
}
|
|
1677
1847
|
}
|
|
1848
|
+
for (const { id, report, linkedRuntime } of reports.values()) {
|
|
1849
|
+
if (linkedRuntime) continue;
|
|
1850
|
+
result.push({
|
|
1851
|
+
id, kind: "harness", runId: report.runId, harness: report.harness.id,
|
|
1852
|
+
label: report.harness.id, status: report.outcome,
|
|
1853
|
+
cleanup: ["complete", "pending"].includes(report.cleanup?.status) ? report.cleanup.status : "unknown",
|
|
1854
|
+
});
|
|
1855
|
+
}
|
|
1678
1856
|
return result;
|
|
1679
1857
|
},
|
|
1680
1858
|
async summary(id) {
|
|
1681
|
-
return (await index(id)).summary();
|
|
1859
|
+
return (await index(id, true)).summary();
|
|
1682
1860
|
},
|
|
1683
1861
|
async timeline(id, options = {}) {
|
|
1684
|
-
|
|
1862
|
+
const current = await index(id);
|
|
1863
|
+
if (current.kind !== "harness") return current.timeline(options);
|
|
1864
|
+
if (options.focus) throw failure("Record was not found", 404);
|
|
1865
|
+
for (const value of [options.from, options.to]) {
|
|
1866
|
+
if (value !== undefined && !Number.isSafeInteger(value)) throw failure("Invalid timeline time");
|
|
1867
|
+
}
|
|
1868
|
+
if (options.from !== undefined && options.to !== undefined && options.from > options.to) throw failure("Invalid timeline range");
|
|
1869
|
+
return { spans: [], points: [], total: 0, truncated: false, from: options.from ?? null, to: options.to ?? null };
|
|
1685
1870
|
},
|
|
1686
1871
|
async events(id, { cursor, limit = 1000, agentId, memberId, type, query, attention = false } = {}) {
|
|
1687
1872
|
const current = await index(id);
|
|
1873
|
+
if (current.kind === "harness") {
|
|
1874
|
+
if (cursor !== "latest") decodeCursor(cursor);
|
|
1875
|
+
return { events: [], cursor: encodeCursor({}), hasMore: false, total: 0, runTotal: 0 };
|
|
1876
|
+
}
|
|
1688
1877
|
const filter = current.eventFilter({ agentId, type, query });
|
|
1689
1878
|
const matches = event => filter(event) && (!attention || needsAttention(event)) &&
|
|
1690
1879
|
(!memberId || current.agents.get(event.agentId)?.memberId === memberId);
|
|
@@ -1755,6 +1944,7 @@ export async function createTraceReader({ root }) {
|
|
|
1755
1944
|
},
|
|
1756
1945
|
async detail(id, eventId, { identity: expectedIdentity } = {}) {
|
|
1757
1946
|
const current = await index(id);
|
|
1947
|
+
if (current.kind === "harness") throw failure("Record was not found", 404);
|
|
1758
1948
|
const relation = current.relations.find((item) => item.id === eventId);
|
|
1759
1949
|
if (relation?.explicit) return { relation };
|
|
1760
1950
|
const event = current.byId.get(eventId);
|
|
@@ -1785,6 +1975,30 @@ export async function createTraceReader({ root }) {
|
|
|
1785
1975
|
}
|
|
1786
1976
|
const files = [];
|
|
1787
1977
|
const contextMatches = [];
|
|
1978
|
+
let research;
|
|
1979
|
+
if (event.kind === "research") {
|
|
1980
|
+
const versions = new Map([[event.candidate, event.sha256], [event.basedOn, event.basedOnSha256]]
|
|
1981
|
+
.filter(([candidate, hash]) => candidate && hash));
|
|
1982
|
+
const matches = [...current.byId.values()].filter(entry => entry.kind === "research" && entry.id !== event.id &&
|
|
1983
|
+
(versions.has(entry.candidate) && versions.get(entry.candidate) === entry.sha256 ||
|
|
1984
|
+
versions.has(entry.basedOn) && versions.get(entry.basedOn) === entry.basedOnSha256));
|
|
1985
|
+
const candidateEvidence = entry => versions.has(entry.candidate) &&
|
|
1986
|
+
versions.get(entry.candidate) === entry.sha256 && /^(?:candidate|train|final)\./.test(entry.operation);
|
|
1987
|
+
const related = [
|
|
1988
|
+
...matches.filter(candidateEvidence).sort(compareTimeline),
|
|
1989
|
+
...matches.filter(entry => !candidateEvidence(entry)).sort(compareTimeline),
|
|
1990
|
+
].slice(0, 100).sort(compareTimeline);
|
|
1991
|
+
const checked = [];
|
|
1992
|
+
for (const [candidate, sha256] of versions) {
|
|
1993
|
+
const file = current.researchCandidates.get(candidate);
|
|
1994
|
+
const status = file?.sha256 === sha256 ? await current.archivedFileStatus(file, sha256) : "record-mismatch";
|
|
1995
|
+
const entry = { path: file?.path ?? `candidates/${candidate}.patch`, sha256, status,
|
|
1996
|
+
...(status === "verified" ? { identity: `sha256:${sha256}` } : {}) };
|
|
1997
|
+
if (status === "verified") files.push(entry);
|
|
1998
|
+
checked.push(entry);
|
|
1999
|
+
}
|
|
2000
|
+
research = { related, relatedTotal: matches.length, files: checked };
|
|
2001
|
+
}
|
|
1788
2002
|
if (relation?.messageId && relation.toAgentId) {
|
|
1789
2003
|
for (const model of current.modelDirectories.values()) {
|
|
1790
2004
|
if (model.event.agentId !== relation.toAgentId) continue;
|
|
@@ -1852,6 +2066,7 @@ export async function createTraceReader({ root }) {
|
|
|
1852
2066
|
serviceStates: current.serviceStates.filter(snapshot => snapshot.serviceId === (record.service ?? record.serviceId)),
|
|
1853
2067
|
} : {}),
|
|
1854
2068
|
contextMatches,
|
|
2069
|
+
...(research ? { research } : {}),
|
|
1855
2070
|
truncated: event.source.length > maxBodyBytes,
|
|
1856
2071
|
};
|
|
1857
2072
|
},
|
|
@@ -1904,28 +2119,29 @@ export async function createTraceReader({ root }) {
|
|
|
1904
2119
|
throw failure("Shared file source was replaced", 409);
|
|
1905
2120
|
}
|
|
1906
2121
|
if (digest) {
|
|
1907
|
-
data = await readVerifiedFile(handle, stat, digest, recorded.bytes, offset, limit);
|
|
2122
|
+
data = await readVerifiedFile(handle, stat, digest, recorded.bytes, offset, limit + 3);
|
|
1908
2123
|
if (!data) throw failure("Archived file version changed", 409);
|
|
1909
2124
|
} else {
|
|
1910
2125
|
const total = Number(stat.size);
|
|
1911
|
-
const buffer = Buffer.alloc(Math.max(0, Math.min(limit, total - offset)));
|
|
2126
|
+
const buffer = Buffer.alloc(Math.max(0, Math.min(limit + 3, total - offset)));
|
|
1912
2127
|
const { bytesRead } = await handle.read(buffer, 0, buffer.length, offset);
|
|
1913
2128
|
if (fileStatSignature(await handle.stat({ bigint: true })) !== fileStatSignature(stat)) {
|
|
1914
2129
|
throw failure("File source changed while being read", 409);
|
|
1915
2130
|
}
|
|
1916
|
-
data = {
|
|
2131
|
+
data = { content: buffer.subarray(0, bytesRead), total };
|
|
1917
2132
|
}
|
|
1918
2133
|
} finally {
|
|
1919
2134
|
await handle.close();
|
|
1920
2135
|
}
|
|
2136
|
+
const { text, bytesRead } = utf8FilePage(data.content, limit);
|
|
1921
2137
|
return {
|
|
1922
2138
|
path,
|
|
1923
2139
|
identity: fileIdentity,
|
|
1924
|
-
text
|
|
2140
|
+
text,
|
|
1925
2141
|
offset,
|
|
1926
|
-
nextOffset: offset +
|
|
2142
|
+
nextOffset: offset + bytesRead,
|
|
1927
2143
|
total: data.total,
|
|
1928
|
-
truncated: offset +
|
|
2144
|
+
truncated: offset + bytesRead < data.total,
|
|
1929
2145
|
};
|
|
1930
2146
|
},
|
|
1931
2147
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function defaultRunRoot(env?: NodeJS.ProcessEnv, home?: string): string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { homedir } from 'node:os';
|
|
2
|
+
import { join, resolve } from 'node:path';
|
|
3
|
+
|
|
4
|
+
/** The shared default; a Harness can still select a private fallback outside its input. */
|
|
5
|
+
export function defaultRunRoot(env = process.env, home = homedir()) {
|
|
6
|
+
return resolve(env.XDG_STATE_HOME || join(home, '.local', 'state'), 'anyswarm', 'runs');
|
|
7
|
+
}
|
|
@@ -124,7 +124,8 @@ async function route(request, response, reader) {
|
|
|
124
124
|
}
|
|
125
125
|
const { pathname, searchParams } = new URL(request.url, 'http://' + loopback);
|
|
126
126
|
if (pathname === '/api/runs') {
|
|
127
|
-
|
|
127
|
+
const runs = await reader.listRuns();
|
|
128
|
+
return json(response, 200, { runs, root: reader.root, rootStatus: reader.rootStatus });
|
|
128
129
|
}
|
|
129
130
|
if (!pathname.startsWith('/api/')) return staticAsset(pathname, response);
|
|
130
131
|
const match = /^\/api\/runs\/([^/]+)(?:\/(events|timeline|records|files|live)(?:\/([^/]+))?)?$/.exec(pathname);
|
|
@@ -183,6 +184,7 @@ export async function startTraceServer({ root, port = 8787 }) {
|
|
|
183
184
|
});
|
|
184
185
|
return {
|
|
185
186
|
url: 'http://' + loopback + ':' + server.address().port,
|
|
187
|
+
get root() { return reader.root; },
|
|
186
188
|
close: () => new Promise((resolve, reject) => {
|
|
187
189
|
server.close(error => error ? reject(error) : resolve());
|
|
188
190
|
server.closeAllConnections();
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { HarnessSession } from '../src/harness/project-harness.js';
|
|
2
|
-
export interface ApplicationObservation {
|
|
3
|
-
session: HarnessSession;
|
|
4
|
-
/** Local records owned by the observed application. */
|
|
5
|
-
traceRoot?: string;
|
|
6
|
-
/** Disconnects the observer while the application retains background ownership. */
|
|
7
|
-
close(): void | Promise<void>;
|
|
8
|
-
}
|
|
9
|
-
export interface ApplicationDescriptor {
|
|
10
|
-
id: string;
|
|
11
|
-
title: string;
|
|
12
|
-
harness: string;
|
|
13
|
-
lifetime: 'task' | 'interactive';
|
|
14
|
-
available: boolean;
|
|
15
|
-
}
|
|
16
|
-
export declare function applicationDescriptors(): readonly ApplicationDescriptor[];
|
|
17
|
-
export declare function findApplication(id: string): ApplicationDescriptor | undefined;
|
|
18
|
-
export declare const applicationAliases: ("autoresearch" | "code" | "super")[];
|
|
19
|
-
export declare function preferredTerminalLifetime(id: string): "interactive" | "task" | undefined;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { existsSync } from 'node:fs';
|
|
2
|
-
const applications = [
|
|
3
|
-
{ id: 'code', title: 'Code', lifetime: 'interactive' },
|
|
4
|
-
{ id: 'autoresearch', title: 'AutoResearch', lifetime: 'task' },
|
|
5
|
-
{ id: 'super', title: 'Personal', lifetime: 'interactive' },
|
|
6
|
-
];
|
|
7
|
-
export function applicationDescriptors() {
|
|
8
|
-
return applications.map(application => {
|
|
9
|
-
const entry = new URL(`../examples/${application.id}/project.js`, import.meta.url);
|
|
10
|
-
return { ...application, harness: entry.href, available: existsSync(entry) };
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
export function findApplication(id) {
|
|
14
|
-
return applicationDescriptors().find(application => application.id === id);
|
|
15
|
-
}
|
|
16
|
-
export const applicationAliases = applications.map(application => application.id);
|
|
17
|
-
export function preferredTerminalLifetime(id) {
|
|
18
|
-
return findApplication(id)?.lifetime ?? (id === 'subagents' ? 'interactive' : undefined);
|
|
19
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { runLocalCommand } from './local-setup.js';
|
|
2
|
-
export declare function terminalObject(value: unknown): Record<string, unknown>;
|
|
3
|
-
type ConfigurationChoice = {
|
|
4
|
-
path?: string;
|
|
5
|
-
source: string;
|
|
6
|
-
};
|
|
7
|
-
type Preference = {
|
|
8
|
-
version: 1;
|
|
9
|
-
harness: string;
|
|
10
|
-
configPath: string;
|
|
11
|
-
};
|
|
12
|
-
export declare class LauncherConfiguration {
|
|
13
|
-
readonly harness: string;
|
|
14
|
-
readonly specifier: string;
|
|
15
|
-
readonly launchDirectory: string;
|
|
16
|
-
readonly workspace: string;
|
|
17
|
-
readonly preferencePath: string;
|
|
18
|
-
readonly isBuiltin: boolean;
|
|
19
|
-
source: string;
|
|
20
|
-
path?: string;
|
|
21
|
-
preference?: Preference;
|
|
22
|
-
preferenceError?: string;
|
|
23
|
-
error?: string;
|
|
24
|
-
configuration?: Record<string, unknown>;
|
|
25
|
-
diagnostics?: Awaited<ReturnType<typeof runLocalCommand>>;
|
|
26
|
-
private choice?;
|
|
27
|
-
constructor(harness: string, specifier: string, launchDirectory: string, cwd?: string, path?: string, choice?: ConfigurationChoice);
|
|
28
|
-
selectedChoice(): ConfigurationChoice | undefined;
|
|
29
|
-
refresh(): Promise<void>;
|
|
30
|
-
private validateRuntime;
|
|
31
|
-
select(path: string): Promise<void>;
|
|
32
|
-
remember(): Promise<void>;
|
|
33
|
-
forget(): Promise<void>;
|
|
34
|
-
diagnose(prepare: boolean, signal: AbortSignal, progress: (message: string) => void, backend?: 'pi' | 'codex'): Promise<void>;
|
|
35
|
-
}
|
|
36
|
-
export {};
|