dispach 0.2.1 → 0.2.3

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 (224) hide show
  1. package/README.md +94 -36
  2. package/dist/APEv2Parser-ysjr6adv.js +5 -0
  3. package/dist/{FlacParser-bf8y3e0w.js.map → APEv2Parser-ysjr6adv.js.map} +1 -1
  4. package/dist/{AiffParser-tbx3xkmk.js → AiffParser-9hj6fpmy.js} +3 -3
  5. package/dist/{AiffParser-tbx3xkmk.js.map → AiffParser-9hj6fpmy.js.map} +1 -1
  6. package/dist/App-2f72vhjv.js +11 -0
  7. package/dist/{App-hjn867nc.js.map → App-2f72vhjv.js.map} +3 -3
  8. package/dist/{AsfParser-d784ak3y.js → AsfParser-7emspn04.js} +3 -3
  9. package/dist/{AsfParser-d784ak3y.js.map → AsfParser-7emspn04.js.map} +1 -1
  10. package/dist/{ConfigEditor-g7eb2wsm.js → ConfigEditor-vk7vxaa6.js} +3 -3
  11. package/dist/{ConfigEditor-g7eb2wsm.js.map → ConfigEditor-vk7vxaa6.js.map} +1 -1
  12. package/dist/{DsdiffParser-vxnfx80c.js → DsdiffParser-dz88pnnr.js} +3 -3
  13. package/dist/{DsdiffParser-vxnfx80c.js.map → DsdiffParser-dz88pnnr.js.map} +1 -1
  14. package/dist/{DsfParser-0xsh0zzk.js → DsfParser-qgh63tbs.js} +3 -3
  15. package/dist/{DsfParser-0xsh0zzk.js.map → DsfParser-qgh63tbs.js.map} +1 -1
  16. package/dist/FlacParser-drm5wq0p.js +5 -0
  17. package/dist/{APEv2Parser-9wqew3zv.js.map → FlacParser-drm5wq0p.js.map} +1 -1
  18. package/dist/{KeyProbe-w8c37s9q.js → KeyProbe-5anphmb7.js} +3 -3
  19. package/dist/{KeyProbe-w8c37s9q.js.map → KeyProbe-5anphmb7.js.map} +1 -1
  20. package/dist/{MP4Parser-tq7r7wd4.js → MP4Parser-yr7p3z12.js} +3 -3
  21. package/dist/{MP4Parser-tq7r7wd4.js.map → MP4Parser-yr7p3z12.js.map} +1 -1
  22. package/dist/{MatroskaParser-a79gsmzb.js → MatroskaParser-jkbsbsk3.js} +3 -3
  23. package/dist/{MatroskaParser-a79gsmzb.js.map → MatroskaParser-jkbsbsk3.js.map} +1 -1
  24. package/dist/{MpegParser-zs61b3wq.js → MpegParser-t93vwnew.js} +3 -3
  25. package/dist/{MpegParser-zs61b3wq.js.map → MpegParser-t93vwnew.js.map} +1 -1
  26. package/dist/{MusepackParser-bp8dm6nz.js → MusepackParser-6e8kbh2d.js} +3 -3
  27. package/dist/{MusepackParser-bp8dm6nz.js.map → MusepackParser-6e8kbh2d.js.map} +1 -1
  28. package/dist/OggParser-ggcypmag.js +5 -0
  29. package/dist/{OggParser-7pxr1sn9.js.map → OggParser-ggcypmag.js.map} +1 -1
  30. package/dist/Picker-j7txnm7w.js +5 -0
  31. package/dist/{Picker-b09hr4tk.js.map → Picker-j7txnm7w.js.map} +1 -1
  32. package/dist/SessionPicker-hpv2ncsb.js +5 -0
  33. package/dist/{SessionPicker-wtfxwdxg.js.map → SessionPicker-hpv2ncsb.js.map} +3 -3
  34. package/dist/SkillBrowser-qc542n71.js +5 -0
  35. package/dist/{SkillBrowser-p9ht63c7.js.map → SkillBrowser-qc542n71.js.map} +1 -1
  36. package/dist/{WavPackParser-gpf3r92t.js → WavPackParser-jw9stzqp.js} +3 -3
  37. package/dist/{WavPackParser-gpf3r92t.js.map → WavPackParser-jw9stzqp.js.map} +1 -1
  38. package/dist/{WaveParser-3kcak550.js → WaveParser-epmncs9w.js} +3 -3
  39. package/dist/{WaveParser-3kcak550.js.map → WaveParser-epmncs9w.js.map} +1 -1
  40. package/dist/WizardApp-pgzcz9zq.js +5 -0
  41. package/dist/{WizardApp-494018sk.js.map → WizardApp-pgzcz9zq.js.map} +3 -3
  42. package/dist/{channels-yhdvxxrb.js → channels-m8nambmm.js} +14 -14
  43. package/dist/{channels-yhdvxxrb.js.map → channels-m8nambmm.js.map} +1 -1
  44. package/dist/client.d.ts +285 -1
  45. package/dist/client.js +11 -11
  46. package/dist/client.js.map +5 -5
  47. package/dist/components/App.d.ts.map +1 -1
  48. package/dist/{config-g0ybmm4t.js → config-hmgrqgf2.js} +17 -17
  49. package/dist/{config-g0ybmm4t.js.map → config-hmgrqgf2.js.map} +1 -1
  50. package/dist/{credential-pkme1sfe.js → credential-nkb2ya59.js} +5 -5
  51. package/dist/{credential-pkme1sfe.js.map → credential-nkb2ya59.js.map} +1 -1
  52. package/dist/{index-q8b1fc3k.js → index-0444sh6x.js} +4 -4
  53. package/dist/{index-q8b1fc3k.js.map → index-0444sh6x.js.map} +1 -1
  54. package/dist/{index-ec101x93.js → index-095hrkyr.js} +6 -6
  55. package/dist/{index-ec101x93.js.map → index-095hrkyr.js.map} +1 -1
  56. package/dist/index-1mbdz3f7.js +12 -0
  57. package/dist/{index-3fgq1acj.js.map → index-1mbdz3f7.js.map} +3 -3
  58. package/dist/index-1x8mzvz7.js +6 -0
  59. package/dist/{index-f056wkb4.js.map → index-1x8mzvz7.js.map} +1 -1
  60. package/dist/{index-633eqxry.js → index-22fzzn7z.js} +7 -7
  61. package/dist/{index-633eqxry.js.map → index-22fzzn7z.js.map} +1 -1
  62. package/dist/index-2bsardvh.js +5 -0
  63. package/dist/{index-9dmgk6d3.js.map → index-2bsardvh.js.map} +2 -2
  64. package/dist/{index-thmq816c.js → index-2zjh5zd5.js} +4 -4
  65. package/dist/{index-thmq816c.js.map → index-2zjh5zd5.js.map} +1 -1
  66. package/dist/{index-ad5c9t83.js → index-308y9xt0.js} +4 -4
  67. package/dist/{index-ad5c9t83.js.map → index-308y9xt0.js.map} +1 -1
  68. package/dist/{index-t6xnecdx.js → index-323jvr1g.js} +4 -4
  69. package/dist/{index-t6xnecdx.js.map → index-323jvr1g.js.map} +1 -1
  70. package/dist/{index-mn34kj95.js → index-3826kf9t.js} +5 -5
  71. package/dist/{index-mn34kj95.js.map → index-3826kf9t.js.map} +1 -1
  72. package/dist/index-38gs9anh.js +9 -0
  73. package/dist/{index-akv6e7ge.js.map → index-38gs9anh.js.map} +1 -1
  74. package/dist/index-3c5jt6by.js +5 -0
  75. package/dist/{index-3b3h8kyh.js.map → index-3c5jt6by.js.map} +2 -2
  76. package/dist/{index-a6mtqkth.js → index-3vzf253k.js} +7 -7
  77. package/dist/{index-a6mtqkth.js.map → index-3vzf253k.js.map} +1 -1
  78. package/dist/{index-5m9wydxb.js → index-42e29zs4.js} +4 -4
  79. package/dist/{index-5m9wydxb.js.map → index-42e29zs4.js.map} +1 -1
  80. package/dist/{index-v7mz396x.js → index-4fj1k64j.js} +4 -4
  81. package/dist/{index-v7mz396x.js.map → index-4fj1k64j.js.map} +1 -1
  82. package/dist/{index-s2tzq27a.js → index-51x0n5z0.js} +5 -5
  83. package/dist/{index-s2tzq27a.js.map → index-51x0n5z0.js.map} +1 -1
  84. package/dist/index-836hc2h1.js +6 -0
  85. package/dist/{index-xa9crtzq.js.map → index-836hc2h1.js.map} +2 -2
  86. package/dist/index-8edck2pr.js +6 -0
  87. package/dist/{index-7gsbzvnc.js.map → index-8edck2pr.js.map} +1 -1
  88. package/dist/index-8tmv33mr.js +6 -0
  89. package/dist/{index-vw2hf4d8.js.map → index-8tmv33mr.js.map} +1 -1
  90. package/dist/index-9t4dz145.js +8 -0
  91. package/dist/{index-0mz7wpbw.js.map → index-9t4dz145.js.map} +2 -2
  92. package/dist/{index-81vj1bxe.js → index-bqdkm3de.js} +4 -4
  93. package/dist/{index-81vj1bxe.js.map → index-bqdkm3de.js.map} +1 -1
  94. package/dist/index-djeqvfms.js +74 -0
  95. package/dist/index-djeqvfms.js.map +13 -0
  96. package/dist/{index-307qmvb0.js → index-dpcm1j62.js} +28 -28
  97. package/dist/{index-307qmvb0.js.map → index-dpcm1j62.js.map} +1 -1
  98. package/dist/index-dv9pdjy4.js +429 -0
  99. package/dist/index-dv9pdjy4.js.map +12 -0
  100. package/dist/{index-j20k6k0m.js → index-dzy19wtf.js} +4 -4
  101. package/dist/{index-j20k6k0m.js.map → index-dzy19wtf.js.map} +1 -1
  102. package/dist/{index-9qv87rq7.js → index-eztfverw.js} +7 -7
  103. package/dist/{index-9qv87rq7.js.map → index-eztfverw.js.map} +1 -1
  104. package/dist/{index-myg5enf5.js → index-fbsrhcga.js} +4 -4
  105. package/dist/{index-myg5enf5.js.map → index-fbsrhcga.js.map} +1 -1
  106. package/dist/{index-6r9h7ftn.js → index-fxpmx6cr.js} +117 -117
  107. package/dist/index-fxpmx6cr.js.map +21 -0
  108. package/dist/{index-ye2yb3xf.js → index-hgm2gchq.js} +6 -6
  109. package/dist/{index-ye2yb3xf.js.map → index-hgm2gchq.js.map} +1 -1
  110. package/dist/index-hpvfqq6r.js +1252 -0
  111. package/dist/{index-26ejkp8q.js.map → index-hpvfqq6r.js.map} +30 -26
  112. package/dist/{index-y34s71qe.js → index-hrwakb11.js} +3 -3
  113. package/dist/{index-y34s71qe.js.map → index-hrwakb11.js.map} +1 -1
  114. package/dist/{index-qh82wtpa.js → index-jc4kmfwa.js} +4 -4
  115. package/dist/{index-qh82wtpa.js.map → index-jc4kmfwa.js.map} +1 -1
  116. package/dist/{index-twcgf73h.js → index-jff5q27j.js} +4 -4
  117. package/dist/{index-twcgf73h.js.map → index-jff5q27j.js.map} +1 -1
  118. package/dist/index-k8e9f466.js +110 -0
  119. package/dist/index-k8e9f466.js.map +13 -0
  120. package/dist/{index-trx9xb59.js → index-m6fqx0ch.js} +7 -7
  121. package/dist/{index-trx9xb59.js.map → index-m6fqx0ch.js.map} +1 -1
  122. package/dist/{index-ac2wzspd.js → index-mjfv7k5w.js} +4 -4
  123. package/dist/{index-ac2wzspd.js.map → index-mjfv7k5w.js.map} +1 -1
  124. package/dist/index-nvc24414.js +6 -0
  125. package/dist/{index-1f1erzfx.js.map → index-nvc24414.js.map} +1 -1
  126. package/dist/index-nxhqf597.js +6 -0
  127. package/dist/{index-w97gprre.js.map → index-nxhqf597.js.map} +1 -1
  128. package/dist/{index-jh2az41t.js → index-p6ya59m6.js} +5 -5
  129. package/dist/{index-jh2az41t.js.map → index-p6ya59m6.js.map} +1 -1
  130. package/dist/{index-psk6q25h.js → index-pqw1n1pv.js} +4 -4
  131. package/dist/{index-psk6q25h.js.map → index-pqw1n1pv.js.map} +1 -1
  132. package/dist/{index-6c4p19m1.js → index-pszmnhgq.js} +2 -2
  133. package/dist/index-qgsdgbk8.js +5 -0
  134. package/dist/{index-wk6andxq.js.map → index-qgsdgbk8.js.map} +2 -2
  135. package/dist/index-qv6ktepc.js +6 -0
  136. package/dist/index-qv6ktepc.js.map +10 -0
  137. package/dist/{index-pdsey1ab.js → index-ry6a4bqh.js} +62 -62
  138. package/dist/{index-pdsey1ab.js.map → index-ry6a4bqh.js.map} +1 -1
  139. package/dist/{index-x9z2xnct.js → index-sh44ymqz.js} +5 -5
  140. package/dist/{index-x9z2xnct.js.map → index-sh44ymqz.js.map} +1 -1
  141. package/dist/{index-zg89tq04.js → index-snz49ndn.js} +4 -4
  142. package/dist/{index-zg89tq04.js.map → index-snz49ndn.js.map} +1 -1
  143. package/dist/{index-zjphh8ch.js → index-xg7s813b.js} +4 -4
  144. package/dist/{index-zjphh8ch.js.map → index-xg7s813b.js.map} +1 -1
  145. package/dist/{index-gqaa06yh.js → index-y7dxq4a4.js} +9 -9
  146. package/dist/{index-gqaa06yh.js.map → index-y7dxq4a4.js.map} +1 -1
  147. package/dist/index-ytxbw8py.js +63 -0
  148. package/dist/{index-0pddq849.js.map → index-ytxbw8py.js.map} +2 -2
  149. package/dist/index-yw3fby4n.js +6 -0
  150. package/dist/{index-4emtktc0.js.map → index-yw3fby4n.js.map} +2 -2
  151. package/dist/{index-skkddg44.js → index-zw6wyas6.js} +4 -4
  152. package/dist/{index-skkddg44.js.map → index-zw6wyas6.js.map} +1 -1
  153. package/dist/index.js +304 -288
  154. package/dist/index.js.map +15 -12
  155. package/dist/init.d.ts.map +1 -1
  156. package/dist/lib/agent-template.d.ts +5 -0
  157. package/dist/lib/agent-template.d.ts.map +1 -1
  158. package/dist/lib/commands.d.ts.map +1 -1
  159. package/dist/lib/init-flow.d.ts +7 -30
  160. package/dist/lib/init-flow.d.ts.map +1 -1
  161. package/dist/lib/owner.d.ts +49 -0
  162. package/dist/lib/owner.d.ts.map +1 -0
  163. package/dist/lib/presets.d.ts +44 -0
  164. package/dist/lib/presets.d.ts.map +1 -0
  165. package/dist/lib/provision.d.ts +8 -1
  166. package/dist/lib/provision.d.ts.map +1 -1
  167. package/dist/lib/relay-client.d.ts +17 -0
  168. package/dist/lib/relay-client.d.ts.map +1 -0
  169. package/dist/lib/schema.d.ts +2 -0
  170. package/dist/lib/schema.d.ts.map +1 -1
  171. package/dist/lib/sessions-view.d.ts +2 -0
  172. package/dist/lib/sessions-view.d.ts.map +1 -1
  173. package/dist/lib/source.d.ts +25 -0
  174. package/dist/lib/source.d.ts.map +1 -1
  175. package/dist/lib/types.d.ts +8 -2
  176. package/dist/lib/types.d.ts.map +1 -1
  177. package/dist/lib/wizard.d.ts.map +1 -1
  178. package/dist/owner.d.ts +16 -0
  179. package/dist/owner.d.ts.map +1 -0
  180. package/dist/run.d.ts.map +1 -1
  181. package/dist/serve.d.ts.map +1 -1
  182. package/dist/transcript.d.ts.map +1 -1
  183. package/dist/{web-f6869dy2.js → web-gfv0mzgs.js} +7 -7
  184. package/dist/{web-f6869dy2.js.map → web-gfv0mzgs.js.map} +1 -1
  185. package/dist/wire.d.ts +50 -0
  186. package/dist/wire.js +5 -5
  187. package/dist/wire.js.map +4 -4
  188. package/dist/wrapper-f662ny3r.js +5 -0
  189. package/dist/{wrapper-52c0vacs.js.map → wrapper-f662ny3r.js.map} +1 -1
  190. package/package.json +4 -1
  191. package/dist/APEv2Parser-9wqew3zv.js +0 -5
  192. package/dist/App-hjn867nc.js +0 -11
  193. package/dist/FlacParser-bf8y3e0w.js +0 -5
  194. package/dist/OggParser-7pxr1sn9.js +0 -5
  195. package/dist/Picker-b09hr4tk.js +0 -5
  196. package/dist/SessionPicker-wtfxwdxg.js +0 -5
  197. package/dist/SkillBrowser-p9ht63c7.js +0 -5
  198. package/dist/WizardApp-494018sk.js +0 -5
  199. package/dist/index-0mz7wpbw.js +0 -8
  200. package/dist/index-0pddq849.js +0 -63
  201. package/dist/index-1f1erzfx.js +0 -6
  202. package/dist/index-26ejkp8q.js +0 -1194
  203. package/dist/index-3b3h8kyh.js +0 -5
  204. package/dist/index-3fgq1acj.js +0 -12
  205. package/dist/index-4emtktc0.js +0 -6
  206. package/dist/index-4t3p7vm9.js +0 -6
  207. package/dist/index-4t3p7vm9.js.map +0 -10
  208. package/dist/index-6r9h7ftn.js.map +0 -21
  209. package/dist/index-7gsbzvnc.js +0 -6
  210. package/dist/index-94k4mh6s.js +0 -96
  211. package/dist/index-94k4mh6s.js.map +0 -13
  212. package/dist/index-9dmgk6d3.js +0 -5
  213. package/dist/index-akv6e7ge.js +0 -9
  214. package/dist/index-f056wkb4.js +0 -6
  215. package/dist/index-s57ztjhq.js +0 -74
  216. package/dist/index-s57ztjhq.js.map +0 -13
  217. package/dist/index-vw2hf4d8.js +0 -6
  218. package/dist/index-w97gprre.js +0 -6
  219. package/dist/index-wk6andxq.js +0 -5
  220. package/dist/index-xa9crtzq.js +0 -6
  221. package/dist/index-z0dgxd7d.js +0 -429
  222. package/dist/index-z0dgxd7d.js.map +0 -11
  223. package/dist/wrapper-52c0vacs.js +0 -5
  224. /package/dist/{index-6c4p19m1.js.map → index-pszmnhgq.js.map} +0 -0
@@ -2,7 +2,7 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/components/App.tsx", "../src/components/CommandOutput.tsx", "../src/components/HistorySearch.tsx", "../src/components/Live.tsx", "../src/components/Palette.tsx", "../src/components/Prompt.tsx", "../src/components/StatusBar.tsx", "../src/components/Transcript.tsx", "../src/lib/scroll.ts", "../src/lib/text-selection.ts", "../src/hooks/useElapsed.ts", "../src/hooks/useTurn.ts", "../src/lib/chat-frame.ts", "../src/lib/clipboard.ts", "../src/lib/subcommand.ts"],
4
4
  "sourcesContent": [
5
- "/**\n * The chat surface — a full-screen session on the alternate buffer.\n *\n * Thin on purpose. Everything worth testing lives in pure modules — `keymap.ts` decides what a keystroke\n * means, `editor.ts` applies it to the line, `transcript.ts` turns bus events into rows, `lib/scroll.ts`\n * moves the window, `lib/chat-frame.ts` decides how many rows each part of the frame may have — so this\n * file is composition plus the decisions that need Ink itself: when to unmount, what to do about a\n * submission arriving mid-turn, and which surface currently owns the keyboard.\n *\n * ## What Phase 5.5 changed here\n *\n * The conversation is no longer in `<Static>`. It is a buffer of rows with a window over it, because\n * `<Static>` writes to the scrollback and the alternate screen discards its buffer on the way out — the\n * two cannot both be true. That has two consequences worth stating before editing:\n *\n * - **The frame has a hard height.** Everything visible must add up to at most the terminal's rows, or\n * Ink's own output scrolls the buffer and the layout comes apart. `chatFrame` owns that arithmetic; no\n * row count is invented in this file.\n * - **^C at an idle prompt takes two presses.** With the buffer discarded on exit, a single reflexive ^C\n * during a long reply would throw the visible conversation away. `keymap.ts` owns the decision; the\n * timer that expires it lives here, because a pure function cannot hold a clock.\n *\n * The Ctrl-C contract from Phase 1 is otherwise unchanged: during a turn it cancels the turn and the\n * prompt comes back.\n */\n\nimport { BRAND, VERSION } from \"@dispach/core\"\nimport { Box, Text, useApp, useInput } from \"ink\"\nimport { type ComponentType, useCallback, useEffect, useMemo, useRef, useState } from \"react\"\nimport { BRAND_INDENT, Brandmark } from \"#components/Brandmark\"\nimport { CommandOutput } from \"#components/CommandOutput\"\nimport type { ConfigEditorProps } from \"#components/ConfigEditor\"\nimport { HistorySearch } from \"#components/HistorySearch\"\nimport { Live } from \"#components/Live\"\nimport { Palette } from \"#components/Palette\"\nimport { Prompt } from \"#components/Prompt\"\nimport type { SessionPickerProps } from \"#components/SessionPicker\"\nimport type { SkillBrowserProps } from \"#components/SkillBrowser\"\nimport { Spinner } from \"#components/Spinner\"\nimport { StatusBar } from \"#components/StatusBar\"\nimport { Transcript } from \"#components/Transcript\"\nimport { applyIntent, EMPTY_EDITOR, selectionRange, submit } from \"#editor\"\nimport { useElapsed } from \"#hooks/useElapsed\"\nimport { useTerminalSize } from \"#hooks/useTerminalSize\"\nimport { useTurn } from \"#hooks/useTurn\"\nimport { keyContext, keyToIntent } from \"#keymap\"\nimport { chatFrame, composerHit, transcriptHit, transcriptRowsAfterBrand } from \"#lib/chat-frame\"\nimport { copyToClipboard } from \"#lib/clipboard\"\nimport type { EditorRow } from \"#lib/config-editor\"\nimport { applyEditorRow, editorRowsFor } from \"#lib/config-rows\"\nimport {\n EXIT_ARM_MS,\n FALLBACK_COLUMNS,\n LANDING_LIST_ROWS,\n MULTI_CLICK_MS,\n SEARCH_ROWS,\n SESSION_PICKER_ROWS,\n} from \"#lib/const\"\nimport { offeredCommands, paletteEntries, paletteFor, paletteSelection } from \"#lib/palette\"\nimport type { AppProps } from \"#lib/schema\"\nimport { screenColumns, titleLine } from \"#lib/screen\"\nimport { FOLLOWING, scroll, slice } from \"#lib/scroll\"\nimport {\n NEW_SESSION_HINT,\n resolveSessionCommand,\n sessionHelpText,\n type ToolsView,\n toolsReport,\n unknownCommandText,\n} from \"#lib/session-commands\"\nimport type { SessionRowSource } from \"#lib/sessions-view\"\nimport { runSubcommand } from \"#lib/subcommand\"\nimport {\n beginSelection,\n dragSelection,\n endSelection,\n extendSelection,\n lineAt,\n selectedText,\n type TextPoint,\n type TextSelection,\n wordAt,\n} from \"#lib/text-selection\"\nimport { THEME } from \"#lib/theme\"\nimport { wordmark } from \"#lib/wordmark\"\nimport { lastStats, transcriptRows } from \"#transcript\"\n\n/**\n * What is layered over the conversation.\n *\n * `output` is a command's captured text; `skills` is the one bespoke view a session hosts so far. Both\n * take the keyboard while open and both *replace* the transcript rather than sitting under it — sharing\n * the screen pushed the conversation off the top of a full-screen frame, which on a surface with no\n * scrollback means gone. Closing either returns to the prompt with the draft untouched, which is what\n * makes a pane an interlude rather than a detour.\n */\ntype Pane =\n | { readonly kind: \"none\" }\n | {\n readonly kind: \"output\"\n readonly label: string\n readonly lines: readonly string[] | undefined\n readonly code?: number\n readonly offset: number\n }\n | { readonly kind: \"skills\" }\n /**\n * The conversation switcher. `undefined` while the store is being read.\n *\n * Loaded when the pane opens rather than kept current, because the list changes only when a turn ends\n * and re-reading it on every frame would put a database query in the render path.\n */\n | { readonly kind: \"sessions\"; readonly stored: readonly SessionRowSource[] | undefined }\n /**\n * The settings editor. `rows` is read when the pane opens, not kept current.\n *\n * Read once because the editor re-reads after each write of its own — keeping it live here would put\n * a file read in the render path for a surface that already knows when it has changed something.\n */\n | { readonly kind: \"config\"; readonly rows: readonly EditorRow[] }\n\nexport function App({\n source,\n sessionKey,\n model,\n agentName,\n warnings,\n freshSession,\n initial,\n correctKeys,\n showReasoning,\n quiet,\n onRestart,\n onSwitch,\n onNew,\n sessions,\n initialDraft,\n manifestPath,\n catalogue,\n status,\n contextView,\n}: AppProps) {\n const { exit } = useApp()\n const size = useTerminalSize()\n const columns = screenColumns(size.columns, FALLBACK_COLUMNS)\n const { state, busy, send, cancel, note, trim } = useTurn({ source, sessionKey, initial })\n // A draft handed in by a `/restart` opens the prompt with the cursor at its end, which is where the\n // person left it. Only the initial value — a later prop change must not overwrite what is being\n // typed now, which is exactly what `useState`'s initialiser semantics give for free.\n const [editor, setEditor] = useState(() =>\n initialDraft === undefined || initialDraft === \"\"\n ? EMPTY_EDITOR\n : { ...EMPTY_EDITOR, value: initialDraft, cursor: [...initialDraft].length },\n )\n\n /**\n * What is on top of the conversation, if anything.\n *\n * A pane is *focused* while it is open, so the prompt's `useInput` stands down — Ink fires every\n * active hook, and two surfaces reading one keystroke is the bug the focus rule exists to prevent.\n */\n const [pane, setPane] = useState<Pane>({ kind: \"none\" })\n /**\n * The skills view's implementation, loaded when it is first opened.\n *\n * Dynamically, and that is not an optimisation. `browse.ts` also imports this component dynamically,\n * and bun's `--splitting` emits a module's exports **twice** when one importer is static and another is\n * dynamic — producing a bundle that dies at parse time with `Duplicate export of 'SkillBrowser'`, which\n * no test that imports source can see. The props come in as a type, which is erased and creates no\n * edge. `boundaries.test.ts` bans the mixing outright.\n */\n const [Browser, setBrowser] = useState<ComponentType<SkillBrowserProps> | undefined>(undefined)\n /**\n * The session switcher's implementation, loaded when the pane first opens.\n *\n * Dynamically for the same reason `Browser` is, and it was caught by the boundaries test rather than\n * remembered: `run.ts` mounts this component too, for a bare `--session` before any chat exists. One\n * static importer and one dynamic one makes bun's `--splitting` emit its exports **twice**, and the\n * built binary then dies at parse time with `Duplicate export of 'SessionPicker'` while every test —\n * which imports source — passes. Both edges dynamic, no duplicate.\n */\n const [Editor, setEditor_] = useState<ComponentType<ConfigEditorProps> | undefined>(undefined)\n const [Sessions, setSessions] = useState<ComponentType<SessionPickerProps> | undefined>(\n undefined,\n )\n /** Where the conversation window sits. Starts and returns to following the newest row. */\n const [view, setView] = useState(FOLLOWING)\n /** A first ^C has landed. Expires, which is why it is here and not in the keymap. */\n const [armed, setArmed] = useState(false)\n /** `/exit` asked; the next keystroke answers. `undefined` means nothing is being confirmed. */\n const [confirming, setConfirming] = useState(false)\n /**\n * Reasoning shown whole rather than folded to a count. Session-wide, and `⌥r` toggles it.\n *\n * Folded is the default because a real turn produced a twenty-three-row block for a one-sentence\n * answer, which filled the terminal and left the reply itself somewhere above the fold.\n */\n const [expandReasoning, setExpandReasoning] = useState(false)\n /**\n * The mouse selection over the transcript, in buffer coordinates.\n *\n * Cleared by eviction below rather than re-keyed: rows are addressed by position, so dropping any from\n * the front shifts every index — a selection kept across a trim would silently start covering different\n * text, which is the \"looks live and is not\" failure `pinned` exists to prevent. There is also nothing\n * to copy from rows that no longer exist.\n */\n const [selection, setSelection] = useState<TextSelection | undefined>(undefined)\n /**\n * The previous press, for counting clicks.\n *\n * A ref rather than state: nothing renders from it, and putting it in state would redraw the whole tree\n * on every press. Multi-click has to be inferred from time and position because a terminal reports\n * three presses and never a \"double click\" — the same reason the reference CLI keeps its own window.\n */\n const lastPress = useRef<{ at: TextPoint; when: number; clicks: number } | undefined>(undefined)\n // Derived from the buffer rather than stored, so the only palette state is where the cursor is.\n const palette = pane.kind === \"none\" ? paletteFor(editor.value) : undefined\n const [paletteIndex, setPaletteIndex] = useState(0)\n\n const elapsed = useElapsed(busy)\n const last = useMemo(() => lastStats(state.items), [state.items])\n\n /**\n * The conversation, wrapped to the width and flattened to rows.\n *\n * Memoised on the three things it depends on. Without that it would re-flatten and re-wrap the whole\n * history on every streamed token, which is the cost `<Static>` used to remove for free.\n */\n const rows = useMemo(\n () => transcriptRows(state.items, { showReasoning, quiet, columns, expandReasoning }),\n [state.items, showReasoning, quiet, columns, expandReasoning],\n )\n\n /**\n * The landing state: a new conversation with nothing sent into it yet.\n *\n * It is a *state of the one frame*, not a screen of its own, and that is the whole design. As a separate\n * screen it was swapped out the moment anything reached the transcript — which `/help`, `/tools` and\n * `/restart` all do — so the landing screen \"disappeared\" for almost every command. And anything added to\n * the other layout was silently missing from it: the palette drew nothing there for a day, and `/exit`'s\n * \"press y\" prompt was invisible, because both live in the layout that was not on screen. One frame\n * removes that class of bug rather than fixing instances of it.\n *\n * `freshSession` is the host's answer to \"is this conversation new\". It used to be load-bearing for a\n * second reason — the chat did not render stored messages, so an empty transcript was equally true of a\n * resumed session — and that is no longer the case: `seedHistory` paints the conversation, so the `user`\n * clause below is now true on its own for anything resumed. Both are kept because they answer different\n * questions, and the remaining job of `freshSession` is the genuinely new session, where there is no\n * history for the second clause to find. The second half is what the owner chose: slash commands, notes\n * and the banner all keep the brand mark, because they are setup rather than conversation. It goes when\n * you actually start talking, and does not come back.\n */\n const landing = freshSession === true && !state.items.some((item) => item.role === \"user\")\n\n // A longer list while landing: there is no conversation to hide behind it, and the screen somebody opens\n // before they know the commands should show all of them rather than six and a counter.\n const listRows = landing ? LANDING_LIST_ROWS : SEARCH_ROWS\n const frame = chatFrame({\n rows: size.rows,\n columns,\n editor,\n live: state.live,\n showReasoning,\n palette,\n paletteMaxRows: listRows,\n searchMaxRows: listRows,\n confirming,\n landing,\n hint: landing,\n })\n /**\n * The brand mark, rendered here so the conversation is charged what it actually draws.\n *\n * `frame.brand` is an allowance and `wordmark` usually takes far less of it — charging the allowance\n * wasted eleven rows on a thirty-row terminal, and the banner ended up scrolled to a mid-wrap fragment of\n * a store path with a third of the screen blank. Computed once and handed to `Brandmark` as lines, so\n * there is no second derivation that could disagree about how tall the frame is.\n */\n const mark =\n frame.brand > 0\n ? wordmark(BRAND.name, { columns: columns - BRAND_INDENT, rows: frame.brand })\n : undefined\n const window = slice(\n view,\n rows.length,\n transcriptRowsAfterBrand(frame, mark?.lines.length ?? 0),\n )\n\n /**\n * Bound the transcript, but only while following the tail.\n *\n * Every item is re-derived and re-wrapped on each frame now that the conversation is a windowed buffer\n * rather than `<Static>` output, so an unbounded one is unbounded work per keystroke. The gate is the\n * point: rows are addressed by position, so dropping any from the front shifts every offset below\n * them — evicting while somebody is parked twelve turns back would leave their offset untouched and\n * the text under it different, which is a session that looks live and is not. Deferring costs nothing,\n * because `esc` returns to the tail and the next append trims then.\n *\n * Called on every change with no check of its own: a buffer under the cap reduces to identical state,\n * so React bails out of the render.\n */\n // `state.items.length` below is a *trigger*, not a read: the body never looks at it, and it is there\n // so a growing conversation re-runs the check. The lint rule offers to remove it, and taking that\n // offer would leave the cap enforced once at mount and never again — a fix that lints clean and does\n // nothing, which is why the suppression carries a reason rather than the dependency being dropped.\n // biome-ignore lint/correctness/useExhaustiveDependencies: a deliberate trigger dependency; see above\n useEffect(() => {\n if (!view.pinned) return\n // Eviction shifts every row index, so a selection made before a trim would afterwards cover\n // different text — the same hazard `pinned` exists for, applied to a highlight. Cleared rather\n // than re-keyed: there is nothing to copy from rows that are gone, and a highlight that quietly\n // slid onto another reply is worse than one that disappeared.\n setSelection(undefined)\n trim()\n }, [view.pinned, state.items.length, trim])\n\n // The armed ^C expires on its own. A prompt that stayed armed indefinitely would turn a ^C pressed\n // minutes ago into the reason a later one ended the session.\n useEffect(() => {\n if (!armed) return\n const timer = setTimeout(() => setArmed(false), EXIT_ARM_MS)\n return () => clearTimeout(timer)\n }, [armed])\n\n /**\n * A submitted line: a slash command, or a message for the model.\n *\n * `draft` is what is *left in the buffer* afterwards, and it has to be passed in rather than read from\n * `editor` here. This closure captures the editor as it was when the frame rendered — before the submit\n * cleared it — so reading `editor.value` returned the command that was just consumed. `/restart` then\n * carried `/restart` across as the draft, which re-opened the palette on top of the new banner: the\n * screen came back identical to before enter was pressed, with the message hidden behind the list, and\n * the restart looked like it had done nothing at all.\n *\n * For a typed command the residual is always empty — `COMMAND_SHAPE` matches the whole trimmed line, so\n * a command cannot share the buffer with a draft. It stays a parameter because a restart offered by a\n * *pane* could, and that is what the carry-across exists for.\n */\n const onSubmit = (text: string, draft: string): void => {\n // Both renderers dispatch through the same table, so `--plain` and the rich path cannot\n // answer the same typed command differently.\n // `offered` is what turns a typed `/config get x` into a command rather than a message. Without\n // it the list defaults to empty, so **no** CLI command resolved when typed with arguments: the\n // palette ran them and typing the same thing sent it to the model as prose, which then answered\n // about it. Selecting `/config` from the list worked, and typing `/config get model.main.id` cost\n // a turn — the same command, two answers, which is exactly what `resolveSessionCommand` living in\n // one place is supposed to prevent.\n const command = resolveSessionCommand(text, offeredCommands())\n if (command !== undefined) {\n switch (command.kind) {\n case \"exit\":\n // Asked, not done. `/exit` is typed deliberately, but so is every other slash command,\n // and the one that discards the visible conversation is worth one keystroke of\n // confirmation on a surface where leaving takes the screen with it.\n setConfirming(true)\n return\n case \"restart\": {\n // The settings an agent booted with are fixed for its lifetime, so a\n // configuration change needs a new one. Nothing is lost either way: the\n // conversation lives in the store and the same session key resumes it.\n //\n // **Attached, the screen does not come down.** The host owns the agent, so this\n // is a request to replace it — and there is nothing in this process to rebuild,\n // so tearing the frame down would be a teardown for its own sake. Embedded,\n // `onRestart` unmounts and the loop builds a new runtime; the unsent draft\n // rides across, because throwing away a half-written message is a second,\n // unasked-for consequence of asking for the first.\n const reload = source.reload\n if (reload === undefined) {\n onRestart?.(draft)\n exit()\n return\n }\n note(\"asking the host to reload this agent…\")\n reload()\n .then((adopted: readonly string[]) =>\n note(\n // Named rather than counted: replacing a supervisor replaces its\n // team, and \"3 agents reloaded\" would leave somebody guessing which.\n `reloaded ${adopted.join(\", \")} — this conversation continues`,\n ),\n )\n .catch((error: unknown) =>\n note(\n `could not reload: ${error instanceof Error ? error.message : String(error)}`,\n ),\n )\n return\n }\n case \"new\":\n // The same unmount-and-reopen route `/restart` and `/sessions` take, for the same\n // reason: a transcript cannot be re-keyed in place. Nothing is destroyed — the\n // conversation being left keeps its key, and the next banner names it.\n onNew?.(draft)\n exit()\n return\n case \"help\":\n note(sessionHelpText())\n return\n case \"tools\":\n // Fire-and-report, like `/status` and `/context` beside it: a component cannot\n // block, so the note is the acknowledgement. Embedded this resolves off the\n // live registry with no await worth mentioning; attached it is a request, and\n // the two must not read differently to whoever typed it.\n source\n .tools()\n .then((view: ToolsView) => note(toolsReport(view)))\n .catch((error: unknown) =>\n note(\n `could not read the tools: ${error instanceof Error ? error.message : String(error)}`,\n ),\n )\n return\n case \"context\":\n // Same shape as `status` below: a component cannot block, so the note is the\n // acknowledgement. Absent means the surface is not offered rather than accepted\n // and silently billed to the model, which is what `/status` did for three phases.\n if (contextView === undefined) {\n note(\"context is unavailable in this session\")\n return\n }\n contextView()\n .then(note)\n .catch((error: unknown) =>\n note(\n `could not read the context: ${error instanceof Error ? error.message : String(error)}`,\n ),\n )\n return\n case \"status\":\n // Declared in `SESSION_COMMANDS`, advertised in `/help` and generated into the\n // palette — and unhandled here, so it fell out of this switch and was sent to the\n // model as prose. Not a type error: the union's first member is\n // `{kind: SessionCommandKind}` and this switch has no exhaustiveness guard, which\n // is why `boundaries.test.ts` now walks every kind. Seventh instance in this repo\n // of every layer being right and one not being connected.\n //\n // Awaited through `.then` rather than inline: a component cannot block, and the\n // note *is* the acknowledgement — the same shape `reset` below uses.\n if (status === undefined) {\n note(\"status is unavailable in this session\")\n return\n }\n status()\n .then(note)\n .catch((error: unknown) =>\n note(\n `could not read the status: ${error instanceof Error ? error.message : String(error)}`,\n ),\n )\n return\n case \"reset\":\n // Fire-and-report rather than awaited: a component cannot block, and the note is\n // the acknowledgement. A failure surfaces as a rejected promise, so it is caught.\n source\n .clearSession(sessionKey)\n .then(() => note(\"session cleared — memory files on disk are untouched\"))\n .catch((error: unknown) =>\n note(\n `could not clear the session: ${error instanceof Error ? error.message : String(error)}`,\n ),\n )\n return\n case \"command\":\n // Through `dispatch`, which is the palette's path too — its own comment says it is\n // shared \"so the two cannot diverge\", and until now only one of the two reached it.\n if (dispatch(`/${command.name}`, command.rest)) return\n note(unknownCommandText({ word: `/${command.name}` }))\n return\n case \"unknown\":\n note(unknownCommandText(command))\n return\n }\n }\n if (busy) {\n // Two turns on one session would interleave in the history the next turn is conditioned\n // on. Refusing is honest; queueing silently would make the reply order unpredictable.\n note(\"a turn is still running — ^C cancels it, then send again\")\n return\n }\n send(text)\n }\n\n /**\n * Run a command and show what it printed.\n *\n * The pane opens *before* the command starts, with a spinner, for the same reason the skills browser\n * mounts before it fetches: a command that takes a second with nothing on screen is indistinguishable\n * from a keystroke that did nothing.\n */\n const openCommand = useCallback(\n (name: string, rest: string) => {\n setPane({ kind: \"output\", label: `/${name}`, lines: undefined, offset: 0 })\n void runSubcommand({ name, rest, manifestPath: manifestPath ?? \"\" })\n .then((result) =>\n setPane({\n kind: \"output\",\n label: `/${name}`,\n lines: result.lines,\n code: result.code,\n offset: 0,\n }),\n )\n .catch((error: unknown) =>\n setPane({\n kind: \"output\",\n label: `/${name}`,\n lines: [error instanceof Error ? error.message : String(error)],\n code: 1,\n offset: 0,\n }),\n )\n },\n [manifestPath],\n )\n\n /** A slash command, from the palette or from a typed line. Shared so the two cannot diverge. */\n const dispatch = useCallback(\n (word: string, rest: string) => {\n const entry = paletteEntries().find((candidate) => candidate.word === word)\n if (entry === undefined) return false\n if (entry.kind === \"view\") {\n if (\n entry.word === \"/sessions\" &&\n sessions !== undefined &&\n onSwitch !== undefined\n ) {\n // Opened before the read finishes, with the spinner the pane draws for an undefined\n // list — the same reason the catalogue mounts before it fetches: a keystroke followed\n // by nothing is indistinguishable from a keystroke that did nothing.\n setPane({ kind: \"sessions\", stored: undefined })\n void import(\"#components/SessionPicker\").then((module) =>\n // Wrapped in a function, or `useState` would call the component as an updater.\n setSessions(() => module.SessionPicker),\n )\n void sessions()\n .then((stored) => setPane({ kind: \"sessions\", stored }))\n .catch((error: unknown) => {\n setPane({ kind: \"none\" })\n note(\n `could not read the stored conversations: ${error instanceof Error ? error.message : String(error)}`,\n )\n })\n return true\n }\n if (entry.word === \"/config\" && (rest.trim() === \"\" || rest.trim() === \"edit\")) {\n // Bare `/config` is the editor; `/config list` and the rest are still the plain\n // command in an output pane, which the fallthrough below handles.\n if (manifestPath === undefined) {\n note(\"this session has no manifest path, so there is nothing to edit\")\n return true\n }\n setPane({ kind: \"config\", rows: editorRowsFor(manifestPath) })\n void import(\"#components/ConfigEditor\").then((module) =>\n // Wrapped in a function, or `useState` would call the component as an updater.\n setEditor_(() => module.ConfigEditor),\n )\n return true\n }\n if (entry.word === \"/skills\" && catalogue !== undefined) {\n setPane({ kind: \"skills\" })\n void import(\"#components/SkillBrowser\").then((module) =>\n // Wrapped in a function, or `useState` would call the component as an updater.\n setBrowser(() => module.SkillBrowser),\n )\n return true\n }\n // A view named in the table with nothing built yet falls back to its own output, which is\n // still the command doing its job — better than a palette entry that does nothing.\n openCommand(entry.word.slice(1), rest)\n return true\n }\n if (entry.kind === \"output\") {\n openCommand(entry.word.slice(1), rest)\n return true\n }\n return false\n },\n // `manifestPath` is read by the `/config` branch. A prop that does not change in practice, and\n // listing it is what stops a later change from being captured stale — the same reason the rule\n // exists rather than a suppression here.\n [openCommand, catalogue, sessions, onSwitch, note, manifestPath],\n )\n\n // ── the pane has the keyboard while it is open ────────────────────────────────────────\n useInput(\n (input, key) => {\n if (pane.kind !== \"output\") return\n if (key.escape || input === \"q\") {\n setPane({ kind: \"none\" })\n return\n }\n const total = pane.lines?.length ?? 0\n const step = key.pageDown || key.pageUp ? frame.pane : 1\n const delta =\n key.downArrow || key.pageDown ? step : key.upArrow || key.pageUp ? -step : 0\n if (delta !== 0) {\n setPane({\n ...pane,\n offset: Math.max(0, Math.min(pane.offset + delta, Math.max(0, total - 1))),\n })\n }\n },\n { isActive: pane.kind === \"output\" },\n )\n\n useInput(\n (input, reported) => {\n // Modifiers off the wire where they can be had, before anything reads one.\n //\n // Ink folds the super bit into `meta` on its legacy path (`modifier & 10`), so `cmd+←` and\n // `⌥←` arrive as the same keystroke and both word-move — measured in a real Warp session.\n // First line of the handler rather than beside `keyToIntent`, because the palette branch below\n // reads `key.escape` and `key.upArrow` too, and a correction applied after it would be one\n // that two of the three branches never got.\n const key = correctKeys === undefined ? reported : correctKeys(reported, input)\n\n // A pending confirmation owns the keyboard for exactly one keystroke. Anything other than a\n // yes is a no — including a stray arrow, because the safe answer to an unclear one is to stay.\n if (confirming) {\n setConfirming(false)\n if (input.toLowerCase() === \"y\" || key.return) exit()\n return\n }\n\n // The palette owns the keys it needs while it is open, and hands everything else to the editor —\n // so typing continues to narrow the list rather than being swallowed by it.\n if (palette !== undefined) {\n if (key.escape) {\n setEditor((current) => applyIntent(current, { kind: \"killToStart\" }))\n setPaletteIndex(0)\n return\n }\n if (key.upArrow || key.downArrow) {\n setPaletteIndex((at) =>\n Math.max(\n 0,\n Math.min(at + (key.downArrow ? 1 : -1), palette.matches.length - 1),\n ),\n )\n return\n }\n if (key.tab) {\n const chosen = paletteSelection(palette, paletteIndex)\n if (chosen !== undefined) {\n setEditor((current) =>\n applyIntent(\n { ...current, value: \"\", cursor: 0 },\n {\n kind: \"insert\",\n text: chosen.word,\n },\n ),\n )\n }\n return\n }\n const selected = paletteSelection(palette, paletteIndex)\n // Only intercepted when something is selected. With no match, enter falls through to the\n // ordinary submit path, which reports `/skils is not a command` and suggests the nearest\n // one — swallowing it here made a mistyped command do nothing at all, which is worse.\n if (key.return && selected !== undefined) {\n const chosen = selected\n setPaletteIndex(0)\n setEditor((current) => ({ ...current, value: \"\", cursor: 0 }))\n // A session verb goes through the same submit path a typed line takes, so `/help` and\n // `/reset` behave identically whether they were completed or typed out.\n // The buffer was cleared in the same handler, so nothing is left behind.\n if (chosen.kind === \"session\") onSubmit(chosen.word, \"\")\n else dispatch(chosen.word, \"\")\n return\n }\n }\n\n const intent = keyToIntent(\n input,\n key,\n keyContext(editor, busy, { armed, scrolled: !view.pinned }),\n )\n\n // Any keystroke that is not the second ^C disarms. Without this the warning would stay true\n // while somebody typed a whole message, and the ^C they pressed at the end of it — meaning\n // \"cancel that\" — would end the session instead.\n if (armed && intent.kind !== \"exit\") setArmed(false)\n\n if (intent.kind === \"arm\") {\n setArmed(true)\n return\n }\n if (intent.kind === \"scroll\") {\n // `times` is the wheel: one chunk can carry several notches, and applying one of them makes\n // a flick of the wheel move a single row. Folded rather than given its own move, so the\n // clamping at both ends stays in one function.\n const times = Math.max(1, intent.times ?? 1)\n setView((current) => {\n let next = current\n for (let step = 0; step < times; step += 1) {\n next = scroll(next, intent.move, rows.length, frame.transcript)\n }\n return next\n })\n return\n }\n if (intent.kind === \"pointer\") {\n // Screen cell to buffer row, through the one function that owns the frame's vertical\n // arithmetic. `undefined` means the cell was chrome — the header, the composer, the status\n // line — and a click there clears the selection rather than selecting the nearest row,\n // because clamping would make clicking the status bar highlight the last reply.\n const hit = transcriptHit(\n { column: intent.column, row: intent.row },\n { brandLines: mark?.lines.length ?? 0, from: window.from, to: window.to },\n )\n if (hit === undefined) {\n // Not the transcript — try the composer. Selecting your own draft with the mouse is\n // the same gesture and a different target, so it is the same branch rather than a\n // second handler that would have to re-derive which cell belongs to whom.\n const offset = composerHit(\n { column: intent.column, row: intent.row },\n { editor, columns, rows: size.rows, hint: landing },\n )\n if (offset === undefined) {\n // Genuine chrome. A press clears both selections rather than clamping to whatever\n // is nearest, because a click on the status line that highlighted the last reply\n // would look deliberate.\n if (intent.gesture === \"press\") {\n setSelection(undefined)\n setEditor((current) => ({ ...current, anchor: undefined }))\n }\n return\n }\n setSelection(undefined)\n setEditor((current) =>\n intent.gesture === \"press\" && !intent.shift\n ? // A press places the caret and starts a possible selection from it; the\n // anchor is set now so the first drag report has something to extend from.\n { ...current, cursor: offset, anchor: offset }\n : // A drag, or a shift-click, moves the cursor and keeps the anchor — which is\n // exactly what `extend` does for a shifted motion, expressed directly\n // because there is no motion here, only a destination.\n {\n ...current,\n cursor: offset,\n anchor: current.anchor ?? current.cursor,\n },\n )\n return\n }\n if (intent.gesture === \"press\") {\n // Shift extends whatever is already there, which is the gesture for correcting a\n // selection that stopped a word short. Checked before the click count, because a\n // shift-click is a deliberate second gesture rather than a fast repeat of the first.\n if (intent.shift && selection !== undefined) {\n setSelection(extendSelection(selection, hit))\n lastPress.current = undefined\n return\n }\n const previous = lastPress.current\n const repeat =\n previous !== undefined &&\n Date.now() - previous.when <= MULTI_CLICK_MS &&\n previous.at.row === hit.row &&\n previous.at.column === hit.column\n // Third click wraps back to one, so a fourth starts a fresh drag rather than doing\n // nothing — a count that only grew would leave rapid clicking permanently stuck on\n // \"line\".\n const clicks = repeat ? (previous.clicks % 3) + 1 : 1\n lastPress.current = { at: hit, when: Date.now(), clicks }\n // One selection at a time. Two visible highlights with one clipboard between them is\n // a screen that cannot say what ⌘C would copy.\n setEditor((current) => ({ ...current, anchor: undefined }))\n setSelection(\n clicks === 3\n ? lineAt(rows, hit)\n : clicks === 2\n ? wordAt(rows, hit)\n : beginSelection(hit),\n )\n return\n }\n if (intent.gesture === \"drag\") {\n setSelection((current) =>\n current === undefined ? undefined : dragSelection(current, hit),\n )\n return\n }\n // Release. The clipboard is written here and nowhere else, because `cmd+c` cannot reach a\n // terminal app — the terminal claims it and finds no native selection, mouse tracking\n // having disabled the one it would have used. Copying on mouse-up is what makes `cmd+v`\n // work, and a copy that failed says so rather than leaving the previous clipboard in place\n // looking like the wrong text was selected.\n // Derived from *this* report rather than from the state in the closure. A release carries\n // its own final position, and `selection` here is whatever the last render saw — which on\n // a fast drag-and-release is one motion behind, so copying from it would drop the last few\n // characters somebody deliberately included.\n const finished =\n selection === undefined\n ? undefined\n : endSelection(dragSelection(selection, hit))\n setSelection(finished)\n const text = selectedText(rows, finished)\n if (text !== \"\") {\n void copyToClipboard(text).then((result) => {\n if (!result.copied && result.problem !== \"nothing selected\") {\n note(`could not copy: ${result.problem ?? \"unknown\"}`)\n }\n })\n }\n return\n }\n if (intent.kind === \"copySelection\" || intent.kind === \"cutSelection\") {\n const range = selectionRange(editor)\n if (range === undefined) {\n note(\"nothing selected — hold shift with a motion, or drag in the box\")\n return\n }\n const text = [...editor.value].slice(range.start, range.end).join(\"\")\n if (intent.kind === \"cutSelection\")\n setEditor((current) => applyIntent(current, intent))\n void copyToClipboard(text).then((result) => {\n if (!result.copied) note(`could not copy: ${result.problem ?? \"unknown\"}`)\n })\n return\n }\n if (intent.kind === \"reasoning\") {\n // A chord with nothing to act on has to say so.\n //\n // Reported as \"⌥r doesn't do anything\", and it was arriving and resolving correctly the\n // whole time: it toggles a fold, and a fold with nothing in it looks exactly like a dead\n // key. Two different reasons for that, and they need two different sentences — a model\n // that never streams reasoning is not the same as a turn that has not produced any yet,\n // and only the first is worth changing a flag over.\n // Visibility, not existence — and the order matters. `useTurn` appends a reasoning item\n // for every delta the model streams *regardless* of `showReasoning`, and `transcript.ts`\n // filters them out at render. So a session with reasoning hidden has items that cannot be\n // shown, and testing existence first fell through to a toggle whose rows were filtered\n // away: silently nothing, which is the failure this whole branch exists to prevent.\n // A subagent's calls fold under the same key, and they are there whether or not this\n // model streams reasoning, so they are checked first: refusing ⌥r for \"reasoning is\n // off\" with a folded subagent on screen would be the dead key again.\n const subagents = state.items.some((item) => (item.subagent?.lines.length ?? 0) > 0)\n if (!subagents && !showReasoning) {\n note(\n \"reasoning is off: either this model does not stream it, or --no-reasoning is set\",\n )\n return\n }\n if (!subagents && !state.items.some((item) => item.role === \"reasoning\")) {\n note(\"no reasoning to show yet — this expands it once a turn has streamed some\")\n return\n }\n // Unfolding changes how tall the conversation is, so the window has to be told to follow\n // the newest row again — leaving it parked would put the reader at a row that has moved.\n setExpandReasoning((current) => !current)\n setView(FOLLOWING)\n return\n }\n if (intent.kind === \"exit\") {\n exit()\n return\n }\n if (intent.kind === \"cancel\") {\n cancel()\n return\n }\n if (intent.kind === \"submit\") {\n const committed = submit(editor)\n setEditor(committed.state)\n // Sending is an implicit \"take me back to the newest row\": a reply arriving into a window\n // parked ten screens up would be generated where nobody can see it.\n setView(FOLLOWING)\n if (committed.text !== \"\") onSubmit(committed.text, committed.state.value)\n return\n }\n if (intent.kind === \"paste\") {\n // Inserted with its newlines intact, as one message.\n //\n // This used to submit every finished line in the chunk, and that was right when the buffer\n // could not hold a newline: the alternative then was silently running the words together.\n // Now that a message is composed rather than typed on one line, sending line-by-line is the\n // bug multi-line composition exists to remove — pasting a twelve-line code block produced\n // twelve messages, each conditioned on the last, and no way to edit any of them.\n setEditor((current) =>\n applyIntent(current, { kind: \"insert\", text: intent.lines.join(\"\\n\") }),\n )\n return\n }\n // The match list changes underneath the cursor on every keystroke, so keeping its position\n // would silently highlight a different entry than the one on screen — the same reason the\n // history search resets its index.\n if (palette !== undefined) setPaletteIndex(0)\n setEditor((current) => applyIntent(current, intent))\n },\n { isActive: pane.kind === \"none\" },\n )\n\n if (pane.kind === \"config\") {\n return (\n <Box flexDirection=\"column\" width={columns} height={size.rows}>\n <Text color={THEME.accent} bold wrap=\"truncate\">\n {titleLine({ title: `${BRAND.name} ${VERSION}`, summary: \"settings\" }, columns)}\n </Text>\n {Editor === undefined ? (\n <Box marginLeft={2}>\n <Spinner label=\"reading the settings\" />\n </Box>\n ) : (\n <Editor\n rows={pane.rows}\n apply={(row, raw) => applyEditorRow(manifestPath ?? \"\", row, raw)}\n reload={() => editorRowsFor(manifestPath ?? \"\")}\n columns={columns}\n window={SESSION_PICKER_ROWS}\n onDone={(changed) => {\n setPane({ kind: \"none\" })\n // An agent's settings are fixed for the lifetime of the process running it,\n // so a change that is not followed by a restart is a change that silently\n // did not apply — rule 8's shape. The draft rides across, for the reason\n // `/restart` carries it: throwing away a half-written message is a second,\n // unasked-for consequence of asking for the first.\n if (changed) {\n onRestart?.(editor.value)\n exit()\n }\n }}\n />\n )}\n {/*\n * The slack goes *below* a long list, not above it. Bottom-anchoring is right for the\n * conversation switcher — a dozen short rows that read as a menu — and wrong here: the\n * settings run past twenty rows, so a spacer above them started the list mid-screen with\n * eight blank rows over it and the rest running off the bottom.\n */}\n <Box flexGrow={1} />\n </Box>\n )\n }\n\n if (pane.kind === \"sessions\") {\n return (\n <Box flexDirection=\"column\" width={columns} height={size.rows}>\n <Text color={THEME.accent} bold wrap=\"truncate\">\n {titleLine(\n { title: `${BRAND.name} ${VERSION}`, summary: \"pick a conversation\" },\n columns,\n )}\n </Text>\n <Box flexGrow={1} />\n {pane.stored === undefined || Sessions === undefined ? (\n <Box marginLeft={2}>\n <Spinner label=\"reading the stored conversations\" />\n </Box>\n ) : (\n <Sessions\n sessions={pane.stored}\n now={Date.now()}\n columns={columns}\n maxRows={SESSION_PICKER_ROWS}\n current={sessionKey}\n onDone={(picked) => {\n if (picked === undefined || picked === sessionKey) {\n // Esc, or the one already open. Either way nothing is worth a rebuild.\n setPane({ kind: \"none\" })\n return\n }\n onSwitch?.(picked, editor.value)\n exit()\n }}\n />\n )}\n <Box flexGrow={1} />\n </Box>\n )\n }\n\n if (pane.kind === \"skills\" && catalogue !== undefined && Browser !== undefined) {\n return (\n <Browser\n title={`${BRAND.name} ${VERSION}`}\n agents={[]}\n target={manifestPath ?? \"\"}\n load={catalogue.load}\n install={catalogue.install}\n onDone={() => setPane({ kind: \"none\" })}\n />\n )\n }\n\n const header = titleLine(\n {\n title: `${BRAND.name} ${VERSION}`,\n summary: \"\",\n agent: { name: agentName, model },\n ...(warnings === undefined || warnings.length === 0 ? {} : { warnings }),\n },\n columns,\n )\n\n return (\n // Fixed height, because the alternate screen has no scrollback to absorb an overshoot: one row too\n // many and Ink's own output scrolls the buffer, which leaves the status line halfway up the display.\n <Box flexDirection=\"column\" width={columns} height={size.rows}>\n {/*\n * Above the one-line header, and only while landing. Nothing appears or disappears when it goes —\n * the line below it is the same line either way, which is what makes the collapse read as the same\n * screen with less on it rather than as a different screen.\n */}\n {mark === undefined ? null : (\n <>\n <Brandmark lines={mark.lines} />\n <Text> </Text>\n </>\n )}\n <Text color={THEME.accent} bold wrap=\"truncate\">\n {header}\n </Text>\n\n {pane.kind === \"output\" ? (\n <Box flexDirection=\"column\">\n <CommandOutput\n lines={pane.lines}\n label={pane.label}\n offset={pane.offset}\n maxRows={frame.pane}\n {...(pane.code === undefined ? {} : { code: pane.code })}\n />\n <Text dimColor wrap=\"truncate\">\n {\" \"}↑↓ scroll · esc back to the prompt\n </Text>\n </Box>\n ) : (\n <Transcript\n rows={rows}\n slice={window}\n {...(selection === undefined ? {} : { selection })}\n />\n )}\n\n {/*\n * Absorbs the slack, so the composer sits on the bottom edge of every frame.\n *\n * Unconditional, and that is the whole of decision 11.98's reversal. It used to stand down while\n * landing, on the grounds that twelve blank rows between the banner and the input read as a\n * half-empty screen — but a bottom-anchored input is where the eye already rests, so what those\n * rows read as is a prompt waiting. The reference CLI puts ~25 there and nobody reports it.\n *\n * The cost of the old arrangement was not the blank rows, it was that the composer *moved*: it\n * was drawn under whatever content existed, so it walked down the screen as the first few\n * messages arrived and only settled once the transcript filled the window. The place you type\n * should not move. A spacer costs nothing once the transcript is full, because by then there is\n * no slack left for it to take.\n */}\n <Box flexGrow={1} />\n\n {state.live === undefined ? null : (\n <Live live={state.live} showReasoning={showReasoning} columns={columns} />\n )}\n {palette === undefined ? null : (\n <Palette\n palette={palette}\n index={paletteIndex}\n width={columns}\n maxRows={frame.paletteRows}\n />\n )}\n <HistorySearch editor={editor} width={columns} maxRows={listRows} />\n {/*\n * Rendered once, in the one frame, which is the fix rather than a feature: this lived only in the\n * transcript layout, so `/exit` typed on the landing screen asked for a confirmation nobody could\n * see — the session simply appeared to ignore the command until a second keystroke ended it.\n */}\n {confirming ? (\n <Text color={THEME.warning} wrap=\"truncate\">\n {\" leave this session? press y to confirm · any other key stays\"}\n </Text>\n ) : null}\n <Prompt\n editor={editor}\n busy={busy}\n columns={columns}\n {...(landing ? { placeholder: \"Ask anything…\" } : {})}\n />\n {/*\n * The keys worth knowing before there is a conversation to learn them from. It stands down once\n * one exists: the status line already carries `^C`, and a permanent hint is a row of conversation.\n */}\n {landing ? (\n <Text dimColor wrap=\"truncate\">\n {\" \"}\n {NEW_SESSION_HINT}\n </Text>\n ) : null}\n {/* The status line is the footer, under the input — where every reference CLI puts\n it, and where the eye rests between keystrokes. */}\n <StatusBar\n status={state.status}\n model={model}\n sessionKey={sessionKey}\n elapsedMs={elapsed}\n last={last}\n quiet={quiet}\n armed={armed}\n {...(state.pressure === undefined ? {} : { pressure: state.pressure })}\n {...(state.phase === undefined ? {} : { phase: state.phase })}\n />\n </Box>\n )\n}\n",
5
+ "/**\n * The chat surface — a full-screen session on the alternate buffer.\n *\n * Thin on purpose. Everything worth testing lives in pure modules — `keymap.ts` decides what a keystroke\n * means, `editor.ts` applies it to the line, `transcript.ts` turns bus events into rows, `lib/scroll.ts`\n * moves the window, `lib/chat-frame.ts` decides how many rows each part of the frame may have — so this\n * file is composition plus the decisions that need Ink itself: when to unmount, what to do about a\n * submission arriving mid-turn, and which surface currently owns the keyboard.\n *\n * ## What Phase 5.5 changed here\n *\n * The conversation is no longer in `<Static>`. It is a buffer of rows with a window over it, because\n * `<Static>` writes to the scrollback and the alternate screen discards its buffer on the way out — the\n * two cannot both be true. That has two consequences worth stating before editing:\n *\n * - **The frame has a hard height.** Everything visible must add up to at most the terminal's rows, or\n * Ink's own output scrolls the buffer and the layout comes apart. `chatFrame` owns that arithmetic; no\n * row count is invented in this file.\n * - **^C at an idle prompt takes two presses.** With the buffer discarded on exit, a single reflexive ^C\n * during a long reply would throw the visible conversation away. `keymap.ts` owns the decision; the\n * timer that expires it lives here, because a pure function cannot hold a clock.\n *\n * The Ctrl-C contract from Phase 1 is otherwise unchanged: during a turn it cancels the turn and the\n * prompt comes back.\n */\n\nimport { BRAND, VERSION } from \"@dispach/core\"\nimport { Box, Text, useApp, useInput } from \"ink\"\nimport { type ComponentType, useCallback, useEffect, useMemo, useRef, useState } from \"react\"\nimport { BRAND_INDENT, Brandmark } from \"#components/Brandmark\"\nimport { CommandOutput } from \"#components/CommandOutput\"\nimport type { ConfigEditorProps } from \"#components/ConfigEditor\"\nimport { HistorySearch } from \"#components/HistorySearch\"\nimport { Live } from \"#components/Live\"\nimport { Palette } from \"#components/Palette\"\nimport { Prompt } from \"#components/Prompt\"\nimport type { SessionPickerProps } from \"#components/SessionPicker\"\nimport type { SkillBrowserProps } from \"#components/SkillBrowser\"\nimport { Spinner } from \"#components/Spinner\"\nimport { StatusBar } from \"#components/StatusBar\"\nimport { Transcript } from \"#components/Transcript\"\nimport { applyIntent, EMPTY_EDITOR, selectionRange, submit } from \"#editor\"\nimport { useElapsed } from \"#hooks/useElapsed\"\nimport { useTerminalSize } from \"#hooks/useTerminalSize\"\nimport { useTurn } from \"#hooks/useTurn\"\nimport { keyContext, keyToIntent } from \"#keymap\"\nimport { chatFrame, composerHit, transcriptHit, transcriptRowsAfterBrand } from \"#lib/chat-frame\"\nimport { copyToClipboard } from \"#lib/clipboard\"\nimport type { EditorRow } from \"#lib/config-editor\"\nimport { applyEditorRow, editorRowsFor } from \"#lib/config-rows\"\nimport {\n EXIT_ARM_MS,\n FALLBACK_COLUMNS,\n LANDING_LIST_ROWS,\n MULTI_CLICK_MS,\n SEARCH_ROWS,\n SESSION_PICKER_ROWS,\n} from \"#lib/const\"\nimport { offeredCommands, paletteEntries, paletteFor, paletteSelection } from \"#lib/palette\"\nimport type { AppProps } from \"#lib/schema\"\nimport { screenColumns, titleLine } from \"#lib/screen\"\nimport { FOLLOWING, scroll, slice } from \"#lib/scroll\"\nimport {\n NEW_SESSION_HINT,\n resolveSessionCommand,\n sessionHelpText,\n type ToolsView,\n toolsReport,\n unknownCommandText,\n} from \"#lib/session-commands\"\nimport type { SessionRowSource } from \"#lib/sessions-view\"\nimport { runSubcommand } from \"#lib/subcommand\"\nimport {\n beginSelection,\n dragSelection,\n endSelection,\n extendSelection,\n lineAt,\n selectedText,\n type TextPoint,\n type TextSelection,\n wordAt,\n} from \"#lib/text-selection\"\nimport { THEME } from \"#lib/theme\"\nimport { wordmark } from \"#lib/wordmark\"\nimport { lastStats, transcriptRows } from \"#transcript\"\n\n/**\n * What is layered over the conversation.\n *\n * `output` is a command's captured text; `skills` is the one bespoke view a session hosts so far. Both\n * take the keyboard while open and both *replace* the transcript rather than sitting under it — sharing\n * the screen pushed the conversation off the top of a full-screen frame, which on a surface with no\n * scrollback means gone. Closing either returns to the prompt with the draft untouched, which is what\n * makes a pane an interlude rather than a detour.\n */\ntype Pane =\n | { readonly kind: \"none\" }\n | {\n readonly kind: \"output\"\n readonly label: string\n readonly lines: readonly string[] | undefined\n readonly code?: number\n readonly offset: number\n }\n | { readonly kind: \"skills\" }\n /**\n * The conversation switcher. `undefined` while the store is being read.\n *\n * Loaded when the pane opens rather than kept current, because the list changes only when a turn ends\n * and re-reading it on every frame would put a database query in the render path.\n */\n | { readonly kind: \"sessions\"; readonly stored: readonly SessionRowSource[] | undefined }\n /**\n * The settings editor. `rows` is read when the pane opens, not kept current.\n *\n * Read once because the editor re-reads after each write of its own — keeping it live here would put\n * a file read in the render path for a surface that already knows when it has changed something.\n */\n | { readonly kind: \"config\"; readonly rows: readonly EditorRow[] }\n\nexport function App({\n source,\n sessionKey,\n model,\n agentName,\n warnings,\n freshSession,\n initial,\n correctKeys,\n showReasoning,\n quiet,\n onRestart,\n onSwitch,\n onNew,\n sessions,\n initialDraft,\n manifestPath,\n catalogue,\n status,\n contextView,\n}: AppProps) {\n const { exit } = useApp()\n const size = useTerminalSize()\n const columns = screenColumns(size.columns, FALLBACK_COLUMNS)\n const { state, busy, send, cancel, note, trim } = useTurn({ source, sessionKey, initial })\n // A draft handed in by a `/restart` opens the prompt with the cursor at its end, which is where the\n // person left it. Only the initial value — a later prop change must not overwrite what is being\n // typed now, which is exactly what `useState`'s initialiser semantics give for free.\n const [editor, setEditor] = useState(() =>\n initialDraft === undefined || initialDraft === \"\"\n ? EMPTY_EDITOR\n : { ...EMPTY_EDITOR, value: initialDraft, cursor: [...initialDraft].length },\n )\n\n /**\n * What is on top of the conversation, if anything.\n *\n * A pane is *focused* while it is open, so the prompt's `useInput` stands down — Ink fires every\n * active hook, and two surfaces reading one keystroke is the bug the focus rule exists to prevent.\n */\n const [pane, setPane] = useState<Pane>({ kind: \"none\" })\n /**\n * The skills view's implementation, loaded when it is first opened.\n *\n * Dynamically, and that is not an optimisation. `browse.ts` also imports this component dynamically,\n * and bun's `--splitting` emits a module's exports **twice** when one importer is static and another is\n * dynamic — producing a bundle that dies at parse time with `Duplicate export of 'SkillBrowser'`, which\n * no test that imports source can see. The props come in as a type, which is erased and creates no\n * edge. `boundaries.test.ts` bans the mixing outright.\n */\n const [Browser, setBrowser] = useState<ComponentType<SkillBrowserProps> | undefined>(undefined)\n /**\n * The session switcher's implementation, loaded when the pane first opens.\n *\n * Dynamically for the same reason `Browser` is, and it was caught by the boundaries test rather than\n * remembered: `run.ts` mounts this component too, for a bare `--session` before any chat exists. One\n * static importer and one dynamic one makes bun's `--splitting` emit its exports **twice**, and the\n * built binary then dies at parse time with `Duplicate export of 'SessionPicker'` while every test —\n * which imports source — passes. Both edges dynamic, no duplicate.\n */\n const [Editor, setEditor_] = useState<ComponentType<ConfigEditorProps> | undefined>(undefined)\n const [Sessions, setSessions] = useState<ComponentType<SessionPickerProps> | undefined>(\n undefined,\n )\n /** Where the conversation window sits. Starts and returns to following the newest row. */\n const [view, setView] = useState(FOLLOWING)\n /** A first ^C has landed. Expires, which is why it is here and not in the keymap. */\n const [armed, setArmed] = useState(false)\n /** `/exit` asked; the next keystroke answers. `undefined` means nothing is being confirmed. */\n const [confirming, setConfirming] = useState(false)\n /**\n * Reasoning shown whole rather than folded to a count. Session-wide, and `⌥r` toggles it.\n *\n * Folded is the default because a real turn produced a twenty-three-row block for a one-sentence\n * answer, which filled the terminal and left the reply itself somewhere above the fold.\n */\n const [expandReasoning, setExpandReasoning] = useState(false)\n /**\n * The mouse selection over the transcript, in buffer coordinates.\n *\n * Cleared by eviction below rather than re-keyed: rows are addressed by position, so dropping any from\n * the front shifts every index — a selection kept across a trim would silently start covering different\n * text, which is the \"looks live and is not\" failure `pinned` exists to prevent. There is also nothing\n * to copy from rows that no longer exist.\n */\n const [selection, setSelection] = useState<TextSelection | undefined>(undefined)\n /**\n * The previous press, for counting clicks.\n *\n * A ref rather than state: nothing renders from it, and putting it in state would redraw the whole tree\n * on every press. Multi-click has to be inferred from time and position because a terminal reports\n * three presses and never a \"double click\" — the same reason the reference CLI keeps its own window.\n */\n const lastPress = useRef<{ at: TextPoint; when: number; clicks: number } | undefined>(undefined)\n // Derived from the buffer rather than stored, so the only palette state is where the cursor is.\n const palette = pane.kind === \"none\" ? paletteFor(editor.value) : undefined\n const [paletteIndex, setPaletteIndex] = useState(0)\n\n const elapsed = useElapsed(busy)\n const last = useMemo(() => lastStats(state.items), [state.items])\n\n /**\n * The conversation, wrapped to the width and flattened to rows.\n *\n * Memoised on the three things it depends on. Without that it would re-flatten and re-wrap the whole\n * history on every streamed token, which is the cost `<Static>` used to remove for free.\n */\n const rows = useMemo(\n () => transcriptRows(state.items, { showReasoning, quiet, columns, expandReasoning }),\n [state.items, showReasoning, quiet, columns, expandReasoning],\n )\n\n /**\n * The landing state: a new conversation with nothing sent into it yet.\n *\n * It is a *state of the one frame*, not a screen of its own, and that is the whole design. As a separate\n * screen it was swapped out the moment anything reached the transcript — which `/help`, `/tools` and\n * `/restart` all do — so the landing screen \"disappeared\" for almost every command. And anything added to\n * the other layout was silently missing from it: the palette drew nothing there for a day, and `/exit`'s\n * \"press y\" prompt was invisible, because both live in the layout that was not on screen. One frame\n * removes that class of bug rather than fixing instances of it.\n *\n * `freshSession` is the host's answer to \"is this conversation new\". It used to be load-bearing for a\n * second reason — the chat did not render stored messages, so an empty transcript was equally true of a\n * resumed session — and that is no longer the case: `seedHistory` paints the conversation, so the `user`\n * clause below is now true on its own for anything resumed. Both are kept because they answer different\n * questions, and the remaining job of `freshSession` is the genuinely new session, where there is no\n * history for the second clause to find. The second half is what the owner chose: slash commands, notes\n * and the banner all keep the brand mark, because they are setup rather than conversation. It goes when\n * you actually start talking, and does not come back.\n */\n const landing = freshSession === true && !state.items.some((item) => item.role === \"user\")\n\n // A longer list while landing: there is no conversation to hide behind it, and the screen somebody opens\n // before they know the commands should show all of them rather than six and a counter.\n const listRows = landing ? LANDING_LIST_ROWS : SEARCH_ROWS\n const frame = chatFrame({\n rows: size.rows,\n columns,\n editor,\n live: state.live,\n showReasoning,\n palette,\n paletteMaxRows: listRows,\n searchMaxRows: listRows,\n confirming,\n landing,\n hint: landing,\n })\n /**\n * The brand mark, rendered here so the conversation is charged what it actually draws.\n *\n * `frame.brand` is an allowance and `wordmark` usually takes far less of it — charging the allowance\n * wasted eleven rows on a thirty-row terminal, and the banner ended up scrolled to a mid-wrap fragment of\n * a store path with a third of the screen blank. Computed once and handed to `Brandmark` as lines, so\n * there is no second derivation that could disagree about how tall the frame is.\n */\n const mark =\n frame.brand > 0\n ? wordmark(BRAND.name, { columns: columns - BRAND_INDENT, rows: frame.brand })\n : undefined\n const window = slice(\n view,\n rows.length,\n transcriptRowsAfterBrand(frame, mark?.lines.length ?? 0),\n )\n\n /**\n * Bound the transcript, but only while following the tail.\n *\n * Every item is re-derived and re-wrapped on each frame now that the conversation is a windowed buffer\n * rather than `<Static>` output, so an unbounded one is unbounded work per keystroke. The gate is the\n * point: rows are addressed by position, so dropping any from the front shifts every offset below\n * them — evicting while somebody is parked twelve turns back would leave their offset untouched and\n * the text under it different, which is a session that looks live and is not. Deferring costs nothing,\n * because `esc` returns to the tail and the next append trims then.\n *\n * Called on every change with no check of its own: a buffer under the cap reduces to identical state,\n * so React bails out of the render.\n */\n // `state.items.length` below is a *trigger*, not a read: the body never looks at it, and it is there\n // so a growing conversation re-runs the check. The lint rule offers to remove it, and taking that\n // offer would leave the cap enforced once at mount and never again — a fix that lints clean and does\n // nothing, which is why the suppression carries a reason rather than the dependency being dropped.\n // biome-ignore lint/correctness/useExhaustiveDependencies: a deliberate trigger dependency; see above\n useEffect(() => {\n if (!view.pinned) return\n // Eviction shifts every row index, so a selection made before a trim would afterwards cover\n // different text — the same hazard `pinned` exists for, applied to a highlight. Cleared rather\n // than re-keyed: there is nothing to copy from rows that are gone, and a highlight that quietly\n // slid onto another reply is worse than one that disappeared.\n setSelection(undefined)\n trim()\n }, [view.pinned, state.items.length, trim])\n\n // The armed ^C expires on its own. A prompt that stayed armed indefinitely would turn a ^C pressed\n // minutes ago into the reason a later one ended the session.\n useEffect(() => {\n if (!armed) return\n const timer = setTimeout(() => setArmed(false), EXIT_ARM_MS)\n return () => clearTimeout(timer)\n }, [armed])\n\n /**\n * A submitted line: a slash command, or a message for the model.\n *\n * `draft` is what is *left in the buffer* afterwards, and it has to be passed in rather than read from\n * `editor` here. This closure captures the editor as it was when the frame rendered — before the submit\n * cleared it — so reading `editor.value` returned the command that was just consumed. `/restart` then\n * carried `/restart` across as the draft, which re-opened the palette on top of the new banner: the\n * screen came back identical to before enter was pressed, with the message hidden behind the list, and\n * the restart looked like it had done nothing at all.\n *\n * For a typed command the residual is always empty — `COMMAND_SHAPE` matches the whole trimmed line, so\n * a command cannot share the buffer with a draft. It stays a parameter because a restart offered by a\n * *pane* could, and that is what the carry-across exists for.\n */\n const onSubmit = (text: string, draft: string): void => {\n // Both renderers dispatch through the same table, so `--plain` and the rich path cannot\n // answer the same typed command differently.\n // `offered` is what turns a typed `/config get x` into a command rather than a message. Without\n // it the list defaults to empty, so **no** CLI command resolved when typed with arguments: the\n // palette ran them and typing the same thing sent it to the model as prose, which then answered\n // about it. Selecting `/config` from the list worked, and typing `/config get model.main.id` cost\n // a turn — the same command, two answers, which is exactly what `resolveSessionCommand` living in\n // one place is supposed to prevent.\n const command = resolveSessionCommand(text, offeredCommands())\n if (command !== undefined) {\n switch (command.kind) {\n case \"exit\":\n // Asked, not done. `/exit` is typed deliberately, but so is every other slash command,\n // and the one that discards the visible conversation is worth one keystroke of\n // confirmation on a surface where leaving takes the screen with it.\n setConfirming(true)\n return\n case \"restart\": {\n // The settings an agent booted with are fixed for its lifetime, so a\n // configuration change needs a new one. Nothing is lost either way: the\n // conversation lives in the store and the same session key resumes it.\n //\n // **Attached, the screen does not come down.** The host owns the agent, so this\n // is a request to replace it — and there is nothing in this process to rebuild,\n // so tearing the frame down would be a teardown for its own sake. Embedded,\n // `onRestart` unmounts and the loop builds a new runtime; the unsent draft\n // rides across, because throwing away a half-written message is a second,\n // unasked-for consequence of asking for the first.\n const reload = source.reload\n if (reload === undefined) {\n onRestart?.(draft)\n exit()\n return\n }\n note(\"asking the host to reload this agent…\")\n reload()\n .then((adopted: readonly string[]) =>\n note(\n // Named rather than counted: replacing a supervisor replaces its\n // team, and \"3 agents reloaded\" would leave somebody guessing which.\n `reloaded ${adopted.join(\", \")} — this conversation continues`,\n ),\n )\n .catch((error: unknown) =>\n note(\n `could not reload: ${error instanceof Error ? error.message : String(error)}`,\n ),\n )\n return\n }\n case \"new\":\n // The same unmount-and-reopen route `/restart` and `/sessions` take, for the same\n // reason: a transcript cannot be re-keyed in place. Nothing is destroyed — the\n // conversation being left keeps its key, and the next banner names it.\n onNew?.(draft)\n exit()\n return\n case \"help\":\n note(sessionHelpText())\n return\n case \"tools\":\n // Fire-and-report, like `/status` and `/context` beside it: a component cannot\n // block, so the note is the acknowledgement. Embedded this resolves off the\n // live registry with no await worth mentioning; attached it is a request, and\n // the two must not read differently to whoever typed it.\n source\n .tools()\n .then((view: ToolsView) => note(toolsReport(view)))\n .catch((error: unknown) =>\n note(\n `could not read the tools: ${error instanceof Error ? error.message : String(error)}`,\n ),\n )\n return\n case \"context\":\n // Same shape as `status` below: a component cannot block, so the note is the\n // acknowledgement. Absent means the surface is not offered rather than accepted\n // and silently billed to the model, which is what `/status` did for three phases.\n if (contextView === undefined) {\n note(\"context is unavailable in this session\")\n return\n }\n contextView()\n .then(note)\n .catch((error: unknown) =>\n note(\n `could not read the context: ${error instanceof Error ? error.message : String(error)}`,\n ),\n )\n return\n case \"status\":\n // Declared in `SESSION_COMMANDS`, advertised in `/help` and generated into the\n // palette — and unhandled here, so it fell out of this switch and was sent to the\n // model as prose. Not a type error: the union's first member is\n // `{kind: SessionCommandKind}` and this switch has no exhaustiveness guard, which\n // is why `boundaries.test.ts` now walks every kind. Seventh instance in this repo\n // of every layer being right and one not being connected.\n //\n // Awaited through `.then` rather than inline: a component cannot block, and the\n // note *is* the acknowledgement — the same shape `reset` below uses.\n if (status === undefined) {\n note(\"status is unavailable in this session\")\n return\n }\n status()\n .then(note)\n .catch((error: unknown) =>\n note(\n `could not read the status: ${error instanceof Error ? error.message : String(error)}`,\n ),\n )\n return\n case \"reset\":\n // Fire-and-report rather than awaited: a component cannot block, and the note is\n // the acknowledgement. A failure surfaces as a rejected promise, so it is caught.\n source\n .clearSession(sessionKey)\n .then(() => note(\"session cleared — memory files on disk are untouched\"))\n .catch((error: unknown) =>\n note(\n `could not clear the session: ${error instanceof Error ? error.message : String(error)}`,\n ),\n )\n return\n case \"command\":\n // Through `dispatch`, which is the palette's path too — its own comment says it is\n // shared \"so the two cannot diverge\", and until now only one of the two reached it.\n if (dispatch(`/${command.name}`, command.rest)) return\n note(unknownCommandText({ word: `/${command.name}` }))\n return\n case \"unknown\":\n note(unknownCommandText(command))\n return\n }\n }\n if (busy) {\n // Two turns on one session would interleave in the history the next turn is conditioned\n // on. Refusing is honest; queueing silently would make the reply order unpredictable.\n note(\"a turn is still running — ^C cancels it, then send again\")\n return\n }\n send(text)\n }\n\n /**\n * Run a command and show what it printed.\n *\n * The pane opens *before* the command starts, with a spinner, for the same reason the skills browser\n * mounts before it fetches: a command that takes a second with nothing on screen is indistinguishable\n * from a keystroke that did nothing.\n */\n const openCommand = useCallback(\n (name: string, rest: string) => {\n setPane({ kind: \"output\", label: `/${name}`, lines: undefined, offset: 0 })\n void runSubcommand({ name, rest, manifestPath: manifestPath ?? \"\" })\n .then((result) =>\n setPane({\n kind: \"output\",\n label: `/${name}`,\n lines: result.lines,\n code: result.code,\n offset: 0,\n }),\n )\n .catch((error: unknown) =>\n setPane({\n kind: \"output\",\n label: `/${name}`,\n lines: [error instanceof Error ? error.message : String(error)],\n code: 1,\n offset: 0,\n }),\n )\n },\n [manifestPath],\n )\n\n /** A slash command, from the palette or from a typed line. Shared so the two cannot diverge. */\n const dispatch = useCallback(\n (word: string, rest: string) => {\n const entry = paletteEntries().find((candidate) => candidate.word === word)\n if (entry === undefined) return false\n if (entry.kind === \"view\") {\n if (\n entry.word === \"/sessions\" &&\n sessions !== undefined &&\n onSwitch !== undefined\n ) {\n // Opened before the read finishes, with the spinner the pane draws for an undefined\n // list — the same reason the catalogue mounts before it fetches: a keystroke followed\n // by nothing is indistinguishable from a keystroke that did nothing.\n setPane({ kind: \"sessions\", stored: undefined })\n void import(\"#components/SessionPicker\").then((module) =>\n // Wrapped in a function, or `useState` would call the component as an updater.\n setSessions(() => module.SessionPicker),\n )\n void sessions()\n .then((stored) => setPane({ kind: \"sessions\", stored }))\n .catch((error: unknown) => {\n setPane({ kind: \"none\" })\n note(\n `could not read the stored conversations: ${error instanceof Error ? error.message : String(error)}`,\n )\n })\n return true\n }\n if (entry.word === \"/config\" && (rest.trim() === \"\" || rest.trim() === \"edit\")) {\n // Bare `/config` is the editor; `/config list` and the rest are still the plain\n // command in an output pane, which the fallthrough below handles.\n if (manifestPath === undefined) {\n note(\"this session has no manifest path, so there is nothing to edit\")\n return true\n }\n setPane({ kind: \"config\", rows: editorRowsFor(manifestPath) })\n void import(\"#components/ConfigEditor\").then((module) =>\n // Wrapped in a function, or `useState` would call the component as an updater.\n setEditor_(() => module.ConfigEditor),\n )\n return true\n }\n if (entry.word === \"/skills\" && catalogue !== undefined) {\n setPane({ kind: \"skills\" })\n void import(\"#components/SkillBrowser\").then((module) =>\n // Wrapped in a function, or `useState` would call the component as an updater.\n setBrowser(() => module.SkillBrowser),\n )\n return true\n }\n // A view named in the table with nothing built yet falls back to its own output, which is\n // still the command doing its job — better than a palette entry that does nothing.\n openCommand(entry.word.slice(1), rest)\n return true\n }\n if (entry.kind === \"output\") {\n openCommand(entry.word.slice(1), rest)\n return true\n }\n return false\n },\n // `manifestPath` is read by the `/config` branch. A prop that does not change in practice, and\n // listing it is what stops a later change from being captured stale — the same reason the rule\n // exists rather than a suppression here.\n [openCommand, catalogue, sessions, onSwitch, note, manifestPath],\n )\n\n // ── the pane has the keyboard while it is open ────────────────────────────────────────\n useInput(\n (input, key) => {\n if (pane.kind !== \"output\") return\n if (key.escape || input === \"q\") {\n setPane({ kind: \"none\" })\n return\n }\n const total = pane.lines?.length ?? 0\n const step = key.pageDown || key.pageUp ? frame.pane : 1\n const delta =\n key.downArrow || key.pageDown ? step : key.upArrow || key.pageUp ? -step : 0\n if (delta !== 0) {\n setPane({\n ...pane,\n offset: Math.max(0, Math.min(pane.offset + delta, Math.max(0, total - 1))),\n })\n }\n },\n { isActive: pane.kind === \"output\" },\n )\n\n useInput(\n (input, reported) => {\n // Modifiers off the wire where they can be had, before anything reads one.\n //\n // Ink folds the super bit into `meta` on its legacy path (`modifier & 10`), so `cmd+←` and\n // `⌥←` arrive as the same keystroke and both word-move — measured in a real Warp session.\n // First line of the handler rather than beside `keyToIntent`, because the palette branch below\n // reads `key.escape` and `key.upArrow` too, and a correction applied after it would be one\n // that two of the three branches never got.\n const key = correctKeys === undefined ? reported : correctKeys(reported, input)\n\n // A pending confirmation owns the keyboard for exactly one keystroke. Anything other than a\n // yes is a no — including a stray arrow, because the safe answer to an unclear one is to stay.\n if (confirming) {\n setConfirming(false)\n if (input.toLowerCase() === \"y\" || key.return) exit()\n return\n }\n\n // The palette owns the keys it needs while it is open, and hands everything else to the editor —\n // so typing continues to narrow the list rather than being swallowed by it.\n if (palette !== undefined) {\n if (key.escape) {\n setEditor((current) => applyIntent(current, { kind: \"killToStart\" }))\n setPaletteIndex(0)\n return\n }\n if (key.upArrow || key.downArrow) {\n setPaletteIndex((at) =>\n Math.max(\n 0,\n Math.min(at + (key.downArrow ? 1 : -1), palette.matches.length - 1),\n ),\n )\n return\n }\n if (key.tab) {\n const chosen = paletteSelection(palette, paletteIndex)\n if (chosen !== undefined) {\n setEditor((current) =>\n applyIntent(\n { ...current, value: \"\", cursor: 0 },\n {\n kind: \"insert\",\n text: chosen.word,\n },\n ),\n )\n }\n return\n }\n const selected = paletteSelection(palette, paletteIndex)\n // Only intercepted when something is selected. With no match, enter falls through to the\n // ordinary submit path, which reports `/skils is not a command` and suggests the nearest\n // one — swallowing it here made a mistyped command do nothing at all, which is worse.\n if (key.return && selected !== undefined) {\n const chosen = selected\n setPaletteIndex(0)\n setEditor((current) => ({ ...current, value: \"\", cursor: 0 }))\n // A session verb goes through the same submit path a typed line takes, so `/help` and\n // `/reset` behave identically whether they were completed or typed out.\n // The buffer was cleared in the same handler, so nothing is left behind.\n if (chosen.kind === \"session\") onSubmit(chosen.word, \"\")\n else dispatch(chosen.word, \"\")\n return\n }\n }\n\n const intent = keyToIntent(\n input,\n key,\n keyContext(editor, busy, { armed, scrolled: !view.pinned }),\n )\n\n // Any keystroke that is not the second ^C disarms. Without this the warning would stay true\n // while somebody typed a whole message, and the ^C they pressed at the end of it — meaning\n // \"cancel that\" — would end the session instead.\n if (armed && intent.kind !== \"exit\") setArmed(false)\n\n if (intent.kind === \"arm\") {\n setArmed(true)\n return\n }\n if (intent.kind === \"scroll\") {\n // `times` is the wheel: one chunk can carry several notches, and applying one of them makes\n // a flick of the wheel move a single row. Folded rather than given its own move, so the\n // clamping at both ends stays in one function.\n const times = Math.max(1, intent.times ?? 1)\n setView((current) => {\n let next = current\n for (let step = 0; step < times; step += 1) {\n next = scroll(next, intent.move, rows.length, frame.transcript)\n }\n return next\n })\n return\n }\n if (intent.kind === \"pointer\") {\n // Screen cell to buffer row, through the one function that owns the frame's vertical\n // arithmetic. `undefined` means the cell was chrome — the header, the composer, the status\n // line — and a click there clears the selection rather than selecting the nearest row,\n // because clamping would make clicking the status bar highlight the last reply.\n const hit = transcriptHit(\n { column: intent.column, row: intent.row },\n { brandLines: mark?.lines.length ?? 0, from: window.from, to: window.to },\n )\n if (hit === undefined) {\n // Not the transcript — try the composer. Selecting your own draft with the mouse is\n // the same gesture and a different target, so it is the same branch rather than a\n // second handler that would have to re-derive which cell belongs to whom.\n const offset = composerHit(\n { column: intent.column, row: intent.row },\n { editor, columns, rows: size.rows, hint: landing },\n )\n if (offset === undefined) {\n // Genuine chrome. A press clears both selections rather than clamping to whatever\n // is nearest, because a click on the status line that highlighted the last reply\n // would look deliberate.\n if (intent.gesture === \"press\") {\n setSelection(undefined)\n setEditor((current) => ({ ...current, anchor: undefined }))\n }\n return\n }\n setSelection(undefined)\n setEditor((current) =>\n intent.gesture === \"press\" && !intent.shift\n ? // A press places the caret and starts a possible selection from it; the\n // anchor is set now so the first drag report has something to extend from.\n { ...current, cursor: offset, anchor: offset }\n : // A drag, or a shift-click, moves the cursor and keeps the anchor — which is\n // exactly what `extend` does for a shifted motion, expressed directly\n // because there is no motion here, only a destination.\n {\n ...current,\n cursor: offset,\n anchor: current.anchor ?? current.cursor,\n },\n )\n return\n }\n if (intent.gesture === \"press\") {\n // Shift extends whatever is already there, which is the gesture for correcting a\n // selection that stopped a word short. Checked before the click count, because a\n // shift-click is a deliberate second gesture rather than a fast repeat of the first.\n if (intent.shift && selection !== undefined) {\n setSelection(extendSelection(selection, hit))\n lastPress.current = undefined\n return\n }\n const previous = lastPress.current\n const repeat =\n previous !== undefined &&\n Date.now() - previous.when <= MULTI_CLICK_MS &&\n previous.at.row === hit.row &&\n previous.at.column === hit.column\n // Third click wraps back to one, so a fourth starts a fresh drag rather than doing\n // nothing — a count that only grew would leave rapid clicking permanently stuck on\n // \"line\".\n const clicks = repeat ? (previous.clicks % 3) + 1 : 1\n lastPress.current = { at: hit, when: Date.now(), clicks }\n // One selection at a time. Two visible highlights with one clipboard between them is\n // a screen that cannot say what ⌘C would copy.\n setEditor((current) => ({ ...current, anchor: undefined }))\n setSelection(\n clicks === 3\n ? lineAt(rows, hit)\n : clicks === 2\n ? wordAt(rows, hit)\n : beginSelection(hit),\n )\n return\n }\n if (intent.gesture === \"drag\") {\n setSelection((current) =>\n current === undefined ? undefined : dragSelection(current, hit),\n )\n return\n }\n // Release. The clipboard is written here and nowhere else, because `cmd+c` cannot reach a\n // terminal app — the terminal claims it and finds no native selection, mouse tracking\n // having disabled the one it would have used. Copying on mouse-up is what makes `cmd+v`\n // work, and a copy that failed says so rather than leaving the previous clipboard in place\n // looking like the wrong text was selected.\n // Derived from *this* report rather than from the state in the closure. A release carries\n // its own final position, and `selection` here is whatever the last render saw — which on\n // a fast drag-and-release is one motion behind, so copying from it would drop the last few\n // characters somebody deliberately included.\n const finished =\n selection === undefined\n ? undefined\n : endSelection(dragSelection(selection, hit))\n setSelection(finished)\n const text = selectedText(rows, finished)\n if (text !== \"\") {\n void copyToClipboard(text).then((result) => {\n if (!result.copied && result.problem !== \"nothing selected\") {\n note(`could not copy: ${result.problem ?? \"unknown\"}`)\n }\n })\n }\n return\n }\n if (intent.kind === \"copySelection\" || intent.kind === \"cutSelection\") {\n const range = selectionRange(editor)\n if (range === undefined) {\n note(\"nothing selected — hold shift with a motion, or drag in the box\")\n return\n }\n const text = [...editor.value].slice(range.start, range.end).join(\"\")\n if (intent.kind === \"cutSelection\")\n setEditor((current) => applyIntent(current, intent))\n void copyToClipboard(text).then((result) => {\n if (!result.copied) note(`could not copy: ${result.problem ?? \"unknown\"}`)\n })\n return\n }\n if (intent.kind === \"reasoning\") {\n // A chord with nothing to act on has to say so.\n //\n // Reported as \"⌥r doesn't do anything\", and it was arriving and resolving correctly the\n // whole time: it toggles a fold, and a fold with nothing in it looks exactly like a dead\n // key. Two different reasons for that, and they need two different sentences — a model\n // that never streams reasoning is not the same as a turn that has not produced any yet,\n // and only the first is worth changing a flag over.\n // Visibility, not existence — and the order matters. `useTurn` appends a reasoning item\n // for every delta the model streams *regardless* of `showReasoning`, and `transcript.ts`\n // filters them out at render. So a session with reasoning hidden has items that cannot be\n // shown, and testing existence first fell through to a toggle whose rows were filtered\n // away: silently nothing, which is the failure this whole branch exists to prevent.\n // A subagent's calls fold under the same key, and they are there whether or not this\n // model streams reasoning, so they are checked first: refusing ⌥r for \"reasoning is\n // off\" with a folded subagent on screen would be the dead key again.\n const subagents = state.items.some((item) =>\n (item.subagents ?? []).some((view) => view.lines.length > 0),\n )\n if (!subagents && !showReasoning) {\n note(\n \"reasoning is off: either this model does not stream it, or --no-reasoning is set\",\n )\n return\n }\n if (!subagents && !state.items.some((item) => item.role === \"reasoning\")) {\n note(\"no reasoning to show yet — this expands it once a turn has streamed some\")\n return\n }\n // Unfolding changes how tall the conversation is, so the window has to be told to follow\n // the newest row again — leaving it parked would put the reader at a row that has moved.\n setExpandReasoning((current) => !current)\n setView(FOLLOWING)\n return\n }\n if (intent.kind === \"exit\") {\n exit()\n return\n }\n if (intent.kind === \"cancel\") {\n cancel()\n return\n }\n if (intent.kind === \"submit\") {\n const committed = submit(editor)\n setEditor(committed.state)\n // Sending is an implicit \"take me back to the newest row\": a reply arriving into a window\n // parked ten screens up would be generated where nobody can see it.\n setView(FOLLOWING)\n if (committed.text !== \"\") onSubmit(committed.text, committed.state.value)\n return\n }\n if (intent.kind === \"paste\") {\n // Inserted with its newlines intact, as one message.\n //\n // This used to submit every finished line in the chunk, and that was right when the buffer\n // could not hold a newline: the alternative then was silently running the words together.\n // Now that a message is composed rather than typed on one line, sending line-by-line is the\n // bug multi-line composition exists to remove — pasting a twelve-line code block produced\n // twelve messages, each conditioned on the last, and no way to edit any of them.\n setEditor((current) =>\n applyIntent(current, { kind: \"insert\", text: intent.lines.join(\"\\n\") }),\n )\n return\n }\n // The match list changes underneath the cursor on every keystroke, so keeping its position\n // would silently highlight a different entry than the one on screen — the same reason the\n // history search resets its index.\n if (palette !== undefined) setPaletteIndex(0)\n setEditor((current) => applyIntent(current, intent))\n },\n { isActive: pane.kind === \"none\" },\n )\n\n if (pane.kind === \"config\") {\n return (\n <Box flexDirection=\"column\" width={columns} height={size.rows}>\n <Text color={THEME.accent} bold wrap=\"truncate\">\n {titleLine({ title: `${BRAND.name} ${VERSION}`, summary: \"settings\" }, columns)}\n </Text>\n {Editor === undefined ? (\n <Box marginLeft={2}>\n <Spinner label=\"reading the settings\" />\n </Box>\n ) : (\n <Editor\n rows={pane.rows}\n apply={(row, raw) => applyEditorRow(manifestPath ?? \"\", row, raw)}\n reload={() => editorRowsFor(manifestPath ?? \"\")}\n columns={columns}\n window={SESSION_PICKER_ROWS}\n onDone={(changed) => {\n setPane({ kind: \"none\" })\n // An agent's settings are fixed for the lifetime of the process running it,\n // so a change that is not followed by a restart is a change that silently\n // did not apply — rule 8's shape. The draft rides across, for the reason\n // `/restart` carries it: throwing away a half-written message is a second,\n // unasked-for consequence of asking for the first.\n if (changed) {\n onRestart?.(editor.value)\n exit()\n }\n }}\n />\n )}\n {/*\n * The slack goes *below* a long list, not above it. Bottom-anchoring is right for the\n * conversation switcher — a dozen short rows that read as a menu — and wrong here: the\n * settings run past twenty rows, so a spacer above them started the list mid-screen with\n * eight blank rows over it and the rest running off the bottom.\n */}\n <Box flexGrow={1} />\n </Box>\n )\n }\n\n if (pane.kind === \"sessions\") {\n return (\n <Box flexDirection=\"column\" width={columns} height={size.rows}>\n <Text color={THEME.accent} bold wrap=\"truncate\">\n {titleLine(\n { title: `${BRAND.name} ${VERSION}`, summary: \"pick a conversation\" },\n columns,\n )}\n </Text>\n <Box flexGrow={1} />\n {pane.stored === undefined || Sessions === undefined ? (\n <Box marginLeft={2}>\n <Spinner label=\"reading the stored conversations\" />\n </Box>\n ) : (\n <Sessions\n sessions={pane.stored}\n now={Date.now()}\n columns={columns}\n maxRows={SESSION_PICKER_ROWS}\n current={sessionKey}\n onDone={(picked) => {\n if (picked === undefined || picked === sessionKey) {\n // Esc, or the one already open. Either way nothing is worth a rebuild.\n setPane({ kind: \"none\" })\n return\n }\n onSwitch?.(picked, editor.value)\n exit()\n }}\n />\n )}\n <Box flexGrow={1} />\n </Box>\n )\n }\n\n if (pane.kind === \"skills\" && catalogue !== undefined && Browser !== undefined) {\n return (\n <Browser\n title={`${BRAND.name} ${VERSION}`}\n agents={[]}\n target={manifestPath ?? \"\"}\n load={catalogue.load}\n install={catalogue.install}\n onDone={() => setPane({ kind: \"none\" })}\n />\n )\n }\n\n const header = titleLine(\n {\n title: `${BRAND.name} ${VERSION}`,\n summary: \"\",\n agent: { name: agentName, model },\n ...(warnings === undefined || warnings.length === 0 ? {} : { warnings }),\n },\n columns,\n )\n\n return (\n // Fixed height, because the alternate screen has no scrollback to absorb an overshoot: one row too\n // many and Ink's own output scrolls the buffer, which leaves the status line halfway up the display.\n <Box flexDirection=\"column\" width={columns} height={size.rows}>\n {/*\n * Above the one-line header, and only while landing. Nothing appears or disappears when it goes —\n * the line below it is the same line either way, which is what makes the collapse read as the same\n * screen with less on it rather than as a different screen.\n */}\n {mark === undefined ? null : (\n <>\n <Brandmark lines={mark.lines} />\n <Text> </Text>\n </>\n )}\n <Text color={THEME.accent} bold wrap=\"truncate\">\n {header}\n </Text>\n\n {pane.kind === \"output\" ? (\n <Box flexDirection=\"column\">\n <CommandOutput\n lines={pane.lines}\n label={pane.label}\n offset={pane.offset}\n maxRows={frame.pane}\n {...(pane.code === undefined ? {} : { code: pane.code })}\n />\n <Text dimColor wrap=\"truncate\">\n {\" \"}↑↓ scroll · esc back to the prompt\n </Text>\n </Box>\n ) : (\n <Transcript\n rows={rows}\n slice={window}\n {...(selection === undefined ? {} : { selection })}\n />\n )}\n\n {/*\n * Absorbs the slack, so the composer sits on the bottom edge of every frame.\n *\n * Unconditional, and that is the whole of decision 11.98's reversal. It used to stand down while\n * landing, on the grounds that twelve blank rows between the banner and the input read as a\n * half-empty screen — but a bottom-anchored input is where the eye already rests, so what those\n * rows read as is a prompt waiting. The reference CLI puts ~25 there and nobody reports it.\n *\n * The cost of the old arrangement was not the blank rows, it was that the composer *moved*: it\n * was drawn under whatever content existed, so it walked down the screen as the first few\n * messages arrived and only settled once the transcript filled the window. The place you type\n * should not move. A spacer costs nothing once the transcript is full, because by then there is\n * no slack left for it to take.\n */}\n <Box flexGrow={1} />\n\n {state.live === undefined ? null : (\n <Live live={state.live} showReasoning={showReasoning} columns={columns} />\n )}\n {palette === undefined ? null : (\n <Palette\n palette={palette}\n index={paletteIndex}\n width={columns}\n maxRows={frame.paletteRows}\n />\n )}\n <HistorySearch editor={editor} width={columns} maxRows={listRows} />\n {/*\n * Rendered once, in the one frame, which is the fix rather than a feature: this lived only in the\n * transcript layout, so `/exit` typed on the landing screen asked for a confirmation nobody could\n * see — the session simply appeared to ignore the command until a second keystroke ended it.\n */}\n {confirming ? (\n <Text color={THEME.warning} wrap=\"truncate\">\n {\" leave this session? press y to confirm · any other key stays\"}\n </Text>\n ) : null}\n <Prompt\n editor={editor}\n busy={busy}\n columns={columns}\n {...(landing ? { placeholder: \"Ask anything…\" } : {})}\n />\n {/*\n * The keys worth knowing before there is a conversation to learn them from. It stands down once\n * one exists: the status line already carries `^C`, and a permanent hint is a row of conversation.\n */}\n {landing ? (\n <Text dimColor wrap=\"truncate\">\n {\" \"}\n {NEW_SESSION_HINT}\n </Text>\n ) : null}\n {/* The status line is the footer, under the input — where every reference CLI puts\n it, and where the eye rests between keystrokes. */}\n <StatusBar\n status={state.status}\n model={model}\n sessionKey={sessionKey}\n elapsedMs={elapsed}\n last={last}\n quiet={quiet}\n armed={armed}\n {...(state.pressure === undefined ? {} : { pressure: state.pressure })}\n {...(state.phase === undefined ? {} : { phase: state.phase })}\n />\n </Box>\n )\n}\n",
6
6
  "/**\n * A command's output, in a scrollable pane inside the session.\n *\n * ## Why one pane rather than nine screens\n *\n * Every command in the table already produces good text — `keyValue` blocks, sections, the house\n * vocabulary in `lib/render.ts`. Nine bespoke screens for `/status`, `/policy`, `/config`, `/model` and\n * the rest would mostly reproduce those same tables in JSX, and several of them are read-only lists where\n * a generic pane and a hand-made one look identical.\n *\n * So this runs the command, captures what it printed, and shows it. That makes *every* non-hidden command\n * reachable from the palette the moment it exists, which is what \"all the CLI inside the TUI\" asks for,\n * and leaves a bespoke view as something a command earns by having a next action worth a keypress —\n * skills and sources have one, `/policy` does not.\n *\n * Controlled: the scroll offset lives in the screen root, and this owns no keyboard.\n */\n\nimport { Box, Text } from \"ink\"\nimport { Spinner } from \"#components/Spinner\"\nimport { viewport } from \"#lib/rows\"\nimport { GLYPH, THEME } from \"#lib/theme\"\n\nexport interface CommandOutputProps {\n /** `undefined` while it is still running. */\n readonly lines: readonly string[] | undefined\n readonly label: string\n /** First visible line. Clamped here, so a shrinking output cannot leave the view past its end. */\n readonly offset: number\n readonly maxRows: number\n /** Non-zero means the command reported a failure; shown, never hidden behind a clean-looking pane. */\n readonly code?: number\n}\n\nexport function CommandOutput({ lines, label, offset, maxRows, code }: CommandOutputProps) {\n if (lines === undefined) {\n return (\n <Box marginLeft={2}>\n <Spinner label={`running ${label}`} />\n </Box>\n )\n }\n\n if (lines.length === 0) {\n return (\n <Box marginLeft={2}>\n <Text color={THEME.muted}>{label} printed nothing</Text>\n </Box>\n )\n }\n\n // `viewport` centres on a cursor; here the cursor *is* the offset, so it is asked for the row at the\n // top of the window and clamped by the same arithmetic the lists use.\n const { from, to } = viewport(\n lines.length,\n Math.min(offset + Math.floor(maxRows / 2), lines.length - 1),\n maxRows,\n )\n\n const visible = lines.slice(from, to).map((text, at) => ({ row: from + at, text }))\n\n return (\n <Box flexDirection=\"column\">\n {code !== undefined && code !== 0 ? (\n <Text color={THEME.error} wrap=\"truncate\">\n {GLYPH.error}\n {label} exited {code}\n </Text>\n ) : null}\n {from > 0 ? (\n <Text dimColor wrap=\"truncate\">\n {\" \"}\n {GLYPH.ellipsis} {from} line{from === 1 ? \"\" : \"s\"} above\n </Text>\n ) : null}\n {visible.map((entry) => (\n // Keyed by the row's position in the whole output, computed before the map so the key is a\n // line number rather than a callback index. Position is the honest identity here: two\n // identical lines in a report are different lines, and a content key would collapse them.\n <Text key={entry.row} wrap=\"truncate\">\n {entry.text}\n </Text>\n ))}\n {to < lines.length ? (\n <Text dimColor wrap=\"truncate\">\n {\" \"}\n {GLYPH.ellipsis} {lines.length - to} line{lines.length - to === 1 ? \"\" : \"s\"}{\" \"}\n below\n </Text>\n ) : null}\n </Box>\n )\n}\n",
7
7
  "/**\n * `^R` — what you have already sent, filtered as you type, above the prompt.\n *\n * A list rather than bash's in-place `(reverse-i-search)` line, and deliberately the same shape the\n * slash palette uses: matches above the input, narrowing as you type, ↑↓ to pick, ⏎ to use, esc to\n * cancel. One interaction learned once and used by both — a shell shows a single match at a time\n * because a shell has one line to work with, which is not a constraint here.\n *\n * Controlled and presentational: the query, the match list and the selected index all come from\n * `editor.ts`, and this component owns no keyboard. The line being composed is untouched until a match\n * is accepted, so the search costs nothing to cancel — which is why the draft can stay on screen\n * underneath.\n */\n\nimport { Box, Text } from \"ink\"\nimport { searchMatches } from \"#editor\"\nimport { clip, viewport } from \"#lib/rows\"\nimport { GLYPH, THEME } from \"#lib/theme\"\nimport type { EditorState } from \"#lib/types\"\n\nexport interface HistorySearchProps {\n readonly editor: EditorState\n /** Terminal columns, so a long message is clipped rather than wrapped into the list. */\n readonly width: number\n /** Visible matches. The list scrolls inside this rather than pushing the prompt off the screen. */\n readonly maxRows: number\n}\n\nexport function HistorySearch({ editor, width, maxRows }: HistorySearchProps) {\n const search = editor.search\n if (search === undefined) return null\n\n const matches = searchMatches(editor)\n const index = Math.min(search.index, Math.max(0, matches.length - 1))\n const { from, to } = viewport(matches.length, index, maxRows)\n // Two for the gutter, and the query line needs room for its own label.\n const room = Math.max(8, width - 4)\n\n return (\n <Box flexDirection=\"column\">\n {matches.length === 0 ? (\n <Text color={THEME.muted} wrap=\"truncate\">\n {\" \"}\n nothing you have sent matches that\n </Text>\n ) : (\n matches.slice(from, to).map((entry, offset) => {\n const at = from + offset\n const selected = at === index\n return (\n // Keyed by the entry, which is unique: `searchMatches` deduplicates, so the same\n // question asked twice appears once.\n <Text key={entry} wrap=\"truncate\">\n <Text color={THEME.accent}>{selected ? GLYPH.pointer : \" \"}</Text>\n <Text bold={selected} dimColor={!selected}>\n {/* Newlines collapsed: a multi-line message has to read as one row here,\n the same rule the catalogue list follows. */}\n {clip(entry.replace(/\\s+/g, \" \"), room)}\n </Text>\n </Text>\n )\n })\n )}\n <Text wrap=\"truncate\">\n <Text color={THEME.muted}>{\" search: \"}</Text>\n {search.query}\n <Text inverse> </Text>\n {matches.length > 1 ? (\n <Text color={THEME.muted}>{` ${index + 1} of ${matches.length}`}</Text>\n ) : null}\n </Text>\n </Box>\n )\n}\n",
8
8
  "/**\n * The reply being generated — the only part of the conversation that redraws.\n *\n * Height-capped on purpose. Ink redraws this whole subtree per frame, so an uncapped pane means redrawing\n * the entire reply on every token: the cost grows with the length of the answer, precisely when the\n * terminal is busiest. `livePane` keeps the newest rows and drops the older ones, which is what the reader\n * is looking at anyway; the whole reply joins the transcript at `turn.end`, so nothing is lost — it just\n * arrives complete rather than in a redrawn window.\n *\n * It renders pre-wrapped rows rather than handing Ink a paragraph, for the reason `lib/wrap.ts` explains:\n * Ink breaks at spaces and a division does not, so a cap measured one way and drawn the other was always\n * a row or two short of the truth. The chat frame subtracts this pane's height from the terminal before it\n * renders, so being short by a row is a frame taller than the screen.\n */\n\nimport { Box, Text } from \"ink\"\nimport { LIVE_PANE_MAX_ROWS } from \"#lib/const\"\nimport type { LiveProps } from \"#lib/schema\"\nimport { livePane } from \"#lib/wrap\"\n\nexport function Live({ live, showReasoning, columns }: LiveProps) {\n const showing = showReasoning && live.reasoning !== \"\" && live.text === \"\"\n const text = showing ? live.reasoning : live.text\n if (text === \"\") return null\n\n // The reasoning label is a prefix on the first row, so the wrap has to account for its width or that\n // row is one longer than every other.\n const label = showing ? \"· reasoning · \" : \"\"\n const pane = livePane(text, columns - [...label].length, LIVE_PANE_MAX_ROWS)\n // Row numbers computed before the map, so the key is a position rather than a callback index. Position\n // is the honest identity here: two identical rows of a streamed reply are different rows, and a content\n // key would collapse them.\n const rows = pane.lines.map((text, at) => ({ at, text }))\n\n return (\n <Box flexDirection=\"column\">\n {pane.hidden > 0 ? (\n <Text dimColor wrap=\"truncate\">\n … {pane.hidden} earlier row(s) hidden while streaming\n </Text>\n ) : null}\n {rows.map((row) => (\n <Text key={`row-${row.at}`} dimColor={showing} wrap=\"truncate\">\n {row.at === 0 ? label : \"\"}\n {row.text}\n </Text>\n ))}\n </Box>\n )\n}\n",
@@ -18,7 +18,7 @@
18
18
  "/**\n * Putting text on the system clipboard.\n *\n * ## Why this has to exist at all\n *\n * `cmd+c` cannot reach a terminal application. The terminal's own Edit > Copy claims it first, and finds no\n * native selection to copy because mouse tracking disabled the terminal's selection in order to deliver the\n * drag events. The reference CLI says the same thing in its own words and draws the same conclusion: copy\n * on mouse-up, so `cmd+v` then works and the chord nobody can intercept is the one that matters.\n *\n * ## Why not OSC 52\n *\n * There is an escape sequence for this — `OSC 52` asks the terminal to set the clipboard — and it is\n * refused, truncated, or silently ignored by enough terminals that a copy would sometimes do nothing with\n * no way to tell. A subprocess either runs or reports why. It is also the only form that works over ssh\n * *without* the remote terminal cooperating, which is a real advantage OSC 52 has; the trade is taken\n * knowingly, and a failure says which command was missing.\n */\n\nimport { spawnCaptureAsync } from \"#lib/spawn\"\n\n/** Candidates in order of preference, first one present wins. */\nconst WRITERS: readonly { readonly command: string; readonly args: readonly string[] }[] = [\n // macOS.\n { command: \"pbcopy\", args: [] },\n // Wayland, before X11: a Wayland session usually has `xclip` too, through Xwayland, and writing to the\n // X clipboard there puts the text somewhere the compositor's own paste will not find it.\n { command: \"wl-copy\", args: [] },\n { command: \"xclip\", args: [\"-selection\", \"clipboard\"] },\n { command: \"xsel\", args: [\"--clipboard\", \"--input\"] },\n]\n\nexport interface CopyResult {\n readonly copied: boolean\n /** Which command did it, for a message that names what happened rather than asserting success. */\n readonly using?: string\n readonly problem?: string\n}\n\n/**\n * Copy `text` to the clipboard, or say why not.\n *\n * Never throws and never reports success it did not have: a copy that silently failed leaves somebody\n * pasting the *previous* contents of their clipboard, which looks like the wrong text was selected.\n */\nexport async function copyToClipboard(text: string): Promise<CopyResult> {\n if (text === \"\") return { copied: false, problem: \"nothing selected\" }\n const missing: string[] = []\n for (const writer of WRITERS) {\n const result = await spawnCaptureAsync({\n command: writer.command,\n args: writer.args,\n input: text,\n // Generous but bounded: a clipboard helper that hangs must not hang the session with it.\n timeoutMs: 2_000,\n })\n if (result.notFound) {\n missing.push(writer.command)\n continue\n }\n if (result.code === 0) return { copied: true, using: writer.command }\n return {\n copied: false,\n using: writer.command,\n problem: result.stderr.trim() || `${writer.command} exited ${result.code}`,\n }\n }\n return { copied: false, problem: `no clipboard command found (tried ${missing.join(\", \")})` }\n}\n",
19
19
  "/**\n * Running one of this binary's own commands, for a pane inside a session.\n *\n * ## Why a child process rather than calling the function\n *\n * The obvious implementation is to call `validateCommand()` and swap `process.stdout.write` for a\n * collector. It is also wrong here: Ink *owns* stdout while a session is mounted, and it writes a frame\n * whenever anything re-renders. A frame drawn during the capture window lands in the collector instead of\n * on the terminal — so the screen silently misses a repaint and the pane shows a frame of itself. Nothing\n * errors; the display is just wrong, intermittently, depending on timing.\n *\n * A child writes to its own pipe. Nothing is hijacked, the frame keeps rendering, and the pane shows\n * exactly what the command prints — which is also the honest thing to show, since \"run this command\" is\n * what the palette offered. The cost is process startup, which is the same ~100 ms every command in this\n * CLI already pays and is invisible next to reading the result.\n *\n * `--plain` is forced, for the reason it exists: a child that thought it had a terminal would return\n * escape sequences, and the pane would render them as text.\n */\n\nimport { findCommand } from \"#lib/commands\"\nimport { spawnCaptureAsync } from \"#lib/spawn\"\n\nexport interface SubcommandResult {\n readonly lines: readonly string[]\n readonly code: number\n}\n\nexport interface SubcommandRequest {\n readonly name: string\n /** Arguments as typed after the command word, split on whitespace. */\n readonly rest: string\n /** The agent this session is running, passed to any command that takes a manifest. */\n readonly manifestPath: string\n /** Injected by tests. `process.execPath` and `process.argv[1]` otherwise. */\n readonly interpreter?: string\n readonly script?: string\n readonly env?: Readonly<Record<string, string | undefined>>\n readonly timeoutMs?: number\n}\n\n/**\n * Where this command wants the manifest among its positionals, or `-1` for one that takes none.\n *\n * Read off the command's own spec rather than a hand-kept list, which was wrong in both directions at\n * once. `NO_MANIFEST` held four names: `soul` takes an *action* first and was not listed, so\n * `/soul distill` ran as `soul <manifestPath> distill` and the action became a path — broken in-session\n * for as long as it has been offered there; and `agents` takes a variadic manifest first and *was*\n * listed, so it ran with none at all.\n *\n * It also could not express the real shape. `config` and `memory` take an action and *then* a manifest,\n * so \"prepend or not\" has no right answer for them — the path belongs at index 1. `soul`'s second\n * positional is a `file` (a long-form identity document, not a manifest), which is why matching on the\n * name matters rather than on the position.\n *\n * The same drift `session-commands.ts` exists to end: a second list describing `COMMANDS` disagrees with\n * it on the first command either one grows. Derived, a new command is covered with nothing to remember.\n */\nfunction manifestIndex(name: string): number {\n return findCommand(name)?.args.findIndex((arg) => arg.name === \"manifest\") ?? -1\n}\n\n/**\n * The argv for a request.\n *\n * Pure and exported so the assembly is testable without starting anything — which matters because\n * getting it wrong means a command runs against the wrong agent, and that is not visible in the output.\n */\nexport function subcommandArgv(request: SubcommandRequest): readonly string[] {\n const rest = request.rest.trim() === \"\" ? [] : request.rest.trim().split(/\\s+/)\n const at = manifestIndex(request.name)\n // Inserted only when everything before it was typed. `/skills` bare would otherwise become\n // `skills <manifestPath>`, putting a path where the action goes — and a command that resolves the\n // agent from the cwd instead is the lesser wrong: it may pick a different agent, where this one\n // cannot run at all. `--plain` stays last, so it cannot be swallowed as a flag's value.\n const positionals =\n at === -1 || rest.length < at\n ? rest\n : [...rest.slice(0, at), request.manifestPath, ...rest.slice(at)]\n return [request.name, ...positionals, \"--plain\"]\n}\n\n/**\n * Why a pane must not run this request, if it must not.\n *\n * A pane captures a child to completion, so a command that never finishes is a pane that shows a spinner\n * until the timeout fires and then reports being killed — thirty seconds of a frozen surface for a flag\n * that worked perfectly at a shell. `daemon logs --follow` is the case: it exists precisely to keep\n * printing until interrupted, and there is nothing for it to be interrupted *by* in here.\n *\n * Refused rather than quietly dropped. Dropping the flag would hand back the tail, which looks like a\n * following command that stopped immediately — a wrong answer that reads as a right one. Keyed off the\n * command's own spec, so a second command that grows a `follow` flag is covered with nothing to remember.\n */\nexport function paneRefusal(request: SubcommandRequest): string | undefined {\n const spec = findCommand(request.name)\n if (spec === undefined) return undefined\n const follow = spec.flags.find((flag) => flag.name === \"follow\")\n if (follow === undefined) return undefined\n const tokens = request.rest.trim().split(/\\s+/)\n const asked = tokens.some(\n (token) =>\n token === \"--follow\" || (follow.short !== undefined && token === `-${follow.short}`),\n )\n if (!asked) return undefined\n return `--follow keeps printing until it is interrupted, and a pane has nothing to interrupt it with. Run it in its own terminal: ${request.name} ${request.rest.trim()}`\n}\n\nexport async function runSubcommand(request: SubcommandRequest): Promise<SubcommandResult> {\n const refusal = paneRefusal(request)\n // Non-zero, because it did not do what was asked. A refusal reported as success is the shape hard\n // rule 8 forbids, whatever the message says.\n if (refusal !== undefined) return { lines: [refusal], code: 1 }\n\n // The interpreter and the script that started this process — `node` and `dist/index.js` under\n // the npm install, `bun` and `src/index.ts` from a checkout. `request.interpreter`/`request.script`\n // override, because the tests inject both; an interpreter injected without a script gets an\n // empty one rather than this process's, which would run the wrong program under the fake.\n const interpreter = request.interpreter ?? process.execPath\n const script =\n request.script ?? (request.interpreter !== undefined ? \"\" : (process.argv[1] ?? \"\"))\n const result = await spawnCaptureAsync({\n command: interpreter,\n args: [script, ...subcommandArgv(request)],\n ...(request.env === undefined ? {} : { env: request.env }),\n timeoutMs: request.timeoutMs ?? 30_000,\n })\n\n // stderr is shown, not dropped. A command that failed says why on stderr, and a pane that showed only\n // stdout would render an empty box for the case a person most needs to read.\n const body = [result.stdout, result.stderr].filter((part) => part.trim() !== \"\").join(\"\\n\")\n const lines = body === \"\" ? [] : body.replace(/\\n+$/, \"\").split(\"\\n\")\n if (result.notFound) {\n return { lines: [`could not run ${interpreter}`], code: 1 }\n }\n if (result.signalled) {\n return { lines: [...lines, `${request.name} was stopped before it finished`], code: 1 }\n }\n return { lines, code: result.code }\n}\n"
20
20
  ],
21
- "mappings": ";0zBA2BA,cAAS,UAAK,YAAM,eAAQ,aAC5B,sBAA6B,gBAAa,cAAW,aAAS,eAAQ,cCVtE,cAAS,WAAK,iEAgBP,SAAS,EAAa,EAAG,QAAO,QAAO,SAAQ,UAAS,QAA4B,CACvF,GAAI,IAAU,OACV,OACI,GAAC,GAAD,CAAK,WAAY,EAAjB,SACI,GAAC,GAAD,CAAS,MAAO,WAAW,IAAS,EACtC,EAIV,GAAI,EAAM,SAAW,EACjB,OACI,GAAC,GAAD,CAAK,WAAY,EAAjB,SACI,GAAC,GAAD,CAAM,MAAO,EAAM,MAAnB,SAAmD,CAAxB,EAA3B,oBAAmD,EACrD,EAMV,IAAQ,OAAM,MAAO,GACjB,EAAM,OACN,KAAK,IAAI,EAAS,KAAK,MAAM,EAAU,CAAC,EAAG,EAAM,OAAS,CAAC,EAC3D,CACJ,EAEM,EAAU,EAAM,MAAM,EAAM,CAAE,EAAE,IAAI,CAAC,EAAM,KAAQ,CAAE,IAAK,EAAO,EAAI,MAAK,EAAE,EAElF,OACI,GAAC,GAAD,CAAK,cAAc,SAAnB,SA4BE,CA3BG,IAAS,QAAa,IAAS,EAC5B,GAAC,GAAD,CAAM,MAAO,EAAM,MAAO,KAAK,WAA/B,SAGE,CAFG,EAAM,MACN,EAFL,WAEoB,GAClB,EACF,KACH,EAAO,EACJ,GAAC,GAAD,CAAM,SAAQ,GAAC,KAAK,WAApB,SAGE,CAFG,KACA,EAAM,SAFX,IAEsB,EAFtB,QAEiC,IAAS,EAAI,GAAK,IAFnD,UAGE,EACF,KACH,EAAQ,IAAI,CAAC,IAIV,GAAC,GAAD,CAAsB,KAAK,WAA3B,SACK,EAAM,MADA,EAAM,GAEf,CACL,EACA,EAAK,EAAM,O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,EAAI,CAAE,WAAU,EACpD,EAiBJ,EAAC,EAAD,CAAK,SAAU,EAAG,EAEjB,EAAM,OAAS,OAAY,KACxB,EAAC,GAAD,CAAM,KAAM,EAAM,KAAM,cAAe,EAAe,QAAS,EAAS,EAE3E,IAAY,OAAY,KACrB,EAAC,GAAD,CACI,QAAS,EACT,MAAO,GACP,MAAO,EACP,QAAS,EAAM,YACnB,EAEJ,EAAC,GAAD,CAAe,OAAQ,EAAQ,MAAO,EAAS,QAAS,GAAU,EAMjE,GACG,EAAC,EAAD,CAAM,MAAO,EAAM,QAAS,KAAK,WAAjC,SACK,iEACH,EACF,KACJ,EAAC,GAAD,CACI,OAAQ,EACR,KAAM,GACN,QAAS,KACJ,EAAU,CAAE,YAAa,eAAgB,EAAI,CAAC,EACvD,EAKC,EACG,EAAC,EAAD,CAAM,SAAQ,GAAC,KAAK,WAApB,SAGE,CAFG,KACA,IACH,EACF,KAGJ,EAAC,GAAD,CACI,OAAQ,EAAM,OACd,MAAO,EACP,WAAY,EACZ,UAAW,GACX,KAAM,GACN,MAAO,EACP,MAAO,MACF,EAAM,WAAa,OAAY,CAAC,EAAI,CAAE,SAAU,EAAM,QAAS,KAC/D,EAAM,QAAU,OAAY,CAAC,EAAI,CAAE,MAAO,EAAM,KAAM,EAC/D,GACF",
22
+ "debugId": "A9CB6A7901DF057064756E2164756E21",
23
23
  "names": []
24
24
  }
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import{B,N,p,a,ne,l,Ee,M,w,pe,xe,CA,P}from"./index-633eqxry.js";import{I}from"./index-t6xnecdx.js";var Q=I(N(),1);function U(e){let t=e.trim();if(t.length!==36||t[8]!=="-"||t[13]!=="-"||t[18]!=="-"||t[23]!=="-")throw Error(`Invalid GUID format: ${e}`);let r,i=new Uint8Array(16);r=parseInt(t.slice(0,8),16),i[0]=r&255,i[1]=r>>>8&255,i[2]=r>>>16&255,i[3]=r>>>24&255,r=parseInt(t.slice(9,13),16),i[4]=r&255,i[5]=r>>>8&255,r=parseInt(t.slice(14,18),16),i[6]=r&255,i[7]=r>>>8&255,r=parseInt(t.slice(19,23),16),i[8]=r>>>8&255,i[9]=r&255,r=parseInt(t.slice(24,32),16),i[10]=r>>>24&255,i[11]=r>>>16&255,i[12]=r>>>8&255,i[13]=r&255,r=parseInt(t.slice(32,36),16),i[14]=r>>>8&255,i[15]=r&255;for(let s=0;s<16;s++)if(!Number.isFinite(i[s]))throw Error(`Invalid GUID format: ${e}`);if(!/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/.test(t))throw Error(`Invalid GUID format: ${e}`);return i}class A{constructor(e){if(e.length!==16)throw Error("GUID must be exactly 16 bytes");this.bytes=e}static fromString(e){return new A(U(e))}toString(){let e=this.bytes,t=(m)=>m.toString(16).padStart(2,"0"),r=t(e[3])+t(e[2])+t(e[1])+t(e[0]),i=t(e[5])+t(e[4]),s=t(e[7])+t(e[6]),o=t(e[8])+t(e[9]),c=t(e[10])+t(e[11])+t(e[12])+t(e[13])+t(e[14])+t(e[15]);return`${r}-${i}-${s}-${o}-${c}`.toUpperCase()}equals(e,t=0){if(t<0||e.length-t<16)return!1;let r=this.bytes;for(let i=0;i<16;i++)if(e[t+i]!==r[i])return!1;return!0}}class n{static fromBin(e,t=0){return new n(n.decode(e,t))}static decode(e,t=0){return new A(e.subarray(t,t+16)).toString()}static decodeMediaType(e){switch(e.str){case n.AudioMedia.str:return"audio";case n.VideoMedia.str:return"video";case n.CommandMedia.str:return"command";case n.Degradable_JPEG_Media.str:return"degradable-jpeg";case n.FileTransferMedia.str:return"file-transfer";case n.BinaryMedia.str:return"binary"}}static encode(e){return U(e)}constructor(e){this.str=e}equals(e){return this.str===e.str}toBin(){return n.encode(this.str)}}n.HeaderObject=new n("75B22630-668E-11CF-A6D9-00AA0062CE6C");n.DataObject=new n("75B22636-668E-11CF-A6D9-00AA0062CE6C");n.SimpleIndexObject=new n("33000890-E5B1-11CF-89F4-00A0C90349CB");n.IndexObject=new n("D6E229D3-35DA-11D1-9034-00A0C90349BE");n.MediaObjectIndexObject=new n("FEB103F8-12AD-4C64-840F-2A1D2F7AD48C");n.TimecodeIndexObject=new n("3CB73FD0-0C4A-4803-953D-EDF7B6228F0C");n.FilePropertiesObject=new n("8CABDCA1-A947-11CF-8EE4-00C00C205365");n.StreamPropertiesObject=new n("B7DC0791-A9B7-11CF-8EE6-00C00C205365");n.HeaderExtensionObject=new n("5FBF03B5-A92E-11CF-8EE3-00C00C205365");n.CodecListObject=new n("86D15240-311D-11D0-A3A4-00A0C90348F6");n.ScriptCommandObject=new n("1EFB1A30-0B62-11D0-A39B-00A0C90348F6");n.MarkerObject=new n("F487CD01-A951-11CF-8EE6-00C00C205365");n.BitrateMutualExclusionObject=new n("D6E229DC-35DA-11D1-9034-00A0C90349BE");n.ErrorCorrectionObject=new n("75B22635-668E-11CF-A6D9-00AA0062CE6C");n.ContentDescriptionObject=new n("75B22633-668E-11CF-A6D9-00AA0062CE6C");n.ExtendedContentDescriptionObject=new n("D2D0A440-E307-11D2-97F0-00A0C95EA850");n.ContentBrandingObject=new n("2211B3FA-BD23-11D2-B4B7-00A0C955FC6E");n.StreamBitratePropertiesObject=new n("7BF875CE-468D-11D1-8D82-006097C9A2B2");n.ContentEncryptionObject=new n("2211B3FB-BD23-11D2-B4B7-00A0C955FC6E");n.ExtendedContentEncryptionObject=new n("298AE614-2622-4C17-B935-DAE07EE9289C");n.DigitalSignatureObject=new n("2211B3FC-BD23-11D2-B4B7-00A0C955FC6E");n.PaddingObject=new n("1806D474-CADF-4509-A4BA-9AABCB96AAE8");n.ExtendedStreamPropertiesObject=new n("14E6A5CB-C672-4332-8399-A96952065B5A");n.AdvancedMutualExclusionObject=new n("A08649CF-4775-4670-8A16-6E35357566CD");n.GroupMutualExclusionObject=new n("D1465A40-5A79-4338-B71B-E36B8FD6C249");n.StreamPrioritizationObject=new n("D4FED15B-88D3-454F-81F0-ED5C45999E24");n.BandwidthSharingObject=new n("A69609E6-517B-11D2-B6AF-00C04FD908E9");n.LanguageListObject=new n("7C4346A9-EFE0-4BFC-B229-393EDE415C85");n.MetadataObject=new n("C5F8CBEA-5BAF-4877-8467-AA8C44FA4CCA");n.MetadataLibraryObject=new n("44231C94-9498-49D1-A141-1D134E457054");n.IndexParametersObject=new n("D6E229DF-35DA-11D1-9034-00A0C90349BE");n.MediaObjectIndexParametersObject=new n("6B203BAD-3F11-48E4-ACA8-D7613DE2CFA7");n.TimecodeIndexParametersObject=new n("F55E496D-9797-4B5D-8C8B-604DFE9BFB24");n.CompatibilityObject=new n("26F18B5D-4584-47EC-9F5F-0E651F0452C9");n.AdvancedContentEncryptionObject=new n("43058533-6981-49E6-9B74-AD12CB86D58C");n.AudioMedia=new n("F8699E40-5B4D-11CF-A8FD-00805F5C442B");n.VideoMedia=new n("BC19EFC0-5B4D-11CF-A8FD-00805F5C442B");n.CommandMedia=new n("59DACFC0-59E6-11D0-A3AC-00A0C90348F6");n.JFIF_Media=new n("B61BE100-5B4E-11CF-A8FD-00805F5C442B");n.Degradable_JPEG_Media=new n("35907DE0-E415-11CF-A917-00805F5C442B");n.FileTransferMedia=new n("91BD222C-F21C-497A-8B6D-5AA86BFC0185");n.BinaryMedia=new n("3AFB65E2-47EF-40F2-AC2C-70A90D71D343");n.ASF_Index_Placeholder_Object=new n("D9AADE20-7C17-4F9C-BC28-8555DD98E2A2");var d=n;function f(e){return Y[e]}function F(e){return xe(pe(e,"utf-16le"))}var Y=[F,H,Z,G,ee,W,H];function H(e){return new Uint8Array(e)}function Z(e,t=0){return W(e,t)===1}function G(e,t=0){return a.get(e,t)}function ee(e,t=0){return ne.get(e,t)}function W(e,t=0){return p.get(e,t)}class g extends M("ASF"){}var z={len:30,get:(e,t)=>{let r=C.get(e,t);if(r.objectSize<z.len)throw new g(`Invalid ASF top-level header object size: ${r.objectSize}`);return{...r,numberOfHeaderObjects:a.get(e,t+24)}}},C={len:24,get:(e,t)=>{let r=ne.get(e,t+16);if(r<BigInt(C.len)||r>BigInt(Number.MAX_SAFE_INTEGER))throw new g(`Invalid ASF header object size: ${r}`);return{objectId:d.fromBin(e,t),objectSize:Number(r)}}};class h{constructor(e){this.len=e.objectSize-C.len}postProcessTag(e,t,r,i){if(t==="WM/Picture")e.push({id:t,value:L.fromBuffer(i)});else{let s=f(r);if(!s)throw new g(`unexpected value headerType: ${r}`);e.push({id:t,value:s(i)})}}}class D extends h{get(e,t){return{fileId:d.fromBin(e,t),fileSize:ne.get(e,t+16),creationDate:ne.get(e,t+24),dataPacketsCount:ne.get(e,t+32),playDuration:ne.get(e,t+40),sendDuration:ne.get(e,t+48),preroll:ne.get(e,t+56),flags:{broadcast:w(e,t+64,24),seekable:w(e,t+64,25)},minimumDataPacketSize:a.get(e,t+68),maximumDataPacketSize:a.get(e,t+72),maximumBitrate:a.get(e,t+76)}}}D.guid=d.FilePropertiesObject;class x extends h{get(e,t){return{streamType:d.decodeMediaType(d.fromBin(e,t)),errorCorrectionType:d.fromBin(e,t+8)}}}x.guid=d.StreamPropertiesObject;class u{constructor(){this.len=22}get(e,t){let r=new DataView(e.buffer,t);return{reserved1:d.fromBin(e,t),reserved2:r.getUint16(16,!0),extensionDataSize:r.getUint32(18,!0)}}}u.guid=d.HeaderExtensionObject;var te={len:20,get:(e,t)=>({entryCount:new DataView(e.buffer,t).getUint16(16,!0)})};class R{constructor(e,t){this.tokenizer=e,this.remaining=t}async readToken(e){this.ensureAvailable(e.len);let t=await this.tokenizer.readToken(e);return this.remaining-=e.len,t}async readNumber(e){return this.readToken(e)}async readBuffer(e){this.ensureAvailable(e);let t=new Uint8Array(e);return await this.tokenizer.readBuffer(t),this.remaining-=e,t}async ignoreRemaining(){let e=await this.tokenizer.ignore(this.remaining);if(e!==this.remaining)throw new g(`Unexpected end of ASF Codec List Object; missing ${this.remaining-e} bytes`);this.remaining=0}ensureAvailable(e){if(e>this.remaining)throw new g(`ASF Codec List field size ${e} exceeds remaining object payload size ${this.remaining}`)}}async function V(e){let t=await e.readNumber(p);return(await e.readToken(new l(t*2,"utf-16le"))).replace("\x00","")}async function q(e,t){let r=new R(e,t),i=await r.readToken(te),s=[];for(let o=0;o<i.entryCount;++o)s.push(await re(r));return await r.ignoreRemaining(),s}async function ae(e){let t=await e.readNumber(p);return e.readBuffer(t)}async function re(e){let t=await e.readNumber(p);return{type:{videoCodec:(t&1)===1,audioCodec:(t&2)===2},codecName:await V(e),description:await V(e),information:await ae(e)}}class j extends h{get(e,t){let r=[],i=new DataView(e.buffer,t),s=10;for(let o=0;o<j.contentDescTags.length;++o){let c=i.getUint16(o*2,!0);if(c>0){let m=j.contentDescTags[o],b=s+c;r.push({id:m,value:F(e.subarray(t+s,t+b))}),s=b}}return r}}j.guid=d.ContentDescriptionObject;j.contentDescTags=["Title","Author","Copyright","Description","Rating"];class T extends h{get(e,t){let r=[],i=new DataView(e.buffer,t),s=i.getUint16(0,!0),o=2;for(let c=0;c<s;c+=1){let m=i.getUint16(o,!0);o+=2;let b=F(e.subarray(t+o,t+o+m));o+=m;let O=i.getUint16(o,!0);o+=2;let S=i.getUint16(o,!0);o+=2;let v=e.subarray(t+o,t+o+S);o+=S,this.postProcessTag(r,b,O,v)}return r}}T.guid=d.ExtendedContentDescriptionObject;class y extends h{get(e,t){let r=new DataView(e.buffer,t);return{startTime:ne.get(e,t),endTime:ne.get(e,t+8),dataBitrate:r.getInt32(12,!0),bufferSize:r.getInt32(16,!0),initialBufferFullness:r.getInt32(20,!0),alternateDataBitrate:r.getInt32(24,!0),alternateBufferSize:r.getInt32(28,!0),alternateInitialBufferFullness:r.getInt32(32,!0),maximumObjectSize:r.getInt32(36,!0),flags:{reliableFlag:w(e,t+40,0),seekableFlag:w(e,t+40,1),resendLiveCleanpointsFlag:w(e,t+40,2)},streamNumber:r.getInt16(42,!0),streamLanguageId:r.getInt16(44,!0),averageTimePerFrame:r.getInt32(52,!0),streamNameCount:r.getInt32(54,!0),payloadExtensionSystems:r.getInt32(56,!0),streamNames:[],streamPropertiesObject:null}}}y.guid=d.ExtendedStreamPropertiesObject;class E extends h{get(e,t){let r=[],i=new DataView(e.buffer,t),s=i.getUint16(0,!0),o=2;for(let c=0;c<s;c+=1){o+=4;let m=i.getUint16(o,!0);o+=2;let b=i.getUint16(o,!0);o+=2;let O=i.getUint32(o,!0);o+=4;let S=F(e.subarray(t+o,t+o+m));o+=m;let v=e.subarray(t+o,t+o+O);o+=O,this.postProcessTag(r,S,b,v)}return r}}E.guid=d.MetadataObject;class k extends E{}k.guid=d.MetadataLibraryObject;class L{static fromBuffer(e){return new L(e.length).get(e,0)}constructor(e){this.len=e}get(e,t){let r=new DataView(e.buffer,t),i=r.getUint8(0),s=r.getInt32(1,!0),o=5;while(r.getUint16(o)!==0)o+=2;let c=new l(o-5,"utf-16le").get(e,5);while(r.getUint16(o)!==0)o+=2;let m=new l(o-5,"utf-16le").get(e,5);return{type:CA[i],format:c,description:m,size:s,data:e.slice(o+4)}}}var _=Q.default("music-metadata:parser:ASF"),oe="asf",J=16777216;class se extends P{async parse(){let e=await this.tokenizer.readToken(z);if(!e.objectId.equals(d.HeaderObject))throw new g(`expected asf header; but was not found; got: ${e.objectId.str}`);if(e.numberOfHeaderObjects<1||e.numberOfHeaderObjects>1e4)throw new g(`Unrealistic number of ASF header objects: ${e.numberOfHeaderObjects}`);await this.parseObjectHeaders(e.numberOfHeaderObjects,e.objectSize-z.len)}async parseObjectHeaders(e,t){let r;for(let i=0;i<e;++i){let{header:s,payloadSize:o}=await this.readObjectHeader(t,"header");switch(_("header GUID=%s",s.objectId.str),s.objectId.str){case D.guid.str:{this.validateAllocationSize(o,"File Properties Object");let c=await this.tokenizer.readToken(new D(s));this.metadata.setFormat("duration",Number(c.playDuration/BigInt(1000))/1e4-Number(c.preroll)/1000),this.metadata.setFormat("bitrate",c.maximumBitrate);break}case x.guid.str:{this.validateAllocationSize(o,"Stream Properties Object");let c=await this.tokenizer.readToken(new x(s));this.metadata.setFormat("container",`ASF/${c.streamType}`);break}case u.guid.str:{let c=new u;if(o<c.len)throw new g(`ASF Header Extension Object payload is too small: ${o} bytes`);let m=await this.tokenizer.readToken(c),b=o-c.len;if(m.extensionDataSize!==b)throw new g(`ASF extension data size ${m.extensionDataSize} does not match enclosing payload size ${b}`);await this.parseExtensionObject(m.extensionDataSize);break}case j.guid.str:this.validateAllocationSize(o,"Content Description Object"),r=await this.tokenizer.readToken(new j(s)),await this.addTags(r);break;case T.guid.str:this.validateAllocationSize(o,"Extended Content Description Object"),r=await this.tokenizer.readToken(new T(s)),await this.addTags(r);break;case d.CodecListObject.str:{this.validateAllocationSize(o,"Codec List Object");let c;try{c=await q(this.tokenizer,o)}catch(b){let O=b instanceof Error?b.message:String(b);throw new g(`Invalid ASF Codec List Object: ${O}`)}c.forEach((b)=>{this.metadata.addStreamInfo({type:b.type.videoCodec?Ee.video:Ee.audio,codecName:b.codecName})});let m=c.filter((b)=>b.type.audioCodec).map((b)=>b.codecName).join("/");this.metadata.setFormat("codec",m);break}case d.StreamBitratePropertiesObject.str:await this.ignorePayload(o,"Stream Bitrate Properties Object");break;case d.PaddingObject.str:_("Padding: %s bytes",o),await this.ignorePayload(o,"Padding Object");break;default:this.metadata.addWarning(`Ignore ASF-Object-GUID: ${s.objectId.str}`),_("Ignore ASF-Object-GUID: %s",s.objectId.str),await this.ignorePayload(o,`object ${s.objectId.str}`)}t-=s.objectSize}if(t!==0)throw new g(`ASF header child objects leave ${t} payload byte(s) unaccounted`)}async addTags(e){await Promise.all(e.map(({id:t,value:r})=>this.metadata.addTag(oe,t,r)))}async readObjectHeader(e,t){if(e<C.len)throw new g(`Insufficient ASF ${t} data for an object header: ${e} bytes`);let r=await this.tokenizer.readToken(C);if(r.objectSize>e)throw new g(`ASF ${t} object size ${r.objectSize} exceeds remaining ${t} payload size ${e}`);return{header:r,payloadSize:this.validatePayloadAvailability(r,`${t} object`)}}validatePayloadAvailability(e,t){let r=e.objectSize-C.len,i=this.tokenizer.fileInfo.size;if(i!==void 0){let s=i-this.tokenizer.position;if(r>s)throw new g(`ASF ${t} payload size ${r} exceeds available input size ${s}`)}return r}validateAllocationSize(e,t){if(e>J)throw new g(`ASF ${t} payload size ${e} exceeds allocation limit ${J}`)}async ignorePayload(e,t){let r;try{r=await this.tokenizer.ignore(e)}catch(i){if(i instanceof B)throw new g(`Unexpected end of ASF ${t}`);throw i}if(r!==e)throw new g(`Unexpected end of ASF ${t}; missing ${e-r} bytes`)}async parseExtensionObject(e){while(e>0){let{header:t,payloadSize:r}=await this.readObjectHeader(e,"extension");switch(t.objectId.str){case y.guid.str:this.validateAllocationSize(r,"Extended Stream Properties Object"),await this.tokenizer.readToken(new y(t));break;case E.guid.str:{this.validateAllocationSize(r,"Metadata Object");let i=await this.tokenizer.readToken(new E(t));await this.addTags(i);break}case k.guid.str:{this.validateAllocationSize(r,"Metadata Library Object");let i=await this.tokenizer.readToken(new k(t));await this.addTags(i);break}case d.PaddingObject.str:await this.ignorePayload(r,"extension Padding Object");break;case d.CompatibilityObject.str:await this.ignorePayload(r,"Compatibility Object");break;case d.ASF_Index_Placeholder_Object.str:await this.ignorePayload(r,"Index Placeholder Object");break;default:this.metadata.addWarning(`Ignore ASF-Object-GUID: ${t.objectId.str}`),await this.ignorePayload(r,`extension object ${t.objectId.str}`);break}e-=t.objectSize}}}export{se as AsfParser};
2
+ import{B,N,f,a,re,l,Ce,M,w,fe,Ke,fA,G}from"./index-22fzzn7z.js";import{I}from"./index-323jvr1g.js";var J=I(N(),1);function v(e){let t=e.trim();if(t.length!==36||t[8]!=="-"||t[13]!=="-"||t[18]!=="-"||t[23]!=="-")throw Error(`Invalid GUID format: ${e}`);let r,i=new Uint8Array(16);r=parseInt(t.slice(0,8),16),i[0]=r&255,i[1]=r>>>8&255,i[2]=r>>>16&255,i[3]=r>>>24&255,r=parseInt(t.slice(9,13),16),i[4]=r&255,i[5]=r>>>8&255,r=parseInt(t.slice(14,18),16),i[6]=r&255,i[7]=r>>>8&255,r=parseInt(t.slice(19,23),16),i[8]=r>>>8&255,i[9]=r&255,r=parseInt(t.slice(24,32),16),i[10]=r>>>24&255,i[11]=r>>>16&255,i[12]=r>>>8&255,i[13]=r&255,r=parseInt(t.slice(32,36),16),i[14]=r>>>8&255,i[15]=r&255;for(let s=0;s<16;s++)if(!Number.isFinite(i[s]))throw Error(`Invalid GUID format: ${e}`);if(!/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/.test(t))throw Error(`Invalid GUID format: ${e}`);return i}class S{constructor(e){if(e.length!==16)throw Error("GUID must be exactly 16 bytes");this.bytes=e}static fromString(e){return new S(v(e))}toString(){let e=this.bytes,t=(m)=>m.toString(16).padStart(2,"0"),r=t(e[3])+t(e[2])+t(e[1])+t(e[0]),i=t(e[5])+t(e[4]),s=t(e[7])+t(e[6]),o=t(e[8])+t(e[9]),c=t(e[10])+t(e[11])+t(e[12])+t(e[13])+t(e[14])+t(e[15]);return`${r}-${i}-${s}-${o}-${c}`.toUpperCase()}equals(e,t=0){if(t<0||e.length-t<16)return!1;let r=this.bytes;for(let i=0;i<16;i++)if(e[t+i]!==r[i])return!1;return!0}}class n{static fromBin(e,t=0){return new n(n.decode(e,t))}static decode(e,t=0){return new S(e.subarray(t,t+16)).toString()}static decodeMediaType(e){switch(e.str){case n.AudioMedia.str:return"audio";case n.VideoMedia.str:return"video";case n.CommandMedia.str:return"command";case n.Degradable_JPEG_Media.str:return"degradable-jpeg";case n.FileTransferMedia.str:return"file-transfer";case n.BinaryMedia.str:return"binary"}}static encode(e){return v(e)}constructor(e){this.str=e}equals(e){return this.str===e.str}toBin(){return n.encode(this.str)}}n.HeaderObject=new n("75B22630-668E-11CF-A6D9-00AA0062CE6C");n.DataObject=new n("75B22636-668E-11CF-A6D9-00AA0062CE6C");n.SimpleIndexObject=new n("33000890-E5B1-11CF-89F4-00A0C90349CB");n.IndexObject=new n("D6E229D3-35DA-11D1-9034-00A0C90349BE");n.MediaObjectIndexObject=new n("FEB103F8-12AD-4C64-840F-2A1D2F7AD48C");n.TimecodeIndexObject=new n("3CB73FD0-0C4A-4803-953D-EDF7B6228F0C");n.FilePropertiesObject=new n("8CABDCA1-A947-11CF-8EE4-00C00C205365");n.StreamPropertiesObject=new n("B7DC0791-A9B7-11CF-8EE6-00C00C205365");n.HeaderExtensionObject=new n("5FBF03B5-A92E-11CF-8EE3-00C00C205365");n.CodecListObject=new n("86D15240-311D-11D0-A3A4-00A0C90348F6");n.ScriptCommandObject=new n("1EFB1A30-0B62-11D0-A39B-00A0C90348F6");n.MarkerObject=new n("F487CD01-A951-11CF-8EE6-00C00C205365");n.BitrateMutualExclusionObject=new n("D6E229DC-35DA-11D1-9034-00A0C90349BE");n.ErrorCorrectionObject=new n("75B22635-668E-11CF-A6D9-00AA0062CE6C");n.ContentDescriptionObject=new n("75B22633-668E-11CF-A6D9-00AA0062CE6C");n.ExtendedContentDescriptionObject=new n("D2D0A440-E307-11D2-97F0-00A0C95EA850");n.ContentBrandingObject=new n("2211B3FA-BD23-11D2-B4B7-00A0C955FC6E");n.StreamBitratePropertiesObject=new n("7BF875CE-468D-11D1-8D82-006097C9A2B2");n.ContentEncryptionObject=new n("2211B3FB-BD23-11D2-B4B7-00A0C955FC6E");n.ExtendedContentEncryptionObject=new n("298AE614-2622-4C17-B935-DAE07EE9289C");n.DigitalSignatureObject=new n("2211B3FC-BD23-11D2-B4B7-00A0C955FC6E");n.PaddingObject=new n("1806D474-CADF-4509-A4BA-9AABCB96AAE8");n.ExtendedStreamPropertiesObject=new n("14E6A5CB-C672-4332-8399-A96952065B5A");n.AdvancedMutualExclusionObject=new n("A08649CF-4775-4670-8A16-6E35357566CD");n.GroupMutualExclusionObject=new n("D1465A40-5A79-4338-B71B-E36B8FD6C249");n.StreamPrioritizationObject=new n("D4FED15B-88D3-454F-81F0-ED5C45999E24");n.BandwidthSharingObject=new n("A69609E6-517B-11D2-B6AF-00C04FD908E9");n.LanguageListObject=new n("7C4346A9-EFE0-4BFC-B229-393EDE415C85");n.MetadataObject=new n("C5F8CBEA-5BAF-4877-8467-AA8C44FA4CCA");n.MetadataLibraryObject=new n("44231C94-9498-49D1-A141-1D134E457054");n.IndexParametersObject=new n("D6E229DF-35DA-11D1-9034-00A0C90349BE");n.MediaObjectIndexParametersObject=new n("6B203BAD-3F11-48E4-ACA8-D7613DE2CFA7");n.TimecodeIndexParametersObject=new n("F55E496D-9797-4B5D-8C8B-604DFE9BFB24");n.CompatibilityObject=new n("26F18B5D-4584-47EC-9F5F-0E651F0452C9");n.AdvancedContentEncryptionObject=new n("43058533-6981-49E6-9B74-AD12CB86D58C");n.AudioMedia=new n("F8699E40-5B4D-11CF-A8FD-00805F5C442B");n.VideoMedia=new n("BC19EFC0-5B4D-11CF-A8FD-00805F5C442B");n.CommandMedia=new n("59DACFC0-59E6-11D0-A3AC-00A0C90348F6");n.JFIF_Media=new n("B61BE100-5B4E-11CF-A8FD-00805F5C442B");n.Degradable_JPEG_Media=new n("35907DE0-E415-11CF-A917-00805F5C442B");n.FileTransferMedia=new n("91BD222C-F21C-497A-8B6D-5AA86BFC0185");n.BinaryMedia=new n("3AFB65E2-47EF-40F2-AC2C-70A90D71D343");n.ASF_Index_Placeholder_Object=new n("D9AADE20-7C17-4F9C-BC28-8555DD98E2A2");var d=n;function _(e){return K[e]}function E(e){return Ke(fe(e,"utf-16le"))}var K=[E,L,Y,Z,ee,H,L];function L(e){return new Uint8Array(e)}function Y(e,t=0){return H(e,t)===1}function Z(e,t=0){return a.get(e,t)}function ee(e,t=0){return re.get(e,t)}function H(e,t=0){return f.get(e,t)}class g extends M("ASF"){}var A={len:30,get:(e,t)=>{let r=j.get(e,t);if(r.objectSize<A.len)throw new g(`Invalid ASF top-level header object size: ${r.objectSize}`);return{...r,numberOfHeaderObjects:a.get(e,t+24)}}},j={len:24,get:(e,t)=>{let r=re.get(e,t+16);if(r<BigInt(j.len)||r>BigInt(Number.MAX_SAFE_INTEGER))throw new g(`Invalid ASF header object size: ${r}`);return{objectId:d.fromBin(e,t),objectSize:Number(r)}}};class C{constructor(e){this.len=e.objectSize-j.len}postProcessTag(e,t,r,i){if(t==="WM/Picture")e.push({id:t,value:P.fromBuffer(i)});else{let s=_(r);if(!s)throw new g(`unexpected value headerType: ${r}`);e.push({id:t,value:s(i)})}}}class F extends C{get(e,t){return{fileId:d.fromBin(e,t),fileSize:re.get(e,t+16),creationDate:re.get(e,t+24),dataPacketsCount:re.get(e,t+32),playDuration:re.get(e,t+40),sendDuration:re.get(e,t+48),preroll:re.get(e,t+56),flags:{broadcast:w(e,t+64,24),seekable:w(e,t+64,25)},minimumDataPacketSize:a.get(e,t+68),maximumDataPacketSize:a.get(e,t+72),maximumBitrate:a.get(e,t+76)}}}F.guid=d.FilePropertiesObject;class D extends C{get(e,t){return{streamType:d.decodeMediaType(d.fromBin(e,t)),errorCorrectionType:d.fromBin(e,t+8)}}}D.guid=d.StreamPropertiesObject;class x{constructor(){this.len=22}get(e,t){let r=new DataView(e.buffer,t);return{reserved1:d.fromBin(e,t),reserved2:r.getUint16(16,!0),extensionDataSize:r.getUint32(18,!0)}}}x.guid=d.HeaderExtensionObject;var te={len:20,get:(e,t)=>({entryCount:new DataView(e.buffer,t).getUint16(16,!0)})};class V{constructor(e,t){this.tokenizer=e,this.remaining=t}async readToken(e){this.ensureAvailable(e.len);let t=await this.tokenizer.readToken(e);return this.remaining-=e.len,t}async readNumber(e){return this.readToken(e)}async readBuffer(e){this.ensureAvailable(e);let t=new Uint8Array(e);return await this.tokenizer.readBuffer(t),this.remaining-=e,t}async ignoreRemaining(){let e=await this.tokenizer.ignore(this.remaining);if(e!==this.remaining)throw new g(`Unexpected end of ASF Codec List Object; missing ${this.remaining-e} bytes`);this.remaining=0}ensureAvailable(e){if(e>this.remaining)throw new g(`ASF Codec List field size ${e} exceeds remaining object payload size ${this.remaining}`)}}async function W(e){let t=await e.readNumber(f);return(await e.readToken(new l(t*2,"utf-16le"))).replace("\x00","")}async function R(e,t){let r=new V(e,t),i=await r.readToken(te),s=[];for(let o=0;o<i.entryCount;++o)s.push(await ne(r));return await r.ignoreRemaining(),s}async function ae(e){let t=await e.readNumber(f);return e.readBuffer(t)}async function ne(e){let t=await e.readNumber(f);return{type:{videoCodec:(t&1)===1,audioCodec:(t&2)===2},codecName:await W(e),description:await W(e),information:await ae(e)}}class p extends C{get(e,t){let r=[],i=new DataView(e.buffer,t),s=10;for(let o=0;o<p.contentDescTags.length;++o){let c=i.getUint16(o*2,!0);if(c>0){let m=p.contentDescTags[o],b=s+c;r.push({id:m,value:E(e.subarray(t+s,t+b))}),s=b}}return r}}p.guid=d.ContentDescriptionObject;p.contentDescTags=["Title","Author","Copyright","Description","Rating"];class u extends C{get(e,t){let r=[],i=new DataView(e.buffer,t),s=i.getUint16(0,!0),o=2;for(let c=0;c<s;c+=1){let m=i.getUint16(o,!0);o+=2;let b=E(e.subarray(t+o,t+o+m));o+=m;let h=i.getUint16(o,!0);o+=2;let k=i.getUint16(o,!0);o+=2;let z=e.subarray(t+o,t+o+k);o+=k,this.postProcessTag(r,b,h,z)}return r}}u.guid=d.ExtendedContentDescriptionObject;class T extends C{get(e,t){let r=new DataView(e.buffer,t);return{startTime:re.get(e,t),endTime:re.get(e,t+8),dataBitrate:r.getInt32(12,!0),bufferSize:r.getInt32(16,!0),initialBufferFullness:r.getInt32(20,!0),alternateDataBitrate:r.getInt32(24,!0),alternateBufferSize:r.getInt32(28,!0),alternateInitialBufferFullness:r.getInt32(32,!0),maximumObjectSize:r.getInt32(36,!0),flags:{reliableFlag:w(e,t+40,0),seekableFlag:w(e,t+40,1),resendLiveCleanpointsFlag:w(e,t+40,2)},streamNumber:r.getInt16(42,!0),streamLanguageId:r.getInt16(44,!0),averageTimePerFrame:r.getInt32(52,!0),streamNameCount:r.getInt32(54,!0),payloadExtensionSystems:r.getInt32(56,!0),streamNames:[],streamPropertiesObject:null}}}T.guid=d.ExtendedStreamPropertiesObject;class O extends C{get(e,t){let r=[],i=new DataView(e.buffer,t),s=i.getUint16(0,!0),o=2;for(let c=0;c<s;c+=1){o+=4;let m=i.getUint16(o,!0);o+=2;let b=i.getUint16(o,!0);o+=2;let h=i.getUint32(o,!0);o+=4;let k=E(e.subarray(t+o,t+o+m));o+=m;let z=e.subarray(t+o,t+o+h);o+=h,this.postProcessTag(r,k,b,z)}return r}}O.guid=d.MetadataObject;class y extends O{}y.guid=d.MetadataLibraryObject;class P{static fromBuffer(e){return new P(e.length).get(e,0)}constructor(e){this.len=e}get(e,t){let r=new DataView(e.buffer,t),i=r.getUint8(0),s=r.getInt32(1,!0),o=5;while(r.getUint16(o)!==0)o+=2;let c=new l(o-5,"utf-16le").get(e,5);while(r.getUint16(o)!==0)o+=2;let m=new l(o-5,"utf-16le").get(e,5);return{type:fA[i],format:c,description:m,size:s,data:e.slice(o+4)}}}var U=J.default("music-metadata:parser:ASF"),oe="asf",q=16777216;class se extends G{async parse(){let e=await this.tokenizer.readToken(A);if(!e.objectId.equals(d.HeaderObject))throw new g(`expected asf header; but was not found; got: ${e.objectId.str}`);if(e.numberOfHeaderObjects<1||e.numberOfHeaderObjects>1e4)throw new g(`Unrealistic number of ASF header objects: ${e.numberOfHeaderObjects}`);await this.parseObjectHeaders(e.numberOfHeaderObjects,e.objectSize-A.len)}async parseObjectHeaders(e,t){let r;for(let i=0;i<e;++i){let{header:s,payloadSize:o}=await this.readObjectHeader(t,"header");switch(U("header GUID=%s",s.objectId.str),s.objectId.str){case F.guid.str:{this.validateAllocationSize(o,"File Properties Object");let c=await this.tokenizer.readToken(new F(s));this.metadata.setFormat("duration",Number(c.playDuration/BigInt(1000))/1e4-Number(c.preroll)/1000),this.metadata.setFormat("bitrate",c.maximumBitrate);break}case D.guid.str:{this.validateAllocationSize(o,"Stream Properties Object");let c=await this.tokenizer.readToken(new D(s));this.metadata.setFormat("container",`ASF/${c.streamType}`);break}case x.guid.str:{let c=new x;if(o<c.len)throw new g(`ASF Header Extension Object payload is too small: ${o} bytes`);let m=await this.tokenizer.readToken(c),b=o-c.len;if(m.extensionDataSize!==b)throw new g(`ASF extension data size ${m.extensionDataSize} does not match enclosing payload size ${b}`);await this.parseExtensionObject(m.extensionDataSize);break}case p.guid.str:this.validateAllocationSize(o,"Content Description Object"),r=await this.tokenizer.readToken(new p(s)),await this.addTags(r);break;case u.guid.str:this.validateAllocationSize(o,"Extended Content Description Object"),r=await this.tokenizer.readToken(new u(s)),await this.addTags(r);break;case d.CodecListObject.str:{this.validateAllocationSize(o,"Codec List Object");let c;try{c=await R(this.tokenizer,o)}catch(b){let h=b instanceof Error?b.message:String(b);throw new g(`Invalid ASF Codec List Object: ${h}`)}c.forEach((b)=>{this.metadata.addStreamInfo({type:b.type.videoCodec?Ce.video:Ce.audio,codecName:b.codecName})});let m=c.filter((b)=>b.type.audioCodec).map((b)=>b.codecName).join("/");this.metadata.setFormat("codec",m);break}case d.StreamBitratePropertiesObject.str:await this.ignorePayload(o,"Stream Bitrate Properties Object");break;case d.PaddingObject.str:U("Padding: %s bytes",o),await this.ignorePayload(o,"Padding Object");break;default:this.metadata.addWarning(`Ignore ASF-Object-GUID: ${s.objectId.str}`),U("Ignore ASF-Object-GUID: %s",s.objectId.str),await this.ignorePayload(o,`object ${s.objectId.str}`)}t-=s.objectSize}if(t!==0)throw new g(`ASF header child objects leave ${t} payload byte(s) unaccounted`)}async addTags(e){await Promise.all(e.map(({id:t,value:r})=>this.metadata.addTag(oe,t,r)))}async readObjectHeader(e,t){if(e<j.len)throw new g(`Insufficient ASF ${t} data for an object header: ${e} bytes`);let r=await this.tokenizer.readToken(j);if(r.objectSize>e)throw new g(`ASF ${t} object size ${r.objectSize} exceeds remaining ${t} payload size ${e}`);return{header:r,payloadSize:this.validatePayloadAvailability(r,`${t} object`)}}validatePayloadAvailability(e,t){let r=e.objectSize-j.len,i=this.tokenizer.fileInfo.size;if(i!==void 0){let s=i-this.tokenizer.position;if(r>s)throw new g(`ASF ${t} payload size ${r} exceeds available input size ${s}`)}return r}validateAllocationSize(e,t){if(e>q)throw new g(`ASF ${t} payload size ${e} exceeds allocation limit ${q}`)}async ignorePayload(e,t){let r;try{r=await this.tokenizer.ignore(e)}catch(i){if(i instanceof B)throw new g(`Unexpected end of ASF ${t}`);throw i}if(r!==e)throw new g(`Unexpected end of ASF ${t}; missing ${e-r} bytes`)}async parseExtensionObject(e){while(e>0){let{header:t,payloadSize:r}=await this.readObjectHeader(e,"extension");switch(t.objectId.str){case T.guid.str:this.validateAllocationSize(r,"Extended Stream Properties Object"),await this.tokenizer.readToken(new T(t));break;case O.guid.str:{this.validateAllocationSize(r,"Metadata Object");let i=await this.tokenizer.readToken(new O(t));await this.addTags(i);break}case y.guid.str:{this.validateAllocationSize(r,"Metadata Library Object");let i=await this.tokenizer.readToken(new y(t));await this.addTags(i);break}case d.PaddingObject.str:await this.ignorePayload(r,"extension Padding Object");break;case d.CompatibilityObject.str:await this.ignorePayload(r,"Compatibility Object");break;case d.ASF_Index_Placeholder_Object.str:await this.ignorePayload(r,"Index Placeholder Object");break;default:this.metadata.addWarning(`Ignore ASF-Object-GUID: ${t.objectId.str}`),await this.ignorePayload(r,`extension object ${t.objectId.str}`);break}e-=t.objectSize}}}export{se as AsfParser};
3
3
 
4
- //# debugId=05C20B46957A865F64756E2164756E21
5
- //# sourceMappingURL=AsfParser-d784ak3y.js.map
4
+ //# debugId=0170C02AE3779ACE64756E2164756E21
5
+ //# sourceMappingURL=AsfParser-7emspn04.js.map