@xingjisoft/neutrino 0.3.0 → 0.4.1

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 (56) hide show
  1. package/README.md +33 -549
  2. package/assets/neutrino.ico +0 -0
  3. package/assets/neutrino.svg +7 -0
  4. package/assets/pro/backend_output_model.txt +5 -0
  5. package/assets/pro/claude-module-prompt.txt +65 -0
  6. package/assets/pro/common.txt +9 -0
  7. package/assets/pro/confirm_model.txt +5 -0
  8. package/assets/pro/front_output_model.txt +9 -0
  9. package/assets/pro/genimage_model.txt +1 -0
  10. package/assets/pro/main_model.txt +5 -0
  11. package/assets/pro/model-template.json +376 -0
  12. package/assets/pro/modeling_model.txt +5 -0
  13. package/assets/pro/plan_model.txt +8 -0
  14. package/assets/pro/thinking_model.txt +3 -0
  15. package/dist/agents.js +22 -3
  16. package/dist/app.js +199 -26
  17. package/dist/background.js +358 -0
  18. package/dist/bin.js +184 -44
  19. package/dist/browser.js +57 -0
  20. package/dist/config.js +174 -26
  21. package/dist/header.js +2 -1
  22. package/dist/index.js +1 -1
  23. package/dist/llm/approval.js +6 -2
  24. package/dist/llm/client.js +197 -28
  25. package/dist/llm/subagent.js +37 -1
  26. package/dist/llm/tools.js +3 -1
  27. package/dist/migration.js +33 -0
  28. package/dist/pro/agents.js +104 -0
  29. package/dist/pro/config.js +88 -0
  30. package/dist/pro/preflight.js +172 -0
  31. package/dist/screens/agentConversation.js +48 -5
  32. package/dist/screens/agentHistory.js +4 -2
  33. package/dist/screens/chat.js +14 -8
  34. package/dist/screens/modelSelect.js +15 -4
  35. package/dist/screens/settings.js +52 -9
  36. package/dist/screens/start.js +48 -15
  37. package/dist/state.js +1 -0
  38. package/dist/terminal/restore.js +3 -12
  39. package/dist/tray.js +138 -0
  40. package/dist/ui.js +58 -0
  41. package/dist/web/hub.js +26 -4
  42. package/dist/web/server.js +495 -74
  43. package/dist/web/service.js +135 -0
  44. package/dist/web/session.js +278 -25
  45. package/dist/web/settings.js +97 -24
  46. package/dist/web/terminalBridge.js +250 -0
  47. package/package.json +37 -37
  48. package/web/README.md +150 -16
  49. package/web/app.js +490 -25
  50. package/web/i18n.js +396 -345
  51. package/web/index.html +120 -15
  52. package/web/neutrino-pro.gif +0 -0
  53. package/web/neutrino.png +0 -0
  54. package/web/pro.js +184 -0
  55. package/web/settings.js +373 -247
  56. package/web/style.css +398 -0
package/web/README.md CHANGED
@@ -15,14 +15,17 @@ A small, dependency-free single page app that is served by the Neutrino CLI at
15
15
  - switch the workspace between every known folder and **All directories**;
16
16
  - switch the provider, model and intensity for the next turn;
17
17
  - edit every terminal setting — defaults, interface language, plan-first turns,
18
- default approval mode, context compression, reviewer and Web password;
18
+ default approval mode, context compression, reviewer, Web password, and LAN
19
+ access;
19
20
  - switch the interface between English and 简体中文, instantly and persistently;
20
21
  - open the same plan / token card as the terminal's `ⓘ`, clear a conversation,
21
- delete a saved transcript, and review other agents' read-only history;
22
+ delete a saved transcript, and review or migrate other agents' history;
22
23
  - drive the running conversation: pause / resume the current turn and send new
23
24
  messages (they queue while the agent is busy);
24
25
  - pick up a saved conversation in the browser and keep chatting, even when no
25
- terminal is running.
26
+ terminal is running;
27
+ - run the console as a detached background service, so conversations started in
28
+ the browser survive closing the terminal and the CLI process.
26
29
 
27
30
  Nothing needs to be built — these are plain `.html`, `.css` and `.js` files.
28
31
 
@@ -35,7 +38,13 @@ neutrino
35
38
  ```
36
39
 
37
40
  Use `--port` to move it, `--no-web` to skip it for that run, or turn it off
38
- permanently in the terminal's **Settings → Web console**.
41
+ permanently in the terminal's **Settings → Web console**. LAN access can be
42
+ switched on and off at any time in the browser's **Settings → Web access**
43
+ without restarting anything.
44
+
45
+ To keep the console alive after the terminal exits, turn on **Settings →
46
+ Background residency** in either workspace, or use `neutrino background` — see
47
+ [Background residency](#background-residency).
39
48
 
40
49
  Or serve only the saved history, without a terminal:
41
50
 
@@ -47,6 +56,44 @@ npm run web
47
56
 
48
57
  Then open <http://127.0.0.1:8765>.
49
58
 
59
+ ## Background residency
60
+
61
+ Background residency is off by default. It is a property of the process, so the
62
+ regular and Pro workspaces share it; changing it in either page (or in the
63
+ terminal's **Settings → Background residency**) applies immediately, including
64
+ to browser tasks already in progress.
65
+
66
+ With it on, closing the terminal or exiting the CLI does not interrupt browser
67
+ conversations. With it off, the console follows its attached terminals and lets
68
+ current browser tasks finish before it shuts down. The terminal's own
69
+ conversations remain local to the terminal. Terminal and standalone launches
70
+ share one Web console; a standalone launch reports a conflict if its requested
71
+ port, interface or password setting differs from the running console. A ready
72
+ service can be managed without a terminal:
73
+
74
+ ```sh
75
+ neutrino background start # detach the web console
76
+ neutrino background status # show its pid and address
77
+ neutrino background open # open it in the default browser
78
+ neutrino background stop # stop it
79
+ ```
80
+
81
+ On Windows the service adds a notification-area icon using the same orbit badge
82
+ as the regular console's top-left logo. Click it to open the console; its menu
83
+ opens or stops the service. `--no-tray` suppresses it, and `NEUTRINO_NO_TRAY=1`
84
+ does the same for automation. The service records its pid, address and a random
85
+ management token in `~/.neutrino/background.json` (mode `0600`) and appends
86
+ startup/stop diagnostics to `~/.neutrino/background.log`. The token protects
87
+ `/api/background/ping` and `/api/background/stop`; it is never sent to a
88
+ browser.
89
+
90
+ When a console is mounted by the terminal and the setting is off, the first
91
+ browser to open it is offered **建议开启后台常驻,避免误触中断任务** with a
92
+ highlighted **开启** and **取消**. Either answer consumes the invitation for
93
+ that CLI run — a reload does not ask again. **开启** applies immediately to the
94
+ current browser tasks. The invitation is never shown when residency is already
95
+ on or by a bare `neutrino web` server.
96
+
50
97
  ## Using it from another device
51
98
 
52
99
  The server binds to loopback by default. To open it from your phone or another
@@ -58,6 +105,17 @@ neutrino --host 100.64.0.7 # TUI + web UI, one specific addres
58
105
  neutrino web --port 8765 --lan # headless web UI, every interface
59
106
  ```
60
107
 
108
+ You can also switch this at runtime from the browser: **Settings → Web access →
109
+ Allow access from other devices (LAN, 0.0.0.0)**. The server re-binds the same
110
+ port to `0.0.0.0` immediately — no restart, and the tab you are using keeps its
111
+ open connections — and saves the choice in `config.json`, so the next launch
112
+ starts on the LAN too. Turning the switch off returns the console to
113
+ `127.0.0.1`. An explicit `--host`/`--lan` decides the interface at startup; the
114
+ in-page switch takes over from there for the running process.
115
+
116
+ The console can read every transcript and drive an agent with shell access, so
117
+ keep the Web password on: anyone who can reach the port can use it.
118
+
61
119
  Startup prints the addresses to open:
62
120
 
63
121
  ```
@@ -108,6 +166,61 @@ headers, token URLs, `--token` and `NEUTRINO_WEB_TOKEN` are no longer used.
108
166
  Static files and the login/logout routes stay public. `--no-auth` explicitly
109
167
  disables password login.
110
168
 
169
+ ## Pro workspace
170
+
171
+ The composer has a preset card at its bottom-right. Open it and drag the slider
172
+ to select a team. There are eight roles: main, reasoning, frontend, backend,
173
+ approval, planning, modeling and reserved image generation. Presets are copied
174
+ unchanged from the supplied example into `~/.neutrino/pro/model.json` on first
175
+ use. Edit role assignments there; **Settings** controls the default preset and
176
+ maximum delegation depth (10 by default).
177
+
178
+ Every task checks all active models with a small completion request. Unavailable
179
+ roles recurse down to lower presets independently, and a popup shows the
180
+ replacements. These changes are task-local. The planner then writes the plan
181
+ before main execution; nested specialist calls and commands use the same
182
+ approval gate, with the approval role providing automated reviews.
183
+
184
+ Pro API additions: settings return `pro.presets`, `pro.preset` and
185
+ `pro.max_recursion_depth`; settings patches accept `pro_preset` and
186
+ `pro_max_recursion_depth`. New and resumed conversations accept `pro_preset`.
187
+ `POST /pro/api/live/:key/pro-preset` with `{"preset":"medium"}` changes an idle
188
+ or paused conversation. Snapshots include `pro.checking`, effective `pro.models`,
189
+ `pro.fallbacks`, `pro.checkId` and any `pro.error`.
190
+
191
+ The console has two workspaces. The regular one lives at `/`; the isolated **Pro** workspace lives at `/pro`. Both use the same page, the
192
+ same login cookie and the same model catalog, but nothing else is shared:
193
+
194
+ - **Conversations** — Pro transcripts are saved under
195
+ `~/.neutrino/pro/session/`, so neither sidebar ever lists the other
196
+ workspace's history. Live sessions are separated too: a Pro tab cannot read,
197
+ stream, drive or close a regular session, and vice versa.
198
+ - **Settings** — Pro has its own `~/.neutrino/pro/config.json` with its own
199
+ language, sound alerts, default preset, delegation depth and recent folders.
200
+ `~/.neutrino/pro/model.json` records role models, effort and context capacities;
201
+ provider credentials stay in the shared ordinary model catalog.
202
+ - **Shared on purpose** — the Web password, the approval policy (default
203
+ approval mode, extreme-risk auto-approval) and the console's LAN access. They
204
+ protect or configure the whole machine, so both workspaces, the terminal and
205
+ every browser read and write the same values.
206
+
207
+ In the regular console, click the orbit badge to the left of the **Neutrino**
208
+ title (or the blue hint pointing at it). A `#151515` curtain fades in and plays
209
+ the `neutrino-pro.gif` wordmark in the centre; after three seconds it fades out
210
+ onto `/pro`. The X on the blue hint dismisses it permanently for this browser.
211
+ In the terminal, the **启用Pro模式** box below the status bar starts the Web
212
+ console if necessary and opens `/pro` in the default browser. Pro mode uses the
213
+ static `web/neutrino.png` wordmark as its top-left logo, renames the sidebar
214
+ brand to **Neutrino Pro**, and puts an **Exit Pro mode / 返回普通模式** button
215
+ at the top-right of the workspace, which returns to the regular console at
216
+ `/`. The rest of the workspace is identical to the regular one. The interface
217
+ is available in English and 简体中文 in both workspaces (each remembers its own
218
+ choice).
219
+
220
+ Every API route below has an isolated twin under `/pro/api/` — for example,
221
+ `/pro/api/overview`, `/pro/api/settings` and `/pro/api/live/:key/stream`. The
222
+ login/logout routes are shared and stay unprefixed.
223
+
111
224
  ## Models and settings
112
225
 
113
226
  Open a conversation to see the **Provider**, **Model** and **Thinking**
@@ -124,12 +237,16 @@ removed can still be continued.
124
237
  The **Settings** (gear) button in the sidebar opens the interface language,
125
238
  plan-first turns, the default approval mode, defaults for new conversations, the
126
239
  context compression threshold, the approval reviewer model, sound alerts, the
127
- extreme-risk automatic approval option, and the Web password. Save settings
128
- explicitly; cancelling leaves the saved values intact. Conversation model changes
129
- are separate from these defaults. Models come from the same catalog as the
130
- terminal, and API keys stay on the server. Configure missing keys in the terminal
131
- model screen first. Intensity uses the same Low–Ultra sampling settings as the
132
- terminal.
240
+ extreme-risk automatic approval option, background residency, LAN access, and
241
+ the Web password. Save settings explicitly; cancelling leaves the saved values
242
+ intact. Conversation model changes are separate from these defaults. Models come
243
+ from the same catalog as the terminal, and API keys stay on the server. Configure
244
+ missing keys in the terminal model screen first. Intensity uses the same
245
+ Low–Ultra sampling settings as the terminal, and both only offer the levels the
246
+ selected model declares in `model.json`. The regular and [Pro](#pro-workspace)
247
+ workspaces keep their own copy of every setting here except the approval policy,
248
+ the Web password, LAN access and background residency, which belong to the whole
249
+ process.
133
250
 
134
251
  ## New conversations and working directories
135
252
 
@@ -154,9 +271,11 @@ that has no conversations yet is still listed after a restart.
154
271
 
155
272
  The sidebar footer and **Settings → Interface** both offer English and 简体中文.
156
273
  The change is applied to the already-open page (labels, messages, status line,
157
- plan card and dialogs) without a reload, is stored in `config.json`, and is
158
- shared by every browser. The terminal UI stays in English. New conversation
159
- content, of course, remains in the language the model writes.
274
+ plan card and dialogs) without a reload, is stored in the workspace's
275
+ `config.json`, and is shared by every browser showing that workspace. The
276
+ regular and Pro workspaces remember their own choice. The terminal UI stays in
277
+ English. New conversation content, of course, remains in the language the model
278
+ writes.
160
279
 
161
280
  ## History vs. live sessions
162
281
 
@@ -198,6 +317,14 @@ the complete transcript in the conversation pane with a `read-only` badge. The
198
317
  sources are the same as the terminal's history browser; OpenCode requires Node.js
199
318
  22.13+ because it reads its SQLite database through `node:sqlite`.
200
319
 
320
+ Click **Migrate session** at the bottom right of an opened transcript to convert
321
+ its readable user/assistant text into a new, saved Neutrino conversation. The
322
+ copy opens immediately in the same working directory, using the current
323
+ Neutrino model (or the current Pro preset on `/pro`). The source is unchanged.
324
+ Foreign system prompts, tool records and non-text attachments are not imported.
325
+ The button is disabled while copying; a failed migration leaves the source open
326
+ with an error so you can retry.
327
+
201
328
  ## Plan-first turns
202
329
 
203
330
  A browser-owned turn is planned before it runs, exactly like a turn in the
@@ -254,13 +381,17 @@ to know whether a conversation is driven by the terminal or by the server.
254
381
  | GET | `/api/fs?path=…` | Folder listing for the picker (folders only, roots, parent) |
255
382
  | POST | `/api/fs/mkdir` | Create `{ "path": "…" }` and return the new path |
256
383
  | POST | `/api/conversations` | Start `{ cwd, selection?, approval_mode? }`, returns `{ key, snapshot }` |
257
- | GET | `/api/settings` | Model catalog, languages and public settings; no credentials |
258
- | POST | `/api/settings` | Save validated `{ selection?, settings? }`, including `language`, `plan_first`, `approval_mode` and `web_password` |
384
+ | 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 |
385
+ | POST | `/api/settings` | Save validated `{ selection?, settings? }`, including `language`, `plan_first`, `approval_mode`, `web_lan`, `background` and `web_password` |
386
+ | POST | `/api/background/dismiss` | Consume the one-time background-residency invitation for this console run |
387
+ | GET | `/api/background/ping` | Management probe of a detached service; requires `Authorization: Bearer <background.json token>` |
388
+ | POST | `/api/background/stop` | Ask a detached service to shut down; same bearer token |
259
389
  | GET | `/api/session/:id` | One saved transcript |
260
390
  | POST | `/api/session/:id/continue` | Resume a transcript with optional `{ selection }`, returns `{ key }` |
261
391
  | POST | `/api/session/:id/delete` | Delete a saved, non-running transcript |
262
392
  | GET | `/api/agents/:agent/sessions?cwd=…` | Read-only sessions from Claude Code / Codex / OpenCode |
263
393
  | GET | `/api/agents/:agent/sessions/:id` | Read-only messages of one other-agent session |
394
+ | POST | `/api/agents/:agent/sessions/:id/migrate` | Copy a source in `cwd` into a saved native conversation and return its live key; accepts optional `selection` or Pro `pro_preset` |
264
395
  | GET | `/api/live/:key` | Snapshot of a live session |
265
396
  | GET | `/api/live/:key/stream` | SSE stream of a live session |
266
397
  | POST | `/api/live/:key/pause` | Pause the running turn |
@@ -277,7 +408,10 @@ to know whether a conversation is driven by the terminal or by the server.
277
408
 
278
409
  Conversation and settings routes require the login cookie; see
279
410
  [Authentication](#authentication). `OPTIONS` is answered unauthenticated so
280
- preflights are not blocked, and it returns no data.
411
+ preflights are not blocked, and it returns no data. The `/api/background/*`
412
+ management routes are the exception: they exist only in a detached service and
413
+ authenticate with the bearer token from `background.json`, because the CLI and
414
+ the tray icon have no browser cookie.
281
415
 
282
416
  ### Approval requests
283
417