@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
@@ -1,18 +1,18 @@
1
- import { workerImageFor, resolveSandboxConnection } from '@anyswarm/core';
1
+ import { workerImageFor, resolveSandboxConnection, ProjectPreflightError } from '@anyswarm/core';
2
2
  function required(...names) {
3
3
  for (const name of names) {
4
4
  const value = process.env[name];
5
5
  if (value)
6
6
  return value;
7
7
  }
8
- throw new Error(`Set ${names.join(' or ')} before running the Subagents Harness`);
8
+ throw new ProjectPreflightError('INVALID_RUN_CONFIGURATION', `Set ${names.join(' or ')} before running the Subagents Harness.`);
9
9
  }
10
10
  const { image, advertiseHost, publicUrl, endpointSource: _endpointSource, executor: setupExecutor, ...sandbox } = resolveSandboxConnection({}, 'SUBAGENTS');
11
11
  const upstream = required('ANYSWARM_MODEL_URL', 'ANYSWARM_SUBAGENTS_MODEL_URL');
12
12
  const token = process.env.ANYSWARM_MODEL_TOKEN ?? process.env.ANYSWARM_SUBAGENTS_MODEL_TOKEN;
13
13
  const executor = process.env.ANYSWARM_EXECUTOR ?? process.env.ANYSWARM_SUBAGENTS_EXECUTOR ?? setupExecutor ?? 'pi';
14
14
  const provider = process.env.ANYSWARM_MODEL_PROVIDER ?? process.env.ANYSWARM_SUBAGENTS_MODEL_PROVIDER ?? 'openai';
15
- 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');
15
+ 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');
16
16
  export default {
17
17
  model: 'default',
18
18
  maxAgents: Number(process.env.ANYSWARM_SUBAGENTS_MAX_AGENTS ?? 4),
@@ -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.
@@ -44,7 +44,7 @@ declare function jobs({ args, cwd, signal }: ActionContext): Promise<{
44
44
  log: string;
45
45
  }>;
46
46
  export declare function personalActions(definition: Harness): {
47
- setup: ({ args, cwd, signal }: ActionContext) => Promise<"Configure GitHub with /setup --repo owner/repo [--path README.md] [--user login] [--publish]." | {
47
+ setup: ({ args, cwd, signal }: ActionContext) => Promise<"Configure GitHub with operator.ts setup --repo owner/repo [--path README.md] [--user login] [--publish]." | {
48
48
  configured: boolean;
49
49
  source: string;
50
50
  account: string;
@@ -27,7 +27,7 @@ async function setup(args, cwd, directory, shutdown) {
27
27
  catch { /* A local Git checkout is optional. */ }
28
28
  const repository = values.repo ?? guessed;
29
29
  if (!repository)
30
- return 'Configure GitHub with /setup --repo owner/repo [--path README.md] [--user login] [--publish].';
30
+ return 'Configure GitHub with operator.ts setup --repo owner/repo [--path README.md] [--user login] [--publish].';
31
31
  const paths = values.path?.length ? [...new Set(values.path)] : ['README.md'];
32
32
  const publish = values.publish ?? false;
33
33
  if (paths.length > 8 || paths.some(path => !safePath(path) || path === 'personal-output.patch')) {
@@ -87,7 +87,7 @@ async function setup(args, cwd, directory, shutdown) {
87
87
  publicationWrite: repo.permissions?.push === false ? 'repository-push-denied' : 'unverified' },
88
88
  requiredPermissions: publish ? 'Issues and Pull requests: read/write; Contents: read/write'
89
89
  : 'Issues and Pull requests: read/write; Contents: read',
90
- 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.' };
90
+ 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.' };
91
91
  }
92
92
  function directoryFor(cwd) {
93
93
  const directory = stateDirectory(cwd);
@@ -121,9 +121,9 @@ async function start(cwd, directory, signal) {
121
121
  let exited = false;
122
122
  try {
123
123
  const cli = fileURLToPath(new URL('../../scripts/anyswarm.js', import.meta.resolve('@anyswarm/core')));
124
- const project = fileURLToPath(new URL('./project.js', import.meta.url));
125
- const entry = existsSync(project) ? project : fileURLToPath(new URL('./project.ts', import.meta.url));
126
- const child = spawn(process.execPath, [cli, '-u', entry, '--cmd', '/serve'], {
124
+ const project = fileURLToPath(new URL('./operator.js', import.meta.url));
125
+ const entry = existsSync(project) ? project : fileURLToPath(new URL('./operator.ts', import.meta.url));
126
+ const child = spawn(process.execPath, [cli, 'run', entry, 'serve'], {
127
127
  cwd, detached: true, stdio: ['ignore', log, log],
128
128
  env: { ...process.env, ANYSWARM_PERSONAL_DAEMON: '1', ANYSWARM_SUPER_STATE_DIR: directory, ANYSWARM_PERSONAL_LAUNCH: launchId },
129
129
  });
@@ -159,8 +159,8 @@ async function start(cwd, directory, signal) {
159
159
  if (diagnostic?.launchId === launchId)
160
160
  throw new Error(`${diagnostic.phase}: ${diagnostic.hint}`);
161
161
  if (failure)
162
- throw new Error('Personal could not launch its background process. Check the Node installation and /logs.');
163
- throw new Error('Personal did not become ready. Use /jobs and /logs for diagnostics.');
162
+ throw new Error('Personal could not launch its background process. Check the Node installation and operator.ts logs.');
163
+ throw new Error('Personal did not become ready. Use operator.ts jobs and logs for diagnostics.');
164
164
  }
165
165
  async function jobs({ args, cwd, signal }) {
166
166
  const directory = directoryFor(cwd);
@@ -190,14 +190,14 @@ async function send(command, { args, cwd, signal }) {
190
190
  if (!client) {
191
191
  signal.throwIfAborted();
192
192
  if (command === 'stop')
193
- return { state: 'stopped', verification: 'Use /jobs for the last cleanup receipt.' };
194
- throw new Error('Start Personal with /start first.');
193
+ return { state: 'stopped', verification: 'Use operator.ts jobs for the last cleanup receipt.' };
194
+ throw new Error('Start Personal with operator.ts start first.');
195
195
  }
196
196
  try {
197
197
  const request = { requestId: randomUUID() };
198
198
  if (command === 'stop') {
199
199
  if (args)
200
- throw new Error('Use /stop to stop Personal or /stop-work <work> to stop one work item.');
200
+ throw new Error('Use stop to stop Personal or stop-work <work> to stop one work item.');
201
201
  const completion = client.session.completion;
202
202
  const receipt = await client.session.stop({ ...request, reason: 'owner_stop' });
203
203
  const result = await completion;
@@ -216,7 +216,7 @@ export function personalActions(definition) {
216
216
  setup: ({ args, cwd, signal }) => setup(args, cwd, directoryFor(cwd), signal),
217
217
  start: ({ args, cwd, signal }) => {
218
218
  if (args)
219
- throw new Error('Use /start without arguments.');
219
+ throw new Error('Use start without arguments.');
220
220
  return start(cwd, directoryFor(cwd), signal);
221
221
  },
222
222
  jobs,
@@ -10,16 +10,16 @@ export class PersonalConfigurationError extends Error {
10
10
  export function backendDiagnostic(error) {
11
11
  if (error instanceof PersonalConfigurationError)
12
12
  return { code: error.code, hint: error.message };
13
- return { code: 'PERSONAL_BACKEND_CONFIG_INVALID', hint: 'Review the Pi and OpenSandbox configuration with anys doctor. Select Pi with anys setup --backend pi.' };
13
+ return { code: 'PERSONAL_BACKEND_CONFIG_INVALID', hint: 'Review the Pi and OpenSandbox configuration with anyswarm doctor. Select Pi with anyswarm setup --backend pi.' };
14
14
  }
15
15
  export function runtimeOptions(outputDir) {
16
16
  if (process.env.ANYSWARM_EXECUTOR && process.env.ANYSWARM_EXECUTOR !== 'pi') {
17
- throw new PersonalConfigurationError('PERSONAL_PI_REQUIRED', 'Personal requires Pi. Run anys setup --backend pi and select Pi in ANYSWARM_EXECUTOR.');
17
+ throw new PersonalConfigurationError('PERSONAL_PI_REQUIRED', 'Personal requires Pi. Run anyswarm setup --backend pi and select Pi in ANYSWARM_EXECUTOR.');
18
18
  }
19
19
  const { image, executor: configured, advertiseHost, publicUrl, endpointSource: _source, ...sandbox } = resolveSandboxConnection({}, 'SUPER');
20
20
  const executor = process.env.ANYSWARM_EXECUTOR ?? configured ?? 'pi';
21
21
  if (executor !== 'pi')
22
- throw new PersonalConfigurationError('PERSONAL_PI_REQUIRED', 'Personal requires Pi. Run anys setup --backend pi.');
22
+ throw new PersonalConfigurationError('PERSONAL_PI_REQUIRED', 'Personal requires Pi. Run anyswarm setup --backend pi.');
23
23
  const url = process.env.ANYSWARM_MODEL_URL;
24
24
  const model = process.env.ANYSWARM_MODEL_ID;
25
25
  if (!url || !model)
@@ -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
  }
@@ -35,7 +35,7 @@ export function loadSettings(root) {
35
35
  }
36
36
  }
37
37
  catch {
38
- throw new Error('Run /setup in Personal or anys -u super --cmd "/setup --repo owner/repo".');
38
+ throw new Error('Run anyswarm run ./operator.ts setup --repo owner/repo.');
39
39
  }
40
40
  }
41
41
  // Keep ownership in a separate rollback-journal database so Inbox readers and writes remain independent.
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,31 @@
1
+ import { personalActions } from './actions.js';
2
+ import personal from './project.js';
3
+ const actions = personalActions(personal);
4
+ const [command, ...args] = process.argv.slice(2);
5
+ if (!command || !Object.hasOwn(actions, command)) {
6
+ console.error('Usage: anyswarm run ./operator.ts setup|start|jobs|logs|ask|answer|approve|reject|stop-work|stop [arguments]');
7
+ process.exitCode = 2;
8
+ }
9
+ else {
10
+ const controller = new AbortController();
11
+ const interrupt = (signal) => {
12
+ process.exitCode = signal === 'SIGINT' ? 130 : 143;
13
+ controller.abort();
14
+ };
15
+ process.on('SIGINT', interrupt).on('SIGTERM', interrupt);
16
+ try {
17
+ const action = actions[command];
18
+ const result = await action({ args: args.join(' '), cwd: process.cwd(), signal: controller.signal });
19
+ if (result !== undefined)
20
+ console.log(JSON.stringify(result));
21
+ }
22
+ catch (error) {
23
+ if (!controller.signal.aborted) {
24
+ console.error(error instanceof Error ? error.message : 'Personal command failed.');
25
+ process.exitCode = 1;
26
+ }
27
+ }
28
+ finally {
29
+ process.off('SIGINT', interrupt).off('SIGTERM', interrupt);
30
+ }
31
+ }
@@ -1,111 +1,4 @@
1
1
  import { type Harness } from '@anyswarm/core';
2
- import { type PersonalStartupFailure } from './config.js';
3
2
  export { observe } from './daemon.js';
4
3
  declare const personal: Harness;
5
- export declare const slashActions: {
6
- setup: ({ args, cwd, signal }: {
7
- args: string;
8
- cwd: string;
9
- signal: AbortSignal;
10
- }) => Promise<"Configure GitHub with /setup --repo owner/repo [--path README.md] [--user login] [--publish]." | {
11
- configured: boolean;
12
- source: string;
13
- account: string;
14
- repository: string;
15
- users: string[];
16
- paths: string[];
17
- publish: boolean;
18
- backend: {
19
- readonly configuration: 'valid';
20
- readonly executor: 'pi';
21
- readonly connectivity: 'unverified';
22
- } | {
23
- readonly code: string;
24
- readonly hint: string;
25
- readonly executor?: undefined;
26
- readonly configuration: 'invalid';
27
- readonly connectivity: 'unverified';
28
- };
29
- connection: string;
30
- github: {
31
- repositoryRead: string;
32
- commentRead: string;
33
- contentRead: string;
34
- replyWrite: string;
35
- publicationWrite: string;
36
- };
37
- requiredPermissions: string;
38
- verification: string;
39
- }>;
40
- start: ({ args, cwd, signal }: {
41
- args: string;
42
- cwd: string;
43
- signal: AbortSignal;
44
- }) => Promise<{
45
- state: string;
46
- repository: string;
47
- account?: undefined;
48
- runId?: undefined;
49
- } | {
50
- state: string;
51
- repository: string;
52
- account: string;
53
- runId: string | null;
54
- }>;
55
- jobs: ({ args, cwd, signal }: {
56
- args: string;
57
- cwd: string;
58
- signal: AbortSignal;
59
- }) => Promise<{
60
- jobs?: {
61
- id: string;
62
- issue: number;
63
- pull: number | undefined;
64
- branch: string | undefined;
65
- waiting: string | undefined;
66
- artifact: {
67
- patch: string;
68
- sha256: string;
69
- checks: string[];
70
- summary: string | undefined;
71
- review: string | undefined;
72
- } | undefined;
73
- }[] | undefined;
74
- events?: {
75
- id: string;
76
- job: string;
77
- thread: number;
78
- state: "delivered" | "failed" | "prepared" | "queued" | "stopped" | "unknown" | "working";
79
- problem: string | undefined;
80
- result: "completed" | "failed" | "waiting" | undefined;
81
- publish: "approval" | "confirmed" | "queued" | "rejected" | "sending" | "unknown" | undefined;
82
- reply: "confirmed" | "queued" | "sending" | "unknown" | undefined;
83
- comment: string | undefined;
84
- originalComment: string | undefined;
85
- url: string | undefined;
86
- rejectionReason: string | undefined;
87
- }[] | undefined;
88
- conflicts?: Record<string, import("node:sqlite").SQLOutputValue>[] | undefined;
89
- state: string;
90
- settings: import("./config.js").PersonalSettings;
91
- runId: string | null | undefined;
92
- live: import("@anyswarm/core").HarnessJson | undefined;
93
- cleanup: unknown;
94
- startupFailure: {} | undefined;
95
- log: string;
96
- }>;
97
- logs: ({ cwd }: {
98
- args: string;
99
- cwd: string;
100
- signal: AbortSignal;
101
- }) => {
102
- log: string;
103
- startupFailure: PersonalStartupFailure | undefined;
104
- };
105
- serve?: (({ cwd, signal }: {
106
- args: string;
107
- cwd: string;
108
- signal: AbortSignal;
109
- }) => Promise<void>) | undefined;
110
- };
111
4
  export default personal;
@@ -9,7 +9,6 @@ import { memberBackend, personalRuntime } from './execution.js';
9
9
  import { GitHub, GitHubApiError, githubToken } from './github.js';
10
10
  import { openInbox } from './inbox.js';
11
11
  import { loadSettings, lockPersonalState, privateDirectory, stateDirectory } from './location.js';
12
- import { personalActions } from './actions.js';
13
12
  import { personalDecisions } from './decisions.js';
14
13
  import { outbox } from './outbox.js';
15
14
  const json = (value) => JSON.parse(JSON.stringify(value));
@@ -25,7 +24,7 @@ function diagnoseFailure(phase, error) {
25
24
  }
26
25
  if (phase === 'runtime-initialization')
27
26
  return { code: 'PERSONAL_RUNTIME_INIT_FAILED',
28
- hint: 'Run anys doctor --smoke. Check the OpenSandbox endpoint and whether the configured callback port is available.' };
27
+ hint: 'Run anyswarm doctor --smoke. Check the OpenSandbox endpoint and whether the configured callback port is available.' };
29
28
  return { code: 'PERSONAL_PROCESSING_FAILED', hint: 'Check /jobs for work and cleanup receipts, then restart Personal with /start.' };
30
29
  }
31
30
  const personal = {
@@ -249,5 +248,4 @@ const personal = {
249
248
  }
250
249
  },
251
250
  };
252
- export const slashActions = personalActions(personal);
253
251
  export default personal;
@@ -1,5 +1,5 @@
1
1
  export declare const setupUsage: string;
2
- export declare const doctorUsage = "Usage: anyswarm doctor [--config <module>] [--smoke]";
2
+ export declare const doctorUsage = "Usage: anyswarm doctor [--mode local|existing] [--config <module>] [--smoke]";
3
3
  export declare const anyswarmUsage: string;
4
4
  export type LocalCommand = {
5
5
  command: 'setup';
@@ -12,6 +12,7 @@ export type LocalCommand = {
12
12
  backendVersion?: string;
13
13
  } | {
14
14
  command: 'doctor';
15
+ mode?: 'existing' | 'local';
15
16
  configPath?: string;
16
17
  smoke: boolean;
17
18
  };
@@ -24,30 +25,14 @@ type HarnessOptions = {
24
25
  };
25
26
  export type ProjectCommand = HarnessOptions & {
26
27
  command: 'harness';
27
- defaults?: boolean;
28
28
  } & ({
29
- mode: 'foreground' | 'headless';
29
+ mode: 'foreground';
30
30
  cwd?: string;
31
31
  prompt: string;
32
32
  } | {
33
33
  mode: 'rpc';
34
34
  });
35
- export type TuiCommand = Partial<HarnessOptions> & {
36
- command: 'tui';
37
- cwd?: string;
38
- prompt?: string;
39
- };
40
- export type HarnessCommand = HarnessOptions & {
41
- command: 'use';
42
- cwd?: string;
43
- prompt?: string;
44
- } & ({
45
- mode: 'auto' | 'tui' | 'headless' | 'foreground' | 'rpc';
46
- } | {
47
- mode: 'action';
48
- slash: string;
49
- });
50
- type AnySwarmCommand = TuiCommand | HarnessCommand | {
35
+ type AnySwarmCommand = {
51
36
  command: 'run';
52
37
  entryPath: string;
53
38
  args: string[];
@@ -57,17 +42,14 @@ type AnySwarmCommand = TuiCommand | HarnessCommand | {
57
42
  directory: string;
58
43
  } | LocalCommand | {
59
44
  command: 'update';
60
- archive?: string;
61
- sha256?: string;
62
45
  } | ProjectCommand | {
63
46
  command: 'recover';
64
47
  directory: string;
65
48
  configPath: string;
66
49
  };
67
- export declare function isLocalHarness(specifier: string): boolean;
68
- export declare function isHarnessName(specifier: string): boolean;
69
- export declare function parseHarnessSelection(args: string[], selected?: string): HarnessCommand;
70
- export declare function parseAnySwarmCommand(args: string[], registered?: Readonly<Record<string, string>>): AnySwarmCommand | {
50
+ export declare function parseProjectCommand(args: string[], source?: string): ProjectCommand;
51
+ export declare function parseSourceHarnessCommand(args: string[], entry: string): ProjectCommand;
52
+ export declare function parseAnySwarmCommand(args: string[]): AnySwarmCommand | {
71
53
  help: string;
72
54
  };
73
55
  export {};