dispach 0.2.4 → 0.2.13

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 (187) hide show
  1. package/README.md +32 -33
  2. package/dist/APEv2Parser-rt8hyadd.js +5 -0
  3. package/dist/{FlacParser-8xprykrh.js.map → APEv2Parser-rt8hyadd.js.map} +1 -1
  4. package/dist/{AiffParser-ns1y9f0g.js → AiffParser-gvpmtb2e.js} +3 -3
  5. package/dist/{AiffParser-ns1y9f0g.js.map → AiffParser-gvpmtb2e.js.map} +1 -1
  6. package/dist/{App-wkpkwgjt.js → App-18dvbyev.js} +8 -8
  7. package/dist/{App-wkpkwgjt.js.map → App-18dvbyev.js.map} +1 -1
  8. package/dist/{AsfParser-bae2a1yf.js → AsfParser-h9zyh6cx.js} +3 -3
  9. package/dist/{AsfParser-bae2a1yf.js.map → AsfParser-h9zyh6cx.js.map} +1 -1
  10. package/dist/{ConfigEditor-hy9jtas3.js → ConfigEditor-444m13ta.js} +3 -3
  11. package/dist/{ConfigEditor-hy9jtas3.js.map → ConfigEditor-444m13ta.js.map} +1 -1
  12. package/dist/{DsdiffParser-s0zvxnfa.js → DsdiffParser-gxqv4gn1.js} +3 -3
  13. package/dist/{DsdiffParser-s0zvxnfa.js.map → DsdiffParser-gxqv4gn1.js.map} +1 -1
  14. package/dist/{DsfParser-90mvzt4v.js → DsfParser-sndt4jbk.js} +3 -3
  15. package/dist/{DsfParser-90mvzt4v.js.map → DsfParser-sndt4jbk.js.map} +1 -1
  16. package/dist/FlacParser-rmkpvf9e.js +5 -0
  17. package/dist/{APEv2Parser-x13n424p.js.map → FlacParser-rmkpvf9e.js.map} +1 -1
  18. package/dist/{KeyProbe-fk5krzks.js → KeyProbe-6t531sy6.js} +3 -3
  19. package/dist/{KeyProbe-fk5krzks.js.map → KeyProbe-6t531sy6.js.map} +1 -1
  20. package/dist/{MP4Parser-nmvbkq21.js → MP4Parser-87xfsck4.js} +3 -3
  21. package/dist/{MP4Parser-nmvbkq21.js.map → MP4Parser-87xfsck4.js.map} +1 -1
  22. package/dist/{MatroskaParser-tsmz2qfq.js → MatroskaParser-7krspfgx.js} +3 -3
  23. package/dist/{MatroskaParser-tsmz2qfq.js.map → MatroskaParser-7krspfgx.js.map} +1 -1
  24. package/dist/{MpegParser-y5fjpaz9.js → MpegParser-jcs35q0h.js} +3 -3
  25. package/dist/{MpegParser-y5fjpaz9.js.map → MpegParser-jcs35q0h.js.map} +1 -1
  26. package/dist/{MusepackParser-544q0byg.js → MusepackParser-d4zfnzk3.js} +3 -3
  27. package/dist/{MusepackParser-544q0byg.js.map → MusepackParser-d4zfnzk3.js.map} +1 -1
  28. package/dist/{OggParser-v77rbjnt.js → OggParser-fbspjs7v.js} +3 -3
  29. package/dist/{OggParser-v77rbjnt.js.map → OggParser-fbspjs7v.js.map} +1 -1
  30. package/dist/{Picker-32m79nmp.js → Picker-x6aj42tc.js} +3 -3
  31. package/dist/{Picker-32m79nmp.js.map → Picker-x6aj42tc.js.map} +1 -1
  32. package/dist/{SessionPicker-9p06npt5.js → SessionPicker-pngdv97x.js} +3 -3
  33. package/dist/{SessionPicker-9p06npt5.js.map → SessionPicker-pngdv97x.js.map} +1 -1
  34. package/dist/{SkillBrowser-ezdx3xsh.js → SkillBrowser-3mnzkakr.js} +3 -3
  35. package/dist/{SkillBrowser-ezdx3xsh.js.map → SkillBrowser-3mnzkakr.js.map} +1 -1
  36. package/dist/{WavPackParser-k623m0hk.js → WavPackParser-0x9z4466.js} +3 -3
  37. package/dist/{WavPackParser-k623m0hk.js.map → WavPackParser-0x9z4466.js.map} +1 -1
  38. package/dist/{WaveParser-nj4p1vx8.js → WaveParser-31b6qtef.js} +3 -3
  39. package/dist/{WaveParser-nj4p1vx8.js.map → WaveParser-31b6qtef.js.map} +1 -1
  40. package/dist/{WizardApp-p350qspw.js → WizardApp-c42wc116.js} +3 -3
  41. package/dist/{WizardApp-p350qspw.js.map → WizardApp-c42wc116.js.map} +1 -1
  42. package/dist/{channels-a9zx9yba.js → channels-nf6d8fvx.js} +14 -14
  43. package/dist/{channels-a9zx9yba.js.map → channels-nf6d8fvx.js.map} +1 -1
  44. package/dist/client.d.ts +1 -1
  45. package/dist/client.js +11 -11
  46. package/dist/client.js.map +4 -4
  47. package/dist/{config-3mz4zwsf.js → config-sx40rg8m.js} +21 -21
  48. package/dist/{config-3mz4zwsf.js.map → config-sx40rg8m.js.map} +1 -1
  49. package/dist/{credential-ja7zmd4c.js → credential-vdbkfk65.js} +5 -5
  50. package/dist/{credential-ja7zmd4c.js.map → credential-vdbkfk65.js.map} +1 -1
  51. package/dist/daemon.d.ts.map +1 -1
  52. package/dist/{index-dcy14zdn.js → index-0dcpsfet.js} +5 -5
  53. package/dist/{index-dcy14zdn.js.map → index-0dcpsfet.js.map} +1 -1
  54. package/dist/{index-a1axc952.js → index-1h8s50d9.js} +4 -4
  55. package/dist/{index-a1axc952.js.map → index-1h8s50d9.js.map} +1 -1
  56. package/dist/{index-ayhdn87b.js → index-1hbvhrsj.js} +4 -4
  57. package/dist/{index-ayhdn87b.js.map → index-1hbvhrsj.js.map} +1 -1
  58. package/dist/{index-5gn74n56.js → index-1hfece7s.js} +7 -7
  59. package/dist/{index-5gn74n56.js.map → index-1hfece7s.js.map} +1 -1
  60. package/dist/{index-0dvs3a06.js → index-2h566rtg.js} +4 -4
  61. package/dist/{index-0dvs3a06.js.map → index-2h566rtg.js.map} +1 -1
  62. package/dist/{index-zzpgsbn3.js → index-4fj1k64j.js} +4 -4
  63. package/dist/{index-zzpgsbn3.js.map → index-4fj1k64j.js.map} +1 -1
  64. package/dist/{index-gezqawvw.js → index-4g4smpkk.js} +5 -5
  65. package/dist/{index-gezqawvw.js.map → index-4g4smpkk.js.map} +1 -1
  66. package/dist/index-4gfsf9n8.js +6 -0
  67. package/dist/{index-tc054tcb.js.map → index-4gfsf9n8.js.map} +1 -1
  68. package/dist/{index-mgef1n4e.js → index-5ptbytze.js} +9 -9
  69. package/dist/{index-mgef1n4e.js.map → index-5ptbytze.js.map} +1 -1
  70. package/dist/{index-f6r3h2yh.js → index-5s1cq8np.js} +5 -5
  71. package/dist/{index-f6r3h2yh.js.map → index-5s1cq8np.js.map} +1 -1
  72. package/dist/{index-rqfwd7j5.js → index-659ggfbf.js} +4 -4
  73. package/dist/{index-rqfwd7j5.js.map → index-659ggfbf.js.map} +1 -1
  74. package/dist/index-6ebppx3t.js +6 -0
  75. package/dist/{index-x9nn57kk.js.map → index-6ebppx3t.js.map} +1 -1
  76. package/dist/{index-4j65jp20.js → index-6pym9p8h.js} +6 -6
  77. package/dist/{index-4j65jp20.js.map → index-6pym9p8h.js.map} +1 -1
  78. package/dist/index-9ejax6hp.js +6 -0
  79. package/dist/{index-s0t15ndj.js.map → index-9ejax6hp.js.map} +1 -1
  80. package/dist/{index-86rb86nr.js → index-9hw9j1qg.js} +4 -4
  81. package/dist/{index-86rb86nr.js.map → index-9hw9j1qg.js.map} +1 -1
  82. package/dist/{index-yz0fcxky.js → index-9xhresrg.js} +4 -4
  83. package/dist/{index-yz0fcxky.js.map → index-9xhresrg.js.map} +1 -1
  84. package/dist/{index-2td5h856.js → index-abm0zyc0.js} +6 -6
  85. package/dist/{index-2td5h856.js.map → index-abm0zyc0.js.map} +1 -1
  86. package/dist/{index-8k8y7edx.js → index-ar5c9d2f.js} +5 -5
  87. package/dist/{index-8k8y7edx.js.map → index-ar5c9d2f.js.map} +1 -1
  88. package/dist/index-bhj4pmrx.js +74 -0
  89. package/dist/index-bhj4pmrx.js.map +13 -0
  90. package/dist/{index-brh25jhq.js → index-brt17yfr.js} +3 -3
  91. package/dist/{index-brh25jhq.js.map → index-brt17yfr.js.map} +1 -1
  92. package/dist/index-bysnsdkd.js +6 -0
  93. package/dist/{index-c6qrcweh.js.map → index-bysnsdkd.js.map} +1 -1
  94. package/dist/{index-kz01jz58.js → index-c74wx9pv.js} +4 -4
  95. package/dist/{index-kz01jz58.js.map → index-c74wx9pv.js.map} +1 -1
  96. package/dist/{index-qj4adnfe.js → index-cm3g4t3r.js} +9 -9
  97. package/dist/{index-qj4adnfe.js.map → index-cm3g4t3r.js.map} +1 -1
  98. package/dist/{index-8mkatm20.js → index-dzp6mc5h.js} +4 -4
  99. package/dist/{index-8mkatm20.js.map → index-dzp6mc5h.js.map} +1 -1
  100. package/dist/{index-b8bfzbfe.js → index-fad09b8c.js} +4 -4
  101. package/dist/{index-b8bfzbfe.js.map → index-fad09b8c.js.map} +1 -1
  102. package/dist/{index-2fw9e5gg.js → index-fvb2dxzn.js} +4 -4
  103. package/dist/{index-2fw9e5gg.js.map → index-fvb2dxzn.js.map} +1 -1
  104. package/dist/index-gpq4agva.js +5 -0
  105. package/dist/{index-635wcsh1.js.map → index-gpq4agva.js.map} +1 -1
  106. package/dist/index-hcpvk5de.js +5 -0
  107. package/dist/{index-7zgjkbb0.js.map → index-hcpvk5de.js.map} +1 -1
  108. package/dist/{index-s0f0s6n5.js → index-jv5t63tp.js} +4 -4
  109. package/dist/{index-s0f0s6n5.js.map → index-jv5t63tp.js.map} +1 -1
  110. package/dist/{index-60h4knj6.js → index-kyz4t0j0.js} +59 -59
  111. package/dist/{index-60h4knj6.js.map → index-kyz4t0j0.js.map} +1 -1
  112. package/dist/{index-7p8d1gf0.js → index-m6r2sxcw.js} +23 -23
  113. package/dist/{index-7p8d1gf0.js.map → index-m6r2sxcw.js.map} +1 -1
  114. package/dist/{index-4fajxhdv.js → index-mhw3d7af.js} +4 -4
  115. package/dist/{index-4fajxhdv.js.map → index-mhw3d7af.js.map} +1 -1
  116. package/dist/{index-h787rq0h.js → index-mk7hrzq7.js} +10 -10
  117. package/dist/{index-h787rq0h.js.map → index-mk7hrzq7.js.map} +1 -1
  118. package/dist/{index-r83jpct7.js → index-n0hqgwad.js} +4 -4
  119. package/dist/{index-r83jpct7.js.map → index-n0hqgwad.js.map} +1 -1
  120. package/dist/{index-k6wq0j4q.js → index-ncb840sk.js} +4 -4
  121. package/dist/{index-k6wq0j4q.js.map → index-ncb840sk.js.map} +1 -1
  122. package/dist/{index-8jejze0z.js → index-ntczmwnf.js} +3 -3
  123. package/dist/{index-8jejze0z.js.map → index-ntczmwnf.js.map} +1 -1
  124. package/dist/{index-ts8a1sdn.js → index-p5gy5s7p.js} +6 -6
  125. package/dist/{index-ts8a1sdn.js.map → index-p5gy5s7p.js.map} +1 -1
  126. package/dist/index-p86w0qjw.js +5 -0
  127. package/dist/{index-pz92ksp8.js.map → index-p86w0qjw.js.map} +1 -1
  128. package/dist/{index-cb45233h.js → index-qhh30m9p.js} +4 -4
  129. package/dist/{index-cb45233h.js.map → index-qhh30m9p.js.map} +1 -1
  130. package/dist/{index-z4adxmzm.js → index-rerdsr3d.js} +5 -5
  131. package/dist/{index-z4adxmzm.js.map → index-rerdsr3d.js.map} +1 -1
  132. package/dist/{index-67sfck4d.js → index-s0mfq8t7.js} +18 -18
  133. package/dist/index-s0mfq8t7.js.map +11 -0
  134. package/dist/{index-9k6qa50r.js → index-s9ybp2r1.js} +6 -6
  135. package/dist/{index-9k6qa50r.js.map → index-s9ybp2r1.js.map} +1 -1
  136. package/dist/index-ss77hvwy.js +1246 -0
  137. package/dist/{index-tv52jhac.js.map → index-ss77hvwy.js.map} +32 -31
  138. package/dist/{index-yy4v9kca.js → index-t9bnt6a1.js} +4 -4
  139. package/dist/{index-yy4v9kca.js.map → index-t9bnt6a1.js.map} +1 -1
  140. package/dist/{index-5zpfz4kb.js → index-w2ss9hn5.js} +7 -7
  141. package/dist/{index-5zpfz4kb.js.map → index-w2ss9hn5.js.map} +1 -1
  142. package/dist/{index-1cagdzqe.js → index-w80shmpv.js} +2 -2
  143. package/dist/index-w8e8qxd4.js +337 -0
  144. package/dist/index-w8e8qxd4.js.map +21 -0
  145. package/dist/{index-xyh98x7p.js → index-z9r4e0yq.js} +4 -4
  146. package/dist/{index-xyh98x7p.js.map → index-z9r4e0yq.js.map} +1 -1
  147. package/dist/{index-039ew35r.js → index-zj87j4j2.js} +4 -4
  148. package/dist/{index-039ew35r.js.map → index-zj87j4j2.js.map} +1 -1
  149. package/dist/{index-446exxcb.js → index-zmerx9rc.js} +7 -7
  150. package/dist/{index-446exxcb.js.map → index-zmerx9rc.js.map} +1 -1
  151. package/dist/{index-nndwx2wp.js → index-zqjtjs7c.js} +39 -39
  152. package/dist/{index-nndwx2wp.js.map → index-zqjtjs7c.js.map} +1 -1
  153. package/dist/index.js +318 -305
  154. package/dist/index.js.map +6 -5
  155. package/dist/lib/launchd.d.ts.map +1 -1
  156. package/dist/lib/service-env.d.ts.map +1 -1
  157. package/dist/lib/templates.d.ts.map +1 -1
  158. package/dist/lib/theme.d.ts.map +1 -1
  159. package/dist/lib/watchdog.d.ts +20 -0
  160. package/dist/lib/watchdog.d.ts.map +1 -0
  161. package/dist/serve.d.ts.map +1 -1
  162. package/dist/skills.d.ts.map +1 -1
  163. package/dist/sources.d.ts.map +1 -1
  164. package/dist/{web-7mdrcb8a.js → web-zvf80ns1.js} +5 -5
  165. package/dist/{web-7mdrcb8a.js.map → web-zvf80ns1.js.map} +1 -1
  166. package/dist/wire.js +11 -11
  167. package/dist/wire.js.map +4 -4
  168. package/dist/wrapper-5zhcdmnk.js +5 -0
  169. package/dist/{wrapper-4hdmdwft.js.map → wrapper-5zhcdmnk.js.map} +1 -1
  170. package/package.json +4 -4
  171. package/dist/APEv2Parser-x13n424p.js +0 -5
  172. package/dist/FlacParser-8xprykrh.js +0 -5
  173. package/dist/index-635wcsh1.js +0 -5
  174. package/dist/index-67sfck4d.js.map +0 -13
  175. package/dist/index-7zgjkbb0.js +0 -5
  176. package/dist/index-c6qrcweh.js +0 -6
  177. package/dist/index-hd5nkwd7.js +0 -74
  178. package/dist/index-hd5nkwd7.js.map +0 -13
  179. package/dist/index-n197qdw1.js +0 -308
  180. package/dist/index-n197qdw1.js.map +0 -21
  181. package/dist/index-pz92ksp8.js +0 -5
  182. package/dist/index-s0t15ndj.js +0 -6
  183. package/dist/index-tc054tcb.js +0 -6
  184. package/dist/index-tv52jhac.js +0 -1252
  185. package/dist/index-x9nn57kk.js +0 -6
  186. package/dist/wrapper-4hdmdwft.js +0 -5
  187. /package/dist/{index-1cagdzqe.js.map → index-w80shmpv.js.map} +0 -0
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
- import{no,ps}from"./index-z4adxmzm.js";import{s}from"./index-ayhdn87b.js";import{Zo,DA}from"./index-446exxcb.js";import{Ne}from"./index-2fw9e5gg.js";import{Box as _,Text as r}from"ink";var B=1;function vn(t,l){let u=Math.max(1,l-B),n=t.value.split(`
3
- `),i=Zo(t),d=[],m=0,a=0;for(let[f,o]of n.entries()){let h=no(o,u),b=f===i.line?ps(o,i.column):-1,c=-1;if(b>=0){c=h.length-1;for(let[p,e]of h.entries())if(b<=e.to){c=p;break}}for(let[p,e]of h.entries()){if(p===c)m=d.length;d.push({start:a+e.from,end:a+e.to,lead:e.lead,text:e.text,caret:p===c?e.lead+Math.max(0,Math.min(b-e.from,e.to-e.from)):void 0})}a+=[...o].length+1}return{rows:d,caretRow:m}}function k(t,l){let u=[...t.text],n=[];for(let[i,d]of u.entries()){let m=i<t.lead?-1:t.start+(i-t.lead),a=l!==void 0&&m>=l.start&&m<l.end,f=t.caret===i,o=n.at(-1);if(o!==void 0&&!f&&!o.caret&&o.selected===a){n[n.length-1]={...o,text:o.text+d};continue}n.push({text:d,selected:a,caret:f})}if(t.caret!==void 0&&t.caret>=u.length)n.push({text:" ",selected:!1,caret:!0});return n}import{jsx as y,jsxs as w}from"react/jsx-runtime";function Ln({editor:t,placeholder:l,secret:u,gutter:n="",maxRows:i,columns:d}){let m=[...n].length,a=" ".repeat(m);if(t.value===""&&l!==void 0&&l!==""){let x=[...l];return w(r,{dimColor:!0,wrap:"truncate",children:[y(r,{color:s.accent,children:n}),y(r,{inverse:!0,children:x[0]??" "}),x.slice(1).join("")]})}let f=DA(t),{rows:o,caretRow:h}=vn(t,Math.max(1,(d??Number.MAX_SAFE_INTEGER)-m)),b=i??o.length,{from:c,to:p}=Ne(o.length,h,Math.max(1,b)),e=c,T=o.length-p;return w(_,{flexDirection:"column",children:[e>0?w(r,{dimColor:!0,wrap:"truncate",children:[a,"… ",e," line",e===1?"":"s"," above"]}):null,o.slice(c,p).map((x,v)=>{let C=c+v,M=u===!0?[...x.text].map(()=>"•"):[...x.text],S=C===c&&e===0?n:a;if(x.caret===void 0&&f===void 0)return w(r,{wrap:"truncate",children:[y(r,{color:s.accent,children:S}),M.join("")]},`row-${C}`);let A=k(x,f),L=0;return w(r,{wrap:"truncate",children:[y(r,{color:s.accent,children:S}),A.map((g)=>{let R=`run-${C}-${L}`;L+=[...g.text].length;let E=u===!0?[...g.text].map(()=>"•").join(""):g.text;if(g.caret)return y(r,{inverse:!0,children:E},R);if(g.selected)return y(r,{backgroundColor:s.selection,children:E},R);return y(r,{children:E},R)})]},`row-${C}`)}),T>0?w(r,{dimColor:!0,wrap:"truncate",children:[a,"… ",T," line",T===1?"":"s"," below"]}):null]})}
4
- export{vn,Ln};
2
+ import{Ao,us}from"./index-rerdsr3d.js";import{s}from"./index-1hbvhrsj.js";import{zo,wA}from"./index-zmerx9rc.js";import{Ne}from"./index-fvb2dxzn.js";import{Box as _,Text as r}from"ink";var B=1;function kn(t,l){let u=Math.max(1,l-B),n=t.value.split(`
3
+ `),i=zo(t),d=[],m=0,a=0;for(let[f,o]of n.entries()){let h=Ao(o,u),b=f===i.line?us(o,i.column):-1,c=-1;if(b>=0){c=h.length-1;for(let[p,e]of h.entries())if(b<=e.to){c=p;break}}for(let[p,e]of h.entries()){if(p===c)m=d.length;d.push({start:a+e.from,end:a+e.to,lead:e.lead,text:e.text,caret:p===c?e.lead+Math.max(0,Math.min(b-e.from,e.to-e.from)):void 0})}a+=[...o].length+1}return{rows:d,caretRow:m}}function k(t,l){let u=[...t.text],n=[];for(let[i,d]of u.entries()){let m=i<t.lead?-1:t.start+(i-t.lead),a=l!==void 0&&m>=l.start&&m<l.end,f=t.caret===i,o=n.at(-1);if(o!==void 0&&!f&&!o.caret&&o.selected===a){n[n.length-1]={...o,text:o.text+d};continue}n.push({text:d,selected:a,caret:f})}if(t.caret!==void 0&&t.caret>=u.length)n.push({text:" ",selected:!1,caret:!0});return n}import{jsx as y,jsxs as w}from"react/jsx-runtime";function vn({editor:t,placeholder:l,secret:u,gutter:n="",maxRows:i,columns:d}){let m=[...n].length,a=" ".repeat(m);if(t.value===""&&l!==void 0&&l!==""){let x=[...l];return w(r,{dimColor:!0,wrap:"truncate",children:[y(r,{color:s.accent,children:n}),y(r,{inverse:!0,children:x[0]??" "}),x.slice(1).join("")]})}let f=wA(t),{rows:o,caretRow:h}=kn(t,Math.max(1,(d??Number.MAX_SAFE_INTEGER)-m)),b=i??o.length,{from:c,to:p}=Ne(o.length,h,Math.max(1,b)),e=c,T=o.length-p;return w(_,{flexDirection:"column",children:[e>0?w(r,{dimColor:!0,wrap:"truncate",children:[a,"… ",e," line",e===1?"":"s"," above"]}):null,o.slice(c,p).map((x,v)=>{let C=c+v,M=u===!0?[...x.text].map(()=>"•"):[...x.text],S=C===c&&e===0?n:a;if(x.caret===void 0&&f===void 0)return w(r,{wrap:"truncate",children:[y(r,{color:s.accent,children:S}),M.join("")]},`row-${C}`);let A=k(x,f),L=0;return w(r,{wrap:"truncate",children:[y(r,{color:s.accent,children:S}),A.map((g)=>{let R=`run-${C}-${L}`;L+=[...g.text].length;let E=u===!0?[...g.text].map(()=>"•").join(""):g.text;if(g.caret)return y(r,{inverse:!0,children:E},R);if(g.selected)return y(r,{backgroundColor:s.selection,children:E},R);return y(r,{children:E},R)})]},`row-${C}`)}),T>0?w(r,{dimColor:!0,wrap:"truncate",children:[a,"… ",T," line",T===1?"":"s"," below"]}):null]})}
4
+ export{kn,vn};
5
5
 
6
- //# debugId=F245CEF813437E0264756E2164756E21
7
- //# sourceMappingURL=index-8k8y7edx.js.map
6
+ //# debugId=588E981E7DAB1F1564756E2164756E21
7
+ //# sourceMappingURL=index-ar5c9d2f.js.map
@@ -6,6 +6,6 @@
6
6
  "/**\n * The composer's visual rows and where the caret sits on them. Pure, so the layout is arithmetic.\n *\n * ## Why the input box needs its own wrapping at all\n *\n * It rendered each logical line with `wrap=\"truncate\"` and no wrapping of its own, which is half of the\n * rule `lib/wrap.ts` states and the half that does not work. Ink truncates to the width Yoga measured,\n * and a `<Box>` with no explicit width takes its *content* width — so a long message made the box wider\n * than the terminal, and what happened next was the terminal's decision rather than ours. Measured at 100\n * columns: VS Code cut the line at the border and took the caret with it, so you could not see what you\n * were typing; Warp wrapped the over-wide row and the tail landed on top of the right-hand border. One\n * cause, two symptoms, and neither reproducible in the other terminal.\n *\n * So the composer wraps its own text, exactly as the transcript and the live pane do, and every row is\n * drawn `wrap=\"truncate\"` as a backstop rather than as the layout.\n *\n * ## One column is reserved, deliberately\n *\n * The caret is drawn as an inverse cell, so it needs a cell — including when it sits at the end of a line\n * that exactly fills the row. Wrapping to `columns - 1` buys that cell once, for every row, with no\n * special case; the alternative is an extra visual row that appears and disappears as you type past the\n * edge, which moves the whole frame on a surface that has no room to move.\n *\n * ## One derivation, two callers\n *\n * `LineCursor` draws these rows and `chat-frame.promptRows` counts them. That is the pairing the repo has\n * been bitten by before — a component that grows a row without the frame arithmetic knowing is a frame\n * taller than the terminal, which on the alternate buffer is corruption rather than crowding. Here the\n * count is `layout.rows.length` plus the notices, by construction.\n */\n\nimport { lineInfo } from \"#editor\"\nimport type { EditorState } from \"#lib/types\"\nimport { expandColumn, wrapRows } from \"#lib/wrap\"\n\n/** A cell reserved so the caret has somewhere to sit at the end of a full row. */\nconst CARET_CELL = 1\n\nexport interface ComposerRow {\n /** What is painted, hanging indent included. Never wider than the window. */\n readonly text: string\n /** Where the caret sits in this row, or `undefined` when it is on another row. */\n readonly caret: number | undefined\n /**\n * Buffer-absolute code-point offsets of the source this row draws, `start` inclusive and `end` not.\n *\n * Absolute rather than line-relative, which is the only form a selection can use: `wrapRows` reports\n * offsets into a single *line*, and a selection is a range over the whole buffer. Adding the line's own\n * start here is the one place that translation belongs — a renderer recomputing it would need the\n * split, the tab expansion and the wrap all over again to get the same number.\n */\n readonly start: number\n readonly end: number\n /** Columns of `text` that are re-applied indent, which no selection may highlight. */\n readonly lead: number\n}\n\n/** A run of a row that is drawn the same way: selected or not, caret or not. */\nexport interface RowSegment {\n readonly text: string\n readonly selected: boolean\n /** The single cell the caret inverts. Never wider than one code point. */\n readonly caret: boolean\n}\n\nexport interface ComposerLayout {\n /** Every visual row of the buffer, in order. At least one, even for an empty buffer. */\n readonly rows: readonly ComposerRow[]\n /** Index into `rows` holding the caret. */\n readonly caretRow: number\n}\n\n/**\n * Every visual row of `editor`'s buffer at `columns`, and which one the caret is on.\n *\n * `columns` is the width available *inside* whatever draws it — a caller with a border and padding\n * subtracts those first, because this cannot see them.\n */\nexport function composerLayout(editor: EditorState, columns: number): ComposerLayout {\n const width = Math.max(1, columns - CARET_CELL)\n const lines = editor.value.split(\"\\n\")\n const cursor = lineInfo(editor)\n\n const rows: ComposerRow[] = []\n let caretRow = 0\n // Where each line starts in the buffer, in code points. The `+ 1` is the newline itself, which no row\n // draws and every offset after it has to account for.\n let base = 0\n for (const [at, line] of lines.entries()) {\n const wrapped = wrapRows(line, width)\n // The caret's column has to be translated into the same tab-expanded coordinates the rows are\n // measured in, or a line containing a tab puts it seven columns to the left of where it is.\n const column = at === cursor.line ? expandColumn(line, cursor.column) : -1\n // Walked backwards so a caret exactly on a break lands at the *end* of the earlier row rather\n // than the start of the later one, which is where a person expects it after pressing → .\n let on = -1\n if (column >= 0) {\n on = wrapped.length - 1\n for (const [n, row] of wrapped.entries()) {\n if (column <= row.to) {\n on = n\n break\n }\n }\n }\n for (const [n, row] of wrapped.entries()) {\n if (n === on) caretRow = rows.length\n rows.push({\n start: base + row.from,\n end: base + row.to,\n lead: row.lead,\n text: row.text,\n // Clamped into the row: a caret past `to` can only mean the source column sat in the\n // whitespace a break consumed, and the end of the row is the honest place for it.\n caret:\n n === on\n ? row.lead + Math.max(0, Math.min(column - row.from, row.to - row.from))\n : undefined,\n })\n }\n base += [...line].length + 1\n }\n return { rows, caretRow }\n}\n\n/**\n * One row, split into the runs a renderer can paint in one go.\n *\n * Built as runs rather than as three slices because the caret can sit anywhere — including inside the\n * selection — and slicing for both produces overlapping ranges that have to be reconciled. Walking the row\n * once and grouping adjacent code points by how they are drawn has no such case, and the caret staying\n * exactly one cell wide is a property of the walk rather than something to remember.\n *\n * The indent is never selected. Those columns are chrome the wrap re-applied; highlighting them would\n * suggest text is included that no offset in the buffer corresponds to.\n */\nexport function rowSegments(\n row: ComposerRow,\n selection: { readonly start: number; readonly end: number } | undefined,\n): readonly RowSegment[] {\n const cells = [...row.text]\n const segments: RowSegment[] = []\n for (const [column, cell] of cells.entries()) {\n // A column past the indent maps back to the source by the same arithmetic the caret uses; one\n // inside it maps to nothing, which is why it can never be selected.\n const offset = column < row.lead ? -1 : row.start + (column - row.lead)\n const isSelected =\n selection !== undefined && offset >= selection.start && offset < selection.end\n const isCaret = row.caret === column\n const last = segments.at(-1)\n // The caret is its own run always, so it stays one cell wide even in the middle of a selection.\n if (last !== undefined && !isCaret && !last.caret && last.selected === isSelected) {\n segments[segments.length - 1] = { ...last, text: last.text + cell }\n continue\n }\n segments.push({ text: cell, selected: isSelected, caret: isCaret })\n }\n // A caret past the last character has no cell to invert, so it needs one. Same reason `LineCursor`\n // inverts a trailing space today.\n if (row.caret !== undefined && row.caret >= cells.length) {\n segments.push({ text: \" \", selected: false, caret: true })\n }\n return segments\n}\n"
7
7
  ],
8
8
  "mappings": ";qJA4BA,cAAS,UAAK,YCQd,IAAM,EAAa,EA0CZ,SAAS,EAAc,CAAC,EAAqB,EAAiC,CACjF,IAAM,EAAQ,KAAK,IAAI,EAAG,EAAU,CAAU,EACxC,EAAQ,EAAO,MAAM,MAAM;AAAA,CAAI,EAC/B,EAAS,GAAS,CAAM,EAExB,EAAsB,CAAC,EACzB,EAAW,EAGX,EAAO,EACX,QAAY,EAAI,KAAS,EAAM,QAAQ,EAAG,CACtC,IAAM,EAAU,GAAS,EAAM,CAAK,EAG9B,EAAS,IAAO,EAAO,KAAO,GAAa,EAAM,EAAO,MAAM,EAAI,GAGpE,EAAK,GACT,GAAI,GAAU,EAAG,CACb,EAAK,EAAQ,OAAS,EACtB,QAAY,EAAG,KAAQ,EAAQ,QAAQ,EACnC,GAAI,GAAU,EAAI,GAAI,CAClB,EAAK,EACL,OAIZ,QAAY,EAAG,KAAQ,EAAQ,QAAQ,EAAG,CACtC,GAAI,IAAM,EAAI,EAAW,EAAK,OAC9B,EAAK,KAAK,CACN,MAAO,EAAO,EAAI,KAClB,IAAK,EAAO,EAAI,GAChB,KAAM,EAAI,KACV,KAAM,EAAI,KAGV,MACI,IAAM,EACA,EAAI,KAAO,KAAK,IAAI,EAAG,KAAK,IAAI,EAAS,EAAI,KAAM,EAAI,GAAK,EAAI,IAAI,CAAC,EACrE,MACd,CAAC,EAEL,GAAQ,CAAC,GAAG,CAAI,EAAE,OAAS,EAE/B,MAAO,CAAE,OAAM,UAAS,EAcrB,SAAS,CAAW,CACvB,EACA,EACqB,CACrB,IAAM,EAAQ,CAAC,GAAG,EAAI,IAAI,EACpB,EAAyB,CAAC,EAChC,QAAY,EAAQ,KAAS,EAAM,QAAQ,EAAG,CAG1C,IAAM,EAAS,EAAS,EAAI,KAAO,GAAK,EAAI,OAAS,EAAS,EAAI,MAC5D,EACF,IAAc,QAAa,GAAU,EAAU,OAAS,EAAS,EAAU,IACzE,EAAU,EAAI,QAAU,EACxB,EAAO,EAAS,GAAG,EAAE,EAE3B,GAAI,IAAS,QAAa,CAAC,GAAW,CAAC,EAAK,OAAS,EAAK,WAAa,EAAY,CAC/E,EAAS,EAAS,OAAS,GAAK,IAAK,EAAM,KAAM,EAAK,KAAO,CAAK,EAClE,SAEJ,EAAS,KAAK,CAAE,KAAM,EAAM,SAAU,EAAY,MAAO,CAAQ,CAAC,EAItE,GAAI,EAAI,QAAU,QAAa,EAAI,OAAS,EAAM,OAC9C,EAAS,KAAK,CAAE,KAAM,IAAK,SAAU,GAAO,MAAO,EAAK,CAAC,EAE7D,OAAO,oDDrGJ,SAAS,EAAU,EACtB,SACA,cACA,SACA,SAAS,GACT,UACA,WACgB,CAChB,IAAM,EAAO,CAAC,GAAG,CAAM,EAAE,OACnB,EAAM,IAAI,OAAO,CAAI,EAE3B,GAAI,EAAO,QAAU,IAAM,IAAgB,QAAa,IAAgB,GAAI,CACxE,IAAM,EAAQ,CAAC,GAAG,CAAW,EAC7B,OACI,EAAC,EAAD,CAAM,SAAQ,GAAC,KAAK,WAApB,SAIE,CAHE,EAAC,EAAD,CAAM,MAAO,EAAM,OAAnB,SAA4B,EAAS,EACrC,EAAC,EAAD,CAAM,QAAO,GAAb,SAAe,EAAM,IAAM,IAAM,EAChC,EAAM,MAAM,CAAC,EAAE,KAAK,EAAE,GACzB,EAQV,IAAM,EAAY,GAAe,CAAM,GAC/B,KAAM,EAAK,YAAa,GAC5B,EACA,KAAK,IAAI,GAAI,GAAW,OAAO,kBAAoB,CAAI,CAC3D,EACM,EAAS,GAAW,EAAI,QACtB,OAAM,MAAO,GAAS,EAAI,OAAQ,EAAU,KAAK,IAAI,EAAG,CAAM,CAAC,EACjE,EAAc,EACd,EAAc,EAAI,OAAS,EAEjC,OACI,EAAC,EAAD,CAAK,cAAc,SAAnB,SA8DE,CA7DG,EAAc,EACX,EAAC,EAAD,CAAM,SAAQ,GAAC,KAAK,WAApB,SAEE,CADG,EADL,KACY,EADZ,QAC8B,IAAgB,EAAI,GAAK,IADvD,UAEE,EACF,KACH,EAAI,MAAM,EAAM,CAAE,EAAE,IAAI,CAAC,EAAK,IAAW,CACtC,IAAM,EAAK,EAAO,EAGZ,EAAQ,IAAW,GAAO,CAAC,GAAG,EAAI,IAAI,EAAE,IAAI,IAAM,GAAG,EAAI,CAAC,GAAG,EAAI,IAAI,EACrE,EAAQ,IAAO,GAAQ,IAAgB,EAAI,EAAS,EAC1D,GAAI,EAAI,QAAU,QAAa,IAAc,OACzC,OAGI,EAAC,EAAD,CAAwB,KAAK,WAA7B,SAGE,CAFE,EAAC,EAAD,CAAM,MAAO,EAAM,OAAnB,SAA4B,EAAQ,EACnC,EAAM,KAAK,EAAE,IAFP,OAAO,GAGhB,EAOV,IAAM,EAAO,EAAY,EAAK,CAAS,EACnC,EAAS,EACb,OACI,EAAC,EAAD,CAAwB,KAAK,WAA7B,SAyBE,CAxBE,EAAC,EAAD,CAAM,MAAO,EAAM,OAAnB,SAA4B,EAAQ,EACnC,EAAK,IAAI,CAAC,IAAQ,CACf,IAAM,EAAM,OAAO,KAAM,IACzB,GAAU,CAAC,GAAG,EAAI,IAAI,EAAE,OACxB,IAAM,EACF,IAAW,GAAO,CAAC,GAAG,EAAI,IAAI,EAAE,IAAI,IAAM,GAAG,EAAE,KAAK,EAAE,EAAI,EAAI,KAGlE,GAAI,EAAI,MACJ,OACI,EAAC,EAAD,CAAgB,QAAO,GAAvB,SACK,GADM,CAET,EAGV,GAAI,EAAI,SACJ,OACI,EAAC,EAAD,CAAgB,gBAAiB,EAAM,UAAvC,SACK,GADM,CAET,EAGV,OAAO,EAAC,EAAD,UAAiB,GAAN,CAAa,EAClC,IAxBM,OAAO,GAyBhB,EAET,EACA,EAAc,EACX,EAAC,EAAD,CAAM,SAAQ,GAAC,KAAK,WAApB,SAEE,CADG,EADL,KACY,EADZ,QAC8B,IAAgB,EAAI,GAAK,IADvD,UAEE,EACF,MACN",
9
- "debugId": "F245CEF813437E0264756E2164756E21",
9
+ "debugId": "588E981E7DAB1F1564756E2164756E21",
10
10
  "names": []
11
11
  }
@@ -0,0 +1,74 @@
1
+ #!/usr/bin/env node
2
+ import{t,r,f,me,a,i,Xe,x,y,de,js,ht,Ot,ce,X}from"./index-ss77hvwy.js";var Rn="dispach",xn="Dispach",Ln=1;function ke(e,n){return{slug:e,name:n,envPrefix:`${e.toUpperCase()}_`,stateDir:`.${e}`,apiVersion:`${e}/v${Ln}`,packageScope:`@${e}`}}var Q=ke(Rn,xn),ee=`${Q.envPrefix}BRAND`,Je=/^[a-z][a-z0-9]*(-[a-z0-9]+)*$/;function Ze(e){return e.split("-").map((n)=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ")}function Qe(e){if(e===void 0)return Q;let n=e.trim();if(n==="")throw Error(`${ee} is set but empty. hint: unset ${ee} 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(!Je.test(n))throw Error(`${ee}="${n}" 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(n===Q.slug)return Q;return ke(n,Ze(n))}var V=Qe(process.env[ee]);function Mn(e,n){let s=Array.from({length:n.length+1},(o,d)=>d);for(let o=1;o<=e.length;o+=1){let d=[o];for(let l=1;l<=n.length;l+=1){let c=(s[l-1]??0)+(e[o-1]===n[l-1]?0:1),u=(d[l-1]??0)+1,h=(s[l]??0)+1;d.push(Math.min(c,u,h))}s=d}return s[n.length]??Math.max(e.length,n.length)}function Yt(e,n){let s,o=Number.POSITIVE_INFINITY;for(let d of n){let l=Mn(e,d);if(l<o)o=l,s=d}return s!==void 0&&o<=Math.max(2,Math.floor(e.length/3))?s:void 0}var et=Symbol.for("dispach.HarnessError");function _(e){return typeof e==="object"&&e!==null&&et in e}class ne extends Error{static ERROR_NAME="HarnessError";code;hint;field;details;constructor(e){super(e.message,e.cause===void 0?void 0:{cause:e.cause});if(this.name=new.target.ERROR_NAME??"HarnessError",this[et]=!0,this.code=e.code,this.hint=e.hint,this.field=e.field,e.detail!==void 0)this.detail=e.detail;this.details=e.details??[]}toDetail(){return{code:this.code,message:this.message,hint:this.hint,...this.field===void 0?{}:{field:this.field},...this.detail===void 0?{}:{detail:this.detail},...this.details.length>1?{details:this.details}:{}}}format(){let e=[`${this.code}: ${this.message}`];if(this.field!==void 0)e.push(` field: ${this.field}`);if(e.push(` hint: ${this.hint}`),this.detail!==void 0)e.push(` detail: ${this.detail}`);if(this.details.length===1)return e.join(`
3
+ `);for(let n of this.details){if(e.push(""),e.push(` ${n.code}: ${n.message}`),n.field!==void 0)e.push(` field: ${n.field}`);e.push(` hint: ${n.hint}`)}return e.join(`
4
+ `)}}class B extends ne{static ERROR_NAME="ConfigError"}class gt extends ne{static ERROR_NAME="ModelError";status;retryAfterSeconds;constructor(e){super(e);this.status=e.status,this.retryAfterSeconds=e.retryAfterSeconds}}class S extends ne{static ERROR_NAME="ToolError"}function tt(e,n){return new B({code:"tools_provider_alias_conflict",message:`The manifest sets tools.providers (${e.join(", ")}) and also the deprecated tools.provider${n===void 0?"Config":` (${n})`}.`,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${n===void 0?"":` — move ${n}'s settings into tools.providers.${n}`}.`,field:"tools.provider"})}function nt(){return new B({code:"workspace_alias_conflict",message:"The manifest sets both context.files and context.static.",hint:"context.files is the deprecated alias for context.static and resolves against the manifest directory, while context.static resolves against context.workspace. Merging them would produce an order nobody wrote and paths nobody can predict from reading the manifest, so pick one — context.static.",field:"context.files"})}function st(e,n){return new S({code:"workspace_not_editable",message:`${e} is declared editable: ${n}, 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 it(){return new S({code:"memory_forget_arguments",message:"memory_forget needs either `query` or `ids`, not both and not neither.",hint:"Call it with `query` first to see what matches, show the person, then call it again with the `ids` they confirm."})}function rt(){return new S({code:"memory_forget_unavailable",message:"Memory cannot be changed from here: nothing runs turns in this context.",hint:"memory_forget works inside a turn of a running agent."})}function ot(){return new S({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 at(e){return new S({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."})}function L(e,n,s,o="images"){return new ne({code:e,message:n,hint:s,field:o})}function dt(e,n,s,o){return new B({code:"schedule_tool_unknown",message:`Schedule "${e}" allows ${n.join(", ")}, which ${n.length===1?"names":"name"} nothing this agent has.`,hint:`A schedule can only narrow the agent's own tools: name a pinned or local slug, a tag: annotation, or *. Available: ${s.join(", ")||"none"}. Refused rather than ignored, because a run with fewer tools than its author wrote fails quietly turns later.`,field:o})}class Ir{runtimeId;#n=new Map;#e=new Map;#t=0;#s;#i;constructor(e){this.runtimeId=e.runtimeId,this.#i=e.now??(()=>new Date().toISOString()),this.#s=e.onHandlerError??((n,s)=>{console.error(`event handler threw while handling ${s.type}:`,n)})}on(e,n,s={}){if(e==="*"){let l=this.#e.has(n),c=s.chunks===!0,u=l?this.#e.get(n)??!1:!1;if(this.#e.set(n,c||u),!l&&c)this.#t+=1;else if(l&&c&&!u)this.#t+=1;return()=>{if(!this.#e.has(n))return;if(this.#e.get(n)===!0)this.#t-=1;this.#e.delete(n)}}let o=this.#n.get(e);if(o===void 0)o=new Set,this.#n.set(e,o);let d=!o.has(n);if(o.add(n),d&&e==="model.chunk")this.#t+=1;return()=>{if(o?.delete(n)===!0&&e==="model.chunk")this.#t-=1}}once(e,n,s={}){let o=this.on(e,(d)=>{o(),n(d)},s);return o}next(e,n,s={}){return new Promise((o,d)=>{let l=this.on(e,(u)=>{l(),n?.removeEventListener("abort",c),o(u)},s),c=()=>{l(),d(n?.reason??Error("aborted"))};n?.addEventListener("abort",c,{once:!0})})}get chunkSubscribers(){return this.#t}emit(e,n,s={}){if(e==="model.chunk"&&this.#t===0)return;let o={v:1,ts:this.#i(),runtimeId:this.runtimeId,...s.agentId===void 0?{}:{agentId:s.agentId},...s.sessionKey===void 0?{}:{sessionKey:s.sessionKey},...s.turnId===void 0?{}:{turnId:s.turnId},...s.stepId===void 0?{}:{stepId:s.stepId},...s.parentTurnId===void 0?{}:{parentTurnId:s.parentTurnId},...s.parentSessionKey===void 0?{}:{parentSessionKey:s.parentSessionKey},type:e,data:n};this.#o(o)}#o(e){let n=e.type==="model.chunk",s=this.#n.get(e.type);if(s!==void 0)for(let o of[...s])this.#r(o,e);for(let[o,d]of[...this.#e]){if(n&&!d)continue;this.#r(o,e)}}#r(e,n){try{e(n)}catch(s){this.#s(s,n)}}}var Ye="0.2.13",Dn=/^(\d+)\.(\d+)\.(\d+)$/,Cn=/^(\d+)(?:\.(\d+))?(?:\.(\d+))?$/;function Un(e){let n=Dn.exec(e.trim());if(n===null)return;return{major:Number(n[1]),minor:Number(n[2]),patch:Number(n[3])}}function Pn(e){let n=/^(\d+\.\d+\.\d+)(?:-[0-9A-Za-z.-]+)?$/.exec(e.trim());return n===null?void 0:Un(n[1]??"")}function Fn(e){let n=Cn.exec(e.trim());if(n===null)return;let[,s,o,d]=n;return{version:{major:Number(s),minor:Number(o??0),patch:Number(d??0)},specified:d!==void 0?3:o!==void 0?2:1}}function D(e,n){if(e.major!==n.major)return e.major-n.major;if(e.minor!==n.minor)return e.minor-n.minor;return e.patch-n.patch}function jn(e){if(e.major!==0)return{major:e.major+1,minor:0,patch:0};if(e.minor!==0)return{major:0,minor:e.minor+1,patch:0};return{major:0,minor:0,patch:e.patch+1}}function Wn(e,n){if(n===1)return{major:e.major+1,minor:0,patch:0};return{major:e.major,minor:e.minor+1,patch:0}}function Bn(e,n){if(n==="*"||n==="x"||n==="X")return!0;let s=/^(>=|<=|>|<|=|\^|~)?\s*(\S.*)$/.exec(n);if(s===null)return;let o=Fn(s[2]??"");if(o===void 0)return;let{version:d,specified:l}=o;switch(s[1]){case"^":return D(e,d)>=0&&D(e,jn(d))<0;case"~":return D(e,d)>=0&&D(e,Wn(d,l))<0;case">=":return D(e,d)>=0;case"<=":return D(e,d)<=0;case">":return D(e,d)>0;case"<":return D(e,d)<0;default:if(l===3)return D(e,d)===0;if(l===2)return e.major===d.major&&e.minor===d.minor;return e.major===d.major}}function dr(e,n){let s=Pn(e);if(s===void 0)return;let o=n.split("||"),d=!1;for(let l of o){let c=l.trim().split(/\s+/).filter((h)=>h!=="");if(c.length===0)return;let u=!0;for(let h of c){let m=Bn(s,h);if(m===void 0)return;if(!m)u=!1}if(d=!0,u)return!0}return d?!1:void 0}var ur=200;var Hn="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 M=(e)=>String.fromCharCode(e),K=M(27),yt=M(7),Kn=new RegExp(`${K}\\[[0-?]*[ -/]*[@-~]`,"g"),Xn=new RegExp(`${K}\\][\\s\\S]*?(?:${yt}|${K}\\\\|$)`,"g"),qn=new RegExp(`${K}[P^_X][\\s\\S]*?(?:${K}\\\\|${yt}|$)`,"g"),Gn=new RegExp(`${K}[@-Z\\\\-_0-9=><]?`,"g"),Yn=new RegExp(`[${M(128)}-${M(159)}]`,"g"),zn=new RegExp(`[${M(0)}-${M(8)}${M(11)}${M(12)}${M(14)}-${M(31)}${M(127)}]`,"g");function jt(e){return e.replace(/\r\n/g,`
5
+ `).replace(/\r/g,`
6
+ `).replace(Xn,"").replace(qn,"").replace(Kn,"").replace(Gn,"").replace(Yn,"").replace(zn,"")}function wt(e){return e==="untrusted"?"obu":"obs"}function bt(e){return e.startsWith(`${wt("untrusted")}_`)?"untrusted":"trusted"}var Vn=3.8;function vt(e){if(e==="")return 0;let n=0;for(let s=0;s<e.length;s+=1)if(e.charCodeAt(s)===10)n+=1;return Math.ceil(e.length/Vn)+n}var Jt=["runtime.ready","store.ready","runtime.stopping","agent.loaded","agent.disposed","agent.reloaded","agent.warning","plugin.loaded","plugin.slow","approval.requested","approval.resolved","handoff.start","handoff.result","peer.ask","peer.answer","turn.start","context.assembled","context.dropped","context.pressure","compaction.stage","context.reset","session.compacted","phase.changed","model.call","model.chunk","model.retry","model.fallback","model.result","media.result","tool.usage","tool.call","tool.result","tool.gated","tool.repair","tools.refreshed","agent.tools.refreshed","agent.channel.status","agent.channel.error","agent.channel.rejected","delivery.sent","delivery.retry","delivery.failed","delivery.uncertain","runtime.released","schedules.reconciled","schedule.fired","schedule.skipped","schedule.deferred","schedule.error","conversation.message","conversation.skipped","action.deferred","action.decided","agent.assigned","memory.read","memory.recalled","memory.forgotten","turn.end","error"],Jn=/\r\n\r\n|\n\n|\r\r/;function lt(e){let n=[],s,o,d;for(let l of e.split(/\r\n|\n|\r/)){if(l===""||l.startsWith(":"))continue;let c=l.indexOf(":"),u=c===-1?l:l.slice(0,c),h=c===-1?"":l.slice(c+1);if(h.startsWith(" "))h=h.slice(1);switch(u){case"data":n.push(h);break;case"event":s=h;break;case"id":o=h;break;case"retry":{let m=Number.parseInt(h,10);if(Number.isFinite(m))d=m;break}default:break}}if(n.length===0&&s===void 0)return;return{...s===void 0?{}:{event:s},data:n.join(`
7
+ `),...o===void 0?{}:{id:o},...d===void 0?{}:{retry:d}}}async function*Er(e){let n=new TextDecoder,s="";for await(let o of e){s+=typeof o==="string"?o:n.decode(o,{stream:!0});while(!0){let d=Jn.exec(s);if(d===null)break;let l=s.slice(0,d.index);s=s.slice(d.index+d[0].length);let c=lt(l);if(c!==void 0)yield c}}if(s+=n.decode(),s.trim()!==""){let o=lt(s);if(o!==void 0)yield o}}function fr(){return{push:(e)=>e,endStep:()=>"",end:()=>""}}var Zn=["format","minimum","maximum","exclusiveMinimum","exclusiveMaximum","minLength","maxLength","pattern","minItems","maxItems"],Qn=new Set(["string","number","integer","boolean","array","object"]),es=["string","number","integer","boolean","object","array"];function A(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)?e:void 0}function C(e){return Array.isArray(e)?e.filter((n)=>typeof n==="string"):[]}function ct(...e){let n=e.map((s)=>typeof s==="string"?s.trim():"").filter((s)=>s!=="");return n.length===0?void 0:n.join(" ")}function ts(e,n){if(!n.startsWith("#/"))return;let s=e;for(let o of n.slice(2).split("/"))s=A(s)?.[o.replace(/~1/g,"/").replace(/~0/g,"~")];return A(s)}function H(e){let s=(Array.isArray(e.type)?e.type:[e.type]).filter((o)=>typeof o==="string"&&Qn.has(o));if(s.length===0&&A(e.properties)!==void 0)return["object"];if(s.length===0&&e.items!==void 0)return["array"];return s}function ns(e,n,s){let o={};for(let c of e)for(let[u,h]of Object.entries(A(c.properties)??{})){let m=A(h);if(m===void 0)continue;let g=o[u]??[];g.push(m),o[u]=g}let d={};for(let[c,u]of Object.entries(o))d[c]=u.length===1?u[0]:se(u,{},n,s);let l=e.map((c)=>C(c.required)).reduce((c,u)=>c.filter((h)=>u.includes(h)));if(Object.keys(d).length===0)return{type:"object"};return{type:"object",properties:d,required:l}}function _t(e){let n=A(e);if(n===void 0)return;if(n.const!==void 0)return{value:n.const};return Array.isArray(n.enum)&&n.enum.length===1?{value:n.enum[0]}:void 0}function ss(e){let n=A(e)?.const;return n===void 0?{}:{const:n}}function Tt(e){return JSON.stringify([H(e),Object.keys(A(e.properties)??{}).sort(),[...C(e.required)].sort(),e.enum,e.items===void 0?void 0:Tt(A(e.items)??{})])}function is(e){let n=(o,d)=>_t(A(o.properties)?.[d])!==void 0;return Object.keys(A(e[0]?.properties)??{}).filter((o)=>e.every((d)=>n(d,o)))}function rs(e,n,s){let o=A(e.properties)??{},d=[],l=new Set;for(let[h,m]of Object.entries(o)){let g=_t(m);if(g!==void 0)d.push(`${h} ${JSON.stringify(g.value)}`),l.add(h)}let c=C(e.required).filter((h)=>!l.has(h)&&!s.includes(h)),u=d.length>0?d.join(", "):typeof e.title==="string"?e.title:`option ${n+1}`;return c.length===0?u:`${u} with ${c.join(", ")}`}function se(e,n,s,o){let d=new Map;for(let T of e.map((N)=>ie(N,s,o))){if(T.type==="null"&&T.enum===void 0)continue;let N=Tt(T);if(!d.has(N))d.set(N,T)}let l=[...d.values()];if(l.length===0)return n;if(l.length===1)return{...l[0],...n};let c=l.filter((T)=>H(T).includes("object")),u=l.filter((T)=>!c.includes(T)&&H(T).includes("array")),h=l.filter((T)=>!c.includes(T)&&!u.includes(T)),m=[...new Set(h.flatMap(H))],g=u.length===0?void 0:{type:"array",items:se(u.map((T)=>A(T.items)??{}),{},s,o)},p=c.length===0?void 0:ns(c,s,o),w=C(p?.required),b=c.length>1?c.map((T,N)=>rs(T,N,w)):[],E=b.some((T)=>!/^option \d+$/.test(T))?`One of: ${b.join("; ")}.`:void 0,k=E===void 0?void 0:is(c)[0],I=A(p?.properties),O=k===void 0?void 0:A(I?.[k]);if(p!==void 0&&k!==void 0&&O!==void 0){let T=ct(O.description,E);p={...p,properties:{...I,[k]:{...O,description:T}}}}let F=(T)=>new Set(l.map((N)=>JSON.stringify(N[T]))).size===1?l[0]?.[T]:void 0,W=n.default===void 0?F("default"):void 0,Z=(...T)=>{let N=ct(n.description??F("description"),O===void 0?E:void 0,...T);return{...W===void 0?{}:{default:W},...n,...N===void 0?{}:{description:N}}};if(g===void 0&&m.length===0&&p!==void 0)return{...p,...Z()};if(p===void 0&&m.length===0&&g!==void 0)return{...g,...Z()};if(g===void 0&&p===void 0){let T=h.map((Ve)=>Ve.enum),N=T.every(Array.isArray)?[...new Set(T.flat())]:void 0;return{type:m.length===1?m[0]:m,...N===void 0?{}:{enum:N},...Z()}}if(g!==void 0){let T=A(g.items)??{},N=H(T);if((p===void 0||N.length===0||N.includes("object"))&&m.every((Ee)=>Ee==="string"||N.includes(Ee)))return{type:"array",items:p===void 0?T:se([T,p],{},s,o),...Z()}}let On=es.filter((T)=>m.includes(T)||T==="object"&&p!==void 0||T==="array"&&g!==void 0),ze=Object.keys(I??{});return{type:On,...Z(ze.length===0?void 0:`As an object, its fields are: ${ze.join(", ")}.`)}}function ie(e,n,s,o=""){let d=e;if(typeof d.$ref==="string"){let c=d.$ref,{$ref:u,...h}=d;if(s.has(c))return{type:"object",...h};let m=ts(n.root,c);if(m===void 0)throw n.conversion.unsupported(o,"$ref");s.add(c),d={...ie(m,n,s,o),...h}}if(Array.isArray(d.allOf)){let{allOf:c,...u}=d,h=c.map(A).filter((p)=>p!==void 0).map((p)=>ie(p,n,s,o)),m=Object.assign({},...h.map((p)=>A(p.properties)??{}),A(u.properties)??{}),g=[...new Set([...h,u].flatMap((p)=>C(p.required)))];if(d=Object.assign({},...h,u),Object.keys(m).length>0)d={...d,properties:m,required:g}}if(d.not!==void 0){let{not:c,...u}=d;d=u}if(d.const!==void 0){let{const:c,...u}=d;d={...u,enum:[c]}}let l=d.anyOf??d.oneOf;if(Array.isArray(l)){let{anyOf:c,oneOf:u,...h}=d,m=l.map(A).filter((p)=>p!==void 0),g=A(h.properties);if(g===void 0)d=se(m,h,n,s);else{let{properties:p,required:w,...b}=h,v=m.map((E)=>({...E,type:E.type??"object",properties:Object.fromEntries(Object.entries({...g,...A(E.properties)??{}}).map(([k,I])=>[k,{...A(I),...A(g[k]),...ss(I)}])),required:[...new Set([...C(h.required),...C(E.required)])]}));d=se(v,b,n,s)}}return d}function os(e){let n=[];for(let s of Zn){let o=e[s];if(o===void 0||o===null)continue;if(typeof o==="object")continue;n.push(`${s} ${String(o)}`)}return n.join(", ")}function as(e){let n=typeof e.description==="string"?e.description.trim():"",s=os(e);if(n===""&&s==="")return;if(s==="")return n;return n===""?s:`${n} (${s})`}function Et(e,n,s,o){let d=new Set(o),l=ie(e,s,d,n),c=H(l),u=c.length>1?c:c[0]??s.conversion.untyped??"string",h=as(l),m=Array.isArray(l.enum)?l.enum.filter((w)=>typeof w==="string"||typeof w==="number"||typeof w==="boolean"):void 0,g=u==="array"?A(l.items):void 0,p=u==="object"?A(l.properties):void 0;return{type:u,...h===void 0?{}:{description:h},...m===void 0||m.length===0?{}:{enum:m},...g===void 0?{}:{items:Et(g,`${n}[]`,s,d)},...p===void 0?{}:{properties:kt(p,n,s,d),required:C(l.required)},...l.default===void 0||l.default===null?{}:{default:l.default}}}function kt(e,n,s,o){let d={};for(let[l,c]of Object.entries(e)){let u=A(c);if(u===void 0)continue;d[l]=Et(u,n===""?l:`${n}.${l}`,s,o)}return d}function ro(e,n){if(e===void 0)return{type:"object",properties:{}};let s={conversion:n,root:e},o=new Set,d=ie(e,s,o,n.rootPath??"parameters"),l=A(d.properties)??{},c=C(d.required),u=kt(l,"",s,o);return{type:"object",properties:u,...c.length===0?{}:{required:c.filter((h)=>(h in u))}}}var At="<<<",St=">>>",te=/^\s*(?:(?:[-*+]|\d+[.)])\s+)?(?:<\s*)?action\s*:(.+)$/i,ds=/^\s*(?:[-*+]\s+|\d+[.)]\s+)?([A-Za-z_][\w.-]*?)\s*:(.*)$/,Ne=/^\s*`{3,}\s*(?:[\w+-]+\s*)?$/,Ae=/^\s*end\s*$/i,ls=/^\s*<\s*action\s*>\s*$/i,ut=/^\s*<\s*\/\s*action\s*>\s*$/i,cs=/^\s*<\/?\s*[A-Za-z_][\w.:-]*\s*(?:\/\s*)?>\s*$/;function ft(e){let n=(e??"").trim();return n.endsWith(">")?n.slice(0,-1).trimEnd():n}function Se(e){return mt(mt(us(e,"`'\"*<"),"`'\"*>"),".,;:").trim()}function us(e,n){let s=0;while(s<e.length&&n.includes(e[s]??""))s+=1;return e.slice(s)}function mt(e,n){let s=e.length;while(s>0&&n.includes(e[s-1]??""))s-=1;return e.slice(0,s)}function $t(e,n,s){let o=e.fields.get(n);if(o===void 0)e.fields.set(n,[s]);else o.push(s)}function Nt(e){if(e.block===void 0||e.heredocKey===void 0)return;let n=[...e.heredocLines];if(n[n.length-1]==="")n.pop();$t(e.block,e.heredocKey,n.join(`
8
+ `)),e.block.wrapped.add(e.heredocKey),e.heredocKey=void 0,e.heredocLines=[]}function j(e){if(Nt(e),e.block!==void 0)e.blocks.push(e.block);e.block=void 0,e.openKey=void 0,e.awaitingSlug=!1}function pt(){return{block:void 0,openKey:void 0,severedKey:void 0,severedPending:void 0,heredocKey:void 0,heredocLines:[],justClosed:!1,awaitingSlug:!1,text:[],blocks:[]}}function hs(e,n,s){let o=n.trim();if(e.heredocKey!==void 0){if(o===St){Nt(e);return}if(Ae.test(o)){j(e),e.justClosed=!0;return}if(te.test(n)){j(e);let c=te.exec(n),u=Se(ft(c?.[1]));if(u!=="")e.block={slug:u,fields:new Map,wrapped:new Set,severed:new Set};return}e.heredocLines.push(n);return}let d=te.exec(n);if(d!==null){let c=Se(ft(d[1]));if(j(e),c==="")return;e.block={slug:c,fields:new Map,wrapped:new Set,severed:new Set};return}if(ls.test(n)){j(e),e.awaitingSlug=!0;return}if(e.awaitingSlug){if(o==="")return;if(ut.test(n)){e.awaitingSlug=!1;return}let c=Se(o);if(e.awaitingSlug=!1,c!=="")e.block={slug:c,fields:new Map,wrapped:new Set,severed:new Set};return}if(ut.test(n)){if(e.block!==void 0)j(e),e.justClosed=!0;return}if(cs.test(n))return;if(e.block===void 0){if(Ne.test(n)&&(e.justClosed||s())){e.justClosed=!1;return}if(Ae.test(o)&&e.severedPending!==void 0){e.severedPending.block.severed.add(e.severedPending.key),e.severedPending=void 0;return}if(te.test(n))e.severedPending=void 0;if(e.text.push(n),o!=="")e.justClosed=!1;return}if(o===""){if(e.openKey!==void 0)e.severedKey=e.openKey;e.openKey=void 0;return}if(Ae.test(o)){e.severedKey=void 0,j(e),e.justClosed=!0;return}if(Ne.test(n))return;let l=ds.exec(n);if(l!==null){let c=(l[1]??"").trim(),u=(l[2]??"").trim();if(e.severedKey=void 0,u===At)e.heredocKey=c,e.heredocLines=[],e.openKey=void 0;else $t(e.block,c,u),e.openKey=c;return}if(e.openKey!==void 0){let c=e.block.fields.get(e.openKey),u=c?.[c.length-1];if(c!==void 0&&u!==void 0)c[c.length-1]=u===""?o:`${u}
9
+ ${o}`;return}if(e.severedKey!==void 0)e.severedPending={block:e.block,key:e.severedKey},e.severedKey=void 0;j(e),e.text.push(n)}function fs(e){if(/^\s*(?:(?:[-*+]|\d+[.)]?)\s*)?$/.test(e))return!0;let n=e.replace(/^\s*(?:[-*+]\s+|\d+[.)]\s+)?/,"").toLowerCase(),s=n.startsWith("<")?n.slice(1):n;if("action:".startsWith(s)||s.startsWith("action:"))return!0;if(/^<\/?$/.test(n)||/^<\/?[a-z_][\w.:-]*>?$/.test(n))return!0;return/^`{1,3}[\w+-]*$/.test(n)}function $e(e){return e.endsWith("\r")?e.slice(0,-1):e}function pr(){let e=pt(),n="",s=0,o,d="",l=!1,c=(p)=>{if(p==="")return"";if(p.trim()==="")return d+=p,"";let w=d+p;if(d="",l)return w;return l=!0,w.replace(/^\s+/,"")},u=(p,w)=>{let b=e.text.length;return hs(e,p,()=>w!==void 0&&te.test(w)),e.text.length>b?p:void 0},h=(p,w,b)=>{let v=u(p,w);if(v===void 0)return"";return c(v.slice(b))+c(`
10
+ `)},m=(p)=>{if(o===void 0)return"";let w=o;return o=void 0,h(w,p,0)};return{push(p){let w="";n+=p;let b=n.indexOf(`
11
+ `);while(b!==-1){let E=$e(n.slice(0,b));if(n=n.slice(b+1),w+=m(E),e.block===void 0&&Ne.test(E)&&!e.justClosed)o=E;else w+=h(E,void 0,s);s=0,b=n.indexOf(`
12
+ `)}let v=$e(n);if(e.block===void 0&&!e.awaitingSlug&&o===void 0&&!fs(v))w+=c(v.slice(s)),s=v.length;return w},endStep(){let p=g();return d=`
13
+
14
+ `,e=pt(),p},end:g};function g(){let p=m(void 0),w=$e(n);if(w!==""){let b=u(w,void 0);if(b!==void 0)p+=c(b.slice(s))}return n="",s=0,o=void 0,p}}var ea=`# 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 \`${At}\` and close it with \`${St}\` 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{readFile as Cs,realpath as It,stat as Ws}from"node:fs/promises";import{isAbsolute as Hs,resolve as Ie,sep as Rt}from"node:path";import{basename as sl,isAbsolute as dn,resolve as ln}from"node:path";import{appendFile as Wt,mkdir as sr,readFile as ir}from"node:fs/promises";import{join as Bt}from"node:path";import{appendFile as gn,mkdir as rr,readFile as or,writeFile as ar}from"node:fs/promises";import{join as lr}from"node:path";import{readFile as Mr,writeFile as Dr}from"node:fs/promises";import{dirname as Ur}from"node:path";import{isDeepStrictEqual as Pr}from"node:util";import{existsSync as $n,mkdirSync as jo,readdirSync as Wo,readFileSync as re,rmSync as Zt,writeFileSync as pe}from"node:fs";import{dirname as Bo,isAbsolute as Ho,join as Te,resolve as Ko}from"node:path";var ps=`${V.slug}_`,gs="0123456789abcdefghjkmnpqrstvwxyz",Es=32;function Cr(){let e=new Uint8Array(Es);crypto.getRandomValues(e);let n="";for(let s of e)n+=gs[s&31]??"0";return`${ps}${n}`}async function hr(e){let n=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(e));return[...new Uint8Array(n)].map((s)=>s.toString(16).padStart(2,"0")).join("")}var Br=64,As=new RegExp("[\\u0000-\\u001f\\u007f]");function Bs(e){if(e.trim()==="")return"A key label cannot be empty.";if(e.length>Br)return`A key label is at most ${Br} characters; this one is ${e.length}.`;if(As.test(e))return"A key label cannot contain control characters, including newlines and tabs.";return}function qr(e){let n=`${e.channel}:${e.peerId}`;return e.thread===void 0||e.thread===""?n:`${n}:${e.thread}`}var $s=/^[0-9a-hjkmnp-tv-z]{6}$/;function Vr(e,n){if(e===n)return!0;return e.startsWith(`${n}~`)&&$s.test(e.slice(n.length+1))}var Is=/~[0-9a-hjkmnp-tv-z]{6}$/;function ys(e,n){let s=n.get(e);if(s!==void 0)return s===e;if(Is.test(e))return[...n.values()].includes(e);return!0}var io=3932160,xt=5;function en(e){let n=(d)=>e[d]??-1;if(n(0)===137&&n(1)===80&&n(2)===78&&n(3)===71)return"image/png";if(n(0)===255&&n(1)===216&&n(2)===255)return"image/jpeg";if(n(0)===71&&n(1)===73&&n(2)===70&&n(3)===56)return"image/gif";let s=n(0)===82&&n(1)===73&&n(2)===70&&n(3)===70,o=n(8)===87&&n(9)===69&&n(10)===66&&n(11)===80;if(s&&o)return"image/webp";return}var Ks=/^[A-Za-z0-9+/]+={0,2}$/;async function Qs(e,n){if(n.length>xt)throw L("image_count_exceeded",`${n.length} images were sent with one message; at most ${xt} are.`,"Send the rest in a following message.");let s=[];for(let[o,d]of n.entries())s.push(await Xs(e,d,`images[${o}]`));return s}async function Xs(e,n,s){if(n.path!==void 0&&n.data!==void 0)throw L("image_source_ambiguous","An image named both a path and inline data.",'Send one: { "path": "files/…/shot.png" }, or { "data": "<base64>", "mediaType": "image/png" }.',s);if(n.path!==void 0)return await qs(e,n.path,s);if(n.data!==void 0)return Ys(n.data,n.mediaType,s);throw L("image_source_missing","An image named neither a path nor data.",`Send { "path": "files/…/shot.png" } (relative to the agent's directory), or { "data": "<base64>", "mediaType": "image/png" }.`,s)}async function qs(e,n,s){if(n.trim()===""||Hs(n))throw L("image_path_invalid",`The image path "${n}" is not relative to the agent's directory.`,"Name the file relative to the agent's directory, e.g. files/<conversation>/shot.png.",s);let o=Ie(e,n),d=Ie(e);if(o!==d&&!o.startsWith(`${d}${Rt}`))throw Lt(n,s);let l,c;try{c=await It(e),l=await It(Ie(e,n))}catch{throw L("image_not_found",`No file at "${n}" in the agent's directory.`,"Save the image inside the agent's directory first, then name it relative to that directory.",s)}if(l!==c&&!l.startsWith(`${c}${Rt}`))throw Lt(n,s);let u=await Ws(l);if(!u.isFile())throw L("image_not_found",`"${n}" is not a file.`,"Name an image file, not a directory.",s);if(u.size>io)throw tn(n,u.size,s);let h=new Uint8Array(await Cs(l)),m=en(h);if(m===void 0)throw nn(n,s);return{mediaType:m,data:Buffer.from(h).toString("base64"),ref:n}}function Ys(e,n,s){let o=e.replace(/\s+/g,"");if(o===""||o.length%4!==0||!Ks.test(o))throw L("image_data_invalid","The image's data is not base64.",`Send the file's bytes base64-encoded, with no "data:" prefix.`,s);let{mediaType:d}=zs(new Uint8Array(Buffer.from(o,"base64")),"upload",s);if(n!==void 0&&n!==d)throw L("image_media_type_mismatch",`The image was declared ${n} and its bytes are ${d}.`,"Leave mediaType out, or send the type the file really is.",s);return{mediaType:d,data:o,ref:"upload"}}function zs(e,n,s="image"){if(e.length>io)throw tn(n,e.length,s);let o=en(e);if(o===void 0)throw nn(n,s);return{mediaType:o,data:Buffer.from(e).toString("base64"),ref:n}}function Lt(e,n){return L("image_path_invalid",`The image path "${e}" leads outside the agent's directory.`,"Images are read from inside the agent's directory only. Copy the file there first.",n)}function tn(e,n,s){return L("image_too_large",`"${e}" is ${n} bytes; an image may be at most ${io}.`,"Resize or compress it first.",s)}function nn(e,n){return L("image_unsupported",`"${e}" is not a PNG, JPEG, GIF or WebP image.`,"Convert it to one of those formats first.",n)}var Vs="session:";function sn(e){return e.startsWith(Vs)}var Js="scope:";function rn(e){return e.startsWith(Js)}var Mt="0123456789abcdefghijklmnopqrstuvwxyz";function Zs(e){let n=new Uint8Array(e);crypto.getRandomValues(n);let s="";for(let o of n)s+=Mt[o%Mt.length];return s}function We(e,n){return`${e}_${n.toString(36)}${Zs(8)}`}function so(e=Date.now()){return We("t",e)}function ms(e=Date.now()){return We("r",e)}function Ss(e=Date.now()){return We("k",e)}var Dt="phase_set",on="*",Ct="tag:";function ws(e){let n=Object.keys(e);return n.find((o)=>e[o]?.entry===!0)??n[0]}function Ut(e){return e.toLowerCase().replace(/[\s_.-]+/g,"")}function an(e,n){if(e===on)return!0;if(e.startsWith(Ct)){let s=e.slice(Ct.length).toLowerCase();return n.tags.some((o)=>o.toLowerCase()===s)}return Ut(e)===Ut(n.slug)}function si(e,n){return e.filter((s)=>!n.some((o)=>an(s,o)))}function ii(e,n){let s=e[n];if(s===void 0)return[on];return s.allow.includes(Dt)?s.allow:[...s.allow,Dt]}function Wr(e){return e!==void 0&&Object.keys(e).length>1}function Ds(e,n){return Object.keys(e).filter((s)=>ii(e,s).some((o)=>an(o,n)))}var qt=["user","agent"];function zr(e,n=""){let s="",o=0;for(;;){let d=e.indexOf("<!--",o);if(d===-1)break;let l=e.indexOf("-->",d+4);if(l===-1)break;s+=e.slice(o,d)+n,o=l+3}return s+e.slice(o)}function ao(e){let n=e.length;while(n>0&&e[n-1]==="/")n-=1;return e.slice(0,n)}var ri=/^---\r?\n([\s\S]*?)\r?\n---[ \t]*(?:\r?\n|$)/,ai=/\n{3,}/g;function di(e){let n=ri.exec(e);return n===null||n===void 0?e:e.slice(n[0].length)}function li(e){return zr(e).replace(ai,`
36
+
37
+ `).trim()}var ae={static:2000,volatile:3500,reminder:500,total:6000};function ci(e){let n=e.files.filter((l)=>l.tier==="volatile");if(n.length===0)return;let s=(l)=>l.editable==="append"||l.editable==="replace",o=n.find((l)=>s(l)&&l.eviction==="oldest")??n.find(s);if(o!==void 0)return{path:o.path,name:o.name,mode:o.editable==="replace"?"replace":"append",budget:o.budget,eviction:o.eviction};let d=n[0];if(d===void 0)return;return{name:d.name,mode:"refused",reason:d.editable}}function le(e){return e.names.map((n,s)=>({name:n,path:dn(n)?n:ln(e.base,n),tier:e.tier,field:`${e.field}[${s}]`}))}function bs(e,n){let s=e.files??[],o=e.static??[];if(s.length>0&&o.length>0)throw nt();let d=dn(e.workspace)?e.workspace:ln(n,e.workspace),l=[],c=[];if(s.length>0)l.push(...le({base:n,names:s,tier:"static",field:"context.files"})),c.push({code:"context_files_deprecated",message:`context.files is deprecated; its ${s.length} file(s) were loaded as the static tier.`,hint:"Move them to context.static and set context.workspace to the directory holding them. The tier lists say which files are cache-stable, which the agent may write to, and which sit after the conversation history — none of which an ordered array can express.",field:"context.files"});if(l.push(...le({base:d,names:o,tier:"static",field:"context.static"})),l.push(...le({base:d,names:e.volatile??[],tier:"volatile",field:"context.volatile"})),e.reminder!==void 0)l.push(...le({base:d,names:[e.reminder],tier:"reminder",field:"context.reminder"}));return{refs:l,warnings:c}}var R=t().min(1),ui=i({delimiters:y(["xml","markdown","plain"]).optional(),intensity:y(["emphatic","neutral","soft"]).optional(),examplesIn:y(["system","user"]).optional(),skillsIn:y(["system","user"]).optional()}).strict(),hi=i({nativeTools:f().optional(),strictSchema:f().optional(),thinking:y(["none","anthropic","openai","deepseek"]).optional(),promptCache:y(["none","anthropic","openai","bedrock"]).optional(),parallelToolCalls:f().optional(),contextWindow:r().int().positive().optional(),maxOutput:r().int().positive().optional(),vision:f().optional(),promptStyle:ui.optional()}).strict(),Pt="chat-completions",cn=i({id:t().min(1),api:t().min(1).optional(),options:x(t(),me()).optional(),baseUrl:t().min(1).optional(),apiKeyEnv:t().min(1).optional(),temperature:r().min(0).max(2).optional(),topP:r().min(0).max(1).optional(),maxTokens:r().int().positive().optional(),reasoningEffort:y(["none","minimal","low","medium","high","xhigh","max"]).optional(),headers:x(t(),t()).optional(),streamUsage:f().optional(),capabilities:hi.optional()}).strict();function hn(e,n){if((e.api??Pt)===Pt&&e.baseUrl===void 0)n.addIssue({code:"custom",path:["baseUrl"],message:"baseUrl is required for the chat-completions transport"})}var fi=cn.superRefine(hn),ue=cn.extend({fallbacks:a(fi).min(1).optional()}).superRefine(hn),mi=i({main:ue,selector:ue.optional(),compactor:ue.optional()}).catchall(ue),pi=i({snip:r().default(0.6),micro:r().default(0.7),collapse:r().default(0.8),reset:r().default(0.88),trim:r().default(0.95)}).strict(),gi=i({static:r().int().positive().default(ae.static),volatile:r().int().positive().default(ae.volatile),reminder:r().int().positive().default(ae.reminder),total:r().int().positive().default(ae.total)}).strict(),yi=i({perRuleSuccess:r().gt(0).lte(1).default(0.9),reliabilityTarget:r().gt(0).lt(1).default(0.8),onExceed:y(["fail","warn"]).default("fail")}).strict(),wi=i({file:t().min(1),requires:i({contextWindow:t().min(1).optional(),class:y(["frontier","small"]).optional()}).strict().optional(),onUnmet:y(["distill","omit","fail"]).default("distill"),distilled:t().min(1).optional()}).strict(),bi=i({dir:t().min(1),maxActive:r().int().nonnegative().default(2),budget:r().int().positive().default(600)}).strict(),vi=i({window:r().int().positive().optional(),reserveOutput:r().int().positive().default(4096),observationMaxTokens:r().int().positive().optional(),modelIdentity:y(["shown","hidden"]).default("shown"),files:a(t().min(1)).default([]),workspace:t().min(1).default("./workspace"),static:a(t().min(1)).default([]),volatile:a(t().min(1)).default([]),reminder:t().min(1).optional(),budgets:gi.prefault({}),rules:yi.prefault({}),soul:wi.optional(),compactionNotice:f().optional(),thresholds:pi.prefault({})}).strict(),_i=i({max:r().int().positive().default(24),reserveWrite:r().int().nonnegative().default(6)}).strict(),Ti=i({onMutate:y(["refuse","confirm","allow"]).default("refuse")}).strict(),Ei=i({mode:y(["ask","allow","deny"]).default("allow"),allow:a(t().min(1)).default([]),deny:a(t().min(1)).default([]),onNoApprover:y(["deny","allow"]).default("deny")}).strict(),ki=i({dialect:y(["nlt","native"]).default("nlt"),providers:x(R,x(t(),me())).default({}),provider:R.optional(),providerConfig:x(t(),me()).default({}),budget:_i.prefault({}),pinned:a(t().min(1)).default([]),search:i({enabled:f().default(!1)}).strict().prefault({}),local:a(t().min(1)).default([]),untrusted:Ti.prefault({}),policy:Ei.prefault({}),eventDetail:y(["none","redacted"]).default("none")}).strict(),Si=i({allow:a(t().min(1)),entry:f().optional()}).strict(),$i=i({dir:t().min(1).default("./skills"),maxActive:r().int().nonnegative().default(1),threshold:r().default(0.35),trusted:a(t().min(1)).optional()}).strict(),Ni=i({retriever:t().min(1).default("fts5"),dir:t().min(1).default("./memory"),maxActive:r().int().nonnegative().default(5),threshold:r().default(0.2),budget:r().int().positive().default(2000),includeHistory:f().default(!0),shared:f().default(!0)}).strict(),Ii=["owner","peer","channel-peer"],Oi=i({scope:y(Ii).default("channel-peer")}).strict(),Ri=i({type:R,id:R,allowFrom:a(t().min(1)).optional(),enabled:f().default(!0),role:R.optional()}).passthrough(),fn=i({channel:R,to:t().min(1)}).strict(),xi=i({default:R.optional(),reply:y(["all","final"]).default("all"),targets:x(t(),fn).default({})}).strict(),ye=js(()=>i({type:y(["string","number","integer","boolean","array","object"]),description:t().optional(),enum:a(Xe([t(),r(),f()])).optional(),items:ye.optional(),properties:x(t(),ye).optional(),required:a(t()).optional()})),mn=i({id:R,manifest:t().min(1),task:t().min(1),artifact:i({type:de("object"),properties:x(t(),ye),required:a(t()).optional()}).strict()}).strict(),Li=i({members:a(mn).min(1)}).strict(),Mi=i({name:R,task:t().min(1),tools:a(t().min(1)).min(1),route:i({tools:a(t().min(1)).min(1)}).strict().optional(),spawn:f().default(!1),artifact:mn.shape.artifact.optional(),model:t().min(1).optional(),maxSteps:r().int().positive().optional(),timeoutMs:r().int().positive().optional()}).strict(),Oe={provider:t().min(1),model:t().min(1).optional(),baseUrl:t().min(1).optional(),apiKeyEnv:t().min(1).optional(),options:x(t(),me()).optional()},Di=i({transcription:i({...Oe,timeoutMs:r().int().positive().default(60000),maxBytes:r().int().positive().default(26214400)}).strict().optional(),speech:i({...Oe,timeoutMs:r().int().positive().default(60000),maxCharacters:r().int().positive().default(3000)}).strict().optional(),image:i({...Oe,timeoutMs:r().int().positive().default(120000),size:t().regex(/^[0-9]+x[0-9]+$/).default("1024x1024")}).strict().optional()}).strict(),Ci=i({enabled:f().default(!1),escalateAfterMs:r().int().nonnegative().default(0)}).strict(),Ui=i({offer:i({task:t().min(1),artifact:i({type:de("object"),properties:x(t(),ye),required:a(t()).optional()}).strict()}).strict().optional(),to:Xe([de("*"),a(R).min(1)]).optional(),ask:f().default(!1)}).strict(),pn=i({id:R,kind:y(["cron","every","at"]),expr:t().min(1),task:t().min(1),deliver:Xe([de("none"),fn]),session:t().min(1).default("isolated"),role:R.optional(),tools:i({allow:a(t().min(1)).min(1)}).strict().optional(),timeoutMs:r().int().positive().optional(),maxSteps:r().int().positive().optional(),enabled:f().default(!0),timezone:t().min(1).optional()}).strict(),Pi=Xe([t().min(1),i({spec:t().min(1),config:x(t(),me()).default({})}).strict()]),Fi=i({identicalCalls:r().int().min(2).default(3),sameTool:r().int().min(2).optional()}).strict(),ji=i({maxSteps:r().int().positive().default(40),noProgress:Fi.prefault({}),turnTimeoutMs:r().int().positive().default(1800000),toolTimeoutMs:r().int().positive().default(120000),maxParallelTools:r().int().positive().default(4),maxConcurrentTurns:r().int().positive().optional(),reloadHoldMs:r().int().nonnegative().default(30000),maxHops:r().int().nonnegative().default(4),tokens:i({max:r().int().positive(),windowMs:r().int().positive()}).strict().optional()}).strict(),Wi=i({enabled:f().default(!1),port:r().int().min(1).max(65535).default(7420),host:t().min(1).default("127.0.0.1"),tokenEnv:t().min(1).default(`${V.envPrefix}API_TOKEN`),allowedOrigins:a(t().min(1)).default([]),allowedHosts:a(t().min(1)).default([])}).strict(),Zr=i({apiVersion:t().min(1),id:R.refine((e)=>!e.startsWith("~"),{message:"An agent id may not start with `~`; that prefix is reserved for shared memory scopes."}),name:t().min(1).optional(),description:t().min(1).max(200,{message:"A description is one line of at most 200 characters; it is rendered into every peer's ask_agent description."}).refine((e)=>!/[\r\n]/.test(e),{message:"A description is one line; put the detail in AGENTS.md."}).optional(),extends:t().min(1).optional(),model:mi,context:vi.prefault({}),tools:ki.prefault({}),phases:x(t(),Si).optional(),skills:$i.optional(),knowledge:bi.optional(),memory:Ni.optional(),sessions:Oi.optional(),channels:a(Ri).default([]),delivery:xi.optional(),schedules:a(pn).default([]),team:Li.optional(),subagents:a(Mi).optional(),media:Di.optional(),standIn:Ci.optional(),delegation:Ui.optional(),plugins:a(Pi).default([]),limits:ji.prefault({}),server:Wi.prefault({})}).strict(),z=["main","selector","compactor"];function Bi(e){return z.includes(e)}function we(e){return Object.keys(e).filter((n)=>!Bi(n))}var Hi={nativeTools:!1,strictSchema:!1,thinking:"none",promptCache:"none",parallelToolCalls:!1,contextWindow:8192,maxOutput:4096},Re={nativeTools:!0,strictSchema:!1,thinking:"none",promptCache:"none",parallelToolCalls:!1,maxOutput:5000},xe={vision:!0,nativeTools:!0,strictSchema:!1,thinking:"anthropic",promptCache:"none",parallelToolCalls:!0},Le="Thinking blocks must be replayed with tool results or multi-step reasoning degrades silently. Prompt caching is unavailable on Anthropic's OpenAI-compatible endpoint; through OpenRouter the chat-completions transport sends cache_control itself (`sendsCacheControl`).",rl=[{pattern:"gpt-4o*",capabilities:{vision:!0,nativeTools:!0,strictSchema:!0,thinking:"none",promptCache:"openai",parallelToolCalls:!0,contextWindow:128000,maxOutput:16384}},{pattern:"gpt-4.1*",capabilities:{vision:!0,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-6*",capabilities:{vision:!0,nativeTools:!0,strictSchema:!0,thinking:"openai",promptCache:"openai",parallelToolCalls:!0,contextWindow:1050000,maxOutput:128000},note:"Window and output are reported figures, unverified here. Run `model probe` or override if your endpoint says otherwise."},{pattern:"gpt-5*",capabilities:{vision:!0,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*","claude-haiku-5*"].map((e)=>({pattern:e,capabilities:{...xe,contextWindow:1e6,maxOutput:128000},note:Le})),{pattern:"claude-haiku-*",family:!0,capabilities:{...xe,contextWindow:200000,maxOutput:64000},note:Le},{pattern:"claude-*",family:!0,capabilities:{...xe,contextWindow:200000,maxOutput:8192},note:Le},{pattern:"nova-micro*",capabilities:{...Re,contextWindow:128000}},{pattern:"nova-lite*",capabilities:{...Re,contextWindow:300000,vision:!0}},{pattern:"nova-pro*",capabilities:{...Re,contextWindow:300000,vision:!0}},{pattern:"gemini*",family:!0,capabilities:{vision:!0,nativeTools:!0,strictSchema:!1,thinking:"none",promptCache:"none",parallelToolCalls:!0,contextWindow:1e6,maxOutput:8192}},{pattern:"glm-5.3*",capabilities:{nativeTools:!0,strictSchema:!1,thinking:"deepseek",promptCache:"none",parallelToolCalls:!1,contextWindow:1048576,maxOutput:131072},note:"Reasoning is billed to the output budget, like the deepseek rows.",verified:"2026-10-21 via OpenRouter, provider z-ai/fp8"},{pattern:"qwen/qwen3.5*",capabilities:{nativeTools:!0,strictSchema:!1,thinking:"deepseek",promptCache:"none",parallelToolCalls:!1,contextWindow:262144,maxOutput:8192},note:"Reasoning is billed to the output budget, so context.reserveOutput must cover reasoning plus the reply.",verified:"2026-10-23 via OpenRouter, provider deepinfra/bf16 (published context_length 262,144)"},{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*",family:!0,capabilities:{nativeTools:!0,strictSchema:!1,thinking:"none",promptCache:"none",parallelToolCalls:!1,contextWindow:32768,maxOutput:8192}},{pattern:"llama*",family:!0,capabilities:{nativeTools:!0,strictSchema:!1,thinking:"none",promptCache:"none",parallelToolCalls:!1,contextWindow:128000,maxOutput:4096}},{pattern:"mistral*",family:!0,capabilities:{nativeTools:!0,strictSchema:!1,thinking:"none",promptCache:"none",parallelToolCalls:!1,contextWindow:32768,maxOutput:8192}},{pattern:"mixtral*",family:!0,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*",family:!0,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*",family:!0,capabilities:{nativeTools:!0,strictSchema:!1,thinking:"none",promptCache:"none",parallelToolCalls:!1,contextWindow:65536,maxOutput:8192}},{pattern:"gemma*",family:!0,capabilities:{nativeTools:!1,strictSchema:!1,thinking:"none",promptCache:"none",parallelToolCalls:!1,contextWindow:8192,maxOutput:4096}},{pattern:"phi*",family:!0,capabilities:{nativeTools:!1,strictSchema:!1,thinking:"none",promptCache:"none",parallelToolCalls:!1,contextWindow:16384,maxOutput:4096}},{pattern:"*",capabilities:Hi}];var Os={attempts:3,baseDelayMs:400,maxDelayMs:8000};var Ns={mode:"allow",allow:[],deny:[],onNoApprover:"deny"},Ki=[{pattern:/\brm\s+(?:-[\w-]+\s+)*-[\w]*[rR][\w]*f|\brm\s+(?:-[\w-]+\s+)*-[\w]*f[\w]*[rR]/i,what:"a recursive forced delete"},{pattern:/--no-preserve-root/i,what:"a delete that disables the root guard"},{pattern:/:\s*\(\s*\)\s*\{\s*:\s*\|\s*:\s*&\s*\}\s*;\s*:/,what:"a fork bomb"},{pattern:/\bmkfs(\.\w+)?\b/i,what:"a filesystem format"},{pattern:/\bdd\b[^\n]*\bof=\/dev\//i,what:"a raw write to a block device"}],Xi=/\s(?:\/|~|\$HOME|\/\*|~\/\*)\s*$/;function qi(e){for(let n of Ki){if(!n.pattern.test(e))continue;if(n.what.includes("recursive")&&!Xi.test(e))continue;return n.what}return}var Gi=/^([A-Za-z_][\w-]*)(?:\((.*)\)\s*)?$/,Yi=new Set(["command","path","file_path","url","content"]);function zi(e){let n=e.trim(),s=Gi.exec(n);if(s===null)return{why:"it is not of the form Tool or Tool(pattern)"};let o=s[1]??"",d=s[2];if(d!==void 0){let l=/^([A-Za-z_]\w*)\s*:/.exec(d)?.[1];if(l!==void 0&&Yi.has(l))return{why:`it addresses "${l}", which carries the whole call — a compound command or a renamed path defeats such a rule, so it would read as protection without being any`};return{rule:{source:n,slug:o,pattern:d.trim()}}}return{rule:{source:n,slug:o}}}function Vi(e){let n=[],s=(o)=>{let d=[];for(let l of o){let{rule:c,why:u}=zi(l);if(c!==void 0)d.push(c);else n.push({source:l,why:u??"it could not be read"})}return d};return{deny:s(e.deny),ask:[],allow:s(e.allow),rejected:n}}function Ji(e){let o=(e.endsWith(":*")?`${e.slice(0,-2)} *`:e).replace(/[.+?^${}()|[\]\\]/g,"\\$&").replace(/\\?\*/g,".*").replace(/ \.\*$/,"(?: .*)?");return new RegExp(`^${o}$`,"i")}var Ft=/^(?:timeout\s+\S+|time|nice(?:\s+-n\s+\S+)?|stdbuf(?:\s+-\S+)*|command|builtin)\s+/i;function Zi(e){let n=e.trim();for(let s=0;s<4&&Ft.test(n);s+=1)n=n.replace(Ft,"").trim();return n}var Qi=1e4,er=/&&|\|\||;|\||&|\n/;function $r(e){return e.split(er).map((n)=>Zi(n)).filter((n)=>n!=="")}function be(e,n,s){if(e.slug.toLowerCase()!==n.slug.toLowerCase())return!1;if(e.pattern===void 0)return!0;if(s===void 0)return!1;return Ji(e.pattern).test(s)}function tr(e,n,s){if(e.pattern===void 0)return e.slug.toLowerCase()===n.slug.toLowerCase();if(s.length===0)return be(e,n,n.match);return s.every((o)=>be(e,n,o))}function nr(e,n,s){if(e.pattern===void 0)return e.slug.toLowerCase()===n.slug.toLowerCase();if(s.length===0)return be(e,n,n.match);return s.some((o)=>be(e,n,o))}function Ms(e,n){let s=Vi(e),o=n.match;if(o!==void 0){let l=qi(o);if(l!==void 0)return{effect:"deny",reason:`${n.slug} was refused: this is ${l}, which is never permitted — not by an allow rule, not by any mode.`};if(o.length>Qi)return{effect:"ask",reason:`${n.slug} was too long to analyse (${o.length} characters), so it is being asked rather than matched.`}}let d=o===void 0?[]:$r(o);for(let l of s.deny)if(nr(l,n,d))return{effect:"deny",reason:`${n.slug} is denied by the rule ${l.source}.`,rule:l.source};for(let l of s.allow)if(tr(l,n,d))return{effect:"allow",reason:`${n.slug} is allowed by the rule ${l.source}.`,rule:l.source};switch(e.mode){case"allow":return{effect:"allow",reason:"No rule matched, and tools.policy.mode is allow."};case"deny":return{effect:"deny",reason:"No rule matched, and tools.policy.mode is deny."};default:return{effect:"ask",reason:`No rule matched ${n.slug}, so it needs an answer from a person.`}}}var cr=/^(?:[-*+]|\d+[.)])[ \t]+\S/,mr=/\*\*(\d{4})-(\d{2})-\d{2}T/;function Ue(e){let n=[],s=-1,o=(d)=>{if(s===-1)return;n.push({start:s,end:d,text:e.slice(s,d).join(`
38
+ `).trimEnd()}),s=-1};for(let d=0;d<e.length;d+=1){let l=e[d]??"";if(cr.test(l)){o(d),s=d;continue}if(s===-1)continue;if(l.trim()===""||/^[ \t]/.test(l))continue;o(d)}return o(e.length),n}function Pe(e){return vt(li(di(e)))}function gr(e,n){let s=mr.exec(e);if(s!==null)return`${s[1]}-${s[2]}.md`;let o=n.getUTCFullYear(),d=`${n.getUTCMonth()+1}`.padStart(2,"0");return`${o}-${d}.md`}function wr(e,n){let s=e.split(/\r?\n/),o=Ue(s),d=[],l=o,c=e,u=Pe(c);while(u>n&&l.length>1){let h=l[0];if(h===void 0)break;d.push(h),l=l.slice(1),c=br(s,d),u=Pe(c)}if(u<=n)return{evict:d,remaining:c,tokens:u};return{evict:d,remaining:c,tokens:u,shortfall:l.length<=1?`${u} tokens remain against a ${n}-token budget with one note left, so eviction cannot help`:`${u} tokens remain against a ${n}-token budget`}}function br(e,n){let s=new Set;for(let o of n)for(let d=o.start;d<o.end;d+=1)s.add(d);return e.filter((o,d)=>!s.has(d)).join(`
39
+ `).replace(/\n{3,}/g,`
40
+
41
+ `)}async function vr(e){let n=e.tags.length===0?"":` _(${e.tags.join(", ")})_`,s=`
42
+ - **${e.now.toISOString()}**${n} ${e.text}
43
+ `;return await gn(e.path,s,"utf8"),await yn(e)}async function yn(e){let n=await or(e.path,"utf8"),s=wr(n,e.budget);if(s.evict.length===0)return{file:e.name,evicted:0,archives:[],...s.shortfall===void 0?{}:{shortfall:s.shortfall}};let o=new Map;for(let d of s.evict){let l=gr(d.text,e.now);o.set(l,[...o.get(l)??[],d.text])}await rr(e.archiveDir,{recursive:!0});for(let[d,l]of o)await gn(lr(e.archiveDir,d),`${l.join(`
44
+ `)}
45
+ `,"utf8");return await ar(e.path,s.remaining,"utf8"),{file:e.name,evicted:s.evict.length,archives:[...o.keys()].sort(),...s.shortfall===void 0?{}:{shortfall:s.shortfall}}}var _e="local",Ht="memory",Kt="notes.md",_r={spec:{slug:"now",provider:_e,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,n){let s=n.now(),o=typeof e.timezone==="string"&&e.timezone!==""?e.timezone:"UTC";if(e.format==="human")return`${new Intl.DateTimeFormat("en-GB",{dateStyle:"full",timeStyle:"short",timeZone:o}).format(s)} (${o})`;if(o==="UTC")return s.toISOString();return`${Tr(s,o)} (${o})`}};function Tr(e,n){let s=new Intl.DateTimeFormat("en-CA",{timeZone:n,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,timeZoneName:"longOffset"}).formatToParts(e),o=(l)=>s.find((c)=>c.type===l)?.value??"",d=o("timeZoneName").replace("GMT","");return`${o("year")}-${o("month")}-${o("day")}T${o("hour")}:${o("minute")}:${o("second")}${d===""?"Z":d}`}var kr={spec:{slug:"memory_write",provider:_e,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,n){let s=typeof e.text==="string"?e.text.trim():"",o=Array.isArray(e.tags)?e.tags.map((h)=>String(h)):[],d=n.now().toISOString(),l=o.length===0?"":` _(${o.join(", ")})_`,c=`
46
+ - **${d}**${l} ${s}
47
+ `;if(n.writeNote!==void 0)return await n.writeNote(o.length===0?s:`${s} (${o.join(", ")})`);let u=await Ar(s,o,c,n);if(n.shareNote===void 0)return u;return`${u} ${await n.shareNote(o.length===0?s:`${s} (${o.join(", ")})`)}`}};async function Ar(e,n,s,o){let d=o.writeTarget;if(d?.mode==="refused")throw st(d.name,d.reason??"none");if(d?.path!==void 0){if(d.budget!==void 0&&o.memoryDir!==void 0&&d.eviction==="oldest"){let c=await vr({path:d.path,name:d.name,budget:d.budget,archiveDir:o.memoryDir,text:e,tags:n,now:o.now()});if(c.shortfall!==void 0)return`Saved to ${c.file}, but it is still over budget: ${c.shortfall}. Ask the person to raise the budget or shorten the file — the agent will not load until they do.`;if(c.evicted===0)return`Saved to ${c.file}.`;return`Saved to ${c.file}. Moved ${c.evicted} older ${c.evicted===1?"note":"notes"} into ${c.archives.join(", ")}, still searchable.`}if(await Wt(d.path,s,"utf8"),d.budget!==void 0){let c=Pe(await ir(d.path,"utf8"))-d.budget;if(c>0)return`Saved to ${d.name}, which is now ${c} tokens over its ${d.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 ${d.name}.`}let l=Bt(o.dir,Ht);return await sr(l,{recursive:!0}),await Wt(Bt(l,Kt),s,"utf8"),`Saved to ${Ht}/${Kt}.`}var Sr=1200,Nr=Sr*3,Or={spec:{slug:"artifact_read",provider:_e,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,n){let s=typeof e.id==="string"?e.id.trim():"",o=typeof e.from==="number"&&e.from>0?Math.floor(e.from):0;if(n.readArtifact===void 0)throw ot();let d=await n.readArtifact(s);if(d===void 0)throw at(s);let l=d.slug===void 0?"observation":`${d.slug} observation`,c=d.content.slice(o,o+Nr),u=o+c.length,h=`Compacted ${l}, ${d.tokens} tokens${o===0?"":`, from character ${o}`}:`;if(u>=d.content.length)return`${h}
48
+ ${c}`;return`${h}
49
+ ${c}
50
+
51
+ [cut here — ${d.content.length-u} characters remain; continue with artifact_read(id, from: ${u})]`},trustOf:(e)=>bt(typeof e.id==="string"?e.id.trim():"")};var Rr=30,xr={spec:{slug:"memory_forget",provider:_e,summary:"Finds and deletes saved notes, and what was said in past conversations.",whenToUse:"the person asks you to forget something you noted. Call it with `query` first, show the person what matched, then call it with the `ids` they confirm",whenNotToUse:"to tidy notes nobody asked you to remove, or with `ids` you have not shown the person",mutating:!0,tags:["write","memory"],parameters:{type:"object",properties:{query:{type:"string",description:"Words every matching note or past message contains, case-insensitive. Lists matches; deletes nothing."},ids:{type:"array",items:{type:"string"},description:"Ids from a previous listing (notes and conversation messages). Deletes exactly these."}}}},async handler(e,n){let s=typeof e.query==="string"?e.query.trim():"",o=Array.isArray(e.ids)?e.ids.map((h)=>String(h).trim()).filter((h)=>h!==""):[];if(s===""===(o.length===0))throw it();if(n.forgetMemory===void 0)throw rt();let d=(h)=>h==="space"?"the team's shared memory":"your notes";if(s!==""){let h=await n.forgetMemory({query:s});if(h.notes.length===0)return`No note in ${d(h.scope)} contains "${s}".`;let m=h.notes.slice(0,Rr),g=h.notes.length>m.length?`
52
+ ${h.notes.length-m.length} more match; use more words to narrow it down.`:"";return[`${h.notes.length} ${h.notes.length===1?"note":"notes"} in ${d(h.scope)} ${h.notes.length===1?"matches":"match"}. Nothing is deleted yet: show these to the person, then call memory_forget with the ids they confirm.`,...m.map((p)=>`- ${p.id} (${p.source}): ${p.text}`)].join(`
53
+ `)+g}let l=await n.forgetMemory({ids:o}),c=l.notes.length===0?`Nothing was deleted from ${d(l.scope)}.`:`Deleted ${l.notes.length} ${l.notes.length===1?"note":"notes"} from ${d(l.scope)}; they will not be recalled again.`,u=l.missing.length===0?"":` No note has ${l.missing.length===1?"the id":"the ids"} ${l.missing.join(", ")}: already gone, or not yours to delete here.`;return c+u}},Lr=[_r,kr,xr,Or],cl=Lr.map((e)=>e.spec.slug);class Vt extends ne{static ERROR_NAME="MediaError"}function Me(e,n,s,o){let d=s.get(n.provider);if(d===void 0)throw new B({code:"media_provider_unknown",message:`${e}.provider is "${n.provider}", and no media provider by that name is registered. Registered: ${[...s.keys()].sort().join(", ")}.`,hint:n.provider==="aws"?"Amazon Transcribe and Nova Canvas come from the media-aws plugin, which the CLI and the image include. An embedder calling the runtime directly passes it in `builtInPlugins`.":'Use "openai" for any endpoint speaking the OpenAI audio and image routes, or add the plugin that provides this one.',field:`${e}.provider`});let l=n.options;if(d.optionsSchema!==void 0&&n.options!==void 0){let m=d.optionsSchema.safeParse(n.options);if(!m.success)throw new B({code:"media_provider_options_invalid",message:`${e}.options are not valid for the ${n.provider} provider: ${m.error.issues?.[0]?.message??"invalid"}.`,hint:`See the ${n.provider} media provider's documentation for the fields it takes.`,field:`${e}.options`});l=m.data}let c=d.create({field:e,config:n,options:l,env:o.env,...o.fetch===void 0?{}:{fetch:o.fetch}}),[u,h]=e==="media.transcription"?[c.transcribe,"transcribe audio"]:e==="media.speech"?[c.synthesize,"speak text"]:[c.generateImage,"generate images"];if(u===void 0)throw new B({code:"media_provider_incapable",message:`The ${n.provider} media provider does not ${h}.`,hint:"Name a provider that does in this section; the two sections may name different providers.",field:`${e}.provider`});return c}var Fr={"audio/ogg":"ogg","audio/opus":"ogg","audio/mpeg":"mp3","audio/mp4":"m4a","audio/x-m4a":"m4a","audio/aac":"m4a","audio/wav":"wav","audio/x-wav":"wav","audio/webm":"webm","audio/flac":"flac"};function jr(e){return Fr[e.split(";")[0]?.trim().toLowerCase()??""]??"ogg"}async function he(e,n,s){let o=(await e.text().catch(()=>"")).slice(0,300);return new Vt({code:"media_provider_refused",message:`${n} was refused (${e.status}): ${o}`,hint:e.status===401||e.status===403?`Check the key in the env var ${s}.apiKeyEnv names, and that it may use this model.`:"The provider's own words are above.",field:s})}var Hr={create(e){let{config:n,field:s}=e,o=ao(n.baseUrl??"https://api.openai.com/v1"),d=n.apiKeyEnv??"OPENAI_API_KEY",l=e.env[d];if(l===void 0||l==="")throw new B({code:"media_key_missing",message:`${s} needs ${d}, which is not set.`,hint:`Put the endpoint's key in ${d}, in the environment or the .env beside the manifest, or name another variable with ${s}.apiKeyEnv.`,field:`${s}.apiKeyEnv`});let c=e.fetch??((h,m)=>fetch(h,m)),u=`Bearer ${l}`;return{async transcribe(h,m){let g=new FormData;g.set("file",new Blob([h.bytes],{type:h.mimeType}),`voice.${jr(h.mimeType)}`),g.set("model",n.model??"whisper-1");let p=await c(`${o}/audio/transcriptions`,{method:"POST",headers:{authorization:u},body:g,signal:m});if(!p.ok)throw await he(p,"The transcription",s);let w=await p.json();return{text:typeof w.text==="string"?w.text:"",...typeof w.duration==="number"?{durationS:w.duration}:{}}},async synthesize(h,m){let g=n.options??{},p=await c(`${o}/audio/speech`,{method:"POST",headers:{authorization:u,"content-type":"application/json"},body:JSON.stringify({model:n.model??"gpt-4o-mini-tts",voice:typeof g.voice==="string"?g.voice:"alloy",input:h.text,response_format:"opus"}),signal:m});if(!p.ok)throw await he(p,"The speech request",s);return{bytes:new Uint8Array(await p.arrayBuffer()),mimeType:"audio/ogg; codecs=opus",characters:h.text.length}},async generateImage(h,m){let g=await c(`${o}/images/generations`,{method:"POST",headers:{authorization:u,"content-type":"application/json"},body:JSON.stringify({model:n.model??"gpt-image-1",prompt:h.prompt,size:h.size,n:1}),signal:m});if(!g.ok)throw await he(g,"The image request",s);let w=(await g.json()).data?.[0];if(w?.b64_json!==void 0)return{bytes:Buffer.from(w.b64_json,"base64"),mimeType:"image/png"};if(w?.url!==void 0){let b=await c(w.url,{signal:m});if(!b.ok)throw await he(b,"Downloading the image",s);return{bytes:new Uint8Array(await b.arrayBuffer()),mimeType:b.headers.get("content-type")??"image/png"}}throw new Vt({code:"media_provider_empty",message:"The image endpoint answered with no image.",hint:"Some endpoints return an empty list for a refused prompt. Rephrasing it is usually what works.",field:s})}}}},Kr=new Map([["openai",Hr]]);function Gr(e,n){let s=new Map([...Kr,...n.providers??[]]),o=e.media?.transcription,d=e.media?.image,l=e.media?.speech;return{...l===void 0?{}:{speech:{config:l,provider:Me("media.speech",l,s,n)}},...o===void 0?{}:{transcription:{config:o,provider:Me("media.transcription",o,s,n)}},...d===void 0?{}:{image:{config:d,provider:Me("media.image",d,s,n)}}}}function wn(e){let n=e.providers??{},s=Object.keys(n),o=e.provider,d=e.providerConfig??{};if(s.length>0&&(o!==void 0||Object.keys(d).length>0))throw tt(s,o);if(o!==void 0)return{selections:[{id:o,config:d,legacy:!0}],warnings:[{code:"tools_provider_deprecated",message:`tools.provider is deprecated; "${o}" was loaded as tools.providers.${o}.`,hint:`Rewrite it as:
54
+ tools:
55
+ providers:
56
+ ${o}: { … the contents of providerConfig … }
57
+ 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 l=s.map((c)=>({id:c,config:n[c]??{},legacy:!1}));if(Object.keys(d).length>0)return{selections:l,warnings:[{code:"tools_provider_config_orphaned",message:`tools.providerConfig has ${Object.keys(d).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:l,warnings:[]}}var Xt=new Map;function bn(e){let n=Xt.get(e);if(n!==void 0)return n;let s;try{s=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(o){throw new B({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:o})}return Xt.set(e,s),s}function Yr(e){bn(e)}function ve(e,n){let s=bn(e).formatToParts(new Date(n)),o=(u)=>{let h=s.find((m)=>m.type===u);return h===void 0?0:Number(h.value)},d=o("year"),l=o("month"),c=o("day");return{year:d,month:l,day:c,hour:o("hour"),minute:o("minute"),second:o("second"),weekday:new Date(Date.UTC(d,l-1,c)).getUTCDay()}}function Jr(e,n){return ve(e,n)}function Gt(e,n){let s=ve(e,n);return Date.UTC(s.year,s.month-1,s.day,s.hour,s.minute,s.second)-(n-n%1000)}function eo(e,n){let s=Date.UTC(n.year,n.month-1,n.day,n.hour,n.minute,n.second),o=s-Gt(e,s);o=s-Gt(e,o);let d=ve(e,o);if(!(d.year===n.year&&d.month===n.month&&d.day===n.day&&d.hour===n.hour&&d.minute===n.minute&&d.second===n.second))return;let c=o-3600000,u=ve(e,c);return u.year===n.year&&u.month===n.month&&u.day===n.day&&u.hour===n.hour&&u.minute===n.minute&&u.second===n.second?c:o}function to(){return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}var no=1462,vn=["jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"],oo=["sun","mon","tue","wed","thu","fri","sat"],q={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:vn,label:"month"},dayOfWeek:{min:0,max:7,names:oo,label:"day of week"}};function U(e,n,s,o){throw new B({code:"schedule_cron_malformed",message:`"${e}" is not a valid cron expression: ${n}`,hint:s,field:o})}function De(e,n,s,o){let d=n.names?.indexOf(e.toLowerCase());if(d!==void 0&&d!==-1)return d+(n.names===vn?1:0);if(!/^\d+$/.test(e))U(s,`"${e}" is not a ${n.label}.`,n.names===void 0?`The ${n.label} field takes numbers ${n.min}-${n.max}, ranges, steps and comma lists.`:`The ${n.label} field takes ${n.min}-${n.max} or a name (${n.names.slice(0,3).join(", ")}…).`,o);let l=Number(e);if(l<n.min||l>n.max)U(s,`${l} is outside the ${n.label} range ${n.min}-${n.max}.`,`Check the field order: ${n.label==="second"?"second minute hour day-of-month month day-of-week":"minute hour day-of-month month day-of-week"}.`,o);return l}function G(e,n,s,o){let d=new Set,l=!0;for(let c of e.split(",")){let u=c.trim();if(u==="")U(s,"an empty entry in a comma list.","Remove the stray comma.",o);let[h="",m]=u.split("/",2),g=m===void 0?1:Number(m);if(m!==void 0&&(!/^\d+$/.test(m)||g<1))U(s,`"${m}" is not a step.`,"A step is a whole number above zero, as in */15.",o);let p,w;if(h==="*"){if(p=n.min,w=n.max,g===1)l=!1}else if(h.includes("-")){let[b="",v=""]=h.split("-",2);if(p=De(b,n,s,o),w=De(v,n,s,o),p>w)U(s,`the range ${h} runs backwards.`,"Write the lower bound first, or use a comma list to wrap around.",o)}else p=De(h,n,s,o),w=m===void 0?p:n.max;for(let b=p;b<=w;b+=g)d.add(b)}if(d.size===0)U(s,"it matches nothing.","Every field must admit at least one value.",o);return{values:d,restricted:l}}function lo(e,n){let s=e.trim();if(s.startsWith("@"))U(s,"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.',n);let o=s.split(/\s+/).filter((O)=>O!=="");if(o.length!==5&&o.length!==6)U(s,`it has ${o.length} field${o.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.",n);let d=o.length===6,[l,c,u,h,m,g]=d?o:["0",...o],p=G(l??"0",q.second,s,n),w=G(c??"",q.minute,s,n),b=G(u??"",q.hour,s,n),v=G(h??"",q.dayOfMonth,s,n),E=G(m??"",q.month,s,n),k=G(g??"",q.dayOfWeek,s,n),I=new Set;for(let O of k.values)I.add(O===7?0:O);return{seconds:p.values,minutes:w.values,hours:b.values,daysOfMonth:v.values,months:E.values,daysOfWeek:I,domRestricted:v.restricted,dowRestricted:k.restricted,source:s}}function uo(e,n,s){let o=e.daysOfMonth.has(n),d=e.daysOfWeek.has(s);if(e.domRestricted&&e.dowRestricted)return o||d;if(e.domRestricted)return o;if(e.dowRestricted)return d;return!0}function zt(e,n,s,o){let d=new Date(Date.UTC(e,n-1,s+o));return[d.getUTCFullYear(),d.getUTCMonth()+1,d.getUTCDate()]}function ho(e,n,s){return new Date(Date.UTC(e,n-1,s)).getUTCDay()}function PA(e,n,s){let o=Jr(s,n+1000),d=new Date(Date.UTC(o.year,o.month-1,o.day+no)),[l,c,u]=[o.year,o.month,o.day],h=!0;while(Date.UTC(l,c-1,u)<=d.getTime()){if(!e.months.has(c)){[l,c,u]=c===12?[l+1,1,1]:[l,c+1,1],h=!1;continue}if(!uo(e,u,ho(l,c,u))){[l,c,u]=zt(l,c,u,1),h=!1;continue}for(let m of[...e.hours].sort((g,p)=>g-p)){if(h&&m<o.hour)continue;for(let g of[...e.minutes].sort((p,w)=>p-w)){if(h&&m===o.hour&&g<o.minute)continue;for(let p of[...e.seconds].sort((w,b)=>w-b)){if(h&&m===o.hour&&g===o.minute&&p<o.second)continue;let w=eo(s,{year:l,month:c,day:u,hour:m,minute:g,second:p});if(w!==void 0)return w}}}[l,c,u]=zt(l,c,u,1),h=!1}return}var fo=/^(\d+)(s|m|h|d)$/,mo={s:1000,m:60000,h:3600000,d:86400000},po=1000,yo=315360000000;function wo(e,n){let s=fo.exec(e.trim());if(s===null)throw new B({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:n});let o=Number(s[1]),d=s[2]??"",l=o*(mo[d]??0);if(l<po)throw new B({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:n});if(l>yo)throw new B({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:n});return{ms:l,source:e.trim()}}var bo=315360000000,vo=900000,Ce=1000;function yr(e){let n=e.timezone??to();Yr(n);let s=e.expr.trim();if(e.kind==="cron"){let d=lo(s,e.field);if(PA(d,e.now,n)===void 0)throw new B({code:"schedule_cron_unsatisfiable",message:`"${s}" 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:d,zone:n,source:s}}if(e.kind==="every")return{kind:"every",every:wo(s,e.field),zone:n,source:s};let o=Date.parse(s);if(Number.isNaN(o))throw new B({code:"schedule_at_malformed",message:`"${s}" 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(o>e.now+bo)throw new B({code:"schedule_at_too_far",message:`${s} 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:o,zone:n,source:s}}function _o(e){let n=2166136261;for(let s=0;s<e.length;s+=1)n^=e.charCodeAt(s),n=Math.imul(n,16777619)>>>0;return n}function Xr(e,n){if(n===void 0||n<=0)return 0;let s=Math.min(Math.floor(n/10),vo);return s<=0?0:_o(e)%s}function To(e,n){if(e.kind==="every")return e.every.ms;if(e.kind==="at")return;let s=PA(e.spec,n,e.zone);if(s===void 0)return;let o=PA(e.spec,s,e.zone);return o===void 0?void 0:o-s}function Eo(e,n,s,o,d={}){if(e.kind==="at"){if(d.consumed===!0)return{runAt:void 0,anchor:void 0,missed:0,missedCapped:!1,late:!1};if(e.at<=o)return{runAt:o,anchor:e.at,missed:0,missedCapped:!1,late:!0};return{runAt:e.at,anchor:e.at,missed:0,missedCapped:!1,late:!1}}let l=Xr(n,To(e,s));if(e.kind==="every"){let m=o-s,g=m<=0?0:Math.floor(m/e.every.ms),p=Math.min(g,Ce),w=g+1,b=s+w*e.every.ms;return{runAt:b+l,anchor:b,missed:p,missedCapped:g>Ce,late:!1}}let c=s,u=0,h=!1;for(;;){let m=PA(e.spec,c,e.zone);if(m===void 0)return{runAt:void 0,anchor:void 0,missed:u,missedCapped:h,late:!1};if(m+l>o)return{runAt:m+l,anchor:m,missed:u,missedCapped:h,late:!1};if(c=m,u+=1,u>=Ce){h=!0;let g=PA(e.spec,o,e.zone);return{runAt:g===void 0?void 0:g+l,anchor:g,missed:u,missedCapped:!0,late:!1}}}}function ko(e,n,s){let o=[],d=Array.isArray(e.schedules)?e.schedules:[],l=new Set((Array.isArray(e.channels)?e.channels:[]).map((m)=>m!==null&&typeof m==="object"&&!Array.isArray(m)?m.id:void 0).filter((m)=>typeof m==="string")),c=new Set([...z,...we(n.model)]),u=new Set,h=new Set;for(let[m,g]of d.entries()){if(g===null||typeof g!=="object"||Array.isArray(g))continue;let p=g,w=typeof p.id==="string"?p.id:`[${m}]`;if(h.has(w))o.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[${m}].id`});h.add(w);let b=p.deliver;if(b===void 0)o.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[${m}].deliver`});else if(b!=="none"&&typeof b==="object"&&!Array.isArray(b)){let k=b.channel;if(typeof k==="string"&&!l.has(k))o.push({code:"schedule_delivery_channel_unknown",message:`Schedule "${w}" delivers to "${k}", which is not a channel id on this agent.${l.size===0?" The agent declares no channels.":` Declared: ${[...l].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[${m}].deliver.channel`})}let v=p.role;if(typeof v==="string"){if(u.add(v),!c.has(v))o.push({code:"schedule_role_unknown",message:`Schedule "${w}" names the model role "${v}", which is not declared under model:. Declared: ${[...c].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[${m}].role`})}let E=n.schedules[m];if(E!==void 0)try{yr({id:E.id,kind:E.kind,expr:E.expr,timezone:E.timezone,now:s,field:`schedules[${m}].expr`})}catch(k){if(!(k instanceof ne))throw k;o.push(k.toDetail())}}for(let m of n.subagents??[])u.add(m.model??"subagent");for(let m of we(n.model)){if(u.has(m))continue;if(Yt(m,z)===void 0)continue;o.push({code:"model_role_unreferenced",message:`model.${m} is declared but no schedule names it, so nothing will ever use it.`,hint:`If "${m}" was meant to be one of ${z.join(", ")}, it is misspelled — and the misspelled one is silently falling back to main. Otherwise point a schedule at it with role: ${m}, or remove it.`,field:`model.${m}`})}return o}function Ao(e){let n=[],s=new Set([...e.tools.pinned,...e.tools.local]),o=new Set([...z,...we(e.model)]),d=new Set,l=new Map;for(let[c,u]of(e.subagents??[]).entries()){let h=`subagents[${c}]`;if(d.has(u.name))n.push({code:"subagent_name_duplicate",message:`Two subagents are called "${u.name}".`,hint:"Give each subagent its own name: it is how events, sessions and usage rows say which child ran.",field:`${h}.name`});d.add(u.name);let m=u.tools.filter((g)=>!s.has(g));if(m.length>0)n.push({code:"subagent_tool_not_pinned",message:`Subagent "${u.name}" lists ${m.join(", ")}, which this agent does not pin.`,hint:"A subagent may only use tools its parent has, so it can never act with more authority than the parent. Add the slug to tools.pinned (or tools.local), or remove it from the subagent.",field:`${h}.tools`});if(u.route===void 0&&!u.spawn)n.push({code:"subagent_unreachable",message:`Subagent "${u.name}" declares neither route nor spawn, so nothing can start it.`,hint:"Add route: {tools: [<slug>]} to run it for those calls, or spawn: true to let the model start it with delegate.",field:h});for(let g of u.route?.tools??[]){if(!u.tools.includes(g))n.push({code:"subagent_route_outside_tools",message:`Subagent "${u.name}" routes ${g} but does not list it under tools, so it could not make the call it is handed.`,hint:`Add ${g} to subagents[${c}].tools.`,field:`${h}.route.tools`});let p=l.get(g);if(p!==void 0&&p!==u.name)n.push({code:"subagent_route_duplicate",message:`${g} is routed to both "${p}" and "${u.name}".`,hint:"A routed call runs exactly one child. Route the slug from one subagent only.",field:`${h}.route.tools`});l.set(g,u.name)}if(u.model!==void 0&&!o.has(u.model))n.push({code:"subagent_role_unknown",message:`Subagent "${u.name}" names the model role "${u.model}", which is not declared under model:. Declared: ${[...o].join(", ")}.`,hint:"Add the role under model:, or remove model: from the subagent to use model.subagent (or main).",field:`${h}.model`})}return n}function So(e){let n=new Set([...z,...we(e.model)]);return(e.channels??[]).flatMap((s,o)=>s.role===void 0||n.has(s.role)?[]:[{code:"channel_role_unknown",message:`Channel "${s.id}" names the model role "${s.role}", which is not declared under model:. Declared: ${[...n].join(", ")}.`,hint:"Add the role under model:, or point the channel at one of the declared roles. Omit role to run its turns on main.",field:`channels[${o}].role`}])}function _n(e){if(typeof e!=="string")return String(e);let n=/^[A-Za-z0-9_./@~-]+$/.test(e),s=/^[A-Za-z0-9_./]/.test(e);if(!n||!s)return JSON.stringify(e);try{return ce(e)===e?e:JSON.stringify(e)}catch{return JSON.stringify(e)}}function oe(e){return e.length-e.trimStart().length}function Be(e){let n=e.trim();return n===""||n.startsWith("#")}function He(e,n,s,o){let d=new RegExp(`^\\s{${s}}${n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*:`);for(let l=o;l<e.length;l+=1){let c=e[l]??"";if(Be(c))continue;if(oe(c)<s)return;if(oe(c)===s&&d.test(c))return l}return}function fe(e,n,s){let o=n;for(let d=n+1;d<e.length;d+=1){let l=e[d]??"";if(Be(l))continue;if(oe(l)<=s)break;o=d}return o}function $o(e){let n;for(let s=0;s<e.length;s+=1){let o=e[s];if(n!==void 0){if(o===n)n=void 0;continue}if(o==='"'||o==="'"){n=o;continue}if(o!=="#"||s===0||!/\s/.test(e[s-1]??""))continue;let d=s;while(d>0&&/\s/.test(e[d-1]??""))d-=1;return e.slice(d)}return""}function Ke(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function J(e,n,s){let o=" ".repeat(s);if(Array.isArray(n)){if(n.length===0)return[`${o}${e}: []`];return[`${o}${e}:`,...n.flatMap((d)=>No(d,s+2))]}if(Ke(n)){let d=Object.entries(n);if(d.length===0)return[`${o}${e}: {}`];return[`${o}${e}:`,...d.flatMap(([l,c])=>J(l,c,s+2))]}return[`${o}${e}: ${_n(n)}`]}function No(e,n){let s=" ".repeat(n);if(!Ke(e))return[`${s}- ${_n(e)}`];let o=Object.entries(e);if(o.length===0)return[`${s}- {}`];let d=o.flatMap(([u,h])=>J(u,h,n+2)),[l,...c]=d;return[`${s}- ${(l??"").trimStart()}`,...c]}function Tn(e,n){let s=0,o=0,d,l=0;for(;l<n.length-1;l+=1){let c=He(e,n[l]??"",o,s);if(c===void 0)break;d=c,s=c+1;let u=e.slice(c+1).find((h)=>!Be(h)&&oe(h)>o);if(u===void 0)return;o=oe(u)}return{searchFrom:s,indent:o,parent:d,depth:l}}function En(e,n){if(n.length===0)return;let s=e.split(`
58
+ `),o=Tn(s,n);if(o===void 0)return;if(o.depth<n.length-1)return e;let d=He(s,n[n.length-1]??"",o.indent,o.searchFrom);if(d===void 0)return e;let l=fe(s,d,o.indent),c=[...s.slice(0,d),...s.slice(l+1)].join(`
59
+ `),u=n.slice(0,-1);if(u.length>0&&X(c).getIn([...u])==null)return En(c,u)??c;return c}function Io(e,n,s){if(n.length===0)return;let o=e.split(`
60
+ `),d=Tn(o,n);if(d===void 0)return;let{searchFrom:l,indent:c,parent:u,depth:h}=d;if(h<n.length-1){if(u===void 0)return;let w=fe(o,u,c-1)+1;return[...o.slice(0,w),...kn(n.slice(h),s,c),...o.slice(w)].join(`
61
+ `)}let m=n[n.length-1]??"",g=He(o,m,c,l);if(g!==void 0){let w=o[g]??"",b=Array.isArray(s)||Ke(s)?"":$o(w),v=fe(o,g,c),E=J(m,s,c);if(b!=="")E[0]=`${E[0]}${b}`;return[...o.slice(0,g),...E,...o.slice(v+1)].join(`
62
+ `)}if(u===void 0)return;let p=fe(o,u,c-1)+1;return[...o.slice(0,p),...J(m,s,c),...o.slice(p)].join(`
63
+ `)}function kn(e,n,s){let[o,...d]=e;if(o===void 0)return[];if(d.length===0)return J(o,n,s);return[`${" ".repeat(s)}${o}:`,...kn(d,n,s+Oo)]}var Oo=2;function Ro(e,n,s){let o=e.split(`
64
+ `),d=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),l=new RegExp(`^#\\s*${d}\\s*:`),c=o.findIndex((m)=>l.test(m));if(c===-1)return;let u=c;while(/^#\s{2,}\S/.test(o[u+1]??""))u+=1;let h=/^#\s*Phase \d/.test(o[c-1]??"")?c-1:c;return[...o.slice(0,h),...J(n,s,0),...o.slice(u+1)].join(`
65
+ `)}function xo(e,n){let s=[...n.path],o=s.join("."),d=qe(X(e),s),l=n.remove===!0?En(e,s):Io(e,s,n.value)??n.fallback?.(e)??(s.length===1?Ro(e,s[0]??"",n.value):void 0),c;if(l===void 0){let p=X(e);if(n.remove===!0)p.deleteIn(s);else p.setIn(s,n.value);c=String(p)}else c=l;let u=X(c);if(u.errors.length>0)throw Y(o,`the result is not valid YAML — ${u.errors[0]?.message??"unparseable"}`);let h=Zr.safeParse(u.toJS());if(!h.success){let p=h.error.issues[0];throw Y(o,`${p?.path.join(".")??o}: ${p?.message??"does not fit the schema"}`)}let g=ko(u.toJS(),h.data,Date.now())[0]??So(h.data)[0]??Ao(h.data)[0];if(g!==void 0)throw Y(o,`${g.message} ${g.hint}`);try{wn(h.data.tools)}catch(p){throw Y(o,p instanceof Error?p.message:"the providers block does not resolve")}return{next:c,before:d,reflowed:l===void 0,manifest:h.data}}async function Ts(e){let{edits:n}=await ei(e.file,[e]);return n[0]}async function ei(e,n){let s;try{s=await Mr(e,"utf8")}catch(l){throw Mo(e,l)}let o=Lo(s,e,n),d=o.next!==s;if(d)await Dr(e,o.next,"utf8");return{edits:o.edits,written:d}}function Lo(e,n,s){let o=e,d=[];for(let l of s){let c={...l,file:n},u=xo(o,c),h=!Pr(u.before,qe(X(u.next),c.path));if(h)Do(c,u.manifest),Co(c,u.manifest),o=u.next;d.push({before:u.before,after:c.remove===!0?void 0:c.value,reflowed:h&&u.reflowed,manifest:u.manifest,changed:h})}return{next:o,edits:d}}function go(e){let n=e.trim();if(n==="")return"";let s=X(n);if(s.errors.length>0)throw new ne({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 s.toJS()}function ti(e,n){return qe(X(e),n)}function Rs(e){return X(e).toJS()}function qe(e,n){let s=e.getIn([...n],!1);if(s===void 0||s===null)return;return ht(s)||Ot(s)?s.toJS(e):s}function Mo(e,n){return new ne({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:n})}function Do(e,n){let s=e.providers;if(s===void 0||!e.path.join(".").startsWith("tools.provider"))return;for(let o of wn(n.tools).selections){let d=s[o.id];if(d===void 0)throw Y(e.path.join("."),`no tool provider called "${o.id}" is available here. Available: ${Object.keys(s).join(", ")||"(none)"}.`);let l;try{l=d({dir:Ur(e.file),env:{},config:o.config,agentId:n.id})}catch(c){if(_(c))throw c;throw Y(e.path.join("."),`the ${o.id} provider refused its config: ${c instanceof Error?c.message:String(c)}`)}l.stop?.()}}function Co(e,n){if(e.mediaProviders===void 0||e.path[0]!=="media")return;for(let s of["transcription","image","speech"]){let o=n.media?.[s];if(o===void 0)continue;try{Gr({...n,media:{[s]:o}},{env:{},providers:new Map(Object.entries(e.mediaProviders))})}catch(d){if(_(d)&&d.code==="media_key_missing")continue;throw d}}}function Y(e,n){return new ne({code:"manifest_edit_invalid",message:`Setting ${e} would make the manifest invalid: ${n}`,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 sA=[{path:"tools.local",means:"built-in tools: now, memory_write, memory_forget, 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:"description",means:"what this agent is for, in one line of at most 200 characters. The person's other agents see it beside this one in ask_agent",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:"model.main.maxTokens",means:"the most one reply may generate; unset lets the endpoint decide",agentListed:!1},{path:"tools.budget.max",means:"how many tools the model is shown at once, built-ins included",agentListed:!1},{path:"model.main.reasoningEffort",means:"none | minimal | low | medium | high | xhigh | max — how hard a reasoning model thinks",agentListed:!1},{path:"model.main",means:"the main model as a whole role, {api, id, baseUrl or options, apiKeyEnv, capabilities, ...}; replaces it in one write",agentListed:!1},{path:"model.<role>",means:"a named model role, {id, api or baseUrl, apiKeyEnv, ...}; a schedule or message runs on it with role: <name>",agentListed:!1},{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},...["static","volatile","reminder","total"].map((e)=>({path:`context.budgets.${e}`,means:`token budget for the ${e==="total"?"whole workspace":`${e} tier`}; a file over it stops the agent loading`,agentListed:!1})),{path:"limits.noProgress",means:"when a turn is stopped for going nowhere, as a map: {identicalCalls: <n, default 3>, sameTool: <n, off when absent>}",agentListed:!1},{path:"limits.noProgress.sameTool",means:"stop a turn after this many calls in a row to one tool, whatever the arguments. Absent, off",agentListed:!1},{path:"context.modelIdentity",means:"shown or hidden: whether the agent can see which model it runs on (hidden keeps tuning settable)",agentListed:!1},{path:"context.window",means:"the token budget for a whole request; unset uses the model's known window",agentListed:!1},{path:"context.observationMaxTokens",means:"how much of a tool's output reaches the model",agentListed:!0},{path:"tools.eventDetail",means:"none | redacted — whether tool events carry the call's arguments and output",agentListed:!1},{path:"context.rules.onExceed",means:"fail | warn — whether too many counted rules in the workspace refuses the load",agentListed:!1},{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:"delivery.reply",means:"channel replies: all (every step's text, default) or final (the last step's only)",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:"media",means:"voice notes, spoken replies and images: {transcription, speech, image}, each {provider: openai|aws, model, apiKeyEnv, options}",toAgent:"image adds image_generate after a restart; filling in the key variable is the person's",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:"delegation.offer",means:`what this agent takes on when another member's agent asks it, as a map: {task: "<one line>", artifact: {type: object, properties: {...}, required: [...]}}. The agents whose delegation.to names this one are reloaded so their roster shows it`,agentListed:!1},{path:"delegation.to",means:`the other members' agents this one may ask, by id, or "*" for every agent that offers. A peer ask is one hop: the asked agent answers, and cannot ask onward`,agentListed:!1},{path:"delegation.ask",means:"true or false: this agent asks the person's other agents (ask_agent) and they may ask it. Both have to say yes; an agent assigned to nobody that says yes is a shared agent anyone's agent may ask",agentListed:!1},{path:"sessions.scope",means:"how a turn's conversation is chosen: channel-peer (one per surface, the default), owner (the owner's turns from every surface share one), or peer (owner, and every registered participant gets one too)",agentListed:!1},{path:"memory.shared",means:"read and write the memory this agent's owner's agents share (agents:<owner>). Default true; false keeps memory_write private",agentListed:!1},{path:"subagents",means:"children that run work in their own context, as a list of {name, task, tools, route?: {tools}, spawn?, model?, maxSteps?, timeoutMs?}. route runs a child for those tool calls; spawn: true lets the model start it with delegate. Each tool must be pinned, and each routed slug belongs to one child",agentListed:!1},{path:"skills.trusted",means:"the skills whose scripts may run, by name. A skill not listed is still used for its steps, and its scripts are documentation only. Absent, every skill's scripts run",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 un(e){return sA.find((n)=>n.path===e)}var Uo=/^model\.([A-Za-z][\w-]*)$/;function co(e){let n=un(e);if(n!==void 0)return GA.includes(n.path)?n:void 0;let s=Uo.exec(e)?.[1];return s===void 0||s==="main"?void 0:un("model.<role>")}var Ai=sA.filter((e)=>e.agentListed).map((e)=>e.path),GA=sA.filter((e)=>e.via===void 0&&!e.path.includes("<")&&!e.path.includes("[")).map((e)=>e.path);var An={kind:"public"};function Sn(e){let n=e.split(".");if(n.length!==4)return;let s=[];for(let o of n){if(o.length===0||o.length>3||!/^[0-9]+$/.test(o))return;if(o.length>1&&o.startsWith("0"))return;let d=Number(o);if(d>255)return;s.push(d)}return s}function Po(e){let n=e.split("%")[0]??"";if(n==="")return;if(!/^[0-9a-fA-F:.]+$/.test(n))return;let s=n.split("::");if(s.length>2)return;let o=(u)=>{if(u==="")return[];let h=u.split(":"),m=[];for(let g=0;g<h.length;g+=1){let p=h[g]??"";if(p.includes(".")){if(g!==h.length-1)return;let b=Sn(p);if(b===void 0)return;m.push(...b);continue}if(p.length===0||p.length>4)return;let w=Number.parseInt(p,16);if(Number.isNaN(w))return;m.push(w>>8&255,w&255)}return m};if(s.length===1){let u=o(n);return u!==void 0&&u.length===16?u:void 0}let d=o(s[0]??""),l=o(s[1]??"");if(d===void 0||l===void 0)return;let c=16-d.length-l.length;if(c<0)return;return[...d,...Array(c).fill(0),...l]}function Fe(e){let[n=0,s=0,o=0,d=0]=e;if(n===0)return{kind:"unspecified",range:"0.0.0.0/8"};if(n===127)return{kind:"loopback",range:"127.0.0.0/8"};if(n===10)return{kind:"private",range:"10.0.0.0/8"};if(n===172&&s>=16&&s<=31)return{kind:"private",range:"172.16.0.0/12"};if(n===192&&s===168)return{kind:"private",range:"192.168.0.0/16"};if(n===100&&s>=64&&s<=127)return{kind:"cgnat",range:"100.64.0.0/10"};if(n===169&&s===254)return{kind:"link-local",range:"169.254.0.0/16"};if(n===192&&s===0&&o===0)return{kind:"reserved",range:"192.0.0.0/24"};if(n===192&&s===0&&o===2)return{kind:"reserved",range:"192.0.2.0/24 (TEST-NET-1)"};if(n===198&&(s===18||s===19))return{kind:"reserved",range:"198.18.0.0/15"};if(n===198&&s===51&&o===100)return{kind:"reserved",range:"198.51.100.0/24 (TEST-NET-2)"};if(n===203&&s===0&&o===113)return{kind:"reserved",range:"203.0.113.0/24 (TEST-NET-3)"};if(n>=224&&n<=239)return{kind:"multicast",range:"224.0.0.0/4"};if(n===255&&s===255&&o===255&&d===255)return{kind:"reserved",range:"255.255.255.255"};if(n>=240)return{kind:"reserved",range:"240.0.0.0/4"};return An}function Fo(e){if(e.length!==16)return{kind:"reserved",range:"unparseable"};if(e.slice(0,10).every((l)=>l===0)&&e[10]===255&&e[11]===255)return Fe(e.slice(12));if(e[0]===0&&e[1]===100&&e[2]===255&&e[3]===155&&e.slice(4,12).every((l)=>l===0))return Fe(e.slice(12));if(e.every((l)=>l===0))return{kind:"unspecified",range:"::"};if(e.slice(0,15).every((l)=>l===0)&&e[15]===1)return{kind:"loopback",range:"::1"};let o=e[0]??0,d=e[1]??0;if((o&254)===252)return{kind:"private",range:"fc00::/7"};if(o===254&&(d&192)===128)return{kind:"link-local",range:"fe80::/10"};if(o===255)return{kind:"multicast",range:"ff00::/8"};if(o===32&&d===1&&e[2]===13&&e[3]===184)return{kind:"reserved",range:"2001:db8::/32"};return An}function Qr(e){let n=e.startsWith("[")&&e.endsWith("]")?e.slice(1,-1):e,s=Sn(n);if(s!==void 0)return Fe(s);let o=Po(n);if(o!==void 0)return Fo(o);return}var ni=["agent","model","day","sender"];var vl=["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(`
66
+ `);var je=1,ge=["MEMORY.md","memory/","knowledge/"],Nn=/^[^/\\.][^/\\]*\.md$/;function P(e,n,s,o){return new ne({code:e,message:n,hint:s,...o===void 0?{}:{field:o}})}function In(e){let n=ci(e.workspace),s=(o)=>Ho(o)?o:Ko(e.dir,o);return{...n?.path===void 0||n.mode==="refused"?{}:{carried:{path:n.path,name:n.name,...n.budget===void 0?{}:{budget:n.budget},...n.eviction===void 0?{}:{eviction:n.eviction}}},...e.manifest.memory===void 0?{}:{memoryDir:s(e.manifest.memory.dir)},...e.manifest.knowledge===void 0?{}:{knowledgeDir:s(e.manifest.knowledge.dir)}}}function Ge(e){if(e===void 0)return[];try{return Wo(e).filter((n)=>Nn.test(n)&&!sn(n)&&!rn(n)).sort()}catch{return[]}}function _s(e){if(e===void 0||e.length===0)return ge;return e.map((n,s)=>{let o=ge.find((d)=>d===n);if(o===void 0)throw P("bundle_path_not_allowed",`"${n}" is not something a bundle can carry.`,`A bundle carries ${ge.join(", ")} and nothing else — never the manifest, secrets or skills.`,`paths.${s}`);return o})}function ks(e,n=ge,s=new Date){let o=In(e),d=[];if(n.includes("MEMORY.md")&&o.carried!==void 0&&$n(o.carried.path))d.push({path:"MEMORY.md",content:re(o.carried.path,"utf8")});for(let[l,c]of[["memory/",o.memoryDir],["knowledge/",o.knowledgeDir]]){if(!n.includes(l)||c===void 0)continue;for(let u of Ge(c))d.push({path:`${l}${u}`,content:re(Te(c,u),"utf8")})}return{version:je,agentId:e.id,exportedAt:s.toISOString(),files:d}}function Xo(e,n,s){let o=`files.${n}.path`;if(e.path==="MEMORY.md"){if(s.carried===void 0)throw P("bundle_memory_not_writable","This agent has no writable memory file to merge MEMORY.md into.","Give a volatile workspace file `editable: append` or `replace`, or export without MEMORY.md.",o);return{abs:s.carried.path,kind:"carried"}}let d=e.path.indexOf("/"),l=e.path.slice(0,d+1),c=e.path.slice(d+1);if(!(l==="memory/"||l==="knowledge/")||!Nn.test(c)||sn(c)||rn(c))throw P("bundle_path_not_allowed",`"${e.path}" is not a path a bundle can carry.`,"A bundle carries MEMORY.md, memory/<name>.md and knowledge/<name>.md — one level, markdown only, never the manifest, secrets or skills.",o);let h=l==="memory/"?s.memoryDir:s.knowledgeDir;if(h===void 0)throw P(l==="memory/"?"bundle_no_memory":"bundle_no_knowledge",`This agent has no ${l==="memory/"?"memory":"knowledge"} block, so "${e.path}" has nowhere to go.`,`Add a \`${l==="memory/"?"memory":"knowledge"}:\` block to the manifest, or export without ${l}.`,o);return{abs:Te(h,c),kind:l==="memory/"?"memory":"knowledge"}}function qo(e,n){let s=new Set(Ue(e.split(/\r?\n/)).map((o)=>o.text));return Ue(n.split(/\r?\n/)).map((o)=>o.text).filter((o)=>!s.has(o))}async function vs(e){let n=e.now??new Date,s=e.mode??"skip",o=Yo(e.bundle),d=In(e.agent),l=o.map((v,E)=>({file:v,...Xo(v,E,d)})),c=new Map,u=(v)=>{if(!c.has(v))c.set(v,$n(v)?re(v,"utf8"):void 0)};for(let v of l)u(v.abs);for(let v of Ge(d.memoryDir))u(Te(d.memoryDir??"",v));if(d.carried!==void 0)u(d.carried.path);let h=[],m=[],g=[],p=[],w=0,b=!1;try{for(let{file:k,abs:I,kind:O}of l){jo(Bo(I),{recursive:!0});let F=c.get(I);if(O==="knowledge"){if(F===k.content||F!==void 0&&s==="skip"){g.push(k.path);continue}pe(I,k.content,"utf8"),(F===void 0?h:p).push(k.path),b=!0;continue}if(F===void 0){pe(I,k.content,"utf8"),h.push(k.path),b||=O==="carried";continue}let W=qo(re(I,"utf8"),k.content);if(W.length===0){g.push(k.path);continue}pe(I,`${re(I,"utf8").trimEnd()}
67
+
68
+ ${W.join(`
69
+ `)}
70
+ `,"utf8"),m.push({path:k.path,notes:W.length}),b||=O==="carried"}let v=d.carried;if(b&&v?.eviction==="oldest"&&v.budget!==void 0&&d.memoryDir!==void 0)w=(await yn({path:v.path,name:v.name,budget:v.budget,archiveDir:d.memoryDir,now:n})).evicted;let E=b?await e.reload():"none";return{added:h,merged:m,skipped:g,overwritten:p,evicted:w,reload:E}}catch(v){if(Go(c,d.memoryDir),!_(v))throw v;throw new ne({code:"bundle_import_refused",message:`Nothing was imported: the agent would not load with this bundle. ${v.message}`,hint:v.hint,...v.field===void 0?{}:{field:v.field}})}}function Go(e,n){for(let[s,o]of e)if(o===void 0)Zt(s,{force:!0});else pe(s,o,"utf8");for(let s of Ge(n)){let o=Te(n??"",s);if(!e.has(o))Zt(o,{force:!0})}}function Yo(e){let n=typeof e==="object"&&e!==null?e:{};if(n.version!==je)throw P("bundle_version_unsupported",`This bundle is version ${JSON.stringify(n.version)}; this build reads version ${je}.`,"Export the bundle again with GET /v1/agents/:id/export on a build that matches.","version");if(!Array.isArray(n.files))throw P("bundle_files_invalid","A bundle needs a `files` list.",'Send the body GET /v1/agents/:id/export returned: { "version": 1, "files": [{ "path", "content" }] }.',"files");let s=new Set;return n.files.map((o,d)=>{let l=typeof o==="object"&&o!==null?o:{};if(typeof l.path!=="string"||typeof l.content!=="string")throw P("bundle_files_invalid",`files.${d} needs a string \`path\` and a string \`content\`.`,"Each entry is { path, content }, as an export writes it.",`files.${d}`);if(s.has(l.path))throw P("bundle_files_invalid",`"${l.path}" appears twice.`,"A bundle names each path once.",`files.${d}.path`);return s.add(l.path),{path:l.path,content:l.content}})}var Qt="agent:";function oi(e){return e.startsWith(Qt)?e.slice(Qt.length):void 0}var El=(()=>{let e=Symbol.for(`${V.slug}.liveRuntimes`),n=globalThis;return n[e]??=new Set,n[e]})();var zo="id, session_key, turn_id, role, content, tool_calls, tool_call_id, origin, tainted, created_at",kl=zo.split(", ").map((e)=>`m.${e}`).join(", ");function Ls(){let e=new Uint8Array(24);return crypto.getRandomValues(e),`whsec_${Buffer.from(e).toString("base64")}`}function Ps(e){return e!=="model.chunk"}var Vo="schedule";function Gs(e,n,s){if(e.startsWith("shared:")){let o=e.slice(7);if(o!=="")return o}return qr({channel:Vo,peerId:n,thread:s})}function Fs(e){let n=pn.safeParse(e.body);if(!n.success){let h=n.error.issues[0];throw new B({code:"schedule_invalid",message:`Schedule rejected: ${h?.path.join(".")??"body"} ${h?.message??"is invalid"}.`,hint:"A schedule needs id, kind (cron|every|at), expr, task and deliver. See docs/02-SPEC-MANIFEST.md.",...h?.path.length===void 0||h.path.length===0?{}:{field:h.path.join(".")}})}let s=n.data;if(s.deliver!=="none"){if(!e.channelIds.includes(s.deliver.channel))throw new B({code:"schedule_delivery_channel_unknown",message:`Schedule "${s.id}" delivers to "${s.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(s.role!==void 0&&!e.roleNames.includes(s.role))throw new B({code:"schedule_role_unknown",message:`Schedule "${s.id}" names the model role "${s.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 o=s.tools?.allow;if(o!==void 0&&e.toolSpecs!==void 0){let h=si(o,e.toolSpecs);if(h.length>0)throw dt(s.id,h,e.toolSpecs.map((m)=>m.slug),"tools.allow")}let d=yr({id:s.id,kind:s.kind,expr:s.expr,timezone:s.timezone,now:e.now,field:"expr"}),l=new Date(e.now).toISOString(),c=Eo(d,s.id,e.now,e.now),u=s.deliver==="none"?void 0:s.deliver;return{agentId:e.agentId,id:s.id,kind:s.kind,expr:s.expr,...s.timezone===void 0?{}:{timezone:s.timezone},task:s.task,...u===void 0?{}:{deliverChannel:u.channel,deliverTo:u.to},sessionMode:s.session,...s.role===void 0?{}:{role:s.role},toolsAllow:s.tools?.allow,timeoutMs:s.timeoutMs,maxSteps:s.maxSteps,enabled:s.enabled,origin:e.origin,anchorAt:c.anchor===void 0?l:new Date(c.anchor).toISOString(),nextRunAt:c.runAt===void 0?void 0:new Date(c.runAt).toISOString(),sourcePath:"",now:l}}function Us(e){return{...e.role===void 0?{}:{role:e.role},...e.toolsAllow===void 0?{}:{toolsAllow:e.toolsAllow},...e.maxSteps===void 0?{}:{maxSteps:e.maxSteps},...e.timeoutMs===void 0?{}:{timeoutMs:e.timeoutMs}}}async function xs(e,n,s,o){if(n.deliverChannel===void 0||n.deliverTo===void 0)return;let d=o.attachments??[];if(o.text.trim()===""&&d.length===0)return;await e.deliver({agentId:n.agentId,sessionKey:s,channelId:n.deliverChannel,recipient:n.deliverTo,text:o.text,turnId:o.turnId,...d.length===0?{}:{attachments:d}})}var Al=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(" "));
71
+ export{V,Yt,_,ne,B,gt,S,Ir,Ye,dr,ur,jt,Jt,Er,fr,ro,pr,Cr,hr,Br,Bs,qr,Vr,ys,io,Qs,so,ms,Ss,ws,Wr,Ds,qt,zr,ao,bs,Zr,Os,Ns,$r,Ms,Vt,PA,yr,Xr,Ts,ei,go,ti,Rs,sA,un,co,Ai,GA,Qr,ni,_s,ks,vs,oi,Ls,Ps,Gs,Fs,Us,xs};
72
+
73
+ //# debugId=D35A0EC8ED7B708064756E2164756E21
74
+ //# sourceMappingURL=index-bhj4pmrx.js.map