@sleep2agi/agent-network 2.3.0-preview.4 → 2.3.0-preview.40

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 (61) hide show
  1. package/README.md +35 -324
  2. package/dist/bin/anet.cjs +101 -0
  3. package/dist/bin/cli.d.ts +1 -0
  4. package/dist/bin/cli.js +20 -1
  5. package/dist/bin/goal-wake-log-render.d.ts +31 -0
  6. package/dist/src/batch-workdir.d.ts +9 -0
  7. package/dist/src/bootstrap-password-db.d.ts +13 -0
  8. package/dist/src/channel-attachments.d.ts +29 -0
  9. package/dist/src/channel-task-trace.d.ts +10 -0
  10. package/dist/src/claude-vendor-env.d.ts +28 -0
  11. package/dist/src/cli-args.d.ts +8 -0
  12. package/dist/src/client-task-trace.d.ts +9 -0
  13. package/dist/src/client.js +1 -1
  14. package/dist/src/codex-model-default.d.ts +6 -0
  15. package/dist/src/controlled-upload.d.ts +83 -0
  16. package/dist/src/copresence-identity.d.ts +339 -0
  17. package/dist/src/dashboard-managed-process.d.ts +35 -0
  18. package/dist/src/environ-alias.d.ts +14 -0
  19. package/dist/src/grok-attach-client.d.ts +115 -0
  20. package/dist/src/grok-copresence-disclosure.d.ts +11 -0
  21. package/dist/src/grok-copresence-profile.d.ts +65 -0
  22. package/dist/src/im/feishu/adapter.d.ts +149 -1
  23. package/dist/src/im/feishu/bridge.d.ts +9 -0
  24. package/dist/src/im/feishu/config.d.ts +31 -0
  25. package/dist/src/im/feishu/hub-upload.d.ts +88 -0
  26. package/dist/src/im/feishu/markdown-image-renderer.d.ts +61 -0
  27. package/dist/src/im/feishu/outbound-marker.d.ts +140 -0
  28. package/dist/src/im/feishu/outbound-paths.d.ts +50 -0
  29. package/dist/src/im/feishu/outbound-route.d.ts +62 -0
  30. package/dist/src/im/feishu/worker-lifecycle.d.ts +13 -0
  31. package/dist/src/im/feishu/worker.js +391 -16
  32. package/dist/src/im/types.d.ts +38 -1
  33. package/dist/src/locale-diagnostic.d.ts +12 -0
  34. package/dist/src/mock-llm.d.ts +12 -0
  35. package/dist/src/node-server.js +7 -1
  36. package/dist/src/normalize-runtime.d.ts +14 -2
  37. package/dist/src/opencode-agent-node-pair.d.ts +14 -0
  38. package/dist/src/opencode-auth-login.d.ts +43 -0
  39. package/dist/src/opencode-launch-env.d.ts +13 -0
  40. package/dist/src/opencode-owner-mode.d.ts +6 -0
  41. package/dist/src/opencode-package-binary.d.ts +21 -0
  42. package/dist/src/opencode-pin.d.ts +44 -0
  43. package/dist/src/opencode-preset.d.ts +73 -0
  44. package/dist/src/opencode-runtime-binding.d.ts +30 -0
  45. package/dist/src/opencode-safe-root.d.ts +27 -0
  46. package/dist/src/opencode-smoke-env.d.ts +1 -0
  47. package/dist/src/outbound-tool-names.d.ts +1 -0
  48. package/dist/src/owner-env-file.d.ts +2 -0
  49. package/dist/src/package-mode-preflight.d.ts +31 -0
  50. package/dist/src/primary-network.d.ts +23 -0
  51. package/dist/src/private-state.d.ts +10 -0
  52. package/dist/src/project-key.d.ts +1 -0
  53. package/dist/src/secret-shell-guidance.d.ts +3 -0
  54. package/dist/src/task-trace.d.ts +33 -0
  55. package/dist/src/tmux-attach.d.ts +8 -0
  56. package/dist/src/tmux-capability.d.ts +58 -0
  57. package/dist/src/tmux-exact-target.d.ts +34 -0
  58. package/dist/src/tmux-pane-prompt.d.ts +22 -0
  59. package/dist/src/token-cli.d.ts +13 -0
  60. package/dist/src/unsafe-package-path-reason.d.ts +17 -0
  61. package/package.json +10 -6
package/README.md CHANGED
@@ -5,363 +5,74 @@
5
5
  [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://github.com/sleep2agi/agent-network/blob/main/LICENSE)
6
6
  [![Docs](https://img.shields.io/badge/docs-anet.sh-009e7e.svg)](https://anet.sh)
7
7
 
8
- Run a local network of AI agents from one CLI.
9
-
10
- `anet` starts a CommHub, launches the web dashboard, creates agent nodes, and lets those nodes talk to each other through MCP tools such as `send_task`, `get_task`, and `get_all_status`.
11
-
12
- ## What It Is
13
-
14
- Agent Network is a local-first multi-agent runtime:
15
-
16
- - **CommHub**: MCP + REST + SSE hub for task routing, auth, networks, and status.
17
- - **Agent nodes**: long-running AI workers backed by Claude Code, Claude Agent SDK, Codex SDK, or Grok Build ACP.
18
- - **Dashboard**: browser UI for topology, chat, tasks, node health, and server telemetry.
19
- - **CLI**: `anet`, the single entry point for setup, auth, node lifecycle, and demos.
20
-
21
- The default path runs entirely on your machine. LAN sharing is opt-in.
22
-
23
- ## Requirements
24
-
25
- - Node.js **>= 22.13.0**
26
- - npm **>= 10**
27
- - Bun **>= 1.2.0** (`anet hub start` lazy-runs the Bun-based CommHub server)
28
- - macOS or Linux
29
-
30
- Install Bun if needed:
31
-
32
- ```bash
33
- curl -fsSL https://bun.sh/install | bash
34
- ```
8
+ `anet` connects local AI agents through one self-hosted Hub. It starts CommHub and the Dashboard, creates node identities, and manages node lifecycle, networks, tokens, tasks, and channels.
35
9
 
36
10
  ## Install
37
11
 
38
- Stable:
12
+ Requires Node.js ≥ 22.13 and Bun ≥ 1.2.
39
13
 
40
14
  ```bash
41
- npm install -g @sleep2agi/agent-network
42
- anet -v
15
+ npm install -g bun @sleep2agi/agent-network @sleep2agi/agent-node
43
16
  ```
44
17
 
45
- Preview channel:
18
+ Stable releases use npm's `latest` tag. Features that are still being validated use `preview`:
46
19
 
47
20
  ```bash
48
- npm install -g @sleep2agi/agent-network@preview
49
- anet -v
21
+ anet upgrade --channel preview
50
22
  ```
51
23
 
52
- Current npm dist-tags verified on 2026-05-28 (v0.10.11 stable):
53
-
54
- | Package | latest | preview |
55
- |---|---:|---:|
56
- | `@sleep2agi/agent-network` | `2.2.10` | `2.2.10-preview.3` |
57
- | `@sleep2agi/commhub-server` | `0.8.4` | `0.8.4-preview.1` |
58
- | `@sleep2agi/agent-network-dashboard` | `0.5.6` | `0.5.7-preview.2` |
59
- | `@sleep2agi/agent-node` | `2.4.7` | `2.4.8-preview.0` |
60
-
61
- ## 5-Minute Quick Start
24
+ Do not copy fixed package or preview numbers from old issues. Check the [versioning guide](https://anet.sh/guide/versioning) and npm dist-tags for the current release.
62
25
 
63
- Open three terminals.
26
+ ## Quick start
64
27
 
65
- ### 1. Start CommHub
28
+ Open three terminals:
66
29
 
67
30
  ```bash
31
+ # Terminal 1 — Hub
68
32
  anet hub start
69
- ```
70
-
71
- Default local URL:
72
-
73
- ```text
74
- http://127.0.0.1:9200
75
- ```
76
-
77
- By default the hub binds to localhost. Use `--host 0.0.0.0` only when you intentionally want LAN clients to connect.
78
-
79
- ### 2. Start Dashboard
80
33
 
81
- ```bash
34
+ # Terminal 2 — Dashboard
82
35
  anet hub dashboard
83
- ```
84
-
85
- Open:
86
-
87
- ```text
88
- http://localhost:3000
89
- ```
90
-
91
- ### 3. Log In, Create A Node, Start It
92
36
 
93
- ```bash
94
- anet login --username admin --password anethub
37
+ # Terminal 3 — login, create, start
38
+ anet login --hub http://127.0.0.1:9200 --username admin
95
39
  anet node create my-bot
96
40
  anet node start my-bot
97
41
  ```
98
42
 
99
- `anet node create` walks you through:
43
+ The node is ready after its log reports `SSE connected`. Open `http://localhost:3000` and send it a task from Dashboard.
100
44
 
101
- 1. Runtime: `claude-code-cli`, `claude-agent-sdk`, `codex-sdk`, or `grok-build-acp`.
102
- 2. Provider preset: Anthropic, MiniMax, InternLM, Xiaomi MiMo, or `custom` (any Anthropic-compatible endpoint — used for DeepSeek / GLM / Kimi / OpenRouter etc.; codex-sdk for OpenAI Codex; grok-build-acp for xAI Grok).
103
- 3. API key and model settings.
45
+ ## Runtime selection
104
46
 
105
- When the node starts successfully, look for:
47
+ `anet node create` shows only runtimes available in the installed release channel. Installation, authentication, permissions, and current availability are maintained in the [runtime guide](https://anet.sh/guide/runtimes).
106
48
 
107
- ```text
108
- SSE connected
109
- ```
49
+ - Claude Code, Claude Agent SDK, Codex SDK, and Grok Build ACP are the published task-runtime paths.
50
+ - Codex TUI co-presence is preview-only and must be started and recovered with `--copresence`; see the [co-presence guide](https://anet.sh/guide/codex-copresence).
51
+ - OpenCode support is preview-only. Its automatic `npx` fallback is intentionally disabled, so install the documented CLI explicitly.
52
+ - Neither npm `latest` nor `preview` includes a shared Grok TUI. Use `grok-build-acp` for published Grok nodes and follow the [Grok TUI status page](https://anet.sh/guide/grok-copresence).
110
53
 
111
- Then use the Dashboard chat panel to send `my-bot` a message.
54
+ Development branches may contain source-only runtime experiments. They are not supported installation paths until they appear in an npm dist-tag and the runtime guide.
112
55
 
113
- ## Multi-Agent Collaboration
56
+ ## What it provides
114
57
 
115
- Create a second node:
58
+ - **CommHub** MCP, REST, SSE task delivery, authentication, networks, and audit state.
59
+ - **Agent Node** — long-running workers backed by the selected runtime.
60
+ - **Dashboard** — topology, chat, tasks, messages, and node health.
61
+ - **CLI** — setup, login, node/project lifecycle, channels, tokens, and diagnostics.
116
62
 
117
- ```bash
118
- anet node create reviewer
119
- anet node start reviewer
120
- ```
121
-
122
- Ask `my-bot`:
123
-
124
- ```text
125
- Ask reviewer to review this plan and summarize the risks.
126
- ```
63
+ Runtimes with CommHub tool integration can discover peers and delegate work with tools such as `get_all_status`, `send_task`, and `get_task`. Replies and ordinary messages do not recursively invoke another model; see the [task lifecycle](https://anet.sh/concepts/task-lifecycle).
127
64
 
128
- The first agent can discover peers with `get_all_status`, delegate work with `send_task`, poll with `get_task`, and integrate the reply. The dashboard Tasks and Messages views show the chain.
65
+ ## Security
129
66
 
130
- ## LAN Hub
131
-
132
- On the hub machine:
133
-
134
- ```bash
135
- anet hub start --host 0.0.0.0
136
- ```
137
-
138
- On another machine:
139
-
140
- ```bash
141
- npm install -g @sleep2agi/agent-network
142
- anet init --hub http://<HUB-LAN-IP>:9200
143
- anet login --username admin --password anethub
144
- anet node create remote-bot
145
- anet node start remote-bot
146
- ```
147
-
148
- Do not expose the hub directly to the public internet without a reverse proxy, HTTPS, firewall rules, and reviewed auth settings.
149
-
150
- ## Runtimes
151
-
152
- | Runtime | Use When | Notes |
153
- |---|---|---|
154
- | `claude-code-cli` | You want Claude Code CLI sessions and channel support | Uses Claude Code process; supports stable `COMMHUB_RESUME_ID` in recent previews |
155
- | `claude-agent-sdk` | You want Anthropic-compatible API providers | Good default for provider presets |
156
- | `codex-sdk` | You want Codex-backed nodes | Useful as a backup runtime when Claude quota is constrained |
157
- | `grok-build-acp` | You want Grok Build through `grok agent stdio` | Requires Grok Build CLI auth; stable for receive/reply, session persistence, and explicit `send_task` delegation |
158
-
159
- ### Grok Build ACP
160
-
161
- `grok-build-acp` uses the local Grok Build CLI via Agent Client Protocol (ACP). Install and authenticate Grok first:
162
-
163
- ```bash
164
- curl -fsSL https://x.ai/cli/install.sh | bash
165
- grok
166
- ```
167
-
168
- Create and start a node:
169
-
170
- ```bash
171
- anet node create grok-demo --runtime grok-build-acp
172
- anet node start grok-demo
173
- ```
174
-
175
- Look for:
176
-
177
- ```text
178
- runtime: grok-build-acp
179
- SSE connected
180
- ```
181
-
182
- Stable support:
183
-
184
- - Receive CommHub tasks through SSE.
185
- - Run one Grok Build ACP turn per task.
186
- - Persist `grokSession` into `.anet/nodes/<name>/config.json`.
187
- - Resume the saved Grok session on the next task.
188
- - Reply to the original sender through CommHub.
189
- - Explicit delegation such as `给 A站助手 发任务: ...` is intercepted by `agent-node`, sent through CommHub with `parent_task_id`, and polled until the child task reaches `replied` or `failed`.
190
-
191
- Current boundary:
192
-
193
- - Grok native MCP tool injection is not the stable path yet.
194
- - For cross-agent delegation, use explicit delegation wording so `agent-node` handles the CommHub call deterministically.
195
- - If Grok returns `grok ACP error -32603`, upgrade to the latest `@sleep2agi/agent-node` and restart the node; recent builds narrow ACP capabilities and include `error.data` diagnostics.
196
-
197
- Details: `docs/grok-build-runtime.md`.
198
-
199
- ## Provider Presets
200
-
201
- `anet node create` writes the correct provider environment into `.anet/nodes/<name>/config.json`.
202
-
203
- | Provider | Status | Notes |
204
- |---|---|---|
205
- | Anthropic | verified path | Native Anthropic Messages API |
206
- | MiniMax | verified path | Anthropic-compatible endpoint |
207
- | DeepSeek | verified path | Anthropic-compatible endpoint |
208
- | GLM / Zhipu | verified path | Anthropic-compatible endpoint |
209
- | Kimi / Moonshot | verified path | Anthropic-compatible endpoint |
210
- | OpenRouter | available | Anthropic-compatible routing |
211
- | Custom | available | Provide base URL, model, and token |
212
-
213
- ## Common Commands
214
-
215
- ```bash
216
- # Hub and dashboard
217
- anet hub start
218
- anet hub dashboard
219
-
220
- # Auth
221
- anet register
222
- anet login --username <user> --password <password>
223
- anet logout
224
- anet whoami
225
- anet passwd
226
-
227
- # Nodes
228
- anet node create <name>
229
- anet node start <name>
230
- anet node start --all
231
- anet node stop <name>
232
- anet node resume <name>
233
- anet node rename <old> <new> --force
234
- anet node delete <name>
235
- anet node ls
236
- anet info <name>
237
- anet logs <name>
238
-
239
- # Network status and repair
240
- anet status
241
- anet tasks [status]
242
- anet doctor
243
- anet doctor --fix
244
-
245
- # Project and session helpers
246
- anet init --hub <url>
247
- anet init project
248
- anet project up
249
- anet project restart
250
- anet project down
251
- anet session ls
252
-
253
- # Channels and upgrades
254
- anet channel add telegram <name> --bot-token <tok> --allow <uid>
255
- anet channel add feishu <name> --app-id <id> --app-secret <secret> --allow <open-id> # see docs/feishu-quickstart.md
256
- anet channel ls
257
- anet upgrade
258
- anet upgrade --channel preview --dry-run
259
-
260
- # Batch / demos
261
- anet create --batch
262
- anet batch list
263
- anet batch stop <prefix>
264
- anet demo sci-team
265
- ```
266
-
267
- ## Configuration Files
268
-
269
- ```text
270
- ~/.anet/config.json
271
- Global CLI profile: hub URL, user token, default network.
272
-
273
- ~/.anet/server/admin-utok.json
274
- Local bootstrap admin token for the hub.
275
-
276
- {project}/.anet/nodes/<name>/config.json
277
- Per-node runtime, model, provider env, node token, channels, and session IDs.
278
- ```
279
-
280
- Example node config:
281
-
282
- ```json
283
- {
284
- "node_id": "n_a1b2c3d4",
285
- "node_name": "my-bot",
286
- "alias": "my-bot",
287
- "hub": "http://127.0.0.1:9200",
288
- "network_id": "default",
289
- "token": "ntok_...",
290
- "runtime": "claude-agent-sdk",
291
- "model": "your-model",
292
- "channels": ["server:commhub"],
293
- "tools": ["Read", "Write", "Edit", "Bash", "Glob", "Grep"],
294
- "env": {
295
- "ANTHROPIC_BASE_URL": "https://example.com/anthropic",
296
- "ANTHROPIC_AUTH_TOKEN": "sk-..."
297
- },
298
- "flags": {
299
- "dangerouslySkipPermissions": true,
300
- "teammateMode": "in-process",
301
- "maxTurns": 50
302
- }
303
- }
304
- ```
305
-
306
- Do not commit `.anet/` or provider API keys.
307
-
308
- ## Security Notes
309
-
310
- - The hub binds to `127.0.0.1` by default.
311
- - LAN mode is explicit: `anet hub start --host 0.0.0.0`.
312
- - Node tokens are network-scoped `ntok_` tokens; user tokens are `utok_`.
313
- - Keep API keys in local node config or env refs; never paste real keys into issues or docs.
314
- - Treat tmux / terminal streaming features as local-admin tools.
315
-
316
- ## What Is Stable vs Experimental
317
-
318
- Stable day-to-day path:
319
-
320
- - `anet hub start` / `anet hub stop` / `anet hub status` (v0.10.11+: SIGTERM → 3s grace → SIGKILL stop; status shows PID + port + `/health` version — no more manual `lsof+kill`)
321
- - `anet hub dashboard`
322
- - `anet login`
323
- - `anet node create/start/stop/delete/rename`
324
- - `anet node start --all`
325
- - `anet project up/restart/down`
326
- - Dashboard chat, task list, topology, and status views
327
-
328
- Actively evolving:
329
-
330
- - IM platform integration (Feishu / Slack / WhatsApp / WeCom)
331
- - Telegram channel binding
332
- - Advanced dashboard topology edges
333
- - Batch orchestration and science-team demos
334
- - Codex runtime expansion
335
- - Grok Build ACP runtime
336
- - Cross-version rename hot-reload
67
+ The default Hub is local-only. Before exposing it beyond localhost, change the initial password and follow the [production deployment guide](https://anet.sh/deploy/production). Do not copy `.anet` node configs between machines: they contain network-bound identity and token material.
337
68
 
338
69
  ## Documentation
339
70
 
340
- - Docs site: https://anet.sh
341
- - Getting started: https://anet.sh/guide/getting-started
342
- - Preview guide: https://anet.sh/guide/preview/getting-started
343
- - Issues: https://github.com/sleep2agi/agent-network/issues
344
-
345
- ## Repository Layout
346
-
347
- This package lives in the `agent-network/` subdirectory of the monorepo:
348
-
349
- ```text
350
- agent-network/
351
- bin/cli.ts anet CLI
352
- src/client.ts SDK client
353
- src/node-server.ts CommHub MCP server bridge used by claude-code-cli
354
- src/im/ IM integration contracts and future adapters
355
- ```
356
-
357
- Related packages live next to it:
358
-
359
- ```text
360
- server/ @sleep2agi/commhub-server
361
- agent-node/ @sleep2agi/agent-node
362
- docs-site/ anet.sh documentation site
363
- ```
364
-
365
- ## License
71
+ - [Getting started](https://anet.sh/guide/getting-started)
72
+ - [CLI reference](https://anet.sh/guide/cli)
73
+ - [Runtime guide](https://anet.sh/guide/runtimes)
74
+ - [Tokens and permissions](https://anet.sh/concepts/tokens)
75
+ - [Troubleshooting](https://anet.sh/troubleshooting)
76
+ - [GitHub repository](https://github.com/sleep2agi/agent-network)
366
77
 
367
- Apache-2.0
78
+ Apache-2.0.
@@ -0,0 +1,101 @@
1
+ #!/usr/bin/env node
2
+ /* eslint-disable */
3
+ // anet 的 bin 入口垫片 —— 唯一职责:在【解析真正的 ESM 入口之前】把 Node 版本讲清楚。
4
+ //
5
+ // 🔴 为什么必须是 CJS,而且必须是手写不进构建:
6
+ //
7
+ // dist/bin/cli.js 是 ESM(package.json 里 type: module),而且经 javascript-obfuscator
8
+ // 处理过。老 Node 读到它的第一行 `import{createRequire}from'node:module'` 就抛
9
+ //
10
+ // SyntaxError: Unexpected token {
11
+ //
12
+ // ——**在任何一行代码执行之前**。cli.ts 里那个 checkNodeVersion()(required "22.13.0")
13
+ // 写在同一个文件里,所以它永远轮不到跑。**一个写在 ESM 里的版本检查,救不了一个
14
+ // 连 ESM 都解析不了的 Node。**
15
+ //
16
+ // 用户实际看到的是一屏混淆后的代码 + SyntaxError,完全指不到真因。
17
+ // (2026-08-18 现场:Node 10/12 世代的栈,`internal/bootstrap/node.js`、
18
+ // `Function.Module.runMain`、`loader.js:723`。)
19
+ //
20
+ // package.json 的 engines.node>=22.13.0 也不拦:npm 默认 engine-strict=false,
21
+ // 那只是安装时的一句警告。
22
+ //
23
+ // 🔴 本文件的写法约束(违反其中任何一条,垫片自己就会在同一个地方炸):
24
+ // - 只用 ES5 语法:var / function / 字符串拼接。不用 const/let、箭头函数、
25
+ // 模板串、可选链(?.)、空值合并(??)。
26
+ // - **不能出现字面量的 `import(...)`** —— 动态 import 是 Node 12.17+ 才能【解析】的
27
+ // 语法,老 Node 在解析阶段就会失败。所以用 new Function 把它推迟到调用时再解析,
28
+ // 而调用只发生在版本检查通过之后。
29
+ // - 不进 bun build,不进 obfuscator。构建里只 cp 过去。
30
+
31
+ // 🔴 两个阈值,回答两个不同的问题。把它们合成一个,就是我 2026-08-18 犯的错:
32
+ //
33
+ // PARSE_FLOOR = 16.0.0 「这个 Node 能不能**加载**入口?」
34
+ // 低于它,dist/bin/cli.js 的第一行 `import{createRequire}from'node:module'`
35
+ // 连解析都过不去(ESM 语句需要 Node>=12;`node:` 前缀需要 >=14.18/16)。
36
+ // 这时**必须硬退**,因为再往下没有任何一行自己的代码能跑。
37
+ //
38
+ // SUPPORTED = 22.13.0 「这个 Node 是不是受支持的版本?」
39
+ // 这是 package.json engines 声明的下限,而产品对它的既有立场是
40
+ // **警告并继续** —— cli.ts 的 checkNodeVersion() 只在 `anet upgrade` 里
41
+ // 打一行 "Continuing anyway"。
42
+ //
43
+ // 🔴 第一版我用 SUPPORTED 做硬退,直接把 e2e 打红了:CI 镜像跑的是 Node 20
44
+ // (tests/Dockerfile 里 setup_20.x),5 个 suite 当场全灭。
45
+ // **垫片不该比产品自己的立场更严** —— 它的职责是把「解析不了」这件事讲清楚,
46
+ // 不是顺手收紧支持策略。那是另一个决定,要单独做。
47
+ var PARSE_FLOOR = '16.0.0';
48
+ var SUPPORTED = '22.13.0';
49
+
50
+ function parts(v) {
51
+ var a = String(v).split('.');
52
+ return [parseInt(a[0], 10) || 0, parseInt(a[1], 10) || 0, parseInt(a[2], 10) || 0];
53
+ }
54
+
55
+ function gte(a, b) {
56
+ return a[0] > b[0]
57
+ || (a[0] === b[0] && a[1] > b[1])
58
+ || (a[0] === b[0] && a[1] === b[1] && a[2] >= b[2]);
59
+ }
60
+
61
+ var cur = parts(process.versions.node);
62
+
63
+ if (!gte(cur, parts(PARSE_FLOOR))) {
64
+ console.error('');
65
+ console.error(' \u274c anet 无法在 Node ' + process.versions.node + ' 上启动。');
66
+ console.error('');
67
+ console.error(' 它的入口是 ESM,而这个版本的 Node 连解析都做不到 —— 没有垫片的话,');
68
+ console.error(' 你看到的会是一屏代码加一句 SyntaxError,而真因是版本。');
69
+ console.error('');
70
+ console.error(' 升级 Node(任选其一):');
71
+ console.error(' nvm install 22 && nvm use 22');
72
+ console.error(' curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash - && sudo apt-get install -y nodejs');
73
+ console.error('');
74
+ console.error(' 然后: node -v && anet -v');
75
+ console.error('');
76
+ process.exit(1);
77
+ }
78
+
79
+ if (!gte(cur, parts(SUPPORTED))) {
80
+ // 警告不退出 —— 与 cli.ts 的既有立场一致。走 stderr,不污染任何解析 stdout 的调用方。
81
+ console.error('[anet] \u26a0 Node ' + process.versions.node + ' 低于受支持的 >=' + SUPPORTED
82
+ + ';能跑,但不保证。升级: nvm install ' + SUPPORTED.split('.')[0]);
83
+ }
84
+
85
+ var path = require('path');
86
+ var url = require('url');
87
+ var entry = path.join(__dirname, 'cli.js');
88
+
89
+ // 🔴 把 argv[1] 指回真入口。cli.ts 有多处用 process.argv[1] 推自身位置
90
+ // (:792 resolve(argv[1])、:1094-1095 join(argv[1],'..','..')、:4445)。
91
+ // 不改的话 argv[1] 会变成本垫片的路径 —— 同目录,多数推导仍成立,
92
+ // 但"多数成立"不是"成立",直接指回去让行为逐字不变。
93
+ process.argv[1] = entry;
94
+
95
+ // 见上:不能写字面量 import()。
96
+ var dynamicImport = new Function('u', 'return import(u);');
97
+ dynamicImport(url.pathToFileURL(entry).href).catch(function (e) {
98
+ console.error('[anet] 无法加载 ' + entry);
99
+ console.error(e && e.stack ? e.stack : e);
100
+ process.exit(1);
101
+ });
package/dist/bin/cli.d.ts CHANGED
@@ -11,3 +11,4 @@
11
11
  */
12
12
  import { normalizeRuntime, type RuntimeName } from "../src/normalize-runtime";
13
13
  export { normalizeRuntime, type RuntimeName };
14
+ export declare const OPENCODE_PINNED_VERSION = "1.18.1";