@anyswarm/core 0.5.1 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +1 -1
- package/README.md +13 -6
- package/dist/examples/README.md +16 -5
- package/dist/examples/authoring/README.md +4 -4
- package/dist/examples/autoresearch/README.md +15 -8
- package/dist/examples/autoresearch/REQUIREMENTS.zh.md +3 -10
- package/dist/examples/autoresearch/demo.js +1 -1
- 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 +3 -0
- package/dist/examples/autoresearch/prepare-demo.d.ts +1 -0
- package/dist/examples/autoresearch/prepare-demo.js +15 -0
- package/dist/examples/autoresearch/prepare.js +3 -3
- package/dist/examples/autoresearch/project.d.ts +0 -94
- package/dist/examples/autoresearch/project.js +2 -20
- package/dist/examples/code/README.md +25 -17
- package/dist/examples/code/REQUIREMENTS.zh.md +3 -3
- package/dist/examples/harness-session/README.md +3 -3
- package/dist/examples/messages/README.md +1 -1
- package/dist/examples/notes/README.md +3 -3
- package/dist/examples/services/mathlib-search/README.md +1 -1
- package/dist/examples/services/persistent-board/README.md +5 -2
- package/dist/examples/subagents/README.md +2 -2
- package/dist/examples/subagents/config.js +3 -3
- package/dist/examples/substrate/README.md +2 -2
- 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/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 +102 -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/local-environment.d.ts +10 -4
- package/dist/scripts/local-environment.js +67 -20
- package/dist/scripts/local-setup.d.ts +3 -0
- package/dist/scripts/local-setup.js +135 -107
- package/dist/scripts/pack-release.js +4 -1
- 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 +2 -2
- package/dist/src/harness/project-runtime.js +3 -1
- package/docs/INDEX.md +2 -1
- package/docs/architecture/04-services.md +1 -1
- package/docs/architecture/07-run-configuration.md +28 -14
- package/docs/architecture/12-code-coverage.md +56 -57
- package/docs/architecture/17-harness-reporting.md +1 -1
- package/docs/architecture/22-website.md +4 -7
- package/docs/architecture/23-project-harness.md +48 -23
- package/docs/architecture/26-code.md +20 -5
- package/docs/architecture/27-personal.md +23 -8
- package/docs/architecture/28-autoresearch.md +18 -6
- package/docs/architecture/INDEX.md +1 -2
- package/docs/architecture/prompts/source-manifest.json +5 -5
- package/docs/architecture/source-map.json +51 -71
- 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/build-your-harness.md +1 -1
- package/docs/en/changelog.md +7 -0
- package/docs/en/first-harness.md +6 -6
- package/docs/en/harnesses/lead-worker.md +1 -1
- package/docs/en/harnesses/peermesh.md +2 -2
- package/docs/en/harnesses/subagents.md +2 -2
- package/docs/en/harnesses/substrate.md +4 -4
- package/docs/en/harnesses/taskpool.md +2 -2
- package/docs/en/latest.md +9 -5
- package/docs/en/quickstart.md +20 -41
- 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/operations/trace-viewer.md +1 -1
- package/docs/third-party-notices.md +0 -1
- package/docs/workflows/development.md +14 -12
- package/docs/workflows/release-and-docs-versioning.md +13 -12
- package/docs/workflows/release-cli-acceptance.md +85 -0
- package/docs/zh/agents.md +1 -1
- package/docs/zh/build-your-harness.md +1 -1
- package/docs/zh/changelog.md +8 -1
- package/docs/zh/first-harness.md +7 -7
- package/docs/zh/harnesses/lead-worker.md +1 -1
- package/docs/zh/harnesses/peermesh.md +2 -2
- package/docs/zh/harnesses/subagents.md +2 -2
- package/docs/zh/harnesses/substrate.md +4 -4
- package/docs/zh/harnesses/taskpool.md +2 -2
- package/docs/zh/latest.md +9 -5
- package/docs/zh/quickstart.md +20 -41
- package/docs/zh/reference/api.md +1 -1
- package/docs/zh/reference/cli.md +19 -79
- package/docs/zh/sandbox.md +3 -3
- package/examples/README.md +16 -5
- package/examples/authoring/README.md +4 -4
- package/examples/autoresearch/README.md +15 -8
- package/examples/autoresearch/REQUIREMENTS.zh.md +3 -10
- package/examples/autoresearch/demo.ts +1 -1
- package/examples/autoresearch/eject.json +2 -0
- package/examples/autoresearch/frontiercs2-config.ts +4 -0
- package/examples/autoresearch/prepare-demo.ts +15 -0
- package/examples/autoresearch/prepare.ts +3 -3
- package/examples/autoresearch/project.ts +2 -19
- package/examples/code/README.md +25 -17
- package/examples/code/REQUIREMENTS.zh.md +3 -3
- package/examples/harness-session/README.md +3 -3
- package/examples/messages/README.md +1 -1
- package/examples/notes/README.md +3 -3
- package/examples/services/mathlib-search/README.md +1 -1
- package/examples/services/persistent-board/README.md +5 -2
- package/examples/subagents/README.md +2 -2
- package/examples/subagents/config.ts +4 -3
- package/examples/substrate/README.md +2 -2
- 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/npm-shrinkwrap.development.json +42 -1541
- package/npm-shrinkwrap.json +3 -43
- package/package.development.json +2 -6
- package/package.json +2 -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 +95 -0
- package/scripts/anyswarm-project.ts +31 -123
- package/scripts/anyswarm-source-runner.ts +9 -36
- package/scripts/anyswarm.ts +4 -24
- package/scripts/local-environment.ts +71 -20
- package/scripts/local-setup.ts +134 -94
- package/scripts/pack-release.ts +4 -1
- package/src/core/worker-image.ts +1 -1
- package/src/harness/project-harness.ts +2 -2
- package/src/harness/project-runtime.ts +2 -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
|
@@ -2,7 +2,7 @@ import { isIP } from 'node:net';
|
|
|
2
2
|
import { resolve } from 'node:path';
|
|
3
3
|
import { stdin, stderr } from 'node:process';
|
|
4
4
|
import { createInterface } from 'node:readline/promises';
|
|
5
|
-
import { checkSetupHost, checkLocalDocker, checkLocalProvider, discoverMacCallback, ensureLocalProvider, localExecdImage, localEgressImage, localProviderImage, resolveLocalEnvironment, } from './local-environment.js';
|
|
5
|
+
import { checkSetupHost, checkHostTools, checkLocalDocker, checkLocalProvider, discoverMacCallback, ensureLocalProvider, localExecdImage, localEgressImage, localProviderImage, resolveLocalEnvironment, } from './local-environment.js';
|
|
6
6
|
import { runLocalSmoke } from './local-setup-smoke.js';
|
|
7
7
|
import { prepareWorkerImage } from './local-setup-worker.js';
|
|
8
8
|
import { selectExecutorDriver } from '../src/core/sandbox/executor-driver.js';
|
|
@@ -12,7 +12,7 @@ import { resolveFilePolicy } from '../src/core/file-policy.js';
|
|
|
12
12
|
import { claimOpenSandboxBackend, createSandbox } from '../src/core/sandbox/opensandbox-backend.js';
|
|
13
13
|
import { snapshotModel } from '../src/core/model/model-access.js';
|
|
14
14
|
import { modelClientProtocol } from '../src/core/model/model-transport.js';
|
|
15
|
-
import { loadAnySwarmConfig, saveSandboxConnection } from '../src/core/sandbox/sandbox-connection.js';
|
|
15
|
+
import { loadAnySwarmConfig, loopbackLifecycle, saveSandboxConnection } from '../src/core/sandbox/sandbox-connection.js';
|
|
16
16
|
function modelState(config, executor) {
|
|
17
17
|
if (config.models === undefined)
|
|
18
18
|
return { configuration: 'missing', verification: 'not-verified' };
|
|
@@ -87,10 +87,12 @@ function reportedHost(value) {
|
|
|
87
87
|
if (value && (/^[a-zA-Z0-9._-]+$/.test(value) || isIP(value)))
|
|
88
88
|
return value;
|
|
89
89
|
}
|
|
90
|
-
function installNextStep(command) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
90
|
+
function installNextStep(command, mode) {
|
|
91
|
+
if (command.command !== 'setup')
|
|
92
|
+
return 'Run your Harness with the same environment.';
|
|
93
|
+
return mode === 'local'
|
|
94
|
+
? 'Run your Harness with the same environment, or repeat the probe with anyswarm doctor --smoke.'
|
|
95
|
+
: 'Run your Harness with the same environment, or check the existing service with anyswarm doctor --mode existing --smoke.';
|
|
94
96
|
}
|
|
95
97
|
const phaseLabels = {
|
|
96
98
|
host: 'Check local Docker',
|
|
@@ -99,62 +101,68 @@ const phaseLabels = {
|
|
|
99
101
|
worker: 'Prepare Worker image',
|
|
100
102
|
smoke: 'Start Worker and check Bridge, controlled Gateway, files and deletion',
|
|
101
103
|
};
|
|
104
|
+
async function probeBackend(selection, signal) {
|
|
105
|
+
try {
|
|
106
|
+
return { selection, version: await checkLocalExecutor(selection, signal) };
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
signal.throwIfAborted();
|
|
110
|
+
if (error.code !== 'LOCAL_EXECUTOR_UNAVAILABLE')
|
|
111
|
+
throw error;
|
|
112
|
+
return { selection, error: error.message };
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
async function backendOnPath(kind, version, signal) {
|
|
116
|
+
let firstFailure;
|
|
117
|
+
let available;
|
|
118
|
+
await findExecutorEntry(kind, async (entry) => {
|
|
119
|
+
const candidate = await probeBackend({ kind, entry, version }, signal);
|
|
120
|
+
if ('version' in candidate) {
|
|
121
|
+
available = candidate;
|
|
122
|
+
return true;
|
|
123
|
+
}
|
|
124
|
+
firstFailure ??= candidate;
|
|
125
|
+
return false;
|
|
126
|
+
});
|
|
127
|
+
return available ?? firstFailure;
|
|
128
|
+
}
|
|
102
129
|
async function chooseBackend(command, saved, configured, signal) {
|
|
103
130
|
const explicit = command.command === 'setup' ? command.backend : undefined;
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
if (
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
catch (error) {
|
|
121
|
-
signal.throwIfAborted();
|
|
122
|
-
if (error.code !== 'LOCAL_EXECUTOR_UNAVAILABLE')
|
|
123
|
-
throw error;
|
|
124
|
-
return false;
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
if (saved?.kind === kind && await matches(saved.entry))
|
|
128
|
-
return { kind, entry: saved.entry, version };
|
|
129
|
-
const entry = await findExecutorEntry(kind, matches) ?? await findExecutorEntry(kind);
|
|
130
|
-
return entry ? { kind, entry, version } : undefined;
|
|
131
|
-
}
|
|
132
|
-
const entry = await findExecutorEntry(kind);
|
|
133
|
-
return entry ? { kind, entry } : undefined;
|
|
131
|
+
const driver = explicit || configured === undefined ? undefined : selectExecutorDriver(configured);
|
|
132
|
+
const preferred = explicit ?? driver?.kind ?? saved?.kind;
|
|
133
|
+
const version = explicit && command.command === 'setup' ? command.backendVersion : driver?.version;
|
|
134
|
+
if (command.command === 'setup' && command.backendPath && explicit) {
|
|
135
|
+
return probeBackend({ kind: explicit, entry: resolve(command.backendPath), version }, signal);
|
|
136
|
+
}
|
|
137
|
+
if (preferred === 'pi' || preferred === 'codex') {
|
|
138
|
+
if (saved?.kind === preferred && !explicit)
|
|
139
|
+
return probeBackend({ ...saved, version: version ?? saved.version }, signal);
|
|
140
|
+
if (saved?.kind === preferred && version !== undefined) {
|
|
141
|
+
const candidate = await probeBackend({ ...saved, version }, signal);
|
|
142
|
+
if ('version' in candidate)
|
|
143
|
+
return candidate;
|
|
144
|
+
}
|
|
145
|
+
return await backendOnPath(preferred, version, signal) ??
|
|
146
|
+
{ issue: `Could not find the selected ${preferred} executable on PATH.` };
|
|
134
147
|
}
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
148
|
+
const detected = await Promise.all(['pi', 'codex'].map(kind => backendOnPath(kind, undefined, signal)));
|
|
149
|
+
const compatible = detected.filter(candidate => candidate !== undefined && 'version' in candidate);
|
|
150
|
+
if (compatible.length === 0) {
|
|
151
|
+
const errors = detected.filter(candidate => candidate !== undefined && 'error' in candidate).map(candidate => candidate.error);
|
|
152
|
+
return { issue: errors.length ? errors.join(' ') : 'Neither Pi nor Codex was found on PATH.' };
|
|
153
|
+
}
|
|
154
|
+
if (compatible.length === 1)
|
|
155
|
+
return compatible[0];
|
|
156
|
+
const selectBackend = { issue: 'Both Pi and Codex have compatible installations. Choose a backend to use.', ambiguous: true };
|
|
141
157
|
if (command.command !== 'setup' || !stdin.isTTY || !stderr.isTTY)
|
|
142
|
-
return;
|
|
158
|
+
return selectBackend;
|
|
143
159
|
const input = createInterface({ input: stdin, output: stderr });
|
|
144
160
|
try {
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
? `${kind} ${probe.value} (${entry}) is compatible.\n`
|
|
151
|
-
: `${probe.reason instanceof Error ? probe.reason.message : `Could not verify ${kind} at ${entry}.`}\n`);
|
|
152
|
-
return probe.status === 'fulfilled';
|
|
153
|
-
});
|
|
154
|
-
if (choices.length <= 1)
|
|
155
|
-
return choices[0];
|
|
156
|
-
const answer = (await input.question(`Select a local backend [${choices.map(({ kind }) => kind).join(', ')}] (pi): `, { signal })).trim() || 'pi';
|
|
157
|
-
return choices.find(candidate => candidate.kind === answer);
|
|
161
|
+
for (const { selection, version } of compatible) {
|
|
162
|
+
stderr.write(`${selection.kind} ${version} (${selection.entry}) is compatible.\n`);
|
|
163
|
+
}
|
|
164
|
+
const answer = (await input.question('Select a local backend [pi, codex] (pi): ', { signal })).trim() || 'pi';
|
|
165
|
+
return compatible.find(candidate => candidate.selection.kind === answer) ?? selectBackend;
|
|
158
166
|
}
|
|
159
167
|
finally {
|
|
160
168
|
input.close();
|
|
@@ -189,7 +197,10 @@ export async function runLocalCommand(command, signal, progress) {
|
|
|
189
197
|
let provider;
|
|
190
198
|
let rootlessDocker = false;
|
|
191
199
|
let stage = 'config';
|
|
200
|
+
progress?.('Detect host system and AnySwarm configuration…');
|
|
192
201
|
try {
|
|
202
|
+
checks.push(...checkSetupHost());
|
|
203
|
+
report.tooling = await checkHostTools(signal);
|
|
193
204
|
const config = command.configPath
|
|
194
205
|
? await loadAnySwarmConfig(command.configPath) : undefined;
|
|
195
206
|
const configured = (config?.executor ?? process.env.ANYSWARM_EXECUTOR);
|
|
@@ -212,46 +223,74 @@ export async function runLocalCommand(command, signal, progress) {
|
|
|
212
223
|
image: config?.image,
|
|
213
224
|
advertiseHost: config?.connection?.advertiseHost ?? config?.connection?.modelGateway?.advertiseHost,
|
|
214
225
|
});
|
|
215
|
-
const
|
|
226
|
+
const hostname = new URL(environment.lifecycleBaseUrl).hostname;
|
|
227
|
+
const loopback = hostname === 'localhost' || hostname === '[::1]' || hostname.startsWith('127.') && isIP(hostname) === 4;
|
|
228
|
+
const reuseExisting = loopback && (environment.management === 'existing' ||
|
|
229
|
+
(!install && environment.mode === 'existing'));
|
|
230
|
+
const mode = command.mode ?? (reuseExisting ? 'existing' : 'local');
|
|
216
231
|
const smoke = install ? mode === 'local' : command.smoke;
|
|
232
|
+
report.mode = mode;
|
|
233
|
+
report.lifecycleSource = environment.endpointSource;
|
|
234
|
+
if (mode === 'local' && (!loopback || !loopbackLifecycle(environment.lifecycleBaseUrl))) {
|
|
235
|
+
checks.push({ id: 'config.lifecycle', ok: false, detail: 'The selected Lifecycle configuration is outside the managed local HTTP loopback profile.',
|
|
236
|
+
remedy: environment.endpointSource === 'saved'
|
|
237
|
+
? 'Use --mode existing to check the saved service, or run anyswarm setup --mode local --endpoint http://127.0.0.1:8080 to replace it after a successful local probe.'
|
|
238
|
+
: 'For local setup, remove the Lifecycle URL override or set it to http://127.0.0.1:8080. Use --mode existing only to connect to a service you explicitly select.' });
|
|
239
|
+
return report;
|
|
240
|
+
}
|
|
241
|
+
if (mode === 'existing' && environment.endpointSource === 'default') {
|
|
242
|
+
checks.push({ id: 'config.lifecycle', ok: false, detail: 'No existing Lifecycle service was configured.',
|
|
243
|
+
remedy: 'Run anyswarm setup for local OpenSandbox, or configure the existing Lifecycle URL and credentials explicitly.' });
|
|
244
|
+
return report;
|
|
245
|
+
}
|
|
217
246
|
if (command.command === 'setup' && command.backend && mode !== 'local') {
|
|
218
|
-
report.mode = mode;
|
|
219
247
|
checks.push({ id: 'config.executor', ok: false, detail: 'Installation selection requires --mode local with a local Docker engine.',
|
|
220
248
|
remedy: 'For an existing deployment, use its prepared Worker image.' });
|
|
221
249
|
return report;
|
|
222
250
|
}
|
|
223
251
|
if (command.command === 'setup' && environment.image && (command.backendPath || command.backendVersion)) {
|
|
224
|
-
report.mode = mode;
|
|
225
252
|
checks.push({ id: 'config.executor', ok: false, detail: 'An installation path or version pin requires a locally built Worker.',
|
|
226
253
|
remedy: 'Remove the configured Worker image to select an installation, or pin the version in the project executor configuration.' });
|
|
227
254
|
return report;
|
|
228
255
|
}
|
|
229
256
|
if (smoke && mode === 'existing' && !environment.image && !driver.adapter) {
|
|
230
|
-
report.mode = mode;
|
|
231
257
|
checks.push({ id: 'config.worker', ok: false, detail: 'An existing service requires an explicitly prepared Worker image.',
|
|
232
258
|
remedy: 'Set ANYSWARM_WORKER_IMAGE to the image provided by the operator.' });
|
|
233
259
|
return report;
|
|
234
260
|
}
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
261
|
+
let localVersion;
|
|
262
|
+
if (mode === 'local' && !environment.image && !driver.adapter) {
|
|
263
|
+
progress?.('Detect an installed Pi or Codex executable…');
|
|
264
|
+
const detected = await chooseBackend(command, environment.localExecutor, configured, signal);
|
|
265
|
+
if ('issue' in detected) {
|
|
266
|
+
const remedy = detected.ambiguous
|
|
267
|
+
? 'Run anyswarm setup --backend pi or anyswarm setup --backend codex.'
|
|
268
|
+
: 'For Pi, run npm install -g @earendil-works/pi-coding-agent, then run anyswarm setup --backend pi. For Codex, run npm install -g @openai/codex, then run anyswarm setup --backend codex.';
|
|
269
|
+
checks.push({ id: 'config.executor', ok: false, detail: detected.issue, remedy });
|
|
270
|
+
}
|
|
271
|
+
else {
|
|
272
|
+
localExecutor = detected.selection;
|
|
273
|
+
executor = { kind: localExecutor.kind, version: localExecutor.version };
|
|
274
|
+
driver = selectExecutorDriver(executor);
|
|
275
|
+
if ('error' in detected) {
|
|
276
|
+
checks.push({ id: 'config.executor', ok: false, detail: detected.error,
|
|
277
|
+
remedy: 'Restore the saved executable or select a supported installation with anyswarm setup --backend pi or anyswarm setup --backend codex.' });
|
|
278
|
+
}
|
|
279
|
+
else {
|
|
280
|
+
localVersion = detected.version;
|
|
281
|
+
const detail = `Detected ${localExecutor.kind} ${localVersion} at ${localExecutor.entry}.`;
|
|
282
|
+
checks.push({ id: 'config.executor', ok: true, detail });
|
|
283
|
+
progress?.(detail);
|
|
284
|
+
}
|
|
244
285
|
}
|
|
245
|
-
if (driver.version !== undefined)
|
|
246
|
-
localExecutor = { ...localExecutor, version: driver.version };
|
|
247
|
-
executor = { kind: localExecutor.kind, version: localExecutor.version };
|
|
248
|
-
driver = selectExecutorDriver(executor);
|
|
249
286
|
}
|
|
250
|
-
|
|
287
|
+
const modelUrl = process.env.ANYSWARM_MODEL_URL || process.env.ANYSWARM_SUBAGENTS_MODEL_URL;
|
|
288
|
+
const modelId = process.env.ANYSWARM_MODEL_ID || process.env.ANYSWARM_SUBAGENTS_MODEL_ID;
|
|
289
|
+
if (!config && modelUrl && (modelId || driver.kind !== 'codex')) {
|
|
251
290
|
const route = {
|
|
252
|
-
provider: process.env.ANYSWARM_MODEL_PROVIDER ?? 'openai',
|
|
253
|
-
model:
|
|
254
|
-
upstream: { url:
|
|
291
|
+
provider: process.env.ANYSWARM_MODEL_PROVIDER ?? process.env.ANYSWARM_SUBAGENTS_MODEL_PROVIDER ?? 'openai',
|
|
292
|
+
model: modelId || 'gpt-5.4', protocol: process.env.ANYSWARM_MODEL_PROTOCOL,
|
|
293
|
+
upstream: { url: modelUrl, headers: {} },
|
|
255
294
|
};
|
|
256
295
|
try {
|
|
257
296
|
snapshotModel(route, driver.kind);
|
|
@@ -264,41 +303,28 @@ export async function runLocalCommand(command, signal, progress) {
|
|
|
264
303
|
else {
|
|
265
304
|
report.model = config ? modelState(config, driver.kind) : { configuration: 'missing', verification: 'not-verified' };
|
|
266
305
|
}
|
|
306
|
+
if (report.model.configuration === 'missing') {
|
|
307
|
+
report.model.remedy = config ? 'Set an upstream endpoint for each active model route in the trusted configuration.'
|
|
308
|
+
: 'Before running the Quickstart Harness, set ANYSWARM_MODEL_URL and ANYSWARM_MODEL_ID. Set ANYSWARM_MODEL_TOKEN if the endpoint requires authentication.';
|
|
309
|
+
}
|
|
267
310
|
if (report.model?.configuration === 'invalid')
|
|
268
311
|
checks.push({
|
|
269
312
|
id: 'config.models', ok: false, detail: 'An active model alias, capability declaration or protocol endpoint is invalid for the selected executor.',
|
|
270
313
|
remedy: 'Use a supported executor and protocol combination, and configure an HTTP(S) endpoint without embedded credentials for each active model alias.',
|
|
271
314
|
});
|
|
272
|
-
if (
|
|
273
|
-
return report;
|
|
274
|
-
if (config) {
|
|
315
|
+
if (config && report.model.configuration !== 'invalid') {
|
|
275
316
|
const { lifecycleBaseUrl, apiKey, endpointHost } = environment;
|
|
276
317
|
checks.push(checkProjectRuntime({
|
|
277
318
|
...config, executor, connection: { ...config.connection, publicUrl: environment.publicUrl },
|
|
278
319
|
}, { ...config.sandbox, endpoint: undefined, lifecycleBaseUrl, apiKey, endpointHost }));
|
|
279
320
|
}
|
|
280
|
-
if (checks.some(check => !check.ok))
|
|
281
|
-
return report;
|
|
282
321
|
report.configuration = {
|
|
283
|
-
executor: { id: driver.kind, version: driver.version,
|
|
322
|
+
executor: { id: driver.kind, version: localVersion ?? driver.version, entry: localExecutor?.entry,
|
|
323
|
+
compatibleVersions: driver.adapter?.compatibleVersions },
|
|
284
324
|
image: environment.image ?? workerImageFor(executor),
|
|
285
325
|
filePolicy: resolveFilePolicy(config?.filePolicy),
|
|
286
326
|
};
|
|
287
|
-
if (localExecutor && !smoke) {
|
|
288
|
-
try {
|
|
289
|
-
report.configuration.executor.version = await checkLocalExecutor(localExecutor, signal);
|
|
290
|
-
}
|
|
291
|
-
catch (error) {
|
|
292
|
-
signal.throwIfAborted();
|
|
293
|
-
if (error.code !== 'LOCAL_EXECUTOR_UNAVAILABLE')
|
|
294
|
-
throw error;
|
|
295
|
-
checks.push({ id: 'config.executor', ok: false, detail: error.message });
|
|
296
|
-
return report;
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
327
|
const publicUrl = environment.publicUrl ?? config?.connection?.bridge?.publicUrl ?? config?.connection?.modelGateway?.publicUrl;
|
|
300
|
-
report.mode = mode;
|
|
301
|
-
report.lifecycleSource = environment.endpointSource;
|
|
302
328
|
report.connection = {
|
|
303
329
|
lifecycleBaseUrl: reportedEndpoint(environment.lifecycleBaseUrl),
|
|
304
330
|
advertiseHost: reportedHost(environment.advertiseHost),
|
|
@@ -310,23 +336,20 @@ export async function runLocalCommand(command, signal, progress) {
|
|
|
310
336
|
};
|
|
311
337
|
stage = 'host';
|
|
312
338
|
const darwin = process.platform === 'darwin';
|
|
313
|
-
checks.push(...checkSetupHost({ requiresLinux: !darwin }));
|
|
314
|
-
if (checks.some(check => !check.ok))
|
|
315
|
-
return report;
|
|
316
339
|
let advertiseHost = environment.advertiseHost;
|
|
317
340
|
let advertiseHostDiscovery = environment.advertiseHostDiscovery;
|
|
318
|
-
if (mode === 'local' && (
|
|
341
|
+
if (mode === 'local' && checks.find(check => check.id === 'host.platform')?.ok) {
|
|
319
342
|
const docker = await timed('host', checkLocalDocker);
|
|
320
343
|
checks.push(docker.diagnostic);
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
rootlessDocker = docker.docker.rootless;
|
|
324
|
-
if (advertiseHost === undefined && docker.docker.advertiseHost !== undefined) {
|
|
344
|
+
rootlessDocker = docker.docker?.rootless ?? false;
|
|
345
|
+
if (advertiseHost === undefined && docker.docker?.advertiseHost !== undefined) {
|
|
325
346
|
advertiseHost = docker.docker.advertiseHost;
|
|
326
347
|
report.connection.advertiseHost = reportedHost(advertiseHost);
|
|
327
348
|
report.connection.sources.advertiseHost = 'docker-network';
|
|
328
349
|
}
|
|
329
350
|
}
|
|
351
|
+
if (checks.some(check => !check.ok))
|
|
352
|
+
return report;
|
|
330
353
|
let image = report.configuration.image;
|
|
331
354
|
if (mode === 'local' && smoke) {
|
|
332
355
|
stage = 'worker';
|
|
@@ -355,7 +378,7 @@ export async function runLocalCommand(command, signal, progress) {
|
|
|
355
378
|
progress?.(provider.created ? 'Started managed OpenSandbox' : 'Reused managed OpenSandbox');
|
|
356
379
|
}
|
|
357
380
|
const active = provider?.config ?? environment;
|
|
358
|
-
checks.push(...await timed('provider', () => checkLocalProvider(active)));
|
|
381
|
+
checks.push(...await timed('provider', () => checkLocalProvider(active, { managed: mode === 'local' })));
|
|
359
382
|
if (checks.some(check => !check.ok))
|
|
360
383
|
return report;
|
|
361
384
|
report.infrastructure = 'preflight-passed';
|
|
@@ -478,8 +501,13 @@ export async function runLocalCommand(command, signal, progress) {
|
|
|
478
501
|
progress?.(`Probe evidence: ${report.smoke.outputDir}`);
|
|
479
502
|
progress?.('Controlled smoke completed. The configured model upstream was not contacted.');
|
|
480
503
|
}
|
|
504
|
+
for (const tool of report.tooling?.filter(check => !check.ok) ?? []) {
|
|
505
|
+
progress?.([tool.detail, tool.remedy].filter(Boolean).join(' '));
|
|
506
|
+
}
|
|
507
|
+
if (report.model?.remedy)
|
|
508
|
+
progress?.(report.model.remedy);
|
|
481
509
|
if (report.ok)
|
|
482
|
-
progress?.(installNextStep(command));
|
|
510
|
+
progress?.(installNextStep(command, report.mode));
|
|
483
511
|
}
|
|
484
512
|
return report;
|
|
485
513
|
}
|
|
@@ -34,11 +34,14 @@ try {
|
|
|
34
34
|
const manifestPath = join(staged, 'package.json');
|
|
35
35
|
const lockPath = join(staged, 'npm-shrinkwrap.json');
|
|
36
36
|
const manifest = JSON.parse(await readFile(manifestPath, 'utf8'));
|
|
37
|
+
// Service images compile TypeScript. The Pi installation belongs to the executor.
|
|
38
|
+
delete manifest.devDependencies?.['@earendil-works/pi-coding-agent'];
|
|
39
|
+
await writeFile(manifestPath, JSON.stringify(manifest, null, 2) + '\n');
|
|
40
|
+
await run('npm', ['install', '--package-lock-only', '--offline', '--ignore-scripts', '--no-audit', '--no-fund'], { cwd: staged });
|
|
37
41
|
const lock = JSON.parse(await readFile(lockPath, 'utf8'));
|
|
38
42
|
if (lock.lockfileVersion !== 3 || !lock.packages?.['']) {
|
|
39
43
|
throw new Error('Release packaging requires a v3 npm shrinkwrap with root package metadata');
|
|
40
44
|
}
|
|
41
|
-
// Only the service-image build stages use the development inputs.
|
|
42
45
|
await rename(manifestPath, join(staged, 'package.development.json'));
|
|
43
46
|
await rename(lockPath, join(staged, 'npm-shrinkwrap.development.json'));
|
|
44
47
|
delete manifest.private;
|
|
@@ -14,7 +14,7 @@ function readPackageVersion() {
|
|
|
14
14
|
// Try the compiled dist/src/core -> package root path next.
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
-
return '0.5.
|
|
17
|
+
return '0.5.2';
|
|
18
18
|
}
|
|
19
19
|
export const PACKAGE_VERSION = readPackageVersion();
|
|
20
20
|
/** Select the locally prepared Worker for the Runtime's executor. */
|
|
@@ -124,6 +124,7 @@ type RunResult = ProjectHarnessResult & Pick<HarnessResult, 'operations' | 'ques
|
|
|
124
124
|
reportPath?: string;
|
|
125
125
|
};
|
|
126
126
|
export declare function failureCode(error: unknown, fallback: string): string;
|
|
127
|
+
export declare function loadProjectConfiguration(directory: string, path: string | undefined): Promise<unknown>;
|
|
127
128
|
export declare function createProjectHost(definition: ProjectHarness, options: StartupOptions, emit: (record: unknown) => void): {
|
|
128
129
|
harness: {
|
|
129
130
|
id: string;
|
|
@@ -79,7 +79,7 @@ export function failureCode(error, fallback) {
|
|
|
79
79
|
return typeof code === 'string' && (/^[A-Z][A-Z0-9_]{0,79}$/.test(code) ||
|
|
80
80
|
(errorDiagnostic(error) && /^[a-z][a-z0-9_]{0,79}$/.test(code))) ? code : fallback;
|
|
81
81
|
}
|
|
82
|
-
async function
|
|
82
|
+
export async function loadProjectConfiguration(directory, path) {
|
|
83
83
|
if (!path)
|
|
84
84
|
return undefined;
|
|
85
85
|
let value;
|
|
@@ -201,7 +201,7 @@ export function createProjectHost(definition, options, emit) {
|
|
|
201
201
|
await writeFile(path, raw.prompt, { flag: 'wx', mode: 0o600 });
|
|
202
202
|
promptPath = path;
|
|
203
203
|
signal.throwIfAborted();
|
|
204
|
-
const configuration = options.configuration !== undefined ? validateConfiguration(options.configuration) : await
|
|
204
|
+
const configuration = options.configuration !== undefined ? validateConfiguration(options.configuration) : await loadProjectConfiguration(options.launchDirectory, options.configPath);
|
|
205
205
|
signal.throwIfAborted();
|
|
206
206
|
let filePolicy;
|
|
207
207
|
try {
|
|
@@ -65,7 +65,9 @@ export async function projectConfiguration(context, defaults) {
|
|
|
65
65
|
throw new Error('Missing sandbox, models or image');
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
|
-
catch {
|
|
68
|
+
catch (error) {
|
|
69
|
+
if (error instanceof ProjectPreflightError)
|
|
70
|
+
throw error;
|
|
69
71
|
throw new ProjectPreflightError('INVALID_RUN_CONFIGURATION', 'Configure sandbox, models and image for this Harness');
|
|
70
72
|
}
|
|
71
73
|
context.signal.throwIfAborted();
|
package/docs/INDEX.md
CHANGED
|
@@ -23,6 +23,7 @@ Start with the user guides to run a Harness or build your own. The English and C
|
|
|
23
23
|
| Reference | Purpose |
|
|
24
24
|
| --- | --- |
|
|
25
25
|
| [Development](workflows/development.md) | Build, validate and contribute changes. |
|
|
26
|
+
| [Release CLI acceptance](workflows/release-cli-acceptance.md) | Verify the installed CLI, one-shot Runs, Trace, eject and npm upgrades. |
|
|
26
27
|
| [Release updates and documentation versions](workflows/release-and-docs-versioning.md) | Publish the next release and plan versioned guides. |
|
|
27
28
|
| [Coding Agent instructions](../AGENTS.md) | Project-specific work rules, permissions and documentation requirements. |
|
|
28
29
|
| [Engineering record conventions](../AGENTS.md#engineering-record-conventions) | Issue scope, evidence and triage conventions. |
|
|
@@ -36,7 +37,7 @@ Start with the user guides to run a Harness or build your own. The English and C
|
|
|
36
37
|
|
|
37
38
|
The user guides describe the supported public surface. The architecture manual describes how the current tree implements it. Source code and generated references establish exact fields and defaults; tests and experiments establish what was verified. Changes to this baseline need corresponding documentation in their implementation PR.
|
|
38
39
|
|
|
39
|
-
The [Core / Harness design](designs/core-harness/README.md) retains reviewed, version-bound decisions and acceptance criteria. Read it with the applicable Issue and later explicit owner decisions; older first-release limits do not override those changes. The design index links the [dynamic Lead-Worker contract](designs/dynamic-lead-worker.md) and CLI
|
|
40
|
+
The [Core / Harness design](designs/core-harness/README.md) retains reviewed, version-bound decisions and acceptance criteria. Read it with the applicable Issue and later explicit owner decisions; older first-release limits do not override those changes. The design index links the [dynamic Lead-Worker contract](designs/dynamic-lead-worker.md) and CLI scope in [#351](https://github.com/AnySwarm/anyswarm/issues/351). Current implementation belongs in Architecture; remaining acceptance stays in the original Issue/PR. Design updates, code, migration, tests and documentation are reviewed together in the implementation PR.
|
|
40
41
|
|
|
41
42
|
The five collaboration projects own their Harnesses and Services under `examples/`. TaskPool also owns its domain stores and compatibility hosts. The [example index](../examples/README.md) explains how to install and build them with the published SDK or a source build. The [repository migration](designs/repository-layout.md) records the audit and verification scope, and the [deployment guide](../deploy/README.md) describes common infrastructure.
|
|
42
43
|
|
|
@@ -148,7 +148,7 @@ Sources: [bundle loader](../../examples/taskpool/deploy/service-hosts/service-bu
|
|
|
148
148
|
|
|
149
149
|
Offline help at the root and Task group lists Task commands, including `create`. `swarm task create --help` supplies the required flags, accepted priorities, the JSON shape for completion conditions, a complete command and the returned Task ID. The live Bridge manifest from `swarm service view task --json` shows which commands the host actually enabled. The normal Task adapter binds Mission and Workspace from its own trusted state when an Agent sends a proposal.
|
|
150
150
|
|
|
151
|
-
`dist/scripts/swarm.js`
|
|
151
|
+
The Worker image links `/usr/local/bin/swarm` to the bundled `dist/scripts/swarm.js` independently of the public npm executable. This non-interactive entry point delegates parsing/invocation to `src/cli/swarm-cli.ts`. Registered Agents use its protected Bridge mode described under [Agent CLI routing](#agent-cli-routing); the direct endpoint/explicit-envelope description here applies to trusted operator calls. swarm --help, swarm service --help, and each domain's --help are offline and explain endpoint variables, JSON/file/stdin input, actor identity and command families. swarm service list reads the configured service manifests; service view reads one manifest. Each built-in CLI command resolves one registered operation, compose a typed operation envelope, send a JSON envelope/input/role request to the HTTP route and print one JSON result on stdout. Command-level help describes required flags and input/output shape. Requests have a bounded timeout (default 30 seconds, maximum 2,147,483,647 milliseconds). Diagnostics and structured failures go to stderr; invalid usage exits 2, HTTP/provider failures or timeouts exit 1, and a successful Judge request whose business verdict is FAIL/source_failure/mathematical_failure/incorrect exits 3 while still printing the authoritative result.
|
|
152
152
|
|
|
153
153
|
The CLI is a client of an already hosted service. It does not construct a domain service, open a service database, or keep long-running work in the Agent sandbox. ANYSWARM_<SERVICE>_SERVICE_URL and the optional bearer token identify the endpoint; ANYSWARM_SERVICE_ENDPOINTS can supply a JSON discovery list for service list. The CLI's request ID is an idempotency key only when the receiving Service honors the envelope operation identity; the CLI does not retry a write after a lost response.
|
|
154
154
|
|