@anyswarm/core 0.5.2 → 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 (210) hide show
  1. package/AGENTS.md +19 -4
  2. package/README.md +68 -61
  3. package/dist/examples/README.md +134 -84
  4. package/dist/examples/autoresearch/README.md +106 -21
  5. package/dist/examples/autoresearch/REQUIREMENTS.zh.md +14 -6
  6. package/dist/examples/autoresearch/config.d.ts +48 -5
  7. package/dist/examples/autoresearch/config.js +57 -23
  8. package/dist/examples/autoresearch/demo.d.ts +12 -4
  9. package/dist/examples/autoresearch/demo.js +65 -22
  10. package/dist/examples/autoresearch/frontiercs2-config.d.ts +2 -2
  11. package/dist/examples/autoresearch/frontiercs2-config.js +13 -2
  12. package/dist/examples/autoresearch/frontiercs2.d.ts +18 -1
  13. package/dist/examples/autoresearch/frontiercs2.js +71 -14
  14. package/dist/examples/autoresearch/prepare-demo.js +34 -3
  15. package/dist/examples/autoresearch/prepare.d.ts +105 -53
  16. package/dist/examples/autoresearch/prepare.js +126 -57
  17. package/dist/examples/autoresearch/project.d.ts +6 -1
  18. package/dist/examples/autoresearch/project.js +130 -26
  19. package/dist/examples/autoresearch/research-service.d.ts +16 -1
  20. package/dist/examples/autoresearch/research-service.js +84 -44
  21. package/dist/examples/code/config.d.ts +1 -0
  22. package/dist/examples/first-harness/AGENTS.md +25 -0
  23. package/dist/examples/first-harness/README.md +136 -0
  24. package/dist/examples/first-harness/config.d.ts +9 -8
  25. package/dist/examples/first-harness/config.js +33 -26
  26. package/dist/examples/first-harness/eject.json +14 -0
  27. package/dist/examples/first-harness/handoff.js +3 -3
  28. package/dist/examples/first-harness/harness.d.ts +14 -18
  29. package/dist/examples/first-harness/harness.js +102 -77
  30. package/dist/examples/first-harness/input/README.md +7 -0
  31. package/dist/examples/first-harness/session.js +2 -1
  32. package/dist/examples/first-harness/tsconfig.json +2 -1
  33. package/dist/examples/harness-session/README.md +1 -1
  34. package/dist/examples/lead-worker/README.md +1 -1
  35. package/dist/examples/lead-worker/project-config.d.ts +1 -0
  36. package/dist/examples/messages/README.md +2 -2
  37. package/dist/examples/notes/README.md +2 -2
  38. package/dist/examples/notes/config.d.ts +1 -0
  39. package/dist/examples/parallel-swarm/AGENTS.md +32 -0
  40. package/dist/examples/parallel-swarm/README.md +136 -0
  41. package/dist/examples/parallel-swarm/board-service.js +25 -8
  42. package/dist/examples/parallel-swarm/board.d.ts +31 -1
  43. package/dist/examples/parallel-swarm/board.js +98 -13
  44. package/dist/examples/parallel-swarm/config.d.ts +11 -0
  45. package/dist/examples/parallel-swarm/config.js +39 -0
  46. package/dist/examples/parallel-swarm/eject.json +5 -0
  47. package/dist/examples/parallel-swarm/harness.d.ts +26 -20
  48. package/dist/examples/parallel-swarm/harness.js +77 -76
  49. package/dist/examples/parallel-swarm/report.d.ts +12 -0
  50. package/dist/examples/parallel-swarm/report.js +30 -0
  51. package/dist/examples/peermesh/README.md +1 -1
  52. package/dist/examples/peermesh/project-config.d.ts +1 -0
  53. package/dist/examples/services/agent-control/README.md +1 -1
  54. package/dist/examples/services/mathlib-search/README.md +1 -1
  55. package/dist/examples/services/mcp-managed/README.md +1 -1
  56. package/dist/examples/services/persistent-board/README.md +1 -1
  57. package/dist/examples/subagents/AGENTS.md +35 -0
  58. package/dist/examples/subagents/README.md +129 -93
  59. package/dist/examples/subagents/config.d.ts +2 -10
  60. package/dist/examples/subagents/config.js +8 -15
  61. package/dist/examples/subagents/eject.json +17 -0
  62. package/dist/examples/subagents/handoff-config.d.ts +41 -0
  63. package/dist/examples/subagents/handoff-config.js +13 -0
  64. package/dist/examples/subagents/model.d.ts +3 -0
  65. package/dist/examples/subagents/model.js +19 -0
  66. package/dist/examples/substrate/README.md +12 -6
  67. package/dist/examples/substrate/config.d.ts +1 -0
  68. package/dist/examples/substrate/project-config.d.ts +1 -0
  69. package/dist/examples/taskpool/README.md +1 -1
  70. package/dist/examples/taskpool/config.d.ts +1 -0
  71. package/dist/examples/taskpool/deploy/service-hosts/service-authority-snapshot.d.ts +4 -4
  72. package/dist/scripts/anyswarm-progress.js +36 -5
  73. package/dist/scripts/build-provenance.json +1 -1
  74. package/dist/scripts/generate-architecture-coverage.js +1 -1
  75. package/dist/scripts/generate-architecture-prompts.js +18 -10
  76. package/dist/scripts/local-environment.d.ts +3 -3
  77. package/dist/scripts/local-environment.js +6 -1
  78. package/dist/scripts/local-setup.js +25 -18
  79. package/dist/scripts/pack-release.js +27 -3
  80. package/dist/src/core/index.js +1 -1
  81. package/dist/src/core/sandbox/opensandbox-backend.js +10 -4
  82. package/dist/src/core/sandbox/sandbox-connection.d.ts +9 -2
  83. package/dist/src/core/sandbox/sandbox-connection.js +22 -7
  84. package/dist/src/harness/project-harness.js +3 -2
  85. package/dist/src/harness/project-rpc-client.js +19 -0
  86. package/dist/src/harness/typescript-loader.d.ts +2 -0
  87. package/dist/src/harness/typescript-loader.js +26 -8
  88. package/dist/src/trace-viewer/command.mjs +6 -3
  89. package/dist/src/trace-viewer/public/app.js +239 -59
  90. package/dist/src/trace-viewer/public/index.html +5 -0
  91. package/dist/src/trace-viewer/public/style.css +22 -0
  92. package/dist/src/trace-viewer/reader.mjs +242 -26
  93. package/dist/src/trace-viewer/run-root.d.mts +1 -0
  94. package/dist/src/trace-viewer/run-root.mjs +7 -0
  95. package/dist/src/trace-viewer/server.mjs +3 -1
  96. package/docs/INDEX.md +9 -8
  97. package/docs/architecture/06-observability-experiments.md +21 -7
  98. package/docs/architecture/07-run-configuration.md +97 -12
  99. package/docs/architecture/08-prompts.md +21 -2
  100. package/docs/architecture/10-service-api-reference.md +12 -5
  101. package/docs/architecture/12-code-coverage.md +129 -86
  102. package/docs/architecture/15-core-runtime.md +1 -1
  103. package/docs/architecture/16-pi-opensandbox-backend.md +2 -0
  104. package/docs/architecture/17-harness-reporting.md +78 -0
  105. package/docs/architecture/22-website.md +53 -18
  106. package/docs/architecture/23-project-harness.md +63 -16
  107. package/docs/architecture/28-autoresearch.md +16 -22
  108. package/docs/architecture/prompts/11-first-sdk-harness.md +9 -9
  109. package/docs/architecture/prompts/16-parallel-swarm.md +46 -13
  110. package/docs/architecture/prompts/22-autoresearch.md +9 -2
  111. package/docs/architecture/prompts/source-manifest.json +78 -54
  112. package/docs/architecture/source-map.json +396 -36
  113. package/docs/designs/core-harness/06-project-harness.md +1 -1
  114. package/docs/en/autoresearch.md +41 -0
  115. package/docs/en/blog/100b-tokens.md +157 -0
  116. package/docs/en/build-your-harness.md +47 -22
  117. package/docs/en/changelog.md +22 -1
  118. package/docs/en/first-harness.md +40 -32
  119. package/docs/en/harnesses/index.md +23 -23
  120. package/docs/en/harnesses/subagents.md +8 -29
  121. package/docs/en/latest.md +26 -5
  122. package/docs/en/overview.md +22 -22
  123. package/docs/en/quickstart.md +55 -21
  124. package/docs/en/reference/api.md +1 -1
  125. package/docs/en/trace-viewer.md +32 -12
  126. package/docs/operations/trace-viewer.md +25 -10
  127. package/docs/workflows/development.md +160 -120
  128. package/docs/workflows/release-and-docs-versioning.md +207 -55
  129. package/docs/workflows/release-cli-acceptance.md +124 -47
  130. package/docs/zh/autoresearch.md +41 -0
  131. package/docs/zh/blog/100b-tokens.md +102 -0
  132. package/docs/zh/build-your-harness.md +48 -23
  133. package/docs/zh/changelog.md +22 -1
  134. package/docs/zh/first-harness.md +43 -35
  135. package/docs/zh/harnesses/index.md +23 -23
  136. package/docs/zh/harnesses/subagents.md +8 -29
  137. package/docs/zh/latest.md +26 -5
  138. package/docs/zh/overview.md +23 -23
  139. package/docs/zh/quickstart.md +51 -21
  140. package/docs/zh/reference/api.md +1 -1
  141. package/docs/zh/trace-viewer.md +32 -12
  142. package/examples/README.md +134 -84
  143. package/examples/autoresearch/README.md +106 -21
  144. package/examples/autoresearch/REQUIREMENTS.zh.md +14 -6
  145. package/examples/autoresearch/config.ts +64 -25
  146. package/examples/autoresearch/demo.ts +75 -22
  147. package/examples/autoresearch/frontiercs2-config.ts +13 -2
  148. package/examples/autoresearch/frontiercs2.ts +64 -11
  149. package/examples/autoresearch/prepare-demo.ts +32 -3
  150. package/examples/autoresearch/prepare.ts +134 -60
  151. package/examples/autoresearch/project.ts +119 -26
  152. package/examples/autoresearch/research-service.ts +91 -41
  153. package/examples/first-harness/AGENTS.md +25 -0
  154. package/examples/first-harness/README.md +136 -0
  155. package/examples/first-harness/config.ts +41 -27
  156. package/examples/first-harness/eject.json +14 -0
  157. package/examples/first-harness/handoff.ts +3 -3
  158. package/examples/first-harness/harness.ts +104 -72
  159. package/examples/first-harness/input/README.md +7 -0
  160. package/examples/first-harness/session.ts +2 -1
  161. package/examples/first-harness/tsconfig.json +2 -1
  162. package/examples/harness-session/README.md +1 -1
  163. package/examples/lead-worker/README.md +1 -1
  164. package/examples/messages/README.md +2 -2
  165. package/examples/notes/README.md +2 -2
  166. package/examples/parallel-swarm/AGENTS.md +32 -0
  167. package/examples/parallel-swarm/README.md +136 -0
  168. package/examples/parallel-swarm/board-service.ts +28 -9
  169. package/examples/parallel-swarm/board.ts +107 -13
  170. package/examples/parallel-swarm/config.ts +47 -0
  171. package/examples/parallel-swarm/eject.json +5 -0
  172. package/examples/parallel-swarm/harness.ts +83 -71
  173. package/examples/parallel-swarm/report.ts +33 -0
  174. package/examples/peermesh/README.md +1 -1
  175. package/examples/services/agent-control/README.md +1 -1
  176. package/examples/services/mathlib-search/README.md +1 -1
  177. package/examples/services/mcp-managed/README.md +1 -1
  178. package/examples/services/persistent-board/README.md +1 -1
  179. package/examples/subagents/AGENTS.md +35 -0
  180. package/examples/subagents/README.md +129 -93
  181. package/examples/subagents/config.ts +8 -15
  182. package/examples/subagents/eject.json +17 -0
  183. package/examples/subagents/handoff-config.ts +14 -0
  184. package/examples/subagents/model.ts +20 -0
  185. package/examples/substrate/README.md +12 -6
  186. package/examples/taskpool/README.md +1 -1
  187. package/npm-shrinkwrap.development.json +9 -2
  188. package/npm-shrinkwrap.json +9 -2
  189. package/package.development.json +2 -1
  190. package/package.json +2 -1
  191. package/scripts/anyswarm-progress.ts +36 -6
  192. package/scripts/generate-architecture-coverage.ts +1 -1
  193. package/scripts/generate-architecture-prompts.ts +21 -10
  194. package/scripts/local-environment.ts +8 -1
  195. package/scripts/local-setup.ts +22 -17
  196. package/scripts/pack-release.ts +24 -3
  197. package/src/core/index.ts +1 -1
  198. package/src/core/sandbox/opensandbox-backend.ts +10 -4
  199. package/src/core/sandbox/sandbox-connection.ts +22 -7
  200. package/src/harness/project-harness.ts +3 -2
  201. package/src/harness/project-rpc-client.ts +23 -0
  202. package/src/harness/typescript-loader.ts +28 -8
  203. package/src/trace-viewer/command.mjs +6 -3
  204. package/src/trace-viewer/public/app.js +239 -59
  205. package/src/trace-viewer/public/index.html +5 -0
  206. package/src/trace-viewer/public/style.css +22 -0
  207. package/src/trace-viewer/reader.mjs +242 -26
  208. package/src/trace-viewer/run-root.d.mts +1 -0
  209. package/src/trace-viewer/run-root.mjs +7 -0
  210. package/src/trace-viewer/server.mjs +3 -1
@@ -1,109 +1,134 @@
1
1
  import { createHash, randomBytes } from 'node:crypto';
2
2
  import { readFile } from 'node:fs/promises';
3
3
  import { join } from 'node:path';
4
- import { createRuntime, createSandbox, ProjectPreflightError, runInput, ServiceRegistry } from '@anyswarm/core';
4
+ import { createRuntime, createSandbox, projectConfiguration, ProjectPreflightError, runInput, ServiceRegistry } from '@anyswarm/core';
5
5
  import { createHandoff } from './handoff.js';
6
+ const channelPattern = /^[a-z][a-z0-9-]{0,23}$/;
7
+ const json = (value) => JSON.parse(JSON.stringify(value));
8
+ const failed = (code, message) => Object.assign(new Error(message), { code });
6
9
  const firstHarness = {
7
10
  id: 'first-harness', apiVersion: 1, questions: true,
8
11
  async run(context) {
9
- const config = (context.configuration ?? (await import('./config.js')).default);
10
- if (!context.clientCapabilities.questions && !/^[a-z][a-z0-9-]{0,23}$/.test(config.channel ?? '')) {
11
- throw new ProjectPreflightError('INVALID_RUN_CONFIGURATION', 'Set ANYSWARM_FIRST_CHANNEL for noninteractive execution');
12
+ const config = await projectConfiguration(context, () => import('./config.js'));
13
+ const presetChannel = config.channel ?? 'preview';
14
+ if (!context.clientCapabilities.questions && !channelPattern.test(presetChannel)) {
15
+ throw new ProjectPreflightError('INVALID_RUN_CONFIGURATION', 'Set channel or ANYSWARM_FIRST_CHANNEL to a lowercase release channel such as preview or beta-east (at most 24 characters).');
16
+ }
17
+ if (!config.models || typeof config.models !== 'object' || Array.isArray(config.models) || typeof config.model !== 'string') {
18
+ throw new ProjectPreflightError('INVALID_RUN_CONFIGURATION', 'Provide a models map and select one of its aliases with model.');
19
+ }
20
+ const model = config.models[config.model];
21
+ const protocol = model?.protocol && typeof model.protocol === 'object' ? model.protocol.clientProtocol : model?.protocol ?? 'responses';
22
+ const executor = typeof config.executor === 'string' ? config.executor : config.executor?.kind;
23
+ if (!Object.hasOwn(config.models, config.model) || !model || model.protocol === null ||
24
+ (executor === 'codex' && protocol !== 'responses') ||
25
+ (executor === 'pi' && protocol !== 'responses' && protocol !== 'chat-completions')) {
26
+ throw new ProjectPreflightError('INVALID_RUN_CONFIGURATION', 'Select a configured model alias. Codex requires the Responses protocol; Pi also supports Chat Completions.');
12
27
  }
13
28
  const reference = randomBytes(6).toString('hex');
14
29
  const handoff = createHandoff();
15
30
  const services = new ServiceRegistry();
16
31
  services.register('handoff', handoff.service, { toolMode: 'cli' });
17
- const runtime = await createRuntime({
18
- sandbox: createSandbox(config.sandbox), connection: config.connection, executor: config.executor, models: config.models,
19
- services, maxAgents: 2, outputDir: context.outputDir,
20
- profiles: {
21
- publisher: {
22
- model: config.model, image: config.image, writable: false, services: { handoff: ['publish'] },
23
- addedSystemPrompt: 'Read release-data.txt. Publish its reference and one short question asking the user for a release channel. Run swarm service invoke handoff publish --help for arguments. Use the workspace for reading files.',
24
- },
25
- writer: {
26
- model: config.model, image: config.image, services: { handoff: ['take'] }, writable: true,
27
- addedSystemPrompt: 'Run swarm service invoke handoff take using the exact Bash command supplied in your task. Use the bash tool in your writable workspace. The command reads the reference from the Service and writes delivery.txt with two newline-terminated lines.',
28
- },
29
- },
30
- });
31
32
  const turn = { signal: context.signal, timeoutMs: 120_000 };
32
- let phase = 'publish';
33
+ let phase = 'starting';
33
34
  let writerId;
34
35
  let channel;
35
36
  let expected;
36
- let failure;
37
- let cleanup;
37
+ let closed;
38
38
  let unobserve;
39
+ let outcome;
39
40
  try {
40
- unobserve = context.registerAgentControls({ runtime });
41
- context.markRunning();
42
- const publisher = await runtime.spawn({
43
- requestId: 'spawn-publisher', profile: 'publisher',
44
- files: { ...context.initial.files, 'release-data.txt': { encoding: 'utf8', data: `${reference}\n` } },
45
- });
46
- await runInput(runtime, publisher.id, [
47
- context.input.prompt,
48
- 'Read the reference in release-data.txt.',
49
- 'Publish the real reference with --reference=<reference> and --question=<quoted text> or use JSON on stdin.',
50
- 'Use request ID publish-release. Finish when the handoff succeeds.',
51
- ].join(' '), { ...turn, requestId: 'publisher-turn' });
52
- const note = handoff.evidence().note;
53
- if (note?.reference !== reference || note.author !== publisher.id)
54
- throw Object.assign(new Error(), { code: 'HANDOFF_NOT_VERIFIED' });
55
- phase = 'channel';
56
- const answer = context.clientCapabilities.questions
57
- ? await context.askUser({ requestId: 'release-channel', kind: 'text', text: note.question, agentId: publisher.id, timeoutMs: 120_000 }, { id: 'release-handoff', agentId: publisher.id, signal: context.signal })
58
- : config.channel;
59
- channel = typeof answer === 'string' ? answer.trim() : undefined;
60
- if (!channel || !/^[a-z][a-z0-9-]{0,23}$/.test(channel))
61
- throw Object.assign(new Error(), { code: 'INVALID_CHANNEL' });
62
- phase = 'write';
63
- const writer = await runtime.spawn({
64
- requestId: 'spawn-writer', profile: 'writer', files: context.initial.files,
65
- collect: { paths: ['delivery.txt'], maxBytes: 4096, includeGit: false, required: true },
66
- });
67
- writerId = writer.id;
68
- await runInput(runtime, writer.id, `The user chose channel ${channel}. Run the following exact command with the bash tool in your workspace:
41
+ outcome = await context.runWithRuntime({
42
+ createRuntime: () => createRuntime({
43
+ sandbox: createSandbox(config.sandbox), connection: config.connection, executor: config.executor, models: config.models,
44
+ services, maxAgents: 2, outputDir: context.outputDir,
45
+ profiles: {
46
+ publisher: {
47
+ model: config.model, image: config.image, writable: false, services: { handoff: ['publish'] },
48
+ addedSystemPrompt: 'Read release-data.txt. Publish its reference and one short question asking for a release channel. The Harness supplies the preset channel or asks its explicit question client. Run swarm service invoke handoff publish --help for arguments. Use the workspace for reading files.',
49
+ },
50
+ writer: {
51
+ model: config.model, image: config.image, services: { handoff: ['take'] }, writable: true,
52
+ addedSystemPrompt: 'Run swarm service invoke handoff take using the exact shell command supplied in your task. Use your command execution tool in the writable workspace. The command reads the reference from the Service and writes delivery.txt with two newline-terminated lines.',
53
+ },
54
+ },
55
+ }),
56
+ async run(runtime) {
57
+ unobserve = context.registerAgentControls({ runtime });
58
+ context.markRunning();
59
+ phase = 'publish';
60
+ const publisher = await runtime.spawn({
61
+ requestId: 'spawn-publisher', profile: 'publisher',
62
+ files: { ...context.initial.files, 'release-data.txt': { encoding: 'utf8', data: `${reference}\n` } },
63
+ });
64
+ await runInput(runtime, publisher.id, [
65
+ context.input.prompt,
66
+ 'Read the reference in release-data.txt.',
67
+ 'Publish the real reference with --reference=<reference> and --question=<quoted text> or use JSON on stdin.',
68
+ 'Use request ID publish-release. Finish when the handoff succeeds.',
69
+ ].join(' '), { ...turn, requestId: 'publisher-turn' });
70
+ const note = handoff.evidence().note;
71
+ if (note?.reference !== reference || note.author !== publisher.id) {
72
+ throw failed('HANDOFF_NOT_VERIFIED', 'The authenticated publisher did not hand off its sandbox reference.');
73
+ }
74
+ phase = 'channel';
75
+ const answer = context.clientCapabilities.questions
76
+ ? await context.askUser({ requestId: 'release-channel', kind: 'text', text: note.question, agentId: publisher.id, timeoutMs: 120_000 }, { id: 'release-handoff', agentId: publisher.id, signal: context.signal })
77
+ : presetChannel;
78
+ channel = typeof answer === 'string' ? answer.trim() : undefined;
79
+ if (!channel || !channelPattern.test(channel))
80
+ throw failed('INVALID_CHANNEL', 'The release channel must start with a lowercase letter and contain at most 24 lowercase letters, digits or hyphens.');
81
+ phase = 'write';
82
+ const writer = await runtime.spawn({
83
+ requestId: 'spawn-writer', profile: 'writer', files: context.initial.files,
84
+ collect: { paths: ['delivery.txt'], maxBytes: 4096, includeGit: false, required: true },
85
+ });
86
+ writerId = writer.id;
87
+ await runInput(runtime, writer.id, `The user chose channel ${channel}. Run the following exact command with your command execution tool in your workspace:
69
88
  swarm service invoke handoff take --request-id take-release | node -e 'const { reference } = JSON.parse(require("node:fs").readFileSync(0, "utf8")).result; console.log("reference=" + reference); console.log("channel=${channel}");' > delivery.txt
70
89
  Finish when the command succeeds.`, { ...turn, requestId: 'writer-turn' });
71
- if (handoff.evidence().read?.reader !== writer.id)
72
- throw Object.assign(new Error(), { code: 'HANDOFF_NOT_READ' });
73
- phase = 'verify';
74
- expected = Buffer.from(`reference=${reference}\nchannel=${channel}\n`);
75
- const snapshot = await runtime.files.snapshot(writer.id, { requestId: 'verify-delivery', paths: ['delivery.txt'], maxBytes: 4096 });
76
- const file = snapshot.files['delivery.txt'];
77
- if (!file || !Buffer.from(file.data, file.encoding).equals(expected))
78
- throw Object.assign(new Error(), { code: 'DELIVERY_BYTES_MISMATCH' });
79
- }
80
- catch (error) {
81
- failure = { stage: phase, code: error.code ?? 'HANDOFF_FAILED' };
90
+ if (handoff.evidence().read?.reader !== writer.id)
91
+ throw failed('HANDOFF_NOT_READ', 'The authenticated writer did not read the published handoff.');
92
+ phase = 'verify-sandbox';
93
+ expected = Buffer.from(`reference=${reference}\nchannel=${channel}\n`);
94
+ const snapshot = await runtime.files.snapshot(writer.id, { requestId: 'verify-delivery', paths: ['delivery.txt'], maxBytes: 4096 });
95
+ const file = snapshot.files['delivery.txt'];
96
+ if (!file || !Buffer.from(file.data, file.encoding).equals(expected)) {
97
+ throw failed('DELIVERY_BYTES_MISMATCH', 'The sandbox delivery does not match the published reference and chosen channel.');
98
+ }
99
+ phase = 'export';
100
+ return { sandboxBytesVerified: true };
101
+ },
102
+ // Capture ownership evidence only. Business verification below must not
103
+ // throw from afterClose, whose errors are classified as cleanup failures.
104
+ afterClose(receipt) { closed = receipt; },
105
+ closeTimeoutMs: 60_000,
106
+ detail: () => ({ phase }),
107
+ });
82
108
  }
83
109
  finally {
84
- try {
85
- cleanup = await runtime.close({ timeoutMs: 60_000 });
86
- }
87
- finally {
88
- unobserve?.();
89
- }
110
+ unobserve?.();
90
111
  }
91
- const directory = cleanup?.agents.find(agent => agent.agentId === writerId)?.artifacts.find(path => path.endsWith('/artifacts/files'));
112
+ const writerReceipt = closed?.agents.find(agent => agent.agentId === writerId);
113
+ const directory = writerReceipt?.artifacts.find(path => path.endsWith('/artifacts/files'));
92
114
  const delivery = directory ? join(directory, 'delivery.txt') : undefined;
93
115
  const bytes = delivery ? await readFile(delivery).catch(() => undefined) : undefined;
94
- const verification = delivery && bytes && expected && bytes.equals(expected)
116
+ const pending = outcome.export?.status === 'pending' || (writerId !== undefined && closed === undefined);
117
+ const verification = outcome.outcome === 'completed' && delivery && bytes && expected && bytes.equals(expected)
95
118
  ? { file: delivery, bytes: bytes.length, sha256: createHash('sha256').update(bytes).digest('hex') } : undefined;
119
+ const wrongBytes = bytes && expected && !bytes.equals(expected);
120
+ const verificationFailure = outcome.outcome === 'completed' && !verification && (wrongBytes || !pending)
121
+ ? { stage: 'verify-export', code: bytes ? 'EXPORTED_BYTES_MISMATCH' : 'DELIVERY_EXPORT_MISSING' } : undefined;
96
122
  const { note, read } = handoff.evidence();
97
- const exportPending = cleanup?.pending?.some(resource => resource.action === 'collect-artifacts');
98
123
  return {
99
- outcome: context.signal.aborted ? 'cancelled' : failure ? 'failed' : 'completed',
100
- reason: failure?.code ?? (context.signal.aborted ? 'stopped' : 'release-handoff'),
101
- result: { runtimeId: runtime.id, failure: failure ?? null, handoff: { author: note?.author ?? null,
102
- publishRequestId: note?.requestId ?? null, read: read ?? null, channel: channel ?? null } },
124
+ ...outcome,
125
+ ...(verificationFailure ? { outcome: 'failed', reason: verificationFailure.code } : {}),
126
+ result: { ...outcome.result, verificationFailure: verificationFailure ?? null,
127
+ handoff: { author: note?.author ?? null, publishRequestId: note?.requestId ?? null, read: read ?? null, channel: channel ?? null } },
103
128
  acceptance: verification ? { status: 'verified', ...verification } : { status: 'unverified' },
104
- artifacts: verification ? [{ path: verification.file, sha256: verification.sha256 }] : [],
105
- ...(writerId ? { export: { status: verification ? 'complete' : exportPending ? 'pending' : 'failed' } } : {}),
106
- cleanup: { status: cleanup?.cleanup ?? 'pending', pending: cleanup?.pending?.map(({ id, kind, action }) => ({ id, kind, action })) ?? null },
129
+ artifacts: [...outcome.artifacts, ...(verification ? [{ path: verification.file, sha256: verification.sha256 }] : [])],
130
+ ...(writerId ? { export: { status: pending ? 'pending' : bytes ? 'complete' : 'failed',
131
+ receipt: json(writerReceipt ?? null) } } : {}),
107
132
  };
108
133
  },
109
134
  };
@@ -0,0 +1,7 @@
1
+ # Release handoff input
2
+
3
+ This directory is the input snapshot for the first SDK Harness. The host generates
4
+ a fresh release reference for every Run and supplies `release-data.txt` only to the
5
+ publisher. The writer must retrieve that reference from the authenticated Handoff
6
+ Service. It writes `delivery.txt` in its own Sandbox; the host verifies and exports
7
+ that file without changing this directory.
@@ -6,7 +6,8 @@ import { createHarnessSession, HarnessRpcClient } from '@anyswarm/core';
6
6
  import firstHarness from './harness.js';
7
7
  const rpc = process.argv[2] === '--rpc';
8
8
  const [cwd = process.cwd(), prompt = 'Prepare a release handoff.'] = process.argv.slice(rpc ? 3 : 2);
9
- const file = fileURLToPath(new URL('./harness.js', import.meta.url));
9
+ // The source export runs .ts directly; compiled package tests use its .js peer.
10
+ const file = fileURLToPath(new URL(new URL(import.meta.url).pathname.endsWith('.ts') ? './harness.ts' : './harness.js', import.meta.url));
10
11
  const child = rpc ? spawn('anyswarm', ['--harness', file, '--mode', 'rpc', '--interaction', 'questions'], { stdio: ['pipe', 'pipe', 'inherit'] }) : undefined;
11
12
  const session = child ? new HarnessRpcClient(child) : createHarnessSession(firstHarness, { clientCapabilities: { questions: true } });
12
13
  const terminal = createInterface({ input: process.stdin, output: process.stderr });
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  "target": "ES2023",
4
- "module": "NodeNext",
4
+ "module": "ESNext",
5
+ "moduleResolution": "Bundler",
5
6
  "strict": true,
6
7
  "skipLibCheck": true,
7
8
  "types": ["node"],
@@ -11,7 +11,7 @@ outside the checkout. Copy the example from that SDK.
11
11
 
12
12
  ```sh
13
13
  npm init -y
14
- npm install --ignore-scripts "${ANYSWARM_SDK_ARCHIVE:-@anyswarm/core@0.5.0}"
14
+ npm install --ignore-scripts "${ANYSWARM_SDK_ARCHIVE:-@anyswarm/core@0.5.2}"
15
15
  sdk=node_modules/@anyswarm/core
16
16
  cp -R "$sdk"/examples/harness-session demo
17
17
  cd demo
@@ -46,7 +46,7 @@ repository sources.
46
46
 
47
47
  ```sh
48
48
  npm init -y
49
- npm install --ignore-scripts "${ANYSWARM_SDK_ARCHIVE:-@anyswarm/core@0.5.0}"
49
+ npm install --ignore-scripts "${ANYSWARM_SDK_ARCHIVE:-@anyswarm/core@0.5.2}"
50
50
  npm install --save-dev typescript @types/node
51
51
  sdk=node_modules/@anyswarm/core
52
52
  cp -R "$sdk"/examples/lead-worker demo
@@ -18,6 +18,7 @@ export declare function leadWorkerConfig(): {
18
18
  useServerProxy: boolean | undefined;
19
19
  egressMode: "dns+nft" | undefined;
20
20
  endpointHost: undefined;
21
+ preparedImage?: string | undefined;
21
22
  resourceLimits: {
22
23
  cpu: string;
23
24
  memory: string;
@@ -42,7 +42,7 @@ example sources from the SDK you installed.
42
42
 
43
43
  ```sh
44
44
  npm init -y
45
- npm install --ignore-scripts "${ANYSWARM_SDK_ARCHIVE:-@anyswarm/core@0.5.0}"
45
+ npm install --ignore-scripts "${ANYSWARM_SDK_ARCHIVE:-@anyswarm/core@0.5.2}"
46
46
  npm install --save-dev typescript @types/node
47
47
  cp -R node_modules/@anyswarm/core/examples/messages demo
48
48
  cd demo
@@ -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 `anyswarm run ./examples/messages/handoff.ts`. It seeds a
119
+ the built checkout root with `node dist/scripts/anyswarm.js 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.
@@ -32,7 +32,7 @@ This example requires Node.js 22.19 or newer, an authenticated OpenSandbox servi
32
32
 
33
33
  ```sh
34
34
  npm init -y
35
- npm install --omit=dev --ignore-scripts "${ANYSWARM_SDK_ARCHIVE:-@anyswarm/core@0.5.0}"
35
+ npm install --omit=dev --ignore-scripts "${ANYSWARM_SDK_ARCHIVE:-@anyswarm/core@0.5.2}"
36
36
  example=node_modules/@anyswarm/core/examples/notes
37
37
  ```
38
38
 
@@ -45,7 +45,7 @@ node_modules/.bin/anyswarm run "$example/main.ts" --help
45
45
  node_modules/.bin/anyswarm run "$example/main.ts" "$example/config.ts" > notes-result.json
46
46
  ```
47
47
 
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.
48
+ `main.ts` imports Runtime, Service Registry, the configurable OpenSandbox backend, `runInput`, `runWithReport` and `readHarnessResult` from the public package exports. Turn order and business checks live in `main.ts`; the editable Service manifest and adapter live in `notes.ts`. Input/report/result helpers belong to the SDK rather than adjacent copied modules. The Harness 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.
49
49
 
50
50
  ## Run and inspect the handoff
51
51
 
@@ -11,6 +11,7 @@ declare const _default: {
11
11
  useServerProxy: boolean | undefined;
12
12
  egressMode: "dns+nft" | undefined;
13
13
  endpointHost: undefined;
14
+ preparedImage?: string | undefined;
14
15
  resourceLimits: {
15
16
  cpu: string;
16
17
  memory: string;
@@ -0,0 +1,32 @@
1
+ # Editing this Parallel Swarm Harness
2
+
3
+ These instructions are for a Coding Agent customizing the exported application.
4
+ Read `README.md`, then the actual collaboration in `harness.ts`, configuration
5
+ in `config.ts`, and the Board and report checks before changing behavior.
6
+
7
+ - Import SDK capabilities from `@anyswarm/core`. Use the installed public types;
8
+ do not depend on the AnySwarm repository's internal source or sibling examples.
9
+ - Keep the collaboration policy visible in ordinary TypeScript. One Harness
10
+ creates one Runtime with researcher and synthesizer Profiles; the CLI/SDK/RPC
11
+ clients use that same default Harness export.
12
+ - Read the user's repository from `context.initial.files` and their question
13
+ from `context.input.prompt`. Preserve snapshot identity and independent Agent
14
+ directories. Export results instead of modifying the user's original files.
15
+ - Honor `context.configuration`. Keep credentials in environment variables or
16
+ the user's private config, and preserve the selected executor and connection.
17
+ - Let the host assign author IDs and rounds. Keep Service permissions, exact
18
+ source checks and cross-author review checks when adapting the Board.
19
+ - Use `context.runWithRuntime` and `runInput` for owned work. Preserve cancellation,
20
+ finite waits, raw export/cleanup receipts and pending resources. A failed
21
+ business check is not a cleanup exception.
22
+ - State exactly what acceptance checks establish. Model text, file existence
23
+ and valid citations do not establish semantic correctness. Add a task-specific
24
+ checker only when the user has specified its actual acceptance rule.
25
+ - Verify changed behavior with focused deterministic checks and review the
26
+ resulting report. Use live model calls only within the user's authorized
27
+ endpoint, model and budget; identify any unrun integration checks honestly.
28
+
29
+ Run the edited source with `npm start -- --cwd /absolute/path/to/project
30
+ --prompt 'your question' --output-dir /absolute/path/to/runs`. The ejected
31
+ `package.json` pins the SDK archive recorded in `anyswarm-source.json`; changing
32
+ the application does not require a new AnySwarm framework or private API.
@@ -0,0 +1,136 @@
1
+ # Parallel repository investigation
2
+
3
+ Ask a concrete question about a local repository and export an engineering
4
+ handoff or change-impact report. Three researchers inspect private copies of the
5
+ same captured input, publish source references to an in-process Board, and review
6
+ one another's findings. A fourth Agent integrates their work into `report.md`.
7
+
8
+ The complete collaboration policy is in `harness.ts`. The example uses public
9
+ `@anyswarm/core` APIs, one Runtime, and the same Harness definition for the CLI,
10
+ SDK and JSONL RPC. It has no mid-run questions or external business Services.
11
+
12
+ ## Run your own repository question
13
+
14
+ Use AnySwarm 0.6.0 or a matching source build to export this example.
15
+ Prepare its Worker and OpenSandbox connection with `anyswarm setup`. You also
16
+ need a model endpoint reachable from the host and credentials for that endpoint;
17
+ setup's Sandbox selection does not configure your model account.
18
+
19
+ ```sh
20
+ anyswarm eject parallel-swarm --dir ./my-swarm
21
+ cd ./my-swarm
22
+ npm install
23
+
24
+ export ANYSWARM_MODEL_URL='https://your-provider.example/v1/responses'
25
+ export ANYSWARM_MODEL_ID='your-model'
26
+ # If required by your provider, set ANYSWARM_MODEL_TOKEN in your environment.
27
+
28
+ npm start -- \
29
+ --cwd /absolute/path/to/your-project \
30
+ --prompt 'Prepare an engineering handoff for this repository: identify the relevant entry points, configuration, main data flow and existing tests. Cite source paths and line numbers. Separate established facts from inferences and checks still needed.' \
31
+ --output-dir /absolute/path/to/runs
32
+ ```
33
+
34
+ Replace the question with your actual concern, for example: “We plan to change
35
+ how configuration is loaded; which modules and existing tests are involved, and
36
+ what still needs to be checked?” No Git diff or known repository defect is needed.
37
+ From this source directory the equivalent entry is
38
+ `anyswarm run ./harness.ts --cwd /absolute/path/to/your-project --prompt '…'`.
39
+ The exported package's `npm start` runs that same editable source.
40
+
41
+ Use `anyswarm trace --root /absolute/path/to/runs --open` to inspect the Run.
42
+ The final result's `artifacts` entry with `kind: "report"` names the actual
43
+ Markdown file. `result.detail.board` contains the findings, authenticated author
44
+ IDs, rounds, citations and checked source excerpts. The Runtime also exports the
45
+ Board's Service state. The original close receipt remains in `cleanup.receipt`.
46
+
47
+ Each Agent receives the captured project files selected by the SDK's file policy.
48
+ The host does not copy changes back to your repository. Researchers cannot write
49
+ their copies. The synthesizer can write its private copy and only `report.md` is
50
+ requested for collection. Changes made to your local project after input capture
51
+ are not part of this Run.
52
+
53
+ ## Configuration and budgets
54
+
55
+ `harness.ts` uses `context.configuration` when supplied, including a CLI
56
+ `--config ./my-config.ts` module. That object is the complete configuration;
57
+ otherwise the Harness loads its own visible `config.ts`. It does not depend on a
58
+ configuration file from another example.
59
+
60
+ The default configuration resolves the saved setup connection and executor for
61
+ the selected endpoint. Common `ANYSWARM_*` model/executor variables override
62
+ `ANYSWARM_PARALLEL_SWARM_*` variables; the saved executor is the next fallback,
63
+ then Pi. Worker image and Sandbox connection overrides use the SDK's
64
+ `resolveSandboxConnection({}, 'PARALLEL_SWARM')` rules. A configured or saved
65
+ image is preserved; otherwise `workerImageFor(executor)` selects it.
66
+
67
+ | Setting | Default behavior |
68
+ | --- | --- |
69
+ | `ANYSWARM_MODEL_URL` | Required model endpoint; scoped fallback is `ANYSWARM_PARALLEL_SWARM_MODEL_URL`. |
70
+ | `ANYSWARM_MODEL_ID`, `ANYSWARM_MODEL_PROVIDER` | Pi defaults to `gpt-5-mini` / `openai`; choose a model your provider supports. Codex requires an explicit model ID. |
71
+ | `ANYSWARM_MODEL_TOKEN` | Optional bearer token; keep it in the environment. |
72
+ | `ANYSWARM_EXECUTOR` | `pi` or `codex`; otherwise inherit setup's executor. |
73
+ | `ANYSWARM_MODEL_PROTOCOL` | `responses`; Pi also accepts `chat-completions`. Codex requires Responses. |
74
+ | `ANYSWARM_CONTEXT_WINDOW` | Optional explicit model context limit, at least 2,048 tokens. |
75
+ | `model`, `models` in a config module | Select a model alias and its complete public SDK model configuration. |
76
+ | `turnTimeoutMs`, `closeTimeoutMs` | 120 seconds for each owned Agent input and 60 seconds for close/reconciliation. All waits must be finite positive integers. |
77
+
78
+ When `ANYSWARM_CONTEXT_WINDOW` supplies capabilities for a custom model, the
79
+ default profile declares `reasoning: false`. If your Responses endpoint returns
80
+ reasoning items, set `models.default.capabilities.reasoning` to `true` in the
81
+ exported `config.ts` or in the full configuration you pass with `--config`.
82
+ Keep the context window and output limit appropriate for the selected model.
83
+ Otherwise the gateway can return `unsupported_responses_request` when the
84
+ executor includes a reasoning item in a subsequent request.
85
+
86
+ The example retains three researchers, two rounds, one synthesizer and a maximum
87
+ of four live Agents. Pi's default output cap is 2,048 tokens per model response;
88
+ Codex preserves executor output parameters. These bounds are configuration,
89
+ not a runtime or cost promise. Adjust the visible config to suit the question
90
+ and your authorized provider budget.
91
+
92
+ ## What the host checks
93
+
94
+ 1. Each of the three researchers publishes at least one first-round finding.
95
+ 2. Every finding includes 1–8 source references. Each reference has a relative
96
+ `path`, 1-based `startLine` / `endLine`, and exact `excerpt` from the captured
97
+ input. Ranges contain 1–40 lines, excerpts are nonblank and at most 4,096 bytes,
98
+ and the final line separator is omitted. CRLF is normalized to LF for checking.
99
+ 3. Each researcher publishes a new second-round review citing a first-round
100
+ finding by another author. The host assigns the round; clients cannot submit
101
+ an author or round override. Unknown citations and self-only reviews fail.
102
+ 4. The synthesizer's required `report.md` is exported, readable as UTF-8 and
103
+ nonblank, within the 1 MiB collection limit. If the input already contained
104
+ `report.md`, an unchanged copy does not pass this export check.
105
+
106
+ `acceptance.status: "verified"` applies only to the listed collaboration and
107
+ export checks; `acceptance.semanticCorrectness` remains `"not-run"`. Source
108
+ locations matching the input do not prove that an excerpt supports a conclusion,
109
+ that reviews are useful, or that a report is complete. The host does not execute
110
+ project tests or validate Markdown citations against the Board. Read the report
111
+ and its evidence before using its recommendations.
112
+
113
+ Incomplete contributions stop the workflow before synthesis. Invalid evidence
114
+ is rejected by the Board without publication. A confirmed bad report is a
115
+ business verification failure, separate from resource cleanup. Unconfirmed
116
+ collection stays `export.status: "pending"` and retains the SDK receipt; it is
117
+ not reported as a confirmed missing file. Cleanup can remain pending even when
118
+ the report has already been exported and checked. Cancellation and Runtime
119
+ initialization errors retain the existing Harness result classification.
120
+
121
+ ## Source and validation
122
+
123
+ | File | What to change |
124
+ | --- | --- |
125
+ | `harness.ts` | Research focus, prompts, rounds, Profiles, input handling and completion checks. |
126
+ | `config.ts` | Connections, executor/model selection, time limits and file policy. |
127
+ | `board.ts` | Source evidence checks, contribution accounting and review rules. |
128
+ | `board-service.ts` | Public Service schemas and authenticated caller mapping. |
129
+ | `report.ts` | Export verification, independently of close/cleanup classification. |
130
+ | `AGENTS.md` | Guidance for a Coding Agent editing this exported Harness. |
131
+
132
+ Repository tests exercise the Board and report failure cases, and run the real
133
+ HarnessSession/Runtime/Service Bridge with a controlled local transport. They
134
+ establish contract behavior, not model quality or compatibility with a particular
135
+ live model. A new paid model or Docker-based run is not implied by these tests;
136
+ record real-run evidence separately with its SDK, model, input and limitations.
@@ -1,14 +1,29 @@
1
1
  import { createInProcessAdapter, serviceFromManifest, } from '@anyswarm/core';
2
+ const EVIDENCE_SCHEMA = {
3
+ type: 'array', minItems: 1, maxItems: 8,
4
+ items: {
5
+ type: 'object',
6
+ properties: {
7
+ path: { type: 'string', minLength: 1 },
8
+ startLine: { type: 'integer', minimum: 1 },
9
+ endLine: { type: 'integer', minimum: 1 },
10
+ excerpt: { type: 'string', minLength: 1, maxLength: 4096 },
11
+ },
12
+ required: ['path', 'startLine', 'endLine', 'excerpt'], additionalProperties: false,
13
+ },
14
+ };
2
15
  const FINDING_SCHEMA = {
3
16
  type: 'object',
4
17
  properties: {
5
18
  id: { type: 'integer' },
6
19
  authorId: { type: 'string' },
20
+ round: { type: 'string', enum: ['research', 'review'] },
7
21
  topic: { type: 'string' },
8
22
  summary: { type: 'string' },
23
+ evidence: EVIDENCE_SCHEMA,
9
24
  cites: { type: 'array', items: { type: 'integer' } },
10
25
  },
11
- required: ['id', 'authorId', 'topic', 'summary', 'cites'],
26
+ required: ['id', 'authorId', 'round', 'topic', 'summary', 'evidence', 'cites'],
12
27
  additionalProperties: false,
13
28
  };
14
29
  export function createBoardRegistration(board) {
@@ -18,25 +33,27 @@ export function createBoardRegistration(board) {
18
33
  id: 'board',
19
34
  title: 'Shared Research Board',
20
35
  purpose: 'Publish, search, and cite findings across parallel swarm researchers.',
21
- provider_version: '1.0.0',
36
+ provider_version: '2.0.0',
22
37
  endpoint: { transport: 'in-process' },
23
38
  capabilities: [
24
39
  {
25
40
  name: 'publish',
26
41
  operation: 'publish',
27
- description: 'Publish a verified finding and optionally cite prior finding IDs.',
42
+ description: 'Publish a finding with exact source references. During review, cite another researcher\'s first-round finding. Source locations are checked; conclusions are not.',
28
43
  side_effect: 'write',
29
44
  idempotent: false,
30
45
  help: { when: 'After discovering or cross-checking a concrete fact' },
31
- errors: [{ code: 'NOT_FOUND', retryable: false }],
46
+ errors: ['NOT_FOUND', 'INVALID_EVIDENCE', 'INVALID_FINDING', 'REVIEW_REQUIRED', 'BOARD_CLOSED', 'NOT_RESEARCHER']
47
+ .map(code => ({ code, retryable: false })),
32
48
  input_schema: {
33
49
  type: 'object',
34
50
  properties: {
35
51
  topic: { type: 'string', minLength: 1, maxLength: 120 },
36
52
  summary: { type: 'string', minLength: 1, maxLength: 2000 },
37
- cites: { type: 'array', items: { type: 'integer', minimum: 1 }, maxItems: 8 },
53
+ evidence: EVIDENCE_SCHEMA,
54
+ cites: { type: 'array', items: { type: 'integer', minimum: 1 }, maxItems: 8, uniqueItems: true },
38
55
  },
39
- required: ['topic', 'summary'],
56
+ required: ['topic', 'summary', 'evidence'],
40
57
  additionalProperties: false,
41
58
  },
42
59
  output_schema: FINDING_SCHEMA,
@@ -67,8 +84,8 @@ export function createBoardRegistration(board) {
67
84
  invoke({ capability, input, caller, assertAuthorized }) {
68
85
  if (capability.operation === 'publish') {
69
86
  assertAuthorized();
70
- const { topic, summary, cites } = input;
71
- return board.publish(caller.agentId, topic, summary, cites);
87
+ const { topic, summary, evidence, cites } = input;
88
+ return board.publish(caller.agentId, topic, summary, evidence, cites);
72
89
  }
73
90
  const { query } = input;
74
91
  return { entries: board.search(query) };
@@ -1,16 +1,46 @@
1
+ import type { FileTree } from '@anyswarm/core';
2
+ export interface SourceReference {
3
+ path: string;
4
+ startLine: number;
5
+ endLine: number;
6
+ excerpt: string;
7
+ }
1
8
  export interface Finding {
2
9
  id: number;
3
10
  authorId: string;
11
+ round: 'research' | 'review';
4
12
  topic: string;
5
13
  summary: string;
14
+ evidence: SourceReference[];
6
15
  cites: number[];
7
16
  }
17
+ /** Checks locations and exact excerpts, not whether they support a conclusion. */
18
+ export declare function verifySourceReference(files: FileTree, reference: SourceReference): SourceReference;
8
19
  export declare class FindingsBoard {
20
+ private readonly files;
9
21
  private entries;
10
- publish(authorId: string, topic: string, summary: string, cites?: number[]): Finding;
22
+ private researchers;
23
+ private round;
24
+ constructor(files: FileTree);
25
+ beginResearch(researchers: readonly string[]): void;
26
+ beginReview(): void;
27
+ finishReview(): void;
28
+ private requireContributions;
29
+ publish(authorId: string, topic: string, summary: string, evidence: readonly SourceReference[], cites?: readonly number[]): Finding;
11
30
  search(query?: string): Finding[];
31
+ contributions(): {
32
+ authorId: string;
33
+ research: number;
34
+ review: number;
35
+ }[];
12
36
  exportState(): {
37
+ round: "closed" | "research" | "review" | "waiting";
13
38
  total: number;
39
+ contributions: {
40
+ authorId: string;
41
+ research: number;
42
+ review: number;
43
+ }[];
14
44
  entries: Finding[];
15
45
  };
16
46
  }