@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,147 +0,0 @@
1
- import { StringDecoder } from 'node:string_decoder';
2
- import { StdinBuffer, stripTerminalSequences, type Terminal } from '@earendil-works/pi-tui';
3
-
4
- const beginPaste = '\x1b[200~';
5
- const endPaste = '\x1b[201~';
6
- const maxPasteBytes = 262_144;
7
-
8
- export function terminalText(value: string) {
9
- return stripTerminalSequences(value).replace(/\r\n?/g, '\n').replace(/\t/g, ' ')
10
- .replace(/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f-\x9f]/g, '');
11
- }
12
-
13
- export class AnySwarmTerminal implements Terminal {
14
- readonly kittyProtocolActive = false;
15
- private readonly input = process.stdin;
16
- private readonly stdout = process.stdout;
17
- private readonly transport = this.stdout.write.bind(this.stdout);
18
- private readonly decoder = new StringDecoder('utf8');
19
- private readonly keys = new StdinBuffer();
20
- private resize?: () => void;
21
- private inputCallback?: (data: string) => void;
22
- private raw?: boolean;
23
- private paused = true;
24
- private partial = '';
25
- private partialTimer?: ReturnType<typeof setTimeout>;
26
-
27
- enableRawMode() {
28
- if (this.raw !== undefined) return;
29
- const previous = this.input.isRaw;
30
- this.paused = this.input.isPaused();
31
- this.input.setRawMode(true);
32
- this.raw = previous;
33
- }
34
-
35
- get enabled() { return this.raw !== undefined; }
36
- private paste?: string[];
37
- private pasteBytes = 0;
38
- private surrogate = '';
39
-
40
- constructor(private readonly pasteRejected: () => void) {
41
- this.keys.on('data', key => {
42
- if (/^[\uD800-\uDBFF]$/.test(key)) {
43
- this.surrogate = key;
44
- return;
45
- }
46
- if (this.surrogate && /^[\uDC00-\uDFFF]$/.test(key)) key = this.surrogate + key;
47
- this.surrogate = '';
48
- this.inputCallback?.(key);
49
- });
50
- }
51
-
52
- start(onInput: (data: string) => void, onResize: () => void) {
53
- this.enableRawMode();
54
- this.inputCallback = onInput;
55
- this.resize = onResize;
56
- this.input.on('data', this.data);
57
- this.stdout.on('resize', onResize);
58
- this.write('\x1b[?2004h');
59
- this.input.resume();
60
- }
61
-
62
- stop() {
63
- if (this.raw === undefined) return;
64
- const previous = this.raw;
65
- this.raw = undefined;
66
- this.inputCallback = undefined;
67
- this.input.off('data', this.data);
68
- if (this.resize) this.stdout.off('resize', this.resize);
69
- this.keys.destroy();
70
- clearTimeout(this.partialTimer);
71
- try { this.input.setRawMode(previous); }
72
- finally {
73
- if (this.paused || this.input.listenerCount('data') === 0) this.input.pause();
74
- this.write('\x1b[?2004l\x1b[?25h');
75
- }
76
- }
77
-
78
- // Keep just the possible delimiter suffix in memory while a paste is open.
79
- // An oversize paste is discarded through its closing delimiter, including embedded keys.
80
- private data = (chunk: Buffer | string) => {
81
- clearTimeout(this.partialTimer);
82
- let remaining = this.partial + (typeof chunk === 'string' ? chunk : this.decoder.write(chunk));
83
- this.partial = '';
84
- while (remaining) {
85
- const delimiter = this.paste ? endPaste : beginPaste;
86
- const index = remaining.indexOf(delimiter);
87
- let end = index;
88
- if (index < 0) {
89
- end = remaining.length;
90
- for (let size = Math.min(delimiter.length - 1, remaining.length); size > 0; size--) {
91
- if (remaining.endsWith(delimiter.slice(0, size))) {
92
- this.partial = remaining.slice(-size);
93
- end -= size;
94
- break;
95
- }
96
- }
97
- }
98
- const content = remaining.slice(0, end);
99
- if (this.paste) {
100
- this.pasteBytes += Buffer.byteLength(content);
101
- if (this.pasteBytes <= maxPasteBytes) this.paste.push(content);
102
- if (index >= 0) {
103
- const pasted = this.paste;
104
- this.paste = undefined;
105
- if (this.pasteBytes > maxPasteBytes) this.pasteRejected();
106
- else this.inputCallback?.(beginPaste + terminalText(pasted.join('')) + endPaste);
107
- }
108
- } else {
109
- // The key buffer owns lone Escape and ordinary terminal key sequences.
110
- if (content) this.keys.process(content);
111
- if (index >= 0) {
112
- this.paste = [];
113
- this.pasteBytes = 0;
114
- }
115
- }
116
- remaining = index >= 0 ? remaining.slice(index + delimiter.length) : '';
117
- }
118
- if (this.partial && !this.paste) {
119
- this.partialTimer = setTimeout(() => {
120
- const pending = this.partial;
121
- this.partial = '';
122
- this.keys.process(pending);
123
- }, 30);
124
- this.partialTimer.unref();
125
- }
126
- if (this.keys.getBuffer().length > 4096) this.keys.clear();
127
- };
128
-
129
- get columns() { return this.stdout.columns || 80; }
130
- get rows() { return this.stdout.rows || 24; }
131
- write(data: string) {
132
- if (this.stdout.writableLength > 512 * 1024) throw new Error('Terminal output is not draining');
133
- this.transport(data);
134
- }
135
- restoreDisplay() { this.transport('\x1b[?2026l\x1b[?2004l\x1b[?7h\x1b[?1049l\x1b[0m\x1b[?25h'); }
136
- drained() { return new Promise<void>((resolve, reject) => this.transport('', error => error ? reject(error) : resolve())); }
137
- async drainInput() {}
138
- moveBy(lines: number) { if (lines) this.write('\x1b[' + Math.abs(lines) + (lines < 0 ? 'A' : 'B')); }
139
- hideCursor() { this.write('\x1b[?25l'); }
140
- showCursor() { this.write('\x1b[?25h'); }
141
- clearLine() { this.write('\x1b[2K'); }
142
- clearFromCursor() { this.write('\x1b[J'); }
143
- clearScreen() { this.write('\x1b[2J\x1b[H'); }
144
- setTitle() {}
145
- setProgress() {}
146
- setProgramStatus() {}
147
- }