@xingjisoft/neutrino 0.1.4 → 0.1.6
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.
- package/README.md +413 -163
- package/assets/prompt.txt +4 -0
- package/dist/agents.js +114 -15
- package/dist/app.js +442 -30
- package/dist/bin.js +177 -5
- package/dist/colors.js +2 -0
- package/dist/compact.js +19 -0
- package/dist/config.js +121 -28
- package/dist/cwd.js +54 -0
- package/dist/header.js +8 -0
- package/dist/llm/approval.js +543 -0
- package/dist/llm/client.js +14 -0
- package/dist/llm/risk.js +377 -0
- package/dist/llm/tools.js +37 -21
- package/dist/persistence.js +51 -0
- package/dist/screens/agentHistory.js +7 -4
- package/dist/screens/chat.js +709 -49
- package/dist/screens/history.js +9 -7
- package/dist/screens/settings.js +131 -14
- package/dist/screens/start.js +50 -16
- package/dist/selection.js +60 -0
- package/dist/state.js +1 -0
- package/dist/terminal/input.js +34 -5
- package/dist/terminal/renderer.js +58 -12
- package/dist/terminal/restore.js +148 -0
- package/dist/ui.js +16 -0
- package/dist/web/auth.js +82 -0
- package/dist/web/hub.js +180 -0
- package/dist/web/server.js +688 -0
- package/dist/web/session.js +572 -0
- package/dist/web/settings.js +101 -0
- package/dist/width.js +20 -0
- package/package.json +6 -4
- package/web/README.md +210 -0
- package/web/app.js +1100 -0
- package/web/index.html +90 -0
- package/web/settings.js +193 -0
- package/web/style.css +1088 -0
- package/web/turns.js +52 -0
package/web/turns.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// Turn folding for the web UI.
|
|
2
|
+
//
|
|
3
|
+
// A conversation is a sequence of turns: each one starts at a user message and
|
|
4
|
+
// runs until the next one. Once the agent has finished a turn, the browser folds
|
|
5
|
+
// it into a single summary line so scrolling back stays manageable, while the
|
|
6
|
+
// complete transcript is still rendered on demand (click the summary).
|
|
7
|
+
//
|
|
8
|
+
// The thresholds mirror TURN_FOLD_MIN_BLOCKS / TURN_FOLD_MIN_CHARS in
|
|
9
|
+
// src/screens/chat.ts, so the terminal and the browser fold the same turns.
|
|
10
|
+
// Short exchanges are left open: hiding two lines behind a click helps nobody.
|
|
11
|
+
|
|
12
|
+
export const TURN_FOLD_MIN_BLOCKS = 4;
|
|
13
|
+
export const TURN_FOLD_MIN_CHARS = 600;
|
|
14
|
+
|
|
15
|
+
/** Split a transcript into turns: `{ start, end }` message index ranges. */
|
|
16
|
+
export function turnRanges(messages) {
|
|
17
|
+
const turns = [];
|
|
18
|
+
messages.forEach((message, index) => {
|
|
19
|
+
if (message.role === "user") turns.push({ start: index, end: messages.length });
|
|
20
|
+
});
|
|
21
|
+
for (let i = 0; i < turns.length - 1; i++) turns[i].end = turns[i + 1].start;
|
|
22
|
+
return turns;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** True when folding this turn saves more room than it costs. */
|
|
26
|
+
export function turnFolds(messages) {
|
|
27
|
+
let blocks = 0;
|
|
28
|
+
let chars = 0;
|
|
29
|
+
for (const message of messages) {
|
|
30
|
+
if (message.role !== "user" && message.role !== "assistant") continue;
|
|
31
|
+
blocks++;
|
|
32
|
+
chars += String(message.content ?? "").length;
|
|
33
|
+
}
|
|
34
|
+
return blocks >= TURN_FOLD_MIN_BLOCKS || chars >= TURN_FOLD_MIN_CHARS;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* The first line of the first (or, with `last`, the last) message in `role`.
|
|
39
|
+
* One line only: the preview is a signpost, the full text is a click away.
|
|
40
|
+
*/
|
|
41
|
+
export function turnPreview(messages, role, last = false) {
|
|
42
|
+
const ordered = last ? [...messages].reverse() : messages;
|
|
43
|
+
for (const message of ordered) {
|
|
44
|
+
if (message.role !== role) continue;
|
|
45
|
+
const line = String(message.content ?? "")
|
|
46
|
+
.split(/\r?\n/)
|
|
47
|
+
.map((part) => part.trim())
|
|
48
|
+
.find((part) => part.length > 0);
|
|
49
|
+
if (line) return line;
|
|
50
|
+
}
|
|
51
|
+
return "";
|
|
52
|
+
}
|