dispach 0.2.2 → 0.2.4

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 (225) hide show
  1. package/README.md +34 -27
  2. package/dist/APEv2Parser-x13n424p.js +5 -0
  3. package/dist/{FlacParser-7t7da7qy.js.map → APEv2Parser-x13n424p.js.map} +1 -1
  4. package/dist/{AiffParser-y21k3fak.js → AiffParser-ns1y9f0g.js} +3 -3
  5. package/dist/{AiffParser-y21k3fak.js.map → AiffParser-ns1y9f0g.js.map} +1 -1
  6. package/dist/App-wkpkwgjt.js +11 -0
  7. package/dist/{App-4w3qkcs4.js.map → App-wkpkwgjt.js.map} +3 -3
  8. package/dist/AsfParser-bae2a1yf.js +5 -0
  9. package/dist/{AsfParser-wd98k2h4.js.map → AsfParser-bae2a1yf.js.map} +1 -1
  10. package/dist/ConfigEditor-hy9jtas3.js +6 -0
  11. package/dist/{ConfigEditor-vk7vxaa6.js.map → ConfigEditor-hy9jtas3.js.map} +1 -1
  12. package/dist/DsdiffParser-s0zvxnfa.js +5 -0
  13. package/dist/{DsdiffParser-cbfaj500.js.map → DsdiffParser-s0zvxnfa.js.map} +1 -1
  14. package/dist/{DsfParser-tybrja4x.js → DsfParser-90mvzt4v.js} +3 -3
  15. package/dist/{DsfParser-tybrja4x.js.map → DsfParser-90mvzt4v.js.map} +1 -1
  16. package/dist/FlacParser-8xprykrh.js +5 -0
  17. package/dist/{APEv2Parser-etzjd528.js.map → FlacParser-8xprykrh.js.map} +1 -1
  18. package/dist/{KeyProbe-5anphmb7.js → KeyProbe-fk5krzks.js} +3 -3
  19. package/dist/{KeyProbe-5anphmb7.js.map → KeyProbe-fk5krzks.js.map} +1 -1
  20. package/dist/MP4Parser-nmvbkq21.js +5 -0
  21. package/dist/{MP4Parser-gc94h1n9.js.map → MP4Parser-nmvbkq21.js.map} +2 -2
  22. package/dist/{MatroskaParser-cy2k4fac.js → MatroskaParser-tsmz2qfq.js} +3 -3
  23. package/dist/{MatroskaParser-cy2k4fac.js.map → MatroskaParser-tsmz2qfq.js.map} +1 -1
  24. package/dist/{MpegParser-c460fwf0.js → MpegParser-y5fjpaz9.js} +3 -3
  25. package/dist/{MpegParser-c460fwf0.js.map → MpegParser-y5fjpaz9.js.map} +1 -1
  26. package/dist/MusepackParser-544q0byg.js +5 -0
  27. package/dist/{MusepackParser-8mq2eabg.js.map → MusepackParser-544q0byg.js.map} +2 -2
  28. package/dist/OggParser-v77rbjnt.js +5 -0
  29. package/dist/{OggParser-7dnc6apg.js.map → OggParser-v77rbjnt.js.map} +1 -1
  30. package/dist/Picker-32m79nmp.js +5 -0
  31. package/dist/{Picker-j7txnm7w.js.map → Picker-32m79nmp.js.map} +1 -1
  32. package/dist/SessionPicker-9p06npt5.js +5 -0
  33. package/dist/{SessionPicker-hpv2ncsb.js.map → SessionPicker-9p06npt5.js.map} +1 -1
  34. package/dist/SkillBrowser-ezdx3xsh.js +5 -0
  35. package/dist/{SkillBrowser-qc542n71.js.map → SkillBrowser-ezdx3xsh.js.map} +1 -1
  36. package/dist/WavPackParser-k623m0hk.js +5 -0
  37. package/dist/{WavPackParser-kt7cds9c.js.map → WavPackParser-k623m0hk.js.map} +1 -1
  38. package/dist/WaveParser-nj4p1vx8.js +5 -0
  39. package/dist/{WaveParser-g47ja0vy.js.map → WaveParser-nj4p1vx8.js.map} +1 -1
  40. package/dist/WizardApp-p350qspw.js +5 -0
  41. package/dist/{WizardApp-q4p979d1.js.map → WizardApp-p350qspw.js.map} +1 -1
  42. package/dist/channels-a9zx9yba.js +31 -0
  43. package/dist/{channels-4t89qpdt.js.map → channels-a9zx9yba.js.map} +1 -1
  44. package/dist/client.d.ts +43 -0
  45. package/dist/client.js +9 -9
  46. package/dist/client.js.map +5 -5
  47. package/dist/components/App.d.ts.map +1 -1
  48. package/dist/config-3mz4zwsf.js +24 -0
  49. package/dist/{config-35r6n1gh.js.map → config-3mz4zwsf.js.map} +2 -2
  50. package/dist/credential-ja7zmd4c.js +19 -0
  51. package/dist/{credential-dpdgg4j6.js.map → credential-ja7zmd4c.js.map} +1 -1
  52. package/dist/index-039ew35r.js +6 -0
  53. package/dist/index-039ew35r.js.map +10 -0
  54. package/dist/index-0dvs3a06.js +6 -0
  55. package/dist/{index-jc4kmfwa.js.map → index-0dvs3a06.js.map} +1 -1
  56. package/dist/{index-pszmnhgq.js → index-1cagdzqe.js} +9 -9
  57. package/dist/{index-pszmnhgq.js.map → index-1cagdzqe.js.map} +1 -1
  58. package/dist/index-2fw9e5gg.js +6 -0
  59. package/dist/{index-0444sh6x.js.map → index-2fw9e5gg.js.map} +1 -1
  60. package/dist/{index-a2eh8dnk.js → index-2td5h856.js} +12 -12
  61. package/dist/{index-a2eh8dnk.js.map → index-2td5h856.js.map} +1 -1
  62. package/dist/{index-m6fqx0ch.js → index-446exxcb.js} +7 -7
  63. package/dist/{index-m6fqx0ch.js.map → index-446exxcb.js.map} +1 -1
  64. package/dist/{index-snz49ndn.js → index-4fajxhdv.js} +4 -4
  65. package/dist/{index-snz49ndn.js.map → index-4fajxhdv.js.map} +1 -1
  66. package/dist/index-4j65jp20.js +9 -0
  67. package/dist/{index-38gs9anh.js.map → index-4j65jp20.js.map} +1 -1
  68. package/dist/index-5gn74n56.js +10 -0
  69. package/dist/{index-ew997be5.js.map → index-5gn74n56.js.map} +2 -2
  70. package/dist/index-5zpfz4kb.js +9 -0
  71. package/dist/{index-8h6kewy1.js.map → index-5zpfz4kb.js.map} +1 -1
  72. package/dist/index-60h4knj6.js +126 -0
  73. package/dist/{index-zce9gy22.js.map → index-60h4knj6.js.map} +2 -2
  74. package/dist/index-635wcsh1.js +5 -0
  75. package/dist/{index-2bsardvh.js.map → index-635wcsh1.js.map} +1 -1
  76. package/dist/index-67sfck4d.js +110 -0
  77. package/dist/index-67sfck4d.js.map +13 -0
  78. package/dist/index-7p8d1gf0.js +63 -0
  79. package/dist/{index-ytxbw8py.js.map → index-7p8d1gf0.js.map} +1 -1
  80. package/dist/index-7zgjkbb0.js +5 -0
  81. package/dist/{index-qgsdgbk8.js.map → index-7zgjkbb0.js.map} +1 -1
  82. package/dist/{index-zw6wyas6.js → index-86rb86nr.js} +4 -4
  83. package/dist/{index-zw6wyas6.js.map → index-86rb86nr.js.map} +1 -1
  84. package/dist/{index-fbsrhcga.js → index-8jejze0z.js} +4 -4
  85. package/dist/{index-fbsrhcga.js.map → index-8jejze0z.js.map} +1 -1
  86. package/dist/index-8k8y7edx.js +7 -0
  87. package/dist/{index-3826kf9t.js.map → index-8k8y7edx.js.map} +1 -1
  88. package/dist/index-8mkatm20.js +6 -0
  89. package/dist/{index-42e29zs4.js.map → index-8mkatm20.js.map} +1 -1
  90. package/dist/{index-3vzf253k.js → index-9k6qa50r.js} +7 -7
  91. package/dist/{index-3vzf253k.js.map → index-9k6qa50r.js.map} +1 -1
  92. package/dist/{index-yw3fby4n.js → index-a1axc952.js} +4 -4
  93. package/dist/{index-yw3fby4n.js.map → index-a1axc952.js.map} +1 -1
  94. package/dist/index-ayhdn87b.js +6 -0
  95. package/dist/{index-dzy19wtf.js.map → index-ayhdn87b.js.map} +1 -1
  96. package/dist/index-b8bfzbfe.js +6 -0
  97. package/dist/{index-7mn8ack9.js.map → index-b8bfzbfe.js.map} +2 -2
  98. package/dist/index-brh25jhq.js +6 -0
  99. package/dist/{index-fa9wvpyw.js.map → index-brh25jhq.js.map} +2 -2
  100. package/dist/index-c6qrcweh.js +6 -0
  101. package/dist/{index-nxhqf597.js.map → index-c6qrcweh.js.map} +1 -1
  102. package/dist/index-cb45233h.js +6 -0
  103. package/dist/{index-nvc24414.js.map → index-cb45233h.js.map} +1 -1
  104. package/dist/{index-51x0n5z0.js → index-dcy14zdn.js} +5 -5
  105. package/dist/{index-51x0n5z0.js.map → index-dcy14zdn.js.map} +1 -1
  106. package/dist/index-f6r3h2yh.js +8 -0
  107. package/dist/{index-twn9bfm2.js.map → index-f6r3h2yh.js.map} +1 -1
  108. package/dist/index-gezqawvw.js +11 -0
  109. package/dist/{index-fcsg95m5.js.map → index-gezqawvw.js.map} +1 -1
  110. package/dist/index-h787rq0h.js +12 -0
  111. package/dist/{index-wc4entme.js.map → index-h787rq0h.js.map} +3 -3
  112. package/dist/index-hd5nkwd7.js +74 -0
  113. package/dist/index-hd5nkwd7.js.map +13 -0
  114. package/dist/index-k6wq0j4q.js +6 -0
  115. package/dist/{index-gq1npngp.js.map → index-k6wq0j4q.js.map} +1 -1
  116. package/dist/index-kz01jz58.js +6 -0
  117. package/dist/{index-323jvr1g.js.map → index-kz01jz58.js.map} +1 -1
  118. package/dist/{index-kjqksgch.js → index-mgef1n4e.js} +10 -10
  119. package/dist/{index-kjqksgch.js.map → index-mgef1n4e.js.map} +1 -1
  120. package/dist/{index-haypwvzd.js → index-n197qdw1.js} +188 -188
  121. package/dist/{index-haypwvzd.js.map → index-n197qdw1.js.map} +3 -3
  122. package/dist/index-nndwx2wp.js +153 -0
  123. package/dist/{index-z157at3s.js.map → index-nndwx2wp.js.map} +2 -2
  124. package/dist/index-pz92ksp8.js +5 -0
  125. package/dist/{index-3c5jt6by.js.map → index-pz92ksp8.js.map} +1 -1
  126. package/dist/index-qj4adnfe.js +14 -0
  127. package/dist/{index-eqqd4k4f.js.map → index-qj4adnfe.js.map} +2 -2
  128. package/dist/index-r83jpct7.js +6 -0
  129. package/dist/{index-gbkma7ds.js.map → index-r83jpct7.js.map} +2 -2
  130. package/dist/{index-2zjh5zd5.js → index-rqfwd7j5.js} +4 -4
  131. package/dist/{index-2zjh5zd5.js.map → index-rqfwd7j5.js.map} +1 -1
  132. package/dist/index-s0f0s6n5.js +6 -0
  133. package/dist/{index-p1zy871m.js.map → index-s0f0s6n5.js.map} +1 -1
  134. package/dist/index-s0t15ndj.js +6 -0
  135. package/dist/{index-8edck2pr.js.map → index-s0t15ndj.js.map} +1 -1
  136. package/dist/index-tc054tcb.js +6 -0
  137. package/dist/{index-8tmv33mr.js.map → index-tc054tcb.js.map} +1 -1
  138. package/dist/{index-095hrkyr.js → index-ts8a1sdn.js} +6 -6
  139. package/dist/{index-095hrkyr.js.map → index-ts8a1sdn.js.map} +1 -1
  140. package/dist/index-tv52jhac.js +1252 -0
  141. package/dist/{index-qg9bn980.js.map → index-tv52jhac.js.map} +15 -14
  142. package/dist/index-x9nn57kk.js +6 -0
  143. package/dist/{index-1x8mzvz7.js.map → index-x9nn57kk.js.map} +1 -1
  144. package/dist/{index-ynsvkqgb.js → index-xyh98x7p.js} +4 -4
  145. package/dist/{index-ynsvkqgb.js.map → index-xyh98x7p.js.map} +1 -1
  146. package/dist/{index-ma6p7bt4.js → index-yy4v9kca.js} +4 -4
  147. package/dist/{index-ma6p7bt4.js.map → index-yy4v9kca.js.map} +1 -1
  148. package/dist/{index-bqdkm3de.js → index-yz0fcxky.js} +4 -4
  149. package/dist/{index-bqdkm3de.js.map → index-yz0fcxky.js.map} +1 -1
  150. package/dist/{index-p6ya59m6.js → index-z4adxmzm.js} +5 -5
  151. package/dist/{index-p6ya59m6.js.map → index-z4adxmzm.js.map} +1 -1
  152. package/dist/{index-4fj1k64j.js → index-zzpgsbn3.js} +4 -4
  153. package/dist/{index-4fj1k64j.js.map → index-zzpgsbn3.js.map} +1 -1
  154. package/dist/index.js +343 -343
  155. package/dist/index.js.map +7 -7
  156. package/dist/lib/source.d.ts +8 -0
  157. package/dist/lib/source.d.ts.map +1 -1
  158. package/dist/lib/types.d.ts +8 -2
  159. package/dist/lib/types.d.ts.map +1 -1
  160. package/dist/run.d.ts.map +1 -1
  161. package/dist/transcript.d.ts.map +1 -1
  162. package/dist/web-7mdrcb8a.js +14 -0
  163. package/dist/{web-zph4h3p9.js.map → web-7mdrcb8a.js.map} +1 -1
  164. package/dist/wire.d.ts +19 -0
  165. package/dist/wire.js +5 -5
  166. package/dist/wire.js.map +4 -4
  167. package/dist/wrapper-4hdmdwft.js +5 -0
  168. package/dist/{wrapper-f662ny3r.js.map → wrapper-4hdmdwft.js.map} +1 -1
  169. package/package.json +1 -1
  170. package/dist/APEv2Parser-etzjd528.js +0 -5
  171. package/dist/App-4w3qkcs4.js +0 -11
  172. package/dist/AsfParser-wd98k2h4.js +0 -5
  173. package/dist/ConfigEditor-vk7vxaa6.js +0 -6
  174. package/dist/DsdiffParser-cbfaj500.js +0 -5
  175. package/dist/FlacParser-7t7da7qy.js +0 -5
  176. package/dist/MP4Parser-gc94h1n9.js +0 -5
  177. package/dist/MusepackParser-8mq2eabg.js +0 -5
  178. package/dist/OggParser-7dnc6apg.js +0 -5
  179. package/dist/Picker-j7txnm7w.js +0 -5
  180. package/dist/SessionPicker-hpv2ncsb.js +0 -5
  181. package/dist/SkillBrowser-qc542n71.js +0 -5
  182. package/dist/WavPackParser-kt7cds9c.js +0 -5
  183. package/dist/WaveParser-g47ja0vy.js +0 -5
  184. package/dist/WizardApp-q4p979d1.js +0 -5
  185. package/dist/channels-4t89qpdt.js +0 -31
  186. package/dist/config-35r6n1gh.js +0 -24
  187. package/dist/credential-dpdgg4j6.js +0 -19
  188. package/dist/index-0444sh6x.js +0 -6
  189. package/dist/index-1x8mzvz7.js +0 -6
  190. package/dist/index-2bsardvh.js +0 -5
  191. package/dist/index-323jvr1g.js +0 -6
  192. package/dist/index-3826kf9t.js +0 -7
  193. package/dist/index-38gs9anh.js +0 -9
  194. package/dist/index-3c5jt6by.js +0 -5
  195. package/dist/index-42e29zs4.js +0 -6
  196. package/dist/index-664xcamy.js +0 -110
  197. package/dist/index-664xcamy.js.map +0 -13
  198. package/dist/index-7mn8ack9.js +0 -6
  199. package/dist/index-8edck2pr.js +0 -6
  200. package/dist/index-8h6kewy1.js +0 -9
  201. package/dist/index-8tmv33mr.js +0 -6
  202. package/dist/index-9914wh1d.js +0 -6
  203. package/dist/index-9914wh1d.js.map +0 -10
  204. package/dist/index-dzy19wtf.js +0 -6
  205. package/dist/index-eqqd4k4f.js +0 -14
  206. package/dist/index-ew997be5.js +0 -10
  207. package/dist/index-fa9wvpyw.js +0 -6
  208. package/dist/index-fcsg95m5.js +0 -11
  209. package/dist/index-gbkma7ds.js +0 -6
  210. package/dist/index-gq1npngp.js +0 -6
  211. package/dist/index-jc4kmfwa.js +0 -6
  212. package/dist/index-nvc24414.js +0 -6
  213. package/dist/index-nxhqf597.js +0 -6
  214. package/dist/index-p1zy871m.js +0 -6
  215. package/dist/index-qg9bn980.js +0 -1213
  216. package/dist/index-qgsdgbk8.js +0 -5
  217. package/dist/index-r4ax3x4d.js +0 -74
  218. package/dist/index-r4ax3x4d.js.map +0 -13
  219. package/dist/index-twn9bfm2.js +0 -8
  220. package/dist/index-wc4entme.js +0 -12
  221. package/dist/index-ytxbw8py.js +0 -63
  222. package/dist/index-z157at3s.js +0 -153
  223. package/dist/index-zce9gy22.js +0 -126
  224. package/dist/web-zph4h3p9.js +0 -14
  225. package/dist/wrapper-f662ny3r.js +0 -5
@@ -8,6 +8,6 @@
8
8
  "/**\n * The init wizard as a pure reducer — a log of answers over `nextQuestion`'s forward-only flow.\n *\n * `nextQuestion` cannot go backwards, so back-navigation is an *answer log*: esc pops the tail\n * and the next question is recomputed from what remains. Popping the tail is always consistent\n * because the log is a prefix of the asking order — re-answering the preset re-derives every\n * downstream default for free. Flag-given answers live in `given` and are never poppable: they\n * were explicit, and backing over them would silently discard something the person typed into a\n * shell.\n *\n * Renderer-free and process-free (PURE-listed): `WizardApp` is one consumer; a test driving the\n * reducer with the same intents is another, and the two cannot diverge.\n */\n\nimport { applyIntent, EMPTY_EDITOR } from \"#editor\"\nimport type { ListIntent } from \"#keymap\"\nimport {\n dirFor,\n type InitStep,\n nextQuestion,\n type PartialAnswers,\n PRESETS,\n presetById,\n type Question,\n type QuestionDefaults,\n SECRET_STEPS,\n validateAnswer,\n} from \"#lib/init-flow\"\nimport { moveSelect, type SelectState } from \"#lib/select\"\nimport type { EditorState, Intent } from \"#lib/types\"\n\nexport type WizardPhase = \"asking\" | \"confirm\" | \"done\" | \"aborted\"\n\nexport interface WizardState {\n /** Flag answers — explicit, never poppable. */\n readonly given: PartialAnswers\n /** What the wizard collected, in asking order. Esc pops the tail. */\n readonly log: readonly { readonly step: InitStep; readonly value: string }[]\n readonly phase: WizardPhase\n /** The current text answer. Reuses the chat editor's state machine wholesale. */\n readonly editor: EditorState\n /** The current select answer (preset step, and the confirm screen's yes/no). */\n readonly select: SelectState\n /** Last validation failure; cleared on the next edit. */\n readonly error: string | undefined\n readonly defaults: QuestionDefaults\n}\n\nexport function startWizard(given: PartialAnswers, defaults: QuestionDefaults): WizardState {\n const state: WizardState = {\n given,\n log: [],\n phase: \"asking\",\n editor: EMPTY_EDITOR,\n select: { index: 0, count: PRESETS.length },\n error: undefined,\n defaults,\n }\n // Flags may already answer everything (`init --user … --name … --preset …` at a TTY): the\n // wizard then opens directly on the confirm screen rather than asking zero questions oddly.\n return currentQuestion(state) === undefined ? enterConfirm(state) : state\n}\n\nexport function partialOf(state: WizardState): PartialAnswers {\n const fromLog = Object.fromEntries(state.log.map((entry) => [entry.step, entry.value]))\n // `given` wins, though overlap cannot occur: nextQuestion never asks an answered step, so the\n // log never contains one.\n return { ...fromLog, ...state.given }\n}\n\nexport function currentQuestion(state: WizardState): Question | undefined {\n return nextQuestion(partialOf(state), state.defaults)\n}\n\n/**\n * Is the current question a fixed set of choices rather than a text field?\n *\n * Read off the question's own `options` rather than compared against a step name. The preset menu was\n * the only select for three phases and \"is this the preset step\" ended up written into the reducer,\n * the renderer and the cursor prefill — so adding a second one had to either repeat all three or\n * generalise them. Generalising is what stops a third repeating them again.\n */\nexport function isSelectStep(state: WizardState): boolean {\n return state.phase === \"asking\" && currentQuestion(state)?.options !== undefined\n}\n\n/** The choices on screen, empty when the question is a text field. */\nexport function selectOptions(state: WizardState): readonly {\n readonly value: string\n readonly label: string\n readonly hint?: string\n}[] {\n return currentQuestion(state)?.options ?? []\n}\n\n/** Whether the question on screen is one whose answer must never be rendered. */\nexport function isSecretStep(state: WizardState): boolean {\n const step = currentQuestion(state)?.step\n return state.phase === \"asking\" && step !== undefined && SECRET_STEPS.has(step)\n}\n\n/**\n * Honest step numbering: walk the flow the same way it will actually be asked, so a keyless\n * preset shrinks the total rather than leaving a count that quietly stops being true.\n */\nexport function stepCounts(state: WizardState): { readonly asked: number; readonly total: number } {\n const walk: Record<string, string> = { ...partialOf(state) }\n let remaining = 0\n for (;;) {\n const question = nextQuestion(walk, state.defaults)\n if (question === undefined) break\n remaining += 1\n walk[question.step] = question.fallback === \"\" ? \"(x)\" : question.fallback\n }\n const asked = state.log.length + Object.keys(state.given).length\n return { asked: asked + (state.phase === \"asking\" ? 1 : 0), total: asked + remaining }\n}\n\nexport type WizardAction =\n | { readonly kind: \"edit\"; readonly intent: Intent }\n | { readonly kind: \"list\"; readonly intent: ListIntent }\n | { readonly kind: \"commit\" }\n | { readonly kind: \"back\" }\n | { readonly kind: \"abort\" }\n\nconst CONFIRM_COUNT = 2 // yes / no\n\nfunction enterConfirm(state: WizardState): WizardState {\n return {\n ...state,\n phase: \"confirm\",\n editor: EMPTY_EDITOR,\n select: { index: 0, count: CONFIRM_COUNT },\n error: undefined,\n }\n}\n\nfunction freshFor(state: WizardState): Pick<WizardState, \"editor\" | \"select\" | \"error\"> {\n const question = nextQuestion(partialOf(state), state.defaults)\n const options = question?.options\n return {\n editor: EMPTY_EDITOR,\n select: {\n index: cursorFor(question),\n count: options === undefined ? PRESETS.length : options.length,\n },\n error: undefined,\n }\n}\n\n/** Prefill the cursor from the question's own fallback (\"1\" → 0). */\nfunction cursorFor(question: Question | undefined): number {\n const options = question?.options\n if (options === undefined) return 0\n const index = Number(question?.fallback) - 1\n return Number.isInteger(index) && index >= 0 && index < options.length ? index : 0\n}\n\nexport function reduceWizard(state: WizardState, action: WizardAction): WizardState {\n if (state.phase === \"done\" || state.phase === \"aborted\") return state\n\n switch (action.kind) {\n case \"abort\":\n return { ...state, phase: \"aborted\" }\n\n case \"edit\":\n if (state.phase !== \"asking\") return state\n return { ...state, editor: applyIntent(state.editor, action.intent), error: undefined }\n\n case \"list\": {\n const intent = action.intent\n if (intent.kind === \"move\") {\n return { ...state, select: moveSelect(state.select, intent.move), error: undefined }\n }\n if (intent.kind === \"choose\") return reduceWizard(state, { kind: \"commit\" })\n if (intent.kind === \"back\") return reduceWizard(state, { kind: \"back\" })\n if (intent.kind === \"exit\") return { ...state, phase: \"aborted\" }\n return state\n }\n\n case \"back\": {\n if (state.phase === \"confirm\") {\n // Back to the last asked question, its previous answer discarded so it re-asks\n // with the same defaults it had the first time.\n if (state.log.length === 0) return { ...state, phase: \"asking\", ...freshFor(state) }\n const log = state.log.slice(0, -1)\n const reopened = { ...state, phase: \"asking\" as const, log }\n return { ...reopened, ...freshFor(reopened) }\n }\n if (state.log.length === 0) return state // nothing wizard-asked to go back to\n const log = state.log.slice(0, -1)\n const popped = { ...state, log }\n return { ...popped, ...freshFor(popped) }\n }\n\n case \"commit\": {\n if (state.phase === \"confirm\") {\n // Index 0 is yes — the summary screen's select. \"no\" backs into the last question.\n return state.select.index === 0\n ? { ...state, phase: \"done\" }\n : reduceWizard(state, { kind: \"back\" })\n }\n\n const question = currentQuestion(state)\n if (question === undefined) return enterConfirm(state)\n\n const raw =\n question.options !== undefined\n ? (question.options[state.select.index]?.value ?? \"\")\n : state.editor.value.trim() === \"\"\n ? question.fallback\n : state.editor.value\n\n const checked = validateAnswer(question.step, raw)\n if (!checked.ok) {\n return { ...state, error: checked.reason }\n }\n\n const advanced: WizardState = {\n ...state,\n log: [...state.log, { step: question.step, value: checked.value }],\n }\n const next = { ...advanced, ...freshFor(advanced) }\n return currentQuestion(next) === undefined ? enterConfirm(next) : next\n }\n }\n}\n\n/**\n * What a secret looks like on screen.\n *\n * Enough to recognise a paste went in, never enough to reconstruct. Short values show nothing at\n * all rather than most of themselves.\n */\nexport function maskSecret(value: string): string {\n if (value === \"\") return \"\"\n if (value.length <= 8) return \"•\".repeat(value.length)\n return `${value.slice(0, 3)}${\"•\".repeat(6)}${value.slice(-2)}`\n}\n\n/** The confirm screen's rows, shared with the plain path's wording. */\nexport function summaryRows(\n state: WizardState,\n): readonly { readonly label: string; readonly value: string }[] {\n const partial = partialOf(state)\n const preset = partial.preset === undefined ? undefined : presetById(partial.preset)\n const endpoint = `${partial.model ?? \"\"} at ${partial.region === undefined ? (partial.baseUrl ?? \"\") : `Bedrock ${partial.region}`}`\n const keyVar = partial.apiKeyEnv ?? preset?.apiKeyEnv\n const key =\n keyVar === undefined\n ? \" (no key)\"\n : ` (${keyVar}=${partial.apiKey === undefined || partial.apiKey === \"\" ? \"not set yet\" : maskSecret(partial.apiKey)})`\n return [\n { label: \"agent\", value: partial.name ?? \"\" },\n { label: \"for\", value: `${partial.user ?? \"\"} — ${partial.purpose ?? \"\"}` },\n { label: \"endpoint\", value: `${endpoint}${key}` },\n // Derived when the answer was `sandbox` or `here`, because the `dir` question is not asked\n // then — and this row is the last thing read before anything is written, so it has to name\n // the directory that will actually exist. `dirFor` is the same function `complete()` calls;\n // a second derivation here is how a confirm screen comes to describe a different path.\n {\n label: \"directory\",\n value: partial.dir ?? dirFor(partial.dirChoice, partial.name, state.defaults) ?? \"\",\n },\n ]\n}\n\n/** The ✓ lines above the current question. */\nexport function answeredRows(\n state: WizardState,\n): readonly { readonly label: string; readonly value: string }[] {\n const labels: Record<InitStep, string> = {\n user: \"Your name\",\n name: \"Agent name\",\n purpose: \"Purpose\",\n preset: \"Endpoint\",\n model: \"Model\",\n baseUrl: \"Base URL\",\n region: \"AWS region\",\n apiKeyEnv: \"Key env var\",\n apiKey: \"API key\",\n web: \"Internet\",\n webBackend: \"Search backend\",\n webKey: \"Search key\",\n system: \"System access\",\n composio: \"Other apps\",\n telegram: \"Telegram\",\n telegramAllow: \"Telegram handle\",\n telegramToken: \"Bot token\",\n whatsapp: \"WhatsApp\",\n whatsappNumber: \"WhatsApp number\",\n schedules: \"none\",\n server: \"HTTP API\",\n // Was literally `\"starter\"` — a value pasted into the label column, so the confirm screen\n // showed \"starter starter\" for the default answer and \"starter none\" for the other one.\n skills: \"Skills\",\n skillsSearch: \"Skill search\",\n skillsPick: \"Skills picked\",\n daemon: \"Background service\",\n serverToken: \"API token\",\n composioKey: \"Composio key\",\n dirChoice: \"Location\",\n dir: \"Directory\",\n }\n return state.log.map((entry) => ({\n label: labels[entry.step],\n // A secret is never echoed back, not even to the person who just typed it: these lines\n // stay on screen for the rest of the wizard and end up in scrollback.\n value: SECRET_STEPS.has(entry.step) ? maskSecret(entry.value) : entry.value,\n }))\n}\n"
9
9
  ],
10
10
  "mappings": ";kzBAUA,cAAS,UAAK,YAAM,eAAQ,aAC5B,sBAAS,gBAAa,gBAAW,eAAY,eCP7C,cAAS,UAAK,8DAOP,SAAS,CAAW,EAAG,QAA0B,CACpD,IAAM,EAAQ,EAAK,OAAO,CAAC,EAAQ,IAAQ,KAAK,IAAI,EAAQ,EAAI,MAAM,MAAM,EAAG,CAAC,EAChF,OACI,EAAC,EAAD,CACI,cAAc,SACd,YAAa,GACb,YAAa,EAAM,OACnB,SAAU,EACV,SAAU,EALd,SAOK,EAAK,IAAI,CAAC,IACP,EAAC,EAAD,UAGE,CAFE,EAAC,EAAD,CAAM,SAAQ,GAAd,SAAgB,EAAI,MAAM,OAAO,EAAQ,CAAC,EAAI,EAC7C,EAAI,QAFE,EAAI,KAGb,CACL,EACH,ECrBV,cAAS,UAAK,8DAaP,SAAS,CAAW,EAAG,OAAM,QAAO,WAAU,OAAM,YAA8B,CAErF,IAAM,EAAQ,KAAK,IAAI,GAAI,GAAG,EAAS,IAAI,CAAC,IAAU,EAAM,MAAM,OAAS,CAAC,CAAC,EAC7E,OACI,EAAC,EAAD,CAAK,cAAc,SAAnB,SAsBE,CArBG,EAAS,IAAI,CAAC,IACX,EAAC,EAAD,UAIE,CAHE,EAAC,EAAD,CAAM,MAAO,EAAM,QAAnB,SAA6B,EAAM,MAAQ,EAC3C,EAAC,EAAD,CAAM,SAAQ,GAAd,SAAgB,EAAM,MAAM,OAAO,CAAK,EAAI,EAC3C,EAAM,QAHA,EAAM,KAIf,CACL,EACD,EAAC,EAAD,CACI,cAAc,SACd,YAAa,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AC,EAAD,CAAK,UAAW,EAAhB,SACI,EAAC,EAAD,CACI,KAAM,EAAO,MACb,MAAO,EAAO,MACd,SAAU,EAAa,CAAK,EAC5B,KAAM,EAJV,SAMK,EAAa,CAAK,EACf,EAAC,EAAD,CAAK,cAAc,SAAnB,SAUE,CATE,EAAC,EAAD,UAAO,EAAgB,CAAK,GAAG,QAAU,GAAK,EAC9C,EAAC,GAAD,CACI,MAAO,EAAc,CAAK,EAAE,IAAI,CAAC,KAAY,CACzC,MAAO,EAAO,SACV,EAAO,OAAS,OAAY,CAAC,EAAI,CAAE,KAAM,EAAO,IAAK,CAC7D,EAAE,EACF,MAAO,EAAM,OAAO,MACpB,SAAQ,GACZ,GACF,EAEF,EAAC,GAAD,CACI,MAAO,EAAgB,CAAK,GAAG,QAAU,GACzC,OAAQ,EAAM,OAMd,QACI,GAAc,EAAK,QAAS,EAAgB,EAAI,GAEpD,QAAS,GACT,YAAa,EAAgB,CAAK,GAAG,UAAY,MAC5C,EAAM,QAAU,OAAY,CAAC,EAAI,CAAE,MAAO,EAAM,KAAM,KACtD,EAAa,CAAK,EAAI,CAAE,OAAQ,EAAK,EAAI,CAAC,EACnD,EAEN,EACJ,EAEL,EAAM,QAAU,SAAc,EAAa,CAAK,GAAK,EAAM,QAAU,WAClE,EAAC,EAAD,CAAM,MAAO,EAAM,MAAnB,SAGE,CAFG,EAAM,MACN,EAAM,OACT,EACF,MACN",
11
- "debugId": "9C127849AE4D264664756E2164756E21",
11
+ "debugId": "715A79343AE1E10A64756E2164756E21",
12
12
  "names": []
13
13
  }
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env node
2
+ import{A,n}from"./index-tv52jhac.js";import"./index-mgef1n4e.js";import"./index-hd5nkwd7.js";import"./index-n197qdw1.js";import"./index-ayhdn87b.js";import{OA,Jn,NA,MA,an,qn,Vn,rr,Wn,zn,Zn}from"./index-nndwx2wp.js";import{oA}from"./index-67sfck4d.js";import{$n}from"./index-ts8a1sdn.js";import"./index-gezqawvw.js";import{De}from"./index-b8bfzbfe.js";import"./index-4j65jp20.js";import{C}from"./index-9k6qa50r.js";import"./index-f6r3h2yh.js";import{o,E}from"./index-tc054tcb.js";import{dirname as p}from"node:path";async function x(e){switch(e.action){case"list":case void 0:return await m(e);case"connect":return await l(e,!0);case"disconnect":return await l(e,!1);case"credential":return await f(e);case"pair":return await g(e);case"unpair":return b(e);default:throw new n({code:"cli_channels_action_unknown",message:`channels: ${JSON.stringify(e.action)} is not an action`,hint:`Actions are list, connect, disconnect, credential and unpair — \`${A.slug} channels list <agent>\`.`})}}async function m(e){let t=rr(e.manifestPath);if(e.json===!0)return process.stdout.write(`${JSON.stringify({channels:t},null,2)}
3
+ `),o;if(t.length===0)return process.stdout.write(`No channels. This agent is reached through the CLI and the HTTP API only.
4
+ Add one with \`${A.slug} config set <agent> channels\`, or answer the channel questions in \`${A.slug} init\`.
5
+ `),o;let i=await an(e.manifestPath),s=t.map((r)=>{let a=i?.get(r.id);return{label:r.id,value:r.type,note:[r.enabled?"enabled":"disabled",...a===void 0?[]:[`now ${a.status}`],r.credentialEnv===void 0?r.type==="whatsapp"?w(r):"no credential in the .env":`${r.credentialEnv} ${r.credentialSet?"set":"NOT SET"}`,r.allowFrom.length===0?r.pairWith===void 0?"allowFrom empty — permits nobody":`allows you (${r.pairWith}) — allowFrom names anyone else`:`allows ${r.allowFrom.join(", ")}${r.pairWith===void 0?"":" and you"}`].join(" · ")}});process.stdout.write(`${C(s)}
6
+ `);for(let[r,a]of i??[]){if(a.input===void 0)continue;if(process.stdout.write(`
7
+ ${r} is waiting to be paired — ${a.detail??"enter this"}:
8
+
9
+ ${a.input.payload}
10
+ `),a.input.expiresAt!==void 0)process.stdout.write(`
11
+ expires ${a.input.expiresAt}
12
+ `)}if(i===void 0)process.stdout.write(`
13
+ Nothing is hosting this agent, so nothing above is a live status — it is what the
14
+ manifest says. Start it with \`${A.slug} serve\` to see what each channel is doing.
15
+ `);return o}function w(e){let t=e.pairWith===void 0?"pairs by QR":`pairs by code to ${e.pairWith}`;return e.paired===!0?`${t}; linked — \`channels unpair\` forgets it`:`${t}; not linked yet`}async function g(e){let t=c(e),i=rr(e.manifestPath).find((d)=>d.id===t);if(i===void 0)throw new n({code:"cli_channel_unknown",message:`No channel "${t}" in ${e.manifestPath}.`,hint:`\`${A.slug} channels list <agent>\` names them.`});if(i.type==="telegram"){let d=await f(e);if(d!==o)return d;let u=await l(e,!0);return process.stdout.write(`${await y(e.manifestPath)}
16
+ `),u}if(i.type!=="whatsapp")throw new n({code:"cli_channel_no_pairing",message:`Channel "${t}" is a ${i.type}, which has no pairing step.`,hint:`Use \`${A.slug} channels connect\` to switch it on, or \`credential\` if it takes a token.`});if(i.pairWith===void 0)throw new n({code:"cli_channel_no_number",message:`Channel "${t}" has no pairWith, so there is no number to pair to.`,hint:"Set pairWith on the channel to the account's own number, digits with the country code. Without it pairing is a QR, which `serve` offers."});if(i.paired===!0)return process.stdout.write(`${t} is already paired to ${i.pairWith}. \`${A.slug} channels unpair\` forgets it first.
17
+ `),o;let s=De(e.manifestPath),{outcome:r,host:a}=await Jn({...e.installServer===void 0?{}:{install:e.installServer}}),h=OA(r);if(h!==void 0)process.stderr.write(h);if(a?.baseUrl!==void 0){let d=await NA(a,e.manifestPath);if(!d.ok)process.stderr.write(`pid ${a.pid} did not adopt ${s}${d.detail===void 0?"":`: ${d.detail}`}
18
+ `);else{let u=await qn({manifestPath:e.manifestPath,channelId:t});if(u==="paired")return process.stdout.write(`${t} is linked to ${i.pairWith}, and pid ${a.pid} is serving it.
19
+ chat: ${oA(a.baseUrl,s)} — or \`${A.slug} run ${s}\`
20
+ `),o;return process.stdout.write(u==="no-code"?`No code arrived from pid ${a.pid} — \`${A.slug} status\` shows what the channel is doing; run this again once it offers one.
21
+ `:`Not paired yet — the host keeps offering codes; run this again.
22
+ `),E}}if(await Vn({manifestPath:e.manifestPath,dir:p(e.manifestPath),number:i.pairWith,channelId:t,...i.authDir===void 0?{}:{authDir:i.authDir}})!=="paired")return E;return process.stdout.write(`Nothing is serving ${s} yet. \`${A.slug} serve ${s}\` runs it here; \`${A.slug} daemon install\` keeps a server running for every agent.
23
+ `),o}async function y(e){let t=await MA(e);switch(t.kind){case"reloaded":return`pid ${t.pid} reloaded it — the change is live.`;case"pending":return`pid ${t.pid} applies it when its ${t.running} running turn(s) finish.`;case"busy":return`pid ${t.pid} has a turn in flight; \`${A.slug} restart ${De(e)}\` once it finishes.`;case"failed":return`pid ${t.pid} did not reload it${t.detail===void 0?"":`: ${t.detail}`} — \`${A.slug} restart ${De(e)}\` to retry.`;case"no-host":return"Nothing is hosting it right now; it takes effect at the next start."}}async function l(e,t){let i=await Wn(e.manifestPath,c(e),t);return process.stdout.write(`${i.note}
24
+ `),o}async function f(e){let t=c(e),i=await $n(`Credential for channel "${t}"`);if(i===void 0||i==="")return process.stdout.write(`Nothing was read, so nothing was written. A secret is never taken from an argument or a pipe —
25
+ run this at a terminal, or put the variable in the .env beside the manifest yourself.
26
+ `),o;let s=zn(e.manifestPath,t,i);return process.stdout.write(`${s.note}
27
+ `),o}function b(e){let t=Zn(e.manifestPath,c(e));return process.stdout.write(`${t.note}
28
+ `),o}function c(e){let t=e.channelId;if(t!==void 0&&t!=="")return t;let i=rr(e.manifestPath),s=i[0];if(i.length===1&&s!==void 0)return s.id;throw new n({code:"cli_channels_needs_id",message:"Which channel?",hint:i.length===0?"This agent declares none. `channels list <agent>` says so too.":`Name one: ${i.map((r)=>r.id).join(", ")}.`,field:"channelId"})}export{x as channelsCommand};
29
+
30
+ //# debugId=B8DAAE99D522868264756E2164756E21
31
+ //# sourceMappingURL=channels-a9zx9yba.js.map
@@ -5,6 +5,6 @@
5
5
  "/**\n * `channels` — what an agent is reachable on, and the four things a person does to one.\n *\n * ## Why a command rather than more `config`\n *\n * Every one of these was possible already and reachable from nowhere obvious. Disconnecting meant\n * `config set <agent> channels '[{…the whole list again…}]'`; changing a token meant knowing that\n * `tokenEnv` names a variable and that `config env` writes it; relinking WhatsApp meant finding a\n * directory and deleting it. That is the standing rule about `init` — a capability reachable only by\n * somebody who already knows the field names is one the surface is hiding — applied to the thing a\n * person touches most after creating an agent.\n *\n * `lib/channel-actions.ts` holds the implementation, because the browser does the same four things\n * through HTTP and two implementations of \"disconnect a channel\" is how two surfaces come to\n * disagree about what it means.\n *\n * ## `status` is a different question from `list`\n *\n * This reads the **manifest**: what is configured, and whether its credential is filled in. Whether\n * a channel is *connected right now* is a fact about a running process, which only a host can\n * answer — `GET /v1/agents/:id` carries it and the `serve` banner prints it. Reporting a manifest\n * flag as a connection is decision 5.17's failure, so the output says which it is showing.\n */\n\nimport { dirname } from \"node:path\"\nimport { BRAND, HarnessError } from \"@dispach/core\"\nimport { announce } from \"#lib/bootstrap\"\nimport {\n type ChannelEntry,\n channelsOf,\n setChannelCredential,\n setChannelEnabled,\n unpairChannel,\n} from \"#lib/channel-actions\"\nimport { askSecret } from \"#lib/confirm\"\nimport { EXIT_FAILURE, EXIT_OK } from \"#lib/const\"\nimport {\n adoptOnHost,\n ensureHost,\n liveChannels,\n reloadOnHost,\n waitForPairing,\n} from \"#lib/host-actions\"\nimport { pairWhatsApp } from \"#lib/init-whatsapp\"\nimport { agentIdFor } from \"#lib/lifecycle\"\nimport { keyValue, type Row } from \"#lib/render\"\nimport type { ChannelsOptions } from \"#lib/schema\"\nimport { webUrl } from \"#lib/web-url\"\n\nexport async function channelsCommand(options: ChannelsOptions): Promise<number> {\n switch (options.action) {\n case \"list\":\n case undefined:\n return await list(options)\n case \"connect\":\n return await flip(options, true)\n case \"disconnect\":\n return await flip(options, false)\n case \"credential\":\n return await credential(options)\n case \"pair\":\n return await pair(options)\n case \"unpair\":\n return unpair(options)\n default:\n throw new HarnessError({\n code: \"cli_channels_action_unknown\",\n message: `channels: ${JSON.stringify(options.action)} is not an action`,\n hint: `Actions are list, connect, disconnect, credential and unpair — \\`${BRAND.slug} channels list <agent>\\`.`,\n })\n }\n}\n\nasync function list(options: ChannelsOptions): Promise<number> {\n const channels = channelsOf(options.manifestPath)\n if (options.json === true) {\n process.stdout.write(`${JSON.stringify({ channels }, null, 2)}\\n`)\n return EXIT_OK\n }\n if (channels.length === 0) {\n process.stdout.write(\n `No channels. This agent is reached through the CLI and the HTTP API only.\\nAdd one with \\`${BRAND.slug} config set <agent> channels\\`, or answer the channel questions in \\`${BRAND.slug} init\\`.\\n`,\n )\n return EXIT_OK\n }\n\n /**\n * **This column never says \"connected\", and that is a correction rather than a wording tweak.**\n *\n * It used to read `channel.enabled ? \"connected\" : \"disconnected\"` — so a WhatsApp channel that\n * had never been paired in its life printed `wa whatsapp connected`, and the footer explaining\n * that this is only the manifest did not undo the word in the table. Reported exactly that way:\n * a number was added, the listing said connected, and nothing anywhere offered a code. A\n * disclaimer under a claim does not cancel the claim.\n *\n * `enabled` and `disabled` are what the file actually says, and the live half now comes from\n * the host below instead of being disclaimed away.\n */\n const live = await liveChannels(options.manifestPath)\n const rows: Row[] = channels.map((channel) => {\n const now = live?.get(channel.id)\n return {\n label: channel.id,\n value: channel.type,\n note: [\n channel.enabled ? \"enabled\" : \"disabled\",\n ...(now === undefined ? [] : [`now ${now.status}`]),\n channel.credentialEnv === undefined\n ? // Said rather than omitted: an absent credential row reads as \"this one needs\n // no setting up\", which for WhatsApp is the opposite of the truth.\n channel.type === \"whatsapp\"\n ? pairingNote(channel)\n : \"no credential in the .env\"\n : `${channel.credentialEnv} ${channel.credentialSet ? \"set\" : \"NOT SET\"}`,\n // The paired account is always admitted, so an empty list no longer means nobody\n // for a channel with a `pairWith` — saying so is what stops the owner editing a\n // field they do not need to.\n channel.allowFrom.length === 0\n ? channel.pairWith === undefined\n ? \"allowFrom empty — permits nobody\"\n : `allows you (${channel.pairWith}) — allowFrom names anyone else`\n : `allows ${channel.allowFrom.join(\", \")}${channel.pairWith === undefined ? \"\" : \" and you\"}`,\n ].join(\" · \"),\n }\n })\n process.stdout.write(`${keyValue(rows)}\\n`)\n\n /**\n * The pending code or QR, from the host that is holding it.\n *\n * This is the half that was missing entirely: `needs_input` reached the `serve` banner and the\n * agent resource and **no command**, so the only way to pair was to watch a log at the moment\n * it scrolled past. A person who ran `channels list` — the command named after the question\n * they had — was told the channel was connected and given nothing to act on.\n */\n for (const [id, state] of live ?? []) {\n if (state.input === undefined) continue\n process.stdout.write(\n `\\n${id} is waiting to be paired — ${state.detail ?? \"enter this\"}:\\n\\n ${state.input.payload}\\n`,\n )\n if (state.input.expiresAt !== undefined)\n process.stdout.write(`\\n expires ${state.input.expiresAt}\\n`)\n }\n\n if (live === undefined)\n // The distinction 5.17 exists for. With no host there is genuinely nothing live to report,\n // and saying so beats printing a status column that is really a config flag.\n process.stdout.write(\n `\\nNothing is hosting this agent, so nothing above is a live status — it is what the\\nmanifest says. Start it with \\`${BRAND.slug} serve\\` to see what each channel is doing.\\n`,\n )\n return EXIT_OK\n}\n\n/** How this WhatsApp entry pairs, and whether it already has. */\nfunction pairingNote(channel: ChannelEntry): string {\n // `pairWith` turns pairing into a code typed into the phone; without it, a QR. The old string\n // said \"paired by QR\" unconditionally — wrong about the method once `pairWith` existed, and\n // wrong about the tense always, since it printed for a channel that had never been paired.\n const how =\n channel.pairWith === undefined ? \"pairs by QR\" : `pairs by code to ${channel.pairWith}`\n return channel.paired === true\n ? `${how}; linked — \\`channels unpair\\` forgets it`\n : `${how}; not linked yet`\n}\n\n/**\n * Connect a channel the way that channel needs.\n *\n * One verb for two mechanisms, because from the person's seat it is one action: \"make this\n * channel work\". WhatsApp pairs by a code typed into the phone; Telegram wants a bot token in the\n * `.env`. Making somebody know which of `credential` and `unpair`-then-`serve` applies is\n * remembering the implementation, and `channels pair <agent> wa` was the first thing typed when\n * the code did not appear — it answered *\"No agent named \\\"pair\\\"\"*, because `pair` was not an\n * action and so was read as the agent.\n *\n * WhatsApp has two cases. If a host is already serving this agent, the code it is offering is\n * shown and the command waits for the phone. If nothing is running, this pairs on its own — the\n * same interlude `init` uses — and the result is on disk for the next `serve`.\n */\nasync function pair(options: ChannelsOptions): Promise<number> {\n const channelId = channelIdOf(options)\n const channel = channelsOf(options.manifestPath).find((entry) => entry.id === channelId)\n if (channel === undefined)\n throw new HarnessError({\n code: \"cli_channel_unknown\",\n message: `No channel \"${channelId}\" in ${options.manifestPath}.`,\n hint: `\\`${BRAND.slug} channels list <agent>\\` names them.`,\n })\n\n if (channel.type === \"telegram\") {\n // A token is the pairing. Prompted and not echoed, then switched on — and the host holding\n // the agent reloads it, or the manifest says \"connected\" while the process runs the old one.\n const code = await credential(options)\n if (code !== EXIT_OK) return code\n const flipped = await flip(options, true)\n process.stdout.write(`${await reloadNote(options.manifestPath)}\\n`)\n return flipped\n }\n\n if (channel.type !== \"whatsapp\")\n throw new HarnessError({\n code: \"cli_channel_no_pairing\",\n message: `Channel \"${channelId}\" is a ${channel.type}, which has no pairing step.`,\n hint: `Use \\`${BRAND.slug} channels connect\\` to switch it on, or \\`credential\\` if it takes a token.`,\n })\n\n if (channel.pairWith === undefined)\n throw new HarnessError({\n code: \"cli_channel_no_number\",\n message: `Channel \"${channelId}\" has no pairWith, so there is no number to pair to.`,\n hint: \"Set pairWith on the channel to the account's own number, digits with the country code. Without it pairing is a QR, which `serve` offers.\",\n })\n\n if (channel.paired === true) {\n process.stdout.write(\n `${channelId} is already paired to ${channel.pairWith}. \\`${BRAND.slug} channels unpair\\` forgets it first.\\n`,\n )\n return EXIT_OK\n }\n\n /**\n * A host does the pairing when one can exist. It holds the socket, so when the phone accepts\n * the session is already in the process that will answer — nothing to reload, nothing to start.\n * The bootstrap puts one up first if none is; a container, CI or a caller with no installer\n * gets `undefined` here and the standalone path below, which pairs in this process and names\n * what to run next.\n */\n const agentId = agentIdFor(options.manifestPath)\n const { outcome, host } = await ensureHost({\n ...(options.installServer === undefined ? {} : { install: options.installServer }),\n })\n const note = announce(outcome)\n if (note !== undefined) process.stderr.write(note)\n if (host?.baseUrl !== undefined) {\n const adopted = await adoptOnHost(host, options.manifestPath)\n if (!adopted.ok) {\n process.stderr.write(\n `pid ${host.pid} did not adopt ${agentId}${adopted.detail === undefined ? \"\" : `: ${adopted.detail}`}\\n`,\n )\n } else {\n const result = await waitForPairing({ manifestPath: options.manifestPath, channelId })\n if (result === \"paired\") {\n process.stdout.write(\n `${channelId} is linked to ${channel.pairWith}, and pid ${host.pid} is serving it.\\n chat: ${webUrl(host.baseUrl, agentId)} — or \\`${BRAND.slug} run ${agentId}\\`\\n`,\n )\n return EXIT_OK\n }\n process.stdout.write(\n result === \"no-code\"\n ? `No code arrived from pid ${host.pid} — \\`${BRAND.slug} status\\` shows what the channel is doing; run this again once it offers one.\\n`\n : `Not paired yet — the host keeps offering codes; run this again.\\n`,\n )\n return EXIT_FAILURE\n }\n }\n\n const paired = await pairWhatsApp({\n manifestPath: options.manifestPath,\n dir: dirname(options.manifestPath),\n number: channel.pairWith,\n channelId,\n ...(channel.authDir === undefined ? {} : { authDir: channel.authDir }),\n })\n if (paired !== \"paired\") return EXIT_FAILURE\n // On disk and read by nothing yet. Said here, because a pairing that lands in a session file\n // and a process that never opens it is the exact dead end this verb exists to close.\n process.stdout.write(\n `Nothing is serving ${agentId} yet. \\`${BRAND.slug} serve ${agentId}\\` runs it here; \\`${BRAND.slug} daemon install\\` keeps a server running for every agent.\\n`,\n )\n return EXIT_OK\n}\n\n/** One line on whether the host holding this agent picked the change up. */\nasync function reloadNote(manifestPath: string): Promise<string> {\n const reloaded = await reloadOnHost(manifestPath)\n switch (reloaded.kind) {\n case \"reloaded\":\n return `pid ${reloaded.pid} reloaded it — the change is live.`\n case \"pending\":\n return `pid ${reloaded.pid} applies it when its ${reloaded.running} running turn(s) finish.`\n case \"busy\":\n return `pid ${reloaded.pid} has a turn in flight; \\`${BRAND.slug} restart ${agentIdFor(manifestPath)}\\` once it finishes.`\n case \"failed\":\n return `pid ${reloaded.pid} did not reload it${reloaded.detail === undefined ? \"\" : `: ${reloaded.detail}`} — \\`${BRAND.slug} restart ${agentIdFor(manifestPath)}\\` to retry.`\n case \"no-host\":\n return `Nothing is hosting it right now; it takes effect at the next start.`\n }\n}\n\nasync function flip(options: ChannelsOptions, enabled: boolean): Promise<number> {\n const result = await setChannelEnabled(options.manifestPath, channelIdOf(options), enabled)\n process.stdout.write(`${result.note}\\n`)\n return EXIT_OK\n}\n\nasync function credential(options: ChannelsOptions): Promise<number> {\n const channelId = channelIdOf(options)\n // **Prompted, never taken from an argument.** An argument lands in shell history *and* in `ps`,\n // readable by every local process for the call's lifetime — the same rule `config env` follows\n // and the reason `renderPlist` throws rather than writing one into a service definition.\n const value = await askSecret(`Credential for channel \"${channelId}\"`)\n // `undefined` covers both \"not a terminal\" and \"cancelled\", and both mean the same thing here:\n // nothing was read, so nothing is written. CI is told rather than having a secret arrive\n // unaudited from a pipe.\n if (value === undefined || value === \"\") {\n process.stdout.write(\n \"Nothing was read, so nothing was written. A secret is never taken from an argument or a pipe —\\nrun this at a terminal, or put the variable in the .env beside the manifest yourself.\\n\",\n )\n return EXIT_OK\n }\n const result = setChannelCredential(options.manifestPath, channelId, value)\n process.stdout.write(`${result.note}\\n`)\n return EXIT_OK\n}\n\n/**\n * Forget a stored pairing.\n *\n * Done on disk rather than through the transport, because the useful moment is usually with the\n * agent **not** running — `ChannelHub.reset` is the live path and the HTTP route uses it. Both end\n * in the same state, which is the state a first start produces.\n */\nfunction unpair(options: ChannelsOptions): number {\n const result = unpairChannel(options.manifestPath, channelIdOf(options))\n process.stdout.write(`${result.note}\\n`)\n return EXIT_OK\n}\n\nfunction channelIdOf(options: ChannelsOptions): string {\n const given = options.channelId\n if (given !== undefined && given !== \"\") return given\n const declared = channelsOf(options.manifestPath)\n // One channel is unambiguous, and making somebody name it would be ceremony. Two is a choice\n // nothing here can make for them.\n const only = declared[0]\n if (declared.length === 1 && only !== undefined) return only.id\n throw new HarnessError({\n code: \"cli_channels_needs_id\",\n message: \"Which channel?\",\n hint:\n declared.length === 0\n ? \"This agent declares none. `channels list <agent>` says so too.\"\n : `Name one: ${declared.map((channel) => channel.id).join(\", \")}.`,\n field: \"channelId\",\n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Y,EAG1C,EAAO,EAAS,GACtB,GAAI,EAAS,SAAW,GAAK,IAAS,OAAW,OAAO,EAAK,GAC7D,MAAM,IAAI,EAAa,CACnB,KAAM,wBACN,QAAS,iBACT,KACI,EAAS,SAAW,EACd,iEACA,aAAa,EAAS,IAAI,CAAC,IAAY,EAAQ,EAAE,EAAE,KAAK,IAAI,KACtE,MAAO,WACX,CAAC",
8
- "debugId": "AF8E4DA29F29449864756E2164756E21",
8
+ "debugId": "B8DAAE99D522868264756E2164756E21",
9
9
  "names": []
10
10
  }
package/dist/client.d.ts CHANGED
@@ -375,6 +375,10 @@ export interface EventDataMap {
375
375
  name?: string;
376
376
  /** The parent's tool call this delegation answers. */
377
377
  callId?: string;
378
+ /** A `delegate` task's position in its call, from 0. Absent for a routed call or a handoff. */
379
+ index?: number;
380
+ /** The label the model gave a `delegate` task. */
381
+ label?: string;
378
382
  };
379
383
  /**
380
384
  * How it ended. `outcome` rather than a boolean, and that is the same reasoning
@@ -391,6 +395,8 @@ export interface EventDataMap {
391
395
  kind: "member" | "self";
392
396
  name?: string;
393
397
  callId?: string;
398
+ index?: number;
399
+ label?: string;
394
400
  outcome: "ok" | "no_artifact" | "budget" | "error";
395
401
  steps: number;
396
402
  tokens: {
@@ -500,6 +506,18 @@ export interface EventDataMap {
500
506
  count: number;
501
507
  warning?: string;
502
508
  };
509
+ /**
510
+ * A session's checkpoint was written (decision 15.21): by `POST …/sessions/:key/compact`, or after a
511
+ * turn whose `reset` fired. `before` and `after` are the estimated tokens a turn would start from.
512
+ * Its own type rather than a `compaction.stage` member, so a client's switch over that union keeps
513
+ * compiling.
514
+ */
515
+ "session.compacted": {
516
+ before: number;
517
+ after: number;
518
+ digest: "model" | "mechanical";
519
+ keptTurns: number;
520
+ };
503
521
  /**
504
522
  * The session moved to another phase, and the visible catalogue changed with it.
505
523
  *
@@ -1391,6 +1409,20 @@ export interface AgentClient {
1391
1409
  readonly sessionKey: string;
1392
1410
  readonly recall: boolean;
1393
1411
  }>;
1412
+ /**
1413
+ * The conversation a message naming `sessionKey` would run in, without sending one. Under
1414
+ * `sessions.scope: owner` a caller's own key runs in `owner:<P>`; follow a turn's events by the
1415
+ * key this returns, not the one sent.
1416
+ */
1417
+ resolveSessionKey(sessionKey: string): Promise<string>;
1418
+ /**
1419
+ * Fold everything before the last `keepTurns` turns (default 2) into a saved digest, so the next
1420
+ * turn starts from it (decision 15.21). Every message stays stored. `409 session_too_short` when
1421
+ * nothing is older than the kept turns.
1422
+ */
1423
+ compactSession(sessionKey: string, options?: {
1424
+ readonly keepTurns?: number;
1425
+ }): Promise<CompactedSession>;
1394
1426
  /**
1395
1427
  * Start the caller's conversation afresh on every surface, for an agent whose `sessionScope` is
1396
1428
  * `owner` or `peer` (`docs/23-SPEC-SESSIONS.md`). `409 session_not_rotatable` for `channel-peer`,
@@ -1850,6 +1882,17 @@ export interface SessionSummary {
1850
1882
  * rotation left behind. True for every key under `channel-peer`. Absent from a server before 0.3.
1851
1883
  */
1852
1884
  readonly head?: boolean;
1885
+ /** When the session's checkpoint was last written (`compactSession`). Absent: never compacted. */
1886
+ readonly compactedAt?: string;
1887
+ }
1888
+ /** What `compactSession` did. `before` and `after` are estimated tokens a turn starts from. */
1889
+ export interface CompactedSession {
1890
+ readonly sessionKey: string;
1891
+ readonly before: number;
1892
+ readonly after: number;
1893
+ /** `model` when a declared `model.compactor` wrote the digest; `mechanical` otherwise. */
1894
+ readonly digest: "model" | "mechanical";
1895
+ readonly keptTurns: number;
1853
1896
  }
1854
1897
  export interface MessagesOptions {
1855
1898
  /** The cursor from a previous page's `nextBefore`. Absent starts at the newest. */
package/dist/client.js CHANGED
@@ -1,12 +1,12 @@
1
- var z="dispach",V="Dispach",J=1;function _(e,t){return{slug:e,name:t,envPrefix:`${e.toUpperCase()}_`,stateDir:`.${e}`,apiVersion:`${e}/v${J}`,packageScope:`@${e}`}}var E=_(z,V),S=`${E.envPrefix}BRAND`,Y=/^[a-z][a-z0-9]*(-[a-z0-9]+)*$/;function Z(e){return e.split("-").map((t)=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function X(e){if(e===void 0)return E;let t=e.trim();if(t==="")throw Error(`${S} is set but empty. hint: unset ${S} entirely to use the default brand — an empty value `+'is treated as a mistake rather than as "no override", because a declared-but-unset variable is usually a container passing through a name it never assigned.');if(!Y.test(t))throw Error(`${S}="${t}" is not a usable brand slug. hint: the slug becomes an env var prefix, a dot-directory, an npm scope, and the `+"manifest apiVersion, so it must be lowercase alphanumeric with inner hyphens — "+"e.g. acme or acme-run.");if(t===E.slug)return E;return _(t,Z(t))}var we=X(process.env[S]);var ve="What I already know, carried from before this conversation and kept current. "+"Not a transcript — these are standing facts about the person I work for and my own working notes. "+"If they ask what I know or remember about them, this is the answer.";var y=(e)=>String.fromCharCode(e),v=y(27),D=y(7),Te=new RegExp(`${v}\\[[0-?]*[ -/]*[@-~]`,"g"),$e=new RegExp(`${v}\\][\\s\\S]*?(?:${D}|${v}\\\\|$)`,"g"),Ee=new RegExp(`${v}[P^_X][\\s\\S]*?(?:${v}\\\\|${D}|$)`,"g"),ke=new RegExp(`${v}[@-Z\\\\-_0-9=><]?`,"g"),Se=new RegExp(`[${y(128)}-${y(159)}]`,"g"),Ce=new RegExp(`[${y(0)}-${y(8)}${y(11)}${y(12)}${y(14)}-${y(31)}${y(127)}]`,"g");var N=["runtime.ready","store.ready","runtime.stopping","agent.loaded","agent.disposed","agent.reloaded","agent.warning","plugin.loaded","plugin.slow","approval.requested","approval.resolved","handoff.start","handoff.result","peer.ask","peer.answer","turn.start","context.assembled","context.dropped","context.pressure","compaction.stage","context.reset","phase.changed","model.call","model.chunk","model.retry","model.fallback","model.result","media.result","tool.usage","tool.call","tool.result","tool.gated","tool.repair","tools.refreshed","agent.tools.refreshed","agent.channel.status","agent.channel.error","agent.channel.rejected","delivery.sent","delivery.retry","delivery.failed","delivery.uncertain","runtime.released","schedules.reconciled","schedule.fired","schedule.skipped","schedule.deferred","schedule.error","conversation.message","conversation.skipped","action.deferred","action.decided","agent.assigned","memory.read","memory.recalled","memory.forgotten","turn.end","error"],Q=/\r\n\r\n|\n\n|\r\r/;function P(e){let t=[],d,a,c;for(let l of e.split(/\r\n|\n|\r/)){if(l===""||l.startsWith(":"))continue;let r=l.indexOf(":"),f=r===-1?l:l.slice(0,r),p=r===-1?"":l.slice(r+1);if(p.startsWith(" "))p=p.slice(1);switch(f){case"data":t.push(p);break;case"event":d=p;break;case"id":a=p;break;case"retry":{let g=Number.parseInt(p,10);if(Number.isFinite(g))c=g;break}default:break}}if(t.length===0&&d===void 0)return;return{...d===void 0?{}:{event:d},data:t.join(`
2
- `),...a===void 0?{}:{id:a},...c===void 0?{}:{retry:c}}}async function*O(e){let t=new TextDecoder,d="";for await(let a of e){d+=typeof a==="string"?a:t.decode(a,{stream:!0});while(!0){let c=Q.exec(d);if(c===null)break;let l=d.slice(0,c.index);d=d.slice(c.index+c[0].length);let r=P(l);if(r!==void 0)yield r}}if(d+=t.decode(),d.trim()!==""){let a=P(d);if(a!==void 0)yield a}}function ee(){return{push:(e)=>e,endStep:()=>"",end:()=>""}}function ne(e){return e!=="final"&&e!=="stopped"}function te(e,t={}){switch(e){case"final":return;case"max_steps":return`stopped${t.steps===void 0?"":` after ${t.steps} steps`} without finishing — say "continue" to carry on, or raise limits.maxSteps`;case"no_progress":return'stopped: the same tool call was repeated with no change — say "continue" with more to go on, or check whether that tool is telling it anything useful';case"truncated":return"the reply was cut off at the output limit — raise model.<role>.maxTokens, or ask for less";case"timeout":return`timed out${t.durationMs===void 0?"":` after ${t.durationMs} ms`} — raise limits.turnTimeoutMs`;case"stopped":return t.cancelledAfterMs===void 0?"cancelled":`cancelled after ${t.cancelledAfterMs.toFixed(0)} ms`;case"error":return}}var re="submit_artifact";var M="<<<",K=">>>",k=/^\s*(?:(?:[-*+]|\d+[.)])\s+)?(?:<\s*)?action\s*:(.+)$/i,se=/^\s*(?:[-*+]\s+|\d+[.)]\s+)?([A-Za-z_][\w.-]*?)\s*:(.*)$/,I=/^\s*`{3,}\s*(?:[\w+-]+\s*)?$/,C=/^\s*end\s*$/i,oe=/^\s*<\s*action\s*>\s*$/i,L=/^\s*<\s*\/\s*action\s*>\s*$/i,ie=/^\s*<\/?\s*[A-Za-z_][\w.:-]*\s*(?:\/\s*)?>\s*$/;function j(e){let t=(e??"").trim();return t.endsWith(">")?t.slice(0,-1).trimEnd():t}function R(e){return x(x(ae(e,"`'\"*<"),"`'\"*>"),".,;:").trim()}function ae(e,t){let d=0;while(d<e.length&&t.includes(e[d]??""))d+=1;return e.slice(d)}function x(e,t){let d=e.length;while(d>0&&t.includes(e[d-1]??""))d-=1;return e.slice(0,d)}function F(e,t,d){let a=e.fields.get(t);if(a===void 0)e.fields.set(t,[d]);else a.push(d)}function q(e){if(e.block===void 0||e.heredocKey===void 0)return;let t=[...e.heredocLines];if(t[t.length-1]==="")t.pop();F(e.block,e.heredocKey,t.join(`
3
- `)),e.block.wrapped.add(e.heredocKey),e.heredocKey=void 0,e.heredocLines=[]}function w(e){if(q(e),e.block!==void 0)e.blocks.push(e.block);e.block=void 0,e.openKey=void 0,e.awaitingSlug=!1}function G(){return{block:void 0,openKey:void 0,severedKey:void 0,severedPending:void 0,heredocKey:void 0,heredocLines:[],justClosed:!1,awaitingSlug:!1,text:[],blocks:[]}}function de(e,t,d){let a=t.trim();if(e.heredocKey!==void 0){if(a===K){q(e);return}if(C.test(a)){w(e),e.justClosed=!0;return}if(k.test(t)){w(e);let r=k.exec(t),f=R(j(r?.[1]));if(f!=="")e.block={slug:f,fields:new Map,wrapped:new Set,severed:new Set};return}e.heredocLines.push(t);return}let c=k.exec(t);if(c!==null){let r=R(j(c[1]));if(w(e),r==="")return;e.block={slug:r,fields:new Map,wrapped:new Set,severed:new Set};return}if(oe.test(t)){w(e),e.awaitingSlug=!0;return}if(e.awaitingSlug){if(a==="")return;if(L.test(t)){e.awaitingSlug=!1;return}let r=R(a);if(e.awaitingSlug=!1,r!=="")e.block={slug:r,fields:new Map,wrapped:new Set,severed:new Set};return}if(L.test(t)){if(e.block!==void 0)w(e),e.justClosed=!0;return}if(ie.test(t))return;if(e.block===void 0){if(I.test(t)&&(e.justClosed||d())){e.justClosed=!1;return}if(C.test(a)&&e.severedPending!==void 0){e.severedPending.block.severed.add(e.severedPending.key),e.severedPending=void 0;return}if(k.test(t))e.severedPending=void 0;if(e.text.push(t),a!=="")e.justClosed=!1;return}if(a===""){if(e.openKey!==void 0)e.severedKey=e.openKey;e.openKey=void 0;return}if(C.test(a)){e.severedKey=void 0,w(e),e.justClosed=!0;return}if(I.test(t))return;let l=se.exec(t);if(l!==null){let r=(l[1]??"").trim(),f=(l[2]??"").trim();if(e.severedKey=void 0,f===M)e.heredocKey=r,e.heredocLines=[],e.openKey=void 0;else F(e.block,r,f),e.openKey=r;return}if(e.openKey!==void 0){let r=e.block.fields.get(e.openKey),f=r?.[r.length-1];if(r!==void 0&&f!==void 0)r[r.length-1]=f===""?a:`${f}
4
- ${a}`;return}if(e.severedKey!==void 0)e.severedPending={block:e.block,key:e.severedKey},e.severedKey=void 0;w(e),e.text.push(t)}function ue(e){if(/^\s*(?:(?:[-*+]|\d+[.)]?)\s*)?$/.test(e))return!0;let t=e.replace(/^\s*(?:[-*+]\s+|\d+[.)]\s+)?/,"").toLowerCase(),d=t.startsWith("<")?t.slice(1):t;if("action:".startsWith(d)||d.startsWith("action:"))return!0;if(/^<\/?$/.test(t)||/^<\/?[a-z_][\w.:-]*>?$/.test(t))return!0;return/^`{1,3}[\w+-]*$/.test(t)}function A(e){return e.endsWith("\r")?e.slice(0,-1):e}function le(){let e=G(),t="",d=0,a,c="",l=!1,r=(s)=>{if(s==="")return"";if(s.trim()==="")return c+=s,"";let n=c+s;if(c="",l)return n;return l=!0,n.replace(/^\s+/,"")},f=(s,n)=>{let i=e.text.length;return de(e,s,()=>n!==void 0&&k.test(n)),e.text.length>i?s:void 0},p=(s,n,i)=>{let u=f(s,n);if(u===void 0)return"";return r(u.slice(i))+r(`
1
+ var z="dispach",V="Dispach",J=1;function _(e,t){return{slug:e,name:t,envPrefix:`${e.toUpperCase()}_`,stateDir:`.${e}`,apiVersion:`${e}/v${J}`,packageScope:`@${e}`}}var k=_(z,V),S=`${k.envPrefix}BRAND`,Y=/^[a-z][a-z0-9]*(-[a-z0-9]+)*$/;function Z(e){return e.split("-").map((t)=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function X(e){if(e===void 0)return k;let t=e.trim();if(t==="")throw Error(`${S} is set but empty. hint: unset ${S} entirely to use the default brand — an empty value `+'is treated as a mistake rather than as "no override", because a declared-but-unset variable is usually a container passing through a name it never assigned.');if(!Y.test(t))throw Error(`${S}="${t}" is not a usable brand slug. hint: the slug becomes an env var prefix, a dot-directory, an npm scope, and the `+"manifest apiVersion, so it must be lowercase alphanumeric with inner hyphens — "+"e.g. acme or acme-run.");if(t===k.slug)return k;return _(t,Z(t))}var we=X(process.env[S]);var ve="What I already know, carried from before this conversation and kept current. "+"Not a transcript — these are standing facts about the person I work for and my own working notes. "+"If they ask what I know or remember about them, this is the answer.";var y=(e)=>String.fromCharCode(e),v=y(27),D=y(7),Te=new RegExp(`${v}\\[[0-?]*[ -/]*[@-~]`,"g"),$e=new RegExp(`${v}\\][\\s\\S]*?(?:${D}|${v}\\\\|$)`,"g"),ke=new RegExp(`${v}[P^_X][\\s\\S]*?(?:${v}\\\\|${D}|$)`,"g"),Ee=new RegExp(`${v}[@-Z\\\\-_0-9=><]?`,"g"),Se=new RegExp(`[${y(128)}-${y(159)}]`,"g"),Ce=new RegExp(`[${y(0)}-${y(8)}${y(11)}${y(12)}${y(14)}-${y(31)}${y(127)}]`,"g");var O=["runtime.ready","store.ready","runtime.stopping","agent.loaded","agent.disposed","agent.reloaded","agent.warning","plugin.loaded","plugin.slow","approval.requested","approval.resolved","handoff.start","handoff.result","peer.ask","peer.answer","turn.start","context.assembled","context.dropped","context.pressure","compaction.stage","context.reset","session.compacted","phase.changed","model.call","model.chunk","model.retry","model.fallback","model.result","media.result","tool.usage","tool.call","tool.result","tool.gated","tool.repair","tools.refreshed","agent.tools.refreshed","agent.channel.status","agent.channel.error","agent.channel.rejected","delivery.sent","delivery.retry","delivery.failed","delivery.uncertain","runtime.released","schedules.reconciled","schedule.fired","schedule.skipped","schedule.deferred","schedule.error","conversation.message","conversation.skipped","action.deferred","action.decided","agent.assigned","memory.read","memory.recalled","memory.forgotten","turn.end","error"],Q=/\r\n\r\n|\n\n|\r\r/;function P(e){let t=[],d,a,c;for(let l of e.split(/\r\n|\n|\r/)){if(l===""||l.startsWith(":"))continue;let r=l.indexOf(":"),f=r===-1?l:l.slice(0,r),p=r===-1?"":l.slice(r+1);if(p.startsWith(" "))p=p.slice(1);switch(f){case"data":t.push(p);break;case"event":d=p;break;case"id":a=p;break;case"retry":{let g=Number.parseInt(p,10);if(Number.isFinite(g))c=g;break}default:break}}if(t.length===0&&d===void 0)return;return{...d===void 0?{}:{event:d},data:t.join(`
2
+ `),...a===void 0?{}:{id:a},...c===void 0?{}:{retry:c}}}async function*N(e){let t=new TextDecoder,d="";for await(let a of e){d+=typeof a==="string"?a:t.decode(a,{stream:!0});while(!0){let c=Q.exec(d);if(c===null)break;let l=d.slice(0,c.index);d=d.slice(c.index+c[0].length);let r=P(l);if(r!==void 0)yield r}}if(d+=t.decode(),d.trim()!==""){let a=P(d);if(a!==void 0)yield a}}function ee(){return{push:(e)=>e,endStep:()=>"",end:()=>""}}function ne(e){return e!=="final"&&e!=="stopped"}function te(e,t={}){switch(e){case"final":return;case"max_steps":return`stopped${t.steps===void 0?"":` after ${t.steps} steps`} without finishing — say "continue" to carry on, or raise limits.maxSteps`;case"no_progress":return'stopped: the same tool call was repeated with no change — say "continue" with more to go on, or check whether that tool is telling it anything useful';case"truncated":return"the reply was cut off at the output limit — raise model.<role>.maxTokens, or ask for less";case"timeout":return`timed out${t.durationMs===void 0?"":` after ${t.durationMs} ms`} — raise limits.turnTimeoutMs`;case"stopped":return t.cancelledAfterMs===void 0?"cancelled":`cancelled after ${t.cancelledAfterMs.toFixed(0)} ms`;case"error":return}}var re="submit_artifact";var M="<<<",K=">>>",E=/^\s*(?:(?:[-*+]|\d+[.)])\s+)?(?:<\s*)?action\s*:(.+)$/i,se=/^\s*(?:[-*+]\s+|\d+[.)]\s+)?([A-Za-z_][\w.-]*?)\s*:(.*)$/,A=/^\s*`{3,}\s*(?:[\w+-]+\s*)?$/,C=/^\s*end\s*$/i,oe=/^\s*<\s*action\s*>\s*$/i,L=/^\s*<\s*\/\s*action\s*>\s*$/i,ie=/^\s*<\/?\s*[A-Za-z_][\w.:-]*\s*(?:\/\s*)?>\s*$/;function j(e){let t=(e??"").trim();return t.endsWith(">")?t.slice(0,-1).trimEnd():t}function R(e){return x(x(ae(e,"`'\"*<"),"`'\"*>"),".,;:").trim()}function ae(e,t){let d=0;while(d<e.length&&t.includes(e[d]??""))d+=1;return e.slice(d)}function x(e,t){let d=e.length;while(d>0&&t.includes(e[d-1]??""))d-=1;return e.slice(0,d)}function F(e,t,d){let a=e.fields.get(t);if(a===void 0)e.fields.set(t,[d]);else a.push(d)}function q(e){if(e.block===void 0||e.heredocKey===void 0)return;let t=[...e.heredocLines];if(t[t.length-1]==="")t.pop();F(e.block,e.heredocKey,t.join(`
3
+ `)),e.block.wrapped.add(e.heredocKey),e.heredocKey=void 0,e.heredocLines=[]}function w(e){if(q(e),e.block!==void 0)e.blocks.push(e.block);e.block=void 0,e.openKey=void 0,e.awaitingSlug=!1}function G(){return{block:void 0,openKey:void 0,severedKey:void 0,severedPending:void 0,heredocKey:void 0,heredocLines:[],justClosed:!1,awaitingSlug:!1,text:[],blocks:[]}}function de(e,t,d){let a=t.trim();if(e.heredocKey!==void 0){if(a===K){q(e);return}if(C.test(a)){w(e),e.justClosed=!0;return}if(E.test(t)){w(e);let r=E.exec(t),f=R(j(r?.[1]));if(f!=="")e.block={slug:f,fields:new Map,wrapped:new Set,severed:new Set};return}e.heredocLines.push(t);return}let c=E.exec(t);if(c!==null){let r=R(j(c[1]));if(w(e),r==="")return;e.block={slug:r,fields:new Map,wrapped:new Set,severed:new Set};return}if(oe.test(t)){w(e),e.awaitingSlug=!0;return}if(e.awaitingSlug){if(a==="")return;if(L.test(t)){e.awaitingSlug=!1;return}let r=R(a);if(e.awaitingSlug=!1,r!=="")e.block={slug:r,fields:new Map,wrapped:new Set,severed:new Set};return}if(L.test(t)){if(e.block!==void 0)w(e),e.justClosed=!0;return}if(ie.test(t))return;if(e.block===void 0){if(A.test(t)&&(e.justClosed||d())){e.justClosed=!1;return}if(C.test(a)&&e.severedPending!==void 0){e.severedPending.block.severed.add(e.severedPending.key),e.severedPending=void 0;return}if(E.test(t))e.severedPending=void 0;if(e.text.push(t),a!=="")e.justClosed=!1;return}if(a===""){if(e.openKey!==void 0)e.severedKey=e.openKey;e.openKey=void 0;return}if(C.test(a)){e.severedKey=void 0,w(e),e.justClosed=!0;return}if(A.test(t))return;let l=se.exec(t);if(l!==null){let r=(l[1]??"").trim(),f=(l[2]??"").trim();if(e.severedKey=void 0,f===M)e.heredocKey=r,e.heredocLines=[],e.openKey=void 0;else F(e.block,r,f),e.openKey=r;return}if(e.openKey!==void 0){let r=e.block.fields.get(e.openKey),f=r?.[r.length-1];if(r!==void 0&&f!==void 0)r[r.length-1]=f===""?a:`${f}
4
+ ${a}`;return}if(e.severedKey!==void 0)e.severedPending={block:e.block,key:e.severedKey},e.severedKey=void 0;w(e),e.text.push(t)}function ue(e){if(/^\s*(?:(?:[-*+]|\d+[.)]?)\s*)?$/.test(e))return!0;let t=e.replace(/^\s*(?:[-*+]\s+|\d+[.)]\s+)?/,"").toLowerCase(),d=t.startsWith("<")?t.slice(1):t;if("action:".startsWith(d)||d.startsWith("action:"))return!0;if(/^<\/?$/.test(t)||/^<\/?[a-z_][\w.:-]*>?$/.test(t))return!0;return/^`{1,3}[\w+-]*$/.test(t)}function I(e){return e.endsWith("\r")?e.slice(0,-1):e}function le(){let e=G(),t="",d=0,a,c="",l=!1,r=(s)=>{if(s==="")return"";if(s.trim()==="")return c+=s,"";let n=c+s;if(c="",l)return n;return l=!0,n.replace(/^\s+/,"")},f=(s,n)=>{let i=e.text.length;return de(e,s,()=>n!==void 0&&E.test(n)),e.text.length>i?s:void 0},p=(s,n,i)=>{let u=f(s,n);if(u===void 0)return"";return r(u.slice(i))+r(`
5
5
  `)},g=(s)=>{if(a===void 0)return"";let n=a;return a=void 0,p(n,s,0)};return{push(s){let n="";t+=s;let i=t.indexOf(`
6
- `);while(i!==-1){let m=A(t.slice(0,i));if(t=t.slice(i+1),n+=g(m),e.block===void 0&&I.test(m)&&!e.justClosed)a=m;else n+=p(m,void 0,d);d=0,i=t.indexOf(`
7
- `)}let u=A(t);if(e.block===void 0&&!e.awaitingSlug&&a===void 0&&!ue(u))n+=r(u.slice(d)),d=u.length;return n},endStep(){let s=o();return c=`
6
+ `);while(i!==-1){let m=I(t.slice(0,i));if(t=t.slice(i+1),n+=g(m),e.block===void 0&&A.test(m)&&!e.justClosed)a=m;else n+=p(m,void 0,d);d=0,i=t.indexOf(`
7
+ `)}let u=I(t);if(e.block===void 0&&!e.awaitingSlug&&a===void 0&&!ue(u))n+=r(u.slice(d)),d=u.length;return n},endStep(){let s=o();return c=`
8
8
 
9
- `,e=G(),s},end:o};function o(){let s=g(void 0),n=A(t);if(n!==""){let i=f(n,void 0);if(i!==void 0)s+=r(i.slice(d))}return t="",d=0,a=void 0,s}}var Re=`# Tools
9
+ `,e=G(),s},end:o};function o(){let s=g(void 0),n=I(t);if(n!==""){let i=f(n,void 0);if(i!==void 0)s+=r(i.slice(d))}return t="",d=0,a=void 0,s}}var Re=`# Tools
10
10
 
11
11
  To use a tool, write an ACTION block. Start each line at the left margin, exactly like this:
12
12
 
@@ -28,7 +28,7 @@ Rules for a block:
28
28
  Anything you write outside a block is shown to the person you are talking to, so keep explanations
29
29
  short and keep them out of the block. When no tool fits, simply reply — never invent a tool, and
30
30
  never guess a value for a required field you have not been given.`;function ce(e){return e.startsWith("subagent:")||e.startsWith("handoff:")}class b extends Error{code;hint;field;details;status;request;constructor(e,t={}){super([e.message,...(e.details??[]).map((d)=>` - ${d.field===void 0?"":`${d.field}: `}${d.message}`),...e.hint===void 0?[]:[` hint: ${e.hint}`]].join(`
31
- `));if(this.name="DispachError",this.code=e.code,this.hint=e.hint??"",this.field=e.field,this.details=e.details??[],this.status=t.status,this.request=t.method===void 0||t.path===void 0?void 0:{method:t.method,path:t.path},t.cause!==void 0)this.cause=t.cause}}function fe(e,t){let d=e instanceof Error?e.message:String(e);return new b({code:"transport_failed",message:`${t.method} ${t.path} did not reach ${t.baseUrl}: ${d}`,hint:"Check the base URL, that the server is running, and that nothing between you and it is refusing the connection. `GET /v1/health` needs no token and is the cheapest probe."},{...t,cause:e})}async function he(e,t){let d;try{let a=await e.json();if(typeof a.error?.code==="string"&&typeof a.error.message==="string")d={code:a.error.code,message:a.error.message,...a.error.hint===void 0?{}:{hint:a.error.hint},...a.error.field===void 0?{}:{field:a.error.field}}}catch{}return new b(d??{code:`http_${e.status}`,message:`${t.method} ${t.path} returned ${e.status} with no error body.`,hint:"This is not a response this server produces, so something between you and it answered — a proxy, a gateway, or a load balancer. Check the URL and what is in front of it."},{status:e.status,...t})}var B=new Set(N);async function*H(e){for await(let t of O(pe(e))){if(t.event===void 0||t.data==="")continue;let d;try{d=JSON.parse(t.data)}catch{continue}yield{name:t.event,data:d}}}async function*pe(e){let t=e.getReader();try{while(!0){let{done:d,value:a}=await t.read();if(d)return;if(a!==void 0)yield a}}finally{t.releaseLock()}}async function*me(e){for await(let{name:t,data:d}of H(e)){if(B.has(t)){yield{kind:"event",event:d};continue}let a=d??{};switch(t){case"turn.accepted":yield{kind:"accepted",turnId:String(a.turnId??""),sessionKey:String(a.sessionKey??"")};break;case"stream.replay":yield{kind:"replay",report:{state:a.state==="ended"?"ended":"running",events:Number(a.events??0),truncated:a.truncated===!0,dropped:Number(a.dropped??0),chunks:a.chunks==="start"||a.chunks==="partial"?a.chunks:"none"}};break;case"stream.ended":yield{kind:"ended",turnId:String(a.turnId??""),status:String(a.status??"unknown"),steps:typeof a.steps==="number"?a.steps:void 0,errorCode:typeof a.errorCode==="string"?a.errorCode:void 0};break;case"stream.unavailable":yield{kind:"unavailable",turnId:String(a.turnId??""),reason:String(a.reason??"not observable from this process")};break;default:break}}}async function*ye(e){for await(let{name:t,data:d}of H(e)){if(B.has(t)){yield{kind:"event",event:d};continue}if(t==="stream.subscribed"){let a=d??{};yield{kind:"subscribed",report:{agentId:typeof a.agentId==="string"?a.agentId:null,types:Array.isArray(a.types)?a.types:null,chunks:a.chunks===!0,implied:typeof a.implied==="string"?a.implied:void 0}}}}}async function*ge(e,t={}){for await(let d of e){if(d.kind==="replay"&&d.report.truncated&&t.allowTruncated!==!0)throw new b({code:"replay_truncated",message:`This turn's replay is missing its oldest ${d.report.dropped} event(s), so the text reconstructed from it would be incomplete.`,hint:"Read the finished text from GET /v1/agents/:id/turns/:turnId, or pass { allowTruncated: true } to accept a fragment. Streaming from the start of a turn is never truncated — this only happens when reattaching to one that has already produced more events than the buffer holds."});if(d.kind==="unavailable")throw new b({code:"turn_not_observable",message:`Turn ${d.turnId} is recorded as running but is not observable here: ${d.reason}.`,hint:"Its events are buffered in whichever process is executing it. Poll GET /v1/agents/:id/turns/:turnId for the outcome."});if(d.kind!=="event")continue;if(d.event.type!=="model.chunk")continue;let a=d.event.data;if(a.kind==="reasoning")continue;if(typeof a.delta==="string")yield a.delta}}function _e(e,t){return e.type===t}function Pe(e){let t=e.baseUrl.length;while(t>0&&e.baseUrl[t-1]==="/")t-=1;let d=e.baseUrl.slice(0,t),a=e.fetch??fetch,c=(o={})=>({...e.token===void 0?{}:{authorization:`Bearer ${e.token}`},...o});async function l(o,s,n={}){let i;try{i=await a(`${d}${s}`,{method:o,headers:c({...n.body===void 0?{}:{"content-type":"application/json"},...n.accept===void 0?{}:{accept:n.accept},...n.headers}),...n.body===void 0?{}:{body:JSON.stringify(n.body)},...n.signal===void 0?{}:{signal:n.signal}})}catch(u){throw fe(u,{method:o,path:s,baseUrl:d})}if(!i.ok)throw await he(i,{method:o,path:s});return i}async function r(o,s,n){return await(await l(o,s,n??{})).json()}async function f(o,s){let n=await l("GET",o,{accept:"text/event-stream",...s===void 0?{}:{signal:s}});if(n.body===null)throw new b({code:"no_response_body",message:`GET ${o} returned ${n.status} with no body to read.`,hint:"An SSE route always has a body. A missing one means something between you and the server buffered the response — commonly a proxy without streaming enabled."},{status:n.status,method:"GET",path:o});return n.body}function p(o,s,n,i={}){let u=(h)=>{let T=new URLSearchParams;if(h?.chunks===!0)T.set("chunks","true");if(h?.children===!0)T.set("children","true");let U=T.toString();return U===""?"":`?${U}`},m={turnId:s,sessionKey:n,replayed:i.replayed===!0,async*stream(h){let T=await f(`/v1/agents/${encodeURIComponent(o)}/turns/${encodeURIComponent(s)}/stream${u(h)}`,h?.signal);yield*me(T)},async*tokens(h){yield*ge(m.stream({chunks:!0,...h,children:!1}),{...h?.allowTruncated===void 0?{}:{allowTruncated:h.allowTruncated}})},async text(){for await(let h of m.stream()){if(h.kind==="ended")break;if(h.kind==="unavailable")break;if(h.kind==="event"&&h.event.type==="turn.end")break}return(await m.get()).text},get:()=>r("GET",`/v1/agents/${encodeURIComponent(o)}/turns/${encodeURIComponent(s)}`),async stop(){await l("POST",`/v1/agents/${encodeURIComponent(o)}/turns/${encodeURIComponent(s)}/stop`)}};return m}function g(o){let s=(n)=>`/v1/agents/${encodeURIComponent(o)}${n}`;return{id:o,async send(n,i){let u=await r("POST",s("/messages"),{body:{text:n,...i?.sessionKey===void 0?{}:{sessionKey:i.sessionKey},...i?.deliver===void 0?{}:{deliver:i.deliver},...i?.from===void 0?{}:{from:i.from},...i?.images===void 0?{}:{images:i.images},...i?.runtimeNote===void 0?{}:{runtimeNote:i.runtimeNote},...i?.chunks===!0?{chunks:!0}:{},...i?.role===void 0?{}:{role:i.role}},...i?.idempotencyKey===void 0?{}:{headers:{"idempotency-key":i.idempotencyKey}},...i?.signal===void 0?{}:{signal:i.signal}});return p(o,u.turnId,u.sessionKey,{replayed:u.replayed===!0})},turn:(n)=>p(o,n,""),describe:()=>r("GET",s("")),tools:()=>r("GET",s("/tools")),skills:()=>r("GET",s("/skills")),sessions:()=>r("GET",s("/sessions")),messages:(n,i)=>{let u=new URLSearchParams;if(i?.before!==void 0)u.set("before",String(i.before));if(i?.limit!==void 0)u.set("limit",String(i.limit));let m=u.size===0?"":`?${u.toString()}`;return r("GET",s(`/sessions/${encodeURIComponent(n)}/messages${m}`))},clearSession:(n)=>r("DELETE",s(`/sessions/${encodeURIComponent(n)}`)),reload:()=>r("POST",s("/reload"),{body:{}}),usage:(n)=>r("GET",s(`/usage${W(n)}`)),turns:(n)=>{let i=new URLSearchParams;if(n?.limit!==void 0)i.set("limit",String(n.limit));if(n?.before!==void 0)i.set("before",String(n.before));let u=i.size===0?"":`?${i.toString()}`;return r("GET",s(`/turns${u}`))},secrets:async()=>(await r("GET",s("/secrets"))).secrets,setSecrets:(n)=>r("PUT",s("/secrets"),{body:{values:n}}),schedules:async()=>(await r("GET",s("/schedules"))).schedules,approvals:async()=>(await r("GET",s("/approvals"))).approvals,createSchedule:(n)=>r("POST",s("/schedules"),{body:n}),updateSchedule:(n,i)=>r("PATCH",s(`/schedules/${encodeURIComponent(n)}`),{body:i}),deleteSchedule:async(n)=>{await r("DELETE",s(`/schedules/${encodeURIComponent(n)}`))},refreshTools:(n)=>r("POST",s("/tools/refresh"),{body:n?.providers===void 0?{}:{providers:n.providers}}),previewSchedule:(n)=>{let i=new URLSearchParams({kind:n.kind,expr:n.expr});if(n.timezone!==void 0)i.set("timezone",n.timezone);if(n.count!==void 0)i.set("count",String(n.count));return r("GET",s(`/schedules/preview?${i.toString()}`))},runSchedule:(n)=>r("POST",s(`/schedules/${encodeURIComponent(n)}/run`),{body:{}}),config:()=>r("GET",s("/config")),setConfig:(n,i,u)=>r("PATCH",s("/config"),{body:{path:n,value:i,...u?.confirm===void 0?{}:{confirm:u.confirm}}}),removeConfig:(n,i)=>r("PATCH",s("/config"),{body:{path:n,remove:!0,...i?.confirm===void 0?{}:{confirm:i.confirm}}}),setConfigs:(n)=>r("PATCH",s("/config"),{body:{changes:n.map((i)=>({...i}))}}),setChannel:(n,i)=>r("PATCH",s(`/channels/${encodeURIComponent(n)}`),{body:{...i}}),unpairChannel:(n)=>r("POST",s(`/channels/${encodeURIComponent(n)}/unpair`)),session:(n)=>r("GET",s(`/sessions/${encodeURIComponent(n)}`)),setPhase:(n,i)=>r("POST",s(`/sessions/${encodeURIComponent(n)}/phase`),{body:{phase:i}}),setRecall:(n,i)=>r("POST",s(`/sessions/${encodeURIComponent(n)}/recall`),{body:{recall:i}}),rotateSession:(n)=>r("POST",s("/sessions/rotate"),{body:n?.from===void 0?{}:{from:n.from}}),approve:async(n,i)=>{await r("POST",s(`/approvals/${encodeURIComponent(n)}`),{body:{granted:i}})},stop:(n)=>r("POST",s("/stop"),{body:n===void 0?{}:{reason:n}}),start:()=>r("POST",s("/start"),{body:{}}),assign:(n)=>r("PUT",s("/assignee"),{body:{participantId:n}}),unassign:()=>r("DELETE",s("/assignee")),assignment:()=>r("GET",s("/assignee")),workspaceFiles:()=>r("GET",s("/workspace")),workspaceFile:(n)=>r("GET",s(`/workspace/${encodeURIComponent(n)}`)),putWorkspaceFile:(n,i)=>r("PUT",s(`/workspace/${encodeURIComponent(n)}`),{body:{content:i}}),exportBundle:(n)=>r("GET",s(`/export${n===void 0?"":`?paths=${encodeURIComponent(n.join(","))}`}`)),importBundle:(n,i)=>r("POST",s("/import"),{body:{bundle:n,...i===void 0?{}:{mode:i}}}),setVars:(n)=>r("PATCH",s("/vars"),{body:{vars:n}}),vars:()=>r("GET",s("/vars")),deliver:(n)=>r("POST",s("/deliveries"),{body:n}),context:(n)=>{let i=new URLSearchParams;if(n?.sessionKey!==void 0)i.set("sessionKey",n.sessionKey);if(n?.input!==void 0)i.set("input",n.input);let u=i.size===0?"":`?${i.toString()}`;return r("GET",s(`/context${u}`))}}}return{agent:g,agents:()=>r("GET","/v1/agents"),health:()=>r("GET","/v1/health"),async ready(){try{return await l("GET","/v1/ready"),!0}catch(o){if(o instanceof b&&o.status===503)return!1;throw o}},provision:()=>r("GET","/v1/provision"),keys:()=>r("GET","/v1/keys"),createKey:(o)=>r("POST","/v1/keys",{body:o}),revokeKey:(o)=>r("DELETE",`/v1/keys/${encodeURIComponent(o)}`),deleteAgent:(o,s)=>r("DELETE",`/v1/agents/${encodeURIComponent(o)}?confirm=${encodeURIComponent(s)}`),backup:async(o)=>(await l("GET",`/v1/backup${o===void 0||o.length===0?"":`?include=${o.join(",")}`}`,{accept:"application/gzip"})).blob(),deleteParticipant:(o)=>r("DELETE",`/v1/participants/${encodeURIComponent(o)}`),createAgent:(o)=>r("POST","/v1/agents",{body:{answers:o}}),usage:(o)=>r("GET",`/v1/usage${W(o)}`),activity:()=>r("GET","/v1/activity"),participants:async()=>(await r("GET","/v1/participants")).participants,registerParticipant:(o)=>r("POST","/v1/participants",{body:o}),conversations:async()=>(await r("GET","/v1/conversations")).conversations,createConversation:(o)=>r("POST","/v1/conversations",{body:o}),conversation:(o)=>r("GET",`/v1/conversations/${encodeURIComponent(o)}`),setMembers:(o,s)=>r("PATCH",`/v1/conversations/${encodeURIComponent(o)}/members`,{body:s}),postMessage:(o,s)=>r("POST",`/v1/conversations/${encodeURIComponent(o)}/messages`,{body:s}),conversationMessages:(o,s={})=>{let n=new URLSearchParams;if(s.after!==void 0)n.set("after",String(s.after));if(s.limit!==void 0)n.set("limit",String(s.limit));let i=n.size===0?"":`?${n}`;return r("GET",`/v1/conversations/${encodeURIComponent(o)}/messages${i}`)},setPresence:(o,s)=>r("PUT",`/v1/participants/${encodeURIComponent(o)}/presence`,{body:{presence:s}}),actions:async(o={})=>(await r("GET",`/v1/actions${o.status===void 0?"":`?status=${o.status}`}`)).actions,decideAction:(o,s)=>r("POST",`/v1/actions/${encodeURIComponent(o)}`,{body:{approve:s}}),addNote:(o)=>r("POST","/v1/memory/notes",{body:o}),notes:async(o)=>(await r("GET",`/v1/memory/notes?scope=${encodeURIComponent(o)}`)).notes,deleteNote:(o)=>r("DELETE",`/v1/memory/notes/${encodeURIComponent(o)}`),memoryReads:async(o)=>(await r("GET",`/v1/participants/${encodeURIComponent(o)}/memory/reads`)).reads,projects:async()=>(await r("GET","/v1/projects")).projects,putProject:(o,s)=>r("PUT",`/v1/projects/${encodeURIComponent(o)}`,{body:s}),deleteProject:(o)=>r("DELETE",`/v1/projects/${encodeURIComponent(o)}`),setSpaceWriter:(o)=>r("PUT","/v1/memory/space/writer",{body:{writer:o}}),webhooks:async()=>(await r("GET","/v1/webhooks")).webhooks,createWebhook:(o)=>r("POST","/v1/webhooks",{body:o}),deleteWebhook:(o)=>r("DELETE",`/v1/webhooks/${encodeURIComponent(o)}`),templates:async()=>(await r("GET","/v1/templates")).templates,createAgentFromTemplate:(o)=>r("POST","/v1/agents",{body:o}),async*events(o){let s=new URLSearchParams;if(o?.agentId!==void 0)s.set("agentId",o.agentId);if(o?.types!==void 0&&o.types.length>0)s.set("types",o.types.join(","));if(o?.chunks===!0)s.set("chunks","true");let n=s.size===0?"":`?${s.toString()}`,i=await f(`/v1/events${n}`,o?.signal);yield*ye(i)}}}function W(e){let t=new URLSearchParams;if(e?.by!==void 0)t.set("by",e.by.join(","));if(e?.from!==void 0)t.set("from",e.from);if(e?.to!==void 0)t.set("to",e.to);return t.size===0?"":`?${t.toString()}`}export{b as DispachError,Pe as createClient,_e as isEvent};
31
+ `));if(this.name="DispachError",this.code=e.code,this.hint=e.hint??"",this.field=e.field,this.details=e.details??[],this.status=t.status,this.request=t.method===void 0||t.path===void 0?void 0:{method:t.method,path:t.path},t.cause!==void 0)this.cause=t.cause}}function fe(e,t){let d=e instanceof Error?e.message:String(e);return new b({code:"transport_failed",message:`${t.method} ${t.path} did not reach ${t.baseUrl}: ${d}`,hint:"Check the base URL, that the server is running, and that nothing between you and it is refusing the connection. `GET /v1/health` needs no token and is the cheapest probe."},{...t,cause:e})}async function he(e,t){let d;try{let a=await e.json();if(typeof a.error?.code==="string"&&typeof a.error.message==="string")d={code:a.error.code,message:a.error.message,...a.error.hint===void 0?{}:{hint:a.error.hint},...a.error.field===void 0?{}:{field:a.error.field}}}catch{}return new b(d??{code:`http_${e.status}`,message:`${t.method} ${t.path} returned ${e.status} with no error body.`,hint:"This is not a response this server produces, so something between you and it answered — a proxy, a gateway, or a load balancer. Check the URL and what is in front of it."},{status:e.status,...t})}var B=new Set(O);async function*H(e){for await(let t of N(pe(e))){if(t.event===void 0||t.data==="")continue;let d;try{d=JSON.parse(t.data)}catch{continue}yield{name:t.event,data:d}}}async function*pe(e){let t=e.getReader();try{while(!0){let{done:d,value:a}=await t.read();if(d)return;if(a!==void 0)yield a}}finally{t.releaseLock()}}async function*me(e){for await(let{name:t,data:d}of H(e)){if(B.has(t)){yield{kind:"event",event:d};continue}let a=d??{};switch(t){case"turn.accepted":yield{kind:"accepted",turnId:String(a.turnId??""),sessionKey:String(a.sessionKey??"")};break;case"stream.replay":yield{kind:"replay",report:{state:a.state==="ended"?"ended":"running",events:Number(a.events??0),truncated:a.truncated===!0,dropped:Number(a.dropped??0),chunks:a.chunks==="start"||a.chunks==="partial"?a.chunks:"none"}};break;case"stream.ended":yield{kind:"ended",turnId:String(a.turnId??""),status:String(a.status??"unknown"),steps:typeof a.steps==="number"?a.steps:void 0,errorCode:typeof a.errorCode==="string"?a.errorCode:void 0};break;case"stream.unavailable":yield{kind:"unavailable",turnId:String(a.turnId??""),reason:String(a.reason??"not observable from this process")};break;default:break}}}async function*ye(e){for await(let{name:t,data:d}of H(e)){if(B.has(t)){yield{kind:"event",event:d};continue}if(t==="stream.subscribed"){let a=d??{};yield{kind:"subscribed",report:{agentId:typeof a.agentId==="string"?a.agentId:null,types:Array.isArray(a.types)?a.types:null,chunks:a.chunks===!0,implied:typeof a.implied==="string"?a.implied:void 0}}}}}async function*ge(e,t={}){for await(let d of e){if(d.kind==="replay"&&d.report.truncated&&t.allowTruncated!==!0)throw new b({code:"replay_truncated",message:`This turn's replay is missing its oldest ${d.report.dropped} event(s), so the text reconstructed from it would be incomplete.`,hint:"Read the finished text from GET /v1/agents/:id/turns/:turnId, or pass { allowTruncated: true } to accept a fragment. Streaming from the start of a turn is never truncated — this only happens when reattaching to one that has already produced more events than the buffer holds."});if(d.kind==="unavailable")throw new b({code:"turn_not_observable",message:`Turn ${d.turnId} is recorded as running but is not observable here: ${d.reason}.`,hint:"Its events are buffered in whichever process is executing it. Poll GET /v1/agents/:id/turns/:turnId for the outcome."});if(d.kind!=="event")continue;if(d.event.type!=="model.chunk")continue;let a=d.event.data;if(a.kind==="reasoning")continue;if(typeof a.delta==="string")yield a.delta}}function _e(e,t){return e.type===t}function Pe(e){let t=e.baseUrl.length;while(t>0&&e.baseUrl[t-1]==="/")t-=1;let d=e.baseUrl.slice(0,t),a=e.fetch??fetch,c=(o={})=>({...e.token===void 0?{}:{authorization:`Bearer ${e.token}`},...o});async function l(o,s,n={}){let i;try{i=await a(`${d}${s}`,{method:o,headers:c({...n.body===void 0?{}:{"content-type":"application/json"},...n.accept===void 0?{}:{accept:n.accept},...n.headers}),...n.body===void 0?{}:{body:JSON.stringify(n.body)},...n.signal===void 0?{}:{signal:n.signal}})}catch(u){throw fe(u,{method:o,path:s,baseUrl:d})}if(!i.ok)throw await he(i,{method:o,path:s});return i}async function r(o,s,n){return await(await l(o,s,n??{})).json()}async function f(o,s){let n=await l("GET",o,{accept:"text/event-stream",...s===void 0?{}:{signal:s}});if(n.body===null)throw new b({code:"no_response_body",message:`GET ${o} returned ${n.status} with no body to read.`,hint:"An SSE route always has a body. A missing one means something between you and the server buffered the response — commonly a proxy without streaming enabled."},{status:n.status,method:"GET",path:o});return n.body}function p(o,s,n,i={}){let u=(h)=>{let T=new URLSearchParams;if(h?.chunks===!0)T.set("chunks","true");if(h?.children===!0)T.set("children","true");let U=T.toString();return U===""?"":`?${U}`},m={turnId:s,sessionKey:n,replayed:i.replayed===!0,async*stream(h){let T=await f(`/v1/agents/${encodeURIComponent(o)}/turns/${encodeURIComponent(s)}/stream${u(h)}`,h?.signal);yield*me(T)},async*tokens(h){yield*ge(m.stream({chunks:!0,...h,children:!1}),{...h?.allowTruncated===void 0?{}:{allowTruncated:h.allowTruncated}})},async text(){for await(let h of m.stream()){if(h.kind==="ended")break;if(h.kind==="unavailable")break;if(h.kind==="event"&&h.event.type==="turn.end")break}return(await m.get()).text},get:()=>r("GET",`/v1/agents/${encodeURIComponent(o)}/turns/${encodeURIComponent(s)}`),async stop(){await l("POST",`/v1/agents/${encodeURIComponent(o)}/turns/${encodeURIComponent(s)}/stop`)}};return m}function g(o){let s=(n)=>`/v1/agents/${encodeURIComponent(o)}${n}`;return{id:o,async send(n,i){let u=await r("POST",s("/messages"),{body:{text:n,...i?.sessionKey===void 0?{}:{sessionKey:i.sessionKey},...i?.deliver===void 0?{}:{deliver:i.deliver},...i?.from===void 0?{}:{from:i.from},...i?.images===void 0?{}:{images:i.images},...i?.runtimeNote===void 0?{}:{runtimeNote:i.runtimeNote},...i?.chunks===!0?{chunks:!0}:{},...i?.role===void 0?{}:{role:i.role}},...i?.idempotencyKey===void 0?{}:{headers:{"idempotency-key":i.idempotencyKey}},...i?.signal===void 0?{}:{signal:i.signal}});return p(o,u.turnId,u.sessionKey,{replayed:u.replayed===!0})},turn:(n)=>p(o,n,""),describe:()=>r("GET",s("")),tools:()=>r("GET",s("/tools")),skills:()=>r("GET",s("/skills")),sessions:()=>r("GET",s("/sessions")),messages:(n,i)=>{let u=new URLSearchParams;if(i?.before!==void 0)u.set("before",String(i.before));if(i?.limit!==void 0)u.set("limit",String(i.limit));let m=u.size===0?"":`?${u.toString()}`;return r("GET",s(`/sessions/${encodeURIComponent(n)}/messages${m}`))},clearSession:(n)=>r("DELETE",s(`/sessions/${encodeURIComponent(n)}`)),reload:()=>r("POST",s("/reload"),{body:{}}),usage:(n)=>r("GET",s(`/usage${W(n)}`)),turns:(n)=>{let i=new URLSearchParams;if(n?.limit!==void 0)i.set("limit",String(n.limit));if(n?.before!==void 0)i.set("before",String(n.before));let u=i.size===0?"":`?${i.toString()}`;return r("GET",s(`/turns${u}`))},secrets:async()=>(await r("GET",s("/secrets"))).secrets,setSecrets:(n)=>r("PUT",s("/secrets"),{body:{values:n}}),schedules:async()=>(await r("GET",s("/schedules"))).schedules,approvals:async()=>(await r("GET",s("/approvals"))).approvals,createSchedule:(n)=>r("POST",s("/schedules"),{body:n}),updateSchedule:(n,i)=>r("PATCH",s(`/schedules/${encodeURIComponent(n)}`),{body:i}),deleteSchedule:async(n)=>{await r("DELETE",s(`/schedules/${encodeURIComponent(n)}`))},refreshTools:(n)=>r("POST",s("/tools/refresh"),{body:n?.providers===void 0?{}:{providers:n.providers}}),previewSchedule:(n)=>{let i=new URLSearchParams({kind:n.kind,expr:n.expr});if(n.timezone!==void 0)i.set("timezone",n.timezone);if(n.count!==void 0)i.set("count",String(n.count));return r("GET",s(`/schedules/preview?${i.toString()}`))},runSchedule:(n)=>r("POST",s(`/schedules/${encodeURIComponent(n)}/run`),{body:{}}),config:()=>r("GET",s("/config")),setConfig:(n,i,u)=>r("PATCH",s("/config"),{body:{path:n,value:i,...u?.confirm===void 0?{}:{confirm:u.confirm}}}),removeConfig:(n,i)=>r("PATCH",s("/config"),{body:{path:n,remove:!0,...i?.confirm===void 0?{}:{confirm:i.confirm}}}),setConfigs:(n)=>r("PATCH",s("/config"),{body:{changes:n.map((i)=>({...i}))}}),setChannel:(n,i)=>r("PATCH",s(`/channels/${encodeURIComponent(n)}`),{body:{...i}}),unpairChannel:(n)=>r("POST",s(`/channels/${encodeURIComponent(n)}/unpair`)),session:(n)=>r("GET",s(`/sessions/${encodeURIComponent(n)}`)),setPhase:(n,i)=>r("POST",s(`/sessions/${encodeURIComponent(n)}/phase`),{body:{phase:i}}),setRecall:(n,i)=>r("POST",s(`/sessions/${encodeURIComponent(n)}/recall`),{body:{recall:i}}),resolveSessionKey:async(n)=>(await r("POST",s("/sessions/resolve"),{body:{sessionKey:n}})).sessionKey,compactSession:(n,i)=>r("POST",s(`/sessions/${encodeURIComponent(n)}/compact`),{body:i?.keepTurns===void 0?{}:{keepTurns:i.keepTurns}}),rotateSession:(n)=>r("POST",s("/sessions/rotate"),{body:n?.from===void 0?{}:{from:n.from}}),approve:async(n,i)=>{await r("POST",s(`/approvals/${encodeURIComponent(n)}`),{body:{granted:i}})},stop:(n)=>r("POST",s("/stop"),{body:n===void 0?{}:{reason:n}}),start:()=>r("POST",s("/start"),{body:{}}),assign:(n)=>r("PUT",s("/assignee"),{body:{participantId:n}}),unassign:()=>r("DELETE",s("/assignee")),assignment:()=>r("GET",s("/assignee")),workspaceFiles:()=>r("GET",s("/workspace")),workspaceFile:(n)=>r("GET",s(`/workspace/${encodeURIComponent(n)}`)),putWorkspaceFile:(n,i)=>r("PUT",s(`/workspace/${encodeURIComponent(n)}`),{body:{content:i}}),exportBundle:(n)=>r("GET",s(`/export${n===void 0?"":`?paths=${encodeURIComponent(n.join(","))}`}`)),importBundle:(n,i)=>r("POST",s("/import"),{body:{bundle:n,...i===void 0?{}:{mode:i}}}),setVars:(n)=>r("PATCH",s("/vars"),{body:{vars:n}}),vars:()=>r("GET",s("/vars")),deliver:(n)=>r("POST",s("/deliveries"),{body:n}),context:(n)=>{let i=new URLSearchParams;if(n?.sessionKey!==void 0)i.set("sessionKey",n.sessionKey);if(n?.input!==void 0)i.set("input",n.input);let u=i.size===0?"":`?${i.toString()}`;return r("GET",s(`/context${u}`))}}}return{agent:g,agents:()=>r("GET","/v1/agents"),health:()=>r("GET","/v1/health"),async ready(){try{return await l("GET","/v1/ready"),!0}catch(o){if(o instanceof b&&o.status===503)return!1;throw o}},provision:()=>r("GET","/v1/provision"),keys:()=>r("GET","/v1/keys"),createKey:(o)=>r("POST","/v1/keys",{body:o}),revokeKey:(o)=>r("DELETE",`/v1/keys/${encodeURIComponent(o)}`),deleteAgent:(o,s)=>r("DELETE",`/v1/agents/${encodeURIComponent(o)}?confirm=${encodeURIComponent(s)}`),backup:async(o)=>(await l("GET",`/v1/backup${o===void 0||o.length===0?"":`?include=${o.join(",")}`}`,{accept:"application/gzip"})).blob(),deleteParticipant:(o)=>r("DELETE",`/v1/participants/${encodeURIComponent(o)}`),createAgent:(o)=>r("POST","/v1/agents",{body:{answers:o}}),usage:(o)=>r("GET",`/v1/usage${W(o)}`),activity:()=>r("GET","/v1/activity"),participants:async()=>(await r("GET","/v1/participants")).participants,registerParticipant:(o)=>r("POST","/v1/participants",{body:o}),conversations:async()=>(await r("GET","/v1/conversations")).conversations,createConversation:(o)=>r("POST","/v1/conversations",{body:o}),conversation:(o)=>r("GET",`/v1/conversations/${encodeURIComponent(o)}`),setMembers:(o,s)=>r("PATCH",`/v1/conversations/${encodeURIComponent(o)}/members`,{body:s}),postMessage:(o,s)=>r("POST",`/v1/conversations/${encodeURIComponent(o)}/messages`,{body:s}),conversationMessages:(o,s={})=>{let n=new URLSearchParams;if(s.after!==void 0)n.set("after",String(s.after));if(s.limit!==void 0)n.set("limit",String(s.limit));let i=n.size===0?"":`?${n}`;return r("GET",`/v1/conversations/${encodeURIComponent(o)}/messages${i}`)},setPresence:(o,s)=>r("PUT",`/v1/participants/${encodeURIComponent(o)}/presence`,{body:{presence:s}}),actions:async(o={})=>(await r("GET",`/v1/actions${o.status===void 0?"":`?status=${o.status}`}`)).actions,decideAction:(o,s)=>r("POST",`/v1/actions/${encodeURIComponent(o)}`,{body:{approve:s}}),addNote:(o)=>r("POST","/v1/memory/notes",{body:o}),notes:async(o)=>(await r("GET",`/v1/memory/notes?scope=${encodeURIComponent(o)}`)).notes,deleteNote:(o)=>r("DELETE",`/v1/memory/notes/${encodeURIComponent(o)}`),memoryReads:async(o)=>(await r("GET",`/v1/participants/${encodeURIComponent(o)}/memory/reads`)).reads,projects:async()=>(await r("GET","/v1/projects")).projects,putProject:(o,s)=>r("PUT",`/v1/projects/${encodeURIComponent(o)}`,{body:s}),deleteProject:(o)=>r("DELETE",`/v1/projects/${encodeURIComponent(o)}`),setSpaceWriter:(o)=>r("PUT","/v1/memory/space/writer",{body:{writer:o}}),webhooks:async()=>(await r("GET","/v1/webhooks")).webhooks,createWebhook:(o)=>r("POST","/v1/webhooks",{body:o}),deleteWebhook:(o)=>r("DELETE",`/v1/webhooks/${encodeURIComponent(o)}`),templates:async()=>(await r("GET","/v1/templates")).templates,createAgentFromTemplate:(o)=>r("POST","/v1/agents",{body:o}),async*events(o){let s=new URLSearchParams;if(o?.agentId!==void 0)s.set("agentId",o.agentId);if(o?.types!==void 0&&o.types.length>0)s.set("types",o.types.join(","));if(o?.chunks===!0)s.set("chunks","true");let n=s.size===0?"":`?${s.toString()}`,i=await f(`/v1/events${n}`,o?.signal);yield*ye(i)}}}function W(e){let t=new URLSearchParams;if(e?.by!==void 0)t.set("by",e.by.join(","));if(e?.from!==void 0)t.set("from",e.from);if(e?.to!==void 0)t.set("to",e.to);return t.size===0?"":`?${t.toString()}`}export{b as DispachError,Pe as createClient,_e as isEvent};
32
32
 
33
- //# debugId=46822B930786255264756E2164756E21
33
+ //# debugId=3B2BF74A58DC6C9164756E2164756E21
34
34
  //# sourceMappingURL=client.js.map