dispach 0.1.2 → 0.2.0-pilot.1

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 (247) hide show
  1. package/README.md +196 -118
  2. package/dist/APEv2Parser-2wqk09q7.js +5 -0
  3. package/dist/APEv2Parser-2wqk09q7.js.map +9 -0
  4. package/dist/AiffParser-zw4g2bdd.js +5 -0
  5. package/dist/AiffParser-zw4g2bdd.js.map +12 -0
  6. package/dist/App-ez7ve0yp.js +11 -0
  7. package/dist/{App-b1yrwrcq.js.map → App-ez7ve0yp.js.map} +6 -7
  8. package/dist/AsfParser-2hfcf5z2.js +5 -0
  9. package/dist/AsfParser-2hfcf5z2.js.map +14 -0
  10. package/dist/ConfigEditor-aamadrx3.js +6 -0
  11. package/dist/{ConfigEditor-n8hdw6r7.js.map → ConfigEditor-aamadrx3.js.map} +2 -2
  12. package/dist/DsdiffParser-n8smktvb.js +5 -0
  13. package/dist/DsdiffParser-n8smktvb.js.map +11 -0
  14. package/dist/DsfParser-npmjp4vr.js +5 -0
  15. package/dist/DsfParser-npmjp4vr.js.map +11 -0
  16. package/dist/FlacParser-xpbs2zmb.js +5 -0
  17. package/dist/FlacParser-xpbs2zmb.js.map +9 -0
  18. package/dist/KeyProbe-4fp152yv.js +5 -0
  19. package/dist/{KeyProbe-9jjeze5r.js.map → KeyProbe-4fp152yv.js.map} +2 -2
  20. package/dist/MP4Parser-es3afcmw.js +5 -0
  21. package/dist/MP4Parser-es3afcmw.js.map +12 -0
  22. package/dist/MatroskaParser-kxysj649.js +5 -0
  23. package/dist/MatroskaParser-kxysj649.js.map +13 -0
  24. package/dist/MpegParser-b3rr7b0f.js +5 -0
  25. package/dist/MpegParser-b3rr7b0f.js.map +13 -0
  26. package/dist/MusepackParser-sgjzmq0r.js +5 -0
  27. package/dist/MusepackParser-sgjzmq0r.js.map +16 -0
  28. package/dist/OggParser-x8h54ynf.js +5 -0
  29. package/dist/OggParser-x8h54ynf.js.map +18 -0
  30. package/dist/Picker-rq015kzc.js +5 -0
  31. package/dist/{Picker-hfeh1g6m.js.map → Picker-rq015kzc.js.map} +2 -2
  32. package/dist/SessionPicker-03zyvd2f.js +5 -0
  33. package/dist/{SessionPicker-zyqkg4dn.js.map → SessionPicker-03zyvd2f.js.map} +2 -2
  34. package/dist/SkillBrowser-8s8rjv98.js +5 -0
  35. package/dist/{SkillBrowser-3qdp8080.js.map → SkillBrowser-8s8rjv98.js.map} +2 -2
  36. package/dist/WavPackParser-w515nnw2.js +5 -0
  37. package/dist/WavPackParser-w515nnw2.js.map +11 -0
  38. package/dist/WaveParser-sb0w9m20.js +5 -0
  39. package/dist/WaveParser-sb0w9m20.js.map +13 -0
  40. package/dist/WizardApp-wr1tftcr.js +5 -0
  41. package/dist/{WizardApp-vzpbydy3.js.map → WizardApp-wr1tftcr.js.map} +3 -3
  42. package/dist/agents.d.ts +19 -3
  43. package/dist/agents.d.ts.map +1 -1
  44. package/dist/channels-gx951qdp.js +31 -0
  45. package/dist/channels-gx951qdp.js.map +10 -0
  46. package/dist/channels.d.ts +26 -0
  47. package/dist/channels.d.ts.map +1 -0
  48. package/dist/client.js +11 -11
  49. package/dist/client.js.map +3 -3
  50. package/dist/config-wvjeejgd.js +24 -0
  51. package/dist/{config-g7za9x13.js.map → config-wvjeejgd.js.map} +2 -2
  52. package/dist/credential-10dn3fxj.js +19 -0
  53. package/dist/{credential-npr6z8c8.js.map → credential-10dn3fxj.js.map} +1 -1
  54. package/dist/daemon.d.ts.map +1 -1
  55. package/dist/index-10009hp8.js +11 -0
  56. package/dist/index-10009hp8.js.map +11 -0
  57. package/dist/index-1xwrkwh5.js +14 -0
  58. package/dist/index-1xwrkwh5.js.map +50 -0
  59. package/dist/index-34p39yfc.js +47 -0
  60. package/dist/index-34p39yfc.js.map +15 -0
  61. package/dist/index-3y96s740.js +6 -0
  62. package/dist/{index-hwpvhaza.js.map → index-3y96s740.js.map} +1 -1
  63. package/dist/index-4ybeefmn.js +6 -0
  64. package/dist/index-4ybeefmn.js.map +11 -0
  65. package/dist/index-59z88wrb.js +6 -0
  66. package/dist/{index-h9mw7b9d.js.map → index-59z88wrb.js.map} +2 -2
  67. package/dist/index-5fwzn21m.js +6 -0
  68. package/dist/{index-gz9x25tz.js.map → index-5fwzn21m.js.map} +2 -2
  69. package/dist/index-6dvnfk8y.js +6 -0
  70. package/dist/index-6dvnfk8y.js.map +10 -0
  71. package/dist/index-6p70fnb7.js +153 -0
  72. package/dist/index-6p70fnb7.js.map +20 -0
  73. package/dist/index-6s471ydn.js +12 -0
  74. package/dist/{index-j55s3ehk.js.map → index-6s471ydn.js.map} +2 -2
  75. package/dist/index-87wcawta.js +6 -0
  76. package/dist/{index-0d93hyfc.js.map → index-87wcawta.js.map} +2 -2
  77. package/dist/index-92gfcbw0.js +6 -0
  78. package/dist/index-92gfcbw0.js.map +9 -0
  79. package/dist/index-a0h0p20f.js +991 -0
  80. package/dist/{index-tv4yv7d2.js.map → index-a0h0p20f.js.map} +27 -23
  81. package/dist/index-bamw24xc.js +6 -0
  82. package/dist/{index-6q4wf8e3.js.map → index-bamw24xc.js.map} +1 -1
  83. package/dist/index-c8ge88a9.js +12 -0
  84. package/dist/{index-258d8bzg.js.map → index-c8ge88a9.js.map} +4 -3
  85. package/dist/index-cb2q8nae.js +6 -0
  86. package/dist/index-cb2q8nae.js.map +13 -0
  87. package/dist/index-ct6bw0a6.js +6 -0
  88. package/dist/{index-4z7axw4r.js.map → index-ct6bw0a6.js.map} +1 -1
  89. package/dist/index-cz6yjxyz.js +10 -0
  90. package/dist/index-cz6yjxyz.js.map +42 -0
  91. package/dist/index-d0c5abkw.js +6 -0
  92. package/dist/{index-vgc3y3rm.js.map → index-d0c5abkw.js.map} +3 -3
  93. package/dist/index-d0vagham.js +31 -0
  94. package/dist/index-d0vagham.js.map +188 -0
  95. package/dist/index-d0zxvr99.js +90 -0
  96. package/dist/index-d0zxvr99.js.map +13 -0
  97. package/dist/{index-s9mbq7h6.js → index-d9c97ver.js} +4 -4
  98. package/dist/{index-s9mbq7h6.js.map → index-d9c97ver.js.map} +1 -1
  99. package/dist/index-e508e0vt.js +6 -0
  100. package/dist/{index-tf71ap9v.js.map → index-e508e0vt.js.map} +1 -1
  101. package/dist/index-esq0knqx.js +6 -0
  102. package/dist/index-esq0knqx.js.map +10 -0
  103. package/dist/index-featyhps.js +6 -0
  104. package/dist/index-featyhps.js.map +10 -0
  105. package/dist/index-fnq44zdt.js +45 -0
  106. package/dist/index-fnq44zdt.js.map +74 -0
  107. package/dist/index-gmn80dwc.js +7 -0
  108. package/dist/{index-02dn6m2j.js.map → index-gmn80dwc.js.map} +2 -2
  109. package/dist/index-gwhx69qs.js +66 -0
  110. package/dist/index-gwhx69qs.js.map +12 -0
  111. package/dist/index-kjgzhf3w.js +9 -0
  112. package/dist/{index-6p999cx4.js.map → index-kjgzhf3w.js.map} +4 -6
  113. package/dist/index-m68cd91a.js +12 -0
  114. package/dist/index-m68cd91a.js.map +23 -0
  115. package/dist/{index-3g3ny01d.js → index-mhmgw54j.js} +4 -4
  116. package/dist/{index-3g3ny01d.js.map → index-mhmgw54j.js.map} +1 -1
  117. package/dist/{index-gme2egyq.js → index-qm612hwa.js} +4 -4
  118. package/dist/{index-gme2egyq.js.map → index-qm612hwa.js.map} +1 -1
  119. package/dist/{index-j7gyr5nx.js → index-qwntpbwe.js} +7 -7
  120. package/dist/{index-j7gyr5nx.js.map → index-qwntpbwe.js.map} +1 -1
  121. package/dist/index-qx3xdk4x.js +6 -0
  122. package/dist/{index-d4x6yvqh.js.map → index-qx3xdk4x.js.map} +3 -4
  123. package/dist/{index-4cf6v9nb.js → index-rh0meegk.js} +4 -4
  124. package/dist/{index-4cf6v9nb.js.map → index-rh0meegk.js.map} +1 -1
  125. package/dist/index-ryb159ff.js +9 -0
  126. package/dist/{index-ff514z3y.js.map → index-ryb159ff.js.map} +3 -5
  127. package/dist/{index-ammv5st7.js → index-s6zfpyqa.js} +6 -6
  128. package/dist/{index-ammv5st7.js.map → index-s6zfpyqa.js.map} +1 -1
  129. package/dist/index-s9va2kmc.js +429 -0
  130. package/dist/index-s9va2kmc.js.map +11 -0
  131. package/dist/index-v5dmsgpx.js +7 -0
  132. package/dist/index-v5dmsgpx.js.map +11 -0
  133. package/dist/index-vaj3mn3a.js +6 -0
  134. package/dist/index-vaj3mn3a.js.map +14 -0
  135. package/dist/index-vy0rbzws.js +6 -0
  136. package/dist/{index-fex44816.js.map → index-vy0rbzws.js.map} +2 -2
  137. package/dist/index-w0s77wfx.js +6 -0
  138. package/dist/{index-v8e92nfw.js.map → index-w0s77wfx.js.map} +1 -1
  139. package/dist/index-wx1jzjzr.js +6 -0
  140. package/dist/{index-qdbq8crg.js.map → index-wx1jzjzr.js.map} +2 -2
  141. package/dist/index-xbn26c8g.js +126 -0
  142. package/dist/index-xbn26c8g.js.map +14 -0
  143. package/dist/index-ytvwyp6k.js +6 -0
  144. package/dist/{index-9r0wyj6w.js.map → index-ytvwyp6k.js.map} +2 -2
  145. package/dist/{index-cqqb6gaq.js → index-yvnwpxbb.js} +5 -5
  146. package/dist/{index-cqqb6gaq.js.map → index-yvnwpxbb.js.map} +1 -1
  147. package/dist/index.js +379 -448
  148. package/dist/index.js.map +26 -28
  149. package/dist/init.d.ts.map +1 -1
  150. package/dist/lib/agent-secrets.d.ts +38 -0
  151. package/dist/lib/agent-secrets.d.ts.map +1 -0
  152. package/dist/lib/agent-template.d.ts +54 -0
  153. package/dist/lib/agent-template.d.ts.map +1 -0
  154. package/dist/lib/channel-actions.d.ts +103 -0
  155. package/dist/lib/channel-actions.d.ts.map +1 -0
  156. package/dist/lib/chat-frame.d.ts +12 -1
  157. package/dist/lib/chat-frame.d.ts.map +1 -1
  158. package/dist/lib/commands.d.ts +13 -0
  159. package/dist/lib/commands.d.ts.map +1 -1
  160. package/dist/lib/const.d.ts +1 -1
  161. package/dist/lib/daemon-plan.d.ts.map +1 -1
  162. package/dist/lib/help.d.ts.map +1 -1
  163. package/dist/lib/host-actions.d.ts +121 -0
  164. package/dist/lib/host-actions.d.ts.map +1 -0
  165. package/dist/lib/init-flow.d.ts +32 -0
  166. package/dist/lib/init-flow.d.ts.map +1 -1
  167. package/dist/lib/init-whatsapp.d.ts +52 -0
  168. package/dist/lib/init-whatsapp.d.ts.map +1 -0
  169. package/dist/lib/plugin-install.d.ts +120 -0
  170. package/dist/lib/plugin-install.d.ts.map +1 -0
  171. package/dist/lib/providers.d.ts.map +1 -1
  172. package/dist/lib/provision.d.ts +13 -0
  173. package/dist/lib/provision.d.ts.map +1 -1
  174. package/dist/lib/readme-table.d.ts +15 -0
  175. package/dist/lib/readme-table.d.ts.map +1 -0
  176. package/dist/lib/sandbox.d.ts +17 -0
  177. package/dist/lib/sandbox.d.ts.map +1 -1
  178. package/dist/lib/schema.d.ts +34 -1
  179. package/dist/lib/schema.d.ts.map +1 -1
  180. package/dist/lib/subcommand.d.ts.map +1 -1
  181. package/dist/lib/web-url.d.ts +15 -0
  182. package/dist/lib/web-url.d.ts.map +1 -0
  183. package/dist/lib/wizard.d.ts.map +1 -1
  184. package/dist/memory.d.ts.map +1 -1
  185. package/dist/model.d.ts.map +1 -1
  186. package/dist/plugins.d.ts +27 -8
  187. package/dist/plugins.d.ts.map +1 -1
  188. package/dist/restart.d.ts +21 -0
  189. package/dist/restart.d.ts.map +1 -0
  190. package/dist/run.d.ts.map +1 -1
  191. package/dist/schedules.d.ts.map +1 -1
  192. package/dist/serve.d.ts.map +1 -1
  193. package/dist/sessions.d.ts.map +1 -1
  194. package/dist/skills.d.ts.map +1 -1
  195. package/dist/status.d.ts +16 -0
  196. package/dist/status.d.ts.map +1 -0
  197. package/dist/tools.d.ts.map +1 -1
  198. package/dist/validate.d.ts.map +1 -1
  199. package/dist/web-61cjhpv2.js +14 -0
  200. package/dist/{web-vkb16r62.js.map → web-61cjhpv2.js.map} +3 -3
  201. package/dist/web.d.ts +2 -13
  202. package/dist/web.d.ts.map +1 -1
  203. package/dist/workspace.d.ts.map +1 -1
  204. package/dist/wrapper-9msjh1xg.js +5 -0
  205. package/dist/wrapper-9msjh1xg.js.map +9 -0
  206. package/package.json +6 -3
  207. package/dist/App-b1yrwrcq.js +0 -11
  208. package/dist/ConfigEditor-n8hdw6r7.js +0 -6
  209. package/dist/KeyProbe-9jjeze5r.js +0 -5
  210. package/dist/Picker-hfeh1g6m.js +0 -5
  211. package/dist/SessionPicker-zyqkg4dn.js +0 -5
  212. package/dist/SkillBrowser-3qdp8080.js +0 -5
  213. package/dist/WizardApp-vzpbydy3.js +0 -5
  214. package/dist/config-g7za9x13.js +0 -24
  215. package/dist/credential-npr6z8c8.js +0 -19
  216. package/dist/index-02dn6m2j.js +0 -7
  217. package/dist/index-0d93hyfc.js +0 -6
  218. package/dist/index-1c5113t4.js +0 -66
  219. package/dist/index-1c5113t4.js.map +0 -12
  220. package/dist/index-258d8bzg.js +0 -12
  221. package/dist/index-4z7axw4r.js +0 -6
  222. package/dist/index-6p999cx4.js +0 -9
  223. package/dist/index-6q4wf8e3.js +0 -6
  224. package/dist/index-9r0wyj6w.js +0 -6
  225. package/dist/index-d4x6yvqh.js +0 -6
  226. package/dist/index-fecm8xe7.js +0 -77
  227. package/dist/index-fecm8xe7.js.map +0 -12
  228. package/dist/index-fex44816.js +0 -6
  229. package/dist/index-ff514z3y.js +0 -14
  230. package/dist/index-gz9x25tz.js +0 -6
  231. package/dist/index-h9mw7b9d.js +0 -6
  232. package/dist/index-hwpvhaza.js +0 -6
  233. package/dist/index-j55s3ehk.js +0 -12
  234. package/dist/index-mtn0g9vc.js +0 -7
  235. package/dist/index-mtn0g9vc.js.map +0 -11
  236. package/dist/index-qdbq8crg.js +0 -6
  237. package/dist/index-tf71ap9v.js +0 -6
  238. package/dist/index-ttwyrdjs.js +0 -427
  239. package/dist/index-ttwyrdjs.js.map +0 -11
  240. package/dist/index-tv4yv7d2.js +0 -903
  241. package/dist/index-ty24n0jh.js +0 -167
  242. package/dist/index-ty24n0jh.js.map +0 -19
  243. package/dist/index-v8e92nfw.js +0 -6
  244. package/dist/index-vgc3y3rm.js +0 -6
  245. package/dist/index-whaw4b18.js +0 -6
  246. package/dist/index-whaw4b18.js.map +0 -10
  247. package/dist/web-vkb16r62.js +0 -14
@@ -3,9 +3,9 @@
3
3
  "sources": ["../src/lib/browser.ts", "../src/web.ts"],
4
4
  "sourcesContent": [
5
5
  "/**\n * Opening a URL in whatever the operating system thinks a browser is.\n *\n * Nothing in this repo opened a browser before, and the temptation is a dependency — there are\n * several, and every one of them is this file plus a matrix of platforms nobody here runs. What it\n * actually takes is one command per platform and an honest answer when there is no browser at all,\n * which is the case that matters most: **a container has none**, and the container is where this\n * runtime is deployed. So \"could not open\" is a first-class outcome with the URL printed beside it,\n * not an error.\n *\n * Three properties, each of which was a decision:\n *\n * **It never blocks.** `open`/`xdg-open` hand off to a browser and exit, but `xdg-open` on a box\n * with no desktop can sit there — and a command that hangs while claiming to have opened a page is\n * worse than one that prints a link. Every call is bounded.\n *\n * **It never fails the command.** The URL is the deliverable; the browser is a convenience. A\n * non-zero exit from `open` means the operator gets a link to click instead, which is exactly what\n * they would have got from `web url`.\n *\n * **It refuses without a TTY.** A piped or scripted run must not sprout a browser window on\n * somebody's screen — and in CI it would open nothing and waste a timeout finding out.\n */\n\nimport { spawnCaptureAsync } from \"#lib/spawn\"\n\n/** Why a URL was not opened. Absent means it was. */\nexport type OpenRefusal =\n /** No terminal, so nothing asked for a window. */\n | \"not-a-terminal\"\n /** `--no-open`. */\n | \"asked-not-to\"\n /** No opener on this platform — a container, a bare server, an unrecognised OS. */\n | \"no-opener\"\n /** There is an opener and it said no. */\n | \"opener-failed\"\n\nexport interface OpenOutcome {\n readonly opened: boolean\n readonly refusal?: OpenRefusal\n /** What the opener said, when it said something worth repeating. */\n readonly detail?: string\n}\n\n/**\n * The command that opens a URL, per platform.\n *\n * `xdg-open` is the freedesktop standard and is what Linux desktops implement; a *server* has none,\n * which is the honest reason this can return nothing. Windows needs the `\"\"` title argument before\n * the URL, because `start` reads a first quoted argument as the window title and would otherwise\n * open a console named after the address.\n */\nfunction openerFor(platform: string): { command: string; args: readonly string[] } | undefined {\n if (platform === \"darwin\") return { command: \"open\", args: [] }\n if (platform === \"linux\") return { command: \"xdg-open\", args: [] }\n if (platform === \"win32\") return { command: \"cmd\", args: [\"/c\", \"start\", \"\"] }\n return undefined\n}\n\n/** Bounded: `xdg-open` on a box with no desktop session can sit indefinitely. */\nconst OPEN_TIMEOUT_MS = 5_000\n\nexport async function openInBrowser(\n url: string,\n options: {\n readonly platform?: string\n readonly isTty?: boolean\n readonly noOpen?: boolean\n readonly spawn?: typeof spawnCaptureAsync\n } = {},\n): Promise<OpenOutcome> {\n if (options.noOpen === true) return { opened: false, refusal: \"asked-not-to\" }\n if (options.isTty !== true) return { opened: false, refusal: \"not-a-terminal\" }\n\n const opener = openerFor(options.platform ?? process.platform)\n if (opener === undefined) return { opened: false, refusal: \"no-opener\" }\n\n const run = options.spawn ?? spawnCaptureAsync\n const result = await run({\n command: opener.command,\n args: [...opener.args, url],\n timeoutMs: OPEN_TIMEOUT_MS,\n })\n\n // `notFound` is its own answer: `xdg-open` missing means this is a server or a container, which\n // is a fact about the deployment rather than a failure to report as one.\n if (result.notFound) return { opened: false, refusal: \"no-opener\" }\n if (result.code !== 0 || result.signalled) {\n return {\n opened: false,\n refusal: \"opener-failed\",\n ...(result.stderr.trim() === \"\" ? {} : { detail: result.stderr.trim() }),\n }\n }\n return { opened: true }\n}\n\n/**\n * What to print. One sentence, and it always ends with the URL.\n *\n * The URL is the deliverable in every branch — including success, because a browser that opened\n * behind another window looks like nothing happened, and because a terminal that prints the link is\n * one somebody can copy out of over SSH.\n */\nexport function openMessage(url: string, outcome: OpenOutcome): string {\n if (outcome.opened) return `opening ${url}`\n switch (outcome.refusal) {\n case \"asked-not-to\":\n return url\n case \"not-a-terminal\":\n return url\n case \"no-opener\":\n // Named rather than apologised for: this is the ordinary state inside a container, and\n // an operator reading \"failed to open a browser\" would go looking for a fault.\n return `no browser here — open this from a machine that has one:\\n ${url}`\n default:\n return `could not open a browser${outcome.detail === undefined ? \"\" : ` (${outcome.detail})`} — open this:\\n ${url}`\n }\n}\n",
6
- "/**\n * The `web` command — the browser as a second view onto the same running agent.\n *\n * The terminal twin of 17.1, and it exists for the same reason: the server owns the agent, and a\n * front end attaches. `run` opens a terminal onto a host; this opens a browser onto the same one,\n * at the same address, holding the same conversation. Neither starts or stops anything.\n *\n * ## Why this is three verbs and not one\n *\n * `run` is what a person types. It needs a host, so it declares `needsServer` and the first-run\n * bootstrap gets one. `open` assumes a host is already there and says so when it is not — the\n * difference matters on a machine where starting a service is not wanted. `url` prints and opens\n * nothing, which is the only form that works in a pipe, in CI, and over SSH.\n *\n * ## The container\n *\n * There is no browser in a container and there never will be, so `no-opener` is an ordinary answer\n * rather than a failure: the URL is printed and the operator opens it from the machine whose port\n * is published. This is the deployment target, so it is the case the wording is written for.\n */\n\nimport { BRAND } from \"@dispach/core\"\nimport { browsableHost } from \"@dispach/server\"\nimport { openInBrowser, openMessage } from \"#lib/browser\"\nimport { EXIT_FAILURE, EXIT_OK } from \"#lib/const\"\nimport { agentIdFor, anyLiveHost, hostToken, liveHostOf } from \"#lib/lifecycle\"\nimport type { WebOptions } from \"#lib/schema\"\n\n/**\n * Where the page lives, with the agent it should open.\n *\n * `?agent=` rather than `/agents/milo` for the reason `04-SPEC-WIRE.md` gives for having no\n * catch-all: a path needs a route, a `WEB_ASSETS` entry, a spec row and a `spec.test.ts` change,\n * and a wildcard would make `/v1/agentss` answer `200 text/html`. A query parameter needs none of\n * them, and the page reads it.\n *\n * No credential is attached. A claim is minted at boot and printed by `serve`, deliberately once —\n * a fresh one per invocation would leave a standing credential in a log — and a durable key in an\n * address bar lands in history, a bookmark and whatever syncs them. The page asks when it has to.\n */\nexport function webUrl(baseUrl: string, agentId?: string): string {\n const url = new URL(baseUrl)\n url.pathname = \"/\"\n /**\n * A bind is not an address, and the container is where that stops being theoretical.\n *\n * The lease publishes what was actually bound, which inside the image is `0.0.0.0` — every\n * interface, and a link no browser can open. `browsableHost` is the same substitution\n * `claimUrl` has always made, shared rather than copied a third time. Found by running this\n * *in the container*: on a laptop `serve` binds `127.0.0.1` and the substitution never fires,\n * so the defect is invisible everywhere except where it is deployed.\n */\n url.hostname = browsableHost(url.hostname)\n if (agentId !== undefined && agentId !== \"\") url.searchParams.set(\"agent\", agentId)\n return url.toString()\n}\n\nexport async function webCommand(options: WebOptions): Promise<number> {\n const action = options.action ?? \"run\"\n const agentId =\n options.manifestPath === undefined ? undefined : agentIdFor(options.manifestPath)\n\n /**\n * Which host, and the same two-part answer `stop` and `run` use.\n *\n * A lease says who is serving an agent; its `base_url` says where, and is published after the\n * bind rather than derived from a manifest — `--port 0` means the port does not exist until the\n * socket does. With no agent named, any live host will do: the page lists what it hosts.\n */\n const lease =\n agentId === undefined\n ? await anyLiveHost(options.store)\n : await liveHostOf(agentId, options.store)\n\n if (lease?.baseUrl === undefined || lease.baseUrl === \"\") {\n process.stderr.write(\n `no ${BRAND.name} server is running${agentId === undefined ? \"\" : ` for \"${agentId}\"`}.\\n` +\n ` hint: ${BRAND.slug} serve${agentId === undefined ? \"\" : ` ${agentId}`} starts one in this terminal, and ${BRAND.slug} daemon install keeps it running.\\n`,\n )\n return EXIT_FAILURE\n }\n\n const url = webUrl(lease.baseUrl, agentId)\n if (action === \"url\") {\n // Only the URL, on stdout, with nothing else — this is the form a script reads.\n process.stdout.write(`${url}\\n`)\n return EXIT_OK\n }\n\n const outcome = await openInBrowser(url, {\n isTty: process.stdout.isTTY === true,\n ...(options.noOpen === true ? { noOpen: true } : {}),\n })\n process.stdout.write(`${openMessage(url, outcome)}\\n`)\n\n // A browser that did not open is not a failed command: the URL is the deliverable and it has\n // been printed. `web url` exists for the caller that wants only that and no sentence around it.\n if (!outcome.opened && options.json === true) {\n process.stdout.write(`${JSON.stringify({ url, opened: false, why: outcome.refusal })}\\n`)\n }\n\n // The credential the page may ask for, named where somebody is already looking — and only when\n // this server has one to demand. A token-less loopback server needs nothing, and telling its\n // operator to mint a key would send them after a problem they do not have.\n if (outcome.opened && hostToken(options.manifestPath ?? \"\") !== undefined) {\n process.stdout.write(\n ` if the page asks for a credential, mint one:\\n` +\n ` ${BRAND.slug} keys new --label 'my browser'\\n`,\n )\n }\n return EXIT_OK\n}\n"
6
+ "/**\n * The `web` command — the browser as a second view onto the same running agent.\n *\n * The terminal twin of 17.1, and it exists for the same reason: the server owns the agent, and a\n * front end attaches. `run` opens a terminal onto a host; this opens a browser onto the same one,\n * at the same address, holding the same conversation. Neither starts or stops anything.\n *\n * ## Why this is three verbs and not one\n *\n * `run` is what a person types. It needs a host, so it declares `needsServer` and the first-run\n * bootstrap gets one. `open` assumes a host is already there and says so when it is not — the\n * difference matters on a machine where starting a service is not wanted. `url` prints and opens\n * nothing, which is the only form that works in a pipe, in CI, and over SSH.\n *\n * ## The container\n *\n * There is no browser in a container and there never will be, so `no-opener` is an ordinary answer\n * rather than a failure: the URL is printed and the operator opens it from the machine whose port\n * is published. This is the deployment target, so it is the case the wording is written for.\n */\n\nimport { BRAND } from \"@dispach/core\"\nimport { openInBrowser, openMessage } from \"#lib/browser\"\nimport { EXIT_FAILURE, EXIT_OK } from \"#lib/const\"\nimport { agentIdFor, anyLiveHost, hostToken, liveHostOf } from \"#lib/lifecycle\"\nimport type { WebOptions } from \"#lib/schema\"\nimport { webUrl } from \"#lib/web-url\"\n\nexport { webUrl }\n\nexport async function webCommand(options: WebOptions): Promise<number> {\n const action = options.action ?? \"run\"\n const agentId =\n options.manifestPath === undefined ? undefined : agentIdFor(options.manifestPath)\n\n /**\n * Which host, and the same two-part answer `stop` and `run` use.\n *\n * A lease says who is serving an agent; its `base_url` says where, and is published after the\n * bind rather than derived from a manifest — `--port 0` means the port does not exist until the\n * socket does. With no agent named, any live host will do: the page lists what it hosts.\n */\n const lease =\n agentId === undefined\n ? await anyLiveHost(options.store)\n : await liveHostOf(agentId, options.store)\n\n if (lease?.baseUrl === undefined || lease.baseUrl === \"\") {\n process.stderr.write(\n `no ${BRAND.name} server is running${agentId === undefined ? \"\" : ` for \"${agentId}\"`}.\\n` +\n ` hint: ${BRAND.slug} serve${agentId === undefined ? \"\" : ` ${agentId}`} starts one in this terminal, and ${BRAND.slug} daemon install keeps it running.\\n`,\n )\n return EXIT_FAILURE\n }\n\n const url = webUrl(lease.baseUrl, agentId)\n if (action === \"url\") {\n // Only the URL, on stdout, with nothing else — this is the form a script reads.\n process.stdout.write(`${url}\\n`)\n return EXIT_OK\n }\n\n const outcome = await openInBrowser(url, {\n isTty: process.stdout.isTTY === true,\n ...(options.noOpen === true ? { noOpen: true } : {}),\n })\n process.stdout.write(`${openMessage(url, outcome)}\\n`)\n\n // A browser that did not open is not a failed command: the URL is the deliverable and it has\n // been printed. `web url` exists for the caller that wants only that and no sentence around it.\n if (!outcome.opened && options.json === true) {\n process.stdout.write(`${JSON.stringify({ url, opened: false, why: outcome.refusal })}\\n`)\n }\n\n // The credential the page may ask for, named where somebody is already looking — and only when\n // this server has one to demand. A token-less loopback server needs nothing, and telling its\n // operator to mint a key would send them after a problem they do not have.\n if (outcome.opened && hostToken(options.manifestPath ?? \"\") !== undefined) {\n process.stdout.write(\n ` if the page asks for a credential, mint one:\\n` +\n ` ${BRAND.slug} credential create --label 'my browser'\\n`,\n )\n }\n return EXIT_OK\n}\n"
7
7
  ],
8
- "mappings": ";qPAoDA,SAAS,CAAS,CAAC,EAA4E,CAC3F,GAAI,IAAa,SAAU,MAAO,CAAE,QAAS,OAAQ,KAAM,CAAC,CAAE,EAC9D,GAAI,IAAa,QAAS,MAAO,CAAE,QAAS,WAAY,KAAM,CAAC,CAAE,EACjE,GAAI,IAAa,QAAS,MAAO,CAAE,QAAS,MAAO,KAAM,CAAC,KAAM,QAAS,EAAE,CAAE,EAC7E,OAIJ,IAAM,EAAkB,KAExB,eAAsB,CAAa,CAC/B,EACA,EAKI,CAAC,EACe,CACpB,GAAI,EAAQ,SAAW,GAAM,MAAO,CAAE,OAAQ,GAAO,QAAS,cAAe,EAC7E,GAAI,EAAQ,QAAU,GAAM,MAAO,CAAE,OAAQ,GAAO,QAAS,gBAAiB,EAE9E,IAAM,EAAS,EAAU,EAAQ,UAAY,QAAQ,QAAQ,EAC7D,GAAI,IAAW,OAAW,MAAO,CAAE,OAAQ,GAAO,QAAS,WAAY,EAGvE,IAAM,EAAS,MADH,EAAQ,OAAS,IACJ,CACrB,QAAS,EAAO,QAChB,KAAM,CAAC,GAAG,EAAO,KAAM,CAAG,EAC1B,UAAW,CACf,CAAC,EAID,GAAI,EAAO,SAAU,MAAO,CAAE,OAAQ,GAAO,QAAS,WAAY,EAClE,GAAI,EAAO,OAAS,GAAK,EAAO,UAC5B,MAAO,CACH,OAAQ,GACR,QAAS,mBACL,EAAO,OAAO,KAAK,IAAM,GAAK,CAAC,EAAI,CAAE,OAAQ,EAAO,OAAO,KAAK,CAAE,CAC1E,EAEJ,MAAO,CAAE,OAAQ,EAAK,EAUnB,SAAS,CAAW,CAAC,EAAa,EAA8B,CACnE,GAAI,EAAQ,OAAQ,MAAO,WAAW,IACtC,OAAQ,EAAQ,aACP,eACD,OAAO,MACN,iBACD,OAAO,MACN,YAGD,MAAO;AAAA,IAA+D,YAEtE,MAAO,2BAA2B,EAAQ,SAAW,OAAY,GAAK,KAAK,EAAQ;AAAA,IAA6B,KC5ErH,SAAS,CAAM,CAAC,EAAiB,EAA0B,CAC9D,IAAM,EAAM,IAAI,IAAI,CAAO,EAY3B,GAXA,EAAI,SAAW,IAUf,EAAI,SAAW,GAAc,EAAI,QAAQ,EACrC,IAAY,QAAa,IAAY,GAAI,EAAI,aAAa,IAAI,QAAS,CAAO,EAClF,OAAO,EAAI,SAAS,EAGxB,eAAsB,CAAU,CAAC,EAAsC,CACnE,IAAM,EAAS,EAAQ,QAAU,MAC3B,EACF,EAAQ,eAAiB,OAAY,OAAY,GAAW,EAAQ,YAAY,EAS9E,EACF,IAAY,OACN,MAAM,GAAY,EAAQ,KAAK,EAC/B,MAAM,GAAW,EAAS,EAAQ,KAAK,EAEjD,GAAI,GAAO,UAAY,QAAa,EAAM,UAAY,GAKlD,OAJA,QAAQ,OAAO,MACX,MAAM,EAAM,yBAAyB,IAAY,OAAY,GAAK,SAAS;AAAA,UAC5D,EAAM,aAAa,IAAY,OAAY,GAAK,IAAI,wCAA8C,EAAM;AAAA,CAC3H,EACO,EAGX,IAAM,EAAM,EAAO,EAAM,QAAS,CAAO,EACzC,GAAI,IAAW,MAGX,OADA,QAAQ,OAAO,MAAM,GAAG;AAAA,CAAO,EACxB,EAGX,IAAM,EAAU,MAAM,EAAc,EAAK,CACrC,MAAO,QAAQ,OAAO,QAAU,MAC5B,EAAQ,SAAW,GAAO,CAAE,OAAQ,EAAK,EAAI,CAAC,CACtD,CAAC,EAKD,GAJA,QAAQ,OAAO,MAAM,GAAG,EAAY,EAAK,CAAO;AAAA,CAAK,EAIjD,CAAC,EAAQ,QAAU,EAAQ,OAAS,GACpC,QAAQ,OAAO,MAAM,GAAG,KAAK,UAAU,CAAE,MAAK,OAAQ,GAAO,IAAK,EAAQ,OAAQ,CAAC;AAAA,CAAK,EAM5F,GAAI,EAAQ,QAAU,GAAU,EAAQ,cAAgB,EAAE,IAAM,OAC5D,QAAQ,OAAO,MACX;AAAA,MACW,EAAM;AAAA,CACrB,EAEJ,OAAO",
9
- "debugId": "2D2C77F38CA438D664756E2164756E21",
8
+ "mappings": ";qPAoDA,SAAS,CAAS,CAAC,EAA4E,CAC3F,GAAI,IAAa,SAAU,MAAO,CAAE,QAAS,OAAQ,KAAM,CAAC,CAAE,EAC9D,GAAI,IAAa,QAAS,MAAO,CAAE,QAAS,WAAY,KAAM,CAAC,CAAE,EACjE,GAAI,IAAa,QAAS,MAAO,CAAE,QAAS,MAAO,KAAM,CAAC,KAAM,QAAS,EAAE,CAAE,EAC7E,OAIJ,IAAM,EAAkB,KAExB,eAAsB,CAAa,CAC/B,EACA,EAKI,CAAC,EACe,CACpB,GAAI,EAAQ,SAAW,GAAM,MAAO,CAAE,OAAQ,GAAO,QAAS,cAAe,EAC7E,GAAI,EAAQ,QAAU,GAAM,MAAO,CAAE,OAAQ,GAAO,QAAS,gBAAiB,EAE9E,IAAM,EAAS,EAAU,EAAQ,UAAY,QAAQ,QAAQ,EAC7D,GAAI,IAAW,OAAW,MAAO,CAAE,OAAQ,GAAO,QAAS,WAAY,EAGvE,IAAM,EAAS,MADH,EAAQ,OAAS,IACJ,CACrB,QAAS,EAAO,QAChB,KAAM,CAAC,GAAG,EAAO,KAAM,CAAG,EAC1B,UAAW,CACf,CAAC,EAID,GAAI,EAAO,SAAU,MAAO,CAAE,OAAQ,GAAO,QAAS,WAAY,EAClE,GAAI,EAAO,OAAS,GAAK,EAAO,UAC5B,MAAO,CACH,OAAQ,GACR,QAAS,mBACL,EAAO,OAAO,KAAK,IAAM,GAAK,CAAC,EAAI,CAAE,OAAQ,EAAO,OAAO,KAAK,CAAE,CAC1E,EAEJ,MAAO,CAAE,OAAQ,EAAK,EAUnB,SAAS,CAAW,CAAC,EAAa,EAA8B,CACnE,GAAI,EAAQ,OAAQ,MAAO,WAAW,IACtC,OAAQ,EAAQ,aACP,eACD,OAAO,MACN,iBACD,OAAO,MACN,YAGD,MAAO;AAAA,IAA+D,YAEtE,MAAO,2BAA2B,EAAQ,SAAW,OAAY,GAAK,KAAK,EAAQ;AAAA,IAA6B,KCtF5H,eAAsB,CAAU,CAAC,EAAsC,CACnE,IAAM,EAAS,EAAQ,QAAU,MAC3B,EACF,EAAQ,eAAiB,OAAY,OAAY,GAAW,EAAQ,YAAY,EAS9E,EACF,IAAY,OACN,MAAM,GAAY,EAAQ,KAAK,EAC/B,MAAM,GAAW,EAAS,EAAQ,KAAK,EAEjD,GAAI,GAAO,UAAY,QAAa,EAAM,UAAY,GAKlD,OAJA,QAAQ,OAAO,MACX,MAAM,EAAM,yBAAyB,IAAY,OAAY,GAAK,SAAS;AAAA,UAC5D,EAAM,aAAa,IAAY,OAAY,GAAK,IAAI,wCAA8C,EAAM;AAAA,CAC3H,EACO,EAGX,IAAM,EAAM,GAAO,EAAM,QAAS,CAAO,EACzC,GAAI,IAAW,MAGX,OADA,QAAQ,OAAO,MAAM,GAAG;AAAA,CAAO,EACxB,EAGX,IAAM,EAAU,MAAM,EAAc,EAAK,CACrC,MAAO,QAAQ,OAAO,QAAU,MAC5B,EAAQ,SAAW,GAAO,CAAE,OAAQ,EAAK,EAAI,CAAC,CACtD,CAAC,EAKD,GAJA,QAAQ,OAAO,MAAM,GAAG,EAAY,EAAK,CAAO;AAAA,CAAK,EAIjD,CAAC,EAAQ,QAAU,EAAQ,OAAS,GACpC,QAAQ,OAAO,MAAM,GAAG,KAAK,UAAU,CAAE,MAAK,OAAQ,GAAO,IAAK,EAAQ,OAAQ,CAAC;AAAA,CAAK,EAM5F,GAAI,EAAQ,QAAU,GAAU,EAAQ,cAAgB,EAAE,IAAM,OAC5D,QAAQ,OAAO,MACX;AAAA,MACW,EAAM;AAAA,CACrB,EAEJ,OAAO",
9
+ "debugId": "C28711B913CBEB5564756E2164756E21",
10
10
  "names": []
11
11
  }
package/dist/web.d.ts CHANGED
@@ -19,18 +19,7 @@
19
19
  * is published. This is the deployment target, so it is the case the wording is written for.
20
20
  */
21
21
  import type { WebOptions } from "#lib/schema";
22
- /**
23
- * Where the page lives, with the agent it should open.
24
- *
25
- * `?agent=` rather than `/agents/milo` for the reason `04-SPEC-WIRE.md` gives for having no
26
- * catch-all: a path needs a route, a `WEB_ASSETS` entry, a spec row and a `spec.test.ts` change,
27
- * and a wildcard would make `/v1/agentss` answer `200 text/html`. A query parameter needs none of
28
- * them, and the page reads it.
29
- *
30
- * No credential is attached. A claim is minted at boot and printed by `serve`, deliberately once —
31
- * a fresh one per invocation would leave a standing credential in a log — and a durable key in an
32
- * address bar lands in history, a bookmark and whatever syncs them. The page asks when it has to.
33
- */
34
- export declare function webUrl(baseUrl: string, agentId?: string): string;
22
+ import { webUrl } from "#lib/web-url";
23
+ export { webUrl };
35
24
  export declare function webCommand(options: WebOptions): Promise<number>;
36
25
  //# sourceMappingURL=web.d.ts.map
package/dist/web.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"web.d.ts","sourceRoot":"","sources":["../src/web.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAOH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAE7C;;;;;;;;;;;GAWG;AACH,wBAAgB,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAehE;AAED,wBAAsB,UAAU,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAsDrE"}
1
+ {"version":3,"file":"web.d.ts","sourceRoot":"","sources":["../src/web.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAMH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAErC,OAAO,EAAE,MAAM,EAAE,CAAA;AAEjB,wBAAsB,UAAU,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAsDrE"}
@@ -1 +1 @@
1
- {"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../src/workspace.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAeH,MAAM,WAAW,gBAAgB;IAC7B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAA;IACvB,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAA;CAC5B;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,gBAAgB,GAAG,MAAM,CAgGlE"}
1
+ {"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../src/workspace.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAcH,MAAM,WAAW,gBAAgB;IAC7B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAA;IACvB,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAA;CAC5B;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,gBAAgB,GAAG,MAAM,CA8FlE"}
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+ import{ys,ZA}from"./index-m68cd91a.js";var a=ys.default;export{a as WebSocketServer,ZA as default};
3
+
4
+ //# debugId=F78888A0AEC6C19F64756E2164756E21
5
+ //# sourceMappingURL=wrapper-9msjh1xg.js.map
@@ -0,0 +1,9 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [
5
+ ],
6
+ "mappings": "",
7
+ "debugId": "F78888A0AEC6C19F64756E2164756E21",
8
+ "names": []
9
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dispach",
3
- "version": "0.1.2",
3
+ "version": "0.2.0-pilot.1",
4
4
  "description": "A lightweight, model-agnostic AI agent runtime — the CLI, the server, and a typed client.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Moeen Mahmud",
@@ -35,7 +35,8 @@
35
35
  "imports": {
36
36
  "#*": "./src/*.ts",
37
37
  "#components/*": "./src/components/*.tsx",
38
- "#plugins": "./src/plugins.ts"
38
+ "#plugins": "./src/plugins.ts",
39
+ "#channels": "./src/channels.ts"
39
40
  },
40
41
  "scripts": {
41
42
  "dev": "bun run ./src/index.ts",
@@ -52,6 +53,7 @@
52
53
  },
53
54
  "devDependencies": {
54
55
  "@dispach/channel-telegram": "workspace:*",
56
+ "@dispach/channel-whatsapp": "workspace:*",
55
57
  "@dispach/client": "workspace:*",
56
58
  "@dispach/core": "workspace:*",
57
59
  "@dispach/server": "workspace:*",
@@ -60,7 +62,8 @@
60
62
  "@dispach/tools-web": "workspace:*",
61
63
  "@types/react": "19.2.18",
62
64
  "ink-testing-library": "4.0.0",
63
- "react-devtools-core": "6.1.5"
65
+ "react-devtools-core": "6.1.5",
66
+ "ws": "^8"
64
67
  },
65
68
  "keywords": [
66
69
  "ai",
@@ -1,11 +0,0 @@
1
- #!/usr/bin/env node
2
- import{e,R}from"./index-tv4yv7d2.js";import{o,qo,Go,u,oe,S,I}from"./index-d4x6yvqh.js";import{an,dt,ln}from"./index-9r0wyj6w.js";import{de}from"./index-v8e92nfw.js";import{ir}from"./index-cqqb6gaq.js";import{wn,bn}from"./index-02dn6m2j.js";import{Yn,yo,wo,on,sn,$t,lt,vo,yr,xo,Eo}from"./index-258d8bzg.js";import{re}from"./index-0d93hyfc.js";import"./index-ttwyrdjs.js";import{le,It}from"./index-whaw4b18.js";import{at,rn}from"./index-ff514z3y.js";import"./index-tf71ap9v.js";import{ge}from"./index-s9mbq7h6.js";import{rr,q}from"./index-h9mw7b9d.js";import"./index-j7gyr5nx.js";import{D,Ut,kt,V,Uo,kn,jt}from"./index-j55s3ehk.js";import{j,lr,An,On,rs,as,ls,ds,cs,dr,Bt,fs}from"./index-vgc3y3rm.js";import{Box as W,Text as Z,useApp as Zt,useInput as ot}from"ink";import{useCallback as rt,useEffect as it,useMemo as st,useRef as Jt,useState as B}from"react";import{Box as Oe,Text as me}from"ink";import{jsx as Se,jsxs as fe}from"react/jsx-runtime";function cn({lines:n,label:t,offset:r,maxRows:i,code:s}){if(n===void 0)return Se(Oe,{marginLeft:2,children:Se(de,{label:`running ${t}`})});if(n.length===0)return Se(Oe,{marginLeft:2,children:fe(me,{color:o.muted,children:[t," printed nothing"]})});let{from:a,to:c}=I(n.length,Math.min(r+Math.floor(i/2),n.length-1),i),m=n.slice(a,c).map((f,b)=>({row:a+b,text:f}));return fe(Oe,{flexDirection:"column",children:[s!==void 0&&s!==0?fe(me,{color:o.error,wrap:"truncate",children:[u.error,t," exited ",s]}):null,a>0?fe(me,{dimColor:!0,wrap:"truncate",children:[" ",u.ellipsis," ",a," line",a===1?"":"s"," above"]}):null,m.map((f)=>Se(me,{wrap:"truncate",children:f.text},f.row)),c<n.length?fe(me,{dimColor:!0,wrap:"truncate",children:[" ",u.ellipsis," ",n.length-c," line",n.length-c===1?"":"s"," ","below"]}):null]})}import{Box as yt,Text as U}from"ink";import{jsx as pe,jsxs as Te}from"react/jsx-runtime";function un({editor:n,width:t,maxRows:r}){let i=n.search;if(i===void 0)return null;let s=Ut(n),a=Math.min(i.index,Math.max(0,s.length-1)),{from:c,to:m}=I(s.length,a,r),f=Math.max(8,t-4);return Te(yt,{flexDirection:"column",children:[s.length===0?Te(U,{color:o.muted,wrap:"truncate",children:[" ","nothing you have sent matches that"]}):s.slice(c,m).map((b,v)=>{let x=c+v===a;return Te(U,{wrap:"truncate",children:[pe(U,{color:o.accent,children:x?u.pointer:" "}),pe(U,{bold:x,dimColor:!x,children:S(b.replace(/\s+/g," "),f)})]},b)}),Te(U,{wrap:"truncate",children:[pe(U,{color:o.muted,children:" search: "}),i.query,pe(U,{inverse:!0,children:" "}),s.length>1?pe(U,{color:o.muted,children:` ${a+1} of ${s.length}`}):null]})]})}import{Box as St,Text as mn}from"ink";import{jsxs as Ie}from"react/jsx-runtime";function fn({live:n,showReasoning:t,columns:r}){let i=t&&n.reasoning!==""&&n.text==="",s=i?n.reasoning:n.text;if(s==="")return null;let a=i?"· reasoning · ":"",c=ir(s,r-[...a].length,lr),m=c.lines.map((f,b)=>({at:b,text:f}));return Ie(St,{flexDirection:"column",children:[c.hidden>0?Ie(mn,{dimColor:!0,wrap:"truncate",children:["… ",c.hidden," earlier row(s) hidden while streaming"]}):null,m.map((f)=>Ie(mn,{dimColor:i,wrap:"truncate",children:[f.at===0?a:"",f.text]},`row-${f.at}`))]})}import{Box as Tt,Text as Y}from"ink";import{jsx as De,jsxs as ae}from"react/jsx-runtime";function Rt(n){return n.matches.reduce((t,r)=>Math.max(t,r.word.length),0)}function pn({palette:n,index:t,width:r,maxRows:i}){if(n.matches.length===0)return ae(Y,{color:o.muted,wrap:"truncate",children:[" ","no command starts with /",n.query]});let s=Math.min(t,n.matches.length-1),{from:a,to:c}=I(n.matches.length,s,i),m=Rt(n),f=Math.max(8,r-(2+m+2));return ae(Tt,{flexDirection:"column",children:[a>0?ae(Y,{dimColor:!0,wrap:"truncate",children:[" ",u.ellipsis," ",a," above"]}):null,n.matches.slice(a,c).map((b,v)=>{let M=a+v===s;return ae(Y,{wrap:"truncate",children:[De(Y,{color:o.accent,children:M?u.pointer:" "}),De(Y,{bold:M,...M?{color:o.accent}:{},children:b.word.padEnd(m)})," ",De(Y,{dimColor:!0,children:S(b.summary,f)})]},b.word)}),c<n.matches.length?ae(Y,{dimColor:!0,wrap:"truncate",children:[" ",u.ellipsis," ",n.matches.length-c," below"]}):null,ae(Y,{dimColor:!0,wrap:"truncate",children:[" ","↑↓ move · tab complete · enter run · esc close"]})]})}import{Box as hn,Text as Pt}from"ink";import{jsx as xn,jsxs as gn}from"react/jsx-runtime";function yn({editor:n,busy:t,placeholder:r,columns:i}){let s=n.value.split(`
3
- `).length,a=Math.max(1,i-4);return gn(hn,{flexDirection:"column",children:[xn(hn,{borderStyle:oe,borderColor:t?o.border:o.borderActive,width:i,paddingX:1,children:xn(bn,{editor:n,gutter:An,maxRows:On,columns:a,...r===void 0?{}:{placeholder:r}})}),s>1?gn(Pt,{dimColor:!0,wrap:"truncate",children:[" ",yo]}):null]})}import{Text as ke}from"ink";import{jsx as Rn,jsxs as Tn}from"react/jsx-runtime";var Et={idle:"ready",thinking:"thinking",streaming:"replying",working:"running a tool",cancelling:"cancelling"};function Mt(n){return`${(n/1000).toFixed(1)}s`}function Sn(n,t){if(n!=="idle")return" · ^C cancels";return t?" · ^C again to leave":" · ^C twice to leave · /exit"}function vt(n){if(n!=="idle")return"";return" · ^O show reasoning"}var Ct=0.5,At=0.8;function Pn({status:n,model:t,sessionKey:r,elapsedMs:i,last:s,quiet:a,armed:c,pressure:m,phase:f}){return Tn(ke,{dimColor:!0,wrap:"truncate",children:[Tn(ke,{color:qo[n],children:[u.dot,Et[n]]}),n==="idle"?"":` ${Mt(i)}`,` · ${t} · ${r}`,f===void 0||a?"":` · ${f}`,m===void 0||m<Ct||a?"":Rn(ke,{...m>=At?{color:o.warning}:{},children:` · ctx ${Math.round(m*100)}%`}),s===void 0||a?"":` · last ${yr(s)}`,vt(n),c===!0?Rn(ke,{color:o.warning,children:Sn(n,!0)}):Sn(n,!1)]})}import{Box as Lt,Text as Re}from"ink";var z={offset:0,pinned:!0};function En(n,t){return Math.max(0,n-t)}function Mn(n,t,r){let i=En(t,r);return n.pinned?i:Math.max(0,Math.min(n.offset,i))}function vn(n,t,r,i){if(t==="bottom")return z;let s=En(r,i);if(s===0)return z;if(t==="top")return{offset:0,pinned:!1};let a=t==="pageUp"||t==="pageDown"?Math.max(1,i-1):1,c=t==="down"||t==="pageDown"?a:-a,m=Mn(n,r,i)+c;if(m>=s)return z;return{offset:Math.max(0,m),pinned:!1}}function Cn(n,t,r){if(r<=0)return{from:0,to:0,above:t,below:0};let i=Mn(n,t,r),s=Math.min(t,i+r);return{from:i,to:s,above:i,below:t-s}}function _n(n,t){return Math.max(as,n-t-1)}function $n(n){let t=[];if(n.above>0)t.push(`↑ ${n.above} row${n.above===1?"":"s"} above`);if(n.below>0)t.push(`↓ ${n.below} row${n.below===1?"":"s"} below`,"esc returns");return t.length===0?"":` ${t.join(" · ")}`}function Ln(n){return{anchor:n,focus:n,dragging:!0}}function He(n,t){if(!n.dragging)return n;return{...n,focus:t}}function Bn(n){return{...n,dragging:!1}}function In(n,t){return{...n,focus:t,dragging:!1}}function _t(n,t){return n.row<t.row||n.row===t.row&&n.column<=t.column}function Dn(n){if(n===void 0)return;let{anchor:t,focus:r}=n;if(t.row===r.row&&t.column===r.column)return;return _t(t,r)?{start:t,end:r}:{start:r,end:t}}function We(n,t,r){let i=Dn(n);if(i===void 0)return;if(t<i.start.row||t>i.end.row)return;let s=t===i.start.row?Math.min(i.start.column,r):0,a=t===i.end.row?Math.min(i.end.column,r):r;return a<=s?void 0:{from:s,to:a}}function Nn(n,t){let r=Dn(t);if(r===void 0)return"";let i=[];for(let s=r.start.row;s<=r.end.row;s+=1){let a=n[s];if(a===void 0)continue;let c=[...a.text],m=We(t,s,c.length),f=m===void 0?"":c.slice(Math.max(m.from,a.lead),m.to).join("");if(a.continuation&&i.length>0){i[i.length-1]+=f;continue}i.push(f)}return i.map((s)=>s.replace(/\s+$/,"")).join(`
4
- `)}function Ne(n){return n!==void 0&&!/\s/.test(n)}function Hn(n,t){let r=n[t.row];if(r===void 0)return{anchor:t,focus:t,dragging:!1};let i=[...r.text];if(!Ne(i[t.column]))return Fe(n,t);let{column:s,column:a}=t;while(s>r.lead&&Ne(i[s-1]))s-=1;while(a<i.length&&Ne(i[a]))a+=1;return{anchor:{row:t.row,column:s},focus:{row:t.row,column:a},dragging:!1}}function Fe(n,t){let r=n[t.row],i=r===void 0?0:[...r.text].length;return{anchor:{row:t.row,column:r?.lead??0},focus:{row:t.row,column:i},dragging:!1}}import{jsx as Ge,jsxs as Wn}from"react/jsx-runtime";function Fn({rows:n,slice:t,selection:r}){let i=n.slice(t.from,t.to),s=$n(t);return Wn(Lt,{flexDirection:"column",children:[Ge(Re,{color:o.muted,wrap:"truncate",children:s===""?" ":s}),i.map((a,c)=>{let m=a.dim===!0?o.muted:Go[a.role],f=[...a.text],b=We(r,t.from+c,f.length);if(b===void 0)return Ge(Re,{wrap:"truncate",bold:a.bold===!0,...m===void 0?{}:{color:m},children:a.text===""?" ":a.text},a.key);let v=Math.max(b.from,a.lead);return Wn(Re,{wrap:"truncate",bold:a.bold===!0,...m===void 0?{}:{color:m},children:[f.slice(0,v).join(""),Ge(Re,{backgroundColor:o.selection,children:f.slice(v,b.to).join("")}),f.slice(b.to).join("")]},a.key)})]})}import{useEffect as Ot,useState as Dt}from"react";var Nt=100;function Gn(n){let[t,r]=Dt(0);return Ot(()=>{if(!n){r(0);return}let i=Date.now();r(0);let s=setInterval(()=>r(Date.now()-i),Nt);return()=>clearInterval(s)},[n]),t}import{useCallback as Pe,useEffect as Ht,useReducer as Wt,useRef as Un}from"react";function Vn(n){let{source:t,sessionKey:r,initial:i}=n,[s,a]=Wt(vo,i),c=Un(void 0),m=Un(t.streamFilter());Ht(()=>t.subscribe((x)=>{if(x.sessionKey!==void 0&&x.sessionKey!==r)return;if(x.type==="model.chunk"){let{delta:O,kind:N}=x.data;if(N==="reasoning"){a({kind:"delta",of:"reasoning",text:O});return}a({kind:"delta",of:"text",text:m.current.push(O)});return}if(x.type==="model.result"){a({kind:"delta",of:"text",text:m.current.endStep()});return}if(x.type==="turn.end")a({kind:"delta",of:"text",text:m.current.end()}),m.current=t.streamFilter();a({kind:"event",event:x})}),[t,r]);let f=Pe((x)=>{a({kind:"user",text:x});let O=new AbortController;c.current=O,t.send(x,{sessionKey:r,signal:O.signal}).catch((N)=>{a({kind:"event",event:{v:1,ts:new Date().toISOString(),runtimeId:"cli",sessionKey:r,type:"error",data:{code:"cli_turn_failed",message:N instanceof Error?N.message:String(N),hint:"This escaped the turn loop's own error handling. Re-run with DEBUG=1 for a stack trace."}}})}).finally(()=>{if(c.current===O)c.current=void 0})},[t,r]),b=Pe(()=>{let x=c.current;if(x===void 0||x.signal.aborted)return;a({kind:"cancelling"}),x.abort()},[]),v=Pe((x)=>a({kind:"note",text:x}),[]),M=Pe(()=>a({kind:"trim"}),[]);return{state:s,busy:s.status!=="idle",send:f,cancel:b,note:v,trim:M}}var Xn=1,Kn=1,Ye=1,jn=2,Ue=4,Ve=2,Ft=14;function zn(n,t){let{rows:r,caretRow:i}=wn(n,Math.max(1,t-Ue-Ve)),s=r.length,{from:a,to:c}=I(s,i,Math.max(1,Math.min(s,On)));return jn+(c-a)+(a>0?1:0)+(s-c>0?1:0)+(n.value.includes(`
5
- `)?1:0)}function Gt(n,t){if(n===void 0)return 0;if(n.matches.length===0)return 1;let r=Math.min(n.matches.length,t),i=n.matches.length>r?1:0;return r+i+1}function Vt(n,t){if(n.search===void 0)return 0;let r=Ut(n);return(r.length===0?1:Math.min(r.length,t))+1}function Zn(n){let t=n.live,r=t===void 0?"":n.showReasoning&&t.reasoning!==""&&t.text===""?t.reasoning:t.text,i=Xn+Kn+ir(r,n.columns-Ft,lr).rows+Gt(n.palette,n.paletteMaxRows)+Vt(n.editor,n.searchMaxRows)+zn(n.editor,n.columns)+(n.confirming?1:0)+(n.hint?1:0),s=_n(n.rows,i);return{brand:n.landing?Math.max(0,s-ds-dr):0,body:s,transcript:Math.max(1,s-Ye),pane:Math.max(1,s-3)}}function Jn(n,t){let r=(t.brandLines===0?0:t.brandLines+dr)+Xn+Ye,i=n.row-r;if(i<0)return;let s=t.from+i;if(s>=t.to)return;return{row:s,column:n.column}}function Qn(n,t){let r=wn(t.editor,Math.max(1,t.columns-Ue-Ve)),i=r.rows.length,{from:s,to:a}=I(i,r.caretRow,Math.max(1,Math.min(i,On))),c=s>0?1:0,m=zn(t.editor,t.columns),b=t.rows-Kn-(t.hint?1:0)-m+jn/2+c,v=n.row-b;if(v<0||v>=a-s)return;let M=r.rows[s+v];if(M===void 0)return;let x=n.column-Ue/2-Ve;if(x<0)return M.start;return Math.min(M.end,M.start+Math.max(0,x-M.lead))}function qn(n,t){let r=t===0?0:t+dr;return Math.max(1,n.body-r-Ye)}var Yt=[{command:"pbcopy",args:[]},{command:"wl-copy",args:[]},{command:"xclip",args:["-selection","clipboard"]},{command:"xsel",args:["--clipboard","--input"]}];async function Xe(n){if(n==="")return{copied:!1,problem:"nothing selected"};let t=[];for(let r of Yt){let i=await ge({command:r.command,args:r.args,input:n,timeoutMs:2000});if(i.notFound){t.push(r.command);continue}if(i.code===0)return{copied:!0,using:r.command};return{copied:!1,using:r.command,problem:i.stderr.trim()||`${r.command} exited ${i.code}`}}return{copied:!1,problem:`no clipboard command found (tried ${t.join(", ")})`}}function Ee(){let n=Yn.map((i)=>({word:i.word,summary:i.summary,kind:"session"})),t=new Set(n.map((i)=>i.word)),r=le.filter((i)=>i.inSession!=="hidden").filter((i)=>!t.has(`/${i.name}`)).map((i)=>({word:`/${i.name}`,summary:i.summary,kind:i.inSession==="view"?"view":"output",spec:i}));return[...n,...r]}function et(n,t=Ee()){if(!/^\/[A-Za-z-]*$/.test(n))return;let r=n.slice(1).toLowerCase(),i=t.filter((s)=>s.word.slice(1).toLowerCase().startsWith(r));return{query:r,matches:i}}function Ke(n,t){if(n.matches.length===0)return;return n.matches[Math.max(0,Math.min(t,n.matches.length-1))]}function nt(){return Ee().filter((n)=>n.kind!=="session").map((n)=>n.word.slice(1))}function Xt(n){return It(n)?.args.findIndex((t)=>t.name==="manifest")??-1}function Kt(n){let t=n.rest.trim()===""?[]:n.rest.trim().split(/\s+/),r=Xt(n.name),i=r===-1||t.length<r?t:[...t.slice(0,r),n.manifestPath,...t.slice(r)];return[n.name,...i,"--plain"]}function zt(n){let t=It(n.name);if(t===void 0)return;let r=t.flags.find((a)=>a.name==="follow");if(r===void 0)return;if(!n.rest.trim().split(/\s+/).some((a)=>a==="--follow"||r.short!==void 0&&a===`-${r.short}`))return;return`--follow keeps printing until it is interrupted, and a pane has nothing to interrupt it with. Run it in its own terminal: ${n.name} ${n.rest.trim()}`}async function tt(n){let t=zt(n);if(t!==void 0)return{lines:[t],code:1};let r=n.interpreter??process.execPath,i=n.script??process.argv[1]??"",s=await ge({command:r,args:[i,...Kt(n)],...n.env===void 0?{}:{env:n.env},timeoutMs:n.timeoutMs??30000}),a=[s.stdout,s.stderr].filter((m)=>m.trim()!=="").join(`
6
- `),c=a===""?[]:a.replace(/\n+$/,"").split(`
7
- `);if(s.notFound)return{lines:[`could not run ${r}`],code:1};if(s.signalled)return{lines:[...c,`${n.name} was stopped before it finished`],code:1};return{lines:c,code:s.code}}import{jsx as w,jsxs as J,Fragment as Qt}from"react/jsx-runtime";function Qr({source:n,sessionKey:t,model:r,agentName:i,warnings:s,freshSession:a,initial:c,correctKeys:m,showReasoning:f,quiet:b,onRestart:v,onSwitch:M,onNew:x,sessions:O,initialDraft:N,manifestPath:F,catalogue:ce,status:je,contextView:ze}){let{exit:Q}=Zt(),ee=re(),P=q(ee.columns,j),{state:C,busy:he,send:ct,cancel:ut,note:g,trim:Ze}=Vn({source:n,sessionKey:t,initial:c}),[L,H]=B(()=>N===void 0||N===""?D:{...D,value:N,cursor:[...N].length}),[k,_]=B({kind:"none"}),[Je,mt]=B(void 0),[Qe,ft]=B(void 0),[qe,pt]=B(void 0),[xe,Me]=B(z),[ue,ve]=B(!1),[Ce,en]=B(!1),[nn,ht]=B(!1),[ne,X]=B(void 0),Ae=Jt(void 0),G=k.kind==="none"?et(L.value):void 0,[_e,we]=B(0),xt=Gn(he),gt=st(()=>xo(C.items),[C.items]),te=st(()=>Eo(C.items,{showReasoning:f,quiet:b,columns:P,expandReasoning:nn}),[C.items,f,b,P,nn]),ie=a===!0&&!C.items.some((h)=>h.role==="user"),be=ie?ls:rs,se=Zn({rows:ee.rows,columns:P,editor:L,live:C.live,showReasoning:f,palette:G,paletteMaxRows:be,searchMaxRows:be,confirming:Ce,landing:ie,hint:ie}),ye=se.brand>0?ln(e.name,{columns:P-dt,rows:se.brand}):void 0,$e=Cn(xe,te.length,qn(se,ye?.lines.length??0));it(()=>{if(!xe.pinned)return;X(void 0),Ze()},[xe.pinned,C.items.length,Ze]),it(()=>{if(!ue)return;let h=setTimeout(()=>ve(!1),fs);return()=>clearTimeout(h)},[ue]);let tn=(h,y)=>{let p=on(h,nt());if(p!==void 0)switch(p.kind){case"exit":en(!0);return;case"restart":{let d=n.reload;if(d===void 0){v?.(y),Q();return}g("asking the host to reload this agent…"),d().then((l)=>g(`reloaded ${l.join(", ")} — this conversation continues`)).catch((l)=>g(`could not reload: ${l instanceof Error?l.message:String(l)}`));return}case"new":x?.(y),Q();return;case"help":g(sn());return;case"tools":n.tools().then((d)=>g(lt(d))).catch((d)=>g(`could not read the tools: ${d instanceof Error?d.message:String(d)}`));return;case"context":if(ze===void 0){g("context is unavailable in this session");return}ze().then(g).catch((d)=>g(`could not read the context: ${d instanceof Error?d.message:String(d)}`));return;case"status":if(je===void 0){g("status is unavailable in this session");return}je().then(g).catch((d)=>g(`could not read the status: ${d instanceof Error?d.message:String(d)}`));return;case"reset":n.clearSession(t).then(()=>g("session cleared — memory files on disk are untouched")).catch((d)=>g(`could not clear the session: ${d instanceof Error?d.message:String(d)}`));return;case"command":if(dn(`/${p.name}`,p.rest))return;g($t({word:`/${p.name}`}));return;case"unknown":g($t(p));return}if(he){g("a turn is still running — ^C cancels it, then send again");return}ct(h)},Le=rt((h,y)=>{_({kind:"output",label:`/${h}`,lines:void 0,offset:0}),tt({name:h,rest:y,manifestPath:F??""}).then((p)=>_({kind:"output",label:`/${h}`,lines:p.lines,code:p.code,offset:0})).catch((p)=>_({kind:"output",label:`/${h}`,lines:[p instanceof Error?p.message:String(p)],code:1,offset:0}))},[F]),dn=rt((h,y)=>{let p=Ee().find((d)=>d.word===h);if(p===void 0)return!1;if(p.kind==="view"){if(p.word==="/sessions"&&O!==void 0&&M!==void 0)return _({kind:"sessions",stored:void 0}),import("./SessionPicker-zyqkg4dn.js").then((d)=>pt(()=>d.SessionPicker)),O().then((d)=>_({kind:"sessions",stored:d})).catch((d)=>{_({kind:"none"}),g(`could not read the stored conversations: ${d instanceof Error?d.message:String(d)}`)}),!0;if(p.word==="/config"&&(y.trim()===""||y.trim()==="edit")){if(F===void 0)return g("this session has no manifest path, so there is nothing to edit"),!0;return _({kind:"config",rows:at(F)}),import("./ConfigEditor-n8hdw6r7.js").then((d)=>ft(()=>d.ConfigEditor)),!0}if(p.word==="/skills"&&ce!==void 0)return _({kind:"skills"}),import("./SkillBrowser-3qdp8080.js").then((d)=>mt(()=>d.SkillBrowser)),!0;return Le(p.word.slice(1),y),!0}if(p.kind==="output")return Le(p.word.slice(1),y),!0;return!1},[Le,ce,O,M,g,F]);if(ot((h,y)=>{if(k.kind!=="output")return;if(y.escape||h==="q"){_({kind:"none"});return}let p=k.lines?.length??0,d=y.pageDown||y.pageUp?se.pane:1,l=y.downArrow||y.pageDown?d:y.upArrow||y.pageUp?-d:0;if(l!==0)_({...k,offset:Math.max(0,Math.min(k.offset+l,Math.max(0,p-1)))})},{isActive:k.kind==="output"}),ot((h,y)=>{let p=m===void 0?y:m(y,h);if(Ce){if(en(!1),h.toLowerCase()==="y"||p.return)Q();return}if(G!==void 0){if(p.escape){H((E)=>V(E,{kind:"killToStart"})),we(0);return}if(p.upArrow||p.downArrow){we((E)=>Math.max(0,Math.min(E+(p.downArrow?1:-1),G.matches.length-1)));return}if(p.tab){let E=Ke(G,_e);if(E!==void 0)H((A)=>V({...A,value:"",cursor:0},{kind:"insert",text:E.word}));return}let l=Ke(G,_e);if(p.return&&l!==void 0){let E=l;if(we(0),H((A)=>({...A,value:"",cursor:0})),E.kind==="session")tn(E.word,"");else dn(E.word,"");return}}let d=jt(h,p,kn(L,he,{armed:ue,scrolled:!xe.pinned}));if(ue&&d.kind!=="exit")ve(!1);if(d.kind==="arm"){ve(!0);return}if(d.kind==="scroll"){let l=Math.max(1,d.times??1);Me((E)=>{let A=E;for(let T=0;T<l;T+=1)A=vn(A,d.move,te.length,se.transcript);return A});return}if(d.kind==="pointer"){let l=Jn({column:d.column,row:d.row},{brandLines:ye?.lines.length??0,from:$e.from,to:$e.to});if(l===void 0){let T=Qn({column:d.column,row:d.row},{editor:L,columns:P,rows:ee.rows,hint:ie});if(T===void 0){if(d.gesture==="press")X(void 0),H((K)=>({...K,anchor:void 0}));return}X(void 0),H((K)=>d.gesture==="press"&&!d.shift?{...K,cursor:T,anchor:T}:{...K,cursor:T,anchor:K.anchor??K.cursor});return}if(d.gesture==="press"){if(d.shift&&ne!==void 0){X(In(ne,l)),Ae.current=void 0;return}let T=Ae.current,Be=T!==void 0&&Date.now()-T.when<=cs&&T.at.row===l.row&&T.at.column===l.column?T.clicks%3+1:1;Ae.current={at:l,when:Date.now(),clicks:Be},H((bt)=>({...bt,anchor:void 0})),X(Be===3?Fe(te,l):Be===2?Hn(te,l):Ln(l));return}if(d.gesture==="drag"){X((T)=>T===void 0?void 0:He(T,l));return}let E=ne===void 0?void 0:Bn(He(ne,l));X(E);let A=Nn(te,E);if(A!=="")Xe(A).then((T)=>{if(!T.copied&&T.problem!=="nothing selected")g(`could not copy: ${T.problem??"unknown"}`)});return}if(d.kind==="copySelection"||d.kind==="cutSelection"){let l=kt(L);if(l===void 0){g("nothing selected — hold shift with a motion, or drag in the box");return}let E=[...L.value].slice(l.start,l.end).join("");if(d.kind==="cutSelection")H((A)=>V(A,d));Xe(E).then((A)=>{if(!A.copied)g(`could not copy: ${A.problem??"unknown"}`)});return}if(d.kind==="reasoning"){if(!f){g("reasoning is off: either this model does not stream it, or --no-reasoning is set");return}if(!C.items.some((l)=>l.role==="reasoning")){g("no reasoning to show yet — this expands it once a turn has streamed some");return}ht((l)=>!l),Me(z);return}if(d.kind==="exit"){Q();return}if(d.kind==="cancel"){ut();return}if(d.kind==="submit"){let l=Uo(L);if(H(l.state),Me(z),l.text!=="")tn(l.text,l.state.value);return}if(d.kind==="paste"){H((l)=>V(l,{kind:"insert",text:d.lines.join(`
8
- `)}));return}if(G!==void 0)we(0);H((l)=>V(l,d))},{isActive:k.kind==="none"}),k.kind==="config")return J(W,{flexDirection:"column",width:P,height:ee.rows,children:[w(Z,{color:o.accent,bold:!0,wrap:"truncate",children:rr({title:`${e.name} ${R}`,summary:"settings"},P)}),Qe===void 0?w(W,{marginLeft:2,children:w(de,{label:"reading the settings"})}):w(Qe,{rows:k.rows,apply:(h,y)=>rn(F??"",h,y),reload:()=>at(F??""),columns:P,window:Bt,onDone:(h)=>{if(_({kind:"none"}),h)v?.(L.value),Q()}}),w(W,{flexGrow:1})]});if(k.kind==="sessions")return J(W,{flexDirection:"column",width:P,height:ee.rows,children:[w(Z,{color:o.accent,bold:!0,wrap:"truncate",children:rr({title:`${e.name} ${R}`,summary:"pick a conversation"},P)}),w(W,{flexGrow:1}),k.stored===void 0||qe===void 0?w(W,{marginLeft:2,children:w(de,{label:"reading the stored conversations"})}):w(qe,{sessions:k.stored,now:Date.now(),columns:P,maxRows:Bt,current:t,onDone:(h)=>{if(h===void 0||h===t){_({kind:"none"});return}M?.(h,L.value),Q()}}),w(W,{flexGrow:1})]});if(k.kind==="skills"&&ce!==void 0&&Je!==void 0)return w(Je,{title:`${e.name} ${R}`,agents:[],target:F??"",load:ce.load,install:ce.install,onDone:()=>_({kind:"none"})});let wt=rr({title:`${e.name} ${R}`,summary:"",agent:{name:i,model:r},...s===void 0||s.length===0?{}:{warnings:s}},P);return J(W,{flexDirection:"column",width:P,height:ee.rows,children:[ye===void 0?null:J(Qt,{children:[w(an,{lines:ye.lines}),w(Z,{children:" "})]}),w(Z,{color:o.accent,bold:!0,wrap:"truncate",children:wt}),k.kind==="output"?J(W,{flexDirection:"column",children:[w(cn,{lines:k.lines,label:k.label,offset:k.offset,maxRows:se.pane,...k.code===void 0?{}:{code:k.code}}),J(Z,{dimColor:!0,wrap:"truncate",children:[" ","↑↓ scroll · esc back to the prompt"]})]}):w(Fn,{rows:te,slice:$e,...ne===void 0?{}:{selection:ne}}),w(W,{flexGrow:1}),C.live===void 0?null:w(fn,{live:C.live,showReasoning:f,columns:P}),G===void 0?null:w(pn,{palette:G,index:_e,width:P,maxRows:be}),w(un,{editor:L,width:P,maxRows:be}),Ce?w(Z,{color:o.warning,wrap:"truncate",children:" leave this session? press y to confirm · any other key stays"}):null,w(yn,{editor:L,busy:he,columns:P,...ie?{placeholder:"Ask anything…"}:{}}),ie?J(Z,{dimColor:!0,wrap:"truncate",children:[" ",wo]}):null,w(Pn,{status:C.status,model:r,sessionKey:t,elapsedMs:xt,last:gt,quiet:b,armed:ue,...C.pressure===void 0?{}:{pressure:C.pressure},...C.phase===void 0?{}:{phase:C.phase}})]})}export{Qr as App};
9
-
10
- //# debugId=EDBCE5697F239D7E64756E2164756E21
11
- //# sourceMappingURL=App-b1yrwrcq.js.map
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env node
2
- import"./index-cqqb6gaq.js";import{o,S,I}from"./index-d4x6yvqh.js";import"./index-02dn6m2j.js";import{nn}from"./index-6q4wf8e3.js";import{re}from"./index-0d93hyfc.js";import{D,V,Sn}from"./index-j55s3ehk.js";import{Ge,Ve,Nn}from"./index-vgc3y3rm.js";import{Box as H,Text as d,useInput as Y}from"ink";import{useState as z}from"react";function E(e){return e!==void 0&&e.kind!=="heading"}function k(e){switch(e.kind){case"setting":return`setting:${e.setting.path}`;case"allow":return`allow:${e.channelId}`;case"secret":return`secret:${e.name}`;case"heading":return`heading:${e.label}`}}function L(e){let t=e.findIndex((r)=>E(r));return t===-1?0:t}function T(e){return{rows:e,cursor:L(e),mode:"browse",editor:D,busy:!1}}function M(e,t){let r=e.rows.length;if(r===0)return e;let l=Math.max(0,Math.min(r-1,t)),h=l>=e.cursor?1:-1;for(let i=l;i>=0&&i<r;i+=h)if(E(e.rows[i]))return{...e,cursor:i};for(let i=l;i>=0&&i<r;i-=h)if(E(e.rows[i]))return{...e,cursor:i};return e}function w(e){return e.rows[e.cursor]}function G(e){switch(e.kind){case"setting":return e.value===void 0||e.value===null?"":typeof e.value==="string"?e.value:JSON.stringify(e.value);case"allow":return e.handles.join(" ");case"secret":case"heading":return""}}function O(e){let t=w(e);if(t===void 0||!E(t)||e.busy)return e;let r=G(t);return{...e,mode:"editing",editor:{...D,value:r,cursor:[...r].length},note:void 0}}function _(e){if(e.mode!=="editing")return e;return{...e,mode:"browse",editor:D,note:void 0}}function W(e,t){return{...e,editor:t,note:void 0}}function F(e){return{...e,busy:!0}}function N(e,t,r){return{...e,rows:t,cursor:Math.min(e.cursor,Math.max(0,t.length-1)),mode:"browse",editor:D,busy:!1,note:r}}function P(e,t){return{...e,busy:!1,note:t}}import{jsx as a,jsxs as x}from"react/jsx-runtime";function ge({rows:e,apply:t,reload:r,columns:l,window:m,focused:h=!0,onDone:i}){let K=re(),v=Math.max(Ge,Math.min(m,K.rows-Ve)),[n,u]=z(()=>T(e)),[C,j]=z(!1),g=w(n);Y((f,c)=>{if(n.busy)return;let s=Sn(f,c,{select:n.mode==="browse",empty:n.editor.value===""});if(s.kind==="abort"){i(C);return}if(s.kind==="back"){if(n.mode==="editing")u(_);else i(C);return}if(s.kind==="list"){if(s.intent.kind==="move"){let y=s.intent.move;u((R)=>M(R,Q(y,R)))}return}if(s.kind==="commit"){if(n.mode==="browse"){u(O);return}J();return}u((y)=>W(y,V(y.editor,s.intent)))},{isActive:h});async function J(){let f=w(n);if(f===void 0)return;u(F);try{let c=await t(f,n.editor.value);j(!0),u((s)=>N(s,r(),c))}catch(c){u((s)=>P(s,c instanceof Error?c.message:String(c)))}}if(n.mode==="editing"&&g!==void 0)return x(H,{flexDirection:"column",children:[a(d,{color:o.muted,wrap:"truncate",children:` ${Z(g)}`}),a(nn,{label:A(g),editor:n.editor,secret:g.kind==="secret",columns:l,maxRows:Math.max(Nn,v-2),...n.note===void 0?{}:{error:n.note}}),a(d,{dimColor:!0,wrap:"truncate",children:n.busy?" writing…":` enter writes it · ${U(g)} · ^C closes`})]});let{from:p,to:b}=I(n.rows.length,n.cursor,v);return x(H,{flexDirection:"column",children:[p>0?a(d,{dimColor:!0,wrap:"truncate",children:` ↑ ${p} above`}):void 0,n.rows.slice(p,b).map((f,c)=>a(q,{row:f,selected:p+c===n.cursor,columns:l},k(f))),b<n.rows.length?a(d,{dimColor:!0,wrap:"truncate",children:` ↓ ${n.rows.length-b} below`}):void 0,a(d,{color:n.note===void 0?o.muted:o.accent,wrap:"truncate",children:n.note===void 0?" ↑↓ move · enter changes it · esc closes":` ${n.note}`})]})}function q({row:e,selected:t,columns:r}){if(e.kind==="heading")return a(d,{color:o.muted,wrap:"truncate",children:`
3
- ${e.label}`});let l=S(A(e),Math.min(34,Math.max(12,Math.floor(r*0.34)))),m=S(B(e),Math.max(8,r-l.length-8));return x(d,{wrap:"truncate",children:[t?a(d,{color:o.accent,children:" ❯ "}):a(d,{children:" "}),a(d,{children:l.padEnd(Math.min(34,Math.max(12,Math.floor(r*0.34))))}),a(d,{color:o.muted,children:` ${m}`})]})}function Q(e,t){switch(e.kind){case"up":return t.cursor-1;case"down":return t.cursor+1;case"first":return 0;case"last":return t.rows.length-1;case"jump":return e.index}}function A(e){switch(e.kind){case"setting":return e.setting.path;case"allow":return`${e.channelId}.allowFrom`;case"secret":return e.name;case"heading":return e.label}}function B(e){switch(e.kind){case"setting":return e.value===void 0||e.value===null?"(not set)":typeof e.value==="string"?e.value:JSON.stringify(e.value);case"allow":return e.handles.length===0?"(nobody)":e.handles.join(" ");case"secret":return e.present?"(set)":"(not set)";case"heading":return""}}function U(e){let t=B(e);return t.length<=X?`esc keeps ${t}`:"esc cancels"}var X=24;function Z(e){switch(e.kind){case"setting":return e.setting.means;case"allow":return"handles this channel accepts messages from, separated by spaces. Empty refuses everyone";case"secret":return e.why;case"heading":return e.label}}export{ge as ConfigEditor};
4
-
5
- //# debugId=6ECE33C1BB078EEF64756E2164756E21
6
- //# sourceMappingURL=ConfigEditor-n8hdw6r7.js.map
@@ -1,5 +0,0 @@
1
- #!/usr/bin/env node
2
- import{o,Tn}from"./index-d4x6yvqh.js";import{D,kn,jt}from"./index-j55s3ehk.js";import{Box as x,Text as a,useInput as I}from"ink";import{useState as k}from"react";function P(e){return[...new TextEncoder().encode(e)].map((t)=>t.toString(16).padStart(2,"0")).join(" ")}function E(e){let t=[];if(e.ctrl)t.push("ctrl");if(e.meta)t.push("meta");if(e.super)t.push("super");if(e.shift)t.push("shift");for(let[r,s]of[["up",e.upArrow],["down",e.downArrow],["left",e.leftArrow],["right",e.rightArrow],["pageUp",e.pageUp],["pageDown",e.pageDown],["home",e.home],["end",e.end],["return",e.return],["escape",e.escape],["tab",e.tab],["backspace",e.backspace],["delete",e.delete]])if(s)t.push(r);if(e.eventType!==void 0&&e.eventType!=="press")t.push(e.eventType);return t.length===0?"—":t.join(" ")}function R(e){return e.super||e.eventType!==void 0}function y(e,t){if(!t)return"not requested — the override is set, so cmd chords cannot arrive";if(e.some((r)=>R(r.key)))return"active — a keystroke carried a modifier only the protocol can express";return"requested; nothing pressed yet has proved it — try cmd+left, or option+r"}function m(e){let t=[...e.bytes].map((r)=>{let s=r.codePointAt(0)??0;return s<32||s===127?".":r}).join("");return[`bytes ${P(e.bytes)}${t===""?"":` ${t}`}`,`ink ${E(e.key)}${e.input===""?"":` input ${JSON.stringify(e.input)}`}`,`intent ${e.intent.kind}`]}import{jsx as i,jsxs as d}from"react/jsx-runtime";var A=6,h=0;function H({columns:e,asked:t,terminal:r,takeRaw:s,correctKeys:u,onDone:g}){let[l,b]=k([]);return I((n,c)=>{let w=s?.(),f=c,p=u===void 0?f:u(f,n);if(n==="q"&&!p.ctrl&&!p.meta&&!p.super){g();return}let T=jt(n,p,kn(D,!1));h+=1;let K=h,S=w??n;b((v)=>[...v,{at:K,bytes:S,input:n,key:p,intent:T}].slice(-A))}),d(x,{flexDirection:"column",children:[d(a,{color:o.accent,bold:!0,wrap:"truncate",children:["key probe · ",r]}),d(a,{color:o.muted,wrap:"truncate",children:["protocol ",y(l,t)]}),i(a,{children:" "}),l.length===0?i(a,{color:o.muted,wrap:"truncate",children:"press any chord — the bytes, Ink's reading of them, and the resolved intent"}):null,l.map((n)=>d(x,{flexDirection:"column",children:[i(a,{color:o.border,wrap:"truncate",children:Tn("",e)}),m(n).map((c)=>i(a,{wrap:"truncate",children:c},c))]},`stroke-${n.at}`)),i(a,{children:" "}),i(a,{dimColor:!0,wrap:"truncate",children:" q leaves · every other key is recorded, ^C included"})]})}export{H as KeyProbe};
3
-
4
- //# debugId=811A621DD931485C64756E2164756E21
5
- //# sourceMappingURL=KeyProbe-9jjeze5r.js.map
@@ -1,5 +0,0 @@
1
- #!/usr/bin/env node
2
- import{u}from"./index-d4x6yvqh.js";import{it}from"./index-4z7axw4r.js";import{ae,W}from"./index-gz9x25tz.js";import{be}from"./index-j55s3ehk.js";import{Box as l,useApp as k,useInput as x}from"ink";import{useCallback as b,useState as y}from"react";import{jsx as r,jsxs as P}from"react/jsx-runtime";function I({title:m,agents:n,onDone:i}){let{exit:o}=k(),[s,d]=y({index:0,count:n.length+1}),a=b((e)=>{i(e),o()},[i,o]);x((e,f)=>{let c=be(e,f);switch(c.kind){case"move":d((t)=>W(t,c.move));return;case"choose":{let t=n[s.index];a(t===void 0?{kind:"create"}:{kind:"run",manifestPath:t.manifestPath});return}case"back":case"exit":a({kind:"quit"});return;case"none":return}});let p=[...n.map((e)=>({label:e.name??e.ref,hint:e.problem!==void 0?`⚠ ${e.problem}`:`${e.modelId??"?"} ${u.bullet}${e.ref}`})),{label:`${u.create}create a new agent`}];return P(l,{flexDirection:"column",children:[r(it,{title:m,lines:["pick an agent · enter runs it · esc quits"]}),r(l,{marginTop:1,children:r(ae,{items:p,index:s.index,numbered:!0})})]})}export{I as Picker};
3
-
4
- //# debugId=0CA88FD304F39B3D64756E2164756E21
5
- //# sourceMappingURL=Picker-hfeh1g6m.js.map
@@ -1,5 +0,0 @@
1
- #!/usr/bin/env node
2
- import{o,S}from"./index-d4x6yvqh.js";import{ae,W}from"./index-gz9x25tz.js";import{uo}from"./index-4cf6v9nb.js";import{qe}from"./index-j7gyr5nx.js";import{be}from"./index-j55s3ehk.js";import{Box as f,Text as u,useInput as v}from"ink";import{useState as w}from"react";var k=14,R=28;function p(r,i){let m=r.reduce((e,n)=>Math.max(e,n.sessionKey.length),0),t=Math.max(k,Math.min(R,m)),l=Math.max(12,i.columns-(2+t+2));return r.map((e)=>{let n=[`${e.messages} message${e.messages===1?"":"s"}`,`${e.turns} turn${e.turns===1?"":"s"}`,qe(e.lastActivityAt,i.now)];if(e.phase!==void 0&&e.phase!=="")n.push(e.phase);if(!uo(e.sessionKey))n.push("named");return{key:e.sessionKey,label:S(e.sessionKey,t).padEnd(t),hint:S(n.join(" · "),l)}})}import{jsx as c,jsxs as h}from"react/jsx-runtime";function Y({sessions:r,now:i,columns:m,maxRows:t,current:l,focused:e=!0,onDone:n}){let a=p(r,{now:i,columns:m}),[d,x]=w({index:0,count:a.length});if(v((s,g)=>{let y=be(s,g);switch(y.kind){case"move":x((b)=>W(b,y.move));return;case"choose":n(a[d.index]?.key);return;case"back":case"exit":n(void 0);return;case"none":return}},{isActive:e}),a.length===0)return h(f,{flexDirection:"column",children:[c(u,{color:o.muted,wrap:"truncate",children:" no stored conversations with this agent yet"}),c(u,{dimColor:!0,wrap:"truncate",children:" esc starts a new one"})]});return h(f,{flexDirection:"column",children:[c(ae,{items:a.map((s)=>({label:s.label,hint:s.key===l?`${s.hint} · in use`:s.hint})),index:d.index,numbered:!0,maxRows:t}),c(u,{dimColor:!0,wrap:"truncate",children:" ↑↓ move · enter opens it · esc keeps the one you are in"})]})}export{Y as SessionPicker};
3
-
4
- //# debugId=22195B969752BBDF64756E2164756E21
5
- //# sourceMappingURL=SessionPicker-zyqkg4dn.js.map
@@ -1,5 +0,0 @@
1
- #!/usr/bin/env node
2
- import{o,u,oe}from"./index-d4x6yvqh.js";import{Qt,ot,en}from"./index-fex44816.js";import{re}from"./index-0d93hyfc.js";import{ae,W}from"./index-gz9x25tz.js";import{de}from"./index-v8e92nfw.js";import{st,tn}from"./index-gme2egyq.js";import{Po,Mo,Lo}from"./index-h9mw7b9d.js";import{zt,be}from"./index-j55s3ehk.js";import{Rn,In,Ge,Ze,Ve}from"./index-vgc3y3rm.js";import{Box as p,Text as f,useInput as X}from"ink";import{useCallback as Y,useEffect as K,useState as L}from"react";import{Box as E,Text as R}from"ink";import{jsx as w,jsxs as H}from"react/jsx-runtime";var D={ok:o.success,warn:o.warning,off:o.muted},B={title:{color:o.accent,bold:!0},summary:{dim:!0},state:{},warning:{color:o.warning}};function U(e){return Math.max(Rn,Math.min(In,e))}function g({header:e,footer:l,children:s}){let x=re(),T=U(x.columns),k=T-4,v=Po(e,k),C=e.state??[];return H(E,{flexDirection:"column",width:T,children:[w(E,{flexDirection:"column",borderStyle:oe,borderColor:o.borderActive,paddingX:1,children:v.map((d)=>d.kind==="state"?w(R,{wrap:"truncate",children:C.map((n,c)=>H(R,{color:D[n.tone],children:[c===0?"":" · ",n.label]},n.label))},d.text):w(R,{wrap:"truncate",bold:B[d.kind].bold===!0,dimColor:B[d.kind].dim===!0,...B[d.kind].color===void 0?{}:{color:B[d.kind].color},children:d.text},d.text))}),w(E,{flexDirection:"column",marginTop:1,children:s}),l===void 0||l.length===0?null:w(E,{marginTop:1,children:H(R,{dimColor:!0,wrap:"truncate",children:[" ",Mo(l,k)]})})]})}import{jsx as t,jsxs as S}from"react/jsx-runtime";function Se({load:e,install:l,agents:s,target:x,focused:T=!0,onDone:k,title:v}){let C=re(),d=Math.max(Ge,Math.min(Ze,C.rows-Ve)),[n,c]=L({kind:"fetching",status:"reading the catalogue"}),[b,O]=L([]),[y,M]=L({cursor:{index:0,count:0},chosen:[]}),[_,A]=L({index:0,count:s.length});K(()=>{let r=!0;return e((i)=>{if(r)c((a)=>a.kind==="fetching"?{...a,status:i}:a)}).then((i)=>{if(!r)return;O(i);let a=st(i);M({cursor:{index:en(a),count:i.length},chosen:[]}),c(i.length===0?{kind:"empty"}:{kind:"picking"})}).catch((i)=>{if(!r)return;c({kind:"failed",message:i instanceof Error?i.message:String(i)})}),()=>{r=!1}},[e]);let P=st(b),I=Y((r)=>{let i=tn(b,y.chosen);c({kind:"installing",count:i.length}),l(i,r).then((a)=>c({kind:"done",report:a})).catch((a)=>c({kind:"failed",message:a instanceof Error?a.message:String(a)}))},[b,y.chosen,l]);X((r,i)=>{if(n.kind==="done"){k(n.report);return}if(n.kind==="failed"||n.kind==="empty"){k(void 0);return}if(n.kind==="fetching"||n.kind==="installing"){if(zt(r,i).kind==="cancel")k(void 0);return}if(n.kind==="picking"){let m=zt(r,i);switch(m.kind){case"move":case"toggle":case"all":M((N)=>ot(N,m.kind==="move"?{kind:"move",move:m.move}:{kind:m.kind},P));return;case"none-selected":M((N)=>ot(N,{kind:"none"},P));return;case"confirm":if(y.chosen.length===0)return;if(x!==void 0)return I(x);if(s.length===1)return I(s[0]?.manifestPath??"");c({kind:"agent"});return;case"cancel":k(void 0);return;case"none":return}}let a=be(r,i);switch(a.kind){case"move":A((m)=>W(m,a.move));return;case"choose":{let m=s[_.index];if(m!==void 0)I(m.manifestPath);return}case"back":c({kind:"picking"});return;case"exit":k(void 0);return;case"none":return}},{isActive:T});let z=y.chosen.length,h={title:v,summary:F(n,b.length,z)};if(n.kind==="fetching")return S(g,{header:h,footer:[{key:"esc",does:"stop waiting"}],children:[t(p,{marginLeft:2,children:t(de,{label:n.status})}),t(p,{marginLeft:2,marginTop:1,children:t(f,{dimColor:!0,children:"once per machine, shared by every agent on it"})})]});if(n.kind==="failed")return t(g,{header:h,footer:[{key:"any key",does:"back"}],children:t(p,{marginLeft:2,children:S(f,{color:o.error,children:[u.error,n.message]})})});if(n.kind==="empty")return t(g,{header:h,footer:[{key:"any key",does:"back"}],children:S(p,{marginLeft:2,flexDirection:"column",children:[t(f,{color:o.muted,children:"no catalogue could be read"}),t(f,{dimColor:!0,children:"`sources update` reports why"})]})});if(n.kind==="installing")return t(g,{header:h,children:t(p,{marginLeft:2,children:t(de,{label:`installing ${n.count} skill${n.count===1?"":"s"}`})})});if(n.kind==="done")return t(g,{header:h,footer:[{key:"any key",does:"back"}],children:t(G,{report:n.report})});if(n.kind==="agent")return t(g,{header:h,footer:[{key:"↑↓",does:"move"},{key:"enter",does:"install"},{key:"esc",does:"back"}],children:t(ae,{items:s.map((r)=>({label:r.name??r.ref,hint:r.problem===void 0?`${r.modelId??"?"} ${u.bullet}${r.ref}`:`⚠ ${r.problem}`})),index:_.index,numbered:!0})});return t(g,{header:h,footer:[{key:"↑↓",does:"move"},{key:"space",does:"tick"},{key:"a/n",does:"all/none"},{key:"enter",does:x===void 0?"continue":"install"},Lo],children:t(Qt,{rows:b,index:y.cursor.index,chosen:y.chosen,window:d,width:C.columns})})}function F(e,l,s){switch(e.kind){case"fetching":return"fetching the catalogue";case"failed":return"could not be read";case"empty":return"nothing to show";case"installing":return"installing";case"done":return`installed ${e.report.installed.length} of ${e.report.total}`;case"agent":return`${s} to install · pick an agent`;case"picking":return s===0?`${l} rows · nothing ticked yet`:`${s} ticked of ${l} rows`}}function G({report:e}){return S(p,{flexDirection:"column",marginLeft:2,children:[S(f,{color:e.failed.length===0?o.success:o.warning,children:[u.check,`installed ${e.installed.length} of ${e.total} skill${e.total===1?"":"s"}`]}),e.installed.length>0?t(f,{dimColor:!0,wrap:"truncate",children:e.installed.join(", ")}):null,e.failed.map((l)=>S(f,{color:o.error,wrap:"truncate",children:[u.error,l.name," — ",l.reason]},l.name)),e.runnable>0?t(p,{marginTop:1,children:t(f,{dimColor:!0,wrap:"truncate",children:`${e.runnable} runnable file${e.runnable===1?"":"s"} across ${e.withCode} skill${e.withCode===1?"":"s"} — \`skills show <agent> <skill>\` names them`})}):null,t(p,{marginTop:1,children:t(f,{dimColor:!0,children:"restart the agent: the catalogue is scanned once at boot"})})]})}export{Se as SkillBrowser};
3
-
4
- //# debugId=0AAECFE521B6D5EA64756E2164756E21
5
- //# sourceMappingURL=SkillBrowser-3qdp8080.js.map
@@ -1,5 +0,0 @@
1
- #!/usr/bin/env node
2
- import{e}from"./index-tv4yv7d2.js";import{st,tn}from"./index-gme2egyq.js";import{o,u,oe}from"./index-d4x6yvqh.js";import"./index-1c5113t4.js";import{nt}from"./index-ty24n0jh.js";import{it}from"./index-4z7axw4r.js";import{an,dt,ln}from"./index-9r0wyj6w.js";import{Qt,ot,en}from"./index-fex44816.js";import{ae,W}from"./index-gz9x25tz.js";import{de}from"./index-v8e92nfw.js";import"./index-cqqb6gaq.js";import"./index-02dn6m2j.js";import{nn}from"./index-6q4wf8e3.js";import{re}from"./index-0d93hyfc.js";import{he,ct,ut,Ct,Fe,Te}from"./index-ttwyrdjs.js";import"./index-6p999cx4.js";import"./index-mtn0g9vc.js";import{q,Do}from"./index-h9mw7b9d.js";import"./index-j7gyr5nx.js";import{D,V,zt,Sn}from"./index-j55s3ehk.js";import{j,$n,Nn}from"./index-vgc3y3rm.js";import{Box as m,Text as h,useApp as ue,useInput as pe}from"ink";import{useCallback as me,useEffect as I,useReducer as fe,useState as ke}from"react";import{Box as ie,Text as N}from"ink";import{jsx as Q,jsxs as se}from"react/jsx-runtime";function Y({rows:n}){let t=n.reduce((r,c)=>Math.max(r,c.label.length),0);return Q(ie,{flexDirection:"column",borderStyle:oe,borderColor:o.border,paddingX:1,paddingY:1,children:n.map((r)=>se(N,{children:[Q(N,{dimColor:!0,children:r.label.padEnd(t+2)}),r.value]},r.label))})}import{Box as H,Text as v}from"ink";import{jsx as E,jsxs as P}from"react/jsx-runtime";function U({step:n,total:t,answered:r,hint:c,children:l}){return P(H,{flexDirection:"column",children:[r.map((p)=>P(v,{children:[E(v,{color:o.success,children:u.check}),E(v,{dimColor:!0,children:p.label.padEnd(18)}),p.value]},p.label)),E(H,{flexDirection:"column",borderStyle:oe,borderColor:o.border,paddingX:1,paddingY:1,marginTop:r.length>0?1:0,children:l}),P(v,{dimColor:!0,children:["step ",n," of ",t," ",u.bullet,c]})]})}function X(n,t){let r={given:n,log:[],phase:"asking",editor:D,select:{index:0,count:he.length},error:void 0,defaults:t};return f(r)===void 0?A(r):r}function b(n){return{...Object.fromEntries(n.log.map((r)=>[r.step,r.value])),...n.given}}function f(n){return Fe(b(n),n.defaults)}function B(n){return n.phase==="asking"&&f(n)?.options!==void 0}function G(n){return f(n)?.options??[]}function Z(n){let t=f(n)?.step;return n.phase==="asking"&&t!==void 0&&Ct.has(t)}function J(n){let t={...b(n)},r=0;for(;;){let l=Fe(t,n.defaults);if(l===void 0)break;r+=1,t[l.step]=l.fallback===""?"(x)":l.fallback}let c=n.log.length+Object.keys(n.given).length;return{asked:c+(n.phase==="asking"?1:0),total:c+r}}var le=2;function A(n){return{...n,phase:"confirm",editor:D,select:{index:0,count:le},error:void 0}}function z(n){let t=Fe(b(n),n.defaults),r=t?.options;return{editor:D,select:{index:ce(t),count:r===void 0?he.length:r.length},error:void 0}}function ce(n){let t=n?.options;if(t===void 0)return 0;let r=Number(n?.fallback)-1;return Number.isInteger(r)&&r>=0&&r<t.length?r:0}function T(n,t){if(n.phase==="done"||n.phase==="aborted")return n;switch(t.kind){case"abort":return{...n,phase:"aborted"};case"edit":if(n.phase!=="asking")return n;return{...n,editor:V(n.editor,t.intent),error:void 0};case"list":{let r=t.intent;if(r.kind==="move")return{...n,select:W(n.select,r.move),error:void 0};if(r.kind==="choose")return T(n,{kind:"commit"});if(r.kind==="back")return T(n,{kind:"back"});if(r.kind==="exit")return{...n,phase:"aborted"};return n}case"back":{if(n.phase==="confirm"){if(n.log.length===0)return{...n,phase:"asking",...z(n)};let l=n.log.slice(0,-1),p={...n,phase:"asking",log:l};return{...p,...z(p)}}if(n.log.length===0)return n;let r=n.log.slice(0,-1),c={...n,log:r};return{...c,...z(c)}}case"commit":{if(n.phase==="confirm")return n.select.index===0?{...n,phase:"done"}:T(n,{kind:"back"});let r=f(n);if(r===void 0)return A(n);let c=r.options!==void 0?r.options[n.select.index]?.value??"":n.editor.value.trim()===""?r.fallback:n.editor.value,l=Te(r.step,c);if(!l.ok)return{...n,error:l.reason};let p={...n,log:[...n.log,{step:r.step,value:l.value}]},d={...p,...z(p)};return f(d)===void 0?A(d):d}}}function ee(n){if(n==="")return"";if(n.length<=8)return"•".repeat(n.length);return`${n.slice(0,3)}${"•".repeat(6)}${n.slice(-2)}`}function ne(n){let t=b(n),r=t.preset===void 0?void 0:ct(t.preset),c=`${t.model??""} at ${t.baseUrl??""}`,l=t.apiKeyEnv??r?.apiKeyEnv,p=l===void 0?" (no key)":` (${l}=${t.apiKey===void 0||t.apiKey===""?"not set yet":ee(t.apiKey)})`;return[{label:"agent",value:t.name??""},{label:"for",value:`${t.user??""} — ${t.purpose??""}`},{label:"endpoint",value:`${c}${p}`},{label:"directory",value:t.dir??ut(t.dirChoice,t.name,n.defaults)??""}]}function te(n){let t={user:"Your name",name:"Agent name",purpose:"Purpose",preset:"Endpoint",model:"Model",baseUrl:"Base URL",apiKeyEnv:"Key env var",apiKey:"API key",web:"Internet",webBackend:"Search backend",webKey:"Search key",system:"System access",composio:"Other apps",telegram:"Telegram",telegramAllow:"Telegram handle",telegramToken:"Bot token",schedules:"none",server:"HTTP API",skills:"Skills",skillsSearch:"Skill search",skillsPick:"Skills picked",daemon:"Background service",serverToken:"API token",composioKey:"Composio key",dirChoice:"Location",dir:"Directory"};return n.log.map((r)=>({label:t[r.step],value:Ct.has(r.step)?ee(r.value):r.value}))}import{jsx as s,jsxs as g}from"react/jsx-runtime";var ge=16,ye=5;function rn({title:n,given:t,defaults:r,onDone:c}){let{exit:l}=ue(),p=re(),[d,k]=ke({kind:"idle"}),[a,x]=fe((i,y)=>T(i,y),void 0,()=>X(t,r)),C=me((i)=>{c(i),l()},[c,l]),L=a.log.some((i)=>i.step==="skills"&&i.value==="find");if(I(()=>{if(!L||d.kind!=="idle")return;k({kind:"fetching",status:"reading the catalogue"}),(async()=>{try{let i=await nt({onStatus:(S)=>k({kind:"fetching",status:S})});if(i.length===0){k({kind:"failed",message:"no catalogue could be read — carrying on without skills"});return}let y=st(i);k({kind:"picking",rows:i,picked:{cursor:{index:en(y),count:i.length},chosen:[]}})}catch(i){k({kind:"failed",message:i instanceof Error?i.message:String(i)})}})()},[L,d.kind]),I(()=>{if(d.kind!=="failed")return;let i=setTimeout(()=>k({kind:"done",refs:[]}),1400);return()=>clearTimeout(i)},[d]),I(()=>{if(a.phase==="done"){let i=d.kind==="done"?d.refs:[];C({...b(a),...i.length===0?{}:{skillsPick:i.join(",")}})}if(a.phase==="aborted")C(void 0)},[a,C,d]),pe((i,y)=>{if(d.kind==="picking"){let F=d.rows,K=st(F),w=zt(i,y);switch(w.kind){case"move":case"toggle":case"all":k({...d,picked:ot(d.picked,w.kind==="move"?{kind:"move",move:w.move}:{kind:w.kind},K)});return;case"none-selected":k({...d,picked:ot(d.picked,{kind:"none"},K)});return;case"confirm":case"cancel":k({kind:"done",refs:w.kind==="cancel"?[]:tn(F,d.picked.chosen).map((_)=>`${_.source}/${_.skill}`)});return;default:return}}if(d.kind==="fetching"||d.kind==="failed")return;let S=Sn(i,y,{select:B(a)||a.phase==="confirm",empty:a.editor.value===""});switch(S.kind){case"abort":x({kind:"abort"});return;case"back":x({kind:"back"});return;case"commit":x({kind:"commit"});return;case"list":x({kind:"list",intent:S.intent});return;case"edit":x({kind:"edit",intent:S.intent});return}}),a.phase==="done"||a.phase==="aborted")return null;if(d.kind==="fetching")return g(m,{flexDirection:"column",children:[s(it,{title:"Skills",lines:["choosing what this agent knows how to do"]}),s(m,{marginTop:1,paddingLeft:2,children:s(de,{label:d.status})})]});if(d.kind==="failed")return g(m,{flexDirection:"column",children:[s(it,{title:"Skills",lines:["carrying on without them"]}),s(m,{marginTop:1,paddingLeft:2,children:s(h,{color:o.warning,children:d.message})})]});if(d.kind==="picking"){let i=d.picked.chosen.length;return g(m,{flexDirection:"column",children:[s(it,{title:"Skills",lines:["space ticks · a all · n none · enter continues · esc skips"]}),s(m,{marginTop:1,children:s(Qt,{rows:d.rows,index:d.picked.cursor.index,chosen:d.picked.chosen,window:Do(void 0,$n),width:q(void 0,j)})}),s(m,{marginTop:1,paddingLeft:2,children:s(h,{color:i===0?o.muted:o.success,children:i===0?"nothing ticked — enter carries on without any":`${i} ticked`})})]})}let O=J(a),R=ln(e.name,{columns:q(p.columns,j)-dt,rows:Math.min(ye,Math.max(0,p.rows-ge))}),M=a.phase==="confirm"?"enter confirm · esc back · ^C quit — nothing written":"enter accepts · esc back · ^C quit — nothing written";return g(m,{flexDirection:"column",children:[R.lines.length>0?s(an,{lines:R.lines}):null,s(m,{marginTop:R.lines.length>0?1:0,children:g(h,{dimColor:!0,wrap:"truncate",children:[n," · a few questions — nothing is written until you confirm"]})}),a.phase==="confirm"?g(m,{flexDirection:"column",marginTop:1,children:[s(Y,{rows:ne(a)}),g(m,{marginTop:1,flexDirection:"column",children:[s(h,{children:"Write the files?"}),s(ae,{items:[{label:"yes"},{label:"no, go back"}],index:a.select.index})]}),s(h,{dimColor:!0,children:M})]}):s(m,{marginTop:1,children:s(U,{step:O.asked,total:O.total,answered:te(a),hint:M,children:B(a)?g(m,{flexDirection:"column",children:[s(h,{children:f(a)?.prompt??""}),s(ae,{items:G(a).map((i)=>({label:i.label,...i.hint===void 0?{}:{hint:i.hint}})),index:a.select.index,numbered:!0})]}):s(nn,{label:f(a)?.prompt??"",editor:a.editor,columns:q(p.columns,j)-dt,maxRows:Nn,placeholder:f(a)?.fallback??"",...a.error===void 0?{}:{error:a.error},...Z(a)?{secret:!0}:{}})})}),a.error!==void 0&&(B(a)||a.phase==="confirm")?g(h,{color:o.error,children:[u.error,a.error]}):null]})}export{rn as WizardApp};
3
-
4
- //# debugId=B844BA4BDFDCBE4B64756E2164756E21
5
- //# sourceMappingURL=WizardApp-vzpbydy3.js.map
@@ -1,24 +0,0 @@
1
- #!/usr/bin/env node
2
- import{E,t,Ft,me,Be,T,Tr,_,M}from"./index-tv4yv7d2.js";import"./index-ttwyrdjs.js";import"./index-d4x6yvqh.js";import{Ye,Mr}from"./index-ammv5st7.js";import{pe,b,J,ue,Z,ie}from"./index-6p999cx4.js";import{w,te}from"./index-mtn0g9vc.js";import{Wn,qn,Gn,gr,Tt,fo,ho,mo,po,go,_t,Zn,Vn,at,rn}from"./index-ff514z3y.js";import{At}from"./index-tf71ap9v.js";import{q}from"./index-h9mw7b9d.js";import{l,d}from"./index-j7gyr5nx.js";import{ve,j,Ze,n}from"./index-vgc3y3rm.js";import{readFileSync as A}from"node:fs";var C=["list","get","set","env","allow","edit"];function ne(e,r,o=(i)=>process.stderr.write(i)){let i=(e??"").trim();if(i==="")return{action:"edit",ref:void 0};if(!C.includes(i))return{action:"edit",ref:i};if(r!==void 0&&C.includes(r))o(`note: reading "${i}" as the action and "${r}" as the agent
3
- `);if(r===void 0&&i!=="list")return{action:i,ref:void 0};return{action:i,ref:r}}async function re(e){let r=e.out??((a)=>process.stdout.write(a)),o=e.action??"";if(!C.includes(o)){let a=E(o,[...C]);throw new t({code:"cli_config_action_unknown",message:`"${o}" is not something config does.`,hint:`One of: ${C.join(", ")}.${a===void 0?"":` Did you mean ${a}?`}`})}let i=te(e.ref??"",e.sandboxEnv);switch(o){case"list":{r(`${fo(Vn(i),i)}
4
- `);let a=Zn(_t(Be(A(i,"utf8"))),At(i));for(let s of a)r(`
5
- ${d(`${s.name} is not set — ${s.why}`)}
6
- `),r(`${d(`\`config env <agent> ${s.name}\` fills it in`)}
7
- `);return n}case"get":return x(i,e,r);case"set":return await N(i,e,r);case"env":return await R(i,e,r);case"edit":return await F(i,e,r);default:return await I(i,e,r)}}function x(e,r,o){let i=(r.name??"").trim(),a=k(i),s=Vn(e).find((c)=>c.setting.path===a.path);return o(`${ho(a,s?.value)}
8
- `),n}function k(e){let r=Tr(e);if(r!==void 0)return r;let o=E(e,[...go()]);throw new t({code:"cli_config_path_unknown",message:`"${e}" is not a setting.`,hint:`\`config list <agent>\` shows every one with its current value.${o===void 0?"":` Did you mean ${o}?`}`,field:"path"})}async function N(e,r,o){let i=(r.name??"").trim(),a=k(i);if(a.via!==void 0)throw new t({code:"cli_config_needs_action",message:`${a.path} is not set by a dotted path.`,hint:`Use \`${a.via}\` — it lives inside a list entry, and it gets its value checked against the service that issues it rather than written verbatim.`,field:"path"});if(r.value===void 0)throw new t({code:"cli_config_value_missing",message:`No value given for ${i}.`,hint:`A bare word, a number, a list as ["a", "b"], or a map as {k: v}. \`config get <agent> ${i}\` shows what it is now.`,field:"value"});let s=Ft(r.value),c=mo(a,s);if(c!==void 0&&r.yes!==!0){if(o(`${d(c)}
9
- `),!await(r.confirm??Ye)(`Change ${a.path} anyway?`))return o(`${l([{label:"unchanged",value:a.path}])}
10
- `),n}let p=At(e),f=Zn(_t(Be(A(e,"utf8"))),p).map((u)=>u.name),g=await Wn(e,i,r.value),m=Zn(_t(Be(A(e,"utf8"))),p).filter((u)=>!f.includes(u.name)),v=await O(e,r);return o(`${po({path:i,before:g.before,after:s,file:e,reflowed:g.reflowed,...v===void 0?{}:{running:v},pending:m,restartHint:S(v?.mode)})}
11
- `),n}function S(e){if(e==="daemon")return"`daemon restart <agent>`";if(e==="embedded")return"`/restart` in this session";if(e==="terminal")return"that process being started again";return"it is started again"}async function O(e,r){let o;try{o=T(e).id}catch{return}if(o===void 0)return;try{let i=await M.open({path:r.store??w(r.sandboxEnv)});try{for(let a of await i.leases.all()){if(a.agentId!==o)continue;if(!_(a.pid))continue;return{pid:a.pid,mode:a.mode}}}finally{await i.close()}}catch{return}return}async function R(e,r,o){let i=(r.name??"").trim();if(!/^[A-Za-z_][A-Za-z0-9_]*$/.test(i))throw new t({code:"cli_config_env_name_invalid",message:`"${i}" is not an environment variable name.`,hint:"Letters, digits and underscores, not starting with a digit — MODEL_API_KEY, TELEGRAM_BOT_TOKEN. `config list <agent>` shows which ones this agent names.",field:"name"});let s=await(r.secret??Mr)(`value for ${i} (not echoed):`);if(s===void 0)throw new t({code:"cli_config_env_no_value",message:`Nothing was written for ${i}.`,hint:"A secret is read from a prompt, never from an argument or a pipe — an argument is visible in `ps` and in shell history. Run this at a terminal, or edit the .env beside the manifest yourself."});if(s==="")throw new t({code:"cli_config_env_empty",message:`An empty value for ${i} would not start the agent.`,hint:"A variable set to nothing fails the load exactly as a missing one does. Nothing was written."});let c=Gn(e,i,s);return o(`${l([{label:"set",value:c.note}])}
12
- `),o(`${d("takes effect the next time the agent starts")}
13
- `),n}async function I(e,r,o){let i=me(A(e,"utf8"),["channels"]);if(!Array.isArray(i)||i.length===0)throw new t({code:"cli_config_no_channels",message:"This agent has no channels, so there is nobody to allow.",hint:"`config set <agent> channels '[{type: telegram, id: tg, tokenEnv: TELEGRAM_BOT_TOKEN, mode: longpoll}]'` declares one first."});let a=i.filter((h)=>typeof h==="object"&&h!==null&&!Array.isArray(h)),s=a.map((h)=>String(h.id??"")).filter((h)=>h!==""),c=r.channel?.trim();if(c===void 0&&a.length>1)throw new t({code:"cli_config_channel_ambiguous",message:`This agent has ${a.length} channels, so --channel says which.`,hint:`One of: ${s.join(", ")}.`,field:"channel"});let p=c===void 0?0:a.findIndex((h)=>String(h.id??"")===c);if(p===-1)throw new t({code:"cli_config_channel_unknown",message:`No channel with id "${c}".`,hint:`Declared: ${s.join(", ")}.${E(c??"",s)===void 0?"":` Did you mean ${E(c??"",s)}?`}`,field:"channel"});let f=a[p],g=gr(r.name??"",String(f.type??"")),m=Array.isArray(f.allowFrom)?f.allowFrom.map(String):[],v=r.remove===!0?m.filter((h)=>h!==g):m.includes(g)?m:[...m,g];if(v.length===m.length&&r.remove===!0)return o(`${l([{label:"unchanged",value:`${g} was not on ${String(f.id)}`}])}
14
- `),n;if(v.length===m.length)return o(`${l([{label:"already allowed",value:`${g} on ${String(f.id)}`}])}
15
- `),n;let u=await qn(e,String(f.id??""),v),y=await O(e,r);if(o(`${l([{label:r.remove===!0?"removed":"allowed",value:g},{label:"channel",value:String(f.id)},{label:"now",value:Tt(v)},{label:"file",value:e}])}
16
- `),u.reflowed)o(`${d("the file was re-serialised — it is valid, and comments may have moved")}
17
- `);if(y!==void 0)o(`${d(`this agent is running (pid ${y.pid}, ${y.mode}) and holds its settings for its lifetime — the change applies after ${S(y.mode)}`)}
18
- `);return n}async function F(e,r,o){let i=ie({plain:!1,json:!1,oneShot:!1});if(i.mode!=="rich")throw new t({code:"cli_config_edit_needs_terminal",message:"The settings editor needs a terminal.",hint:`Not one here (${i.because}). \`config list\` reads them and \`config set\` changes one, both of which work on a pipe.`});let[{render:a},{createElement:s},{ConfigEditor:c}]=await Promise.all([import("ink"),import("react"),import("./ConfigEditor-n8hdw6r7.js")]),p=!1,f=()=>{},g=new Promise((u)=>{f=u});pe(),process.stdout.write(ve);let m=a(s(c,{rows:at(e),apply:(u,y)=>rn(e,u,y),reload:()=>at(e),columns:q(process.stdout.columns,j),window:Ze,onDone:(u)=>{p=u,f()}}),{exitOnCtrlC:!1,...Z()});b(()=>m.unmount()),await g,m.unmount(),J(),await ue();let v=await O(e,r);if(!p)return o(`${l([{label:"unchanged",value:e}])}
19
- `),n;return o(`${l([{label:"changed",value:e}])}
20
- `),o(`${d(`takes effect after ${S(v?.mode)}`)}
21
- `),n}export{re as configCommand,ne as readAction};
22
-
23
- //# debugId=A1FEF871B88EA65364756E2164756E21
24
- //# sourceMappingURL=config-g7za9x13.js.map
@@ -1,19 +0,0 @@
1
- #!/usr/bin/env node
2
- import{e,nr}from"./index-tv4yv7d2.js";import"./index-ttwyrdjs.js";import"./index-whaw4b18.js";import{se}from"./index-hwpvhaza.js";import{Pe,Qe,ur,Kt}from"./index-qdbq8crg.js";import"./index-mtn0g9vc.js";function g(n){let t=/^(\d+)\s*(s|m|h|d)?$/.exec(n.trim());if(t===null)throw new se({code:"credential_usage",message:`--expires ${JSON.stringify(n)} is not a duration.`,hint:"Write it as 30s, 15m, 2h or 7d — or as a plain number of seconds."});let i=Number(t[1]);if(i===0)throw new se({code:"credential_usage",message:"--expires 0 would mint a credential that has already expired.",hint:"Leave the flag off for a key that never expires, or give it a real duration like 1h."});let s={s:1,m:60,h:3600,d:86400}[t[2]??"s"]??1;return i*s}function y(n){let t=n.split(",").map((s)=>s.trim().toLowerCase()).filter((s)=>s!==""),i=t.filter((s)=>!nr.includes(s));if(i.length>0)throw new se({code:"credential_usage",message:`--can names ${i.map((s)=>JSON.stringify(s)).join(", ")}, which is not a capability.`,hint:`The four are: ${nr.join(", ")}. read is every GET; chat sends a message, answers an approval and stops a turn; write covers schedules, phase and clearing a session; admin covers credentials, provisioning and start/stop.`});return t}function f(n){return n.split(",").map((t)=>t.trim()).filter((t)=>t!=="")}function l(n){let t=[];if(t.push(n.scope?.agents===void 0?"every agent":n.scope.agents.join(", ")),n.scope?.sessions!==void 0)t.push(`sessions ${n.scope.sessions}`);if(t.push(n.scope?.can===void 0?"all capabilities":n.scope.can.join("+")),n.expiresAt!==void 0)t.push(`until ${n.expiresAt}`);return t.join(" · ")}async function d(n){let t=await Pe(n);if(t===void 0)throw new se({code:"credential_usage",message:"No server is running, so there is nothing to mint a credential on.",hint:`A credential belongs to a server rather than to a file, so this command is an API client. Start one with \`${e.slug} serve\`, or use POST /v1/keys directly against a server you can already reach.`});return{lease:t,manifest:Kt(t.agentId)}}async function v(n){if(n.action==="create")return await h(n);if(n.action==="list")return await p(n);if(n.action==="revoke")return await m(n);throw new se({code:"credential_usage",message:`Unknown action ${JSON.stringify(n.action)}.`,hint:"The actions are create, list and revoke."})}async function h(n){let t=n.label?.trim();if(t===void 0||t==="")throw new se({code:"credential_usage",message:"--label is required.",hint:'A label is the only thing distinguishing two credentials in a listing, and "key 2" is a name nobody can act on when deciding which to revoke.'});let i={...n.agents===void 0?{}:{agents:f(n.agents)},...n.sessions===void 0?{}:{sessions:n.sessions},...n.can===void 0?{}:{can:y(n.can)},...n.expires===void 0?{}:{expiresIn:g(n.expires)}},{lease:s,manifest:o}=await d(n.store),a=await Qe(s,"/v1/keys",{label:t,...Object.keys(i).length===0?{}:{scope:i}},o);if(!a.ok)return c(a,"mint a credential");let r=a.body;if(n.json===!0)return process.stdout.write(`${JSON.stringify(r,null,2)}
3
- `),0;return process.stdout.write(`${r.secret}
4
- `),process.stderr.write(` ${r.label} · ${r.keyId}
5
- `),process.stderr.write(` reaches ${l(r)}
6
- `),process.stderr.write(` This is the only time the secret is shown. It is stored as a fingerprint and no route returns it.
7
- `),0}async function p(n){let{lease:t,manifest:i}=await d(n.store),s=await ur(t,"GET","/v1/keys",i);if(!s.ok)return c(s,"list credentials");let o=s.body,a=o.keys??[];if(n.json===!0)return process.stdout.write(`${JSON.stringify(o,null,2)}
8
- `),0;if(a.length===0)return process.stdout.write(`No credentials. The server token is the only way in.
9
- `),0;for(let r of a){let u=r.revokedAt===void 0?"live":"revoked";process.stdout.write(`${r.keyId} ${u.padEnd(7)} ${r.label}
10
- `),process.stdout.write(` reaches ${l(r)}
11
- `),process.stdout.write(` created ${r.createdAt}${r.lastUsedAt===void 0?" · never used":` · last used ${r.lastUsedAt}`}
12
- `)}return 0}async function m(n){let t=n.keyId?.trim();if(t===void 0||t==="")throw new se({code:"credential_usage",message:"Which credential?",hint:`\`${e.slug} credential list\` prints the ids. Revoking is permanent — a revoked secret can never be re-presented.`});let{lease:i,manifest:s}=await d(n.store),o=await ur(i,"DELETE",`/v1/keys/${encodeURIComponent(t)}`,s);if(!o.ok)return c(o,"revoke that credential");let a=o.body;if(n.json===!0)return process.stdout.write(`${JSON.stringify(a,null,2)}
13
- `),0;return process.stdout.write(`revoked ${a.keyId} · ${a.label}
14
- `),0}function c(n,t){if(process.stderr.write(`Could not ${t}${n.status===0?"":` (${n.status})`}: ${n.detail??"the host did not answer"}
15
- `),n.hint!==void 0)process.stderr.write(` hint: ${n.hint}
16
- `);return 1}export{v as credentialCommand};
17
-
18
- //# debugId=A2FA2E4460FA817D64756E2164756E21
19
- //# sourceMappingURL=credential-npr6z8c8.js.map
@@ -1,7 +0,0 @@
1
- #!/usr/bin/env node
2
- import{vn,Fo}from"./index-cqqb6gaq.js";import{o,I}from"./index-d4x6yvqh.js";import{ar,kt}from"./index-j55s3ehk.js";var B=1;function wn(t,l){let u=Math.max(1,l-B),r=t.value.split(`
3
- `),i=ar(t),d=[],m=0,s=0;for(let[f,n]of r.entries()){let h=vn(n,u),b=f===i.line?Fo(n,i.column):-1,c=-1;if(b>=0){c=h.length-1;for(let[p,e]of h.entries())if(b<=e.to){c=p;break}}for(let[p,e]of h.entries()){if(p===c)m=d.length;d.push({start:s+e.from,end:s+e.to,lead:e.lead,text:e.text,caret:p===c?e.lead+Math.max(0,Math.min(b-e.from,e.to-e.from)):void 0})}s+=[...n].length+1}return{rows:d,caretRow:m}}function k(t,l){let u=[...t.text],r=[];for(let[i,d]of u.entries()){let m=i<t.lead?-1:t.start+(i-t.lead),s=l!==void 0&&m>=l.start&&m<l.end,f=t.caret===i,n=r.at(-1);if(n!==void 0&&!f&&!n.caret&&n.selected===s){r[r.length-1]={...n,text:n.text+d};continue}r.push({text:d,selected:s,caret:f})}if(t.caret!==void 0&&t.caret>=u.length)r.push({text:" ",selected:!1,caret:!0});return r}import{Box as _,Text as a}from"ink";import{jsx as y,jsxs as w}from"react/jsx-runtime";function bn({editor:t,placeholder:l,secret:u,gutter:r="",maxRows:i,columns:d}){let m=[...r].length,s=" ".repeat(m);if(t.value===""&&l!==void 0&&l!==""){let x=[...l];return w(a,{dimColor:!0,wrap:"truncate",children:[y(a,{color:o.accent,children:r}),y(a,{inverse:!0,children:x[0]??" "}),x.slice(1).join("")]})}let f=kt(t),{rows:n,caretRow:h}=wn(t,Math.max(1,(d??Number.MAX_SAFE_INTEGER)-m)),b=i??n.length,{from:c,to:p}=I(n.length,h,Math.max(1,b)),e=c,T=n.length-p;return w(_,{flexDirection:"column",children:[e>0?w(a,{dimColor:!0,wrap:"truncate",children:[s,"… ",e," line",e===1?"":"s"," above"]}):null,n.slice(c,p).map((x,v)=>{let C=c+v,M=u===!0?[...x.text].map(()=>"•"):[...x.text],S=C===c&&e===0?r:s;if(x.caret===void 0&&f===void 0)return w(a,{wrap:"truncate",children:[y(a,{color:o.accent,children:S}),M.join("")]},`row-${C}`);let A=k(x,f),L=0;return w(a,{wrap:"truncate",children:[y(a,{color:o.accent,children:S}),A.map((g)=>{let R=`run-${C}-${L}`;L+=[...g.text].length;let E=u===!0?[...g.text].map(()=>"•").join(""):g.text;if(g.caret)return y(a,{inverse:!0,children:E},R);if(g.selected)return y(a,{backgroundColor:o.selection,children:E},R);return y(a,{children:E},R)})]},`row-${C}`)}),T>0?w(a,{dimColor:!0,wrap:"truncate",children:[s,"… ",T," line",T===1?"":"s"," below"]}):null]})}
4
- export{wn,bn};
5
-
6
- //# debugId=3FDEB5D0EE7A656F64756E2164756E21
7
- //# sourceMappingURL=index-02dn6m2j.js.map
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env node
2
- import{j,$n}from"./index-vgc3y3rm.js";import{useStdout as u}from"ink";import{useEffect as i,useState as t}from"react";function s(e){let n=e?.columns,o=e?.rows;return{columns:n===void 0||n<=0?j:n,rows:o===void 0||o<=0?$n:o}}function re(){let{stdout:e}=u(),[n,o]=t(()=>s(e));return i(()=>{if(e===void 0)return;let r=()=>o(s(e));return e.on("resize",r),()=>void e.off("resize",r)},[e]),n}
3
- export{re};
4
-
5
- //# debugId=0E83A1C1932ED9F964756E2164756E21
6
- //# sourceMappingURL=index-0d93hyfc.js.map