dispach 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (195) hide show
  1. package/README.md +134 -85
  2. package/dist/App-qfqvx9c7.js +11 -0
  3. package/dist/{App-b1yrwrcq.js.map → App-qfqvx9c7.js.map} +6 -7
  4. package/dist/ConfigEditor-apcnj4nj.js +6 -0
  5. package/dist/{ConfigEditor-n8hdw6r7.js.map → ConfigEditor-apcnj4nj.js.map} +2 -2
  6. package/dist/KeyProbe-ya5t3v3v.js +5 -0
  7. package/dist/{KeyProbe-9jjeze5r.js.map → KeyProbe-ya5t3v3v.js.map} +2 -2
  8. package/dist/Picker-b7mn0mjg.js +5 -0
  9. package/dist/{Picker-hfeh1g6m.js.map → Picker-b7mn0mjg.js.map} +1 -1
  10. package/dist/SessionPicker-vacfwczg.js +5 -0
  11. package/dist/{SessionPicker-zyqkg4dn.js.map → SessionPicker-vacfwczg.js.map} +2 -2
  12. package/dist/SkillBrowser-66ntwaa9.js +5 -0
  13. package/dist/{SkillBrowser-3qdp8080.js.map → SkillBrowser-66ntwaa9.js.map} +1 -1
  14. package/dist/WizardApp-123998yh.js +5 -0
  15. package/dist/{WizardApp-vzpbydy3.js.map → WizardApp-123998yh.js.map} +3 -3
  16. package/dist/agents.d.ts +19 -3
  17. package/dist/agents.d.ts.map +1 -1
  18. package/dist/channels-q4fwqq87.js +31 -0
  19. package/dist/channels-q4fwqq87.js.map +10 -0
  20. package/dist/channels.d.ts +26 -0
  21. package/dist/channels.d.ts.map +1 -0
  22. package/dist/client.js +10 -10
  23. package/dist/client.js.map +3 -3
  24. package/dist/config-64q4mgxc.js +24 -0
  25. package/dist/{config-g7za9x13.js.map → config-64q4mgxc.js.map} +2 -2
  26. package/dist/{credential-npr6z8c8.js → credential-2sj7vsmw.js} +5 -5
  27. package/dist/{credential-npr6z8c8.js.map → credential-2sj7vsmw.js.map} +1 -1
  28. package/dist/daemon.d.ts.map +1 -1
  29. package/dist/index-0k3w2mxf.js +6 -0
  30. package/dist/{index-hwpvhaza.js.map → index-0k3w2mxf.js.map} +1 -1
  31. package/dist/index-1s81qstp.js +6 -0
  32. package/dist/{index-v8e92nfw.js.map → index-1s81qstp.js.map} +1 -1
  33. package/dist/index-2rycma8x.js +12 -0
  34. package/dist/{index-258d8bzg.js.map → index-2rycma8x.js.map} +4 -3
  35. package/dist/index-2zye08c4.js +6 -0
  36. package/dist/{index-vgc3y3rm.js.map → index-2zye08c4.js.map} +2 -2
  37. package/dist/{index-gme2egyq.js → index-3km1jwh7.js} +4 -4
  38. package/dist/{index-gme2egyq.js.map → index-3km1jwh7.js.map} +1 -1
  39. package/dist/index-3mtgcvkq.js +429 -0
  40. package/dist/index-3mtgcvkq.js.map +11 -0
  41. package/dist/index-4knb5vjm.js +90 -0
  42. package/dist/index-4knb5vjm.js.map +13 -0
  43. package/dist/{index-3g3ny01d.js → index-5nwwekk0.js} +4 -4
  44. package/dist/{index-3g3ny01d.js.map → index-5nwwekk0.js.map} +1 -1
  45. package/dist/index-5rm7dwq4.js +6 -0
  46. package/dist/index-5rm7dwq4.js.map +11 -0
  47. package/dist/index-79epttpm.js +6 -0
  48. package/dist/index-79epttpm.js.map +10 -0
  49. package/dist/{index-4cf6v9nb.js → index-7yk1zvds.js} +4 -4
  50. package/dist/{index-4cf6v9nb.js.map → index-7yk1zvds.js.map} +1 -1
  51. package/dist/index-81gb4ey4.js +6 -0
  52. package/dist/{index-4z7axw4r.js.map → index-81gb4ey4.js.map} +1 -1
  53. package/dist/index-8a5d8sfe.js +6 -0
  54. package/dist/{index-0d93hyfc.js.map → index-8a5d8sfe.js.map} +1 -1
  55. package/dist/index-a21zyy54.js +6 -0
  56. package/dist/index-a21zyy54.js.map +9 -0
  57. package/dist/index-b6da6c16.js +92 -0
  58. package/dist/index-b6da6c16.js.map +15 -0
  59. package/dist/index-byxrc961.js +903 -0
  60. package/dist/{index-tv4yv7d2.js.map → index-byxrc961.js.map} +16 -15
  61. package/dist/{index-ammv5st7.js → index-cgfg6t5a.js} +6 -6
  62. package/dist/{index-ammv5st7.js.map → index-cgfg6t5a.js.map} +1 -1
  63. package/dist/{index-s9mbq7h6.js → index-ehzwdnc3.js} +4 -4
  64. package/dist/{index-s9mbq7h6.js.map → index-ehzwdnc3.js.map} +1 -1
  65. package/dist/index-fzmmhmk2.js +7 -0
  66. package/dist/index-fzmmhmk2.js.map +11 -0
  67. package/dist/index-g3pk0kc0.js +6 -0
  68. package/dist/{index-9r0wyj6w.js.map → index-g3pk0kc0.js.map} +2 -2
  69. package/dist/index-h828nk24.js +153 -0
  70. package/dist/index-h828nk24.js.map +20 -0
  71. package/dist/{index-02dn6m2j.js → index-jq999vcw.js} +5 -5
  72. package/dist/{index-02dn6m2j.js.map → index-jq999vcw.js.map} +2 -2
  73. package/dist/index-k2aq5bg0.js +9 -0
  74. package/dist/{index-6p999cx4.js.map → index-k2aq5bg0.js.map} +4 -6
  75. package/dist/{index-cqqb6gaq.js → index-k3y8y3wj.js} +5 -5
  76. package/dist/{index-cqqb6gaq.js.map → index-k3y8y3wj.js.map} +1 -1
  77. package/dist/index-k59wwdgz.js +9 -0
  78. package/dist/{index-ff514z3y.js.map → index-k59wwdgz.js.map} +3 -5
  79. package/dist/index-nmnnwa02.js +6 -0
  80. package/dist/{index-6q4wf8e3.js.map → index-nmnnwa02.js.map} +1 -1
  81. package/dist/index-nn3tk25c.js +6 -0
  82. package/dist/{index-d4x6yvqh.js.map → index-nn3tk25c.js.map} +3 -4
  83. package/dist/index-q0hxh57v.js +126 -0
  84. package/dist/index-q0hxh57v.js.map +14 -0
  85. package/dist/index-srmhk9g5.js +11 -0
  86. package/dist/index-srmhk9g5.js.map +11 -0
  87. package/dist/index-swtyfhha.js +6 -0
  88. package/dist/{index-fex44816.js.map → index-swtyfhha.js.map} +2 -2
  89. package/dist/index-whq42sat.js +6 -0
  90. package/dist/{index-h9mw7b9d.js.map → index-whq42sat.js.map} +1 -1
  91. package/dist/{index-j7gyr5nx.js → index-wzsmh5j0.js} +7 -7
  92. package/dist/{index-j7gyr5nx.js.map → index-wzsmh5j0.js.map} +1 -1
  93. package/dist/{index-j55s3ehk.js → index-x7v1zq89.js} +7 -7
  94. package/dist/{index-j55s3ehk.js.map → index-x7v1zq89.js.map} +2 -2
  95. package/dist/index-xhzmv4dh.js +66 -0
  96. package/dist/index-xhzmv4dh.js.map +12 -0
  97. package/dist/index-xmv47vs0.js +6 -0
  98. package/dist/{index-gz9x25tz.js.map → index-xmv47vs0.js.map} +2 -2
  99. package/dist/index-y4c32wn7.js +6 -0
  100. package/dist/{index-qdbq8crg.js.map → index-y4c32wn7.js.map} +2 -2
  101. package/dist/index-yjcdp72k.js +6 -0
  102. package/dist/{index-tf71ap9v.js.map → index-yjcdp72k.js.map} +1 -1
  103. package/dist/index-zn24991r.js +6 -0
  104. package/dist/index-zn24991r.js.map +10 -0
  105. package/dist/index.js +374 -443
  106. package/dist/index.js.map +23 -27
  107. package/dist/init.d.ts.map +1 -1
  108. package/dist/lib/channel-actions.d.ts +103 -0
  109. package/dist/lib/channel-actions.d.ts.map +1 -0
  110. package/dist/lib/chat-frame.d.ts +12 -1
  111. package/dist/lib/chat-frame.d.ts.map +1 -1
  112. package/dist/lib/commands.d.ts +13 -0
  113. package/dist/lib/commands.d.ts.map +1 -1
  114. package/dist/lib/const.d.ts +1 -1
  115. package/dist/lib/host-actions.d.ts +121 -0
  116. package/dist/lib/host-actions.d.ts.map +1 -0
  117. package/dist/lib/init-flow.d.ts +32 -0
  118. package/dist/lib/init-flow.d.ts.map +1 -1
  119. package/dist/lib/init-whatsapp.d.ts +52 -0
  120. package/dist/lib/init-whatsapp.d.ts.map +1 -0
  121. package/dist/lib/plugin-install.d.ts +120 -0
  122. package/dist/lib/plugin-install.d.ts.map +1 -0
  123. package/dist/lib/providers.d.ts.map +1 -1
  124. package/dist/lib/provision.d.ts.map +1 -1
  125. package/dist/lib/readme-table.d.ts +15 -0
  126. package/dist/lib/readme-table.d.ts.map +1 -0
  127. package/dist/lib/sandbox.d.ts +15 -0
  128. package/dist/lib/sandbox.d.ts.map +1 -1
  129. package/dist/lib/schema.d.ts +34 -1
  130. package/dist/lib/schema.d.ts.map +1 -1
  131. package/dist/lib/subcommand.d.ts.map +1 -1
  132. package/dist/lib/web-url.d.ts +15 -0
  133. package/dist/lib/web-url.d.ts.map +1 -0
  134. package/dist/lib/wizard.d.ts.map +1 -1
  135. package/dist/memory.d.ts.map +1 -1
  136. package/dist/model.d.ts.map +1 -1
  137. package/dist/plugins.d.ts +27 -8
  138. package/dist/plugins.d.ts.map +1 -1
  139. package/dist/restart.d.ts +21 -0
  140. package/dist/restart.d.ts.map +1 -0
  141. package/dist/run.d.ts.map +1 -1
  142. package/dist/schedules.d.ts.map +1 -1
  143. package/dist/serve.d.ts.map +1 -1
  144. package/dist/sessions.d.ts.map +1 -1
  145. package/dist/skills.d.ts.map +1 -1
  146. package/dist/status.d.ts +16 -0
  147. package/dist/status.d.ts.map +1 -0
  148. package/dist/tools.d.ts.map +1 -1
  149. package/dist/validate.d.ts.map +1 -1
  150. package/dist/web-923c7f5e.js +14 -0
  151. package/dist/{web-vkb16r62.js.map → web-923c7f5e.js.map} +3 -3
  152. package/dist/web.d.ts +2 -13
  153. package/dist/web.d.ts.map +1 -1
  154. package/dist/workspace.d.ts.map +1 -1
  155. package/dist/wrapper-0w9b3my0.js +11 -0
  156. package/dist/wrapper-0w9b3my0.js.map +23 -0
  157. package/package.json +6 -3
  158. package/dist/App-b1yrwrcq.js +0 -11
  159. package/dist/ConfigEditor-n8hdw6r7.js +0 -6
  160. package/dist/KeyProbe-9jjeze5r.js +0 -5
  161. package/dist/Picker-hfeh1g6m.js +0 -5
  162. package/dist/SessionPicker-zyqkg4dn.js +0 -5
  163. package/dist/SkillBrowser-3qdp8080.js +0 -5
  164. package/dist/WizardApp-vzpbydy3.js +0 -5
  165. package/dist/config-g7za9x13.js +0 -24
  166. package/dist/index-0d93hyfc.js +0 -6
  167. package/dist/index-1c5113t4.js +0 -66
  168. package/dist/index-1c5113t4.js.map +0 -12
  169. package/dist/index-258d8bzg.js +0 -12
  170. package/dist/index-4z7axw4r.js +0 -6
  171. package/dist/index-6p999cx4.js +0 -9
  172. package/dist/index-6q4wf8e3.js +0 -6
  173. package/dist/index-9r0wyj6w.js +0 -6
  174. package/dist/index-d4x6yvqh.js +0 -6
  175. package/dist/index-fecm8xe7.js +0 -77
  176. package/dist/index-fecm8xe7.js.map +0 -12
  177. package/dist/index-fex44816.js +0 -6
  178. package/dist/index-ff514z3y.js +0 -14
  179. package/dist/index-gz9x25tz.js +0 -6
  180. package/dist/index-h9mw7b9d.js +0 -6
  181. package/dist/index-hwpvhaza.js +0 -6
  182. package/dist/index-mtn0g9vc.js +0 -7
  183. package/dist/index-mtn0g9vc.js.map +0 -11
  184. package/dist/index-qdbq8crg.js +0 -6
  185. package/dist/index-tf71ap9v.js +0 -6
  186. package/dist/index-ttwyrdjs.js +0 -427
  187. package/dist/index-ttwyrdjs.js.map +0 -11
  188. package/dist/index-tv4yv7d2.js +0 -903
  189. package/dist/index-ty24n0jh.js +0 -167
  190. package/dist/index-ty24n0jh.js.map +0 -19
  191. package/dist/index-v8e92nfw.js +0 -6
  192. package/dist/index-vgc3y3rm.js +0 -6
  193. package/dist/index-whaw4b18.js +0 -6
  194. package/dist/index-whaw4b18.js.map +0 -10
  195. package/dist/web-vkb16r62.js +0 -14
@@ -0,0 +1,66 @@
1
+ #!/usr/bin/env node
2
+ import{n,a,y,Ze,d,s,Le,T,f,qA,ci,Pe,Ue,x,Y}from"./index-byxrc961.js";var ut="dispach",ft="Dispach",pt=1;function z(e,t){return{slug:e,name:t,envPrefix:`${e.toUpperCase()}_`,stateDir:`.${e}`,apiVersion:`${e}/v${pt}`,packageScope:`@${e}`}}var U=z(ut,ft),F=`${U.envPrefix}BRAND`,pe=/^[a-z][a-z0-9]*(-[a-z0-9]+)*$/;function ge(e){return e.split("-").map((t)=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function ye(e){if(e===void 0)return U;let t=e.trim();if(t==="")throw Error(`${F} is set but empty. hint: unset ${F} 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(!pe.test(t))throw Error(`${F}="${t}" is not a usable brand slug. hint: the slug becomes an env var prefix, a dot-directory, an npm scope, and the `+"manifest apiVersion, so it must be lowercase alphanumeric with inner hyphens — "+"e.g. acme or acme-run.");if(t===U.slug)return U;return z(t,ge(t))}var re=ye(process.env[F]);function gt(e,t){let r=Array.from({length:t.length+1},(i,o)=>o);for(let i=1;i<=e.length;i+=1){let o=[i];for(let l=1;l<=t.length;l+=1){let c=(r[l-1]??0)+(e[i-1]===t[l-1]?0:1),h=(o[l-1]??0)+1,p=(r[l]??0)+1;o.push(Math.min(c,h,p))}r=o}return r[t.length]??Math.max(e.length,t.length)}function wA(e,t){let r,i=Number.POSITIVE_INFINITY;for(let o of t){let l=gt(e,o);if(l<i)i=l,r=o}return r!==void 0&&i<=Math.max(2,Math.floor(e.length/3))?r:void 0}var we=Symbol.for("dispach.HarnessError");function ee(e){return typeof e==="object"&&e!==null&&we in e}class j extends Error{static ERROR_NAME="HarnessError";code;hint;field;details;constructor(e){super(e.message,e.cause===void 0?void 0:{cause:e.cause});this.name=new.target.ERROR_NAME??"HarnessError",this[we]=!0,this.code=e.code,this.hint=e.hint,this.field=e.field,this.details=e.details??[]}toDetail(){return this.field===void 0?{code:this.code,message:this.message,hint:this.hint}:{code:this.code,message:this.message,hint:this.hint,field:this.field}}format(){let e=[`${this.code}: ${this.message}`];if(this.field!==void 0)e.push(` field: ${this.field}`);if(e.push(` hint: ${this.hint}`),this.details.length===1)return e.join(`
3
+ `);for(let t of this.details){if(e.push(""),e.push(` ${t.code}: ${t.message}`),t.field!==void 0)e.push(` field: ${t.field}`);e.push(` hint: ${t.hint}`)}return e.join(`
4
+ `)}}class E extends j{static ERROR_NAME="ConfigError"}class u extends j{static ERROR_NAME="ToolError"}function be(e,t){return new E({code:"tools_provider_alias_conflict",message:`The manifest sets tools.providers (${e.join(", ")}) and also the deprecated tools.provider${t===void 0?"Config":` (${t})`}.`,hint:`Keep tools.providers and delete the other two. Merging them would give the scalar a position in the map that nobody wrote, and provider order decides which one wins a slug collision${t===void 0?"":` — move ${t}'s settings into tools.providers.${t}`}.`,field:"tools.provider"})}function ke(e,t){return new u({code:"workspace_not_editable",message:`${e} is declared editable: ${t}, so it cannot be written to.`,hint:"Point the write at a volatile file whose frontmatter allows it (editable: append or replace), or change that file's frontmatter. Read-only identity is deliberate — it is the most effective known mitigation for persona drift, so this refuses rather than silently doing nothing."})}function Te(){return new u({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 Ee(e){return new u({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."})}class wn{runtimeId;#n=new Map;#e=new Map;#t=0;#s;#r;constructor(e){this.runtimeId=e.runtimeId,this.#r=e.now??(()=>new Date().toISOString()),this.#s=e.onHandlerError??((t,r)=>{console.error(`event handler threw while handling ${r.type}:`,t)})}on(e,t,r={}){if(e==="*"){let l=this.#e.has(t),c=r.chunks===!0,h=l?this.#e.get(t)??!1:!1;if(this.#e.set(t,c||h),!l&&c)this.#t+=1;else if(l&&c&&!h)this.#t+=1;return()=>{if(!this.#e.has(t))return;if(this.#e.get(t)===!0)this.#t-=1;this.#e.delete(t)}}let i=this.#n.get(e);if(i===void 0)i=new Set,this.#n.set(e,i);let o=!i.has(t);if(i.add(t),o&&e==="model.chunk")this.#t+=1;return()=>{if(i?.delete(t)===!0&&e==="model.chunk")this.#t-=1}}once(e,t,r={}){let i=this.on(e,(o)=>{i(),t(o)},r);return i}next(e,t,r={}){return new Promise((i,o)=>{let l=this.on(e,(h)=>{l(),t?.removeEventListener("abort",c),i(h)},r),c=()=>{l(),o(t?.reason??Error("aborted"))};t?.addEventListener("abort",c,{once:!0})})}get chunkSubscribers(){return this.#t}emit(e,t,r={}){if(e==="model.chunk"&&this.#t===0)return;let i={v:1,ts:this.#r(),runtimeId:this.runtimeId,...r.agentId===void 0?{}:{agentId:r.agentId},...r.sessionKey===void 0?{}:{sessionKey:r.sessionKey},...r.turnId===void 0?{}:{turnId:r.turnId},...r.stepId===void 0?{}:{stepId:r.stepId},type:e,data:t};this.#o(i)}#o(e){let t=e.type==="model.chunk",r=this.#n.get(e.type);if(r!==void 0)for(let i of[...r])this.#i(i,e);for(let[i,o]of[...this.#e]){if(t&&!o)continue;this.#i(i,e)}}#i(e,t){try{e(t)}catch(r){this.#s(r,t)}}}var je="0.1.3",bt=/^(\d+)\.(\d+)\.(\d+)$/,vt=/^(\d+)(?:\.(\d+))?(?:\.(\d+))?$/;function kt(e){let t=bt.exec(e.trim());if(t===null)return;return{major:Number(t[1]),minor:Number(t[2]),patch:Number(t[3])}}function Tt(e){let t=vt.exec(e.trim());if(t===null)return;let[,r,i,o]=t;return{version:{major:Number(r),minor:Number(i??0),patch:Number(o??0)},specified:o!==void 0?3:i!==void 0?2:1}}function I(e,t){if(e.major!==t.major)return e.major-t.major;if(e.minor!==t.minor)return e.minor-t.minor;return e.patch-t.patch}function Et(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 _t(e,t){if(t===1)return{major:e.major+1,minor:0,patch:0};return{major:e.major,minor:e.minor+1,patch:0}}function At(e,t){if(t==="*"||t==="x"||t==="X")return!0;let r=/^(>=|<=|>|<|=|\^|~)?\s*(.+)$/.exec(t);if(r===null)return;let i=Tt(r[2]??"");if(i===void 0)return;let{version:o,specified:l}=i;switch(r[1]){case"^":return I(e,o)>=0&&I(e,Et(o))<0;case"~":return I(e,o)>=0&&I(e,_t(o,l))<0;case">=":return I(e,o)>=0;case"<=":return I(e,o)<=0;case">":return I(e,o)>0;case"<":return I(e,o)<0;default:if(l===3)return I(e,o)===0;if(l===2)return e.major===o.major&&e.minor===o.minor;return e.major===o.major}}function mn(e,t){let r=kt(e);if(r===void 0)return;let i=t.split("||"),o=!1;for(let l of i){let c=l.trim().split(/\s+/).filter((p)=>p!=="");if(c.length===0)return;let h=!0;for(let p of c){let m=At(r,p);if(m===void 0)return;if(!m)h=!1}if(o=!0,h)return!0}return o?!1:void 0}var Dn=200;var St="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 $t=3.8;function xe(e){if(e==="")return 0;let t=0;for(let r=0;r<e.length;r+=1)if(e.charCodeAt(r)===10)t+=1;return Math.ceil(e.length/$t)+t}var _e=["runtime.ready","store.ready","runtime.stopping","agent.loaded","agent.disposed","agent.warning","plugin.loaded","plugin.slow","approval.requested","approval.resolved","handoff.start","handoff.result","turn.start","context.assembled","context.dropped","context.pressure","compaction.stage","context.reset","phase.changed","model.call","model.chunk","model.retry","model.result","tool.call","tool.result","tool.gated","tool.repair","tools.refreshed","agent.channel.status","agent.channel.error","agent.channel.rejected","delivery.sent","delivery.retry","delivery.failed","delivery.uncertain","runtime.released","schedules.reconciled","schedule.fired","schedule.skipped","schedule.deferred","schedule.error","turn.end","error"],A=(e)=>String.fromCharCode(e),L=A(27),Ne=A(7),xt=new RegExp(`${L}\\[[0-?]*[ -/]*[@-~]`,"g"),Nt=new RegExp(`${L}\\][\\s\\S]*?(?:${Ne}|${L}\\\\|$)`,"g"),It=new RegExp(`${L}[P^_X][\\s\\S]*?(?:${L}\\\\|${Ne}|$)`,"g"),Rt=new RegExp(`${L}[@-Z\\\\-_0-9=><]?`,"g"),Ot=new RegExp(`[${A(128)}-${A(159)}]`,"g"),Lt=new RegExp(`[${A(0)}-${A(8)}${A(11)}${A(12)}${A(14)}-${A(31)}${A(127)}]`,"g");function ve(e){return e.replace(/\r\n/g,`
5
+ `).replace(/\r/g,`
6
+ `).replace(Nt,"").replace(It,"").replace(xt,"").replace(Rt,"").replace(Ot,"").replace(Lt,"")}var Mt=/\r\n\r\n|\n\n|\r\r/;function Ae(e){let t=[],r,i,o;for(let l of e.split(/\r\n|\n|\r/)){if(l===""||l.startsWith(":"))continue;let c=l.indexOf(":"),h=c===-1?l:l.slice(0,c),p=c===-1?"":l.slice(c+1);if(p.startsWith(" "))p=p.slice(1);switch(h){case"data":t.push(p);break;case"event":r=p;break;case"id":i=p;break;case"retry":{let m=Number.parseInt(p,10);if(Number.isFinite(m))o=m;break}default:break}}if(t.length===0&&r===void 0)return;return{...r===void 0?{}:{event:r},data:t.join(`
7
+ `),...i===void 0?{}:{id:i},...o===void 0?{}:{retry:o}}}async function*bn(e){let t=new TextDecoder,r="";for await(let i of e){r+=typeof i==="string"?i:t.decode(i,{stream:!0});while(!0){let o=Mt.exec(r);if(o===null)break;let l=r.slice(0,o.index);r=r.slice(o.index+o[0].length);let c=Ae(l);if(c!==void 0)yield c}}if(r+=t.decode(),r.trim()!==""){let i=Ae(r);if(i!==void 0)yield i}}function Sn(){return{push:(e)=>e,endStep:()=>"",end:()=>""}}var Ie="<<<",Re=">>>",P=/^\s*(?:[-*+]\s+|\d+[.)]\s+)?<?\s*action\s*:\s*(.+?)\s*>?\s*$/i,Ct=/^\s*(?:[-*+]\s+|\d+[.)]\s+)?([A-Za-z_][\w.-]*?)\s*:\s*(.*)$/,Q=/^\s*`{3,}\s*[\w+-]*\s*$/,V=/^\s*end\s*$/i,Dt=/^\s*<\s*action\s*>\s*$/i,Se=/^\s*<\s*\/\s*action\s*>\s*$/i,Ut=/^\s*<\/?\s*[A-Za-z_][\w.:-]*\s*\/?\s*>\s*$/;function J(e){return e.replace(/^[`'"*<]+/,"").replace(/[`'"*>]+$/,"").replace(/[.,;:]+$/,"").trim()}function Oe(e,t,r){let i=e.fields.get(t);if(i===void 0)e.fields.set(t,[r]);else i.push(r)}function Me(e){if(e.block===void 0||e.heredocKey===void 0)return;let t=[...e.heredocLines];if(t[t.length-1]==="")t.pop();Oe(e.block,e.heredocKey,t.join(`
8
+ `)),e.block.wrapped.add(e.heredocKey),e.heredocKey=void 0,e.heredocLines=[]}function O(e){if(Me(e),e.block!==void 0)e.blocks.push(e.block);e.block=void 0,e.openKey=void 0,e.awaitingSlug=!1}function $e(){return{block:void 0,openKey:void 0,severedKey:void 0,severedPending:void 0,heredocKey:void 0,heredocLines:[],justClosed:!1,awaitingSlug:!1,text:[],blocks:[]}}function Ft(e,t,r){let i=t.trim();if(e.heredocKey!==void 0){if(i===Re){Me(e);return}if(V.test(i)){O(e),e.justClosed=!0;return}if(P.test(t)){O(e);let c=P.exec(t),h=J(c?.[1]??"");if(h!=="")e.block={slug:h,fields:new Map,wrapped:new Set,severed:new Set};return}e.heredocLines.push(t);return}let o=P.exec(t);if(o!==null){let c=J(o[1]??"");if(O(e),c==="")return;e.block={slug:c,fields:new Map,wrapped:new Set,severed:new Set};return}if(Dt.test(t)){O(e),e.awaitingSlug=!0;return}if(e.awaitingSlug){if(i==="")return;if(Se.test(t)){e.awaitingSlug=!1;return}let c=J(i);if(e.awaitingSlug=!1,c!=="")e.block={slug:c,fields:new Map,wrapped:new Set,severed:new Set};return}if(Se.test(t)){if(e.block!==void 0)O(e),e.justClosed=!0;return}if(Ut.test(t))return;if(e.block===void 0){if(Q.test(t)&&(e.justClosed||r())){e.justClosed=!1;return}if(V.test(i)&&e.severedPending!==void 0){e.severedPending.block.severed.add(e.severedPending.key),e.severedPending=void 0;return}if(P.test(t))e.severedPending=void 0;if(e.text.push(t),i!=="")e.justClosed=!1;return}if(i===""){if(e.openKey!==void 0)e.severedKey=e.openKey;e.openKey=void 0;return}if(V.test(i)){e.severedKey=void 0,O(e),e.justClosed=!0;return}if(Q.test(t))return;let l=Ct.exec(t);if(l!==null){let c=(l[1]??"").trim(),h=(l[2]??"").trim();if(e.severedKey=void 0,h===Ie)e.heredocKey=c,e.heredocLines=[],e.openKey=void 0;else Oe(e.block,c,h),e.openKey=c;return}if(e.openKey!==void 0){let c=e.block.fields.get(e.openKey),h=c?.[c.length-1];if(c!==void 0&&h!==void 0)c[c.length-1]=h===""?i:`${h}
9
+ ${i}`;return}if(e.severedKey!==void 0)e.severedPending={block:e.block,key:e.severedKey},e.severedKey=void 0;O(e),e.text.push(t)}function Pt(e){if(/^\s*(?:[-*+]|\d+[.)]?)?\s*$/.test(e))return!0;let t=e.replace(/^\s*(?:[-*+]\s+|\d+[.)]\s+)?/,"").toLowerCase(),r=t.startsWith("<")?t.slice(1):t;if("action:".startsWith(r)||r.startsWith("action:"))return!0;if(/^<\/?$/.test(t)||/^<\/?[a-z_][\w.:-]*>?$/.test(t))return!0;return/^`{1,3}[\w+-]*$/.test(t)}function Z(e){return e.endsWith("\r")?e.slice(0,-1):e}function Mn(){let e=$e(),t="",r=0,i,o="",l=!1,c=(g)=>{if(g==="")return"";if(g.trim()==="")return o+=g,"";let w=o+g;if(o="",l)return w;return l=!0,w.replace(/^\s+/,"")},h=(g,w)=>{let b=e.text.length;return Ft(e,g,()=>w!==void 0&&P.test(w)),e.text.length>b?g:void 0},p=(g,w,b)=>{let k=h(g,w);if(k===void 0)return"";return c(k.slice(b))+c(`
10
+ `)},m=(g)=>{if(i===void 0)return"";let w=i;return i=void 0,p(w,g,0)};return{push(g){let w="";t+=g;let b=t.indexOf(`
11
+ `);while(b!==-1){let _=Z(t.slice(0,b));if(t=t.slice(b+1),w+=m(_),e.block===void 0&&Q.test(_)&&!e.justClosed)i=_;else w+=p(_,void 0,r);r=0,b=t.indexOf(`
12
+ `)}let k=Z(t);if(e.block===void 0&&!e.awaitingSlug&&i===void 0&&!Pt(k))w+=c(k.slice(r)),r=k.length;return w},endStep(){let g=v();return o=`
13
+
14
+ `,e=$e(),g},end:v};function v(){let g=m(void 0),w=Z(t);if(w!==""){let b=h(w,void 0);if(b!==void 0)g+=c(b.slice(r))}return t="",r=0,i=void 0,g}}var Ps=`# 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 \`${Ie}\` and close it with \`${Re}\` alone on its own line.
29
+ - Finish every block with \`END\` alone on its own line.
30
+ - Several blocks are allowed. They run in the order you write them.
31
+ - Use only the tools listed below, only their listed fields, and always give every required field.
32
+
33
+ Anything you write outside a block is shown to the person you are talking to, so keep explanations
34
+ short and keep them out of the block. When no tool fits, simply reply — never invent a tool, and
35
+ never guess a value for a required field you have not been given.`;import{appendFile as Be,mkdir as Fn,readFile as Pn}from"node:fs/promises";import{join as Xe}from"node:path";import{appendFile as Ge,mkdir as jn,readFile as Hn,writeFile as Kn}from"node:fs/promises";import{join as Bn}from"node:path";import{readFile as os,writeFile as as}from"node:fs/promises";var jt=`${re.slug}_`,Wt="0123456789abcdefghjkmnpqrstvwxyz",Ht=32;function kn(){let e=new Uint8Array(Ht);crypto.getRandomValues(e);let t="";for(let r of e)t+=Wt[r&31]??"0";return`${jt}${t}`}async function On(e){let t=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(e));return[...new Uint8Array(t)].map((r)=>r.toString(16).padStart(2,"0")).join("")}var Nn=64,Kt=new RegExp("[\\u0000-\\u001f\\u007f]");function Wo(e){if(e.trim()==="")return"A key label cannot be empty.";if(e.length>Nn)return`A key label is at most ${Nn} characters; this one is ${e.length}.`;if(Kt.test(e))return"A key label cannot contain control characters, including newlines and tabs.";return}function Bt(e){let t=`${e.channel}:${e.peerId}`;return e.thread===void 0||e.thread===""?t:`${t}:${e.thread}`}var Ce="0123456789abcdefghijklmnopqrstuvwxyz";function Xt(e){let t=new Uint8Array(e);crypto.getRandomValues(t);let r="";for(let i of t)r+=Ce[i%Ce.length];return r}function ce(e,t){return`${e}_${t.toString(36)}${Xt(8)}`}function ht(e=Date.now()){return ce("t",e)}function Zo(e=Date.now()){return ce("r",e)}function Xo(e=Date.now()){return ce("k",e)}var De="phase_set",nt="*",Fe="tag:";function $o(e){let t=Object.keys(e);return t.find((i)=>e[i]?.entry===!0)??t[0]}function We(e){return e.toLowerCase().replace(/[\s_.-]+/g,"")}function Gt(e,t){if(e===nt)return!0;if(e.startsWith(Fe)){let r=e.slice(Fe.length).toLowerCase();return t.tags.some((i)=>i.toLowerCase()===r)}return We(e)===We(t.slug)}function qt(e,t){let r=e[t];if(r===void 0)return[nt];return r.allow.includes(De)?r.allow:[...r.allow,De]}function Wn(e){return e!==void 0&&Object.keys(e).length>1}function ei(e,t){return Object.keys(e).filter((r)=>qt(e,r).some((i)=>Gt(i,t)))}var qe=["user","agent"];var Yt=/^---\r?\n([\s\S]*?)\r?\n---[ \t]*(?:\r?\n|$)/,zt=/<!--[\s\S]*?-->/g,Vt=/\n{3,}/g;function Jt(e){let t=Yt.exec(e);return t===null||t===void 0?e:e.slice(t[0].length)}function Zt(e){return e.replace(zt,"").replace(Vt,`
36
+
37
+ `).trim()}var B={static:2000,volatile:3500,reminder:500,total:6000};var N=n().min(1),Qt=s({delimiters:f(["xml","markdown","plain"]).optional(),intensity:f(["emphatic","neutral","soft"]).optional(),examplesIn:f(["system","user"]).optional(),skillsIn:f(["system","user"]).optional()}).strict(),en=s({nativeTools:y().optional(),strictSchema:y().optional(),thinking:f(["none","anthropic","openai","deepseek"]).optional(),promptCache:f(["none","anthropic","openai"]).optional(),parallelToolCalls:y().optional(),contextWindow:a().int().positive().optional(),maxOutput:a().int().positive().optional(),promptStyle:Qt.optional()}).strict(),X=s({id:n().min(1),baseUrl:n().min(1),apiKeyEnv:n().min(1).optional(),temperature:a().min(0).max(2).optional(),topP:a().min(0).max(1).optional(),maxTokens:a().int().positive().optional(),reasoningEffort:f(["none","minimal","low","medium","high"]).optional(),headers:T(n(),n()).optional(),streamUsage:y().optional(),capabilities:en.optional()}).strict(),tn=s({main:X,selector:X.optional(),compactor:X.optional()}).catchall(X),nn=s({snip:a().default(0.6),micro:a().default(0.7),collapse:a().default(0.8),reset:a().default(0.88),trim:a().default(0.95)}).strict(),sn=s({static:a().int().positive().default(B.static),volatile:a().int().positive().default(B.volatile),reminder:a().int().positive().default(B.reminder),total:a().int().positive().default(B.total)}).strict(),rn=s({perRuleSuccess:a().gt(0).lte(1).default(0.9),reliabilityTarget:a().gt(0).lt(1).default(0.8),onExceed:f(["fail","warn"]).default("fail")}).strict(),on=s({file:n().min(1),requires:s({contextWindow:n().min(1).optional(),class:f(["frontier","small"]).optional()}).strict().optional(),onUnmet:f(["distill","omit","fail"]).default("distill"),distilled:n().min(1).optional()}).strict(),an=s({dir:n().min(1),maxActive:a().int().nonnegative().default(2),budget:a().int().positive().default(600)}).strict(),dn=s({window:a().int().positive().optional(),reserveOutput:a().int().positive().default(4096),observationMaxTokens:a().int().positive().default(2000),files:d(n().min(1)).default([]),workspace:n().min(1).default("./workspace"),static:d(n().min(1)).default([]),volatile:d(n().min(1)).default([]),reminder:n().min(1).optional(),budgets:sn.prefault({}),rules:rn.prefault({}),soul:on.optional(),compactionNotice:y().optional(),thresholds:nn.prefault({})}).strict(),ln=s({max:a().int().positive().default(24),reserveWrite:a().int().nonnegative().default(6)}).strict(),cn=s({onMutate:f(["refuse","confirm","allow"]).default("refuse")}).strict(),un=s({mode:f(["ask","allow","deny"]).default("allow"),allow:d(n().min(1)).default([]),deny:d(n().min(1)).default([]),onNoApprover:f(["deny","allow"]).default("deny")}).strict(),hn=s({dialect:f(["nlt","native"]).default("nlt"),providers:T(N,T(n(),Ze())).default({}),provider:N.optional(),providerConfig:T(n(),Ze()).default({}),budget:ln.prefault({}),pinned:d(n().min(1)).default([]),search:s({enabled:y().default(!1)}).strict().prefault({}),local:d(n().min(1)).default([]),untrusted:cn.prefault({}),policy:un.prefault({})}).strict(),fn=s({allow:d(n().min(1)),entry:y().optional()}).strict(),pn=s({dir:n().min(1).default("./skills"),maxActive:a().int().nonnegative().default(1),threshold:a().default(0.35)}).strict(),gn=s({retriever:n().min(1).default("fts5"),dir:n().min(1).default("./memory"),maxActive:a().int().nonnegative().default(5),threshold:a().default(0.2),budget:a().int().positive().default(2000),includeHistory:y().default(!0)}).strict(),yn=s({type:N,id:N,allowFrom:d(n().min(1)).optional(),enabled:y().default(!0)}).passthrough(),st=s({channel:N,to:n().min(1)}).strict(),vn=s({default:N.optional(),targets:T(n(),st).default({})}).strict(),ae=ci(()=>s({type:f(["string","number","integer","boolean","array","object"]),description:n().optional(),enum:d(Le([n(),a(),y()])).optional(),items:ae.optional(),properties:T(n(),ae).optional(),required:d(n()).optional()})),Tn=s({id:N,manifest:n().min(1),task:n().min(1),artifact:s({type:qA("object"),properties:T(n(),ae),required:d(n()).optional()}).strict()}).strict(),En=s({members:d(Tn).min(1)}).strict(),rt=s({id:N,kind:f(["cron","every","at"]),expr:n().min(1),task:n().min(1),deliver:Le([qA("none"),st]),session:n().min(1).default("isolated"),role:N.optional(),enabled:y().default(!0),timezone:n().min(1).optional()}).strict(),_n=Le([n().min(1),s({spec:n().min(1),config:T(n(),Ze()).default({})}).strict()]),An=s({identicalCalls:a().int().min(2).default(3)}).strict(),$n=s({maxSteps:a().int().positive().default(40),noProgress:An.prefault({}),turnTimeoutMs:a().int().positive().default(1800000),toolTimeoutMs:a().int().positive().default(120000),maxParallelTools:a().int().positive().default(4)}).strict(),xn=s({enabled:y().default(!1),port:a().int().min(1).max(65535).default(7420),host:n().min(1).default("127.0.0.1"),tokenEnv:n().min(1).default(`${re.envPrefix}API_TOKEN`),allowedOrigins:d(n().min(1)).default([]),allowedHosts:d(n().min(1)).default([])}).strict(),In=s({apiVersion:n().min(1),id:N,name:n().min(1).optional(),extends:n().min(1).optional(),model:tn,context:dn.prefault({}),tools:hn.prefault({}),phases:T(n(),fn).optional(),skills:pn.optional(),knowledge:an.optional(),memory:gn.optional(),channels:d(yn).default([]),delivery:vn.optional(),schedules:d(rt).default([]),team:En.optional(),plugins:d(_n).default([]),limits:$n.prefault({}),server:xn.prefault({})}).strict(),de=["main","selector","compactor"];function Rn(e){return de.includes(e)}function He(e){return Object.keys(e).filter((t)=>!Rn(t))}var Ln={nativeTools:!1,strictSchema:!1,thinking:"none",promptCache:"none",parallelToolCalls:!1,contextWindow:8192,maxOutput:4096},te={nativeTools:!0,strictSchema:!1,thinking:"anthropic",promptCache:"none",parallelToolCalls:!0},ne="Thinking blocks must be replayed with tool results or multi-step reasoning degrades silently. Prompt caching is unavailable on the OpenAI-compatible endpoint; the native Messages API is the only route to it.",_i=[{pattern:"gpt-4o*",capabilities:{nativeTools:!0,strictSchema:!0,thinking:"none",promptCache:"openai",parallelToolCalls:!0,contextWindow:128000,maxOutput:16384}},{pattern:"gpt-4.1*",capabilities:{nativeTools:!0,strictSchema:!0,thinking:"none",promptCache:"openai",parallelToolCalls:!0,contextWindow:1e6,maxOutput:32768}},{pattern:"gpt-4-turbo*",capabilities:{nativeTools:!0,strictSchema:!1,thinking:"none",promptCache:"none",parallelToolCalls:!0,contextWindow:128000,maxOutput:4096}},{pattern:"gpt-3.5*",capabilities:{nativeTools:!0,strictSchema:!1,thinking:"none",promptCache:"none",parallelToolCalls:!0,contextWindow:16385,maxOutput:4096}},{pattern:"gpt-5*",capabilities:{nativeTools:!0,strictSchema:!0,thinking:"openai",promptCache:"openai",parallelToolCalls:!0,contextWindow:200000,maxOutput:32768},note:"Deliberately conservative on window and output. Override if your endpoint serves more."},{pattern:"o1*",capabilities:{nativeTools:!0,strictSchema:!0,thinking:"openai",promptCache:"openai",parallelToolCalls:!1,contextWindow:200000,maxOutput:1e5}},{pattern:"o3*",capabilities:{nativeTools:!0,strictSchema:!0,thinking:"openai",promptCache:"openai",parallelToolCalls:!1,contextWindow:200000,maxOutput:1e5}},{pattern:"o4*",capabilities:{nativeTools:!0,strictSchema:!0,thinking:"openai",promptCache:"openai",parallelToolCalls:!1,contextWindow:200000,maxOutput:1e5}},...["claude-fable-5*","claude-opus-5*","claude-opus-4-8*","claude-opus-4-7*","claude-opus-4-6*","claude-sonnet-5*","claude-sonnet-4-6*"].map((e)=>({pattern:e,capabilities:{...te,contextWindow:1e6,maxOutput:128000},note:ne})),{pattern:"claude-haiku-*",capabilities:{...te,contextWindow:200000,maxOutput:64000},note:ne},{pattern:"claude-*",family:!0,capabilities:{...te,contextWindow:200000,maxOutput:8192},note:ne},{pattern:"gemini*",family:!0,capabilities:{nativeTools:!0,strictSchema:!1,thinking:"none",promptCache:"none",parallelToolCalls:!0,contextWindow:1e6,maxOutput:8192}},{pattern:"qwen3.5*",capabilities:{nativeTools:!0,strictSchema:!1,thinking:"deepseek",promptCache:"none",parallelToolCalls:!1,contextWindow:32768,maxOutput:8192},note:"Served locally by Ollama, which reports no token usage unless model.<role>.streamUsage is set — token figures come from the estimator until it is. Reasoning is billed to the output budget, so context.reserveOutput must cover reasoning plus the reply.",verified:"2026-08-13 against qwen3.5:9b on localhost:11434/v1"},{pattern:"qwen*",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:Ln}];var Ke=/^(?:timeout\s+\S+|time|nice(?:\s+-n\s+\S+)?|stdbuf(?:\s+-\S+)*|command|builtin)\s+/i;function Cn(e){let t=e.trim();for(let r=0;r<4&&Ke.test(t);r+=1)t=t.replace(Ke,"").trim();return t}var Un=/\s*(?:&&|\|\||;|\||&|\n)\s*/;function Ai(e){return e.split(Un).map((t)=>Cn(t)).filter((t)=>t!=="")}var Xn=/^(?:[-*+]|\d+[.)])[ \t]+\S/,Gn=/\*\*(\d{4})-(\d{2})-\d{2}T/;function qn(e){let t=[],r=-1,i=(o)=>{if(r===-1)return;t.push({start:r,end:o,text:e.slice(r,o).join(`
38
+ `).trimEnd()}),r=-1};for(let o=0;o<e.length;o+=1){let l=e[o]??"";if(Xn.test(l)){i(o),r=o;continue}if(r===-1)continue;if(l.trim()===""||/^[ \t]/.test(l))continue;i(o)}return i(e.length),t}function le(e){return xe(Zt(Jt(e)))}function Yn(e,t){let r=Gn.exec(e);if(r!==null)return`${r[1]}-${r[2]}.md`;let i=t.getUTCFullYear(),o=`${t.getUTCMonth()+1}`.padStart(2,"0");return`${i}-${o}.md`}function zn(e,t){let r=e.split(/\r?\n/),i=qn(r),o=[],l=i,c=e,h=le(c);while(h>t&&l.length>1){let p=l[0];if(p===void 0)break;o.push(p),l=l.slice(1),c=Vn(r,o),h=le(c)}if(h<=t)return{evict:o,remaining:c,tokens:h};return{evict:o,remaining:c,tokens:h,shortfall:l.length<=1?`${h} tokens remain against a ${t}-token budget with one note left, so eviction cannot help`:`${h} tokens remain against a ${t}-token budget`}}function Vn(e,t){let r=new Set;for(let i of t)for(let o=i.start;o<i.end;o+=1)r.add(o);return e.filter((i,o)=>!r.has(o)).join(`
39
+ `).replace(/\n{3,}/g,`
40
+
41
+ `)}async function Jn(e){let t=e.tags.length===0?"":` _(${e.tags.join(", ")})_`,r=`
42
+ - **${e.now.toISOString()}**${t} ${e.text}
43
+ `;await Ge(e.path,r,"utf8");let i=await Hn(e.path,"utf8"),o=zn(i,e.budget);if(o.evict.length===0)return{file:e.name,evicted:0,archives:[],...o.shortfall===void 0?{}:{shortfall:o.shortfall}};let l=new Map;for(let c of o.evict){let h=Yn(c.text,e.now);l.set(h,[...l.get(h)??[],c.text])}await jn(e.archiveDir,{recursive:!0});for(let[c,h]of l)await Ge(Bn(e.archiveDir,c),`${h.join(`
44
+ `)}
45
+ `,"utf8");return await Kn(e.path,o.remaining,"utf8"),{file:e.name,evicted:o.evict.length,archives:[...l.keys()].sort(),...o.shortfall===void 0?{}:{shortfall:o.shortfall}}}var ue="local",Ye="memory",Ve="notes.md",Qn={spec:{slug:"now",provider:ue,summary:"Reports the current date and time.",whenToUse:"you need today's date or the current time — including to work out what 'tomorrow' or 'in three hours' means",whenNotToUse:"the person already told you the date or time; use theirs rather than replacing it with the clock",mutating:!1,tags:["read","time"],parameters:{type:"object",properties:{timezone:{type:"string",description:"IANA name such as Europe/London. Defaults to UTC."},format:{type:"string",description:"iso for a machine-readable timestamp, human for a readable one",enum:["iso","human"],default:"iso"}}}},handler(e,t){let r=t.now(),i=typeof e.timezone==="string"&&e.timezone!==""?e.timezone:"UTC";if(e.format==="human")return`${new Intl.DateTimeFormat("en-GB",{dateStyle:"full",timeStyle:"short",timeZone:i}).format(r)} (${i})`;if(i==="UTC")return r.toISOString();return`${es(r,i)} (${i})`}};function es(e,t){let r=new Intl.DateTimeFormat("en-CA",{timeZone:t,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,timeZoneName:"longOffset"}).formatToParts(e),i=(l)=>r.find((c)=>c.type===l)?.value??"",o=i("timeZoneName").replace("GMT","");return`${i("year")}-${i("month")}-${i("day")}T${i("hour")}:${i("minute")}:${i("second")}${o===""?"Z":o}`}var ts={spec:{slug:"memory_write",provider:ue,summary:"Saves a short note for later recall.",whenToUse:"the person tells you something durable about themselves or their work that later conversations should know",whenNotToUse:"for anything already in this conversation, for secrets or credentials, or to store your own reasoning",mutating:!0,tags:["write","memory"],parameters:{type:"object",properties:{text:{type:"string",description:"The note, in one or two sentences."},tags:{type:"array",items:{type:"string"},description:"Optional labels."}},required:["text"]}},async handler(e,t){let r=typeof e.text==="string"?e.text.trim():"",i=Array.isArray(e.tags)?e.tags.map((m)=>String(m)):[],o=t.now().toISOString(),l=i.length===0?"":` _(${i.join(", ")})_`,c=`
46
+ - **${o}**${l} ${r}
47
+ `,h=t.writeTarget;if(h?.mode==="refused")throw ke(h.name,h.reason??"none");if(h?.path!==void 0){if(h.budget!==void 0&&t.memoryDir!==void 0&&h.eviction==="oldest"){let m=await Jn({path:h.path,name:h.name,budget:h.budget,archiveDir:t.memoryDir,text:r,tags:i,now:t.now()});if(m.shortfall!==void 0)return`Saved to ${m.file}, but it is still over budget: ${m.shortfall}. Ask the person to raise the budget or shorten the file — the agent will not load until they do.`;if(m.evicted===0)return`Saved to ${m.file}.`;return`Saved to ${m.file}. Moved ${m.evicted} older ${m.evicted===1?"note":"notes"} into ${m.archives.join(", ")}, still searchable.`}if(await Be(h.path,c,"utf8"),h.budget!==void 0){let m=le(await Pn(h.path,"utf8"))-h.budget;if(m>0)return`Saved to ${h.name}, which is now ${m} tokens over its ${h.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 ${h.name}.`}let p=Xe(t.dir,Ye);return await Fn(p,{recursive:!0}),await Be(Xe(p,Ve),c,"utf8"),`Saved to ${Ye}/${Ve}.`}},ns=1200,ss=ns*3,rs={spec:{slug:"artifact_read",provider:ue,summary:"Reads back a tool result that compaction replaced with a pointer.",whenToUse:"a compaction marker in this conversation names an id, and you need the tool result it replaced",whenNotToUse:"for anything still written out in the conversation, or to explore — every id comes from a marker, so there is nothing to browse",mutating:!1,tags:["read","context"],parameters:{type:"object",properties:{id:{type:"string",description:"The id printed inside the compaction marker, copied character for character."},from:{type:"integer",description:"Character offset to continue from. Omit for the beginning; a truncated reply says the number to pass."}},required:["id"]}},async handler(e,t){let r=typeof e.id==="string"?e.id.trim():"",i=typeof e.from==="number"&&e.from>0?Math.floor(e.from):0;if(t.readArtifact===void 0)throw Te();let o=await t.readArtifact(r);if(o===void 0)throw Ee(r);let l=o.slug===void 0?"observation":`${o.slug} observation`,c=o.content.slice(i,i+ss),h=i+c.length,p=`Compacted ${l}, ${o.tokens} tokens${i===0?"":`, from character ${i}`}:`;if(h>=o.content.length)return`${p}
48
+ ${c}`;return`${p}
49
+ ${c}
50
+
51
+ [cut here — ${o.content.length-h} characters remain; continue with artifact_read(id, from: ${h})]`}};var is=[Qn,ts,rs],Ii=is.map((e)=>e.spec.slug);function ds(e){let t=e.providers??{},r=Object.keys(t),i=e.provider,o=e.providerConfig??{};if(r.length>0&&(i!==void 0||Object.keys(o).length>0))throw be(r,i);if(i!==void 0)return{selections:[{id:i,config:o,legacy:!0}],warnings:[{code:"tools_provider_deprecated",message:`tools.provider is deprecated; "${i}" was loaded as tools.providers.${i}.`,hint:`Rewrite it as:
52
+ tools:
53
+ providers:
54
+ ${i}: { … the contents of providerConfig … }
55
+ The scalar permits exactly one provider, which is why an agent could not have the shell and the web at the same time. It still works and will keep working for now; nothing about the resolved catalogue changes.`,field:"tools.provider"}]};let l=r.map((c)=>({id:c,config:t[c]??{},legacy:!1}));if(Object.keys(o).length>0)return{selections:l,warnings:[{code:"tools_provider_config_orphaned",message:`tools.providerConfig has ${Object.keys(o).length} setting(s) and no tools.provider names a provider to apply them to, so they do nothing.`,hint:"Move them into the matching tools.providers.<id> block and delete tools.providerConfig. Reported rather than ignored: a configuration that looks applied and is not is worse than one that fails.",field:"tools.providerConfig"}]};return{selections:l,warnings:[]}}var Je=new Map;function it(e){let t=Je.get(e);if(t!==void 0)return t;let r;try{r=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(i){throw new E({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:i})}return Je.set(e,r),r}function ls(e){it(e)}function q(e,t){let r=it(e).formatToParts(new Date(t)),i=(h)=>{let p=r.find((m)=>m.type===h);return p===void 0?0:Number(p.value)},o=i("year"),l=i("month"),c=i("day");return{year:o,month:l,day:c,hour:i("hour"),minute:i("minute"),second:i("second"),weekday:new Date(Date.UTC(o,l-1,c)).getUTCDay()}}function cs(e,t){return q(e,t)}function Qe(e,t){let r=q(e,t);return Date.UTC(r.year,r.month-1,r.day,r.hour,r.minute,r.second)-(t-t%1000)}function us(e,t){let r=Date.UTC(t.year,t.month-1,t.day,t.hour,t.minute,t.second),i=r-Qe(e,r);i=r-Qe(e,i);let o=q(e,i);if(!(o.year===t.year&&o.month===t.month&&o.day===t.day&&o.hour===t.hour&&o.minute===t.minute&&o.second===t.second))return;let c=i-3600000,h=q(e,c);return h.year===t.year&&h.month===t.month&&h.day===t.day&&h.hour===t.hour&&h.minute===t.minute&&h.second===t.second?c:i}function hs(){return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}var fs=1462,ot=["jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"],ms=["sun","mon","tue","wed","thu","fri","sat"],M={second:{min:0,max:59,label:"second"},minute:{min:0,max:59,label:"minute"},hour:{min:0,max:23,label:"hour"},dayOfMonth:{min:1,max:31,label:"day of month"},month:{min:1,max:12,names:ot,label:"month"},dayOfWeek:{min:0,max:7,names:ms,label:"day of week"}};function R(e,t,r,i){throw new E({code:"schedule_cron_malformed",message:`"${e}" is not a valid cron expression: ${t}`,hint:r,field:i})}function se(e,t,r,i){let o=t.names?.indexOf(e.toLowerCase());if(o!==void 0&&o!==-1)return o+(t.names===ot?1:0);if(!/^\d+$/.test(e))R(r,`"${e}" is not a ${t.label}.`,t.names===void 0?`The ${t.label} field takes numbers ${t.min}-${t.max}, ranges, steps and comma lists.`:`The ${t.label} field takes ${t.min}-${t.max} or a name (${t.names.slice(0,3).join(", ")}…).`,i);let l=Number(e);if(l<t.min||l>t.max)R(r,`${l} is outside the ${t.label} range ${t.min}-${t.max}.`,`Check the field order: ${t.label==="second"?"second minute hour day-of-month month day-of-week":"minute hour day-of-month month day-of-week"}.`,i);return l}function C(e,t,r,i){let o=new Set,l=!0;for(let c of e.split(",")){let h=c.trim();if(h==="")R(r,"an empty entry in a comma list.","Remove the stray comma.",i);let[p="",m]=h.split("/",2),v=m===void 0?1:Number(m);if(m!==void 0&&(!/^\d+$/.test(m)||v<1))R(r,`"${m}" is not a step.`,"A step is a whole number above zero, as in */15.",i);let g,w;if(p==="*"){if(g=t.min,w=t.max,v===1)l=!1}else if(p.includes("-")){let[b="",k=""]=p.split("-",2);if(g=se(b,t,r,i),w=se(k,t,r,i),g>w)R(r,`the range ${p} runs backwards.`,"Write the lower bound first, or use a comma list to wrap around.",i)}else g=se(p,t,r,i),w=m===void 0?g:t.max;for(let b=g;b<=w;b+=v)o.add(b)}if(o.size===0)R(r,"it matches nothing.","Every field must admit at least one value.",i);return{values:o,restricted:l}}function ps(e,t){let r=e.trim();if(r.startsWith("@"))R(r,"macros are not supported.",'Write the fields out — @daily is "0 0 * * *", @hourly is "0 * * * *", @weekly is "0 0 * * 0". For a plain interval use kind: every with an expression like 24h.',t);let i=r.split(/\s+/).filter((K)=>K!=="");if(i.length!==5&&i.length!==6)R(r,`it has ${i.length} field${i.length===1?"":"s"}, not 5 or 6.`,"Five fields are minute hour day-of-month month day-of-week. A sixth leading field is seconds.",t);let o=i.length===6,[l,c,h,p,m,v]=o?i:["0",...i],g=C(l??"0",M.second,r,t),w=C(c??"",M.minute,r,t),b=C(h??"",M.hour,r,t),k=C(p??"",M.dayOfMonth,r,t),_=C(m??"",M.month,r,t),S=C(v??"",M.dayOfWeek,r,t),me=new Set;for(let K of S.values)me.add(K===7?0:K);return{seconds:g.values,minutes:w.values,hours:b.values,daysOfMonth:k.values,months:_.values,daysOfWeek:me,domRestricted:k.restricted,dowRestricted:S.restricted,source:r}}function gs(e,t,r){let i=e.daysOfMonth.has(t),o=e.daysOfWeek.has(r);if(e.domRestricted&&e.dowRestricted)return i||o;if(e.domRestricted)return i;if(e.dowRestricted)return o;return!0}function et(e,t,r,i){let o=new Date(Date.UTC(e,t-1,r+i));return[o.getUTCFullYear(),o.getUTCMonth()+1,o.getUTCDate()]}function ys(e,t,r){return new Date(Date.UTC(e,t-1,r)).getUTCDay()}function W(e,t,r){let i=cs(r,t+1000),o=new Date(Date.UTC(i.year,i.month-1,i.day+fs)),[l,c,h]=[i.year,i.month,i.day],p=!0;while(Date.UTC(l,c-1,h)<=o.getTime()){if(!e.months.has(c)){[l,c,h]=c===12?[l+1,1,1]:[l,c+1,1],p=!1;continue}if(!gs(e,h,ys(l,c,h))){[l,c,h]=et(l,c,h,1),p=!1;continue}for(let m of[...e.hours].sort((v,g)=>v-g)){if(p&&m<i.hour)continue;for(let v of[...e.minutes].sort((g,w)=>g-w)){if(p&&m===i.hour&&v<i.minute)continue;for(let g of[...e.seconds].sort((w,b)=>w-b)){if(p&&m===i.hour&&v===i.minute&&g<i.second)continue;let w=us(r,{year:l,month:c,day:h,hour:m,minute:v,second:g});if(w!==void 0)return w}}}[l,c,h]=et(l,c,h,1),p=!1}return}var ws=/^(\d+)(s|m|h|d)$/,bs={s:1000,m:60000,h:3600000,d:86400000},vs=1000,ks=315360000000;function Ts(e,t){let r=ws.exec(e.trim());if(r===null)throw new E({code:"schedule_duration_malformed",message:`"${e}" is not a duration.`,hint:"A duration is a whole number and one unit: 90s, 15m, 2h, 7d. There is no combined form — write 90m rather than 1h30m.",field:t});let i=Number(r[1]),o=r[2]??"",l=i*(bs[o]??0);if(l<vs)throw new E({code:"schedule_duration_too_small",message:`"${e}" is under the one-second minimum.`,hint:"An interval below a second is a busy loop rather than a schedule. If the intent is to run continuously, a schedule is the wrong mechanism.",field:t});if(l>ks)throw new E({code:"schedule_duration_too_large",message:`"${e}" is over the ten-year maximum.`,hint:"An interval this long is almost always a unit typo — check whether d was meant where h was written.",field:t});return{ms:l,source:e.trim()}}var Es=315360000000,_s=900000,ie=1000;function at(e){let t=e.timezone??hs();ls(t);let r=e.expr.trim();if(e.kind==="cron"){let o=ps(r,e.field);if(W(o,e.now,t)===void 0)throw new E({code:"schedule_cron_unsatisfiable",message:`"${r}" never matches a real date.`,hint:"The expression parses but names a day that does not occur — 30 February, or a weekday-and-date pair that never coincide. Checked over four years, so a leap-year schedule like 0 3 29 2 * is accepted.",field:e.field});return{kind:"cron",spec:o,zone:t,source:r}}if(e.kind==="every")return{kind:"every",every:Ts(r,e.field),zone:t,source:r};let i=Date.parse(r);if(Number.isNaN(i))throw new E({code:"schedule_at_malformed",message:`"${r}" 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(i>e.now+Es)throw new E({code:"schedule_at_too_far",message:`${r} 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:i,zone:t,source:r}}function As(e){let t=2166136261;for(let r=0;r<e.length;r+=1)t^=e.charCodeAt(r),t=Math.imul(t,16777619)>>>0;return t}function Ss(e,t){if(t===void 0||t<=0)return 0;let r=Math.min(Math.floor(t/10),_s);return r<=0?0:As(e)%r}function $s(e,t){if(e.kind==="every")return e.every.ms;if(e.kind==="at")return;let r=W(e.spec,t,e.zone);if(r===void 0)return;let i=W(e.spec,r,e.zone);return i===void 0?void 0:i-r}function xs(e,t,r,i,o={}){if(e.kind==="at"){if(o.consumed===!0)return{runAt:void 0,anchor:void 0,missed:0,missedCapped:!1,late:!1};if(e.at<=i)return{runAt:i,anchor:e.at,missed:0,missedCapped:!1,late:!0};return{runAt:e.at,anchor:e.at,missed:0,missedCapped:!1,late:!1}}let l=Ss(t,$s(e,r));if(e.kind==="every"){let m=i-r,v=m<=0?0:Math.floor(m/e.every.ms),g=Math.min(v,ie),w=v+1,b=r+w*e.every.ms;return{runAt:b+l,anchor:b,missed:g,missedCapped:v>ie,late:!1}}let c=r,h=0,p=!1;for(;;){let m=W(e.spec,c,e.zone);if(m===void 0)return{runAt:void 0,anchor:void 0,missed:h,missedCapped:p,late:!1};if(m+l>i)return{runAt:m+l,anchor:m,missed:h,missedCapped:p,late:!1};if(c=m,h+=1,h>=ie){p=!0;let v=W(e.spec,i,e.zone);return{runAt:v===void 0?void 0:v+l,anchor:v,missed:h,missedCapped:!0,late:!1}}}}function Ns(e,t,r){let i=[],o=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([...de,...He(t.model)]),h=new Set,p=new Set;for(let[m,v]of o.entries()){if(v===null||typeof v!=="object"||Array.isArray(v))continue;let g=v,w=typeof g.id==="string"?g.id:`[${m}]`;if(p.has(w))i.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`});p.add(w);let b=g.deliver;if(b===void 0)i.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 S=b.channel;if(typeof S==="string"&&!l.has(S))i.push({code:"schedule_delivery_channel_unknown",message:`Schedule "${w}" delivers to "${S}", 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 k=g.role;if(typeof k==="string"){if(h.add(k),!c.has(k))i.push({code:"schedule_role_unknown",message:`Schedule "${w}" names the model role "${k}", 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 _=t.schedules[m];if(_!==void 0)try{at({id:_.id,kind:_.kind,expr:_.expr,timezone:_.timezone,now:r,field:`schedules[${m}].expr`})}catch(S){if(!(S instanceof j))throw S;i.push(S.toDetail())}}for(let m of He(t.model)){if(h.has(m))continue;i.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 ${de.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 i}function dt(e){if(typeof e!=="string")return String(e);let t=/^[A-Za-z0-9_./@~-]+$/.test(e),r=/^[A-Za-z0-9_./]/.test(e);if(!t||!r)return JSON.stringify(e);try{return x(e)===e?e:JSON.stringify(e)}catch{return JSON.stringify(e)}}function H(e){return e.length-e.trimStart().length}function he(e){let t=e.trim();return t===""||t.startsWith("#")}function tt(e,t,r,i){let o=new RegExp(`^\\s{${r}}${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*:`);for(let l=i;l<e.length;l+=1){let c=e[l]??"";if(he(c))continue;if(H(c)<r)return;if(H(c)===r&&o.test(c))return l}return}function oe(e,t,r){let i=t;for(let o=t+1;o<e.length;o+=1){let l=e[o]??"";if(he(l))continue;if(H(l)<=r)break;i=o}return i}function Is(e){let t;for(let r=0;r<e.length;r+=1){let i=e[r];if(t!==void 0){if(i===t)t=void 0;continue}if(i==='"'||i==="'"){t=i;continue}if(i!=="#"||r===0||!/\s/.test(e[r-1]??""))continue;let o=r;while(o>0&&/\s/.test(e[o-1]??""))o-=1;return e.slice(o)}return""}function fe(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function D(e,t,r){let i=" ".repeat(r);if(Array.isArray(t)){if(t.length===0)return[`${i}${e}: []`];return[`${i}${e}:`,...t.flatMap((o)=>Rs(o,r+2))]}if(fe(t)){let o=Object.entries(t);if(o.length===0)return[`${i}${e}: {}`];return[`${i}${e}:`,...o.flatMap(([l,c])=>D(l,c,r+2))]}return[`${i}${e}: ${dt(t)}`]}function Rs(e,t){let r=" ".repeat(t);if(!fe(e))return[`${r}- ${dt(e)}`];let i=Object.entries(e);if(i.length===0)return[`${r}- {}`];let o=i.flatMap(([h,p])=>D(h,p,t+2)),[l,...c]=o;return[`${r}- ${(l??"").trimStart()}`,...c]}function Os(e,t,r){if(t.length===0)return;let i=e.split(`
56
+ `),o=0,l=0,c,h=0;for(;h<t.length-1;h+=1){let g=tt(i,t[h]??"",l,o);if(g===void 0)break;c=g,o=g+1;let w=i.slice(g+1).find((b)=>!he(b)&&H(b)>l);if(w===void 0)return;l=H(w)}if(h<t.length-1){if(c===void 0)return;let g=oe(i,c,l-1)+1;return[...i.slice(0,g),...lt(t.slice(h),r,l),...i.slice(g)].join(`
57
+ `)}let p=t[t.length-1]??"",m=tt(i,p,l,o);if(m!==void 0){let g=i[m]??"",w=Array.isArray(r)||fe(r)?"":Is(g),b=oe(i,m,l),k=D(p,r,l);if(w!=="")k[0]=`${k[0]}${w}`;return[...i.slice(0,m),...k,...i.slice(b+1)].join(`
58
+ `)}if(c===void 0)return;let v=oe(i,c,l-1)+1;return[...i.slice(0,v),...D(p,r,l),...i.slice(v)].join(`
59
+ `)}function lt(e,t,r){let[i,...o]=e;if(i===void 0)return[];if(o.length===0)return D(i,t,r);return[`${" ".repeat(r)}${i}:`,...lt(o,t,r+Ls)]}var Ls=2;function Ms(e,t,r){let i=e.split(`
60
+ `),o=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),l=new RegExp(`^#\\s*${o}\\s*:`),c=i.findIndex((m)=>l.test(m));if(c===-1)return;let h=c;while(/^#\s{2,}\S/.test(i[h+1]??""))h+=1;let p=/^#\s*Phase \d/.test(i[c-1]??"")?c-1:c;return[...i.slice(0,p),...D(t,r,0),...i.slice(h+1)].join(`
61
+ `)}function Cs(e,t){let r=[...t.path],i=r.join("."),o=ct(Y(e),r),l=Os(e,r,t.value)??t.fallback?.(e)??(r.length===1?Ms(e,r[0]??"",t.value):void 0),c;if(l===void 0){let g=Y(e);g.setIn(r,t.value),c=String(g)}else c=l;let h=Y(c);if(h.errors.length>0)throw G(i,`the result is not valid YAML — ${h.errors[0]?.message??"unparseable"}`);let p=In.safeParse(h.toJS());if(!p.success){let g=p.error.issues[0];throw G(i,`${g?.path.join(".")??i}: ${g?.message??"does not fit the schema"}`)}let v=Ns(h.toJS(),p.data,Date.now())[0];if(v!==void 0)throw G(i,`${v.message} ${v.hint}`);try{ds(p.data.tools)}catch(g){throw G(i,g instanceof Error?g.message:"the providers block does not resolve")}return{next:c,before:o,reflowed:l===void 0,manifest:p.data}}async function yt(e){let t;try{t=await os(e.file,"utf8")}catch(i){throw Ds(e.file,i)}let r=Cs(t,e);return await as(e.file,r.next,"utf8"),{...r,after:e.value}}function wt(e){let t=e.trim();if(t==="")return"";let r=Y(t);if(r.errors.length>0)throw new j({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 r.toJS()}function ti(e,t){return ct(Y(e),t)}function ct(e,t){let r=e.getIn([...t],!1);if(r===void 0||r===null)return;return Pe(r)||Ue(r)?r.toJS(e):r}function Ds(e,t){return new j({code:"manifest_edit_unreadable",message:`Cannot read the manifest at ${e} to change it.`,hint:"Check the path and file permissions. Nothing was written.",cause:t})}function G(e,t){return new j({code:"manifest_edit_invalid",message:`Setting ${e} would make the manifest invalid: ${t}`,hint:"Nothing was written. Check the value's shape — a list is [a, b], a map is {k: v} — against the field this path names."})}var ze=[{path:"tools.local",means:"built-in tools: now, memory_write, artifact_read",agentListed:!0},{path:"tools.providers",means:"where tools come from, as a map — {system: {}} for shell and files, {web: {backend: tavily, apiKeyEnv: TAVILY_API_KEY}} for the internet. Several at once",toAgent:"A writeRoots key inside is refused",agentListed:!0},{path:"tools.pinned",means:"the tools from those providers this agent may call",agentListed:!0},{path:"tools.policy.allow",means:'rules permitting a call: "exec", or narrower like "exec(git *)". Also what lets a mutating tool run in a turn that has read untrusted content',agentListed:!0},{path:"tools.policy.deny",means:"rules refusing a call. Beats any allow rule",toAgent:"Replacing these is refused: it is the one edit whose only purpose is to remove a restriction someone set",agentListed:!0,confirm:"Deny rules are the restrictions that beat every allow rule. Replacing them removes whatever was deliberately put out of reach."},{path:"tools.policy.mode",means:"allow | ask | deny — for calls no rule mentions",agentListed:!0},{path:"tools.untrusted.onMutate",means:"refuse | confirm | allow — what happens when a tool that changes something is asked for in a turn that has read outside content",toAgent:'Cannot be set to "allow"',agentListed:!0,confirm:'Setting this to "allow" turns off the check that stops text from outside the conversation driving a tool that changes things. A fetched page that says "now delete the backups" would be acted on.'},{path:"tools.dialect",means:"nlt | native — how tool calls are written",agentListed:!0},{path:"model.main.id",means:"the model this agent runs on",agentListed:!0},{path:"model.main.temperature",means:"0 to 2",agentListed:!0},{path:"limits.maxSteps",means:"tool calls allowed in one turn",agentListed:!0},{path:"limits.toolTimeoutMs",means:"how long any single tool may take",agentListed:!0},{path:"context.observationMaxTokens",means:"how much of a tool's output reaches the model",agentListed:!0},{path:"channels",means:"how people reach this agent, as a list — [{type: telegram, id: tg, tokenEnv: TELEGRAM_BOT_TOKEN, mode: longpoll}]. The token goes in the .env",toAgent:"The token itself goes in the .env, which only a person can write. allowFrom is refused here: who may talk to you is not yours to decide",agentListed:!0},{path:"delivery",means:"where a reply goes when a turn has no origin — {default: tg}. Names a channel id, not a channel type",agentListed:!0},{path:"schedules",means:'what runs unattended, as a list — [{id, kind: cron|every|at, expr, task, deliver}]. expr is a 5- or 6-field cron, a duration like 15m, or an ISO instant; deliver is {channel, to} or the literal "none"',toAgent:"Only `serve` fires these; under `run` they are validated and listed and no timer starts. deliver.to is the address a reply is *sent* to — on Telegram the numeric chat id, never an @handle, which addresses a channel and not a person. It is the id inbound messages arrive on, so read it off your own session keys (tg:<id>); allowFrom holds handles and confers nothing here. Set role to name a model other than main. The whole list is replaced, so read it first",agentListed:!0},{path:"server.enabled",means:"true | false — serve the HTTP API on 127.0.0.1",toAgent:"host and tokenEnv are refused: binding anywhere reachable is not yours to decide",agentListed:!0},{path:"server.port",means:"port for the HTTP API",agentListed:!0},{path:"channels[].allowFrom",means:"who may talk to this agent through a channel. Empty or absent refuses everyone — a bot that is connected, healthy and answering nobody is almost always this",agentListed:!1,via:"config allow"},{path:"server.host",means:"the address the HTTP API binds. 127.0.0.1 is local only; anything else is reachable from the network",agentListed:!1},{path:"server.tokenEnv",means:"the env var holding the bearer token the API requires. Without it the API is unauthenticated",agentListed:!1},{path:"tools.providers.<id>.writeRoots",means:"the directories a file tool may write to, for that provider. Nothing outside them is writable — and this binds file tools only, never exec, which carries its target inside a shell string",agentListed:!1}];function ni(e){return ze.find((t)=>t.path===e)}var Zn=ze.filter((e)=>e.agentListed).map((e)=>e.path),mt=ze.filter((e)=>e.via===void 0&&!e.path.includes("<")&&!e.path.includes("[")).map((e)=>e.path);var Ui=["Summarise the conversation above for your own future reference. You are writing notes to yourself, not a report for a person.","","The person's own requests are preserved verbatim below your summary, so do not restate them.","Keep: decisions taken and why, facts established by tool results, and anything still outstanding.","Drop: pleasantries, your own reasoning, and anything already superseded.","Write plain prose under 300 words. No headings, no preamble, no closing summary.","End with one line naming what this summary does not cover, so a later step knows to ask rather than assume."].join(`
62
+ `);var Us="schedule";function oi(e,t,r){if(e.startsWith("shared:")){let i=e.slice(7);if(i!=="")return i}return Bt({channel:Us,peerId:t,thread:r})}function ii(e){let t=rt.safeParse(e.body);if(!t.success){let h=t.error.issues[0];throw new E({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 r=t.data;if(r.deliver!=="none"){if(!e.channelIds.includes(r.deliver.channel))throw new E({code:"schedule_delivery_channel_unknown",message:`Schedule "${r.id}" delivers to "${r.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(r.role!==void 0&&!e.roleNames.includes(r.role))throw new E({code:"schedule_role_unknown",message:`Schedule "${r.id}" names the model role "${r.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 i=at({id:r.id,kind:r.kind,expr:r.expr,timezone:r.timezone,now:e.now,field:"expr"}),o=new Date(e.now).toISOString(),l=xs(i,r.id,e.now,e.now),c=r.deliver==="none"?void 0:r.deliver;return{agentId:e.agentId,id:r.id,kind:r.kind,expr:r.expr,...r.timezone===void 0?{}:{timezone:r.timezone},task:r.task,...c===void 0?{}:{deliverChannel:c.channel,deliverTo:c.to},sessionMode:r.session,...r.role===void 0?{}:{role:r.role},enabled:r.enabled,origin:e.origin,anchorAt:l.anchor===void 0?o:new Date(l.anchor).toISOString(),nextRunAt:l.runAt===void 0?void 0:new Date(l.runAt).toISOString(),sourcePath:"",now:o}}var Fi=new Set("a an and are as at be but by do does for from had has have he her his i if in is it its me my not of on or our she that the their them then there they this to was we were what when which who will with you your would could should im ive dont its ill".split(" "));
63
+ export{re,wA,ee,j,E,u,wn,je,mn,Dn,_e,ve,bn,Sn,Mn,kn,On,Nn,Wo,ht,Zo,Xo,$o,Wn,ei,qe,Ai,yt,wt,ti,ze,ni,Zn,mt,oi,ii};
64
+
65
+ //# debugId=8823A3F23A6FC82B64756E2164756E21
66
+ //# sourceMappingURL=index-xhzmv4dh.js.map