@xingjisoft/neutrino 0.6.0 → 0.7.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 (169) hide show
  1. package/README.md +6 -1
  2. package/assets/fast-planner.txt +57 -0
  3. package/assets/fast-replanner.txt +28 -0
  4. package/dist/agents.d.ts +25 -0
  5. package/dist/app.d.ts +206 -0
  6. package/dist/app.js +15 -0
  7. package/dist/background.d.ts +96 -0
  8. package/dist/bin.d.ts +2 -0
  9. package/dist/bin.js +40 -3
  10. package/dist/browser.d.ts +18 -0
  11. package/dist/clipboard.d.ts +16 -0
  12. package/dist/colors.d.ts +29 -0
  13. package/dist/compact.d.ts +52 -0
  14. package/dist/config.d.ts +221 -0
  15. package/dist/config.js +22 -7
  16. package/dist/cwd.d.ts +19 -0
  17. package/dist/fast/artifacts.d.ts +26 -0
  18. package/dist/fast/artifacts.js +109 -0
  19. package/dist/fast/engine.d.ts +78 -0
  20. package/dist/fast/engine.js +657 -0
  21. package/dist/fast/evidence.d.ts +21 -0
  22. package/dist/fast/evidence.js +68 -0
  23. package/dist/fast/planner.d.ts +10 -0
  24. package/dist/fast/planner.js +51 -0
  25. package/dist/fast/pool.d.ts +17 -0
  26. package/dist/fast/pool.js +78 -0
  27. package/dist/fast/scheduler.d.ts +54 -0
  28. package/dist/fast/scheduler.js +383 -0
  29. package/dist/fast/types.d.ts +100 -0
  30. package/dist/fast/types.js +21 -0
  31. package/dist/fast/worker.d.ts +23 -0
  32. package/dist/fast/worker.js +185 -0
  33. package/dist/header.d.ts +3 -0
  34. package/dist/index.d.ts +5 -0
  35. package/dist/llm/approval.d.ts +204 -0
  36. package/dist/llm/approval.js +14 -3
  37. package/dist/llm/client.d.ts +118 -0
  38. package/dist/llm/client.js +57 -8
  39. package/dist/llm/codeExecutor.d.ts +14 -0
  40. package/dist/llm/codemode.d.ts +15 -0
  41. package/dist/llm/context.d.ts +29 -0
  42. package/dist/llm/context.js +17 -4
  43. package/dist/llm/diagnostics.d.ts +91 -0
  44. package/dist/llm/diagnostics.js +242 -0
  45. package/dist/llm/plan.d.ts +148 -0
  46. package/dist/llm/retry.d.ts +80 -0
  47. package/dist/llm/risk.d.ts +21 -0
  48. package/dist/llm/risk.js +7 -0
  49. package/dist/llm/runtime.d.ts +189 -0
  50. package/dist/llm/runtime.js +178 -24
  51. package/dist/llm/search.d.ts +2 -0
  52. package/dist/llm/searchNetwork.d.ts +8 -0
  53. package/dist/llm/subagent.d.ts +112 -0
  54. package/dist/llm/subagent.js +25 -12
  55. package/dist/llm/tools.d.ts +20 -0
  56. package/dist/llm/tools.js +4 -1
  57. package/dist/llm/workspace.d.ts +6 -0
  58. package/dist/llm/workspace.js +271 -0
  59. package/dist/markdown.d.ts +58 -0
  60. package/dist/migration.d.ts +8 -0
  61. package/dist/persistence.d.ts +14 -0
  62. package/dist/plugins/catalog.d.ts +20 -0
  63. package/dist/plugins/catalog.js +45 -0
  64. package/dist/plugins/cli.d.ts +1 -0
  65. package/dist/plugins/cli.js +106 -0
  66. package/dist/plugins/host.d.ts +121 -0
  67. package/dist/plugins/host.js +450 -0
  68. package/dist/plugins/manager.d.ts +24 -0
  69. package/dist/plugins/manager.js +288 -0
  70. package/dist/plugins/package.d.ts +5 -0
  71. package/dist/plugins/package.js +53 -0
  72. package/dist/plugins/runner.d.ts +1 -0
  73. package/dist/plugins/runner.js +227 -0
  74. package/dist/plugins/session.d.ts +12 -0
  75. package/dist/plugins/session.js +97 -0
  76. package/dist/plugins/terminal.d.ts +22 -0
  77. package/dist/plugins/terminal.js +33 -0
  78. package/dist/plugins/types.d.ts +178 -0
  79. package/dist/plugins/types.js +6 -0
  80. package/dist/plugins/validation.d.ts +14 -0
  81. package/dist/plugins/validation.js +174 -0
  82. package/dist/plugins/web-sdk.d.ts +58 -0
  83. package/dist/plugins/web-sdk.js +1 -0
  84. package/dist/pro/agents.d.ts +34 -0
  85. package/dist/pro/agents.js +1 -1
  86. package/dist/pro/config.d.ts +75 -0
  87. package/dist/pro/config.js +3 -2
  88. package/dist/pro/preflight.d.ts +21 -0
  89. package/dist/sanitize.d.ts +34 -0
  90. package/dist/screens/agentConversation.d.ts +28 -0
  91. package/dist/screens/agentHistory.d.ts +25 -0
  92. package/dist/screens/agentSelect.d.ts +16 -0
  93. package/dist/screens/chat.d.ts +292 -0
  94. package/dist/screens/chat.js +179 -65
  95. package/dist/screens/history.d.ts +23 -0
  96. package/dist/screens/modelSelect.d.ts +29 -0
  97. package/dist/screens/plugins.d.ts +29 -0
  98. package/dist/screens/plugins.js +196 -0
  99. package/dist/screens/settings.d.ts +42 -0
  100. package/dist/screens/start.d.ts +43 -0
  101. package/dist/screens/start.js +25 -17
  102. package/dist/screens/updatePrompt.d.ts +41 -0
  103. package/dist/selection.d.ts +75 -0
  104. package/dist/state.d.ts +26 -0
  105. package/dist/terminal/buffer.d.ts +47 -0
  106. package/dist/terminal/input.d.ts +70 -0
  107. package/dist/terminal/renderer.d.ts +43 -0
  108. package/dist/terminal/restore.d.ts +41 -0
  109. package/dist/terminal/screen.d.ts +57 -0
  110. package/dist/tray.d.ts +14 -0
  111. package/dist/ui.d.ts +123 -0
  112. package/dist/update.d.ts +71 -0
  113. package/dist/updateWatch.d.ts +43 -0
  114. package/dist/web/approvalQueue.d.ts +8 -0
  115. package/dist/web/approvalQueue.js +59 -0
  116. package/dist/web/auth.d.ts +14 -0
  117. package/dist/web/clientState.d.ts +16 -0
  118. package/dist/web/folderPicker.d.ts +34 -0
  119. package/dist/web/folderPicker.js +544 -0
  120. package/dist/web/hub.d.ts +213 -0
  121. package/dist/web/hub.js +14 -2
  122. package/dist/web/localApi.d.ts +11 -0
  123. package/dist/web/localApi.js +260 -0
  124. package/dist/web/plugins.d.ts +8 -0
  125. package/dist/web/plugins.js +64 -0
  126. package/dist/web/server.d.ts +81 -0
  127. package/dist/web/server.js +127 -19
  128. package/dist/web/service.d.ts +7 -0
  129. package/dist/web/service.js +1 -0
  130. package/dist/web/session.d.ts +176 -0
  131. package/dist/web/session.js +170 -21
  132. package/dist/web/settings.d.ts +65 -0
  133. package/dist/web/terminalBridge.d.ts +15 -0
  134. package/dist/web/terminalBridge.js +8 -2
  135. package/dist/width.d.ts +6 -0
  136. package/docs/plugins/README.md +126 -0
  137. package/docs/plugins/agent-sdk.md +92 -0
  138. package/docs/plugins/architecture.md +64 -0
  139. package/docs/plugins/compatibility.md +34 -0
  140. package/docs/plugins/development.md +55 -0
  141. package/docs/plugins/manifest.md +59 -0
  142. package/docs/plugins/manifest.schema.json +286 -0
  143. package/docs/plugins/security.md +53 -0
  144. package/docs/plugins/skills-prompts.md +69 -0
  145. package/docs/plugins/ui-sdk.md +109 -0
  146. package/examples/local-api.py +105 -0
  147. package/examples/plugins/cards/card.html +6 -0
  148. package/examples/plugins/cards/neutrino.plugin.json +42 -0
  149. package/examples/plugins/composer/editor.html +10 -0
  150. package/examples/plugins/composer/neutrino.plugin.json +10 -0
  151. package/examples/plugins/function-tools/agent.js +32 -0
  152. package/examples/plugins/function-tools/neutrino.plugin.json +15 -0
  153. package/examples/plugins/menus-tabs/neutrino.plugin.json +15 -0
  154. package/examples/plugins/menus-tabs/panel.html +6 -0
  155. package/examples/plugins/skills-prompts/neutrino.plugin.json +13 -0
  156. package/examples/plugins/skills-prompts/prompts/evidence.md +1 -0
  157. package/examples/plugins/skills-prompts/prompts/reviewer.md +1 -0
  158. package/examples/plugins/skills-prompts/skills/review/SKILL.md +8 -0
  159. package/examples/plugins/theme/neutrino.plugin.json +12 -0
  160. package/package.json +66 -42
  161. package/web/LOCAL-API.md +65 -0
  162. package/web/README.md +30 -8
  163. package/web/app.js +256 -67
  164. package/web/i18n.js +18 -3
  165. package/web/index.html +3 -1
  166. package/web/plugins.css +10 -0
  167. package/web/plugins.js +230 -0
  168. package/web/style.css +12 -3
  169. package/web/turns.js +7 -8
@@ -0,0 +1,65 @@
1
+ # Local programmatic API / 本机程序 API
2
+
3
+ Neutrino 的后端运行时,会同时启动独立的本机 HTTP API。它只监听 IPv4 `127.0.0.1`;即使 Web 控制台开启局域网访问,本 API 也不会随之对局域网开放。默认端口为 `8766`,可在启动前设置 `NEUTRINO_API_PORT`(`0` 表示由操作系统选择空闲端口)。Web 端口设置为 `0` 时,未指定 API 端口也会自动选择空闲端口。端口被占用时后端启动失败并报告错误。API 随后端关闭而关闭。需要不启动 Web 界面时,可单独运行 `neutrino api`(可选 `--port 0` 自动选择端口),只启动本机 API;退出该进程后 API 关闭。`--no-web` 本身不会自动启动这个独立进程。
4
+
5
+ 后端启动后在 `~/.neutrino/api.json` 写入连接信息;设置了 `NEUTRINO_HOME` 时使用 `$NEUTRINO_HOME/api.json`。文件内容为 `{ "pid": 123, "url": "http://127.0.0.1:8766/api/v1", "token": "..." }`,其中端口以文件中的实际地址为准。正常关闭时文件会删除;异常退出可能留下旧文件,连接失败时应检查进程和重新读取文件。多个使用同一数据目录的独立服务会共用发现文件,最后启动的服务会更新它。不要把 token 分享到日志、URL 或网页。Unix 上文件以 `0600` 创建;Windows 的访问控制取决于用户目录的 ACL。
6
+
7
+ 所有请求都需要 `Authorization: Bearer <token>`;Host 必须是发现文件中的 `127.0.0.1:<port>`,带 `Origin` 的请求会被拒绝。使用编程语言的 HTTP 客户端访问;这个接口不开放浏览器跨域调用。接口中的路径均相对于 `api.json` 的 `url`。Pro 工作区在路径开头添加 `/pro`,例如 `/pro/conversations`、`/pro/live/:key/events`。普通和 Pro 的会话、历史互相隔离。
8
+
9
+ ## 开始对话
10
+
11
+ 1. `GET /models` 查看服务商、模型和支持的思考强度;`GET /capabilities` 查看模式。Pro 使用 `GET /pro/models` 查看团队预设。
12
+ 2. `POST /conversations` 创建对话:
13
+
14
+ ```json
15
+ {
16
+ "cwd": "/absolute/path/to/project",
17
+ "selection": { "provider": "Provider", "model": "Model", "intensity": "High" },
18
+ "agent_mode": "standard",
19
+ "approval_mode": "request"
20
+ }
21
+ ```
22
+
23
+ `cwd` 必须是存在的目录。`selection` 指已配置模型;可选 `agent_mode` 为 `standard`、`ptc`、`fast` 或 `fast_dag`,后者还受现有 Fast 可用性配置约束。审批模式为 `request` 或 `auto`。不传的字段沿用当前工作区默认值。返回 `{ok, key, cwd, snapshot}`;`key` 是当前进程中的活动会话标识,重启后应通过历史记录恢复。
24
+
25
+ Pro 创建使用 `POST /pro/conversations` 和 `{ "cwd": "...", "pro_preset": "medium", "approval_mode": "request" }`。Pro 按团队预设选择各角色的模型与强度,不能通过普通 `agent_mode` 指定其他执行模式。
26
+ 3. 建议先连接 `GET /live/:key/events`,再 `POST /live/:key/message`,请求体 `{ "text": "请检查这个项目" }`。运行中的消息按现有 Web 行为排队;请求也可带 `agent_mode` 指定下一回合的模式。
27
+ 4. 流中出现 `snapshot.approval` 或 `approval.requested` 时,使用 `POST /live/:key/approvals/:approval_id` 答复 `{ "approved": true }` 或 `{ "approved": false }`。必须传 JSON 布尔值。请求已取消、已回答或 ID 已过期时返回 `409`;不能用旧 ID 回答新请求。多个审批会依次呈现。`auto` 模式仍遵循现有的自动审查和极高风险规则。
28
+
29
+ `examples/local-api.py` 是标准库示例:
30
+
31
+ ```sh
32
+ python3 examples/local-api.py --cwd /path/to/project \
33
+ --provider Provider --model Model --intensity High --mode standard \
34
+ '请检查这个项目'
35
+ ```
36
+
37
+ 示例订阅输出与状态并在终端询问审批;按 Ctrl+C 可退出客户端。退出或断线不会自动停止服务端任务、批准或拒绝待处理审批;可重新连接并在快照中找到待处理请求,或调用暂停接口。长任务客户端应实现重连,保存事件 ID,并同时展示完整快照中的消息;示例只演示基础连接。
38
+
39
+ ## 流式协议
40
+
41
+ `GET /live/:key/events` 返回 SSE,含 `snapshot`、`approval.requested`、`approval.resolved` 和 `gone` 事件,另有注释心跳。`snapshot` 与 Web 使用同一会话快照:
42
+
43
+ - `messages` 和 `streamingContent` 提供已记录消息、工具调用与当前流式文本;文本为当前累计值,不是增量。
44
+ - `busy`、`paused`、`queued`、`compressing`、`retrying`、`saveError`、`tokens`、`task`、`plan`、`subagent`、`fast`、`pro`、`reviewing` 和 `approval` 等字段描述运行状态。字段可为空或按模式缺省。应结合这些字段和最终消息判断结果,`busy: false` 本身不代表任务成功。
45
+ - `approval` 包含 ID、工具、完整参数、工作目录、风险等级、摘要和原因;`reviewing` 是自动审查进度,不表示正在等待人工审批。`approval.resolved` 表示该请求不再等待,并不单独声明批准还是拒绝。
46
+
47
+ 快照更新采用现有 Web 的合并机制,适合实时显示当前状态,不保证逐 token 或每一次短暂中间状态都单独送达。订阅期间产生的事件带 `id`;重新连接时可用 `Last-Event-ID` 请求重放。服务端在首次订阅后为每个会话保留最近 256 个事件,且尽量限制到约 4 MiB,未连接的会话在 10 分钟后可被清理;单个大快照可能超过这个大小。重放历史不可用时发送 `reset`,随后发送当前完整 `snapshot`。每次连接都会提供当前快照;首次订阅之前的短暂事件和服务重启前的事件无法重放,历史消息请通过会话历史读取。服务支持最多 64 个同时被监视的会话,资源不足时返回 `503`。
48
+
49
+ ## 其他接口
50
+
51
+ 这些接口复用 Web 的业务处理,参数、响应及冲突行为与 [Web API](README.md#api) 一致;普通工作区在以下路径前加 `/api/v1`,Pro 在 `/api/v1` 后再加 `/pro`:
52
+
53
+ | 功能 | 路径 |
54
+ | --- | --- |
55
+ | 会话列表和状态 | `GET /overview`、`GET /sessions`、`GET /live/:key` |
56
+ | 活动会话控制 | `POST /live/:key/pause`、`resume`、`clear`、`close` |
57
+ | 会话配置 | `POST /live/:key/model`、`agent-mode`、`approval-mode`;Pro 使用 `pro-preset` |
58
+ | 历史记录 | `GET /session/:id`、`POST /session/:id/continue`、`POST /session/:id/delete` |
59
+ | 工作目录 | `GET/POST /workspaces`、`GET /fs?path=...`、`POST /fs/mkdir`、`POST /fs/pick` |
60
+ | 其他 Agent 会话 | `GET /agents/:agent/sessions?cwd=...`、`GET /agents/:agent/sessions/:id`、`POST /agents/:agent/sessions/:id/migrate` |
61
+ | 插件 | `GET /plugins`、`GET /plugins/catalog`、`GET /plugins/asset`、`POST /plugins`;参见[插件文档](../docs/plugins/README.md) |
62
+ | 更新状态与操作 | `GET /update/events`、`POST /update/check`、`POST /update` |
63
+ | 侧边栏已读状态 | `GET/POST /seen` |
64
+
65
+ `GET /health` 为健康检查。`GET /live/:key/stream` 仍提供 Web 原有快照流,推荐新客户端使用 `/events`。Web 自身的 `/api/...`、登录方式和局域网行为保持不变。本 API 不提供全局设置、登录、后台服务管理接口;对话级配置和插件操作可用。终端拥有的会话不能通过 `close` 关闭,与 Web 相同。
package/web/README.md CHANGED
@@ -6,14 +6,16 @@ A small, dependency-free single page app that is served by the Neutrino CLI at
6
6
  - browse every saved conversation grouped by working directory (like Codex),
7
7
  with only the five latest transcripts per path shown and the rest collapsed;
8
8
  - watch a running terminal conversation stream in real time: the work behind every
9
- finished turn folds into one line that opens on a click, while the reply itself
10
- stays on screen (the turn being answered is open, and a pause is not a fold);
9
+ finished turn folds into one line that opens on a click, while the full user
10
+ input and final reply stay on screen; earlier history also folds only AI output
11
+ (the turn being answered is open, and a pause is not a fold);
11
12
  - read replies as rendered markdown: headings, nested/task lists, tables, block
12
13
  quotes, code fences, emphasis, safe links and images; raw HTML is escaped;
13
- - start a new conversation in a working directory you choose, including a folder
14
- created from the built-in folder picker;
14
+ - start a new conversation in a working directory you choose, in the operating
15
+ system's folder window (or the in-page picker, which can also create a folder);
15
16
  - switch the workspace between every known folder and **All directories**;
16
17
  - switch the provider, model and intensity for the next turn;
18
+ - select Standard, PTC, the original Fast mode, the new **Fast Mode** (`fast_dag`), or Pro from the composer menu; the choice is saved per conversation and frozen when a message is submitted. See [Fast Mode](../docs/fast-mode.md) for configuration and measured limitations;
17
19
  - edit every terminal setting — defaults, interface language, plan-first turns,
18
20
  default approval mode, context compression, reviewer, Web password, and LAN
19
21
  access;
@@ -259,10 +261,23 @@ working directory plus provider, model, thinking level and approval mode. The
259
261
  conversation is browser-owned from that moment: it appears in the sidebar under
260
262
  its folder and is written to its own session file once the first message exists.
261
263
 
262
- **Browse…** opens the server-side folder picker. It lists folders only, offers
264
+ **Browse…** opens the operating system's own folder window — the Explorer
265
+ dialog on Windows, `choose folder` on macOS, zenity or kdialog on Linux —
266
+ drawn by the console process, so the folder is picked the way it is picked in
267
+ any other application. A browser can only ever see the *contents* of a folder
268
+ it was allowed to read, never the absolute path, which is why the window comes
269
+ from the server and not from the page.
270
+
271
+ The window is raised above the browser and flashed when it opens: it belongs to
272
+ a process that has no window of its own, so Windows would otherwise leave it
273
+ behind the page, with nothing in the taskbar to find it by.
274
+
275
+ The in-page folder picker stays as the fallback: it lists folders only, offers
263
276
  the existing drive roots (on Windows) or `/`, moves up through the directory
264
- tree, and can create a folder in place. **Use this folder** fills the working
265
- directory of the new conversation.
277
+ tree, and can create a folder in place. It opens when no system window can be
278
+ drawn — a phone or another device on the LAN, a headless server, a desktop
279
+ without zenity or kdialog — and **Use this folder** fills the working directory
280
+ in that case too.
266
281
 
267
282
  **Working directories** (the folder button under New conversation) shows every
268
283
  folder the console has opened or that already holds conversations. Choosing one
@@ -391,6 +406,8 @@ to know whether a conversation is driven by the terminal or by the server.
391
406
 
392
407
  ## API
393
408
 
409
+ For other local programs, use the independently authenticated, loopback-only [programmatic API](LOCAL-API.md).
410
+
394
411
  | Method | Path | Purpose |
395
412
  | --- | --- | --- |
396
413
  | GET | `/api/overview` | Sessions grouped by cwd + live sessions |
@@ -398,7 +415,8 @@ to know whether a conversation is driven by the terminal or by the server.
398
415
  | GET | `/api/workspaces` | Recent working directories, launch cwd and home |
399
416
  | POST | `/api/workspaces` | Validate and remember `{ "path": "…" }` |
400
417
  | GET | `/api/fs?path=…` | Folder listing for the picker (folders only, roots, parent) |
401
- | POST | `/api/fs/mkdir` | Create `{ "path": "…" }` and return the new path |
418
+ | POST | `/api/fs/mkdir` | Create `{ "path": "…" }` and return the new path |
419
+ | POST | `/api/fs/pick` | Open the operating system's folder window on this machine and return `{ "path": … }` — `null` when it was closed; loopback clients only |
402
420
  | POST | `/api/conversations` | Start `{ cwd, selection?, approval_mode? }`, returns `{ key, snapshot }` |
403
421
  | GET | `/api/settings` | Model catalog (each model lists its supported intensities), languages, public settings, the live bind address (`web_host`, `web_urls`) and the background state (`background`, `background_running`, `background_url`, one-time `background_prompt`); no credentials |
404
422
  | POST | `/api/settings` | Save validated `{ selection?, settings? }`, including `language`, `plan_first`, `approval_mode`, `web_lan`, `background` and `web_password` |
@@ -465,3 +483,7 @@ programmatically (409 when nothing is pending).
465
483
 
466
484
  `POST /api/live/:key/approval-mode` with `{"mode":"request"|"auto"}` changes
467
485
  the conversation mode and returns its current snapshot (400 for invalid modes).
486
+
487
+ ## Plugins / 插件
488
+
489
+ Open **Plugins** in the sidebar to install local plugins, enable them per profile or project, edit configuration, and select replacement composers and cards. Views use sandboxed iframes and versioned draft APIs. See [插件文档](../docs/plugins/README.md).