@sagmans/dsh-tui 0.5.2 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (285) hide show
  1. package/.agents/skills/dsh-tui-dogfood/SKILL.md +83 -0
  2. package/.agents/skills/dsh-tui-dogfood/references/home-state.md +78 -0
  3. package/.agents/skills/dsh-tui-dogfood/scripts/clone-links.mjs +133 -0
  4. package/.agents/skills/dsh-tui-dogfood/scripts/run-plugin-from-worktree.sh +417 -0
  5. package/.agents/skills/dsh-tui-update-models/SKILL.md +121 -0
  6. package/.agents/skills/dsh-tui-update-models/references/model-wiring.md +162 -0
  7. package/.agents/skills/dsh-tui-update-models/scripts/dump-model-catalog.mjs +178 -0
  8. package/README.md +131 -17
  9. package/lib/agent/host.d.ts +11 -0
  10. package/lib/agent/host.d.ts.map +1 -1
  11. package/lib/agent/host.js +16 -2
  12. package/lib/agent/host.js.map +1 -1
  13. package/lib/agent/present.d.ts.map +1 -1
  14. package/lib/agent/present.js +2 -1
  15. package/lib/agent/present.js.map +1 -1
  16. package/lib/agent/undo.d.ts +52 -0
  17. package/lib/agent/undo.d.ts.map +1 -0
  18. package/lib/agent/undo.js +106 -0
  19. package/lib/agent/undo.js.map +1 -0
  20. package/lib/cards/composition.d.ts +68 -0
  21. package/lib/cards/composition.d.ts.map +1 -0
  22. package/lib/cards/composition.js +117 -0
  23. package/lib/cards/composition.js.map +1 -0
  24. package/lib/cards/presenter.d.ts +23 -0
  25. package/lib/cards/presenter.d.ts.map +1 -0
  26. package/lib/cards/presenter.js +394 -0
  27. package/lib/cards/presenter.js.map +1 -0
  28. package/lib/cards/preview.d.ts +42 -0
  29. package/lib/cards/preview.d.ts.map +1 -0
  30. package/lib/cards/preview.js +51 -0
  31. package/lib/cards/preview.js.map +1 -0
  32. package/lib/cards.d.ts +42 -95
  33. package/lib/cards.d.ts.map +1 -1
  34. package/lib/cards.js +4 -526
  35. package/lib/cards.js.map +1 -1
  36. package/lib/compat/section.d.ts +29 -0
  37. package/lib/compat/section.d.ts.map +1 -0
  38. package/lib/compat/section.js +82 -0
  39. package/lib/compat/section.js.map +1 -0
  40. package/lib/config.d.ts +27 -2
  41. package/lib/config.d.ts.map +1 -1
  42. package/lib/config.js +61 -1
  43. package/lib/config.js.map +1 -1
  44. package/lib/contracts.d.ts +28 -0
  45. package/lib/contracts.d.ts.map +1 -1
  46. package/lib/fold-cursor.d.ts +8 -0
  47. package/lib/fold-cursor.d.ts.map +1 -1
  48. package/lib/fold-cursor.js +18 -0
  49. package/lib/fold-cursor.js.map +1 -1
  50. package/lib/gates/question-card.d.ts +77 -0
  51. package/lib/gates/question-card.d.ts.map +1 -0
  52. package/lib/gates/question-card.js +113 -0
  53. package/lib/gates/question-card.js.map +1 -0
  54. package/lib/gates/questions.d.ts +127 -0
  55. package/lib/gates/questions.d.ts.map +1 -0
  56. package/lib/gates/questions.js +418 -0
  57. package/lib/gates/questions.js.map +1 -0
  58. package/lib/gates.d.ts +1 -113
  59. package/lib/gates.d.ts.map +1 -1
  60. package/lib/gates.js +1 -484
  61. package/lib/gates.js.map +1 -1
  62. package/lib/herdr/reporter.d.ts +9 -4
  63. package/lib/herdr/reporter.d.ts.map +1 -1
  64. package/lib/herdr/reporter.js +5 -9
  65. package/lib/herdr/reporter.js.map +1 -1
  66. package/lib/herdr/state.d.ts +35 -4
  67. package/lib/herdr/state.d.ts.map +1 -1
  68. package/lib/herdr/state.js +37 -4
  69. package/lib/herdr/state.js.map +1 -1
  70. package/lib/index.d.ts +1 -0
  71. package/lib/index.d.ts.map +1 -1
  72. package/lib/index.js +343 -2267
  73. package/lib/index.js.map +1 -1
  74. package/lib/input/action-catalog.d.ts +74 -0
  75. package/lib/input/action-catalog.d.ts.map +1 -0
  76. package/lib/input/action-catalog.js +137 -0
  77. package/lib/input/action-catalog.js.map +1 -0
  78. package/lib/input/actions.d.ts +5 -81
  79. package/lib/input/actions.d.ts.map +1 -1
  80. package/lib/input/actions.js +4 -621
  81. package/lib/input/actions.js.map +1 -1
  82. package/lib/input/completion.d.ts +11 -1
  83. package/lib/input/completion.d.ts.map +1 -1
  84. package/lib/input/completion.js +17 -1
  85. package/lib/input/completion.js.map +1 -1
  86. package/lib/input/file-index.d.ts +40 -0
  87. package/lib/input/file-index.d.ts.map +1 -0
  88. package/lib/input/file-index.js +141 -0
  89. package/lib/input/file-index.js.map +1 -0
  90. package/lib/input/file-search.d.ts +1 -38
  91. package/lib/input/file-search.d.ts.map +1 -1
  92. package/lib/input/file-search.js +1 -487
  93. package/lib/input/file-search.js.map +1 -1
  94. package/lib/input/key-press.d.ts +57 -0
  95. package/lib/input/key-press.d.ts.map +1 -0
  96. package/lib/input/key-press.js +218 -0
  97. package/lib/input/key-press.js.map +1 -0
  98. package/lib/input/keymap-conflicts.d.ts +59 -0
  99. package/lib/input/keymap-conflicts.d.ts.map +1 -0
  100. package/lib/input/keymap-conflicts.js +292 -0
  101. package/lib/input/keymap-conflicts.js.map +1 -0
  102. package/lib/input/keymap-settings.js +1 -1
  103. package/lib/input/keymap-settings.js.map +1 -1
  104. package/lib/input/keymap.d.ts.map +1 -1
  105. package/lib/input/keymap.js +5 -1
  106. package/lib/input/keymap.js.map +1 -1
  107. package/lib/input/submission.d.ts +11 -1
  108. package/lib/input/submission.d.ts.map +1 -1
  109. package/lib/input/submission.js +10 -1
  110. package/lib/input/submission.js.map +1 -1
  111. package/lib/input/workspace-files.d.ts +10 -0
  112. package/lib/input/workspace-files.d.ts.map +1 -0
  113. package/lib/input/workspace-files.js +359 -0
  114. package/lib/input/workspace-files.js.map +1 -0
  115. package/lib/install-skills.d.ts +20 -0
  116. package/lib/install-skills.d.ts.map +1 -0
  117. package/lib/install-skills.js +198 -0
  118. package/lib/install-skills.js.map +1 -0
  119. package/lib/keys-command.d.ts +2 -1
  120. package/lib/keys-command.d.ts.map +1 -1
  121. package/lib/keys-command.js +2 -1
  122. package/lib/keys-command.js.map +1 -1
  123. package/lib/model-list.d.ts +37 -0
  124. package/lib/model-list.d.ts.map +1 -0
  125. package/lib/model-list.js +60 -0
  126. package/lib/model-list.js.map +1 -0
  127. package/lib/startup.d.ts +8 -0
  128. package/lib/startup.d.ts.map +1 -1
  129. package/lib/startup.js +120 -24
  130. package/lib/startup.js.map +1 -1
  131. package/lib/subagents.d.ts +7 -3
  132. package/lib/subagents.d.ts.map +1 -1
  133. package/lib/subagents.js +28 -4
  134. package/lib/subagents.js.map +1 -1
  135. package/lib/surface/appearance-preferences.d.ts +26 -0
  136. package/lib/surface/appearance-preferences.d.ts.map +1 -0
  137. package/lib/surface/appearance-preferences.js +139 -0
  138. package/lib/surface/appearance-preferences.js.map +1 -0
  139. package/lib/surface/appearance.d.ts +87 -0
  140. package/lib/surface/appearance.d.ts.map +1 -0
  141. package/lib/surface/appearance.js +353 -0
  142. package/lib/surface/appearance.js.map +1 -0
  143. package/lib/surface/background-work.d.ts +49 -0
  144. package/lib/surface/background-work.d.ts.map +1 -0
  145. package/lib/surface/background-work.js +146 -0
  146. package/lib/surface/background-work.js.map +1 -0
  147. package/lib/surface/commands.d.ts +80 -0
  148. package/lib/surface/commands.d.ts.map +1 -0
  149. package/lib/surface/commands.js +364 -0
  150. package/lib/surface/commands.js.map +1 -0
  151. package/lib/surface/modal-input.d.ts +58 -0
  152. package/lib/surface/modal-input.d.ts.map +1 -0
  153. package/lib/surface/modal-input.js +237 -0
  154. package/lib/surface/modal-input.js.map +1 -0
  155. package/lib/surface/model-choice.d.ts +54 -0
  156. package/lib/surface/model-choice.d.ts.map +1 -0
  157. package/lib/surface/model-choice.js +325 -0
  158. package/lib/surface/model-choice.js.map +1 -0
  159. package/lib/surface/preset-choice.d.ts +78 -0
  160. package/lib/surface/preset-choice.d.ts.map +1 -0
  161. package/lib/surface/preset-choice.js +163 -0
  162. package/lib/surface/preset-choice.js.map +1 -0
  163. package/lib/surface/prompt-input.d.ts +97 -0
  164. package/lib/surface/prompt-input.d.ts.map +1 -0
  165. package/lib/surface/prompt-input.js +215 -0
  166. package/lib/surface/prompt-input.js.map +1 -0
  167. package/lib/surface/prompt-memory.d.ts +76 -0
  168. package/lib/surface/prompt-memory.d.ts.map +1 -0
  169. package/lib/surface/prompt-memory.js +167 -0
  170. package/lib/surface/prompt-memory.js.map +1 -0
  171. package/lib/surface/session-lifecycle.d.ts +120 -0
  172. package/lib/surface/session-lifecycle.d.ts.map +1 -0
  173. package/lib/surface/session-lifecycle.js +321 -0
  174. package/lib/surface/session-lifecycle.js.map +1 -0
  175. package/lib/surface/session-picker.d.ts +39 -0
  176. package/lib/surface/session-picker.d.ts.map +1 -0
  177. package/lib/surface/session-picker.js +107 -0
  178. package/lib/surface/session-picker.js.map +1 -0
  179. package/lib/surface/session-view.d.ts +86 -0
  180. package/lib/surface/session-view.d.ts.map +1 -0
  181. package/lib/surface/session-view.js +215 -0
  182. package/lib/surface/session-view.js.map +1 -0
  183. package/lib/surface/staged-turns.d.ts +81 -0
  184. package/lib/surface/staged-turns.d.ts.map +1 -0
  185. package/lib/surface/staged-turns.js +206 -0
  186. package/lib/surface/staged-turns.js.map +1 -0
  187. package/lib/surface/terminal-lifecycle.d.ts +76 -0
  188. package/lib/surface/terminal-lifecycle.d.ts.map +1 -0
  189. package/lib/surface/terminal-lifecycle.js +222 -0
  190. package/lib/surface/terminal-lifecycle.js.map +1 -0
  191. package/lib/terminal/warning-screen.d.ts +8 -1
  192. package/lib/terminal/warning-screen.d.ts.map +1 -1
  193. package/lib/terminal/warning-screen.js +9 -0
  194. package/lib/terminal/warning-screen.js.map +1 -1
  195. package/lib/terminal-text/scan.d.ts +44 -0
  196. package/lib/terminal-text/scan.d.ts.map +1 -0
  197. package/lib/terminal-text/scan.js +195 -0
  198. package/lib/terminal-text/scan.js.map +1 -0
  199. package/lib/terminal-text/sgr.d.ts +32 -0
  200. package/lib/terminal-text/sgr.d.ts.map +1 -0
  201. package/lib/terminal-text/sgr.js +203 -0
  202. package/lib/terminal-text/sgr.js.map +1 -0
  203. package/lib/terminal-text.d.ts +1 -1
  204. package/lib/terminal-text.d.ts.map +1 -1
  205. package/lib/terminal-text.js +2 -379
  206. package/lib/terminal-text.js.map +1 -1
  207. package/lib/theme-command.js +2 -1
  208. package/lib/theme-command.js.map +1 -1
  209. package/lib/theme-defaults.d.ts +64 -0
  210. package/lib/theme-defaults.d.ts.map +1 -0
  211. package/lib/theme-defaults.js +248 -0
  212. package/lib/theme-defaults.js.map +1 -0
  213. package/lib/theme-resolver.d.ts +36 -0
  214. package/lib/theme-resolver.d.ts.map +1 -0
  215. package/lib/theme-resolver.js +112 -0
  216. package/lib/theme-resolver.js.map +1 -0
  217. package/lib/theme-schema.d.ts +6 -6
  218. package/lib/theme-schema.d.ts.map +1 -1
  219. package/lib/theme-schema.js +3 -2
  220. package/lib/theme-schema.js.map +1 -1
  221. package/lib/theme-settings.d.ts +13 -15
  222. package/lib/theme-settings.d.ts.map +1 -1
  223. package/lib/theme-settings.js +27 -19
  224. package/lib/theme-settings.js.map +1 -1
  225. package/lib/theme-tokens.d.ts +1 -90
  226. package/lib/theme-tokens.d.ts.map +1 -1
  227. package/lib/theme-tokens.js +11 -341
  228. package/lib/theme-tokens.js.map +1 -1
  229. package/lib/theme.d.ts +1 -1
  230. package/lib/theme.d.ts.map +1 -1
  231. package/lib/theme.js +2 -1
  232. package/lib/theme.js.map +1 -1
  233. package/lib/tool-display.d.ts.map +1 -1
  234. package/lib/tool-display.js +2 -1
  235. package/lib/tool-display.js.map +1 -1
  236. package/lib/transcript/message-content.d.ts +21 -0
  237. package/lib/transcript/message-content.d.ts.map +1 -0
  238. package/lib/transcript/message-content.js +61 -0
  239. package/lib/transcript/message-content.js.map +1 -0
  240. package/lib/transcript/tool-calls.d.ts +106 -0
  241. package/lib/transcript/tool-calls.d.ts.map +1 -0
  242. package/lib/transcript/tool-calls.js +254 -0
  243. package/lib/transcript/tool-calls.js.map +1 -0
  244. package/lib/transcript.d.ts +38 -43
  245. package/lib/transcript.d.ts.map +1 -1
  246. package/lib/transcript.js +58 -245
  247. package/lib/transcript.js.map +1 -1
  248. package/lib/ui/copy.d.ts +17 -0
  249. package/lib/ui/copy.d.ts.map +1 -0
  250. package/lib/ui/copy.js +104 -0
  251. package/lib/ui/copy.js.map +1 -0
  252. package/lib/ui/dock.d.ts +35 -3
  253. package/lib/ui/dock.d.ts.map +1 -1
  254. package/lib/ui/dock.js +124 -23
  255. package/lib/ui/dock.js.map +1 -1
  256. package/lib/ui/editor.d.ts.map +1 -1
  257. package/lib/ui/editor.js +2 -1
  258. package/lib/ui/editor.js.map +1 -1
  259. package/lib/ui/frame.d.ts +31 -0
  260. package/lib/ui/frame.d.ts.map +1 -1
  261. package/lib/ui/frame.js +27 -4
  262. package/lib/ui/frame.js.map +1 -1
  263. package/lib/ui/keymap-picker.d.ts +2 -1
  264. package/lib/ui/keymap-picker.d.ts.map +1 -1
  265. package/lib/ui/keymap-picker.js +1 -0
  266. package/lib/ui/keymap-picker.js.map +1 -1
  267. package/lib/ui/view/gate-card.d.ts +21 -0
  268. package/lib/ui/view/gate-card.d.ts.map +1 -0
  269. package/lib/ui/view/gate-card.js +104 -0
  270. package/lib/ui/view/gate-card.js.map +1 -0
  271. package/lib/ui/view/tool-card.d.ts +138 -0
  272. package/lib/ui/view/tool-card.d.ts.map +1 -0
  273. package/lib/ui/view/tool-card.js +413 -0
  274. package/lib/ui/view/tool-card.js.map +1 -0
  275. package/lib/ui/view/transcript-message.d.ts +62 -0
  276. package/lib/ui/view/transcript-message.d.ts.map +1 -0
  277. package/lib/ui/view/transcript-message.js +158 -0
  278. package/lib/ui/view/transcript-message.js.map +1 -0
  279. package/lib/ui/view.d.ts +87 -156
  280. package/lib/ui/view.d.ts.map +1 -1
  281. package/lib/ui/view.js +122 -556
  282. package/lib/ui/view.js.map +1 -1
  283. package/package.json +3 -1
  284. package/themes/deepseek-blue.yaml +9 -0
  285. package/themes/violet-orbit.yaml +7 -0
@@ -61,6 +61,17 @@ export declare function agentRoute(ctx: Context, options: Pick<StartAgentOptions
61
61
  model?: string;
62
62
  reasoningEffort?: ReasoningEffortId;
63
63
  };
64
+ /**
65
+ * Whether a refused resume means the session simply has no durable log yet.
66
+ *
67
+ * Matched by the harness's stable error name rather than a class import: the
68
+ * surface mounts a compatible release RANGE, so the persistence package it
69
+ * would import is not necessarily the one behind the refusal. Any other
70
+ * failure — a composition that will not mount, an unreadable log — has to
71
+ * surface as itself, because falling back to a create hides it behind the
72
+ * identity collision of a session that does exist.
73
+ */
74
+ export declare function absentSession(error: unknown): boolean;
64
75
  /**
65
76
  * Create or resume the one agent this surface drives.
66
77
  *
@@ -1 +1 @@
1
- {"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../../src/agent/host.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAA;AACnD,OAAO,EAAuC,KAAK,SAAS,EAAE,MAAM,0BAA0B,CAAA;AAC9F,OAAO,EAAE,iBAAiB,EAAqB,MAAM,sBAAsB,CAAA;AAE3E,0EAA0E;AAC1E,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAA;IAC7B,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAA;IACrB,yDAAyD;IACzD,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,8DAA8D;IAC9D,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,0DAA0D;IAC1D,SAAS,IAAI,IAAI,CAAA;IACjB,6CAA6C;IAC7C,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CACzB;AAED,gEAAgE;AAChE,MAAM,WAAW,eAAe;IAC9B,sCAAsC;IACtC,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAA;IACxB,2EAA2E;IAC3E,QAAQ,CAAC,MAAM,EAAE,SAAS,OAAO,EAAE,CAAA;CACpC;AAED,6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ACrD;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,eAAe,CAAC,EAAE,iBAAiB,CAAA;CAAE,CAiB5E;AAED;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAErD;AAMD;;;;;;GAMG;AACH,wBAAsB,UAAU,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,QAAQ,CAAC,CAoC5F"}
package/lib/agent/host.js CHANGED
@@ -26,6 +26,19 @@ export function agentRoute(ctx, options) {
26
26
  : { reasoningEffort: ReasoningEffortId(selection.reasoningEffort) }),
27
27
  };
28
28
  }
29
+ /**
30
+ * Whether a refused resume means the session simply has no durable log yet.
31
+ *
32
+ * Matched by the harness's stable error name rather than a class import: the
33
+ * surface mounts a compatible release RANGE, so the persistence package it
34
+ * would import is not necessarily the one behind the refusal. Any other
35
+ * failure — a composition that will not mount, an unreadable log — has to
36
+ * surface as itself, because falling back to a create hides it behind the
37
+ * identity collision of a session that does exist.
38
+ */
39
+ export function absentSession(error) {
40
+ return error instanceof Error && error.name === 'SessionPersistenceNotFoundError';
41
+ }
29
42
  function userMessage(text) {
30
43
  return createUserMessage({ content: [{ type: 'text', text }], source: { kind: 'user' } });
31
44
  }
@@ -52,11 +65,12 @@ export async function startAgent(ctx, options) {
52
65
  const identity = options.fork === undefined
53
66
  ? { ...meta, ...preset }
54
67
  : { ...meta, parentSession: options.fork.from, isSeeded: true, ...preset };
68
+ const create = () => ctx.agents.create({ sessionId: options.sessionId, meta: identity, agentOptions, ...branch, ...setup });
55
69
  const handle = options.resume
56
70
  ? await ctx.agents
57
71
  .resume({ resumeSessionId: options.sessionId, agentOptions, ...setup })
58
- .catch(() => ctx.agents.create({ sessionId: options.sessionId, meta: identity, agentOptions, ...branch, ...setup }))
59
- : await ctx.agents.create({ sessionId: options.sessionId, meta: identity, agentOptions, ...branch, ...setup });
72
+ .catch((error) => (absentSession(error) ? create() : Promise.reject(error)))
73
+ : await create();
60
74
  let disposed = false;
61
75
  return {
62
76
  sessionId: options.sessionId,
@@ -1 +1 @@
1
- {"version":3,"file":"host.js","sourceRoot":"","sources":["../../src/agent/host.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAqC,MAAM,0BAA0B,CAAA;AAC9F,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAmD3E;;;;;;;GAOG;AACH,MAAM,UAAU,UAAU,CACxB,GAAY,EACZ,OAAsD;IAEtD,IAAI,OAAO,CAAC,KAAK,KAAK,SAAS,IAAI,OAAO,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;QAClE,OAAO;YACL,GAAG,CAAC,OAAO,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC;YACzE,GAAG,CAAC,OAAO,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC;SACjE,CAAA;IACH,CAAC;IACD,MAAM,SAAS,GAAG,GAAG,CAAC,GAAG,CAAC,mBAAmB,CAAC,EAAE,gBAAgB,EAAE,CAAA;IAClE,OAAO,SAAS,KAAK,SAAS;QAC5B,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC;YACE,QAAQ,EAAE,SAAS,CAAC,QAAQ;YAC5B,KAAK,EAAE,SAAS,CAAC,KAAK;YACtB,GAAG,CAAC,SAAS,CAAC,eAAe,KAAK,SAAS;gBACzC,CAAC,CAAC,EAAE;gBACJ,CAAC,CAAC,EAAE,eAAe,EAAE,iBAAiB,CAAC,SAAS,CAAC,eAAe,CAAC,EAAE,CAAC;SACvE,CAAA;AACP,CAAC;AAED,SAAS,WAAW,CAAC,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/agent/present.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAA;AACnD,OAAO,EAIL,KAAK,aAAa,EAEnB,MAAM,aAAa,CAAA;AA4BpB;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,GAAG,SAAS,GAAG,aAAa,CAqChG"}
1
+ {"version":3,"file":"present.d.ts","sourceRoot":"","sources":["../../src/agent/present.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAA;AAEnD,OAAO,EAAgB,KAAK,aAAa,EAAwB,MAAM,aAAa,CAAA;AA4BpF;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,GAAG,SAAS,GAAG,aAAa,CAqChG"}
@@ -1,4 +1,5 @@
1
- import { cardOfCall, cardOfResult, contentLines, } from "../cards.js";
1
+ import { cardOfCall, cardOfResult } from "../cards/presenter.js";
2
+ import { contentLines } from "../cards.js";
2
3
  function parseArguments(argumentsJson) {
3
4
  try {
4
5
  return JSON.parse(argumentsJson);
@@ -1 +1 @@
1
- {"version":3,"file":"present.js","sourceRoot":"","sources":["../../src/agent/present.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,UAAU,EACV,YAAY,EACZ,YAAY,GAGb,MAAM,aAAa,CAAA;AAEpB,SAAS,cAAc,CAAC,aAAqB;IAC3C,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,aAAa,CAAY,CAAA;IAC7C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAA;IAClB,CAAC;AACH,CA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AO,YAAY,CAAC,IAAI,EAAE;oBACxB,IAAI;oBACJ,MAAM,EAAE,KAAK,CAAC,OAAO;oBACrB,YAAY,EAAE,YAAY,CAAC,KAAK,CAAC,OAAO,CAAC;iBAC1C,CAAC,CAAA;YACJ,CAAC;YAAC,MAAM,CAAC;gBACP,OAAO,SAAS,CAAA;YAClB,CAAC;QACH,CAAC;KACF,CAAA;AACH,CAAC"}
@@ -0,0 +1,52 @@
1
+ import type { SessionId } from '@deepseek-ai/dsh-session';
2
+ import type { ForkEvent } from './fork.ts';
3
+ /**
4
+ * The undo cursor's arithmetic, kept out of the terminal surface.
5
+ *
6
+ * The session log is append-only, so undo cannot delete a prompt: the cursor
7
+ * only counts how many trailing turns the transcript hides and which prefix a
8
+ * divergence continues from. Reading the turns from the log on every step keeps
9
+ * the durable state a single number that can never go stale.
10
+ */
11
+ /** One closed turn that contains a direct prompt and can be undone as a unit. */
12
+ export interface TurnPoint {
13
+ /** Turn number the harness opened. */
14
+ readonly turn: number;
15
+ /** Index of the turn's `turn/start`: the prefix a divergence inherits. */
16
+ readonly seedCount: number;
17
+ /** The first direct prompt's text, which the composer gets back. */
18
+ readonly promptText: string;
19
+ }
20
+ /** The staged cursor over one session's closed turns. */
21
+ export interface UndoState {
22
+ readonly sessionId: SessionId | undefined;
23
+ /** How many trailing turns the transcript hides; 0 is the tip. */
24
+ readonly hidden: number;
25
+ /** The composer text this state wrote last, so a reader's edit is never overwritten. */
26
+ readonly lastRestored: string;
27
+ }
28
+ /** The cursor before any session is open. */
29
+ export declare const NO_UNDO: UndoState;
30
+ /**
31
+ * How long an undo waits for an interrupted turn to close before giving up.
32
+ *
33
+ * The harness closes the turn as its abort settles, so a wait is needed; a
34
+ * bounded one keeps a stuck tool from leaving the key press unanswered.
35
+ */
36
+ export declare const UNDO_TURN_SETTLE_MS = 10000;
37
+ /** The cursor at the tip of one session. */
38
+ export declare function resetUndo(sessionId: SessionId): UndoState;
39
+ /**
40
+ * The closed turns a direct prompt can be undone from, in log order.
41
+ *
42
+ * A turn is one `turn/start`...`turn/end` bracket; only a closed bracket with at least one direct prompt
43
+ * is a unit. Injected context also arrives as `user/message`, which is why the source kind is checked.
44
+ */
45
+ export declare function turnsOf(events: readonly ForkEvent[]): readonly TurnPoint[];
46
+ /** Step the cursor one turn back, or undefined when nothing is left to hide. */
47
+ export declare function undoStep(state: UndoState, turns: readonly TurnPoint[]): UndoState | undefined;
48
+ /** Step the cursor one turn forward, or undefined when it is already at the tip. */
49
+ export declare function redoStep(state: UndoState, turns: readonly TurnPoint[]): UndoState | undefined;
50
+ /** The oldest hidden turn: where a divergence forks, or undefined at the tip. */
51
+ export declare function hiddenTail(state: UndoState, turns: readonly TurnPoint[]): TurnPoint | undefined;
52
+ //# sourceMappingURL=undo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"undo.d.ts","sourceRoot":"","sources":["../../src/agent/undo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACzD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAE1C;;;;;;;GAOG;AAEH,iFAAiF;AACjF,MAAM,WAAW,SAAS;IACxB,sCAAsC;IACtC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,0EAA0E;IAC1E,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,oEAAoE;IACpE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;CAC5B;AAED,yDAAyD;AACzD,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,SAAS,EAAE,SAAS,GAAG,SAAS,CAAA;IACzC,kEAAkE;IAClE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,wFAAwF;IACxF,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;CAC9B;AAED,6CAA6C;AAC7C,eAAO,MAAM,OAAO,EAAE,SAAiE,CAAA;AAEvF;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,QAAS,CAAA;AAEzC,4CAA4C;AAC5C,wBAAgB,SAAS,CAAC,SAAS,EAAE,SAAS,GAAG,SAAS,CAEzD;AAqCD;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,MAAM,EAAE,SAAS,SAAS,EAAE,GAAG,SAAS,SAAS,EAAE,CA+B1E;AAED,gFAAgF;AAChF,wBAAgB,QAAQ,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,SAAS,EAAE,GAAG,SAAS,GAAG,SAAS,CAI7F;AAED,oFAAoF;AACpF,wBAAgB,QAAQ,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,SAAS,EAAE,GAAG,SAAS,GAAG,SAAS,CAI7F;AAED,iFAAiF;AACjF,wBAAgB,UAAU,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,SAAS,EAAE,GAAG,SAAS,GAAG,SAAS,CAE/F"}
@@ -0,0 +1,106 @@
1
+ /** The cursor before any session is open. */
2
+ export const NO_UNDO = { sessionId: undefined, hidden: 0, lastRestored: '' };
3
+ /**
4
+ * How long an undo waits for an interrupted turn to close before giving up.
5
+ *
6
+ * The harness closes the turn as its abort settles, so a wait is needed; a
7
+ * bounded one keeps a stuck tool from leaving the key press unanswered.
8
+ */
9
+ export const UNDO_TURN_SETTLE_MS = 10_000;
10
+ /** The cursor at the tip of one session. */
11
+ export function resetUndo(sessionId) {
12
+ return { sessionId, hidden: 0, lastRestored: '' };
13
+ }
14
+ function asRecord(value) {
15
+ return typeof value === 'object' && value !== null ? value : undefined;
16
+ }
17
+ /** The text blocks of a direct prompt, joined the way the composer hands them back. */
18
+ function promptText(data) {
19
+ const content = asRecord(data)?.content;
20
+ const parts = [];
21
+ for (const block of Array.isArray(content) ? content : []) {
22
+ const text = asRecord(block)?.text;
23
+ if (typeof text === 'string')
24
+ parts.push(text);
25
+ }
26
+ return parts.join('\n');
27
+ }
28
+ /** Whether an event is the human's own prompt rather than injected context. */
29
+ function isDirectPrompt(event) {
30
+ return event.type === 'user/message' && asRecord(asRecord(event.data)?.source)?.kind === 'user';
31
+ }
32
+ /** Where each delivered prompt first entered the inbox, by message id. */
33
+ function deliveryIndex(events) {
34
+ const delivered = new Map();
35
+ for (let index = 0; index < events.length; index += 1) {
36
+ const event = events[index];
37
+ if (event?.type !== 'agent/inbox/spliced')
38
+ continue;
39
+ const inserted = asRecord(event.data)?.inserted;
40
+ for (const message of Array.isArray(inserted) ? inserted : []) {
41
+ const id = asRecord(message)?.id;
42
+ if (typeof id === 'string' && !delivered.has(id))
43
+ delivered.set(id, index);
44
+ }
45
+ }
46
+ return delivered;
47
+ }
48
+ /**
49
+ * The closed turns a direct prompt can be undone from, in log order.
50
+ *
51
+ * A turn is one `turn/start`...`turn/end` bracket; only a closed bracket with at least one direct prompt
52
+ * is a unit. Injected context also arrives as `user/message`, which is why the source kind is checked.
53
+ */
54
+ export function turnsOf(events) {
55
+ const delivered = deliveryIndex(events);
56
+ const turns = [];
57
+ let open;
58
+ for (let index = 0; index < events.length; index += 1) {
59
+ const event = events[index];
60
+ if (event === undefined)
61
+ continue;
62
+ if (event.type === 'turn/start') {
63
+ const turn = asRecord(event.data)?.turn;
64
+ open = { turn: typeof turn === 'number' ? turn : turns.length + 1, startIndex: index, seedCount: index };
65
+ continue;
66
+ }
67
+ if (open === undefined)
68
+ continue;
69
+ if (open.promptText === undefined && isDirectPrompt(event)) {
70
+ open.promptText = promptText(event.data);
71
+ const id = asRecord(event.data)?.id;
72
+ // A prompt enters the log as an inbox splice just before the turn it
73
+ // opens; a seed that kept that splice would make the branch deliver the
74
+ // very prompt the reader undid, so the cut is the splice, not the turn.
75
+ const splice = typeof id === 'string' ? delivered.get(id) : undefined;
76
+ open.seedCount = Math.min(open.startIndex, splice ?? open.startIndex);
77
+ continue;
78
+ }
79
+ if (event.type === 'turn/end') {
80
+ if (open.promptText !== undefined) {
81
+ turns.push({ turn: open.turn, seedCount: open.seedCount, promptText: open.promptText });
82
+ }
83
+ open = undefined;
84
+ }
85
+ }
86
+ return turns;
87
+ }
88
+ /** Step the cursor one turn back, or undefined when nothing is left to hide. */
89
+ export function undoStep(state, turns) {
90
+ if (state.hidden >= turns.length)
91
+ return undefined;
92
+ const hidden = state.hidden + 1;
93
+ return { ...state, hidden, lastRestored: turns[turns.length - hidden]?.promptText ?? state.lastRestored };
94
+ }
95
+ /** Step the cursor one turn forward, or undefined when it is already at the tip. */
96
+ export function redoStep(state, turns) {
97
+ if (state.hidden === 0)
98
+ return undefined;
99
+ const hidden = state.hidden - 1;
100
+ return { ...state, hidden, lastRestored: hidden === 0 ? '' : turns[turns.length - hidden]?.promptText ?? '' };
101
+ }
102
+ /** The oldest hidden turn: where a divergence forks, or undefined at the tip. */
103
+ export function hiddenTail(state, turns) {
104
+ return state.hidden === 0 ? undefined : turns[turns.length - state.hidden];
105
+ }
106
+ //# sourceMappingURL=undo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"undo.js","sourceRoot":"","sources":["../../src/agent/undo.ts"],"names":[],"mappings":"AA+BA,6CAA6C;AAC7C,MAAM,CAAC,MAAM,OAAO,GAAc,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC,EAAE,YAAY,EAAE,EAAE,EAAE,CAAA;AAEvF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAA;AAEzC,4CAA4C;AAC5C,MAAM,UAAU,SAAS,CAAC,SAAoB;IAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC,EAAE,YAAY,EAAE,EAAE,EAAE,CAAA;AACnD,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC,CAAC,CAAE,KAAiC,CAAC,CAAC,CAAC,SAAS,CAAA;AACrG,CAAC;AAED,uFAAuF;AACvF,SAAS,UAAU,CAAC,IAAa;IAC/B,MAAM,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,GAAG,CAAC,CAAA;IAC/B,OAAO,EAAE,GAAG,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,UAAU,IAAI,EAAE,EAAE,CAAA;AAC/G,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,UAAU,CAAC,KAAgB,EAAE,KAA2B;IACtE,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAA;AAC5E,CAAC"}
@@ -0,0 +1,68 @@
1
+ import { type ToolSubCall, type ToolSubCallRows, type ToolCard } from '../cards.ts';
2
+ /**
3
+ * Nested calls retained on one PTC card.
4
+ *
5
+ * A program can dispatch in a loop, and one line each is small but not free;
6
+ * the cap keeps a card bounded while {@link ToolCard.subCallsTotal} still
7
+ * reports everything the program ran.
8
+ */
9
+ export declare const SUBCALL_MAX = 100;
10
+ /**
11
+ * What the fold learned about one dispatched call, in the order it learned it.
12
+ *
13
+ * A call is logged twice — once when the program asks for it, once with what it
14
+ * answered — and each moment supplies part of the row: the call view names it,
15
+ * the result view says how it ended and what it produced.
16
+ */
17
+ export interface SubCallFacts {
18
+ /** The card the call declared, or nothing when no presenter answered for it. */
19
+ readonly view: ToolCard | undefined;
20
+ /** The rows the row opens to, once the call reported them. */
21
+ readonly output: ToolSubCallRows | undefined;
22
+ /** How the call finished, as the tool that ran it reported. */
23
+ readonly status: string | undefined;
24
+ /** Whether the call is logged and still unanswered. */
25
+ readonly running: boolean;
26
+ /** Whether the call is one the log marked as an error. */
27
+ readonly failed: boolean;
28
+ }
29
+ /**
30
+ * The one-line row for one nested call, as its start or its settle leaves it.
31
+ *
32
+ * A tool that declares a call view is drawn exactly as its own header would be;
33
+ * only a tool with no view at all falls back to its registry name and raw call,
34
+ * because the surface cannot name a salient argument for a schema it never saw.
35
+ * A settle logs the same call again, and the presenter that answered the first
36
+ * time is asked again for the view it would draw — so the row's identity comes
37
+ * from the row already on screen wherever there is one, and only a call that was
38
+ * dropped earlier is named from the log. The row also keeps how the call ended,
39
+ * because a program's calls are told apart by their outcomes rather than by
40
+ * anything the program itself says about them.
41
+ */
42
+ export declare function subCallRow(id: string, name: string, argumentsJson: string, facts: SubCallFacts, existing?: ToolSubCall): ToolSubCall;
43
+ /**
44
+ * The rows one dispatched call keeps, from the card that drew them.
45
+ *
46
+ * The total is clamped to what was kept: a card built from a call or result
47
+ * view reports no total of its own, because it is not a stream retention had to
48
+ * cut, and a count below the rows on screen would hint at rows already shown.
49
+ */
50
+ export declare function subCallRows(card: ToolCard | undefined): ToolSubCallRows | undefined;
51
+ /**
52
+ * The header fields a rebuilt card must keep.
53
+ *
54
+ * Replacing a card's rows says nothing about what the call was made with, what
55
+ * it measured, how it ended, or which calls it dispatched, so those fields
56
+ * travel with the rebuild: dropping the argument is how a shell card loses its
57
+ * command the moment a presenter declines the result.
58
+ */
59
+ export declare function carriedFields(card: ToolCard): Pick<ToolCard, 'argument' | 'stats' | 'status' | 'subCalls' | 'subCallsTotal'>;
60
+ /**
61
+ * Collapse one call and its result into the single row the reader sees.
62
+ *
63
+ * The pending row already told the reader what the tool is doing, so the
64
+ * settled row keeps that header and swaps in the outcome; a result that
65
+ * presents nothing keeps the call's detail rather than blanking the row.
66
+ */
67
+ export declare function mergeCards(call: ToolCard | undefined, result: ToolCard | undefined): ToolCard;
68
+ //# sourceMappingURL=composition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"composition.d.ts","sourceRoot":"","sources":["../../src/cards/composition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,eAAe,EAAE,KAAK,QAAQ,EAAY,MAAM,aAAa,CAAA;AAG7F;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,MAAM,CAAA;AAE9B;;;;;;GAMG;AACH,MAAM,WAAW,YAAY;IAC3B,gFAAgF;IAChF,QAAQ,CAAC,IAAI,EAAE,QAAQ,GAAG,SAAS,CAAA;IACnC,8DAA8D;IAC9D,QAAQ,CAAC,MAAM,EAAE,eAAe,GAAG,SAAS,CAAA;IAC5C,+DAA+D;IAC/D,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAA;IACnC,uDAAuD;IACvD,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IACzB,0DAA0D;IAC1D,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAA;CACzB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,QAAQ,CAAC,EAAE,WAAW,GAAG,WAAW,CAuBpI;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,QAAQ,GAAG,SAAS,GAAG,eAAe,GAAG,SAAS,CAGnF;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI,CAAC,QAAQ,EAAE,UAAU,GAAG,OAAO,GAAG,QAAQ,GAAG,UAAU,GAAG,eAAe,CAAC,CAQ5H;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,QAAQ,GAAG,SAAS,EAAE,MAAM,EAAE,QAAQ,GAAG,SAAS,GAAG,QAAQ,CA8B7F"}
@@ -0,0 +1,117 @@
1
+ import { clipLine } from "../cards.js";
2
+ import { title } from "./presenter.js";
3
+ /**
4
+ * Nested calls retained on one PTC card.
5
+ *
6
+ * A program can dispatch in a loop, and one line each is small but not free;
7
+ * the cap keeps a card bounded while {@link ToolCard.subCallsTotal} still
8
+ * reports everything the program ran.
9
+ */
10
+ export const SUBCALL_MAX = 100;
11
+ /**
12
+ * The one-line row for one nested call, as its start or its settle leaves it.
13
+ *
14
+ * A tool that declares a call view is drawn exactly as its own header would be;
15
+ * only a tool with no view at all falls back to its registry name and raw call,
16
+ * because the surface cannot name a salient argument for a schema it never saw.
17
+ * A settle logs the same call again, and the presenter that answered the first
18
+ * time is asked again for the view it would draw — so the row's identity comes
19
+ * from the row already on screen wherever there is one, and only a call that was
20
+ * dropped earlier is named from the log. The row also keeps how the call ended,
21
+ * because a program's calls are told apart by their outcomes rather than by
22
+ * anything the program itself says about them.
23
+ */
24
+ export function subCallRow(id, name, argumentsJson, facts, existing) {
25
+ const { view, output, status, running, failed } = facts;
26
+ const title = view?.title ?? existing?.title ?? name;
27
+ const raw = view !== undefined || existing !== undefined ? undefined : clipLine(argumentsJson);
28
+ const argument = view?.argument ?? existing?.argument ?? raw;
29
+ // A failed call keeps only what still holds: the change it declared never
30
+ // happened, so the rows that drew as applied go with the outcome that never
31
+ // came. Its outcome stays, because the reason it failed is what a reader opens
32
+ // the row to read.
33
+ const presented = failed ? undefined : subCallRows(view) ?? existing?.presented;
34
+ // A settle that reports nothing keeps what the row already said about its own
35
+ // outcome, because a call does not stop having finished a certain way.
36
+ const ended = status ?? existing?.status;
37
+ return {
38
+ id,
39
+ title,
40
+ ...(argument === undefined || argument === '' ? {} : { argument }),
41
+ ...(ended === undefined || ended === '' ? {} : { status: ended }),
42
+ failed,
43
+ running,
44
+ ...(presented === undefined ? {} : { presented }),
45
+ ...(output === undefined ? {} : { output }),
46
+ };
47
+ }
48
+ /**
49
+ * The rows one dispatched call keeps, from the card that drew them.
50
+ *
51
+ * The total is clamped to what was kept: a card built from a call or result
52
+ * view reports no total of its own, because it is not a stream retention had to
53
+ * cut, and a count below the rows on screen would hint at rows already shown.
54
+ */
55
+ export function subCallRows(card) {
56
+ if (card === undefined || card.detail.length === 0)
57
+ return undefined;
58
+ return { kind: card.kind, rows: card.detail, totalLines: Math.max(card.totalLines, card.detail.length) };
59
+ }
60
+ /**
61
+ * The header fields a rebuilt card must keep.
62
+ *
63
+ * Replacing a card's rows says nothing about what the call was made with, what
64
+ * it measured, how it ended, or which calls it dispatched, so those fields
65
+ * travel with the rebuild: dropping the argument is how a shell card loses its
66
+ * command the moment a presenter declines the result.
67
+ */
68
+ export function carriedFields(card) {
69
+ return {
70
+ ...(card.argument === undefined ? {} : { argument: card.argument }),
71
+ ...(card.stats === undefined ? {} : { stats: card.stats }),
72
+ ...(card.status === undefined ? {} : { status: card.status }),
73
+ ...(card.subCalls === undefined ? {} : { subCalls: card.subCalls }),
74
+ ...(card.subCallsTotal === undefined ? {} : { subCallsTotal: card.subCallsTotal }),
75
+ };
76
+ }
77
+ /**
78
+ * Collapse one call and its result into the single row the reader sees.
79
+ *
80
+ * The pending row already told the reader what the tool is doing, so the
81
+ * settled row keeps that header and swaps in the outcome; a result that
82
+ * presents nothing keeps the call's detail rather than blanking the row.
83
+ */
84
+ export function mergeCards(call, result) {
85
+ const base = call ?? result;
86
+ if (base === undefined)
87
+ throw new Error('mergeCards requires at least one card');
88
+ if (call === undefined || result === undefined)
89
+ return base;
90
+ const kind = result.kind === 'generic' ? call.kind : result.kind;
91
+ // The result, when it names one, knows the argument that was actually acted
92
+ // on; a terminal result omits it, so the pending call's command is kept. The
93
+ // result also owns the measured facts, because only it knows the outcome.
94
+ const argument = result.argument ?? call.argument;
95
+ const stats = result.stats ?? call.stats;
96
+ const status = result.status ?? call.status;
97
+ // The nested calls belong to the call, not the outcome: a result never carries
98
+ // them, so the merge has to hand the call's own list through.
99
+ const subCalls = result.subCalls ?? call.subCalls;
100
+ const subCallsTotal = result.subCallsTotal ?? call.subCallsTotal;
101
+ return {
102
+ kind,
103
+ // The tool that ran is the call's identity: a result card describes the same
104
+ // call, so it cannot rename the message a reader's clicks are remembered by.
105
+ tool: call.tool,
106
+ title: call.title,
107
+ ...(argument === undefined ? {} : { argument }),
108
+ ...(stats === undefined ? {} : { stats }),
109
+ ...(status === undefined ? {} : { status }),
110
+ ...(subCalls === undefined ? {} : { subCalls }),
111
+ ...(subCallsTotal === undefined ? {} : { subCallsTotal }),
112
+ detail: result.detail.length > 0 ? result.detail : call.detail,
113
+ failed: result.failed,
114
+ totalLines: result.detail.length > 0 ? result.totalLines : call.totalLines,
115
+ };
116
+ }
117
+ //# sourceMappingURL=composition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"composition.js","sourceRoot":"","sources":["../../src/cards/composition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyD,QAAQ,EAAE,MAAM,aAAa,CAAA;AAC7F,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAEtC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,CAAA;AAsB9B;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,UAAU,CAAC,EAAU,EAAE,IAAY,EAAE,aAAqB,EAAE,KAAmB,EAAE,QAAsB;IACrH,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,KAAK,CAAA;IACvD,MAAM,KAAK,GAAG,IAAI,EAAE,KAAK,IAAI,QAAQ,EAAE,KAAK,IAAI,IAAI,CAAA;IACpD,MAAM,GAAG,GAAG,IAAI,KAAK,SAAS,IAAI,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAA;IAC9F,MAAM,QAAQ,GAAG,IAAI,EAAE,QAAQ,IAAI,QAAQ,EAAE,QAAQ,IAAI,GAAG,CAAA;IAC5D,0EAA0E;IAC1E,4EAA4E;IAC5E,+EAA+E;IAC/E,mBAAmB;IACnB,MAAM,SAAS,GAAG,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,QAAQ,EAAE,SAAS,CAAA;IAC/E,8EAA8E;IAC9E,uEAAuE;IACvE,MAAM,KAAK,GAAG,MAAM,IAAI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G,MAAM,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,CAAA;IACjD,MAAM,aAAa,GAAG,MAAM,CAAC,aAAa,IAAI,IAAI,CAAC,aAAa,CAAA;IAChE,OAAO;QACL,IAAI;QACJ,6EAA6E;QAC7E,6EAA6E;QAC7E,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,GAAG,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC;QAC/C,GAAG,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC;QACzC,GAAG,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC;QAC3C,GAAG,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC;QAC/C,GAAG,CAAC,aAAa,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,CAAC;QACzD,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM;QAC9D,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU;KAC3E,CAAA;AACH,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { type CardRow, type ToolCard } from '../cards.ts';
2
+ import { type FileDiff, type ToolCallView, type ToolResultView } from '@deepseek-ai/dsh-tools';
3
+ /**
4
+ * Render one file change as a bounded unified hunk.
5
+ *
6
+ * Only the changed middle is shown: a presenter has the prior and next text but
7
+ * no hunk list, so trimming the shared prefix and suffix yields the same region
8
+ * a full diff would highlight without paying for a line-diff computation on
9
+ * every frame.
10
+ */
11
+ export declare function renderFileDiff(diff: FileDiff): CardRow[];
12
+ export declare function title(view: {
13
+ title?: string;
14
+ }, fallback: string): string;
15
+ /** Map a tool's pending-call intent to a card, falling back to the raw call name. */
16
+ export declare function cardOfCall(view: ToolCallView | undefined, name: string): ToolCard;
17
+ /** Map a tool's result intent to a card, falling back to the model-facing text. */
18
+ export declare function cardOfResult(view: ToolResultView | undefined, input: {
19
+ readonly name: string;
20
+ readonly failed: boolean;
21
+ readonly contentLines: readonly string[];
22
+ }): ToolCard;
23
+ //# sourceMappingURL=presenter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"presenter.d.ts","sourceRoot":"","sources":["../../src/cards/presenter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAA0B,KAAK,QAAQ,EAAkC,MAAM,aAAa,CAAA;AACjH,OAAO,EAA0C,KAAK,QAAQ,EAA4I,KAAK,YAAY,EAAE,KAAK,cAAc,EAAsB,MAAM,wBAAwB,CAAA;AAoGpS;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO,EAAE,CAsBxD;AAaD,wBAAgB,KAAK,CAAC,IAAI,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAKxE;AAkBD,qFAAqF;AACrF,wBAAgB,UAAU,CAAC,IAAI,EAAE,YAAY,GAAG,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,QAAQ,CAgEjF;AAED,mFAAmF;AACnF,wBAAgB,YAAY,CAC1B,IAAI,EAAE,cAAc,GAAG,SAAS,EAChC,KAAK,EAAE;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,GACnG,QAAQ,CAoJV"}