@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
@@ -7,27 +7,34 @@ An AutoResearch Run starts equal peers in separate AnySwarm Sandboxes. Each peer
7
7
  Use a Linux x86-64 machine with Git LFS, Python 3, a local Docker daemon and an existing authenticated OpenSandbox deployment with `dns+nft` egress. Prepare a supported Pi Worker using the normal AnySwarm setup flow. Configure the existing Kimi K3 Responses route using `ANYSWARM_MODEL_URL`, `ANYSWARM_MODEL_TOKEN`, `ANYSWARM_MODEL_PROVIDER=kimi_proxy` and `ANYSWARM_MODEL_ID=k3`. Keep the token in trusted host configuration if your proxy requires one.
8
8
 
9
9
  ```sh
10
- anys -u autoresearch --cmd /prepare
11
- anys -u autoresearch
10
+ anyswarm eject autoresearch --dir ./research-demo
11
+ cd ./research-demo
12
+ npm install
13
+ npm exec -- anyswarm run ./prepare-demo.ts
14
+ npm run start -- --config ./frontiercs2-config.ts --prompt "Run the prepared FrontierCS-2 task." --output-dir ./runs
12
15
  ```
13
16
 
14
17
  Preparation prints prerequisite checks and the resource plan. It reports K3 configuration and HTTP route reachability separately, and reports inference as not attempted. It fetches only the pinned task and shared dependencies, checks the Pumpkin release hash, builds images, completes an independent no-model reference run and checks the authorized submission role. Initial image builds can take several minutes. Rerunning preparation reuses verified materials and images. Reference records are environment evidence. The model receives a clean starter and only public train feedback.
15
18
 
16
- Type `/demo frontiercs2` in the composer. The stream shows peer claims, submitted candidates, patch reads, reviews and train scores. When a candidate becomes available, eligible peers receive a prompt to read and review its exact version. The live Trace shows detailed research, peer messages and reviews. Use `@peer-2 <suggestion>`, `/interrupt peer-2` or `/stop peer-2` to control one peer. The Trace link serves the current Run on loopback. For a remote controller, forward its port over SSH. After the CLI exits, use the printed replay command.
17
-
18
- For a script or pipe, use `anys -u autoresearch --cmd '/demo frontiercs2'`. The live Trace URL goes to stderr. Session events and the final result go to stdout as JSONL.
19
+ The demo configuration selects the clean pinned starter and trusted FrontierCS-2 evaluator. The
20
+ terminal prints Run and Agent milestones. Use `anyswarm trace --root ./runs`
21
+ during or after the Run for peer claims, patches, reviews, train scores and final
22
+ records. For a remote controller, forward the Trace port over SSH.
19
23
 
20
24
  The default smoke budget is four Kimi K3 peers, a shared twelve-minute work window and eight train admissions. The demo records actual model usage without capping the request count. The application reserves additional time for final and cleanup. The result includes every frozen candidate, its hash and author, best candidate, Pumpkin record, final result and cleanup receipt. A valid candidate with a low score is a completed evaluation. A run without a valid candidate returns failure, even when it records an official zero for a selected invalid candidate.
21
25
 
22
26
  ## Run your own project
23
27
 
24
28
  ```sh
25
- anys -u autoresearch --config ./research.ts "Your objective"
26
- anys eject autoresearch --dir ./my-research
29
+ anyswarm --harness autoresearch --config ./research.ts --prompt "Your objective" --output-dir ./runs
30
+ anyswarm eject autoresearch --dir ./my-research
27
31
  ```
28
32
 
29
33
  The trusted TypeScript configuration exports a `ResearchConfiguration` object. Set `targetPath` relative to the invocation directory, `goal`, `direction` (`max` or `min`), optional `targetScore`, shared `budget` with an optional `maxModelRequests`, `model`, `executor`, `image`, `sandbox` and `connection`. The evaluator receives an immutable copy of the patch. Its `train(patch, signal, admitted)` returns `{valid, score, feedback}`. Call `admitted` with the trusted job identifier when one exists. `final(patch, signal)` returns the result of the independent final evaluation. The optional `start` and `close` own evaluator resources. All callbacks run as trusted host code. Run candidate code only inside an evaluator-owned isolated environment. Apply the patch to a fresh copy of the baseline, keep evaluator rules inaccessible to it and honor each supplied abort signal.
30
34
 
31
- The exported `project.ts` is the editable Harness. Install its pinned SDK archive with `npm install` in the export directory, then run `anys -u ./project.ts --cwd /path/to/project --config ./research.ts "Your objective"`. The export includes the FrontierCS-2 adapter and preparation source. The installed CLI hosts the terminal and live Trace.
35
+ The exported `project.ts` is the editable Harness. Run `npm install` in the export directory
36
+ to install the pinned SDK, then run
37
+ `npm run start -- --cwd /path/to/project --config ./research.ts --prompt "Your objective"`.
38
+ The export includes the FrontierCS-2 preparation and adapter sources.
32
39
 
33
40
  See [the requirements](REQUIREMENTS.zh.md).
@@ -1,18 +1,11 @@
1
1
  # AutoResearch 需求
2
2
 
3
- 用户配置目标、可信评测和总预算后,团队自动研究、评测、选择候选并收尾。流式终端显示认领方向、提交候选和 train 反馈,支持向单个成员发送建议、中断当前轮次和停止成员。实时 Trace 提供消息、复核、候选沿用和回执,结束后可回放。
3
+ 用户配置目标、可信评测和总预算后,团队自动研究、评测、选择候选并收尾。单次命令显示运行阶段和清理结果。Trace 提供认领方向、候选、train 反馈、消息、复核和回执,可在运行中查看,结束后回放。SDK 和 RPC 客户端可以向成员发送建议、中断当前轮次或停止成员。
4
4
 
5
5
  FrontierCS-2 demo 固定 `7e48965c7cef2a567c2669c8e2f10b06386289c9` 的 `binary_fuse_filter` 和该版本的 Pumpkin。团队至少四名平级 AnySwarm Worker,同一次 Run 使用真实 `kimi_proxy/k3`,没有统一 Lead。成员自行认领研究方向、交流和选择沿用的成果。Harness 管理资源、共享预算与可信评测。demo 的研究窗口为 12 分钟,官方 train 额度为 8 次,记录模型请求数但不限制次数。官方 train 公开反馈进入看板,final 结果只写入用户记录。
6
6
 
7
- ```sh
8
- anys -u autoresearch --cmd /prepare
9
- anys -u autoresearch --cmd "/demo frontiercs2"
10
- anys -u autoresearch --config ./research.ts "研究目标"
11
- anys eject autoresearch --dir ./my-research
12
- ```
7
+ 参照[快速上手](README.md)准备并运行。
13
8
 
14
9
  验收从候选包开始。独立 reference 完成无模型 train/final。实际 demo 从干净 starter 开始,保存四路真实 K3 活动重叠的证据、至少一次可关联到具体候选的同行复核或采用,以及 Worker 候选、官方 train、最终保存、final 和资源回收的关联记录。记录全队的资源、模型用量与费用。未知回执和待清理资源保留可核对的标识。官方零分作为求解结果记录。
15
10
 
16
- 在交互入口 `anys -u autoresearch` 也可输入 `/prepare` 和 `/demo frontiercs2`。
17
-
18
- 范围以 [#337](https://github.com/AnySwarm/anyswarm/issues/337) 和随后确认的四成员、Agensh 式扁平协作、实时 Trace 为准。终端交互遵循 [#344](https://github.com/AnySwarm/anyswarm/issues/344)。
11
+ 研究范围以 [#337](https://github.com/AnySwarm/anyswarm/issues/337) 和随后确认的四成员、Agensh 式扁平协作、实时 Trace 为准。宿主入口遵循 [#351](https://github.com/AnySwarm/anyswarm/issues/351)。
@@ -17,7 +17,7 @@ export function frontierTrainEvaluation(returned: Record<string, unknown>) {
17
17
  }
18
18
 
19
19
  export async function frontierDemo() {
20
- const ready = await loadPrepared().catch(() => { throw new Error('Prepare the pinned demo first with anys -u autoresearch --cmd /prepare.'); });
20
+ const ready = await loadPrepared().catch(() => { throw new Error('Prepare the pinned demo first with anyswarm run ./prepare-demo.ts.'); });
21
21
  const { budget, paths, saved, starter } = ready;
22
22
  const defaults = defaultResearchConnection();
23
23
  const model = kimiModel();
@@ -9,6 +9,8 @@
9
9
  "research-service.ts",
10
10
  "demo.ts",
11
11
  "prepare.ts",
12
+ "prepare-demo.ts",
13
+ "frontiercs2-config.ts",
12
14
  "frontiercs2.ts",
13
15
  "process.ts"
14
16
  ]
@@ -0,0 +1,4 @@
1
+ import { frontierDemo } from './demo.js';
2
+
3
+ const { configuration } = await frontierDemo();
4
+ export default configuration;
@@ -0,0 +1,15 @@
1
+ import { prepareFrontier } from './prepare.js';
2
+
3
+ const controller = new AbortController();
4
+ const interrupt = (signal: NodeJS.Signals) => {
5
+ process.exitCode = signal === 'SIGINT' ? 130 : 143;
6
+ controller.abort();
7
+ };
8
+ process.on('SIGINT', interrupt).on('SIGTERM', interrupt);
9
+ try {
10
+ const report = await prepareFrontier({ signal: controller.signal, progress: console.error });
11
+ console.log(JSON.stringify(report, null, 2));
12
+ process.exitCode ??= report.ok ? 0 : 2;
13
+ } finally {
14
+ process.off('SIGINT', interrupt).off('SIGTERM', interrupt);
15
+ }
@@ -74,7 +74,7 @@ function paths(home: string, dockerContext: string): FrontierPaths {
74
74
  export async function loadPrepared(home = frontierHome()) {
75
75
  const saved = JSON.parse(await readFile(join(home, 'prepared.json'), 'utf8')) as Prepared;
76
76
  if (saved.version !== 2 || saved.revision !== frontierRevision || saved.pumpkin !== pumpkinPin ||
77
- !/^[a-zA-Z0-9._-]+$/.test(saved.dockerContext)) throw new Error('Run anys autoresearch demo frontiercs2 --prepare to refresh this demo.');
77
+ !/^[a-zA-Z0-9._-]+$/.test(saved.dockerContext)) throw new Error('Run anyswarm autoresearch demo frontiercs2 --prepare to refresh this demo.');
78
78
  const locations = paths(home, saved.dockerContext);
79
79
  const reference = join(home, 'reference');
80
80
  const [bridgeDigest, sourceDigest] = await Promise.all([treeDigest(locations.source), treeDigest(reference)]);
@@ -217,12 +217,12 @@ export async function prepareFrontier({ signal, progress, home = frontierHome()
217
217
  ]);
218
218
  const ok = Boolean(sandbox.apiKey && authenticated.ok && [401, 403].includes(anonymous.status) && sandbox.egressMode === 'dns+nft');
219
219
  await Promise.all([authenticated.body?.cancel(), anonymous.body?.cancel()]);
220
- check('opensandbox', ok, ok ? 'Authenticated Lifecycle endpoint.' : 'Configure an authenticated OpenSandbox with dns+nft egress and run anys doctor.');
220
+ check('opensandbox', ok, ok ? 'Authenticated Lifecycle endpoint.' : 'Configure an authenticated OpenSandbox with dns+nft egress and run anyswarm doctor.');
221
221
  const worker = validContext && await command('docker', ['--context', dockerContext, 'image', 'inspect', '--format', '{{.Id}}', image],
222
222
  { timeoutMs: 8000, signal }).catch(() => undefined);
223
223
  check('worker-image', !!worker && worker.code === 0,
224
224
  worker && worker.code === 0 ? worker.stdout.trim() : 'Select the prepared AnySwarm Worker image for this Docker daemon.');
225
- } catch (error) { check('opensandbox', false, `Check the existing endpoint with anys doctor. ${(error as Error).name}`); }
225
+ } catch (error) { check('opensandbox', false, `Check the existing endpoint with anyswarm doctor. ${(error as Error).name}`); }
226
226
  const report = { ok: false, benchmark: frontierRevision, pumpkin: pumpkinPin, budget, resources, checks, home, modelInference: 'not-attempted' as const };
227
227
  if (checks.some(row => !row.ok)) return report;
228
228
  signal.throwIfAborted();
@@ -3,9 +3,7 @@ import { join, resolve } from 'node:path';
3
3
  import { setTimeout as delay } from 'node:timers/promises';
4
4
  import { createRuntime, createSandbox, getExecutorCapabilities, observeProjectRuntime, ProjectPreflightError, runInput, ServiceRegistry,
5
5
  type CloseReceipt, type Harness, type Profile, type HarnessContext, type HarnessJson, type InterruptReceipt, type JsonValue, type Runtime } from '@anyswarm/core';
6
- import { checkBudget, demoGoal, type ResearchConfiguration } from './config.js';
7
- import { frontierDemo } from './demo.js';
8
- import { prepareFrontier } from './prepare.js';
6
+ import { checkBudget, type ResearchConfiguration } from './config.js';
9
7
  import { appendResearchEvent, candidatePath, createResearch, researchOperations, withDeadline } from './research-service.js';
10
8
 
11
9
  const instructions = `You are one of several equal research peers exploring the same goal. Choose your own concrete direction and coordinate directly with peers.
@@ -41,7 +39,7 @@ function configuration(value: unknown): ResearchConfiguration {
41
39
  !config.evaluator || typeof config.evaluator.train !== 'function' || typeof config.evaluator.final !== 'function' ||
42
40
  !config.executor || !config.image || !config.model || !config.sandbox || !config.connection ||
43
41
  (config.targetScore !== undefined && !Number.isFinite(config.targetScore))) {
44
- throw new ProjectPreflightError('AUTORESEARCH_CONFIG_REQUIRED', 'Use anys -u autoresearch --config ./research.ts with a goal, trusted evaluator and runtime settings, or run /demo frontiercs2.');
42
+ throw new ProjectPreflightError('AUTORESEARCH_CONFIG_REQUIRED', 'Run anyswarm --harness autoresearch --config ./research.ts --prompt <goal> with a trusted evaluator and runtime settings.');
45
43
  }
46
44
  for (const ms of [config.evaluationTimeoutMs, config.closeTimeoutMs]) {
47
45
  if (ms !== undefined && (!Number.isSafeInteger(ms) || ms < 1 || ms > 2_147_483_647)) {
@@ -56,20 +54,6 @@ export function resolveWorkspace({ cwd, configuration }: { cwd: string; configur
56
54
  return typeof target === 'string' && target.trim() ? resolve(cwd, target) : cwd;
57
55
  }
58
56
 
59
- export const slashActions = {
60
- async prepare({ args, signal, progress = console.error }: { args: string; signal: AbortSignal; progress?: (message: string) => void }) {
61
- if (args && args !== 'frontiercs2') throw new Error('Usage: /prepare [frontiercs2]');
62
- const result = await prepareFrontier({ signal, progress });
63
- return result.ok ? result : { kind: 'action-report' as const, exitCode: 2, result };
64
- },
65
- async demo({ args, signal }: { args: string; signal: AbortSignal }) {
66
- if (args !== 'frontiercs2') throw new Error('Usage: /demo frontiercs2');
67
- const { configuration, starter } = await frontierDemo();
68
- signal.throwIfAborted();
69
- return { kind: 'start-run' as const, cwd: starter, prompt: demoGoal, configuration };
70
- },
71
- };
72
-
73
57
  type PeerWork = {
74
58
  controller: AbortController;
75
59
  interrupt?: Promise<InterruptReceipt>;
@@ -280,7 +264,6 @@ export default {
280
264
  : { status: 'unknown', requestId: request.requestId };
281
265
  },
282
266
  });
283
- context.emit({ kind: 'trace.request', runDirectory: context.outputDir });
284
267
  status = 'spawning peers';
285
268
  research.event('run.start');
286
269
  const setup = await Promise.allSettled(peerLabels.map(async label => {
@@ -1,25 +1,33 @@
1
- # Code quickstart
1
+ # Code SDK example
2
2
 
3
- Prepare an OpenSandbox connection, a Pi or Codex Worker, and a model route using AnySwarm's CLI quickstart. On the Linux host that holds your project, open its directory and run:
3
+ Code runs a coding Agent in a writable Sandbox, verifies a candidate on the Linux
4
+ host and applies authorized edits to the project. Ask the lead Agent to delegate
5
+ a separable task when you want an editor to work in parallel. Between turns,
6
+ Code reconciles edits made by the user and returns conflicting paths for review.
4
7
 
5
- ```sh
6
- anys -u code
7
- anys -u code "Add a test for the empty-input case"
8
- ```
9
-
10
- You can also start `anys` and enter `/code`. Enter sends, Alt+Enter adds a line, Ctrl+C interrupts the current task, and `/quit` closes the team. `/diff` prints the latest completed turn's paths, patch preview and full patch location into the conversation. Use `/agents` for the member roster, `@<editor> <message>` to steer an active editor, and `/stop <editor>` to stop that editor. Answer inline verification confirmations with `/y` or `/n`, and editor questions with `/reply <id> <answer>`. Use `/config` and `/doctor` for setup information and `/trace` for Trace Viewer.
11
-
12
- The main Agent edits and tests a copy of your current project in one writable Sandbox. Follow-up requests reuse its conversation. AnySwarm reconciles your files before each turn, including edits you made between turns. To delegate, write a request such as “Ask a subagent to write the regression test while you fix the implementation.” The main Agent can continue while the child works in a separate Sandbox, then collect and review the result. The host checks the integrated changes before writeback. If an edit conflicts with yours, resolve the reported path before retrying.
13
-
14
- The default configuration reads `ANYSWARM_MODEL_URL`, optional `ANYSWARM_MODEL_TOKEN`, `ANYSWARM_MODEL_ID` and `ANYSWARM_MODEL_PROVIDER`. Code-specific `ANYSWARM_CODE_*` equivalents take precedence. Use `anys -u code --config ./trusted.ts` for an explicit model/Sandbox configuration. The application can ask before running a detected `npm test` or `make test`. Set `check` to an argv array in a trusted config to authorize it for each candidate, or set `check: false` to skip verification. Checks run locally with your permissions in a temporary copy. Code copies a supported existing Node dependency installation into that copy. Install the project's dependencies first if the checker reports an unavailable environment. A failed verification leaves the original project files in place. After a successful task, `/quit` returns 0 when cleanup completes and keeps the report location visible.
15
-
16
- To edit the application itself:
8
+ Prepare OpenSandbox, a supported Pi or Codex Worker and a model route. Export the
9
+ source outside the target project and install its pinned SDK.
17
10
 
18
11
  ```sh
19
- anys eject code --dir ./my-code
12
+ anyswarm eject code --dir ./my-code
20
13
  cd ./my-code
21
14
  npm install
22
- anys run ./project.ts --mode tui --lifetime interactive --cwd /path/to/project
15
+ npm run start -- --cwd /path/to/project --config ./trusted.ts --prompt "Add a test for empty input" --output-dir ./runs
16
+ anyswarm trace --root ./runs
23
17
  ```
24
18
 
25
- The exported package uses the SDK bytes from the installed AnySwarm package. Edit `prompts.ts` or `project.ts` and run the same command again to use your version. Keep the exported source outside the project directory if you do not want its files in the project scope.
19
+ The default configuration reads `ANYSWARM_MODEL_URL`, optional
20
+ `ANYSWARM_MODEL_TOKEN`, `ANYSWARM_MODEL_ID` and `ANYSWARM_MODEL_PROVIDER`.
21
+ Code-specific `ANYSWARM_CODE_*` values take precedence. The example command uses
22
+ an explicit trusted config. Set `check` to an argv array to authorize
23
+ verification, or set `check: false` to skip it. Checks run with the host user's
24
+ permissions in a temporary copy and can reuse a supported Node dependency
25
+ installation. A failed check or writeback conflict retains the original files.
26
+ The Run report includes verification, changed paths and the retained diff.
27
+
28
+ For follow-up turns and questions, import the Harness in an application and
29
+ drive it through `createHarnessSession`, or connect to
30
+ `npm run start -- --mode rpc --lifetime interactive --interaction questions`
31
+ with `HarnessRpcClient`. Send the target directory in the RPC `run` input.
32
+ See [HarnessSession clients](../harness-session/README.md) for the protocol and
33
+ [Code architecture](../../docs/architecture/26-code.md) for writeback rules.
@@ -1,11 +1,11 @@
1
1
  # Code 用户需求
2
2
 
3
- 适用范围见 [#336](https://github.com/AnySwarm/anyswarm/issues/336)。用户在自己的项目目录运行 `anys -u code [任务]`,也可以打开 `anys` 后输入 `/code`。共享界面显示项目、执行器和模型。用户可以回答内联问题、用 `/diff` 查看最近一轮的改动,或继续输入。退出时提供清理结果。
3
+ 适用范围见 [#336](https://github.com/AnySwarm/anyswarm/issues/336)。[#351](https://github.com/AnySwarm/anyswarm/issues/351) 将 Code 保留为进阶 SDK 示例。单次运行接收任务和显式配置,多轮输入、问答、差异和成员控制由 SDK 或 RPC 客户端处理。
4
4
 
5
5
  - 一个会话由一个 Runtime 管理。主 Agent 默认在一个可写的隔离工作区读项目、改代码并运行检查。用户可以在聊天中要求委派,主 Agent 可以和独立子 Agent 同时工作,收取结果并审查。用户可针对任意活跃成员发消息、中断或停止。
6
6
  - 每轮以用户当前目录的内容为起点,包含已跟踪文件的未提交修改和未忽略的新文件。宿主比较主 Agent、已收取的子 Agent 结果和实时工作树,合并后按任务授权写回。用户改动冲突时显示路径并保留原文件。
7
7
  - 用户可见改动文件和实际 diff。宿主监督配置或用户确认的检查,并展示命令、退出码和状态。Node 检查可复用受支持的现有依赖安装,缺失时显示校验环境问题。无命令时显示未验证。校验失败时保留原项目文件。
8
- - `Ctrl+C` 请求中断当前轮,之后可以继续输入。`/quit` 等待资源清理。空闲时在成功任务后退出,清理确认后返回 0。会话收尾保留报告、检查结果、已写入的路径和 Trace。
9
- - `anys eject code` 导出完整 TS 应用。作者能在仓库外直接运行、修改并重新执行其副本。
8
+ - 多轮客户端可以请求中断当前轮,之后继续输入,也可停止整个会话并等待清理。单次运行在任务完成、清理确认后返回 0。会话收尾保留报告、检查结果、已写入的路径和 Trace。
9
+ - `anyswarm eject code` 导出完整 TS 应用。作者能在仓库外直接运行、修改并重新执行其副本。
10
10
 
11
11
  验收使用同一个仓库外安装的候选包。用真实项目覆盖默认单 Agent 两轮编辑、用户明确要求并行委派、中断后继续、验证失败、并行成员控制、退出清理和导出源码。记录每轮文件上传下载字节数、实际容器数、峰值内存和最终检查结果。ProgramBench 使用同一 Code 应用,运行状态和官方评分单独记录。
@@ -15,9 +15,9 @@ npm install --ignore-scripts "${ANYSWARM_SDK_ARCHIVE:-@anyswarm/core@0.5.0}"
15
15
  sdk=node_modules/@anyswarm/core
16
16
  cp -R "$sdk"/examples/harness-session demo
17
17
  cd demo
18
- ../node_modules/.bin/anys run ./sdk.ts /absolute/path/to/project 'Run the direct SDK example'
19
- ../node_modules/.bin/anys run ./rpc.ts /absolute/path/to/project 'Run the RPC example'
20
- ../node_modules/.bin/anys run ./terminal.ts /absolute/path/to/project 'Ask me the two business questions'
18
+ ../node_modules/.bin/anyswarm run ./sdk.ts /absolute/path/to/project 'Run the direct SDK example'
19
+ ../node_modules/.bin/anyswarm run ./rpc.ts /absolute/path/to/project 'Run the RPC example'
20
+ ../node_modules/.bin/anyswarm run ./terminal.ts /absolute/path/to/project 'Ask me the two business questions'
21
21
  ```
22
22
 
23
23
  The SDK and RPC programs answer both questions and send a subsequent input
@@ -116,7 +116,7 @@ The external Service remains running after the Harness closes.
116
116
 
117
117
  [`project.ts`](project.ts) consumes the user's directory and prompt.
118
118
  [`handoff.ts`](handoff.ts) is a separate fixed-payload diagnostic, invoked from
119
- the checkout root with `anys run ./examples/messages/handoff.ts`. It seeds a
119
+ the checkout root with `anyswarm run ./examples/messages/handoff.ts`. It seeds a
120
120
  value in the writer's files, then compares the reader's exported `received.txt`
121
121
  byte for byte. Its report goes under `handoff-runs/` unless `ANYSWARM_SDK_OUTPUT`
122
122
  overrides it. The common project runner has its own input and report handling.
@@ -41,8 +41,8 @@ Set `ANYSWARM_NOTES_IMAGE` to your compatible worker image ID and `ANYSWARM_NOTE
41
41
  The sample uses Pi and the configured common model route by default (`openai` / `gpt-5.4` when model labels are omitted). Common `ANYSWARM_MODEL_*` and `ANYSWARM_EXECUTOR` variables take precedence over scoped Notes variables. To run Codex, set `ANYSWARM_NOTES_EXECUTOR=codex` and `ANYSWARM_NOTES_MODEL_ID` to the model served by your endpoint. `ANYSWARM_NOTES_MODEL_PROVIDER` labels the model and defaults to `openai` for Codex. For a custom configuration module, set `executor` and its `models` mapping. The same Reader thread handles both reader inputs. See the [backend guide](../../docs/architecture/16-pi-opensandbox-backend.md#codex-app-server) for the credential and trace contract.
42
42
 
43
43
  ```sh
44
- node_modules/.bin/anys run "$example/main.ts" --help
45
- node_modules/.bin/anys run "$example/main.ts" "$example/config.ts" > notes-result.json
44
+ node_modules/.bin/anyswarm run "$example/main.ts" --help
45
+ node_modules/.bin/anyswarm run "$example/main.ts" "$example/config.ts" > notes-result.json
46
46
  ```
47
47
 
48
48
  `main.ts` imports Runtime, Service Registry and the configurable OpenSandbox backend from the public package exports. `run-input.ts`, `run-report.ts` and `read-result.ts` are editable host modules. The Harness owns the turn order, the Notes manifest and adapter, the role grants and verification. It uses `followUp` on an idle Agent after subscribing, with one input source and a fresh ID. An unknown or queued submission remains explicit and sends no replacement.
@@ -56,7 +56,7 @@ Read the final CLI report from `notes-result.json`. It contains the Runtime iden
56
56
  ```sh
57
57
  runtime_id=$(node -e 'const fs=require("node:fs"); console.log(JSON.parse(fs.readFileSync("notes-result.json","utf8")).runtimeId)')
58
58
  run_dir=$(node -e 'const fs=require("node:fs"),path=require("node:path"); console.log(path.dirname(JSON.parse(fs.readFileSync("notes-result.json","utf8")).reportPath))')
59
- node_modules/.bin/anys run "$example/main.ts" --result "$run_dir" --runtime-id "$runtime_id"
59
+ node_modules/.bin/anyswarm run "$example/main.ts" --result "$run_dir" --runtime-id "$runtime_id"
60
60
  ```
61
61
 
62
62
  Result inspection reads `harness-report.json` and `runtime.json`, checks both recorded identities, and projects business failure, recorded Core status, per-Agent execution/cleanup, pending count and artifact availability. It reports the Harness result's location without printing its content or interpreting business acceptance. Open the indicated Harness report's `result.verifiedFiles` and reader archive to inspect the actual checked deliverables. A pending receipt remains pending even if another recorded receipt later reports complete. This command reads saved files and does not contact or control a running Runtime.
@@ -39,7 +39,7 @@ process. See the maintained [Mathlib service implementation](../../../docs/archi
39
39
 
40
40
  To run the host without a container after building the checkout, use
41
41
  `npm run service:mathlib-search` from the root, or
42
- `../../../node_modules/.bin/anys run ./main.ts` from this directory.
42
+ `../../../node_modules/.bin/anyswarm run ./main.ts` from this directory.
43
43
  The caller supplies the host token with `MATHLIB_SEARCH_TOKEN`, and configures
44
44
  the endpoint in its own service adapter. The application/operator owns the
45
45
  external provider's lifecycle and persistent data; Runtime close does not remove it.
@@ -56,10 +56,13 @@ Open the completed Run, expand **Service states**, and inspect the Board export.
56
56
  Copy this example from the installed SDK as shown above. Configure OpenSandbox and select an installed Worker with setup or `ANYSWARM_WORKER_IMAGE`. Open the example in a regular terminal and run:
57
57
 
58
58
  ```sh
59
- anys -u ./live.ts 'Watch the persistent Board'
59
+ anyswarm --harness ./live.ts --mode rpc --lifetime interactive
60
60
  ```
61
61
 
62
- Enter two short findings in the composer. Each commit appears in the stream with its row ID, and the status header updates the committed count. Use `/stop` to finish and `/trace` to inspect the saved Run. The example uses SQLite and does not spawn an Agent or call a model. SDK and RPC clients can read the live count, recent IDs and commit times through the Service observation hook. The final export remains available to Trace Viewer after the Harness closes.
62
+ Use a [Harness RPC client](../../harness-session/README.md) to start the Run
63
+ and submit two short findings with its input operation. Each commit emits the
64
+ row ID and updates the committed count. Stop the Session, then inspect its saved
65
+ records with `anyswarm trace`.
63
66
 
64
67
  ## Author a different Service
65
68
 
@@ -52,7 +52,7 @@ The example defaults to a local OpenSandbox lifecycle URL of `http://127.0.0.1:8
52
52
  From `examples/subagents/`, run one task.
53
53
 
54
54
  ```sh
55
- ../../node_modules/.bin/anys run ./main.ts \
55
+ ../../node_modules/.bin/anyswarm run ./main.ts \
56
56
  ./config.ts \
57
57
  'Suggest two checks to make before merging a pull request.'
58
58
  ```
@@ -80,7 +80,7 @@ Install the published SDK or a matching source archive as described above. The e
80
80
  ```sh
81
81
  sdk=node_modules/@anyswarm/core
82
82
  example="$sdk"/examples/subagents
83
- node_modules/.bin/anys run "$example/main.ts" "$example/config.ts" --interactive
83
+ node_modules/.bin/anyswarm run "$example/main.ts" "$example/config.ts" --interactive
84
84
  ```
85
85
 
86
86
  The configured `doctor --smoke` path covers Pi projects. The installed Codex example runs through the same local OpenSandbox provider and its own executor. [Codex startup and capabilities](../../docs/architecture/16-pi-opensandbox-backend.md#codex-app-server)
@@ -1,11 +1,12 @@
1
- import { workerImageFor, resolveSandboxConnection } from '@anyswarm/core';
1
+ import { workerImageFor, resolveSandboxConnection, ProjectPreflightError } from '@anyswarm/core';
2
2
 
3
3
  function required(...names: string[]) {
4
4
  for (const name of names) {
5
5
  const value = process.env[name];
6
6
  if (value) return value;
7
7
  }
8
- throw new Error(`Set ${names.join(' or ')} before running the Subagents Harness`);
8
+ throw new ProjectPreflightError('INVALID_RUN_CONFIGURATION',
9
+ `Set ${names.join(' or ')} before running the Subagents Harness.`);
9
10
  }
10
11
 
11
12
  const { image, advertiseHost, publicUrl, endpointSource: _endpointSource, executor: setupExecutor, ...sandbox } = resolveSandboxConnection({}, 'SUBAGENTS');
@@ -13,7 +14,7 @@ const upstream = required('ANYSWARM_MODEL_URL', 'ANYSWARM_SUBAGENTS_MODEL_URL');
13
14
  const token = process.env.ANYSWARM_MODEL_TOKEN ?? process.env.ANYSWARM_SUBAGENTS_MODEL_TOKEN;
14
15
  const executor = process.env.ANYSWARM_EXECUTOR ?? process.env.ANYSWARM_SUBAGENTS_EXECUTOR ?? setupExecutor ?? 'pi';
15
16
  const provider = process.env.ANYSWARM_MODEL_PROVIDER ?? process.env.ANYSWARM_SUBAGENTS_MODEL_PROVIDER ?? 'openai';
16
- const model = process.env.ANYSWARM_MODEL_ID ?? process.env.ANYSWARM_SUBAGENTS_MODEL_ID ?? (executor === 'codex' ? required('ANYSWARM_SUBAGENTS_MODEL_ID', 'ANYSWARM_MODEL_ID') : 'gpt-5.4');
17
+ const model = process.env.ANYSWARM_MODEL_ID ?? process.env.ANYSWARM_SUBAGENTS_MODEL_ID ?? (executor === 'codex' ? required('ANYSWARM_MODEL_ID', 'ANYSWARM_SUBAGENTS_MODEL_ID') : 'gpt-5.4');
17
18
 
18
19
  export default {
19
20
  model: 'default',
@@ -65,8 +65,8 @@ requires `ANYSWARM_SUBSTRATE_RUN`; it is not the input to the normal project com
65
65
  From this directory after building:
66
66
 
67
67
  ```sh
68
- ../../node_modules/.bin/anys run ./main.ts --help
69
- ../../node_modules/.bin/anys run ./main.ts ./config.ts
68
+ ../../node_modules/.bin/anyswarm run ./main.ts --help
69
+ ../../node_modules/.bin/anyswarm run ./main.ts ./config.ts
70
70
  ```
71
71
 
72
72
  For an installed package, replace `../../dist/examples/substrate` with
@@ -4,37 +4,49 @@ Personal receives GitHub Issue and linked PR requests in the background. The use
4
4
 
5
5
  ## Connect and start
6
6
 
7
- Use Node.js 22.19 or later, Git and an existing Pi/OpenSandbox connection. Run `anys setup --backend pi` for host setup. This candidate's end-to-end acceptance uses Linux. Set `ANYSWARM_MODEL_URL` to the full Responses endpoint and `ANYSWARM_MODEL_ID` to the model ID. Optional `ANYSWARM_MODEL_PROVIDER`, `ANYSWARM_MODEL_TOKEN` and `ANYSWARM_MODEL_HEADERS_JSON` follow the model provider. For a reasoning model outside the built-in model catalog, set `ANYSWARM_MODEL_REASONING=true`. Keep credentials in the host environment or credential manager.
7
+ Use Node.js 22.19 or later, Git and an existing Pi/OpenSandbox connection. Run `anyswarm setup --backend pi` for host setup. This candidate's end-to-end acceptance uses Linux. Set `ANYSWARM_MODEL_URL` to the full Responses endpoint and `ANYSWARM_MODEL_ID` to the model ID. Optional `ANYSWARM_MODEL_PROVIDER`, `ANYSWARM_MODEL_TOKEN` and `ANYSWARM_MODEL_HEADERS_JSON` follow the model provider. For a reasoning model outside the built-in model catalog, set `ANYSWARM_MODEL_REASONING=true`. Keep credentials in the host environment or credential manager.
8
8
 
9
- Open `anys`, enter `/super`, then use the composer:
9
+ Export the SDK example and install its pinned dependencies. Run the operator
10
+ from the same launch directory for each command.
10
11
 
11
- ```text
12
- /setup --repo owner/project --path README.md
13
- /start
14
- /jobs
12
+ ```sh
13
+ anyswarm eject super --dir ./personal-src
14
+ cd ./personal-src
15
+ npm install
16
+ npm exec -- anyswarm run ./operator.ts setup --repo owner/project --path README.md
17
+ npm exec -- anyswarm run ./operator.ts start
18
+ npm exec -- anyswarm run ./operator.ts jobs
15
19
  ```
16
20
 
17
- For scripts, use the same actions through `anys -u super --cmd`, for example `anys -u super --cmd '/jobs #123'`. `/setup` infers the repository from a GitHub `origin` when available and defaults to the authenticated GitHub login and `README.md`. Use repeated `--user` or `--path` to allow other logins or up to eight existing UTF-8 files. Set `ANYSWARM_SUPER_GITHUB_TOKEN` or use an existing GitHub CLI login. Allow Issues and Pull requests read/write for conversations and Contents read for files. Creating or updating a Draft PR also needs Contents and Pull requests write.
18
-
19
- `/setup` reports the verified GitHub identity, repository, comments and requested files. It validates the local Pi and model configuration and gives the fix for an invalid setting. GitHub reply and PR writes stay unverified until the corresponding operations succeed. `/start` initializes the Runtime. A real work item verifies Worker and model connectivity. `/jobs` and `/logs` show the most recent background failure stage and its repair hint.
21
+ Setup can infer the repository from a GitHub `origin`. It defaults to the
22
+ authenticated GitHub login and `README.md`. Use repeated `--user` or `--path` to
23
+ allow other logins or up to eight existing UTF-8 files. Set
24
+ `ANYSWARM_SUPER_GITHUB_TOKEN` or use an existing GitHub CLI login. Allow Issues
25
+ and Pull requests read/write and Contents read. Draft PR publication also
26
+ needs Contents and Pull requests write. Setup verifies identity, reads, Pi and
27
+ local model configuration. The first real work item verifies Worker and model
28
+ connectivity. `jobs` and `logs` show the last background failure and its repair hint.
20
29
 
21
30
  ## Work with the Router
22
31
 
23
- Post `/super Update the installation instructions` on an Issue in scope or enter `/ask #123 Update the installation instructions` in the composer. GitHub follows the original Issue or its bound Draft PR. In the terminal, `@router #123 Add a Linux example` sends a follow-up through the same inbox. Use `#<issue>` or an unambiguous work ID prefix in place of `#123` for an existing work item.
24
-
25
- When the Router asks a question, use `/answer #123 <text>` or answer its decision card. Personal sends the verified patch and Reviewer findings to the local approval card. Use `/approve #123` to let the host publish this patch and post a follow-up receipt. `/reject #123 [reason]` records the rejection locally. Use `--publish` at setup if you want automatic publication for the configured repository. `/jobs [work]` shows the artifact, decisions and reply receipts. `/stop-work <work>` stops a single work item.
32
+ Post `/super Update the installation instructions` on an Issue in scope, or run
33
+ `npm exec -- anyswarm run ./operator.ts ask '#123' Update the installation instructions`.
34
+ GitHub follows the original Issue or its bound Draft PR. Use the same operator
35
+ with `jobs '#123'` to view status, artifacts and decisions, `answer '#123' <text>`
36
+ to respond, `approve '#123'` to publish, or `reject '#123' [reason]` to decline.
37
+ An unambiguous work ID prefix also works. Setup's `--publish` opts into automatic
38
+ publication.
26
39
 
27
- Type `q` or `/quit` to detach. Use `/stop` to stop the daemon and `/logs` for its log path. `/trace` opens the Trace Viewer at the attached Personal instance's Runtime records. Every Runtime has a bounded model request budget.
40
+ Use `stop-work <work>` to stop one item, `logs` for the daemon log path, and
41
+ `npm exec -- anyswarm run ./operator.ts stop` to stop the daemon and wait for
42
+ its cleanup receipt. Use `anyswarm trace --root <state-directory>/runs` to
43
+ inspect Runtime records. The daemon keeps running between operator commands.
28
44
 
29
45
  State is keyed by the launch directory and lives under `$XDG_STATE_HOME/anyswarm/personal` or `~/.local/state/anyswarm/personal`. To reuse state across launch directories, set `ANYSWARM_SUPER_STATE_DIR` to the same absolute, private path. Stop an older candidate before starting a new version against its state. A restart retains tasks, verified artifacts, decisions and pending replies. Unknown GitHub mutations are reconciled by identity. Personal reads a newly linked PR's comments even if it has already advanced the repository cursor during recovery. The original Sandbox can require cleanup after a crash. Same-host recovery uses the original Worker-reachable address and `ANYSWARM_SUPER_CALLBACK_PORT` when set.
30
46
 
31
- ## Edit your copy
32
-
33
- ```sh
34
- anys eject super --dir ./personal-src
35
- cd ./personal-src
36
- npm install
37
- npm run start
38
- ```
47
+ ## SDK clients
39
48
 
40
- The SDK-bound export includes the TypeScript Harness, Slash Actions and GitHub adapter. `npm run start` opens the shared terminal with the exported module. The same module can run in a foreground process with `anys run ./project.ts --prompt 'Run Personal GitHub inbox'`. The exported and installed daemons use the same state lock. The export contains the application sources and SDK provenance.
49
+ Import the exported `project.ts` into an application or use `observe` from
50
+ `daemon.ts` to connect to a running Personal daemon via `HarnessRpcClient`.
51
+ The SDK client can receive live questions and send answers by ID. The
52
+ operator commands and SDK use the same persisted Inbox and ownership lock.
@@ -30,7 +30,7 @@ async function setup(args: string, cwd: string, directory: string, shutdown: Abo
30
30
  guessed = /^(?:https:\/\/github\.com\/|git@github\.com:)([^/]+\/[^/]+?)(?:\.git)?$/.exec(remote)?.[1];
31
31
  } catch { /* A local Git checkout is optional. */ }
32
32
  const repository = values.repo ?? guessed;
33
- if (!repository) return 'Configure GitHub with /setup --repo owner/repo [--path README.md] [--user login] [--publish].';
33
+ if (!repository) return 'Configure GitHub with operator.ts setup --repo owner/repo [--path README.md] [--user login] [--publish].';
34
34
  const paths = values.path?.length ? [...new Set(values.path)] : ['README.md'];
35
35
  const publish = values.publish ?? false;
36
36
  if (paths.length > 8 || paths.some(path => !safePath(path) || path === 'personal-output.patch')) {
@@ -78,7 +78,7 @@ async function setup(args: string, cwd: string, directory: string, shutdown: Abo
78
78
  publicationWrite: repo.permissions?.push === false ? 'repository-push-denied' : 'unverified' },
79
79
  requiredPermissions: publish ? 'Issues and Pull requests: read/write; Contents: read/write'
80
80
  : 'Issues and Pull requests: read/write; Contents: read',
81
- verification: 'After the backend configuration is valid, /start initializes the Runtime. A real work item verifies Worker, model and reply connectivity. An approved publication verifies PR write access.' };
81
+ verification: 'After the backend configuration is valid, start initializes the Runtime. A real work item verifies Worker, model and reply connectivity. An approved publication verifies PR write access.' };
82
82
  }
83
83
 
84
84
  function directoryFor(cwd: string) {
@@ -107,9 +107,9 @@ async function start(cwd: string, directory: string, signal: AbortSignal) {
107
107
  let exited = false;
108
108
  try {
109
109
  const cli = fileURLToPath(new URL('../../scripts/anyswarm.js', import.meta.resolve('@anyswarm/core')));
110
- const project = fileURLToPath(new URL('./project.js', import.meta.url));
111
- const entry = existsSync(project) ? project : fileURLToPath(new URL('./project.ts', import.meta.url));
112
- const child = spawn(process.execPath, [cli, '-u', entry, '--cmd', '/serve'], {
110
+ const project = fileURLToPath(new URL('./operator.js', import.meta.url));
111
+ const entry = existsSync(project) ? project : fileURLToPath(new URL('./operator.ts', import.meta.url));
112
+ const child = spawn(process.execPath, [cli, 'run', entry, 'serve'], {
113
113
  cwd, detached: true, stdio: ['ignore', log, log],
114
114
  env: { ...process.env, ANYSWARM_PERSONAL_DAEMON: '1', ANYSWARM_SUPER_STATE_DIR: directory, ANYSWARM_PERSONAL_LAUNCH: launchId },
115
115
  });
@@ -134,8 +134,8 @@ async function start(cwd: string, directory: string, signal: AbortSignal) {
134
134
  }
135
135
  const diagnostic = lastStartupFailure(directory);
136
136
  if (diagnostic?.launchId === launchId) throw new Error(`${diagnostic.phase}: ${diagnostic.hint}`);
137
- if (failure) throw new Error('Personal could not launch its background process. Check the Node installation and /logs.');
138
- throw new Error('Personal did not become ready. Use /jobs and /logs for diagnostics.');
137
+ if (failure) throw new Error('Personal could not launch its background process. Check the Node installation and operator.ts logs.');
138
+ throw new Error('Personal did not become ready. Use operator.ts jobs and logs for diagnostics.');
139
139
  }
140
140
 
141
141
  async function jobs({ args, cwd, signal }: ActionContext) {
@@ -159,13 +159,13 @@ async function send(command: string, { args, cwd, signal }: ActionContext) {
159
159
  const client = await probe(cwd, signal);
160
160
  if (!client) {
161
161
  signal.throwIfAborted();
162
- if (command === 'stop') return { state: 'stopped', verification: 'Use /jobs for the last cleanup receipt.' };
163
- throw new Error('Start Personal with /start first.');
162
+ if (command === 'stop') return { state: 'stopped', verification: 'Use operator.ts jobs for the last cleanup receipt.' };
163
+ throw new Error('Start Personal with operator.ts start first.');
164
164
  }
165
165
  try {
166
166
  const request = { requestId: randomUUID() };
167
167
  if (command === 'stop') {
168
- if (args) throw new Error('Use /stop to stop Personal or /stop-work <work> to stop one work item.');
168
+ if (args) throw new Error('Use stop to stop Personal or stop-work <work> to stop one work item.');
169
169
  const completion = client.session.completion;
170
170
  const receipt = await client.session.stop({ ...request, reason: 'owner_stop' });
171
171
  const result = await completion;
@@ -181,7 +181,7 @@ export function personalActions(definition: Harness) {
181
181
  return {
182
182
  setup: ({ args, cwd, signal }: ActionContext) => setup(args, cwd, directoryFor(cwd), signal),
183
183
  start: ({ args, cwd, signal }: ActionContext) => {
184
- if (args) throw new Error('Use /start without arguments.');
184
+ if (args) throw new Error('Use start without arguments.');
185
185
  return start(cwd, directoryFor(cwd), signal);
186
186
  },
187
187
  jobs,
@@ -25,17 +25,17 @@ export class PersonalConfigurationError extends Error {
25
25
 
26
26
  export function backendDiagnostic(error: unknown) {
27
27
  if (error instanceof PersonalConfigurationError) return { code: error.code, hint: error.message };
28
- return { code: 'PERSONAL_BACKEND_CONFIG_INVALID', hint: 'Review the Pi and OpenSandbox configuration with anys doctor. Select Pi with anys setup --backend pi.' };
28
+ return { code: 'PERSONAL_BACKEND_CONFIG_INVALID', hint: 'Review the Pi and OpenSandbox configuration with anyswarm doctor. Select Pi with anyswarm setup --backend pi.' };
29
29
  }
30
30
 
31
31
  export function runtimeOptions(outputDir: string) {
32
32
  if (process.env.ANYSWARM_EXECUTOR && process.env.ANYSWARM_EXECUTOR !== 'pi') {
33
- throw new PersonalConfigurationError('PERSONAL_PI_REQUIRED', 'Personal requires Pi. Run anys setup --backend pi and select Pi in ANYSWARM_EXECUTOR.');
33
+ throw new PersonalConfigurationError('PERSONAL_PI_REQUIRED', 'Personal requires Pi. Run anyswarm setup --backend pi and select Pi in ANYSWARM_EXECUTOR.');
34
34
  }
35
35
  const { image, executor: configured, advertiseHost, publicUrl, endpointSource: _source, ...sandbox } =
36
36
  resolveSandboxConnection({}, 'SUPER');
37
37
  const executor = process.env.ANYSWARM_EXECUTOR ?? configured ?? 'pi';
38
- if (executor !== 'pi') throw new PersonalConfigurationError('PERSONAL_PI_REQUIRED', 'Personal requires Pi. Run anys setup --backend pi.');
38
+ if (executor !== 'pi') throw new PersonalConfigurationError('PERSONAL_PI_REQUIRED', 'Personal requires Pi. Run anyswarm setup --backend pi.');
39
39
  const url = process.env.ANYSWARM_MODEL_URL;
40
40
  const model = process.env.ANYSWARM_MODEL_ID;
41
41
  if (!url || !model) throw new PersonalConfigurationError('PERSONAL_MODEL_CONFIG_MISSING',
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "apiVersion": 1,
3
3
  "entry": "project.ts",
4
- "files": ["project.ts", "config.ts", "prompts.ts", "inbox.ts", "outbox.ts", "github.ts", "artifact.ts", "coordinator.ts", "execution.ts", "location.ts", "actions.ts", "daemon.ts", "decisions.ts", "README.md"]
4
+ "files": ["project.ts", "config.ts", "prompts.ts", "inbox.ts", "outbox.ts", "github.ts", "artifact.ts", "coordinator.ts", "execution.ts", "location.ts", "actions.ts", "operator.ts", "daemon.ts", "decisions.ts", "README.md"]
5
5
  }
@@ -32,7 +32,7 @@ export function loadSettings(root: string): PersonalSettings {
32
32
  try { return JSON.parse(readFileSync(fd, 'utf8')); }
33
33
  finally { closeSync(fd); }
34
34
  } catch {
35
- throw new Error('Run /setup in Personal or anys -u super --cmd "/setup --repo owner/repo".');
35
+ throw new Error('Run anyswarm run ./operator.ts setup --repo owner/repo.');
36
36
  }
37
37
  }
38
38