dispach 0.2.0 → 0.2.2

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 (226) hide show
  1. package/README.md +144 -49
  2. package/dist/APEv2Parser-etzjd528.js +5 -0
  3. package/dist/{FlacParser-6jwner07.js.map → APEv2Parser-etzjd528.js.map} +1 -1
  4. package/dist/{AiffParser-n65syezh.js → AiffParser-y21k3fak.js} +3 -3
  5. package/dist/{AiffParser-n65syezh.js.map → AiffParser-y21k3fak.js.map} +1 -1
  6. package/dist/App-4w3qkcs4.js +11 -0
  7. package/dist/{App-pmqmzsb3.js.map → App-4w3qkcs4.js.map} +1 -1
  8. package/dist/{AsfParser-da1fqvxz.js → AsfParser-wd98k2h4.js} +3 -3
  9. package/dist/{AsfParser-da1fqvxz.js.map → AsfParser-wd98k2h4.js.map} +1 -1
  10. package/dist/{ConfigEditor-4nqbeejh.js → ConfigEditor-vk7vxaa6.js} +3 -3
  11. package/dist/{ConfigEditor-4nqbeejh.js.map → ConfigEditor-vk7vxaa6.js.map} +1 -1
  12. package/dist/{DsdiffParser-gk95sj7t.js → DsdiffParser-cbfaj500.js} +3 -3
  13. package/dist/{DsdiffParser-gk95sj7t.js.map → DsdiffParser-cbfaj500.js.map} +1 -1
  14. package/dist/{DsfParser-b0enevjw.js → DsfParser-tybrja4x.js} +3 -3
  15. package/dist/{DsfParser-b0enevjw.js.map → DsfParser-tybrja4x.js.map} +1 -1
  16. package/dist/FlacParser-7t7da7qy.js +5 -0
  17. package/dist/{APEv2Parser-jdp5yp24.js.map → FlacParser-7t7da7qy.js.map} +1 -1
  18. package/dist/{KeyProbe-rspsxpsr.js → KeyProbe-5anphmb7.js} +3 -3
  19. package/dist/{KeyProbe-rspsxpsr.js.map → KeyProbe-5anphmb7.js.map} +1 -1
  20. package/dist/{MP4Parser-ph7rv2fn.js → MP4Parser-gc94h1n9.js} +3 -3
  21. package/dist/{MP4Parser-ph7rv2fn.js.map → MP4Parser-gc94h1n9.js.map} +1 -1
  22. package/dist/{MatroskaParser-fjk1mpct.js → MatroskaParser-cy2k4fac.js} +3 -3
  23. package/dist/{MatroskaParser-fjk1mpct.js.map → MatroskaParser-cy2k4fac.js.map} +1 -1
  24. package/dist/{MpegParser-vp7cj8ts.js → MpegParser-c460fwf0.js} +3 -3
  25. package/dist/{MpegParser-vp7cj8ts.js.map → MpegParser-c460fwf0.js.map} +1 -1
  26. package/dist/{MusepackParser-v22gft1f.js → MusepackParser-8mq2eabg.js} +3 -3
  27. package/dist/{MusepackParser-v22gft1f.js.map → MusepackParser-8mq2eabg.js.map} +1 -1
  28. package/dist/OggParser-7dnc6apg.js +5 -0
  29. package/dist/{OggParser-as1m8xsa.js.map → OggParser-7dnc6apg.js.map} +1 -1
  30. package/dist/Picker-j7txnm7w.js +5 -0
  31. package/dist/{Picker-jkmd5xnx.js.map → Picker-j7txnm7w.js.map} +1 -1
  32. package/dist/SessionPicker-hpv2ncsb.js +5 -0
  33. package/dist/{SessionPicker-3712ke3k.js.map → SessionPicker-hpv2ncsb.js.map} +3 -3
  34. package/dist/SkillBrowser-qc542n71.js +5 -0
  35. package/dist/{SkillBrowser-qhsyszt4.js.map → SkillBrowser-qc542n71.js.map} +1 -1
  36. package/dist/{WavPackParser-b4qqavzg.js → WavPackParser-kt7cds9c.js} +3 -3
  37. package/dist/{WavPackParser-b4qqavzg.js.map → WavPackParser-kt7cds9c.js.map} +1 -1
  38. package/dist/{WaveParser-fqs1h38f.js → WaveParser-g47ja0vy.js} +3 -3
  39. package/dist/{WaveParser-fqs1h38f.js.map → WaveParser-g47ja0vy.js.map} +1 -1
  40. package/dist/WizardApp-q4p979d1.js +5 -0
  41. package/dist/{WizardApp-qrq36nv8.js.map → WizardApp-q4p979d1.js.map} +3 -3
  42. package/dist/{channels-gf31stv7.js → channels-4t89qpdt.js} +18 -18
  43. package/dist/{channels-gf31stv7.js.map → channels-4t89qpdt.js.map} +1 -1
  44. package/dist/client.d.ts +242 -1
  45. package/dist/client.js +11 -11
  46. package/dist/client.js.map +5 -5
  47. package/dist/config-35r6n1gh.js +24 -0
  48. package/dist/{config-z2cd0c5f.js.map → config-35r6n1gh.js.map} +1 -1
  49. package/dist/credential-dpdgg4j6.js +19 -0
  50. package/dist/{credential-h0wmsjsw.js.map → credential-dpdgg4j6.js.map} +1 -1
  51. package/dist/{index-3s2q0m64.js → index-0444sh6x.js} +4 -4
  52. package/dist/{index-3s2q0m64.js.map → index-0444sh6x.js.map} +1 -1
  53. package/dist/{index-v271gbaz.js → index-095hrkyr.js} +6 -6
  54. package/dist/{index-v271gbaz.js.map → index-095hrkyr.js.map} +1 -1
  55. package/dist/index-1x8mzvz7.js +6 -0
  56. package/dist/{index-rhv6gqpt.js.map → index-1x8mzvz7.js.map} +1 -1
  57. package/dist/index-2bsardvh.js +5 -0
  58. package/dist/{index-tny7c703.js.map → index-2bsardvh.js.map} +2 -2
  59. package/dist/{index-9m6b14b4.js → index-2zjh5zd5.js} +4 -4
  60. package/dist/{index-9m6b14b4.js.map → index-2zjh5zd5.js.map} +1 -1
  61. package/dist/{index-t6xnecdx.js → index-323jvr1g.js} +4 -4
  62. package/dist/{index-t6xnecdx.js.map → index-323jvr1g.js.map} +1 -1
  63. package/dist/{index-gace5ac7.js → index-3826kf9t.js} +5 -5
  64. package/dist/{index-gace5ac7.js.map → index-3826kf9t.js.map} +1 -1
  65. package/dist/index-38gs9anh.js +9 -0
  66. package/dist/{index-b7qc21s7.js.map → index-38gs9anh.js.map} +1 -1
  67. package/dist/index-3c5jt6by.js +5 -0
  68. package/dist/{index-3mvenfbg.js.map → index-3c5jt6by.js.map} +2 -2
  69. package/dist/{index-k2q76dhw.js → index-3vzf253k.js} +7 -7
  70. package/dist/{index-k2q76dhw.js.map → index-3vzf253k.js.map} +1 -1
  71. package/dist/{index-t5d8ey5t.js → index-42e29zs4.js} +4 -4
  72. package/dist/{index-t5d8ey5t.js.map → index-42e29zs4.js.map} +1 -1
  73. package/dist/{index-v7mz396x.js → index-4fj1k64j.js} +4 -4
  74. package/dist/{index-v7mz396x.js.map → index-4fj1k64j.js.map} +1 -1
  75. package/dist/{index-gqbny9gy.js → index-51x0n5z0.js} +6 -6
  76. package/dist/{index-gqbny9gy.js.map → index-51x0n5z0.js.map} +1 -1
  77. package/dist/index-664xcamy.js +110 -0
  78. package/dist/index-664xcamy.js.map +13 -0
  79. package/dist/index-7mn8ack9.js +6 -0
  80. package/dist/{index-qe3ybzh6.js.map → index-7mn8ack9.js.map} +2 -2
  81. package/dist/index-8edck2pr.js +6 -0
  82. package/dist/{index-kktaw552.js.map → index-8edck2pr.js.map} +1 -1
  83. package/dist/index-8h6kewy1.js +9 -0
  84. package/dist/{index-s4a28ctb.js.map → index-8h6kewy1.js.map} +1 -1
  85. package/dist/index-8tmv33mr.js +6 -0
  86. package/dist/{index-v6taf4vn.js.map → index-8tmv33mr.js.map} +1 -1
  87. package/dist/index-9914wh1d.js +6 -0
  88. package/dist/index-9914wh1d.js.map +10 -0
  89. package/dist/{index-y6r1k2yd.js → index-a2eh8dnk.js} +7 -7
  90. package/dist/{index-y6r1k2yd.js.map → index-a2eh8dnk.js.map} +1 -1
  91. package/dist/{index-81vj1bxe.js → index-bqdkm3de.js} +4 -4
  92. package/dist/{index-81vj1bxe.js.map → index-bqdkm3de.js.map} +1 -1
  93. package/dist/{index-rfa0ztab.js → index-dzy19wtf.js} +4 -4
  94. package/dist/{index-rfa0ztab.js.map → index-dzy19wtf.js.map} +1 -1
  95. package/dist/{index-c2qjdz4q.js → index-eqqd4k4f.js} +9 -9
  96. package/dist/{index-c2qjdz4q.js.map → index-eqqd4k4f.js.map} +1 -1
  97. package/dist/{index-g1d06ct5.js → index-ew997be5.js} +7 -7
  98. package/dist/{index-g1d06ct5.js.map → index-ew997be5.js.map} +1 -1
  99. package/dist/{index-0v2gw4mk.js → index-fa9wvpyw.js} +3 -3
  100. package/dist/{index-0v2gw4mk.js.map → index-fa9wvpyw.js.map} +1 -1
  101. package/dist/{index-rvq7t636.js → index-fbsrhcga.js} +4 -4
  102. package/dist/{index-rvq7t636.js.map → index-fbsrhcga.js.map} +1 -1
  103. package/dist/index-fcsg95m5.js +11 -0
  104. package/dist/{index-5nprb9px.js.map → index-fcsg95m5.js.map} +1 -1
  105. package/dist/{index-dgrwpzz9.js → index-gbkma7ds.js} +4 -4
  106. package/dist/{index-dgrwpzz9.js.map → index-gbkma7ds.js.map} +1 -1
  107. package/dist/{index-0m0x1454.js → index-gq1npngp.js} +4 -4
  108. package/dist/{index-0m0x1454.js.map → index-gq1npngp.js.map} +1 -1
  109. package/dist/index-haypwvzd.js +308 -0
  110. package/dist/index-haypwvzd.js.map +21 -0
  111. package/dist/{index-g8n8rhtr.js → index-jc4kmfwa.js} +4 -4
  112. package/dist/{index-g8n8rhtr.js.map → index-jc4kmfwa.js.map} +1 -1
  113. package/dist/index-kjqksgch.js +429 -0
  114. package/dist/index-kjqksgch.js.map +12 -0
  115. package/dist/{index-es4bgkbh.js → index-m6fqx0ch.js} +7 -7
  116. package/dist/{index-es4bgkbh.js.map → index-m6fqx0ch.js.map} +1 -1
  117. package/dist/{index-60jxyzbe.js → index-ma6p7bt4.js} +4 -4
  118. package/dist/{index-60jxyzbe.js.map → index-ma6p7bt4.js.map} +1 -1
  119. package/dist/index-nvc24414.js +6 -0
  120. package/dist/{index-2yj11ykt.js.map → index-nvc24414.js.map} +1 -1
  121. package/dist/index-nxhqf597.js +6 -0
  122. package/dist/{index-m5rmhcez.js.map → index-nxhqf597.js.map} +1 -1
  123. package/dist/{index-jmnjcw61.js → index-p1zy871m.js} +4 -4
  124. package/dist/{index-jmnjcw61.js.map → index-p1zy871m.js.map} +1 -1
  125. package/dist/{index-2pzgta33.js → index-p6ya59m6.js} +5 -5
  126. package/dist/{index-2pzgta33.js.map → index-p6ya59m6.js.map} +1 -1
  127. package/dist/{index-6c4p19m1.js → index-pszmnhgq.js} +2 -2
  128. package/dist/index-qg9bn980.js +1213 -0
  129. package/dist/{index-1h9pqnec.js.map → index-qg9bn980.js.map} +28 -25
  130. package/dist/index-qgsdgbk8.js +5 -0
  131. package/dist/{index-ak304afj.js.map → index-qgsdgbk8.js.map} +2 -2
  132. package/dist/index-r4ax3x4d.js +74 -0
  133. package/dist/index-r4ax3x4d.js.map +13 -0
  134. package/dist/{index-m01mb74d.js → index-snz49ndn.js} +4 -4
  135. package/dist/{index-m01mb74d.js.map → index-snz49ndn.js.map} +1 -1
  136. package/dist/index-twn9bfm2.js +8 -0
  137. package/dist/{index-dwxmy0kx.js.map → index-twn9bfm2.js.map} +2 -2
  138. package/dist/{index-0p9p6fvc.js → index-wc4entme.js} +10 -10
  139. package/dist/{index-0p9p6fvc.js.map → index-wc4entme.js.map} +3 -3
  140. package/dist/{index-wxmqyv4c.js → index-ynsvkqgb.js} +4 -4
  141. package/dist/{index-wxmqyv4c.js.map → index-ynsvkqgb.js.map} +1 -1
  142. package/dist/index-ytxbw8py.js +63 -0
  143. package/dist/{index-fcqy46mh.js.map → index-ytxbw8py.js.map} +2 -2
  144. package/dist/index-yw3fby4n.js +6 -0
  145. package/dist/{index-dh2g58s1.js.map → index-yw3fby4n.js.map} +2 -2
  146. package/dist/{index-ccpq4k6r.js → index-z157at3s.js} +28 -28
  147. package/dist/{index-ccpq4k6r.js.map → index-z157at3s.js.map} +1 -1
  148. package/dist/{index-s78sq9g1.js → index-zce9gy22.js} +64 -64
  149. package/dist/{index-s78sq9g1.js.map → index-zce9gy22.js.map} +1 -1
  150. package/dist/{index-jv7egrh2.js → index-zw6wyas6.js} +4 -4
  151. package/dist/{index-jv7egrh2.js.map → index-zw6wyas6.js.map} +1 -1
  152. package/dist/index.js +308 -292
  153. package/dist/index.js.map +15 -12
  154. package/dist/init.d.ts.map +1 -1
  155. package/dist/lib/agent-template.d.ts +5 -0
  156. package/dist/lib/agent-template.d.ts.map +1 -1
  157. package/dist/lib/commands.d.ts.map +1 -1
  158. package/dist/lib/init-flow.d.ts +7 -30
  159. package/dist/lib/init-flow.d.ts.map +1 -1
  160. package/dist/lib/owner.d.ts +49 -0
  161. package/dist/lib/owner.d.ts.map +1 -0
  162. package/dist/lib/presets.d.ts +44 -0
  163. package/dist/lib/presets.d.ts.map +1 -0
  164. package/dist/lib/provision.d.ts +8 -1
  165. package/dist/lib/provision.d.ts.map +1 -1
  166. package/dist/lib/relay-client.d.ts +17 -0
  167. package/dist/lib/relay-client.d.ts.map +1 -0
  168. package/dist/lib/schema.d.ts +2 -0
  169. package/dist/lib/schema.d.ts.map +1 -1
  170. package/dist/lib/sessions-view.d.ts +2 -0
  171. package/dist/lib/sessions-view.d.ts.map +1 -1
  172. package/dist/lib/source.d.ts +17 -0
  173. package/dist/lib/source.d.ts.map +1 -1
  174. package/dist/lib/wizard.d.ts.map +1 -1
  175. package/dist/owner.d.ts +16 -0
  176. package/dist/owner.d.ts.map +1 -0
  177. package/dist/run.d.ts.map +1 -1
  178. package/dist/serve.d.ts.map +1 -1
  179. package/dist/transcript.d.ts.map +1 -1
  180. package/dist/web-zph4h3p9.js +14 -0
  181. package/dist/{web-stkkwyka.js.map → web-zph4h3p9.js.map} +1 -1
  182. package/dist/wire.d.ts +31 -0
  183. package/dist/wire.js +2 -2
  184. package/dist/wire.js.map +4 -4
  185. package/dist/wrapper-f662ny3r.js +5 -0
  186. package/dist/{wrapper-bwxbqa53.js.map → wrapper-f662ny3r.js.map} +1 -1
  187. package/package.json +5 -2
  188. package/dist/APEv2Parser-jdp5yp24.js +0 -5
  189. package/dist/App-pmqmzsb3.js +0 -11
  190. package/dist/FlacParser-6jwner07.js +0 -5
  191. package/dist/OggParser-as1m8xsa.js +0 -5
  192. package/dist/Picker-jkmd5xnx.js +0 -5
  193. package/dist/SessionPicker-3712ke3k.js +0 -5
  194. package/dist/SkillBrowser-qhsyszt4.js +0 -5
  195. package/dist/WizardApp-qrq36nv8.js +0 -5
  196. package/dist/config-z2cd0c5f.js +0 -24
  197. package/dist/credential-h0wmsjsw.js +0 -19
  198. package/dist/index-026q0y3a.js +0 -6
  199. package/dist/index-026q0y3a.js.map +0 -10
  200. package/dist/index-1h9pqnec.js +0 -1194
  201. package/dist/index-1wxw30j1.js +0 -74
  202. package/dist/index-1wxw30j1.js.map +0 -13
  203. package/dist/index-2yj11ykt.js +0 -6
  204. package/dist/index-358nsn9t.js +0 -65
  205. package/dist/index-358nsn9t.js.map +0 -21
  206. package/dist/index-3mvenfbg.js +0 -5
  207. package/dist/index-5nprb9px.js +0 -11
  208. package/dist/index-ak304afj.js +0 -5
  209. package/dist/index-b7qc21s7.js +0 -9
  210. package/dist/index-dh2g58s1.js +0 -6
  211. package/dist/index-dwxmy0kx.js +0 -8
  212. package/dist/index-fcqy46mh.js +0 -63
  213. package/dist/index-kktaw552.js +0 -6
  214. package/dist/index-m5rmhcez.js +0 -6
  215. package/dist/index-qe3ybzh6.js +0 -6
  216. package/dist/index-rhv6gqpt.js +0 -6
  217. package/dist/index-s4a28ctb.js +0 -9
  218. package/dist/index-tny7c703.js +0 -5
  219. package/dist/index-v6taf4vn.js +0 -6
  220. package/dist/index-y605a1rj.js +0 -429
  221. package/dist/index-y605a1rj.js.map +0 -11
  222. package/dist/index-z88f35vs.js +0 -96
  223. package/dist/index-z88f35vs.js.map +0 -13
  224. package/dist/web-stkkwyka.js +0 -14
  225. package/dist/wrapper-bwxbqa53.js +0 -5
  226. /package/dist/{index-6c4p19m1.js.map → index-pszmnhgq.js.map} +0 -0
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+ import{i,b,$e}from"./index-dzy19wtf.js";import{Ln,SA,Pn}from"./index-nvc24414.js";import{je}from"./index-fbsrhcga.js";import{At,_e}from"./index-42e29zs4.js";import{nt}from"./index-1x8mzvz7.js";import{qA,Mo}from"./index-2zjh5zd5.js";import{An,mt}from"./index-m6fqx0ch.js";import{Ws,zs,Zs}from"./index-jc4kmfwa.js";import{Go,Fo,EA,CA,pA}from"./index-8tmv33mr.js";import{Box as g,Text as u,useInput as U}from"ink";import{useCallback as X,useEffect as Y,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 W={ok:i.success,warn:i.warning,off:i.muted},B={title:{color:i.accent,bold:!0},summary:{dim:!0},state:{},warning:{color:i.warning}};function D(e){return Math.max(Go,Math.min(Fo,e))}function k({header:e,footer:l,children:s}){let S=je(),T=D(S.columns),f=T-4,v=Ws(e,f),C=e.state??[];return H(E,{flexDirection:"column",width:T,children:[w(E,{flexDirection:"column",borderStyle:$e,borderColor:i.borderActive,paddingX:1,children:v.map((d)=>d.kind==="state"?w(R,{wrap:"truncate",children:C.map((n,c)=>H(R,{color:W[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:[" ",zs(l,f)]})})]})}import{jsx as t,jsxs as y}from"react/jsx-runtime";function ke({load:e,install:l,agents:s,target:S,focused:T=!0,onDone:f,title:v}){let C=je(),d=Math.max(EA,Math.min(CA,C.rows-pA)),[n,c]=L({kind:"fetching",status:"reading the catalogue"}),[x,O]=L([]),[h,M]=L({cursor:{index:0,count:0},chosen:[]}),[_,A]=L({index:0,count:s.length});Y(()=>{let o=!0;return e((r)=>{if(o)c((a)=>a.kind==="fetching"?{...a,status:r}:a)}).then((r)=>{if(!o)return;O(r);let a=qA(r);M({cursor:{index:Pn(a),count:r.length},chosen:[]}),c(r.length===0?{kind:"empty"}:{kind:"picking"})}).catch((r)=>{if(!o)return;c({kind:"failed",message:r instanceof Error?r.message:String(r)})}),()=>{o=!1}},[e]);let P=qA(x),I=X((o)=>{let r=Mo(x,h.chosen);c({kind:"installing",count:r.length}),l(r,o).then((a)=>c({kind:"done",report:a})).catch((a)=>c({kind:"failed",message:a instanceof Error?a.message:String(a)}))},[x,h.chosen,l]);U((o,r)=>{if(n.kind==="done"){f(n.report);return}if(n.kind==="failed"||n.kind==="empty"){f(void 0);return}if(n.kind==="fetching"||n.kind==="installing"){if(An(o,r).kind==="cancel")f(void 0);return}if(n.kind==="picking"){let m=An(o,r);switch(m.kind){case"move":case"toggle":case"all":M((N)=>SA(N,m.kind==="move"?{kind:"move",move:m.move}:{kind:m.kind},P));return;case"none-selected":M((N)=>SA(N,{kind:"none"},P));return;case"confirm":if(h.chosen.length===0)return;if(S!==void 0)return I(S);if(s.length===1)return I(s[0]?.manifestPath??"");c({kind:"agent"});return;case"cancel":f(void 0);return;case"none":return}}let a=mt(o,r);switch(a.kind){case"move":A((m)=>_e(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":f(void 0);return;case"none":return}},{isActive:T});let z=h.chosen.length,p={title:v,summary:K(n,x.length,z)};if(n.kind==="fetching")return y(k,{header:p,footer:[{key:"esc",does:"stop waiting"}],children:[t(g,{marginLeft:2,children:t(nt,{label:n.status})}),t(g,{marginLeft:2,marginTop:1,children:t(u,{dimColor:!0,children:"once per machine, shared by every agent on it"})})]});if(n.kind==="failed")return t(k,{header:p,footer:[{key:"any key",does:"back"}],children:t(g,{marginLeft:2,children:y(u,{color:i.error,children:[b.error,n.message]})})});if(n.kind==="empty")return t(k,{header:p,footer:[{key:"any key",does:"back"}],children:y(g,{marginLeft:2,flexDirection:"column",children:[t(u,{color:i.muted,children:"no catalogue could be read"}),t(u,{dimColor:!0,children:"`sources update` reports why"})]})});if(n.kind==="installing")return t(k,{header:p,children:t(g,{marginLeft:2,children:t(nt,{label:`installing ${n.count} skill${n.count===1?"":"s"}`})})});if(n.kind==="done")return t(k,{header:p,footer:[{key:"any key",does:"back"}],children:t(F,{report:n.report})});if(n.kind==="agent")return t(k,{header:p,footer:[{key:"↑↓",does:"move"},{key:"enter",does:"install"},{key:"esc",does:"back"}],children:t(At,{items:s.map((o)=>({label:o.name??o.ref,hint:o.problem===void 0?`${o.modelId??"?"} ${b.bullet}${o.ref}`:`⚠ ${o.problem}`})),index:_.index,numbered:!0})});return t(k,{header:p,footer:[{key:"↑↓",does:"move"},{key:"space",does:"tick"},{key:"a/n",does:"all/none"},{key:"enter",does:S===void 0?"continue":"install"},Zs],children:t(Ln,{rows:x,index:h.cursor.index,chosen:h.chosen,window:d,width:C.columns})})}function K(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 F({report:e}){return y(g,{flexDirection:"column",marginLeft:2,children:[y(u,{color:e.failed.length===0?i.success:i.warning,children:[b.check,`installed ${e.installed.length} of ${e.total} skill${e.total===1?"":"s"}`]}),e.installed.length>0?t(u,{dimColor:!0,wrap:"truncate",children:e.installed.join(", ")}):null,e.failed.map((l)=>y(u,{color:i.error,wrap:"truncate",children:[b.error,l.name," — ",l.reason]},l.name)),e.runnable>0?t(g,{marginTop:1,children:t(u,{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(g,{marginTop:1,children:t(u,{dimColor:!0,children:"restart the agent: the catalogue is scanned once at boot"})})]})}export{ke as SkillBrowser};
3
+
4
+ //# debugId=F89F0E23892C60C864756E2164756E21
5
+ //# sourceMappingURL=SkillBrowser-qc542n71.js.map
@@ -6,6 +6,6 @@
6
6
  "/**\n * The frame every surface renders inside: header, body, footer.\n *\n * Replaces the three hand-rolled banners that came before it. `Banner` stays for what it is good at —\n * a title and some dim lines — and this composes it with the two things every screen also needed and\n * each solved separately: a live state row, and a footer saying what the keys do.\n *\n * ## It measures the terminal itself\n *\n * Width comes from `useTerminalSize()` rather than from a prop. The alternative was tried and is what\n * shipped in Phase 5: the caller measured once, passed numbers down, and a resized terminal left\n * every row laid out for a width that no longer existed. A component that reads the size cannot\n * forget to, and there is exactly one hook doing it.\n *\n * The clamps stay the kit's rather than the measurement's, because they are policy — 40 columns is\n * where a description column stops being worth having, 140 is where a description stops belonging on\n * the same line as its name. They are applied to the *live* value here.\n *\n * ## No input, no exit\n *\n * Presentational, like every component in this kit: it renders what it is given and owns no keyboard.\n * The focused surface owns the single `useInput`, and this is never it.\n */\n\nimport { Box, Text } from \"ink\"\nimport type { ReactNode } from \"react\"\nimport { useTerminalSize } from \"#hooks/useTerminalSize\"\nimport { MAX_SCREEN_COLUMNS, MIN_SCREEN_COLUMNS } from \"#lib/const\"\nimport {\n type HeaderLine,\n headerLines,\n hintLine,\n type KeyHint,\n type ScreenHeader,\n type StateChip,\n} from \"#lib/screen\"\nimport { BORDER_STYLE, THEME } from \"#lib/theme\"\n\nexport interface ScreenProps {\n readonly header: ScreenHeader\n readonly footer?: readonly KeyHint[]\n /**\n * Optional: a screen whose whole content is its header is a real screen — a one-line report, or a\n * list that came back empty. Required, it also made `createElement(Screen, props, body)` a type\n * error, because the third argument is not matched against a mandatory `children` prop.\n */\n readonly children?: ReactNode\n}\n\n/** Chip tone → colour. The pure module names a role; the mapping to a colour lives with the theme. */\nconst TONE: Record<StateChip[\"tone\"], string> = {\n ok: THEME.success,\n warn: THEME.warning,\n off: THEME.muted,\n}\n\n/** Header line kind → how it is drawn. Exhaustive, so a new kind is a type error rather than a plain line. */\nconst LINE_STYLE: Record<\n HeaderLine[\"kind\"],\n { readonly color?: string; readonly dim?: boolean; readonly bold?: boolean }\n> = {\n title: { color: THEME.accent, bold: true },\n summary: { dim: true },\n state: {},\n warning: { color: THEME.warning },\n}\n\n/** The live columns, clamped. Exported so a body lays its rows out against the same number. */\nexport function screenWidth(columns: number): number {\n return Math.max(MIN_SCREEN_COLUMNS, Math.min(MAX_SCREEN_COLUMNS, columns))\n}\n\nexport function Screen({ header, footer, children }: ScreenProps) {\n const size = useTerminalSize()\n const width = screenWidth(size.columns)\n // Two columns for the border, two for the padding: what the header may actually use.\n const inner = width - 4\n const lines = headerLines(header, inner)\n const chips = header.state ?? []\n\n return (\n <Box flexDirection=\"column\" width={width}>\n <Box\n flexDirection=\"column\"\n borderStyle={BORDER_STYLE}\n borderColor={THEME.borderActive}\n paddingX={1}\n >\n {lines.map((line) =>\n // The state row is the one line whose parts are coloured individually, so it is\n // rendered from the chips rather than from its own already-joined text. The text is\n // still what the tests read, and the two cannot disagree because `headerLines`\n // built that string from the same array.\n line.kind === \"state\" ? (\n <Text key={line.text} wrap=\"truncate\">\n {chips.map((chip, at) => (\n <Text key={chip.label} color={TONE[chip.tone]}>\n {at === 0 ? \"\" : \" · \"}\n {chip.label}\n </Text>\n ))}\n </Text>\n ) : (\n <Text\n key={line.text}\n wrap=\"truncate\"\n bold={LINE_STYLE[line.kind].bold === true}\n dimColor={LINE_STYLE[line.kind].dim === true}\n {...(LINE_STYLE[line.kind].color === undefined\n ? {}\n : { color: LINE_STYLE[line.kind].color })}\n >\n {line.text}\n </Text>\n ),\n )}\n </Box>\n\n <Box flexDirection=\"column\" marginTop={1}>\n {children}\n </Box>\n\n {footer === undefined || footer.length === 0 ? null : (\n <Box marginTop={1}>\n <Text dimColor wrap=\"truncate\">\n {\" \"}\n {hintLine(footer, inner)}\n </Text>\n </Box>\n )}\n </Box>\n )\n}\n"
7
7
  ],
8
8
  "mappings": ";yWAsBA,cAAS,UAAK,cAAM,YACpB,sBAAS,eAAa,cAAW,cCCjC,cAAS,UAAK,8DA0Bd,IAAM,EAA0C,CAC5C,GAAI,EAAM,QACV,KAAM,EAAM,QACZ,IAAK,EAAM,KACf,EAGM,EAGF,CACA,MAAO,CAAE,MAAO,EAAM,OAAQ,KAAM,EAAK,EACzC,QAAS,CAAE,IAAK,EAAK,EACrB,MAAO,CAAC,EACR,QAAS,CAAE,MAAO,EAAM,OAAQ,CACpC,EAGO,SAAS,CAAW,C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d,IAAK,UACD,OAAO,IAAW,EACZ,GAAG,8BACH,GAAG,eAAoB,UAUzC,SAAS,CAAU,EAAG,UAA8C,CAChE,OACI,EAAC,EAAD,CAAK,cAAc,SAAS,WAAY,EAAxC,SA0BE,CAzBE,EAAC,EAAD,CAAM,MAAO,EAAO,OAAO,SAAW,EAAI,EAAM,QAAU,EAAM,QAAhE,SAGE,CAFG,EAAM,MACN,aAAa,EAAO,UAAU,aAAa,EAAO,cAAc,EAAO,QAAU,EAAI,GAAK,OAC7F,EACD,EAAO,UAAU,OAAS,EACvB,EAAC,EAAD,CAAM,SAAQ,GAAC,KAAK,WAApB,SACK,EAAO,UAAU,KAAK,IAAI,EAC7B,EACF,KACH,EAAO,OAAO,IAAI,CAAC,IAChB,EAAC,EAAD,CAAyB,MAAO,EAAM,MAAO,KAAK,WAAlD,SAGE,CAFG,EAAM,MACN,EAAQ,KAFb,MAEsB,EAAQ,SAFnB,EAAQ,IAGjB,CACL,EACA,EAAO,SAAW,EACf,EAAC,EAAD,CAAK,UAAW,EAAhB,SACI,EAAC,EAAD,CAAM,SAAQ,GAAC,KAAK,WAApB,SACK,GAAG,EAAO,yBAAyB,EAAO,WAAa,EAAI,GAAK,cAAc,EAAO,iBAAiB,EAAO,WAAa,EAAI,GAAK,mDACtI,EACJ,EACF,KACJ,EAAC,EAAD,CAAK,UAAW,EAAhB,SACI,EAAC,EAAD,CAAM,SAAQ,GAAd,oEAAyE,EAC3E,GACJ",
9
- "debugId": "CDD7006C9D9EB02E64756E2164756E21",
9
+ "debugId": "F89F0E23892C60C864756E2164756E21",
10
10
  "names": []
11
11
  }
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import{N,E,p,xo,a,v,Ho,M,P,O,ft}from"./index-g1d06ct5.js";import{I}from"./index-t6xnecdx.js";var f=[6000,8000,9600,11025,12000,16000,22050,24000,32000,44100,48000,64000,88200,96000,192000,-1],l={len:32,get:(t,e)=>{let i=a.get(t,e+24),o={BlockID:O.get(t,e),blockSize:a.get(t,e+4),version:p.get(t,e+8),totalSamples:a.get(t,e+12),blockIndex:a.get(t,e+16),blockSamples:a.get(t,e+20),flags:{bitsPerSample:(1+c(i,0,2))*8,isMono:s(i,2),isHybrid:s(i,3),isJointStereo:s(i,4),crossChannel:s(i,5),hybridNoiseShaping:s(i,6),floatingPoint:s(i,7),samplingRate:f[c(i,23,4)],isDSD:s(i,31)},crc:new v(4).get(t,e+28)};if(o.flags.isDSD)o.totalSamples*=8;return o}},m={len:1,get:(t,e)=>({functionId:c(t[e],0,6),isOptional:s(t[e],5),isOddSize:s(t[e],6),largeBlock:s(t[e],7)})};function s(t,e){return c(t,e,1)===1}function c(t,e,i){return t>>>e&4294967295>>>32-i}var h=I(N(),1);var n=h.default("music-metadata:parser:WavPack");class d extends M("WavPack"){}class u extends P{constructor(){super(...arguments);this.audioDataSize=0}async parse(){return this.metadata.setAudioOnly(),this.audioDataSize=0,await this.parseWavPackBlocks(),ft(this.metadata,this.tokenizer,this.options)}async parseWavPackBlocks(){do{if(await this.tokenizer.peekToken(O)!=="wvpk")break;let e=await this.tokenizer.readToken(l);if(e.BlockID!=="wvpk")throw new d("Invalid WavPack Block-ID");if(n(`WavPack header blockIndex=${e.blockIndex}, len=${l.len}`),e.blockIndex===0&&!this.metadata.format.container){if(this.metadata.setFormat("container","WavPack"),this.metadata.setFormat("lossless",!e.flags.isHybrid),this.metadata.setFormat("bitsPerSample",e.flags.bitsPerSample),!e.flags.isDSD)this.metadata.setFormat("sampleRate",e.flags.samplingRate),this.metadata.setFormat("duration",e.totalSamples/e.flags.samplingRate);this.metadata.setFormat("numberOfChannels",e.flags.isMono?1:2),this.metadata.setFormat("numberOfSamples",e.totalSamples),this.metadata.setFormat("codec",e.flags.isDSD?"DSD":"PCM")}let i=e.blockSize-(l.len-8);if(await(e.blockIndex===0?this.parseMetadataSubBlock(e,i):this.tokenizer.ignore(i)),e.blockSamples>0)this.audioDataSize+=e.blockSize}while(!this.tokenizer.fileInfo.size||this.tokenizer.fileInfo.size-this.tokenizer.position>=l.len);if(this.metadata.format.duration)this.metadata.setFormat("bitrate",this.audioDataSize*8/this.metadata.format.duration)}async parseMetadataSubBlock(t,e){let i=e;while(i>m.len){let o=await this.tokenizer.readToken(m),k=await this.tokenizer.readNumber(o.largeBlock?xo:E),r=new Uint8Array(k*2-(o.isOddSize?1:0));switch(await this.tokenizer.readBuffer(r),n(`Metadata Sub-Blocks functionId=0x${o.functionId.toString(16)}, id.largeBlock=${o.largeBlock},data-size=${r.length}`),o.functionId){case 0:break;case 14:{n("ID_DSD_BLOCK");let S=1<<E.get(r,0),g=t.flags.samplingRate*S*8;if(!t.flags.isDSD)throw new d("Only expect DSD block if DSD-flag is set");this.metadata.setFormat("sampleRate",g),this.metadata.setFormat("duration",t.totalSamples/g);break}case 36:n("ID_ALT_TRAILER: trailer for non-wav files");break;case 38:this.metadata.setFormat("audioMD5",r);break;case 47:n(`ID_BLOCK_CHECKSUM: checksum=${Ho(r)}`);break;default:n(`Ignore unsupported meta-sub-block-id functionId=0x${o.functionId.toString(16)}`);break}if(i-=m.len+(o.largeBlock?xo.len:E.len)+k*2,n(`remainingLength=${i}`),o.isOddSize)this.tokenizer.ignore(1)}if(i!==0)throw new d("metadata-sub-block should fit it remaining length")}}export{u as WavPackParser};
2
+ import{N,C,f,Ko,a,L,Yo,M,P,O,hA}from"./index-ew997be5.js";import{I}from"./index-323jvr1g.js";var T=[6000,8000,9600,11025,12000,16000,22050,24000,32000,44100,48000,64000,88200,96000,192000,-1],l={len:32,get:(t,e)=>{let i=a.get(t,e+24),o={BlockID:O.get(t,e),blockSize:a.get(t,e+4),version:f.get(t,e+8),totalSamples:a.get(t,e+12),blockIndex:a.get(t,e+16),blockSamples:a.get(t,e+20),flags:{bitsPerSample:(1+c(i,0,2))*8,isMono:s(i,2),isHybrid:s(i,3),isJointStereo:s(i,4),crossChannel:s(i,5),hybridNoiseShaping:s(i,6),floatingPoint:s(i,7),samplingRate:T[c(i,23,4)],isDSD:s(i,31)},crc:new L(4).get(t,e+28)};if(o.flags.isDSD)o.totalSamples*=8;return o}},m={len:1,get:(t,e)=>({functionId:c(t[e],0,6),isOptional:s(t[e],5),isOddSize:s(t[e],6),largeBlock:s(t[e],7)})};function s(t,e){return c(t,e,1)===1}function c(t,e,i){return t>>>e&4294967295>>>32-i}var g=I(N(),1);var n=g.default("music-metadata:parser:WavPack");class d extends M("WavPack"){}class u extends P{constructor(){super(...arguments);this.audioDataSize=0}async parse(){return this.metadata.setAudioOnly(),this.audioDataSize=0,await this.parseWavPackBlocks(),hA(this.metadata,this.tokenizer,this.options)}async parseWavPackBlocks(){do{if(await this.tokenizer.peekToken(O)!=="wvpk")break;let e=await this.tokenizer.readToken(l);if(e.BlockID!=="wvpk")throw new d("Invalid WavPack Block-ID");if(n(`WavPack header blockIndex=${e.blockIndex}, len=${l.len}`),e.blockIndex===0&&!this.metadata.format.container){if(this.metadata.setFormat("container","WavPack"),this.metadata.setFormat("lossless",!e.flags.isHybrid),this.metadata.setFormat("bitsPerSample",e.flags.bitsPerSample),!e.flags.isDSD)this.metadata.setFormat("sampleRate",e.flags.samplingRate),this.metadata.setFormat("duration",e.totalSamples/e.flags.samplingRate);this.metadata.setFormat("numberOfChannels",e.flags.isMono?1:2),this.metadata.setFormat("numberOfSamples",e.totalSamples),this.metadata.setFormat("codec",e.flags.isDSD?"DSD":"PCM")}let i=e.blockSize-(l.len-8);if(await(e.blockIndex===0?this.parseMetadataSubBlock(e,i):this.tokenizer.ignore(i)),e.blockSamples>0)this.audioDataSize+=e.blockSize}while(!this.tokenizer.fileInfo.size||this.tokenizer.fileInfo.size-this.tokenizer.position>=l.len);if(this.metadata.format.duration)this.metadata.setFormat("bitrate",this.audioDataSize*8/this.metadata.format.duration)}async parseMetadataSubBlock(t,e){let i=e;while(i>m.len){let o=await this.tokenizer.readToken(m),k=await this.tokenizer.readNumber(o.largeBlock?Ko:C),r=new Uint8Array(k*2-(o.isOddSize?1:0));switch(await this.tokenizer.readBuffer(r),n(`Metadata Sub-Blocks functionId=0x${o.functionId.toString(16)}, id.largeBlock=${o.largeBlock},data-size=${r.length}`),o.functionId){case 0:break;case 14:{n("ID_DSD_BLOCK");let h=1<<C.get(r,0),p=t.flags.samplingRate*h*8;if(!t.flags.isDSD)throw new d("Only expect DSD block if DSD-flag is set");this.metadata.setFormat("sampleRate",p),this.metadata.setFormat("duration",t.totalSamples/p);break}case 36:n("ID_ALT_TRAILER: trailer for non-wav files");break;case 38:this.metadata.setFormat("audioMD5",r);break;case 47:n(`ID_BLOCK_CHECKSUM: checksum=${Yo(r)}`);break;default:n(`Ignore unsupported meta-sub-block-id functionId=0x${o.functionId.toString(16)}`);break}if(i-=m.len+(o.largeBlock?Ko.len:C.len)+k*2,n(`remainingLength=${i}`),o.isOddSize)this.tokenizer.ignore(1)}if(i!==0)throw new d("metadata-sub-block should fit it remaining length")}}export{u as WavPackParser};
3
3
 
4
- //# debugId=EB3A5C76A667237364756E2164756E21
5
- //# sourceMappingURL=WavPackParser-b4qqavzg.js.map
4
+ //# debugId=E3AA932F5DECE66E64756E2164756E21
5
+ //# sourceMappingURL=WavPackParser-kt7cds9c.js.map
@@ -6,6 +6,6 @@
6
6
  "import * as Token from 'token-types';\nimport { tryParseApeHeader } from '../apev2/APEv2Parser.js';\nimport { FourCcToken } from '../common/FourCC.js';\nimport { BasicParser } from '../common/BasicParser.js';\nimport { BlockHeaderToken, MetadataIdToken } from './WavPackToken.js';\nimport initDebug from 'debug';\nimport { uint8ArrayToHex } from 'uint8array-extras';\nimport { makeUnexpectedFileContentError } from '../ParseError.js';\nconst debug = initDebug('music-metadata:parser:WavPack');\nexport class WavPackContentError extends makeUnexpectedFileContentError('WavPack') {\n}\n/**\n * WavPack Parser\n */\nexport class WavPackParser extends BasicParser {\n constructor() {\n super(...arguments);\n this.audioDataSize = 0;\n }\n async parse() {\n this.metadata.setAudioOnly();\n this.audioDataSize = 0;\n // First parse all WavPack blocks\n await this.parseWavPackBlocks();\n // try to parse APEv2 header\n return tryParseApeHeader(this.metadata, this.tokenizer, this.options);\n }\n async parseWavPackBlocks() {\n do {\n const blockId = await this.tokenizer.peekToken(FourCcToken);\n if (blockId !== 'wvpk')\n break;\n const header = await this.tokenizer.readToken(BlockHeaderToken);\n if (header.BlockID !== 'wvpk')\n throw new WavPackContentError('Invalid WavPack Block-ID');\n debug(`WavPack header blockIndex=${header.blockIndex}, len=${BlockHeaderToken.len}`);\n if (header.blockIndex === 0 && !this.metadata.format.container) {\n this.metadata.setFormat('container', 'WavPack');\n this.metadata.setFormat('lossless', !header.flags.isHybrid);\n // tagTypes: this.type,\n this.metadata.setFormat('bitsPerSample', header.flags.bitsPerSample);\n if (!header.flags.isDSD) {\n // In case isDSD, these values will ne set in ID_DSD_BLOCK\n this.metadata.setFormat('sampleRate', header.flags.samplingRate);\n this.metadata.setFormat('duration', header.totalSamples / header.flags.samplingRate);\n }\n this.metadata.setFormat('numberOfChannels', header.flags.isMono ? 1 : 2);\n this.metadata.setFormat('numberOfSamples', header.totalSamples);\n this.metadata.setFormat('codec', header.flags.isDSD ? 'DSD' : 'PCM');\n }\n const ignoreBytes = header.blockSize - (BlockHeaderToken.len - 8);\n await (header.blockIndex === 0 ? this.parseMetadataSubBlock(header, ignoreBytes) : this.tokenizer.ignore(ignoreBytes));\n if (header.blockSamples > 0) {\n this.audioDataSize += header.blockSize; // Count audio data for bit-rate calculation\n }\n } while (!this.tokenizer.fileInfo.size || this.tokenizer.fileInfo.size - this.tokenizer.position >= BlockHeaderToken.len);\n if (this.metadata.format.duration) {\n this.metadata.setFormat('bitrate', this.audioDataSize * 8 / this.metadata.format.duration);\n }\n }\n /**\n * Ref: http://www.wavpack.com/WavPack5FileFormat.pdf, 3.0 Metadata Sub-blocks\n * @param header Header\n * @param remainingLength Remaining length\n */\n async parseMetadataSubBlock(header, remainingLength) {\n let remaining = remainingLength;\n while (remaining > MetadataIdToken.len) {\n const id = await this.tokenizer.readToken(MetadataIdToken);\n const dataSizeInWords = await this.tokenizer.readNumber(id.largeBlock ? Token.UINT24_LE : Token.UINT8);\n const data = new Uint8Array(dataSizeInWords * 2 - (id.isOddSize ? 1 : 0));\n await this.tokenizer.readBuffer(data);\n debug(`Metadata Sub-Blocks functionId=0x${id.functionId.toString(16)}, id.largeBlock=${id.largeBlock},data-size=${data.length}`);\n switch (id.functionId) {\n case 0x0: // ID_DUMMY: could be used to pad WavPack blocks\n break;\n case 0xe: { // ID_DSD_BLOCK\n debug('ID_DSD_BLOCK');\n // https://github.com/dbry/WavPack/issues/71#issuecomment-483094813\n const mp = 1 << Token.UINT8.get(data, 0);\n const samplingRate = header.flags.samplingRate * mp * 8; // ToDo: second factor should be read from DSD-metadata block https://github.com/dbry/WavPack/issues/71#issuecomment-483094813\n if (!header.flags.isDSD)\n throw new WavPackContentError('Only expect DSD block if DSD-flag is set');\n this.metadata.setFormat('sampleRate', samplingRate);\n this.metadata.setFormat('duration', header.totalSamples / samplingRate);\n break;\n }\n case 0x24: // ID_ALT_TRAILER: maybe used to embed original ID3 tag header\n debug('ID_ALT_TRAILER: trailer for non-wav files');\n break;\n case 0x26: // ID_MD5_CHECKSUM\n this.metadata.setFormat('audioMD5', data);\n break;\n case 0x2f: // ID_BLOCK_CHECKSUM\n debug(`ID_BLOCK_CHECKSUM: checksum=${uint8ArrayToHex(data)}`);\n break;\n default:\n debug(`Ignore unsupported meta-sub-block-id functionId=0x${id.functionId.toString(16)}`);\n break;\n }\n remaining -= MetadataIdToken.len + (id.largeBlock ? Token.UINT24_LE.len : Token.UINT8.len) + dataSizeInWords * 2;\n debug(`remainingLength=${remaining}`);\n if (id.isOddSize)\n this.tokenizer.ignore(1);\n }\n if (remaining !== 0)\n throw new WavPackContentError('metadata-sub-block should fit it remaining length');\n }\n}\n"
7
7
  ],
8
8
  "mappings": ";6FAEA,IAAM,EAAc,CAAC,KAAM,KAAM,KAAM,MAAO,MAAO,MAAO,MAAO,MAAO,MAAO,MAC7E,MAAO,MAAO,MAAO,MAAO,OAA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ACH,KAAK,UAAU,OAAO,CAAC,EAE/B,GAAI,IAAc,EACd,MAAM,IAAI,EAAoB,mDAAmD,EAE7F",
9
- "debugId": "EB3A5C76A667237364756E2164756E21",
9
+ "debugId": "E3AA932F5DECE66E64756E2164756E21",
10
10
  "names": []
11
11
  }
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import{h,Ne,N,p,a,v,l,M,xe,P,O}from"./index-g1d06ct5.js";import{Qe}from"./index-0v2gw4mk.js";import{I}from"./index-t6xnecdx.js";var A=I(N(),1);var o={len:8,get:(t,e)=>({chunkID:new l(4,"latin1").get(t,e),chunkSize:a.get(t,e+4)})};class d{constructor(t){this.tagHeader=t,this.len=t.chunkSize,this.len+=this.len&1}get(t,e){return new l(this.tagHeader.chunkSize,"utf8").get(t,e)}}class c extends M("Wave"){}var i={PCM:1,ADPCM:2,IEEE_FLOAT:3,ALAW:6,MULAW:7,DVI_ADPCM:17,GSM610:49,MPEG_ADTS_AAC:5632,MPEG_LOAS:5634,RAW_AAC1:255,DOLBY_AC3_SPDIF:146,DVM:8192,RAW_SPORT:576,ESST_AC3:577,DRM:9,DTS2:8193,MPEG:80,MPEGLAYER3:85},S={[i.PCM]:"PCM",[i.ADPCM]:"ADPCM",[i.IEEE_FLOAT]:"IEEE_FLOAT",[i.ALAW]:"ALAW",[i.MULAW]:"MULAW",[i.DVI_ADPCM]:"DVI_ADPCM",[i.GSM610]:"GSM610",[i.MPEG_ADTS_AAC]:"MPEG_ADTS_AAC",[i.MPEG_LOAS]:"MPEG_LOAS",[i.RAW_AAC1]:"RAW_AAC1",[i.DOLBY_AC3_SPDIF]:"DOLBY_AC3_SPDIF",[i.DVM]:"DVM",[i.RAW_SPORT]:"RAW_SPORT",[i.ESST_AC3]:"ESST_AC3",[i.DRM]:"DRM",[i.DTS2]:"DTS2",[i.MPEG]:"MPEG",[i.MPEGLAYER3]:"MPEGLAYER3"};class T{constructor(t){if(t.chunkSize<16)throw new c("Invalid chunk size");this.len=t.chunkSize}get(t,e){return{wFormatTag:p.get(t,e),nChannels:p.get(t,e+2),nSamplesPerSec:a.get(t,e+4),nAvgBytesPerSec:a.get(t,e+8),nBlockAlign:p.get(t,e+12),wBitsPerSample:p.get(t,e+14)}}}class g{constructor(t){if(t.chunkSize<4)throw new c("Invalid fact chunk size.");this.len=t.chunkSize}get(t,e){return{dwSampleLength:a.get(t,e)}}}var u={len:420,get:(t,e)=>({description:xe(new l(256,"ascii").get(t,e)).trim(),originator:xe(new l(32,"ascii").get(t,e+256)).trim(),originatorReference:xe(new l(32,"ascii").get(t,e+288)).trim(),originationDate:xe(new l(10,"ascii").get(t,e+320)).trim(),originationTime:xe(new l(8,"ascii").get(t,e+330)).trim(),timeReferenceLow:a.get(t,e+338),timeReferenceHigh:a.get(t,e+342),version:p.get(t,e+346),umid:new v(64).get(t,e+348),loudnessValue:p.get(t,e+412),maxTruePeakLevel:p.get(t,e+414),maxMomentaryLoudness:p.get(t,e+416),maxShortTermLoudness:p.get(t,e+418)})};var r=A.default("music-metadata:parser:RIFF");class w extends P{constructor(){super(...arguments);this.blockAlign=0,this.avgBytesPerSec=0}async parse(){let t=await this.tokenizer.readToken(o);if(r(`pos=${this.tokenizer.position}, parse: chunkID=${t.chunkID}`),t.chunkID!=="RIFF")return;return this.metadata.setAudioOnly(),this.parseRiffChunk(t.chunkSize).catch((e)=>{if(!(e instanceof h))throw e})}async parseRiffChunk(t){let e=await this.tokenizer.readToken(O);switch(this.metadata.setFormat("container",e),e){case"WAVE":return this.readWaveChunk(t-O.len);default:throw new c(`Unsupported RIFF format: RIFF/${e}`)}}async readWaveChunk(t){while(t>=o.len){let e=await this.tokenizer.readToken(o);if(t-=o.len+e.chunkSize,e.chunkSize>t)this.metadata.addWarning("Data chunk size exceeds file size");switch(this.header=e,r(`pos=${this.tokenizer.position}, readChunk: chunkID=RIFF/WAVE/${e.chunkID}`),e.chunkID){case"LIST":await this.parseListTag(e);break;case"fact":this.metadata.setFormat("lossless",!1),this.fact=await this.tokenizer.readToken(new g(e));break;case"fmt ":{let n=await this.tokenizer.readToken(new T(e)),s=S[n.wFormatTag];if(!s)r(`WAVE/non-PCM format=${n.wFormatTag}`),s=`non-PCM (${n.wFormatTag})`;this.metadata.setFormat("codec",s),this.metadata.setFormat("bitsPerSample",n.wBitsPerSample),this.metadata.setFormat("sampleRate",n.nSamplesPerSec),this.metadata.setFormat("numberOfChannels",n.nChannels),this.blockAlign=n.nBlockAlign,this.avgBytesPerSec=n.nAvgBytesPerSec;break}case"id3 ":case"ID3 ":{let n=await this.tokenizer.readToken(new v(e.chunkSize)),s=Ne(n);await new Qe().parse(this.metadata,s,this.options);break}case"data":{if(this.metadata.format.lossless!==!1)this.metadata.setFormat("lossless",!0);let n=e.chunkSize;if(this.tokenizer.fileInfo.size){let k=this.tokenizer.fileInfo.size-this.tokenizer.position;if(k<n)this.metadata.addWarning("data chunk length exceeding file length"),n=k}let s=this.fact?this.fact.dwSampleLength:n===4294967295?void 0:n/this.blockAlign;if(s){if(this.metadata.setFormat("numberOfSamples",s),this.metadata.format.sampleRate)this.metadata.setFormat("duration",s/this.metadata.format.sampleRate)}if(this.avgBytesPerSec>0)this.metadata.setFormat("bitrate",this.avgBytesPerSec*8);else if(this.metadata.format.duration)this.metadata.setFormat("bitrate",n*8/this.metadata.format.duration);await this.tokenizer.ignore(e.chunkSize);break}case"bext":{let n=await this.tokenizer.readToken(u);Object.keys(n).forEach((k)=>{this.metadata.addTag("exif",`bext.${k}`,n[k])});let s=e.chunkSize-u.len;await this.tokenizer.ignore(s);break}case"\x00\x00\x00\x00":r(`Ignore padding chunk: RIFF/${e.chunkID} of ${e.chunkSize} bytes`),this.metadata.addWarning(`Ignore chunk: RIFF/${e.chunkID}`),await this.tokenizer.ignore(e.chunkSize);break;default:r(`Ignore chunk: RIFF/${e.chunkID} of ${e.chunkSize} bytes`),this.metadata.addWarning(`Ignore chunk: RIFF/${e.chunkID}`),await this.tokenizer.ignore(e.chunkSize)}if(this.header.chunkSize%2===1)r("Read odd padding byte"),await this.tokenizer.ignore(1)}}async parseListTag(t){let e=await this.tokenizer.readToken(new l(4,"latin1"));switch(r("pos=%s, parseListTag: chunkID=RIFF/WAVE/LIST/%s",this.tokenizer.position,e),e){case"INFO":return this.parseRiffInfoTags(t.chunkSize-4);default:return this.metadata.addWarning(`Ignore chunk: RIFF/WAVE/LIST/${e}`),r(`Ignoring chunkID=RIFF/WAVE/LIST/${e}`),this.tokenizer.ignore(t.chunkSize-4).then()}}async parseRiffInfoTags(t){while(t>=8){let e=await this.tokenizer.readToken(o),n=new d(e),s=await this.tokenizer.readToken(n);this.addTag(e.chunkID,xe(s)),t-=8+n.len}if(t!==0)throw new c(`Illegal remaining size: ${t}`)}addTag(t,e){this.metadata.addTag("exif",t,e)}}export{w as WaveParser};
2
+ import{B,Me,N,f,a,L,l,M,Ke,P,O}from"./index-ew997be5.js";import{Qe}from"./index-fa9wvpyw.js";import{I}from"./index-323jvr1g.js";var p=I(N(),1);var o={len:8,get:(t,e)=>({chunkID:new l(4,"latin1").get(t,e),chunkSize:a.get(t,e+4)})};class m{constructor(t){this.tagHeader=t,this.len=t.chunkSize,this.len+=this.len&1}get(t,e){return new l(this.tagHeader.chunkSize,"utf8").get(t,e)}}class h extends M("Wave"){}var i={PCM:1,ADPCM:2,IEEE_FLOAT:3,ALAW:6,MULAW:7,DVI_ADPCM:17,GSM610:49,MPEG_ADTS_AAC:5632,MPEG_LOAS:5634,RAW_AAC1:255,DOLBY_AC3_SPDIF:146,DVM:8192,RAW_SPORT:576,ESST_AC3:577,DRM:9,DTS2:8193,MPEG:80,MPEGLAYER3:85},u={[i.PCM]:"PCM",[i.ADPCM]:"ADPCM",[i.IEEE_FLOAT]:"IEEE_FLOAT",[i.ALAW]:"ALAW",[i.MULAW]:"MULAW",[i.DVI_ADPCM]:"DVI_ADPCM",[i.GSM610]:"GSM610",[i.MPEG_ADTS_AAC]:"MPEG_ADTS_AAC",[i.MPEG_LOAS]:"MPEG_LOAS",[i.RAW_AAC1]:"RAW_AAC1",[i.DOLBY_AC3_SPDIF]:"DOLBY_AC3_SPDIF",[i.DVM]:"DVM",[i.RAW_SPORT]:"RAW_SPORT",[i.ESST_AC3]:"ESST_AC3",[i.DRM]:"DRM",[i.DTS2]:"DTS2",[i.MPEG]:"MPEG",[i.MPEGLAYER3]:"MPEGLAYER3"};class d{constructor(t){if(t.chunkSize<16)throw new h("Invalid chunk size");this.len=t.chunkSize}get(t,e){return{wFormatTag:f.get(t,e),nChannels:f.get(t,e+2),nSamplesPerSec:a.get(t,e+4),nAvgBytesPerSec:a.get(t,e+8),nBlockAlign:f.get(t,e+12),wBitsPerSample:f.get(t,e+14)}}}class T{constructor(t){if(t.chunkSize<4)throw new h("Invalid fact chunk size.");this.len=t.chunkSize}get(t,e){return{dwSampleLength:a.get(t,e)}}}var g={len:420,get:(t,e)=>({description:Ke(new l(256,"ascii").get(t,e)).trim(),originator:Ke(new l(32,"ascii").get(t,e+256)).trim(),originatorReference:Ke(new l(32,"ascii").get(t,e+288)).trim(),originationDate:Ke(new l(10,"ascii").get(t,e+320)).trim(),originationTime:Ke(new l(8,"ascii").get(t,e+330)).trim(),timeReferenceLow:a.get(t,e+338),timeReferenceHigh:a.get(t,e+342),version:f.get(t,e+346),umid:new L(64).get(t,e+348),loudnessValue:f.get(t,e+412),maxTruePeakLevel:f.get(t,e+414),maxMomentaryLoudness:f.get(t,e+416),maxShortTermLoudness:f.get(t,e+418)})};var r=p.default("music-metadata:parser:RIFF");class F extends P{constructor(){super(...arguments);this.blockAlign=0,this.avgBytesPerSec=0}async parse(){let t=await this.tokenizer.readToken(o);if(r(`pos=${this.tokenizer.position}, parse: chunkID=${t.chunkID}`),t.chunkID!=="RIFF")return;return this.metadata.setAudioOnly(),this.parseRiffChunk(t.chunkSize).catch((e)=>{if(!(e instanceof B))throw e})}async parseRiffChunk(t){let e=await this.tokenizer.readToken(O);switch(this.metadata.setFormat("container",e),e){case"WAVE":return this.readWaveChunk(t-O.len);default:throw new h(`Unsupported RIFF format: RIFF/${e}`)}}async readWaveChunk(t){while(t>=o.len){let e=await this.tokenizer.readToken(o);if(t-=o.len+e.chunkSize,e.chunkSize>t)this.metadata.addWarning("Data chunk size exceeds file size");switch(this.header=e,r(`pos=${this.tokenizer.position}, readChunk: chunkID=RIFF/WAVE/${e.chunkID}`),e.chunkID){case"LIST":await this.parseListTag(e);break;case"fact":this.metadata.setFormat("lossless",!1),this.fact=await this.tokenizer.readToken(new T(e));break;case"fmt ":{let n=await this.tokenizer.readToken(new d(e)),s=u[n.wFormatTag];if(!s)r(`WAVE/non-PCM format=${n.wFormatTag}`),s=`non-PCM (${n.wFormatTag})`;this.metadata.setFormat("codec",s),this.metadata.setFormat("bitsPerSample",n.wBitsPerSample),this.metadata.setFormat("sampleRate",n.nSamplesPerSec),this.metadata.setFormat("numberOfChannels",n.nChannels),this.blockAlign=n.nBlockAlign,this.avgBytesPerSec=n.nAvgBytesPerSec;break}case"id3 ":case"ID3 ":{let n=await this.tokenizer.readToken(new L(e.chunkSize)),s=Me(n);await new Qe().parse(this.metadata,s,this.options);break}case"data":{if(this.metadata.format.lossless!==!1)this.metadata.setFormat("lossless",!0);let n=e.chunkSize;if(this.tokenizer.fileInfo.size){let c=this.tokenizer.fileInfo.size-this.tokenizer.position;if(c<n)this.metadata.addWarning("data chunk length exceeding file length"),n=c}let s=this.fact?this.fact.dwSampleLength:n===4294967295?void 0:n/this.blockAlign;if(s){if(this.metadata.setFormat("numberOfSamples",s),this.metadata.format.sampleRate)this.metadata.setFormat("duration",s/this.metadata.format.sampleRate)}if(this.avgBytesPerSec>0)this.metadata.setFormat("bitrate",this.avgBytesPerSec*8);else if(this.metadata.format.duration)this.metadata.setFormat("bitrate",n*8/this.metadata.format.duration);await this.tokenizer.ignore(e.chunkSize);break}case"bext":{let n=await this.tokenizer.readToken(g);Object.keys(n).forEach((c)=>{this.metadata.addTag("exif",`bext.${c}`,n[c])});let s=e.chunkSize-g.len;await this.tokenizer.ignore(s);break}case"\x00\x00\x00\x00":r(`Ignore padding chunk: RIFF/${e.chunkID} of ${e.chunkSize} bytes`),this.metadata.addWarning(`Ignore chunk: RIFF/${e.chunkID}`),await this.tokenizer.ignore(e.chunkSize);break;default:r(`Ignore chunk: RIFF/${e.chunkID} of ${e.chunkSize} bytes`),this.metadata.addWarning(`Ignore chunk: RIFF/${e.chunkID}`),await this.tokenizer.ignore(e.chunkSize)}if(this.header.chunkSize%2===1)r("Read odd padding byte"),await this.tokenizer.ignore(1)}}async parseListTag(t){let e=await this.tokenizer.readToken(new l(4,"latin1"));switch(r("pos=%s, parseListTag: chunkID=RIFF/WAVE/LIST/%s",this.tokenizer.position,e),e){case"INFO":return this.parseRiffInfoTags(t.chunkSize-4);default:return this.metadata.addWarning(`Ignore chunk: RIFF/WAVE/LIST/${e}`),r(`Ignoring chunkID=RIFF/WAVE/LIST/${e}`),this.tokenizer.ignore(t.chunkSize-4).then()}}async parseRiffInfoTags(t){while(t>=8){let e=await this.tokenizer.readToken(o),n=new m(e),s=await this.tokenizer.readToken(n);this.addTag(e.chunkID,Ke(s)),t-=8+n.len}if(t!==0)throw new h(`Illegal remaining size: ${t}`)}addTag(t,e){this.metadata.addTag("exif",t,e)}}export{F as WaveParser};
3
3
 
4
- //# debugId=32D2831566970E9264756E2164756E21
5
- //# sourceMappingURL=WaveParser-fqs1h38f.js.map
4
+ //# debugId=6668E83D14ADEDA964756E2164756E21
5
+ //# sourceMappingURL=WaveParser-g47ja0vy.js.map
@@ -8,6 +8,6 @@
8
8
  "import * as Token from 'token-types';\nimport { stripNulls } from '../common/Util.js';\n/**\n * Broadcast Audio Extension Chunk\n * Ref: https://tech.ebu.ch/docs/tech/tech3285.pdf\n */\nexport const BroadcastAudioExtensionChunk = {\n len: 420,\n get: (uint8array, off) => {\n return {\n description: stripNulls(new Token.StringType(256, 'ascii').get(uint8array, off)).trim(),\n originator: stripNulls(new Token.StringType(32, 'ascii').get(uint8array, off + 256)).trim(),\n originatorReference: stripNulls(new Token.StringType(32, 'ascii').get(uint8array, off + 288)).trim(),\n originationDate: stripNulls(new Token.StringType(10, 'ascii').get(uint8array, off + 320)).trim(),\n originationTime: stripNulls(new Token.StringType(8, 'ascii').get(uint8array, off + 330)).trim(),\n timeReferenceLow: Token.UINT32_LE.get(uint8array, off + 338),\n timeReferenceHigh: Token.UINT32_LE.get(uint8array, off + 342),\n version: Token.UINT16_LE.get(uint8array, off + 346),\n umid: new Token.Uint8ArrayType(64).get(uint8array, off + 348),\n loudnessValue: Token.UINT16_LE.get(uint8array, off + 412),\n maxTruePeakLevel: Token.UINT16_LE.get(uint8array, off + 414),\n maxMomentaryLoudness: Token.UINT16_LE.get(uint8array, off + 416),\n maxShortTermLoudness: Token.UINT16_LE.get(uint8array, off + 418)\n };\n }\n};\n"
9
9
  ],
10
10
  "mappings": ";gIAEA,eCEO,IAAM,EAAS,CAClB,IAAK,EACL,IAAK,CAAC,EAAK,KACA,CAEH,QAAS,IAAU,EAAW,EAAG,QAAQ,EAAE,IAAI,EAAK,CAAG,EAEvD,UAAiB,EAAU,IAAI,EAAK,EAAM,CAAC,CAC/C,EAER,EAIO,MAAM,CAAiB,CAC1B,WAAW,CAAC,EAAW,CACnB,KAAK,UAAY,EACjB,KAAK,IAAM,EAAU,UACrB,KAAK,KAAO,KAAK,IAAM,EAE3B,GAAG,CAAC,EAAK,EAAK,CACV,OAAO,IAAU,EAAW,KAAK,UAAU,UAAW,MAAM,EAAE,IAAI,EAAK,CAAG,EAElF,CCzBO,MAAM,UAAyB,EAA+B,MAAM,CAAE,CAC7E,CAIO,IAAM,EAAa,CACtB,IAAK,EACL,MAAO,EACP,WAAY,EACZ,KAAM,EACN,MAAO,EACP,UAAW,GACX,OAAQ,GAER,cAAe,KACf,UAAW,KACX,SAAU,IAEV,gBAAiB,IACjB,IAAK,KACL,UAAW,IACX,SAAU,IACV,IAAK,EACL,KAAM,KACN,KAAM,GACN,WAAY,EAChB,EACa,EAAoB,EAC5B,EAAW,KAAM,OACj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AK,UAAU,OAAO,CAAC,SAInC,YAAY,CAAC,EAAY,CAC3B,IAAM,EAAW,MAAM,KAAK,UAAU,UAAU,IAAU,EAAW,EAAG,QAAQ,CAAC,EAEjF,OADA,EAAM,kDAAmD,KAAK,UAAU,SAAU,CAAQ,EAClF,GACJ,IAAK,OACD,OAAO,KAAK,kBAAkB,EAAW,UAAY,CAAC,EAC1D,QAGI,OAFA,KAAK,SAAS,WAAW,gCAAgC,GAAU,EACnE,EAAM,mCAAmC,GAAU,EAC5C,KAAK,UAAU,OAAO,EAAW,UAAY,CAAC,EAAE,KAAK,SAGlE,iBAAiB,CAAC,EAAW,CAC/B,MAAO,GAAa,EAAG,CACnB,IAAM,EAAS,MAAM,KAAK,UAAU,UAAe,CAAM,EACnD,EAAa,IAAS,EAAiB,CAAM,EAC7C,EAAQ,MAAM,KAAK,UAAU,UAAU,CAAU,EACvD,KAAK,OAAO,EAAO,QAAc,GAAW,CAAK,CAAC,EAClD,GAAc,EAAI,EAAW,IAEjC,GAAI,IAAc,EACd,MAAM,IAAI,EAAiB,2BAA2B,GAAW,EAGzE,MAAM,CAAC,EAAI,EAAO,CACd,KAAK,SAAS,OAAO,OAAQ,EAAI,CAAK,EAE9C",
11
- "debugId": "32D2831566970E9264756E2164756E21",
11
+ "debugId": "6668E83D14ADEDA964756E2164756E21",
12
12
  "names": []
13
13
  }
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+ import{t}from"./index-qg9bn980.js";import{qA,Mo}from"./index-2zjh5zd5.js";import{i,b,$e}from"./index-dzy19wtf.js";import"./index-r4ax3x4d.js";import"./index-haypwvzd.js";import{LA}from"./index-zce9gy22.js";import{QA}from"./index-nxhqf597.js";import{Rn,mA,_n}from"./index-snz49ndn.js";import{Ln,SA,Pn}from"./index-nvc24414.js";import{At,_e}from"./index-42e29zs4.js";import{nt}from"./index-1x8mzvz7.js";import"./index-p6ya59m6.js";import"./index-3826kf9t.js";import{Tn}from"./index-8edck2pr.js";import{je}from"./index-fbsrhcga.js";import{ze,Vt,FA,Cn,aA,Wt}from"./index-kjqksgch.js";import{he,Ge,An,Fn}from"./index-m6fqx0ch.js";import"./index-ynsvkqgb.js";import"./index-38gs9anh.js";import"./index-3vzf253k.js";import"./index-twn9bfm2.js";import{Pe,$s}from"./index-jc4kmfwa.js";import{be,vo,xo}from"./index-8tmv33mr.js";import{Box as p,Text as g,useApp as re,useInput as te}from"ink";import{useCallback as oe,useEffect as P,useReducer as ie,useState as ae}from"react";import{Box as j,Text as K}from"ink";import{jsx as N,jsxs as J}from"react/jsx-runtime";function _({rows:e}){let r=e.reduce((n,c)=>Math.max(n,c.label.length),0);return N(j,{flexDirection:"column",borderStyle:$e,borderColor:i.border,paddingX:1,paddingY:1,children:e.map((n)=>J(K,{children:[N(K,{dimColor:!0,children:n.label.padEnd(r+2)}),n.value]},n.label))})}import{Box as Q,Text as W}from"ink";import{jsx as A,jsxs as R}from"react/jsx-runtime";function Y({step:e,total:r,answered:n,hint:c,children:l}){let u=Math.max(18,...n.map((o)=>o.label.length+2));return R(Q,{flexDirection:"column",children:[n.map((o)=>R(W,{children:[A(W,{color:i.success,children:b.check}),A(W,{dimColor:!0,children:o.label.padEnd(u)}),o.value]},o.label)),A(Q,{flexDirection:"column",borderStyle:$e,borderColor:i.border,paddingX:1,paddingY:1,marginTop:n.length>0?1:0,children:l}),R(W,{dimColor:!0,children:["step ",e," of ",r," ",b.bullet,c]})]})}function H(e,r){let n={given:e,log:[],phase:"asking",editor:he,select:{index:0,count:ze.length},error:void 0,defaults:r};return m(n)===void 0?E(n):n}function y(e){return{...Object.fromEntries(e.log.map((n)=>[n.step,n.value])),...e.given}}function m(e){return aA(y(e),e.defaults)}function z(e){return e.phase==="asking"&&m(e)?.options!==void 0}function q(e){return m(e)?.options??[]}function U(e){let r=m(e)?.step;return e.phase==="asking"&&r!==void 0&&Cn.has(r)}function X(e){let r={...y(e)},n=0;for(;;){let l=aA(r,e.defaults);if(l===void 0)break;n+=1,r[l.step]=l.fallback===""?"(x)":l.fallback}let c=e.log.length+Object.keys(e.given).length;return{asked:c+(e.phase==="asking"?1:0),total:c+n}}var ee=2;function E(e){return{...e,phase:"confirm",editor:he,select:{index:0,count:ee},error:void 0}}function v(e){let r=aA(y(e),e.defaults),n=r?.options;return{editor:he,select:{index:ne(r),count:n===void 0?ze.length:n.length},error:void 0}}function ne(e){let r=e?.options;if(r===void 0)return 0;let n=Number(e?.fallback)-1;return Number.isInteger(n)&&n>=0&&n<r.length?n:0}function T(e,r){if(e.phase==="done"||e.phase==="aborted")return e;switch(r.kind){case"abort":return{...e,phase:"aborted"};case"edit":if(e.phase!=="asking")return e;return{...e,editor:Ge(e.editor,r.intent),error:void 0};case"list":{let n=r.intent;if(n.kind==="move")return{...e,select:_e(e.select,n.move),error:void 0};if(n.kind==="choose")return T(e,{kind:"commit"});if(n.kind==="back")return T(e,{kind:"back"});if(n.kind==="exit")return{...e,phase:"aborted"};return e}case"back":{if(e.phase==="confirm"){if(e.log.length===0)return{...e,phase:"asking",...v(e)};let l=e.log.slice(0,-1),u={...e,phase:"asking",log:l};return{...u,...v(u)}}if(e.log.length===0)return e;let n=e.log.slice(0,-1),c={...e,log:n};return{...c,...v(c)}}case"commit":{if(e.phase==="confirm")return e.select.index===0?{...e,phase:"done"}:T(e,{kind:"back"});let n=m(e);if(n===void 0)return E(e);let c=n.options!==void 0?n.options[e.select.index]?.value??"":e.editor.value.trim()===""?n.fallback:e.editor.value,l=Wt(n.step,c);if(!l.ok)return{...e,error:l.reason};let u={...e,log:[...e.log,{step:n.step,value:l.value}]},o={...u,...v(u)};return m(o)===void 0?E(o):o}}}function G(e){if(e==="")return"";if(e.length<=8)return"•".repeat(e.length);return`${e.slice(0,3)}${"•".repeat(6)}${e.slice(-2)}`}function V(e){let r=y(e),n=r.preset===void 0?void 0:Vt(r.preset),c=`${r.model??""} at ${r.region===void 0?r.baseUrl??"":`Bedrock ${r.region}`}`,l=r.apiKeyEnv??n?.apiKeyEnv,u=l===void 0?" (no key)":` (${l}=${r.apiKey===void 0||r.apiKey===""?"not set yet":G(r.apiKey)})`;return[{label:"agent",value:r.name??""},{label:"for",value:`${r.user??""} — ${r.purpose??""}`},{label:"endpoint",value:`${c}${u}`},{label:"directory",value:r.dir??FA(r.dirChoice,r.name,e.defaults)??""}]}function Z(e){let r={user:"Your name",name:"Agent name",purpose:"Purpose",preset:"Endpoint",model:"Model",baseUrl:"Base URL",region:"AWS region",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",whatsapp:"WhatsApp",whatsappNumber:"WhatsApp number",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 e.log.map((n)=>({label:r[n.step],value:Cn.has(n.step)?G(n.value):n.value}))}import{jsx as s,jsxs as k}from"react/jsx-runtime";var de=16,se=5;function Xe({title:e,given:r,defaults:n,onDone:c}){let{exit:l}=re(),u=je(),[o,f]=ae({kind:"idle"}),[d,x]=ie((a,h)=>T(a,h),void 0,()=>H(r,n)),B=oe((a)=>{c(a),l()},[c,l]),D=d.log.some((a)=>a.step==="skills"&&a.value==="find");if(P(()=>{if(!D||o.kind!=="idle")return;f({kind:"fetching",status:"reading the catalogue"}),(async()=>{try{let a=await LA({onStatus:(S)=>f({kind:"fetching",status:S})});if(a.length===0){f({kind:"failed",message:"no catalogue could be read — carrying on without skills"});return}let h=qA(a);f({kind:"picking",rows:a,picked:{cursor:{index:Pn(h),count:a.length},chosen:[]}})}catch(a){f({kind:"failed",message:a instanceof Error?a.message:String(a)})}})()},[D,o.kind]),P(()=>{if(o.kind!=="failed")return;let a=setTimeout(()=>f({kind:"done",refs:[]}),1400);return()=>clearTimeout(a)},[o]),P(()=>{if(d.phase==="done"){let a=o.kind==="done"?o.refs:[];B({...y(d),...a.length===0?{}:{skillsPick:a.join(",")}})}if(d.phase==="aborted")B(void 0)},[d,B,o]),te((a,h)=>{if(o.kind==="picking"){let O=o.rows,M=qA(O),w=An(a,h);switch(w.kind){case"move":case"toggle":case"all":f({...o,picked:SA(o.picked,w.kind==="move"?{kind:"move",move:w.move}:{kind:w.kind},M)});return;case"none-selected":f({...o,picked:SA(o.picked,{kind:"none"},M)});return;case"confirm":case"cancel":f({kind:"done",refs:w.kind==="cancel"?[]:Mo(O,o.picked.chosen).map((F)=>`${F.source}/${F.skill}`)});return;default:return}}if(o.kind==="fetching"||o.kind==="failed")return;let S=Fn(a,h,{select:z(d)||d.phase==="confirm",empty:d.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}}),d.phase==="done"||d.phase==="aborted")return null;if(o.kind==="fetching")return k(p,{flexDirection:"column",children:[s(QA,{title:"Skills",lines:["choosing what this agent knows how to do"]}),s(p,{marginTop:1,paddingLeft:2,children:s(nt,{label:o.status})})]});if(o.kind==="failed")return k(p,{flexDirection:"column",children:[s(QA,{title:"Skills",lines:["carrying on without them"]}),s(p,{marginTop:1,paddingLeft:2,children:s(g,{color:i.warning,children:o.message})})]});if(o.kind==="picking"){let a=o.picked.chosen.length;return k(p,{flexDirection:"column",children:[s(QA,{title:"Skills",lines:["space ticks · a all · n none · enter continues · esc skips"]}),s(p,{marginTop:1,children:s(Ln,{rows:o.rows,index:o.picked.cursor.index,chosen:o.picked.chosen,window:$s(void 0,vo),width:Pe(void 0,be)})}),s(p,{marginTop:1,paddingLeft:2,children:s(g,{color:a===0?i.muted:i.success,children:a===0?"nothing ticked — enter carries on without any":`${a} ticked`})})]})}let I=X(d),C=_n(t.name,{columns:Pe(u.columns,be)-mA,rows:Math.min(se,Math.max(0,u.rows-de))}),L=d.phase==="confirm"?"enter confirm · esc back · ^C quit — nothing written":"enter accepts · esc back · ^C quit — nothing written";return k(p,{flexDirection:"column",children:[C.lines.length>0?s(Rn,{lines:C.lines}):null,s(p,{marginTop:C.lines.length>0?1:0,children:k(g,{dimColor:!0,wrap:"truncate",children:[e," · a few questions — nothing is written until you confirm"]})}),d.phase==="confirm"?k(p,{flexDirection:"column",marginTop:1,children:[s(_,{rows:V(d)}),k(p,{marginTop:1,flexDirection:"column",children:[s(g,{children:"Write the files?"}),s(At,{items:[{label:"yes"},{label:"no, go back"}],index:d.select.index})]}),s(g,{dimColor:!0,children:L})]}):s(p,{marginTop:1,children:s(Y,{step:I.asked,total:I.total,answered:Z(d),hint:L,children:z(d)?k(p,{flexDirection:"column",children:[s(g,{children:m(d)?.prompt??""}),s(At,{items:q(d).map((a)=>({label:a.label,...a.hint===void 0?{}:{hint:a.hint}})),index:d.select.index,numbered:!0})]}):s(Tn,{label:m(d)?.prompt??"",editor:d.editor,columns:Pe(u.columns,be)-mA,maxRows:xo,placeholder:m(d)?.fallback??"",...d.error===void 0?{}:{error:d.error},...U(d)?{secret:!0}:{}})})}),d.error!==void 0&&(z(d)||d.phase==="confirm")?k(g,{color:i.error,children:[b.error,d.error]}):null]})}export{Xe as WizardApp};
3
+
4
+ //# debugId=9C127849AE4D264664756E2164756E21
5
+ //# sourceMappingURL=WizardApp-q4p979d1.js.map
@@ -5,9 +5,9 @@
5
5
  "/**\n * The init wizard's Ink root: one `useInput`, a pure reducer, and the kit.\n *\n * Deliberately NO `<Static>` anywhere here — answered lines are editable via esc-back, which is\n * incompatible with Static's write-once contract, and the whole wizard is a couple of dozen\n * dynamic rows with no streaming, so full-frame redraw is free. Do not \"optimise\" this into\n * Static; the transcript's constraints do not apply to a form.\n */\n\nimport { BRAND } from \"@dispach/core\"\nimport { Box, Text, useApp, useInput } from \"ink\"\nimport { useCallback, useEffect, useReducer, useState } from \"react\"\nimport { fetchCatalogue } from \"#browse\"\nimport { Banner } from \"#components/Banner\"\nimport { BRAND_INDENT, Brandmark } from \"#components/Brandmark\"\nimport { CheckList } from \"#components/CheckList\"\nimport { SelectList } from \"#components/SelectList\"\nimport { Spinner } from \"#components/Spinner\"\nimport { SummaryCard } from \"#components/SummaryCard\"\nimport { TextField } from \"#components/TextField\"\nimport { WizardFrame } from \"#components/WizardFrame\"\nimport { useTerminalSize } from \"#hooks/useTerminalSize\"\nimport { keyToCheckIntent, keyToWizardIntent } from \"#keymap\"\nimport { type BrowseRow, chosenEntries, selectableOf } from \"#lib/browse\"\nimport { FALLBACK_COLUMNS, FALLBACK_ROWS, FIELD_ROWS } from \"#lib/const\"\nimport type { PartialAnswers, QuestionDefaults } from \"#lib/init-flow\"\nimport { firstSelectable, type MultiSelectState, reduceMultiSelect } from \"#lib/multiselect\"\nimport { screenColumns, screenRows } from \"#lib/screen\"\nimport { GLYPH, THEME } from \"#lib/theme\"\nimport {\n answeredRows,\n currentQuestion,\n isSecretStep,\n isSelectStep,\n partialOf,\n reduceWizard,\n selectOptions,\n startWizard,\n stepCounts,\n summaryRows,\n type WizardState,\n} from \"#lib/wizard\"\nimport { wordmark } from \"#lib/wordmark\"\n\n/**\n * Rows the wizard body needs before a wordmark is affordable — the field box, the answered-so-far list as\n * it grows, the step line, and a margin. Measured against the tallest question rather than the current one:\n * a mark that fitted on step 1 and pushed the step line off the screen on step 12 is worse than no mark.\n */\nconst WIZARD_BODY_ROWS = 16\n/** The mark never takes more than the chat's own largest tier, however tall the terminal is. */\nconst WORDMARK_MAX_ROWS = 5\n\nexport interface WizardAppProps {\n readonly title: string\n readonly given: PartialAnswers\n readonly defaults: QuestionDefaults\n /** The collected answers, or undefined when the person backed out. */\n readonly onDone: (answers: PartialAnswers | undefined) => void\n}\n\n/**\n * The catalogue step, which is a *screen* rather than a question.\n *\n * It lives in the root's own state instead of the pure reducer for one reason: it needs a network fetch, and\n * `nextQuestion` is a pure synchronous function over static option tables. That was the excuse for asking a\n * text question instead — \"what does it do often?\" — in a tree that already had a checklist. Wrong: the\n * reducer's shape is a fact about the reducer, and the *flow* is what the person sees. So the answer stays a\n * static three-way choice, and picking happens here, between two questions, with the remaining questions\n * carrying on afterwards.\n *\n * `fetchCatalogue` reports progress through a callback rather than to stdout, because writing to stdout\n * while Ink owns the frame paints over it — and being *async* is what keeps the spinner turning and the\n * keystrokes consumed. A blocking `spawnSync` here froze the app and let the tty echo the arrow keys\n * somebody pressed during a twenty-second clone, straight into the middle of the output.\n */\ntype Catalogue =\n | { readonly kind: \"idle\" }\n | { readonly kind: \"fetching\"; readonly status: string }\n | {\n readonly kind: \"picking\"\n readonly rows: readonly BrowseRow[]\n readonly picked: MultiSelectState\n }\n | { readonly kind: \"failed\"; readonly message: string }\n | { readonly kind: \"done\"; readonly refs: readonly string[] }\n\nexport function WizardApp({ title, given, defaults, onDone }: WizardAppProps) {\n const { exit } = useApp()\n // The live size, so a resize re-picks the wordmark's tier rather than freezing whichever one fitted at\n // launch. `screenColumns` is what handles a stream reporting a width of zero.\n const size = useTerminalSize()\n const [catalogue, setCatalogue] = useState<Catalogue>({ kind: \"idle\" })\n const [state, dispatch] = useReducer(\n (current: WizardState, action: Parameters<typeof reduceWizard>[1]) =>\n reduceWizard(current, action),\n undefined,\n () => startWizard(given, defaults),\n )\n\n const finish = useCallback(\n (answers: PartialAnswers | undefined) => {\n onDone(answers)\n exit()\n },\n [onDone, exit],\n )\n\n // Answered `find`, and the answer came from the *log* rather than from a flag — a `--skills find` run\n // would otherwise open the picker before the first question, which is not \"in the flow\", it is instead\n // of it.\n const wantsCatalogue = state.log.some(\n (entry) => entry.step === \"skills\" && entry.value === \"find\",\n )\n\n useEffect(() => {\n if (!wantsCatalogue || catalogue.kind !== \"idle\") return\n setCatalogue({ kind: \"fetching\", status: \"reading the catalogue\" })\n void (async () => {\n try {\n const rows = await fetchCatalogue({\n onStatus: (status) => setCatalogue({ kind: \"fetching\", status }),\n })\n if (rows.length === 0) {\n setCatalogue({\n kind: \"failed\",\n message: \"no catalogue could be read — carrying on without skills\",\n })\n return\n }\n const selectable = selectableOf(rows)\n setCatalogue({\n kind: \"picking\",\n rows,\n picked: {\n cursor: { index: firstSelectable(selectable), count: rows.length },\n chosen: [],\n },\n })\n } catch (error) {\n // Never fatal. A network that is down must not cost somebody the agent they were setting up.\n setCatalogue({\n kind: \"failed\",\n message: error instanceof Error ? error.message : String(error),\n })\n }\n })()\n }, [wantsCatalogue, catalogue.kind])\n\n // A failure is shown for a moment and then stepped past, rather than blocking on a keypress nobody\n // needs to make: there is no decision left to take.\n useEffect(() => {\n if (catalogue.kind !== \"failed\") return\n const timer = setTimeout(() => setCatalogue({ kind: \"done\", refs: [] }), 1400)\n return () => clearTimeout(timer)\n }, [catalogue])\n\n useEffect(() => {\n if (state.phase === \"done\") {\n const refs = catalogue.kind === \"done\" ? catalogue.refs : []\n finish({\n ...partialOf(state),\n ...(refs.length === 0 ? {} : { skillsPick: refs.join(\",\") }),\n })\n }\n if (state.phase === \"aborted\") finish(undefined)\n }, [state, finish, catalogue])\n\n useInput((input, key) => {\n // While the catalogue owns the screen it owns the keyboard. Routed here rather than by disabling\n // `useInput`: Ink allows one handler per root, and two would race for the same keypress.\n if (catalogue.kind === \"picking\") {\n const rows = catalogue.rows\n const selectable = selectableOf(rows)\n const intent = keyToCheckIntent(input, key)\n switch (intent.kind) {\n case \"move\":\n case \"toggle\":\n case \"all\":\n setCatalogue({\n ...catalogue,\n picked: reduceMultiSelect(\n catalogue.picked,\n intent.kind === \"move\"\n ? { kind: \"move\", move: intent.move }\n : { kind: intent.kind },\n selectable,\n ),\n })\n return\n case \"none-selected\":\n setCatalogue({\n ...catalogue,\n picked: reduceMultiSelect(catalogue.picked, { kind: \"none\" }, selectable),\n })\n return\n case \"confirm\":\n case \"cancel\":\n // Enter with nothing ticked and esc are the same outcome — no skills — and both carry\n // on with the remaining questions rather than ending anything.\n setCatalogue({\n kind: \"done\",\n refs:\n intent.kind === \"cancel\"\n ? []\n : chosenEntries(rows, catalogue.picked.chosen).map(\n (entry) => `${entry.source}/${entry.skill}`,\n ),\n })\n return\n default:\n return\n }\n }\n if (catalogue.kind === \"fetching\" || catalogue.kind === \"failed\") return\n\n const intent = keyToWizardIntent(input, key, {\n select: isSelectStep(state) || state.phase === \"confirm\",\n empty: state.editor.value === \"\",\n })\n switch (intent.kind) {\n case \"abort\":\n dispatch({ kind: \"abort\" })\n return\n case \"back\":\n dispatch({ kind: \"back\" })\n return\n case \"commit\":\n dispatch({ kind: \"commit\" })\n return\n case \"list\":\n dispatch({ kind: \"list\", intent: intent.intent })\n return\n case \"edit\":\n dispatch({ kind: \"edit\", intent: intent.intent })\n return\n }\n })\n\n if (state.phase === \"done\" || state.phase === \"aborted\") return null\n\n if (catalogue.kind === \"fetching\") {\n return (\n <Box flexDirection=\"column\">\n <Banner title=\"Skills\" lines={[\"choosing what this agent knows how to do\"]} />\n <Box marginTop={1} paddingLeft={2}>\n <Spinner label={catalogue.status} />\n </Box>\n </Box>\n )\n }\n\n if (catalogue.kind === \"failed\") {\n return (\n <Box flexDirection=\"column\">\n <Banner title=\"Skills\" lines={[\"carrying on without them\"]} />\n <Box marginTop={1} paddingLeft={2}>\n <Text color={THEME.warning}>{catalogue.message}</Text>\n </Box>\n </Box>\n )\n }\n\n if (catalogue.kind === \"picking\") {\n const ticked = catalogue.picked.chosen.length\n return (\n <Box flexDirection=\"column\">\n <Banner\n title=\"Skills\"\n lines={[\"space ticks · a all · n none · enter continues · esc skips\"]}\n />\n <Box marginTop={1}>\n <CheckList\n rows={catalogue.rows}\n index={catalogue.picked.cursor.index}\n chosen={catalogue.picked.chosen}\n window={screenRows(undefined, FALLBACK_ROWS)}\n width={screenColumns(undefined, FALLBACK_COLUMNS)}\n />\n </Box>\n <Box marginTop={1} paddingLeft={2}>\n <Text color={ticked === 0 ? THEME.muted : THEME.success}>\n {ticked === 0\n ? \"nothing ticked — enter carries on without any\"\n : `${ticked} ticked`}\n </Text>\n </Box>\n </Box>\n )\n }\n\n const counts = stepCounts(state)\n // Rows the wizard body needs before a picture is affordable: the field box, the answered-so-far list,\n // the step line, and a margin. Below that the mark degrades and then goes.\n const mark = wordmark(BRAND.name, {\n columns: screenColumns(size.columns, FALLBACK_COLUMNS) - BRAND_INDENT,\n rows: Math.min(WORDMARK_MAX_ROWS, Math.max(0, size.rows - WIZARD_BODY_ROWS)),\n })\n\n const hint =\n state.phase === \"confirm\"\n ? \"enter confirm · esc back · ^C quit — nothing written\"\n : \"enter accepts · esc back · ^C quit — nothing written\"\n\n return (\n <Box flexDirection=\"column\">\n {/*\n * The wordmark, then a one-line header — the chat's own shape, and the same `wordmark` rather\n * than a second mark for a second surface.\n *\n * It replaces a boxed title rather than sitting above one. Keeping both would put the product\n * name on screen twice, three rows apart, which is the duplication the chat banner had until\n * this phase — a picture of the name above a box that also spells it, three rows apart.\n *\n * The budget is what makes it degrade. `wordmark` walks its tiers down to a single spaced-out\n * line and there is no floor below that, so a short or narrow terminal loses the picture rather\n * than the questions.\n */}\n {mark.lines.length > 0 ? <Brandmark lines={mark.lines} /> : null}\n <Box marginTop={mark.lines.length > 0 ? 1 : 0}>\n <Text dimColor wrap=\"truncate\">\n {title} · a few questions — nothing is written until you confirm\n </Text>\n </Box>\n {state.phase === \"confirm\" ? (\n <Box flexDirection=\"column\" marginTop={1}>\n <SummaryCard rows={summaryRows(state)} />\n <Box marginTop={1} flexDirection=\"column\">\n <Text>Write the files?</Text>\n <SelectList\n items={[{ label: \"yes\" }, { label: \"no, go back\" }]}\n index={state.select.index}\n />\n </Box>\n <Text dimColor>{hint}</Text>\n </Box>\n ) : (\n <Box marginTop={1}>\n <WizardFrame\n step={counts.asked}\n total={counts.total}\n answered={answeredRows(state)}\n hint={hint}\n >\n {isSelectStep(state) ? (\n <Box flexDirection=\"column\">\n <Text>{currentQuestion(state)?.prompt ?? \"\"}</Text>\n <SelectList\n items={selectOptions(state).map((option) => ({\n label: option.label,\n ...(option.hint === undefined ? {} : { hint: option.hint }),\n }))}\n index={state.select.index}\n numbered\n />\n </Box>\n ) : (\n <TextField\n label={currentQuestion(state)?.prompt ?? \"\"}\n editor={state.editor}\n // Not a bug fix here: the bordered frame already bounds the text, so a\n // long answer wrapped without this — measured, rather than assumed after\n // the settings editor turned out to be broken. Passed because the\n // component that owns a bounded window should do its own wrapping, and\n // because `maxRows` is a real bound on the height that did not exist.\n columns={\n screenColumns(size.columns, FALLBACK_COLUMNS) - BRAND_INDENT\n }\n maxRows={FIELD_ROWS}\n placeholder={currentQuestion(state)?.fallback ?? \"\"}\n {...(state.error === undefined ? {} : { error: state.error })}\n {...(isSecretStep(state) ? { secret: true } : {})}\n />\n )}\n </WizardFrame>\n </Box>\n )}\n {state.error !== undefined && (isSelectStep(state) || state.phase === \"confirm\") ? (\n <Text color={THEME.error}>\n {GLYPH.error}\n {state.error}\n </Text>\n ) : null}\n </Box>\n )\n}\n",
6
6
  "/**\n * The confirm screen's answer recap: labels dim and right-padded, values plain, in a card.\n */\n\nimport { Box, Text } from \"ink\"\nimport { BORDER_STYLE, THEME } from \"#lib/theme\"\n\nexport interface SummaryCardProps {\n readonly rows: readonly { readonly label: string; readonly value: string }[]\n}\n\nexport function SummaryCard({ rows }: SummaryCardProps) {\n const width = rows.reduce((widest, row) => Math.max(widest, row.label.length), 0)\n return (\n <Box\n flexDirection=\"column\"\n borderStyle={BORDER_STYLE}\n borderColor={THEME.border}\n paddingX={1}\n paddingY={1}\n >\n {rows.map((row) => (\n <Text key={row.label}>\n <Text dimColor>{row.label.padEnd(width + 2)}</Text>\n {row.value}\n </Text>\n ))}\n </Box>\n )\n}\n",
7
7
  "/**\n * The wizard's chrome: answered lines above, the current question in a rounded box, a dim hint\n * footer. The `step m of n` count is honest — a keyless preset shrinks `total`, and the frame\n * shows whatever the reducer computed rather than a number that quietly stops being true.\n */\n\nimport { Box, Text } from \"ink\"\nimport type { ReactNode } from \"react\"\nimport { BORDER_STYLE, GLYPH, THEME } from \"#lib/theme\"\n\nexport interface WizardFrameProps {\n readonly step: number\n readonly total: number\n /** Already-answered questions, rendered ✓ label value. Esc pops the last one. */\n readonly answered: readonly { readonly label: string; readonly value: string }[]\n readonly hint: string\n readonly children: ReactNode\n}\n\nexport function WizardFrame({ step, total, answered, hint, children }: WizardFrameProps) {\n // Sized from the longest label, with a gap: a fixed 18 ran \"Background service\" (18) into its value.\n const width = Math.max(18, ...answered.map((entry) => entry.label.length + 2))\n return (\n <Box flexDirection=\"column\">\n {answered.map((entry) => (\n <Text key={entry.label}>\n <Text color={THEME.success}>{GLYPH.check}</Text>\n <Text dimColor>{entry.label.padEnd(width)}</Text>\n {entry.value}\n </Text>\n ))}\n <Box\n flexDirection=\"column\"\n borderStyle={BORDER_STYLE}\n borderColor={THEME.border}\n paddingX={1}\n paddingY={1}\n marginTop={answered.length > 0 ? 1 : 0}\n >\n {children}\n </Box>\n <Text dimColor>\n step {step} of {total} {GLYPH.bullet}\n {hint}\n </Text>\n </Box>\n )\n}\n",
8
- "/**\n * The init wizard as a pure reducer — a log of answers over `nextQuestion`'s forward-only flow.\n *\n * `nextQuestion` cannot go backwards, so back-navigation is an *answer log*: esc pops the tail\n * and the next question is recomputed from what remains. Popping the tail is always consistent\n * because the log is a prefix of the asking order — re-answering the preset re-derives every\n * downstream default for free. Flag-given answers live in `given` and are never poppable: they\n * were explicit, and backing over them would silently discard something the person typed into a\n * shell.\n *\n * Renderer-free and process-free (PURE-listed): `WizardApp` is one consumer; a test driving the\n * reducer with the same intents is another, and the two cannot diverge.\n */\n\nimport { applyIntent, EMPTY_EDITOR } from \"#editor\"\nimport type { ListIntent } from \"#keymap\"\nimport {\n dirFor,\n type InitStep,\n nextQuestion,\n type PartialAnswers,\n PRESETS,\n presetById,\n type Question,\n type QuestionDefaults,\n SECRET_STEPS,\n validateAnswer,\n} from \"#lib/init-flow\"\nimport { moveSelect, type SelectState } from \"#lib/select\"\nimport type { EditorState, Intent } from \"#lib/types\"\n\nexport type WizardPhase = \"asking\" | \"confirm\" | \"done\" | \"aborted\"\n\nexport interface WizardState {\n /** Flag answers — explicit, never poppable. */\n readonly given: PartialAnswers\n /** What the wizard collected, in asking order. Esc pops the tail. */\n readonly log: readonly { readonly step: InitStep; readonly value: string }[]\n readonly phase: WizardPhase\n /** The current text answer. Reuses the chat editor's state machine wholesale. */\n readonly editor: EditorState\n /** The current select answer (preset step, and the confirm screen's yes/no). */\n readonly select: SelectState\n /** Last validation failure; cleared on the next edit. */\n readonly error: string | undefined\n readonly defaults: QuestionDefaults\n}\n\nexport function startWizard(given: PartialAnswers, defaults: QuestionDefaults): WizardState {\n const state: WizardState = {\n given,\n log: [],\n phase: \"asking\",\n editor: EMPTY_EDITOR,\n select: { index: 0, count: PRESETS.length },\n error: undefined,\n defaults,\n }\n // Flags may already answer everything (`init --user … --name … --preset …` at a TTY): the\n // wizard then opens directly on the confirm screen rather than asking zero questions oddly.\n return currentQuestion(state) === undefined ? enterConfirm(state) : state\n}\n\nexport function partialOf(state: WizardState): PartialAnswers {\n const fromLog = Object.fromEntries(state.log.map((entry) => [entry.step, entry.value]))\n // `given` wins, though overlap cannot occur: nextQuestion never asks an answered step, so the\n // log never contains one.\n return { ...fromLog, ...state.given }\n}\n\nexport function currentQuestion(state: WizardState): Question | undefined {\n return nextQuestion(partialOf(state), state.defaults)\n}\n\n/**\n * Is the current question a fixed set of choices rather than a text field?\n *\n * Read off the question's own `options` rather than compared against a step name. The preset menu was\n * the only select for three phases and \"is this the preset step\" ended up written into the reducer,\n * the renderer and the cursor prefill — so adding a second one had to either repeat all three or\n * generalise them. Generalising is what stops a third repeating them again.\n */\nexport function isSelectStep(state: WizardState): boolean {\n return state.phase === \"asking\" && currentQuestion(state)?.options !== undefined\n}\n\n/** The choices on screen, empty when the question is a text field. */\nexport function selectOptions(state: WizardState): readonly {\n readonly value: string\n readonly label: string\n readonly hint?: string\n}[] {\n return currentQuestion(state)?.options ?? []\n}\n\n/** Whether the question on screen is one whose answer must never be rendered. */\nexport function isSecretStep(state: WizardState): boolean {\n const step = currentQuestion(state)?.step\n return state.phase === \"asking\" && step !== undefined && SECRET_STEPS.has(step)\n}\n\n/**\n * Honest step numbering: walk the flow the same way it will actually be asked, so a keyless\n * preset shrinks the total rather than leaving a count that quietly stops being true.\n */\nexport function stepCounts(state: WizardState): { readonly asked: number; readonly total: number } {\n const walk: Record<string, string> = { ...partialOf(state) }\n let remaining = 0\n for (;;) {\n const question = nextQuestion(walk, state.defaults)\n if (question === undefined) break\n remaining += 1\n walk[question.step] = question.fallback === \"\" ? \"(x)\" : question.fallback\n }\n const asked = state.log.length + Object.keys(state.given).length\n return { asked: asked + (state.phase === \"asking\" ? 1 : 0), total: asked + remaining }\n}\n\nexport type WizardAction =\n | { readonly kind: \"edit\"; readonly intent: Intent }\n | { readonly kind: \"list\"; readonly intent: ListIntent }\n | { readonly kind: \"commit\" }\n | { readonly kind: \"back\" }\n | { readonly kind: \"abort\" }\n\nconst CONFIRM_COUNT = 2 // yes / no\n\nfunction enterConfirm(state: WizardState): WizardState {\n return {\n ...state,\n phase: \"confirm\",\n editor: EMPTY_EDITOR,\n select: { index: 0, count: CONFIRM_COUNT },\n error: undefined,\n }\n}\n\nfunction freshFor(state: WizardState): Pick<WizardState, \"editor\" | \"select\" | \"error\"> {\n const question = nextQuestion(partialOf(state), state.defaults)\n const options = question?.options\n return {\n editor: EMPTY_EDITOR,\n select: {\n index: cursorFor(question),\n count: options === undefined ? PRESETS.length : options.length,\n },\n error: undefined,\n }\n}\n\n/** Prefill the cursor from the question's own fallback (\"1\" → 0). */\nfunction cursorFor(question: Question | undefined): number {\n const options = question?.options\n if (options === undefined) return 0\n const index = Number(question?.fallback) - 1\n return Number.isInteger(index) && index >= 0 && index < options.length ? index : 0\n}\n\nexport function reduceWizard(state: WizardState, action: WizardAction): WizardState {\n if (state.phase === \"done\" || state.phase === \"aborted\") return state\n\n switch (action.kind) {\n case \"abort\":\n return { ...state, phase: \"aborted\" }\n\n case \"edit\":\n if (state.phase !== \"asking\") return state\n return { ...state, editor: applyIntent(state.editor, action.intent), error: undefined }\n\n case \"list\": {\n const intent = action.intent\n if (intent.kind === \"move\") {\n return { ...state, select: moveSelect(state.select, intent.move), error: undefined }\n }\n if (intent.kind === \"choose\") return reduceWizard(state, { kind: \"commit\" })\n if (intent.kind === \"back\") return reduceWizard(state, { kind: \"back\" })\n if (intent.kind === \"exit\") return { ...state, phase: \"aborted\" }\n return state\n }\n\n case \"back\": {\n if (state.phase === \"confirm\") {\n // Back to the last asked question, its previous answer discarded so it re-asks\n // with the same defaults it had the first time.\n if (state.log.length === 0) return { ...state, phase: \"asking\", ...freshFor(state) }\n const log = state.log.slice(0, -1)\n const reopened = { ...state, phase: \"asking\" as const, log }\n return { ...reopened, ...freshFor(reopened) }\n }\n if (state.log.length === 0) return state // nothing wizard-asked to go back to\n const log = state.log.slice(0, -1)\n const popped = { ...state, log }\n return { ...popped, ...freshFor(popped) }\n }\n\n case \"commit\": {\n if (state.phase === \"confirm\") {\n // Index 0 is yes — the summary screen's select. \"no\" backs into the last question.\n return state.select.index === 0\n ? { ...state, phase: \"done\" }\n : reduceWizard(state, { kind: \"back\" })\n }\n\n const question = currentQuestion(state)\n if (question === undefined) return enterConfirm(state)\n\n const raw =\n question.options !== undefined\n ? (question.options[state.select.index]?.value ?? \"\")\n : state.editor.value.trim() === \"\"\n ? question.fallback\n : state.editor.value\n\n const checked = validateAnswer(question.step, raw)\n if (!checked.ok) {\n return { ...state, error: checked.reason }\n }\n\n const advanced: WizardState = {\n ...state,\n log: [...state.log, { step: question.step, value: checked.value }],\n }\n const next = { ...advanced, ...freshFor(advanced) }\n return currentQuestion(next) === undefined ? enterConfirm(next) : next\n }\n }\n}\n\n/**\n * What a secret looks like on screen.\n *\n * Enough to recognise a paste went in, never enough to reconstruct. Short values show nothing at\n * all rather than most of themselves.\n */\nexport function maskSecret(value: string): string {\n if (value === \"\") return \"\"\n if (value.length <= 8) return \"•\".repeat(value.length)\n return `${value.slice(0, 3)}${\"•\".repeat(6)}${value.slice(-2)}`\n}\n\n/** The confirm screen's rows, shared with the plain path's wording. */\nexport function summaryRows(\n state: WizardState,\n): readonly { readonly label: string; readonly value: string }[] {\n const partial = partialOf(state)\n const preset = partial.preset === undefined ? undefined : presetById(partial.preset)\n const endpoint = `${partial.model ?? \"\"} at ${partial.baseUrl ?? \"\"}`\n const keyVar = partial.apiKeyEnv ?? preset?.apiKeyEnv\n const key =\n keyVar === undefined\n ? \" (no key)\"\n : ` (${keyVar}=${partial.apiKey === undefined || partial.apiKey === \"\" ? \"not set yet\" : maskSecret(partial.apiKey)})`\n return [\n { label: \"agent\", value: partial.name ?? \"\" },\n { label: \"for\", value: `${partial.user ?? \"\"} — ${partial.purpose ?? \"\"}` },\n { label: \"endpoint\", value: `${endpoint}${key}` },\n // Derived when the answer was `sandbox` or `here`, because the `dir` question is not asked\n // then — and this row is the last thing read before anything is written, so it has to name\n // the directory that will actually exist. `dirFor` is the same function `complete()` calls;\n // a second derivation here is how a confirm screen comes to describe a different path.\n {\n label: \"directory\",\n value: partial.dir ?? dirFor(partial.dirChoice, partial.name, state.defaults) ?? \"\",\n },\n ]\n}\n\n/** The ✓ lines above the current question. */\nexport function answeredRows(\n state: WizardState,\n): readonly { readonly label: string; readonly value: string }[] {\n const labels: Record<InitStep, string> = {\n user: \"Your name\",\n name: \"Agent name\",\n purpose: \"Purpose\",\n preset: \"Endpoint\",\n model: \"Model\",\n baseUrl: \"Base URL\",\n apiKeyEnv: \"Key env var\",\n apiKey: \"API key\",\n web: \"Internet\",\n webBackend: \"Search backend\",\n webKey: \"Search key\",\n system: \"System access\",\n composio: \"Other apps\",\n telegram: \"Telegram\",\n telegramAllow: \"Telegram handle\",\n telegramToken: \"Bot token\",\n whatsapp: \"WhatsApp\",\n whatsappNumber: \"WhatsApp number\",\n schedules: \"none\",\n server: \"HTTP API\",\n // Was literally `\"starter\"` — a value pasted into the label column, so the confirm screen\n // showed \"starter starter\" for the default answer and \"starter none\" for the other one.\n skills: \"Skills\",\n skillsSearch: \"Skill search\",\n skillsPick: \"Skills picked\",\n daemon: \"Background service\",\n serverToken: \"API token\",\n composioKey: \"Composio key\",\n dirChoice: \"Location\",\n dir: \"Directory\",\n }\n return state.log.map((entry) => ({\n label: labels[entry.step],\n // A secret is never echoed back, not even to the person who just typed it: these lines\n // stay on screen for the rest of the wizard and end up in scrollback.\n value: SECRET_STEPS.has(entry.step) ? maskSecret(entry.value) : entry.value,\n }))\n}\n"
8
+ "/**\n * The init wizard as a pure reducer — a log of answers over `nextQuestion`'s forward-only flow.\n *\n * `nextQuestion` cannot go backwards, so back-navigation is an *answer log*: esc pops the tail\n * and the next question is recomputed from what remains. Popping the tail is always consistent\n * because the log is a prefix of the asking order — re-answering the preset re-derives every\n * downstream default for free. Flag-given answers live in `given` and are never poppable: they\n * were explicit, and backing over them would silently discard something the person typed into a\n * shell.\n *\n * Renderer-free and process-free (PURE-listed): `WizardApp` is one consumer; a test driving the\n * reducer with the same intents is another, and the two cannot diverge.\n */\n\nimport { applyIntent, EMPTY_EDITOR } from \"#editor\"\nimport type { ListIntent } from \"#keymap\"\nimport {\n dirFor,\n type InitStep,\n nextQuestion,\n type PartialAnswers,\n PRESETS,\n presetById,\n type Question,\n type QuestionDefaults,\n SECRET_STEPS,\n validateAnswer,\n} from \"#lib/init-flow\"\nimport { moveSelect, type SelectState } from \"#lib/select\"\nimport type { EditorState, Intent } from \"#lib/types\"\n\nexport type WizardPhase = \"asking\" | \"confirm\" | \"done\" | \"aborted\"\n\nexport interface WizardState {\n /** Flag answers — explicit, never poppable. */\n readonly given: PartialAnswers\n /** What the wizard collected, in asking order. Esc pops the tail. */\n readonly log: readonly { readonly step: InitStep; readonly value: string }[]\n readonly phase: WizardPhase\n /** The current text answer. Reuses the chat editor's state machine wholesale. */\n readonly editor: EditorState\n /** The current select answer (preset step, and the confirm screen's yes/no). */\n readonly select: SelectState\n /** Last validation failure; cleared on the next edit. */\n readonly error: string | undefined\n readonly defaults: QuestionDefaults\n}\n\nexport function startWizard(given: PartialAnswers, defaults: QuestionDefaults): WizardState {\n const state: WizardState = {\n given,\n log: [],\n phase: \"asking\",\n editor: EMPTY_EDITOR,\n select: { index: 0, count: PRESETS.length },\n error: undefined,\n defaults,\n }\n // Flags may already answer everything (`init --user … --name … --preset …` at a TTY): the\n // wizard then opens directly on the confirm screen rather than asking zero questions oddly.\n return currentQuestion(state) === undefined ? enterConfirm(state) : state\n}\n\nexport function partialOf(state: WizardState): PartialAnswers {\n const fromLog = Object.fromEntries(state.log.map((entry) => [entry.step, entry.value]))\n // `given` wins, though overlap cannot occur: nextQuestion never asks an answered step, so the\n // log never contains one.\n return { ...fromLog, ...state.given }\n}\n\nexport function currentQuestion(state: WizardState): Question | undefined {\n return nextQuestion(partialOf(state), state.defaults)\n}\n\n/**\n * Is the current question a fixed set of choices rather than a text field?\n *\n * Read off the question's own `options` rather than compared against a step name. The preset menu was\n * the only select for three phases and \"is this the preset step\" ended up written into the reducer,\n * the renderer and the cursor prefill — so adding a second one had to either repeat all three or\n * generalise them. Generalising is what stops a third repeating them again.\n */\nexport function isSelectStep(state: WizardState): boolean {\n return state.phase === \"asking\" && currentQuestion(state)?.options !== undefined\n}\n\n/** The choices on screen, empty when the question is a text field. */\nexport function selectOptions(state: WizardState): readonly {\n readonly value: string\n readonly label: string\n readonly hint?: string\n}[] {\n return currentQuestion(state)?.options ?? []\n}\n\n/** Whether the question on screen is one whose answer must never be rendered. */\nexport function isSecretStep(state: WizardState): boolean {\n const step = currentQuestion(state)?.step\n return state.phase === \"asking\" && step !== undefined && SECRET_STEPS.has(step)\n}\n\n/**\n * Honest step numbering: walk the flow the same way it will actually be asked, so a keyless\n * preset shrinks the total rather than leaving a count that quietly stops being true.\n */\nexport function stepCounts(state: WizardState): { readonly asked: number; readonly total: number } {\n const walk: Record<string, string> = { ...partialOf(state) }\n let remaining = 0\n for (;;) {\n const question = nextQuestion(walk, state.defaults)\n if (question === undefined) break\n remaining += 1\n walk[question.step] = question.fallback === \"\" ? \"(x)\" : question.fallback\n }\n const asked = state.log.length + Object.keys(state.given).length\n return { asked: asked + (state.phase === \"asking\" ? 1 : 0), total: asked + remaining }\n}\n\nexport type WizardAction =\n | { readonly kind: \"edit\"; readonly intent: Intent }\n | { readonly kind: \"list\"; readonly intent: ListIntent }\n | { readonly kind: \"commit\" }\n | { readonly kind: \"back\" }\n | { readonly kind: \"abort\" }\n\nconst CONFIRM_COUNT = 2 // yes / no\n\nfunction enterConfirm(state: WizardState): WizardState {\n return {\n ...state,\n phase: \"confirm\",\n editor: EMPTY_EDITOR,\n select: { index: 0, count: CONFIRM_COUNT },\n error: undefined,\n }\n}\n\nfunction freshFor(state: WizardState): Pick<WizardState, \"editor\" | \"select\" | \"error\"> {\n const question = nextQuestion(partialOf(state), state.defaults)\n const options = question?.options\n return {\n editor: EMPTY_EDITOR,\n select: {\n index: cursorFor(question),\n count: options === undefined ? PRESETS.length : options.length,\n },\n error: undefined,\n }\n}\n\n/** Prefill the cursor from the question's own fallback (\"1\" → 0). */\nfunction cursorFor(question: Question | undefined): number {\n const options = question?.options\n if (options === undefined) return 0\n const index = Number(question?.fallback) - 1\n return Number.isInteger(index) && index >= 0 && index < options.length ? index : 0\n}\n\nexport function reduceWizard(state: WizardState, action: WizardAction): WizardState {\n if (state.phase === \"done\" || state.phase === \"aborted\") return state\n\n switch (action.kind) {\n case \"abort\":\n return { ...state, phase: \"aborted\" }\n\n case \"edit\":\n if (state.phase !== \"asking\") return state\n return { ...state, editor: applyIntent(state.editor, action.intent), error: undefined }\n\n case \"list\": {\n const intent = action.intent\n if (intent.kind === \"move\") {\n return { ...state, select: moveSelect(state.select, intent.move), error: undefined }\n }\n if (intent.kind === \"choose\") return reduceWizard(state, { kind: \"commit\" })\n if (intent.kind === \"back\") return reduceWizard(state, { kind: \"back\" })\n if (intent.kind === \"exit\") return { ...state, phase: \"aborted\" }\n return state\n }\n\n case \"back\": {\n if (state.phase === \"confirm\") {\n // Back to the last asked question, its previous answer discarded so it re-asks\n // with the same defaults it had the first time.\n if (state.log.length === 0) return { ...state, phase: \"asking\", ...freshFor(state) }\n const log = state.log.slice(0, -1)\n const reopened = { ...state, phase: \"asking\" as const, log }\n return { ...reopened, ...freshFor(reopened) }\n }\n if (state.log.length === 0) return state // nothing wizard-asked to go back to\n const log = state.log.slice(0, -1)\n const popped = { ...state, log }\n return { ...popped, ...freshFor(popped) }\n }\n\n case \"commit\": {\n if (state.phase === \"confirm\") {\n // Index 0 is yes — the summary screen's select. \"no\" backs into the last question.\n return state.select.index === 0\n ? { ...state, phase: \"done\" }\n : reduceWizard(state, { kind: \"back\" })\n }\n\n const question = currentQuestion(state)\n if (question === undefined) return enterConfirm(state)\n\n const raw =\n question.options !== undefined\n ? (question.options[state.select.index]?.value ?? \"\")\n : state.editor.value.trim() === \"\"\n ? question.fallback\n : state.editor.value\n\n const checked = validateAnswer(question.step, raw)\n if (!checked.ok) {\n return { ...state, error: checked.reason }\n }\n\n const advanced: WizardState = {\n ...state,\n log: [...state.log, { step: question.step, value: checked.value }],\n }\n const next = { ...advanced, ...freshFor(advanced) }\n return currentQuestion(next) === undefined ? enterConfirm(next) : next\n }\n }\n}\n\n/**\n * What a secret looks like on screen.\n *\n * Enough to recognise a paste went in, never enough to reconstruct. Short values show nothing at\n * all rather than most of themselves.\n */\nexport function maskSecret(value: string): string {\n if (value === \"\") return \"\"\n if (value.length <= 8) return \"•\".repeat(value.length)\n return `${value.slice(0, 3)}${\"•\".repeat(6)}${value.slice(-2)}`\n}\n\n/** The confirm screen's rows, shared with the plain path's wording. */\nexport function summaryRows(\n state: WizardState,\n): readonly { readonly label: string; readonly value: string }[] {\n const partial = partialOf(state)\n const preset = partial.preset === undefined ? undefined : presetById(partial.preset)\n const endpoint = `${partial.model ?? \"\"} at ${partial.region === undefined ? (partial.baseUrl ?? \"\") : `Bedrock ${partial.region}`}`\n const keyVar = partial.apiKeyEnv ?? preset?.apiKeyEnv\n const key =\n keyVar === undefined\n ? \" (no key)\"\n : ` (${keyVar}=${partial.apiKey === undefined || partial.apiKey === \"\" ? \"not set yet\" : maskSecret(partial.apiKey)})`\n return [\n { label: \"agent\", value: partial.name ?? \"\" },\n { label: \"for\", value: `${partial.user ?? \"\"} — ${partial.purpose ?? \"\"}` },\n { label: \"endpoint\", value: `${endpoint}${key}` },\n // Derived when the answer was `sandbox` or `here`, because the `dir` question is not asked\n // then — and this row is the last thing read before anything is written, so it has to name\n // the directory that will actually exist. `dirFor` is the same function `complete()` calls;\n // a second derivation here is how a confirm screen comes to describe a different path.\n {\n label: \"directory\",\n value: partial.dir ?? dirFor(partial.dirChoice, partial.name, state.defaults) ?? \"\",\n },\n ]\n}\n\n/** The ✓ lines above the current question. */\nexport function answeredRows(\n state: WizardState,\n): readonly { readonly label: string; readonly value: string }[] {\n const labels: Record<InitStep, string> = {\n user: \"Your name\",\n name: \"Agent name\",\n purpose: \"Purpose\",\n preset: \"Endpoint\",\n model: \"Model\",\n baseUrl: \"Base URL\",\n region: \"AWS region\",\n apiKeyEnv: \"Key env var\",\n apiKey: \"API key\",\n web: \"Internet\",\n webBackend: \"Search backend\",\n webKey: \"Search key\",\n system: \"System access\",\n composio: \"Other apps\",\n telegram: \"Telegram\",\n telegramAllow: \"Telegram handle\",\n telegramToken: \"Bot token\",\n whatsapp: \"WhatsApp\",\n whatsappNumber: \"WhatsApp number\",\n schedules: \"none\",\n server: \"HTTP API\",\n // Was literally `\"starter\"` — a value pasted into the label column, so the confirm screen\n // showed \"starter starter\" for the default answer and \"starter none\" for the other one.\n skills: \"Skills\",\n skillsSearch: \"Skill search\",\n skillsPick: \"Skills picked\",\n daemon: \"Background service\",\n serverToken: \"API token\",\n composioKey: \"Composio key\",\n dirChoice: \"Location\",\n dir: \"Directory\",\n }\n return state.log.map((entry) => ({\n label: labels[entry.step],\n // A secret is never echoed back, not even to the person who just typed it: these lines\n // stay on screen for the rest of the wizard and end up in scrollback.\n value: SECRET_STEPS.has(entry.step) ? maskSecret(entry.value) : entry.value,\n }))\n}\n"
9
9
  ],
10
- "mappings": ";kzBAUA,cAAS,UAAK,YAAM,eAAQ,aAC5B,sBAAS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13
  }
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
- import{A,t}from"./index-1h9pqnec.js";import"./index-y605a1rj.js";import"./index-1wxw30j1.js";import"./index-358nsn9t.js";import"./index-rfa0ztab.js";import{wt,Hn,Dt,Kn,on,Yn,jn,tr,Jn,qn,Vn}from"./index-ccpq4k6r.js";import{et}from"./index-z88f35vs.js";import{Wn}from"./index-v271gbaz.js";import"./index-5nprb9px.js";import{me}from"./index-qe3ybzh6.js";import"./index-b7qc21s7.js";import{u}from"./index-k2q76dhw.js";import"./index-dwxmy0kx.js";import{o,d}from"./index-v6taf4vn.js";import{dirname as w}from"node:path";async function x(e){switch(e.action){case"list":case void 0:return await g(e);case"connect":return await f(e,!0);case"disconnect":return await f(e,!1);case"credential":return await m(e);case"pair":return await b(e);case"unpair":return P(e);default:throw new t({code:"cli_channels_action_unknown",message:`channels: ${JSON.stringify(e.action)} is not an action`,hint:`Actions are list, connect, disconnect, credential and unpair — \`${A.slug} channels list <agent>\`.`})}}async function g(e){let n=tr(e.manifestPath);if(e.json===!0)return process.stdout.write(`${JSON.stringify({channels:n},null,2)}
2
+ import{t,A}from"./index-qg9bn980.js";import"./index-kjqksgch.js";import"./index-r4ax3x4d.js";import"./index-haypwvzd.js";import"./index-dzy19wtf.js";import{bA,jn,OA,NA,sn,Jn,qn,or,Vn,Wn,zn}from"./index-z157at3s.js";import{AA}from"./index-664xcamy.js";import{Zn}from"./index-095hrkyr.js";import"./index-fcsg95m5.js";import{me}from"./index-7mn8ack9.js";import"./index-38gs9anh.js";import{u}from"./index-3vzf253k.js";import"./index-twn9bfm2.js";import{o,d}from"./index-8tmv33mr.js";import{dirname as w}from"node:path";async function x(e){switch(e.action){case"list":case void 0:return await g(e);case"connect":return await f(e,!0);case"disconnect":return await f(e,!1);case"credential":return await m(e);case"pair":return await b(e);case"unpair":return P(e);default:throw new A({code:"cli_channels_action_unknown",message:`channels: ${JSON.stringify(e.action)} is not an action`,hint:`Actions are list, connect, disconnect, credential and unpair — \`${t.slug} channels list <agent>\`.`})}}async function g(e){let n=or(e.manifestPath);if(e.json===!0)return process.stdout.write(`${JSON.stringify({channels:n},null,2)}
3
3
  `),o;if(n.length===0)return process.stdout.write(`No channels. This agent is reached through the CLI and the HTTP API only.
4
- Add one with \`${A.slug} config set <agent> channels\`, or answer the channel questions in \`${A.slug} init\`.
5
- `),o;let i=await on(e.manifestPath),s=n.map((r)=>{let a=i?.get(r.id);return{label:r.id,value:r.type,note:[r.enabled?"enabled":"disabled",...a===void 0?[]:[`now ${a.status}`],r.credentialEnv===void 0?r.type==="whatsapp"?y(r):"no credential in the .env":`${r.credentialEnv} ${r.credentialSet?"set":"NOT SET"}`,r.allowFrom.length===0?r.pairWith===void 0?"allowFrom empty — permits nobody":`allows you (${r.pairWith}) — allowFrom names anyone else`:`allows ${r.allowFrom.join(", ")}${r.pairWith===void 0?"":" and you"}`].join(" · ")}});process.stdout.write(`${u(s)}
4
+ Add one with \`${t.slug} config set <agent> channels\`, or answer the channel questions in \`${t.slug} init\`.
5
+ `),o;let i=await sn(e.manifestPath),s=n.map((r)=>{let a=i?.get(r.id);return{label:r.id,value:r.type,note:[r.enabled?"enabled":"disabled",...a===void 0?[]:[`now ${a.status}`],r.credentialEnv===void 0?r.type==="whatsapp"?y(r):"no credential in the .env":`${r.credentialEnv} ${r.credentialSet?"set":"NOT SET"}`,r.allowFrom.length===0?r.pairWith===void 0?"allowFrom empty — permits nobody":`allows you (${r.pairWith}) — allowFrom names anyone else`:`allows ${r.allowFrom.join(", ")}${r.pairWith===void 0?"":" and you"}`].join(" · ")}});process.stdout.write(`${u(s)}
6
6
  `);for(let[r,a]of i??[]){if(a.input===void 0)continue;if(process.stdout.write(`
7
7
  ${r} is waiting to be paired — ${a.detail??"enter this"}:
8
8
 
@@ -11,21 +11,21 @@ ${r} is waiting to be paired — ${a.detail??"enter this"}:
11
11
  expires ${a.input.expiresAt}
12
12
  `)}if(i===void 0)process.stdout.write(`
13
13
  Nothing is hosting this agent, so nothing above is a live status — it is what the
14
- manifest says. Start it with \`${A.slug} serve\` to see what each channel is doing.
15
- `);return o}function y(e){let n=e.pairWith===void 0?"pairs by QR":`pairs by code to ${e.pairWith}`;return e.paired===!0?`${n}; linked — \`channels unpair\` forgets it`:`${n}; not linked yet`}async function b(e){let n=h(e),i=tr(e.manifestPath).find((c)=>c.id===n);if(i===void 0)throw new t({code:"cli_channel_unknown",message:`No channel "${n}" in ${e.manifestPath}.`,hint:`\`${A.slug} channels list <agent>\` names them.`});if(i.type==="telegram"){let c=await m(e);if(c!==o)return c;let l=await f(e,!0);return process.stdout.write(`${await v(e.manifestPath)}
16
- `),l}if(i.type!=="whatsapp")throw new t({code:"cli_channel_no_pairing",message:`Channel "${n}" is a ${i.type}, which has no pairing step.`,hint:`Use \`${A.slug} channels connect\` to switch it on, or \`credential\` if it takes a token.`});if(i.pairWith===void 0)throw new t({code:"cli_channel_no_number",message:`Channel "${n}" has no pairWith, so there is no number to pair to.`,hint:"Set pairWith on the channel to the account's own number, digits with the country code. Without it pairing is a QR, which `serve` offers."});if(i.paired===!0)return process.stdout.write(`${n} is already paired to ${i.pairWith}. \`${A.slug} channels unpair\` forgets it first.
17
- `),o;let s=me(e.manifestPath),{outcome:r,host:a}=await Hn({...e.installServer===void 0?{}:{install:e.installServer}}),p=wt(r);if(p!==void 0)process.stderr.write(p);if(a?.baseUrl!==void 0){let c=await Dt(a,e.manifestPath);if(!c.ok)process.stderr.write(`pid ${a.pid} did not adopt ${s}${c.detail===void 0?"":`: ${c.detail}`}
18
- `);else{let l=await Yn({manifestPath:e.manifestPath,channelId:n});if(l==="paired")return process.stdout.write(`${n} is linked to ${i.pairWith}, and pid ${a.pid} is serving it.
19
- chat: ${et(a.baseUrl,s)} — or \`${A.slug} run ${s}\`
20
- `),o;return process.stdout.write(l==="no-code"?`No code arrived from pid ${a.pid} — \`${A.slug} status\` shows what the channel is doing; run this again once it offers one.
14
+ manifest says. Start it with \`${t.slug} serve\` to see what each channel is doing.
15
+ `);return o}function y(e){let n=e.pairWith===void 0?"pairs by QR":`pairs by code to ${e.pairWith}`;return e.paired===!0?`${n}; linked — \`channels unpair\` forgets it`:`${n}; not linked yet`}async function b(e){let n=h(e),i=or(e.manifestPath).find((c)=>c.id===n);if(i===void 0)throw new A({code:"cli_channel_unknown",message:`No channel "${n}" in ${e.manifestPath}.`,hint:`\`${t.slug} channels list <agent>\` names them.`});if(i.type==="telegram"){let c=await m(e);if(c!==o)return c;let l=await f(e,!0);return process.stdout.write(`${await v(e.manifestPath)}
16
+ `),l}if(i.type!=="whatsapp")throw new A({code:"cli_channel_no_pairing",message:`Channel "${n}" is a ${i.type}, which has no pairing step.`,hint:`Use \`${t.slug} channels connect\` to switch it on, or \`credential\` if it takes a token.`});if(i.pairWith===void 0)throw new A({code:"cli_channel_no_number",message:`Channel "${n}" has no pairWith, so there is no number to pair to.`,hint:"Set pairWith on the channel to the account's own number, digits with the country code. Without it pairing is a QR, which `serve` offers."});if(i.paired===!0)return process.stdout.write(`${n} is already paired to ${i.pairWith}. \`${t.slug} channels unpair\` forgets it first.
17
+ `),o;let s=me(e.manifestPath),{outcome:r,host:a}=await jn({...e.installServer===void 0?{}:{install:e.installServer}}),p=bA(r);if(p!==void 0)process.stderr.write(p);if(a?.baseUrl!==void 0){let c=await OA(a,e.manifestPath);if(!c.ok)process.stderr.write(`pid ${a.pid} did not adopt ${s}${c.detail===void 0?"":`: ${c.detail}`}
18
+ `);else{let l=await Jn({manifestPath:e.manifestPath,channelId:n});if(l==="paired")return process.stdout.write(`${n} is linked to ${i.pairWith}, and pid ${a.pid} is serving it.
19
+ chat: ${AA(a.baseUrl,s)} — or \`${t.slug} run ${s}\`
20
+ `),o;return process.stdout.write(l==="no-code"?`No code arrived from pid ${a.pid} — \`${t.slug} status\` shows what the channel is doing; run this again once it offers one.
21
21
  `:`Not paired yet — the host keeps offering codes; run this again.
22
- `),d}}if(await jn({manifestPath:e.manifestPath,dir:w(e.manifestPath),number:i.pairWith,channelId:n,...i.authDir===void 0?{}:{authDir:i.authDir}})!=="paired")return d;return process.stdout.write(`Nothing is serving ${s} yet. \`${A.slug} serve ${s}\` runs it here; \`${A.slug} daemon install\` keeps a server running for every agent.
23
- `),o}async function v(e){let n=await Kn(e);switch(n.kind){case"reloaded":return`pid ${n.pid} reloaded it — the change is live.`;case"pending":return`pid ${n.pid} applies it when its ${n.running} running turn(s) finish.`;case"busy":return`pid ${n.pid} has a turn in flight; \`${A.slug} restart ${me(e)}\` once it finishes.`;case"failed":return`pid ${n.pid} did not reload it${n.detail===void 0?"":`: ${n.detail}`} — \`${A.slug} restart ${me(e)}\` to retry.`;case"no-host":return"Nothing is hosting it right now; it takes effect at the next start."}}async function f(e,n){let i=await Jn(e.manifestPath,h(e),n);return process.stdout.write(`${i.note}
24
- `),o}async function m(e){let n=h(e),i=await Wn(`Credential for channel "${n}"`);if(i===void 0||i==="")return process.stdout.write(`Nothing was read, so nothing was written. A secret is never taken from an argument or a pipe —
22
+ `),d}}if(await qn({manifestPath:e.manifestPath,dir:w(e.manifestPath),number:i.pairWith,channelId:n,...i.authDir===void 0?{}:{authDir:i.authDir}})!=="paired")return d;return process.stdout.write(`Nothing is serving ${s} yet. \`${t.slug} serve ${s}\` runs it here; \`${t.slug} daemon install\` keeps a server running for every agent.
23
+ `),o}async function v(e){let n=await NA(e);switch(n.kind){case"reloaded":return`pid ${n.pid} reloaded it — the change is live.`;case"pending":return`pid ${n.pid} applies it when its ${n.running} running turn(s) finish.`;case"busy":return`pid ${n.pid} has a turn in flight; \`${t.slug} restart ${me(e)}\` once it finishes.`;case"failed":return`pid ${n.pid} did not reload it${n.detail===void 0?"":`: ${n.detail}`} — \`${t.slug} restart ${me(e)}\` to retry.`;case"no-host":return"Nothing is hosting it right now; it takes effect at the next start."}}async function f(e,n){let i=await Vn(e.manifestPath,h(e),n);return process.stdout.write(`${i.note}
24
+ `),o}async function m(e){let n=h(e),i=await Zn(`Credential for channel "${n}"`);if(i===void 0||i==="")return process.stdout.write(`Nothing was read, so nothing was written. A secret is never taken from an argument or a pipe —
25
25
  run this at a terminal, or put the variable in the .env beside the manifest yourself.
26
- `),o;let s=qn(e.manifestPath,n,i);return process.stdout.write(`${s.note}
27
- `),o}function P(e){let n=Vn(e.manifestPath,h(e));return process.stdout.write(`${n.note}
28
- `),o}function h(e){let n=e.channelId;if(n!==void 0&&n!=="")return n;let i=tr(e.manifestPath),s=i[0];if(i.length===1&&s!==void 0)return s.id;throw new t({code:"cli_channels_needs_id",message:"Which channel?",hint:i.length===0?"This agent declares none. `channels list <agent>` says so too.":`Name one: ${i.map((r)=>r.id).join(", ")}.`,field:"channelId"})}export{x as channelsCommand};
26
+ `),o;let s=Wn(e.manifestPath,n,i);return process.stdout.write(`${s.note}
27
+ `),o}function P(e){let n=zn(e.manifestPath,h(e));return process.stdout.write(`${n.note}
28
+ `),o}function h(e){let n=e.channelId;if(n!==void 0&&n!=="")return n;let i=or(e.manifestPath),s=i[0];if(i.length===1&&s!==void 0)return s.id;throw new A({code:"cli_channels_needs_id",message:"Which channel?",hint:i.length===0?"This agent declares none. `channels list <agent>` says so too.":`Name one: ${i.map((r)=>r.id).join(", ")}.`,field:"channelId"})}export{x as channelsCommand};
29
29
 
30
- //# debugId=458D1D0A468DA65264756E2164756E21
31
- //# sourceMappingURL=channels-gf31stv7.js.map
30
+ //# debugId=AF8E4DA29F29449864756E2164756E21
31
+ //# sourceMappingURL=channels-4t89qpdt.js.map
@@ -5,6 +5,6 @@
5
5
  "/**\n * `channels` — what an agent is reachable on, and the four things a person does to one.\n *\n * ## Why a command rather than more `config`\n *\n * Every one of these was possible already and reachable from nowhere obvious. Disconnecting meant\n * `config set <agent> channels '[{…the whole list again…}]'`; changing a token meant knowing that\n * `tokenEnv` names a variable and that `config env` writes it; relinking WhatsApp meant finding a\n * directory and deleting it. That is the standing rule about `init` — a capability reachable only by\n * somebody who already knows the field names is one the surface is hiding — applied to the thing a\n * person touches most after creating an agent.\n *\n * `lib/channel-actions.ts` holds the implementation, because the browser does the same four things\n * through HTTP and two implementations of \"disconnect a channel\" is how two surfaces come to\n * disagree about what it means.\n *\n * ## `status` is a different question from `list`\n *\n * This reads the **manifest**: what is configured, and whether its credential is filled in. Whether\n * a channel is *connected right now* is a fact about a running process, which only a host can\n * answer — `GET /v1/agents/:id` carries it and the `serve` banner prints it. Reporting a manifest\n * flag as a connection is decision 5.17's failure, so the output says which it is showing.\n */\n\nimport { dirname } from \"node:path\"\nimport { BRAND, HarnessError } from \"@dispach/core\"\nimport { announce } from \"#lib/bootstrap\"\nimport {\n type ChannelEntry,\n channelsOf,\n setChannelCredential,\n setChannelEnabled,\n unpairChannel,\n} from \"#lib/channel-actions\"\nimport { askSecret } from \"#lib/confirm\"\nimport { EXIT_FAILURE, EXIT_OK } from \"#lib/const\"\nimport {\n adoptOnHost,\n ensureHost,\n liveChannels,\n reloadOnHost,\n waitForPairing,\n} from \"#lib/host-actions\"\nimport { pairWhatsApp } from \"#lib/init-whatsapp\"\nimport { agentIdFor } from \"#lib/lifecycle\"\nimport { keyValue, type Row } from \"#lib/render\"\nimport type { ChannelsOptions } from \"#lib/schema\"\nimport { webUrl } from \"#lib/web-url\"\n\nexport async function channelsCommand(options: ChannelsOptions): Promise<number> {\n switch (options.action) {\n case \"list\":\n case undefined:\n return await list(options)\n case \"connect\":\n return await flip(options, true)\n case \"disconnect\":\n return await flip(options, false)\n case \"credential\":\n return await credential(options)\n case \"pair\":\n return await pair(options)\n case \"unpair\":\n return unpair(options)\n default:\n throw new HarnessError({\n code: \"cli_channels_action_unknown\",\n message: `channels: ${JSON.stringify(options.action)} is not an action`,\n hint: `Actions are list, connect, disconnect, credential and unpair — \\`${BRAND.slug} channels list <agent>\\`.`,\n })\n }\n}\n\nasync function list(options: ChannelsOptions): Promise<number> {\n const channels = channelsOf(options.manifestPath)\n if (options.json === true) {\n process.stdout.write(`${JSON.stringify({ channels }, null, 2)}\\n`)\n return EXIT_OK\n }\n if (channels.length === 0) {\n process.stdout.write(\n `No channels. This agent is reached through the CLI and the HTTP API only.\\nAdd one with \\`${BRAND.slug} config set <agent> channels\\`, or answer the channel questions in \\`${BRAND.slug} init\\`.\\n`,\n )\n return EXIT_OK\n }\n\n /**\n * **This column never says \"connected\", and that is a correction rather than a wording tweak.**\n *\n * It used to read `channel.enabled ? \"connected\" : \"disconnected\"` — so a WhatsApp channel that\n * had never been paired in its life printed `wa whatsapp connected`, and the footer explaining\n * that this is only the manifest did not undo the word in the table. Reported exactly that way:\n * a number was added, the listing said connected, and nothing anywhere offered a code. A\n * disclaimer under a claim does not cancel the claim.\n *\n * `enabled` and `disabled` are what the file actually says, and the live half now comes from\n * the host below instead of being disclaimed away.\n */\n const live = await liveChannels(options.manifestPath)\n const rows: Row[] = channels.map((channel) => {\n const now = live?.get(channel.id)\n return {\n label: channel.id,\n value: channel.type,\n note: [\n channel.enabled ? \"enabled\" : \"disabled\",\n ...(now === undefined ? [] : [`now ${now.status}`]),\n channel.credentialEnv === undefined\n ? // Said rather than omitted: an absent credential row reads as \"this one needs\n // no setting up\", which for WhatsApp is the opposite of the truth.\n channel.type === \"whatsapp\"\n ? pairingNote(channel)\n : \"no credential in the .env\"\n : `${channel.credentialEnv} ${channel.credentialSet ? \"set\" : \"NOT SET\"}`,\n // The paired account is always admitted, so an empty list no longer means nobody\n // for a channel with a `pairWith` — saying so is what stops the owner editing a\n // field they do not need to.\n channel.allowFrom.length === 0\n ? channel.pairWith === undefined\n ? \"allowFrom empty — permits nobody\"\n : `allows you (${channel.pairWith}) — allowFrom names anyone else`\n : `allows ${channel.allowFrom.join(\", \")}${channel.pairWith === undefined ? \"\" : \" and you\"}`,\n ].join(\" · \"),\n }\n })\n process.stdout.write(`${keyValue(rows)}\\n`)\n\n /**\n * The pending code or QR, from the host that is holding it.\n *\n * This is the half that was missing entirely: `needs_input` reached the `serve` banner and the\n * agent resource and **no command**, so the only way to pair was to watch a log at the moment\n * it scrolled past. A person who ran `channels list` — the command named after the question\n * they had — was told the channel was connected and given nothing to act on.\n */\n for (const [id, state] of live ?? []) {\n if (state.input === undefined) continue\n process.stdout.write(\n `\\n${id} is waiting to be paired — ${state.detail ?? \"enter this\"}:\\n\\n ${state.input.payload}\\n`,\n )\n if (state.input.expiresAt !== undefined)\n process.stdout.write(`\\n expires ${state.input.expiresAt}\\n`)\n }\n\n if (live === undefined)\n // The distinction 5.17 exists for. With no host there is genuinely nothing live to report,\n // and saying so beats printing a status column that is really a config flag.\n process.stdout.write(\n `\\nNothing is hosting this agent, so nothing above is a live status — it is what the\\nmanifest says. Start it with \\`${BRAND.slug} serve\\` to see what each channel is doing.\\n`,\n )\n return EXIT_OK\n}\n\n/** How this WhatsApp entry pairs, and whether it already has. */\nfunction pairingNote(channel: ChannelEntry): string {\n // `pairWith` turns pairing into a code typed into the phone; without it, a QR. The old string\n // said \"paired by QR\" unconditionally — wrong about the method once `pairWith` existed, and\n // wrong about the tense always, since it printed for a channel that had never been paired.\n const how =\n channel.pairWith === undefined ? \"pairs by QR\" : `pairs by code to ${channel.pairWith}`\n return channel.paired === true\n ? `${how}; linked — \\`channels unpair\\` forgets it`\n : `${how}; not linked yet`\n}\n\n/**\n * Connect a channel the way that channel needs.\n *\n * One verb for two mechanisms, because from the person's seat it is one action: \"make this\n * channel work\". WhatsApp pairs by a code typed into the phone; Telegram wants a bot token in the\n * `.env`. Making somebody know which of `credential` and `unpair`-then-`serve` applies is\n * remembering the implementation, and `channels pair <agent> wa` was the first thing typed when\n * the code did not appear — it answered *\"No agent named \\\"pair\\\"\"*, because `pair` was not an\n * action and so was read as the agent.\n *\n * WhatsApp has two cases. If a host is already serving this agent, the code it is offering is\n * shown and the command waits for the phone. If nothing is running, this pairs on its own — the\n * same interlude `init` uses — and the result is on disk for the next `serve`.\n */\nasync function pair(options: ChannelsOptions): Promise<number> {\n const channelId = channelIdOf(options)\n const channel = channelsOf(options.manifestPath).find((entry) => entry.id === channelId)\n if (channel === undefined)\n throw new HarnessError({\n code: \"cli_channel_unknown\",\n message: `No channel \"${channelId}\" in ${options.manifestPath}.`,\n hint: `\\`${BRAND.slug} channels list <agent>\\` names them.`,\n })\n\n if (channel.type === \"telegram\") {\n // A token is the pairing. Prompted and not echoed, then switched on — and the host holding\n // the agent reloads it, or the manifest says \"connected\" while the process runs the old one.\n const code = await credential(options)\n if (code !== EXIT_OK) return code\n const flipped = await flip(options, true)\n process.stdout.write(`${await reloadNote(options.manifestPath)}\\n`)\n return flipped\n }\n\n if (channel.type !== \"whatsapp\")\n throw new HarnessError({\n code: \"cli_channel_no_pairing\",\n message: `Channel \"${channelId}\" is a ${channel.type}, which has no pairing step.`,\n hint: `Use \\`${BRAND.slug} channels connect\\` to switch it on, or \\`credential\\` if it takes a token.`,\n })\n\n if (channel.pairWith === undefined)\n throw new HarnessError({\n code: \"cli_channel_no_number\",\n message: `Channel \"${channelId}\" has no pairWith, so there is no number to pair to.`,\n hint: \"Set pairWith on the channel to the account's own number, digits with the country code. Without it pairing is a QR, which `serve` offers.\",\n })\n\n if (channel.paired === true) {\n process.stdout.write(\n `${channelId} is already paired to ${channel.pairWith}. \\`${BRAND.slug} channels unpair\\` forgets it first.\\n`,\n )\n return EXIT_OK\n }\n\n /**\n * A host does the pairing when one can exist. It holds the socket, so when the phone accepts\n * the session is already in the process that will answer — nothing to reload, nothing to start.\n * The bootstrap puts one up first if none is; a container, CI or a caller with no installer\n * gets `undefined` here and the standalone path below, which pairs in this process and names\n * what to run next.\n */\n const agentId = agentIdFor(options.manifestPath)\n const { outcome, host } = await ensureHost({\n ...(options.installServer === undefined ? {} : { install: options.installServer }),\n })\n const note = announce(outcome)\n if (note !== undefined) process.stderr.write(note)\n if (host?.baseUrl !== undefined) {\n const adopted = await adoptOnHost(host, options.manifestPath)\n if (!adopted.ok) {\n process.stderr.write(\n `pid ${host.pid} did not adopt ${agentId}${adopted.detail === undefined ? \"\" : `: ${adopted.detail}`}\\n`,\n )\n } else {\n const result = await waitForPairing({ manifestPath: options.manifestPath, channelId })\n if (result === \"paired\") {\n process.stdout.write(\n `${channelId} is linked to ${channel.pairWith}, and pid ${host.pid} is serving it.\\n chat: ${webUrl(host.baseUrl, agentId)} — or \\`${BRAND.slug} run ${agentId}\\`\\n`,\n )\n return EXIT_OK\n }\n process.stdout.write(\n result === \"no-code\"\n ? `No code arrived from pid ${host.pid} — \\`${BRAND.slug} status\\` shows what the channel is doing; run this again once it offers one.\\n`\n : `Not paired yet — the host keeps offering codes; run this again.\\n`,\n )\n return EXIT_FAILURE\n }\n }\n\n const paired = await pairWhatsApp({\n manifestPath: options.manifestPath,\n dir: dirname(options.manifestPath),\n number: channel.pairWith,\n channelId,\n ...(channel.authDir === undefined ? {} : { authDir: channel.authDir }),\n })\n if (paired !== \"paired\") return EXIT_FAILURE\n // On disk and read by nothing yet. Said here, because a pairing that lands in a session file\n // and a process that never opens it is the exact dead end this verb exists to close.\n process.stdout.write(\n `Nothing is serving ${agentId} yet. \\`${BRAND.slug} serve ${agentId}\\` runs it here; \\`${BRAND.slug} daemon install\\` keeps a server running for every agent.\\n`,\n )\n return EXIT_OK\n}\n\n/** One line on whether the host holding this agent picked the change up. */\nasync function reloadNote(manifestPath: string): Promise<string> {\n const reloaded = await reloadOnHost(manifestPath)\n switch (reloaded.kind) {\n case \"reloaded\":\n return `pid ${reloaded.pid} reloaded it — the change is live.`\n case \"pending\":\n return `pid ${reloaded.pid} applies it when its ${reloaded.running} running turn(s) finish.`\n case \"busy\":\n return `pid ${reloaded.pid} has a turn in flight; \\`${BRAND.slug} restart ${agentIdFor(manifestPath)}\\` once it finishes.`\n case \"failed\":\n return `pid ${reloaded.pid} did not reload it${reloaded.detail === undefined ? \"\" : `: ${reloaded.detail}`} — \\`${BRAND.slug} restart ${agentIdFor(manifestPath)}\\` to retry.`\n case \"no-host\":\n return `Nothing is hosting it right now; it takes effect at the next start.`\n }\n}\n\nasync function flip(options: ChannelsOptions, enabled: boolean): Promise<number> {\n const result = await setChannelEnabled(options.manifestPath, channelIdOf(options), enabled)\n process.stdout.write(`${result.note}\\n`)\n return EXIT_OK\n}\n\nasync function credential(options: ChannelsOptions): Promise<number> {\n const channelId = channelIdOf(options)\n // **Prompted, never taken from an argument.** An argument lands in shell history *and* in `ps`,\n // readable by every local process for the call's lifetime — the same rule `config env` follows\n // and the reason `renderPlist` throws rather than writing one into a service definition.\n const value = await askSecret(`Credential for channel \"${channelId}\"`)\n // `undefined` covers both \"not a terminal\" and \"cancelled\", and both mean the same thing here:\n // nothing was read, so nothing is written. CI is told rather than having a secret arrive\n // unaudited from a pipe.\n if (value === undefined || value === \"\") {\n process.stdout.write(\n \"Nothing was read, so nothing was written. A secret is never taken from an argument or a pipe —\\nrun this at a terminal, or put the variable in the .env beside the manifest yourself.\\n\",\n )\n return EXIT_OK\n }\n const result = setChannelCredential(options.manifestPath, channelId, value)\n process.stdout.write(`${result.note}\\n`)\n return EXIT_OK\n}\n\n/**\n * Forget a stored pairing.\n *\n * Done on disk rather than through the transport, because the useful moment is usually with the\n * agent **not** running — `ChannelHub.reset` is the live path and the HTTP route uses it. Both end\n * in the same state, which is the state a first start produces.\n */\nfunction unpair(options: ChannelsOptions): number {\n const result = unpairChannel(options.manifestPath, channelIdOf(options))\n process.stdout.write(`${result.note}\\n`)\n return EXIT_OK\n}\n\nfunction channelIdOf(options: ChannelsOptions): string {\n const given = options.channelId\n if (given !== undefined && given !== \"\") return given\n const declared = channelsOf(options.manifestPath)\n // One channel is unambiguous, and making somebody name it would be ceremony. Two is a choice\n // nothing here can make for them.\n const only = declared[0]\n if (declared.length === 1 && only !== undefined) return only.id\n throw new HarnessError({\n code: \"cli_channels_needs_id\",\n message: \"Which channel?\",\n hint:\n declared.length === 0\n ? \"This agent declares none. `channels list <agent>` says so too.\"\n : `Name one: ${declared.map((channel) => channel.id).join(\", \")}.`,\n field: \"channelId\",\n })\n}\n"
6
6
  ],
7
7
  "mappings": ";+dAwBA,kBAAS,kBAyBF,eAAe,CAAe,CAAC,EAA2C,CAC7E,OAAQ,EAAQ,QACZ,IAAK,O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