@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
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createHash, randomUUID } from 'node:crypto';
|
|
2
|
-
import {
|
|
2
|
+
import { constants } from 'node:fs';
|
|
3
|
+
import { mkdir, open, readFile, readdir, writeFile } from 'node:fs/promises';
|
|
3
4
|
import { join } from 'node:path';
|
|
4
5
|
import { setTimeout as delay } from 'node:timers/promises';
|
|
5
6
|
import { command, requireSuccess } from './process.js';
|
|
@@ -7,8 +8,31 @@ export const frontierRevision = '7e48965c7cef2a567c2669c8e2f10b06386289c9';
|
|
|
7
8
|
export const pumpkinPin = '2026-11-30 ca3ce7ae0da5616464b00ee7962aecac0fc0b38d a1bb9c633f1f700ea42bceb9cd9512f684e9063d3a8ae6c9485526a1dd68016f';
|
|
8
9
|
export const frontierTask = 'tasks/binary_fuse_filter/task.star';
|
|
9
10
|
export const submissionLimit = 1024 * 1024;
|
|
11
|
+
const officialJudgeSeconds = 180;
|
|
12
|
+
const grantCallTimeoutSeconds = 181;
|
|
10
13
|
export const judgeTimeMs = 190_000;
|
|
11
14
|
export const frontierFinalTimeMs = 250_000;
|
|
15
|
+
export async function preparePumpkin(source, cache, signal) {
|
|
16
|
+
await mkdir(cache, { recursive: true, mode: 0o700 });
|
|
17
|
+
// The pinned launcher extracts with the caller's umask. Only the bootstrap
|
|
18
|
+
// needs 022; prepare and the official evaluation keep the operator's umask.
|
|
19
|
+
requireSuccess(await command('/bin/sh', ['-c', 'umask 022; exec ./pumpkin --version'], {
|
|
20
|
+
cwd: source, env: { ...process.env, XDG_CACHE_HOME: cache }, timeoutMs: 240_000, signal,
|
|
21
|
+
}), 'Initialize pinned Pumpkin tools');
|
|
22
|
+
// Repair a cache populated by an earlier prepare under a restrictive umask.
|
|
23
|
+
const checksum = pumpkinPin.split(' ')[2];
|
|
24
|
+
const binary = await open(join(cache, 'pumpkin', checksum, 'bin', 'sandboxd'), constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
|
|
25
|
+
try {
|
|
26
|
+
const info = await binary.stat();
|
|
27
|
+
if (!info.isFile())
|
|
28
|
+
throw new Error('The pinned Pumpkin sandboxd is not a regular file');
|
|
29
|
+
if ((info.mode & 0o111) !== 0o111)
|
|
30
|
+
await binary.chmod((info.mode & 0o777) | 0o111);
|
|
31
|
+
}
|
|
32
|
+
finally {
|
|
33
|
+
await binary.close();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
12
36
|
export function digest(bytes) {
|
|
13
37
|
return createHash('sha256').update(bytes).digest('hex');
|
|
14
38
|
}
|
|
@@ -74,6 +98,8 @@ export class FrontierRun {
|
|
|
74
98
|
container;
|
|
75
99
|
imageId;
|
|
76
100
|
judges;
|
|
101
|
+
grants;
|
|
102
|
+
cleanupEvidence = { status: 'pending', runIds: [], pendingContainers: [] };
|
|
77
103
|
closed = false;
|
|
78
104
|
constructor(paths, runs) {
|
|
79
105
|
this.paths = paths;
|
|
@@ -86,7 +112,7 @@ export class FrontierRun {
|
|
|
86
112
|
return command('docker', ['--context', this.paths.dockerContext, ...args], { timeoutMs, signal, input });
|
|
87
113
|
}
|
|
88
114
|
get record() { return this.id ? join(this.runs, this.id) : undefined; }
|
|
89
|
-
async start(seconds, signal, timeoutMs = 360_000) {
|
|
115
|
+
async start(seconds, signal, timeoutMs = 360_000, maxEvaluations = 1) {
|
|
90
116
|
await mkdir(this.runs, { recursive: true, mode: 0o700 });
|
|
91
117
|
const start = await this.pumpkin(['run', frontierTask, '--arg', 'agent=anyswarm', '--arg', `deadline_seconds=${seconds}`,
|
|
92
118
|
'--config', this.paths.config, '--runs', this.runs], timeoutMs, signal);
|
|
@@ -112,11 +138,14 @@ export class FrontierRun {
|
|
|
112
138
|
const role = ir.roles?.find((role) => role.name === 'agent');
|
|
113
139
|
const grantTrain = role?.runtime?.agent?.grants?.find((grant) => grant.name === 'train');
|
|
114
140
|
const grantFinal = role?.runtime?.agent?.grants?.find((grant) => grant.name === 'final');
|
|
115
|
-
if (grantTrain?.job?.target !== 'train_judge' || !(grantTrain.job.calls >=
|
|
141
|
+
if (grantTrain?.job?.target !== 'train_judge' || !(grantTrain.job.calls >= maxEvaluations) ||
|
|
142
|
+
grantTrain.job.cumulative_seconds !== 12_000 || grantTrain.job.call_timeout_seconds !== grantCallTimeoutSeconds ||
|
|
116
143
|
grantTrain.job.payload_max_bytes !== submissionLimit || grantFinal?.now?.payload_max_bytes !== submissionLimit ||
|
|
117
144
|
grantFinal.now.body?.arguments?.finalize?.type !== 'bool' || ir.final?.target !== undefined && ir.final.target !== 'final_judge') {
|
|
118
|
-
throw new Error('The Pumpkin role does not
|
|
145
|
+
throw new Error('The Pumpkin role does not authorize the requested train budget or the pinned judge limits');
|
|
119
146
|
}
|
|
147
|
+
this.grants = { trainCalls: grantTrain.job.calls, trainCumulativeSeconds: grantTrain.job.cumulative_seconds,
|
|
148
|
+
judgeSeconds: officialJudgeSeconds, callTimeoutSeconds: grantTrain.job.call_timeout_seconds, maxBytes: grantTrain.job.payload_max_bytes };
|
|
120
149
|
const grants = await this.docker(['exec', this.container, '/bin/sh', '-eu', '-c',
|
|
121
150
|
'test -w /pumpkin; exec /.pumpkin/bin/sandboxctl ops'], 5_000, started);
|
|
122
151
|
const ops = JSON.parse(requireSuccess(grants, 'Check official Pumpkin grants and submission scratch space'));
|
|
@@ -148,8 +177,26 @@ export class FrontierRun {
|
|
|
148
177
|
const state = JSON.parse(reply.stdout);
|
|
149
178
|
if (state.kind !== 'status' || state.job !== job)
|
|
150
179
|
throw new Error('Official train status is unknown');
|
|
151
|
-
if (state.state === 'completed' && state.returned)
|
|
152
|
-
|
|
180
|
+
if (state.state === 'completed' && state.returned) {
|
|
181
|
+
const payload = { digest: `sha256:${digest(bytes)}`, size: bytes.byteLength };
|
|
182
|
+
// A score can be available while Pumpkin is still releasing the job's
|
|
183
|
+
// sandbox. The next admission is safe only after the recorded teardown.
|
|
184
|
+
while (true) {
|
|
185
|
+
const log = await readFile(join(this.record, 'log.jsonl'), { encoding: 'utf8', signal: deadline });
|
|
186
|
+
const lines = log.split('\n');
|
|
187
|
+
lines.pop(); // The last line may still be in flight.
|
|
188
|
+
const entries = lines.map(line => JSON.parse(line));
|
|
189
|
+
const action = entries.flatMap(entry => entry.actions ?? [])
|
|
190
|
+
.find(entry => entry.kind === 'start_call' && entry.grant === 'train' && entry.job === job);
|
|
191
|
+
if (action?.payload?.digest !== payload.digest || action.payload.size !== payload.size) {
|
|
192
|
+
throw new Error('Official train result does not match the submitted payload');
|
|
193
|
+
}
|
|
194
|
+
if (entries.some(({ event }) => event?.kind === 'call_torn_down' && event.job === job)) {
|
|
195
|
+
return { job, returned: state.returned, payload };
|
|
196
|
+
}
|
|
197
|
+
await delay(250, undefined, { signal: deadline });
|
|
198
|
+
}
|
|
199
|
+
}
|
|
153
200
|
if (state.state === 'errored')
|
|
154
201
|
throw new Error(`Official train job ${job} failed`);
|
|
155
202
|
if (state.state !== 'queued' && state.state !== 'running')
|
|
@@ -182,19 +229,29 @@ export class FrontierRun {
|
|
|
182
229
|
return { outcome, record };
|
|
183
230
|
}
|
|
184
231
|
async close() {
|
|
232
|
+
this.cleanupEvidence = { status: 'pending', runIds: [], pendingContainers: [] };
|
|
185
233
|
try {
|
|
186
|
-
const ids = this.id ? [this.id] : (await readdir(this.runs, { withFileTypes: true }).catch(
|
|
187
|
-
|
|
234
|
+
const ids = this.id ? [this.id] : (await readdir(this.runs, { withFileTypes: true }).catch(error => {
|
|
235
|
+
if (error.code === 'ENOENT')
|
|
236
|
+
return [];
|
|
237
|
+
throw error;
|
|
238
|
+
})).filter(entry => entry.isDirectory() && runId.test(entry.name)).map(entry => entry.name);
|
|
239
|
+
this.cleanupEvidence.runIds = ids;
|
|
240
|
+
let confirmed = true;
|
|
188
241
|
for (const id of ids) {
|
|
189
242
|
const finished = this.closed || await readFile(join(this.runs, id, 'outcome.json'), 'utf8')
|
|
190
243
|
.then(raw => JSON.parse(raw).state === 'finished').catch(() => false);
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
if (remaining
|
|
195
|
-
|
|
244
|
+
const cancelled = finished || (await this.pumpkin(['cancel', '--runs', this.runs, id], 20_000).catch(() => undefined))?.code === 0;
|
|
245
|
+
const remaining = await this.docker(['container', 'ls', '-a', '--no-trunc', '--filter', `label=pumpkin.run=${id}`, '--format', '{{.ID}}'], 5_000)
|
|
246
|
+
.catch(() => undefined);
|
|
247
|
+
if (!cancelled || remaining?.code !== 0)
|
|
248
|
+
confirmed = false;
|
|
249
|
+
if (remaining?.code === 0)
|
|
250
|
+
this.cleanupEvidence.pendingContainers.push(...remaining.stdout.trim().split('\n').filter(Boolean));
|
|
196
251
|
}
|
|
197
|
-
|
|
252
|
+
if (confirmed && !this.cleanupEvidence.pendingContainers.length)
|
|
253
|
+
this.cleanupEvidence.status = 'complete';
|
|
254
|
+
return this.cleanupEvidence.status;
|
|
198
255
|
}
|
|
199
256
|
catch {
|
|
200
257
|
return 'pending';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { resolve } from 'node:path';
|
|
2
|
+
import { pathToFileURL } from 'node:url';
|
|
3
|
+
import { parseArgs } from 'node:util';
|
|
4
|
+
import { prepareFrontier } from './prepare.js';
|
|
5
|
+
const controller = new AbortController();
|
|
6
|
+
const interrupt = (signal) => {
|
|
7
|
+
process.exitCode = signal === 'SIGINT' ? 130 : 143;
|
|
8
|
+
controller.abort();
|
|
9
|
+
};
|
|
10
|
+
process.on('SIGINT', interrupt).on('SIGTERM', interrupt);
|
|
11
|
+
try {
|
|
12
|
+
const { values } = parseArgs({ options: {
|
|
13
|
+
config: { type: 'string', default: './frontiercs2-config.ts' },
|
|
14
|
+
check: { type: 'boolean' },
|
|
15
|
+
help: { type: 'boolean' },
|
|
16
|
+
} });
|
|
17
|
+
if (values.help) {
|
|
18
|
+
console.log('Usage: anyswarm run ./prepare-demo.ts [--config ./frontiercs2-config.ts] [--check]');
|
|
19
|
+
console.log('Choose an executor with anyswarm setup, then set a model and a team budget in the shared configuration. --check reports prerequisites without preparing the pinned task or calling a model.');
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
const { default: configuration } = await import(pathToFileURL(resolve(values.config)).href);
|
|
23
|
+
if (!configuration?.frontierStateDir || !configuration.budget || !configuration.sandbox || !configuration.connection) {
|
|
24
|
+
throw new Error('The configuration must default-export frontierDemo({ model, budget, ... }). See frontiercs2-config.ts.');
|
|
25
|
+
}
|
|
26
|
+
const report = await prepareFrontier({ configuration, checkOnly: values.check, signal: controller.signal, progress: console.error });
|
|
27
|
+
for (const row of report.checks)
|
|
28
|
+
console.error(`${row.ok ? 'OK' : 'ACTION'} ${row.name}: ${row.detail}`);
|
|
29
|
+
console.error('Model inference was not attempted.');
|
|
30
|
+
if (report.ok && !values.check) {
|
|
31
|
+
console.error('Prepared. Use the same configuration with anyswarm run ./project.ts --config <your-config> --prompt "Run the FrontierCS-2 task." --output-dir ./runs');
|
|
32
|
+
}
|
|
33
|
+
console.log(JSON.stringify(report, null, 2));
|
|
34
|
+
process.exitCode ??= report.ok ? 0 : 2;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
if (!controller.signal.aborted) {
|
|
39
|
+
console.error(error instanceof Error ? error.message : 'Could not load the FrontierCS-2 configuration.');
|
|
40
|
+
console.error('Check the exported frontiercs2-config.ts and run anyswarm setup or anyswarm doctor for your backend.');
|
|
41
|
+
process.exitCode = 2;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
finally {
|
|
45
|
+
process.off('SIGINT', interrupt).off('SIGTERM', interrupt);
|
|
46
|
+
}
|
|
@@ -1,95 +1,147 @@
|
|
|
1
|
+
import type { ModelConfig, SandboxConfig } from '@anyswarm/core';
|
|
2
|
+
import type { FrontierConfiguration } from './demo.js';
|
|
1
3
|
import { type ResearchBudget } from './config.js';
|
|
2
4
|
import { type FrontierPaths, type JudgeImages } from './frontiercs2.js';
|
|
3
|
-
export declare function resourcePlan(budget: ResearchBudget): {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
export declare function resourcePlan(budget: ResearchBudget, sandbox: SandboxConfig): {
|
|
6
|
+
prepare: {
|
|
7
|
+
roles: {
|
|
8
|
+
role: string;
|
|
9
|
+
count: number;
|
|
10
|
+
cpu: number;
|
|
11
|
+
memoryGiB: number;
|
|
12
|
+
placement: string;
|
|
13
|
+
}[];
|
|
14
|
+
cpu: number;
|
|
15
|
+
memoryGiB: number;
|
|
16
|
+
diskGiB: number;
|
|
17
|
+
gpu: number;
|
|
18
|
+
};
|
|
19
|
+
run: {
|
|
20
|
+
roles: {
|
|
21
|
+
role: string;
|
|
22
|
+
count: number;
|
|
23
|
+
cpu: number;
|
|
24
|
+
memoryGiB: number;
|
|
25
|
+
placement: string;
|
|
26
|
+
}[];
|
|
7
27
|
cpu: number;
|
|
8
28
|
memoryGiB: number;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
gpu: number;
|
|
29
|
+
diskGiB: number;
|
|
30
|
+
gpu: number;
|
|
31
|
+
};
|
|
32
|
+
localWorkers: boolean;
|
|
14
33
|
};
|
|
15
34
|
export interface Check {
|
|
16
35
|
name: string;
|
|
17
36
|
ok: boolean;
|
|
18
37
|
detail: string;
|
|
19
38
|
}
|
|
20
|
-
export declare function
|
|
39
|
+
export declare function checkModelRoute(model: ModelConfig, executor: FrontierConfiguration['executor'], signal: AbortSignal): Promise<Check[]>;
|
|
40
|
+
interface Prepared {
|
|
41
|
+
version: 2;
|
|
42
|
+
revision: string;
|
|
43
|
+
pumpkin: string;
|
|
44
|
+
sourceDigest: string;
|
|
45
|
+
bridgeDigest: string;
|
|
46
|
+
bridgeImage: string;
|
|
47
|
+
judges: JudgeImages;
|
|
48
|
+
dockerContext: string;
|
|
49
|
+
referenceRecord: string;
|
|
50
|
+
}
|
|
51
|
+
export declare const starterPath: (home: string) => string;
|
|
21
52
|
export declare function loadPrepared(home?: string): Promise<{
|
|
22
|
-
saved:
|
|
23
|
-
version: 2;
|
|
24
|
-
revision: string;
|
|
25
|
-
pumpkin: string;
|
|
26
|
-
sourceDigest: string;
|
|
27
|
-
bridgeDigest: string;
|
|
28
|
-
bridgeImage: string;
|
|
29
|
-
judges: JudgeImages;
|
|
30
|
-
dockerContext: string;
|
|
31
|
-
referenceRecord: string;
|
|
32
|
-
budget: ResearchBudget;
|
|
33
|
-
};
|
|
53
|
+
saved: Prepared;
|
|
34
54
|
paths: FrontierPaths;
|
|
35
|
-
budget: ResearchBudget;
|
|
36
55
|
starter: string;
|
|
37
56
|
}>;
|
|
38
|
-
export declare function prepareFrontier({ signal, progress,
|
|
57
|
+
export declare function prepareFrontier({ signal, progress, configuration, checkOnly }: {
|
|
39
58
|
signal: AbortSignal;
|
|
40
59
|
progress: (message: string) => void;
|
|
41
|
-
|
|
60
|
+
configuration: FrontierConfiguration;
|
|
61
|
+
checkOnly?: boolean;
|
|
42
62
|
}): Promise<{
|
|
43
63
|
ok: boolean;
|
|
44
64
|
benchmark: string;
|
|
45
65
|
pumpkin: string;
|
|
46
66
|
budget: ResearchBudget;
|
|
47
67
|
resources: {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
68
|
+
prepare: {
|
|
69
|
+
roles: {
|
|
70
|
+
role: string;
|
|
71
|
+
count: number;
|
|
72
|
+
cpu: number;
|
|
73
|
+
memoryGiB: number;
|
|
74
|
+
placement: string;
|
|
75
|
+
}[];
|
|
51
76
|
cpu: number;
|
|
52
77
|
memoryGiB: number;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
78
|
+
diskGiB: number;
|
|
79
|
+
gpu: number;
|
|
80
|
+
};
|
|
81
|
+
run: {
|
|
82
|
+
roles: {
|
|
83
|
+
role: string;
|
|
84
|
+
count: number;
|
|
85
|
+
cpu: number;
|
|
86
|
+
memoryGiB: number;
|
|
87
|
+
placement: string;
|
|
88
|
+
}[];
|
|
89
|
+
cpu: number;
|
|
90
|
+
memoryGiB: number;
|
|
91
|
+
diskGiB: number;
|
|
92
|
+
gpu: number;
|
|
93
|
+
};
|
|
94
|
+
localWorkers: boolean;
|
|
58
95
|
};
|
|
59
96
|
checks: Check[];
|
|
60
97
|
home: string;
|
|
98
|
+
model: {
|
|
99
|
+
provider: string | null;
|
|
100
|
+
id: string | null;
|
|
101
|
+
};
|
|
61
102
|
modelInference: 'not-attempted';
|
|
62
103
|
} | {
|
|
63
104
|
benchmark: string;
|
|
64
105
|
pumpkin: string;
|
|
65
106
|
budget: ResearchBudget;
|
|
66
107
|
resources: {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
108
|
+
prepare: {
|
|
109
|
+
roles: {
|
|
110
|
+
role: string;
|
|
111
|
+
count: number;
|
|
112
|
+
cpu: number;
|
|
113
|
+
memoryGiB: number;
|
|
114
|
+
placement: string;
|
|
115
|
+
}[];
|
|
70
116
|
cpu: number;
|
|
71
117
|
memoryGiB: number;
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
118
|
+
diskGiB: number;
|
|
119
|
+
gpu: number;
|
|
120
|
+
};
|
|
121
|
+
run: {
|
|
122
|
+
roles: {
|
|
123
|
+
role: string;
|
|
124
|
+
count: number;
|
|
125
|
+
cpu: number;
|
|
126
|
+
memoryGiB: number;
|
|
127
|
+
placement: string;
|
|
128
|
+
}[];
|
|
129
|
+
cpu: number;
|
|
130
|
+
memoryGiB: number;
|
|
131
|
+
diskGiB: number;
|
|
132
|
+
gpu: number;
|
|
133
|
+
};
|
|
134
|
+
localWorkers: boolean;
|
|
77
135
|
};
|
|
78
136
|
checks: Check[];
|
|
79
137
|
home: string;
|
|
138
|
+
model: {
|
|
139
|
+
provider: string | null;
|
|
140
|
+
id: string | null;
|
|
141
|
+
};
|
|
80
142
|
modelInference: 'not-attempted';
|
|
81
143
|
ok: boolean;
|
|
82
144
|
reused: boolean;
|
|
83
|
-
prepared:
|
|
84
|
-
version: 2;
|
|
85
|
-
revision: string;
|
|
86
|
-
pumpkin: string;
|
|
87
|
-
sourceDigest: string;
|
|
88
|
-
bridgeDigest: string;
|
|
89
|
-
bridgeImage: string;
|
|
90
|
-
judges: JudgeImages;
|
|
91
|
-
dockerContext: string;
|
|
92
|
-
referenceRecord: string;
|
|
93
|
-
budget: ResearchBudget;
|
|
94
|
-
};
|
|
145
|
+
prepared: Prepared;
|
|
95
146
|
}>;
|
|
147
|
+
export {};
|