@linxiraos/pi-tui 1.4.6 → 1.4.7

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.
Files changed (278) hide show
  1. package/CHANGELOG.md +194 -195
  2. package/README.md +34 -34
  3. package/dist/types/app-keybindings.d.ts +15 -0
  4. package/dist/types/apps/session-picker.d.ts +5 -0
  5. package/dist/types/charts/chart-plan.d.ts +9 -7
  6. package/dist/types/chat/assistant-message.d.ts +15 -3
  7. package/dist/types/chat/bash-execution.d.ts +2 -0
  8. package/dist/types/chat/display-preferences.d.ts +2 -0
  9. package/dist/types/chat/extension-types.d.ts +31 -0
  10. package/dist/types/chat/reply-write.d.ts +48 -0
  11. package/dist/types/chat/table-chart.d.ts +4 -3
  12. package/dist/types/chat/tool-execution.d.ts +1 -2
  13. package/dist/types/chat/transcript-outline.d.ts +7 -0
  14. package/dist/types/chat/transcript-render-helpers.d.ts +2 -0
  15. package/dist/types/chrome/index.d.ts +1 -0
  16. package/dist/types/chrome/transcript-notice.d.ts +35 -0
  17. package/dist/types/chrome/transcript-status.d.ts +20 -8
  18. package/dist/types/components/editor.d.ts +8 -0
  19. package/dist/types/components/markdown.d.ts +7 -0
  20. package/dist/types/native/blobs.d.ts +2 -1
  21. package/dist/types/native/picker.d.ts +4 -4
  22. package/dist/types/overlays/annotation-overlay.d.ts +7 -1
  23. package/dist/types/overlays/annotation-types.d.ts +28 -0
  24. package/dist/types/overlays/login-dialog.d.ts +5 -1
  25. package/dist/types/overlays/model-browser.d.ts +10 -1
  26. package/dist/types/overlays/oauth-selector.d.ts +23 -0
  27. package/dist/types/overlays/plan-review-overlay.d.ts +2 -0
  28. package/dist/types/overlays/rewind-selector.d.ts +1 -1
  29. package/dist/types/overlays/session-selector.d.ts +22 -2
  30. package/dist/types/prompt/composer.d.ts +43 -0
  31. package/dist/types/prompt/interactive-context-helpers.d.ts +10 -3
  32. package/dist/types/render/extension-links.d.ts +65 -0
  33. package/dist/types/render/hyperlink.d.ts +25 -7
  34. package/dist/types/render/index.d.ts +1 -0
  35. package/dist/types/setup/scenes/glyph.d.ts +1 -1
  36. package/dist/types/setup/scenes/model.d.ts +1 -1
  37. package/dist/types/setup/scenes/outro.d.ts +5 -4
  38. package/dist/types/setup/scenes/sign-in.d.ts +13 -8
  39. package/dist/types/setup/scenes/types.d.ts +16 -1
  40. package/dist/types/setup/startup-splash.d.ts +1 -1
  41. package/dist/types/setup/wizard-overlay.d.ts +11 -7
  42. package/dist/types/setup/wizard.d.ts +5 -1
  43. package/dist/types/status-line/component.d.ts +1 -1
  44. package/dist/types/status-line/context-usage.d.ts +28 -6
  45. package/dist/types/status-line/host.d.ts +6 -2
  46. package/dist/types/theme/theme.d.ts +0 -23
  47. package/dist/types/tools/bash-interactive.d.ts +6 -0
  48. package/dist/types/tools/bash.d.ts +2 -0
  49. package/dist/types/tools/default-renderer.d.ts +6 -4
  50. package/dist/types/tools/irc.d.ts +6 -0
  51. package/dist/types/tools/json-tree.d.ts +23 -4
  52. package/dist/types/tools/lsp.d.ts +2 -0
  53. package/dist/types/tools/mcp.d.ts +6 -5
  54. package/dist/types/tools/native-view.d.ts +1 -1
  55. package/dist/types/tools/renderer.d.ts +2 -0
  56. package/dist/types/tools/streaming-output.d.ts +11 -0
  57. package/dist/types/tools/task.d.ts +9 -1
  58. package/dist/types/tools/url-scheme-host.d.ts +17 -0
  59. package/dist/types/tools/yield.d.ts +1 -1
  60. package/dist/types/tui.d.ts +7 -2
  61. package/package.json +10 -14
  62. package/src/app-keybindings.d.ts +15 -0
  63. package/src/app-keybindings.ts +15 -0
  64. package/src/apps/session-picker.ts +7 -0
  65. package/src/charts/chart-plan.d.ts +9 -7
  66. package/src/charts/chart-plan.ts +20 -50
  67. package/src/chat/advisor-message.ts +2 -0
  68. package/src/chat/assistant-message.d.ts +15 -3
  69. package/src/chat/assistant-message.ts +137 -19
  70. package/src/chat/background-tan-message.ts +4 -0
  71. package/src/chat/bash-execution.d.ts +2 -0
  72. package/src/chat/bash-execution.ts +6 -0
  73. package/src/chat/chat-transcript-builder.ts +58 -28
  74. package/src/chat/compaction-summary-message.ts +2 -1
  75. package/src/chat/display-preferences.d.ts +2 -0
  76. package/src/chat/display-preferences.ts +3 -0
  77. package/src/chat/extension-types.d.ts +31 -0
  78. package/src/chat/extension-types.ts +34 -0
  79. package/src/chat/reply-write.d.ts +48 -0
  80. package/src/chat/reply-write.ts +127 -0
  81. package/src/chat/table-chart.d.ts +4 -3
  82. package/src/chat/table-chart.ts +10 -4
  83. package/src/chat/tool-execution.d.ts +1 -2
  84. package/src/chat/tool-execution.ts +20 -13
  85. package/src/chat/transcript-outline.d.ts +7 -0
  86. package/src/chat/transcript-outline.ts +27 -0
  87. package/src/chat/transcript-render-helpers.d.ts +2 -0
  88. package/src/chat/transcript-render-helpers.ts +66 -24
  89. package/src/chrome/index.ts +1 -0
  90. package/src/chrome/transcript-notice.d.ts +35 -0
  91. package/src/chrome/transcript-notice.ts +83 -0
  92. package/src/chrome/transcript-status.d.ts +20 -8
  93. package/src/chrome/transcript-status.ts +29 -29
  94. package/src/components/editor.d.ts +8 -0
  95. package/src/components/editor.ts +10 -1
  96. package/src/components/markdown.d.ts +7 -0
  97. package/src/components/markdown.ts +116 -6
  98. package/src/hotkeys-markdown.ts +1 -0
  99. package/src/native/backend.ts +5 -66
  100. package/src/native/blobs.d.ts +2 -1
  101. package/src/native/blobs.ts +3 -2
  102. package/src/native/picker.d.ts +4 -4
  103. package/src/native/picker.ts +4 -4
  104. package/src/overlays/advisor-config.ts +1 -10
  105. package/src/overlays/annotation-overlay.ts +125 -37
  106. package/src/overlays/annotation-types.ts +24 -0
  107. package/src/overlays/hook-selector.ts +2 -2
  108. package/src/overlays/login-dialog.ts +31 -5
  109. package/src/overlays/mcp-add-wizard.ts +1 -1
  110. package/src/overlays/model-browser.ts +37 -0
  111. package/src/overlays/model-hub.ts +1 -7
  112. package/src/overlays/model-picker.ts +1 -10
  113. package/src/overlays/oauth-selector.ts +44 -6
  114. package/src/overlays/plan-review-overlay.ts +13 -2
  115. package/src/overlays/rewind-selector.ts +29 -12
  116. package/src/overlays/session-selector.ts +313 -42
  117. package/src/overlays/usage-dashboard.ts +5 -12
  118. package/src/prompt/composer.ts +216 -1
  119. package/src/prompt/custom-editor.ts +6 -1
  120. package/src/prompt/emoji-autocomplete.ts +0 -2
  121. package/src/prompt/interactive-context-helpers.ts +29 -4
  122. package/src/render/extension-links.d.ts +65 -0
  123. package/src/render/extension-links.ts +214 -0
  124. package/src/render/hyperlink.d.ts +25 -7
  125. package/src/render/hyperlink.ts +65 -9
  126. package/src/render/index.d.ts +1 -0
  127. package/src/render/index.ts +1 -0
  128. package/src/setup/scenes/composer.ts +2 -0
  129. package/src/setup/scenes/glyph.ts +3 -1
  130. package/src/setup/scenes/model.ts +192 -29
  131. package/src/setup/scenes/outro.ts +33 -15
  132. package/src/setup/scenes/sign-in.ts +196 -400
  133. package/src/setup/scenes/theme.ts +2 -0
  134. package/src/setup/scenes/types.ts +18 -1
  135. package/src/setup/startup-splash.ts +8 -7
  136. package/src/setup/wizard-overlay.ts +164 -35
  137. package/src/setup/wizard.ts +11 -2
  138. package/src/status-line/component.ts +4 -10
  139. package/src/status-line/context-usage.ts +72 -21
  140. package/src/status-line/host.ts +6 -2
  141. package/src/terminal.ts +24 -2
  142. package/src/theme/defaults.json +1 -0
  143. package/src/theme/loader.ts +1 -1
  144. package/src/theme/theme.d.ts +0 -23
  145. package/src/theme/theme.ts +2 -75
  146. package/src/tools/bash-interactive.d.ts +49 -0
  147. package/src/tools/bash-interactive.ts +6 -1
  148. package/src/tools/bash.d.ts +2 -0
  149. package/src/tools/bash.ts +2 -0
  150. package/src/tools/default-renderer.d.ts +6 -4
  151. package/src/tools/default-renderer.ts +9 -6
  152. package/src/tools/eval.ts +14 -4
  153. package/src/tools/irc.d.ts +6 -0
  154. package/src/tools/irc.ts +6 -0
  155. package/src/tools/job-widget.ts +13 -1
  156. package/src/tools/json-tree.d.ts +23 -4
  157. package/src/tools/json-tree.ts +132 -42
  158. package/src/tools/lsp.d.ts +2 -0
  159. package/src/tools/lsp.ts +36 -15
  160. package/src/tools/mcp.d.ts +6 -5
  161. package/src/tools/mcp.ts +20 -12
  162. package/src/tools/native-view.d.ts +1 -1
  163. package/src/tools/native-view.ts +1 -1
  164. package/src/tools/renderer.d.ts +2 -0
  165. package/src/tools/renderer.ts +2 -0
  166. package/src/tools/streaming-output.d.ts +11 -0
  167. package/src/tools/streaming-output.ts +41 -0
  168. package/src/tools/task.d.ts +9 -1
  169. package/src/tools/task.ts +59 -16
  170. package/src/tools/url-scheme-host.d.ts +17 -0
  171. package/src/tools/url-scheme-host.ts +21 -0
  172. package/src/tools/yield.d.ts +1 -1
  173. package/src/tools/yield.ts +18 -9
  174. package/src/tui.d.ts +7 -2
  175. package/src/tui.ts +43 -15
  176. package/dist/types/theme/defaults/index.d.ts +0 -10289
  177. package/src/theme/defaults/alabaster.json +0 -103
  178. package/src/theme/defaults/amethyst.json +0 -106
  179. package/src/theme/defaults/anthracite.json +0 -103
  180. package/src/theme/defaults/basalt.json +0 -101
  181. package/src/theme/defaults/birch.json +0 -105
  182. package/src/theme/defaults/dark-abyss.json +0 -101
  183. package/src/theme/defaults/dark-arctic.json +0 -114
  184. package/src/theme/defaults/dark-aurora.json +0 -105
  185. package/src/theme/defaults/dark-catppuccin.json +0 -117
  186. package/src/theme/defaults/dark-cavern.json +0 -101
  187. package/src/theme/defaults/dark-celestial.json +0 -116
  188. package/src/theme/defaults/dark-copper.json +0 -105
  189. package/src/theme/defaults/dark-cosmos.json +0 -100
  190. package/src/theme/defaults/dark-cyberpunk.json +0 -112
  191. package/src/theme/defaults/dark-dracula.json +0 -108
  192. package/src/theme/defaults/dark-eclipse.json +0 -101
  193. package/src/theme/defaults/dark-ember.json +0 -105
  194. package/src/theme/defaults/dark-equinox.json +0 -100
  195. package/src/theme/defaults/dark-forest.json +0 -106
  196. package/src/theme/defaults/dark-github.json +0 -115
  197. package/src/theme/defaults/dark-gruvbox.json +0 -122
  198. package/src/theme/defaults/dark-lavender.json +0 -105
  199. package/src/theme/defaults/dark-lunar.json +0 -99
  200. package/src/theme/defaults/dark-midnight.json +0 -105
  201. package/src/theme/defaults/dark-monochrome.json +0 -104
  202. package/src/theme/defaults/dark-monokai.json +0 -108
  203. package/src/theme/defaults/dark-nebula.json +0 -100
  204. package/src/theme/defaults/dark-neon-noir.json +0 -110
  205. package/src/theme/defaults/dark-nord.json +0 -108
  206. package/src/theme/defaults/dark-ocean.json +0 -111
  207. package/src/theme/defaults/dark-one.json +0 -110
  208. package/src/theme/defaults/dark-poimandres.json +0 -125
  209. package/src/theme/defaults/dark-rainforest.json +0 -101
  210. package/src/theme/defaults/dark-reef.json +0 -101
  211. package/src/theme/defaults/dark-retro.json +0 -102
  212. package/src/theme/defaults/dark-rose-pine.json +0 -106
  213. package/src/theme/defaults/dark-sakura.json +0 -105
  214. package/src/theme/defaults/dark-slate.json +0 -105
  215. package/src/theme/defaults/dark-solarized.json +0 -107
  216. package/src/theme/defaults/dark-solstice.json +0 -100
  217. package/src/theme/defaults/dark-starfall.json +0 -101
  218. package/src/theme/defaults/dark-sunset.json +0 -109
  219. package/src/theme/defaults/dark-swamp.json +0 -100
  220. package/src/theme/defaults/dark-synthwave.json +0 -113
  221. package/src/theme/defaults/dark-taiga.json +0 -101
  222. package/src/theme/defaults/dark-terminal.json +0 -105
  223. package/src/theme/defaults/dark-tokyo-night.json +0 -111
  224. package/src/theme/defaults/dark-tundra.json +0 -101
  225. package/src/theme/defaults/dark-twilight.json +0 -101
  226. package/src/theme/defaults/dark-volcanic.json +0 -101
  227. package/src/theme/defaults/graphite.json +0 -102
  228. package/src/theme/defaults/index.d.ts +0 -10289
  229. package/src/theme/defaults/index.ts +0 -203
  230. package/src/theme/defaults/light-arctic.json +0 -117
  231. package/src/theme/defaults/light-aurora-day.json +0 -101
  232. package/src/theme/defaults/light-canyon.json +0 -101
  233. package/src/theme/defaults/light-catppuccin.json +0 -116
  234. package/src/theme/defaults/light-cirrus.json +0 -100
  235. package/src/theme/defaults/light-coral.json +0 -105
  236. package/src/theme/defaults/light-cyberpunk.json +0 -106
  237. package/src/theme/defaults/light-dawn.json +0 -100
  238. package/src/theme/defaults/light-dunes.json +0 -101
  239. package/src/theme/defaults/light-eucalyptus.json +0 -105
  240. package/src/theme/defaults/light-forest.json +0 -110
  241. package/src/theme/defaults/light-frost.json +0 -105
  242. package/src/theme/defaults/light-github.json +0 -125
  243. package/src/theme/defaults/light-glacier.json +0 -101
  244. package/src/theme/defaults/light-gruvbox.json +0 -118
  245. package/src/theme/defaults/light-haze.json +0 -100
  246. package/src/theme/defaults/light-honeycomb.json +0 -105
  247. package/src/theme/defaults/light-lagoon.json +0 -101
  248. package/src/theme/defaults/light-lavender.json +0 -105
  249. package/src/theme/defaults/light-meadow.json +0 -101
  250. package/src/theme/defaults/light-mint.json +0 -105
  251. package/src/theme/defaults/light-monochrome.json +0 -111
  252. package/src/theme/defaults/light-ocean.json +0 -109
  253. package/src/theme/defaults/light-one.json +0 -109
  254. package/src/theme/defaults/light-opal.json +0 -101
  255. package/src/theme/defaults/light-orchard.json +0 -101
  256. package/src/theme/defaults/light-paper.json +0 -105
  257. package/src/theme/defaults/light-poimandres.json +0 -125
  258. package/src/theme/defaults/light-prism.json +0 -100
  259. package/src/theme/defaults/light-retro.json +0 -108
  260. package/src/theme/defaults/light-sand.json +0 -105
  261. package/src/theme/defaults/light-savanna.json +0 -101
  262. package/src/theme/defaults/light-solarized.json +0 -112
  263. package/src/theme/defaults/light-soleil.json +0 -100
  264. package/src/theme/defaults/light-sunset.json +0 -109
  265. package/src/theme/defaults/light-synthwave.json +0 -108
  266. package/src/theme/defaults/light-tokyo-night.json +0 -121
  267. package/src/theme/defaults/light-wetland.json +0 -101
  268. package/src/theme/defaults/light-zenith.json +0 -99
  269. package/src/theme/defaults/limestone.json +0 -104
  270. package/src/theme/defaults/mahogany.json +0 -107
  271. package/src/theme/defaults/marble.json +0 -103
  272. package/src/theme/defaults/obsidian.json +0 -101
  273. package/src/theme/defaults/onyx.json +0 -101
  274. package/src/theme/defaults/pearl.json +0 -103
  275. package/src/theme/defaults/porcelain.json +0 -101
  276. package/src/theme/defaults/quartz.json +0 -106
  277. package/src/theme/defaults/sandstone.json +0 -105
  278. package/src/theme/defaults/titanium.json +0 -100
@@ -323,6 +323,47 @@ export function truncateLineBytes(
323
323
  return { text: materializeString(`${head}…`), wasTruncated: true };
324
324
  }
325
325
 
326
+ /** Leading characters of a text's first line {@link findColumnCapped} searches for. */
327
+ const CAPPED_PROBE_CHARS = 16;
328
+
329
+ /**
330
+ * Where `text` shows in `output` written through an {@link OutputSink} with
331
+ * `maxColumns`, searching from `from`: each of its lines whole, or, where the
332
+ * cap cut the output line, a head of it and `…` ending that output line.
333
+ * Only the first line can be cut short of its first 16 characters (after
334
+ * other text on its output line); such text is not found.
335
+ */
336
+ export function findColumnCapped(output: string, text: string, from = 0): { start: number; end: number } | undefined {
337
+ if (!text) return undefined;
338
+ const lines = text.split(NL);
339
+ const probe = lines[0] ? lines[0].slice(0, CAPPED_PROBE_CHARS) : NL;
340
+ for (let at = output.indexOf(probe, from); at !== -1; at = output.indexOf(probe, at + 1)) {
341
+ const end = cappedLinesEnd(output, at, lines);
342
+ if (end !== undefined) return { start: at, end };
343
+ }
344
+ return undefined;
345
+ }
346
+
347
+ /** End of `lines` shown in column-capped `output` from `at`, if they show there. */
348
+ function cappedLinesEnd(output: string, at: number, lines: readonly string[]): number | undefined {
349
+ let pos = at;
350
+ for (let i = 0; i < lines.length; i++) {
351
+ const line = lines[i];
352
+ const last = i === lines.length - 1;
353
+ if (output.startsWith(line, pos) && (last || output[pos + line.length] === NL)) {
354
+ pos += last ? line.length : line.length + 1;
355
+ continue;
356
+ }
357
+ let eol = output.indexOf(NL, pos);
358
+ if (eol === -1) eol = output.length;
359
+ if (eol === pos || output[eol - 1] !== ELLIPSIS || !line.startsWith(output.slice(pos, eol - 1))) return undefined;
360
+ if (last) return eol;
361
+ if (eol === output.length) return undefined;
362
+ pos = eol + 1;
363
+ }
364
+ return pos;
365
+ }
366
+
326
367
  // =============================================================================
327
368
  // Content truncation (line + byte aware, no full Buffer allocation)
328
369
  // =============================================================================
@@ -105,8 +105,9 @@ export interface TaskItem {
105
105
  sourceSession?: string;
106
106
  /** Optional model selector override for the historical source session. */
107
107
  model?: string | string[];
108
- /** The work; required by the schema. */
108
+ /** Inline instructions; exactly one of task or taskFile is required. */
109
109
  task?: string;
110
+ taskFile?: string;
110
111
  /** How open-ended the work is; required by the schema and the child's sole `auto` thinking classification input. */
111
112
  solutionSpace?: string;
112
113
  /** Per-spawn thinking effort: lowest/middle/highest level the resolved model supports. Overrides the agent's default selector (e.g. `auto`). */
@@ -137,6 +138,8 @@ export interface TaskParams {
137
138
  model?: string | string[];
138
139
  /** The work (flat form). */
139
140
  task?: string;
141
+ /** Absolute path or local:// URL to a UTF-8 file (flat form), mutually exclusive with task. */
142
+ taskFile?: string;
140
143
  /** How open-ended the work is (flat form); see {@link TaskItem.solutionSpace}. */
141
144
  solutionSpace?: string;
142
145
  /** Per-spawn thinking effort (flat form): lowest/middle/highest level the resolved model supports. */
@@ -212,6 +215,9 @@ export interface AgentProgress {
212
215
  status: "pending" | "running" | "completed" | "failed" | "aborted";
213
216
  task: string;
214
217
  assignment?: string;
218
+ taskFile?: string;
219
+ /** SHA-256 of the exact task file bytes before decoding and trimming. */
220
+ taskFileSha256?: string;
215
221
  description?: string;
216
222
  lastIntent?: string;
217
223
  currentTool?: string;
@@ -319,6 +325,8 @@ export interface SingleResult {
319
325
  agentSource: AgentSource;
320
326
  task: string;
321
327
  assignment?: string;
328
+ taskFile?: string;
329
+ taskFileSha256?: string;
322
330
  description?: string;
323
331
  lastIntent?: string;
324
332
  exitCode: number;
package/src/tools/task.ts CHANGED
@@ -46,12 +46,13 @@ import { formatOutputInline, renderJsonTreeLines, describeJsonTree } from "./jso
46
46
  import { repairDoubleEncodedJsonString } from "./task-repair-args";
47
47
  import { getSubprocessToolRenderer } from "./subprocess";
48
48
  import { assembleYieldResult, type YieldSectionShapes } from "./task-yield-assembly";
49
- import type { TspAgentProps, TspTone } from "@linxiraos/pi-wire";
50
- import { compact, kv, md, node, span, text } from "../native/describe";
49
+ import type { TspAgentProps, TspProps, TspTone } from "@linxiraos/pi-wire";
50
+ import { compact, kv, md, node, propNode, span, text } from "../native/describe";
51
51
  import type { NativeNode } from "../native/node";
52
52
  import { OwnerMemo, sameItems } from "../native/memo";
53
53
  import { plainText } from "../native/spans";
54
54
  import { errorText, noteText, resultText } from "./native-view";
55
+ import { describeJsonValue } from "./json-tree";
55
56
  import { taskSummary } from "../overlays/agent-hub-renderer";
56
57
 
57
58
  /** Render context threaded in from `ToolExecutionComponent.#buildRenderContext`. */
@@ -479,6 +480,12 @@ function renderTaskSection(
479
480
  return lines;
480
481
  }
481
482
 
483
+ function taskPreviewText(task: unknown, taskFile: unknown): string {
484
+ if (typeof task === "string") return task;
485
+ if (typeof taskFile !== "string") return "";
486
+ return flattenLine(replaceTabs(shortenPath(sanitizeText(taskFile))));
487
+ }
488
+
482
489
  /**
483
490
  * First line of a streamed `task` brief, trimmed — a row's secondary text.
484
491
  * The args stream in token by token, so non-string values fall through to "".
@@ -519,7 +526,7 @@ function renderTaskCallLines(args: Partial<TaskParams> | undefined, theme: Theme
519
526
 
520
527
  const rawName = typeof args.name === "string" ? args.name.trim() : "";
521
528
  const idLabel = rawName ? formatTaskId(rawName) : "";
522
- const brief = taskFirstLine(args.task);
529
+ const brief = taskFirstLine(taskPreviewText(args.task, args.taskFile));
523
530
  if (idLabel || brief) {
524
531
  let line = `${bullet} ${theme.fg("accent", theme.bold(idLabel || "agent"))}`;
525
532
  if (brief) {
@@ -555,7 +562,7 @@ function renderTaskItemLines(tasks: TaskItem[] | undefined, theme: Theme): strin
555
562
  const rawName = typeof item?.name === "string" ? item.name.trim() : "";
556
563
  const idLabel = rawName ? formatTaskId(rawName) : `#${i + 1}`;
557
564
  let line = `${bullet} ${theme.fg("accent", theme.bold(idLabel))}`;
558
- const brief = taskFirstLine(item?.task);
565
+ const brief = taskFirstLine(taskPreviewText(item?.task, item?.taskFile));
559
566
  if (brief) {
560
567
  line += `: ${theme.fg("muted", previewLine(brief, 64))}`;
561
568
  }
@@ -1797,7 +1804,7 @@ function describeContext(raw: unknown): NativeNode | undefined {
1797
1804
  return line ? text([span(line, "muted")], { wrap: "word", lines: 2, role: "zeta.tool.context" }) : undefined;
1798
1805
  }
1799
1806
 
1800
- /** The full assignment, markdown, as the first expanded child of an agent. */
1807
+ /** The full assignment, markdown: an agent's first expanded child and its row's hover card. */
1801
1808
  function describeAssignment(raw: string | undefined): NativeNode | undefined {
1802
1809
  const source = raw ? sanitizeText(repairDoubleEncodedJsonString(raw)).trim() : "";
1803
1810
  return source ? md(source, { role: "zeta.task.assignment" }) : undefined;
@@ -1829,6 +1836,8 @@ interface AgentDescribeState {
1829
1836
  readonly nowMs: number;
1830
1837
  readonly expanded: boolean;
1831
1838
  readonly background: boolean;
1839
+ /** The host draws the `json` kind. */
1840
+ readonly json: boolean;
1832
1841
  }
1833
1842
 
1834
1843
  /** Settled and in-flight child snapshots a subagent carries, as nested agent nodes. */
@@ -1858,8 +1867,26 @@ function describeNestedTasks(
1858
1867
  return out;
1859
1868
  }
1860
1869
 
1861
- function agentNode(p: TspAgentProps, children: readonly (NativeNode | undefined)[], key: string): NativeNode {
1862
- return node("agent", p, compact(children), key);
1870
+ /** Earliest start seen per running subagent (`nowMs - durationMs`), so a snapshot with a stale or zero `durationMs` can't restart its timer. */
1871
+ const runStartMs = new Map<string, number>();
1872
+
1873
+ function runningAge(progress: { id: string; durationMs: number }, nowMs: number): number {
1874
+ const start = nowMs - Math.max(0, progress.durationMs);
1875
+ const known = runStartMs.get(progress.id);
1876
+ const anchor = known === undefined ? start : Math.min(known, start);
1877
+ runStartMs.set(progress.id, anchor);
1878
+ return Math.max(0, nowMs - anchor);
1879
+ }
1880
+
1881
+ /** An `agent` node; its row's hover card shows the whole `assignment` the row only summarizes. */
1882
+ function agentNode(
1883
+ p: TspAgentProps,
1884
+ assignment: NativeNode | undefined,
1885
+ children: readonly (NativeNode | undefined)[],
1886
+ key: string,
1887
+ ): NativeNode {
1888
+ const props: TspProps<"agent"> = assignment ? { ...p, hovercard: propNode(assignment) } : p;
1889
+ return node("agent", props, compact(children), key);
1863
1890
  }
1864
1891
 
1865
1892
  function describeProgressAgent(progress: AgentProgress, state: AgentDescribeState, depth: number): NativeNode {
@@ -1881,6 +1908,7 @@ function describeProgressAgent(progress: AgentProgress, state: AgentDescribeStat
1881
1908
  const summary = taskSummary(progress.description || progress.assignment || progress.task);
1882
1909
  // The agent's own stage line (from its completion probe) rides beside the task while it runs.
1883
1910
  const stage = running && progress.stage ? plainText(progress.stage) : "";
1911
+ const assignment = describeAssignment(progress.assignment ?? progress.task);
1884
1912
  const retry =
1885
1913
  running && progress.retryState
1886
1914
  ? {
@@ -1907,7 +1935,7 @@ function describeProgressAgent(progress: AgentProgress, state: AgentDescribeStat
1907
1935
  ...contextStats(progress.contextTokens, progress.contextWindow),
1908
1936
  done: running && progress.completionPercent !== undefined ? progress.completionPercent / 100 : undefined,
1909
1937
  cost: progress.cost > 0 ? progress.cost : undefined,
1910
- ...(running ? { age: progress.durationMs } : { took: progress.durationMs }),
1938
+ ...(running ? { age: runningAge(progress, nowMs) } : { took: progress.durationMs }),
1911
1939
  },
1912
1940
  retry,
1913
1941
  badges: agentBadges(state.background, undefined),
@@ -1915,8 +1943,9 @@ function describeProgressAgent(progress: AgentProgress, state: AgentDescribeStat
1915
1943
  collapsible: true,
1916
1944
  collapsed: !state.expanded,
1917
1945
  },
1946
+ assignment,
1918
1947
  [
1919
- describeAssignment(progress.assignment ?? progress.task),
1948
+ assignment,
1920
1949
  progress.resolvedModelRoute ? noteText(progress.resolvedModelRoute, "dim") : undefined,
1921
1950
  !running && progress.retryFailure
1922
1951
  ? text(
@@ -1950,6 +1979,7 @@ function describeResultAgent(result: SingleResult, state: AgentDescribeState, de
1950
1979
  else if (warning && success) badges.push({ text: "warning", tone: "warning" });
1951
1980
  if (result.truncated) badges.push({ text: "truncated", tone: "warning" });
1952
1981
  const cost = result.usage?.cost.total ?? 0;
1982
+ const assignment = describeAssignment(result.assignment ?? result.task);
1953
1983
  return agentNode(
1954
1984
  {
1955
1985
  name: formatTaskId(result.id),
@@ -1972,15 +2002,17 @@ function describeResultAgent(result: SingleResult, state: AgentDescribeState, de
1972
2002
  collapsible: true,
1973
2003
  collapsed: !state.expanded,
1974
2004
  },
2005
+ assignment,
1975
2006
  [
1976
- describeAssignment(result.assignment ?? result.task),
2007
+ assignment,
1977
2008
  result.resolvedModelRoute ? noteText(result.resolvedModelRoute, "dim") : undefined,
1978
2009
  aborted && result.abortReason ? errorLine(result.abortReason) : undefined,
1979
2010
  warning ? errorLine(warning, "warning") : undefined,
1980
2011
  result.error ? errorLine(result.error) : undefined,
1981
2012
  result.retryFailure ? errorLine(`auto-retry gave up: ${result.retryFailure.errorMessage}`) : undefined,
2013
+ // The structured result is the agent's answer: its containers open one level, as in the fallback tree.
1982
2014
  structured !== undefined
1983
- ? describeJsonTree(structured)
2015
+ ? describeJsonValue(structured, { native: state.json, open: 1 })
1984
2016
  : output
1985
2017
  ? md(output, { role: "zeta.task.output" })
1986
2018
  : undefined,
@@ -2026,16 +2058,18 @@ function describeTaskCall(args: TaskParams | undefined): NativeToolView {
2026
2058
  status: "pending",
2027
2059
  badges: agentBadges(false, isolated === true),
2028
2060
  },
2061
+ describeAssignment(typeof brief === "string" ? brief : undefined),
2029
2062
  [],
2030
2063
  key,
2031
2064
  );
2032
2065
  const flatName = typeof args?.name === "string" ? args.name.trim() : "";
2033
- if (flatName || taskFirstLine(args?.task)) {
2066
+ const flatBrief = taskPreviewText(args?.task, args?.taskFile);
2067
+ if (flatName || taskFirstLine(flatBrief)) {
2034
2068
  agents.push(
2035
2069
  pending(
2036
2070
  flatName ? formatTaskId(flatName) : "agent",
2037
2071
  args?.agent,
2038
- args?.task,
2072
+ flatBrief,
2039
2073
  args?.isolated,
2040
2074
  flatName || "agent",
2041
2075
  ),
@@ -2048,7 +2082,7 @@ function describeTaskCall(args: TaskParams | undefined): NativeToolView {
2048
2082
  pending(
2049
2083
  name ? formatTaskId(name) : `#${index + 1}`,
2050
2084
  entry?.agent,
2051
- entry?.task,
2085
+ taskPreviewText(entry?.task, entry?.taskFile),
2052
2086
  entry?.isolated,
2053
2087
  name || `#${index + 1}`,
2054
2088
  ),
@@ -2093,6 +2127,7 @@ function describeTaskResult(
2093
2127
  nowMs: options.renderContext?.nowMs ?? Date.now(),
2094
2128
  expanded: options.expanded,
2095
2129
  background,
2130
+ json: options.json === true,
2096
2131
  },
2097
2132
  0,
2098
2133
  );
@@ -2165,7 +2200,7 @@ export const taskToolRenderer = {
2165
2200
  options: TaskRenderOptions,
2166
2201
  args?: TaskParams,
2167
2202
  ): NativeToolView | undefined {
2168
- return taskResultMemo.get(result, [options.renderContext?.nowMs, options.expanded], () =>
2203
+ return taskResultMemo.get(result, [options.renderContext?.nowMs, options.expanded, options.json], () =>
2169
2204
  describeTaskResult(result, options, args),
2170
2205
  );
2171
2206
  },
@@ -2218,8 +2253,9 @@ export interface TaskItem {
2218
2253
  sourceSession?: string;
2219
2254
  /** Optional model selector override for the historical source session. */
2220
2255
  model?: string | string[];
2221
- /** The work; required by the schema. */
2256
+ /** Inline instructions; exactly one of task or taskFile is required. */
2222
2257
  task?: string;
2258
+ taskFile?: string;
2223
2259
  /** How open-ended the work is; required by the schema and the child's sole `auto` thinking classification input. */
2224
2260
  solutionSpace?: string;
2225
2261
  /** Per-spawn thinking effort: lowest/middle/highest level the resolved model supports. Overrides the agent's default selector (e.g. `auto`). */
@@ -2251,6 +2287,8 @@ export interface TaskParams {
2251
2287
  model?: string | string[];
2252
2288
  /** The work (flat form). */
2253
2289
  task?: string;
2290
+ /** Absolute path or local:// URL to a UTF-8 file (flat form), mutually exclusive with task. */
2291
+ taskFile?: string;
2254
2292
  /** How open-ended the work is (flat form); see {@link TaskItem.solutionSpace}. */
2255
2293
  solutionSpace?: string;
2256
2294
  /** Per-spawn thinking effort (flat form): lowest/middle/highest level the resolved model supports. */
@@ -2339,6 +2377,9 @@ export interface AgentProgress {
2339
2377
  status: "pending" | "running" | "completed" | "failed" | "aborted";
2340
2378
  task: string;
2341
2379
  assignment?: string;
2380
+ taskFile?: string;
2381
+ /** SHA-256 of the exact task file bytes before decoding and trimming. */
2382
+ taskFileSha256?: string;
2342
2383
  description?: string;
2343
2384
  lastIntent?: string;
2344
2385
  currentTool?: string;
@@ -2447,6 +2488,8 @@ export interface SingleResult {
2447
2488
  agentSource: AgentSource;
2448
2489
  task: string;
2449
2490
  assignment?: string;
2491
+ taskFile?: string;
2492
+ taskFileSha256?: string;
2450
2493
  description?: string;
2451
2494
  lastIntent?: string;
2452
2495
  exitCode: number;
@@ -4,6 +4,15 @@
4
4
  * selector peeling and transcript renderers consult it instead of hardcoding
5
5
  * scheme names.
6
6
  */
7
+ /**
8
+ * Mutation class of a writable scheme; drives plan-mode and device-only `write` gates.
9
+ * - `workspace`: mutates user/external state; blocked in plan mode and device-only sessions.
10
+ * - `sandbox`: session scratch space (local://); allowed in plan mode and device-only sessions.
11
+ * - `coordination`: peer messaging (agent://); always allowed. `SchemeWritePolicy.cancels` grants the same per URL.
12
+ * - `device`: tool-device dispatch (xd://); always allowed, the device enforces its own policy.
13
+ * - `reply`: a message to the user (out://); always allowed, and transcripts draw the content as assistant prose.
14
+ */
15
+ export type SchemeWriteScope = "workspace" | "sandbox" | "coordination" | "device" | "reply";
7
16
  /** Renderer-relevant subset of a registered scheme's declared spec. */
8
17
  export interface InternalUrlSchemeSpec {
9
18
  /** `lines`: a trailing `:<selector>` chain is a read selector; `none`/`opaque`: never peel. */
@@ -12,16 +21,24 @@ export interface InternalUrlSchemeSpec {
12
21
  readonly portAuthority?: boolean;
13
22
  /** Read cards collapse into the compact read group like plain files instead of expanding. */
14
23
  readonly compactTranscript?: boolean;
24
+ /** Write policy; absent on read-only schemes. Transcripts draw `reply`-scoped writes as assistant prose. */
25
+ readonly write?: {
26
+ readonly scope: SchemeWriteScope;
27
+ };
15
28
  }
16
29
  /** Scheme registry capabilities installed by the internal URL host. */
17
30
  export interface InternalUrlSchemeHost {
18
31
  /** Declared spec of a registered scheme (case-insensitive); undefined when unregistered. */
19
32
  spec(scheme: string): InternalUrlSchemeSpec | undefined;
33
+ /** Declared specs of every registered scheme, keyed by lowercased scheme. */
34
+ specs(): ReadonlyMap<string, InternalUrlSchemeSpec>;
20
35
  }
21
36
  /** Install the scheme registry. Until one is installed, no URL counts as an internal scheme. */
22
37
  export declare function setInternalUrlSchemeHost(host: InternalUrlSchemeHost): void;
23
38
  /** Declared spec of `scheme`; undefined when it is unregistered or no host is installed. */
24
39
  export declare function internalUrlSchemeSpec(scheme: string): InternalUrlSchemeSpec | undefined;
40
+ /** Declared specs of every registered scheme, keyed by lowercased scheme; empty when no host is installed. */
41
+ export declare function internalUrlSchemeSpecs(): ReadonlyMap<string, InternalUrlSchemeSpec>;
25
42
  /** Split a hierarchical `scheme://rest` URL into its lowercased scheme and the text after `://`. */
26
43
  export declare function splitUrlScheme(input: string): {
27
44
  scheme: string;
@@ -5,6 +5,16 @@
5
5
  * scheme names.
6
6
  */
7
7
 
8
+ /**
9
+ * Mutation class of a writable scheme; drives plan-mode and device-only `write` gates.
10
+ * - `workspace`: mutates user/external state; blocked in plan mode and device-only sessions.
11
+ * - `sandbox`: session scratch space (local://); allowed in plan mode and device-only sessions.
12
+ * - `coordination`: peer messaging (agent://); always allowed. `SchemeWritePolicy.cancels` grants the same per URL.
13
+ * - `device`: tool-device dispatch (xd://); always allowed, the device enforces its own policy.
14
+ * - `reply`: a message to the user (out://); always allowed, and transcripts draw the content as assistant prose.
15
+ */
16
+ export type SchemeWriteScope = "workspace" | "sandbox" | "coordination" | "device" | "reply";
17
+
8
18
  /** Renderer-relevant subset of a registered scheme's declared spec. */
9
19
  export interface InternalUrlSchemeSpec {
10
20
  /** `lines`: a trailing `:<selector>` chain is a read selector; `none`/`opaque`: never peel. */
@@ -13,12 +23,16 @@ export interface InternalUrlSchemeSpec {
13
23
  readonly portAuthority?: boolean;
14
24
  /** Read cards collapse into the compact read group like plain files instead of expanding. */
15
25
  readonly compactTranscript?: boolean;
26
+ /** Write policy; absent on read-only schemes. Transcripts draw `reply`-scoped writes as assistant prose. */
27
+ readonly write?: { readonly scope: SchemeWriteScope };
16
28
  }
17
29
 
18
30
  /** Scheme registry capabilities installed by the internal URL host. */
19
31
  export interface InternalUrlSchemeHost {
20
32
  /** Declared spec of a registered scheme (case-insensitive); undefined when unregistered. */
21
33
  spec(scheme: string): InternalUrlSchemeSpec | undefined;
34
+ /** Declared specs of every registered scheme, keyed by lowercased scheme. */
35
+ specs(): ReadonlyMap<string, InternalUrlSchemeSpec>;
22
36
  }
23
37
 
24
38
  let schemeHost: InternalUrlSchemeHost | undefined;
@@ -33,6 +47,13 @@ export function internalUrlSchemeSpec(scheme: string): InternalUrlSchemeSpec | u
33
47
  return schemeHost?.spec(scheme);
34
48
  }
35
49
 
50
+ const NO_SPECS: ReadonlyMap<string, InternalUrlSchemeSpec> = new Map();
51
+
52
+ /** Declared specs of every registered scheme, keyed by lowercased scheme; empty when no host is installed. */
53
+ export function internalUrlSchemeSpecs(): ReadonlyMap<string, InternalUrlSchemeSpec> {
54
+ return schemeHost?.specs() ?? NO_SPECS;
55
+ }
56
+
36
57
  const URL_SCHEME_RE = /^([a-z][a-z0-9+.-]*):\/\//i;
37
58
 
38
59
  /** Split a hierarchical `scheme://rest` URL into its lowercased scheme and the text after `://`. */
@@ -15,7 +15,7 @@ export declare const yieldToolRenderer: {
15
15
  renderCall(args: YieldRenderArgs, options: RenderResultOptions, theme: Theme): Component;
16
16
  renderResult(result: ToolRenderResult<YieldItem>, options: RenderResultContextOptions, theme: Theme, args?: YieldRenderArgs): Component;
17
17
  describeCall(args: YieldRenderArgs, options: RenderResultOptions): NativeToolView;
18
- describeResult(result: ToolRenderResult<YieldItem>, _options: RenderResultContextOptions, args?: YieldRenderArgs): NativeToolView;
18
+ describeResult(result: ToolRenderResult<YieldItem>, options: RenderResultContextOptions, args?: YieldRenderArgs): NativeToolView;
19
19
  mergeCallAndResult: true;
20
20
  animatedPendingPreview: true;
21
21
  };
@@ -16,7 +16,7 @@ import type { Theme } from "../theme/theme";
16
16
  import type { Component } from "../tui";
17
17
  import { wrapTextWithAnsi } from "../utils";
18
18
  import {
19
- describeJsonTree,
19
+ describeJsonValue,
20
20
  JSON_TREE_MAX_DEPTH_COLLAPSED,
21
21
  JSON_TREE_MAX_DEPTH_EXPANDED,
22
22
  JSON_TREE_MAX_LINES_COLLAPSED,
@@ -98,15 +98,20 @@ function sizeMeta(data: unknown): string | undefined {
98
98
  return undefined;
99
99
  }
100
100
 
101
- function describeData(data: unknown, streaming: boolean): NativeChild | undefined {
101
+ function describeData(data: unknown, streaming: boolean, json: boolean): NativeChild | undefined {
102
102
  if (data === undefined) return undefined;
103
103
  if (typeof data === "string") return data.trim() ? md(data, { stream: streaming }) : noteText("(empty)");
104
104
  // Open to the depth cap: the data is the card's whole point, and the
105
105
  // collapsed card's preview clamp already bounds what shows.
106
- return describeJsonTree(data, { hiddenRootKeys: [], openDepth: JSON_TREE_MAX_DEPTH_EXPANDED });
106
+ return describeJsonValue(data, {
107
+ native: json,
108
+ open: JSON_TREE_MAX_DEPTH_EXPANDED - 1,
109
+ hiddenRootKeys: [],
110
+ openDepth: JSON_TREE_MAX_DEPTH_EXPANDED,
111
+ });
107
112
  }
108
113
 
109
- function describeSubmission(s: Submission, streaming: boolean): NativeToolView {
114
+ function describeSubmission(s: Submission, streaming: boolean, json: boolean): NativeToolView {
110
115
  const size = sizeMeta(s.data);
111
116
  return {
112
117
  tool: {
@@ -119,7 +124,7 @@ function describeSubmission(s: Submission, streaming: boolean): NativeToolView {
119
124
  tone: s.settled && s.error !== undefined ? "error" : undefined,
120
125
  body: compact([
121
126
  s.error !== undefined ? errorText(s.error) : undefined,
122
- describeData(s.data, streaming),
127
+ describeData(s.data, streaming, json),
123
128
  s.note ? noteText(s.note, "dim") : undefined,
124
129
  ]),
125
130
  };
@@ -207,16 +212,20 @@ export const yieldToolRenderer = {
207
212
 
208
213
  describeCall(args: YieldRenderArgs, options: RenderResultOptions): NativeToolView {
209
214
  const streaming = options.argsComplete === false;
210
- return callMemo.get(args, [streaming], () => describeSubmission(readSubmission(args, undefined), streaming));
215
+ const json = options.json === true;
216
+ return callMemo.get(args, [streaming, json], () =>
217
+ describeSubmission(readSubmission(args, undefined), streaming, json),
218
+ );
211
219
  },
212
220
 
213
221
  describeResult(
214
222
  result: ToolRenderResult<YieldItem>,
215
- _options: RenderResultContextOptions,
223
+ options: RenderResultContextOptions,
216
224
  args?: YieldRenderArgs,
217
225
  ): NativeToolView {
218
- return resultMemo.get(result.content, [args, result.details, result.isError], () =>
219
- describeSubmission(readSubmission(args, result), false),
226
+ const json = options.json === true;
227
+ return resultMemo.get(result.content, [args, result.details, result.isError, json], () =>
228
+ describeSubmission(readSubmission(args, result), false, json),
220
229
  );
221
230
  },
222
231
 
package/src/tui.d.ts CHANGED
@@ -80,7 +80,9 @@ export interface TUIStartOptions {
80
80
  * switches to raw input and replays the kernel-buffered keystrokes.
81
81
  *
82
82
  * A terminal expected to speak TSP needs raw input from the start, so it
83
- * gets it; its keystrokes are held instead (TSP events and the cell-size
83
+ * gets it. Plain typing (printable text, Backspace) still edits the focused
84
+ * component live, as the kernel echo shows it elsewhere; the first other key
85
+ * and every key after it are held instead (TSP events and the cell-size
84
86
  * reply still apply) until {@link TUI.releaseHeldInput} replays them.
85
87
  */
86
88
  deferInput?: boolean;
@@ -525,7 +527,10 @@ export declare class TUI extends Container {
525
527
  * never come.
526
528
  */
527
529
  addStartListener(listener: StartListener): () => void;
528
- addInputListener(listener: InputListener): () => void;
530
+ /** Registers a key listener; `prepend` gives a foreground input owner first refusal over global shortcuts. */
531
+ addInputListener(listener: InputListener, options?: {
532
+ prepend?: boolean;
533
+ }): () => void;
529
534
  removeInputListener(listener: InputListener): void;
530
535
  stop(): void;
531
536
  /**
package/src/tui.ts CHANGED
@@ -21,7 +21,7 @@ import * as postmortem from "@linxiraos/pi-utils/postmortem";
21
21
  import type { TspFrame, TspNode, TspText } from "@linxiraos/pi-wire";
22
22
  import { DEFAULT_MAX_INLINE_IMAGES, ImageBudget } from "./components/image";
23
23
  import { TuiDebugServer } from "./debug-server";
24
- import { isKeyRelease, matchesKey } from "./keys";
24
+ import { extractPrintableText, isKeyRelease, matchesKey } from "./keys";
25
25
  import { KITTY_PLACEHOLDER } from "./kitty-graphics";
26
26
  import { LoopWatchdog } from "./loop-watchdog";
27
27
  import { assumedTspHello, NativeBackend, type NativeHost } from "./native/backend";
@@ -52,6 +52,7 @@ import {
52
52
  } from "./terminal-capabilities";
53
53
  import { onTerminalBackgroundFallbackChange } from "./theme/theme";
54
54
  import { compositeLineAt } from "./render/composite";
55
+ import { stripExtensionLinkMarkers } from "./render/extension-links";
55
56
  import { tmuxMultiplexer } from "./multiplexers/tmux";
56
57
  import {
57
58
  Ellipsis,
@@ -214,7 +215,9 @@ export interface TUIStartOptions {
214
215
  * switches to raw input and replays the kernel-buffered keystrokes.
215
216
  *
216
217
  * A terminal expected to speak TSP needs raw input from the start, so it
217
- * gets it; its keystrokes are held instead (TSP events and the cell-size
218
+ * gets it. Plain typing (printable text, Backspace) still edits the focused
219
+ * component live, as the kernel echo shows it elsewhere; the first other key
220
+ * and every key after it are held instead (TSP events and the cell-size
218
221
  * reply still apply) until {@link TUI.releaseHeldInput} replays them.
219
222
  */
220
223
  deferInput?: boolean;
@@ -1044,7 +1047,8 @@ export class TUI extends Container {
1044
1047
  #inputDeferred = false;
1045
1048
  /**
1046
1049
  * Keystrokes held since a TSP `deferInput` start, replayed by
1047
- * releaseHeldInput(); undefined when not holding.
1050
+ * releaseHeldInput(); undefined when not holding, empty while plain typing
1051
+ * still goes through live.
1048
1052
  */
1049
1053
  #heldInput: string[] | undefined;
1050
1054
  /**
@@ -2549,8 +2553,13 @@ export class TUI extends Container {
2549
2553
  }
2550
2554
  }
2551
2555
 
2552
- addInputListener(listener: InputListener): () => void {
2553
- this.#inputListeners.add(listener);
2556
+ /** Registers a key listener; `prepend` gives a foreground input owner first refusal over global shortcuts. */
2557
+ addInputListener(listener: InputListener, options?: { prepend?: boolean }): () => void {
2558
+ if (options?.prepend) {
2559
+ this.#inputListeners = new Set([listener, ...this.#inputListeners]);
2560
+ } else {
2561
+ this.#inputListeners.add(listener);
2562
+ }
2554
2563
  return () => {
2555
2564
  this.#inputListeners.delete(listener);
2556
2565
  };
@@ -3069,7 +3078,11 @@ export class TUI extends Container {
3069
3078
  }
3070
3079
  if (data.length === 0) return;
3071
3080
 
3072
- if (this.#heldInput !== undefined && this.#focusedComponent === this.#heldFocus) {
3081
+ if (
3082
+ this.#heldInput !== undefined &&
3083
+ this.#focusedComponent === this.#heldFocus &&
3084
+ !this.#typesThroughHold(data)
3085
+ ) {
3073
3086
  this.#holdInput(data);
3074
3087
  return;
3075
3088
  }
@@ -3159,6 +3172,18 @@ export class TUI extends Container {
3159
3172
  return holder?.component === focused ? holder.preFocus : null;
3160
3173
  }
3161
3174
 
3175
+ /**
3176
+ * Whether a keystroke typed during a TSP startup hold edits the focused
3177
+ * component now: plain typing (printable text, Backspace) and key releases,
3178
+ * while nothing is queued ahead of them. The draft then grows as it is typed,
3179
+ * like a cooked tty's echo; a shortcut waits for the handlers that act on it,
3180
+ * and whatever follows it waits behind it to keep typing order.
3181
+ */
3182
+ #typesThroughHold(data: string): boolean {
3183
+ if (this.#heldInput!.length > 0) return false;
3184
+ return extractPrintableText(data) !== undefined || matchesKey(data, "backspace") || isKeyRelease(data);
3185
+ }
3186
+
3162
3187
  /**
3163
3188
  * Queue a keystroke typed before the app installed its key handlers; input
3164
3189
  * listeners see it once, on replay. The cell-size reply is a terminal report,
@@ -4266,45 +4291,48 @@ export class TUI extends Container {
4266
4291
  LINE_FIT_MAX_SOURCE_CODE_UNITS,
4267
4292
  Math.max(LINE_FIT_MIN_SOURCE_CODE_UNITS, safeWidth * LINE_FIT_SOURCE_WIDTH_MULTIPLIER),
4268
4293
  );
4294
+ // Extension link markers exist only for hit-testing; the terminal must never get an openable
4295
+ // hyperlink. Strip before fitting (so a cut cannot split one) and before classifying.
4296
+ const output = stripExtensionLinkMarkers(raw);
4269
4297
 
4270
4298
  let source: string;
4271
4299
  let classification: LineClassification;
4272
- if (raw.length <= maxSourceLength) {
4300
+ if (output.length <= maxSourceLength) {
4273
4301
  // The overwhelmingly common path classifies image markers, OSC 8,
4274
4302
  // ANSI validity, OSC 66, non-ASCII, and exact ASCII width together.
4275
- classification = this.#classifyLine(raw, safeWidth);
4303
+ classification = this.#classifyLine(output, safeWidth);
4276
4304
  if (classification.isImage) {
4277
4305
  return {
4278
4306
  raw,
4279
4307
  width,
4280
4308
  widthEpoch,
4281
4309
  imageProtocol,
4282
- line: raw,
4283
- terminalContent: raw,
4310
+ line: output,
4311
+ terminalContent: output,
4284
4312
  asciiWidth: undefined,
4285
4313
  isImage: true,
4286
4314
  hasOsc8: false,
4287
4315
  };
4288
4316
  }
4289
- source = raw;
4317
+ source = output;
4290
4318
  } else {
4291
4319
  // Fitting a giant source can discard everything after the visible
4292
4320
  // prefix. Preserve image rows verbatim first, but do not scan the
4293
4321
  // entire source for width/OSC metadata that will immediately vanish.
4294
- if (TERMINAL.isImageLine(raw)) {
4322
+ if (TERMINAL.isImageLine(output)) {
4295
4323
  return {
4296
4324
  raw,
4297
4325
  width,
4298
4326
  widthEpoch,
4299
4327
  imageProtocol,
4300
- line: raw,
4301
- terminalContent: raw,
4328
+ line: output,
4329
+ terminalContent: output,
4302
4330
  asciiWidth: undefined,
4303
4331
  isImage: true,
4304
4332
  hasOsc8: false,
4305
4333
  };
4306
4334
  }
4307
- source = this.#lineFitSource(raw, safeWidth, maxSourceLength);
4335
+ source = this.#lineFitSource(output, safeWidth, maxSourceLength);
4308
4336
  // Preserve the former lineRewriteSequence classification: fitting can
4309
4337
  // move a marker from outside the raw scan window into the prepared
4310
4338
  // line's window, at which point terminal image dispatch owns it.