@poolzin/pool-bot 2026.2.23 → 2026.2.25
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/CHANGELOG.md +29 -0
- package/dist/acp/client.js +207 -18
- package/dist/acp/secret-file.js +22 -0
- package/dist/agents/agent-scope.js +10 -0
- package/dist/agents/bash-process-registry.test-helpers.js +29 -0
- package/dist/agents/bash-tools.exec-approval-request.js +20 -0
- package/dist/agents/bash-tools.exec-host-gateway.js +230 -0
- package/dist/agents/bash-tools.exec-host-node.js +235 -0
- package/dist/agents/bash-tools.exec-types.js +1 -0
- package/dist/agents/bash-tools.process.js +224 -218
- package/dist/agents/content-blocks.js +16 -0
- package/dist/agents/model-fallback.js +96 -101
- package/dist/agents/models-config.providers.js +299 -182
- package/dist/agents/pi-embedded-payloads.js +1 -0
- package/dist/agents/pi-embedded-runner/run.overflow-compaction.fixture.js +34 -0
- package/dist/agents/skills.test-helpers.js +13 -0
- package/dist/agents/stable-stringify.js +12 -0
- package/dist/agents/subagent-registry.mocks.shared.js +12 -0
- package/dist/agents/test-helpers/assistant-message-fixtures.js +29 -0
- package/dist/agents/test-helpers/pi-tools-sandbox-context.js +27 -0
- package/dist/agents/tool-policy-shared.js +108 -0
- package/dist/agents/tools/browser-tool.js +160 -54
- package/dist/agents/tools/cron-tool.test-helpers.js +12 -0
- package/dist/agents/tools/discord-actions-moderation-shared.js +27 -0
- package/dist/agents/tools/image-tool.js +214 -99
- package/dist/agents/tools/sessions-history-tool.js +140 -108
- package/dist/agents/workspace.js +222 -46
- package/dist/auto-reply/commands-registry.js +15 -18
- package/dist/auto-reply/fallback-state.js +114 -0
- package/dist/auto-reply/model-runtime.js +68 -0
- package/dist/auto-reply/reply/agent-runner-execution.js +36 -4
- package/dist/auto-reply/reply/agent-runner.js +165 -39
- package/dist/auto-reply/reply/commands-setunset-standard.js +13 -0
- package/dist/browser/config.js +26 -0
- package/dist/browser/navigation-guard.js +31 -0
- package/dist/browser/routes/agent.act.js +431 -424
- package/dist/browser/routes/agent.shared.js +47 -3
- package/dist/browser/routes/agent.snapshot.js +122 -116
- package/dist/browser/routes/agent.storage.js +303 -297
- package/dist/browser/routes/tabs.js +154 -100
- package/dist/browser/server-lifecycle.js +37 -0
- package/dist/build-info.json +3 -3
- package/dist/channels/allow-from.js +25 -0
- package/dist/channels/plugins/account-action-gate.js +13 -0
- package/dist/channels/plugins/message-actions.js +10 -0
- package/dist/channels/telegram/api.js +18 -0
- package/dist/cli/argv.js +84 -21
- package/dist/cli/banner.js +2 -1
- package/dist/cli/exec-approvals-cli.js +92 -124
- package/dist/cli/memory-cli.js +158 -61
- package/dist/cli/nodes-cli/register.push.js +63 -0
- package/dist/cli/nodes-media-utils.js +21 -0
- package/dist/cli/plugins-cli.js +245 -61
- package/dist/cli/program/build-program.js +3 -1
- package/dist/cli/program/command-registry.js +223 -136
- package/dist/cli/program/help.js +43 -12
- package/dist/cli/route.js +1 -1
- package/dist/cli/test-runtime-capture.js +24 -0
- package/dist/commands/agent.js +163 -87
- package/dist/commands/channels.mock-harness.js +23 -0
- package/dist/commands/daemon-install-runtime-warning.js +11 -0
- package/dist/commands/onboard-helpers.js +4 -4
- package/dist/commands/sessions.test-helpers.js +61 -0
- package/dist/compat/legacy-names.js +2 -2
- package/dist/config/commands.js +3 -0
- package/dist/config/config.js +1 -1
- package/dist/config/env-substitution.js +62 -34
- package/dist/config/env-vars.js +9 -0
- package/dist/config/io.js +571 -171
- package/dist/config/merge-patch.js +50 -4
- package/dist/config/redact-snapshot.js +404 -76
- package/dist/config/schema.js +58 -570
- package/dist/config/validation.js +140 -85
- package/dist/config/zod-schema.hooks.js +40 -11
- package/dist/config/zod-schema.installs.js +20 -0
- package/dist/config/zod-schema.js +8 -7
- package/dist/control-ui/assets/{index-HRr1grwl.js → index-Dvkl4Xlx.js} +2 -1
- package/dist/control-ui/assets/{index-HRr1grwl.js.map → index-Dvkl4Xlx.js.map} +1 -1
- package/dist/control-ui/index.html +1 -1
- package/dist/daemon/cmd-argv.js +21 -0
- package/dist/daemon/cmd-set.js +58 -0
- package/dist/daemon/service-types.js +1 -0
- package/dist/discord/monitor/exec-approvals.js +357 -162
- package/dist/gateway/auth.js +38 -3
- package/dist/gateway/call.js +149 -68
- package/dist/gateway/canvas-capability.js +75 -0
- package/dist/gateway/control-plane-audit.js +28 -0
- package/dist/gateway/control-plane-rate-limit.js +53 -0
- package/dist/gateway/events.js +1 -0
- package/dist/gateway/hooks.js +109 -54
- package/dist/gateway/http-common.js +22 -0
- package/dist/gateway/method-scopes.js +169 -0
- package/dist/gateway/net.js +23 -0
- package/dist/gateway/openresponses-http.js +120 -110
- package/dist/gateway/probe-auth.js +2 -0
- package/dist/gateway/protocol/index.js +3 -2
- package/dist/gateway/protocol/schema/protocol-schemas.js +2 -0
- package/dist/gateway/protocol/schema/push.js +18 -0
- package/dist/gateway/protocol/schema.js +1 -0
- package/dist/gateway/server-http.js +236 -52
- package/dist/gateway/server-methods/agent.js +162 -24
- package/dist/gateway/server-methods/chat.js +461 -130
- package/dist/gateway/server-methods/config.js +193 -150
- package/dist/gateway/server-methods/nodes.helpers.js +12 -0
- package/dist/gateway/server-methods/nodes.js +251 -69
- package/dist/gateway/server-methods/push.js +53 -0
- package/dist/gateway/server-reload-handlers.js +2 -3
- package/dist/gateway/server-runtime-config.js +5 -0
- package/dist/gateway/server-runtime-state.js +2 -0
- package/dist/gateway/server-ws-runtime.js +1 -0
- package/dist/gateway/server.impl.js +296 -139
- package/dist/gateway/session-preview.test-helpers.js +11 -0
- package/dist/gateway/startup-auth.js +126 -0
- package/dist/gateway/test-helpers.agent-results.js +15 -0
- package/dist/gateway/test-helpers.mocks.js +37 -14
- package/dist/gateway/test-helpers.server.js +161 -77
- package/dist/hooks/bundled/session-memory/handler.js +165 -34
- package/dist/hooks/gmail-watcher-lifecycle.js +23 -0
- package/dist/infra/archive-path.js +49 -0
- package/dist/infra/device-pairing.js +148 -167
- package/dist/infra/exec-approvals-allowlist.js +19 -70
- package/dist/infra/exec-approvals-analysis.js +44 -17
- package/dist/infra/exec-safe-bin-policy.js +269 -0
- package/dist/infra/fixed-window-rate-limit.js +33 -0
- package/dist/infra/git-root.js +61 -0
- package/dist/infra/heartbeat-active-hours.js +2 -2
- package/dist/infra/heartbeat-reason.js +40 -0
- package/dist/infra/heartbeat-runner.js +72 -32
- package/dist/infra/install-source-utils.js +91 -7
- package/dist/infra/node-pairing.js +50 -105
- package/dist/infra/npm-integrity.js +45 -0
- package/dist/infra/npm-pack-install.js +40 -0
- package/dist/infra/outbound/channel-adapters.js +20 -7
- package/dist/infra/outbound/message-action-runner.js +107 -327
- package/dist/infra/outbound/message.js +59 -36
- package/dist/infra/outbound/outbound-policy.js +52 -25
- package/dist/infra/outbound/outbound-send-service.js +58 -71
- package/dist/infra/pairing-files.js +10 -0
- package/dist/infra/plain-object.js +9 -0
- package/dist/infra/push-apns.js +365 -0
- package/dist/infra/restart-sentinel.js +16 -1
- package/dist/infra/restart.js +229 -26
- package/dist/infra/scp-host.js +54 -0
- package/dist/infra/update-startup.js +86 -9
- package/dist/media/inbound-path-policy.js +114 -0
- package/dist/media/input-files.js +16 -0
- package/dist/memory/test-manager.js +8 -0
- package/dist/plugin-sdk/temp-path.js +47 -0
- package/dist/plugins/discovery.js +217 -23
- package/dist/plugins/hook-runner-global.js +16 -0
- package/dist/plugins/loader.js +192 -26
- package/dist/plugins/logger.js +8 -0
- package/dist/plugins/manifest-registry.js +3 -0
- package/dist/plugins/path-safety.js +34 -0
- package/dist/plugins/registry.js +5 -2
- package/dist/plugins/runtime/index.js +271 -206
- package/dist/providers/github-copilot-models.js +4 -1
- package/dist/security/audit-channel.js +8 -19
- package/dist/security/audit-extra.async.js +354 -182
- package/dist/security/audit-extra.js +11 -1
- package/dist/security/audit-extra.sync.js +340 -33
- package/dist/security/audit-fs.js +31 -13
- package/dist/security/audit.js +145 -371
- package/dist/security/dm-policy-shared.js +24 -0
- package/dist/security/external-content.js +20 -8
- package/dist/security/fix.js +49 -85
- package/dist/security/scan-paths.js +20 -0
- package/dist/security/secret-equal.js +3 -7
- package/dist/security/windows-acl.js +30 -15
- package/dist/shared/node-list-parse.js +13 -0
- package/dist/shared/operator-scope-compat.js +37 -0
- package/dist/shared/text-chunking.js +29 -0
- package/dist/slack/blocks.test-helpers.js +31 -0
- package/dist/slack/monitor/mrkdwn.js +8 -0
- package/dist/telegram/bot-message-dispatch.js +366 -164
- package/dist/telegram/draft-stream.js +30 -7
- package/dist/telegram/reasoning-lane-coordinator.js +128 -0
- package/dist/terminal/prompt-select-styled.js +9 -0
- package/dist/test-utils/command-runner.js +6 -0
- package/dist/test-utils/internal-hook-event-payload.js +10 -0
- package/dist/test-utils/model-auth-mock.js +12 -0
- package/dist/test-utils/provider-usage-fetch.js +14 -0
- package/dist/test-utils/temp-home.js +33 -0
- package/dist/tui/components/chat-log.js +9 -0
- package/dist/tui/tui-command-handlers.js +36 -27
- package/dist/tui/tui-event-handlers.js +122 -32
- package/dist/tui/tui.js +181 -45
- package/dist/utils/mask-api-key.js +10 -0
- package/dist/utils/run-with-concurrency.js +39 -0
- package/dist/web/media.js +4 -0
- package/docs/tools/slash-commands.md +5 -1
- package/extensions/bluebubbles/package.json +1 -1
- package/extensions/copilot-proxy/package.json +1 -1
- package/extensions/diagnostics-otel/package.json +1 -1
- package/extensions/discord/package.json +1 -1
- package/extensions/feishu/package.json +1 -1
- package/extensions/feishu/src/external-keys.ts +19 -0
- package/extensions/google-antigravity-auth/package.json +1 -1
- package/extensions/google-gemini-cli-auth/package.json +1 -1
- package/extensions/googlechat/package.json +1 -1
- package/extensions/imessage/package.json +1 -1
- package/extensions/irc/package.json +1 -1
- package/extensions/line/package.json +1 -1
- package/extensions/llm-task/package.json +1 -1
- package/extensions/lobster/package.json +1 -1
- package/extensions/lobster/src/windows-spawn.ts +193 -0
- package/extensions/matrix/CHANGELOG.md +5 -0
- package/extensions/matrix/package.json +1 -1
- package/extensions/matrix/src/matrix/actions/limits.ts +6 -0
- package/extensions/mattermost/package.json +1 -1
- package/extensions/mattermost/src/mattermost/reactions.test-helpers.ts +83 -0
- package/extensions/memory-core/package.json +1 -1
- package/extensions/memory-lancedb/package.json +1 -1
- package/extensions/minimax-portal-auth/package.json +1 -1
- package/extensions/msteams/CHANGELOG.md +5 -0
- package/extensions/msteams/package.json +1 -1
- package/extensions/nextcloud-talk/package.json +1 -1
- package/extensions/nostr/CHANGELOG.md +5 -0
- package/extensions/nostr/package.json +1 -1
- package/extensions/open-prose/package.json +1 -1
- package/extensions/openai-codex-auth/package.json +1 -1
- package/extensions/signal/package.json +1 -1
- package/extensions/slack/package.json +1 -1
- package/extensions/telegram/package.json +1 -1
- package/extensions/tlon/package.json +1 -1
- package/extensions/twitch/CHANGELOG.md +5 -0
- package/extensions/twitch/package.json +1 -1
- package/extensions/voice-call/CHANGELOG.md +5 -0
- package/extensions/voice-call/package.json +1 -1
- package/extensions/whatsapp/package.json +1 -1
- package/extensions/zalo/CHANGELOG.md +5 -0
- package/extensions/zalo/package.json +1 -1
- package/extensions/zalouser/CHANGELOG.md +5 -0
- package/extensions/zalouser/package.json +1 -1
- package/package.json +1 -1
|
@@ -1,36 +1,42 @@
|
|
|
1
1
|
import { asString, extractTextFromMessage, isCommandMessage } from "./tui-formatters.js";
|
|
2
2
|
import { TuiStreamAssembler } from "./tui-stream-assembler.js";
|
|
3
3
|
export function createEventHandlers(context) {
|
|
4
|
-
const { chatLog, tui, state, setActivityStatus, refreshSessionInfo } = context;
|
|
4
|
+
const { chatLog, tui, state, setActivityStatus, refreshSessionInfo, loadHistory, isLocalRunId, forgetLocalRunId, clearLocalRunIds, } = context;
|
|
5
5
|
const finalizedRuns = new Map();
|
|
6
6
|
const sessionRuns = new Map();
|
|
7
7
|
let streamAssembler = new TuiStreamAssembler();
|
|
8
8
|
let lastSessionKey = state.currentSessionKey;
|
|
9
9
|
const pruneRunMap = (runs) => {
|
|
10
|
-
if (runs.size <= 200)
|
|
10
|
+
if (runs.size <= 200) {
|
|
11
11
|
return;
|
|
12
|
+
}
|
|
12
13
|
const keepUntil = Date.now() - 10 * 60 * 1000;
|
|
13
14
|
for (const [key, ts] of runs) {
|
|
14
|
-
if (runs.size <= 150)
|
|
15
|
+
if (runs.size <= 150) {
|
|
15
16
|
break;
|
|
16
|
-
|
|
17
|
+
}
|
|
18
|
+
if (ts < keepUntil) {
|
|
17
19
|
runs.delete(key);
|
|
20
|
+
}
|
|
18
21
|
}
|
|
19
22
|
if (runs.size > 200) {
|
|
20
23
|
for (const key of runs.keys()) {
|
|
21
24
|
runs.delete(key);
|
|
22
|
-
if (runs.size <= 150)
|
|
25
|
+
if (runs.size <= 150) {
|
|
23
26
|
break;
|
|
27
|
+
}
|
|
24
28
|
}
|
|
25
29
|
}
|
|
26
30
|
};
|
|
27
31
|
const syncSessionKey = () => {
|
|
28
|
-
if (state.currentSessionKey === lastSessionKey)
|
|
32
|
+
if (state.currentSessionKey === lastSessionKey) {
|
|
29
33
|
return;
|
|
34
|
+
}
|
|
30
35
|
lastSessionKey = state.currentSessionKey;
|
|
31
36
|
finalizedRuns.clear();
|
|
32
37
|
sessionRuns.clear();
|
|
33
38
|
streamAssembler = new TuiStreamAssembler();
|
|
39
|
+
clearLocalRunIds?.();
|
|
34
40
|
};
|
|
35
41
|
const noteSessionRun = (runId) => {
|
|
36
42
|
sessionRuns.set(runId, Date.now());
|
|
@@ -42,18 +48,44 @@ export function createEventHandlers(context) {
|
|
|
42
48
|
streamAssembler.drop(runId);
|
|
43
49
|
pruneRunMap(finalizedRuns);
|
|
44
50
|
};
|
|
51
|
+
const clearActiveRunIfMatch = (runId) => {
|
|
52
|
+
if (state.activeChatRunId === runId) {
|
|
53
|
+
state.activeChatRunId = null;
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
const hasConcurrentActiveRun = (runId) => {
|
|
57
|
+
const activeRunId = state.activeChatRunId;
|
|
58
|
+
if (!activeRunId || activeRunId === runId) {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
return sessionRuns.has(activeRunId);
|
|
62
|
+
};
|
|
63
|
+
const maybeRefreshHistoryForRun = (runId) => {
|
|
64
|
+
if (isLocalRunId?.(runId)) {
|
|
65
|
+
forgetLocalRunId?.(runId);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if (hasConcurrentActiveRun(runId)) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
void loadHistory?.();
|
|
72
|
+
};
|
|
45
73
|
const handleChatEvent = (payload) => {
|
|
46
|
-
if (!payload || typeof payload !== "object")
|
|
74
|
+
if (!payload || typeof payload !== "object") {
|
|
47
75
|
return;
|
|
76
|
+
}
|
|
48
77
|
const evt = payload;
|
|
49
78
|
syncSessionKey();
|
|
50
|
-
if (evt.sessionKey !== state.currentSessionKey)
|
|
79
|
+
if (evt.sessionKey !== state.currentSessionKey) {
|
|
51
80
|
return;
|
|
81
|
+
}
|
|
52
82
|
if (finalizedRuns.has(evt.runId)) {
|
|
53
|
-
if (evt.state === "delta")
|
|
83
|
+
if (evt.state === "delta") {
|
|
54
84
|
return;
|
|
55
|
-
|
|
85
|
+
}
|
|
86
|
+
if (evt.state === "final") {
|
|
56
87
|
return;
|
|
88
|
+
}
|
|
57
89
|
}
|
|
58
90
|
noteSessionRun(evt.runId);
|
|
59
91
|
if (!state.activeChatRunId) {
|
|
@@ -61,98 +93,156 @@ export function createEventHandlers(context) {
|
|
|
61
93
|
}
|
|
62
94
|
if (evt.state === "delta") {
|
|
63
95
|
const displayText = streamAssembler.ingestDelta(evt.runId, evt.message, state.showThinking);
|
|
64
|
-
if (!displayText)
|
|
96
|
+
if (!displayText) {
|
|
65
97
|
return;
|
|
98
|
+
}
|
|
66
99
|
chatLog.updateAssistant(displayText, evt.runId);
|
|
67
100
|
setActivityStatus("streaming");
|
|
68
101
|
}
|
|
69
102
|
if (evt.state === "final") {
|
|
103
|
+
const wasActiveRun = state.activeChatRunId === evt.runId;
|
|
104
|
+
if (!evt.message) {
|
|
105
|
+
maybeRefreshHistoryForRun(evt.runId);
|
|
106
|
+
chatLog.dropAssistant(evt.runId);
|
|
107
|
+
noteFinalizedRun(evt.runId);
|
|
108
|
+
clearActiveRunIfMatch(evt.runId);
|
|
109
|
+
if (wasActiveRun) {
|
|
110
|
+
setActivityStatus("idle");
|
|
111
|
+
}
|
|
112
|
+
void refreshSessionInfo?.();
|
|
113
|
+
tui.requestRender();
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
70
116
|
if (isCommandMessage(evt.message)) {
|
|
117
|
+
maybeRefreshHistoryForRun(evt.runId);
|
|
71
118
|
const text = extractTextFromMessage(evt.message);
|
|
72
|
-
if (text)
|
|
119
|
+
if (text) {
|
|
73
120
|
chatLog.addSystem(text);
|
|
121
|
+
}
|
|
74
122
|
streamAssembler.drop(evt.runId);
|
|
75
123
|
noteFinalizedRun(evt.runId);
|
|
76
|
-
|
|
77
|
-
|
|
124
|
+
clearActiveRunIfMatch(evt.runId);
|
|
125
|
+
if (wasActiveRun) {
|
|
126
|
+
setActivityStatus("idle");
|
|
127
|
+
}
|
|
78
128
|
void refreshSessionInfo?.();
|
|
79
129
|
tui.requestRender();
|
|
80
130
|
return;
|
|
81
131
|
}
|
|
132
|
+
maybeRefreshHistoryForRun(evt.runId);
|
|
82
133
|
const stopReason = evt.message && typeof evt.message === "object" && !Array.isArray(evt.message)
|
|
83
134
|
? typeof evt.message.stopReason === "string"
|
|
84
135
|
? evt.message.stopReason
|
|
85
136
|
: ""
|
|
86
137
|
: "";
|
|
87
138
|
const finalText = streamAssembler.finalize(evt.runId, evt.message, state.showThinking);
|
|
88
|
-
|
|
139
|
+
const suppressEmptyExternalPlaceholder = finalText === "(no output)" && !isLocalRunId?.(evt.runId);
|
|
140
|
+
if (suppressEmptyExternalPlaceholder) {
|
|
141
|
+
chatLog.dropAssistant(evt.runId);
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
chatLog.finalizeAssistant(finalText, evt.runId);
|
|
145
|
+
}
|
|
89
146
|
noteFinalizedRun(evt.runId);
|
|
90
|
-
|
|
91
|
-
|
|
147
|
+
clearActiveRunIfMatch(evt.runId);
|
|
148
|
+
if (wasActiveRun) {
|
|
149
|
+
setActivityStatus(stopReason === "error" ? "error" : "idle");
|
|
150
|
+
}
|
|
92
151
|
// Refresh session info to update token counts in footer
|
|
93
152
|
void refreshSessionInfo?.();
|
|
94
153
|
}
|
|
95
154
|
if (evt.state === "aborted") {
|
|
155
|
+
const wasActiveRun = state.activeChatRunId === evt.runId;
|
|
96
156
|
chatLog.addSystem("run aborted");
|
|
97
157
|
streamAssembler.drop(evt.runId);
|
|
98
158
|
sessionRuns.delete(evt.runId);
|
|
99
|
-
|
|
100
|
-
|
|
159
|
+
clearActiveRunIfMatch(evt.runId);
|
|
160
|
+
if (wasActiveRun) {
|
|
161
|
+
setActivityStatus("aborted");
|
|
162
|
+
}
|
|
101
163
|
void refreshSessionInfo?.();
|
|
164
|
+
maybeRefreshHistoryForRun(evt.runId);
|
|
102
165
|
}
|
|
103
166
|
if (evt.state === "error") {
|
|
167
|
+
const wasActiveRun = state.activeChatRunId === evt.runId;
|
|
104
168
|
chatLog.addSystem(`run error: ${evt.errorMessage ?? "unknown"}`);
|
|
105
169
|
streamAssembler.drop(evt.runId);
|
|
106
170
|
sessionRuns.delete(evt.runId);
|
|
107
|
-
|
|
108
|
-
|
|
171
|
+
clearActiveRunIfMatch(evt.runId);
|
|
172
|
+
if (wasActiveRun) {
|
|
173
|
+
setActivityStatus("error");
|
|
174
|
+
}
|
|
109
175
|
void refreshSessionInfo?.();
|
|
176
|
+
maybeRefreshHistoryForRun(evt.runId);
|
|
110
177
|
}
|
|
111
178
|
tui.requestRender();
|
|
112
179
|
};
|
|
113
180
|
const handleAgentEvent = (payload) => {
|
|
114
|
-
if (!payload || typeof payload !== "object")
|
|
181
|
+
if (!payload || typeof payload !== "object") {
|
|
115
182
|
return;
|
|
183
|
+
}
|
|
116
184
|
const evt = payload;
|
|
117
185
|
syncSessionKey();
|
|
118
186
|
// Agent events (tool streaming, lifecycle) are emitted per-run. Filter against the
|
|
119
|
-
// active chat run id, not the session id.
|
|
187
|
+
// active chat run id, not the session id. Tool results can arrive after the chat
|
|
188
|
+
// final event, so accept finalized runs for tool updates.
|
|
120
189
|
const isActiveRun = evt.runId === state.activeChatRunId;
|
|
121
|
-
|
|
190
|
+
const isKnownRun = isActiveRun || sessionRuns.has(evt.runId) || finalizedRuns.has(evt.runId);
|
|
191
|
+
if (!isKnownRun) {
|
|
122
192
|
return;
|
|
193
|
+
}
|
|
123
194
|
if (evt.stream === "tool") {
|
|
195
|
+
const verbose = state.sessionInfo.verboseLevel ?? "off";
|
|
196
|
+
const allowToolEvents = verbose !== "off";
|
|
197
|
+
const allowToolOutput = verbose === "full";
|
|
198
|
+
if (!allowToolEvents) {
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
124
201
|
const data = evt.data ?? {};
|
|
125
202
|
const phase = asString(data.phase, "");
|
|
126
203
|
const toolCallId = asString(data.toolCallId, "");
|
|
127
204
|
const toolName = asString(data.name, "tool");
|
|
128
|
-
if (!toolCallId)
|
|
205
|
+
if (!toolCallId) {
|
|
129
206
|
return;
|
|
207
|
+
}
|
|
130
208
|
if (phase === "start") {
|
|
131
209
|
chatLog.startTool(toolCallId, toolName, data.args);
|
|
132
210
|
}
|
|
133
211
|
else if (phase === "update") {
|
|
212
|
+
if (!allowToolOutput) {
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
134
215
|
chatLog.updateToolResult(toolCallId, data.partialResult, {
|
|
135
216
|
partial: true,
|
|
136
217
|
});
|
|
137
218
|
}
|
|
138
219
|
else if (phase === "result") {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
220
|
+
if (allowToolOutput) {
|
|
221
|
+
chatLog.updateToolResult(toolCallId, data.result, {
|
|
222
|
+
isError: Boolean(data.isError),
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
chatLog.updateToolResult(toolCallId, { content: [] }, { isError: Boolean(data.isError) });
|
|
227
|
+
}
|
|
142
228
|
}
|
|
143
229
|
tui.requestRender();
|
|
144
230
|
return;
|
|
145
231
|
}
|
|
146
232
|
if (evt.stream === "lifecycle") {
|
|
147
|
-
if (!isActiveRun)
|
|
233
|
+
if (!isActiveRun) {
|
|
148
234
|
return;
|
|
235
|
+
}
|
|
149
236
|
const phase = typeof evt.data?.phase === "string" ? evt.data.phase : "";
|
|
150
|
-
if (phase === "start")
|
|
237
|
+
if (phase === "start") {
|
|
151
238
|
setActivityStatus("running");
|
|
152
|
-
|
|
239
|
+
}
|
|
240
|
+
if (phase === "end") {
|
|
153
241
|
setActivityStatus("idle");
|
|
154
|
-
|
|
242
|
+
}
|
|
243
|
+
if (phase === "error") {
|
|
155
244
|
setActivityStatus("error");
|
|
245
|
+
}
|
|
156
246
|
tui.requestRender();
|
|
157
247
|
}
|
|
158
248
|
};
|