dispach 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (195) hide show
  1. package/README.md +134 -85
  2. package/dist/App-qfqvx9c7.js +11 -0
  3. package/dist/{App-b1yrwrcq.js.map → App-qfqvx9c7.js.map} +6 -7
  4. package/dist/ConfigEditor-apcnj4nj.js +6 -0
  5. package/dist/{ConfigEditor-n8hdw6r7.js.map → ConfigEditor-apcnj4nj.js.map} +2 -2
  6. package/dist/KeyProbe-ya5t3v3v.js +5 -0
  7. package/dist/{KeyProbe-9jjeze5r.js.map → KeyProbe-ya5t3v3v.js.map} +2 -2
  8. package/dist/Picker-b7mn0mjg.js +5 -0
  9. package/dist/{Picker-hfeh1g6m.js.map → Picker-b7mn0mjg.js.map} +1 -1
  10. package/dist/SessionPicker-vacfwczg.js +5 -0
  11. package/dist/{SessionPicker-zyqkg4dn.js.map → SessionPicker-vacfwczg.js.map} +2 -2
  12. package/dist/SkillBrowser-66ntwaa9.js +5 -0
  13. package/dist/{SkillBrowser-3qdp8080.js.map → SkillBrowser-66ntwaa9.js.map} +1 -1
  14. package/dist/WizardApp-123998yh.js +5 -0
  15. package/dist/{WizardApp-vzpbydy3.js.map → WizardApp-123998yh.js.map} +3 -3
  16. package/dist/agents.d.ts +19 -3
  17. package/dist/agents.d.ts.map +1 -1
  18. package/dist/channels-q4fwqq87.js +31 -0
  19. package/dist/channels-q4fwqq87.js.map +10 -0
  20. package/dist/channels.d.ts +26 -0
  21. package/dist/channels.d.ts.map +1 -0
  22. package/dist/client.js +10 -10
  23. package/dist/client.js.map +3 -3
  24. package/dist/config-64q4mgxc.js +24 -0
  25. package/dist/{config-g7za9x13.js.map → config-64q4mgxc.js.map} +2 -2
  26. package/dist/{credential-npr6z8c8.js → credential-2sj7vsmw.js} +5 -5
  27. package/dist/{credential-npr6z8c8.js.map → credential-2sj7vsmw.js.map} +1 -1
  28. package/dist/daemon.d.ts.map +1 -1
  29. package/dist/index-0k3w2mxf.js +6 -0
  30. package/dist/{index-hwpvhaza.js.map → index-0k3w2mxf.js.map} +1 -1
  31. package/dist/index-1s81qstp.js +6 -0
  32. package/dist/{index-v8e92nfw.js.map → index-1s81qstp.js.map} +1 -1
  33. package/dist/index-2rycma8x.js +12 -0
  34. package/dist/{index-258d8bzg.js.map → index-2rycma8x.js.map} +4 -3
  35. package/dist/index-2zye08c4.js +6 -0
  36. package/dist/{index-vgc3y3rm.js.map → index-2zye08c4.js.map} +2 -2
  37. package/dist/{index-gme2egyq.js → index-3km1jwh7.js} +4 -4
  38. package/dist/{index-gme2egyq.js.map → index-3km1jwh7.js.map} +1 -1
  39. package/dist/index-3mtgcvkq.js +429 -0
  40. package/dist/index-3mtgcvkq.js.map +11 -0
  41. package/dist/index-4knb5vjm.js +90 -0
  42. package/dist/index-4knb5vjm.js.map +13 -0
  43. package/dist/{index-3g3ny01d.js → index-5nwwekk0.js} +4 -4
  44. package/dist/{index-3g3ny01d.js.map → index-5nwwekk0.js.map} +1 -1
  45. package/dist/index-5rm7dwq4.js +6 -0
  46. package/dist/index-5rm7dwq4.js.map +11 -0
  47. package/dist/index-79epttpm.js +6 -0
  48. package/dist/index-79epttpm.js.map +10 -0
  49. package/dist/{index-4cf6v9nb.js → index-7yk1zvds.js} +4 -4
  50. package/dist/{index-4cf6v9nb.js.map → index-7yk1zvds.js.map} +1 -1
  51. package/dist/index-81gb4ey4.js +6 -0
  52. package/dist/{index-4z7axw4r.js.map → index-81gb4ey4.js.map} +1 -1
  53. package/dist/index-8a5d8sfe.js +6 -0
  54. package/dist/{index-0d93hyfc.js.map → index-8a5d8sfe.js.map} +1 -1
  55. package/dist/index-a21zyy54.js +6 -0
  56. package/dist/index-a21zyy54.js.map +9 -0
  57. package/dist/index-b6da6c16.js +92 -0
  58. package/dist/index-b6da6c16.js.map +15 -0
  59. package/dist/index-byxrc961.js +903 -0
  60. package/dist/{index-tv4yv7d2.js.map → index-byxrc961.js.map} +16 -15
  61. package/dist/{index-ammv5st7.js → index-cgfg6t5a.js} +6 -6
  62. package/dist/{index-ammv5st7.js.map → index-cgfg6t5a.js.map} +1 -1
  63. package/dist/{index-s9mbq7h6.js → index-ehzwdnc3.js} +4 -4
  64. package/dist/{index-s9mbq7h6.js.map → index-ehzwdnc3.js.map} +1 -1
  65. package/dist/index-fzmmhmk2.js +7 -0
  66. package/dist/index-fzmmhmk2.js.map +11 -0
  67. package/dist/index-g3pk0kc0.js +6 -0
  68. package/dist/{index-9r0wyj6w.js.map → index-g3pk0kc0.js.map} +2 -2
  69. package/dist/index-h828nk24.js +153 -0
  70. package/dist/index-h828nk24.js.map +20 -0
  71. package/dist/{index-02dn6m2j.js → index-jq999vcw.js} +5 -5
  72. package/dist/{index-02dn6m2j.js.map → index-jq999vcw.js.map} +2 -2
  73. package/dist/index-k2aq5bg0.js +9 -0
  74. package/dist/{index-6p999cx4.js.map → index-k2aq5bg0.js.map} +4 -6
  75. package/dist/{index-cqqb6gaq.js → index-k3y8y3wj.js} +5 -5
  76. package/dist/{index-cqqb6gaq.js.map → index-k3y8y3wj.js.map} +1 -1
  77. package/dist/index-k59wwdgz.js +9 -0
  78. package/dist/{index-ff514z3y.js.map → index-k59wwdgz.js.map} +3 -5
  79. package/dist/index-nmnnwa02.js +6 -0
  80. package/dist/{index-6q4wf8e3.js.map → index-nmnnwa02.js.map} +1 -1
  81. package/dist/index-nn3tk25c.js +6 -0
  82. package/dist/{index-d4x6yvqh.js.map → index-nn3tk25c.js.map} +3 -4
  83. package/dist/index-q0hxh57v.js +126 -0
  84. package/dist/index-q0hxh57v.js.map +14 -0
  85. package/dist/index-srmhk9g5.js +11 -0
  86. package/dist/index-srmhk9g5.js.map +11 -0
  87. package/dist/index-swtyfhha.js +6 -0
  88. package/dist/{index-fex44816.js.map → index-swtyfhha.js.map} +2 -2
  89. package/dist/index-whq42sat.js +6 -0
  90. package/dist/{index-h9mw7b9d.js.map → index-whq42sat.js.map} +1 -1
  91. package/dist/{index-j7gyr5nx.js → index-wzsmh5j0.js} +7 -7
  92. package/dist/{index-j7gyr5nx.js.map → index-wzsmh5j0.js.map} +1 -1
  93. package/dist/{index-j55s3ehk.js → index-x7v1zq89.js} +7 -7
  94. package/dist/{index-j55s3ehk.js.map → index-x7v1zq89.js.map} +2 -2
  95. package/dist/index-xhzmv4dh.js +66 -0
  96. package/dist/index-xhzmv4dh.js.map +12 -0
  97. package/dist/index-xmv47vs0.js +6 -0
  98. package/dist/{index-gz9x25tz.js.map → index-xmv47vs0.js.map} +2 -2
  99. package/dist/index-y4c32wn7.js +6 -0
  100. package/dist/{index-qdbq8crg.js.map → index-y4c32wn7.js.map} +2 -2
  101. package/dist/index-yjcdp72k.js +6 -0
  102. package/dist/{index-tf71ap9v.js.map → index-yjcdp72k.js.map} +1 -1
  103. package/dist/index-zn24991r.js +6 -0
  104. package/dist/index-zn24991r.js.map +10 -0
  105. package/dist/index.js +374 -443
  106. package/dist/index.js.map +23 -27
  107. package/dist/init.d.ts.map +1 -1
  108. package/dist/lib/channel-actions.d.ts +103 -0
  109. package/dist/lib/channel-actions.d.ts.map +1 -0
  110. package/dist/lib/chat-frame.d.ts +12 -1
  111. package/dist/lib/chat-frame.d.ts.map +1 -1
  112. package/dist/lib/commands.d.ts +13 -0
  113. package/dist/lib/commands.d.ts.map +1 -1
  114. package/dist/lib/const.d.ts +1 -1
  115. package/dist/lib/host-actions.d.ts +121 -0
  116. package/dist/lib/host-actions.d.ts.map +1 -0
  117. package/dist/lib/init-flow.d.ts +32 -0
  118. package/dist/lib/init-flow.d.ts.map +1 -1
  119. package/dist/lib/init-whatsapp.d.ts +52 -0
  120. package/dist/lib/init-whatsapp.d.ts.map +1 -0
  121. package/dist/lib/plugin-install.d.ts +120 -0
  122. package/dist/lib/plugin-install.d.ts.map +1 -0
  123. package/dist/lib/providers.d.ts.map +1 -1
  124. package/dist/lib/provision.d.ts.map +1 -1
  125. package/dist/lib/readme-table.d.ts +15 -0
  126. package/dist/lib/readme-table.d.ts.map +1 -0
  127. package/dist/lib/sandbox.d.ts +15 -0
  128. package/dist/lib/sandbox.d.ts.map +1 -1
  129. package/dist/lib/schema.d.ts +34 -1
  130. package/dist/lib/schema.d.ts.map +1 -1
  131. package/dist/lib/subcommand.d.ts.map +1 -1
  132. package/dist/lib/web-url.d.ts +15 -0
  133. package/dist/lib/web-url.d.ts.map +1 -0
  134. package/dist/lib/wizard.d.ts.map +1 -1
  135. package/dist/memory.d.ts.map +1 -1
  136. package/dist/model.d.ts.map +1 -1
  137. package/dist/plugins.d.ts +27 -8
  138. package/dist/plugins.d.ts.map +1 -1
  139. package/dist/restart.d.ts +21 -0
  140. package/dist/restart.d.ts.map +1 -0
  141. package/dist/run.d.ts.map +1 -1
  142. package/dist/schedules.d.ts.map +1 -1
  143. package/dist/serve.d.ts.map +1 -1
  144. package/dist/sessions.d.ts.map +1 -1
  145. package/dist/skills.d.ts.map +1 -1
  146. package/dist/status.d.ts +16 -0
  147. package/dist/status.d.ts.map +1 -0
  148. package/dist/tools.d.ts.map +1 -1
  149. package/dist/validate.d.ts.map +1 -1
  150. package/dist/web-923c7f5e.js +14 -0
  151. package/dist/{web-vkb16r62.js.map → web-923c7f5e.js.map} +3 -3
  152. package/dist/web.d.ts +2 -13
  153. package/dist/web.d.ts.map +1 -1
  154. package/dist/workspace.d.ts.map +1 -1
  155. package/dist/wrapper-0w9b3my0.js +11 -0
  156. package/dist/wrapper-0w9b3my0.js.map +23 -0
  157. package/package.json +6 -3
  158. package/dist/App-b1yrwrcq.js +0 -11
  159. package/dist/ConfigEditor-n8hdw6r7.js +0 -6
  160. package/dist/KeyProbe-9jjeze5r.js +0 -5
  161. package/dist/Picker-hfeh1g6m.js +0 -5
  162. package/dist/SessionPicker-zyqkg4dn.js +0 -5
  163. package/dist/SkillBrowser-3qdp8080.js +0 -5
  164. package/dist/WizardApp-vzpbydy3.js +0 -5
  165. package/dist/config-g7za9x13.js +0 -24
  166. package/dist/index-0d93hyfc.js +0 -6
  167. package/dist/index-1c5113t4.js +0 -66
  168. package/dist/index-1c5113t4.js.map +0 -12
  169. package/dist/index-258d8bzg.js +0 -12
  170. package/dist/index-4z7axw4r.js +0 -6
  171. package/dist/index-6p999cx4.js +0 -9
  172. package/dist/index-6q4wf8e3.js +0 -6
  173. package/dist/index-9r0wyj6w.js +0 -6
  174. package/dist/index-d4x6yvqh.js +0 -6
  175. package/dist/index-fecm8xe7.js +0 -77
  176. package/dist/index-fecm8xe7.js.map +0 -12
  177. package/dist/index-fex44816.js +0 -6
  178. package/dist/index-ff514z3y.js +0 -14
  179. package/dist/index-gz9x25tz.js +0 -6
  180. package/dist/index-h9mw7b9d.js +0 -6
  181. package/dist/index-hwpvhaza.js +0 -6
  182. package/dist/index-mtn0g9vc.js +0 -7
  183. package/dist/index-mtn0g9vc.js.map +0 -11
  184. package/dist/index-qdbq8crg.js +0 -6
  185. package/dist/index-tf71ap9v.js +0 -6
  186. package/dist/index-ttwyrdjs.js +0 -427
  187. package/dist/index-ttwyrdjs.js.map +0 -11
  188. package/dist/index-tv4yv7d2.js +0 -903
  189. package/dist/index-ty24n0jh.js +0 -167
  190. package/dist/index-ty24n0jh.js.map +0 -19
  191. package/dist/index-v8e92nfw.js +0 -6
  192. package/dist/index-vgc3y3rm.js +0 -6
  193. package/dist/index-whaw4b18.js +0 -6
  194. package/dist/index-whaw4b18.js.map +0 -10
  195. package/dist/web-vkb16r62.js +0 -14
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env node
2
- import{o,u,xn,En,Tn,I}from"./index-d4x6yvqh.js";import{W}from"./index-gz9x25tz.js";import{Box as T,Text as d}from"ink";import{jsx as m,jsxs as s}from"react/jsx-runtime";function Qt({rows:e,index:t,chosen:c,window:n,width:l}){let{from:r,to:a}=I(e.length,t,n),b=new Set(c),g=e.reduce((i,p)=>p.kind==="item"?Math.max(i,p.label.length):i,0),M=xn(l,g);return s(T,{flexDirection:"column",children:[r>0?s(d,{dimColor:!0,wrap:"truncate",children:[" ",u.ellipsis," ",r," above"]}):null,e.slice(r,a).map((i,p)=>{let x=r+p;if(i.kind!=="item"){let f=i.kind==="source";return s(d,{wrap:"truncate",bold:f,color:f?o.accent:o.muted,children:[f?" ":" ",Tn(i.label,l-(f?2:4))]},x)}let h=x===t,y=b.has(x),S=En({name:i.label,meta:i.meta??"",description:i.description??""},M);return s(d,{wrap:"truncate",children:[m(d,{color:o.accent,children:h?u.pointer:" "}),m(d,{color:y?o.success:o.muted,children:y?u.checked:u.unchecked}),m(d,{bold:h,...y?{color:o.success}:{},children:S.name})," ",m(d,{color:o.muted,children:S.meta}),S.description===""?"":" ",m(d,{dimColor:!0,children:S.description})]},x)}),a<e.length?s(d,{dimColor:!0,wrap:"truncate",children:[" ",u.ellipsis," ",e.length-a," below"]}):null]})}function k(e,t,c){let n=e;for(let l=0;l<=t.length;l+=1){if(t[n.index]===!0)return n;let r=W(n,{kind:c?"down":"up"});if(r.index===n.index)return;n=r}return}function v(e,t,c,n){if(c.length===0)return e;return k(t,c,n)??k(t,c,!n)??e}function ot(e,t,c){switch(t.kind){case"move":{if(!c.includes(!0))return e;let n=W(e.cursor,t.move),l=n.index>=e.cursor.index;return{...e,cursor:v(e.cursor,n,c,l)}}case"toggle":{let n=e.cursor.index;if(c[n]!==!0)return e;let l=e.chosen.includes(n)?e.chosen.filter((r)=>r!==n):[...e.chosen,n].sort((r,a)=>r-a);return{...e,chosen:l}}case"all":{let n=c.flatMap((l,r)=>l?[r]:[]);return{...e,chosen:n}}case"none":return{...e,chosen:[]}}}function en(e){let t=e.indexOf(!0);return t===-1?0:t}
3
- export{Qt,ot,en};
4
-
5
- //# debugId=E6CE155E3D3FA44364756E2164756E21
6
- //# sourceMappingURL=index-fex44816.js.map
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env node
2
- import{t,pt,Ft,me,Be,Ke}from"./index-tv4yv7d2.js";import{wr}from"./index-ttwyrdjs.js";import{At,To}from"./index-tf71ap9v.js";import{l,p,d,c}from"./index-j7gyr5nx.js";import{chmodSync as E,existsSync as _,readFileSync as b,statSync as R,writeFileSync as N}from"node:fs";import{dirname as j,join as F}from"node:path";function x(e){if(!(e===""||/^["']/.test(e)||/\s/.test(e)||e.includes("#")||e!==e.trim()))return e;return`"${e.replace(/\\/g,"\\\\").replace(/"/g,"\\\"").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}"`}function w(e,n,o){let r=`${n}=${x(o)}`,i=e.split(`
3
- `),s=new RegExp(`^\\s*(?:export\\s+)?${n}\\s*=`),a=i.findIndex((u)=>s.test(u));if(a!==-1){let u=i[a]??"",h=/^\s*export\s+/.exec(u)?.[0]??"";return{text:[...i.slice(0,a),`${h}${r}`,...i.slice(a+1)].join(`
4
- `),replaced:!0}}let f=e.replace(/\n+$/,"");return{text:f===""?`${r}
5
- `:`${f}
6
- ${r}
7
- `,replaced:!1}}function T(e){return F(j(e),".env")}async function Wn(e,n,o){let r=Ft(o),i=await pt({file:e,path:n.split("."),value:r});return{note:`${n} is now ${O(r)}`,reflowed:i.reflowed,before:i.before}}async function qn(e,n,o){let r=b(e,"utf8"),i=me(r,["channels"]);if(!Array.isArray(i))throw new t({code:"cli_config_no_channels",message:"This agent has no channels, so there is nobody to allow.",hint:"`config set <agent> channels '[{type: telegram, id: tg, tokenEnv: TELEGRAM_BOT_TOKEN, mode: longpoll}]'` declares one first."});let s=i.filter((g)=>typeof g==="object"&&g!==null&&!Array.isArray(g)),a=s.findIndex((g)=>String(g.id??"")===n);if(a===-1)throw new t({code:"cli_config_channel_unknown",message:`No channel with id "${n}".`,hint:`Declared: ${s.map((g)=>String(g.id??"")).join(", ")}.`,field:"channel"});let f=s[a],u=o.map((g)=>gr(g,String(f.type??""))),h=[...new Set(u)],m=Array.isArray(f.allowFrom)?f.allowFrom.map(String):[],A=await pt({file:e,path:["channels"],value:s.map((g,S)=>S===a?{...g,allowFrom:h}:g)});return{note:h.length===0?`${n} now allows nobody, which refuses every message`:`${n} now allows ${h.join(", ")}`,reflowed:A.reflowed,before:m}}function Gn(e,n,o){if(!/^[A-Za-z_][A-Za-z0-9_]*$/.test(n))throw new t({code:"cli_config_env_name_invalid",message:`"${n}" is not an environment variable name.`,hint:"Letters, digits and underscores, not starting with a digit — MODEL_API_KEY, TELEGRAM_BOT_TOKEN.",field:"name"});if(o==="")throw new t({code:"cli_config_env_empty",message:`An empty value for ${n} would not start the agent.`,hint:"A variable set to nothing fails the load exactly as a missing one does. Nothing was written."});let r=T(e),i=_(r)?b(r,"utf8"):"",s=w(i,n,o);N(r,s.text,{encoding:"utf8",mode:384});let a=(R(r).mode&63)!==0;if(a)E(r,384);return{note:`${n} ${s.replaced?"replaced":"written"} in ${r}${a?" (tightened to 0600)":""}`,reflowed:!1,before:void 0}}function gr(e,n){let o=e.trim();if(o==="")throw new t({code:"cli_config_handle_missing",message:"No handle given.",hint:"On Telegram that is the username, not the display name.",field:"handle"});if(n!=="telegram")return o;let r=wr(o);if(!r.ok)throw new t({code:"cli_config_handle_invalid",message:`"${o}" ${r.reason}`,hint:"A handle that cannot exist matches nobody, and the only symptom is the bot silently refusing every message from the person it was set up for.",field:"handle"});return r.value}function O(e){if(e==="")return"empty";if(typeof e==="string")return e;return JSON.stringify(e)}function Tt(e){if(e===void 0||e===null)return"(not set)";if(typeof e==="string")return e===""?'""':e;if(typeof e==="boolean"||typeof e==="number")return String(e);return JSON.stringify(e)}function V(e){return e.split(/[.[]/)[0]??e}function fo(e,n){let o=[`${n}`,""],r=new Map;for(let s of e){let a=V(s.setting.path);r.set(a,[...r.get(a)??[],s])}let i=!0;for(let[s,a]of r){o.push(p(s,i)),i=!1;for(let f of a){let u=f.setting.agentListed?"":" · yours only",h=f.setting.via===void 0?"":` · set with \`${f.setting.via}\``,m=f.setting.confirm===void 0?"":" · asks first";o.push(l([{label:f.setting.path,value:Tt(f.value)}]),c(`${f.setting.means}${u}${h}${m}`,4))}}return o.push("","A change takes effect the next time the agent starts. `yours only` marks a field the agent is","refused: what it may do is its to ask for, where it writes and who may reach it are yours."),o.join(`
8
- `)}function ho(e,n){return[l([{label:e.path,value:Tt(n)}]),c(e.means,4),...e.toAgent===void 0?[]:[c(`to the agent: ${e.toAgent}`,4)]].join(`
9
- `)}function mo(e,n){if(e.confirm===void 0)return;if(e.path==="tools.untrusted.onMutate"&&String(n).toLowerCase()!=="allow")return;return e.confirm}function po(e){let n=[l([{label:"set",value:`${e.path} = ${Tt(e.after)}`},{label:"was",value:e.before===void 0?"(not set)":Tt(e.before)},{label:"file",value:e.file}])];if(e.reflowed)n.push("",d("the block could not be edited in place, so the file was re-serialised — it is valid, and comments may have moved"));if(e.running!==void 0)n.push("",d(`this agent is running (pid ${e.running.pid}, ${e.running.mode}) and holds its settings for its lifetime — the change applies after ${e.restartHint}`));for(let o of e.pending)n.push(d(`${o.name} is not set — ${o.why}`)),n.push(d(`fill it in with \`config env <agent> ${o.name}\``));return n.join(`
10
- `)}function go(){return Ke.filter((e)=>e.via===void 0&&!/[[<]/.test(e.path)).map((e)=>e.path)}function _t(e){if(typeof e!=="object"||e===null)return[];let n=e,o=[],r=(f,u)=>{if(typeof f==="string"&&f!=="")o.push({name:f,why:u})},i=y(n.model);for(let f of["main","selector","compactor"]){let u=y(i?.[f]);r(u?.apiKeyEnv,"the manifest will not load until it is set")}if(Array.isArray(n.channels))for(let f of n.channels){let u=y(f);if(u===void 0||u.enabled===!1)continue;r(u.tokenEnv,`the ${String(u.id??u.type??"channel")} channel is read at boot, so the agent will not start until it is set`)}let s=y(n.server);if(s?.enabled===!0)r(s.tokenEnv,"the HTTP API would accept unauthenticated requests. This does not stop the agent starting");let a=y(y(n.tools)?.providers);for(let[f,u]of Object.entries(a??{}))r(y(u)?.apiKeyEnv,`the ${f} provider's tools will not work until it is set`);return o}function y(e){if(typeof e!=="object"||e===null||Array.isArray(e))return;return e}function Zn(e,n){return e.filter((o)=>n[o.name]===void 0||n[o.name]==="")}function k(e,n){let o=[],r=new Map;for(let i of e){if(i.setting.via!==void 0||/[[<]/.test(i.setting.path))continue;let s=i.setting.path.split(".")[0]??i.setting.path;r.set(s,[...r.get(s)??[],i])}for(let[i,s]of r){o.push({kind:"heading",label:i});for(let a of s)o.push({kind:"setting",setting:a.setting,value:a.value})}if(n.channels.length>0){o.push({kind:"heading",label:"who may reach it"});for(let i of n.channels)o.push({kind:"allow",channelId:i.id,channelType:i.type,handles:i.allowFrom})}if(n.secrets.length>0){o.push({kind:"heading",label:"secrets — written to the .env, never shown"});for(let i of n.secrets)o.push({kind:"secret",name:i.name,why:i.why,present:n.present(i.name)})}return o}import{readFileSync as v}from"node:fs";function Vn(e){let n=v(e,"utf8");return Ke.map((o)=>{if(o.path==="channels[].allowFrom"){let r=me(n,["channels"]);if(!Array.isArray(r))return{setting:o,value:void 0};let i={};for(let s of r){if(typeof s!=="object"||s===null)continue;let a=s;if(typeof a.id!=="string")continue;i[a.id]=a.allowFrom??[]}return{setting:o,value:Object.keys(i).length===0?void 0:i}}if(o.path==="tools.providers.<id>.writeRoots"){let r=me(n,["tools","providers"]);if(typeof r!=="object"||r===null||Array.isArray(r))return{setting:o,value:void 0};let i={};for(let[s,a]of Object.entries(r)){if(typeof a!=="object"||a===null)continue;let f=a.writeRoots;if(f!==void 0)i[s]=f}return{setting:o,value:Object.keys(i).length===0?void 0:i}}return{setting:o,value:me(n,o.path.split("."))}})}function at(e){let n=v(e,"utf8"),o=Be(n),r=At(e),i=me(n,["channels"]);return k(Vn(e),{channels:(Array.isArray(i)?i:[]).filter((s)=>typeof s==="object"&&s!==null&&!Array.isArray(s)).map((s)=>({id:String(s.id??""),type:String(s.type??""),allowFrom:Array.isArray(s.allowFrom)?s.allowFrom.map(String):[]})).filter((s)=>s.id!==""),secrets:_t(o),present:(s)=>To(r,s)})}async function rn(e,n,o){switch(n.kind){case"setting":{if(o.trim()==="")throw new t({code:"cli_config_value_missing",message:`No value given for ${n.setting.path}.`,hint:'A bare word, a number, a list as ["a", "b"], or a map as {k: v}.',field:"value"});return(await Wn(e,n.setting.path,o)).note}case"allow":{let r=o.trim()===""?[]:o.trim().split(/\s+/);return(await qn(e,n.channelId,r)).note}case"secret":return Gn(e,n.name,o).note;case"heading":return""}}
11
- export{Wn,qn,Gn,gr,Tt,fo,ho,mo,po,go,_t,Zn,Vn,at,rn};
12
-
13
- //# debugId=D81357B6476A51F364756E2164756E21
14
- //# sourceMappingURL=index-ff514z3y.js.map
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env node
2
- import{o,u,I}from"./index-d4x6yvqh.js";import{Box as f,Text as d}from"ink";import{jsxs as r}from"react/jsx-runtime";function ae({items:e,index:n,numbered:t,maxRows:p}){let m=p===void 0?e.length:Math.max(1,p),{from:c,to:x}=I(e.length,n,m),s=e.slice(c,x).map((l,i)=>({at:c+i,item:l}));return r(f,{flexDirection:"column",children:[c>0?r(d,{dimColor:!0,wrap:"truncate",children:[" ",u.ellipsis," ",c," above"]}):null,s.map(({at:l,item:i})=>{let a=l===n,y=t===!0?`${l+1}. `:"";return r(d,{wrap:"truncate",...a?{color:o.accent}:{},children:[a?u.pointer:" ",r(d,{bold:a,children:[y,i.label]}),i.hint===void 0?"":r(d,{dimColor:!0,...a?{color:o.muted}:{},children:[" ",i.hint]})]},`row-${l}`)}),x<e.length?r(d,{dimColor:!0,wrap:"truncate",children:[" ",u.ellipsis," ",e.length-x," below"]}):null]})}function W(e,n){if(e.count===0)return e;let t=e.count-1;switch(n.kind){case"up":return{...e,index:Math.max(0,e.index-1)};case"down":return{...e,index:Math.min(t,e.index+1)};case"first":return{...e,index:0};case"last":return{...e,index:t};case"jump":return n.index<0||n.index>t?e:{...e,index:n.index}}}
3
- export{ae,W};
4
-
5
- //# debugId=2BA8171202239BF664756E2164756E21
6
- //# sourceMappingURL=index-gz9x25tz.js.map
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env node
2
- import{S}from"./index-d4x6yvqh.js";import{Rn,In,Ge,Ze,Ve}from"./index-vgc3y3rm.js";var s=" · ",l=3;function Po(n,e){let t=[{kind:"title",text:S(n.title,e)}],r=n.agent===void 0?n.summary:[`${n.agent.name}${s}${n.agent.model}`,n.summary].filter((a)=>a!=="").join(s);if(r!=="")t.push({kind:"summary",text:S(r,e)});let i=n.state??[];if(i.length>0)t.push({kind:"state",text:S(i.map((a)=>a.label).join(s),e)});let o=n.warnings??[];for(let a of o.slice(0,l))t.push({kind:"warning",text:S(`⚠ ${a}`,e)});if(o.length>l)t.push({kind:"warning",text:S(`⚠ and ${o.length-l} more`,e)});return t}function Mo(n,e){let t=n.map((i)=>`${i.key} ${i.does}`),r="";for(let i of t){let o=r===""?i:`${r}${s}${i}`;if([...o].length>e)break;r=o}return r===""?S(t[0]??"",e):r}function rr(n,e){let t=[n.title];if(n.summary!=="")t.push(n.summary);if(n.agent!==void 0)t.push(n.agent.name,n.agent.model);let r=n.warnings??[];if(r.length>0)t.push(`⚠ ${r.length} note${r.length===1?"":"s"} at the top`);return S(t.join(s),e)}var Lo={key:"q",does:"back"};function u(n,e){return n===void 0||n<=0?e:n}function q(n,e){return Math.max(Rn,Math.min(In,u(n,e)))}function Do(n,e){return Math.max(Ge,Math.min(Ze,u(n,e)-Ve))}
3
- export{Po,Mo,rr,Lo,q,Do};
4
-
5
- //# debugId=CCA62814AD4503FC64756E2164756E21
6
- //# sourceMappingURL=index-h9mw7b9d.js.map
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env node
2
- import{e,t}from"./index-tv4yv7d2.js";import{Rt,le,It,Ot,Ao}from"./index-whaw4b18.js";class se extends t{static ERROR_NAME="UsageError"}function D(n,s){let i=Array.from({length:s.length+1},(r,f)=>f);for(let r=1;r<=n.length;r+=1){let f=[r];for(let u=1;u<=s.length;u+=1){let h=(i[u-1]??0)+(n[r-1]===s[u-1]?0:1),c=(f[u-1]??0)+1,b=(i[u]??0)+1;f.push(Math.min(h,c,b))}i=f}return i[s.length]??Math.max(n.length,s.length)}function R(n,s){let i,r=Number.POSITIVE_INFINITY;for(let f of s){let u=D(n,f);if(u<r)r=u,i=f}return i!==void 0&&r<=Math.max(2,Math.floor(n.length/3))?i:void 0}class N{#e;#t;constructor(n,s){this.#e=n,this.#t=s}#n(n,s){let i=this.#t.get(n);if(i===void 0)throw new se({code:"cli_flag_not_declared",message:`No flag "${n}" is declared for this command.`,hint:"This is a bug in the CLI, not in the command line. Add the flag to lib/commands.ts or fix the reader."});if(i.kind!==s)throw new se({code:"cli_flag_kind_mismatch",message:`Flag "${n}" is declared as ${i.kind} but was read as ${s}.`,hint:"This is a bug in the CLI. The reader and lib/commands.ts disagree."});return this.#e.get(n)}str(n){let s=this.#n(n,"string");return typeof s==="string"?s:void 0}num(n){let s=this.#n(n,"number");return typeof s==="number"?s:void 0}bool(n){return this.#n(n,"boolean")===!0}has(n){return this.#e.has(n)}}function g(n,s,i,r){return r===void 0?{code:n,message:s,hint:i}:{code:n,message:s,hint:i,field:r}}function v(n){let s=n[0];return new se({code:"cli_usage",message:n.length===1&&s!==void 0?s.message:`${n.length} problems with the command line.`,hint:n.length===1&&s!==void 0?s.hint:"Each problem below names the flag and its fix.",...s?.field===void 0?{}:{field:s.field},details:n})}function E(n,s,i){let r=Number(s);if(s.trim()===""||!Number.isFinite(r))return g("cli_flag_not_a_number",`${i} expects a number, got ${JSON.stringify(s)}.`,`Pass a number, as in ${i} 50. The old parser silently used the default here, which made a typo look like it worked.`,i);if(n.integer===!0&&!Number.isInteger(r))return g("cli_flag_not_an_integer",`${i} expects a whole number, got ${s}.`,`Drop the fractional part: ${i} ${Math.trunc(r)}.`,i);if(n.min!==void 0&&r<n.min)return g("cli_flag_below_min",`${i} must be at least ${n.min}, got ${r}.`,`Pass ${n.min} or more.`,i);return r}function jr(n){let s=n[0];if(s===void 0)return{kind:"usage"};if(s.startsWith("-")){let a=new Set(Rt.flatMap((o)=>o.short===void 0?[`--${o.name}`]:[`--${o.name}`,`-${o.short}`])),l=n.filter((o)=>!a.has(o));if(l.length>0)throw v([g("cli_no_command","No command given.",`Run \`${e.slug} --help\` for the command list. Commands are ${le.map((o)=>o.name).join(", ")}.`,l[0])]);if(n.includes("--version")||n.includes("-v"))return{kind:"version"};if(n.includes("--help")||n.includes("-h"))return{kind:"help",command:void 0};return{kind:"usage"}}let i=It(s);if(i===void 0){let a=R(s,le.map((l)=>l.name));throw v([g("cli_unknown_command",`Unknown command "${s}".`,a===void 0?`Run \`${e.slug} --help\` for the command list.`:`Did you mean "${a}"? Run \`${e.slug} --help\` for the full list.`,s)])}let r=new Map(Ot(i).map((a)=>[a.name,a])),f=new Map(Ot(i).filter((a)=>a.short!==void 0).map((a)=>[a.short,a])),u=new Map,h=[],c=[],b=!1,F=(a,l,o)=>{if(l===""){c.push(g("cli_flag_empty_value",`${o} was given an empty value.`,"Pass a value, or drop the flag entirely to use the default.",o));return}if(a.kind==="number"){let d=E(a,l,o);if(typeof d==="number")u.set(a.name,d);else c.push(d);return}u.set(a.name,l)};for(let a=1;a<n.length;a+=1){let l=n[a];if(l===void 0)continue;if(b){h.push(l);continue}if(l==="--"){b=!0;continue}if(l.startsWith("--")){let o=l.slice(2),d=o.indexOf("="),p=d===-1?o:o.slice(0,d),m=r.get(p);if(m===void 0){let y=Ao(p,i.name),M=R(p,[...r.keys()]);c.push(g(y.length>0?"cli_flag_wrong_command":"cli_unknown_flag",y.length>0?`${i.name} does not accept --${p}.`:`Unknown flag --${p}.`,y.length>0?`--${p} is accepted by: ${y.join(", ")}.`:M===void 0?`Run \`${e.slug} ${i.name} --help\` for the flags this command accepts.`:`Did you mean --${M}?`,`--${p}`));continue}let _=`--${p}`;if(m.kind==="boolean"){if(d!==-1){c.push(g("cli_flag_takes_no_value",`${_} is a switch and takes no value.`,`Drop the "=${o.slice(d+1)}" — pass ${_} on its own.`,_));continue}u.set(m.name,!0);continue}if(d!==-1){F(m,o.slice(d+1),_);continue}let k=n[a+1];if(m.bare!==void 0&&(k===void 0||k.startsWith("-"))){u.set(m.name,m.bare);continue}if(k===void 0){c.push(g("cli_flag_needs_value",`${_} needs a value.`,`Pass one, as in ${_} <${m.placeholder??"value"}>.`,_));continue}F(m,k,_),a+=1;continue}if(l.startsWith("-")&&l.length>1){for(let o of[...l.slice(1)]){let d=f.get(o);if(d===void 0){c.push(g("cli_unknown_flag",`Unknown flag -${o}.`,`Run \`${e.slug} ${i.name} --help\` for the flags this command accepts.`,`-${o}`));continue}if(d.kind!=="boolean"){c.push(g("cli_short_flag_needs_value",`-${o} takes a value and cannot be bundled.`,`Write it on its own: --${d.name} <${d.placeholder??"value"}>.`,`-${o}`));continue}u.set(d.name,!0)}continue}h.push(l)}let w=new N(u,r);if(w.bool("help"))return{kind:"help",command:i};if(w.bool("version"))return{kind:"version"};let S=i.args.some((a)=>a.variadic===!0),x=i.args.filter((a)=>a.required);if(c.length>0)throw v(c);else if(h.length<x.length){let a=x[h.length];c.push(g("cli_missing_argument",`${i.name} needs ${a===void 0?"another argument":`a ${a.name}`}.`,`Usage: ${e.slug} ${i.name} ${i.args.map((l)=>`<${l.name}${l.variadic===!0?"...":""}>`).join(" ")}`))}else if(!S&&h.length>i.args.length){let a=h.slice(i.args.length);c.push(g("cli_unexpected_argument",`${i.name} takes ${i.args.length} argument(s), got ${h.length}.`,i.unexpectedArgHint??`Unexpected: ${a.join(" ")}. Quote a value containing spaces.`))}if(c.length>0)throw v(c);return{kind:"command",parsed:{command:i,positionals:h,flags:w}}}
3
- export{se,jr};
4
-
5
- //# debugId=EAE3DB2145C6B8F464756E2164756E21
6
- //# sourceMappingURL=index-hwpvhaza.js.map
@@ -1,7 +0,0 @@
1
- #!/usr/bin/env node
2
- import{e,E,t,T}from"./index-tv4yv7d2.js";function f(n){return n!==void 0&&n!==""}function Ee(n=process.env){return{noColor:f(n.NO_COLOR),dumbTerminal:n.TERM==="dumb",ci:f(n.CI)&&n.CI!=="false",debug:f(n.DEBUG),sandboxHome:f(n[`${e.envPrefix}HOME`])?n[`${e.envPrefix}HOME`]:void 0,noEnhancedKeys:f(n[`${e.envPrefix}NO_CSI_U`])}}import{existsSync as l,readdirSync as x,statSync as p}from"node:fs";import{homedir as R}from"node:os";import{isAbsolute as S,join as i,resolve as h,sep as b}from"node:path";function ee(n=process.env){return Ee(n).sandboxHome??i(R(),e.stateDir)}function B(n){return i(ee(n),"agents")}function w(n){return i(ee(n),"store.db")}function Xt(n){let o=i(ee(n),"logs","server");return{out:i(o,"out.log"),err:i(o,"err.log")}}function Jt(n,o){let s=i(ee(o),"logs");return{out:i(s,`${n}.out.log`),err:i(s,`${n}.err.log`)}}function P(n,o){let s=h(B(o)),d=h(n);return d===s||d.startsWith(s+b)}function ao(n,o){if(P(n,o))return;return`note: ${h(n)} is outside the sandbox (${B(o)}) — this agent has no bare name, so every later command needs its path. Omit --dir to put it in the sandbox.`}function K(n){let o=B(n),s;try{s=x(o)}catch{return[]}let d=[];for(let r of s.sort()){let u=i(o,r),g=i(u,"agent.yaml");try{if(!p(u).isDirectory())continue}catch{continue}if(!l(g))continue;let y=0;try{y=p(g).mtimeMs}catch{}try{let c=T(g);d.push({ref:r,dir:u,manifestPath:g,mtimeMs:y,...c.id===void 0?{}:{id:c.id},...c.name===void 0?{}:{name:c.name},...c.modelId===void 0?{}:{modelId:c.modelId}})}catch(c){d.push({ref:r,dir:u,manifestPath:g,mtimeMs:y,problem:c instanceof Error?c.message:String(c)})}}let a=new Map;for(let r of d){if(r.id===void 0)continue;a.set(r.id,[...a.get(r.id)??[],r])}let m=d.map((r)=>{if(r.id===void 0||(a.get(r.id)?.length??0)<2)return r;return{...r,problem:`manifest id "${r.id}" is shared with another sandbox agent — their sessions share one history`}});return[...m.filter((r)=>r.problem===void 0),...m.filter((r)=>r.problem!==void 0)]}function te(n,o,s=process.cwd()){let d=n.includes(b)||n.includes("/")||n.endsWith(".yaml")||n.endsWith(".yml"),a=S(n)?n:h(s,n);if(!d&&l(a)&&l(i(B(o),n)))process.stderr.write(`note: using ./${n} from the current directory; a sandbox agent "${n}" also exists — run it from elsewhere, or as ${i(B(o),n)}
3
- `);if(d||l(a)){if(l(a)){if(p(a).isDirectory()){let g=i(a,"agent.yaml");if(l(g))return g;throw new t({code:"cli_agent_dir_without_manifest",message:`${n} is a directory with no agent.yaml inside.`,hint:"Point at the manifest itself, or at a directory that holds one. Sandbox agents are run by bare name, with no path separators."})}return a}throw new t({code:"cli_agent_path_missing",message:`${n} looks like a path, and nothing is there.`,hint:`Paths resolve against the current directory. For an agent in the sandbox, use its bare name — \`${e.slug} run <name>\` — which resolves under ${B(o)}.`})}let m=i(B(o),n,"agent.yaml");if(l(m))return m;let r=K(o).map((g)=>g.ref),u=E(n,r);throw new t({code:"cli_agent_unknown",message:`No agent named "${n}" in the sandbox${r.length===0?", which is empty":""}.`,hint:r.length===0?`Create one with \`${e.slug} init\`, or pass a path to an agent.yaml.`:`Known agents: ${r.join(", ")}.${u===void 0?"":` Did you mean ${u}?`} A path (./dir or file.yaml) is also accepted.`})}
4
- export{Ee,ee,B,w,Xt,Jt,ao,K,te};
5
-
6
- //# debugId=6744C413011979E664756E2164756E21
7
- //# sourceMappingURL=index-mtn0g9vc.js.map
@@ -1,11 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/lib/env.ts", "../src/lib/sandbox.ts"],
4
- "sourcesContent": [
5
- "/**\n * Every environment read the CLI makes.\n *\n * Centralised for the same reason termheat centralises it: an environment variable consulted deep\n * inside a component is untestable and invisible. Everything downstream takes an `EnvFacts` value,\n * so the interesting logic — `resolveMode` especially — is a pure function of its inputs.\n */\n\nimport { BRAND } from \"@dispach/core\"\nimport type { EnvFacts } from \"#lib/types\"\n\n/**\n * `NO_COLOR` is honoured when present and non-empty, per no-color.org. An exported-but-empty\n * variable is a container passing through something unset, not a stated preference.\n */\nfunction isSet(value: string | undefined): boolean {\n return value !== undefined && value !== \"\"\n}\n\nexport function readEnv(env: Readonly<Record<string, string | undefined>> = process.env): EnvFacts {\n return {\n noColor: isSet(env.NO_COLOR),\n dumbTerminal: env.TERM === \"dumb\",\n // `CI=false` is set by tooling that wants to say \"not CI\", and taking it literally would\n // strip interactivity from a terminal that has it.\n ci: isSet(env.CI) && env.CI !== \"false\",\n debug: isSet(env.DEBUG),\n // The sandbox root override, `<ENVPREFIX>HOME`. Brand-derived so a rename moves it.\n sandboxHome: isSet(env[`${BRAND.envPrefix}HOME`])\n ? env[`${BRAND.envPrefix}HOME`]\n : undefined,\n // Brand-derived like the sandbox root above, so a rename moves it.\n noEnhancedKeys: isSet(env[`${BRAND.envPrefix}NO_CSI_U`]),\n }\n}\n",
6
- "/**\n * The home sandbox: where agents live when nobody says otherwise.\n *\n * `~/<stateDir>/` (brand-derived, so a rename moves it) holds `agents/<ref>/` for init-created\n * agents and `store.db` for their sessions. One root, one store: the store schema is already\n * keyed by agent id, and a cwd-relative default meant the same agent got a different session\n * history in every directory you happened to be in.\n *\n * Discovery reads manifest *headers*, never `loadManifest`: loading expands env references and\n * checks that key variables are set, so a picker built on it would fail exactly when it is\n * needed most — on a machine where the key is not exported yet. A broken manifest becomes a\n * listed entry with a `problem`, never a broken listing.\n *\n * Tests override the root with `<ENVPREFIX>HOME` pointed at a tmpdir; nothing here touches the\n * real home directory when that is set.\n */\n\nimport { existsSync, readdirSync, statSync } from \"node:fs\"\nimport { homedir } from \"node:os\"\nimport { isAbsolute, join, resolve, sep } from \"node:path\"\nimport { BRAND, HarnessError, nearest, readManifestHeader } from \"@dispach/core\"\nimport { readEnv } from \"#lib/env\"\n\nexport function sandboxRoot(\n env: Readonly<Record<string, string | undefined>> = process.env,\n): string {\n const override = readEnv(env).sandboxHome\n return override ?? join(homedir(), BRAND.stateDir)\n}\n\nexport function agentsDir(env?: Readonly<Record<string, string | undefined>>): string {\n return join(sandboxRoot(env), \"agents\")\n}\n\nexport function storePath(env?: Readonly<Record<string, string | undefined>>): string {\n return join(sandboxRoot(env), \"store.db\")\n}\n\n/**\n * Where a service writes its output, keyed by the agent's **manifest id**.\n *\n * Not by the directory name, which is what `run <ref>` takes — the same split as the store's\n * `agent_id` and the launchd label. Two directories with one manifest id therefore share these files,\n * which `listAgents` already warns about.\n *\n * Here rather than in `daemon.ts`, where it was private, because it is a fact about the sandbox layout\n * and `remove` needs it too. Moved rather than duplicated: a second copy of a path derivation is how\n * one command deletes a file another command is still writing to.\n */\n/**\n * Where the one server unit writes, in a **subdirectory** rather than beside the agent logs.\n *\n * `logs/<id>.err.log` is the per-agent shape, so a flat `logs/server.err.log` would collide with an\n * agent whose id happened to be `server` — and the collision would appear as a service and an agent\n * appending to one file, which is the kind of thing nobody diagnoses from a log.\n */\nexport function serverLogPaths(env?: Readonly<Record<string, string | undefined>>): {\n readonly out: string\n readonly err: string\n} {\n const dir = join(sandboxRoot(env), \"logs\", \"server\")\n return { out: join(dir, \"out.log\"), err: join(dir, \"err.log\") }\n}\n\nexport function logPaths(\n agentId: string,\n env?: Readonly<Record<string, string | undefined>>,\n): { readonly out: string; readonly err: string } {\n const dir = join(sandboxRoot(env), \"logs\")\n return { out: join(dir, `${agentId}.out.log`), err: join(dir, `${agentId}.err.log`) }\n}\n\n/**\n * Is this path inside the sandbox's agents directory?\n *\n * Both sides are resolved first, for the reason `root.ts` already records: an unresolved\n * `<base>/../../elsewhere` passes a prefix test while landing nowhere near the base. The `sep`\n * suffix is what stops `~/.brand/agents-backup` reading as inside `~/.brand/agents`.\n */\nexport function insideSandbox(\n targetDir: string,\n env?: Readonly<Record<string, string | undefined>>,\n): boolean {\n const base = resolve(agentsDir(env))\n const target = resolve(targetDir)\n return target === base || target.startsWith(base + sep)\n}\n\n/**\n * The one-line note an out-of-sandbox target earns, or `undefined` when it is inside.\n *\n * A note rather than a refusal: `init --dir ./examples/scout` is a legitimate thing to want, and a\n * command that refuses it would be one people work around with `mv`. What is *not* legitimate is\n * doing it silently — an agent outside the sandbox has no bare name, so every later `run`, `config`,\n * `daemon` and `schedules` call needs a path, and the reason for that is only obvious at the moment\n * the directory is chosen.\n *\n * Pure and separate from the write so the sentence can be asserted without a filesystem.\n */\nexport function outsideSandboxNote(\n targetDir: string,\n env?: Readonly<Record<string, string | undefined>>,\n): string | undefined {\n if (insideSandbox(targetDir, env)) return undefined\n return `note: ${resolve(targetDir)} is outside the sandbox (${agentsDir(env)}) — this agent has no bare name, so every later command needs its path. Omit --dir to put it in the sandbox.`\n}\n\nexport interface SandboxAgent {\n /** The directory name — what `run <ref>` takes. Filesystem-unique by construction. */\n readonly ref: string\n /** Absolute agent directory. */\n readonly dir: string\n /** Absolute path to its agent.yaml. */\n readonly manifestPath: string\n /** From the manifest header; may differ from `ref` for hand-copied directories. */\n readonly id?: string\n readonly name?: string\n /** Raw — may literally be an unexpanded `${MODEL_ID}` reference. */\n readonly modelId?: string\n /** Modification time of the manifest, for \"recently used\" ordering hints. */\n readonly mtimeMs: number\n /** Present when the manifest could not be read; the entry lists anyway, honestly. */\n readonly problem?: string\n}\n\n/**\n * Every agent directory in the sandbox, alphabetical by ref with broken entries last.\n *\n * Broken means the header could not be read — the entry still appears, carrying the problem,\n * because a listing that silently hides a corrupted agent turns \"why is my agent gone\" into a\n * filesystem investigation. Duplicate manifest ids are marked the same way: both run, but their\n * sessions share a store keyed by that id, which is worth a warning rather than a pretence.\n */\nexport function listAgents(\n env?: Readonly<Record<string, string | undefined>>,\n): readonly SandboxAgent[] {\n const dir = agentsDir(env)\n let entries: string[]\n try {\n entries = readdirSync(dir)\n } catch {\n // No sandbox yet is the normal first-run state, not an error.\n return []\n }\n\n const agents: SandboxAgent[] = []\n for (const ref of entries.sort()) {\n const agentDir = join(dir, ref)\n const manifestPath = join(agentDir, \"agent.yaml\")\n try {\n if (!statSync(agentDir).isDirectory()) continue\n } catch {\n continue\n }\n if (!existsSync(manifestPath)) continue\n\n let mtimeMs = 0\n try {\n mtimeMs = statSync(manifestPath).mtimeMs\n } catch {\n // Raced away between existsSync and statSync; list it with what we have.\n }\n\n try {\n const header = readManifestHeader(manifestPath)\n agents.push({\n ref,\n dir: agentDir,\n manifestPath,\n mtimeMs,\n ...(header.id === undefined ? {} : { id: header.id }),\n ...(header.name === undefined ? {} : { name: header.name }),\n ...(header.modelId === undefined ? {} : { modelId: header.modelId }),\n })\n } catch (error) {\n agents.push({\n ref,\n dir: agentDir,\n manifestPath,\n mtimeMs,\n problem: error instanceof Error ? error.message : String(error),\n })\n }\n }\n\n // Duplicate manifest ids share session history — say so rather than pretend it is fine.\n const byId = new Map<string, SandboxAgent[]>()\n for (const agent of agents) {\n if (agent.id === undefined) continue\n byId.set(agent.id, [...(byId.get(agent.id) ?? []), agent])\n }\n const marked = agents.map((agent) => {\n if (agent.id === undefined || (byId.get(agent.id)?.length ?? 0) < 2) return agent\n return {\n ...agent,\n problem: `manifest id \"${agent.id}\" is shared with another sandbox agent — their sessions share one history`,\n }\n })\n\n return [\n ...marked.filter((a) => a.problem === undefined),\n ...marked.filter((a) => a.problem !== undefined),\n ]\n}\n\n/**\n * Turn what the user typed into a manifest path.\n *\n * The filesystem wins: anything that looks like a path (a separator, a .yaml suffix, or a thing\n * that exists here) is a path, so `./milo` always forces the file even when a sandbox agent\n * `milo` exists — the same rule git applies to pathspec-versus-branch, with the same free escape\n * hatch. Only then is the ref tried as a sandbox agent name.\n */\nexport function resolveAgentRef(\n ref: string,\n env?: Readonly<Record<string, string | undefined>>,\n cwd: string = process.cwd(),\n): string {\n const looksLikePath =\n ref.includes(sep) || ref.includes(\"/\") || ref.endsWith(\".yaml\") || ref.endsWith(\".yml\")\n const asPath = isAbsolute(ref) ? ref : resolve(cwd, ref)\n\n // A bare name that happens to exist in the cwd wins as a path — but silently running the\n // wrong agent is worse than one stderr line. Only fires on genuine ambiguity.\n if (!looksLikePath && existsSync(asPath) && existsSync(join(agentsDir(env), ref))) {\n process.stderr.write(\n `note: using ./${ref} from the current directory; a sandbox agent \"${ref}\" also exists — run it from elsewhere, or as ${join(agentsDir(env), ref)}\\n`,\n )\n }\n\n if (looksLikePath || existsSync(asPath)) {\n if (existsSync(asPath)) {\n if (statSync(asPath).isDirectory()) {\n const inside = join(asPath, \"agent.yaml\")\n if (existsSync(inside)) return inside\n throw new HarnessError({\n code: \"cli_agent_dir_without_manifest\",\n message: `${ref} is a directory with no agent.yaml inside.`,\n hint: \"Point at the manifest itself, or at a directory that holds one. Sandbox agents are run by bare name, with no path separators.\",\n })\n }\n return asPath\n }\n throw new HarnessError({\n code: \"cli_agent_path_missing\",\n message: `${ref} looks like a path, and nothing is there.`,\n hint: `Paths resolve against the current directory. For an agent in the sandbox, use its bare name — \\`${BRAND.slug} run <name>\\` — which resolves under ${agentsDir(env)}.`,\n })\n }\n\n const sandboxManifest = join(agentsDir(env), ref, \"agent.yaml\")\n if (existsSync(sandboxManifest)) return sandboxManifest\n\n const known = listAgents(env).map((agent) => agent.ref)\n const suggestion = nearest(ref, known)\n throw new HarnessError({\n code: \"cli_agent_unknown\",\n message: `No agent named \"${ref}\" in the sandbox${known.length === 0 ? \", which is empty\" : \"\"}.`,\n hint:\n known.length === 0\n ? `Create one with \\`${BRAND.slug} init\\`, or pass a path to an agent.yaml.`\n : `Known agents: ${known.join(\", \")}.${suggestion === undefined ? \"\" : ` Did you mean ${suggestion}?`} A path (./dir or file.yaml) is also accepted.`,\n })\n}\n"
7
- ],
8
- "mappings": "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",
9
- "debugId": "6744C413011979E664756E2164756E21",
10
- "names": []
11
- }
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env node
2
- import{e,T,x,_,M,m}from"./index-tv4yv7d2.js";import{w,K}from"./index-mtn0g9vc.js";async function zr(t,i,n){let s=[];if(t.length===0)for(let a of K(i)){if(a.problem!==void 0||a.id===void 0)continue;s.push({agentId:a.id,manifestPath:a.manifestPath})}else for(let a of t){let r=T(a);s.push({agentId:r.id??"",manifestPath:a})}let o=await f(async(a)=>new Map((await a.agentState.list()).filter((r)=>!r.enabled).map((r)=>[r.agentId,r.reason])),n);return s.map((a)=>{let r=o?.get(a.agentId),d=o?.has(a.agentId)===!0;return{...a,enabled:!d,...r===void 0?{}:{reason:r}}})}async function f(t,i){let n;try{return n=await M.open({path:i??w()}),await t(n)}catch{return}finally{await n?.close()}}async function Pn(t,i,n,s){await f(async(o)=>{if(i)await o.agentState.enable(t);else await o.agentState.disable(t,new Date().toISOString(),n===void 0?void 0:n)},s)}async function Br(t,i){return await f(async(n)=>{let s=await n.agentState.get(t);if(s===void 0)return{enabled:!0};return{enabled:s.enabled,...s.reason===void 0?{}:{reason:s.reason}}},i)}async function Ce(t,i){return await f(async(n)=>{let s=await n.leases.get(t);if(s===void 0)return;if(s.pid===process.pid||!_(s.pid))return;return s},i)}async function Pe(t){return[...(await St(t)).filter((n)=>n.baseUrl!==void 0)].sort((n,s)=>n.agentId.localeCompare(s.agentId))[0]}async function St(t){return await f(async(i)=>(await i.leases.all()).filter((n)=>n.pid!==process.pid&&_(n.pid)),t)??[]}function xt(t){return t===void 0||t===""?"":T(t).id??""}function Je(t){let i=process.env[`${e.envPrefix}API_TOKEN`];try{let n=x(t,{env:m([t])}),s=n.env[n.manifest.server.tokenEnv];return s===void 0||s===""?i:s}catch{return i===""?void 0:i}}async function Qe(t,i,n,s){let o=t.baseUrl;if(o===void 0)return{ok:!1,status:0,detail:"this host serves no HTTP"};let a=s===void 0?void 0:Je(s);try{let r=await fetch(`${o}${i}`,{method:"POST",headers:{"content-type":"application/json",...a===void 0?{}:{authorization:`Bearer ${a}`}},body:JSON.stringify(n),signal:AbortSignal.timeout(c)});if(r.ok){let u=await r.json().catch(()=>{return});return{ok:!0,status:r.status,...u===void 0?{}:{body:u}}}let d=await r.json().catch(()=>{return});return{ok:!1,status:r.status,...d?.error?.message===void 0?{}:{detail:d.error.message},...d?.error?.hint===void 0?{}:{hint:d.error.hint}}}catch(r){return{ok:!1,status:0,detail:r instanceof Error?r.message:String(r)}}}async function ur(t,i,n,s){let o=t.baseUrl;if(o===void 0)return{ok:!1,status:0,detail:"this host serves no HTTP"};let a=s===void 0?void 0:Je(s);try{let r=await fetch(`${o}${n}`,{method:i,headers:a===void 0?{}:{authorization:`Bearer ${a}`},signal:AbortSignal.timeout(c)}),d=await r.json().catch(()=>{return});if(r.ok)return{ok:!0,status:r.status,...d===void 0?{}:{body:d}};let u=d;return{ok:!1,status:r.status,...u?.error?.message===void 0?{}:{detail:u.error.message},...u?.error?.hint===void 0?{}:{hint:u.error.hint}}}catch(r){return{ok:!1,status:0,detail:r instanceof Error?r.message:String(r)}}}var c=1e4;function Kt(t,i){for(let n of K(i))if(n.id===t)return n.manifestPath;return}
3
- export{zr,Pn,Br,Ce,Pe,St,xt,Je,Qe,ur,Kt};
4
-
5
- //# debugId=00E8CDAE2C5FDD7B64756E2164756E21
6
- //# sourceMappingURL=index-qdbq8crg.js.map
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env node
2
- import{gt,pn,Or,m}from"./index-tv4yv7d2.js";import{existsSync as E,readFileSync as h}from"node:fs";import{dirname as l,join as o,resolve as u}from"node:path";function At(n){let e=o(l(n),".env"),r={};if(E(e))try{r=gt(h(e,"utf8"))}catch{}return pn(r,m([n]))}function To(n,e){let r=n[e];return r!==void 0&&r!==""}function f(n,e,r={}){let i=l(n),t=u(r.cwd??process.cwd()),d=r.readDir??Or,v=r.env??process.env,g=m([n],r),p=d(i),y=d(t),a=g[e];if(a!==void 0&&a!==""){let b=u(i)===t,c=y[e];if(!b&&c!==void 0&&v[e]===c)return{kind:"ambiguous",path:o(t,".env")};return{kind:"export"}}let s=p[e];if(s!==void 0&&s!=="")return{kind:"agent",path:o(i,".env")};return{kind:"unset"}}function _o(n){switch(n.kind){case"export":return"from the environment, not a .env file";case"ambiguous":return"from the environment or ./.env — indistinguishable";case"agent":return;case"unset":return"not set"}}function $o(n){let e=[],r=x(n.rawModelId);if(r!==void 0)e.push({field:"model.main.id",variable:r,origin:f(n.manifestPath,r,n.options??{})});if(n.apiKeyEnv!==void 0)e.push({field:"model.main.apiKeyEnv",variable:n.apiKeyEnv,origin:f(n.manifestPath,n.apiKeyEnv,n.options??{})});return e}function x(n){if(n===void 0)return;return/^\$\{([A-Za-z_][A-Za-z0-9_]*)\}$/.exec(n.trim())?.[1]}
3
- export{At,To,_o,$o};
4
-
5
- //# debugId=09DE6EA43B9B21E464756E2164756E21
6
- //# sourceMappingURL=index-tf71ap9v.js.map