dispach 0.1.1 → 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 (198) hide show
  1. package/README.md +188 -80
  2. package/dist/App-qfqvx9c7.js +11 -0
  3. package/dist/{App-5a35bjkt.js.map → App-qfqvx9c7.js.map} +6 -7
  4. package/dist/ConfigEditor-apcnj4nj.js +6 -0
  5. package/dist/{ConfigEditor-7nnc2ke6.js.map → ConfigEditor-apcnj4nj.js.map} +2 -2
  6. package/dist/KeyProbe-ya5t3v3v.js +5 -0
  7. package/dist/{KeyProbe-kbz0j6sm.js.map → KeyProbe-ya5t3v3v.js.map} +2 -2
  8. package/dist/Picker-b7mn0mjg.js +5 -0
  9. package/dist/{Picker-2zjjt17a.js.map → Picker-b7mn0mjg.js.map} +1 -1
  10. package/dist/SessionPicker-vacfwczg.js +5 -0
  11. package/dist/{SessionPicker-fyyvxy40.js.map → SessionPicker-vacfwczg.js.map} +2 -2
  12. package/dist/SkillBrowser-66ntwaa9.js +5 -0
  13. package/dist/{SkillBrowser-x7r51zy0.js.map → SkillBrowser-66ntwaa9.js.map} +1 -1
  14. package/dist/WizardApp-123998yh.js +5 -0
  15. package/dist/{WizardApp-v0dghsyw.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 +5 -5
  24. package/dist/config-64q4mgxc.js +24 -0
  25. package/dist/{config-9cv76yrk.js.map → config-64q4mgxc.js.map} +2 -2
  26. package/dist/credential-2sj7vsmw.js +19 -0
  27. package/dist/{credential-yxqj8x1f.js.map → credential-2sj7vsmw.js.map} +2 -2
  28. package/dist/daemon.d.ts.map +1 -1
  29. package/dist/index-0k3w2mxf.js +6 -0
  30. package/dist/{index-5x4dn0gg.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-zxh0ntgf.js.map → index-2rycma8x.js.map} +4 -3
  35. package/dist/index-2zye08c4.js +6 -0
  36. package/dist/{index-2wmsmcbr.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-a4xqgdrm.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-7z4sw2dm.js.map → index-byxrc961.js.map} +18 -17
  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-ez2mb28y.js → index-ehzwdnc3.js} +4 -4
  64. package/dist/{index-ez2mb28y.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-zked16y4.js → index-jq999vcw.js} +5 -5
  72. package/dist/{index-zked16y4.js.map → index-jq999vcw.js.map} +2 -2
  73. package/dist/index-k2aq5bg0.js +9 -0
  74. package/dist/{index-nvm5hwe4.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-83bqtze0.js.map → index-k59wwdgz.js.map} +3 -5
  79. package/dist/index-nmnnwa02.js +6 -0
  80. package/dist/{index-73jfw4jp.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-17an0jqq.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-e0j1jafd.js → index-x7v1zq89.js} +7 -7
  94. package/dist/{index-e0j1jafd.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-dwyr2kdm.js.map → index-y4c32wn7.js.map} +2 -2
  101. package/dist/index-yjcdp72k.js +6 -0
  102. package/dist/{index-0b1hdwnm.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 +49 -4
  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-x77y8w3v.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/wire.js +10 -10
  155. package/dist/wire.js.map +4 -4
  156. package/dist/workspace.d.ts.map +1 -1
  157. package/dist/wrapper-0w9b3my0.js +11 -0
  158. package/dist/wrapper-0w9b3my0.js.map +23 -0
  159. package/package.json +6 -3
  160. package/dist/App-5a35bjkt.js +0 -11
  161. package/dist/ConfigEditor-7nnc2ke6.js +0 -6
  162. package/dist/KeyProbe-kbz0j6sm.js +0 -5
  163. package/dist/Picker-2zjjt17a.js +0 -5
  164. package/dist/SessionPicker-fyyvxy40.js +0 -5
  165. package/dist/SkillBrowser-x7r51zy0.js +0 -5
  166. package/dist/WizardApp-v0dghsyw.js +0 -5
  167. package/dist/config-9cv76yrk.js +0 -24
  168. package/dist/credential-yxqj8x1f.js +0 -19
  169. package/dist/index-000rxxy3.js +0 -7
  170. package/dist/index-000rxxy3.js.map +0 -11
  171. package/dist/index-0b1hdwnm.js +0 -6
  172. package/dist/index-17an0jqq.js +0 -6
  173. package/dist/index-2wmsmcbr.js +0 -6
  174. package/dist/index-4z7axw4r.js +0 -6
  175. package/dist/index-5t6wahx8.js +0 -66
  176. package/dist/index-5t6wahx8.js.map +0 -12
  177. package/dist/index-5x4dn0gg.js +0 -6
  178. package/dist/index-73jfw4jp.js +0 -6
  179. package/dist/index-7z4sw2dm.js +0 -903
  180. package/dist/index-83bqtze0.js +0 -14
  181. package/dist/index-9bkd0fdj.js +0 -427
  182. package/dist/index-9bkd0fdj.js.map +0 -11
  183. package/dist/index-9r0wyj6w.js +0 -6
  184. package/dist/index-a4xqgdrm.js +0 -6
  185. package/dist/index-d4x6yvqh.js +0 -6
  186. package/dist/index-d69d6pkm.js +0 -167
  187. package/dist/index-d69d6pkm.js.map +0 -19
  188. package/dist/index-dwyr2kdm.js +0 -6
  189. package/dist/index-fex44816.js +0 -6
  190. package/dist/index-gz9x25tz.js +0 -6
  191. package/dist/index-nvm5hwe4.js +0 -9
  192. package/dist/index-r3wwvqzb.js +0 -77
  193. package/dist/index-r3wwvqzb.js.map +0 -12
  194. package/dist/index-v8e92nfw.js +0 -6
  195. package/dist/index-xf178c4m.js +0 -6
  196. package/dist/index-xf178c4m.js.map +0 -10
  197. package/dist/index-zxh0ntgf.js +0 -12
  198. package/dist/web-x77y8w3v.js +0 -14
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env node
2
- import"./index-cqqb6gaq.js";import{o,S,I}from"./index-d4x6yvqh.js";import"./index-zked16y4.js";import{nn}from"./index-73jfw4jp.js";import{re}from"./index-a4xqgdrm.js";import{D,V,Sn}from"./index-e0j1jafd.js";import{Ge,Ve,Nn}from"./index-2wmsmcbr.js";import{Box as H,Text as d,useInput as Y}from"ink";import{useState as z}from"react";function E(e){return e!==void 0&&e.kind!=="heading"}function k(e){switch(e.kind){case"setting":return`setting:${e.setting.path}`;case"allow":return`allow:${e.channelId}`;case"secret":return`secret:${e.name}`;case"heading":return`heading:${e.label}`}}function L(e){let t=e.findIndex((r)=>E(r));return t===-1?0:t}function T(e){return{rows:e,cursor:L(e),mode:"browse",editor:D,busy:!1}}function M(e,t){let r=e.rows.length;if(r===0)return e;let l=Math.max(0,Math.min(r-1,t)),h=l>=e.cursor?1:-1;for(let i=l;i>=0&&i<r;i+=h)if(E(e.rows[i]))return{...e,cursor:i};for(let i=l;i>=0&&i<r;i-=h)if(E(e.rows[i]))return{...e,cursor:i};return e}function w(e){return e.rows[e.cursor]}function G(e){switch(e.kind){case"setting":return e.value===void 0||e.value===null?"":typeof e.value==="string"?e.value:JSON.stringify(e.value);case"allow":return e.handles.join(" ");case"secret":case"heading":return""}}function O(e){let t=w(e);if(t===void 0||!E(t)||e.busy)return e;let r=G(t);return{...e,mode:"editing",editor:{...D,value:r,cursor:[...r].length},note:void 0}}function _(e){if(e.mode!=="editing")return e;return{...e,mode:"browse",editor:D,note:void 0}}function W(e,t){return{...e,editor:t,note:void 0}}function F(e){return{...e,busy:!0}}function N(e,t,r){return{...e,rows:t,cursor:Math.min(e.cursor,Math.max(0,t.length-1)),mode:"browse",editor:D,busy:!1,note:r}}function P(e,t){return{...e,busy:!1,note:t}}import{jsx as a,jsxs as x}from"react/jsx-runtime";function ge({rows:e,apply:t,reload:r,columns:l,window:m,focused:h=!0,onDone:i}){let K=re(),v=Math.max(Ge,Math.min(m,K.rows-Ve)),[n,u]=z(()=>T(e)),[C,j]=z(!1),g=w(n);Y((f,c)=>{if(n.busy)return;let s=Sn(f,c,{select:n.mode==="browse",empty:n.editor.value===""});if(s.kind==="abort"){i(C);return}if(s.kind==="back"){if(n.mode==="editing")u(_);else i(C);return}if(s.kind==="list"){if(s.intent.kind==="move"){let y=s.intent.move;u((R)=>M(R,Q(y,R)))}return}if(s.kind==="commit"){if(n.mode==="browse"){u(O);return}J();return}u((y)=>W(y,V(y.editor,s.intent)))},{isActive:h});async function J(){let f=w(n);if(f===void 0)return;u(F);try{let c=await t(f,n.editor.value);j(!0),u((s)=>N(s,r(),c))}catch(c){u((s)=>P(s,c instanceof Error?c.message:String(c)))}}if(n.mode==="editing"&&g!==void 0)return x(H,{flexDirection:"column",children:[a(d,{color:o.muted,wrap:"truncate",children:` ${Z(g)}`}),a(nn,{label:A(g),editor:n.editor,secret:g.kind==="secret",columns:l,maxRows:Math.max(Nn,v-2),...n.note===void 0?{}:{error:n.note}}),a(d,{dimColor:!0,wrap:"truncate",children:n.busy?" writing…":` enter writes it · ${U(g)} · ^C closes`})]});let{from:p,to:b}=I(n.rows.length,n.cursor,v);return x(H,{flexDirection:"column",children:[p>0?a(d,{dimColor:!0,wrap:"truncate",children:` ↑ ${p} above`}):void 0,n.rows.slice(p,b).map((f,c)=>a(q,{row:f,selected:p+c===n.cursor,columns:l},k(f))),b<n.rows.length?a(d,{dimColor:!0,wrap:"truncate",children:` ↓ ${n.rows.length-b} below`}):void 0,a(d,{color:n.note===void 0?o.muted:o.accent,wrap:"truncate",children:n.note===void 0?" ↑↓ move · enter changes it · esc closes":` ${n.note}`})]})}function q({row:e,selected:t,columns:r}){if(e.kind==="heading")return a(d,{color:o.muted,wrap:"truncate",children:`
3
- ${e.label}`});let l=S(A(e),Math.min(34,Math.max(12,Math.floor(r*0.34)))),m=S(B(e),Math.max(8,r-l.length-8));return x(d,{wrap:"truncate",children:[t?a(d,{color:o.accent,children:" ❯ "}):a(d,{children:" "}),a(d,{children:l.padEnd(Math.min(34,Math.max(12,Math.floor(r*0.34))))}),a(d,{color:o.muted,children:` ${m}`})]})}function Q(e,t){switch(e.kind){case"up":return t.cursor-1;case"down":return t.cursor+1;case"first":return 0;case"last":return t.rows.length-1;case"jump":return e.index}}function A(e){switch(e.kind){case"setting":return e.setting.path;case"allow":return`${e.channelId}.allowFrom`;case"secret":return e.name;case"heading":return e.label}}function B(e){switch(e.kind){case"setting":return e.value===void 0||e.value===null?"(not set)":typeof e.value==="string"?e.value:JSON.stringify(e.value);case"allow":return e.handles.length===0?"(nobody)":e.handles.join(" ");case"secret":return e.present?"(set)":"(not set)";case"heading":return""}}function U(e){let t=B(e);return t.length<=X?`esc keeps ${t}`:"esc cancels"}var X=24;function Z(e){switch(e.kind){case"setting":return e.setting.means;case"allow":return"handles this channel accepts messages from, separated by spaces. Empty refuses everyone";case"secret":return e.why;case"heading":return e.label}}export{ge as ConfigEditor};
4
-
5
- //# debugId=6ECE33C1BB078EEF64756E2164756E21
6
- //# sourceMappingURL=ConfigEditor-7nnc2ke6.js.map
@@ -1,5 +0,0 @@
1
- #!/usr/bin/env node
2
- import{o,Tn}from"./index-d4x6yvqh.js";import{D,kn,jt}from"./index-e0j1jafd.js";import{Box as x,Text as a,useInput as I}from"ink";import{useState as k}from"react";function P(e){return[...new TextEncoder().encode(e)].map((t)=>t.toString(16).padStart(2,"0")).join(" ")}function E(e){let t=[];if(e.ctrl)t.push("ctrl");if(e.meta)t.push("meta");if(e.super)t.push("super");if(e.shift)t.push("shift");for(let[r,s]of[["up",e.upArrow],["down",e.downArrow],["left",e.leftArrow],["right",e.rightArrow],["pageUp",e.pageUp],["pageDown",e.pageDown],["home",e.home],["end",e.end],["return",e.return],["escape",e.escape],["tab",e.tab],["backspace",e.backspace],["delete",e.delete]])if(s)t.push(r);if(e.eventType!==void 0&&e.eventType!=="press")t.push(e.eventType);return t.length===0?"—":t.join(" ")}function R(e){return e.super||e.eventType!==void 0}function y(e,t){if(!t)return"not requested — the override is set, so cmd chords cannot arrive";if(e.some((r)=>R(r.key)))return"active — a keystroke carried a modifier only the protocol can express";return"requested; nothing pressed yet has proved it — try cmd+left, or option+r"}function m(e){let t=[...e.bytes].map((r)=>{let s=r.codePointAt(0)??0;return s<32||s===127?".":r}).join("");return[`bytes ${P(e.bytes)}${t===""?"":` ${t}`}`,`ink ${E(e.key)}${e.input===""?"":` input ${JSON.stringify(e.input)}`}`,`intent ${e.intent.kind}`]}import{jsx as i,jsxs as d}from"react/jsx-runtime";var A=6,h=0;function H({columns:e,asked:t,terminal:r,takeRaw:s,correctKeys:u,onDone:g}){let[l,b]=k([]);return I((n,c)=>{let w=s?.(),f=c,p=u===void 0?f:u(f,n);if(n==="q"&&!p.ctrl&&!p.meta&&!p.super){g();return}let T=jt(n,p,kn(D,!1));h+=1;let K=h,S=w??n;b((v)=>[...v,{at:K,bytes:S,input:n,key:p,intent:T}].slice(-A))}),d(x,{flexDirection:"column",children:[d(a,{color:o.accent,bold:!0,wrap:"truncate",children:["key probe · ",r]}),d(a,{color:o.muted,wrap:"truncate",children:["protocol ",y(l,t)]}),i(a,{children:" "}),l.length===0?i(a,{color:o.muted,wrap:"truncate",children:"press any chord — the bytes, Ink's reading of them, and the resolved intent"}):null,l.map((n)=>d(x,{flexDirection:"column",children:[i(a,{color:o.border,wrap:"truncate",children:Tn("",e)}),m(n).map((c)=>i(a,{wrap:"truncate",children:c},c))]},`stroke-${n.at}`)),i(a,{children:" "}),i(a,{dimColor:!0,wrap:"truncate",children:" q leaves · every other key is recorded, ^C included"})]})}export{H as KeyProbe};
3
-
4
- //# debugId=811A621DD931485C64756E2164756E21
5
- //# sourceMappingURL=KeyProbe-kbz0j6sm.js.map
@@ -1,5 +0,0 @@
1
- #!/usr/bin/env node
2
- import{u}from"./index-d4x6yvqh.js";import{it}from"./index-4z7axw4r.js";import{ae,W}from"./index-gz9x25tz.js";import{we}from"./index-e0j1jafd.js";import{Box as l,useApp as k,useInput as x}from"ink";import{useCallback as b,useState as y}from"react";import{jsx as r,jsxs as P}from"react/jsx-runtime";function I({title:m,agents:n,onDone:i}){let{exit:o}=k(),[s,d]=y({index:0,count:n.length+1}),a=b((e)=>{i(e),o()},[i,o]);x((e,f)=>{let c=we(e,f);switch(c.kind){case"move":d((t)=>W(t,c.move));return;case"choose":{let t=n[s.index];a(t===void 0?{kind:"create"}:{kind:"run",manifestPath:t.manifestPath});return}case"back":case"exit":a({kind:"quit"});return;case"none":return}});let p=[...n.map((e)=>({label:e.name??e.ref,hint:e.problem!==void 0?`⚠ ${e.problem}`:`${e.modelId??"?"} ${u.bullet}${e.ref}`})),{label:`${u.create}create a new agent`}];return P(l,{flexDirection:"column",children:[r(it,{title:m,lines:["pick an agent · enter runs it · esc quits"]}),r(l,{marginTop:1,children:r(ae,{items:p,index:s.index,numbered:!0})})]})}export{I as Picker};
3
-
4
- //# debugId=2075979772A2217364756E2164756E21
5
- //# sourceMappingURL=Picker-2zjjt17a.js.map
@@ -1,5 +0,0 @@
1
- #!/usr/bin/env node
2
- import{o,S}from"./index-d4x6yvqh.js";import{ae,W}from"./index-gz9x25tz.js";import{uo}from"./index-4cf6v9nb.js";import{qe}from"./index-j7gyr5nx.js";import{we}from"./index-e0j1jafd.js";import{Box as f,Text as u,useInput as v}from"ink";import{useState as w}from"react";var k=14,R=28;function p(r,i){let m=r.reduce((e,n)=>Math.max(e,n.sessionKey.length),0),t=Math.max(k,Math.min(R,m)),l=Math.max(12,i.columns-(2+t+2));return r.map((e)=>{let n=[`${e.messages} message${e.messages===1?"":"s"}`,`${e.turns} turn${e.turns===1?"":"s"}`,qe(e.lastActivityAt,i.now)];if(e.phase!==void 0&&e.phase!=="")n.push(e.phase);if(!uo(e.sessionKey))n.push("named");return{key:e.sessionKey,label:S(e.sessionKey,t).padEnd(t),hint:S(n.join(" · "),l)}})}import{jsx as c,jsxs as h}from"react/jsx-runtime";function Y({sessions:r,now:i,columns:m,maxRows:t,current:l,focused:e=!0,onDone:n}){let a=p(r,{now:i,columns:m}),[d,x]=w({index:0,count:a.length});if(v((s,g)=>{let y=we(s,g);switch(y.kind){case"move":x((b)=>W(b,y.move));return;case"choose":n(a[d.index]?.key);return;case"back":case"exit":n(void 0);return;case"none":return}},{isActive:e}),a.length===0)return h(f,{flexDirection:"column",children:[c(u,{color:o.muted,wrap:"truncate",children:" no stored conversations with this agent yet"}),c(u,{dimColor:!0,wrap:"truncate",children:" esc starts a new one"})]});return h(f,{flexDirection:"column",children:[c(ae,{items:a.map((s)=>({label:s.label,hint:s.key===l?`${s.hint} · in use`:s.hint})),index:d.index,numbered:!0,maxRows:t}),c(u,{dimColor:!0,wrap:"truncate",children:" ↑↓ move · enter opens it · esc keeps the one you are in"})]})}export{Y as SessionPicker};
3
-
4
- //# debugId=88D9416514333DE764756E2164756E21
5
- //# sourceMappingURL=SessionPicker-fyyvxy40.js.map
@@ -1,5 +0,0 @@
1
- #!/usr/bin/env node
2
- import{o,u,oe}from"./index-d4x6yvqh.js";import{Qt,ot,en}from"./index-fex44816.js";import{re}from"./index-a4xqgdrm.js";import{ae,W}from"./index-gz9x25tz.js";import{de}from"./index-v8e92nfw.js";import{st,tn}from"./index-gme2egyq.js";import{Po,Mo,Lo}from"./index-17an0jqq.js";import{zt,we}from"./index-e0j1jafd.js";import{Rn,In,Ge,Ze,Ve}from"./index-2wmsmcbr.js";import{Box as p,Text as f,useInput as X}from"ink";import{useCallback as Y,useEffect as K,useState as L}from"react";import{Box as E,Text as R}from"ink";import{jsx as w,jsxs as H}from"react/jsx-runtime";var D={ok:o.success,warn:o.warning,off:o.muted},B={title:{color:o.accent,bold:!0},summary:{dim:!0},state:{},warning:{color:o.warning}};function U(e){return Math.max(Rn,Math.min(In,e))}function g({header:e,footer:l,children:s}){let x=re(),T=U(x.columns),k=T-4,v=Po(e,k),C=e.state??[];return H(E,{flexDirection:"column",width:T,children:[w(E,{flexDirection:"column",borderStyle:oe,borderColor:o.borderActive,paddingX:1,children:v.map((d)=>d.kind==="state"?w(R,{wrap:"truncate",children:C.map((n,c)=>H(R,{color:D[n.tone],children:[c===0?"":" · ",n.label]},n.label))},d.text):w(R,{wrap:"truncate",bold:B[d.kind].bold===!0,dimColor:B[d.kind].dim===!0,...B[d.kind].color===void 0?{}:{color:B[d.kind].color},children:d.text},d.text))}),w(E,{flexDirection:"column",marginTop:1,children:s}),l===void 0||l.length===0?null:w(E,{marginTop:1,children:H(R,{dimColor:!0,wrap:"truncate",children:[" ",Mo(l,k)]})})]})}import{jsx as t,jsxs as S}from"react/jsx-runtime";function Se({load:e,install:l,agents:s,target:x,focused:T=!0,onDone:k,title:v}){let C=re(),d=Math.max(Ge,Math.min(Ze,C.rows-Ve)),[n,c]=L({kind:"fetching",status:"reading the catalogue"}),[b,O]=L([]),[y,M]=L({cursor:{index:0,count:0},chosen:[]}),[_,A]=L({index:0,count:s.length});K(()=>{let r=!0;return e((i)=>{if(r)c((a)=>a.kind==="fetching"?{...a,status:i}:a)}).then((i)=>{if(!r)return;O(i);let a=st(i);M({cursor:{index:en(a),count:i.length},chosen:[]}),c(i.length===0?{kind:"empty"}:{kind:"picking"})}).catch((i)=>{if(!r)return;c({kind:"failed",message:i instanceof Error?i.message:String(i)})}),()=>{r=!1}},[e]);let P=st(b),I=Y((r)=>{let i=tn(b,y.chosen);c({kind:"installing",count:i.length}),l(i,r).then((a)=>c({kind:"done",report:a})).catch((a)=>c({kind:"failed",message:a instanceof Error?a.message:String(a)}))},[b,y.chosen,l]);X((r,i)=>{if(n.kind==="done"){k(n.report);return}if(n.kind==="failed"||n.kind==="empty"){k(void 0);return}if(n.kind==="fetching"||n.kind==="installing"){if(zt(r,i).kind==="cancel")k(void 0);return}if(n.kind==="picking"){let m=zt(r,i);switch(m.kind){case"move":case"toggle":case"all":M((N)=>ot(N,m.kind==="move"?{kind:"move",move:m.move}:{kind:m.kind},P));return;case"none-selected":M((N)=>ot(N,{kind:"none"},P));return;case"confirm":if(y.chosen.length===0)return;if(x!==void 0)return I(x);if(s.length===1)return I(s[0]?.manifestPath??"");c({kind:"agent"});return;case"cancel":k(void 0);return;case"none":return}}let a=we(r,i);switch(a.kind){case"move":A((m)=>W(m,a.move));return;case"choose":{let m=s[_.index];if(m!==void 0)I(m.manifestPath);return}case"back":c({kind:"picking"});return;case"exit":k(void 0);return;case"none":return}},{isActive:T});let z=y.chosen.length,h={title:v,summary:F(n,b.length,z)};if(n.kind==="fetching")return S(g,{header:h,footer:[{key:"esc",does:"stop waiting"}],children:[t(p,{marginLeft:2,children:t(de,{label:n.status})}),t(p,{marginLeft:2,marginTop:1,children:t(f,{dimColor:!0,children:"once per machine, shared by every agent on it"})})]});if(n.kind==="failed")return t(g,{header:h,footer:[{key:"any key",does:"back"}],children:t(p,{marginLeft:2,children:S(f,{color:o.error,children:[u.error,n.message]})})});if(n.kind==="empty")return t(g,{header:h,footer:[{key:"any key",does:"back"}],children:S(p,{marginLeft:2,flexDirection:"column",children:[t(f,{color:o.muted,children:"no catalogue could be read"}),t(f,{dimColor:!0,children:"`sources update` reports why"})]})});if(n.kind==="installing")return t(g,{header:h,children:t(p,{marginLeft:2,children:t(de,{label:`installing ${n.count} skill${n.count===1?"":"s"}`})})});if(n.kind==="done")return t(g,{header:h,footer:[{key:"any key",does:"back"}],children:t(G,{report:n.report})});if(n.kind==="agent")return t(g,{header:h,footer:[{key:"↑↓",does:"move"},{key:"enter",does:"install"},{key:"esc",does:"back"}],children:t(ae,{items:s.map((r)=>({label:r.name??r.ref,hint:r.problem===void 0?`${r.modelId??"?"} ${u.bullet}${r.ref}`:`⚠ ${r.problem}`})),index:_.index,numbered:!0})});return t(g,{header:h,footer:[{key:"↑↓",does:"move"},{key:"space",does:"tick"},{key:"a/n",does:"all/none"},{key:"enter",does:x===void 0?"continue":"install"},Lo],children:t(Qt,{rows:b,index:y.cursor.index,chosen:y.chosen,window:d,width:C.columns})})}function F(e,l,s){switch(e.kind){case"fetching":return"fetching the catalogue";case"failed":return"could not be read";case"empty":return"nothing to show";case"installing":return"installing";case"done":return`installed ${e.report.installed.length} of ${e.report.total}`;case"agent":return`${s} to install · pick an agent`;case"picking":return s===0?`${l} rows · nothing ticked yet`:`${s} ticked of ${l} rows`}}function G({report:e}){return S(p,{flexDirection:"column",marginLeft:2,children:[S(f,{color:e.failed.length===0?o.success:o.warning,children:[u.check,`installed ${e.installed.length} of ${e.total} skill${e.total===1?"":"s"}`]}),e.installed.length>0?t(f,{dimColor:!0,wrap:"truncate",children:e.installed.join(", ")}):null,e.failed.map((l)=>S(f,{color:o.error,wrap:"truncate",children:[u.error,l.name," — ",l.reason]},l.name)),e.runnable>0?t(p,{marginTop:1,children:t(f,{dimColor:!0,wrap:"truncate",children:`${e.runnable} runnable file${e.runnable===1?"":"s"} across ${e.withCode} skill${e.withCode===1?"":"s"} — \`skills show <agent> <skill>\` names them`})}):null,t(p,{marginTop:1,children:t(f,{dimColor:!0,children:"restart the agent: the catalogue is scanned once at boot"})})]})}export{Se as SkillBrowser};
3
-
4
- //# debugId=458279489A2650AB64756E2164756E21
5
- //# sourceMappingURL=SkillBrowser-x7r51zy0.js.map
@@ -1,5 +0,0 @@
1
- #!/usr/bin/env node
2
- import{e}from"./index-7z4sw2dm.js";import{st,tn}from"./index-gme2egyq.js";import{o,u,oe}from"./index-d4x6yvqh.js";import"./index-5t6wahx8.js";import{nt}from"./index-d69d6pkm.js";import{it}from"./index-4z7axw4r.js";import{an,dt,ln}from"./index-9r0wyj6w.js";import{Qt,ot,en}from"./index-fex44816.js";import{ae,W}from"./index-gz9x25tz.js";import{de}from"./index-v8e92nfw.js";import"./index-cqqb6gaq.js";import"./index-zked16y4.js";import{nn}from"./index-73jfw4jp.js";import{re}from"./index-a4xqgdrm.js";import{De,ct,ut,Ct,Fe,Ee}from"./index-9bkd0fdj.js";import"./index-nvm5hwe4.js";import"./index-000rxxy3.js";import{q,Do}from"./index-17an0jqq.js";import"./index-j7gyr5nx.js";import{D,V,zt,Sn}from"./index-e0j1jafd.js";import{j,$n,Nn}from"./index-2wmsmcbr.js";import{Box as m,Text as h,useApp as ue,useInput as pe}from"ink";import{useCallback as me,useEffect as I,useReducer as fe,useState as ke}from"react";import{Box as ie,Text as N}from"ink";import{jsx as Q,jsxs as se}from"react/jsx-runtime";function Y({rows:n}){let t=n.reduce((r,c)=>Math.max(r,c.label.length),0);return Q(ie,{flexDirection:"column",borderStyle:oe,borderColor:o.border,paddingX:1,paddingY:1,children:n.map((r)=>se(N,{children:[Q(N,{dimColor:!0,children:r.label.padEnd(t+2)}),r.value]},r.label))})}import{Box as H,Text as v}from"ink";import{jsx as E,jsxs as P}from"react/jsx-runtime";function U({step:n,total:t,answered:r,hint:c,children:l}){return P(H,{flexDirection:"column",children:[r.map((p)=>P(v,{children:[E(v,{color:o.success,children:u.check}),E(v,{dimColor:!0,children:p.label.padEnd(18)}),p.value]},p.label)),E(H,{flexDirection:"column",borderStyle:oe,borderColor:o.border,paddingX:1,paddingY:1,marginTop:r.length>0?1:0,children:l}),P(v,{dimColor:!0,children:["step ",n," of ",t," ",u.bullet,c]})]})}function X(n,t){let r={given:n,log:[],phase:"asking",editor:D,select:{index:0,count:De.length},error:void 0,defaults:t};return f(r)===void 0?A(r):r}function b(n){return{...Object.fromEntries(n.log.map((r)=>[r.step,r.value])),...n.given}}function f(n){return Fe(b(n),n.defaults)}function B(n){return n.phase==="asking"&&f(n)?.options!==void 0}function G(n){return f(n)?.options??[]}function Z(n){let t=f(n)?.step;return n.phase==="asking"&&t!==void 0&&Ct.has(t)}function J(n){let t={...b(n)},r=0;for(;;){let l=Fe(t,n.defaults);if(l===void 0)break;r+=1,t[l.step]=l.fallback===""?"(x)":l.fallback}let c=n.log.length+Object.keys(n.given).length;return{asked:c+(n.phase==="asking"?1:0),total:c+r}}var le=2;function A(n){return{...n,phase:"confirm",editor:D,select:{index:0,count:le},error:void 0}}function z(n){let t=Fe(b(n),n.defaults),r=t?.options;return{editor:D,select:{index:ce(t),count:r===void 0?De.length:r.length},error:void 0}}function ce(n){let t=n?.options;if(t===void 0)return 0;let r=Number(n?.fallback)-1;return Number.isInteger(r)&&r>=0&&r<t.length?r:0}function T(n,t){if(n.phase==="done"||n.phase==="aborted")return n;switch(t.kind){case"abort":return{...n,phase:"aborted"};case"edit":if(n.phase!=="asking")return n;return{...n,editor:V(n.editor,t.intent),error:void 0};case"list":{let r=t.intent;if(r.kind==="move")return{...n,select:W(n.select,r.move),error:void 0};if(r.kind==="choose")return T(n,{kind:"commit"});if(r.kind==="back")return T(n,{kind:"back"});if(r.kind==="exit")return{...n,phase:"aborted"};return n}case"back":{if(n.phase==="confirm"){if(n.log.length===0)return{...n,phase:"asking",...z(n)};let l=n.log.slice(0,-1),p={...n,phase:"asking",log:l};return{...p,...z(p)}}if(n.log.length===0)return n;let r=n.log.slice(0,-1),c={...n,log:r};return{...c,...z(c)}}case"commit":{if(n.phase==="confirm")return n.select.index===0?{...n,phase:"done"}:T(n,{kind:"back"});let r=f(n);if(r===void 0)return A(n);let c=r.options!==void 0?r.options[n.select.index]?.value??"":n.editor.value.trim()===""?r.fallback:n.editor.value,l=Ee(r.step,c);if(!l.ok)return{...n,error:l.reason};let p={...n,log:[...n.log,{step:r.step,value:l.value}]},d={...p,...z(p)};return f(d)===void 0?A(d):d}}}function ee(n){if(n==="")return"";if(n.length<=8)return"•".repeat(n.length);return`${n.slice(0,3)}${"•".repeat(6)}${n.slice(-2)}`}function ne(n){let t=b(n),r=t.preset===void 0?void 0:ct(t.preset),c=`${t.model??""} at ${t.baseUrl??""}`,l=t.apiKeyEnv??r?.apiKeyEnv,p=l===void 0?" (no key)":` (${l}=${t.apiKey===void 0||t.apiKey===""?"not set yet":ee(t.apiKey)})`;return[{label:"agent",value:t.name??""},{label:"for",value:`${t.user??""} — ${t.purpose??""}`},{label:"endpoint",value:`${c}${p}`},{label:"directory",value:t.dir??ut(t.dirChoice,t.name,n.defaults)??""}]}function te(n){let t={user:"Your name",name:"Agent name",purpose:"Purpose",preset:"Endpoint",model:"Model",baseUrl:"Base URL",apiKeyEnv:"Key env var",apiKey:"API key",web:"Internet",webBackend:"Search backend",webKey:"Search key",system:"System access",composio:"Other apps",telegram:"Telegram",telegramAllow:"Telegram handle",telegramToken:"Bot token",schedules:"none",server:"HTTP API",skills:"Skills",skillsSearch:"Skill search",skillsPick:"Skills picked",daemon:"Background service",serverToken:"API token",composioKey:"Composio key",dirChoice:"Location",dir:"Directory"};return n.log.map((r)=>({label:t[r.step],value:Ct.has(r.step)?ee(r.value):r.value}))}import{jsx as s,jsxs as g}from"react/jsx-runtime";var ge=16,he=5;function rn({title:n,given:t,defaults:r,onDone:c}){let{exit:l}=ue(),p=re(),[d,k]=ke({kind:"idle"}),[a,x]=fe((i,y)=>T(i,y),void 0,()=>X(t,r)),C=me((i)=>{c(i),l()},[c,l]),L=a.log.some((i)=>i.step==="skills"&&i.value==="find");if(I(()=>{if(!L||d.kind!=="idle")return;k({kind:"fetching",status:"reading the catalogue"}),(async()=>{try{let i=await nt({onStatus:(S)=>k({kind:"fetching",status:S})});if(i.length===0){k({kind:"failed",message:"no catalogue could be read — carrying on without skills"});return}let y=st(i);k({kind:"picking",rows:i,picked:{cursor:{index:en(y),count:i.length},chosen:[]}})}catch(i){k({kind:"failed",message:i instanceof Error?i.message:String(i)})}})()},[L,d.kind]),I(()=>{if(d.kind!=="failed")return;let i=setTimeout(()=>k({kind:"done",refs:[]}),1400);return()=>clearTimeout(i)},[d]),I(()=>{if(a.phase==="done"){let i=d.kind==="done"?d.refs:[];C({...b(a),...i.length===0?{}:{skillsPick:i.join(",")}})}if(a.phase==="aborted")C(void 0)},[a,C,d]),pe((i,y)=>{if(d.kind==="picking"){let F=d.rows,K=st(F),w=zt(i,y);switch(w.kind){case"move":case"toggle":case"all":k({...d,picked:ot(d.picked,w.kind==="move"?{kind:"move",move:w.move}:{kind:w.kind},K)});return;case"none-selected":k({...d,picked:ot(d.picked,{kind:"none"},K)});return;case"confirm":case"cancel":k({kind:"done",refs:w.kind==="cancel"?[]:tn(F,d.picked.chosen).map((_)=>`${_.source}/${_.skill}`)});return;default:return}}if(d.kind==="fetching"||d.kind==="failed")return;let S=Sn(i,y,{select:B(a)||a.phase==="confirm",empty:a.editor.value===""});switch(S.kind){case"abort":x({kind:"abort"});return;case"back":x({kind:"back"});return;case"commit":x({kind:"commit"});return;case"list":x({kind:"list",intent:S.intent});return;case"edit":x({kind:"edit",intent:S.intent});return}}),a.phase==="done"||a.phase==="aborted")return null;if(d.kind==="fetching")return g(m,{flexDirection:"column",children:[s(it,{title:"Skills",lines:["choosing what this agent knows how to do"]}),s(m,{marginTop:1,paddingLeft:2,children:s(de,{label:d.status})})]});if(d.kind==="failed")return g(m,{flexDirection:"column",children:[s(it,{title:"Skills",lines:["carrying on without them"]}),s(m,{marginTop:1,paddingLeft:2,children:s(h,{color:o.warning,children:d.message})})]});if(d.kind==="picking"){let i=d.picked.chosen.length;return g(m,{flexDirection:"column",children:[s(it,{title:"Skills",lines:["space ticks · a all · n none · enter continues · esc skips"]}),s(m,{marginTop:1,children:s(Qt,{rows:d.rows,index:d.picked.cursor.index,chosen:d.picked.chosen,window:Do(void 0,$n),width:q(void 0,j)})}),s(m,{marginTop:1,paddingLeft:2,children:s(h,{color:i===0?o.muted:o.success,children:i===0?"nothing ticked — enter carries on without any":`${i} ticked`})})]})}let O=J(a),R=ln(e.name,{columns:q(p.columns,j)-dt,rows:Math.min(he,Math.max(0,p.rows-ge))}),M=a.phase==="confirm"?"enter confirm · esc back · ^C quit — nothing written":"enter accepts · esc back · ^C quit — nothing written";return g(m,{flexDirection:"column",children:[R.lines.length>0?s(an,{lines:R.lines}):null,s(m,{marginTop:R.lines.length>0?1:0,children:g(h,{dimColor:!0,wrap:"truncate",children:[n," · a few questions — nothing is written until you confirm"]})}),a.phase==="confirm"?g(m,{flexDirection:"column",marginTop:1,children:[s(Y,{rows:ne(a)}),g(m,{marginTop:1,flexDirection:"column",children:[s(h,{children:"Write the files?"}),s(ae,{items:[{label:"yes"},{label:"no, go back"}],index:a.select.index})]}),s(h,{dimColor:!0,children:M})]}):s(m,{marginTop:1,children:s(U,{step:O.asked,total:O.total,answered:te(a),hint:M,children:B(a)?g(m,{flexDirection:"column",children:[s(h,{children:f(a)?.prompt??""}),s(ae,{items:G(a).map((i)=>({label:i.label,...i.hint===void 0?{}:{hint:i.hint}})),index:a.select.index,numbered:!0})]}):s(nn,{label:f(a)?.prompt??"",editor:a.editor,columns:q(p.columns,j)-dt,maxRows:Nn,placeholder:f(a)?.fallback??"",...a.error===void 0?{}:{error:a.error},...Z(a)?{secret:!0}:{}})})}),a.error!==void 0&&(B(a)||a.phase==="confirm")?g(h,{color:o.error,children:[u.error,a.error]}):null]})}export{rn as WizardApp};
3
-
4
- //# debugId=19398E4310D271E264756E2164756E21
5
- //# sourceMappingURL=WizardApp-v0dghsyw.js.map
@@ -1,24 +0,0 @@
1
- #!/usr/bin/env node
2
- import{E,t,Ft,he,Be,T,Tr,_,M}from"./index-7z4sw2dm.js";import"./index-9bkd0fdj.js";import"./index-d4x6yvqh.js";import{Ye,Mr}from"./index-ammv5st7.js";import{me,b,J,ue,Z,ie}from"./index-nvm5hwe4.js";import{w,te}from"./index-000rxxy3.js";import{Wn,qn,Gn,gr,Tt,fo,ho,mo,po,go,_t,Zn,Vn,at,rn}from"./index-83bqtze0.js";import{At}from"./index-0b1hdwnm.js";import{q}from"./index-17an0jqq.js";import{l,d}from"./index-j7gyr5nx.js";import{be,j,Ze,n}from"./index-2wmsmcbr.js";import{readFileSync as A}from"node:fs";var C=["list","get","set","env","allow","edit"];function ne(e,r,o=(i)=>process.stderr.write(i)){let i=(e??"").trim();if(i==="")return{action:"edit",ref:void 0};if(!C.includes(i))return{action:"edit",ref:i};if(r!==void 0&&C.includes(r))o(`note: reading "${i}" as the action and "${r}" as the agent
3
- `);if(r===void 0&&i!=="list")return{action:i,ref:void 0};return{action:i,ref:r}}async function re(e){let r=e.out??((a)=>process.stdout.write(a)),o=e.action??"";if(!C.includes(o)){let a=E(o,[...C]);throw new t({code:"cli_config_action_unknown",message:`"${o}" is not something config does.`,hint:`One of: ${C.join(", ")}.${a===void 0?"":` Did you mean ${a}?`}`})}let i=te(e.ref??"",e.sandboxEnv);switch(o){case"list":{r(`${fo(Vn(i),i)}
4
- `);let a=Zn(_t(Be(A(i,"utf8"))),At(i));for(let s of a)r(`
5
- ${d(`${s.name} is not set — ${s.why}`)}
6
- `),r(`${d(`\`config env <agent> ${s.name}\` fills it in`)}
7
- `);return n}case"get":return x(i,e,r);case"set":return await N(i,e,r);case"env":return await R(i,e,r);case"edit":return await F(i,e,r);default:return await I(i,e,r)}}function x(e,r,o){let i=(r.name??"").trim(),a=k(i),s=Vn(e).find((c)=>c.setting.path===a.path);return o(`${ho(a,s?.value)}
8
- `),n}function k(e){let r=Tr(e);if(r!==void 0)return r;let o=E(e,[...go()]);throw new t({code:"cli_config_path_unknown",message:`"${e}" is not a setting.`,hint:`\`config list <agent>\` shows every one with its current value.${o===void 0?"":` Did you mean ${o}?`}`,field:"path"})}async function N(e,r,o){let i=(r.name??"").trim(),a=k(i);if(a.via!==void 0)throw new t({code:"cli_config_needs_action",message:`${a.path} is not set by a dotted path.`,hint:`Use \`${a.via}\` — it lives inside a list entry, and it gets its value checked against the service that issues it rather than written verbatim.`,field:"path"});if(r.value===void 0)throw new t({code:"cli_config_value_missing",message:`No value given for ${i}.`,hint:`A bare word, a number, a list as ["a", "b"], or a map as {k: v}. \`config get <agent> ${i}\` shows what it is now.`,field:"value"});let s=Ft(r.value),c=mo(a,s);if(c!==void 0&&r.yes!==!0){if(o(`${d(c)}
9
- `),!await(r.confirm??Ye)(`Change ${a.path} anyway?`))return o(`${l([{label:"unchanged",value:a.path}])}
10
- `),n}let p=At(e),f=Zn(_t(Be(A(e,"utf8"))),p).map((u)=>u.name),g=await Wn(e,i,r.value),m=Zn(_t(Be(A(e,"utf8"))),p).filter((u)=>!f.includes(u.name)),v=await O(e,r);return o(`${po({path:i,before:g.before,after:s,file:e,reflowed:g.reflowed,...v===void 0?{}:{running:v},pending:m,restartHint:S(v?.mode)})}
11
- `),n}function S(e){if(e==="daemon")return"`daemon restart <agent>`";if(e==="embedded")return"`/restart` in this session";if(e==="terminal")return"that process being started again";return"it is started again"}async function O(e,r){let o;try{o=T(e).id}catch{return}if(o===void 0)return;try{let i=await M.open({path:r.store??w(r.sandboxEnv)});try{for(let a of await i.leases.all()){if(a.agentId!==o)continue;if(!_(a.pid))continue;return{pid:a.pid,mode:a.mode}}}finally{await i.close()}}catch{return}return}async function R(e,r,o){let i=(r.name??"").trim();if(!/^[A-Za-z_][A-Za-z0-9_]*$/.test(i))throw new t({code:"cli_config_env_name_invalid",message:`"${i}" is not an environment variable name.`,hint:"Letters, digits and underscores, not starting with a digit — MODEL_API_KEY, TELEGRAM_BOT_TOKEN. `config list <agent>` shows which ones this agent names.",field:"name"});let s=await(r.secret??Mr)(`value for ${i} (not echoed):`);if(s===void 0)throw new t({code:"cli_config_env_no_value",message:`Nothing was written for ${i}.`,hint:"A secret is read from a prompt, never from an argument or a pipe — an argument is visible in `ps` and in shell history. Run this at a terminal, or edit the .env beside the manifest yourself."});if(s==="")throw new t({code:"cli_config_env_empty",message:`An empty value for ${i} would not start the agent.`,hint:"A variable set to nothing fails the load exactly as a missing one does. Nothing was written."});let c=Gn(e,i,s);return o(`${l([{label:"set",value:c.note}])}
12
- `),o(`${d("takes effect the next time the agent starts")}
13
- `),n}async function I(e,r,o){let i=he(A(e,"utf8"),["channels"]);if(!Array.isArray(i)||i.length===0)throw new t({code:"cli_config_no_channels",message:"This agent has no channels, so there is nobody to allow.",hint:"`config set <agent> channels '[{type: telegram, id: tg, tokenEnv: TELEGRAM_BOT_TOKEN, mode: longpoll}]'` declares one first."});let a=i.filter((h)=>typeof h==="object"&&h!==null&&!Array.isArray(h)),s=a.map((h)=>String(h.id??"")).filter((h)=>h!==""),c=r.channel?.trim();if(c===void 0&&a.length>1)throw new t({code:"cli_config_channel_ambiguous",message:`This agent has ${a.length} channels, so --channel says which.`,hint:`One of: ${s.join(", ")}.`,field:"channel"});let p=c===void 0?0:a.findIndex((h)=>String(h.id??"")===c);if(p===-1)throw new t({code:"cli_config_channel_unknown",message:`No channel with id "${c}".`,hint:`Declared: ${s.join(", ")}.${E(c??"",s)===void 0?"":` Did you mean ${E(c??"",s)}?`}`,field:"channel"});let f=a[p],g=gr(r.name??"",String(f.type??"")),m=Array.isArray(f.allowFrom)?f.allowFrom.map(String):[],v=r.remove===!0?m.filter((h)=>h!==g):m.includes(g)?m:[...m,g];if(v.length===m.length&&r.remove===!0)return o(`${l([{label:"unchanged",value:`${g} was not on ${String(f.id)}`}])}
14
- `),n;if(v.length===m.length)return o(`${l([{label:"already allowed",value:`${g} on ${String(f.id)}`}])}
15
- `),n;let u=await qn(e,String(f.id??""),v),y=await O(e,r);if(o(`${l([{label:r.remove===!0?"removed":"allowed",value:g},{label:"channel",value:String(f.id)},{label:"now",value:Tt(v)},{label:"file",value:e}])}
16
- `),u.reflowed)o(`${d("the file was re-serialised — it is valid, and comments may have moved")}
17
- `);if(y!==void 0)o(`${d(`this agent is running (pid ${y.pid}, ${y.mode}) and holds its settings for its lifetime — the change applies after ${S(y.mode)}`)}
18
- `);return n}async function F(e,r,o){let i=ie({plain:!1,json:!1,oneShot:!1});if(i.mode!=="rich")throw new t({code:"cli_config_edit_needs_terminal",message:"The settings editor needs a terminal.",hint:`Not one here (${i.because}). \`config list\` reads them and \`config set\` changes one, both of which work on a pipe.`});let[{render:a},{createElement:s},{ConfigEditor:c}]=await Promise.all([import("ink"),import("react"),import("./ConfigEditor-7nnc2ke6.js")]),p=!1,f=()=>{},g=new Promise((u)=>{f=u});me(),process.stdout.write(be);let m=a(s(c,{rows:at(e),apply:(u,y)=>rn(e,u,y),reload:()=>at(e),columns:q(process.stdout.columns,j),window:Ze,onDone:(u)=>{p=u,f()}}),{exitOnCtrlC:!1,...Z()});b(()=>m.unmount()),await g,m.unmount(),J(),await ue();let v=await O(e,r);if(!p)return o(`${l([{label:"unchanged",value:e}])}
19
- `),n;return o(`${l([{label:"changed",value:e}])}
20
- `),o(`${d(`takes effect after ${S(v?.mode)}`)}
21
- `),n}export{re as configCommand,ne as readAction};
22
-
23
- //# debugId=77B7D4100F95487764756E2164756E21
24
- //# sourceMappingURL=config-9cv76yrk.js.map
@@ -1,19 +0,0 @@
1
- #!/usr/bin/env node
2
- import{e,nr}from"./index-7z4sw2dm.js";import"./index-xf178c4m.js";import{se}from"./index-5x4dn0gg.js";import{Ce,Qe,ur,Kt}from"./index-dwyr2kdm.js";import"./index-000rxxy3.js";function g(n){let t=/^(\d+)\s*(s|m|h|d)?$/.exec(n.trim());if(t===null)throw new se({code:"credential_usage",message:`--expires ${JSON.stringify(n)} is not a duration.`,hint:"Write it as 30s, 15m, 2h or 7d — or as a plain number of seconds."});let i=Number(t[1]);if(i===0)throw new se({code:"credential_usage",message:"--expires 0 would mint a credential that has already expired.",hint:"Leave the flag off for a key that never expires, or give it a real duration like 1h."});let s={s:1,m:60,h:3600,d:86400}[t[2]??"s"]??1;return i*s}function y(n){let t=n.split(",").map((s)=>s.trim().toLowerCase()).filter((s)=>s!==""),i=t.filter((s)=>!nr.includes(s));if(i.length>0)throw new se({code:"credential_usage",message:`--can names ${i.map((s)=>JSON.stringify(s)).join(", ")}, which is not a capability.`,hint:`The four are: ${nr.join(", ")}. read is every GET; chat sends a message, answers an approval and stops a turn; write covers schedules, phase and clearing a session; admin covers credentials, provisioning and start/stop.`});return t}function f(n){return n.split(",").map((t)=>t.trim()).filter((t)=>t!=="")}function l(n){let t=[];if(t.push(n.scope?.agents===void 0?"every agent":n.scope.agents.join(", ")),n.scope?.sessions!==void 0)t.push(`sessions ${n.scope.sessions}`);if(t.push(n.scope?.can===void 0?"all capabilities":n.scope.can.join("+")),n.expiresAt!==void 0)t.push(`until ${n.expiresAt}`);return t.join(" · ")}async function d(n){let t=await Ce(n);if(t===void 0)throw new se({code:"credential_usage",message:"No server is running, so there is nothing to mint a credential on.",hint:`A credential belongs to a server rather than to a file, so this command is an API client. Start one with \`${e.slug} serve\`, or use POST /v1/keys directly against a server you can already reach.`});return{lease:t,manifest:Kt(t.agentId)}}async function v(n){if(n.action==="create")return await h(n);if(n.action==="list")return await p(n);if(n.action==="revoke")return await m(n);throw new se({code:"credential_usage",message:`Unknown action ${JSON.stringify(n.action)}.`,hint:"The actions are create, list and revoke."})}async function h(n){let t=n.label?.trim();if(t===void 0||t==="")throw new se({code:"credential_usage",message:"--label is required.",hint:'A label is the only thing distinguishing two credentials in a listing, and "key 2" is a name nobody can act on when deciding which to revoke.'});let i={...n.agents===void 0?{}:{agents:f(n.agents)},...n.sessions===void 0?{}:{sessions:n.sessions},...n.can===void 0?{}:{can:y(n.can)},...n.expires===void 0?{}:{expiresIn:g(n.expires)}},{lease:s,manifest:o}=await d(n.store),a=await Qe(s,"/v1/keys",{label:t,...Object.keys(i).length===0?{}:{scope:i}},o);if(!a.ok)return c(a,"mint a credential");let r=a.body;if(n.json===!0)return process.stdout.write(`${JSON.stringify(r,null,2)}
3
- `),0;return process.stdout.write(`${r.secret}
4
- `),process.stderr.write(` ${r.label} · ${r.keyId}
5
- `),process.stderr.write(` reaches ${l(r)}
6
- `),process.stderr.write(` This is the only time the secret is shown. It is stored as a fingerprint and no route returns it.
7
- `),0}async function p(n){let{lease:t,manifest:i}=await d(n.store),s=await ur(t,"GET","/v1/keys",i);if(!s.ok)return c(s,"list credentials");let o=s.body,a=o.keys??[];if(n.json===!0)return process.stdout.write(`${JSON.stringify(o,null,2)}
8
- `),0;if(a.length===0)return process.stdout.write(`No credentials. The server token is the only way in.
9
- `),0;for(let r of a){let u=r.revokedAt===void 0?"live":"revoked";process.stdout.write(`${r.keyId} ${u.padEnd(7)} ${r.label}
10
- `),process.stdout.write(` reaches ${l(r)}
11
- `),process.stdout.write(` created ${r.createdAt}${r.lastUsedAt===void 0?" · never used":` · last used ${r.lastUsedAt}`}
12
- `)}return 0}async function m(n){let t=n.keyId?.trim();if(t===void 0||t==="")throw new se({code:"credential_usage",message:"Which credential?",hint:`\`${e.slug} credential list\` prints the ids. Revoking is permanent — a revoked secret can never be re-presented.`});let{lease:i,manifest:s}=await d(n.store),o=await ur(i,"DELETE",`/v1/keys/${encodeURIComponent(t)}`,s);if(!o.ok)return c(o,"revoke that credential");let a=o.body;if(n.json===!0)return process.stdout.write(`${JSON.stringify(a,null,2)}
13
- `),0;return process.stdout.write(`revoked ${a.keyId} · ${a.label}
14
- `),0}function c(n,t){if(process.stderr.write(`Could not ${t}${n.status===0?"":` (${n.status})`}: ${n.detail??"the host did not answer"}
15
- `),n.hint!==void 0)process.stderr.write(` hint: ${n.hint}
16
- `);return 1}export{v as credentialCommand};
17
-
18
- //# debugId=BFD639E58283AE8E64756E2164756E21
19
- //# sourceMappingURL=credential-yxqj8x1f.js.map
@@ -1,7 +0,0 @@
1
- #!/usr/bin/env node
2
- import{e,E,t,T}from"./index-7z4sw2dm.js";function f(n){return n!==void 0&&n!==""}function xe(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 xe(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{xe,ee,B,w,Xt,Jt,ao,K,te};
5
-
6
- //# debugId=6CD099BA631E191464756E2164756E21
7
- //# sourceMappingURL=index-000rxxy3.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": ";yCAeA,SAAS,CAAK,CAAC,EAAoC,CAC/C,OAAO,IAAU,QAAa,IAAU,GAGrC,SAAS,EAAO,CAAC,EAAoD,QAAQ,IAAe,CAC/F,MAAO,CACH,QAAS,EAAM,EAAI,QAAQ,EAC3B,aAAc,EAAI,OAAS,OAG3B,GAAI,EAAM,EAAI,EAAE,GAAK,EAAI,KAAO,QAChC,MAAO,EAAM,EAAI,KAAK,EAEtB,YAAa,EAAM,EAAI,GAAG,EAAM,gBAAgB,EAC1C,EAAI,GAAG,EAAM,iBACb,OAEN,eAAgB,EAAM,EAAI,GAAG,EAAM,oBAAoB,CAC3D,EChBJ,qBAAS,iBAAY,cAAa,gBAClC,kBAAS,gBACT,qBAAS,UAAY,aAAM,SAAS,kBAI7B,SAAS,EAAW,CACvB,EAAoD,QAAQ,IACtD,CAEN,OADiB,GAAQ,CAAG,EAAE,aACX,EAAK,EAAQ,EAAG,EAAM,QAAQ,EAG9C,SAAS,CAAS,CAAC,EAA4D,CAClF,OAAO,EAAK,GAAY,CAAG,EAAG,QAAQ,EAGnC,SAAS,CAAS,CAAC,EAA4D,CAClF,OAAO,EAAK,GAAY,CAAG,EAAG,UAAU,EAqBrC,SAAS,EAAc,CAAC,EAG7B,CACE,IAAM,EAAM,EAAK,GAAY,CAAG,EAAG,OAAQ,QAAQ,EACnD,MAAO,CAAE,IAAK,EAAK,EAAK,SAAS,EAAG,IAAK,EAAK,EAAK,SAAS,CAAE,EAG3D,SAAS,EAAQ,CACpB,EACA,EAC8C,CAC9C,IAAM,EAAM,EAAK,GAAY,CAAG,EAAG,MAAM,EACzC,MAAO,CAAE,IAAK,EAAK,EAAK,GAAG,WAAiB,EAAG,IAAK,EAAK,EAAK,GAAG,WAAiB,CAAE,EAUjF,SAAS,CAAa,CACzB,EACA,EACO,CACP,IAAM,EAAO,EAAQ,EAAU,CAAG,CAAC,EAC7B,EAAS,EAAQ,CAAS,EAChC,OAAO,IAAW,GAAQ,EAAO,WAAW,EAAO,CAAG,EAcnD,SAAS,EAAkB,CAC9B,EACA,EACkB,CAClB,GAAI,EAAc,EAAW,CAAG,EAAG,OACnC,MAAO,SAAS,EAAQ,CAAS,6BAA6B,EAAU,CAAG,gHA6BxE,SAAS,CAAU,CACtB,EACuB,CACvB,IAAM,EAAM,EAAU,CAAG,EACrB,EACJ,GAAI,CACA,EAAU,EAAY,CAAG,EAC3B,KAAM,CAEJ,MAAO,CAAC,EAGZ,IAAM,EAAyB,CAAC,EAChC,QAAW,KAAO,EAAQ,KAAK,EAAG,CAC9B,IAAM,EAAW,EAAK,EAAK,CAAG,EACxB,EAAe,EAAK,EAAU,YAAY,EAChD,GAAI,CACA,GAAI,CAAC,EAAS,CAAQ,EAAE,YAAY,EAAG,SACzC,KAAM,CACJ,SAEJ,GAAI,CAAC,EAAW,CAAY,EAAG,SAE/B,IAAI,EAAU,EACd,GAAI,CACA,EAAU,EAAS,CAAY,EAAE,QACnC,KAAM,EAIR,GAAI,CACA,IAAM,EAAS,EAAmB,CAAY,EAC9C,EAAO,KAAK,CACR,MACA,IAAK,EACL,eACA,aACI,EAAO,KAAO,OAAY,CAAC,EAAI,CAAE,GAAI,EAAO,EAAG,KAC/C,EAAO,OAAS,OAAY,CAAC,EAAI,CAAE,KAAM,EAAO,IAAK,KACrD,EAAO,UAAY,OAAY,CAAC,EAAI,CAAE,QAAS,EAAO,OAAQ,CACtE,CAAC,EACH,MAAO,EAAO,CACZ,EAAO,KAAK,CACR,MACA,IAAK,EACL,eACA,UACA,QAAS,aAAiB,MAAQ,EAAM,QAAU,OAAO,CAAK,CAClE,CAAC,GAKT,IAAM,EAAO,IAAI,IACjB,QAAW,KAAS,EAAQ,CACxB,GAAI,EAAM,KAAO,OAAW,SAC5B,EAAK,IAAI,EAAM,GAAI,CAAC,GAAI,EAAK,IAAI,EAAM,EAAE,GAAK,CAAC,EAAI,CAAK,CAAC,EAE7D,IAAM,EAAS,EAAO,IAAI,CAAC,IAAU,CACjC,GAAI,EAAM,KAAO,SAAc,EAAK,IAAI,EAAM,EAAE,GAAG,QAAU,GAAK,EAAG,OAAO,EAC5E,MAAO,IACA,EACH,QAAS,gBAAgB,EAAM,6EACnC,EACH,EAED,MAAO,CACH,GAAG,EAAO,OAAO,CAAC,IAAM,EAAE,UAAY,MAAS,EAC/C,GAAG,EAAO,OAAO,CAAC,IAAM,EAAE,UAAY,MAAS,CACnD,EAWG,SAAS,EAAe,CAC3B,EACA,EACA,EAAc,QAAQ,IAAI,EACpB,CACN,IAAM,EACF,EAAI,SAAS,CAAG,GAAK,EAAI,SAAS,GAAG,GAAK,EAAI,SAAS,OAAO,GAAK,EAAI,SAAS,MAAM,EACpF,EAAS,EAAW,CAAG,EAAI,EAAM,EAAQ,EAAK,CAAG,EAIvD,GAAI,CAAC,GAAiB,EAAW,CAAM,GAAK,EAAW,EAAK,EAAU,CAAG,EAAG,CAAG,CAAC,EAC5E,QAAQ,OAAO,MACX,iBAAiB,kDAAoD,iDAAmD,EAAK,EAAU,CAAG,EAAG,CAAG;AAAA,CACpJ,EAGJ,GAAI,GAAiB,EAAW,CAAM,EAAG,CACrC,GAAI,EAAW,CAAM,EAAG,CACpB,GAAI,EAAS,CAAM,EAAE,YAAY,EAAG,CAChC,IAAM,EAAS,EAAK,EAAQ,YAAY,EACxC,GAAI,EAAW,CAAM,EAAG,OAAO,EAC/B,MAAM,IAAI,EAAa,CACnB,KAAM,iCACN,QAAS,GAAG,8CACZ,KAAM,+HACV,CAAC,EAEL,OAAO,EAEX,MAAM,IAAI,EAAa,CACnB,KAAM,yBACN,QAAS,GAAG,6CACZ,KAAM,mGAAmG,EAAM,4CAA4C,EAAU,CAAG,IAC5K,CAAC,EAGL,IAAM,EAAkB,EAAK,EAAU,CAAG,EAAG,EAAK,YAAY,EAC9D,GAAI,EAAW,CAAe,EAAG,OAAO,EAExC,IAAM,EAAQ,EAAW,CAAG,EAAE,IAAI,CAAC,IAAU,EAAM,GAAG,EAChD,EAAa,EAAQ,EAAK,CAAK,EACrC,MAAM,IAAI,EAAa,CACnB,KAAM,oBACN,QAAS,mBAAmB,oBAAsB,EAAM,SAAW,EAAI,mBAAqB,MAC5F,KACI,EAAM,SAAW,EACX,qBAAqB,EAAM,gDAC3B,iBAAiB,EAAM,KAAK,IAAI,KAAK,IAAe,OAAY,GAAK,iBAAiB,oDACpG,CAAC",
9
- "debugId": "6CD099BA631E191464756E2164756E21",
10
- "names": []
11
- }
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env node
2
- import{gt,pn,Or,m}from"./index-7z4sw2dm.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-0b1hdwnm.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-2wmsmcbr.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-17an0jqq.js.map
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env node
2
- var Xo="\x1B[?25h",_n="\x1B[0m",Jo="\x1B[2m",be="\x1B[?1049h",Qo="\x1B[?1049l",es="\x1B[<u",j=80,$n=24,lr=12,An="› ",Rn=40,In=140,Ge=8,Ze=40,Ve=8,ts=200,Cr=100,On=10,ns=4,rs=6,Nn=3,os=2000,Cn=50,ss=1,n=0,s=1,is=143;var as=3,ls=22,ds=8,cs=400,dr=1,Bt=12,us=300,fs=2000;
3
- export{Xo,_n,Jo,be,Qo,es,j,$n,lr,An,Rn,In,Ge,Ze,Ve,ts,Cr,On,ns,rs,Nn,os,Cn,ss,n,s,is,as,ls,ds,cs,dr,Bt,us,fs};
4
-
5
- //# debugId=E1274E50B3CA1FD064756E2164756E21
6
- //# sourceMappingURL=index-2wmsmcbr.js.map
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env node
2
- import{o,oe}from"./index-d4x6yvqh.js";import{Box as l,Text as e}from"ink";import{jsx as n,jsxs as d}from"react/jsx-runtime";function it({title:t,lines:i}){return d(l,{flexDirection:"column",borderStyle:oe,borderColor:o.borderActive,paddingX:1,children:[n(e,{bold:!0,color:o.accent,children:t}),i.map((r)=>n(e,{dimColor:!0,children:r},r))]})}
3
- export{it};
4
-
5
- //# debugId=C0826684AC8FD63F64756E2164756E21
6
- //# sourceMappingURL=index-4z7axw4r.js.map
@@ -1,66 +0,0 @@
1
- #!/usr/bin/env node
2
- import{r,a,v,Ue,h,i,_e,P,g,Lt,No,$e,Ae,F,U}from"./index-7z4sw2dm.js";var ct="dispach",ut="Dispach",ht=1;function q(e,t){return{slug:e,name:t,envPrefix:`${e.toUpperCase()}_`,stateDir:`.${e}`,apiVersion:`${e}/v${ht}`,packageScope:`@${e}`}}var M=q(ct,ut),C=`${M.envPrefix}BRAND`,he=/^[a-z][a-z0-9]*(-[a-z0-9]+)*$/;function me(e){return e.split("-").map((t)=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function pe(e){if(e===void 0)return M;let t=e.trim();if(t==="")throw Error(`${C} is set but empty. hint: unset ${C} entirely to use the default brand — an empty value `+'is treated as a mistake rather than as "no override", because a declared-but-unset variable is usually a container passing through a name it never assigned.');if(!he.test(t))throw Error(`${C}="${t}" is not a usable brand slug. hint: the slug becomes an env var prefix, a dot-directory, an npm scope, and the `+"manifest apiVersion, so it must be lowercase alphanumeric with inner hyphens — "+"e.g. acme or acme-run.");if(t===M.slug)return M;return q(t,me(t))}var Q=pe(process.env[C]);function ft(e,t){let n=Array.from({length:t.length+1},(s,o)=>o);for(let s=1;s<=e.length;s+=1){let o=[s];for(let d=1;d<=t.length;d+=1){let l=(n[d-1]??0)+(e[s-1]===t[d-1]?0:1),c=(o[d-1]??0)+1,m=(n[d]??0)+1;o.push(Math.min(l,c,m))}n=o}return n[t.length]??Math.max(e.length,t.length)}function rt(e,t){let n,s=Number.POSITIVE_INFINITY;for(let o of t){let d=ft(e,o);if(d<s)s=d,n=o}return n!==void 0&&s<=Math.max(2,Math.floor(e.length/3))?n:void 0}var ge=Symbol.for("dispach.HarnessError");function fe(e){return typeof e==="object"&&e!==null&&ge in e}class z extends Error{static ERROR_NAME="HarnessError";code;hint;field;details;constructor(e){super(e.message,e.cause===void 0?void 0:{cause:e.cause});this.name=new.target.ERROR_NAME??"HarnessError",this[ge]=!0,this.code=e.code,this.hint=e.hint,this.field=e.field,this.details=e.details??[]}toDetail(){return this.field===void 0?{code:this.code,message:this.message,hint:this.hint}:{code:this.code,message:this.message,hint:this.hint,field:this.field}}format(){let e=[`${this.code}: ${this.message}`];if(this.field!==void 0)e.push(` field: ${this.field}`);if(e.push(` hint: ${this.hint}`),this.details.length===1)return e.join(`
3
- `);for(let t of this.details){if(e.push(""),e.push(` ${t.code}: ${t.message}`),t.field!==void 0)e.push(` field: ${t.field}`);e.push(` hint: ${t.hint}`)}return e.join(`
4
- `)}}class y extends z{static ERROR_NAME="ConfigError"}class f extends z{static ERROR_NAME="ToolError"}function ye(e,t){return new y({code:"tools_provider_alias_conflict",message:`The manifest sets tools.providers (${e.join(", ")}) and also the deprecated tools.provider${t===void 0?"Config":` (${t})`}.`,hint:`Keep tools.providers and delete the other two. Merging them would give the scalar a position in the map that nobody wrote, and provider order decides which one wins a slug collision${t===void 0?"":` — move ${t}'s settings into tools.providers.${t}`}.`,field:"tools.provider"})}function we(e,t){return new f({code:"workspace_not_editable",message:`${e} is declared editable: ${t}, so it cannot be written to.`,hint:"Point the write at a volatile file whose frontmatter allows it (editable: append or replace), or change that file's frontmatter. Read-only identity is deliberate — it is the most effective known mitigation for persona drift, so this refuses rather than silently doing nothing."})}function be(){return new f({code:"artifact_unavailable",message:"This runtime has no artifact store, so a compacted observation cannot be read back.",hint:"artifact_read only works inside a session backed by a store. If you are seeing a compaction pointer without one, the pointer was written by a different process — report the text of the pointer rather than guessing at what it replaced."})}function ve(e){return new f({code:"artifact_not_found",message:`No compacted observation is stored under ${JSON.stringify(e)} in this conversation.`,hint:"Copy the id exactly from the pointer in the conversation — it is not guessable and it is scoped to this conversation. If the pointer came from a session you have since switched away from, the observation is not reachable from here."})}var qt="0.1.1";var mt="What I already know, carried from before this conversation and kept current. "+"Not a transcript — these are standing facts about the person I work for and my own working notes. "+"If they ask what I know or remember about them, this is the answer.";var pt=3.8;function Ne(e){if(e==="")return 0;let t=0;for(let n=0;n<e.length;n+=1)if(e.charCodeAt(n)===10)t+=1;return Math.ceil(e.length/pt)+t}var Pe=["runtime.ready","store.ready","runtime.stopping","agent.loaded","agent.disposed","agent.warning","plugin.loaded","plugin.slow","approval.requested","approval.resolved","handoff.start","handoff.result","turn.start","context.assembled","context.dropped","context.pressure","compaction.stage","context.reset","phase.changed","model.call","model.chunk","model.retry","model.result","tool.call","tool.result","tool.gated","tool.repair","tools.refreshed","agent.channel.status","agent.channel.error","agent.channel.rejected","delivery.sent","delivery.retry","delivery.failed","delivery.uncertain","runtime.released","schedules.reconciled","schedule.fired","schedule.skipped","schedule.deferred","schedule.error","turn.end","error"],_=(e)=>String.fromCharCode(e),I=_(27),Ie=_(7),gt=new RegExp(`${I}\\[[0-?]*[ -/]*[@-~]`,"g"),yt=new RegExp(`${I}\\][\\s\\S]*?(?:${Ie}|${I}\\\\|$)`,"g"),wt=new RegExp(`${I}[P^_X][\\s\\S]*?(?:${I}\\\\|${Ie}|$)`,"g"),bt=new RegExp(`${I}[@-Z\\\\-_0-9=><]?`,"g"),vt=new RegExp(`[${_(128)}-${_(159)}]`,"g"),kt=new RegExp(`[${_(0)}-${_(8)}${_(11)}${_(12)}${_(14)}-${_(31)}${_(127)}]`,"g");function Se(e){return e.replace(/\r\n/g,`
5
- `).replace(/\r/g,`
6
- `).replace(yt,"").replace(wt,"").replace(gt,"").replace(bt,"").replace(vt,"").replace(kt,"")}var Tt=/\r\n\r\n|\n\n|\r\r/;function ke(e){let t=[],n,s,o;for(let d of e.split(/\r\n|\n|\r/)){if(d===""||d.startsWith(":"))continue;let l=d.indexOf(":"),c=l===-1?d:d.slice(0,l),m=l===-1?"":d.slice(l+1);if(m.startsWith(" "))m=m.slice(1);switch(c){case"data":t.push(m);break;case"event":n=m;break;case"id":s=m;break;case"retry":{let u=Number.parseInt(m,10);if(Number.isFinite(u))o=u;break}default:break}}if(t.length===0&&n===void 0)return;return{...n===void 0?{}:{event:n},data:t.join(`
7
- `),...s===void 0?{}:{id:s},...o===void 0?{}:{retry:o}}}async function*Fn(e){let t=new TextDecoder,n="";for await(let s of e){n+=typeof s==="string"?s:t.decode(s,{stream:!0});while(!0){let o=Tt.exec(n);if(o===null)break;let d=n.slice(0,o.index);n=n.slice(o.index+o[0].length);let l=ke(d);if(l!==void 0)yield l}}if(n+=t.decode(),n.trim()!==""){let s=ke(n);if(s!==void 0)yield s}}function Un(){return{push:(e)=>e,endStep:()=>"",end:()=>""}}var Oe="<<<",Re=">>>",H=/^\s*(?:[-*+]\s+|\d+[.)]\s+)?<?\s*action\s*:\s*(.+?)\s*>?\s*$/i,Et=/^\s*(?:[-*+]\s+|\d+[.)]\s+)?([A-Za-z_][\w.-]*?)\s*:\s*(.*)$/,J=/^\s*`{3,}\s*[\w+-]*\s*$/,Te=/^\s*end\s*$/i,_t=/^\s*<\s*action\s*>\s*$/i,Ee=/^\s*<\s*\/\s*action\s*>\s*$/i,At=/^\s*<\/?\s*[A-Za-z_][\w.:-]*\s*\/?\s*>\s*$/;function Y(e){return e.replace(/^[`'"*<]+/,"").replace(/[`'"*>]+$/,"").replace(/[.,;:]+$/,"").trim()}function Ce(e,t,n){let s=e.fields.get(t);if(s===void 0)e.fields.set(t,[n]);else s.push(n)}function De(e){if(e.block===void 0||e.heredocKey===void 0)return;let t=[...e.heredocLines];if(t[t.length-1]==="")t.pop();Ce(e.block,e.heredocKey,t.join(`
8
- `)),e.block.wrapped.add(e.heredocKey),e.heredocKey=void 0,e.heredocLines=[]}function N(e){if(De(e),e.block!==void 0)e.blocks.push(e.block);e.block=void 0,e.openKey=void 0,e.awaitingSlug=!1}function xe(){return{block:void 0,openKey:void 0,heredocKey:void 0,heredocLines:[],justClosed:!1,awaitingSlug:!1,text:[],blocks:[]}}function St(e,t,n){let s=t.trim();if(e.heredocKey!==void 0){if(s===Re){De(e);return}if(Te.test(s)){N(e),e.justClosed=!0;return}if(H.test(t)){N(e);let l=H.exec(t),c=Y(l?.[1]??"");if(c!=="")e.block={slug:c,fields:new Map,wrapped:new Set};return}e.heredocLines.push(t);return}let o=H.exec(t);if(o!==null){let l=Y(o[1]??"");if(N(e),l==="")return;e.block={slug:l,fields:new Map,wrapped:new Set};return}if(_t.test(t)){N(e),e.awaitingSlug=!0;return}if(e.awaitingSlug){if(s==="")return;if(Ee.test(t)){e.awaitingSlug=!1;return}let l=Y(s);if(e.awaitingSlug=!1,l!=="")e.block={slug:l,fields:new Map,wrapped:new Set};return}if(Ee.test(t)){if(e.block!==void 0)N(e),e.justClosed=!0;return}if(At.test(t))return;if(e.block===void 0){if(J.test(t)&&(e.justClosed||n())){e.justClosed=!1;return}if(e.text.push(t),s!=="")e.justClosed=!1;return}if(s===""){e.openKey=void 0;return}if(Te.test(s)){N(e),e.justClosed=!0;return}if(J.test(t))return;let d=Et.exec(t);if(d!==null){let l=(d[1]??"").trim(),c=(d[2]??"").trim();if(c===Oe)e.heredocKey=l,e.heredocLines=[],e.openKey=void 0;else Ce(e.block,l,c),e.openKey=l;return}if(e.openKey!==void 0){let l=e.block.fields.get(e.openKey),c=l?.[l.length-1];if(l!==void 0&&c!==void 0)l[l.length-1]=c===""?s:`${c}
9
- ${s}`;return}N(e),e.text.push(t)}function xt(e){if(/^\s*(?:[-*+]|\d+[.)]?)?\s*$/.test(e))return!0;let t=e.replace(/^\s*(?:[-*+]\s+|\d+[.)]\s+)?/,"").toLowerCase(),n=t.startsWith("<")?t.slice(1):t;if("action:".startsWith(n)||n.startsWith("action:"))return!0;if(/^<\/?$/.test(t)||/^<\/?[a-z_][\w.:-]*>?$/.test(t))return!0;return/^`{1,3}[\w+-]*$/.test(t)}function V(e){return e.endsWith("\r")?e.slice(0,-1):e}function jn(){let e=xe(),t="",n=0,s,o="",d=!1,l=(p)=>{if(p==="")return"";if(p.trim()==="")return o+=p,"";let w=o+p;if(o="",d)return w;return d=!0,w.replace(/^\s+/,"")},c=(p,w)=>{let b=e.text.length;return St(e,p,()=>w!==void 0&&H.test(w)),e.text.length>b?p:void 0},m=(p,w,b)=>{let T=c(p,w);if(T===void 0)return"";return l(T.slice(b))+l(`
10
- `)},u=(p)=>{if(s===void 0)return"";let w=s;return s=void 0,m(w,p,0)};return{push(p){let w="";t+=p;let b=t.indexOf(`
11
- `);while(b!==-1){let E=V(t.slice(0,b));if(t=t.slice(b+1),w+=u(E),e.block===void 0&&J.test(E)&&!e.justClosed)s=E;else w+=m(E,void 0,n);n=0,b=t.indexOf(`
12
- `)}let T=V(t);if(e.block===void 0&&!e.awaitingSlug&&s===void 0&&!xt(T))w+=l(T.slice(n)),n=T.length;return w},endStep(){let p=k();return o=`
13
-
14
- `,e=xe(),p},end:k};function k(){let p=u(void 0),w=V(t);if(w!==""){let b=c(w,void 0);if(b!==void 0)p+=l(b.slice(n))}return t="",n=0,s=void 0,p}}var $s=`# Tools
15
-
16
- To use a tool, write an ACTION block. Start each line at the left margin, exactly like this:
17
-
18
- ACTION: weather_lookup
19
- city: Lisbon
20
- units: celsius
21
- END
22
-
23
- That block is an example of the shape only. Your own tools are listed below — take the tool name and
24
- every field name from that list, spelled exactly as it is written there.
25
-
26
- Rules for a block:
27
- - One field per line, written as \`name: value\`, where \`name\` is one of that tool's own field names.
28
- - For a value spanning several lines, open it with \`${Oe}\` and close it with \`${Re}\` alone on its own line.
29
- - Finish every block with \`END\` alone on its own line.
30
- - Several blocks are allowed. They run in the order you write them.
31
- - Use only the tools listed below, only their listed fields, and always give every required field.
32
-
33
- Anything you write outside a block is shown to the person you are talking to, so keep explanations
34
- short and keep them out of the block. When no tool fits, simply reply — never invent a tool, and
35
- never guess a value for a required field you have not been given.`;import{appendFile as Xe,mkdir as En,readFile as _n}from"node:fs/promises";import{join as Ge}from"node:path";import{appendFile as qe,mkdir as An,readFile as Sn,writeFile as xn}from"node:fs/promises";import{join as $n}from"node:path";import{readFile as Yn,writeFile as Vn}from"node:fs/promises";var $t=`${Q.slug}_`,Nt="0123456789abcdefghjkmnpqrstvwxyz",It=32;function zn(){let e=new Uint8Array(It);crypto.getRandomValues(e);let t="";for(let n of e)t+=Nt[n&31]??"0";return`${$t}${t}`}async function Bn(e){let t=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(e));return[...new Uint8Array(t)].map((n)=>n.toString(16).padStart(2,"0")).join("")}var Kn=64,Ot=new RegExp("[\\u0000-\\u001f\\u007f]");function Xr(e){if(e.trim()==="")return"A key label cannot be empty.";if(e.length>Kn)return`A key label is at most ${Kn} characters; this one is ${e.length}.`;if(Ot.test(e))return"A key label cannot contain control characters, including newlines and tabs.";return}function Rt(e){let t=`${e.channel}:${e.peerId}`;return e.thread===void 0||e.thread===""?t:`${t}:${e.thread}`}var Fe="0123456789abcdefghijklmnopqrstuvwxyz";function Mt(e){let t=new Uint8Array(e);crypto.getRandomValues(t);let n="";for(let s of t)n+=Fe[s%Fe.length];return n}function ae(e,t){return`${e}_${t.toString(36)}${Mt(8)}`}function Gt(e=Date.now()){return ae("t",e)}function Jr(e=Date.now()){return ae("r",e)}function Qr(e=Date.now()){return ae("k",e)}var je="phase_set",et="*",We="tag:";function eo(e){let t=Object.keys(e);return t.find((s)=>e[s]?.entry===!0)??t[0]}function He(e){return e.toLowerCase().replace(/[\s_.-]+/g,"")}function Ct(e,t){if(e===et)return!0;if(e.startsWith(We)){let n=e.slice(We.length).toLowerCase();return t.tags.some((s)=>s.toLowerCase()===n)}return He(e)===He(t.slug)}function Dt(e,t){let n=e[t];if(n===void 0)return[et];return n.allow.includes(je)?n.allow:[...n.allow,je]}function mr(e){return e!==void 0&&Object.keys(e).length>1}function to(e,t){return Object.keys(e).filter((n)=>Dt(e,n).some((s)=>Ct(s,t)))}var Me=["user","agent"];var Ut=/^---\r?\n([\s\S]*?)\r?\n---[ \t]*(?:\r?\n|$)/,Ft=/<!--[\s\S]*?-->/g,Pt=/\n{3,}/g;function jt(e){let t=Ut.exec(e);return t===null||t===void 0?e:e.slice(t[0].length)}function Wt(e){return e.replace(Ft,"").replace(Pt,`
36
-
37
- `).trim()}var K={static:2000,volatile:3500,reminder:500,total:6000};var S=r().min(1),Ht=i({delimiters:g(["xml","markdown","plain"]).optional(),intensity:g(["emphatic","neutral","soft"]).optional(),examplesIn:g(["system","user"]).optional(),skillsIn:g(["system","user"]).optional()}).strict(),Kt=i({nativeTools:v().optional(),strictSchema:v().optional(),thinking:g(["none","anthropic","openai","deepseek"]).optional(),promptCache:g(["none","anthropic","openai"]).optional(),parallelToolCalls:v().optional(),contextWindow:a().int().positive().optional(),maxOutput:a().int().positive().optional(),promptStyle:Ht.optional()}).strict(),B=i({id:r().min(1),baseUrl:r().min(1),apiKeyEnv:r().min(1).optional(),temperature:a().min(0).max(2).optional(),topP:a().min(0).max(1).optional(),maxTokens:a().int().positive().optional(),reasoningEffort:g(["none","minimal","low","medium","high"]).optional(),headers:P(r(),r()).optional(),streamUsage:v().optional(),capabilities:Kt.optional()}).strict(),Bt=i({main:B,selector:B.optional(),compactor:B.optional()}).catchall(B),Xt=i({snip:a().default(0.6),micro:a().default(0.7),collapse:a().default(0.8),reset:a().default(0.88),trim:a().default(0.95)}).strict(),zt=i({static:a().int().positive().default(K.static),volatile:a().int().positive().default(K.volatile),reminder:a().int().positive().default(K.reminder),total:a().int().positive().default(K.total)}).strict(),Jt=i({perRuleSuccess:a().gt(0).lte(1).default(0.9),reliabilityTarget:a().gt(0).lt(1).default(0.8),onExceed:g(["fail","warn"]).default("fail")}).strict(),Qt=i({file:r().min(1),requires:i({contextWindow:r().min(1).optional(),class:g(["frontier","small"]).optional()}).strict().optional(),onUnmet:g(["distill","omit","fail"]).default("distill"),distilled:r().min(1).optional()}).strict(),en=i({dir:r().min(1),maxActive:a().int().nonnegative().default(2),budget:a().int().positive().default(600)}).strict(),tn=i({window:a().int().positive().optional(),reserveOutput:a().int().positive().default(4096),observationMaxTokens:a().int().positive().default(2000),files:h(r().min(1)).default([]),workspace:r().min(1).default("./workspace"),static:h(r().min(1)).default([]),volatile:h(r().min(1)).default([]),reminder:r().min(1).optional(),budgets:zt.prefault({}),rules:Jt.prefault({}),soul:Qt.optional(),compactionNotice:v().optional(),thresholds:Xt.prefault({})}).strict(),nn=i({max:a().int().positive().default(24),reserveWrite:a().int().nonnegative().default(6)}).strict(),sn=i({onMutate:g(["refuse","confirm","allow"]).default("refuse")}).strict(),rn=i({mode:g(["ask","allow","deny"]).default("allow"),allow:h(r().min(1)).default([]),deny:h(r().min(1)).default([]),onNoApprover:g(["deny","allow"]).default("deny")}).strict(),on=i({dialect:g(["nlt","native"]).default("nlt"),providers:P(S,P(r(),Ue())).default({}),provider:S.optional(),providerConfig:P(r(),Ue()).default({}),budget:nn.prefault({}),pinned:h(r().min(1)).default([]),search:i({enabled:v().default(!1)}).strict().prefault({}),local:h(r().min(1)).default([]),untrusted:sn.prefault({}),policy:rn.prefault({})}).strict(),an=i({allow:h(r().min(1)),entry:v().optional()}).strict(),dn=i({dir:r().min(1).default("./skills"),maxActive:a().int().nonnegative().default(1),threshold:a().default(0.35)}).strict(),ln=i({retriever:r().min(1).default("fts5"),dir:r().min(1).default("./memory"),maxActive:a().int().nonnegative().default(5),threshold:a().default(0.2),budget:a().int().positive().default(2000),includeHistory:v().default(!0)}).strict(),cn=i({type:S,id:S,allowFrom:h(r().min(1)).optional(),enabled:v().default(!0)}).passthrough(),tt=i({channel:S,to:r().min(1)}).strict(),un=i({default:S.optional(),targets:P(r(),tt).default({})}).strict(),re=No(()=>i({type:g(["string","number","integer","boolean","array","object"]),description:r().optional(),enum:h(_e([r(),a(),v()])).optional(),items:re.optional(),properties:P(r(),re).optional(),required:h(r()).optional()})),hn=i({id:S,manifest:r().min(1),task:r().min(1),artifact:i({type:Lt("object"),properties:P(r(),re),required:h(r()).optional()}).strict()}).strict(),fn=i({members:h(hn).min(1)}).strict(),nt=i({id:S,kind:g(["cron","every","at"]),expr:r().min(1),task:r().min(1),deliver:_e([Lt("none"),tt]),session:r().min(1).default("isolated"),role:S.optional(),enabled:v().default(!0),timezone:r().min(1).optional()}).strict(),mn=_e([r().min(1),i({spec:r().min(1),config:P(r(),Ue()).default({})}).strict()]),pn=i({identicalCalls:a().int().min(2).default(3)}).strict(),gn=i({maxSteps:a().int().positive().default(40),noProgress:pn.prefault({}),turnTimeoutMs:a().int().positive().default(1800000),toolTimeoutMs:a().int().positive().default(120000),maxParallelTools:a().int().positive().default(4)}).strict(),yn=i({enabled:v().default(!1),port:a().int().min(1).max(65535).default(7420),host:r().min(1).default("127.0.0.1"),tokenEnv:r().min(1).default(`${Q.envPrefix}API_TOKEN`),allowedOrigins:h(r().min(1)).default([]),allowedHosts:h(r().min(1)).default([])}).strict(),wn=i({apiVersion:r().min(1),id:S,name:r().min(1).optional(),extends:r().min(1).optional(),model:Bt,context:tn.prefault({}),tools:on.prefault({}),phases:P(r(),an).optional(),skills:dn.optional(),knowledge:en.optional(),memory:ln.optional(),channels:h(cn).default([]),delivery:un.optional(),schedules:h(nt).default([]),team:fn.optional(),plugins:h(mn).default([]),limits:gn.prefault({}),server:yn.prefault({})}).strict(),oe=["main","selector","compactor"];function bn(e){return oe.includes(e)}function Ke(e){return Object.keys(e).filter((t)=>!bn(t))}var vn={nativeTools:!1,strictSchema:!1,thinking:"none",promptCache:"none",parallelToolCalls:!1,contextWindow:8192,maxOutput:4096},Z={nativeTools:!0,strictSchema:!1,thinking:"anthropic",promptCache:"none",parallelToolCalls:!0},ee="Thinking blocks must be replayed with tool results or multi-step reasoning degrades silently. Prompt caching is unavailable on the OpenAI-compatible endpoint; the native Messages API is the only route to it.",vo=[{pattern:"gpt-4o*",capabilities:{nativeTools:!0,strictSchema:!0,thinking:"none",promptCache:"openai",parallelToolCalls:!0,contextWindow:128000,maxOutput:16384}},{pattern:"gpt-4.1*",capabilities:{nativeTools:!0,strictSchema:!0,thinking:"none",promptCache:"openai",parallelToolCalls:!0,contextWindow:1e6,maxOutput:32768}},{pattern:"gpt-4-turbo*",capabilities:{nativeTools:!0,strictSchema:!1,thinking:"none",promptCache:"none",parallelToolCalls:!0,contextWindow:128000,maxOutput:4096}},{pattern:"gpt-3.5*",capabilities:{nativeTools:!0,strictSchema:!1,thinking:"none",promptCache:"none",parallelToolCalls:!0,contextWindow:16385,maxOutput:4096}},{pattern:"gpt-5*",capabilities:{nativeTools:!0,strictSchema:!0,thinking:"openai",promptCache:"openai",parallelToolCalls:!0,contextWindow:200000,maxOutput:32768},note:"Deliberately conservative on window and output. Override if your endpoint serves more."},{pattern:"o1*",capabilities:{nativeTools:!0,strictSchema:!0,thinking:"openai",promptCache:"openai",parallelToolCalls:!1,contextWindow:200000,maxOutput:1e5}},{pattern:"o3*",capabilities:{nativeTools:!0,strictSchema:!0,thinking:"openai",promptCache:"openai",parallelToolCalls:!1,contextWindow:200000,maxOutput:1e5}},{pattern:"o4*",capabilities:{nativeTools:!0,strictSchema:!0,thinking:"openai",promptCache:"openai",parallelToolCalls:!1,contextWindow:200000,maxOutput:1e5}},...["claude-fable-5*","claude-opus-5*","claude-opus-4-8*","claude-opus-4-7*","claude-opus-4-6*","claude-sonnet-5*","claude-sonnet-4-6*"].map((e)=>({pattern:e,capabilities:{...Z,contextWindow:1e6,maxOutput:128000},note:ee})),{pattern:"claude-haiku-*",capabilities:{...Z,contextWindow:200000,maxOutput:64000},note:ee},{pattern:"claude-*",capabilities:{...Z,contextWindow:200000,maxOutput:8192},note:ee},{pattern:"gemini*",capabilities:{nativeTools:!0,strictSchema:!1,thinking:"none",promptCache:"none",parallelToolCalls:!0,contextWindow:1e6,maxOutput:8192}},{pattern:"qwen3.5*",capabilities:{nativeTools:!0,strictSchema:!1,thinking:"deepseek",promptCache:"none",parallelToolCalls:!1,contextWindow:32768,maxOutput:8192},note:"Served locally by Ollama, which reports no token usage unless model.<role>.streamUsage is set — token figures come from the estimator until it is. Reasoning is billed to the output budget, so context.reserveOutput must cover reasoning plus the reply.",verified:"2026-08-13 against qwen3.5:9b on localhost:11434/v1"},{pattern:"qwen*",capabilities:{nativeTools:!0,strictSchema:!1,thinking:"none",promptCache:"none",parallelToolCalls:!1,contextWindow:32768,maxOutput:8192}},{pattern:"llama*",capabilities:{nativeTools:!0,strictSchema:!1,thinking:"none",promptCache:"none",parallelToolCalls:!1,contextWindow:128000,maxOutput:4096}},{pattern:"mistral*",capabilities:{nativeTools:!0,strictSchema:!1,thinking:"none",promptCache:"none",parallelToolCalls:!1,contextWindow:32768,maxOutput:8192}},{pattern:"mixtral*",capabilities:{nativeTools:!0,strictSchema:!1,thinking:"none",promptCache:"none",parallelToolCalls:!1,contextWindow:32768,maxOutput:8192}},{pattern:"deepseek-v4-pro*",capabilities:{nativeTools:!0,strictSchema:!1,thinking:"deepseek",promptCache:"none",parallelToolCalls:!1,contextWindow:393216,maxOutput:393216},note:"Reasoning tokens are billed to the output budget. With max_tokens=16 this model returned empty content and finish_reason=length; context.reserveOutput must cover reasoning plus the reply.",verified:"2026-08-12 against api.deepseek.com/v1"},{pattern:"deepseek-v4-flash*",capabilities:{nativeTools:!0,strictSchema:!1,thinking:"deepseek",promptCache:"none",parallelToolCalls:!1,contextWindow:1048576,maxOutput:393216},verified:"2026-08-12 against api.deepseek.com/v1 (reasoning confirmed). Measured 2026-08-25 by `model probe --window`: contextWindow 1048576 as a ceiling — the endpoint refused a 1048576-token prompt and named that number; maxOutput 393216 from a refusal naming the range [1, 393216]; automatic prompt caching confirmed at 1024 of 1115 prompt tokens with no breakpoints sent, which is why promptCache stays `none` (it describes the runtime's job, not the provider's behaviour)."},{pattern:"deepseek-v4*",capabilities:{nativeTools:!0,strictSchema:!1,thinking:"deepseek",promptCache:"none",parallelToolCalls:!1,contextWindow:393216,maxOutput:393216},note:"Family fallback for v4 ids this registry has not seen. Assumes reasoning, because both measured v4 models emit it."},{pattern:"deepseek-reasoner*",capabilities:{nativeTools:!1,strictSchema:!1,thinking:"deepseek",promptCache:"none",parallelToolCalls:!1,contextWindow:65536,maxOutput:8192},note:"Not served by the account this registry was tested against. Numbers are from provider documentation and are deliberately low — override them if your endpoint serves this id."},{pattern:"deepseek-chat*",capabilities:{nativeTools:!0,strictSchema:!1,thinking:"none",promptCache:"none",parallelToolCalls:!0,contextWindow:65536,maxOutput:8192},note:"Unverified, from provider documentation."},{pattern:"deepseek-r1*",capabilities:{nativeTools:!1,strictSchema:!1,thinking:"deepseek",promptCache:"none",parallelToolCalls:!1,contextWindow:65536,maxOutput:8192},note:"The open-weight name for the reasoner, used by self-hosted and Ollama deployments."},{pattern:"deepseek*",capabilities:{nativeTools:!0,strictSchema:!1,thinking:"none",promptCache:"none",parallelToolCalls:!1,contextWindow:65536,maxOutput:8192}},{pattern:"gemma*",capabilities:{nativeTools:!1,strictSchema:!1,thinking:"none",promptCache:"none",parallelToolCalls:!1,contextWindow:8192,maxOutput:4096}},{pattern:"phi*",capabilities:{nativeTools:!1,strictSchema:!1,thinking:"none",promptCache:"none",parallelToolCalls:!1,contextWindow:16384,maxOutput:4096}},{pattern:"*",capabilities:vn}];var Be=/^(?:timeout\s+\S+|time|nice(?:\s+-n\s+\S+)?|stdbuf(?:\s+-\S+)*|command|builtin)\s+/i;function kn(e){let t=e.trim();for(let n=0;n<4&&Be.test(t);n+=1)t=t.replace(Be,"").trim();return t}var Tn=/\s*(?:&&|\|\||;|\||&|\n)\s*/;function no(e){return e.split(Tn).map((t)=>kn(t)).filter((t)=>t!=="")}var Nn=/^(?:[-*+]|\d+[.)])[ \t]+\S/,In=/\*\*(\d{4})-(\d{2})-\d{2}T/;function On(e){let t=[],n=-1,s=(o)=>{if(n===-1)return;t.push({start:n,end:o,text:e.slice(n,o).join(`
38
- `).trimEnd()}),n=-1};for(let o=0;o<e.length;o+=1){let d=e[o]??"";if(Nn.test(d)){s(o),n=o;continue}if(n===-1)continue;if(d.trim()===""||/^[ \t]/.test(d))continue;s(o)}return s(e.length),t}function ie(e){return Ne(Wt(jt(e)))}function Rn(e,t){let n=In.exec(e);if(n!==null)return`${n[1]}-${n[2]}.md`;let s=t.getUTCFullYear(),o=`${t.getUTCMonth()+1}`.padStart(2,"0");return`${s}-${o}.md`}function Ln(e,t){let n=e.split(/\r?\n/),s=On(n),o=[],d=s,l=e,c=ie(l);while(c>t&&d.length>1){let m=d[0];if(m===void 0)break;o.push(m),d=d.slice(1),l=Mn(n,o),c=ie(l)}if(c<=t)return{evict:o,remaining:l,tokens:c};return{evict:o,remaining:l,tokens:c,shortfall:d.length<=1?`${c} tokens remain against a ${t}-token budget with one note left, so eviction cannot help`:`${c} tokens remain against a ${t}-token budget`}}function Mn(e,t){let n=new Set;for(let s of t)for(let o=s.start;o<s.end;o+=1)n.add(o);return e.filter((s,o)=>!n.has(o)).join(`
39
- `).replace(/\n{3,}/g,`
40
-
41
- `)}async function Cn(e){let t=e.tags.length===0?"":` _(${e.tags.join(", ")})_`,n=`
42
- - **${e.now.toISOString()}**${t} ${e.text}
43
- `;await qe(e.path,n,"utf8");let s=await Sn(e.path,"utf8"),o=Ln(s,e.budget);if(o.evict.length===0)return{file:e.name,evicted:0,archives:[],...o.shortfall===void 0?{}:{shortfall:o.shortfall}};let d=new Map;for(let l of o.evict){let c=Rn(l.text,e.now);d.set(c,[...d.get(c)??[],l.text])}await An(e.archiveDir,{recursive:!0});for(let[l,c]of d)await qe($n(e.archiveDir,l),`${c.join(`
44
- `)}
45
- `,"utf8");return await xn(e.path,o.remaining,"utf8"),{file:e.name,evicted:o.evict.length,archives:[...d.keys()].sort(),...o.shortfall===void 0?{}:{shortfall:o.shortfall}}}var de="local",Ye="memory",ze="notes.md",Dn={spec:{slug:"now",provider:de,summary:"Reports the current date and time.",whenToUse:"you need today's date or the current time — including to work out what 'tomorrow' or 'in three hours' means",whenNotToUse:"the person already told you the date or time; use theirs rather than replacing it with the clock",mutating:!1,tags:["read","time"],parameters:{type:"object",properties:{timezone:{type:"string",description:"IANA name such as Europe/London. Defaults to UTC."},format:{type:"string",description:"iso for a machine-readable timestamp, human for a readable one",enum:["iso","human"],default:"iso"}}}},handler(e,t){let n=t.now(),s=typeof e.timezone==="string"&&e.timezone!==""?e.timezone:"UTC";if(e.format==="human")return`${new Intl.DateTimeFormat("en-GB",{dateStyle:"full",timeStyle:"short",timeZone:s}).format(n)} (${s})`;if(s==="UTC")return n.toISOString();return`${Pn(n,s)} (${s})`}};function Pn(e,t){let n=new Intl.DateTimeFormat("en-CA",{timeZone:t,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,timeZoneName:"longOffset"}).formatToParts(e),s=(d)=>n.find((l)=>l.type===d)?.value??"",o=s("timeZoneName").replace("GMT","");return`${s("year")}-${s("month")}-${s("day")}T${s("hour")}:${s("minute")}:${s("second")}${o===""?"Z":o}`}var Wn={spec:{slug:"memory_write",provider:de,summary:"Saves a short note for later recall.",whenToUse:"the person tells you something durable about themselves or their work that later conversations should know",whenNotToUse:"for anything already in this conversation, for secrets or credentials, or to store your own reasoning",mutating:!0,tags:["write","memory"],parameters:{type:"object",properties:{text:{type:"string",description:"The note, in one or two sentences."},tags:{type:"array",items:{type:"string"},description:"Optional labels."}},required:["text"]}},async handler(e,t){let n=typeof e.text==="string"?e.text.trim():"",s=Array.isArray(e.tags)?e.tags.map((u)=>String(u)):[],o=t.now().toISOString(),d=s.length===0?"":` _(${s.join(", ")})_`,l=`
46
- - **${o}**${d} ${n}
47
- `,c=t.writeTarget;if(c?.mode==="refused")throw we(c.name,c.reason??"none");if(c?.path!==void 0){if(c.budget!==void 0&&t.memoryDir!==void 0&&c.eviction==="oldest"){let u=await Cn({path:c.path,name:c.name,budget:c.budget,archiveDir:t.memoryDir,text:n,tags:s,now:t.now()});if(u.shortfall!==void 0)return`Saved to ${u.file}, but it is still over budget: ${u.shortfall}. Ask the person to raise the budget or shorten the file — the agent will not load until they do.`;if(u.evicted===0)return`Saved to ${u.file}.`;return`Saved to ${u.file}. Moved ${u.evicted} older ${u.evicted===1?"note":"notes"} into ${u.archives.join(", ")}, still searchable.`}if(await Xe(c.path,l,"utf8"),c.budget!==void 0){let u=ie(await _n(c.path,"utf8"))-c.budget;if(u>0)return`Saved to ${c.name}, which is now ${u} tokens over its ${c.budget}-token budget. The agent will not load until that is fixed: add \`eviction: oldest\` to its frontmatter so older notes move to the memory directory, or raise the budget.`}return`Saved to ${c.name}.`}let m=Ge(t.dir,Ye);return await En(m,{recursive:!0}),await Xe(Ge(m,ze),l,"utf8"),`Saved to ${Ye}/${ze}.`}},Hn=1200,Xn=Hn*3,Gn={spec:{slug:"artifact_read",provider:de,summary:"Reads back a tool result that compaction replaced with a pointer.",whenToUse:"a compaction marker in this conversation names an id, and you need the tool result it replaced",whenNotToUse:"for anything still written out in the conversation, or to explore — every id comes from a marker, so there is nothing to browse",mutating:!1,tags:["read","context"],parameters:{type:"object",properties:{id:{type:"string",description:"The id printed inside the compaction marker, copied character for character."},from:{type:"integer",description:"Character offset to continue from. Omit for the beginning; a truncated reply says the number to pass."}},required:["id"]}},async handler(e,t){let n=typeof e.id==="string"?e.id.trim():"",s=typeof e.from==="number"&&e.from>0?Math.floor(e.from):0;if(t.readArtifact===void 0)throw be();let o=await t.readArtifact(n);if(o===void 0)throw ve(n);let d=o.slug===void 0?"observation":`${o.slug} observation`,l=o.content.slice(s,s+Xn),c=s+l.length,m=`Compacted ${d}, ${o.tokens} tokens${s===0?"":`, from character ${s}`}:`;if(c>=o.content.length)return`${m}
48
- ${l}`;return`${m}
49
- ${l}
50
-
51
- [cut here — ${o.content.length-c} characters remain; continue with artifact_read(id, from: ${c})]`}};var qn=[Dn,Wn,Gn],Ao=qn.map((e)=>e.spec.slug);function Jn(e){let t=e.providers??{},n=Object.keys(t),s=e.provider,o=e.providerConfig??{};if(n.length>0&&(s!==void 0||Object.keys(o).length>0))throw ye(n,s);if(s!==void 0)return{selections:[{id:s,config:o,legacy:!0}],warnings:[{code:"tools_provider_deprecated",message:`tools.provider is deprecated; "${s}" was loaded as tools.providers.${s}.`,hint:`Rewrite it as:
52
- tools:
53
- providers:
54
- ${s}: { … the contents of providerConfig … }
55
- The scalar permits exactly one provider, which is why an agent could not have the shell and the web at the same time. It still works and will keep working for now; nothing about the resolved catalogue changes.`,field:"tools.provider"}]};let d=n.map((l)=>({id:l,config:t[l]??{},legacy:!1}));if(Object.keys(o).length>0)return{selections:d,warnings:[{code:"tools_provider_config_orphaned",message:`tools.providerConfig has ${Object.keys(o).length} setting(s) and no tools.provider names a provider to apply them to, so they do nothing.`,hint:"Move them into the matching tools.providers.<id> block and delete tools.providerConfig. Reported rather than ignored: a configuration that looks applied and is not is worse than one that fails.",field:"tools.providerConfig"}]};return{selections:d,warnings:[]}}var Ve=new Map;function st(e){let t=Ve.get(e);if(t!==void 0)return t;let n;try{n=new Intl.DateTimeFormat("en-US",{timeZone:e,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch(s){throw new y({code:"schedule_timezone_unknown",message:`"${e}" is not a timezone this runtime recognises.`,hint:"Use an IANA name such as Asia/Dhaka, Europe/London or America/Sao_Paulo — not an abbreviation like BST and not a UTC offset. Omit the field to use the TZ environment variable, then UTC.",field:"timezone",cause:s})}return Ve.set(e,n),n}function Zn(e){st(e)}function G(e,t){let n=st(e).formatToParts(new Date(t)),s=(c)=>{let m=n.find((u)=>u.type===c);return m===void 0?0:Number(m.value)},o=s("year"),d=s("month"),l=s("day");return{year:o,month:d,day:l,hour:s("hour"),minute:s("minute"),second:s("second"),weekday:new Date(Date.UTC(o,d-1,l)).getUTCDay()}}function Qn(e,t){return G(e,t)}function Je(e,t){let n=G(e,t);return Date.UTC(n.year,n.month-1,n.day,n.hour,n.minute,n.second)-(t-t%1000)}function es(e,t){let n=Date.UTC(t.year,t.month-1,t.day,t.hour,t.minute,t.second),s=n-Je(e,n);s=n-Je(e,s);let o=G(e,s);if(!(o.year===t.year&&o.month===t.month&&o.day===t.day&&o.hour===t.hour&&o.minute===t.minute&&o.second===t.second))return;let l=s-3600000,c=G(e,l);return c.year===t.year&&c.month===t.month&&c.day===t.day&&c.hour===t.hour&&c.minute===t.minute&&c.second===t.second?l:s}function ts(){return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}var ns=1462,ot=["jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"],ss=["sun","mon","tue","wed","thu","fri","sat"],O={second:{min:0,max:59,label:"second"},minute:{min:0,max:59,label:"minute"},hour:{min:0,max:23,label:"hour"},dayOfMonth:{min:1,max:31,label:"day of month"},month:{min:1,max:12,names:ot,label:"month"},dayOfWeek:{min:0,max:7,names:ss,label:"day of week"}};function x(e,t,n,s){throw new y({code:"schedule_cron_malformed",message:`"${e}" is not a valid cron expression: ${t}`,hint:n,field:s})}function te(e,t,n,s){let o=t.names?.indexOf(e.toLowerCase());if(o!==void 0&&o!==-1)return o+(t.names===ot?1:0);if(!/^\d+$/.test(e))x(n,`"${e}" is not a ${t.label}.`,t.names===void 0?`The ${t.label} field takes numbers ${t.min}-${t.max}, ranges, steps and comma lists.`:`The ${t.label} field takes ${t.min}-${t.max} or a name (${t.names.slice(0,3).join(", ")}…).`,s);let d=Number(e);if(d<t.min||d>t.max)x(n,`${d} is outside the ${t.label} range ${t.min}-${t.max}.`,`Check the field order: ${t.label==="second"?"second minute hour day-of-month month day-of-week":"minute hour day-of-month month day-of-week"}.`,s);return d}function R(e,t,n,s){let o=new Set,d=!0;for(let l of e.split(",")){let c=l.trim();if(c==="")x(n,"an empty entry in a comma list.","Remove the stray comma.",s);let[m="",u]=c.split("/",2),k=u===void 0?1:Number(u);if(u!==void 0&&(!/^\d+$/.test(u)||k<1))x(n,`"${u}" is not a step.`,"A step is a whole number above zero, as in */15.",s);let p,w;if(m==="*"){if(p=t.min,w=t.max,k===1)d=!1}else if(m.includes("-")){let[b="",T=""]=m.split("-",2);if(p=te(b,t,n,s),w=te(T,t,n,s),p>w)x(n,`the range ${m} runs backwards.`,"Write the lower bound first, or use a comma list to wrap around.",s)}else p=te(m,t,n,s),w=u===void 0?p:t.max;for(let b=p;b<=w;b+=k)o.add(b)}if(o.size===0)x(n,"it matches nothing.","Every field must admit at least one value.",s);return{values:o,restricted:d}}function rs(e,t){let n=e.trim();if(n.startsWith("@"))x(n,"macros are not supported.",'Write the fields out — @daily is "0 0 * * *", @hourly is "0 * * * *", @weekly is "0 0 * * 0". For a plain interval use kind: every with an expression like 24h.',t);let s=n.split(/\s+/).filter((W)=>W!=="");if(s.length!==5&&s.length!==6)x(n,`it has ${s.length} field${s.length===1?"":"s"}, not 5 or 6.`,"Five fields are minute hour day-of-month month day-of-week. A sixth leading field is seconds.",t);let o=s.length===6,[d,l,c,m,u,k]=o?s:["0",...s],p=R(d??"0",O.second,n,t),w=R(l??"",O.minute,n,t),b=R(c??"",O.hour,n,t),T=R(m??"",O.dayOfMonth,n,t),E=R(u??"",O.month,n,t),A=R(k??"",O.dayOfWeek,n,t),ue=new Set;for(let W of A.values)ue.add(W===7?0:W);return{seconds:p.values,minutes:w.values,hours:b.values,daysOfMonth:T.values,months:E.values,daysOfWeek:ue,domRestricted:T.restricted,dowRestricted:A.restricted,source:n}}function os(e,t,n){let s=e.daysOfMonth.has(t),o=e.daysOfWeek.has(n);if(e.domRestricted&&e.dowRestricted)return s||o;if(e.domRestricted)return s;if(e.dowRestricted)return o;return!0}function Ze(e,t,n,s){let o=new Date(Date.UTC(e,t-1,n+s));return[o.getUTCFullYear(),o.getUTCMonth()+1,o.getUTCDate()]}function is(e,t,n){return new Date(Date.UTC(e,t-1,n)).getUTCDay()}function D(e,t,n){let s=Qn(n,t+1000),o=new Date(Date.UTC(s.year,s.month-1,s.day+ns)),[d,l,c]=[s.year,s.month,s.day],m=!0;while(Date.UTC(d,l-1,c)<=o.getTime()){if(!e.months.has(l)){[d,l,c]=l===12?[d+1,1,1]:[d,l+1,1],m=!1;continue}if(!os(e,c,is(d,l,c))){[d,l,c]=Ze(d,l,c,1),m=!1;continue}for(let u of[...e.hours].sort((k,p)=>k-p)){if(m&&u<s.hour)continue;for(let k of[...e.minutes].sort((p,w)=>p-w)){if(m&&u===s.hour&&k<s.minute)continue;for(let p of[...e.seconds].sort((w,b)=>w-b)){if(m&&u===s.hour&&k===s.minute&&p<s.second)continue;let w=es(n,{year:d,month:l,day:c,hour:u,minute:k,second:p});if(w!==void 0)return w}}}[d,l,c]=Ze(d,l,c,1),m=!1}return}var as=/^(\d+)(s|m|h|d)$/,ds={s:1000,m:60000,h:3600000,d:86400000},ls=1000,cs=315360000000;function us(e,t){let n=as.exec(e.trim());if(n===null)throw new y({code:"schedule_duration_malformed",message:`"${e}" is not a duration.`,hint:"A duration is a whole number and one unit: 90s, 15m, 2h, 7d. There is no combined form — write 90m rather than 1h30m.",field:t});let s=Number(n[1]),o=n[2]??"",d=s*(ds[o]??0);if(d<ls)throw new y({code:"schedule_duration_too_small",message:`"${e}" is under the one-second minimum.`,hint:"An interval below a second is a busy loop rather than a schedule. If the intent is to run continuously, a schedule is the wrong mechanism.",field:t});if(d>cs)throw new y({code:"schedule_duration_too_large",message:`"${e}" is over the ten-year maximum.`,hint:"An interval this long is almost always a unit typo — check whether d was meant where h was written.",field:t});return{ms:d,source:e.trim()}}var hs=315360000000,fs=900000,ne=1000;function it(e){let t=e.timezone??ts();Zn(t);let n=e.expr.trim();if(e.kind==="cron"){let o=rs(n,e.field);if(D(o,e.now,t)===void 0)throw new y({code:"schedule_cron_unsatisfiable",message:`"${n}" never matches a real date.`,hint:"The expression parses but names a day that does not occur — 30 February, or a weekday-and-date pair that never coincide. Checked over four years, so a leap-year schedule like 0 3 29 2 * is accepted.",field:e.field});return{kind:"cron",spec:o,zone:t,source:n}}if(e.kind==="every")return{kind:"every",every:us(n,e.field),zone:t,source:n};let s=Date.parse(n);if(Number.isNaN(s))throw new y({code:"schedule_at_malformed",message:`"${n}" is not an ISO 8601 instant.`,hint:"Write a full timestamp with an offset, as in 2026-12-25T09:00:00+06:00 or 2026-12-25T03:00:00Z. A bare date has no time of day.",field:e.field});if(s>e.now+hs)throw new y({code:"schedule_at_too_far",message:`${n} is more than ten years away.`,hint:"A one-shot this far out is almost always a year typo. Ten years is the documented bound.",field:e.field});return{kind:"at",at:s,zone:t,source:n}}function ms(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619)>>>0;return t}function ps(e,t){if(t===void 0||t<=0)return 0;let n=Math.min(Math.floor(t/10),fs);return n<=0?0:ms(e)%n}function gs(e,t){if(e.kind==="every")return e.every.ms;if(e.kind==="at")return;let n=D(e.spec,t,e.zone);if(n===void 0)return;let s=D(e.spec,n,e.zone);return s===void 0?void 0:s-n}function ys(e,t,n,s,o={}){if(e.kind==="at"){if(o.consumed===!0)return{runAt:void 0,anchor:void 0,missed:0,missedCapped:!1,late:!1};if(e.at<=s)return{runAt:s,anchor:e.at,missed:0,missedCapped:!1,late:!0};return{runAt:e.at,anchor:e.at,missed:0,missedCapped:!1,late:!1}}let d=ps(t,gs(e,n));if(e.kind==="every"){let u=s-n,k=u<=0?0:Math.floor(u/e.every.ms),p=Math.min(k,ne),w=k+1,b=n+w*e.every.ms;return{runAt:b+d,anchor:b,missed:p,missedCapped:k>ne,late:!1}}let l=n,c=0,m=!1;for(;;){let u=D(e.spec,l,e.zone);if(u===void 0)return{runAt:void 0,anchor:void 0,missed:c,missedCapped:m,late:!1};if(u+d>s)return{runAt:u+d,anchor:u,missed:c,missedCapped:m,late:!1};if(l=u,c+=1,c>=ne){m=!0;let k=D(e.spec,s,e.zone);return{runAt:k===void 0?void 0:k+d,anchor:k,missed:c,missedCapped:!0,late:!1}}}}function ws(e,t,n){let s=[],o=Array.isArray(e.schedules)?e.schedules:[],d=new Set((Array.isArray(e.channels)?e.channels:[]).map((u)=>u!==null&&typeof u==="object"&&!Array.isArray(u)?u.id:void 0).filter((u)=>typeof u==="string")),l=new Set([...oe,...Ke(t.model)]),c=new Set,m=new Set;for(let[u,k]of o.entries()){if(k===null||typeof k!=="object"||Array.isArray(k))continue;let p=k,w=typeof p.id==="string"?p.id:`[${u}]`;if(m.has(w))s.push({code:"schedule_id_duplicate",message:`Two schedules share the id "${w}".`,hint:"A schedule id is the key reconciliation matches on and the segment of its session key, so it must be unique within an agent.",field:`schedules[${u}].id`});m.add(w);let b=p.deliver;if(b===void 0)s.push({code:"schedule_missing_delivery",message:`Schedule "${w}" has no delivery target.`,hint:'Set deliver to { channel, to }, or the literal "none" to return results only via the event stream.',field:`schedules[${u}].deliver`});else if(b!=="none"&&typeof b==="object"&&!Array.isArray(b)){let A=b.channel;if(typeof A==="string"&&!d.has(A))s.push({code:"schedule_delivery_channel_unknown",message:`Schedule "${w}" delivers to "${A}", which is not a channel id on this agent.${d.size===0?" The agent declares no channels.":` Declared: ${[...d].join(", ")}.`}`,hint:`A delivery target names a channel's id, not its type. Use deliver: "none" to return results through the event stream instead.`,field:`schedules[${u}].deliver.channel`})}let T=p.role;if(typeof T==="string"){if(c.add(T),!l.has(T))s.push({code:"schedule_role_unknown",message:`Schedule "${w}" names the model role "${T}", which is not declared under model:. Declared: ${[...l].join(", ")}.`,hint:"Add the role under model:, or point the schedule at one of the declared roles. Omit role entirely to use main.",field:`schedules[${u}].role`})}let E=t.schedules[u];if(E!==void 0)try{it({id:E.id,kind:E.kind,expr:E.expr,timezone:E.timezone,now:n,field:`schedules[${u}].expr`})}catch(A){if(!(A instanceof z))throw A;s.push(A.toDetail())}}for(let u of Ke(t.model)){if(c.has(u))continue;s.push({code:"model_role_unreferenced",message:`model.${u} is declared but no schedule names it, so nothing will ever use it.`,hint:`If "${u}" was meant to be one of ${oe.join(", ")}, it is misspelled — and the misspelled one is silently falling back to main. Otherwise point a schedule at it with role: ${u}, or remove it.`,field:`model.${u}`})}return s}function at(e){if(typeof e!=="string")return String(e);let t=/^[A-Za-z0-9_./@~-]+$/.test(e),n=/^[A-Za-z0-9_./]/.test(e);if(!t||!n)return JSON.stringify(e);try{return F(e)===e?e:JSON.stringify(e)}catch{return JSON.stringify(e)}}function j(e){return e.length-e.trimStart().length}function le(e){let t=e.trim();return t===""||t.startsWith("#")}function Qe(e,t,n,s){let o=new RegExp(`^\\s{${n}}${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*:`);for(let d=s;d<e.length;d+=1){let l=e[d]??"";if(le(l))continue;if(j(l)<n)return;if(j(l)===n&&o.test(l))return d}return}function se(e,t,n){let s=t;for(let o=t+1;o<e.length;o+=1){let d=e[o]??"";if(le(d))continue;if(j(d)<=n)break;s=o}return s}function bs(e){let t;for(let n=0;n<e.length;n+=1){let s=e[n];if(t!==void 0){if(s===t)t=void 0;continue}if(s==='"'||s==="'"){t=s;continue}if(s!=="#"||n===0||!/\s/.test(e[n-1]??""))continue;let o=n;while(o>0&&/\s/.test(e[o-1]??""))o-=1;return e.slice(o)}return""}function ce(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function L(e,t,n){let s=" ".repeat(n);if(Array.isArray(t)){if(t.length===0)return[`${s}${e}: []`];return[`${s}${e}:`,...t.flatMap((o)=>vs(o,n+2))]}if(ce(t)){let o=Object.entries(t);if(o.length===0)return[`${s}${e}: {}`];return[`${s}${e}:`,...o.flatMap(([d,l])=>L(d,l,n+2))]}return[`${s}${e}: ${at(t)}`]}function vs(e,t){let n=" ".repeat(t);if(!ce(e))return[`${n}- ${at(e)}`];let s=Object.entries(e);if(s.length===0)return[`${n}- {}`];let o=s.flatMap(([c,m])=>L(c,m,t+2)),[d,...l]=o;return[`${n}- ${(d??"").trimStart()}`,...l]}function ks(e,t,n){if(t.length===0)return;let s=e.split(`
56
- `),o=0,d=0,l,c=0;for(;c<t.length-1;c+=1){let p=Qe(s,t[c]??"",d,o);if(p===void 0)break;l=p,o=p+1;let w=s.slice(p+1).find((b)=>!le(b)&&j(b)>d);if(w===void 0)return;d=j(w)}if(c<t.length-1){if(l===void 0)return;let p=se(s,l,d-1)+1;return[...s.slice(0,p),...dt(t.slice(c),n,d),...s.slice(p)].join(`
57
- `)}let m=t[t.length-1]??"",u=Qe(s,m,d,o);if(u!==void 0){let p=s[u]??"",w=Array.isArray(n)||ce(n)?"":bs(p),b=se(s,u,d),T=L(m,n,d);if(w!=="")T[0]=`${T[0]}${w}`;return[...s.slice(0,u),...T,...s.slice(b+1)].join(`
58
- `)}if(l===void 0)return;let k=se(s,l,d-1)+1;return[...s.slice(0,k),...L(m,n,d),...s.slice(k)].join(`
59
- `)}function dt(e,t,n){let[s,...o]=e;if(s===void 0)return[];if(o.length===0)return L(s,t,n);return[`${" ".repeat(n)}${s}:`,...dt(o,t,n+Ts)]}var Ts=2;function Es(e,t,n){let s=e.split(`
60
- `),o=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),d=new RegExp(`^#\\s*${o}\\s*:`),l=s.findIndex((u)=>d.test(u));if(l===-1)return;let c=l;while(/^#\s{2,}\S/.test(s[c+1]??""))c+=1;let m=/^#\s*Phase \d/.test(s[l-1]??"")?l-1:l;return[...s.slice(0,m),...L(t,n,0),...s.slice(c+1)].join(`
61
- `)}function _s(e,t){let n=[...t.path],s=n.join("."),o=lt(U(e),n),d=ks(e,n,t.value)??t.fallback?.(e)??(n.length===1?Es(e,n[0]??"",t.value):void 0),l;if(d===void 0){let p=U(e);p.setIn(n,t.value),l=String(p)}else l=d;let c=U(l);if(c.errors.length>0)throw X(s,`the result is not valid YAML — ${c.errors[0]?.message??"unparseable"}`);let m=wn.safeParse(c.toJS());if(!m.success){let p=m.error.issues[0];throw X(s,`${p?.path.join(".")??s}: ${p?.message??"does not fit the schema"}`)}let k=ws(c.toJS(),m.data,Date.now())[0];if(k!==void 0)throw X(s,`${k.message} ${k.hint}`);try{Jn(m.data.tools)}catch(p){throw X(s,p instanceof Error?p.message:"the providers block does not resolve")}return{next:l,before:o,reflowed:d===void 0,manifest:m.data}}async function Zt(e){let t;try{t=await Yn(e.file,"utf8")}catch(s){throw As(e.file,s)}let n=_s(t,e);return await Vn(e.file,n.next,"utf8"),{...n,after:e.value}}function Vt(e){let t=e.trim();if(t==="")return"";let n=U(t);if(n.errors.length>0)throw new z({code:"manifest_value_unreadable",message:`Cannot read ${JSON.stringify(e)} as a value.`,hint:'A bare word, a number, true or false, a list as ["a", "b"], or a map as {k: v}. Quote anything containing a colon or a "#".'});return n.toJS()}function ro(e,t){return lt(U(e),t)}function lt(e,t){let n=e.getIn([...t],!1);if(n===void 0||n===null)return;return $e(n)||Ae(n)?n.toJS(e):n}function As(e,t){return new z({code:"manifest_edit_unreadable",message:`Cannot read the manifest at ${e} to change it.`,hint:"Check the path and file permissions. Nothing was written.",cause:t})}function X(e,t){return new z({code:"manifest_edit_invalid",message:`Setting ${e} would make the manifest invalid: ${t}`,hint:"Nothing was written. Check the value's shape — a list is [a, b], a map is {k: v} — against the field this path names."})}var Le=[{path:"tools.local",means:"built-in tools: now, memory_write, artifact_read",agentListed:!0},{path:"tools.providers",means:"where tools come from, as a map — {system: {}} for shell and files, {web: {backend: tavily, apiKeyEnv: TAVILY_API_KEY}} for the internet. Several at once",toAgent:"A writeRoots key inside is refused",agentListed:!0},{path:"tools.pinned",means:"the tools from those providers this agent may call",agentListed:!0},{path:"tools.policy.allow",means:'rules permitting a call: "exec", or narrower like "exec(git *)". Also what lets a mutating tool run in a turn that has read untrusted content',agentListed:!0},{path:"tools.policy.deny",means:"rules refusing a call. Beats any allow rule",toAgent:"Replacing these is refused: it is the one edit whose only purpose is to remove a restriction someone set",agentListed:!0,confirm:"Deny rules are the restrictions that beat every allow rule. Replacing them removes whatever was deliberately put out of reach."},{path:"tools.policy.mode",means:"allow | ask | deny — for calls no rule mentions",agentListed:!0},{path:"tools.untrusted.onMutate",means:"refuse | confirm | allow — what happens when a tool that changes something is asked for in a turn that has read outside content",toAgent:'Cannot be set to "allow"',agentListed:!0,confirm:'Setting this to "allow" turns off the check that stops text from outside the conversation driving a tool that changes things. A fetched page that says "now delete the backups" would be acted on.'},{path:"tools.dialect",means:"nlt | native — how tool calls are written",agentListed:!0},{path:"model.main.id",means:"the model this agent runs on",agentListed:!0},{path:"model.main.temperature",means:"0 to 2",agentListed:!0},{path:"limits.maxSteps",means:"tool calls allowed in one turn",agentListed:!0},{path:"limits.toolTimeoutMs",means:"how long any single tool may take",agentListed:!0},{path:"context.observationMaxTokens",means:"how much of a tool's output reaches the model",agentListed:!0},{path:"channels",means:"how people reach this agent, as a list — [{type: telegram, id: tg, tokenEnv: TELEGRAM_BOT_TOKEN, mode: longpoll}]. The token goes in the .env",toAgent:"The token itself goes in the .env, which only a person can write. allowFrom is refused here: who may talk to you is not yours to decide",agentListed:!0},{path:"delivery",means:"where a reply goes when a turn has no origin — {default: tg}. Names a channel id, not a channel type",agentListed:!0},{path:"schedules",means:'what runs unattended, as a list — [{id, kind: cron|every|at, expr, task, deliver}]. expr is a 5- or 6-field cron, a duration like 15m, or an ISO instant; deliver is {channel, to} or the literal "none"',toAgent:"Only `serve` fires these; under `run` they are validated and listed and no timer starts. deliver.to is the address a reply is *sent* to — on Telegram the numeric chat id, never an @handle, which addresses a channel and not a person. It is the id inbound messages arrive on, so read it off your own session keys (tg:<id>); allowFrom holds handles and confers nothing here. Set role to name a model other than main. The whole list is replaced, so read it first",agentListed:!0},{path:"server.enabled",means:"true | false — serve the HTTP API on 127.0.0.1",toAgent:"host and tokenEnv are refused: binding anywhere reachable is not yours to decide",agentListed:!0},{path:"server.port",means:"port for the HTTP API",agentListed:!0},{path:"channels[].allowFrom",means:"who may talk to this agent through a channel. Empty or absent refuses everyone — a bot that is connected, healthy and answering nobody is almost always this",agentListed:!1,via:"config allow"},{path:"server.host",means:"the address the HTTP API binds. 127.0.0.1 is local only; anything else is reachable from the network",agentListed:!1},{path:"server.tokenEnv",means:"the env var holding the bearer token the API requires. Without it the API is unauthenticated",agentListed:!1},{path:"tools.providers.<id>.writeRoots",means:"the directories a file tool may write to, for that provider. Nothing outside them is writable — and this binds file tools only, never exec, which carries its target inside a shell string",agentListed:!1}];function oo(e){return Le.find((t)=>t.path===e)}var pr=Le.filter((e)=>e.agentListed).map((e)=>e.path),Yt=Le.filter((e)=>e.via===void 0&&!e.path.includes("<")&&!e.path.includes("[")).map((e)=>e.path);var Lo=["Summarise the conversation above for your own future reference. You are writing notes to yourself, not a report for a person.","","The person's own requests are preserved verbatim below your summary, so do not restate them.","Keep: decisions taken and why, facts established by tool results, and anything still outstanding.","Drop: pleasantries, your own reasoning, and anything already superseded.","Write plain prose under 300 words. No headings, no preamble, no closing summary.","End with one line naming what this summary does not cover, so a later step knows to ask rather than assume."].join(`
62
- `);var Ss="schedule";function so(e,t,n){if(e.startsWith("shared:")){let s=e.slice(7);if(s!=="")return s}return Rt({channel:Ss,peerId:t,thread:n})}function io(e){let t=nt.safeParse(e.body);if(!t.success){let c=t.error.issues[0];throw new y({code:"schedule_invalid",message:`Schedule rejected: ${c?.path.join(".")??"body"} ${c?.message??"is invalid"}.`,hint:"A schedule needs id, kind (cron|every|at), expr, task and deliver. See docs/02-SPEC-MANIFEST.md.",...c?.path.length===void 0||c.path.length===0?{}:{field:c.path.join(".")}})}let n=t.data;if(n.deliver!=="none"){if(!e.channelIds.includes(n.deliver.channel))throw new y({code:"schedule_delivery_channel_unknown",message:`Schedule "${n.id}" delivers to "${n.deliver.channel}", which is not a channel id on this agent.${e.channelIds.length===0?" The agent declares no channels.":` Declared: ${e.channelIds.join(", ")}.`}`,hint:`A delivery target names a channel's id, not its type. Use deliver: "none" to return results through the event stream instead.`,field:"deliver.channel"})}if(n.role!==void 0&&!e.roleNames.includes(n.role))throw new y({code:"schedule_role_unknown",message:`Schedule "${n.id}" names the model role "${n.role}", which is not declared under model:. Declared: ${e.roleNames.join(", ")}.`,hint:"Add the role under model: in the manifest, or point the schedule at one of the declared roles. Omit role entirely to use main.",field:"role"});let s=it({id:n.id,kind:n.kind,expr:n.expr,timezone:n.timezone,now:e.now,field:"expr"}),o=new Date(e.now).toISOString(),d=ys(s,n.id,e.now,e.now),l=n.deliver==="none"?void 0:n.deliver;return{agentId:e.agentId,id:n.id,kind:n.kind,expr:n.expr,...n.timezone===void 0?{}:{timezone:n.timezone},task:n.task,...l===void 0?{}:{deliverChannel:l.channel,deliverTo:l.to},sessionMode:n.session,...n.role===void 0?{}:{role:n.role},enabled:n.enabled,origin:e.origin,anchorAt:d.anchor===void 0?o:new Date(d.anchor).toISOString(),nextRunAt:d.runAt===void 0?void 0:new Date(d.runAt).toISOString(),sourcePath:"",now:o}}var Mo=new Set("a an and are as at be but by do does for from had has have he her his i if in is it its me my not of on or our she that the their them then there they this to was we were what when which who will with you your would could should im ive dont its ill".split(" "));
63
- export{Q,rt,fe,z,y,f,qt,Pe,Se,Fn,Un,jn,zn,Bn,Kn,Xr,Gt,Jr,Qr,eo,mr,to,Me,no,Zt,Vt,ro,Le,oo,pr,Yt,so,io};
64
-
65
- //# debugId=3DCD48EDAA86987664756E2164756E21
66
- //# sourceMappingURL=index-5t6wahx8.js.map