@deepseek-harness-tui/dsh-tui 0.18.0 → 0.19.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.
- package/README.md +35 -10
- package/bin/dsh-tui.js +46 -3
- package/guide/dsh-tui-guide/codex-backend.en.md +2 -2
- package/guide/dsh-tui-guide/codex-backend.md +2 -2
- package/guide/dsh-tui-guide/configuration.en.md +7 -2
- package/guide/dsh-tui-guide/configuration.md +7 -2
- package/guide/dsh-tui-guide/getting-started.en.md +168 -4
- package/guide/dsh-tui-guide/getting-started.md +121 -14
- package/guide/dsh-tui-guide/interaction.en.md +11 -10
- package/guide/dsh-tui-guide/interaction.md +5 -4
- package/guide/dsh-tui-guide/user-guide.en.md +6 -5
- package/guide/dsh-tui-guide/user-guide.md +6 -5
- package/lib/settings.json +1 -1
- package/lib/types/adapter/ports/channel-ui.d.ts +10 -7
- package/lib/types/adapter/ports/channel-ui.d.ts.map +1 -1
- package/lib/types/adapter/ports/channel-view.d.ts +28 -5
- package/lib/types/adapter/ports/channel-view.d.ts.map +1 -1
- package/lib/types/agent/events.d.ts +12 -5
- package/lib/types/agent/events.d.ts.map +1 -1
- package/lib/types/agent/session.d.ts +5 -0
- package/lib/types/agent/session.d.ts.map +1 -1
- package/lib/types/backends/claude/translate/core.d.ts +2 -2
- package/lib/types/backends/claude/translate/core.d.ts.map +1 -1
- package/lib/types/backends/claude/translate/core.js +10 -6
- package/lib/types/backends/codex/session/commands.d.ts +2 -0
- package/lib/types/backends/codex/session/commands.d.ts.map +1 -1
- package/lib/types/backends/codex/session/commands.js +8 -4
- package/lib/types/backends/codex/session/input.d.ts +11 -7
- package/lib/types/backends/codex/session/input.d.ts.map +1 -1
- package/lib/types/backends/codex/session/input.js +68 -15
- package/lib/types/backends/codex/session/session.d.ts.map +1 -1
- package/lib/types/backends/codex/session/session.js +2 -3
- package/lib/types/channel/projection.d.ts.map +1 -1
- package/lib/types/channel/projection.js +78 -10
- package/lib/types/channel/questions.d.ts +19 -3
- package/lib/types/channel/questions.d.ts.map +1 -1
- package/lib/types/channel/sanitize.d.ts.map +1 -1
- package/lib/types/channel/sanitize.js +8 -4
- package/lib/types/channel/subagent-failure.d.ts +49 -0
- package/lib/types/channel/subagent-failure.d.ts.map +1 -0
- package/lib/types/channel/subagent-failure.js +59 -0
- package/lib/types/channel/transcript.d.ts +17 -0
- package/lib/types/channel/transcript.d.ts.map +1 -1
- package/lib/types/channel/transcript.js +35 -0
- package/lib/types/commands.js +1 -1
- package/lib/types/components/MessageList.d.ts.map +1 -1
- package/lib/types/components/MessageList.js +11 -7
- package/lib/types/components/PromptInput.d.ts.map +1 -1
- package/lib/types/components/PromptInput.js +61 -6
- package/lib/types/components/SubagentDashboard.d.ts.map +1 -1
- package/lib/types/components/SubagentDashboard.js +7 -1
- package/lib/types/components/messages/AssistantToolUseMessage.d.ts.map +1 -1
- package/lib/types/components/messages/AssistantToolUseMessage.js +5 -2
- package/lib/types/components/questions/AskUserQuestionPanel.d.ts +5 -8
- package/lib/types/components/questions/AskUserQuestionPanel.d.ts.map +1 -1
- package/lib/types/components/questions/AskUserQuestionPanel.js +7 -4
- package/lib/types/components/questions/PlanReviewPanel.d.ts +3 -6
- package/lib/types/components/questions/PlanReviewPanel.d.ts.map +1 -1
- package/lib/types/components/revealScope.d.ts +15 -0
- package/lib/types/components/revealScope.d.ts.map +1 -0
- package/lib/types/components/revealScope.js +17 -0
- package/lib/types/components/sidePanel/btw/BtwComposer.d.ts +34 -1
- package/lib/types/components/sidePanel/btw/BtwComposer.d.ts.map +1 -1
- package/lib/types/components/sidePanel/btw/BtwComposer.js +108 -7
- package/lib/types/components/sidePanel/btw/BtwPanelAdapter.d.ts.map +1 -1
- package/lib/types/components/sidePanel/btw/BtwPanelAdapter.js +1 -1
- package/lib/types/components/sidePanel/btw/BtwThreadScene.d.ts.map +1 -1
- package/lib/types/components/sidePanel/btw/BtwThreadScene.js +1 -1
- package/lib/types/components/smoothReveal.d.ts +36 -6
- package/lib/types/components/smoothReveal.d.ts.map +1 -1
- package/lib/types/components/smoothReveal.js +92 -21
- package/lib/types/components/workspaces/HomeWorkspaceRow.d.ts +4 -14
- package/lib/types/components/workspaces/HomeWorkspaceRow.d.ts.map +1 -1
- package/lib/types/components/workspaces/HomeWorkspaceRow.js +26 -17
- package/lib/types/dsh-adapter/backend/session.d.ts.map +1 -1
- package/lib/types/dsh-adapter/backend/session.js +12 -0
- package/lib/types/dsh-adapter/backend/translate.d.ts.map +1 -1
- package/lib/types/dsh-adapter/backend/translate.js +6 -1
- package/lib/types/dsh-adapter/channel/attached-context.d.ts +15 -2
- package/lib/types/dsh-adapter/channel/attached-context.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/attached-context.js +26 -3
- package/lib/types/dsh-adapter/channel/binding-events.d.ts +3 -0
- package/lib/types/dsh-adapter/channel/binding-events.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/binding-events.js +43 -2
- package/lib/types/dsh-adapter/channel/context-bookkeeping.d.ts +2 -6
- package/lib/types/dsh-adapter/channel/context-bookkeeping.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/context-bookkeeping.js +7 -1
- package/lib/types/dsh-adapter/channel/core/compose.d.ts +2 -6
- package/lib/types/dsh-adapter/channel/core/compose.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/core/compose.js +1 -1
- package/lib/types/dsh-adapter/channel/core/local-actions.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/core/local-actions.js +3 -26
- package/lib/types/dsh-adapter/channel/emitter.js +1 -1
- package/lib/types/dsh-adapter/channel/extensions.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/extensions.js +8 -0
- package/lib/types/dsh-adapter/channel/input-actions.d.ts +2 -2
- package/lib/types/dsh-adapter/channel/input-actions.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/input-actions.js +34 -10
- package/lib/types/dsh-adapter/channel/input-delivery.d.ts +3 -7
- package/lib/types/dsh-adapter/channel/input-delivery.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/input-delivery.js +14 -5
- package/lib/types/dsh-adapter/channel/model-actions.d.ts +4 -1
- package/lib/types/dsh-adapter/channel/model-actions.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/model-actions.js +26 -9
- package/lib/types/dsh-adapter/channel/model-selection.d.ts +27 -2
- package/lib/types/dsh-adapter/channel/model-selection.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/model-selection.js +81 -37
- package/lib/types/dsh-adapter/channel/model-switch.d.ts +1 -1
- package/lib/types/dsh-adapter/channel/model-switch.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/session-rewind.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/session-rewind.js +6 -2
- package/lib/types/dsh-adapter/channel/session-tree-actions.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/session-tree-actions.js +8 -4
- package/lib/types/dsh-adapter/channel/settings-host.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/settings-host.js +6 -3
- package/lib/types/dsh-adapter/channel/transcript.d.ts +3 -2
- package/lib/types/dsh-adapter/channel/transcript.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/transcript.js +13 -4
- package/lib/types/dsh-adapter/channel/types.d.ts +11 -2
- package/lib/types/dsh-adapter/channel/types.d.ts.map +1 -1
- package/lib/types/dsh-adapter/contract.d.ts +26 -3
- package/lib/types/dsh-adapter/contract.d.ts.map +1 -1
- package/lib/types/dsh-adapter/contract.js +44 -5
- package/lib/types/dsh-adapter/fresh-agent.d.ts +1 -1
- package/lib/types/dsh-adapter/fresh-agent.d.ts.map +1 -1
- package/lib/types/dsh-adapter/fresh-agent.js +60 -11
- package/lib/types/dsh-adapter/host-access.d.ts.map +1 -1
- package/lib/types/dsh-adapter/host-access.js +60 -11
- package/lib/types/dsh-adapter/host-contract.d.ts +1 -1
- package/lib/types/dsh-adapter/host-contract.d.ts.map +1 -1
- package/lib/types/dsh-adapter/host-contract.js +4 -2
- package/lib/types/dsh-adapter/host-dsh.d.ts +0 -8
- package/lib/types/dsh-adapter/host-dsh.d.ts.map +1 -1
- package/lib/types/dsh-adapter/host-dsh.js +27 -6
- package/lib/types/dsh-adapter/host-entry.js +4 -0
- package/lib/types/dsh-adapter/oauth/profiles.d.ts.map +1 -1
- package/lib/types/dsh-adapter/oauth/profiles.js +14 -1
- package/lib/types/dsh-adapter/plugin.d.ts.map +1 -1
- package/lib/types/dsh-adapter/plugin.js +143 -44
- package/lib/types/dsh-adapter/presets.d.ts +38 -11
- package/lib/types/dsh-adapter/presets.d.ts.map +1 -1
- package/lib/types/dsh-adapter/presets.js +46 -17
- package/lib/types/dsh-adapter/process-exit.d.ts +1 -1
- package/lib/types/dsh-adapter/process-exit.js +1 -1
- package/lib/types/dsh-adapter/questions.d.ts +3 -4
- package/lib/types/dsh-adapter/questions.d.ts.map +1 -1
- package/lib/types/dsh-adapter/questions.js +1 -1
- package/lib/types/dsh-adapter/session-list-metadata.js +2 -2
- package/lib/types/dsh-adapter/subagents.d.ts +5 -0
- package/lib/types/dsh-adapter/subagents.d.ts.map +1 -1
- package/lib/types/dsh-adapter/subagents.js +22 -1
- package/lib/types/dsh-adapter/team-mode.d.ts +17 -10
- package/lib/types/dsh-adapter/team-mode.d.ts.map +1 -1
- package/lib/types/dsh-adapter/team-mode.js +19 -12
- package/lib/types/dsh-adapter/tool-scope.d.ts +24 -0
- package/lib/types/dsh-adapter/tool-scope.d.ts.map +1 -0
- package/lib/types/dsh-adapter/tool-scope.js +127 -0
- package/lib/types/dsh-adapter/types.d.ts +2 -1
- package/lib/types/dsh-adapter/types.d.ts.map +1 -1
- package/lib/types/heldInputs.d.ts +55 -16
- package/lib/types/heldInputs.d.ts.map +1 -1
- package/lib/types/heldInputs.js +277 -41
- package/lib/types/i18n.d.ts +227 -11
- package/lib/types/i18n.d.ts.map +1 -1
- package/lib/types/i18n.js +60 -5
- package/lib/types/ink/components/App.d.ts +2 -0
- package/lib/types/ink/components/App.d.ts.map +1 -1
- package/lib/types/ink/components/App.js +8 -0
- package/lib/types/ink/events/input-event.d.ts.map +1 -1
- package/lib/types/ink/events/input-event.js +7 -6
- package/lib/types/ink/hit-test.d.ts +2 -0
- package/lib/types/ink/hit-test.d.ts.map +1 -1
- package/lib/types/ink/hit-test.js +10 -0
- package/lib/types/ink/hooks/use-program-status.d.ts +1 -1
- package/lib/types/ink/hooks/use-program-status.d.ts.map +1 -1
- package/lib/types/ink/hooks/use-program-status.js +3 -2
- package/lib/types/ink/ink.d.ts +1 -0
- package/lib/types/ink/ink.d.ts.map +1 -1
- package/lib/types/ink/ink.js +5 -2
- package/lib/types/ink/parse-keypress.d.ts.map +1 -1
- package/lib/types/ink/parse-keypress.js +25 -0
- package/lib/types/ink/terminal.d.ts +13 -2
- package/lib/types/ink/terminal.d.ts.map +1 -1
- package/lib/types/ink/terminal.js +29 -5
- package/lib/types/screens/Chat.d.ts.map +1 -1
- package/lib/types/screens/Chat.js +43 -2
- package/lib/types/screens/SessionSupervisor.d.ts +3 -6
- package/lib/types/screens/SessionSupervisor.d.ts.map +1 -1
- package/lib/types/screens/SessionSupervisor.js +5 -8
- package/lib/types/screens/sessionSupervisor/ForeignSessionPanes.d.ts +1 -2
- package/lib/types/screens/sessionSupervisor/ForeignSessionPanes.d.ts.map +1 -1
- package/lib/types/screens/sessionSupervisor/ForeignSessionPanes.js +2 -2
- package/lib/types/screens/sessionSupervisor/model.d.ts +1 -1
- package/lib/types/screens/sessionSupervisor/model.js +1 -1
- package/lib/types/sessionMounts.d.ts +12 -5
- package/lib/types/sessionMounts.d.ts.map +1 -1
- package/lib/types/sessionMounts.js +33 -6
- package/lib/types/update.d.ts +412 -20
- package/lib/types/update.d.ts.map +1 -1
- package/lib/types/update.js +2094 -193
- package/lib/types/updateHost.d.ts +198 -0
- package/lib/types/updateHost.d.ts.map +1 -0
- package/lib/types/updateHost.js +608 -0
- package/lib/types/utils/processName.d.ts +16 -0
- package/lib/types/utils/processName.d.ts.map +1 -0
- package/lib/types/utils/processName.js +27 -0
- package/package.json +111 -108
- package/tui-profile/feed/README.md +1 -1
- package/tui-profile/feed/first-party.json +1 -1
|
@@ -2,6 +2,7 @@ import { codexText } from '../text.js';
|
|
|
2
2
|
import { errorText, rec, str } from '../narrow.js';
|
|
3
3
|
import { CLIENT } from '../protocol/index.js';
|
|
4
4
|
import { codexImageInputs } from './images.js';
|
|
5
|
+
import { RPC_ERROR, rpcCode } from '../rpc/client.js';
|
|
5
6
|
/** The model-facing input of a submission: every text block as its own
|
|
6
7
|
* text input (the first is what the user typed), in block order. */
|
|
7
8
|
export function userInputOf(input) {
|
|
@@ -33,8 +34,16 @@ export function createInputQueue(deps) {
|
|
|
33
34
|
const steered = new Map();
|
|
34
35
|
/** Why the running turn is being cancelled (decides the fate of steers). */
|
|
35
36
|
let cancelCause;
|
|
37
|
+
/** How many `turn/interrupt` calls are on the wire: a `turn/completed` that
|
|
38
|
+
* lands before the last one is answered is the server's own end, not this
|
|
39
|
+
* interrupt's (see `onTurnCompleted`). A boolean would let the first reply
|
|
40
|
+
* clear the window while a second interrupt is still unanswered. */
|
|
41
|
+
let interruptInFlight = 0;
|
|
36
42
|
let forceTimer;
|
|
37
43
|
let steerFallbackSaid = false;
|
|
44
|
+
/** The running turn showed a user message: what it started ran, echoed
|
|
45
|
+
* id or not (an id-less echo must not read as a refusal). */
|
|
46
|
+
let userMessageSeen = false;
|
|
38
47
|
/** The connection is down: nothing is sent until it is back. */
|
|
39
48
|
let offline = false;
|
|
40
49
|
/** The connection is gone FOR GOOD: submits fail fast instead of parking. */
|
|
@@ -57,8 +66,12 @@ export function createInputQueue(deps) {
|
|
|
57
66
|
resolveReviewStart = undefined;
|
|
58
67
|
starting = undefined;
|
|
59
68
|
};
|
|
60
|
-
/** Send one input as a new turn.
|
|
61
|
-
|
|
69
|
+
/** Send one input as a new turn. A queued input a protocol-level refusal
|
|
70
|
+
* rejects is `dropped` (the channel holds it); a direct submit's refusal
|
|
71
|
+
* answers it. A timeout, a lost connection or an `internal`/unknown error
|
|
72
|
+
* is no refusal: the server may still run the turn, so the input stays a
|
|
73
|
+
* discard. */
|
|
74
|
+
const startTurn = async (entry, queued = false) => {
|
|
62
75
|
started.set(entry.id, entry);
|
|
63
76
|
let resolveStart;
|
|
64
77
|
starting = new Promise(resolve => { resolveStart = resolve; });
|
|
@@ -82,8 +95,20 @@ export function createInputQueue(deps) {
|
|
|
82
95
|
resolveStart(undefined);
|
|
83
96
|
const reason = codexText('codex-turn-start-failed', { err: errorText(error) });
|
|
84
97
|
deps.debug(`codex: turn/start failed (${errorText(error)})`);
|
|
85
|
-
|
|
86
|
-
|
|
98
|
+
// Only a protocol-level rejection proves the server did not take the
|
|
99
|
+
// input. `internal` or an unknown code may answer a request it already
|
|
100
|
+
// started, so holding that input could run it twice (#1651).
|
|
101
|
+
const code = rpcCode(error);
|
|
102
|
+
const refused = !offline
|
|
103
|
+
&& (code === RPC_ERROR.invalidRequest || code === RPC_ERROR.methodNotFound || code === RPC_ERROR.invalidParams);
|
|
104
|
+
// A queued input has no caller left to read the result, so its refusal is
|
|
105
|
+
// announced on the pending channel. A direct submit carries `dropped`
|
|
106
|
+
// back instead: retiring its preview here would race that answer.
|
|
107
|
+
if (refused && queued)
|
|
108
|
+
deps.emit([pendingEvent({ dropped: [entry.id] })]);
|
|
109
|
+
else if (!refused)
|
|
110
|
+
deps.emit([pendingEvent({ discarded: [entry.id] })]);
|
|
111
|
+
return { accepted: false, reason, ...(refused ? { dropped: true } : {}) };
|
|
87
112
|
}
|
|
88
113
|
finally {
|
|
89
114
|
starting = undefined;
|
|
@@ -96,7 +121,7 @@ export function createInputQueue(deps) {
|
|
|
96
121
|
const next = queue.shift();
|
|
97
122
|
if (next === undefined)
|
|
98
123
|
return;
|
|
99
|
-
void startTurn(next).then(result => {
|
|
124
|
+
void startTurn(next, true).then(result => {
|
|
100
125
|
if (!result.accepted)
|
|
101
126
|
deps.emit([{ type: 'notice', level: 'error', text: result.reason ?? codexText('codex-turn-start-failed', { err: '' }) }]);
|
|
102
127
|
else
|
|
@@ -134,8 +159,13 @@ export function createInputQueue(deps) {
|
|
|
134
159
|
// Dispose has already stopped notification delivery. It cannot wait for
|
|
135
160
|
// a review lifecycle id that only a notification could resolve.
|
|
136
161
|
const turnId = activeTurnId ?? (resolveReviewStart !== undefined && !waitForReviewStart ? undefined : await starting);
|
|
137
|
-
if (turnId === undefined)
|
|
162
|
+
if (turnId === undefined) {
|
|
163
|
+
// No turn took it (its start failed): the next turn's end is not this
|
|
164
|
+
// interrupt's.
|
|
165
|
+
cancelCause = undefined;
|
|
138
166
|
return true;
|
|
167
|
+
}
|
|
168
|
+
interruptInFlight += 1;
|
|
139
169
|
try {
|
|
140
170
|
await deps.call(CLIENT.turnInterrupt, { threadId: deps.threadId, turnId });
|
|
141
171
|
}
|
|
@@ -143,6 +173,9 @@ export function createInputQueue(deps) {
|
|
|
143
173
|
deps.debug(`codex: turn/interrupt failed (${errorText(error)})`);
|
|
144
174
|
return false;
|
|
145
175
|
}
|
|
176
|
+
finally {
|
|
177
|
+
interruptInFlight -= 1;
|
|
178
|
+
}
|
|
146
179
|
if (forceTimer === undefined) {
|
|
147
180
|
forceTimer = deps.clock.setTimeout(() => {
|
|
148
181
|
forceTimer = undefined;
|
|
@@ -163,14 +196,21 @@ export function createInputQueue(deps) {
|
|
|
163
196
|
settleReviewStart();
|
|
164
197
|
activeTurnId = undefined;
|
|
165
198
|
reviewTurnId = undefined;
|
|
166
|
-
|
|
199
|
+
// A `turn/completed` that lands while `turn/interrupt` is still unanswered
|
|
200
|
+
// is the server's own end: the interrupt came too late to stop it, so the
|
|
201
|
+
// turn is not this session's cancellation and unclaimed inputs stay
|
|
202
|
+
// `dropped` (the channel holds them) instead of being thrown away.
|
|
203
|
+
const cause = interruptInFlight > 0 && !interrupted ? undefined : cancelCause;
|
|
167
204
|
cancelCause = undefined;
|
|
205
|
+
const ran = userMessageSeen;
|
|
206
|
+
userMessageSeen = false;
|
|
168
207
|
const events = [];
|
|
169
|
-
// A turn/start whose user message
|
|
208
|
+
// A turn/start whose turn showed no user message: it did not run. Unless
|
|
209
|
+
// this session cancelled the turn, the input is held (`dropped`).
|
|
170
210
|
if (started.size > 0) {
|
|
171
211
|
const ids = [...started.keys()];
|
|
172
212
|
started.clear();
|
|
173
|
-
events.push(pendingEvent({ discarded: ids }));
|
|
213
|
+
events.push(pendingEvent(cause === undefined && !ran ? { dropped: ids } : { discarded: ids }));
|
|
174
214
|
}
|
|
175
215
|
if (steered.size > 0) {
|
|
176
216
|
const leftover = [...steered.values()];
|
|
@@ -220,7 +260,14 @@ export function createInputQueue(deps) {
|
|
|
220
260
|
return steer(entry);
|
|
221
261
|
case 'now':
|
|
222
262
|
queue.unshift({ ...entry, urgent: true });
|
|
223
|
-
|
|
263
|
+
// This session's own interrupt, like a user cancel: an input the
|
|
264
|
+
// turn had not echoed yet is discarded, not held as dropped.
|
|
265
|
+
cancelCause ??= 'user';
|
|
266
|
+
void interrupt().then(ok => {
|
|
267
|
+
// The turn goes on: its end must not be read as this interrupt's.
|
|
268
|
+
if (!ok && cancelCause === 'user')
|
|
269
|
+
cancelCause = undefined;
|
|
270
|
+
});
|
|
224
271
|
return { accepted: true };
|
|
225
272
|
default:
|
|
226
273
|
queue.push(entry);
|
|
@@ -257,8 +304,12 @@ export function createInputQueue(deps) {
|
|
|
257
304
|
queue.splice(index, 1);
|
|
258
305
|
return true;
|
|
259
306
|
},
|
|
260
|
-
/**
|
|
307
|
+
/** The turn showed a user message; one carrying a client id back says
|
|
308
|
+
* that input ran. */
|
|
261
309
|
claim(clientId) {
|
|
310
|
+
userMessageSeen = true;
|
|
311
|
+
if (clientId === undefined)
|
|
312
|
+
return undefined;
|
|
262
313
|
if (!started.delete(clientId) && !steered.delete(clientId))
|
|
263
314
|
return undefined;
|
|
264
315
|
return pendingEvent({ claimed: [clientId] });
|
|
@@ -301,6 +352,7 @@ export function createInputQueue(deps) {
|
|
|
301
352
|
settleReviewStart();
|
|
302
353
|
activeTurnId = undefined;
|
|
303
354
|
reviewTurnId = undefined;
|
|
355
|
+
userMessageSeen = false;
|
|
304
356
|
const lost = [...started.keys(), ...steered.keys()];
|
|
305
357
|
started.clear();
|
|
306
358
|
steered.clear();
|
|
@@ -311,15 +363,16 @@ export function createInputQueue(deps) {
|
|
|
311
363
|
dead = false;
|
|
312
364
|
drain();
|
|
313
365
|
},
|
|
314
|
-
/** The connection is gone for good: the parked queue
|
|
315
|
-
*
|
|
316
|
-
* forever behind an offline flag nothing will ever
|
|
366
|
+
/** The connection is gone for good: the parked queue never went out,
|
|
367
|
+
* so it is `dropped` (the channel holds it) and later submits fail fast
|
|
368
|
+
* instead of parking forever behind an offline flag nothing will ever
|
|
369
|
+
* clear. */
|
|
317
370
|
permanentLoss() {
|
|
318
371
|
offline = false;
|
|
319
372
|
dead = true;
|
|
320
373
|
const dropped = queue.map(entry => entry.id);
|
|
321
374
|
queue = [];
|
|
322
|
-
return dropped.length === 0 ? [] : [pendingEvent({
|
|
375
|
+
return dropped.length === 0 ? [] : [pendingEvent({ dropped })];
|
|
323
376
|
},
|
|
324
377
|
/** Dispose: forget everything, stop the timer. */
|
|
325
378
|
close() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../../../src/backends/codex/session/session.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAc,YAAY,EAAoD,MAAM,2BAA2B,CAAA;AAI3H,OAAO,EAAuC,KAAK,GAAG,EAAE,MAAM,cAAc,CAAA;AAyB5E,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAOhE,qEAAqE;AACrE,wBAAgB,YAAY,CAAC,QAAQ,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,GAAG,YAAY,CAkB7E;AAED,yEAAyE;AACzE,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAKpF;AAED;;qBAEqB;AACrB,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,YAAY,CAAC,
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../../../src/backends/codex/session/session.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAc,YAAY,EAAoD,MAAM,2BAA2B,CAAA;AAI3H,OAAO,EAAuC,KAAK,GAAG,EAAE,MAAM,cAAc,CAAA;AAyB5E,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAOhE,qEAAqE;AACrE,wBAAgB,YAAY,CAAC,QAAQ,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,GAAG,YAAY,CAkB7E;AAED,yEAAyE;AACzE,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAKpF;AAED;;qBAEqB;AACrB,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,YAAY,CAAC,CAsuBpF"}
|
|
@@ -460,9 +460,8 @@ export async function openCodexSession(deps) {
|
|
|
460
460
|
const item = rec(params.item);
|
|
461
461
|
if (item?.type === 'enteredReviewMode' && nativeTurn !== undefined)
|
|
462
462
|
noteReviewStarted(nativeTurn);
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
const claimed = input.claim(clientId);
|
|
463
|
+
if (item?.type === 'userMessage') {
|
|
464
|
+
const claimed = input.claim(str(item.clientId));
|
|
466
465
|
if (claimed !== undefined)
|
|
467
466
|
before.push(claimed);
|
|
468
467
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"projection.d.ts","sourceRoot":"","sources":["../../../src/channel/projection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,g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,0DAA0D;AAC1D,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,eAAe,EAAE,IAAI,EAAE,qBAAqB;oBA88ClE,SAAS,UAAU,EAAE,QAAQ,cAAc,KAAG,IAAI;iBA6CvD,IAAI;2BAhuCM,IAAI;6BAmDF,IAAI;;;;;;;;;;;EA4sCnC;AAED,MAAM,MAAM,iBAAiB,GAAG,UAAU,CAAC,OAAO,uBAAuB,CAAC,CAAA"}
|
|
@@ -3,10 +3,10 @@ import { t } from '../i18n.js';
|
|
|
3
3
|
import { logForDebugging } from '../utils/debug.js';
|
|
4
4
|
import { laneOf } from './activity.js';
|
|
5
5
|
import { buildQuestionRecord, parseQuestionRecordAnswers, parseQuestionRecordQuestions } from './question-record.js';
|
|
6
|
-
import { cleanRenderText, NOTICE_CELLS } from './sanitize.js';
|
|
6
|
+
import { cleanCommandReport, cleanRenderText, NOTICE_CELLS } from './sanitize.js';
|
|
7
7
|
import { appendLiveOutput } from './live-output.js';
|
|
8
8
|
import { replaySelectionAttachment } from './selection-record.js';
|
|
9
|
-
import { ARGS_PREVIEW_LIMIT, LOCAL_OUTPUT_LIMIT, preview, RESULT_PREVIEW_LIMIT } from './transcript.js';
|
|
9
|
+
import { ARGS_PREVIEW_LIMIT, LOCAL_OUTPUT_LIMIT, preview, previewIndented, RESULT_PREVIEW_LIMIT, trimLocalRows } from './transcript.js';
|
|
10
10
|
import { addUsageToBucket, emptyCostBuckets, estimateTokens, estimateTokensFraction, usageOutputTokens } from './usage.js';
|
|
11
11
|
/** Notice keys whose live toast is tracked (a repeat replaces it). */
|
|
12
12
|
const MAX_KEYED_TOASTS = 32;
|
|
@@ -201,7 +201,11 @@ export function createChannelProjection(state, deps) {
|
|
|
201
201
|
assistantRowsBySeq.set(row.seq, row);
|
|
202
202
|
};
|
|
203
203
|
const openStreaming = (seq) => {
|
|
204
|
-
|
|
204
|
+
// `fresh` is a LIVE-only claim (channel-view.ts): a replay batch folds the
|
|
205
|
+
// session's own durable deltas through this same factory, and a replayed
|
|
206
|
+
// row that claims freshness makes the transcript typewrite history from
|
|
207
|
+
// its first character on every resume.
|
|
208
|
+
streaming = { id: deps.rowIds.value, kind: 'assistant', text: '', streaming: true, fresh: !replaying, ...seq !== undefined ? { seq } : {} };
|
|
205
209
|
deps.rowIds.value += 1;
|
|
206
210
|
appendRow(streaming);
|
|
207
211
|
indexAssistantRow(streaming);
|
|
@@ -691,11 +695,50 @@ export function createChannelProjection(state, deps) {
|
|
|
691
695
|
}
|
|
692
696
|
// Command output a backend recorded as an input (Claude: `!!` output
|
|
693
697
|
// sent on to the model): live, the channel already showed the command
|
|
694
|
-
// and its output; a replay restores the output row.
|
|
698
|
+
// and its output; a replay restores the output row. A backend command
|
|
699
|
+
// that answers itself (`/usage`, `/diff`) has no channel-side echo, and
|
|
700
|
+
// marks its record `displayLive` so the live pass draws it too.
|
|
695
701
|
if (event.source === 'command-output') {
|
|
696
|
-
if (replaying && event.text !== '') {
|
|
697
|
-
|
|
698
|
-
|
|
702
|
+
if ((replaying || event.displayLive === true) && event.text !== '') {
|
|
703
|
+
if (event.displayLive === true) {
|
|
704
|
+
// A backend command's own report (`/usage` windows, a git diff): the
|
|
705
|
+
// same bounded shape `pushLocal` uses for registry reports — 200
|
|
706
|
+
// lines, 64K UTF-16 units, 4000 cells per line, ANSI/C0 stripped,
|
|
707
|
+
// indentation and blank rows kept; a trailing newline is not a row.
|
|
708
|
+
const report = cleanCommandReport(event.text);
|
|
709
|
+
// A terminator-only report has nothing to draw: a lone title row
|
|
710
|
+
// would read as a render failure. The channel-side sink keeps the
|
|
711
|
+
// same guard, so both shapes stay identical.
|
|
712
|
+
if (report.lines.length === 0 && !report.truncated)
|
|
713
|
+
return;
|
|
714
|
+
// The `local` title is the block boundary `trimLocalRows` relies on
|
|
715
|
+
// (and tells the reader which command produced the report). `label`
|
|
716
|
+
// is a neutral event field, so it takes the same render sanitizer as
|
|
717
|
+
// the body instead of reaching the row verbatim; a label that cleans
|
|
718
|
+
// to nothing falls back to the neutral title rather than drawing an
|
|
719
|
+
// empty row.
|
|
720
|
+
const title = cleanRenderText(event.label ?? '', NOTICE_CELLS) || t('command-output-title');
|
|
721
|
+
trimLocalRows(state.rows, report.lines.length + 1 + Number(report.truncated));
|
|
722
|
+
appendRow({ id: deps.rowIds.value, kind: 'local', text: title, seq: event.seq });
|
|
723
|
+
deps.rowIds.value += 1;
|
|
724
|
+
for (const line of report.lines) {
|
|
725
|
+
// `cleanCommandReport` already bounded the line in cells; this
|
|
726
|
+
// call only normalizes newlines and blank rows (the 65K limit can
|
|
727
|
+
// never cut here — a 240 limit would undo the report budget).
|
|
728
|
+
appendRow({ id: deps.rowIds.value, kind: 'local-output', text: previewIndented(line, 65_536), seq: event.seq });
|
|
729
|
+
deps.rowIds.value += 1;
|
|
730
|
+
}
|
|
731
|
+
if (report.truncated) {
|
|
732
|
+
appendRow({ id: deps.rowIds.value, kind: 'local-output', text: t('command-output-truncated'), seq: event.seq });
|
|
733
|
+
deps.rowIds.value += 1;
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
else {
|
|
737
|
+
// `!`/`!!` output keeps the live shape the channel already showed
|
|
738
|
+
// (one flattened row): the replay must not disagree with it.
|
|
739
|
+
appendRow({ id: deps.rowIds.value, kind: 'local-output', text: preview(event.text, LOCAL_OUTPUT_LIMIT), seq: event.seq });
|
|
740
|
+
deps.rowIds.value += 1;
|
|
741
|
+
}
|
|
699
742
|
}
|
|
700
743
|
return;
|
|
701
744
|
}
|
|
@@ -960,8 +1003,9 @@ export function createChannelProjection(state, deps) {
|
|
|
960
1003
|
// usage-bearing message emits nothing (nothing was measured), and a
|
|
961
1004
|
// fully successful zero-usage turn stays quiet too.
|
|
962
1005
|
const outcome = reason.kind === 'completed' ? 'completed'
|
|
963
|
-
: reason.kind === 'aborted'
|
|
964
|
-
: '
|
|
1006
|
+
: reason.kind === 'aborted' && reason.cause === 'disposed' ? 'stopped'
|
|
1007
|
+
: reason.kind === 'aborted' || reason.kind === 'interrupted' ? 'interrupted'
|
|
1008
|
+
: 'error';
|
|
965
1009
|
// The turn's terminal state is projected from the close reason itself,
|
|
966
1010
|
// NOT from the ledger below: a turn that emitted no usage-bearing message
|
|
967
1011
|
// still ended (and can have failed or been cancelled), and the ledger is
|
|
@@ -999,6 +1043,12 @@ export function createChannelProjection(state, deps) {
|
|
|
999
1043
|
emitTurnSummary();
|
|
1000
1044
|
return;
|
|
1001
1045
|
}
|
|
1046
|
+
if (reason.kind === 'aborted' && reason.cause === 'disposed') {
|
|
1047
|
+
appendRow({ id: deps.rowIds.value, kind: 'notice', text: t('session-stopped') });
|
|
1048
|
+
deps.rowIds.value += 1;
|
|
1049
|
+
emitTurnSummary();
|
|
1050
|
+
return;
|
|
1051
|
+
}
|
|
1002
1052
|
if (reason.kind === 'aborted' || reason.kind === 'interrupted') {
|
|
1003
1053
|
// A user cancel closes the turn as `aborted`; `interrupted` only
|
|
1004
1054
|
// appears for crash-orphaned turns. Both user-interruption paths
|
|
@@ -1498,10 +1548,28 @@ export function createChannelProjection(state, deps) {
|
|
|
1498
1548
|
lastTextDelta.clear();
|
|
1499
1549
|
// Rows still on screen when a replay starts keep matching by seq, so a
|
|
1500
1550
|
// replay over painted history reuses them instead of duplicating them.
|
|
1551
|
+
// Everything the replay leaves behind is settled history, so the reused
|
|
1552
|
+
// rows drop their live-only `fresh` claim too: a rebind/resume that
|
|
1553
|
+
// replays over painted rows would otherwise keep typewriting them.
|
|
1501
1554
|
assistantRowsBySeq.clear();
|
|
1502
|
-
|
|
1555
|
+
let droppedFresh = false;
|
|
1556
|
+
for (const row of state.rows) {
|
|
1557
|
+
if (row.fresh === true) {
|
|
1558
|
+
delete row.fresh;
|
|
1559
|
+
// Read-view snapshots reuse untouched rows from the previous
|
|
1560
|
+
// revision, so dropping the live claim has to move this row's dirty
|
|
1561
|
+
// revision with it — otherwise a panel keeps serving `fresh: true`.
|
|
1562
|
+
markChannelReadDirty(row);
|
|
1563
|
+
droppedFresh = true;
|
|
1564
|
+
}
|
|
1503
1565
|
if (row.kind === 'assistant')
|
|
1504
1566
|
indexAssistantRow(row);
|
|
1567
|
+
}
|
|
1568
|
+
// The array itself is reused whole when its revision matches, before any
|
|
1569
|
+
// row is inspected; move it too or the rows above stay hidden behind the
|
|
1570
|
+
// previous snapshot.
|
|
1571
|
+
if (droppedFresh)
|
|
1572
|
+
markChannelReadDirty(state.rows);
|
|
1505
1573
|
replaying = true;
|
|
1506
1574
|
try {
|
|
1507
1575
|
for (const event of events)
|
|
@@ -29,6 +29,24 @@ export interface QuestionOption {
|
|
|
29
29
|
readonly label: string;
|
|
30
30
|
readonly description?: string;
|
|
31
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Presentation intent a panel may branch on. `plan-review` opens the decision
|
|
34
|
+
* card; `approval` is the blocking permission decision the upstream ask-user
|
|
35
|
+
* protocol gained in 0.2.2 (its option labels are caller-named, so the
|
|
36
|
+
* ordinary question layout renders it).
|
|
37
|
+
*/
|
|
38
|
+
export type QuestionIntentView = (PlanReviewIntentView & {
|
|
39
|
+
readonly callId?: string;
|
|
40
|
+
}) | {
|
|
41
|
+
readonly kind: 'approval';
|
|
42
|
+
/** Option label granting the scope described by the caller. */
|
|
43
|
+
readonly approve: string;
|
|
44
|
+
/** Option label refusing the requested access. */
|
|
45
|
+
readonly reject: string;
|
|
46
|
+
/** Optional persistent grant, offered only when the caller supports it. */
|
|
47
|
+
readonly always?: string;
|
|
48
|
+
readonly callId?: string;
|
|
49
|
+
};
|
|
32
50
|
/** One question as the panel renders it. */
|
|
33
51
|
export interface QuestionItem {
|
|
34
52
|
readonly id: string;
|
|
@@ -40,9 +58,7 @@ export interface QuestionItem {
|
|
|
40
58
|
readonly options?: readonly QuestionOption[];
|
|
41
59
|
readonly multiSelect?: boolean;
|
|
42
60
|
/** Presentation intent: `plan-review` switches to the decision card. */
|
|
43
|
-
readonly intent?:
|
|
44
|
-
readonly callId?: string;
|
|
45
|
-
};
|
|
61
|
+
readonly intent?: QuestionIntentView;
|
|
46
62
|
/** Hide the trailing free-text row for pure option questions (wizards). */
|
|
47
63
|
readonly hideCustomInput?: boolean;
|
|
48
64
|
/** Pre-checked option labels / default-focused option. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"questions.d.ts","sourceRoot":"","sources":["../../../src/channel/questions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAGL,KAAK,qBAAqB,EAC3B,MAAM,8BAA8B,CAAA;AACrC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AAE9D,gCAAgC;AAChC,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAC9B;AAED,4CAA4C;AAC5C,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,0EAA0E;IAC1E,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,cAAc,EAAE,CAAA;IAC5C,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAA;IAC9B,wEAAwE;IACxE,QAAQ,CAAC,MAAM,CAAC,EAAE,
|
|
1
|
+
{"version":3,"file":"questions.d.ts","sourceRoot":"","sources":["../../../src/channel/questions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAGL,KAAK,qBAAqB,EAC3B,MAAM,8BAA8B,CAAA;AACrC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AAE9D,gCAAgC;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IlC,OAAO,CAAC,IAAI;IAIZ,sEAAsE;IACtE,OAAO,CAAC,eAAe;IAyBvB;;;;;;;;OAQG;IACH,GAAG,CAAC,OAAO,EAAE,eAAe,EACxB,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,cAAc,CAAC;IAgC5D,8CAA8C;IAC9C,OAAO,CAAC,SAAS;IAOjB;;;;;OAKG;IACH,aAAa,CAAC,SAAS,EAAE,iBAAiB,GAAG,IAAI;IAqCjD;;;;OAIG;IACH,cAAc,CAAC,KAAK,CAAC,EAAE,aAAa,GAAG,IAAI;IAW3C;;;;OAIG;IACH,WAAW,CAAC,KAAK,CAAC,EAAE,aAAa,GAAG,IAAI;IAWxC,6DAA6D;IAC7D,aAAa,IAAI,IAAI;IAUrB,+DAA+D;IAC/D,SAAS,IAAI,IAAI;IASjB,wEAAwE;IACxE,OAAO,CAAC,MAAM;IAId,sEAAsE;IACtE,OAAO,CAAC,IAAI;CAGb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../../src/channel/sanitize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAKH,4DAA4D;AAC5D,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAevE;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAEzE;AAED;mFACmF;AACnF,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IAAC,SAAS,EAAE,OAAO,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../../src/channel/sanitize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAKH,4DAA4D;AAC5D,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAevE;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAEzE;AAED;mFACmF;AACnF,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IAAC,SAAS,EAAE,OAAO,CAAA;CAAE,CA6BzF;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAGxE;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAQhE;AAED;;6CAE6C;AAC7C,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAGnD;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAKxD;AAaD;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAG7E;AAED;;qCAEqC;AACrC,eAAO,MAAM,YAAY,MAAM,CAAA"}
|
|
@@ -50,11 +50,15 @@ export function cleanCommandReport(value) {
|
|
|
50
50
|
const maxCodeUnits = 65_536;
|
|
51
51
|
const maxLines = 200;
|
|
52
52
|
const maxCells = 4000;
|
|
53
|
-
|
|
53
|
+
// A trailing line terminator (`\n`, `\r\n` or a lone `\r`) is not an empty
|
|
54
|
+
// reported row; leaving the `\r` behind would charge a cell/unit to the last
|
|
55
|
+
// line (clipping a 4000-cell line or faking a 64K truncation).
|
|
56
|
+
const raw = value.replace(/\r\n$|[\r\n]$/u, '');
|
|
57
|
+
let bounded = raw.slice(0, maxCodeUnits);
|
|
54
58
|
// Do not split a Unicode scalar at the allocation boundary.
|
|
55
|
-
if (bounded.length <
|
|
59
|
+
if (bounded.length < raw.length && /[\uD800-\uDBFF]$/u.test(bounded))
|
|
56
60
|
bounded = bounded.slice(0, -1);
|
|
57
|
-
let truncated = bounded.length <
|
|
61
|
+
let truncated = bounded.length < raw.length;
|
|
58
62
|
const rows = bounded.split(/\r?\n/u);
|
|
59
63
|
if (rows.length > maxLines)
|
|
60
64
|
truncated = true;
|
|
@@ -74,7 +78,7 @@ export function cleanCommandReport(value) {
|
|
|
74
78
|
}
|
|
75
79
|
return `${clipped}…`;
|
|
76
80
|
});
|
|
77
|
-
return { lines:
|
|
81
|
+
return { lines: raw === '' ? [] : lines, truncated };
|
|
78
82
|
}
|
|
79
83
|
/**
|
|
80
84
|
* Sanitize an untrusted (possibly non-string) value. Non-scalars — objects,
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Channel-level failure counts for delegation children.
|
|
3
|
+
*
|
|
4
|
+
* A failed child's own error text stays where the backend put it; this module
|
|
5
|
+
* only counts how many runs a provider answered and how many of those failed,
|
|
6
|
+
* so one broken channel cannot read as "every subagent is broken". It never
|
|
7
|
+
* invents a diagnosis: the per-item `product/stage/category` sentence a
|
|
8
|
+
* product provider emits reaches the transcript as a tool result, not as
|
|
9
|
+
* `SubagentState.error`, so parsing it here would be parsing a field that
|
|
10
|
+
* never carries it.
|
|
11
|
+
*/
|
|
12
|
+
import type { SubagentStatus } from '../adapter/ports/channel-view.js';
|
|
13
|
+
export interface ChannelFailureSummary {
|
|
14
|
+
readonly provider: string;
|
|
15
|
+
readonly failed: number;
|
|
16
|
+
/** Runs the provider answered for: `failed + completed`. A user-cancelled
|
|
17
|
+
* child did not get an answer, so cancelling must not dilute the rate that
|
|
18
|
+
* decides a banner. */
|
|
19
|
+
readonly settled: number;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Children the provider answered for, grouped by that provider. `provider` is
|
|
23
|
+
* absent on rows discovered from a durable catalog without a provider name;
|
|
24
|
+
* `''` reaches here from a host registry that reported an empty name. Both are
|
|
25
|
+
* skipped rather than bucketed under a guess.
|
|
26
|
+
*
|
|
27
|
+
* This is a plain count — callers decide what is worth surfacing. Rows that
|
|
28
|
+
* carry `settledRuns` are counted from that history: a continuable child
|
|
29
|
+
* reuses one `agentId` and resets to `running` when it opens the next run, so
|
|
30
|
+
* the live row alone would report at most one failure no matter how often the
|
|
31
|
+
* same child failed. The live row is only the fallback for callers that have
|
|
32
|
+
* no history (older projections, focused tests).
|
|
33
|
+
*/
|
|
34
|
+
export declare function summarizeChannelFailures(rows: readonly {
|
|
35
|
+
readonly provider?: string | undefined;
|
|
36
|
+
readonly status: SubagentStatus;
|
|
37
|
+
readonly settledRuns?: readonly {
|
|
38
|
+
readonly provider?: string | undefined;
|
|
39
|
+
readonly status: SubagentStatus;
|
|
40
|
+
}[];
|
|
41
|
+
}[]): ChannelFailureSummary[];
|
|
42
|
+
/**
|
|
43
|
+
* Whether a summary is worth a banner: a switchable product route, at least
|
|
44
|
+
* two failures, and failures at least half of the runs that got an answer.
|
|
45
|
+
* One failed child is business as usual; a channel failing most of what it
|
|
46
|
+
* runs is not.
|
|
47
|
+
*/
|
|
48
|
+
export declare function isDegradedChannel(summary: ChannelFailureSummary): boolean;
|
|
49
|
+
//# sourceMappingURL=subagent-failure.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subagent-failure.d.ts","sourceRoot":"","sources":["../../../src/channel/subagent-failure.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAA;AAEtE,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB;;4BAEwB;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CACzB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,SAAS;IACb,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACtC,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAA;IAC/B,QAAQ,CAAC,WAAW,CAAC,EAAE,SAAS;QAAE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAAC,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAA;KAAE,EAAE,CAAA;CAC9G,EAAE,GACF,qBAAqB,EAAE,CAiBzB;AAiBD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAGzE"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Children the provider answered for, grouped by that provider. `provider` is
|
|
3
|
+
* absent on rows discovered from a durable catalog without a provider name;
|
|
4
|
+
* `''` reaches here from a host registry that reported an empty name. Both are
|
|
5
|
+
* skipped rather than bucketed under a guess.
|
|
6
|
+
*
|
|
7
|
+
* This is a plain count — callers decide what is worth surfacing. Rows that
|
|
8
|
+
* carry `settledRuns` are counted from that history: a continuable child
|
|
9
|
+
* reuses one `agentId` and resets to `running` when it opens the next run, so
|
|
10
|
+
* the live row alone would report at most one failure no matter how often the
|
|
11
|
+
* same child failed. The live row is only the fallback for callers that have
|
|
12
|
+
* no history (older projections, focused tests).
|
|
13
|
+
*/
|
|
14
|
+
export function summarizeChannelFailures(rows) {
|
|
15
|
+
const buckets = new Map();
|
|
16
|
+
for (const row of rows) {
|
|
17
|
+
const runs = row.settledRuns !== undefined && row.settledRuns.length > 0 ? row.settledRuns : [row];
|
|
18
|
+
for (const run of runs) {
|
|
19
|
+
const provider = run.provider === undefined || run.provider === '' ? row.provider : run.provider;
|
|
20
|
+
if (provider === undefined || provider === '')
|
|
21
|
+
continue;
|
|
22
|
+
if (run.status !== 'failed' && run.status !== 'completed')
|
|
23
|
+
continue;
|
|
24
|
+
const bucket = buckets.get(provider) ?? { failed: 0, settled: 0 };
|
|
25
|
+
bucket.settled += 1;
|
|
26
|
+
if (run.status === 'failed')
|
|
27
|
+
bucket.failed += 1;
|
|
28
|
+
buckets.set(provider, bucket);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return Array.from(buckets, ([provider, bucket]) => ({ provider, ...bucket }))
|
|
32
|
+
.filter(summary => summary.failed > 0)
|
|
33
|
+
.sort((left, right) => right.failed - left.failed || left.provider.localeCompare(right.provider));
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Product delegation routes whose provider a user can actually swap: the
|
|
37
|
+
* `provider:` values of the shipped `tool-subagent-*` preset rows for the
|
|
38
|
+
* Claude Code and Codex products.
|
|
39
|
+
*
|
|
40
|
+
* Everything else is excluded on purpose. The built-in `subagent` default, the
|
|
41
|
+
* workflow member lane (`subagent-projection.ts` writes `provider:
|
|
42
|
+
* 'workflow'`), and the Claude backend's per-child `subagent_type` (`Explore`,
|
|
43
|
+
* `general-purpose`, …) are not switchable routes, so a banner offering
|
|
44
|
+
* "switch provider" would be advice nobody can act on. This is a positive
|
|
45
|
+
* list, not an exclusion list: a new backend inventing a provider name must
|
|
46
|
+
* opt in rather than start bannering by default.
|
|
47
|
+
*/
|
|
48
|
+
const SWITCHABLE_PRODUCT_PROVIDERS = new Set(['claude-code', 'codex']);
|
|
49
|
+
/**
|
|
50
|
+
* Whether a summary is worth a banner: a switchable product route, at least
|
|
51
|
+
* two failures, and failures at least half of the runs that got an answer.
|
|
52
|
+
* One failed child is business as usual; a channel failing most of what it
|
|
53
|
+
* runs is not.
|
|
54
|
+
*/
|
|
55
|
+
export function isDegradedChannel(summary) {
|
|
56
|
+
if (!SWITCHABLE_PRODUCT_PROVIDERS.has(summary.provider))
|
|
57
|
+
return false;
|
|
58
|
+
return summary.failed >= 2 && summary.failed * 2 >= summary.settled;
|
|
59
|
+
}
|
|
@@ -14,4 +14,21 @@ export declare const LOCAL_OUTPUT_LIMIT = 240;
|
|
|
14
14
|
*/
|
|
15
15
|
export declare const MAX_ROWS = 600;
|
|
16
16
|
export declare function preview(text: string, limit: number): string;
|
|
17
|
+
/**
|
|
18
|
+
* One report line that keeps its shape: blank rows stay blank and leading
|
|
19
|
+
* indentation survives; a stray newline still cannot become a second row.
|
|
20
|
+
*/
|
|
21
|
+
export declare function previewIndented(text: string, limit: number): string;
|
|
22
|
+
/**
|
|
23
|
+
* Keep local rows inside the transcript budget: drop the oldest `local` block
|
|
24
|
+
* (its title plus its `local-output` lines) until the incoming report fits.
|
|
25
|
+
* A run of headerless `local-output` rows (a `!!` replay with no `local`
|
|
26
|
+
* companion) counts as one block — nothing marks a boundary inside it.
|
|
27
|
+
* Local rows cannot be restored from backend history, so nothing else bounds
|
|
28
|
+
* them — `foldRows` deliberately leaves them alone. Shared by `pushLocal`
|
|
29
|
+
* (channel-side reports) and the projector (backend command reports).
|
|
30
|
+
*/
|
|
31
|
+
export declare function trimLocalRows(rows: {
|
|
32
|
+
kind: string;
|
|
33
|
+
}[], nextLines: number): void;
|
|
17
34
|
//# sourceMappingURL=transcript.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transcript.d.ts","sourceRoot":"","sources":["../../../src/channel/transcript.ts"],"names":[],"mappings":"AAAA;gDACgD;AAEhD,eAAO,MAAM,kBAAkB,MAAM,CAAA;AAErC,eAAO,MAAM,oBAAoB,MAAM,CAAA;AAEvC,uEAAuE;AACvE,eAAO,MAAM,kBAAkB,MAAM,CAAA;AAErC;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ,MAAM,CAAA;AAE3B,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAG3D"}
|
|
1
|
+
{"version":3,"file":"transcript.d.ts","sourceRoot":"","sources":["../../../src/channel/transcript.ts"],"names":[],"mappings":"AAAA;gDACgD;AAEhD,eAAO,MAAM,kBAAkB,MAAM,CAAA;AAErC,eAAO,MAAM,oBAAoB,MAAM,CAAA;AAEvC,uEAAuE;AACvE,eAAO,MAAM,kBAAkB,MAAM,CAAA;AAErC;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ,MAAM,CAAA;AAE3B,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAG3D;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAMnE;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,EAAE,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAS/E"}
|
|
@@ -17,3 +17,38 @@ export function preview(text, limit) {
|
|
|
17
17
|
const flat = text.replace(/\s+/g, ' ').trim();
|
|
18
18
|
return flat.length <= limit ? flat : `${flat.slice(0, limit)}…`;
|
|
19
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* One report line that keeps its shape: blank rows stay blank and leading
|
|
22
|
+
* indentation survives; a stray newline still cannot become a second row.
|
|
23
|
+
*/
|
|
24
|
+
export function previewIndented(text, limit) {
|
|
25
|
+
const line = text.replace(/[\r\n]+/gu, ' ').replace(/\s+$/u, '');
|
|
26
|
+
// A truly empty Text node measures as zero height; one no-break space keeps
|
|
27
|
+
// the blank row the report asked for without painting anything.
|
|
28
|
+
if (line === '')
|
|
29
|
+
return '\u00a0';
|
|
30
|
+
return line.length <= limit ? line : `${line.slice(0, limit)}…`;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Keep local rows inside the transcript budget: drop the oldest `local` block
|
|
34
|
+
* (its title plus its `local-output` lines) until the incoming report fits.
|
|
35
|
+
* A run of headerless `local-output` rows (a `!!` replay with no `local`
|
|
36
|
+
* companion) counts as one block — nothing marks a boundary inside it.
|
|
37
|
+
* Local rows cannot be restored from backend history, so nothing else bounds
|
|
38
|
+
* them — `foldRows` deliberately leaves them alone. Shared by `pushLocal`
|
|
39
|
+
* (channel-side reports) and the projector (backend command reports).
|
|
40
|
+
*/
|
|
41
|
+
export function trimLocalRows(rows, nextLines) {
|
|
42
|
+
let count = rows.reduce((sum, row) => sum + Number(row.kind === 'local' || row.kind === 'local-output'), nextLines);
|
|
43
|
+
for (let i = 0; count > MAX_ROWS && i < rows.length;) {
|
|
44
|
+
if (rows[i].kind !== 'local' && rows[i].kind !== 'local-output') {
|
|
45
|
+
i++;
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
let end = i + 1;
|
|
49
|
+
while (rows[end]?.kind === 'local-output')
|
|
50
|
+
end++;
|
|
51
|
+
count -= end - i;
|
|
52
|
+
rows.splice(i, end - i);
|
|
53
|
+
}
|
|
54
|
+
}
|
package/lib/types/commands.js
CHANGED
|
@@ -85,7 +85,7 @@ export const LOCAL_COMMANDS = [
|
|
|
85
85
|
{ name: 'mcp', description: 'Show MCP status' },
|
|
86
86
|
{ name: 'skills', description: 'List available skills' },
|
|
87
87
|
{ name: 'plugin', description: 'Show plugin diagnostics, added plugins, and switchable experimental features' },
|
|
88
|
-
{ name: 'update', description: '
|
|
88
|
+
{ name: 'update', description: 'Align the TUI, dsh engine and global launcher, then restart' },
|
|
89
89
|
// Skills are discovered through the DSH registry and added at runtime.
|
|
90
90
|
// A local entry of the same name would win the collision filter.
|
|
91
91
|
// Misc / not applicable on this leaf
|