zcode-app-cli 3.10.1-17 → 3.10.2-19
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 +2 -1
- package/bin/zcode.js +6 -7
- package/config.example.json +4 -6
- package/package.json +3 -2
- package/vendor/extraction.json +9 -4
- package/vendor/node_modules/@zcode/tui/dist/index.js +716 -153
- package/vendor/node_modules/@zcode/tui/package.json +1 -1
- package/vendor/zcode.cjs +3 -3
- package/zcode-runtime.lock.json +3 -3
|
@@ -24,17 +24,15 @@ var config_example_default = {
|
|
|
24
24
|
"glm-5.3": { "name": "GLM-5.3" },
|
|
25
25
|
"glm-5.3-flash": {
|
|
26
26
|
"name": "GLM-5.3-Flash",
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
"limit": { "context": 1e6 },
|
|
27
|
+
"limit": {
|
|
28
|
+
"context": 1e6,
|
|
29
|
+
"output": 128e3
|
|
30
|
+
},
|
|
32
31
|
"modalities": {
|
|
33
32
|
"input": [
|
|
34
33
|
"text",
|
|
35
34
|
"image",
|
|
36
|
-
"video"
|
|
37
|
-
"pdf"
|
|
35
|
+
"video"
|
|
38
36
|
],
|
|
39
37
|
"output": ["text"]
|
|
40
38
|
}
|
|
@@ -101,6 +99,7 @@ var config_example_default = {
|
|
|
101
99
|
"locale": "auto",
|
|
102
100
|
"theme": "auto",
|
|
103
101
|
"tuiMode": "regular",
|
|
102
|
+
"copyOnSelect": true,
|
|
104
103
|
"notifications": {
|
|
105
104
|
"method": "auto",
|
|
106
105
|
"condition": "unfocused"
|
|
@@ -156990,6 +156989,75 @@ var AssistantStream = class {
|
|
|
156990
156989
|
}
|
|
156991
156990
|
};
|
|
156992
156991
|
//#endregion
|
|
156992
|
+
//#region packages/zcode-tui/src/tool-renderers/registry.ts
|
|
156993
|
+
function normalizeToolName(name) {
|
|
156994
|
+
return name.toLowerCase().replace(/[^a-z0-9]/gu, "");
|
|
156995
|
+
}
|
|
156996
|
+
const canonicalAliases = /* @__PURE__ */ new Map([
|
|
156997
|
+
["read", "Read"],
|
|
156998
|
+
["fileread", "Read"],
|
|
156999
|
+
["write", "Write"],
|
|
157000
|
+
["filewrite", "Write"],
|
|
157001
|
+
["edit", "Edit"],
|
|
157002
|
+
["fileedit", "Edit"],
|
|
157003
|
+
["applypatch", "ApplyPatch"],
|
|
157004
|
+
["patch", "ApplyPatch"],
|
|
157005
|
+
["bash", "Bash"],
|
|
157006
|
+
["shell", "Bash"],
|
|
157007
|
+
["exec", "Bash"],
|
|
157008
|
+
["glob", "Glob"],
|
|
157009
|
+
["find", "Glob"],
|
|
157010
|
+
["grep", "Grep"],
|
|
157011
|
+
["searchtext", "Grep"],
|
|
157012
|
+
["webfetch", "WebFetch"],
|
|
157013
|
+
["fetch", "WebFetch"],
|
|
157014
|
+
["websearch", "WebSearch"],
|
|
157015
|
+
["todoread", "TodoRead"],
|
|
157016
|
+
["todowrite", "TodoWrite"],
|
|
157017
|
+
["goalread", "GoalRead"],
|
|
157018
|
+
["readsessioncontext", "ReadSessionContext"],
|
|
157019
|
+
["askuserquestion", "AskUserQuestion"],
|
|
157020
|
+
["sendmessage", "SendMessage"],
|
|
157021
|
+
["taskstop", "TaskStop"],
|
|
157022
|
+
["killshell", "TaskStop"],
|
|
157023
|
+
["killbash", "TaskStop"],
|
|
157024
|
+
["taskoutput", "TaskOutput"],
|
|
157025
|
+
["agent", "Agent"],
|
|
157026
|
+
["subagent", "Agent"],
|
|
157027
|
+
["task", "Task"],
|
|
157028
|
+
["skill", "Skill"],
|
|
157029
|
+
["enterplanmode", "EnterPlanMode"],
|
|
157030
|
+
["exitplanmode", "ExitPlanMode"],
|
|
157031
|
+
["exitplanmodev2", "ExitPlanMode"]
|
|
157032
|
+
]);
|
|
157033
|
+
function isMcpToolName(name) {
|
|
157034
|
+
return /^(?:mcp__|mcp[:./])/iu.test(name.trim());
|
|
157035
|
+
}
|
|
157036
|
+
function canonicalToolName(name) {
|
|
157037
|
+
return canonicalAliases.get(normalizeToolName(name)) ?? (isMcpToolName(name) ? "MCP" : void 0);
|
|
157038
|
+
}
|
|
157039
|
+
function isKnownTool(name) {
|
|
157040
|
+
return canonicalToolName(name) !== void 0;
|
|
157041
|
+
}
|
|
157042
|
+
function isAgentDispatchTool(name) {
|
|
157043
|
+
if (!name) return false;
|
|
157044
|
+
const canonical = canonicalToolName(name);
|
|
157045
|
+
return canonical === "Agent" || canonical === "Task";
|
|
157046
|
+
}
|
|
157047
|
+
function isGroupedInformationTool(name) {
|
|
157048
|
+
const canonical = canonicalToolName(name);
|
|
157049
|
+
return canonical === "Read" || canonical === "Glob" || canonical === "Grep";
|
|
157050
|
+
}
|
|
157051
|
+
function toolGroupKind(name) {
|
|
157052
|
+
const canonical = canonicalToolName(name);
|
|
157053
|
+
if (canonical === "Read") return "read";
|
|
157054
|
+
if (canonical === "Glob" || canonical === "Grep") return "search";
|
|
157055
|
+
}
|
|
157056
|
+
function displayNameForMcp(name) {
|
|
157057
|
+
const parts = name.trim().replace(/^mcp(?:__|[:./])/iu, "").split(/__|[:./]/u).filter(Boolean);
|
|
157058
|
+
return parts.length > 0 ? `MCP · ${parts.join("/")}` : "MCP";
|
|
157059
|
+
}
|
|
157060
|
+
//#endregion
|
|
156993
157061
|
//#region packages/zcode-tui/src/background-task-events.ts
|
|
156994
157062
|
const maximumEntriesPerTask = 32;
|
|
156995
157063
|
const maximumCharactersPerTask = 64e3;
|
|
@@ -157003,7 +157071,7 @@ function taskIdFor(event) {
|
|
|
157003
157071
|
return event.taskId ?? event.agentId;
|
|
157004
157072
|
}
|
|
157005
157073
|
function terminalTaskStatus(status) {
|
|
157006
|
-
return status === "completed" || status === "failed" || status === "timed_out" || status === "cancelled" || status === "spawn_error" || status === "lost" || status === "stopped";
|
|
157074
|
+
return status === "completed" || status === "failed" || status === "timed_out" || status === "cancelled" || status === "killed" || status === "spawn_error" || status === "lost" || status === "stopped";
|
|
157007
157075
|
}
|
|
157008
157076
|
function taskFailure(status) {
|
|
157009
157077
|
return status === "failed" || status === "timed_out" || status === "spawn_error" || status === "lost";
|
|
@@ -157011,22 +157079,18 @@ function taskFailure(status) {
|
|
|
157011
157079
|
function bounded(value) {
|
|
157012
157080
|
return value.length <= maximumEntryCharacters ? value : value.slice(0, maximumEntryCharacters) + "\n[truncated]";
|
|
157013
157081
|
}
|
|
157014
|
-
function
|
|
157015
|
-
const normalized = name?.trim().toLowerCase();
|
|
157016
|
-
return normalized === "agent" || normalized === "subagent";
|
|
157017
|
-
}
|
|
157018
|
-
function record$2(value) {
|
|
157082
|
+
function record$3(value) {
|
|
157019
157083
|
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
157020
157084
|
}
|
|
157021
157085
|
function explicitlyBackgroundAgentInput(value) {
|
|
157022
|
-
return record$
|
|
157086
|
+
return record$3(value)?.run_in_background === true;
|
|
157023
157087
|
}
|
|
157024
157088
|
function asyncAgentResult(value) {
|
|
157025
|
-
const root = record$
|
|
157089
|
+
const root = record$3(value);
|
|
157026
157090
|
return [
|
|
157027
157091
|
root,
|
|
157028
|
-
record$
|
|
157029
|
-
record$
|
|
157092
|
+
record$3(root?.output),
|
|
157093
|
+
record$3(root?.result)
|
|
157030
157094
|
].some((candidate) => candidate?.isAsync === true || candidate?.status === "async_launched" || candidate?.status === "backgrounded" || typeof candidate?.backgroundTaskId === "string");
|
|
157031
157095
|
}
|
|
157032
157096
|
function toolScope(event) {
|
|
@@ -157153,7 +157217,7 @@ var BackgroundTaskEventStore = class {
|
|
|
157153
157217
|
isBackgroundToolScoped(event) {
|
|
157154
157218
|
const scope = toolScope(event);
|
|
157155
157219
|
const part = event.part?.type === "tool" ? event.part : void 0;
|
|
157156
|
-
return Boolean(
|
|
157220
|
+
return Boolean(isAgentDispatchTool(scope.name) && (explicitlyBackgroundAgentInput(event.input ?? part?.input) || asyncAgentResult(event.result ?? part?.output))) || Boolean(scope.id && this.scopedTool(scope.id)) || Boolean(scope.parentId && this.scopedTool(scope.parentId));
|
|
157157
157221
|
}
|
|
157158
157222
|
recordUserMessage(taskId, message) {
|
|
157159
157223
|
this.record(taskId, "user", message);
|
|
@@ -157215,10 +157279,10 @@ var BackgroundTaskEventStore = class {
|
|
|
157215
157279
|
const scope = toolScope(event);
|
|
157216
157280
|
if (scope.id && scope.parentId) this.rememberToolParent(scope.id, scope.parentId);
|
|
157217
157281
|
const part = event.part?.type === "tool" ? event.part : void 0;
|
|
157218
|
-
const backgroundLifecycleParent = (event.type === "background_task_started" || event.type === "background_task_updated") && (event.taskKind === "local_agent" || event.toolName
|
|
157282
|
+
const backgroundLifecycleParent = (event.type === "background_task_started" || event.type === "background_task_updated") && (event.taskKind === "local_agent" || isAgentDispatchTool(event.toolName)) ? event.progress?.parentToolCallId : void 0;
|
|
157219
157283
|
if (backgroundLifecycleParent) this.rememberScopedToolCall(backgroundLifecycleParent);
|
|
157220
157284
|
if (!scope.id) return;
|
|
157221
|
-
if (
|
|
157285
|
+
if (isAgentDispatchTool(scope.name) && (explicitlyBackgroundAgentInput(event.input ?? part?.input) || asyncAgentResult(event.result ?? part?.output)) || Boolean(scope.parentId && this.scopedTool(scope.parentId))) this.rememberScopedToolCall(scope.id);
|
|
157222
157286
|
}
|
|
157223
157287
|
scopedTool(toolCallId) {
|
|
157224
157288
|
let current = toolCallId;
|
|
@@ -157453,6 +157517,68 @@ function isWindowedComponent(component) {
|
|
|
157453
157517
|
//#endregion
|
|
157454
157518
|
//#region packages/zcode-tui/src/choice-dialog.ts
|
|
157455
157519
|
const fullscreenDialogContentMaxWidth = 100;
|
|
157520
|
+
/** Leading numeric parameter of a Kitty CSI-u sequence: the base key code. */
|
|
157521
|
+
const kittyCsiUBaseCodepointPattern = /^\x1b\[(\d+)(?=[:;u])/u;
|
|
157522
|
+
const controlCharacterPattern$1 = /[\u0000-\u001f\u007f-\u009f]/u;
|
|
157523
|
+
/**
|
|
157524
|
+
* Codepoint ranges inside the Unicode private use area that terminals reserve
|
|
157525
|
+
* for keys rather than glyphs:
|
|
157526
|
+
*
|
|
157527
|
+
* - Kitty's keyboard protocol encodes functional keys (F1-F35, PrintScreen,
|
|
157528
|
+
* CapsLock, media keys, IME process keys, modifiers, …) in 57344-57454.
|
|
157529
|
+
* - macOS/AppKit reports its own function keys as 0xF700-0xF8FF (NSUpArrow
|
|
157530
|
+
* FunctionKey … NSModeSwitchFunctionKey), which some terminals pass through
|
|
157531
|
+
* raw.
|
|
157532
|
+
*
|
|
157533
|
+
* Everything else in the private use area is a real glyph — Nerd Font icons
|
|
157534
|
+
* live just above Kitty's block (Powerline starts at 0xE0A0, Seti at 0xE5FA,
|
|
157535
|
+
* Font Awesome at 0xF000) — so it must stay typeable and pasteable.
|
|
157536
|
+
*/
|
|
157537
|
+
const functionalKeyRanges = [{
|
|
157538
|
+
start: 57344,
|
|
157539
|
+
end: 57454
|
|
157540
|
+
}, {
|
|
157541
|
+
start: 63232,
|
|
157542
|
+
end: 63743
|
|
157543
|
+
}];
|
|
157544
|
+
function isFunctionalKeyCharacter(character) {
|
|
157545
|
+
const codepoint = character.codePointAt(0);
|
|
157546
|
+
if (codepoint === void 0) return false;
|
|
157547
|
+
return functionalKeyRanges.some(({ start, end }) => codepoint >= start && codepoint <= end);
|
|
157548
|
+
}
|
|
157549
|
+
function containsFunctionalKeyCharacter(value) {
|
|
157550
|
+
return [...value].some(isFunctionalKeyCharacter);
|
|
157551
|
+
}
|
|
157552
|
+
/**
|
|
157553
|
+
* True when a Kitty CSI-u sequence describes a functional key with no text
|
|
157554
|
+
* equivalent.
|
|
157555
|
+
*
|
|
157556
|
+
* Rather than duplicating pi-tui's functional-key mapping table (which would
|
|
157557
|
+
* silently drift as that table grows), this asks pi-tui to decode the *base*
|
|
157558
|
+
* key code on its own. Numpad keys and friends normalize to real text; anything
|
|
157559
|
+
* that still decodes to a reserved key codepoint has no text equivalent. Testing
|
|
157560
|
+
* the base code also ignores the shifted/alternate fields, which must never
|
|
157561
|
+
* turn a functional key into text.
|
|
157562
|
+
*/
|
|
157563
|
+
function isTextlessFunctionalKey(data) {
|
|
157564
|
+
const match = kittyCsiUBaseCodepointPattern.exec(data);
|
|
157565
|
+
if (!match) return false;
|
|
157566
|
+
const decodedBase = decodeKittyPrintable(`\x1b[${match[1]}u`);
|
|
157567
|
+
return decodedBase === void 0 || containsFunctionalKeyCharacter(decodedBase);
|
|
157568
|
+
}
|
|
157569
|
+
/**
|
|
157570
|
+
* Resolve the text a key press should append to the filter, or undefined when
|
|
157571
|
+
* the input is not text and should fall through to list navigation.
|
|
157572
|
+
*/
|
|
157573
|
+
function decodeFilterText(data) {
|
|
157574
|
+
if (data.length === 0) return void 0;
|
|
157575
|
+
if (isKeyRelease(data)) return void 0;
|
|
157576
|
+
if (isTextlessFunctionalKey(data)) return void 0;
|
|
157577
|
+
const printable = decodeKittyPrintable(data);
|
|
157578
|
+
if (printable !== void 0) return containsFunctionalKeyCharacter(printable) ? void 0 : printable;
|
|
157579
|
+
if (controlCharacterPattern$1.test(data) || containsFunctionalKeyCharacter(data)) return void 0;
|
|
157580
|
+
return data;
|
|
157581
|
+
}
|
|
157456
157582
|
var FullscreenDialogSurface = class {
|
|
157457
157583
|
dialog;
|
|
157458
157584
|
theme;
|
|
@@ -157628,9 +157754,9 @@ var ChoiceDialog = class {
|
|
|
157628
157754
|
this.updateFilter(removeLastGrapheme(this.filter));
|
|
157629
157755
|
return;
|
|
157630
157756
|
}
|
|
157631
|
-
const
|
|
157632
|
-
if (
|
|
157633
|
-
this.updateFilter(this.filter +
|
|
157757
|
+
const text = decodeFilterText(data);
|
|
157758
|
+
if (text !== void 0) {
|
|
157759
|
+
this.updateFilter(this.filter + text);
|
|
157634
157760
|
return;
|
|
157635
157761
|
}
|
|
157636
157762
|
this.list.handleInput(data);
|
|
@@ -159781,6 +159907,7 @@ const palettes = {
|
|
|
159781
159907
|
quote: "38;5;109",
|
|
159782
159908
|
toolPendingSurface: "38;5;252;48;5;236",
|
|
159783
159909
|
toolErrorSurface: "38;5;252;48;5;52",
|
|
159910
|
+
scrollbarThumb: "48;5;238",
|
|
159784
159911
|
diffAddedLine: "38;5;120;48;5;22",
|
|
159785
159912
|
diffRemovedLine: "38;5;210;48;5;52",
|
|
159786
159913
|
diffHunkLine: "38;5;159;48;5;24",
|
|
@@ -159798,6 +159925,7 @@ const palettes = {
|
|
|
159798
159925
|
quote: "38;5;24",
|
|
159799
159926
|
toolPendingSurface: "38;5;58;48;5;230",
|
|
159800
159927
|
toolErrorSurface: "38;5;236;48;5;224",
|
|
159928
|
+
scrollbarThumb: "48;5;252",
|
|
159801
159929
|
diffAddedLine: "38;5;22;48;5;194",
|
|
159802
159930
|
diffRemovedLine: "38;5;88;48;5;224",
|
|
159803
159931
|
diffHunkLine: "38;5;24;48;5;189",
|
|
@@ -159824,6 +159952,7 @@ function createTheme(enabled, initialColorScheme = "dark") {
|
|
|
159824
159952
|
const quote = paletteStyle(state, "quote", enabled);
|
|
159825
159953
|
const toolPendingBackground = paletteStyle(state, "toolPendingSurface", enabled);
|
|
159826
159954
|
const toolErrorBackground = paletteStyle(state, "toolErrorSurface", enabled);
|
|
159955
|
+
const scrollbarThumb = paletteStyle(state, "scrollbarThumb", enabled);
|
|
159827
159956
|
const diffAddedLine = paletteStyle(state, "diffAddedLine", enabled);
|
|
159828
159957
|
const diffRemovedLine = paletteStyle(state, "diffRemovedLine", enabled);
|
|
159829
159958
|
const diffHunkLine = paletteStyle(state, "diffHunkLine", enabled);
|
|
@@ -159852,6 +159981,7 @@ function createTheme(enabled, initialColorScheme = "dark") {
|
|
|
159852
159981
|
bold,
|
|
159853
159982
|
toolPendingBackground,
|
|
159854
159983
|
toolErrorBackground,
|
|
159984
|
+
scrollbarThumb,
|
|
159855
159985
|
diffAddedLine,
|
|
159856
159986
|
diffRemovedLine,
|
|
159857
159987
|
diffHunkLine,
|
|
@@ -160604,69 +160734,6 @@ function planText$1(input) {
|
|
|
160604
160734
|
}
|
|
160605
160735
|
}
|
|
160606
160736
|
//#endregion
|
|
160607
|
-
//#region packages/zcode-tui/src/tool-renderers/registry.ts
|
|
160608
|
-
function normalizeToolName(name) {
|
|
160609
|
-
return name.toLowerCase().replace(/[^a-z0-9]/gu, "");
|
|
160610
|
-
}
|
|
160611
|
-
const canonicalAliases = /* @__PURE__ */ new Map([
|
|
160612
|
-
["read", "Read"],
|
|
160613
|
-
["fileread", "Read"],
|
|
160614
|
-
["write", "Write"],
|
|
160615
|
-
["filewrite", "Write"],
|
|
160616
|
-
["edit", "Edit"],
|
|
160617
|
-
["fileedit", "Edit"],
|
|
160618
|
-
["applypatch", "ApplyPatch"],
|
|
160619
|
-
["patch", "ApplyPatch"],
|
|
160620
|
-
["bash", "Bash"],
|
|
160621
|
-
["shell", "Bash"],
|
|
160622
|
-
["exec", "Bash"],
|
|
160623
|
-
["glob", "Glob"],
|
|
160624
|
-
["find", "Glob"],
|
|
160625
|
-
["grep", "Grep"],
|
|
160626
|
-
["searchtext", "Grep"],
|
|
160627
|
-
["webfetch", "WebFetch"],
|
|
160628
|
-
["fetch", "WebFetch"],
|
|
160629
|
-
["websearch", "WebSearch"],
|
|
160630
|
-
["todoread", "TodoRead"],
|
|
160631
|
-
["todowrite", "TodoWrite"],
|
|
160632
|
-
["goalread", "GoalRead"],
|
|
160633
|
-
["readsessioncontext", "ReadSessionContext"],
|
|
160634
|
-
["askuserquestion", "AskUserQuestion"],
|
|
160635
|
-
["sendmessage", "SendMessage"],
|
|
160636
|
-
["taskstop", "TaskStop"],
|
|
160637
|
-
["killshell", "TaskStop"],
|
|
160638
|
-
["killbash", "TaskStop"],
|
|
160639
|
-
["agent", "Agent"],
|
|
160640
|
-
["subagent", "Agent"],
|
|
160641
|
-
["task", "Task"],
|
|
160642
|
-
["skill", "Skill"],
|
|
160643
|
-
["enterplanmode", "EnterPlanMode"],
|
|
160644
|
-
["exitplanmode", "ExitPlanMode"],
|
|
160645
|
-
["exitplanmodev2", "ExitPlanMode"]
|
|
160646
|
-
]);
|
|
160647
|
-
function isMcpToolName(name) {
|
|
160648
|
-
return /^(?:mcp__|mcp[:./])/iu.test(name.trim());
|
|
160649
|
-
}
|
|
160650
|
-
function canonicalToolName(name) {
|
|
160651
|
-
return canonicalAliases.get(normalizeToolName(name)) ?? (isMcpToolName(name) ? "MCP" : void 0);
|
|
160652
|
-
}
|
|
160653
|
-
function isKnownTool(name) {
|
|
160654
|
-
return canonicalToolName(name) !== void 0;
|
|
160655
|
-
}
|
|
160656
|
-
function isGroupedInformationTool(name) {
|
|
160657
|
-
const canonical = canonicalToolName(name);
|
|
160658
|
-
return canonical === "Read" || canonical === "Glob" || canonical === "Grep";
|
|
160659
|
-
}
|
|
160660
|
-
function toolGroupKind(name) {
|
|
160661
|
-
const canonical = canonicalToolName(name);
|
|
160662
|
-
if (canonical === "Read") return "read";
|
|
160663
|
-
if (canonical === "Glob" || canonical === "Grep") return "search";
|
|
160664
|
-
}
|
|
160665
|
-
function displayNameForMcp(name) {
|
|
160666
|
-
const parts = name.trim().replace(/^mcp(?:__|[:./])/iu, "").split(/__|[:./]/u).filter(Boolean);
|
|
160667
|
-
return parts.length > 0 ? `MCP · ${parts.join("/")}` : "MCP";
|
|
160668
|
-
}
|
|
160669
|
-
//#endregion
|
|
160670
160737
|
//#region packages/zcode-tui/src/tool-renderers/helpers.ts
|
|
160671
160738
|
function recordString(record, keys) {
|
|
160672
160739
|
if (!record) return void 0;
|
|
@@ -160811,6 +160878,10 @@ function toolSummary(name, input) {
|
|
|
160811
160878
|
]);
|
|
160812
160879
|
return task ? `task ${task}` : void 0;
|
|
160813
160880
|
}
|
|
160881
|
+
case "TaskOutput": {
|
|
160882
|
+
const task = recordString(record, ["task_id", "taskId"]);
|
|
160883
|
+
return task ? `task ${task}` : void 0;
|
|
160884
|
+
}
|
|
160814
160885
|
case "Agent":
|
|
160815
160886
|
case "Task": return recordString(record, [
|
|
160816
160887
|
"description",
|
|
@@ -161003,6 +161074,137 @@ function taskStopRender(options) {
|
|
|
161003
161074
|
consumesResult: Boolean(record)
|
|
161004
161075
|
};
|
|
161005
161076
|
}
|
|
161077
|
+
const taskOutputDisplayLimit = 2e3;
|
|
161078
|
+
const retrievalStatusLabels = {
|
|
161079
|
+
success: "retrieved",
|
|
161080
|
+
not_ready: "not ready yet",
|
|
161081
|
+
timeout: "timed out waiting"
|
|
161082
|
+
};
|
|
161083
|
+
function taskOutputDisplayFromTask(record) {
|
|
161084
|
+
const task = isRecord(record.task) ? record.task : void 0;
|
|
161085
|
+
const retrievalStatus = recordString(record, ["retrieval_status", "retrievalStatus"]);
|
|
161086
|
+
if (!task && !retrievalStatus) return void 0;
|
|
161087
|
+
return {
|
|
161088
|
+
retrievalStatus,
|
|
161089
|
+
taskStatus: recordString(task, ["status"]),
|
|
161090
|
+
source: "fallback"
|
|
161091
|
+
};
|
|
161092
|
+
}
|
|
161093
|
+
function taskOutputDisplayFromString(value) {
|
|
161094
|
+
const trimmed = value.trim();
|
|
161095
|
+
if (trimmed.startsWith("{")) try {
|
|
161096
|
+
const parsed = JSON.parse(trimmed);
|
|
161097
|
+
const fromJson = isRecord(parsed) ? taskOutputDisplayFromTask(parsed) : void 0;
|
|
161098
|
+
if (fromJson) return fromJson;
|
|
161099
|
+
} catch {}
|
|
161100
|
+
if (value.includes("<retrieval_status>")) {
|
|
161101
|
+
const status = /<retrieval_status>([^<]+)<\/retrieval_status>/u.exec(value)?.[1];
|
|
161102
|
+
const taskStatus = /<status>([^<]+)<\/status>/u.exec(value)?.[1];
|
|
161103
|
+
if (status || taskStatus) return {
|
|
161104
|
+
retrievalStatus: status ? sanitizeTerminalText(status.trim(), { preserveSgr: false }) : void 0,
|
|
161105
|
+
taskStatus: taskStatus ? sanitizeTerminalText(taskStatus.trim(), { preserveSgr: false }) : void 0,
|
|
161106
|
+
source: "fallback"
|
|
161107
|
+
};
|
|
161108
|
+
}
|
|
161109
|
+
}
|
|
161110
|
+
function compactTaskOutput(value) {
|
|
161111
|
+
const raw = directText(value)?.trimEnd();
|
|
161112
|
+
if (!raw) return { truncated: false };
|
|
161113
|
+
const output = truncateGraphemes(raw, taskOutputDisplayLimit, "");
|
|
161114
|
+
return {
|
|
161115
|
+
output,
|
|
161116
|
+
truncated: output !== raw
|
|
161117
|
+
};
|
|
161118
|
+
}
|
|
161119
|
+
function taskOutputFailureMessage(result, depth = 0) {
|
|
161120
|
+
if (depth > 3) return void 0;
|
|
161121
|
+
if (typeof result === "string") {
|
|
161122
|
+
const trimmed = result.trim();
|
|
161123
|
+
if (!trimmed.startsWith("{")) return void 0;
|
|
161124
|
+
try {
|
|
161125
|
+
return taskOutputFailureMessage(JSON.parse(trimmed), depth + 1);
|
|
161126
|
+
} catch {
|
|
161127
|
+
return;
|
|
161128
|
+
}
|
|
161129
|
+
}
|
|
161130
|
+
if (!isRecord(result)) return void 0;
|
|
161131
|
+
if (result.success === false || result.result === false) {
|
|
161132
|
+
const message = recordString(result, ["message", "error"]);
|
|
161133
|
+
if (message) return oneLine$2(message, 240);
|
|
161134
|
+
}
|
|
161135
|
+
for (const candidate of [
|
|
161136
|
+
result.output,
|
|
161137
|
+
result.content,
|
|
161138
|
+
result.result
|
|
161139
|
+
]) {
|
|
161140
|
+
if (candidate === result || typeof candidate === "boolean") continue;
|
|
161141
|
+
const nested = taskOutputFailureMessage(candidate, depth + 1);
|
|
161142
|
+
if (nested) return nested;
|
|
161143
|
+
}
|
|
161144
|
+
}
|
|
161145
|
+
/**
|
|
161146
|
+
* Prefer the runtime's compact `display` metadata; fall back to the raw
|
|
161147
|
+
* `{retrieval_status, task}` result or the persisted model-content string.
|
|
161148
|
+
* Restored parts arrive as `{output, display}` and live results as
|
|
161149
|
+
* `{success, content, display}` — in both the raw field can embed a full
|
|
161150
|
+
* subagent transcript, so it must never be rendered directly. When a restored
|
|
161151
|
+
* part carries no display metadata at all, `upsertProtocolPart` passes the
|
|
161152
|
+
* persisted `state.output` string through as the whole result.
|
|
161153
|
+
*/
|
|
161154
|
+
function taskOutputDisplay(result) {
|
|
161155
|
+
if (typeof result === "string") return taskOutputDisplayFromString(result);
|
|
161156
|
+
const record = isRecord(result) ? result : void 0;
|
|
161157
|
+
if (!record) return void 0;
|
|
161158
|
+
const display = isRecord(record.display) ? record.display : isRecord(record.resultDisplay) ? record.resultDisplay : void 0;
|
|
161159
|
+
if (display && (recordString(display, ["kind"]) === "task_output" || recordString(display, ["retrievalStatus", "retrieval_status"]))) {
|
|
161160
|
+
const compact = compactTaskOutput(display.output);
|
|
161161
|
+
return {
|
|
161162
|
+
retrievalStatus: recordString(display, ["retrievalStatus", "retrieval_status"]),
|
|
161163
|
+
taskStatus: recordString(display, [
|
|
161164
|
+
"taskStatus",
|
|
161165
|
+
"task_status",
|
|
161166
|
+
"status"
|
|
161167
|
+
]),
|
|
161168
|
+
output: compact.output,
|
|
161169
|
+
truncated: booleanField(display, ["truncated"]) === true || compact.truncated,
|
|
161170
|
+
source: "display"
|
|
161171
|
+
};
|
|
161172
|
+
}
|
|
161173
|
+
const nested = taskOutputDisplayFromTask(record);
|
|
161174
|
+
if (nested) return nested;
|
|
161175
|
+
for (const candidate of [record.output, record.content]) {
|
|
161176
|
+
if (typeof candidate !== "string") continue;
|
|
161177
|
+
const fallback = taskOutputDisplayFromString(candidate);
|
|
161178
|
+
if (fallback) return fallback;
|
|
161179
|
+
}
|
|
161180
|
+
}
|
|
161181
|
+
function taskOutputRender(options) {
|
|
161182
|
+
const taskId = recordString(isRecord(options.input) ? options.input : void 0, [
|
|
161183
|
+
"task_id",
|
|
161184
|
+
"taskId",
|
|
161185
|
+
"taskID"
|
|
161186
|
+
]);
|
|
161187
|
+
const display = taskOutputDisplay(options.result);
|
|
161188
|
+
const body = [];
|
|
161189
|
+
const status = display ? compactStatusLine([
|
|
161190
|
+
display.retrievalStatus ? retrievalStatusLabels[display.retrievalStatus] ?? display.retrievalStatus.replaceAll("_", " ") : void 0,
|
|
161191
|
+
display.taskStatus && display.taskStatus !== display.retrievalStatus ? display.taskStatus.replaceAll("_", " ") : void 0,
|
|
161192
|
+
display.truncated ? "output truncated" : void 0
|
|
161193
|
+
], options.theme) : void 0;
|
|
161194
|
+
if (status) body.push(status);
|
|
161195
|
+
if (display?.source === "display" && display.output?.trim()) body.push(display.output.trimEnd());
|
|
161196
|
+
else if (display?.retrievalStatus === "not_ready" || display?.retrievalStatus === "timeout") body.push(options.theme.muted("No output yet — check again with TaskOutput or /tasks."));
|
|
161197
|
+
else {
|
|
161198
|
+
const failureMessage = taskOutputFailureMessage(options.result);
|
|
161199
|
+
body.push(failureMessage ?? options.theme.muted("Task output is available in /tasks."));
|
|
161200
|
+
}
|
|
161201
|
+
return {
|
|
161202
|
+
displayName: "TaskOutput",
|
|
161203
|
+
summary: taskId ? `task ${taskId}` : toolSummary(options.name, options.input),
|
|
161204
|
+
body: body.join("\n") || void 0,
|
|
161205
|
+
consumesResult: true
|
|
161206
|
+
};
|
|
161207
|
+
}
|
|
161006
161208
|
//#endregion
|
|
161007
161209
|
//#region packages/zcode-tui/src/tool-renderers/workflow.ts
|
|
161008
161210
|
function todoItems(value) {
|
|
@@ -161303,6 +161505,7 @@ const rendererRegistry = {
|
|
|
161303
161505
|
AskUserQuestion: questionRender,
|
|
161304
161506
|
SendMessage: sendMessageRender,
|
|
161305
161507
|
TaskStop: taskStopRender,
|
|
161508
|
+
TaskOutput: taskOutputRender,
|
|
161306
161509
|
Agent: agentRender,
|
|
161307
161510
|
Task: agentRender,
|
|
161308
161511
|
Skill: skillRender,
|
|
@@ -161805,11 +162008,11 @@ function findExecutable(name, env = process.env, platform = process.platform) {
|
|
|
161805
162008
|
}
|
|
161806
162009
|
return null;
|
|
161807
162010
|
}
|
|
161808
|
-
function record$
|
|
162011
|
+
function record$2(value) {
|
|
161809
162012
|
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
161810
162013
|
}
|
|
161811
162014
|
function configuredNotifications(config) {
|
|
161812
|
-
return record$
|
|
162015
|
+
return record$2(record$2(record$2(config)?.ui)?.notifications);
|
|
161813
162016
|
}
|
|
161814
162017
|
function notificationSettings(env = process.env, config) {
|
|
161815
162018
|
const configured = configuredNotifications(config);
|
|
@@ -161828,7 +162031,7 @@ async function readStoredNotificationSettings(env = process.env) {
|
|
|
161828
162031
|
}
|
|
161829
162032
|
async function writeNotificationSettings(settings, env = process.env) {
|
|
161830
162033
|
return await updateUserConfig((config) => {
|
|
161831
|
-
const ui = record$
|
|
162034
|
+
const ui = record$2(config.ui) ?? {};
|
|
161832
162035
|
ui.notifications = { ...settings };
|
|
161833
162036
|
config.ui = ui;
|
|
161834
162037
|
}, env);
|
|
@@ -161960,6 +162163,7 @@ var TurnNotifier = class {
|
|
|
161960
162163
|
active = false;
|
|
161961
162164
|
focusReporting = false;
|
|
161962
162165
|
terminalFocus = "unknown";
|
|
162166
|
+
terminalUnavailable = false;
|
|
161963
162167
|
constructor(options) {
|
|
161964
162168
|
this.options = options;
|
|
161965
162169
|
this.env = options.env ?? process.env;
|
|
@@ -162023,11 +162227,24 @@ var TurnNotifier = class {
|
|
|
162023
162227
|
return false;
|
|
162024
162228
|
}
|
|
162025
162229
|
}
|
|
162230
|
+
/**
|
|
162231
|
+
* Marks the terminal as unusable after an async stream failure (EIO/EPIPE).
|
|
162232
|
+
* writeTerminal's synchronous try/catch cannot observe those; the stream
|
|
162233
|
+
* error handler calls this so later writes are dropped instead of racing
|
|
162234
|
+
* another doomed write against the dying stream.
|
|
162235
|
+
*/
|
|
162236
|
+
markTerminalUnavailable() {
|
|
162237
|
+
this.terminalUnavailable = true;
|
|
162238
|
+
this.focusReporting = false;
|
|
162239
|
+
this.terminalFocus = "unknown";
|
|
162240
|
+
}
|
|
162026
162241
|
writeTerminal(data) {
|
|
162242
|
+
if (this.terminalUnavailable) return false;
|
|
162027
162243
|
try {
|
|
162028
162244
|
this.options.writeTerminal(data);
|
|
162029
162245
|
return true;
|
|
162030
162246
|
} catch {
|
|
162247
|
+
this.terminalUnavailable = true;
|
|
162031
162248
|
return false;
|
|
162032
162249
|
}
|
|
162033
162250
|
}
|
|
@@ -162046,12 +162263,24 @@ var TurnNotifier = class {
|
|
|
162046
162263
|
}
|
|
162047
162264
|
};
|
|
162048
162265
|
//#endregion
|
|
162266
|
+
//#region packages/zcode-tui/src/stream-error-guard.ts
|
|
162267
|
+
function watchStreamErrors(sources, onError) {
|
|
162268
|
+
const uniqueSources = [...new Set(sources)];
|
|
162269
|
+
for (const source of uniqueSources) source.on("error", onError);
|
|
162270
|
+
let active = true;
|
|
162271
|
+
return () => {
|
|
162272
|
+
if (!active) return;
|
|
162273
|
+
active = false;
|
|
162274
|
+
for (const source of uniqueSources) source.off("error", onError);
|
|
162275
|
+
};
|
|
162276
|
+
}
|
|
162277
|
+
//#endregion
|
|
162049
162278
|
//#region packages/zcode-tui/src/tui-mode.ts
|
|
162050
|
-
function record(value) {
|
|
162279
|
+
function record$1(value) {
|
|
162051
162280
|
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
162052
162281
|
}
|
|
162053
162282
|
function configuredTuiMode(config) {
|
|
162054
|
-
const value = record(record(config)?.ui)?.tuiMode;
|
|
162283
|
+
const value = record$1(record$1(config)?.ui)?.tuiMode;
|
|
162055
162284
|
return typeof value === "string" ? value : void 0;
|
|
162056
162285
|
}
|
|
162057
162286
|
function tuiMode(value) {
|
|
@@ -162067,12 +162296,31 @@ async function readTuiMode(env = process.env) {
|
|
|
162067
162296
|
}
|
|
162068
162297
|
async function writeTuiMode(mode, env = process.env) {
|
|
162069
162298
|
return await updateUserConfig((config) => {
|
|
162070
|
-
const ui = record(config.ui) ?? {};
|
|
162299
|
+
const ui = record$1(config.ui) ?? {};
|
|
162071
162300
|
ui.tuiMode = mode;
|
|
162072
162301
|
config.ui = ui;
|
|
162073
162302
|
}, env);
|
|
162074
162303
|
}
|
|
162075
162304
|
//#endregion
|
|
162305
|
+
//#region packages/zcode-tui/src/copy-on-select.ts
|
|
162306
|
+
function record(value) {
|
|
162307
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
162308
|
+
}
|
|
162309
|
+
function configuredCopyOnSelect(config) {
|
|
162310
|
+
const value = record(record(config)?.ui)?.copyOnSelect;
|
|
162311
|
+
return typeof value === "boolean" ? value : void 0;
|
|
162312
|
+
}
|
|
162313
|
+
async function readCopyOnSelect(env = process.env) {
|
|
162314
|
+
return configuredCopyOnSelect(await readUserConfig(env)) ?? true;
|
|
162315
|
+
}
|
|
162316
|
+
async function writeCopyOnSelect(enabled, env = process.env) {
|
|
162317
|
+
return await updateUserConfig((config) => {
|
|
162318
|
+
const ui = record(config.ui) ?? {};
|
|
162319
|
+
ui.copyOnSelect = enabled;
|
|
162320
|
+
config.ui = ui;
|
|
162321
|
+
}, env);
|
|
162322
|
+
}
|
|
162323
|
+
//#endregion
|
|
162076
162324
|
//#region packages/zcode-tui/src/selectors.ts
|
|
162077
162325
|
function pickerRequest(input, commands) {
|
|
162078
162326
|
const match = /^\/([^\s]+)(?:\s+(.*))?$/u.exec(input.trim());
|
|
@@ -162687,6 +162935,8 @@ const backgroundStatuses = /* @__PURE__ */ new Set([
|
|
|
162687
162935
|
"failed",
|
|
162688
162936
|
"timed_out",
|
|
162689
162937
|
"cancelled",
|
|
162938
|
+
"killed",
|
|
162939
|
+
"stopped",
|
|
162690
162940
|
"spawn_error",
|
|
162691
162941
|
"lost"
|
|
162692
162942
|
]);
|
|
@@ -162895,12 +163145,18 @@ function normalizeRuntimeProjection(value) {
|
|
|
162895
163145
|
}),
|
|
162896
163146
|
backgroundJobs: records(rawBackgroundJobs).flatMap((item) => {
|
|
162897
163147
|
const taskId = stringField(item, "taskId", "taskID", "id");
|
|
162898
|
-
const
|
|
162899
|
-
|
|
162900
|
-
|
|
163148
|
+
const details = taskId ? taskDetails.get(taskId) : void 0;
|
|
163149
|
+
const definedDetails = details ? Object.fromEntries(Object.entries(details).filter(([, field]) => field !== void 0)) : void 0;
|
|
163150
|
+
const job = backgroundJobFrom(definedDetails ? {
|
|
163151
|
+
...item,
|
|
163152
|
+
...definedDetails
|
|
162901
163153
|
} : item);
|
|
162902
163154
|
return job ? [job] : [];
|
|
162903
163155
|
}),
|
|
163156
|
+
restoredBackgroundTasks: records(projection.restoredBackgroundTasks ?? value.restoredBackgroundTasks).flatMap((item) => {
|
|
163157
|
+
const job = backgroundJobFrom(item);
|
|
163158
|
+
return job ? [job] : [];
|
|
163159
|
+
}),
|
|
162904
163160
|
contextUsage: contextUsageFrom(runtime?.contextUsage ?? value.contextUsage, projection),
|
|
162905
163161
|
lastError: lastErrorType && lastErrorMessage ? {
|
|
162906
163162
|
type: lastErrorType,
|
|
@@ -163372,24 +163628,111 @@ var SystemEventView = class {
|
|
|
163372
163628
|
};
|
|
163373
163629
|
//#endregion
|
|
163374
163630
|
//#region packages/zcode-tui/src/thinking-view.ts
|
|
163631
|
+
const maxLiveThinkingLines = 24;
|
|
163632
|
+
const maxLiveThinkingCharacters = 4096;
|
|
163633
|
+
function safeCutStart(value, requested) {
|
|
163634
|
+
let start = Math.max(0, Math.min(value.length, requested));
|
|
163635
|
+
if (start > 0 && start < value.length) {
|
|
163636
|
+
const before = value.charCodeAt(start - 1);
|
|
163637
|
+
const current = value.charCodeAt(start);
|
|
163638
|
+
if (before >= 55296 && before <= 56319 && current >= 56320 && current <= 57343) start += 1;
|
|
163639
|
+
}
|
|
163640
|
+
return start;
|
|
163641
|
+
}
|
|
163642
|
+
function safeSuffixStart(value, maximumCharacters) {
|
|
163643
|
+
return safeCutStart(value, value.length - maximumCharacters);
|
|
163644
|
+
}
|
|
163645
|
+
/** Keeps the visible streaming window bounded without copying the full trace. */
|
|
163646
|
+
var ThinkingTailBuffer = class {
|
|
163647
|
+
lines = [""];
|
|
163648
|
+
length = 0;
|
|
163649
|
+
cachedValue;
|
|
163650
|
+
replace(text) {
|
|
163651
|
+
const start = safeSuffixStart(text, maxLiveThinkingCharacters);
|
|
163652
|
+
const lines = text.slice(start).split("\n");
|
|
163653
|
+
if (lines.length > maxLiveThinkingLines) lines.splice(0, lines.length - maxLiveThinkingLines);
|
|
163654
|
+
this.lines = lines;
|
|
163655
|
+
this.length = this.lines.join("\n").length;
|
|
163656
|
+
this.cachedValue = void 0;
|
|
163657
|
+
}
|
|
163658
|
+
append(delta) {
|
|
163659
|
+
if (!delta) return;
|
|
163660
|
+
if (delta.indexOf("\n") < 0) {
|
|
163661
|
+
const last = this.lines.length - 1;
|
|
163662
|
+
this.lines[last] = `${this.lines[last] ?? ""}${delta}`;
|
|
163663
|
+
this.length += delta.length;
|
|
163664
|
+
if (this.length > maxLiveThinkingCharacters) this.trim();
|
|
163665
|
+
this.cachedValue = void 0;
|
|
163666
|
+
return;
|
|
163667
|
+
}
|
|
163668
|
+
const parts = delta.split("\n");
|
|
163669
|
+
const last = this.lines.length - 1;
|
|
163670
|
+
this.lines[last] = `${this.lines[last] ?? ""}${parts[0] ?? ""}`;
|
|
163671
|
+
for (let index = 1; index < parts.length; index += 1) this.lines.push(parts[index]);
|
|
163672
|
+
this.length += delta.length;
|
|
163673
|
+
if (this.lines.length > maxLiveThinkingLines || this.length > maxLiveThinkingCharacters) this.trim();
|
|
163674
|
+
this.cachedValue = void 0;
|
|
163675
|
+
}
|
|
163676
|
+
value() {
|
|
163677
|
+
if (this.cachedValue === void 0) this.cachedValue = this.lines.join("\n");
|
|
163678
|
+
return this.cachedValue;
|
|
163679
|
+
}
|
|
163680
|
+
trim() {
|
|
163681
|
+
if (this.lines.length > maxLiveThinkingLines) {
|
|
163682
|
+
const removed = this.lines.splice(0, this.lines.length - maxLiveThinkingLines);
|
|
163683
|
+
this.length -= removed.reduce((total, line) => total + line.length + 1, 0);
|
|
163684
|
+
}
|
|
163685
|
+
while (this.length > maxLiveThinkingCharacters && this.lines.length > 0) {
|
|
163686
|
+
const first = this.lines[0];
|
|
163687
|
+
const separatorLength = this.lines.length > 1 ? 1 : 0;
|
|
163688
|
+
const removable = first.length + separatorLength;
|
|
163689
|
+
const excess = this.length - maxLiveThinkingCharacters;
|
|
163690
|
+
if (removable <= excess) {
|
|
163691
|
+
this.lines.shift();
|
|
163692
|
+
this.length -= removable;
|
|
163693
|
+
if (this.lines.length === 0) this.lines.push("");
|
|
163694
|
+
continue;
|
|
163695
|
+
}
|
|
163696
|
+
const start = safeCutStart(first, excess);
|
|
163697
|
+
this.lines[0] = first.slice(start);
|
|
163698
|
+
this.length -= start;
|
|
163699
|
+
break;
|
|
163700
|
+
}
|
|
163701
|
+
}
|
|
163702
|
+
};
|
|
163375
163703
|
var ThinkingView = class extends Box {
|
|
163376
163704
|
theme;
|
|
163377
163705
|
text = "";
|
|
163706
|
+
hasVisibleText = false;
|
|
163378
163707
|
completed = false;
|
|
163379
163708
|
expanded = false;
|
|
163380
163709
|
dirty = false;
|
|
163710
|
+
liveTail = new ThinkingTailBuffer();
|
|
163381
163711
|
constructor(theme) {
|
|
163382
163712
|
super(1, 0);
|
|
163383
163713
|
this.theme = theme;
|
|
163384
163714
|
}
|
|
163385
163715
|
append(delta) {
|
|
163386
163716
|
if (!delta) return;
|
|
163387
|
-
|
|
163717
|
+
const sanitized = sanitizeTerminalText(delta, { preserveSgr: false });
|
|
163718
|
+
if (!sanitized) return;
|
|
163719
|
+
this.completed = false;
|
|
163720
|
+
this.hasVisibleText ||= sanitized.trim().length > 0;
|
|
163721
|
+
this.text += sanitized;
|
|
163722
|
+
this.liveTail.append(sanitized);
|
|
163388
163723
|
this.dirty = true;
|
|
163389
163724
|
}
|
|
163390
163725
|
setText(text) {
|
|
163391
163726
|
const sanitized = sanitizeTerminalText(text, { preserveSgr: false });
|
|
163392
163727
|
if (this.text === sanitized) return;
|
|
163728
|
+
if (sanitized.startsWith(this.text)) {
|
|
163729
|
+
const delta = sanitized.slice(this.text.length);
|
|
163730
|
+
this.liveTail.append(delta);
|
|
163731
|
+
this.hasVisibleText ||= delta.trim().length > 0;
|
|
163732
|
+
} else {
|
|
163733
|
+
this.liveTail.replace(sanitized);
|
|
163734
|
+
this.hasVisibleText = sanitized.trim().length > 0;
|
|
163735
|
+
}
|
|
163393
163736
|
this.text = sanitized;
|
|
163394
163737
|
this.dirty = true;
|
|
163395
163738
|
}
|
|
@@ -163407,7 +163750,7 @@ var ThinkingView = class extends Box {
|
|
|
163407
163750
|
return this.expanded;
|
|
163408
163751
|
}
|
|
163409
163752
|
hasHiddenContent() {
|
|
163410
|
-
return this.completed &&
|
|
163753
|
+
return this.completed && this.hasVisibleText && !this.expanded;
|
|
163411
163754
|
}
|
|
163412
163755
|
getSearchText() {
|
|
163413
163756
|
return this.text;
|
|
@@ -163421,12 +163764,15 @@ var ThinkingView = class extends Box {
|
|
|
163421
163764
|
}
|
|
163422
163765
|
rebuild() {
|
|
163423
163766
|
this.clear();
|
|
163424
|
-
const title = this.completed ? `${this.theme.muted("◇")} ${this.theme.bold("Thought")}${this.
|
|
163767
|
+
const title = this.completed ? `${this.theme.muted("◇")} ${this.theme.bold("Thought")}${this.hasVisibleText && !this.expanded ? this.theme.muted(" · Ctrl+O to expand") : ""}` : `${this.theme.accent("◇")} ${this.theme.bold("Thinking")} ${this.theme.muted("· active")}`;
|
|
163425
163768
|
this.addChild(new Text(title, 0, 0));
|
|
163426
|
-
if (this.
|
|
163427
|
-
|
|
163428
|
-
|
|
163429
|
-
|
|
163769
|
+
if (this.hasVisibleText && (!this.completed || this.expanded)) {
|
|
163770
|
+
const body = this.completed || this.expanded ? this.text : this.liveTail.value();
|
|
163771
|
+
this.addChild(new Markdown(body, 1, 0, this.theme.markdown, {
|
|
163772
|
+
color: this.theme.muted,
|
|
163773
|
+
italic: true
|
|
163774
|
+
}));
|
|
163775
|
+
}
|
|
163430
163776
|
}
|
|
163431
163777
|
};
|
|
163432
163778
|
//#endregion
|
|
@@ -164779,6 +165125,7 @@ const terminalStatuses = /* @__PURE__ */ new Set([
|
|
|
164779
165125
|
"failed",
|
|
164780
165126
|
"timed_out",
|
|
164781
165127
|
"cancelled",
|
|
165128
|
+
"killed",
|
|
164782
165129
|
"spawn_error",
|
|
164783
165130
|
"lost",
|
|
164784
165131
|
"stopped"
|
|
@@ -165443,6 +165790,7 @@ const backgroundTaskAttentionStatuses = /* @__PURE__ */ new Set([
|
|
|
165443
165790
|
"spawn_error",
|
|
165444
165791
|
"lost"
|
|
165445
165792
|
]);
|
|
165793
|
+
const defaultBackgroundResumeMessage = "Continue the assigned task from the last completed step. Re-check the current workspace state and finish the remaining work.";
|
|
165446
165794
|
function backgroundTaskKindLabel(job) {
|
|
165447
165795
|
switch (job.taskKind) {
|
|
165448
165796
|
case "local_agent": return job.agentType ? `Agent (${job.agentType})` : "Agent";
|
|
@@ -165459,13 +165807,33 @@ function backgroundTaskSortRank(job) {
|
|
|
165459
165807
|
}
|
|
165460
165808
|
function backgroundAgentPart(part) {
|
|
165461
165809
|
if (part.type !== "tool") return false;
|
|
165462
|
-
|
|
165463
|
-
if (name !== "agent" && name !== "subagent") return false;
|
|
165810
|
+
if (!isAgentDispatchTool(part.toolName)) return false;
|
|
165464
165811
|
const input = isRecord(part.input) ? part.input : void 0;
|
|
165465
165812
|
const output = isRecord(part.output) ? part.output : void 0;
|
|
165466
165813
|
const nestedOutput = isRecord(output?.output) ? output.output : void 0;
|
|
165467
165814
|
return input?.run_in_background === true || output?.isAsync === true || output?.status === "async_launched" || output?.status === "backgrounded" || typeof output?.backgroundTaskId === "string" || nestedOutput?.isAsync === true || nestedOutput?.status === "async_launched" || nestedOutput?.status === "backgrounded" || typeof nestedOutput?.backgroundTaskId === "string";
|
|
165468
165815
|
}
|
|
165816
|
+
/**
|
|
165817
|
+
* Conversation-facing notice for a task-center action (resume / restart /
|
|
165818
|
+
* guidance). Side-channel task actions are invisible to the model otherwise —
|
|
165819
|
+
* surfacing them through the main conversation lets the coordinator wait on
|
|
165820
|
+
* the task with TaskOutput(block=true) instead of finalizing without it.
|
|
165821
|
+
*/
|
|
165822
|
+
function taskCoordinatorNotice(job, restart, message) {
|
|
165823
|
+
const label = job.description ? `${job.taskId} (${job.description})` : job.taskId;
|
|
165824
|
+
return [
|
|
165825
|
+
restart ? `Background task ${label} was restarted from the task center with the instruction:` : isActiveBackgroundJob(job) ? `Guidance was sent to background task ${label}:` : `Background task ${label} was resumed from the task center with the instruction:`,
|
|
165826
|
+
`"${message}"`,
|
|
165827
|
+
"If your current work depends on this task, call TaskOutput with block=true to wait for its result before giving your final answer; otherwise continue and its completion notification will arrive automatically."
|
|
165828
|
+
].join("\n");
|
|
165829
|
+
}
|
|
165830
|
+
function backgroundCancellationFailure(value) {
|
|
165831
|
+
if (isRecord(value) && value.cancelled === true) return void 0;
|
|
165832
|
+
if (!isRecord(value)) return "cancellation was not confirmed";
|
|
165833
|
+
const reason = asString(value.reason)?.replaceAll("_", " ");
|
|
165834
|
+
const status = asString(value.status)?.replaceAll("_", " ");
|
|
165835
|
+
return [reason, status ? `status ${status}` : void 0].filter(Boolean).join(" · ") || "cancellation was not confirmed";
|
|
165836
|
+
}
|
|
165469
165837
|
function backgroundToolPartIds(parts) {
|
|
165470
165838
|
const hidden = /* @__PURE__ */ new Set();
|
|
165471
165839
|
for (const part of parts) {
|
|
@@ -165670,6 +166038,7 @@ var ZCodeTui = class {
|
|
|
165670
166038
|
mode;
|
|
165671
166039
|
model;
|
|
165672
166040
|
tuiMode;
|
|
166041
|
+
copyOnSelect = true;
|
|
165673
166042
|
thoughtLevel;
|
|
165674
166043
|
modelOptions;
|
|
165675
166044
|
effortOptions;
|
|
@@ -165678,6 +166047,7 @@ var ZCodeTui = class {
|
|
|
165678
166047
|
unsubscribeWorkflow;
|
|
165679
166048
|
unsubscribeSession;
|
|
165680
166049
|
backgroundTaskEvents = new BackgroundTaskEventStore();
|
|
166050
|
+
restoredNoticeSeen = /* @__PURE__ */ new Set();
|
|
165681
166051
|
turnWork = new TurnWorkTracker();
|
|
165682
166052
|
backgroundCoordinatorMessageIds = /* @__PURE__ */ new Set();
|
|
165683
166053
|
workflowPanel;
|
|
@@ -165719,6 +166089,7 @@ var ZCodeTui = class {
|
|
|
165719
166089
|
backgroundHandoffInterruptInFlight = false;
|
|
165720
166090
|
updateCheckAbortController;
|
|
165721
166091
|
loginRequired;
|
|
166092
|
+
removeStreamErrorGuards;
|
|
165722
166093
|
constructor(options) {
|
|
165723
166094
|
this.options = options;
|
|
165724
166095
|
this.animateTurnTimer = turnTimerAnimationEnabled();
|
|
@@ -165791,6 +166162,9 @@ var ZCodeTui = class {
|
|
|
165791
166162
|
} catch (error) {
|
|
165792
166163
|
notificationConfigError = error instanceof Error ? error.message : String(error);
|
|
165793
166164
|
}
|
|
166165
|
+
try {
|
|
166166
|
+
this.setCopyOnSelect(await readCopyOnSelect());
|
|
166167
|
+
} catch {}
|
|
165794
166168
|
try {
|
|
165795
166169
|
const configEnv = { ...process.env };
|
|
165796
166170
|
delete configEnv.ZCODE_TUI_MODE;
|
|
@@ -165806,6 +166180,7 @@ var ZCodeTui = class {
|
|
|
165806
166180
|
const onSigint = () => this.handleSignal("SIGINT");
|
|
165807
166181
|
const onSigterm = () => this.handleSignal("SIGTERM");
|
|
165808
166182
|
const onSighup = () => this.handleSignal("SIGHUP");
|
|
166183
|
+
this.installStreamErrorGuards();
|
|
165809
166184
|
process.once("SIGINT", onSigint);
|
|
165810
166185
|
process.once("SIGTERM", onSigterm);
|
|
165811
166186
|
if (process.platform !== "win32") process.once("SIGHUP", onSighup);
|
|
@@ -165852,9 +166227,15 @@ var ZCodeTui = class {
|
|
|
165852
166227
|
process.off("SIGINT", onSigint);
|
|
165853
166228
|
process.off("SIGTERM", onSigterm);
|
|
165854
166229
|
if (process.platform !== "win32") process.off("SIGHUP", onSighup);
|
|
165855
|
-
|
|
165856
|
-
this.
|
|
165857
|
-
|
|
166230
|
+
try {
|
|
166231
|
+
if (startAttempted && !this.stopped) {
|
|
166232
|
+
this.stop();
|
|
166233
|
+
await this.done;
|
|
166234
|
+
}
|
|
166235
|
+
} finally {
|
|
166236
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
166237
|
+
this.removeStreamErrorGuards?.();
|
|
166238
|
+
this.removeStreamErrorGuards = void 0;
|
|
165858
166239
|
}
|
|
165859
166240
|
}
|
|
165860
166241
|
}
|
|
@@ -165862,6 +166243,25 @@ var ZCodeTui = class {
|
|
|
165862
166243
|
process.exitCode = signalExitCode(signal);
|
|
165863
166244
|
if (!this.stopped) this.stop();
|
|
165864
166245
|
}
|
|
166246
|
+
/**
|
|
166247
|
+
* process.stdout/stderr stream errors (EIO when the pty is gone, EPIPE when
|
|
166248
|
+
* the reader disconnected) are emitted asynchronously, so the synchronous
|
|
166249
|
+
* try/catch around every terminal write cannot observe them. Without a
|
|
166250
|
+
* listener Node rethrows them and kills the process — a doomed notification
|
|
166251
|
+
* write after the pane closes would crash the whole TUI. Absorb stream
|
|
166252
|
+
* death here, stop notification writes, and let the run loop unwind through
|
|
166253
|
+
* the normal stop path.
|
|
166254
|
+
*/
|
|
166255
|
+
installStreamErrorGuards() {
|
|
166256
|
+
if (this.removeStreamErrorGuards) return;
|
|
166257
|
+
this.removeStreamErrorGuards = watchStreamErrors([process.stdout, process.stderr], () => {
|
|
166258
|
+
this.notifications.markTerminalUnavailable();
|
|
166259
|
+
if (!this.stopped) {
|
|
166260
|
+
process.exitCode = 1;
|
|
166261
|
+
this.stop();
|
|
166262
|
+
}
|
|
166263
|
+
});
|
|
166264
|
+
}
|
|
165865
166265
|
async resolveTerminalColorScheme() {
|
|
165866
166266
|
if (!this.colorsEnabled || this.themePreference !== "auto") return;
|
|
165867
166267
|
try {
|
|
@@ -165870,6 +166270,14 @@ var ZCodeTui = class {
|
|
|
165870
166270
|
if (colorScheme) this.theme.setColorScheme(colorScheme);
|
|
165871
166271
|
} catch {}
|
|
165872
166272
|
}
|
|
166273
|
+
/** The live fullscreen alt screen, when the active TUI is the fullscreen one. */
|
|
166274
|
+
get fullscreenAltScreen() {
|
|
166275
|
+
return this.ui instanceof ZCodeAltScreen ? this.ui : void 0;
|
|
166276
|
+
}
|
|
166277
|
+
setCopyOnSelect(enabled) {
|
|
166278
|
+
this.copyOnSelect = enabled;
|
|
166279
|
+
this.fullscreenAltScreen?.setCopyOnSelect(enabled);
|
|
166280
|
+
}
|
|
165873
166281
|
createTui(mode) {
|
|
165874
166282
|
let fullscreenTui;
|
|
165875
166283
|
const terminal = new NotifyingProcessTerminal((data) => {
|
|
@@ -165888,6 +166296,7 @@ var ZCodeTui = class {
|
|
|
165888
166296
|
return false;
|
|
165889
166297
|
}
|
|
165890
166298
|
},
|
|
166299
|
+
copyOnSelect: this.copyOnSelect,
|
|
165891
166300
|
mouse: true,
|
|
165892
166301
|
wheelScrollLines: 3
|
|
165893
166302
|
});
|
|
@@ -165991,7 +166400,8 @@ var ZCodeTui = class {
|
|
|
165991
166400
|
follow: "end",
|
|
165992
166401
|
primary: true,
|
|
165993
166402
|
overscroll: "chain",
|
|
165994
|
-
scrollbar: "
|
|
166403
|
+
scrollbar: "auto",
|
|
166404
|
+
scrollbarStyle: this.theme.scrollbarThumb
|
|
165995
166405
|
});
|
|
165996
166406
|
this.fullscreenLayout ??= new VStack([
|
|
165997
166407
|
{
|
|
@@ -166220,7 +166630,7 @@ var ZCodeTui = class {
|
|
|
166220
166630
|
},
|
|
166221
166631
|
{
|
|
166222
166632
|
name: "copy",
|
|
166223
|
-
description: "Copy the latest assistant response"
|
|
166633
|
+
description: "Copy the active fullscreen selection or latest assistant response"
|
|
166224
166634
|
},
|
|
166225
166635
|
{
|
|
166226
166636
|
name: "paste-image",
|
|
@@ -166367,12 +166777,12 @@ var ZCodeTui = class {
|
|
|
166367
166777
|
return { consume: true };
|
|
166368
166778
|
}
|
|
166369
166779
|
if (matchesKey(data, "ctrl+c")) {
|
|
166370
|
-
if (this.
|
|
166780
|
+
if (this.editor.getText()) this.editor.setText("");
|
|
166781
|
+
else if (this.turnAbortController) {
|
|
166371
166782
|
this.pendingSteerInterrupt = void 0;
|
|
166372
166783
|
this.turnAbortController.abort();
|
|
166373
166784
|
this.updateActivity("cancelling…");
|
|
166374
|
-
} else
|
|
166375
|
-
else this.stop();
|
|
166785
|
+
} else this.stop();
|
|
166376
166786
|
return { consume: true };
|
|
166377
166787
|
}
|
|
166378
166788
|
if (matchesKey(data, "ctrl+d") && !this.editor.getText() && !this.turnAbortController) {
|
|
@@ -166384,6 +166794,14 @@ var ZCodeTui = class {
|
|
|
166384
166794
|
this.clearRewindEscape();
|
|
166385
166795
|
return { consume: true };
|
|
166386
166796
|
}
|
|
166797
|
+
if (this.transcript.searchStatus() || this.transcript.cursorStatus()) {
|
|
166798
|
+
this.clearRewindEscape();
|
|
166799
|
+
this.transcript.clearSearch();
|
|
166800
|
+
this.transcript.clearCursor();
|
|
166801
|
+
this.updateMetadata();
|
|
166802
|
+
this.ui.requestRender(true);
|
|
166803
|
+
return { consume: true };
|
|
166804
|
+
}
|
|
166387
166805
|
if (this.turnAbortController) {
|
|
166388
166806
|
this.clearRewindEscape();
|
|
166389
166807
|
const pendingSteer = this.inputQueue.hasPendingSteers();
|
|
@@ -166395,14 +166813,6 @@ var ZCodeTui = class {
|
|
|
166395
166813
|
else this.requestForegroundTurnInterrupt();
|
|
166396
166814
|
return { consume: true };
|
|
166397
166815
|
}
|
|
166398
|
-
if (this.transcript.searchStatus() || this.transcript.cursorStatus()) {
|
|
166399
|
-
this.clearRewindEscape();
|
|
166400
|
-
this.transcript.clearSearch();
|
|
166401
|
-
this.transcript.clearCursor();
|
|
166402
|
-
this.updateMetadata();
|
|
166403
|
-
this.ui.requestRender(true);
|
|
166404
|
-
return { consume: true };
|
|
166405
|
-
}
|
|
166406
166816
|
if (!this.editor.getText() && this.activeSubmissions === 0) {
|
|
166407
166817
|
this.handleRewindEscape();
|
|
166408
166818
|
return { consume: true };
|
|
@@ -166412,7 +166822,7 @@ var ZCodeTui = class {
|
|
|
166412
166822
|
}
|
|
166413
166823
|
async submit(rawInput, queuedSubmission) {
|
|
166414
166824
|
const input = (queuedSubmission?.input ?? rawInput).trim();
|
|
166415
|
-
if (!input || this.stopped) return;
|
|
166825
|
+
if (!input || this.stopped) return false;
|
|
166416
166826
|
const submission = queuedSubmission ?? protectSubmission(input);
|
|
166417
166827
|
if (submission.recordHistory) {
|
|
166418
166828
|
this.rememberEditorHistory(input);
|
|
@@ -166437,7 +166847,7 @@ var ZCodeTui = class {
|
|
|
166437
166847
|
return;
|
|
166438
166848
|
}
|
|
166439
166849
|
if (input === "/copy") {
|
|
166440
|
-
await this.
|
|
166850
|
+
await this.copySelectionOrLastResponse();
|
|
166441
166851
|
return;
|
|
166442
166852
|
}
|
|
166443
166853
|
if (input === "/paste-image") {
|
|
@@ -166525,7 +166935,7 @@ var ZCodeTui = class {
|
|
|
166525
166935
|
...submission,
|
|
166526
166936
|
recordHistory: false
|
|
166527
166937
|
});
|
|
166528
|
-
return;
|
|
166938
|
+
return true;
|
|
166529
166939
|
}
|
|
166530
166940
|
if (!steering && this.backgroundTaskEvents.hasActiveHandoffs()) {
|
|
166531
166941
|
this.inputQueue.queueFollowUp({
|
|
@@ -166533,7 +166943,7 @@ var ZCodeTui = class {
|
|
|
166533
166943
|
recordHistory: false
|
|
166534
166944
|
});
|
|
166535
166945
|
this.interruptBackgroundHandoffForInput();
|
|
166536
|
-
return;
|
|
166946
|
+
return true;
|
|
166537
166947
|
}
|
|
166538
166948
|
if (!steering && !input.startsWith("/") && !this.sessionTitleEmitted) {
|
|
166539
166949
|
const sessionTitle = sessionTitleFromFirstMessage(submission.displayInput);
|
|
@@ -166549,7 +166959,7 @@ var ZCodeTui = class {
|
|
|
166549
166959
|
...submission,
|
|
166550
166960
|
recordHistory: false
|
|
166551
166961
|
});
|
|
166552
|
-
return;
|
|
166962
|
+
return true;
|
|
166553
166963
|
}
|
|
166554
166964
|
const attachments = !steering && !input.startsWith("/") ? [...this.pendingAttachments] : [];
|
|
166555
166965
|
if (steering && !this.options.sendInput) {
|
|
@@ -166557,7 +166967,7 @@ var ZCodeTui = class {
|
|
|
166557
166967
|
...submission,
|
|
166558
166968
|
recordHistory: false
|
|
166559
166969
|
});
|
|
166560
|
-
return;
|
|
166970
|
+
return true;
|
|
166561
166971
|
}
|
|
166562
166972
|
if (attachments.length > 0) this.clearPendingAttachments(false);
|
|
166563
166973
|
const abortController = new AbortController();
|
|
@@ -166566,6 +166976,7 @@ var ZCodeTui = class {
|
|
|
166566
166976
|
const callOptions = {
|
|
166567
166977
|
abortSignal: abortController.signal,
|
|
166568
166978
|
delivery: steering ? "steer_active_turn" : "start_turn",
|
|
166979
|
+
queueDelivery: steering ? "guide" : void 0,
|
|
166569
166980
|
expectedTurnId: steering ? this.activeTurnId : void 0,
|
|
166570
166981
|
inputId,
|
|
166571
166982
|
pendingInputReservationId: queuedSubmission?.pendingInputReservationId,
|
|
@@ -166597,7 +167008,7 @@ var ZCodeTui = class {
|
|
|
166597
167008
|
this.activeSubmissions += 1;
|
|
166598
167009
|
} else this.steerAbortControllers.add(abortController);
|
|
166599
167010
|
if (!steering || submission.status) this.updateActivity(submission.status ?? "working…");
|
|
166600
|
-
const notificationEligible = !steering && !input.startsWith("/");
|
|
167011
|
+
const notificationEligible = !steering && !input.startsWith("/") && queuedSubmission?.suppressCompletionNotification !== true;
|
|
166601
167012
|
if (notificationEligible) this.pendingTurnNotification = "completed";
|
|
166602
167013
|
let accepted = false;
|
|
166603
167014
|
let unfinishedToolState = "interrupted";
|
|
@@ -166610,9 +167021,9 @@ var ZCodeTui = class {
|
|
|
166610
167021
|
} else {
|
|
166611
167022
|
const preparedInput = promptInput(runtimeInput, attachments);
|
|
166612
167023
|
const outcome = queuedSubmission?.pendingInputIds?.length && this.options.promoteQueuedInput ? await this.options.promoteQueuedInput(preparedInput, queuedSubmission.pendingInputIds, callOptions) : await this.options.sendInput(preparedInput, callOptions);
|
|
166613
|
-
if (steering && this.activeTurnEpoch !== turnEpoch) return;
|
|
167024
|
+
if (steering && this.activeTurnEpoch !== turnEpoch) return false;
|
|
166614
167025
|
const disposition = await this.handleSendOutcome(outcome);
|
|
166615
|
-
if (steering && this.activeTurnEpoch !== turnEpoch) return;
|
|
167026
|
+
if (steering && this.activeTurnEpoch !== turnEpoch) return false;
|
|
166616
167027
|
if (steering && disposition.targetTurnId) this.activeTurnId = disposition.targetTurnId;
|
|
166617
167028
|
if (pendingSteer && disposition.pendingInputId) this.inputQueue.associateSteer(pendingSteer.inputId, disposition.pendingInputId, disposition.targetTurnId);
|
|
166618
167029
|
accepted = disposition.accepted;
|
|
@@ -166671,6 +167082,7 @@ var ZCodeTui = class {
|
|
|
166671
167082
|
this.refreshSessionUsage();
|
|
166672
167083
|
}
|
|
166673
167084
|
if (nextCommand) await this.submit(nextCommand.input, nextCommand);
|
|
167085
|
+
return accepted;
|
|
166674
167086
|
}
|
|
166675
167087
|
finishPrimaryTurnSubmission(turnEpoch, abortController, unfinishedToolState) {
|
|
166676
167088
|
this.activeSubmissions = Math.max(0, this.activeSubmissions - 1);
|
|
@@ -166740,6 +167152,7 @@ var ZCodeTui = class {
|
|
|
166740
167152
|
this.pendingSteerInterrupt = void 0;
|
|
166741
167153
|
this.foregroundTurnInterrupt = abortController;
|
|
166742
167154
|
this.updateActivity("cancelling…");
|
|
167155
|
+
this.cancelActiveBackgroundAgentTasks();
|
|
166743
167156
|
const interruptTurn = this.options.interruptTurn;
|
|
166744
167157
|
if (!interruptTurn) {
|
|
166745
167158
|
abortController.abort();
|
|
@@ -166752,6 +167165,51 @@ var ZCodeTui = class {
|
|
|
166752
167165
|
if (this.turnAbortController === abortController && !abortController.signal.aborted) abortController.abort();
|
|
166753
167166
|
});
|
|
166754
167167
|
}
|
|
167168
|
+
/**
|
|
167169
|
+
* Backgrounded agents owned by the interrupted turn are detached from its
|
|
167170
|
+
* abort signal, so cancel those explicitly. Older agents and non-agent tasks
|
|
167171
|
+
* remain independent and continue running.
|
|
167172
|
+
*/
|
|
167173
|
+
cancelActiveBackgroundAgentTasks() {
|
|
167174
|
+
const cancelBackgroundTask = this.options.cancelBackgroundTask;
|
|
167175
|
+
if (!cancelBackgroundTask) return;
|
|
167176
|
+
const jobs = this.runtimeProjection?.backgroundJobs ?? [];
|
|
167177
|
+
const active = jobs.filter((job) => isActiveBackgroundJob(job) && job.taskKind === "local_agent" && job.cancellable !== false && (this.turnWork.ownsTask(job.taskId) || Boolean(this.activeTurnId && job.turnId === this.activeTurnId)));
|
|
167178
|
+
const activeIds = new Set(active.map((job) => job.taskId));
|
|
167179
|
+
const surviving = jobs.filter((job) => isActiveBackgroundJob(job) && !activeIds.has(job.taskId));
|
|
167180
|
+
if (active.length === 0 && surviving.length === 0) return;
|
|
167181
|
+
(async () => {
|
|
167182
|
+
const stopped = [];
|
|
167183
|
+
const failed = [];
|
|
167184
|
+
for (const job of active) try {
|
|
167185
|
+
const failure = backgroundCancellationFailure(await cancelBackgroundTask(job.taskId));
|
|
167186
|
+
if (failure) {
|
|
167187
|
+
failed.push({
|
|
167188
|
+
detail: failure,
|
|
167189
|
+
taskId: job.taskId
|
|
167190
|
+
});
|
|
167191
|
+
this.backgroundTaskEvents.recordSystemMessage(job.taskId, `Task was not cancelled: ${failure}.`, true);
|
|
167192
|
+
continue;
|
|
167193
|
+
}
|
|
167194
|
+
stopped.push(job.taskId);
|
|
167195
|
+
this.backgroundTaskEvents.recordSystemMessage(job.taskId, "Task cancelled by Esc interrupt.");
|
|
167196
|
+
} catch (error) {
|
|
167197
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
167198
|
+
failed.push({
|
|
167199
|
+
detail,
|
|
167200
|
+
taskId: job.taskId
|
|
167201
|
+
});
|
|
167202
|
+
this.backgroundTaskEvents.recordSystemMessage(job.taskId, detail, true);
|
|
167203
|
+
}
|
|
167204
|
+
if (stopped.length > 0) this.addNotice(`Esc also stopped background task${stopped.length > 1 ? "s" : ""}: ${stopped.join(", ")}.`, "muted");
|
|
167205
|
+
for (const failure of failed) this.addNotice(`Esc could not stop background task ${failure.taskId}: ${failure.detail}.`, "warning");
|
|
167206
|
+
if (surviving.length > 0) {
|
|
167207
|
+
const ids = surviving.map((job) => job.taskId).join(", ");
|
|
167208
|
+
this.addNotice(`Background task${surviving.length > 1 ? "s" : ""} ${ids} keep${surviving.length > 1 ? "" : "s"} running — /tasks stop <task-id> to stop.`, "muted");
|
|
167209
|
+
}
|
|
167210
|
+
if (active.length > 0) await this.refreshRuntimeState();
|
|
167211
|
+
})();
|
|
167212
|
+
}
|
|
166755
167213
|
isPendingSteerInterrupt(turnEpoch, abortController) {
|
|
166756
167214
|
const pending = this.pendingSteerInterrupt;
|
|
166757
167215
|
return pending?.turnEpoch === turnEpoch && pending.abortController === abortController;
|
|
@@ -166863,25 +167321,18 @@ var ZCodeTui = class {
|
|
|
166863
167321
|
this.completeThinking();
|
|
166864
167322
|
this.assistantStream.breakSegment();
|
|
166865
167323
|
}
|
|
166866
|
-
if (event.kind === "text_start")
|
|
167324
|
+
if (event.kind === "text_start") this.currentToolGroup = void 0;
|
|
167325
|
+
else if (event.kind === "text_delta" && event.delta) {
|
|
166867
167326
|
this.currentToolGroup = void 0;
|
|
166868
|
-
this.
|
|
166869
|
-
|
|
166870
|
-
} else if (event.kind === "text_delta" && event.delta) {
|
|
167327
|
+
this.recordAssistantText(this.assistantStream.append(event.delta, void 0, event.messageId));
|
|
167328
|
+
} else if (event.kind === "text_end") {} else if (event.kind === "reasoning_start") {
|
|
166871
167329
|
this.currentToolGroup = void 0;
|
|
166872
|
-
this.completeThinking();
|
|
166873
|
-
this.recordAssistantText(this.assistantStream.append(event.delta, event.partId, event.messageId));
|
|
166874
|
-
} else if (event.kind === "text_end") this.assistantStream.breakSegment();
|
|
166875
|
-
else if (event.kind === "reasoning_start") {
|
|
166876
|
-
this.currentToolGroup = void 0;
|
|
166877
|
-
this.assistantStream.breakSegment();
|
|
166878
167330
|
this.updateActivity("thinking…", false);
|
|
166879
167331
|
} else if (event.kind === "reasoning_delta") {
|
|
166880
167332
|
this.currentToolGroup = void 0;
|
|
166881
|
-
this.assistantStream.breakSegment();
|
|
166882
167333
|
this.updateActivity("thinking…", false);
|
|
166883
|
-
if (event.delta && (this.currentThinking || event.delta.trim())) this.appendThinking(event.delta,
|
|
166884
|
-
} else if (event.kind === "reasoning_end") this.
|
|
167334
|
+
if (event.delta && (this.currentThinking || event.delta.trim())) this.appendThinking(event.delta, void 0, event.messageId);
|
|
167335
|
+
} else if (event.kind === "reasoning_end") this.settleThinking();
|
|
166885
167336
|
else if (event.kind === "tool_input_start") {
|
|
166886
167337
|
const tool = this.ensureToolView(event.toolCallId, event.toolName, event.partId, event.messageId);
|
|
166887
167338
|
tool.input = void 0;
|
|
@@ -167286,10 +167737,15 @@ var ZCodeTui = class {
|
|
|
167286
167737
|
}
|
|
167287
167738
|
this.currentThinking.append(delta);
|
|
167288
167739
|
}
|
|
167289
|
-
|
|
167740
|
+
settleThinking(partId) {
|
|
167290
167741
|
const thinking = partId ? this.thinkingParts.get(partId) : this.currentThinking;
|
|
167291
|
-
if (!thinking) return;
|
|
167742
|
+
if (!thinking) return void 0;
|
|
167292
167743
|
thinking.complete();
|
|
167744
|
+
return thinking;
|
|
167745
|
+
}
|
|
167746
|
+
completeThinking(partId) {
|
|
167747
|
+
const thinking = this.settleThinking(partId);
|
|
167748
|
+
if (!thinking) return;
|
|
167293
167749
|
if (this.currentThinking === thinking) {
|
|
167294
167750
|
this.currentThinking = void 0;
|
|
167295
167751
|
this.currentThinkingPartId = void 0;
|
|
@@ -168376,6 +168832,11 @@ var ZCodeTui = class {
|
|
|
168376
168832
|
value: "tui-mode",
|
|
168377
168833
|
label: "Display mode",
|
|
168378
168834
|
description: tuiModeOverride === "fullscreen" || tuiModeOverride === "regular" ? `Current: ${this.tuiMode === "fullscreen" ? "Fullscreen" : "Regular"} (environment override)` : `Current: ${this.tuiMode === "fullscreen" ? "Fullscreen" : "Regular"}`
|
|
168835
|
+
},
|
|
168836
|
+
{
|
|
168837
|
+
value: "copy-on-select",
|
|
168838
|
+
label: "Fullscreen copy on select",
|
|
168839
|
+
description: `Current: ${this.copyOnSelect ? "Enabled" : "Disabled"}`
|
|
168379
168840
|
}
|
|
168380
168841
|
],
|
|
168381
168842
|
selectedIndex: selectedSettingIndex
|
|
@@ -168400,7 +168861,7 @@ var ZCodeTui = class {
|
|
|
168400
168861
|
}, {
|
|
168401
168862
|
value: "fullscreen",
|
|
168402
168863
|
label: "Fullscreen",
|
|
168403
|
-
description: "Alternate screen with
|
|
168864
|
+
description: "Alternate screen with a fixed composer and transient themed scrollbar"
|
|
168404
168865
|
}],
|
|
168405
168866
|
selectedIndex: this.tuiMode === "fullscreen" ? 1 : 0
|
|
168406
168867
|
});
|
|
@@ -168418,6 +168879,42 @@ var ZCodeTui = class {
|
|
|
168418
168879
|
selectedSettingIndex = 3;
|
|
168419
168880
|
continue;
|
|
168420
168881
|
}
|
|
168882
|
+
if (setting.value === "copy-on-select") {
|
|
168883
|
+
selectedSettingIndex = 4;
|
|
168884
|
+
const selected = await this.showChoice({
|
|
168885
|
+
title: "Fullscreen copy on select",
|
|
168886
|
+
prompt: "Only applies to fullscreen mode. Releasing a mouse selection copies it to the clipboard.",
|
|
168887
|
+
help: "Up/Down choose · Enter save · Esc back",
|
|
168888
|
+
items: [{
|
|
168889
|
+
value: "enabled",
|
|
168890
|
+
label: "Enabled",
|
|
168891
|
+
description: "Release copies the selection (default)"
|
|
168892
|
+
}, {
|
|
168893
|
+
value: "disabled",
|
|
168894
|
+
label: "Disabled",
|
|
168895
|
+
description: "Selection only highlights; copy manually via /copy or the terminal"
|
|
168896
|
+
}],
|
|
168897
|
+
selectedIndex: this.copyOnSelect ? 0 : 1
|
|
168898
|
+
});
|
|
168899
|
+
if (!selected) {
|
|
168900
|
+
feedback = "No changes · Esc closes settings";
|
|
168901
|
+
continue;
|
|
168902
|
+
}
|
|
168903
|
+
const next = selected.value === "enabled";
|
|
168904
|
+
if (next === this.copyOnSelect) {
|
|
168905
|
+
feedback = "Copy on select unchanged";
|
|
168906
|
+
continue;
|
|
168907
|
+
}
|
|
168908
|
+
try {
|
|
168909
|
+
await writeCopyOnSelect(next);
|
|
168910
|
+
this.setCopyOnSelect(next);
|
|
168911
|
+
feedback = `Copy on select ${next ? "enabled" : "disabled"} · saved`;
|
|
168912
|
+
} catch (error) {
|
|
168913
|
+
this.addNotice(error instanceof Error ? error.message : String(error), "error");
|
|
168914
|
+
feedback = "Could not save the setting · select it to retry";
|
|
168915
|
+
}
|
|
168916
|
+
continue;
|
|
168917
|
+
}
|
|
168421
168918
|
selectedSettingIndex = setting.value === "notification-condition" ? 2 : setting.value === "notification-method" ? 1 : 0;
|
|
168422
168919
|
let next = stored;
|
|
168423
168920
|
let changedLabel;
|
|
@@ -169138,10 +169635,18 @@ var ZCodeTui = class {
|
|
|
169138
169635
|
const canMessage = job.taskKind === "local_agent" && Boolean(this.options.sendBackgroundTaskMessage);
|
|
169139
169636
|
const canStop = active && job.cancellable !== false && Boolean(this.options.cancelBackgroundTask);
|
|
169140
169637
|
const items = [
|
|
169141
|
-
...canMessage ? [{
|
|
169638
|
+
...canMessage ? active ? [{
|
|
169142
169639
|
value: "message",
|
|
169143
|
-
label:
|
|
169144
|
-
description:
|
|
169640
|
+
label: "Message agent",
|
|
169641
|
+
description: "Send guidance to this task"
|
|
169642
|
+
}] : [{
|
|
169643
|
+
value: "resume",
|
|
169644
|
+
label: "Resume agent",
|
|
169645
|
+
description: "Continue from the saved child session"
|
|
169646
|
+
}, {
|
|
169647
|
+
value: "resume-with-instructions",
|
|
169648
|
+
label: "Resume with instructions",
|
|
169649
|
+
description: "Continue the saved child session with custom guidance"
|
|
169145
169650
|
}] : [],
|
|
169146
169651
|
...canMessage && active ? [{
|
|
169147
169652
|
value: "restart",
|
|
@@ -169193,11 +169698,16 @@ var ZCodeTui = class {
|
|
|
169193
169698
|
await this.stopBackgroundTask(job.taskId);
|
|
169194
169699
|
continue;
|
|
169195
169700
|
}
|
|
169196
|
-
if (action.value === "
|
|
169701
|
+
if (action.value === "resume" && !active) {
|
|
169702
|
+
await this.messageBackgroundTask(job, defaultBackgroundResumeMessage);
|
|
169703
|
+
continue;
|
|
169704
|
+
}
|
|
169705
|
+
if (action.value === "message" || action.value === "resume-with-instructions" || action.value === "restart") {
|
|
169197
169706
|
const restart = action.value === "restart";
|
|
169707
|
+
const customResume = action.value === "resume-with-instructions";
|
|
169198
169708
|
const message = await this.showTextPrompt({
|
|
169199
|
-
title: restart ? "Restart background agent" :
|
|
169200
|
-
prompt: restart ? `Describe what ${job.agentId ?? job.taskId} should continue or repair after restart.` :
|
|
169709
|
+
title: restart ? "Restart background agent" : customResume ? "Resume background agent with instructions" : "Message background agent",
|
|
169710
|
+
prompt: restart ? `Describe what ${job.agentId ?? job.taskId} should continue or repair after restart.` : customResume ? `Describe what ${job.agentId ?? job.taskId} should continue or repair.` : `Send guidance to ${job.agentId ?? job.taskId}.`
|
|
169201
169711
|
});
|
|
169202
169712
|
if (message?.trim()) await this.messageBackgroundTask(job, message.trim(), restart);
|
|
169203
169713
|
continue;
|
|
@@ -169303,7 +169813,7 @@ var ZCodeTui = class {
|
|
|
169303
169813
|
this.addNotice(`No background task found with ID ${taskId}.`, "warning");
|
|
169304
169814
|
return;
|
|
169305
169815
|
}
|
|
169306
|
-
const message = suppliedMessage || (resume ?
|
|
169816
|
+
const message = suppliedMessage || (resume ? defaultBackgroundResumeMessage : "");
|
|
169307
169817
|
if (!message) {
|
|
169308
169818
|
this.addNotice(`Usage: /tasks message ${taskId} <message>`, "muted");
|
|
169309
169819
|
return;
|
|
@@ -169334,6 +169844,7 @@ var ZCodeTui = class {
|
|
|
169334
169844
|
if (status === "failed") throw new Error(asString(record?.error) ?? detail);
|
|
169335
169845
|
this.backgroundTaskEvents.recordSystemMessage(job.taskId, detail);
|
|
169336
169846
|
this.addNotice(detail, "muted");
|
|
169847
|
+
await this.notifyTaskCoordinator(job, restart, message);
|
|
169337
169848
|
await this.refreshRuntimeState();
|
|
169338
169849
|
} catch (error) {
|
|
169339
169850
|
const detail = error instanceof Error ? error.message : String(error);
|
|
@@ -169343,6 +169854,23 @@ var ZCodeTui = class {
|
|
|
169343
169854
|
this.updateActivity(void 0);
|
|
169344
169855
|
}
|
|
169345
169856
|
}
|
|
169857
|
+
async notifyTaskCoordinator(job, restart, message) {
|
|
169858
|
+
const coordinatorNotice = taskCoordinatorNotice(job, restart, message);
|
|
169859
|
+
let failure;
|
|
169860
|
+
try {
|
|
169861
|
+
if (await this.submit(coordinatorNotice, {
|
|
169862
|
+
...protectSubmission(coordinatorNotice),
|
|
169863
|
+
recordHistory: false,
|
|
169864
|
+
suppressCompletionNotification: true
|
|
169865
|
+
}) === true) return;
|
|
169866
|
+
failure = "the coordinator notice was not accepted";
|
|
169867
|
+
} catch (error) {
|
|
169868
|
+
failure = error instanceof Error ? error.message : String(error);
|
|
169869
|
+
}
|
|
169870
|
+
const detail = `Task action succeeded, but ${failure}.`;
|
|
169871
|
+
this.backgroundTaskEvents.recordSystemMessage(job.taskId, detail, true);
|
|
169872
|
+
this.addNotice(detail, "warning");
|
|
169873
|
+
}
|
|
169346
169874
|
async stopBackgroundTask(taskId) {
|
|
169347
169875
|
if (!taskId) {
|
|
169348
169876
|
this.addNotice("Usage: /tasks stop <task-id>", "muted");
|
|
@@ -169398,7 +169926,12 @@ var ZCodeTui = class {
|
|
|
169398
169926
|
this.ui.requestRender();
|
|
169399
169927
|
}
|
|
169400
169928
|
}
|
|
169401
|
-
async
|
|
169929
|
+
async copySelectionOrLastResponse() {
|
|
169930
|
+
const fullscreen = this.fullscreenAltScreen;
|
|
169931
|
+
if (fullscreen?.hasActiveSelection()) {
|
|
169932
|
+
await fullscreen.copyActiveSelectionToClipboard();
|
|
169933
|
+
return;
|
|
169934
|
+
}
|
|
169402
169935
|
const text = this.transcript.selectedText() ?? this.lastAssistantText;
|
|
169403
169936
|
if (!text) {
|
|
169404
169937
|
this.addNotice("There is no assistant response to copy.", "muted");
|
|
@@ -169570,6 +170103,7 @@ var ZCodeTui = class {
|
|
|
169570
170103
|
applyRuntimeProjection(projection) {
|
|
169571
170104
|
if (!projection) return;
|
|
169572
170105
|
this.runtimeProjection = projection;
|
|
170106
|
+
this.noticeRestoredBackgroundTasks(projection);
|
|
169573
170107
|
this.reconcileTurnTiming(projection);
|
|
169574
170108
|
if (projection.sessionId) this.sessionId = projection.sessionId;
|
|
169575
170109
|
this.sessionMetrics = mergeProjectionMetrics(this.sessionMetrics, {
|
|
@@ -169580,6 +170114,35 @@ var ZCodeTui = class {
|
|
|
169580
170114
|
}, Boolean(this.options.readSessionUsage));
|
|
169581
170115
|
this.updateRuntimeActivity(false);
|
|
169582
170116
|
}
|
|
170117
|
+
/**
|
|
170118
|
+
* Surface tasks the persisted background-agent restore bridge re-registered.
|
|
170119
|
+
* Tasks that completed or failed while ZCode was closed never produce a
|
|
170120
|
+
* completion notification, so without this notice they are silent — the
|
|
170121
|
+
* model-facing task_status attachment alone does not reach the user.
|
|
170122
|
+
*/
|
|
170123
|
+
noticeRestoredBackgroundTasks(projection) {
|
|
170124
|
+
for (const job of projection.restoredBackgroundTasks ?? []) {
|
|
170125
|
+
const seenKey = `${projection.sessionId ?? ""}/${job.taskId}`;
|
|
170126
|
+
if (this.restoredNoticeSeen.has(seenKey)) continue;
|
|
170127
|
+
this.restoredNoticeSeen.add(seenKey);
|
|
170128
|
+
const label = job.description ? `${job.taskId} (${job.description})` : job.taskId;
|
|
170129
|
+
if (job.status === "completed") this.addSystemEvent({
|
|
170130
|
+
tone: "muted",
|
|
170131
|
+
title: "Background task completed while ZCode was closed",
|
|
170132
|
+
detail: `${label} finished before this session was resumed. Collect its result with TaskOutput or open /tasks.`
|
|
170133
|
+
});
|
|
170134
|
+
else if (job.status === "failed") this.addSystemEvent({
|
|
170135
|
+
tone: "error",
|
|
170136
|
+
title: "Background task failed while ZCode was closed",
|
|
170137
|
+
detail: `${label} failed before this session was resumed. Resume it from /tasks to continue.`
|
|
170138
|
+
});
|
|
170139
|
+
else this.addSystemEvent({
|
|
170140
|
+
tone: "warning",
|
|
170141
|
+
title: "Background task restored from this session",
|
|
170142
|
+
detail: `${label} was interrupted before ZCode closed. Resume it from /tasks when needed.`
|
|
170143
|
+
});
|
|
170144
|
+
}
|
|
170145
|
+
}
|
|
169583
170146
|
updateRuntimeActivity(requestRender = true) {
|
|
169584
170147
|
this.runtimeActivity.update({
|
|
169585
170148
|
projection: this.runtimeProjection,
|