zcode-app-cli 3.10.1-17 → 3.10.2-18

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.
@@ -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
- "attachment": true,
28
- "supportsImages": true,
29
- "supportsPdf": true,
30
- "supportsVideo": true,
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 backgroundAgentToolName(name) {
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$2(value)?.run_in_background === true;
157086
+ return record$3(value)?.run_in_background === true;
157023
157087
  }
157024
157088
  function asyncAgentResult(value) {
157025
- const root = record$2(value);
157089
+ const root = record$3(value);
157026
157090
  return [
157027
157091
  root,
157028
- record$2(root?.output),
157029
- record$2(root?.result)
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(backgroundAgentToolName(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));
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 === "Agent") ? event.progress?.parentToolCallId : void 0;
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 (backgroundAgentToolName(scope.name) && (explicitlyBackgroundAgentInput(event.input ?? part?.input) || asyncAgentResult(event.result ?? part?.output)) || Boolean(scope.parentId && this.scopedTool(scope.parentId))) this.rememberScopedToolCall(scope.id);
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 printable = decodeKittyPrintable(data) ?? (data.length > 0 && !/[\u0000-\u001f\u007f-\u009f]/u.test(data) ? data : void 0);
157632
- if (printable !== void 0) {
157633
- this.updateFilter(this.filter + printable);
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);
@@ -160604,69 +160730,6 @@ function planText$1(input) {
160604
160730
  }
160605
160731
  }
160606
160732
  //#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
160733
  //#region packages/zcode-tui/src/tool-renderers/helpers.ts
160671
160734
  function recordString(record, keys) {
160672
160735
  if (!record) return void 0;
@@ -160811,6 +160874,10 @@ function toolSummary(name, input) {
160811
160874
  ]);
160812
160875
  return task ? `task ${task}` : void 0;
160813
160876
  }
160877
+ case "TaskOutput": {
160878
+ const task = recordString(record, ["task_id", "taskId"]);
160879
+ return task ? `task ${task}` : void 0;
160880
+ }
160814
160881
  case "Agent":
160815
160882
  case "Task": return recordString(record, [
160816
160883
  "description",
@@ -161003,6 +161070,137 @@ function taskStopRender(options) {
161003
161070
  consumesResult: Boolean(record)
161004
161071
  };
161005
161072
  }
161073
+ const taskOutputDisplayLimit = 2e3;
161074
+ const retrievalStatusLabels = {
161075
+ success: "retrieved",
161076
+ not_ready: "not ready yet",
161077
+ timeout: "timed out waiting"
161078
+ };
161079
+ function taskOutputDisplayFromTask(record) {
161080
+ const task = isRecord(record.task) ? record.task : void 0;
161081
+ const retrievalStatus = recordString(record, ["retrieval_status", "retrievalStatus"]);
161082
+ if (!task && !retrievalStatus) return void 0;
161083
+ return {
161084
+ retrievalStatus,
161085
+ taskStatus: recordString(task, ["status"]),
161086
+ source: "fallback"
161087
+ };
161088
+ }
161089
+ function taskOutputDisplayFromString(value) {
161090
+ const trimmed = value.trim();
161091
+ if (trimmed.startsWith("{")) try {
161092
+ const parsed = JSON.parse(trimmed);
161093
+ const fromJson = isRecord(parsed) ? taskOutputDisplayFromTask(parsed) : void 0;
161094
+ if (fromJson) return fromJson;
161095
+ } catch {}
161096
+ if (value.includes("<retrieval_status>")) {
161097
+ const status = /<retrieval_status>([^<]+)<\/retrieval_status>/u.exec(value)?.[1];
161098
+ const taskStatus = /<status>([^<]+)<\/status>/u.exec(value)?.[1];
161099
+ if (status || taskStatus) return {
161100
+ retrievalStatus: status ? sanitizeTerminalText(status.trim(), { preserveSgr: false }) : void 0,
161101
+ taskStatus: taskStatus ? sanitizeTerminalText(taskStatus.trim(), { preserveSgr: false }) : void 0,
161102
+ source: "fallback"
161103
+ };
161104
+ }
161105
+ }
161106
+ function compactTaskOutput(value) {
161107
+ const raw = directText(value)?.trimEnd();
161108
+ if (!raw) return { truncated: false };
161109
+ const output = truncateGraphemes(raw, taskOutputDisplayLimit, "");
161110
+ return {
161111
+ output,
161112
+ truncated: output !== raw
161113
+ };
161114
+ }
161115
+ function taskOutputFailureMessage(result, depth = 0) {
161116
+ if (depth > 3) return void 0;
161117
+ if (typeof result === "string") {
161118
+ const trimmed = result.trim();
161119
+ if (!trimmed.startsWith("{")) return void 0;
161120
+ try {
161121
+ return taskOutputFailureMessage(JSON.parse(trimmed), depth + 1);
161122
+ } catch {
161123
+ return;
161124
+ }
161125
+ }
161126
+ if (!isRecord(result)) return void 0;
161127
+ if (result.success === false || result.result === false) {
161128
+ const message = recordString(result, ["message", "error"]);
161129
+ if (message) return oneLine$2(message, 240);
161130
+ }
161131
+ for (const candidate of [
161132
+ result.output,
161133
+ result.content,
161134
+ result.result
161135
+ ]) {
161136
+ if (candidate === result || typeof candidate === "boolean") continue;
161137
+ const nested = taskOutputFailureMessage(candidate, depth + 1);
161138
+ if (nested) return nested;
161139
+ }
161140
+ }
161141
+ /**
161142
+ * Prefer the runtime's compact `display` metadata; fall back to the raw
161143
+ * `{retrieval_status, task}` result or the persisted model-content string.
161144
+ * Restored parts arrive as `{output, display}` and live results as
161145
+ * `{success, content, display}` — in both the raw field can embed a full
161146
+ * subagent transcript, so it must never be rendered directly. When a restored
161147
+ * part carries no display metadata at all, `upsertProtocolPart` passes the
161148
+ * persisted `state.output` string through as the whole result.
161149
+ */
161150
+ function taskOutputDisplay(result) {
161151
+ if (typeof result === "string") return taskOutputDisplayFromString(result);
161152
+ const record = isRecord(result) ? result : void 0;
161153
+ if (!record) return void 0;
161154
+ const display = isRecord(record.display) ? record.display : isRecord(record.resultDisplay) ? record.resultDisplay : void 0;
161155
+ if (display && (recordString(display, ["kind"]) === "task_output" || recordString(display, ["retrievalStatus", "retrieval_status"]))) {
161156
+ const compact = compactTaskOutput(display.output);
161157
+ return {
161158
+ retrievalStatus: recordString(display, ["retrievalStatus", "retrieval_status"]),
161159
+ taskStatus: recordString(display, [
161160
+ "taskStatus",
161161
+ "task_status",
161162
+ "status"
161163
+ ]),
161164
+ output: compact.output,
161165
+ truncated: booleanField(display, ["truncated"]) === true || compact.truncated,
161166
+ source: "display"
161167
+ };
161168
+ }
161169
+ const nested = taskOutputDisplayFromTask(record);
161170
+ if (nested) return nested;
161171
+ for (const candidate of [record.output, record.content]) {
161172
+ if (typeof candidate !== "string") continue;
161173
+ const fallback = taskOutputDisplayFromString(candidate);
161174
+ if (fallback) return fallback;
161175
+ }
161176
+ }
161177
+ function taskOutputRender(options) {
161178
+ const taskId = recordString(isRecord(options.input) ? options.input : void 0, [
161179
+ "task_id",
161180
+ "taskId",
161181
+ "taskID"
161182
+ ]);
161183
+ const display = taskOutputDisplay(options.result);
161184
+ const body = [];
161185
+ const status = display ? compactStatusLine([
161186
+ display.retrievalStatus ? retrievalStatusLabels[display.retrievalStatus] ?? display.retrievalStatus.replaceAll("_", " ") : void 0,
161187
+ display.taskStatus && display.taskStatus !== display.retrievalStatus ? display.taskStatus.replaceAll("_", " ") : void 0,
161188
+ display.truncated ? "output truncated" : void 0
161189
+ ], options.theme) : void 0;
161190
+ if (status) body.push(status);
161191
+ if (display?.source === "display" && display.output?.trim()) body.push(display.output.trimEnd());
161192
+ else if (display?.retrievalStatus === "not_ready" || display?.retrievalStatus === "timeout") body.push(options.theme.muted("No output yet — check again with TaskOutput or /tasks."));
161193
+ else {
161194
+ const failureMessage = taskOutputFailureMessage(options.result);
161195
+ body.push(failureMessage ?? options.theme.muted("Task output is available in /tasks."));
161196
+ }
161197
+ return {
161198
+ displayName: "TaskOutput",
161199
+ summary: taskId ? `task ${taskId}` : toolSummary(options.name, options.input),
161200
+ body: body.join("\n") || void 0,
161201
+ consumesResult: true
161202
+ };
161203
+ }
161006
161204
  //#endregion
161007
161205
  //#region packages/zcode-tui/src/tool-renderers/workflow.ts
161008
161206
  function todoItems(value) {
@@ -161303,6 +161501,7 @@ const rendererRegistry = {
161303
161501
  AskUserQuestion: questionRender,
161304
161502
  SendMessage: sendMessageRender,
161305
161503
  TaskStop: taskStopRender,
161504
+ TaskOutput: taskOutputRender,
161306
161505
  Agent: agentRender,
161307
161506
  Task: agentRender,
161308
161507
  Skill: skillRender,
@@ -161805,11 +162004,11 @@ function findExecutable(name, env = process.env, platform = process.platform) {
161805
162004
  }
161806
162005
  return null;
161807
162006
  }
161808
- function record$1(value) {
162007
+ function record$2(value) {
161809
162008
  return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
161810
162009
  }
161811
162010
  function configuredNotifications(config) {
161812
- return record$1(record$1(record$1(config)?.ui)?.notifications);
162011
+ return record$2(record$2(record$2(config)?.ui)?.notifications);
161813
162012
  }
161814
162013
  function notificationSettings(env = process.env, config) {
161815
162014
  const configured = configuredNotifications(config);
@@ -161828,7 +162027,7 @@ async function readStoredNotificationSettings(env = process.env) {
161828
162027
  }
161829
162028
  async function writeNotificationSettings(settings, env = process.env) {
161830
162029
  return await updateUserConfig((config) => {
161831
- const ui = record$1(config.ui) ?? {};
162030
+ const ui = record$2(config.ui) ?? {};
161832
162031
  ui.notifications = { ...settings };
161833
162032
  config.ui = ui;
161834
162033
  }, env);
@@ -162047,11 +162246,11 @@ var TurnNotifier = class {
162047
162246
  };
162048
162247
  //#endregion
162049
162248
  //#region packages/zcode-tui/src/tui-mode.ts
162050
- function record(value) {
162249
+ function record$1(value) {
162051
162250
  return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
162052
162251
  }
162053
162252
  function configuredTuiMode(config) {
162054
- const value = record(record(config)?.ui)?.tuiMode;
162253
+ const value = record$1(record$1(config)?.ui)?.tuiMode;
162055
162254
  return typeof value === "string" ? value : void 0;
162056
162255
  }
162057
162256
  function tuiMode(value) {
@@ -162067,12 +162266,31 @@ async function readTuiMode(env = process.env) {
162067
162266
  }
162068
162267
  async function writeTuiMode(mode, env = process.env) {
162069
162268
  return await updateUserConfig((config) => {
162070
- const ui = record(config.ui) ?? {};
162269
+ const ui = record$1(config.ui) ?? {};
162071
162270
  ui.tuiMode = mode;
162072
162271
  config.ui = ui;
162073
162272
  }, env);
162074
162273
  }
162075
162274
  //#endregion
162275
+ //#region packages/zcode-tui/src/copy-on-select.ts
162276
+ function record(value) {
162277
+ return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
162278
+ }
162279
+ function configuredCopyOnSelect(config) {
162280
+ const value = record(record(config)?.ui)?.copyOnSelect;
162281
+ return typeof value === "boolean" ? value : void 0;
162282
+ }
162283
+ async function readCopyOnSelect(env = process.env) {
162284
+ return configuredCopyOnSelect(await readUserConfig(env)) ?? true;
162285
+ }
162286
+ async function writeCopyOnSelect(enabled, env = process.env) {
162287
+ return await updateUserConfig((config) => {
162288
+ const ui = record(config.ui) ?? {};
162289
+ ui.copyOnSelect = enabled;
162290
+ config.ui = ui;
162291
+ }, env);
162292
+ }
162293
+ //#endregion
162076
162294
  //#region packages/zcode-tui/src/selectors.ts
162077
162295
  function pickerRequest(input, commands) {
162078
162296
  const match = /^\/([^\s]+)(?:\s+(.*))?$/u.exec(input.trim());
@@ -162687,6 +162905,8 @@ const backgroundStatuses = /* @__PURE__ */ new Set([
162687
162905
  "failed",
162688
162906
  "timed_out",
162689
162907
  "cancelled",
162908
+ "killed",
162909
+ "stopped",
162690
162910
  "spawn_error",
162691
162911
  "lost"
162692
162912
  ]);
@@ -162895,12 +163115,18 @@ function normalizeRuntimeProjection(value) {
162895
163115
  }),
162896
163116
  backgroundJobs: records(rawBackgroundJobs).flatMap((item) => {
162897
163117
  const taskId = stringField(item, "taskId", "taskID", "id");
162898
- const job = backgroundJobFrom(taskId && taskDetails.has(taskId) ? {
162899
- ...taskDetails.get(taskId),
162900
- ...item
163118
+ const details = taskId ? taskDetails.get(taskId) : void 0;
163119
+ const definedDetails = details ? Object.fromEntries(Object.entries(details).filter(([, field]) => field !== void 0)) : void 0;
163120
+ const job = backgroundJobFrom(definedDetails ? {
163121
+ ...item,
163122
+ ...definedDetails
162901
163123
  } : item);
162902
163124
  return job ? [job] : [];
162903
163125
  }),
163126
+ restoredBackgroundTasks: records(projection.restoredBackgroundTasks ?? value.restoredBackgroundTasks).flatMap((item) => {
163127
+ const job = backgroundJobFrom(item);
163128
+ return job ? [job] : [];
163129
+ }),
162904
163130
  contextUsage: contextUsageFrom(runtime?.contextUsage ?? value.contextUsage, projection),
162905
163131
  lastError: lastErrorType && lastErrorMessage ? {
162906
163132
  type: lastErrorType,
@@ -163384,7 +163610,10 @@ var ThinkingView = class extends Box {
163384
163610
  }
163385
163611
  append(delta) {
163386
163612
  if (!delta) return;
163387
- this.text += sanitizeTerminalText(delta, { preserveSgr: false });
163613
+ const sanitized = sanitizeTerminalText(delta, { preserveSgr: false });
163614
+ if (!sanitized) return;
163615
+ this.completed = false;
163616
+ this.text += sanitized;
163388
163617
  this.dirty = true;
163389
163618
  }
163390
163619
  setText(text) {
@@ -164779,6 +165008,7 @@ const terminalStatuses = /* @__PURE__ */ new Set([
164779
165008
  "failed",
164780
165009
  "timed_out",
164781
165010
  "cancelled",
165011
+ "killed",
164782
165012
  "spawn_error",
164783
165013
  "lost",
164784
165014
  "stopped"
@@ -165443,6 +165673,7 @@ const backgroundTaskAttentionStatuses = /* @__PURE__ */ new Set([
165443
165673
  "spawn_error",
165444
165674
  "lost"
165445
165675
  ]);
165676
+ const defaultBackgroundResumeMessage = "Continue the assigned task from the last completed step. Re-check the current workspace state and finish the remaining work.";
165446
165677
  function backgroundTaskKindLabel(job) {
165447
165678
  switch (job.taskKind) {
165448
165679
  case "local_agent": return job.agentType ? `Agent (${job.agentType})` : "Agent";
@@ -165459,13 +165690,33 @@ function backgroundTaskSortRank(job) {
165459
165690
  }
165460
165691
  function backgroundAgentPart(part) {
165461
165692
  if (part.type !== "tool") return false;
165462
- const name = part.toolName.trim().toLowerCase();
165463
- if (name !== "agent" && name !== "subagent") return false;
165693
+ if (!isAgentDispatchTool(part.toolName)) return false;
165464
165694
  const input = isRecord(part.input) ? part.input : void 0;
165465
165695
  const output = isRecord(part.output) ? part.output : void 0;
165466
165696
  const nestedOutput = isRecord(output?.output) ? output.output : void 0;
165467
165697
  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
165698
  }
165699
+ /**
165700
+ * Conversation-facing notice for a task-center action (resume / restart /
165701
+ * guidance). Side-channel task actions are invisible to the model otherwise —
165702
+ * surfacing them through the main conversation lets the coordinator wait on
165703
+ * the task with TaskOutput(block=true) instead of finalizing without it.
165704
+ */
165705
+ function taskCoordinatorNotice(job, restart, message) {
165706
+ const label = job.description ? `${job.taskId} (${job.description})` : job.taskId;
165707
+ return [
165708
+ 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:`,
165709
+ `"${message}"`,
165710
+ "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."
165711
+ ].join("\n");
165712
+ }
165713
+ function backgroundCancellationFailure(value) {
165714
+ if (isRecord(value) && value.cancelled === true) return void 0;
165715
+ if (!isRecord(value)) return "cancellation was not confirmed";
165716
+ const reason = asString(value.reason)?.replaceAll("_", " ");
165717
+ const status = asString(value.status)?.replaceAll("_", " ");
165718
+ return [reason, status ? `status ${status}` : void 0].filter(Boolean).join(" · ") || "cancellation was not confirmed";
165719
+ }
165469
165720
  function backgroundToolPartIds(parts) {
165470
165721
  const hidden = /* @__PURE__ */ new Set();
165471
165722
  for (const part of parts) {
@@ -165670,6 +165921,7 @@ var ZCodeTui = class {
165670
165921
  mode;
165671
165922
  model;
165672
165923
  tuiMode;
165924
+ copyOnSelect = true;
165673
165925
  thoughtLevel;
165674
165926
  modelOptions;
165675
165927
  effortOptions;
@@ -165678,6 +165930,7 @@ var ZCodeTui = class {
165678
165930
  unsubscribeWorkflow;
165679
165931
  unsubscribeSession;
165680
165932
  backgroundTaskEvents = new BackgroundTaskEventStore();
165933
+ restoredNoticeSeen = /* @__PURE__ */ new Set();
165681
165934
  turnWork = new TurnWorkTracker();
165682
165935
  backgroundCoordinatorMessageIds = /* @__PURE__ */ new Set();
165683
165936
  workflowPanel;
@@ -165791,6 +166044,9 @@ var ZCodeTui = class {
165791
166044
  } catch (error) {
165792
166045
  notificationConfigError = error instanceof Error ? error.message : String(error);
165793
166046
  }
166047
+ try {
166048
+ this.setCopyOnSelect(await readCopyOnSelect());
166049
+ } catch {}
165794
166050
  try {
165795
166051
  const configEnv = { ...process.env };
165796
166052
  delete configEnv.ZCODE_TUI_MODE;
@@ -165870,6 +166126,14 @@ var ZCodeTui = class {
165870
166126
  if (colorScheme) this.theme.setColorScheme(colorScheme);
165871
166127
  } catch {}
165872
166128
  }
166129
+ /** The live fullscreen alt screen, when the active TUI is the fullscreen one. */
166130
+ get fullscreenAltScreen() {
166131
+ return this.ui instanceof ZCodeAltScreen ? this.ui : void 0;
166132
+ }
166133
+ setCopyOnSelect(enabled) {
166134
+ this.copyOnSelect = enabled;
166135
+ this.fullscreenAltScreen?.setCopyOnSelect(enabled);
166136
+ }
165873
166137
  createTui(mode) {
165874
166138
  let fullscreenTui;
165875
166139
  const terminal = new NotifyingProcessTerminal((data) => {
@@ -165888,6 +166152,7 @@ var ZCodeTui = class {
165888
166152
  return false;
165889
166153
  }
165890
166154
  },
166155
+ copyOnSelect: this.copyOnSelect,
165891
166156
  mouse: true,
165892
166157
  wheelScrollLines: 3
165893
166158
  });
@@ -166220,7 +166485,7 @@ var ZCodeTui = class {
166220
166485
  },
166221
166486
  {
166222
166487
  name: "copy",
166223
- description: "Copy the latest assistant response"
166488
+ description: "Copy the active fullscreen selection or latest assistant response"
166224
166489
  },
166225
166490
  {
166226
166491
  name: "paste-image",
@@ -166384,6 +166649,14 @@ var ZCodeTui = class {
166384
166649
  this.clearRewindEscape();
166385
166650
  return { consume: true };
166386
166651
  }
166652
+ if (this.transcript.searchStatus() || this.transcript.cursorStatus()) {
166653
+ this.clearRewindEscape();
166654
+ this.transcript.clearSearch();
166655
+ this.transcript.clearCursor();
166656
+ this.updateMetadata();
166657
+ this.ui.requestRender(true);
166658
+ return { consume: true };
166659
+ }
166387
166660
  if (this.turnAbortController) {
166388
166661
  this.clearRewindEscape();
166389
166662
  const pendingSteer = this.inputQueue.hasPendingSteers();
@@ -166395,14 +166668,6 @@ var ZCodeTui = class {
166395
166668
  else this.requestForegroundTurnInterrupt();
166396
166669
  return { consume: true };
166397
166670
  }
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
166671
  if (!this.editor.getText() && this.activeSubmissions === 0) {
166407
166672
  this.handleRewindEscape();
166408
166673
  return { consume: true };
@@ -166412,7 +166677,7 @@ var ZCodeTui = class {
166412
166677
  }
166413
166678
  async submit(rawInput, queuedSubmission) {
166414
166679
  const input = (queuedSubmission?.input ?? rawInput).trim();
166415
- if (!input || this.stopped) return;
166680
+ if (!input || this.stopped) return false;
166416
166681
  const submission = queuedSubmission ?? protectSubmission(input);
166417
166682
  if (submission.recordHistory) {
166418
166683
  this.rememberEditorHistory(input);
@@ -166437,7 +166702,7 @@ var ZCodeTui = class {
166437
166702
  return;
166438
166703
  }
166439
166704
  if (input === "/copy") {
166440
- await this.copyLastResponse();
166705
+ await this.copySelectionOrLastResponse();
166441
166706
  return;
166442
166707
  }
166443
166708
  if (input === "/paste-image") {
@@ -166525,7 +166790,7 @@ var ZCodeTui = class {
166525
166790
  ...submission,
166526
166791
  recordHistory: false
166527
166792
  });
166528
- return;
166793
+ return true;
166529
166794
  }
166530
166795
  if (!steering && this.backgroundTaskEvents.hasActiveHandoffs()) {
166531
166796
  this.inputQueue.queueFollowUp({
@@ -166533,7 +166798,7 @@ var ZCodeTui = class {
166533
166798
  recordHistory: false
166534
166799
  });
166535
166800
  this.interruptBackgroundHandoffForInput();
166536
- return;
166801
+ return true;
166537
166802
  }
166538
166803
  if (!steering && !input.startsWith("/") && !this.sessionTitleEmitted) {
166539
166804
  const sessionTitle = sessionTitleFromFirstMessage(submission.displayInput);
@@ -166549,7 +166814,7 @@ var ZCodeTui = class {
166549
166814
  ...submission,
166550
166815
  recordHistory: false
166551
166816
  });
166552
- return;
166817
+ return true;
166553
166818
  }
166554
166819
  const attachments = !steering && !input.startsWith("/") ? [...this.pendingAttachments] : [];
166555
166820
  if (steering && !this.options.sendInput) {
@@ -166557,7 +166822,7 @@ var ZCodeTui = class {
166557
166822
  ...submission,
166558
166823
  recordHistory: false
166559
166824
  });
166560
- return;
166825
+ return true;
166561
166826
  }
166562
166827
  if (attachments.length > 0) this.clearPendingAttachments(false);
166563
166828
  const abortController = new AbortController();
@@ -166566,6 +166831,7 @@ var ZCodeTui = class {
166566
166831
  const callOptions = {
166567
166832
  abortSignal: abortController.signal,
166568
166833
  delivery: steering ? "steer_active_turn" : "start_turn",
166834
+ queueDelivery: steering ? "guide" : void 0,
166569
166835
  expectedTurnId: steering ? this.activeTurnId : void 0,
166570
166836
  inputId,
166571
166837
  pendingInputReservationId: queuedSubmission?.pendingInputReservationId,
@@ -166597,7 +166863,7 @@ var ZCodeTui = class {
166597
166863
  this.activeSubmissions += 1;
166598
166864
  } else this.steerAbortControllers.add(abortController);
166599
166865
  if (!steering || submission.status) this.updateActivity(submission.status ?? "working…");
166600
- const notificationEligible = !steering && !input.startsWith("/");
166866
+ const notificationEligible = !steering && !input.startsWith("/") && queuedSubmission?.suppressCompletionNotification !== true;
166601
166867
  if (notificationEligible) this.pendingTurnNotification = "completed";
166602
166868
  let accepted = false;
166603
166869
  let unfinishedToolState = "interrupted";
@@ -166610,9 +166876,9 @@ var ZCodeTui = class {
166610
166876
  } else {
166611
166877
  const preparedInput = promptInput(runtimeInput, attachments);
166612
166878
  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;
166879
+ if (steering && this.activeTurnEpoch !== turnEpoch) return false;
166614
166880
  const disposition = await this.handleSendOutcome(outcome);
166615
- if (steering && this.activeTurnEpoch !== turnEpoch) return;
166881
+ if (steering && this.activeTurnEpoch !== turnEpoch) return false;
166616
166882
  if (steering && disposition.targetTurnId) this.activeTurnId = disposition.targetTurnId;
166617
166883
  if (pendingSteer && disposition.pendingInputId) this.inputQueue.associateSteer(pendingSteer.inputId, disposition.pendingInputId, disposition.targetTurnId);
166618
166884
  accepted = disposition.accepted;
@@ -166671,6 +166937,7 @@ var ZCodeTui = class {
166671
166937
  this.refreshSessionUsage();
166672
166938
  }
166673
166939
  if (nextCommand) await this.submit(nextCommand.input, nextCommand);
166940
+ return accepted;
166674
166941
  }
166675
166942
  finishPrimaryTurnSubmission(turnEpoch, abortController, unfinishedToolState) {
166676
166943
  this.activeSubmissions = Math.max(0, this.activeSubmissions - 1);
@@ -166740,6 +167007,7 @@ var ZCodeTui = class {
166740
167007
  this.pendingSteerInterrupt = void 0;
166741
167008
  this.foregroundTurnInterrupt = abortController;
166742
167009
  this.updateActivity("cancelling…");
167010
+ this.cancelActiveBackgroundAgentTasks();
166743
167011
  const interruptTurn = this.options.interruptTurn;
166744
167012
  if (!interruptTurn) {
166745
167013
  abortController.abort();
@@ -166752,6 +167020,51 @@ var ZCodeTui = class {
166752
167020
  if (this.turnAbortController === abortController && !abortController.signal.aborted) abortController.abort();
166753
167021
  });
166754
167022
  }
167023
+ /**
167024
+ * Backgrounded agents owned by the interrupted turn are detached from its
167025
+ * abort signal, so cancel those explicitly. Older agents and non-agent tasks
167026
+ * remain independent and continue running.
167027
+ */
167028
+ cancelActiveBackgroundAgentTasks() {
167029
+ const cancelBackgroundTask = this.options.cancelBackgroundTask;
167030
+ if (!cancelBackgroundTask) return;
167031
+ const jobs = this.runtimeProjection?.backgroundJobs ?? [];
167032
+ 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)));
167033
+ const activeIds = new Set(active.map((job) => job.taskId));
167034
+ const surviving = jobs.filter((job) => isActiveBackgroundJob(job) && !activeIds.has(job.taskId));
167035
+ if (active.length === 0 && surviving.length === 0) return;
167036
+ (async () => {
167037
+ const stopped = [];
167038
+ const failed = [];
167039
+ for (const job of active) try {
167040
+ const failure = backgroundCancellationFailure(await cancelBackgroundTask(job.taskId));
167041
+ if (failure) {
167042
+ failed.push({
167043
+ detail: failure,
167044
+ taskId: job.taskId
167045
+ });
167046
+ this.backgroundTaskEvents.recordSystemMessage(job.taskId, `Task was not cancelled: ${failure}.`, true);
167047
+ continue;
167048
+ }
167049
+ stopped.push(job.taskId);
167050
+ this.backgroundTaskEvents.recordSystemMessage(job.taskId, "Task cancelled by Esc interrupt.");
167051
+ } catch (error) {
167052
+ const detail = error instanceof Error ? error.message : String(error);
167053
+ failed.push({
167054
+ detail,
167055
+ taskId: job.taskId
167056
+ });
167057
+ this.backgroundTaskEvents.recordSystemMessage(job.taskId, detail, true);
167058
+ }
167059
+ if (stopped.length > 0) this.addNotice(`Esc also stopped background task${stopped.length > 1 ? "s" : ""}: ${stopped.join(", ")}.`, "muted");
167060
+ for (const failure of failed) this.addNotice(`Esc could not stop background task ${failure.taskId}: ${failure.detail}.`, "warning");
167061
+ if (surviving.length > 0) {
167062
+ const ids = surviving.map((job) => job.taskId).join(", ");
167063
+ this.addNotice(`Background task${surviving.length > 1 ? "s" : ""} ${ids} keep${surviving.length > 1 ? "" : "s"} running — /tasks stop <task-id> to stop.`, "muted");
167064
+ }
167065
+ if (active.length > 0) await this.refreshRuntimeState();
167066
+ })();
167067
+ }
166755
167068
  isPendingSteerInterrupt(turnEpoch, abortController) {
166756
167069
  const pending = this.pendingSteerInterrupt;
166757
167070
  return pending?.turnEpoch === turnEpoch && pending.abortController === abortController;
@@ -166863,25 +167176,18 @@ var ZCodeTui = class {
166863
167176
  this.completeThinking();
166864
167177
  this.assistantStream.breakSegment();
166865
167178
  }
166866
- if (event.kind === "text_start") {
167179
+ if (event.kind === "text_start") this.currentToolGroup = void 0;
167180
+ else if (event.kind === "text_delta" && event.delta) {
166867
167181
  this.currentToolGroup = void 0;
166868
- this.completeThinking();
166869
- this.assistantStream.breakSegment();
166870
- } else if (event.kind === "text_delta" && event.delta) {
166871
- 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") {
167182
+ this.recordAssistantText(this.assistantStream.append(event.delta, void 0, event.messageId));
167183
+ } else if (event.kind === "text_end") {} else if (event.kind === "reasoning_start") {
166876
167184
  this.currentToolGroup = void 0;
166877
- this.assistantStream.breakSegment();
166878
167185
  this.updateActivity("thinking…", false);
166879
167186
  } else if (event.kind === "reasoning_delta") {
166880
167187
  this.currentToolGroup = void 0;
166881
- this.assistantStream.breakSegment();
166882
167188
  this.updateActivity("thinking…", false);
166883
- if (event.delta && (this.currentThinking || event.delta.trim())) this.appendThinking(event.delta, event.partId, event.messageId);
166884
- } else if (event.kind === "reasoning_end") this.completeThinking(event.partId);
167189
+ if (event.delta && (this.currentThinking || event.delta.trim())) this.appendThinking(event.delta, void 0, event.messageId);
167190
+ } else if (event.kind === "reasoning_end") this.settleThinking();
166885
167191
  else if (event.kind === "tool_input_start") {
166886
167192
  const tool = this.ensureToolView(event.toolCallId, event.toolName, event.partId, event.messageId);
166887
167193
  tool.input = void 0;
@@ -167286,10 +167592,15 @@ var ZCodeTui = class {
167286
167592
  }
167287
167593
  this.currentThinking.append(delta);
167288
167594
  }
167289
- completeThinking(partId) {
167595
+ settleThinking(partId) {
167290
167596
  const thinking = partId ? this.thinkingParts.get(partId) : this.currentThinking;
167291
- if (!thinking) return;
167597
+ if (!thinking) return void 0;
167292
167598
  thinking.complete();
167599
+ return thinking;
167600
+ }
167601
+ completeThinking(partId) {
167602
+ const thinking = this.settleThinking(partId);
167603
+ if (!thinking) return;
167293
167604
  if (this.currentThinking === thinking) {
167294
167605
  this.currentThinking = void 0;
167295
167606
  this.currentThinkingPartId = void 0;
@@ -168376,6 +168687,11 @@ var ZCodeTui = class {
168376
168687
  value: "tui-mode",
168377
168688
  label: "Display mode",
168378
168689
  description: tuiModeOverride === "fullscreen" || tuiModeOverride === "regular" ? `Current: ${this.tuiMode === "fullscreen" ? "Fullscreen" : "Regular"} (environment override)` : `Current: ${this.tuiMode === "fullscreen" ? "Fullscreen" : "Regular"}`
168690
+ },
168691
+ {
168692
+ value: "copy-on-select",
168693
+ label: "Fullscreen copy on select",
168694
+ description: `Current: ${this.copyOnSelect ? "Enabled" : "Disabled"}`
168379
168695
  }
168380
168696
  ],
168381
168697
  selectedIndex: selectedSettingIndex
@@ -168418,6 +168734,42 @@ var ZCodeTui = class {
168418
168734
  selectedSettingIndex = 3;
168419
168735
  continue;
168420
168736
  }
168737
+ if (setting.value === "copy-on-select") {
168738
+ selectedSettingIndex = 4;
168739
+ const selected = await this.showChoice({
168740
+ title: "Fullscreen copy on select",
168741
+ prompt: "Only applies to fullscreen mode. Releasing a mouse selection copies it to the clipboard.",
168742
+ help: "Up/Down choose · Enter save · Esc back",
168743
+ items: [{
168744
+ value: "enabled",
168745
+ label: "Enabled",
168746
+ description: "Release copies the selection (default)"
168747
+ }, {
168748
+ value: "disabled",
168749
+ label: "Disabled",
168750
+ description: "Selection only highlights; copy manually via /copy or the terminal"
168751
+ }],
168752
+ selectedIndex: this.copyOnSelect ? 0 : 1
168753
+ });
168754
+ if (!selected) {
168755
+ feedback = "No changes · Esc closes settings";
168756
+ continue;
168757
+ }
168758
+ const next = selected.value === "enabled";
168759
+ if (next === this.copyOnSelect) {
168760
+ feedback = "Copy on select unchanged";
168761
+ continue;
168762
+ }
168763
+ try {
168764
+ await writeCopyOnSelect(next);
168765
+ this.setCopyOnSelect(next);
168766
+ feedback = `Copy on select ${next ? "enabled" : "disabled"} · saved`;
168767
+ } catch (error) {
168768
+ this.addNotice(error instanceof Error ? error.message : String(error), "error");
168769
+ feedback = "Could not save the setting · select it to retry";
168770
+ }
168771
+ continue;
168772
+ }
168421
168773
  selectedSettingIndex = setting.value === "notification-condition" ? 2 : setting.value === "notification-method" ? 1 : 0;
168422
168774
  let next = stored;
168423
168775
  let changedLabel;
@@ -169138,10 +169490,18 @@ var ZCodeTui = class {
169138
169490
  const canMessage = job.taskKind === "local_agent" && Boolean(this.options.sendBackgroundTaskMessage);
169139
169491
  const canStop = active && job.cancellable !== false && Boolean(this.options.cancelBackgroundTask);
169140
169492
  const items = [
169141
- ...canMessage ? [{
169493
+ ...canMessage ? active ? [{
169142
169494
  value: "message",
169143
- label: active ? "Message agent" : "Resume agent",
169144
- description: active ? "Send guidance to this task" : "Continue from the saved child session"
169495
+ label: "Message agent",
169496
+ description: "Send guidance to this task"
169497
+ }] : [{
169498
+ value: "resume",
169499
+ label: "Resume agent",
169500
+ description: "Continue from the saved child session"
169501
+ }, {
169502
+ value: "resume-with-instructions",
169503
+ label: "Resume with instructions",
169504
+ description: "Continue the saved child session with custom guidance"
169145
169505
  }] : [],
169146
169506
  ...canMessage && active ? [{
169147
169507
  value: "restart",
@@ -169193,11 +169553,16 @@ var ZCodeTui = class {
169193
169553
  await this.stopBackgroundTask(job.taskId);
169194
169554
  continue;
169195
169555
  }
169196
- if (action.value === "message" || action.value === "restart") {
169556
+ if (action.value === "resume" && !active) {
169557
+ await this.messageBackgroundTask(job, defaultBackgroundResumeMessage);
169558
+ continue;
169559
+ }
169560
+ if (action.value === "message" || action.value === "resume-with-instructions" || action.value === "restart") {
169197
169561
  const restart = action.value === "restart";
169562
+ const customResume = action.value === "resume-with-instructions";
169198
169563
  const message = await this.showTextPrompt({
169199
- title: restart ? "Restart background agent" : active ? "Message background agent" : "Resume background agent",
169200
- prompt: restart ? `Describe what ${job.agentId ?? job.taskId} should continue or repair after restart.` : active ? `Send guidance to ${job.agentId ?? job.taskId}.` : `Describe what ${job.agentId ?? job.taskId} should continue or repair.`
169564
+ title: restart ? "Restart background agent" : customResume ? "Resume background agent with instructions" : "Message background agent",
169565
+ 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
169566
  });
169202
169567
  if (message?.trim()) await this.messageBackgroundTask(job, message.trim(), restart);
169203
169568
  continue;
@@ -169303,7 +169668,7 @@ var ZCodeTui = class {
169303
169668
  this.addNotice(`No background task found with ID ${taskId}.`, "warning");
169304
169669
  return;
169305
169670
  }
169306
- const message = suppliedMessage || (resume ? "Continue the assigned task from the last completed step. Re-check the current workspace state and finish the remaining work." : "");
169671
+ const message = suppliedMessage || (resume ? defaultBackgroundResumeMessage : "");
169307
169672
  if (!message) {
169308
169673
  this.addNotice(`Usage: /tasks message ${taskId} <message>`, "muted");
169309
169674
  return;
@@ -169334,6 +169699,7 @@ var ZCodeTui = class {
169334
169699
  if (status === "failed") throw new Error(asString(record?.error) ?? detail);
169335
169700
  this.backgroundTaskEvents.recordSystemMessage(job.taskId, detail);
169336
169701
  this.addNotice(detail, "muted");
169702
+ await this.notifyTaskCoordinator(job, restart, message);
169337
169703
  await this.refreshRuntimeState();
169338
169704
  } catch (error) {
169339
169705
  const detail = error instanceof Error ? error.message : String(error);
@@ -169343,6 +169709,23 @@ var ZCodeTui = class {
169343
169709
  this.updateActivity(void 0);
169344
169710
  }
169345
169711
  }
169712
+ async notifyTaskCoordinator(job, restart, message) {
169713
+ const coordinatorNotice = taskCoordinatorNotice(job, restart, message);
169714
+ let failure;
169715
+ try {
169716
+ if (await this.submit(coordinatorNotice, {
169717
+ ...protectSubmission(coordinatorNotice),
169718
+ recordHistory: false,
169719
+ suppressCompletionNotification: true
169720
+ }) === true) return;
169721
+ failure = "the coordinator notice was not accepted";
169722
+ } catch (error) {
169723
+ failure = error instanceof Error ? error.message : String(error);
169724
+ }
169725
+ const detail = `Task action succeeded, but ${failure}.`;
169726
+ this.backgroundTaskEvents.recordSystemMessage(job.taskId, detail, true);
169727
+ this.addNotice(detail, "warning");
169728
+ }
169346
169729
  async stopBackgroundTask(taskId) {
169347
169730
  if (!taskId) {
169348
169731
  this.addNotice("Usage: /tasks stop <task-id>", "muted");
@@ -169398,7 +169781,12 @@ var ZCodeTui = class {
169398
169781
  this.ui.requestRender();
169399
169782
  }
169400
169783
  }
169401
- async copyLastResponse() {
169784
+ async copySelectionOrLastResponse() {
169785
+ const fullscreen = this.fullscreenAltScreen;
169786
+ if (fullscreen?.hasActiveSelection()) {
169787
+ await fullscreen.copyActiveSelectionToClipboard();
169788
+ return;
169789
+ }
169402
169790
  const text = this.transcript.selectedText() ?? this.lastAssistantText;
169403
169791
  if (!text) {
169404
169792
  this.addNotice("There is no assistant response to copy.", "muted");
@@ -169570,6 +169958,7 @@ var ZCodeTui = class {
169570
169958
  applyRuntimeProjection(projection) {
169571
169959
  if (!projection) return;
169572
169960
  this.runtimeProjection = projection;
169961
+ this.noticeRestoredBackgroundTasks(projection);
169573
169962
  this.reconcileTurnTiming(projection);
169574
169963
  if (projection.sessionId) this.sessionId = projection.sessionId;
169575
169964
  this.sessionMetrics = mergeProjectionMetrics(this.sessionMetrics, {
@@ -169580,6 +169969,35 @@ var ZCodeTui = class {
169580
169969
  }, Boolean(this.options.readSessionUsage));
169581
169970
  this.updateRuntimeActivity(false);
169582
169971
  }
169972
+ /**
169973
+ * Surface tasks the persisted background-agent restore bridge re-registered.
169974
+ * Tasks that completed or failed while ZCode was closed never produce a
169975
+ * completion notification, so without this notice they are silent — the
169976
+ * model-facing task_status attachment alone does not reach the user.
169977
+ */
169978
+ noticeRestoredBackgroundTasks(projection) {
169979
+ for (const job of projection.restoredBackgroundTasks ?? []) {
169980
+ const seenKey = `${projection.sessionId ?? ""}/${job.taskId}`;
169981
+ if (this.restoredNoticeSeen.has(seenKey)) continue;
169982
+ this.restoredNoticeSeen.add(seenKey);
169983
+ const label = job.description ? `${job.taskId} (${job.description})` : job.taskId;
169984
+ if (job.status === "completed") this.addSystemEvent({
169985
+ tone: "muted",
169986
+ title: "Background task completed while ZCode was closed",
169987
+ detail: `${label} finished before this session was resumed. Collect its result with TaskOutput or open /tasks.`
169988
+ });
169989
+ else if (job.status === "failed") this.addSystemEvent({
169990
+ tone: "error",
169991
+ title: "Background task failed while ZCode was closed",
169992
+ detail: `${label} failed before this session was resumed. Resume it from /tasks to continue.`
169993
+ });
169994
+ else this.addSystemEvent({
169995
+ tone: "warning",
169996
+ title: "Background task restored from this session",
169997
+ detail: `${label} was interrupted before ZCode closed. Resume it from /tasks when needed.`
169998
+ });
169999
+ }
170000
+ }
169583
170001
  updateRuntimeActivity(requestRender = true) {
169584
170002
  this.runtimeActivity.update({
169585
170003
  projection: this.runtimeProjection,