@vascend/talos 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/LICENSE +22 -0
- package/README.md +37 -12
- package/dist/core/agent.d.ts +16 -3
- package/dist/core/agent.js +170 -70
- package/dist/core/background.d.ts +10 -3
- package/dist/core/background.js +55 -9
- package/dist/core/bootstrap.js +1 -0
- package/dist/core/compaction.js +1 -1
- package/dist/core/config-storage.d.ts +5 -0
- package/dist/core/config-storage.js +83 -0
- package/dist/core/config.d.ts +11 -2
- package/dist/core/config.js +24 -8
- package/dist/core/context-ledger.js +2 -1
- package/dist/core/context-policy.d.ts +1 -1
- package/dist/core/context-policy.js +10 -7
- package/dist/core/credentials.js +29 -30
- package/dist/core/effort.d.ts +1 -1
- package/dist/core/effort.js +5 -1
- package/dist/core/execution-guidance.d.ts +1 -1
- package/dist/core/execution-guidance.js +2 -0
- package/dist/core/file-coordination.d.ts +3 -0
- package/dist/core/file-coordination.js +28 -0
- package/dist/core/file-lease-store.d.ts +3 -0
- package/dist/core/file-lease-store.js +28 -12
- package/dist/core/fusion.d.ts +24 -0
- package/dist/core/fusion.js +80 -0
- package/dist/core/model-limits.d.ts +1 -0
- package/dist/core/model-limits.js +5 -1
- package/dist/core/permission-queue.js +15 -15
- package/dist/core/request-plan.js +4 -3
- package/dist/core/session-naming.d.ts +3 -0
- package/dist/core/session-naming.js +47 -0
- package/dist/core/session-usage.js +4 -1
- package/dist/core/session.d.ts +5 -2
- package/dist/core/session.js +22 -7
- package/dist/core/settings.d.ts +2 -0
- package/dist/core/settings.js +5 -16
- package/dist/core/step-policy.d.ts +18 -0
- package/dist/core/step-policy.js +6 -0
- package/dist/core/storage-health.d.ts +24 -0
- package/dist/core/storage-health.js +72 -0
- package/dist/core/tool-artifacts.d.ts +2 -0
- package/dist/core/tool-artifacts.js +21 -3
- package/dist/core/tool-result-index.js +29 -33
- package/dist/core/tool-result-store.js +6 -5
- package/dist/core/types.d.ts +26 -2
- package/dist/core/user-inbox.d.ts +9 -0
- package/dist/core/user-inbox.js +22 -3
- package/dist/core/user-input.js +1 -1
- package/dist/fusion/autopilot-fast.d.ts +59 -0
- package/dist/fusion/autopilot-fast.js +213 -0
- package/dist/fusion/autopilot.d.ts +75 -0
- package/dist/fusion/autopilot.js +308 -0
- package/dist/fusion/focus.d.ts +30 -0
- package/dist/fusion/focus.js +122 -0
- package/dist/fusion/gate.d.ts +30 -0
- package/dist/fusion/gate.js +95 -0
- package/dist/fusion/jev.d.ts +71 -0
- package/dist/fusion/jev.js +164 -0
- package/dist/fusion/receipts.d.ts +25 -0
- package/dist/fusion/receipts.js +34 -0
- package/dist/fusion/route.d.ts +25 -0
- package/dist/fusion/route.js +84 -0
- package/dist/fusion/run.d.ts +4 -0
- package/dist/fusion/run.js +186 -0
- package/dist/horizon/engine.d.ts +20 -1
- package/dist/horizon/engine.js +57 -0
- package/dist/horizon/index.d.ts +2 -2
- package/dist/horizon/index.js +1 -1
- package/dist/horizon/types.d.ts +29 -0
- package/dist/index.js +12 -0
- package/dist/providers/anthropic-oauth.d.ts +8 -3
- package/dist/providers/anthropic-oauth.js +13 -10
- package/dist/providers/anthropic.d.ts +9 -2
- package/dist/providers/anthropic.js +64 -21
- package/dist/providers/cli-models.d.ts +30 -0
- package/dist/providers/cli-models.js +194 -0
- package/dist/providers/model-effort.js +1 -1
- package/dist/providers/openai-oauth.d.ts +8 -3
- package/dist/providers/openai-oauth.js +9 -3
- package/dist/providers/openrouter-manual-fallback.d.ts +3 -1
- package/dist/providers/openrouter-manual-fallback.js +20 -20
- package/dist/providers/registry.js +3 -2
- package/dist/providers/retry.d.ts +3 -0
- package/dist/providers/retry.js +44 -1
- package/dist/remote/cifratura.d.ts +12 -0
- package/dist/remote/cifratura.js +66 -0
- package/dist/remote/index.d.ts +15 -0
- package/dist/remote/index.js +65 -0
- package/dist/remote/relay-client.d.ts +58 -0
- package/dist/remote/relay-client.js +315 -0
- package/dist/remote/sessione-remota.d.ts +60 -0
- package/dist/remote/sessione-remota.js +266 -0
- package/dist/sdk.d.ts +7 -2
- package/dist/sdk.js +3 -1
- package/dist/tools/builtin.js +41 -20
- package/dist/tools/capabilities.d.ts +3 -1
- package/dist/tools/capabilities.js +5 -2
- package/dist/tools/computer-use.js +2 -1
- package/dist/tools/pagination.js +1 -1
- package/dist/tools/program.js +34 -21
- package/dist/tools/team-tools.js +11 -6
- package/dist/tui/account-entry.js +14 -9
- package/dist/tui/agent-label.d.ts +2 -0
- package/dist/tui/agent-label.js +5 -0
- package/dist/tui/agent-sessions-screen.d.ts +35 -0
- package/dist/tui/agent-sessions-screen.js +178 -0
- package/dist/tui/agent-sessions.d.ts +53 -0
- package/dist/tui/agent-sessions.js +236 -0
- package/dist/tui/bottom-input.d.ts +57 -2
- package/dist/tui/bottom-input.js +449 -54
- package/dist/tui/branding.js +8 -4
- package/dist/tui/capability-lists.d.ts +10 -0
- package/dist/tui/capability-lists.js +41 -0
- package/dist/tui/command-output-registry.js +4 -0
- package/dist/tui/command-transcript.d.ts +1 -1
- package/dist/tui/command-transcript.js +17 -21
- package/dist/tui/commands.js +6 -2
- package/dist/tui/compaction-status.d.ts +7 -0
- package/dist/tui/compaction-status.js +39 -0
- package/dist/tui/config-recovery.d.ts +12 -0
- package/dist/tui/config-recovery.js +54 -0
- package/dist/tui/context-meter.d.ts +3 -0
- package/dist/tui/context-meter.js +35 -8
- package/dist/tui/diff.d.ts +9 -0
- package/dist/tui/diff.js +43 -19
- package/dist/tui/fusion-menu.d.ts +5 -0
- package/dist/tui/fusion-menu.js +89 -0
- package/dist/tui/i18n-catalog.js +351 -2
- package/dist/tui/live-command.d.ts +1 -0
- package/dist/tui/live-command.js +9 -0
- package/dist/tui/live-output.d.ts +1 -0
- package/dist/tui/live-output.js +11 -0
- package/dist/tui/logo.js +3 -0
- package/dist/tui/model-details.js +13 -12
- package/dist/tui/model-picker.d.ts +2 -0
- package/dist/tui/model-picker.js +59 -0
- package/dist/tui/model-selection.js +19 -10
- package/dist/tui/native-scrollback.d.ts +2 -1
- package/dist/tui/native-scrollback.js +31 -6
- package/dist/tui/prompt-queue-store.d.ts +1 -0
- package/dist/tui/prompt-queue-store.js +4 -0
- package/dist/tui/prompt-queue.d.ts +3 -0
- package/dist/tui/prompt-queue.js +19 -1
- package/dist/tui/provider-label.d.ts +2 -0
- package/dist/tui/provider-label.js +9 -0
- package/dist/tui/provider-menu.js +25 -24
- package/dist/tui/queue-screen.js +2 -1
- package/dist/tui/queued-questions.js +2 -4
- package/dist/tui/quick-help.d.ts +1 -1
- package/dist/tui/quick-help.js +3 -0
- package/dist/tui/remote-command.d.ts +7 -0
- package/dist/tui/remote-command.js +79 -0
- package/dist/tui/repl.d.ts +11 -2
- package/dist/tui/repl.js +457 -327
- package/dist/tui/review-store.d.ts +8 -1
- package/dist/tui/review-store.js +64 -11
- package/dist/tui/review-team.js +4 -3
- package/dist/tui/runtime-error.d.ts +2 -0
- package/dist/tui/runtime-error.js +26 -0
- package/dist/tui/scrollback-archive.d.ts +16 -0
- package/dist/tui/scrollback-archive.js +90 -0
- package/dist/tui/selector-mouse.d.ts +1 -0
- package/dist/tui/selector-mouse.js +1 -1
- package/dist/tui/selector.d.ts +11 -0
- package/dist/tui/selector.js +28 -4
- package/dist/tui/session-controls.d.ts +26 -0
- package/dist/tui/session-controls.js +65 -0
- package/dist/tui/session-naming-notice.d.ts +14 -0
- package/dist/tui/session-naming-notice.js +59 -0
- package/dist/tui/session-picker.d.ts +2 -0
- package/dist/tui/session-picker.js +32 -0
- package/dist/tui/session-replay.d.ts +1 -0
- package/dist/tui/session-replay.js +101 -32
- package/dist/tui/session-transcript-layout.d.ts +9 -0
- package/dist/tui/session-transcript-layout.js +41 -0
- package/dist/tui/startup.js +63 -33
- package/dist/tui/status-line.d.ts +1 -1
- package/dist/tui/status-line.js +20 -12
- package/dist/tui/storage-warning.d.ts +2 -0
- package/dist/tui/storage-warning.js +35 -0
- package/dist/tui/talos-art-data.d.ts +1 -0
- package/dist/tui/talos-art-data.js +2 -0
- package/dist/tui/talos-art.d.ts +1 -0
- package/dist/tui/talos-art.js +9 -0
- package/dist/tui/task-labels.d.ts +1 -0
- package/dist/tui/task-labels.js +8 -0
- package/dist/tui/terminal-text.d.ts +2 -1
- package/dist/tui/terminal-text.js +28 -2
- package/dist/tui/theme.js +2 -2
- package/dist/tui/tool-presentation.d.ts +3 -0
- package/dist/tui/tool-presentation.js +98 -0
- package/dist/tui/tool-style.js +4 -0
- package/dist/tui/transcript-store.d.ts +25 -0
- package/dist/tui/transcript-store.js +151 -0
- package/dist/tui/usage-footer.d.ts +1 -1
- package/dist/tui/usage-footer.js +3 -1
- package/dist/tui/vascend-id.d.ts +49 -0
- package/dist/tui/vascend-id.js +321 -0
- package/dist/tui/web-login-screen.js +4 -3
- package/dist/tui/web-login.d.ts +7 -15
- package/dist/tui/web-login.js +38 -78
- package/dist/tui/worker-transcripts.d.ts +31 -0
- package/dist/tui/worker-transcripts.js +91 -0
- package/dist/vascend/candidate-collector.d.ts +6 -5
- package/dist/vascend/candidate-collector.js +44 -43
- package/dist/vascend/context-feedback-loop.js +2 -0
- package/dist/vascend/context-lint.js +32 -2
- package/dist/vascend/context-market-selection.js +12 -5
- package/dist/vascend/context-pack-render.js +10 -4
- package/dist/vascend/context-packet-mirrors.d.ts +8 -0
- package/dist/vascend/context-packet-mirrors.js +24 -0
- package/dist/vascend/context-plan-events.d.ts +4 -0
- package/dist/vascend/context-plan-events.js +44 -0
- package/dist/vascend/context-snapshot.d.ts +1 -0
- package/dist/vascend/context-snapshot.js +8 -5
- package/dist/vascend/context-store-reader.d.ts +20 -0
- package/dist/vascend/context-store-reader.js +46 -0
- package/dist/vascend/context-window-compiler.d.ts +1 -0
- package/dist/vascend/context-window-compiler.js +1 -0
- package/dist/vascend/file-lock.d.ts +1 -0
- package/dist/vascend/file-lock.js +26 -0
- package/dist/vascend/granular-kingdom.d.ts +1 -0
- package/dist/vascend/granular-kingdom.js +52 -17
- package/dist/vascend/kingdom-bus.d.ts +1 -0
- package/dist/vascend/kingdom-bus.js +3 -0
- package/dist/vascend/kingdom-channel.d.ts +2 -0
- package/dist/vascend/kingdom-channel.js +3 -0
- package/dist/vascend/kingdom-live.d.ts +32 -4
- package/dist/vascend/kingdom-live.js +149 -13
- package/dist/vascend/kingdom-run.d.ts +5 -1
- package/dist/vascend/kingdom-run.js +6 -2
- package/dist/vascend/kingdom.d.ts +3 -0
- package/dist/vascend/kingdom.js +22 -11
- package/dist/vascend/memory-packet.d.ts +2 -1
- package/dist/vascend/memory-packet.js +31 -44
- package/dist/vascend/memory-store.d.ts +1 -0
- package/dist/vascend/memory-store.js +12 -4
- package/dist/vascend/plan-store.d.ts +3 -1
- package/dist/vascend/plan-store.js +6 -4
- package/dist/vascend/room-memory.d.ts +13 -2
- package/dist/vascend/room-memory.js +48 -6
- package/dist/vascend/runtime.d.ts +3 -11
- package/dist/vascend/runtime.js +11 -123
- package/dist/vascend/session-search.js +2 -0
- package/dist/vascend/team-session.js +3 -2
- package/dist/vascend/vision.d.ts +3 -1
- package/dist/vascend/vision.js +6 -4
- package/dist/vascend/worker-session.d.ts +20 -0
- package/dist/vascend/worker-session.js +83 -0
- package/package.json +2 -2
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import { WorkerTranscripts } from "./worker-transcripts.js";
|
|
2
|
+
import { tr } from "./i18n.js";
|
|
3
|
+
import { runtimeError } from "./runtime-error.js";
|
|
4
|
+
import { oneLine, plainText } from "./terminal-text.js";
|
|
5
|
+
const EMPTY = { input: 0, output: 0 };
|
|
6
|
+
const MAIN = "main";
|
|
7
|
+
const MAX_TEXT = 64_000;
|
|
8
|
+
const count = (n) => Number.isFinite(n) && n >= 0 ? n : 0;
|
|
9
|
+
const tokens = (u) => ({ input: count(u.inputTokens) + count(u.cacheReadTokens) + count(u.cacheWriteTokens), output: count(u.outputTokens) });
|
|
10
|
+
const add = (a, b) => ({ input: a.input + b.input, output: a.output + b.output });
|
|
11
|
+
function fresh(id, actor, goal = "") {
|
|
12
|
+
return { id, actor, goal, activity: "", live: true, running: false, elapsedMs: 0,
|
|
13
|
+
ledger: EMPTY, fallback: EMPTY, ledgerSeen: false, usageKnown: false, usageMissing: false,
|
|
14
|
+
streaming: "", transcript: [] };
|
|
15
|
+
}
|
|
16
|
+
// Session IDs come from the worker lifecycle, not from a tool call or a label.
|
|
17
|
+
// A finished response does not imply that its worker has been despawned.
|
|
18
|
+
export class AgentSessions {
|
|
19
|
+
conversations = new WorkerTranscripts();
|
|
20
|
+
sessions = new Map([[MAIN, fresh(MAIN, MAIN)]]);
|
|
21
|
+
actors = new Map();
|
|
22
|
+
seenUsage = new Set();
|
|
23
|
+
deleted = new Set();
|
|
24
|
+
listeners = new Set();
|
|
25
|
+
messageListeners = new Set();
|
|
26
|
+
onMessage(listener) {
|
|
27
|
+
this.messageListeners.add(listener);
|
|
28
|
+
return () => { this.messageListeners.delete(listener); };
|
|
29
|
+
}
|
|
30
|
+
subscribe(listener) {
|
|
31
|
+
this.listeners.add(listener);
|
|
32
|
+
return () => { this.listeners.delete(listener); };
|
|
33
|
+
}
|
|
34
|
+
changed() { for (const listener of this.listeners)
|
|
35
|
+
listener(); }
|
|
36
|
+
reset() {
|
|
37
|
+
this.conversations.reset();
|
|
38
|
+
this.sessions = new Map([[MAIN, fresh(MAIN, MAIN)]]);
|
|
39
|
+
this.actors.clear();
|
|
40
|
+
this.seenUsage.clear();
|
|
41
|
+
this.deleted.clear();
|
|
42
|
+
this.changed();
|
|
43
|
+
}
|
|
44
|
+
restoreMain(history) {
|
|
45
|
+
for (const record of history.records) {
|
|
46
|
+
if (!record.actor)
|
|
47
|
+
this.record({ type: "usage", record, persisted: true });
|
|
48
|
+
}
|
|
49
|
+
if (history.incomplete)
|
|
50
|
+
this.sessions.set(MAIN, { ...this.sessions.get(MAIN), usageMissing: true });
|
|
51
|
+
this.changed();
|
|
52
|
+
}
|
|
53
|
+
list(now = Date.now()) {
|
|
54
|
+
return [...this.sessions.values()].filter(s => s.live).map(s => this.snapshot(s, now));
|
|
55
|
+
}
|
|
56
|
+
get(id, now = Date.now()) {
|
|
57
|
+
const s = this.sessions.get(id);
|
|
58
|
+
return s ? this.snapshot(s, now) : undefined;
|
|
59
|
+
}
|
|
60
|
+
get hasAgents() { return [...this.sessions.values()].some(s => s.id !== MAIN && s.live); }
|
|
61
|
+
snapshot(s, now) {
|
|
62
|
+
const usage = s.ledgerSeen ? s.ledger : s.fallback;
|
|
63
|
+
return { kingdomId: s.kingdomId, context: s.context, compacting: s.compacting, compactingAt: s.compactingAt, notice: s.notice, id: s.id, actor: s.actor, goal: s.goal, activity: s.activity, live: s.live, running: s.running,
|
|
64
|
+
startedAt: s.startedAt, elapsedMs: s.elapsedMs + (s.startedAt === undefined ? 0 : Math.max(0, now - s.startedAt)),
|
|
65
|
+
inputTokens: usage.input, outputTokens: usage.output, usageKnown: s.usageKnown, usageMissing: s.usageMissing,
|
|
66
|
+
transcript: s.streaming ? [...s.transcript, s.streaming] : s.transcript };
|
|
67
|
+
}
|
|
68
|
+
/** Remove only the live UI session, never files or persisted team reports. */
|
|
69
|
+
delete(id) {
|
|
70
|
+
if (id === MAIN || !this.sessions.has(id))
|
|
71
|
+
return false;
|
|
72
|
+
this.deleted.add(id);
|
|
73
|
+
this.sessions.delete(id);
|
|
74
|
+
this.conversations.delete(id);
|
|
75
|
+
for (const [actor, sessionId] of this.actors)
|
|
76
|
+
if (sessionId === id)
|
|
77
|
+
this.actors.delete(actor);
|
|
78
|
+
this.changed();
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
notify(id, notice) {
|
|
82
|
+
const session = this.sessions.get(id);
|
|
83
|
+
if (session) {
|
|
84
|
+
this.sessions.set(id, { ...session, notice });
|
|
85
|
+
this.changed();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
begin(goal, at = Date.now()) {
|
|
89
|
+
const s = this.sessions.get(MAIN);
|
|
90
|
+
this.sessions.set(MAIN, { ...s, goal, startedAt: s.startedAt ?? at, running: true,
|
|
91
|
+
activity: tr("Avvio", "Starting") });
|
|
92
|
+
this.changed();
|
|
93
|
+
}
|
|
94
|
+
finish(at = Date.now()) {
|
|
95
|
+
this.stop(MAIN, at, false);
|
|
96
|
+
this.changed();
|
|
97
|
+
}
|
|
98
|
+
stop(id, at, despawn) {
|
|
99
|
+
const s = this.sessions.get(id);
|
|
100
|
+
if (!s)
|
|
101
|
+
return;
|
|
102
|
+
this.sessions.set(id, { ...s, live: !despawn, running: false, startedAt: undefined,
|
|
103
|
+
elapsedMs: s.elapsedMs + (s.startedAt === undefined ? 0 : Math.max(0, at - s.startedAt)),
|
|
104
|
+
activity: tr("Concluso", "Finished") });
|
|
105
|
+
}
|
|
106
|
+
log(s, text, stream = false) {
|
|
107
|
+
if (s.id === MAIN)
|
|
108
|
+
return s;
|
|
109
|
+
const clean = plainText(text).slice(0, 12_000);
|
|
110
|
+
if (stream)
|
|
111
|
+
return { ...s, streaming: (s.streaming + clean).slice(-12_000) };
|
|
112
|
+
const transcript = [...s.transcript, ...(s.streaming ? [s.streaming] : []), clean];
|
|
113
|
+
let size = transcript.reduce((total, item) => total + item.length, 0);
|
|
114
|
+
while (transcript.length > 100 || size > MAX_TEXT)
|
|
115
|
+
size -= transcript.shift().length;
|
|
116
|
+
return { ...s, streaming: "", transcript };
|
|
117
|
+
}
|
|
118
|
+
record(event, at = Date.now(), actor = "Talos") {
|
|
119
|
+
if (event.type === "kingdom" && event.phase === "session") {
|
|
120
|
+
if (this.deleted.has(event.sessionId))
|
|
121
|
+
return;
|
|
122
|
+
if (event.state === "despawned")
|
|
123
|
+
this.conversations.delete(event.sessionId);
|
|
124
|
+
if (event.state === "spawned") {
|
|
125
|
+
if (!this.sessions.has(event.sessionId)) {
|
|
126
|
+
this.sessions.set(event.sessionId, { ...fresh(event.sessionId, event.slug, event.goal),
|
|
127
|
+
kingdomId: event.kingdomId, startedAt: event.at, running: true, activity: tr("Avvio", "Starting") });
|
|
128
|
+
}
|
|
129
|
+
this.actors.set(event.slug, event.sessionId);
|
|
130
|
+
const session = this.sessions.get(event.sessionId);
|
|
131
|
+
this.sessions.set(event.sessionId, { ...session, live: true, running: true, startedAt: session.startedAt ?? event.at });
|
|
132
|
+
}
|
|
133
|
+
else
|
|
134
|
+
this.stop(event.sessionId, event.at, event.state === "despawned");
|
|
135
|
+
// Retain a small completed history, without dropping any live worker.
|
|
136
|
+
const completed = [...this.sessions.values()].filter(s => !s.live);
|
|
137
|
+
for (const s of completed.slice(0, Math.max(0, completed.length - 32))) {
|
|
138
|
+
this.sessions.delete(s.id);
|
|
139
|
+
this.conversations.delete(s.id);
|
|
140
|
+
}
|
|
141
|
+
this.changed();
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
let id = actor === "Talos" ? MAIN : this.actors.get(actor);
|
|
145
|
+
if (event.type === "usage") {
|
|
146
|
+
if (this.deleted.has(event.record.sessionId))
|
|
147
|
+
return;
|
|
148
|
+
id = this.sessions.has(event.record.sessionId) ? event.record.sessionId
|
|
149
|
+
: event.record.actor ? this.actors.get(event.record.actor) : id;
|
|
150
|
+
}
|
|
151
|
+
else if (event.type === "kingdom") {
|
|
152
|
+
if ("slug" in event)
|
|
153
|
+
id = this.actors.get(event.slug);
|
|
154
|
+
else if (event.phase === "message")
|
|
155
|
+
id = this.actors.get(event.from);
|
|
156
|
+
else
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
if (!id)
|
|
160
|
+
return;
|
|
161
|
+
let s = this.sessions.get(id);
|
|
162
|
+
if (!s)
|
|
163
|
+
return;
|
|
164
|
+
if (event.type === "usage") {
|
|
165
|
+
if (this.seenUsage.has(event.record.id))
|
|
166
|
+
return;
|
|
167
|
+
this.seenUsage.add(event.record.id);
|
|
168
|
+
s = { ...s, ledgerSeen: s.ledgerSeen || !!event.record.usage, ledger: event.record.usage ? add(s.ledger, tokens(event.record.usage)) : s.ledger,
|
|
169
|
+
usageKnown: s.usageKnown || !!event.record.usage, usageMissing: s.usageMissing || !event.record.usage };
|
|
170
|
+
}
|
|
171
|
+
else if (event.type === "turn_end") {
|
|
172
|
+
s = { ...s, fallback: event.usage ? add(s.fallback, tokens(event.usage)) : s.fallback,
|
|
173
|
+
usageKnown: s.usageKnown || !!event.usage };
|
|
174
|
+
}
|
|
175
|
+
else if (event.type === "context_window")
|
|
176
|
+
s = { ...s, context: event.ledger };
|
|
177
|
+
else if (event.type === "compacting")
|
|
178
|
+
s = { ...s, compacting: true, compactingAt: at };
|
|
179
|
+
else if (event.type === "compaction_end")
|
|
180
|
+
s = { ...s, compacting: false };
|
|
181
|
+
else if (event.type === "compacted")
|
|
182
|
+
s = { ...s, compacting: false,
|
|
183
|
+
context: s.context ? { ...s.context, tokens: event.tokensAfter, fraction: event.tokensAfter / s.context.window, pressure: event.tokensAfter / s.context.compactAt } : undefined };
|
|
184
|
+
else if (event.type === "status")
|
|
185
|
+
s = { ...s, activity: oneLine(event.label) };
|
|
186
|
+
else if (event.type === "turn_start")
|
|
187
|
+
s = { ...s, running: true, live: true,
|
|
188
|
+
startedAt: s.startedAt ?? at, notice: undefined, activity: tr("Elaborazione", "Thinking") };
|
|
189
|
+
else if (event.type === "reasoning")
|
|
190
|
+
s = { ...s, activity: tr("Elaborazione", "Thinking") };
|
|
191
|
+
else if (event.type === "text")
|
|
192
|
+
s = { ...this.log(s, event.delta, true), activity: tr("Risposta in corso", "Writing") };
|
|
193
|
+
else if (event.type === "tool_call") {
|
|
194
|
+
const args = event.call.input;
|
|
195
|
+
const target = String(args["path"] ?? args["command"] ?? args["pattern"] ?? args["query"] ?? "");
|
|
196
|
+
const activity = `${event.call.name} ${oneLine(target)}`.trim();
|
|
197
|
+
s = { ...this.log(s, `${event.call.name}\n${target}`), activity };
|
|
198
|
+
}
|
|
199
|
+
else if (event.type === "tool_result")
|
|
200
|
+
s = this.log(s, event.result.output);
|
|
201
|
+
else if (event.type === "user_message")
|
|
202
|
+
s = this.log(s, event.text);
|
|
203
|
+
else if (event.type === "error")
|
|
204
|
+
s = { ...this.log(s, runtimeError(event.message)), activity: oneLine(runtimeError(event.message)) };
|
|
205
|
+
else if (event.type === "done")
|
|
206
|
+
s = { ...s, compacting: false, activity: tr("Concluso", "Finished") };
|
|
207
|
+
else if (event.type === "kingdom") {
|
|
208
|
+
if (event.phase === "usage")
|
|
209
|
+
s = { ...s, fallback: { input: count(event.inputTokens), output: count(event.outputTokens) }, usageKnown: true };
|
|
210
|
+
else if (event.phase === "tool") {
|
|
211
|
+
const activity = `${event.tool} ${oneLine(event.command ?? event.args ?? "")}`.trim();
|
|
212
|
+
s = event.state === "start" ? { ...this.log(s, `${event.tool}\n${event.command ?? event.args ?? ""}`), activity }
|
|
213
|
+
: this.log(s, event.output ?? event.state);
|
|
214
|
+
}
|
|
215
|
+
else if (event.phase === "vassal")
|
|
216
|
+
s = { ...s,
|
|
217
|
+
activity: oneLine(event.label ?? (event.state === "done" ? tr("Concluso", "Finished") : tr("Elaborazione", "Thinking"))) };
|
|
218
|
+
else if (event.phase === "say" || event.phase === "note" || event.phase === "inbox" || event.phase === "message")
|
|
219
|
+
s = this.log(s, event.text);
|
|
220
|
+
else
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
else
|
|
224
|
+
return;
|
|
225
|
+
if (id !== MAIN && s.live) {
|
|
226
|
+
this.conversations.record(id, event);
|
|
227
|
+
if (event.type === "user_message") {
|
|
228
|
+
s = { ...s, notice: tr("Messaggio preso in carico", "Message received") };
|
|
229
|
+
for (const listener of this.messageListeners)
|
|
230
|
+
listener(id, event.id);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
this.sessions.set(id, s);
|
|
234
|
+
this.changed();
|
|
235
|
+
}
|
|
236
|
+
}
|
|
@@ -5,6 +5,32 @@ import { type QueuedPrompt } from "./prompt-queue.js";
|
|
|
5
5
|
import type { QueuePersistence } from "./prompt-queue-store.js";
|
|
6
6
|
import { type QueueStyle } from "./queue-screen.js";
|
|
7
7
|
export interface BottomInputHandlers {
|
|
8
|
+
readonly bindSessionInbox?: (session: import("./agent-sessions.js").AgentSession, inbox: import("../core/user-inbox.js").UserInbox) => {
|
|
9
|
+
ok: boolean;
|
|
10
|
+
error?: string;
|
|
11
|
+
};
|
|
12
|
+
readonly wakeSession?: (session: import("./agent-sessions.js").AgentSession) => {
|
|
13
|
+
ok: boolean;
|
|
14
|
+
error?: string;
|
|
15
|
+
};
|
|
16
|
+
readonly onSessionSubmit?: (session: import("./agent-sessions.js").AgentSession, text: string, parts: readonly ContentPart[], immediate: boolean) => {
|
|
17
|
+
ok: boolean;
|
|
18
|
+
error?: string;
|
|
19
|
+
};
|
|
20
|
+
readonly onSessionStop?: (session: import("./agent-sessions.js").AgentSession) => {
|
|
21
|
+
ok: boolean;
|
|
22
|
+
error?: string;
|
|
23
|
+
};
|
|
24
|
+
readonly onSessionDelete?: (session: import("./agent-sessions.js").AgentSession) => {
|
|
25
|
+
ok: boolean;
|
|
26
|
+
error?: string;
|
|
27
|
+
};
|
|
28
|
+
readonly onSessionBackground?: (session: import("./agent-sessions.js").AgentSession) => {
|
|
29
|
+
ok: boolean;
|
|
30
|
+
error?: string;
|
|
31
|
+
};
|
|
32
|
+
readonly sessionFooter?: (session: import("./agent-sessions.js").AgentSession, width: number) => readonly string[];
|
|
33
|
+
readonly sessionBelowInput?: (session: import("./agent-sessions.js").AgentSession, width: number) => readonly string[];
|
|
8
34
|
readonly nativeScroll?: boolean;
|
|
9
35
|
readonly review?: ReviewStore;
|
|
10
36
|
readonly createReviewScreen?: (section?: string) => TerminalScreen;
|
|
@@ -18,11 +44,15 @@ export interface BottomInputHandlers {
|
|
|
18
44
|
readonly attachmentStyle?: (s: string) => string;
|
|
19
45
|
readonly footerLines: () => readonly string[];
|
|
20
46
|
readonly belowInputLines?: () => readonly string[];
|
|
47
|
+
readonly currentModel?: () => string;
|
|
48
|
+
readonly limitWarningStyle?: (s: string) => string;
|
|
49
|
+
readonly warningLines?: () => readonly string[];
|
|
21
50
|
readonly completion: (buffer: string) => string | null;
|
|
22
51
|
readonly hint: (buffer: string) => string;
|
|
23
52
|
readonly statusStyle?: (s: string) => string;
|
|
24
53
|
readonly boxStyle?: (s: string) => string;
|
|
25
54
|
readonly onSubmit: (line: string, signal: AbortSignal, fromQueue?: boolean, queued?: QueuedPrompt) => Promise<void>;
|
|
55
|
+
readonly onCommandDuringRun?: (line: string, signal: AbortSignal) => Promise<void>;
|
|
26
56
|
readonly prepareQueuedInput?: (text: string) => readonly ContentPart[];
|
|
27
57
|
readonly queuePersistence?: () => QueuePersistence;
|
|
28
58
|
readonly restoreQueuedInput?: (entry: QueuedPrompt) => QueuedPrompt;
|
|
@@ -51,7 +81,9 @@ export declare class BottomInput {
|
|
|
51
81
|
private readonly h;
|
|
52
82
|
private buffer;
|
|
53
83
|
private cursor;
|
|
54
|
-
private
|
|
84
|
+
private history;
|
|
85
|
+
private composerSession;
|
|
86
|
+
private readonly sessionDrafts;
|
|
55
87
|
private histIdx;
|
|
56
88
|
private draft;
|
|
57
89
|
private active;
|
|
@@ -59,9 +91,13 @@ export declare class BottomInput {
|
|
|
59
91
|
private ctrlCConfirmation;
|
|
60
92
|
private ctrlCTimer?;
|
|
61
93
|
private running;
|
|
94
|
+
private commandPending;
|
|
62
95
|
private readonly questions;
|
|
63
96
|
private runAbort?;
|
|
64
97
|
private queue;
|
|
98
|
+
private readonly workerQueues;
|
|
99
|
+
private get composerQueue();
|
|
100
|
+
private ensureWorkerQueue;
|
|
65
101
|
private queueEditor;
|
|
66
102
|
private readonly log;
|
|
67
103
|
private readonly logIds;
|
|
@@ -84,8 +120,15 @@ export declare class BottomInput {
|
|
|
84
120
|
private kingdomBoard;
|
|
85
121
|
private overlay;
|
|
86
122
|
private screen;
|
|
123
|
+
private readonly agentSessions?;
|
|
124
|
+
private sessionsUnsubscribe?;
|
|
125
|
+
private messagesUnsubscribe?;
|
|
126
|
+
private sessionsTimer?;
|
|
87
127
|
private modal;
|
|
88
128
|
private statusLabel;
|
|
129
|
+
private sessionLimitNotice;
|
|
130
|
+
private compactionStartedAt;
|
|
131
|
+
private compactionPreviousStatus;
|
|
89
132
|
private statusTool;
|
|
90
133
|
private roomStatus;
|
|
91
134
|
private roomTimer?;
|
|
@@ -95,6 +138,7 @@ export declare class BottomInput {
|
|
|
95
138
|
private tokensOut;
|
|
96
139
|
private frame;
|
|
97
140
|
private spinnerTimer?;
|
|
141
|
+
private readonly namingNotice;
|
|
98
142
|
private lastLayout?;
|
|
99
143
|
private liveStartRow;
|
|
100
144
|
private paintedRows;
|
|
@@ -120,7 +164,7 @@ export declare class BottomInput {
|
|
|
120
164
|
private createQueue;
|
|
121
165
|
restoreQueue(): void;
|
|
122
166
|
get review(): ReviewStore | undefined;
|
|
123
|
-
get userInbox(): import("../
|
|
167
|
+
get userInbox(): import("../core/user-inbox.js").UserInbox;
|
|
124
168
|
acceptQueuedMessage(id: string): string | undefined;
|
|
125
169
|
pauseQueuedMessages(): void;
|
|
126
170
|
showQueue(): void;
|
|
@@ -129,6 +173,10 @@ export declare class BottomInput {
|
|
|
129
173
|
private finishQueueEdit;
|
|
130
174
|
showReview(section?: string): void;
|
|
131
175
|
private get screenVisible();
|
|
176
|
+
private get workerVisible();
|
|
177
|
+
private syncSessionComposer;
|
|
178
|
+
showAgents(): void;
|
|
179
|
+
private sessionArrow;
|
|
132
180
|
static supported(): boolean;
|
|
133
181
|
start(): Promise<void>;
|
|
134
182
|
write(text: string): void;
|
|
@@ -140,8 +188,13 @@ export declare class BottomInput {
|
|
|
140
188
|
setLogLine(index: number, text: string): void;
|
|
141
189
|
setTokens(newInput: number, cache: number, outTok: number): void;
|
|
142
190
|
setStatus(label: string | null): void;
|
|
191
|
+
setCompacting(active: boolean): void;
|
|
192
|
+
showSessionNaming(title: string): void;
|
|
193
|
+
setSessionNaming(phase: "start" | "end", title: string): void;
|
|
143
194
|
getLogLine(index: number): string | undefined;
|
|
144
195
|
isBusy(): boolean;
|
|
196
|
+
submitExternal(line: string, immediate?: boolean): boolean;
|
|
197
|
+
requestStop(): boolean;
|
|
145
198
|
setStatusTool(name: string | null): void;
|
|
146
199
|
setRoomStatus(label: string | null, state?: "running" | "done" | "failed"): void;
|
|
147
200
|
private reportFailure;
|
|
@@ -160,6 +213,7 @@ export declare class BottomInput {
|
|
|
160
213
|
private trimLog;
|
|
161
214
|
private renderedLog;
|
|
162
215
|
private touchLog;
|
|
216
|
+
cyclePermissionMode(): void;
|
|
163
217
|
pause(): void;
|
|
164
218
|
resume(): void;
|
|
165
219
|
setKingdomVassals(data: ReadonlyArray<{
|
|
@@ -207,6 +261,7 @@ export declare class BottomInput {
|
|
|
207
261
|
private submit;
|
|
208
262
|
private dispatch;
|
|
209
263
|
private startNextQueued;
|
|
264
|
+
private runLiveCommand;
|
|
210
265
|
private runLine;
|
|
211
266
|
private quit;
|
|
212
267
|
}
|