@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.
Files changed (171) hide show
  1. package/AGENTS.md +1 -1
  2. package/README.md +13 -6
  3. package/dist/examples/README.md +16 -5
  4. package/dist/examples/authoring/README.md +4 -4
  5. package/dist/examples/autoresearch/README.md +15 -8
  6. package/dist/examples/autoresearch/REQUIREMENTS.zh.md +3 -10
  7. package/dist/examples/autoresearch/demo.js +1 -1
  8. package/dist/examples/autoresearch/eject.json +2 -0
  9. package/dist/examples/autoresearch/frontiercs2-config.d.ts +2 -0
  10. package/dist/examples/autoresearch/frontiercs2-config.js +3 -0
  11. package/dist/examples/autoresearch/prepare-demo.d.ts +1 -0
  12. package/dist/examples/autoresearch/prepare-demo.js +15 -0
  13. package/dist/examples/autoresearch/prepare.js +3 -3
  14. package/dist/examples/autoresearch/project.d.ts +0 -94
  15. package/dist/examples/autoresearch/project.js +2 -20
  16. package/dist/examples/code/README.md +25 -17
  17. package/dist/examples/code/REQUIREMENTS.zh.md +3 -3
  18. package/dist/examples/harness-session/README.md +3 -3
  19. package/dist/examples/messages/README.md +1 -1
  20. package/dist/examples/notes/README.md +3 -3
  21. package/dist/examples/services/mathlib-search/README.md +1 -1
  22. package/dist/examples/services/persistent-board/README.md +5 -2
  23. package/dist/examples/subagents/README.md +2 -2
  24. package/dist/examples/subagents/config.js +3 -3
  25. package/dist/examples/substrate/README.md +2 -2
  26. package/dist/examples/super/README.md +34 -22
  27. package/dist/examples/super/actions.d.ts +1 -1
  28. package/dist/examples/super/actions.js +11 -11
  29. package/dist/examples/super/config.js +3 -3
  30. package/dist/examples/super/eject.json +1 -1
  31. package/dist/examples/super/location.js +1 -1
  32. package/dist/examples/super/operator.d.ts +1 -0
  33. package/dist/examples/super/operator.js +31 -0
  34. package/dist/examples/super/project.d.ts +0 -107
  35. package/dist/examples/super/project.js +1 -3
  36. package/dist/scripts/anyswarm-arguments.d.ts +7 -25
  37. package/dist/scripts/anyswarm-arguments.js +69 -97
  38. package/dist/scripts/anyswarm-eject.js +1 -1
  39. package/dist/scripts/anyswarm-harnesses.d.ts +0 -1
  40. package/dist/scripts/anyswarm-harnesses.js +1 -22
  41. package/dist/scripts/anyswarm-installation.d.ts +7 -40
  42. package/dist/scripts/anyswarm-installation.js +17 -291
  43. package/dist/scripts/anyswarm-launch.d.ts +6 -36
  44. package/dist/scripts/anyswarm-launch.js +32 -81
  45. package/dist/scripts/anyswarm-progress.d.ts +6 -0
  46. package/dist/scripts/anyswarm-progress.js +102 -0
  47. package/dist/scripts/anyswarm-project.d.ts +1 -9
  48. package/dist/scripts/anyswarm-project.js +40 -127
  49. package/dist/scripts/anyswarm-source-runner.js +9 -41
  50. package/dist/scripts/anyswarm.js +6 -26
  51. package/dist/scripts/build-provenance.json +1 -1
  52. package/dist/scripts/local-environment.d.ts +10 -4
  53. package/dist/scripts/local-environment.js +67 -20
  54. package/dist/scripts/local-setup.d.ts +3 -0
  55. package/dist/scripts/local-setup.js +135 -107
  56. package/dist/scripts/pack-release.js +4 -1
  57. package/dist/src/core/worker-image.js +1 -1
  58. package/dist/src/harness/project-harness.d.ts +1 -0
  59. package/dist/src/harness/project-harness.js +2 -2
  60. package/dist/src/harness/project-runtime.js +3 -1
  61. package/docs/INDEX.md +2 -1
  62. package/docs/architecture/04-services.md +1 -1
  63. package/docs/architecture/07-run-configuration.md +28 -14
  64. package/docs/architecture/12-code-coverage.md +56 -57
  65. package/docs/architecture/17-harness-reporting.md +1 -1
  66. package/docs/architecture/22-website.md +4 -7
  67. package/docs/architecture/23-project-harness.md +48 -23
  68. package/docs/architecture/26-code.md +20 -5
  69. package/docs/architecture/27-personal.md +23 -8
  70. package/docs/architecture/28-autoresearch.md +18 -6
  71. package/docs/architecture/INDEX.md +1 -2
  72. package/docs/architecture/prompts/source-manifest.json +5 -5
  73. package/docs/architecture/source-map.json +51 -71
  74. package/docs/designs/core-harness/01-core.md +2 -2
  75. package/docs/designs/core-harness/06-project-harness.md +3 -3
  76. package/docs/designs/core-harness/README.md +2 -2
  77. package/docs/en/agents.md +1 -1
  78. package/docs/en/build-your-harness.md +1 -1
  79. package/docs/en/changelog.md +7 -0
  80. package/docs/en/first-harness.md +6 -6
  81. package/docs/en/harnesses/lead-worker.md +1 -1
  82. package/docs/en/harnesses/peermesh.md +2 -2
  83. package/docs/en/harnesses/subagents.md +2 -2
  84. package/docs/en/harnesses/substrate.md +4 -4
  85. package/docs/en/harnesses/taskpool.md +2 -2
  86. package/docs/en/latest.md +9 -5
  87. package/docs/en/quickstart.md +20 -41
  88. package/docs/en/reference/api.md +1 -1
  89. package/docs/en/reference/cli.md +47 -85
  90. package/docs/en/sandbox.md +3 -3
  91. package/docs/operations/trace-viewer.md +1 -1
  92. package/docs/third-party-notices.md +0 -1
  93. package/docs/workflows/development.md +14 -12
  94. package/docs/workflows/release-and-docs-versioning.md +13 -12
  95. package/docs/workflows/release-cli-acceptance.md +85 -0
  96. package/docs/zh/agents.md +1 -1
  97. package/docs/zh/build-your-harness.md +1 -1
  98. package/docs/zh/changelog.md +8 -1
  99. package/docs/zh/first-harness.md +7 -7
  100. package/docs/zh/harnesses/lead-worker.md +1 -1
  101. package/docs/zh/harnesses/peermesh.md +2 -2
  102. package/docs/zh/harnesses/subagents.md +2 -2
  103. package/docs/zh/harnesses/substrate.md +4 -4
  104. package/docs/zh/harnesses/taskpool.md +2 -2
  105. package/docs/zh/latest.md +9 -5
  106. package/docs/zh/quickstart.md +20 -41
  107. package/docs/zh/reference/api.md +1 -1
  108. package/docs/zh/reference/cli.md +19 -79
  109. package/docs/zh/sandbox.md +3 -3
  110. package/examples/README.md +16 -5
  111. package/examples/authoring/README.md +4 -4
  112. package/examples/autoresearch/README.md +15 -8
  113. package/examples/autoresearch/REQUIREMENTS.zh.md +3 -10
  114. package/examples/autoresearch/demo.ts +1 -1
  115. package/examples/autoresearch/eject.json +2 -0
  116. package/examples/autoresearch/frontiercs2-config.ts +4 -0
  117. package/examples/autoresearch/prepare-demo.ts +15 -0
  118. package/examples/autoresearch/prepare.ts +3 -3
  119. package/examples/autoresearch/project.ts +2 -19
  120. package/examples/code/README.md +25 -17
  121. package/examples/code/REQUIREMENTS.zh.md +3 -3
  122. package/examples/harness-session/README.md +3 -3
  123. package/examples/messages/README.md +1 -1
  124. package/examples/notes/README.md +3 -3
  125. package/examples/services/mathlib-search/README.md +1 -1
  126. package/examples/services/persistent-board/README.md +5 -2
  127. package/examples/subagents/README.md +2 -2
  128. package/examples/subagents/config.ts +4 -3
  129. package/examples/substrate/README.md +2 -2
  130. package/examples/super/README.md +34 -22
  131. package/examples/super/actions.ts +11 -11
  132. package/examples/super/config.ts +3 -3
  133. package/examples/super/eject.json +1 -1
  134. package/examples/super/location.ts +1 -1
  135. package/examples/super/operator.ts +28 -0
  136. package/examples/super/project.ts +1 -3
  137. package/npm-shrinkwrap.development.json +42 -1541
  138. package/npm-shrinkwrap.json +3 -43
  139. package/package.development.json +2 -6
  140. package/package.json +2 -5
  141. package/scripts/anyswarm-arguments.ts +67 -96
  142. package/scripts/anyswarm-eject.ts +1 -1
  143. package/scripts/anyswarm-harnesses.ts +1 -18
  144. package/scripts/anyswarm-installation.ts +18 -294
  145. package/scripts/anyswarm-launch.ts +30 -102
  146. package/scripts/anyswarm-progress.ts +95 -0
  147. package/scripts/anyswarm-project.ts +31 -123
  148. package/scripts/anyswarm-source-runner.ts +9 -36
  149. package/scripts/anyswarm.ts +4 -24
  150. package/scripts/local-environment.ts +71 -20
  151. package/scripts/local-setup.ts +134 -94
  152. package/scripts/pack-release.ts +4 -1
  153. package/src/core/worker-image.ts +1 -1
  154. package/src/harness/project-harness.ts +2 -2
  155. package/src/harness/project-runtime.ts +2 -1
  156. package/dist/scripts/anyswarm-applications.d.ts +0 -19
  157. package/dist/scripts/anyswarm-applications.js +0 -19
  158. package/dist/scripts/anyswarm-tui-config.d.ts +0 -36
  159. package/dist/scripts/anyswarm-tui-config.js +0 -189
  160. package/dist/scripts/anyswarm-tui-session.d.ts +0 -66
  161. package/dist/scripts/anyswarm-tui-session.js +0 -304
  162. package/dist/scripts/anyswarm-tui-terminal.d.ts +0 -41
  163. package/dist/scripts/anyswarm-tui-terminal.js +0 -154
  164. package/dist/scripts/anyswarm-tui.d.ts +0 -2
  165. package/dist/scripts/anyswarm-tui.js +0 -1012
  166. package/docs/architecture/25-foreground-tui.md +0 -51
  167. package/scripts/anyswarm-applications.ts +0 -39
  168. package/scripts/anyswarm-tui-config.ts +0 -174
  169. package/scripts/anyswarm-tui-session.ts +0 -295
  170. package/scripts/anyswarm-tui-terminal.ts +0 -147
  171. package/scripts/anyswarm-tui.ts +0 -912
@@ -3,7 +3,7 @@ import { resolve } from 'node:path';
3
3
  import { stdin, stderr } from 'node:process';
4
4
  import { createInterface } from 'node:readline/promises';
5
5
  import {
6
- checkSetupHost, checkLocalDocker, checkLocalProvider, discoverMacCallback, ensureLocalProvider, localExecdImage, localEgressImage, localProviderImage, resolveLocalEnvironment,
6
+ checkSetupHost, checkHostTools, checkLocalDocker, checkLocalProvider, discoverMacCallback, ensureLocalProvider, localExecdImage, localEgressImage, localProviderImage, resolveLocalEnvironment,
7
7
  type DiagnosticCheck,
8
8
  } from './local-environment.js';
9
9
  import { runLocalSmoke } from './local-setup-smoke.js';
@@ -18,14 +18,14 @@ import { claimOpenSandboxBackend, createSandbox } from '../src/core/sandbox/open
18
18
  import { snapshotModel } from '../src/core/model/model-access.js';
19
19
  import { modelClientProtocol } from '../src/core/model/model-transport.js';
20
20
  import type { SandboxConfig } from '../src/core/backend-config.js';
21
- import { loadAnySwarmConfig, saveSandboxConnection } from '../src/core/sandbox/sandbox-connection.js';
21
+ import { loadAnySwarmConfig, loopbackLifecycle, saveSandboxConnection } from '../src/core/sandbox/sandbox-connection.js';
22
22
  import type { LocalCommand } from './anyswarm-arguments.js';
23
23
 
24
24
  type ProjectConfig = Parameters<typeof createSubagentsHarness>[0];
25
25
  type Provider = Awaited<ReturnType<typeof ensureLocalProvider>>;
26
26
  type Smoke = Awaited<ReturnType<typeof runLocalSmoke>>;
27
27
  type Timing = { id: string; elapsedMs: number; cached?: boolean };
28
- type Model = { configuration: 'complete' | 'missing' | 'invalid'; verification: 'not-verified' };
28
+ type Model = { configuration: 'complete' | 'missing' | 'invalid'; verification: 'not-verified'; remedy?: string };
29
29
 
30
30
  function modelState(config: ProjectConfig, executor: string): Model {
31
31
  if (config.models === undefined) return { configuration: 'missing', verification: 'not-verified' };
@@ -95,10 +95,11 @@ function reportedHost(value?: string): string | undefined {
95
95
  if (value && (/^[a-zA-Z0-9._-]+$/.test(value) || isIP(value))) return value;
96
96
  }
97
97
 
98
- function installNextStep(command: LocalCommand): string {
99
- return command.command === 'setup'
100
- ? 'Run your Harness with the same environment and resolveSandboxConnection(), or repeat the probe with anyswarm doctor --smoke.'
101
- : 'Run your Harness with the same environment.';
98
+ function installNextStep(command: LocalCommand, mode?: 'existing' | 'local'): string {
99
+ if (command.command !== 'setup') return 'Run your Harness with the same environment.';
100
+ return mode === 'local'
101
+ ? 'Run your Harness with the same environment, or repeat the probe with anyswarm doctor --smoke.'
102
+ : 'Run your Harness with the same environment, or check the existing service with anyswarm doctor --mode existing --smoke.';
102
103
  }
103
104
 
104
105
  const phaseLabels: Record<string, string> = {
@@ -109,56 +110,71 @@ const phaseLabels: Record<string, string> = {
109
110
  smoke: 'Start Worker and check Bridge, controlled Gateway, files and deletion',
110
111
  };
111
112
 
113
+ type BackendProbe = {
114
+ selection: LocalExecutorSelection;
115
+ } & ({ version: string } | { error: string });
116
+
117
+ async function probeBackend(selection: LocalExecutorSelection, signal: AbortSignal): Promise<BackendProbe> {
118
+ try {
119
+ return { selection, version: await checkLocalExecutor(selection, signal) };
120
+ } catch (error) {
121
+ signal.throwIfAborted();
122
+ if ((error as { code?: string }).code !== 'LOCAL_EXECUTOR_UNAVAILABLE') throw error;
123
+ return { selection, error: (error as Error).message };
124
+ }
125
+ }
126
+
127
+ async function backendOnPath(kind: LocalExecutorSelection['kind'], version: string | undefined, signal: AbortSignal) {
128
+ let firstFailure: BackendProbe | undefined;
129
+ let available: BackendProbe | undefined;
130
+ await findExecutorEntry(kind, async entry => {
131
+ const candidate = await probeBackend({ kind, entry, version }, signal);
132
+ if ('version' in candidate) {
133
+ available = candidate;
134
+ return true;
135
+ }
136
+ firstFailure ??= candidate;
137
+ return false;
138
+ });
139
+ return available ?? firstFailure;
140
+ }
141
+
112
142
  async function chooseBackend(
113
143
  command: LocalCommand, saved: LocalExecutorSelection | undefined, configured: ExecutorSelection | undefined, signal: AbortSignal,
114
- ): Promise<LocalExecutorSelection | undefined> {
144
+ ): Promise<BackendProbe | { issue: string; ambiguous?: boolean }> {
115
145
  const explicit = command.command === 'setup' ? command.backend : undefined;
116
- const version = command.command === 'setup' ? command.backendVersion : undefined;
117
- if (command.command === 'setup' && command.backendPath && explicit) return { kind: explicit, entry: resolve(command.backendPath), version };
118
- const preferred = explicit ?? (configured ? selectExecutorDriver(configured).kind : saved?.kind);
119
- if (preferred && preferred !== 'pi' && preferred !== 'codex') return;
120
- if (saved && (!preferred || preferred === saved.kind) && !explicit) return saved;
121
- if (preferred) {
122
- const kind = preferred as LocalExecutorSelection['kind'];
123
- if (version !== undefined) {
124
- const matches = async (entry: string) => {
125
- try {
126
- await checkLocalExecutor({ kind, entry, version }, signal);
127
- return true;
128
- } catch (error) {
129
- signal.throwIfAborted();
130
- if ((error as { code?: string }).code !== 'LOCAL_EXECUTOR_UNAVAILABLE') throw error;
131
- return false;
132
- }
133
- };
134
- if (saved?.kind === kind && await matches(saved.entry)) return { kind, entry: saved.entry, version };
135
- const entry = await findExecutorEntry(kind, matches) ?? await findExecutorEntry(kind);
136
- return entry ? { kind, entry, version } : undefined;
146
+ const driver = explicit || configured === undefined ? undefined : selectExecutorDriver(configured);
147
+ const preferred = explicit ?? driver?.kind ?? saved?.kind;
148
+ const version = explicit && command.command === 'setup' ? command.backendVersion : driver?.version;
149
+ if (command.command === 'setup' && command.backendPath && explicit) {
150
+ return probeBackend({ kind: explicit, entry: resolve(command.backendPath), version }, signal);
151
+ }
152
+ if (preferred === 'pi' || preferred === 'codex') {
153
+ if (saved?.kind === preferred && !explicit) return probeBackend({ ...saved, version: version ?? saved.version }, signal);
154
+ if (saved?.kind === preferred && version !== undefined) {
155
+ const candidate = await probeBackend({ ...saved, version }, signal);
156
+ if ('version' in candidate) return candidate;
137
157
  }
138
- const entry = await findExecutorEntry(kind);
139
- return entry ? { kind, entry } : undefined;
158
+ return await backendOnPath(preferred, version, signal) ??
159
+ { issue: `Could not find the selected ${preferred} executable on PATH.` };
140
160
  }
141
161
 
142
- const installed = (await Promise.all((['pi', 'codex'] as const).map(async kind => {
143
- const entry = await findExecutorEntry(kind);
144
- return entry ? { kind, entry } : undefined;
145
- }))).filter(value => value !== undefined);
146
- if (installed.length <= 1) return installed[0];
147
- if (command.command !== 'setup' || !stdin.isTTY || !stderr.isTTY) return;
162
+ const detected = await Promise.all((['pi', 'codex'] as const).map(kind => backendOnPath(kind, undefined, signal)));
163
+ const compatible = detected.filter(candidate => candidate !== undefined && 'version' in candidate);
164
+ if (compatible.length === 0) {
165
+ const errors = detected.filter(candidate => candidate !== undefined && 'error' in candidate).map(candidate => candidate.error);
166
+ return { issue: errors.length ? errors.join(' ') : 'Neither Pi nor Codex was found on PATH.' };
167
+ }
168
+ if (compatible.length === 1) return compatible[0]!;
169
+ const selectBackend = { issue: 'Both Pi and Codex have compatible installations. Choose a backend to use.', ambiguous: true };
170
+ if (command.command !== 'setup' || !stdin.isTTY || !stderr.isTTY) return selectBackend;
148
171
  const input = createInterface({ input: stdin, output: stderr });
149
172
  try {
150
- const probes = await Promise.allSettled(installed.map(candidate => checkLocalExecutor(candidate, signal)));
151
- signal.throwIfAborted();
152
- const choices = installed.filter(({ kind, entry }, index) => {
153
- const probe = probes[index]!;
154
- stderr.write(probe.status === 'fulfilled'
155
- ? `${kind} ${probe.value} (${entry}) is compatible.\n`
156
- : `${probe.reason instanceof Error ? probe.reason.message : `Could not verify ${kind} at ${entry}.`}\n`);
157
- return probe.status === 'fulfilled';
158
- });
159
- if (choices.length <= 1) return choices[0];
160
- const answer = (await input.question(`Select a local backend [${choices.map(({ kind }) => kind).join(', ')}] (pi): `, { signal })).trim() || 'pi';
161
- return choices.find(candidate => candidate.kind === answer);
173
+ for (const { selection, version } of compatible) {
174
+ stderr.write(`${selection.kind} ${version} (${selection.entry}) is compatible.\n`);
175
+ }
176
+ const answer = (await input.question('Select a local backend [pi, codex] (pi): ', { signal })).trim() || 'pi';
177
+ return compatible.find(candidate => candidate.selection.kind === answer) ?? selectBackend;
162
178
  } finally {
163
179
  input.close();
164
180
  }
@@ -185,11 +201,12 @@ export async function runLocalCommand(command: LocalCommand, signal: AbortSignal
185
201
  model?: Model;
186
202
  modelUpstreamVerification: 'not-verified';
187
203
  configuration?: {
188
- executor: { id: string; version?: string; compatibleVersions?: readonly string[] };
204
+ executor: { id: string; version?: string; entry?: string; compatibleVersions?: readonly string[] };
189
205
  image: string;
190
206
  filePolicy: ResolvedFilePolicy;
191
207
  };
192
208
  checks: DiagnosticCheck[];
209
+ tooling?: DiagnosticCheck[];
193
210
  timings: Timing[];
194
211
  elapsedMs: number;
195
212
  interrupted: boolean;
@@ -222,7 +239,10 @@ export async function runLocalCommand(command: LocalCommand, signal: AbortSignal
222
239
  let provider: Provider | undefined;
223
240
  let rootlessDocker = false;
224
241
  let stage = 'config';
242
+ progress?.('Detect host system and AnySwarm configuration…');
225
243
  try {
244
+ checks.push(...checkSetupHost());
245
+ report.tooling = await checkHostTools(signal);
226
246
  const config = command.configPath
227
247
  ? await loadAnySwarmConfig(command.configPath) as ProjectConfig : undefined;
228
248
  const configured = (config?.executor ?? process.env.ANYSWARM_EXECUTOR) as ExecutorSelection | undefined;
@@ -243,45 +263,72 @@ export async function runLocalCommand(command: LocalCommand, signal: AbortSignal
243
263
  image: config?.image,
244
264
  advertiseHost: config?.connection?.advertiseHost ?? config?.connection?.modelGateway?.advertiseHost,
245
265
  });
246
- const mode = (command.command === 'setup' ? command.mode : undefined) ?? environment.mode;
266
+ const hostname = new URL(environment.lifecycleBaseUrl).hostname;
267
+ const loopback = hostname === 'localhost' || hostname === '[::1]' || hostname.startsWith('127.') && isIP(hostname) === 4;
268
+ const reuseExisting = loopback && (environment.management === 'existing' ||
269
+ (!install && environment.mode === 'existing'));
270
+ const mode = command.mode ?? (reuseExisting ? 'existing' : 'local');
247
271
  const smoke = install ? mode === 'local' : command.smoke;
272
+ report.mode = mode;
273
+ report.lifecycleSource = environment.endpointSource;
274
+ if (mode === 'local' && (!loopback || !loopbackLifecycle(environment.lifecycleBaseUrl))) {
275
+ checks.push({ id: 'config.lifecycle', ok: false, detail: 'The selected Lifecycle configuration is outside the managed local HTTP loopback profile.',
276
+ remedy: environment.endpointSource === 'saved'
277
+ ? '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.'
278
+ : '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.' });
279
+ return report;
280
+ }
281
+ if (mode === 'existing' && environment.endpointSource === 'default') {
282
+ checks.push({ id: 'config.lifecycle', ok: false, detail: 'No existing Lifecycle service was configured.',
283
+ remedy: 'Run anyswarm setup for local OpenSandbox, or configure the existing Lifecycle URL and credentials explicitly.' });
284
+ return report;
285
+ }
248
286
  if (command.command === 'setup' && command.backend && mode !== 'local') {
249
- report.mode = mode;
250
287
  checks.push({ id: 'config.executor', ok: false, detail: 'Installation selection requires --mode local with a local Docker engine.',
251
288
  remedy: 'For an existing deployment, use its prepared Worker image.' });
252
289
  return report;
253
290
  }
254
291
  if (command.command === 'setup' && environment.image && (command.backendPath || command.backendVersion)) {
255
- report.mode = mode;
256
292
  checks.push({ id: 'config.executor', ok: false, detail: 'An installation path or version pin requires a locally built Worker.',
257
293
  remedy: 'Remove the configured Worker image to select an installation, or pin the version in the project executor configuration.' });
258
294
  return report;
259
295
  }
260
296
  if (smoke && mode === 'existing' && !environment.image && !driver.adapter) {
261
- report.mode = mode;
262
297
  checks.push({ id: 'config.worker', ok: false, detail: 'An existing service requires an explicitly prepared Worker image.',
263
298
  remedy: 'Set ANYSWARM_WORKER_IMAGE to the image provided by the operator.' });
264
299
  return report;
265
300
  }
266
- if (mode === 'local' && !environment.image && !driver.adapter && (smoke || environment.localExecutor)) {
267
- localExecutor = await chooseBackend(command, environment.localExecutor, configured, signal);
268
- if (!localExecutor) {
269
- report.mode = mode;
270
- checks.push({
271
- id: 'config.executor', ok: false, detail: 'Select a supported local Pi or Codex executable.',
272
- remedy: 'Install Pi or Codex with npm and rerun setup --backend pi|codex. Use --backend-path for a different installation.',
273
- });
274
- return report;
301
+ let localVersion: string | undefined;
302
+ if (mode === 'local' && !environment.image && !driver.adapter) {
303
+ progress?.('Detect an installed Pi or Codex executable…');
304
+ const detected = await chooseBackend(command, environment.localExecutor, configured, signal);
305
+ if ('issue' in detected) {
306
+ const remedy = detected.ambiguous
307
+ ? 'Run anyswarm setup --backend pi or anyswarm setup --backend codex.'
308
+ : '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.';
309
+ checks.push({ id: 'config.executor', ok: false, detail: detected.issue, remedy });
310
+ } else {
311
+ localExecutor = detected.selection;
312
+ executor = { kind: localExecutor.kind, version: localExecutor.version };
313
+ driver = selectExecutorDriver(executor);
314
+ if ('error' in detected) {
315
+ checks.push({ id: 'config.executor', ok: false, detail: detected.error,
316
+ remedy: 'Restore the saved executable or select a supported installation with anyswarm setup --backend pi or anyswarm setup --backend codex.' });
317
+ } else {
318
+ localVersion = detected.version;
319
+ const detail = `Detected ${localExecutor.kind} ${localVersion} at ${localExecutor.entry}.`;
320
+ checks.push({ id: 'config.executor', ok: true, detail });
321
+ progress?.(detail);
322
+ }
275
323
  }
276
- if (driver.version !== undefined) localExecutor = { ...localExecutor, version: driver.version };
277
- executor = { kind: localExecutor.kind, version: localExecutor.version };
278
- driver = selectExecutorDriver(executor);
279
324
  }
280
- if (!config && process.env.ANYSWARM_MODEL_URL) {
325
+ const modelUrl = process.env.ANYSWARM_MODEL_URL || process.env.ANYSWARM_SUBAGENTS_MODEL_URL;
326
+ const modelId = process.env.ANYSWARM_MODEL_ID || process.env.ANYSWARM_SUBAGENTS_MODEL_ID;
327
+ if (!config && modelUrl && (modelId || driver.kind !== 'codex')) {
281
328
  const route = {
282
- provider: process.env.ANYSWARM_MODEL_PROVIDER ?? 'openai',
283
- model: process.env.ANYSWARM_MODEL_ID ?? '', protocol: process.env.ANYSWARM_MODEL_PROTOCOL,
284
- upstream: { url: process.env.ANYSWARM_MODEL_URL, headers: {} },
329
+ provider: process.env.ANYSWARM_MODEL_PROVIDER ?? process.env.ANYSWARM_SUBAGENTS_MODEL_PROVIDER ?? 'openai',
330
+ model: modelId || 'gpt-5.4', protocol: process.env.ANYSWARM_MODEL_PROTOCOL,
331
+ upstream: { url: modelUrl, headers: {} },
285
332
  };
286
333
  try {
287
334
  snapshotModel(route as Parameters<typeof snapshotModel>[0], driver.kind);
@@ -292,36 +339,27 @@ export async function runLocalCommand(command: LocalCommand, signal: AbortSignal
292
339
  } else {
293
340
  report.model = config ? modelState(config, driver.kind) : { configuration: 'missing', verification: 'not-verified' };
294
341
  }
342
+ if (report.model.configuration === 'missing') {
343
+ report.model.remedy = config ? 'Set an upstream endpoint for each active model route in the trusted configuration.'
344
+ : 'Before running the Quickstart Harness, set ANYSWARM_MODEL_URL and ANYSWARM_MODEL_ID. Set ANYSWARM_MODEL_TOKEN if the endpoint requires authentication.';
345
+ }
295
346
  if (report.model?.configuration === 'invalid') checks.push({
296
347
  id: 'config.models', ok: false, detail: 'An active model alias, capability declaration or protocol endpoint is invalid for the selected executor.',
297
348
  remedy: 'Use a supported executor and protocol combination, and configure an HTTP(S) endpoint without embedded credentials for each active model alias.',
298
349
  });
299
- if (checks.some(check => !check.ok)) return report;
300
- if (config) {
350
+ if (config && report.model.configuration !== 'invalid') {
301
351
  const { lifecycleBaseUrl, apiKey, endpointHost } = environment;
302
352
  checks.push(checkProjectRuntime({
303
353
  ...config, executor, connection: { ...config.connection, publicUrl: environment.publicUrl },
304
354
  }, { ...config.sandbox, endpoint: undefined, lifecycleBaseUrl, apiKey, endpointHost }));
305
355
  }
306
- if (checks.some(check => !check.ok)) return report;
307
356
  report.configuration = {
308
- executor: { id: driver.kind, version: driver.version, compatibleVersions: driver.adapter?.compatibleVersions },
357
+ executor: { id: driver.kind, version: localVersion ?? driver.version, entry: localExecutor?.entry,
358
+ compatibleVersions: driver.adapter?.compatibleVersions },
309
359
  image: environment.image ?? workerImageFor(executor),
310
360
  filePolicy: resolveFilePolicy(config?.filePolicy),
311
361
  };
312
- if (localExecutor && !smoke) {
313
- try {
314
- report.configuration.executor.version = await checkLocalExecutor(localExecutor, signal);
315
- } catch (error) {
316
- signal.throwIfAborted();
317
- if ((error as { code?: string }).code !== 'LOCAL_EXECUTOR_UNAVAILABLE') throw error;
318
- checks.push({ id: 'config.executor', ok: false, detail: (error as Error).message });
319
- return report;
320
- }
321
- }
322
362
  const publicUrl = environment.publicUrl ?? config?.connection?.bridge?.publicUrl ?? config?.connection?.modelGateway?.publicUrl;
323
- report.mode = mode;
324
- report.lifecycleSource = environment.endpointSource;
325
363
  report.connection = {
326
364
  lifecycleBaseUrl: reportedEndpoint(environment.lifecycleBaseUrl),
327
365
  advertiseHost: reportedHost(environment.advertiseHost),
@@ -333,21 +371,19 @@ export async function runLocalCommand(command: LocalCommand, signal: AbortSignal
333
371
  };
334
372
  stage = 'host';
335
373
  const darwin = process.platform === 'darwin';
336
- checks.push(...checkSetupHost({ requiresLinux: !darwin }));
337
- if (checks.some(check => !check.ok)) return report;
338
374
  let advertiseHost = environment.advertiseHost;
339
375
  let advertiseHostDiscovery = environment.advertiseHostDiscovery;
340
- if (mode === 'local' && (smoke || darwin)) {
376
+ if (mode === 'local' && checks.find(check => check.id === 'host.platform')?.ok) {
341
377
  const docker = await timed('host', checkLocalDocker);
342
378
  checks.push(docker.diagnostic);
343
- if (!docker.docker) return report;
344
- rootlessDocker = docker.docker.rootless;
345
- if (advertiseHost === undefined && docker.docker.advertiseHost !== undefined) {
379
+ rootlessDocker = docker.docker?.rootless ?? false;
380
+ if (advertiseHost === undefined && docker.docker?.advertiseHost !== undefined) {
346
381
  advertiseHost = docker.docker.advertiseHost;
347
382
  report.connection.advertiseHost = reportedHost(advertiseHost);
348
383
  report.connection.sources.advertiseHost = 'docker-network';
349
384
  }
350
385
  }
386
+ if (checks.some(check => !check.ok)) return report;
351
387
  let image = report.configuration.image;
352
388
  if (mode === 'local' && smoke) {
353
389
  stage = 'worker';
@@ -375,7 +411,7 @@ export async function runLocalCommand(command: LocalCommand, signal: AbortSignal
375
411
  progress?.(provider.created ? 'Started managed OpenSandbox' : 'Reused managed OpenSandbox');
376
412
  }
377
413
  const active = provider?.config ?? environment;
378
- checks.push(...await timed('provider', () => checkLocalProvider(active)));
414
+ checks.push(...await timed('provider', () => checkLocalProvider(active, { managed: mode === 'local' })));
379
415
  if (checks.some(check => !check.ok)) return report;
380
416
 
381
417
  report.infrastructure = 'preflight-passed';
@@ -484,7 +520,11 @@ export async function runLocalCommand(command: LocalCommand, signal: AbortSignal
484
520
  if (report.smoke.outputDir) progress?.(`Probe evidence: ${report.smoke.outputDir}`);
485
521
  progress?.('Controlled smoke completed. The configured model upstream was not contacted.');
486
522
  }
487
- if (report.ok) progress?.(installNextStep(command));
523
+ for (const tool of report.tooling?.filter(check => !check.ok) ?? []) {
524
+ progress?.([tool.detail, tool.remedy].filter(Boolean).join(' '));
525
+ }
526
+ if (report.model?.remedy) progress?.(report.model.remedy);
527
+ if (report.ok) progress?.(installNextStep(command, report.mode));
488
528
  }
489
529
  return report;
490
530
  }
@@ -37,12 +37,15 @@ try {
37
37
  const manifestPath = join(staged, 'package.json');
38
38
  const lockPath = join(staged, 'npm-shrinkwrap.json');
39
39
  const manifest = JSON.parse(await readFile(manifestPath, 'utf8'));
40
+ // Service images compile TypeScript. The Pi installation belongs to the executor.
41
+ delete manifest.devDependencies?.['@earendil-works/pi-coding-agent'];
42
+ await writeFile(manifestPath, JSON.stringify(manifest, null, 2) + '\n');
43
+ await run('npm', ['install', '--package-lock-only', '--offline', '--ignore-scripts', '--no-audit', '--no-fund'], { cwd: staged });
40
44
  const lock = JSON.parse(await readFile(lockPath, 'utf8'));
41
45
  if (lock.lockfileVersion !== 3 || !lock.packages?.['']) {
42
46
  throw new Error('Release packaging requires a v3 npm shrinkwrap with root package metadata');
43
47
  }
44
48
 
45
- // Only the service-image build stages use the development inputs.
46
49
  await rename(manifestPath, join(staged, 'package.development.json'));
47
50
  await rename(lockPath, join(staged, 'npm-shrinkwrap.development.json'));
48
51
  delete manifest.private;
@@ -16,7 +16,7 @@ function readPackageVersion(): string {
16
16
  // Try the compiled dist/src/core -> package root path next.
17
17
  }
18
18
  }
19
- return '0.5.1';
19
+ return '0.5.2';
20
20
  }
21
21
 
22
22
  export const PACKAGE_VERSION = readPackageVersion();
@@ -165,7 +165,7 @@ export function failureCode(error: unknown, fallback: string) {
165
165
  (errorDiagnostic(error) && /^[a-z][a-z0-9_]{0,79}$/.test(code))) ? code : fallback;
166
166
  }
167
167
 
168
- async function loadConfiguration(directory: string, path: string | undefined): Promise<unknown> {
168
+ export async function loadProjectConfiguration(directory: string, path: string | undefined): Promise<unknown> {
169
169
  if (!path) return undefined;
170
170
  let value: unknown;
171
171
  try {
@@ -290,7 +290,7 @@ export function createProjectHost(definition: ProjectHarness, options: StartupOp
290
290
  await writeFile(path, raw.prompt, { flag: 'wx', mode: 0o600 });
291
291
  promptPath = path;
292
292
  signal.throwIfAborted();
293
- const configuration = options.configuration !== undefined ? validateConfiguration(options.configuration) : await loadConfiguration(options.launchDirectory, options.configPath);
293
+ const configuration = options.configuration !== undefined ? validateConfiguration(options.configuration) : await loadProjectConfiguration(options.launchDirectory, options.configPath);
294
294
  signal.throwIfAborted();
295
295
  let filePolicy;
296
296
  try { filePolicy = resolveFilePolicy((configuration as { filePolicy?: FilePolicy } | undefined)?.filePolicy); }
@@ -63,7 +63,8 @@ export async function projectConfiguration<C>(context: ProjectHarnessContext, de
63
63
  if (!value || typeof value !== 'object' || !('sandbox' in value) || !('models' in value) || !('image' in value)) {
64
64
  throw new Error('Missing sandbox, models or image');
65
65
  }
66
- } catch {
66
+ } catch (error) {
67
+ if (error instanceof ProjectPreflightError) throw error;
67
68
  throw new ProjectPreflightError('INVALID_RUN_CONFIGURATION', 'Configure sandbox, models and image for this Harness');
68
69
  }
69
70
  context.signal.throwIfAborted();
@@ -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 {};