@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.
Files changed (301) hide show
  1. package/AGENTS.md +20 -5
  2. package/README.md +69 -55
  3. package/dist/examples/README.md +138 -77
  4. package/dist/examples/authoring/README.md +4 -4
  5. package/dist/examples/autoresearch/README.md +108 -16
  6. package/dist/examples/autoresearch/REQUIREMENTS.zh.md +13 -12
  7. package/dist/examples/autoresearch/config.d.ts +48 -5
  8. package/dist/examples/autoresearch/config.js +57 -23
  9. package/dist/examples/autoresearch/demo.d.ts +12 -4
  10. package/dist/examples/autoresearch/demo.js +65 -22
  11. package/dist/examples/autoresearch/eject.json +2 -0
  12. package/dist/examples/autoresearch/frontiercs2-config.d.ts +2 -0
  13. package/dist/examples/autoresearch/frontiercs2-config.js +14 -0
  14. package/dist/examples/autoresearch/frontiercs2.d.ts +18 -1
  15. package/dist/examples/autoresearch/frontiercs2.js +71 -14
  16. package/dist/examples/autoresearch/prepare-demo.d.ts +1 -0
  17. package/dist/examples/autoresearch/prepare-demo.js +46 -0
  18. package/dist/examples/autoresearch/prepare.d.ts +105 -53
  19. package/dist/examples/autoresearch/prepare.js +126 -57
  20. package/dist/examples/autoresearch/project.d.ts +6 -95
  21. package/dist/examples/autoresearch/project.js +131 -45
  22. package/dist/examples/autoresearch/research-service.d.ts +16 -1
  23. package/dist/examples/autoresearch/research-service.js +84 -44
  24. package/dist/examples/code/README.md +25 -17
  25. package/dist/examples/code/REQUIREMENTS.zh.md +3 -3
  26. package/dist/examples/code/config.d.ts +1 -0
  27. package/dist/examples/first-harness/AGENTS.md +25 -0
  28. package/dist/examples/first-harness/README.md +136 -0
  29. package/dist/examples/first-harness/config.d.ts +9 -8
  30. package/dist/examples/first-harness/config.js +33 -26
  31. package/dist/examples/first-harness/eject.json +14 -0
  32. package/dist/examples/first-harness/handoff.js +3 -3
  33. package/dist/examples/first-harness/harness.d.ts +14 -18
  34. package/dist/examples/first-harness/harness.js +102 -77
  35. package/dist/examples/first-harness/input/README.md +7 -0
  36. package/dist/examples/first-harness/session.js +2 -1
  37. package/dist/examples/first-harness/tsconfig.json +2 -1
  38. package/dist/examples/harness-session/README.md +4 -4
  39. package/dist/examples/lead-worker/README.md +1 -1
  40. package/dist/examples/lead-worker/project-config.d.ts +1 -0
  41. package/dist/examples/messages/README.md +2 -2
  42. package/dist/examples/notes/README.md +5 -5
  43. package/dist/examples/notes/config.d.ts +1 -0
  44. package/dist/examples/parallel-swarm/AGENTS.md +32 -0
  45. package/dist/examples/parallel-swarm/README.md +136 -0
  46. package/dist/examples/parallel-swarm/board-service.js +25 -8
  47. package/dist/examples/parallel-swarm/board.d.ts +31 -1
  48. package/dist/examples/parallel-swarm/board.js +98 -13
  49. package/dist/examples/parallel-swarm/config.d.ts +11 -0
  50. package/dist/examples/parallel-swarm/config.js +39 -0
  51. package/dist/examples/parallel-swarm/eject.json +5 -0
  52. package/dist/examples/parallel-swarm/harness.d.ts +26 -20
  53. package/dist/examples/parallel-swarm/harness.js +77 -76
  54. package/dist/examples/parallel-swarm/report.d.ts +12 -0
  55. package/dist/examples/parallel-swarm/report.js +30 -0
  56. package/dist/examples/peermesh/README.md +1 -1
  57. package/dist/examples/peermesh/project-config.d.ts +1 -0
  58. package/dist/examples/services/agent-control/README.md +1 -1
  59. package/dist/examples/services/mathlib-search/README.md +1 -1
  60. package/dist/examples/services/mcp-managed/README.md +1 -1
  61. package/dist/examples/services/persistent-board/README.md +6 -3
  62. package/dist/examples/subagents/AGENTS.md +35 -0
  63. package/dist/examples/subagents/README.md +129 -93
  64. package/dist/examples/subagents/config.d.ts +2 -10
  65. package/dist/examples/subagents/config.js +9 -16
  66. package/dist/examples/subagents/eject.json +17 -0
  67. package/dist/examples/subagents/handoff-config.d.ts +41 -0
  68. package/dist/examples/subagents/handoff-config.js +13 -0
  69. package/dist/examples/subagents/model.d.ts +3 -0
  70. package/dist/examples/subagents/model.js +19 -0
  71. package/dist/examples/substrate/README.md +12 -6
  72. package/dist/examples/substrate/config.d.ts +1 -0
  73. package/dist/examples/substrate/project-config.d.ts +1 -0
  74. package/dist/examples/super/README.md +34 -22
  75. package/dist/examples/super/actions.d.ts +1 -1
  76. package/dist/examples/super/actions.js +11 -11
  77. package/dist/examples/super/config.js +3 -3
  78. package/dist/examples/super/eject.json +1 -1
  79. package/dist/examples/super/location.js +1 -1
  80. package/dist/examples/super/operator.d.ts +1 -0
  81. package/dist/examples/super/operator.js +31 -0
  82. package/dist/examples/super/project.d.ts +0 -107
  83. package/dist/examples/super/project.js +1 -3
  84. package/dist/examples/taskpool/README.md +1 -1
  85. package/dist/examples/taskpool/config.d.ts +1 -0
  86. package/dist/examples/taskpool/deploy/service-hosts/service-authority-snapshot.d.ts +4 -4
  87. package/dist/scripts/anyswarm-arguments.d.ts +7 -25
  88. package/dist/scripts/anyswarm-arguments.js +69 -97
  89. package/dist/scripts/anyswarm-eject.js +1 -1
  90. package/dist/scripts/anyswarm-harnesses.d.ts +0 -1
  91. package/dist/scripts/anyswarm-harnesses.js +1 -22
  92. package/dist/scripts/anyswarm-installation.d.ts +7 -40
  93. package/dist/scripts/anyswarm-installation.js +17 -291
  94. package/dist/scripts/anyswarm-launch.d.ts +6 -36
  95. package/dist/scripts/anyswarm-launch.js +32 -81
  96. package/dist/scripts/anyswarm-progress.d.ts +6 -0
  97. package/dist/scripts/anyswarm-progress.js +133 -0
  98. package/dist/scripts/anyswarm-project.d.ts +1 -9
  99. package/dist/scripts/anyswarm-project.js +40 -127
  100. package/dist/scripts/anyswarm-source-runner.js +9 -41
  101. package/dist/scripts/anyswarm.js +6 -26
  102. package/dist/scripts/build-provenance.json +1 -1
  103. package/dist/scripts/generate-architecture-coverage.js +1 -1
  104. package/dist/scripts/generate-architecture-prompts.js +18 -10
  105. package/dist/scripts/local-environment.d.ts +13 -7
  106. package/dist/scripts/local-environment.js +73 -21
  107. package/dist/scripts/local-setup.d.ts +3 -0
  108. package/dist/scripts/local-setup.js +153 -118
  109. package/dist/scripts/pack-release.js +31 -4
  110. package/dist/src/core/index.js +1 -1
  111. package/dist/src/core/sandbox/opensandbox-backend.js +10 -4
  112. package/dist/src/core/sandbox/sandbox-connection.d.ts +9 -2
  113. package/dist/src/core/sandbox/sandbox-connection.js +22 -7
  114. package/dist/src/core/worker-image.js +1 -1
  115. package/dist/src/harness/project-harness.d.ts +1 -0
  116. package/dist/src/harness/project-harness.js +5 -4
  117. package/dist/src/harness/project-rpc-client.js +19 -0
  118. package/dist/src/harness/project-runtime.js +3 -1
  119. package/dist/src/harness/typescript-loader.d.ts +2 -0
  120. package/dist/src/harness/typescript-loader.js +26 -8
  121. package/dist/src/trace-viewer/command.mjs +6 -3
  122. package/dist/src/trace-viewer/public/app.js +239 -59
  123. package/dist/src/trace-viewer/public/index.html +5 -0
  124. package/dist/src/trace-viewer/public/style.css +22 -0
  125. package/dist/src/trace-viewer/reader.mjs +242 -26
  126. package/dist/src/trace-viewer/run-root.d.mts +1 -0
  127. package/dist/src/trace-viewer/run-root.mjs +7 -0
  128. package/dist/src/trace-viewer/server.mjs +3 -1
  129. package/docs/INDEX.md +11 -9
  130. package/docs/architecture/04-services.md +1 -1
  131. package/docs/architecture/06-observability-experiments.md +21 -7
  132. package/docs/architecture/07-run-configuration.md +118 -19
  133. package/docs/architecture/08-prompts.md +21 -2
  134. package/docs/architecture/10-service-api-reference.md +12 -5
  135. package/docs/architecture/12-code-coverage.md +157 -115
  136. package/docs/architecture/15-core-runtime.md +1 -1
  137. package/docs/architecture/16-pi-opensandbox-backend.md +2 -0
  138. package/docs/architecture/17-harness-reporting.md +79 -1
  139. package/docs/architecture/22-website.md +52 -20
  140. package/docs/architecture/23-project-harness.md +109 -37
  141. package/docs/architecture/26-code.md +20 -5
  142. package/docs/architecture/27-personal.md +23 -8
  143. package/docs/architecture/28-autoresearch.md +18 -12
  144. package/docs/architecture/INDEX.md +1 -2
  145. package/docs/architecture/prompts/11-first-sdk-harness.md +9 -9
  146. package/docs/architecture/prompts/16-parallel-swarm.md +46 -13
  147. package/docs/architecture/prompts/22-autoresearch.md +9 -2
  148. package/docs/architecture/prompts/source-manifest.json +76 -52
  149. package/docs/architecture/source-map.json +445 -105
  150. package/docs/designs/core-harness/01-core.md +2 -2
  151. package/docs/designs/core-harness/06-project-harness.md +3 -3
  152. package/docs/designs/core-harness/README.md +2 -2
  153. package/docs/en/agents.md +1 -1
  154. package/docs/en/autoresearch.md +41 -0
  155. package/docs/en/blog/100b-tokens.md +157 -0
  156. package/docs/en/build-your-harness.md +47 -22
  157. package/docs/en/changelog.md +29 -1
  158. package/docs/en/first-harness.md +40 -32
  159. package/docs/en/harnesses/index.md +23 -23
  160. package/docs/en/harnesses/lead-worker.md +1 -1
  161. package/docs/en/harnesses/peermesh.md +2 -2
  162. package/docs/en/harnesses/subagents.md +10 -31
  163. package/docs/en/harnesses/substrate.md +4 -4
  164. package/docs/en/harnesses/taskpool.md +2 -2
  165. package/docs/en/latest.md +30 -5
  166. package/docs/en/overview.md +22 -22
  167. package/docs/en/quickstart.md +69 -56
  168. package/docs/en/reference/api.md +1 -1
  169. package/docs/en/reference/cli.md +47 -85
  170. package/docs/en/sandbox.md +3 -3
  171. package/docs/en/trace-viewer.md +32 -12
  172. package/docs/operations/trace-viewer.md +26 -11
  173. package/docs/third-party-notices.md +0 -1
  174. package/docs/workflows/development.md +160 -118
  175. package/docs/workflows/release-and-docs-versioning.md +207 -54
  176. package/docs/workflows/release-cli-acceptance.md +162 -0
  177. package/docs/zh/agents.md +1 -1
  178. package/docs/zh/autoresearch.md +41 -0
  179. package/docs/zh/blog/100b-tokens.md +102 -0
  180. package/docs/zh/build-your-harness.md +48 -23
  181. package/docs/zh/changelog.md +29 -1
  182. package/docs/zh/first-harness.md +43 -35
  183. package/docs/zh/harnesses/index.md +23 -23
  184. package/docs/zh/harnesses/lead-worker.md +1 -1
  185. package/docs/zh/harnesses/peermesh.md +2 -2
  186. package/docs/zh/harnesses/subagents.md +10 -31
  187. package/docs/zh/harnesses/substrate.md +4 -4
  188. package/docs/zh/harnesses/taskpool.md +2 -2
  189. package/docs/zh/latest.md +30 -5
  190. package/docs/zh/overview.md +23 -23
  191. package/docs/zh/quickstart.md +66 -57
  192. package/docs/zh/reference/api.md +1 -1
  193. package/docs/zh/reference/cli.md +19 -79
  194. package/docs/zh/sandbox.md +3 -3
  195. package/docs/zh/trace-viewer.md +32 -12
  196. package/examples/README.md +138 -77
  197. package/examples/authoring/README.md +4 -4
  198. package/examples/autoresearch/README.md +108 -16
  199. package/examples/autoresearch/REQUIREMENTS.zh.md +13 -12
  200. package/examples/autoresearch/config.ts +64 -25
  201. package/examples/autoresearch/demo.ts +75 -22
  202. package/examples/autoresearch/eject.json +2 -0
  203. package/examples/autoresearch/frontiercs2-config.ts +15 -0
  204. package/examples/autoresearch/frontiercs2.ts +64 -11
  205. package/examples/autoresearch/prepare-demo.ts +44 -0
  206. package/examples/autoresearch/prepare.ts +134 -60
  207. package/examples/autoresearch/project.ts +120 -44
  208. package/examples/autoresearch/research-service.ts +91 -41
  209. package/examples/code/README.md +25 -17
  210. package/examples/code/REQUIREMENTS.zh.md +3 -3
  211. package/examples/first-harness/AGENTS.md +25 -0
  212. package/examples/first-harness/README.md +136 -0
  213. package/examples/first-harness/config.ts +41 -27
  214. package/examples/first-harness/eject.json +14 -0
  215. package/examples/first-harness/handoff.ts +3 -3
  216. package/examples/first-harness/harness.ts +104 -72
  217. package/examples/first-harness/input/README.md +7 -0
  218. package/examples/first-harness/session.ts +2 -1
  219. package/examples/first-harness/tsconfig.json +2 -1
  220. package/examples/harness-session/README.md +4 -4
  221. package/examples/lead-worker/README.md +1 -1
  222. package/examples/messages/README.md +2 -2
  223. package/examples/notes/README.md +5 -5
  224. package/examples/parallel-swarm/AGENTS.md +32 -0
  225. package/examples/parallel-swarm/README.md +136 -0
  226. package/examples/parallel-swarm/board-service.ts +28 -9
  227. package/examples/parallel-swarm/board.ts +107 -13
  228. package/examples/parallel-swarm/config.ts +47 -0
  229. package/examples/parallel-swarm/eject.json +5 -0
  230. package/examples/parallel-swarm/harness.ts +83 -71
  231. package/examples/parallel-swarm/report.ts +33 -0
  232. package/examples/peermesh/README.md +1 -1
  233. package/examples/services/agent-control/README.md +1 -1
  234. package/examples/services/mathlib-search/README.md +1 -1
  235. package/examples/services/mcp-managed/README.md +1 -1
  236. package/examples/services/persistent-board/README.md +6 -3
  237. package/examples/subagents/AGENTS.md +35 -0
  238. package/examples/subagents/README.md +129 -93
  239. package/examples/subagents/config.ts +9 -15
  240. package/examples/subagents/eject.json +17 -0
  241. package/examples/subagents/handoff-config.ts +14 -0
  242. package/examples/subagents/model.ts +20 -0
  243. package/examples/substrate/README.md +12 -6
  244. package/examples/super/README.md +34 -22
  245. package/examples/super/actions.ts +11 -11
  246. package/examples/super/config.ts +3 -3
  247. package/examples/super/eject.json +1 -1
  248. package/examples/super/location.ts +1 -1
  249. package/examples/super/operator.ts +28 -0
  250. package/examples/super/project.ts +1 -3
  251. package/examples/taskpool/README.md +1 -1
  252. package/npm-shrinkwrap.development.json +46 -1538
  253. package/npm-shrinkwrap.json +10 -43
  254. package/package.development.json +3 -6
  255. package/package.json +3 -5
  256. package/scripts/anyswarm-arguments.ts +67 -96
  257. package/scripts/anyswarm-eject.ts +1 -1
  258. package/scripts/anyswarm-harnesses.ts +1 -18
  259. package/scripts/anyswarm-installation.ts +18 -294
  260. package/scripts/anyswarm-launch.ts +30 -102
  261. package/scripts/anyswarm-progress.ts +125 -0
  262. package/scripts/anyswarm-project.ts +31 -123
  263. package/scripts/anyswarm-source-runner.ts +9 -36
  264. package/scripts/anyswarm.ts +4 -24
  265. package/scripts/generate-architecture-coverage.ts +1 -1
  266. package/scripts/generate-architecture-prompts.ts +21 -10
  267. package/scripts/local-environment.ts +79 -21
  268. package/scripts/local-setup.ts +150 -105
  269. package/scripts/pack-release.ts +28 -4
  270. package/src/core/index.ts +1 -1
  271. package/src/core/sandbox/opensandbox-backend.ts +10 -4
  272. package/src/core/sandbox/sandbox-connection.ts +22 -7
  273. package/src/core/worker-image.ts +1 -1
  274. package/src/harness/project-harness.ts +5 -4
  275. package/src/harness/project-rpc-client.ts +23 -0
  276. package/src/harness/project-runtime.ts +2 -1
  277. package/src/harness/typescript-loader.ts +28 -8
  278. package/src/trace-viewer/command.mjs +6 -3
  279. package/src/trace-viewer/public/app.js +239 -59
  280. package/src/trace-viewer/public/index.html +5 -0
  281. package/src/trace-viewer/public/style.css +22 -0
  282. package/src/trace-viewer/reader.mjs +242 -26
  283. package/src/trace-viewer/run-root.d.mts +1 -0
  284. package/src/trace-viewer/run-root.mjs +7 -0
  285. package/src/trace-viewer/server.mjs +3 -1
  286. package/dist/scripts/anyswarm-applications.d.ts +0 -19
  287. package/dist/scripts/anyswarm-applications.js +0 -19
  288. package/dist/scripts/anyswarm-tui-config.d.ts +0 -36
  289. package/dist/scripts/anyswarm-tui-config.js +0 -189
  290. package/dist/scripts/anyswarm-tui-session.d.ts +0 -66
  291. package/dist/scripts/anyswarm-tui-session.js +0 -304
  292. package/dist/scripts/anyswarm-tui-terminal.d.ts +0 -41
  293. package/dist/scripts/anyswarm-tui-terminal.js +0 -154
  294. package/dist/scripts/anyswarm-tui.d.ts +0 -2
  295. package/dist/scripts/anyswarm-tui.js +0 -1012
  296. package/docs/architecture/25-foreground-tui.md +0 -51
  297. package/scripts/anyswarm-applications.ts +0 -39
  298. package/scripts/anyswarm-tui-config.ts +0 -174
  299. package/scripts/anyswarm-tui-session.ts +0 -295
  300. package/scripts/anyswarm-tui-terminal.ts +0 -147
  301. package/scripts/anyswarm-tui.ts +0 -912
@@ -2,7 +2,7 @@ import { execFile, spawn } from 'node:child_process';
2
2
  import { randomBytes, randomUUID } from 'node:crypto';
3
3
  import { access, lstat, mkdir, readFile, rm, writeFile } from 'node:fs/promises';
4
4
  import { createConnection, isIP } from 'node:net';
5
- import { homedir, platform } from 'node:os';
5
+ import { homedir, platform, release } from 'node:os';
6
6
  import { join } from 'node:path';
7
7
  import { setTimeout as delay } from 'node:timers/promises';
8
8
  import { fileURLToPath } from 'node:url';
@@ -34,16 +34,33 @@ export async function resolveLocalEnvironment(partial = {}, scope) {
34
34
  export function resolveSubagentsEnvironment(config = {}) {
35
35
  return resolveLocalEnvironment(config, 'SUBAGENTS');
36
36
  }
37
- export function checkSetupHost({ requiresLinux = true } = {}) {
37
+ export function checkSetupHost() {
38
38
  const [major, minor] = process.versions.node.split('.').map(Number);
39
39
  const os = platform();
40
40
  return [
41
- requiresLinux
42
- ? check('host.linux', os === 'linux', `Host operating system ${os}`, os === 'darwin' ? 'macOS managed Worker preparation and smoke are not yet available in this build.' : 'Run this command on Linux.')
43
- : check('host.platform', os === 'linux' || os === 'darwin', `Host operating system ${os}`, 'Run this command on Linux or macOS.'),
44
- check('host.node', major > 22 || major === 22 && minor >= 19, `Node.js ${process.versions.node}`, 'Install Node.js 22.19 or newer.'),
41
+ check('host.platform', os === 'linux' || os === 'darwin', `Host operating system ${os} ${release()} (${process.arch})`, 'Run this command on Linux or macOS.'),
42
+ check('host.node', major > 22 || major === 22 && minor >= 19, `Node.js ${process.versions.node} (${process.execPath})`, 'Install Node.js 22.19 or newer.'),
45
43
  ];
46
44
  }
45
+ export async function checkHostTools(signal) {
46
+ return Promise.all(['npm', 'git'].map(async (tool) => {
47
+ const id = `host.${tool}`;
48
+ const remedy = tool === 'npm' ? 'Install Node.js with npm and use that installation on PATH.'
49
+ : 'Install Git before running a project Harness that captures local files.';
50
+ const options = { signal, timeout: 5_000 };
51
+ let path;
52
+ try {
53
+ path = (await execute('/bin/sh', ['-c', 'command -v "$1"', 'anyswarm', tool], options)).stdout.trim();
54
+ const version = (await execute(tool, ['--version'], options)).stdout.trim();
55
+ return check(id, true, `${tool === 'git' ? version : 'npm ' + version} (${path})`);
56
+ }
57
+ catch {
58
+ signal.throwIfAborted();
59
+ const detail = path ? `Could not verify ${tool} at ${path}.` : `${tool} was not found on PATH.`;
60
+ return check(id, false, detail, remedy);
61
+ }
62
+ }));
63
+ }
47
64
  async function dockerInstallRemedy() {
48
65
  const release = await readFile('/etc/os-release', 'utf8').catch(() => '');
49
66
  const id = /^ID="?([a-z0-9_-]+)/m.exec(release)?.[1];
@@ -63,31 +80,64 @@ async function dockerInstallRemedy() {
63
80
  export async function resolveLocalDocker() {
64
81
  const socket = await localDockerSocket();
65
82
  const info = JSON.parse(await run('docker', ['info', '--format', '{{json .}}']));
66
- if (info.OSType !== 'linux')
67
- throw new Error('Local setup needs a Linux Docker Engine.');
83
+ if (info.OSType !== 'linux') {
84
+ throw Object.assign(new Error('Local setup needs a Linux Docker Engine.'), { code: 'DOCKER_OS' });
85
+ }
68
86
  if (darwin && ![nativeArchitecture, ...(nativeArchitecture === 'arm64' ? ['aarch64'] : ['x86_64'])].includes(info.Architecture)) {
69
87
  throw Object.assign(new Error('The Docker daemon does not match the native Mac architecture.'), { code: 'DOCKER_ARCHITECTURE' });
70
88
  }
71
89
  const bridge = darwin ? undefined : JSON.parse(await run('docker', ['network', 'inspect', 'bridge']).catch(() => '[]'))[0];
72
90
  const advertiseHost = bridge?.IPAM?.Config?.find((entry) => isIP(entry.Gateway ?? '') === 4)?.Gateway;
73
- return { socket, advertiseHost, rootless: info.SecurityOptions?.some((value) => value.includes('rootless')) === true };
91
+ return { socket, advertiseHost, rootless: info.SecurityOptions?.some((value) => value.includes('rootless')) === true,
92
+ clientVersion: info.ClientInfo?.Version, context: info.ClientInfo?.Context,
93
+ engineVersion: info.ServerVersion };
74
94
  }
75
95
  export async function checkLocalDocker() {
76
96
  try {
77
97
  const docker = await resolveLocalDocker();
78
- return { docker, diagnostic: check('host.docker-engine', true, `Linux Docker Engine (${docker.rootless ? 'rootless' : 'rootful'})`) };
98
+ const version = /^(\d+)\.(\d+)\./.exec(docker.engineVersion ?? '');
99
+ if (!darwin && docker.rootless && version &&
100
+ (Number(version[1]) < 29 || (Number(version[1]) === 29 && Number(version[2]) < 5))) {
101
+ return { diagnostic: check('host.docker-engine', false, `Rootless Docker Engine ${docker.engineVersion} cannot expose the local OpenSandbox host-network port to this host.`, 'Use Docker Engine 29.5 or newer, a rootful local Docker context, or an existing OpenSandbox endpoint.') };
102
+ }
103
+ const engine = [`Linux Docker Engine`, docker.engineVersion, `(${docker.rootless ? 'rootless' : 'rootful'})`].filter(Boolean).join(' ');
104
+ const client = docker.clientVersion ? `Docker CLI ${docker.clientVersion}` : '';
105
+ const context = docker.context ? `context ${docker.context}` : '';
106
+ return { docker, diagnostic: check('host.docker-engine', true, [engine, client, context].filter(Boolean).join(', ')) };
79
107
  }
80
108
  catch (error) {
81
109
  if (error.code === 'DOCKER_ARCHITECTURE') {
82
110
  return { diagnostic: check('host.docker-engine', false, 'The Docker daemon does not match the native Mac architecture.', 'Select a native local Docker engine for this Mac and run docker info. AnySwarm does not fall back to emulation.') };
83
111
  }
84
- const missing = error.code === 'ENOENT' &&
85
- error.syscall === 'spawn docker';
86
- const remedy = platform() === 'darwin'
87
- ? 'Install Docker Desktop for Mac (https://docs.docker.com/desktop/setup/install/mac-install/), open it, and wait for the engine to start. If you already use another local Linux engine such as OrbStack, start that instead. The Docker CLI alone is not enough. Run docker context show and docker info. If needed, run docker context ls and docker context use <local-context>. Also check any DOCKER_CONTEXT or DOCKER_HOST override.'
88
- : missing ? await dockerInstallRemedy() :
89
- 'Run docker context show and docker info. Start the selected engine or use an authorized local Docker context. For a socket permission error, ask the host administrator to grant access and sign in again after any group change. Then rerun the same anyswarm setup command.';
90
- return { diagnostic: check('host.docker-engine', false, 'Could not access a Linux Docker Engine through the selected local Unix Docker context.', remedy) };
112
+ const { code, syscall, stderr = '' } = error;
113
+ const missing = code === 'ENOENT' && syscall === 'spawn docker';
114
+ const contextRemedy = 'Run docker context show and docker info. If needed, run docker context ls and docker context use <local-context>. Check DOCKER_CONTEXT and DOCKER_HOST overrides.';
115
+ if (code === 'LOCAL_WORKER_UNAVAILABLE') {
116
+ return { diagnostic: check('host.docker-engine', false, 'The selected Docker context does not use a local Unix socket.', contextRemedy) };
117
+ }
118
+ if (code === 'DOCKER_OS') {
119
+ return { diagnostic: check('host.docker-engine', false, 'The selected Docker daemon is not a Linux engine.', contextRemedy) };
120
+ }
121
+ if (code === 'EACCES' || code === 'EPERM' || /permission denied.*(?:socket|docker daemon)|(?:socket|docker daemon).*permission denied/i.test(stderr)) {
122
+ return { diagnostic: check('host.docker-engine', false, 'Permission denied while accessing the local Docker engine.', 'Ask the host administrator to grant socket access. Sign in again after any group change and run docker info as your login user.') };
123
+ }
124
+ let desktopRemedy = 'Install Docker Desktop for Mac (https://docs.docker.com/desktop/setup/install/mac-install/), open it, and wait for the engine to start.';
125
+ if (darwin) {
126
+ const app = 'Docker.app/Contents/Info.plist';
127
+ const installed = await Promise.all(['/Applications', join(homedir(), 'Applications')]
128
+ .map(directory => access(join(directory, app)).then(() => true, () => false)));
129
+ if (installed.some(Boolean)) {
130
+ desktopRemedy = 'Docker Desktop is installed. Open Docker Desktop or wait for its engine to finish starting, then check that its CLI is on PATH.';
131
+ }
132
+ desktopRemedy += ' If you already use another local Linux engine such as OrbStack, start that instead.';
133
+ }
134
+ if (missing) {
135
+ return { diagnostic: check('host.docker-engine', false, 'The Docker CLI was not found on PATH.', darwin ? desktopRemedy + ' ' + contextRemedy : await dockerInstallRemedy()) };
136
+ }
137
+ const unavailable = code === 'ENOENT' || /cannot connect|connection refused|daemon running/i.test(stderr);
138
+ const detail = unavailable ? 'The Docker CLI is installed, but the local daemon or its Unix socket is unavailable.'
139
+ : 'Could not verify the selected local Docker engine.';
140
+ return { diagnostic: check('host.docker-engine', false, detail, (darwin ? desktopRemedy : 'Start the local Docker engine, then verify access as your login user.') + ' ' + contextRemedy) };
91
141
  }
92
142
  }
93
143
  export async function discoverMacCallback(image, signal) {
@@ -198,11 +248,13 @@ async function authenticatedHealth(config, budget) {
198
248
  return error instanceof SandboxApiException && (error.statusCode === 401 || error.statusCode === 403) ? 'denied' : 'unreachable';
199
249
  }
200
250
  }
201
- export async function checkLocalProvider(config, { requireAuth = true } = {}) {
251
+ export async function checkLocalProvider(config, { requireAuth = true, managed = false } = {}) {
202
252
  const [healthy, denied] = await Promise.all([providerHealthy(config, true), requireAuth ? providerHealthy(config, false) : true]);
203
253
  return [
204
- check('provider.health', healthy, healthy ? 'OpenSandbox lifecycle listing is reachable with the configured credentials.' : 'OpenSandbox lifecycle listing failed.', 'Check ANYSWARM_LIFECYCLE_URL (or sandbox.lifecycleBaseUrl in --config), TLS trust, and the lifecycle API key. Rerun the same command.'),
205
- ...(requireAuth ? [check('provider.authentication', denied && !!config.apiKey, denied && config.apiKey ? 'Lifecycle rejects requests without the configured API key.' : 'Lifecycle authentication could not be confirmed.', 'Configure a lifecycle API key on OpenSandbox and pass it through trusted anyswarm configuration.')] : []),
254
+ check('provider.health', healthy, healthy ? 'OpenSandbox lifecycle listing is reachable with the configured credentials.' : 'OpenSandbox lifecycle listing failed.', managed ? 'Run anyswarm setup to start or restore the managed OpenSandbox service.'
255
+ : 'Check ANYSWARM_LIFECYCLE_URL (or sandbox.lifecycleBaseUrl in --config), TLS trust, and the lifecycle API key. Rerun the same command.'),
256
+ ...(requireAuth ? [check('provider.authentication', denied && !!config.apiKey, denied && config.apiKey ? 'Lifecycle rejects requests without the configured API key.' : 'Lifecycle authentication could not be confirmed.', managed ? 'Run anyswarm setup to check the managed service and its local credentials.'
257
+ : 'Configure a lifecycle API key on OpenSandbox and pass it through trusted anyswarm configuration.')] : []),
206
258
  ];
207
259
  }
208
260
  async function withProviderLock(config, action, signal) {
@@ -297,7 +349,7 @@ async function ensureLocalProviderLocked(config, { signal } = {}) {
297
349
  if (error.code !== 'EEXIST')
298
350
  throw error;
299
351
  }
300
- config = { ...config, apiKey: resolveSandboxConnection({ lifecycleBaseUrl: config.lifecycleBaseUrl }).apiKey };
352
+ config = { ...config, apiKey: resolveSandboxConnection({ lifecycleBaseUrl: config.lifecycleBaseUrl }, undefined, { discoverHost: false }).apiKey };
301
353
  }
302
354
  if (!config.apiKey)
303
355
  throw new Error('Could not load the owner-only OpenSandbox lifecycle key.');
@@ -13,6 +13,7 @@ type Timing = {
13
13
  type Model = {
14
14
  configuration: 'complete' | 'missing' | 'invalid';
15
15
  verification: 'not-verified';
16
+ remedy?: string;
16
17
  };
17
18
  export declare function runLocalCommand(command: LocalCommand, signal: AbortSignal, progress?: (message: string) => void): Promise<{
18
19
  command: LocalCommand['command'];
@@ -39,12 +40,14 @@ export declare function runLocalCommand(command: LocalCommand, signal: AbortSign
39
40
  executor: {
40
41
  id: string;
41
42
  version?: string;
43
+ entry?: string;
42
44
  compatibleVersions?: readonly string[];
43
45
  };
44
46
  image: string;
45
47
  filePolicy: ResolvedFilePolicy;
46
48
  };
47
49
  checks: DiagnosticCheck[];
50
+ tooling?: DiagnosticCheck[];
48
51
  timings: Timing[];
49
52
  elapsedMs: number;
50
53
  interrupted: boolean;
@@ -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';
@@ -11,8 +11,9 @@ import { checkLocalExecutor, findExecutorEntry } from '../src/core/sandbox/local
11
11
  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
+ import { readSubagentsModel } from '../examples/subagents/model.js';
14
15
  import { modelClientProtocol } from '../src/core/model/model-transport.js';
15
- import { loadAnySwarmConfig, saveSandboxConnection } from '../src/core/sandbox/sandbox-connection.js';
16
+ import { loadAnySwarmConfig, loopbackLifecycle, saveSandboxConnection } from '../src/core/sandbox/sandbox-connection.js';
16
17
  function modelState(config, executor) {
17
18
  if (config.models === undefined)
18
19
  return { configuration: 'missing', verification: 'not-verified' };
@@ -87,10 +88,12 @@ function reportedHost(value) {
87
88
  if (value && (/^[a-zA-Z0-9._-]+$/.test(value) || isIP(value)))
88
89
  return value;
89
90
  }
90
- function installNextStep(command) {
91
- return command.command === 'setup'
92
- ? 'Run your Harness with the same environment and resolveSandboxConnection(), or repeat the probe with anyswarm doctor --smoke.'
93
- : 'Run your Harness with the same environment.';
91
+ function installNextStep(command, mode) {
92
+ if (command.command !== 'setup')
93
+ return 'Run your Harness with the same environment.';
94
+ return mode === 'local'
95
+ ? 'Run your Harness with the same environment, or repeat the probe with anyswarm doctor --smoke.'
96
+ : 'Run your Harness with the same environment, or check the existing service with anyswarm doctor --mode existing --smoke.';
94
97
  }
95
98
  const phaseLabels = {
96
99
  host: 'Check local Docker',
@@ -99,62 +102,68 @@ const phaseLabels = {
99
102
  worker: 'Prepare Worker image',
100
103
  smoke: 'Start Worker and check Bridge, controlled Gateway, files and deletion',
101
104
  };
105
+ async function probeBackend(selection, signal) {
106
+ try {
107
+ return { selection, version: await checkLocalExecutor(selection, signal) };
108
+ }
109
+ catch (error) {
110
+ signal.throwIfAborted();
111
+ if (error.code !== 'LOCAL_EXECUTOR_UNAVAILABLE')
112
+ throw error;
113
+ return { selection, error: error.message };
114
+ }
115
+ }
116
+ async function backendOnPath(kind, version, signal) {
117
+ let firstFailure;
118
+ let available;
119
+ await findExecutorEntry(kind, async (entry) => {
120
+ const candidate = await probeBackend({ kind, entry, version }, signal);
121
+ if ('version' in candidate) {
122
+ available = candidate;
123
+ return true;
124
+ }
125
+ firstFailure ??= candidate;
126
+ return false;
127
+ });
128
+ return available ?? firstFailure;
129
+ }
102
130
  async function chooseBackend(command, saved, configured, signal) {
103
131
  const explicit = command.command === 'setup' ? command.backend : undefined;
104
- const version = command.command === 'setup' ? command.backendVersion : undefined;
105
- if (command.command === 'setup' && command.backendPath && explicit)
106
- return { kind: explicit, entry: resolve(command.backendPath), version };
107
- const preferred = explicit ?? (configured ? selectExecutorDriver(configured).kind : saved?.kind);
108
- if (preferred && preferred !== 'pi' && preferred !== 'codex')
109
- return;
110
- if (saved && (!preferred || preferred === saved.kind) && !explicit)
111
- return saved;
112
- if (preferred) {
113
- const kind = preferred;
114
- if (version !== undefined) {
115
- const matches = async (entry) => {
116
- try {
117
- await checkLocalExecutor({ kind, entry, version }, signal);
118
- return true;
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;
132
+ const driver = explicit || configured === undefined ? undefined : selectExecutorDriver(configured);
133
+ const preferred = explicit ?? driver?.kind ?? saved?.kind;
134
+ const version = explicit && command.command === 'setup' ? command.backendVersion : driver?.version;
135
+ if (command.command === 'setup' && command.backendPath && explicit) {
136
+ return probeBackend({ kind: explicit, entry: resolve(command.backendPath), version }, signal);
134
137
  }
135
- const installed = (await Promise.all(['pi', 'codex'].map(async (kind) => {
136
- const entry = await findExecutorEntry(kind);
137
- return entry ? { kind, entry } : undefined;
138
- }))).filter(value => value !== undefined);
139
- if (installed.length <= 1)
140
- return installed[0];
138
+ if (preferred === 'pi' || preferred === 'codex') {
139
+ if (saved?.kind === preferred && !explicit)
140
+ return probeBackend({ ...saved, version: version ?? saved.version }, signal);
141
+ if (saved?.kind === preferred && version !== undefined) {
142
+ const candidate = await probeBackend({ ...saved, version }, signal);
143
+ if ('version' in candidate)
144
+ return candidate;
145
+ }
146
+ return await backendOnPath(preferred, version, signal) ??
147
+ { issue: `Could not find the selected ${preferred} executable on PATH.` };
148
+ }
149
+ const detected = await Promise.all(['pi', 'codex'].map(kind => backendOnPath(kind, undefined, signal)));
150
+ const compatible = detected.filter(candidate => candidate !== undefined && 'version' in candidate);
151
+ if (compatible.length === 0) {
152
+ const errors = detected.filter(candidate => candidate !== undefined && 'error' in candidate).map(candidate => candidate.error);
153
+ return { issue: errors.length ? errors.join(' ') : 'Neither Pi nor Codex was found on PATH.' };
154
+ }
155
+ if (compatible.length === 1)
156
+ return compatible[0];
157
+ const selectBackend = { issue: 'Both Pi and Codex have compatible installations. Choose a backend to use.', ambiguous: true };
141
158
  if (command.command !== 'setup' || !stdin.isTTY || !stderr.isTTY)
142
- return;
159
+ return selectBackend;
143
160
  const input = createInterface({ input: stdin, output: stderr });
144
161
  try {
145
- const probes = await Promise.allSettled(installed.map(candidate => checkLocalExecutor(candidate, signal)));
146
- signal.throwIfAborted();
147
- const choices = installed.filter(({ kind, entry }, index) => {
148
- const probe = probes[index];
149
- stderr.write(probe.status === 'fulfilled'
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);
162
+ for (const { selection, version } of compatible) {
163
+ stderr.write(`${selection.kind} ${version} (${selection.entry}) is compatible.\n`);
164
+ }
165
+ const answer = (await input.question('Select a local backend [pi, codex] (pi): ', { signal })).trim() || 'pi';
166
+ return compatible.find(candidate => candidate.selection.kind === answer) ?? selectBackend;
158
167
  }
159
168
  finally {
160
169
  input.close();
@@ -189,7 +198,10 @@ export async function runLocalCommand(command, signal, progress) {
189
198
  let provider;
190
199
  let rootlessDocker = false;
191
200
  let stage = 'config';
201
+ progress?.('Detect host system and AnySwarm configuration…');
192
202
  try {
203
+ checks.push(...checkSetupHost());
204
+ report.tooling = await checkHostTools(signal);
193
205
  const config = command.configPath
194
206
  ? await loadAnySwarmConfig(command.configPath) : undefined;
195
207
  const configured = (config?.executor ?? process.env.ANYSWARM_EXECUTOR);
@@ -205,100 +217,114 @@ export async function runLocalCommand(command, signal, progress) {
205
217
  checks.push({ id: 'config.executor', ok: false, detail: 'Select a configured executor.' });
206
218
  return report;
207
219
  }
220
+ stage = 'connection';
221
+ const configuredPublicUrl = config?.connection?.publicUrl ?? config?.connection?.bridge?.publicUrl ?? config?.connection?.modelGateway?.publicUrl;
208
222
  const environment = await resolveLocalEnvironment({
209
223
  ...config?.sandbox,
210
224
  ...(command.command === 'setup' && command.endpoint ? { endpoint: command.endpoint, lifecycleBaseUrl: undefined } : {}),
211
- publicUrl: command.command === 'setup' ? command.publicUrl ?? config?.connection?.publicUrl : config?.connection?.publicUrl,
225
+ publicUrl: command.command === 'setup' ? command.publicUrl ?? configuredPublicUrl : configuredPublicUrl,
212
226
  image: config?.image,
213
227
  advertiseHost: config?.connection?.advertiseHost ?? config?.connection?.modelGateway?.advertiseHost,
214
228
  });
215
- const mode = (command.command === 'setup' ? command.mode : undefined) ?? environment.mode;
229
+ stage = 'config';
230
+ const hostname = new URL(environment.lifecycleBaseUrl).hostname;
231
+ const loopback = hostname === 'localhost' || hostname === '[::1]' || hostname.startsWith('127.') && isIP(hostname) === 4;
232
+ const reuseExisting = loopback && (environment.management === 'existing' ||
233
+ (!install && environment.mode === 'existing'));
234
+ const mode = command.mode ?? (reuseExisting ? 'existing' : 'local');
216
235
  const smoke = install ? mode === 'local' : command.smoke;
236
+ report.mode = mode;
237
+ report.lifecycleSource = environment.endpointSource;
238
+ if (mode === 'local' && (!loopback || !loopbackLifecycle(environment.lifecycleBaseUrl))) {
239
+ checks.push({ id: 'config.lifecycle', ok: false, detail: 'The selected Lifecycle configuration is outside the managed local HTTP loopback profile.',
240
+ remedy: environment.endpointSource === 'saved'
241
+ ? '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.'
242
+ : '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.' });
243
+ return report;
244
+ }
245
+ if (mode === 'existing' && environment.endpointSource === 'default') {
246
+ checks.push({ id: 'config.lifecycle', ok: false, detail: 'No existing Lifecycle service was configured.',
247
+ remedy: 'Run anyswarm setup for local OpenSandbox, or configure the existing Lifecycle URL and credentials explicitly.' });
248
+ return report;
249
+ }
217
250
  if (command.command === 'setup' && command.backend && mode !== 'local') {
218
- report.mode = mode;
219
251
  checks.push({ id: 'config.executor', ok: false, detail: 'Installation selection requires --mode local with a local Docker engine.',
220
252
  remedy: 'For an existing deployment, use its prepared Worker image.' });
221
253
  return report;
222
254
  }
223
255
  if (command.command === 'setup' && environment.image && (command.backendPath || command.backendVersion)) {
224
- report.mode = mode;
225
256
  checks.push({ id: 'config.executor', ok: false, detail: 'An installation path or version pin requires a locally built Worker.',
226
257
  remedy: 'Remove the configured Worker image to select an installation, or pin the version in the project executor configuration.' });
227
258
  return report;
228
259
  }
229
260
  if (smoke && mode === 'existing' && !environment.image && !driver.adapter) {
230
- report.mode = mode;
231
261
  checks.push({ id: 'config.worker', ok: false, detail: 'An existing service requires an explicitly prepared Worker image.',
232
262
  remedy: 'Set ANYSWARM_WORKER_IMAGE to the image provided by the operator.' });
233
263
  return report;
234
264
  }
235
- if (mode === 'local' && !environment.image && !driver.adapter && (smoke || environment.localExecutor)) {
236
- localExecutor = await chooseBackend(command, environment.localExecutor, configured, signal);
237
- if (!localExecutor) {
238
- report.mode = mode;
239
- checks.push({
240
- id: 'config.executor', ok: false, detail: 'Select a supported local Pi or Codex executable.',
241
- remedy: 'Install Pi or Codex with npm and rerun setup --backend pi|codex. Use --backend-path for a different installation.',
242
- });
243
- return report;
265
+ let localVersion;
266
+ if (mode === 'local' && !environment.image && !driver.adapter) {
267
+ progress?.('Detect an installed Pi or Codex executable…');
268
+ const detected = await chooseBackend(command, environment.localExecutor, configured, signal);
269
+ if ('issue' in detected) {
270
+ const remedy = detected.ambiguous
271
+ ? 'Run anyswarm setup --backend pi or anyswarm setup --backend codex.'
272
+ : '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.';
273
+ checks.push({ id: 'config.executor', ok: false, detail: detected.issue, remedy });
244
274
  }
245
- if (driver.version !== undefined)
246
- localExecutor = { ...localExecutor, version: driver.version };
247
- executor = { kind: localExecutor.kind, version: localExecutor.version };
248
- driver = selectExecutorDriver(executor);
275
+ else {
276
+ localExecutor = detected.selection;
277
+ executor = { kind: localExecutor.kind, version: localExecutor.version };
278
+ driver = selectExecutorDriver(executor);
279
+ if ('error' in detected) {
280
+ checks.push({ id: 'config.executor', ok: false, detail: detected.error,
281
+ remedy: 'Restore the saved executable or select a supported installation with anyswarm setup --backend pi or anyswarm setup --backend codex.' });
282
+ }
283
+ else {
284
+ localVersion = detected.version;
285
+ const detail = `Detected ${localExecutor.kind} ${localVersion} at ${localExecutor.entry}.`;
286
+ checks.push({ id: 'config.executor', ok: true, detail });
287
+ progress?.(detail);
288
+ }
289
+ }
290
+ }
291
+ if (config) {
292
+ report.model = modelState(config, driver.kind);
249
293
  }
250
- if (!config && process.env.ANYSWARM_MODEL_URL) {
251
- const route = {
252
- provider: process.env.ANYSWARM_MODEL_PROVIDER ?? 'openai',
253
- model: process.env.ANYSWARM_MODEL_ID ?? '', protocol: process.env.ANYSWARM_MODEL_PROTOCOL,
254
- upstream: { url: process.env.ANYSWARM_MODEL_URL, headers: {} },
255
- };
294
+ else {
256
295
  try {
257
- snapshotModel(route, driver.kind);
258
- report.model = { configuration: 'complete', verification: 'not-verified' };
296
+ const route = readSubagentsModel(driver.kind);
297
+ if (route)
298
+ snapshotModel(route, driver.kind);
299
+ report.model = { configuration: route ? 'complete' : 'missing', verification: 'not-verified' };
259
300
  }
260
301
  catch {
261
302
  report.model = { configuration: 'invalid', verification: 'not-verified' };
262
303
  }
263
304
  }
264
- else {
265
- report.model = config ? modelState(config, driver.kind) : { configuration: 'missing', verification: 'not-verified' };
305
+ if (report.model.configuration === 'missing') {
306
+ report.model.remedy = config ? 'Set an upstream endpoint for each active model route in the trusted configuration.'
307
+ : 'Before running the Quickstart Harness, set ANYSWARM_MODEL_URL and ANYSWARM_MODEL_ID. Set ANYSWARM_MODEL_TOKEN if the endpoint requires authentication.';
266
308
  }
267
309
  if (report.model?.configuration === 'invalid')
268
310
  checks.push({
269
311
  id: 'config.models', ok: false, detail: 'An active model alias, capability declaration or protocol endpoint is invalid for the selected executor.',
270
312
  remedy: 'Use a supported executor and protocol combination, and configure an HTTP(S) endpoint without embedded credentials for each active model alias.',
271
313
  });
272
- if (checks.some(check => !check.ok))
273
- return report;
274
- if (config) {
314
+ if (config && report.model.configuration !== 'invalid') {
275
315
  const { lifecycleBaseUrl, apiKey, endpointHost } = environment;
276
316
  checks.push(checkProjectRuntime({
277
- ...config, executor, connection: { ...config.connection, publicUrl: environment.publicUrl },
317
+ ...config, executor, connection: { ...config.connection, publicUrl: environment.publicUrl,
318
+ advertiseHost: environment.advertiseHost },
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, compatibleVersions: driver.adapter?.compatibleVersions },
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
- const publicUrl = environment.publicUrl ?? config?.connection?.bridge?.publicUrl ?? config?.connection?.modelGateway?.publicUrl;
300
- report.mode = mode;
301
- report.lifecycleSource = environment.endpointSource;
327
+ const publicUrl = environment.publicUrl;
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' && (smoke || darwin)) {
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
- if (!docker.docker)
322
- return report;
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';
@@ -403,14 +426,21 @@ export async function runLocalCommand(command, signal, progress) {
403
426
  // Configuration imports and provider/npm errors can contain credentials.
404
427
  const failure = {
405
428
  config: ['Could not load the project configuration.', 'Check the trusted config.js and adjacent .env file.'],
429
+ connection: ['Could not resolve the OpenSandbox connection.', 'Check the Lifecycle endpoint and Runtime callback settings.'],
406
430
  host: ['Could not complete the host capability checks.', 'Check the installation diagnostics for the selected setup mode.'],
407
431
  worker: ['Could not prepare the compatible Worker image.', 'Check local Docker and the configured Worker image.'],
408
432
  provider: ['Could not prepare or verify a compatible OpenSandbox provider.', 'Run anyswarm doctor to check lifecycle authentication. Ensure the requested endpoint or local port is available.'],
409
433
  smoke: ['Could not complete the infrastructure probe.', 'Check the local OpenSandbox service, Worker image and host network.'],
410
434
  };
411
435
  let [detail, remedy] = failure[stage];
436
+ let checkId = stage;
412
437
  const code = error?.code;
413
- if (code === 'DOCKER_CALLBACK_UNAVAILABLE') {
438
+ if (code === 'HOST_NETWORK_DISCOVERY_FAILED' && stage === 'connection') {
439
+ checkId = 'host.network-discovery';
440
+ detail = 'Could not inspect host network interfaces for the Sandbox callback address.';
441
+ remedy = 'Set ANYSWARM_ADVERTISE_HOST or ANYSWARM_RUNTIME_PUBLIC_URL to an address reachable from the Sandbox, then rerun the command.';
442
+ }
443
+ else if (code === 'DOCKER_CALLBACK_UNAVAILABLE') {
414
444
  detail = 'The Docker container could not resolve a unique Mac callback IPv4 address.';
415
445
  remedy = 'Check host.docker.internal from the selected local engine, or configure a Runtime publicUrl reachable from the Sandbox.';
416
446
  }
@@ -441,7 +471,7 @@ export async function runLocalCommand(command, signal, progress) {
441
471
  remedy = 'Verify that the selected rootless Docker context can start containers and expose the Lifecycle address. Check delegated CPU and memory controllers before retrying.';
442
472
  }
443
473
  if (!signal.aborted)
444
- checks.push({ id: stage, ok: false, detail, remedy });
474
+ checks.push({ id: checkId, ok: false, detail, remedy });
445
475
  // A provider deployment can fail before returning its ownership handle.
446
476
  if (stage === 'provider' && error && typeof error === 'object' && 'cleanup' in error && error.cleanup && typeof error.cleanup === 'object' &&
447
477
  'id' in error.cleanup && typeof error.cleanup.id === 'string' && 'status' in error.cleanup &&
@@ -478,8 +508,13 @@ export async function runLocalCommand(command, signal, progress) {
478
508
  progress?.(`Probe evidence: ${report.smoke.outputDir}`);
479
509
  progress?.('Controlled smoke completed. The configured model upstream was not contacted.');
480
510
  }
511
+ for (const tool of report.tooling?.filter(check => !check.ok) ?? []) {
512
+ progress?.([tool.detail, tool.remedy].filter(Boolean).join(' '));
513
+ }
514
+ if (report.model?.remedy)
515
+ progress?.(report.model.remedy);
481
516
  if (report.ok)
482
- progress?.(installNextStep(command));
517
+ progress?.(installNextStep(command, report.mode));
483
518
  }
484
519
  return report;
485
520
  }