dispach 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +144 -49
- package/dist/APEv2Parser-etzjd528.js +5 -0
- package/dist/{FlacParser-6jwner07.js.map → APEv2Parser-etzjd528.js.map} +1 -1
- package/dist/{AiffParser-n65syezh.js → AiffParser-y21k3fak.js} +3 -3
- package/dist/{AiffParser-n65syezh.js.map → AiffParser-y21k3fak.js.map} +1 -1
- package/dist/App-4w3qkcs4.js +11 -0
- package/dist/{App-pmqmzsb3.js.map → App-4w3qkcs4.js.map} +1 -1
- package/dist/{AsfParser-da1fqvxz.js → AsfParser-wd98k2h4.js} +3 -3
- package/dist/{AsfParser-da1fqvxz.js.map → AsfParser-wd98k2h4.js.map} +1 -1
- package/dist/{ConfigEditor-4nqbeejh.js → ConfigEditor-vk7vxaa6.js} +3 -3
- package/dist/{ConfigEditor-4nqbeejh.js.map → ConfigEditor-vk7vxaa6.js.map} +1 -1
- package/dist/{DsdiffParser-gk95sj7t.js → DsdiffParser-cbfaj500.js} +3 -3
- package/dist/{DsdiffParser-gk95sj7t.js.map → DsdiffParser-cbfaj500.js.map} +1 -1
- package/dist/{DsfParser-b0enevjw.js → DsfParser-tybrja4x.js} +3 -3
- package/dist/{DsfParser-b0enevjw.js.map → DsfParser-tybrja4x.js.map} +1 -1
- package/dist/FlacParser-7t7da7qy.js +5 -0
- package/dist/{APEv2Parser-jdp5yp24.js.map → FlacParser-7t7da7qy.js.map} +1 -1
- package/dist/{KeyProbe-rspsxpsr.js → KeyProbe-5anphmb7.js} +3 -3
- package/dist/{KeyProbe-rspsxpsr.js.map → KeyProbe-5anphmb7.js.map} +1 -1
- package/dist/{MP4Parser-ph7rv2fn.js → MP4Parser-gc94h1n9.js} +3 -3
- package/dist/{MP4Parser-ph7rv2fn.js.map → MP4Parser-gc94h1n9.js.map} +1 -1
- package/dist/{MatroskaParser-fjk1mpct.js → MatroskaParser-cy2k4fac.js} +3 -3
- package/dist/{MatroskaParser-fjk1mpct.js.map → MatroskaParser-cy2k4fac.js.map} +1 -1
- package/dist/{MpegParser-vp7cj8ts.js → MpegParser-c460fwf0.js} +3 -3
- package/dist/{MpegParser-vp7cj8ts.js.map → MpegParser-c460fwf0.js.map} +1 -1
- package/dist/{MusepackParser-v22gft1f.js → MusepackParser-8mq2eabg.js} +3 -3
- package/dist/{MusepackParser-v22gft1f.js.map → MusepackParser-8mq2eabg.js.map} +1 -1
- package/dist/OggParser-7dnc6apg.js +5 -0
- package/dist/{OggParser-as1m8xsa.js.map → OggParser-7dnc6apg.js.map} +1 -1
- package/dist/Picker-j7txnm7w.js +5 -0
- package/dist/{Picker-jkmd5xnx.js.map → Picker-j7txnm7w.js.map} +1 -1
- package/dist/SessionPicker-hpv2ncsb.js +5 -0
- package/dist/{SessionPicker-3712ke3k.js.map → SessionPicker-hpv2ncsb.js.map} +3 -3
- package/dist/SkillBrowser-qc542n71.js +5 -0
- package/dist/{SkillBrowser-qhsyszt4.js.map → SkillBrowser-qc542n71.js.map} +1 -1
- package/dist/{WavPackParser-b4qqavzg.js → WavPackParser-kt7cds9c.js} +3 -3
- package/dist/{WavPackParser-b4qqavzg.js.map → WavPackParser-kt7cds9c.js.map} +1 -1
- package/dist/{WaveParser-fqs1h38f.js → WaveParser-g47ja0vy.js} +3 -3
- package/dist/{WaveParser-fqs1h38f.js.map → WaveParser-g47ja0vy.js.map} +1 -1
- package/dist/WizardApp-q4p979d1.js +5 -0
- package/dist/{WizardApp-qrq36nv8.js.map → WizardApp-q4p979d1.js.map} +3 -3
- package/dist/{channels-gf31stv7.js → channels-4t89qpdt.js} +18 -18
- package/dist/{channels-gf31stv7.js.map → channels-4t89qpdt.js.map} +1 -1
- package/dist/client.d.ts +242 -1
- package/dist/client.js +11 -11
- package/dist/client.js.map +5 -5
- package/dist/config-35r6n1gh.js +24 -0
- package/dist/{config-z2cd0c5f.js.map → config-35r6n1gh.js.map} +1 -1
- package/dist/credential-dpdgg4j6.js +19 -0
- package/dist/{credential-h0wmsjsw.js.map → credential-dpdgg4j6.js.map} +1 -1
- package/dist/{index-3s2q0m64.js → index-0444sh6x.js} +4 -4
- package/dist/{index-3s2q0m64.js.map → index-0444sh6x.js.map} +1 -1
- package/dist/{index-v271gbaz.js → index-095hrkyr.js} +6 -6
- package/dist/{index-v271gbaz.js.map → index-095hrkyr.js.map} +1 -1
- package/dist/index-1x8mzvz7.js +6 -0
- package/dist/{index-rhv6gqpt.js.map → index-1x8mzvz7.js.map} +1 -1
- package/dist/index-2bsardvh.js +5 -0
- package/dist/{index-tny7c703.js.map → index-2bsardvh.js.map} +2 -2
- package/dist/{index-9m6b14b4.js → index-2zjh5zd5.js} +4 -4
- package/dist/{index-9m6b14b4.js.map → index-2zjh5zd5.js.map} +1 -1
- package/dist/{index-t6xnecdx.js → index-323jvr1g.js} +4 -4
- package/dist/{index-t6xnecdx.js.map → index-323jvr1g.js.map} +1 -1
- package/dist/{index-gace5ac7.js → index-3826kf9t.js} +5 -5
- package/dist/{index-gace5ac7.js.map → index-3826kf9t.js.map} +1 -1
- package/dist/index-38gs9anh.js +9 -0
- package/dist/{index-b7qc21s7.js.map → index-38gs9anh.js.map} +1 -1
- package/dist/index-3c5jt6by.js +5 -0
- package/dist/{index-3mvenfbg.js.map → index-3c5jt6by.js.map} +2 -2
- package/dist/{index-k2q76dhw.js → index-3vzf253k.js} +7 -7
- package/dist/{index-k2q76dhw.js.map → index-3vzf253k.js.map} +1 -1
- package/dist/{index-t5d8ey5t.js → index-42e29zs4.js} +4 -4
- package/dist/{index-t5d8ey5t.js.map → index-42e29zs4.js.map} +1 -1
- package/dist/{index-v7mz396x.js → index-4fj1k64j.js} +4 -4
- package/dist/{index-v7mz396x.js.map → index-4fj1k64j.js.map} +1 -1
- package/dist/{index-gqbny9gy.js → index-51x0n5z0.js} +6 -6
- package/dist/{index-gqbny9gy.js.map → index-51x0n5z0.js.map} +1 -1
- package/dist/index-664xcamy.js +110 -0
- package/dist/index-664xcamy.js.map +13 -0
- package/dist/index-7mn8ack9.js +6 -0
- package/dist/{index-qe3ybzh6.js.map → index-7mn8ack9.js.map} +2 -2
- package/dist/index-8edck2pr.js +6 -0
- package/dist/{index-kktaw552.js.map → index-8edck2pr.js.map} +1 -1
- package/dist/index-8h6kewy1.js +9 -0
- package/dist/{index-s4a28ctb.js.map → index-8h6kewy1.js.map} +1 -1
- package/dist/index-8tmv33mr.js +6 -0
- package/dist/{index-v6taf4vn.js.map → index-8tmv33mr.js.map} +1 -1
- package/dist/index-9914wh1d.js +6 -0
- package/dist/index-9914wh1d.js.map +10 -0
- package/dist/{index-y6r1k2yd.js → index-a2eh8dnk.js} +7 -7
- package/dist/{index-y6r1k2yd.js.map → index-a2eh8dnk.js.map} +1 -1
- package/dist/{index-81vj1bxe.js → index-bqdkm3de.js} +4 -4
- package/dist/{index-81vj1bxe.js.map → index-bqdkm3de.js.map} +1 -1
- package/dist/{index-rfa0ztab.js → index-dzy19wtf.js} +4 -4
- package/dist/{index-rfa0ztab.js.map → index-dzy19wtf.js.map} +1 -1
- package/dist/{index-c2qjdz4q.js → index-eqqd4k4f.js} +9 -9
- package/dist/{index-c2qjdz4q.js.map → index-eqqd4k4f.js.map} +1 -1
- package/dist/{index-g1d06ct5.js → index-ew997be5.js} +7 -7
- package/dist/{index-g1d06ct5.js.map → index-ew997be5.js.map} +1 -1
- package/dist/{index-0v2gw4mk.js → index-fa9wvpyw.js} +3 -3
- package/dist/{index-0v2gw4mk.js.map → index-fa9wvpyw.js.map} +1 -1
- package/dist/{index-rvq7t636.js → index-fbsrhcga.js} +4 -4
- package/dist/{index-rvq7t636.js.map → index-fbsrhcga.js.map} +1 -1
- package/dist/index-fcsg95m5.js +11 -0
- package/dist/{index-5nprb9px.js.map → index-fcsg95m5.js.map} +1 -1
- package/dist/{index-dgrwpzz9.js → index-gbkma7ds.js} +4 -4
- package/dist/{index-dgrwpzz9.js.map → index-gbkma7ds.js.map} +1 -1
- package/dist/{index-0m0x1454.js → index-gq1npngp.js} +4 -4
- package/dist/{index-0m0x1454.js.map → index-gq1npngp.js.map} +1 -1
- package/dist/index-haypwvzd.js +308 -0
- package/dist/index-haypwvzd.js.map +21 -0
- package/dist/{index-g8n8rhtr.js → index-jc4kmfwa.js} +4 -4
- package/dist/{index-g8n8rhtr.js.map → index-jc4kmfwa.js.map} +1 -1
- package/dist/index-kjqksgch.js +429 -0
- package/dist/index-kjqksgch.js.map +12 -0
- package/dist/{index-es4bgkbh.js → index-m6fqx0ch.js} +7 -7
- package/dist/{index-es4bgkbh.js.map → index-m6fqx0ch.js.map} +1 -1
- package/dist/{index-60jxyzbe.js → index-ma6p7bt4.js} +4 -4
- package/dist/{index-60jxyzbe.js.map → index-ma6p7bt4.js.map} +1 -1
- package/dist/index-nvc24414.js +6 -0
- package/dist/{index-2yj11ykt.js.map → index-nvc24414.js.map} +1 -1
- package/dist/index-nxhqf597.js +6 -0
- package/dist/{index-m5rmhcez.js.map → index-nxhqf597.js.map} +1 -1
- package/dist/{index-jmnjcw61.js → index-p1zy871m.js} +4 -4
- package/dist/{index-jmnjcw61.js.map → index-p1zy871m.js.map} +1 -1
- package/dist/{index-2pzgta33.js → index-p6ya59m6.js} +5 -5
- package/dist/{index-2pzgta33.js.map → index-p6ya59m6.js.map} +1 -1
- package/dist/{index-6c4p19m1.js → index-pszmnhgq.js} +2 -2
- package/dist/index-qg9bn980.js +1213 -0
- package/dist/{index-1h9pqnec.js.map → index-qg9bn980.js.map} +28 -25
- package/dist/index-qgsdgbk8.js +5 -0
- package/dist/{index-ak304afj.js.map → index-qgsdgbk8.js.map} +2 -2
- package/dist/index-r4ax3x4d.js +74 -0
- package/dist/index-r4ax3x4d.js.map +13 -0
- package/dist/{index-m01mb74d.js → index-snz49ndn.js} +4 -4
- package/dist/{index-m01mb74d.js.map → index-snz49ndn.js.map} +1 -1
- package/dist/index-twn9bfm2.js +8 -0
- package/dist/{index-dwxmy0kx.js.map → index-twn9bfm2.js.map} +2 -2
- package/dist/{index-0p9p6fvc.js → index-wc4entme.js} +10 -10
- package/dist/{index-0p9p6fvc.js.map → index-wc4entme.js.map} +3 -3
- package/dist/{index-wxmqyv4c.js → index-ynsvkqgb.js} +4 -4
- package/dist/{index-wxmqyv4c.js.map → index-ynsvkqgb.js.map} +1 -1
- package/dist/index-ytxbw8py.js +63 -0
- package/dist/{index-fcqy46mh.js.map → index-ytxbw8py.js.map} +2 -2
- package/dist/index-yw3fby4n.js +6 -0
- package/dist/{index-dh2g58s1.js.map → index-yw3fby4n.js.map} +2 -2
- package/dist/{index-ccpq4k6r.js → index-z157at3s.js} +28 -28
- package/dist/{index-ccpq4k6r.js.map → index-z157at3s.js.map} +1 -1
- package/dist/{index-s78sq9g1.js → index-zce9gy22.js} +64 -64
- package/dist/{index-s78sq9g1.js.map → index-zce9gy22.js.map} +1 -1
- package/dist/{index-jv7egrh2.js → index-zw6wyas6.js} +4 -4
- package/dist/{index-jv7egrh2.js.map → index-zw6wyas6.js.map} +1 -1
- package/dist/index.js +308 -292
- package/dist/index.js.map +15 -12
- package/dist/init.d.ts.map +1 -1
- package/dist/lib/agent-template.d.ts +5 -0
- package/dist/lib/agent-template.d.ts.map +1 -1
- package/dist/lib/commands.d.ts.map +1 -1
- package/dist/lib/init-flow.d.ts +7 -30
- package/dist/lib/init-flow.d.ts.map +1 -1
- package/dist/lib/owner.d.ts +49 -0
- package/dist/lib/owner.d.ts.map +1 -0
- package/dist/lib/presets.d.ts +44 -0
- package/dist/lib/presets.d.ts.map +1 -0
- package/dist/lib/provision.d.ts +8 -1
- package/dist/lib/provision.d.ts.map +1 -1
- package/dist/lib/relay-client.d.ts +17 -0
- package/dist/lib/relay-client.d.ts.map +1 -0
- package/dist/lib/schema.d.ts +2 -0
- package/dist/lib/schema.d.ts.map +1 -1
- package/dist/lib/sessions-view.d.ts +2 -0
- package/dist/lib/sessions-view.d.ts.map +1 -1
- package/dist/lib/source.d.ts +17 -0
- package/dist/lib/source.d.ts.map +1 -1
- package/dist/lib/wizard.d.ts.map +1 -1
- package/dist/owner.d.ts +16 -0
- package/dist/owner.d.ts.map +1 -0
- package/dist/run.d.ts.map +1 -1
- package/dist/serve.d.ts.map +1 -1
- package/dist/transcript.d.ts.map +1 -1
- package/dist/web-zph4h3p9.js +14 -0
- package/dist/{web-stkkwyka.js.map → web-zph4h3p9.js.map} +1 -1
- package/dist/wire.d.ts +31 -0
- package/dist/wire.js +2 -2
- package/dist/wire.js.map +4 -4
- package/dist/wrapper-f662ny3r.js +5 -0
- package/dist/{wrapper-bwxbqa53.js.map → wrapper-f662ny3r.js.map} +1 -1
- package/package.json +5 -2
- package/dist/APEv2Parser-jdp5yp24.js +0 -5
- package/dist/App-pmqmzsb3.js +0 -11
- package/dist/FlacParser-6jwner07.js +0 -5
- package/dist/OggParser-as1m8xsa.js +0 -5
- package/dist/Picker-jkmd5xnx.js +0 -5
- package/dist/SessionPicker-3712ke3k.js +0 -5
- package/dist/SkillBrowser-qhsyszt4.js +0 -5
- package/dist/WizardApp-qrq36nv8.js +0 -5
- package/dist/config-z2cd0c5f.js +0 -24
- package/dist/credential-h0wmsjsw.js +0 -19
- package/dist/index-026q0y3a.js +0 -6
- package/dist/index-026q0y3a.js.map +0 -10
- package/dist/index-1h9pqnec.js +0 -1194
- package/dist/index-1wxw30j1.js +0 -74
- package/dist/index-1wxw30j1.js.map +0 -13
- package/dist/index-2yj11ykt.js +0 -6
- package/dist/index-358nsn9t.js +0 -65
- package/dist/index-358nsn9t.js.map +0 -21
- package/dist/index-3mvenfbg.js +0 -5
- package/dist/index-5nprb9px.js +0 -11
- package/dist/index-ak304afj.js +0 -5
- package/dist/index-b7qc21s7.js +0 -9
- package/dist/index-dh2g58s1.js +0 -6
- package/dist/index-dwxmy0kx.js +0 -8
- package/dist/index-fcqy46mh.js +0 -63
- package/dist/index-kktaw552.js +0 -6
- package/dist/index-m5rmhcez.js +0 -6
- package/dist/index-qe3ybzh6.js +0 -6
- package/dist/index-rhv6gqpt.js +0 -6
- package/dist/index-s4a28ctb.js +0 -9
- package/dist/index-tny7c703.js +0 -5
- package/dist/index-v6taf4vn.js +0 -6
- package/dist/index-y605a1rj.js +0 -429
- package/dist/index-y605a1rj.js.map +0 -11
- package/dist/index-z88f35vs.js +0 -96
- package/dist/index-z88f35vs.js.map +0 -13
- package/dist/web-stkkwyka.js +0 -14
- package/dist/wrapper-bwxbqa53.js +0 -5
- /package/dist/{index-6c4p19m1.js.map → index-pszmnhgq.js.map} +0 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{n,s,_,He,E,r,pt,x,D,ft,js,bt,Ot,ge,z}from"./index-qg9bn980.js";var wn="dispach",bn="Dispach",vn=1;function he(e,t){return{slug:e,name:t,envPrefix:`${e.toUpperCase()}_`,stateDir:`.${e}`,apiVersion:`${e}/v${vn}`,packageScope:`@${e}`}}var K=he(wn,bn),X=`${K.envPrefix}BRAND`,Ue=/^[a-z][a-z0-9]*(-[a-z0-9]+)*$/;function Pe(e){return e.split("-").map((t)=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function Fe(e){if(e===void 0)return K;let t=e.trim();if(t==="")throw Error(`${X} is set but empty. hint: unset ${X} 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(!Ue.test(t))throw Error(`${X}="${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===K.slug)return K;return he(t,Pe(t))}var se=Fe(process.env[X]);function _n(e,t){let i=Array.from({length:t.length+1},(o,a)=>a);for(let o=1;o<=e.length;o+=1){let a=[o];for(let d=1;d<=t.length;d+=1){let l=(i[d-1]??0)+(e[o-1]===t[d-1]?0:1),c=(a[d-1]??0)+1,u=(i[d]??0)+1;a.push(Math.min(l,c,u))}i=a}return i[t.length]??Math.max(e.length,t.length)}function Yt(e,t){let i,o=Number.POSITIVE_INFINITY;for(let a of t){let d=_n(e,a);if(d<o)o=d,i=a}return i!==void 0&&o<=Math.max(2,Math.floor(e.length/3))?i:void 0}var je=Symbol.for("dispach.HarnessError");function R(e){return typeof e==="object"&&e!==null&&je in e}class te 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[je]=!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 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 h extends te{static ERROR_NAME="ConfigError"}class st extends te{static ERROR_NAME="ModelError";status;retryAfterSeconds;constructor(e){super(e);this.status=e.status,this.retryAfterSeconds=e.retryAfterSeconds}}class S extends te{static ERROR_NAME="ToolError"}function We(e,t){return new h({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 Be(){return new h({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 Ke(e,t){return new S({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 Xe(){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 Ge(){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 qe(){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 Ye(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 k(e,t,i,o="images"){return new te({code:e,message:t,hint:i,field:o})}function ze(e,t,i,o){return new h({code:"schedule_tool_unknown",message:`Schedule "${e}" allows ${t.join(", ")}, which ${t.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: ${i.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??((t,i)=>{console.error(`event handler threw while handling ${i.type}:`,t)})}on(e,t,i={}){if(e==="*"){let d=this.#e.has(t),l=i.chunks===!0,c=d?this.#e.get(t)??!1:!1;if(this.#e.set(t,l||c),!d&&l)this.#t+=1;else if(d&&l&&!c)this.#t+=1;return()=>{if(!this.#e.has(t))return;if(this.#e.get(t)===!0)this.#t-=1;this.#e.delete(t)}}let o=this.#n.get(e);if(o===void 0)o=new Set,this.#n.set(e,o);let a=!o.has(t);if(o.add(t),a&&e==="model.chunk")this.#t+=1;return()=>{if(o?.delete(t)===!0&&e==="model.chunk")this.#t-=1}}once(e,t,i={}){let o=this.on(e,(a)=>{o(),t(a)},i);return o}next(e,t,i={}){return new Promise((o,a)=>{let d=this.on(e,(c)=>{d(),t?.removeEventListener("abort",l),o(c)},i),l=()=>{d(),a(t?.reason??Error("aborted"))};t?.addEventListener("abort",l,{once:!0})})}get chunkSubscribers(){return this.#t}emit(e,t,i={}){if(e==="model.chunk"&&this.#t===0)return;let o={v:1,ts:this.#i(),runtimeId:this.runtimeId,...i.agentId===void 0?{}:{agentId:i.agentId},...i.sessionKey===void 0?{}:{sessionKey:i.sessionKey},...i.turnId===void 0?{}:{turnId:i.turnId},...i.stepId===void 0?{}:{stepId:i.stepId},...i.parentTurnId===void 0?{}:{parentTurnId:i.parentTurnId},...i.parentSessionKey===void 0?{}:{parentSessionKey:i.parentSessionKey},type:e,data:t};this.#o(o)}#o(e){let t=e.type==="model.chunk",i=this.#n.get(e.type);if(i!==void 0)for(let o of[...i])this.#r(o,e);for(let[o,a]of[...this.#e]){if(t&&!a)continue;this.#r(o,e)}}#r(e,t){try{e(t)}catch(i){this.#s(i,t)}}}var xe="0.2.2",Tn=/^(\d+)\.(\d+)\.(\d+)$/,En=/^(\d+)(?:\.(\d+))?(?:\.(\d+))?$/;function kn(e){let t=Tn.exec(e.trim());if(t===null)return;return{major:Number(t[1]),minor:Number(t[2]),patch:Number(t[3])}}function An(e){let t=/^(\d+\.\d+\.\d+)(?:-[0-9A-Za-z.-]+)?$/.exec(e.trim());return t===null?void 0:kn(t[1]??"")}function Sn(e){let t=En.exec(e.trim());if(t===null)return;let[,i,o,a]=t;return{version:{major:Number(i),minor:Number(o??0),patch:Number(a??0)},specified:a!==void 0?3:o!==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 $n(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 Nn(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 In(e,t){if(t==="*"||t==="x"||t==="X")return!0;let i=/^(>=|<=|>|<|=|\^|~)?\s*(\S.*)$/.exec(t);if(i===null)return;let o=Sn(i[2]??"");if(o===void 0)return;let{version:a,specified:d}=o;switch(i[1]){case"^":return I(e,a)>=0&&I(e,$n(a))<0;case"~":return I(e,a)>=0&&I(e,Nn(a,d))<0;case">=":return I(e,a)>=0;case"<=":return I(e,a)<=0;case">":return I(e,a)>0;case"<":return I(e,a)<0;default:if(d===3)return I(e,a)===0;if(d===2)return e.major===a.major&&e.minor===a.minor;return e.major===a.major}}function dr(e,t){let i=An(e);if(i===void 0)return;let o=t.split("||"),a=!1;for(let d of o){let l=d.trim().split(/\s+/).filter((u)=>u!=="");if(l.length===0)return;let c=!0;for(let u of l){let f=In(i,u);if(f===void 0)return;if(!f)c=!1}if(a=!0,c)return!0}return a?!1:void 0}var ur=200;var On="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 A=(e)=>String.fromCharCode(e),P=A(27),nt=A(7),Rn=new RegExp(`${P}\\[[0-?]*[ -/]*[@-~]`,"g"),xn=new RegExp(`${P}\\][\\s\\S]*?(?:${nt}|${P}\\\\|$)`,"g"),Ln=new RegExp(`${P}[P^_X][\\s\\S]*?(?:${P}\\\\|${nt}|$)`,"g"),Mn=new RegExp(`${P}[@-Z\\\\-_0-9=><]?`,"g"),Dn=new RegExp(`[${A(128)}-${A(159)}]`,"g"),Cn=new RegExp(`[${A(0)}-${A(8)}${A(11)}${A(12)}${A(14)}-${A(31)}${A(127)}]`,"g");function jt(e){return e.replace(/\r\n/g,`
|
|
5
|
+
`).replace(/\r/g,`
|
|
6
|
+
`).replace(xn,"").replace(Ln,"").replace(Rn,"").replace(Mn,"").replace(Dn,"").replace(Cn,"")}function it(e){return e==="untrusted"?"obu":"obs"}function rt(e){return e.startsWith(`${it("untrusted")}_`)?"untrusted":"trusted"}var Un=3.8;function ot(e){if(e==="")return 0;let t=0;for(let i=0;i<e.length;i+=1)if(e.charCodeAt(i)===10)t+=1;return Math.ceil(e.length/Un)+t}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","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"],Pn=/\r\n\r\n|\n\n|\r\r/;function Ve(e){let t=[],i,o,a;for(let d of e.split(/\r\n|\n|\r/)){if(d===""||d.startsWith(":"))continue;let l=d.indexOf(":"),c=l===-1?d:d.slice(0,l),u=l===-1?"":d.slice(l+1);if(u.startsWith(" "))u=u.slice(1);switch(c){case"data":t.push(u);break;case"event":i=u;break;case"id":o=u;break;case"retry":{let f=Number.parseInt(u,10);if(Number.isFinite(f))a=f;break}default:break}}if(t.length===0&&i===void 0)return;return{...i===void 0?{}:{event:i},data:t.join(`
|
|
7
|
+
`),...o===void 0?{}:{id:o},...a===void 0?{}:{retry:a}}}async function*Er(e){let t=new TextDecoder,i="";for await(let o of e){i+=typeof o==="string"?o:t.decode(o,{stream:!0});while(!0){let a=Pn.exec(i);if(a===null)break;let d=i.slice(0,a.index);i=i.slice(a.index+a[0].length);let l=Ve(d);if(l!==void 0)yield l}}if(i+=t.decode(),i.trim()!==""){let o=Ve(i);if(o!==void 0)yield o}}function Cr(){return{push:(e)=>e,endStep:()=>"",end:()=>""}}var at=["anyOf","oneOf","allOf","not","$ref"],Fn=["format","minimum","maximum","exclusiveMinimum","exclusiveMaximum","minLength","maxLength","pattern","minItems","maxItems"],jn=new Set(["string","number","integer","boolean","array","object"]),Wn=new Set(["string","number","integer","boolean"]);function Bn(e){let t=e.anyOf??e.oneOf,i=Array.isArray(t)?t.map((a)=>{let d=L(a);if(d===void 0)return;return Object.keys(d).filter((c)=>c!=="type"&&c!=="description"&&c!=="title").length===0?d.type:void 0}):Array.isArray(e.type)?e.type:[];if(t!==void 0&&!Array.isArray(t))return;let o=i.filter((a)=>a!=="null");if(o.length<2)return;if(!o.every((a)=>typeof a==="string"&&Wn.has(a)))return;return[...new Set(o)]}function L(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)?e:void 0}function Hn(e){let t=[];for(let i of Fn){let o=e[i];if(o===void 0||o===null)continue;if(typeof o==="object")continue;t.push(`${i} ${String(o)}`)}return t.join(", ")}function Je(e){let t=typeof e.description==="string"?e.description.trim():"",i=Hn(e);if(t===""&&i==="")return;if(i==="")return t;return t===""?i:`${t} (${i})`}function dt(e){return Array.isArray(e)?e.filter((t)=>typeof t==="string"):[]}function Kn(e){let t=e.anyOf??e.oneOf;if(!Array.isArray(t)||t.length!==2)return e;let i=(c)=>L(c)?.type==="null",o=t.find((c)=>!i(c));if(!t.some(i)||L(o)===void 0)return e;let{anyOf:a,oneOf:d,...l}=e;return{...L(o),...l}}function Xn(e){if(!Array.isArray(e))return e;let t=e.filter((i)=>i!=="null");return t.length===1?t[0]:e}function lt(e,t,i){let o=Kn(e),a=Bn(o),d=a===void 0?o:(({anyOf:p,oneOf:y,...w})=>w)(o);for(let p of at)if(d[p]!==void 0)throw i.unsupported(t,p);if(a!==void 0){let p=Je(d);return{type:a,...p===void 0?{}:{description:p},...d.default===void 0||d.default===null?{}:{default:d.default}}}let l=Xn(d.type);if(Array.isArray(l))throw i.unsupported(t,"type: []");let c=typeof l==="string"&&jn.has(l)?l:i.untyped??"string",u=Je(d),f=Array.isArray(d.enum)?d.enum.filter((p)=>typeof p==="string"||typeof p==="number"||typeof p==="boolean"):void 0,g=c==="array"?L(d.items):void 0,m=c==="object"?L(d.properties):void 0;return{type:c,...u===void 0?{}:{description:u},...f===void 0||f.length===0?{}:{enum:f},...g===void 0?{}:{items:lt(g,`${t}[]`,i)},...m===void 0?{}:{properties:ct(m,t,i),required:dt(d.required)},...d.default===void 0||d.default===null?{}:{default:d.default}}}function ct(e,t,i){let o={};for(let[a,d]of Object.entries(e)){let l=L(d);if(l===void 0)continue;o[a]=lt(l,t===""?a:`${t}.${a}`,i)}return o}function ro(e,t){if(e===void 0)return{type:"object",properties:{}};for(let d of at)if(e[d]!==void 0)throw t.unsupported(t.rootPath??"parameters",d);let i=L(e.properties)??{},o=dt(e.required),a=ct(i,"",t);return{type:"object",properties:a,...o.length===0?{}:{required:o.filter((d)=>(d in a))}}}var ut="<<<",ht=">>>",G=/^\s*(?:(?:[-*+]|\d+[.)])\s+)?(?:<\s*)?action\s*:(.+)$/i,Gn=/^\s*(?:[-*+]\s+|\d+[.)]\s+)?([A-Za-z_][\w.-]*?)\s*:(.*)$/,ye=/^\s*`{3,}\s*(?:[\w+-]+\s*)?$/,fe=/^\s*end\s*$/i,qn=/^\s*<\s*action\s*>\s*$/i,Ze=/^\s*<\s*\/\s*action\s*>\s*$/i,Yn=/^\s*<\/?\s*[A-Za-z_][\w.:-]*\s*(?:\/\s*)?>\s*$/;function Qe(e){let t=(e??"").trim();return t.endsWith(">")?t.slice(0,-1).trimEnd():t}function me(e){return et(et(zn(e,"`'\"*<"),"`'\"*>"),".,;:").trim()}function zn(e,t){let i=0;while(i<e.length&&t.includes(e[i]??""))i+=1;return e.slice(i)}function et(e,t){let i=e.length;while(i>0&&t.includes(e[i-1]??""))i-=1;return e.slice(0,i)}function mt(e,t,i){let o=e.fields.get(t);if(o===void 0)e.fields.set(t,[i]);else o.push(i)}function gt(e){if(e.block===void 0||e.heredocKey===void 0)return;let t=[...e.heredocLines];if(t[t.length-1]==="")t.pop();mt(e.block,e.heredocKey,t.join(`
|
|
8
|
+
`)),e.block.wrapped.add(e.heredocKey),e.heredocKey=void 0,e.heredocLines=[]}function U(e){if(gt(e),e.block!==void 0)e.blocks.push(e.block);e.block=void 0,e.openKey=void 0,e.awaitingSlug=!1}function tt(){return{block:void 0,openKey:void 0,severedKey:void 0,severedPending:void 0,heredocKey:void 0,heredocLines:[],justClosed:!1,awaitingSlug:!1,text:[],blocks:[]}}function Vn(e,t,i){let o=t.trim();if(e.heredocKey!==void 0){if(o===ht){gt(e);return}if(fe.test(o)){U(e),e.justClosed=!0;return}if(G.test(t)){U(e);let l=G.exec(t),c=me(Qe(l?.[1]));if(c!=="")e.block={slug:c,fields:new Map,wrapped:new Set,severed:new Set};return}e.heredocLines.push(t);return}let a=G.exec(t);if(a!==null){let l=me(Qe(a[1]));if(U(e),l==="")return;e.block={slug:l,fields:new Map,wrapped:new Set,severed:new Set};return}if(qn.test(t)){U(e),e.awaitingSlug=!0;return}if(e.awaitingSlug){if(o==="")return;if(Ze.test(t)){e.awaitingSlug=!1;return}let l=me(o);if(e.awaitingSlug=!1,l!=="")e.block={slug:l,fields:new Map,wrapped:new Set,severed:new Set};return}if(Ze.test(t)){if(e.block!==void 0)U(e),e.justClosed=!0;return}if(Yn.test(t))return;if(e.block===void 0){if(ye.test(t)&&(e.justClosed||i())){e.justClosed=!1;return}if(fe.test(o)&&e.severedPending!==void 0){e.severedPending.block.severed.add(e.severedPending.key),e.severedPending=void 0;return}if(G.test(t))e.severedPending=void 0;if(e.text.push(t),o!=="")e.justClosed=!1;return}if(o===""){if(e.openKey!==void 0)e.severedKey=e.openKey;e.openKey=void 0;return}if(fe.test(o)){e.severedKey=void 0,U(e),e.justClosed=!0;return}if(ye.test(t))return;let d=Gn.exec(t);if(d!==null){let l=(d[1]??"").trim(),c=(d[2]??"").trim();if(e.severedKey=void 0,c===ut)e.heredocKey=l,e.heredocLines=[],e.openKey=void 0;else mt(e.block,l,c),e.openKey=l;return}if(e.openKey!==void 0){let l=e.block.fields.get(e.openKey),c=l?.[l.length-1];if(l!==void 0&&c!==void 0)l[l.length-1]=c===""?o:`${c}
|
|
9
|
+
${o}`;return}if(e.severedKey!==void 0)e.severedPending={block:e.block,key:e.severedKey},e.severedKey=void 0;U(e),e.text.push(t)}function Jn(e){if(/^\s*(?:(?:[-*+]|\d+[.)]?)\s*)?$/.test(e))return!0;let t=e.replace(/^\s*(?:[-*+]\s+|\d+[.)]\s+)?/,"").toLowerCase(),i=t.startsWith("<")?t.slice(1):t;if("action:".startsWith(i)||i.startsWith("action:"))return!0;if(/^<\/?$/.test(t)||/^<\/?[a-z_][\w.:-]*>?$/.test(t))return!0;return/^`{1,3}[\w+-]*$/.test(t)}function pe(e){return e.endsWith("\r")?e.slice(0,-1):e}function pr(){let e=tt(),t="",i=0,o,a="",d=!1,l=(m)=>{if(m==="")return"";if(m.trim()==="")return a+=m,"";let p=a+m;if(a="",d)return p;return d=!0,p.replace(/^\s+/,"")},c=(m,p)=>{let y=e.text.length;return Vn(e,m,()=>p!==void 0&&G.test(p)),e.text.length>y?m:void 0},u=(m,p,y)=>{let w=c(m,p);if(w===void 0)return"";return l(w.slice(y))+l(`
|
|
10
|
+
`)},f=(m)=>{if(o===void 0)return"";let p=o;return o=void 0,u(p,m,0)};return{push(m){let p="";t+=m;let y=t.indexOf(`
|
|
11
|
+
`);while(y!==-1){let b=pe(t.slice(0,y));if(t=t.slice(y+1),p+=f(b),e.block===void 0&&ye.test(b)&&!e.justClosed)o=b;else p+=u(b,void 0,i);i=0,y=t.indexOf(`
|
|
12
|
+
`)}let w=pe(t);if(e.block===void 0&&!e.awaitingSlug&&o===void 0&&!Jn(w))p+=l(w.slice(i)),i=w.length;return p},endStep(){let m=g();return a=`
|
|
13
|
+
|
|
14
|
+
`,e=tt(),m},end:g};function g(){let m=f(void 0),p=pe(t);if(p!==""){let y=c(p,void 0);if(y!==void 0)m+=l(y.slice(i))}return t="",i=0,o=void 0,m}}var To=`# 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 \`${ut}\` and close it with \`${ht}\` 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 is,realpath as yt,stat as rs}from"node:fs/promises";import{isAbsolute as os,resolve as we,sep as wt}from"node:path";import{basename as Ed,isAbsolute as Gt,resolve as zt}from"node:path";import{appendFile as Nt,mkdir as $i,readFile as Ni}from"node:fs/promises";import{join as It}from"node:path";import{appendFile as nn,mkdir as Ii,readFile as Oi,writeFile as Ri}from"node:fs/promises";import{join as xi}from"node:path";import{readFile as zi,writeFile as Vi}from"node:fs/promises";import{dirname as Ji}from"node:path";import{isDeepStrictEqual as Zi}from"node:util";import{existsSync as pn,readdirSync as oo,readFileSync as q,rmSync as Ct,writeFileSync as ie}from"node:fs";import{isAbsolute as lo,join as ce,resolve as uo}from"node:path";var Zn=`${se.slug}_`,Qn="0123456789abcdefghjkmnpqrstvwxyz",es=32;function fr(){let e=new Uint8Array(es);crypto.getRandomValues(e);let t="";for(let i of e)t+=Qn[i&31]??"0";return`${Zn}${t}`}async function hr(e){let t=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(e));return[...new Uint8Array(t)].map((i)=>i.toString(16).padStart(2,"0")).join("")}var Br=64,ts=new RegExp("[\\u0000-\\u001f\\u007f]");function ys(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(ts.test(e))return"A key label cannot contain control characters, including newlines and tabs.";return}function qr(e){let t=`${e.channel}:${e.peerId}`;return e.thread===void 0||e.thread===""?t:`${t}:${e.thread}`}var ns=/^[0-9a-hjkmnp-tv-z]{6}$/;function Vr(e,t){if(e===t)return!0;return e.startsWith(`${t}~`)&&ns.test(e.slice(t.length+1))}var ss=/~[0-9a-hjkmnp-tv-z]{6}$/;function Qs(e,t){let i=t.get(e);if(i!==void 0)return i===e;if(ss.test(e))return[...t.values()].includes(e);return!0}var io=3932160,vt=5;function Pt(e){let t=(a)=>e[a]??-1;if(t(0)===137&&t(1)===80&&t(2)===78&&t(3)===71)return"image/png";if(t(0)===255&&t(1)===216&&t(2)===255)return"image/jpeg";if(t(0)===71&&t(1)===73&&t(2)===70&&t(3)===56)return"image/gif";let i=t(0)===82&&t(1)===73&&t(2)===70&&t(3)===70,o=t(8)===87&&t(9)===69&&t(10)===66&&t(11)===80;if(i&&o)return"image/webp";return}var as=/^[A-Za-z0-9+/]+={0,2}$/;async function ms(e,t){if(t.length>vt)throw k("image_count_exceeded",`${t.length} images were sent with one message; at most ${vt} are.`,"Send the rest in a following message.");let i=[];for(let[o,a]of t.entries())i.push(await ds(e,a,`images[${o}]`));return i}async function ds(e,t,i){if(t.path!==void 0&&t.data!==void 0)throw k("image_source_ambiguous","An image named both a path and inline data.",'Send one: { "path": "files/…/shot.png" }, or { "data": "<base64>", "mediaType": "image/png" }.',i);if(t.path!==void 0)return await ls(e,t.path,i);if(t.data!==void 0)return cs(t.data,t.mediaType,i);throw k("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" }.`,i)}async function ls(e,t,i){if(t.trim()===""||os(t))throw k("image_path_invalid",`The image path "${t}" is not relative to the agent's directory.`,"Name the file relative to the agent's directory, e.g. files/<conversation>/shot.png.",i);let o=we(e,t),a=we(e);if(o!==a&&!o.startsWith(`${a}${wt}`))throw _t(t,i);let d,l;try{l=await yt(e),d=await yt(we(e,t))}catch{throw k("image_not_found",`No file at "${t}" in the agent's directory.`,"Save the image inside the agent's directory first, then name it relative to that directory.",i)}if(d!==l&&!d.startsWith(`${l}${wt}`))throw _t(t,i);let c=await rs(d);if(!c.isFile())throw k("image_not_found",`"${t}" is not a file.`,"Name an image file, not a directory.",i);if(c.size>io)throw Ft(t,c.size,i);let u=new Uint8Array(await is(d)),f=Pt(u);if(f===void 0)throw Wt(t,i);return{mediaType:f,data:Buffer.from(u).toString("base64"),ref:t}}function cs(e,t,i){let o=e.replace(/\s+/g,"");if(o===""||o.length%4!==0||!as.test(o))throw k("image_data_invalid","The image's data is not base64.",`Send the file's bytes base64-encoded, with no "data:" prefix.`,i);let{mediaType:a}=us(new Uint8Array(Buffer.from(o,"base64")),"upload",i);if(t!==void 0&&t!==a)throw k("image_media_type_mismatch",`The image was declared ${t} and its bytes are ${a}.`,"Leave mediaType out, or send the type the file really is.",i);return{mediaType:a,data:o,ref:"upload"}}function us(e,t,i="image"){if(e.length>io)throw Ft(t,e.length,i);let o=Pt(e);if(o===void 0)throw Wt(t,i);return{mediaType:o,data:Buffer.from(e).toString("base64"),ref:t}}function _t(e,t){return k("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.",t)}function Ft(e,t,i){return k("image_too_large",`"${e}" is ${t} bytes; an image may be at most ${io}.`,"Resize or compress it first.",i)}function Wt(e,t){return k("image_unsupported",`"${e}" is not a PNG, JPEG, GIF or WebP image.`,"Convert it to one of those formats first.",t)}var hs="session:";function Bt(e){return e.startsWith(hs)}var fs="scope:";function Ht(e){return e.startsWith(fs)}var Tt="0123456789abcdefghijklmnopqrstuvwxyz";function ps(e){let t=new Uint8Array(e);crypto.getRandomValues(t);let i="";for(let o of t)i+=Tt[o%Tt.length];return i}function Oe(e,t){return`${e}_${t.toString(36)}${ps(8)}`}function so(e=Date.now()){return Oe("t",e)}function Ss(e=Date.now()){return Oe("r",e)}function ws(e=Date.now()){return Oe("k",e)}var Et="phase_set",Kt="*",kt="tag:";function Ds(e){let t=Object.keys(e);return t.find((o)=>e[o]?.entry===!0)??t[0]}function At(e){return e.toLowerCase().replace(/[\s_.-]+/g,"")}function Xt(e,t){if(e===Kt)return!0;if(e.startsWith(kt)){let i=e.slice(kt.length).toLowerCase();return t.tags.some((o)=>o.toLowerCase()===i)}return At(e)===At(t.slug)}function gs(e,t){return e.filter((i)=>!t.some((o)=>Xt(i,o)))}function Es(e,t){let i=e[t];if(i===void 0)return[Kt];return i.allow.includes(Et)?i.allow:[...i.allow,Et]}function Wr(e){return e!==void 0&&Object.keys(e).length>1}function bs(e,t){return Object.keys(e).filter((i)=>Es(e,i).some((o)=>Xt(o,t)))}var iA=["user","agent"];function zr(e,t=""){let i="",o=0;for(;;){let a=e.indexOf("<!--",o);if(a===-1)break;let d=e.indexOf("-->",a+4);if(d===-1)break;i+=e.slice(o,a)+t,o=d+3}return i+e.slice(o)}function ao(e){let t=e.length;while(t>0&&e[t-1]==="/")t-=1;return e.slice(0,t)}var As=/^---\r?\n([\s\S]*?)\r?\n---[ \t]*(?:\r?\n|$)/,$s=/\n{3,}/g;function Is(e){let t=As.exec(e);return t===null||t===void 0?e:e.slice(t[0].length)}function xs(e){return zr(e).replace($s,`
|
|
36
|
+
|
|
37
|
+
`).trim()}var J={static:2000,volatile:3500,reminder:500,total:6000};function Cs(e){let t=e.files.filter((d)=>d.tier==="volatile");if(t.length===0)return;let i=(d)=>d.editable==="append"||d.editable==="replace",o=t.find((d)=>i(d)&&d.eviction==="oldest")??t.find(i);if(o!==void 0)return{path:o.path,name:o.name,mode:o.editable==="replace"?"replace":"append",budget:o.budget,eviction:o.eviction};let a=t[0];if(a===void 0)return;return{name:a.name,mode:"refused",reason:a.editable}}function Z(e){return e.names.map((t,i)=>({name:t,path:Gt(t)?t:zt(e.base,t),tier:e.tier,field:`${e.field}[${i}]`}))}function Os(e,t){let i=e.files??[],o=e.static??[];if(i.length>0&&o.length>0)throw Be();let a=Gt(e.workspace)?e.workspace:zt(t,e.workspace),d=[],l=[];if(i.length>0)d.push(...Z({base:t,names:i,tier:"static",field:"context.files"})),l.push({code:"context_files_deprecated",message:`context.files is deprecated; its ${i.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(d.push(...Z({base:a,names:o,tier:"static",field:"context.static"})),d.push(...Z({base:a,names:e.volatile??[],tier:"volatile",field:"context.volatile"})),e.reminder!==void 0)d.push(...Z({base:a,names:[e.reminder],tier:"reminder",field:"context.reminder"}));return{refs:d,warnings:l}}var T=n().min(1),Ws=r({delimiters:D(["xml","markdown","plain"]).optional(),intensity:D(["emphatic","neutral","soft"]).optional(),examplesIn:D(["system","user"]).optional(),skillsIn:D(["system","user"]).optional()}).strict(),Bs=r({nativeTools:_().optional(),strictSchema:_().optional(),thinking:D(["none","anthropic","openai","deepseek"]).optional(),promptCache:D(["none","anthropic","openai","bedrock"]).optional(),parallelToolCalls:_().optional(),contextWindow:s().int().positive().optional(),maxOutput:s().int().positive().optional(),vision:_().optional(),promptStyle:Ws.optional()}).strict(),St="chat-completions",Vt=r({id:n().min(1),api:n().min(1).optional(),options:x(n(),He()).optional(),baseUrl:n().min(1).optional(),apiKeyEnv:n().min(1).optional(),temperature:s().min(0).max(2).optional(),topP:s().min(0).max(1).optional(),maxTokens:s().int().positive().optional(),reasoningEffort:D(["none","minimal","low","medium","high","xhigh","max"]).optional(),headers:x(n(),n()).optional(),streamUsage:_().optional(),capabilities:Bs.optional()}).strict();function Zt(e,t){if((e.api??St)===St&&e.baseUrl===void 0)t.addIssue({code:"custom",path:["baseUrl"],message:"baseUrl is required for the chat-completions transport"})}var Hs=Vt.superRefine(Zt),Q=Vt.extend({fallbacks:E(Hs).min(1).optional()}).superRefine(Zt),Ks=r({main:Q,selector:Q.optional(),compactor:Q.optional()}).catchall(Q),Xs=r({snip:s().default(0.6),micro:s().default(0.7),collapse:s().default(0.8),reset:s().default(0.88),trim:s().default(0.95)}).strict(),qs=r({static:s().int().positive().default(J.static),volatile:s().int().positive().default(J.volatile),reminder:s().int().positive().default(J.reminder),total:s().int().positive().default(J.total)}).strict(),Ys=r({perRuleSuccess:s().gt(0).lte(1).default(0.9),reliabilityTarget:s().gt(0).lt(1).default(0.8),onExceed:D(["fail","warn"]).default("fail")}).strict(),zs=r({file:n().min(1),requires:r({contextWindow:n().min(1).optional(),class:D(["frontier","small"]).optional()}).strict().optional(),onUnmet:D(["distill","omit","fail"]).default("distill"),distilled:n().min(1).optional()}).strict(),Vs=r({dir:n().min(1),maxActive:s().int().nonnegative().default(2),budget:s().int().positive().default(600)}).strict(),Js=r({window:s().int().positive().optional(),reserveOutput:s().int().positive().default(4096),observationMaxTokens:s().int().positive().optional(),modelIdentity:D(["shown","hidden"]).default("shown"),files:E(n().min(1)).default([]),workspace:n().min(1).default("./workspace"),static:E(n().min(1)).default([]),volatile:E(n().min(1)).default([]),reminder:n().min(1).optional(),budgets:qs.prefault({}),rules:Ys.prefault({}),soul:zs.optional(),compactionNotice:_().optional(),thresholds:Xs.prefault({})}).strict(),Zs=r({max:s().int().positive().default(24),reserveWrite:s().int().nonnegative().default(6)}).strict(),si=r({onMutate:D(["refuse","confirm","allow"]).default("refuse")}).strict(),ii=r({mode:D(["ask","allow","deny"]).default("allow"),allow:E(n().min(1)).default([]),deny:E(n().min(1)).default([]),onNoApprover:D(["deny","allow"]).default("deny")}).strict(),ri=r({dialect:D(["nlt","native"]).default("nlt"),providers:x(T,x(n(),He())).default({}),provider:T.optional(),providerConfig:x(n(),He()).default({}),budget:Zs.prefault({}),pinned:E(n().min(1)).default([]),search:r({enabled:_().default(!1)}).strict().prefault({}),local:E(n().min(1)).default([]),untrusted:si.prefault({}),policy:ii.prefault({}),eventDetail:D(["none","redacted"]).default("none")}).strict(),oi=r({allow:E(n().min(1)),entry:_().optional()}).strict(),ai=r({dir:n().min(1).default("./skills"),maxActive:s().int().nonnegative().default(1),threshold:s().default(0.35),trusted:E(n().min(1)).optional()}).strict(),di=r({retriever:n().min(1).default("fts5"),dir:n().min(1).default("./memory"),maxActive:s().int().nonnegative().default(5),threshold:s().default(0.2),budget:s().int().positive().default(2000),includeHistory:_().default(!0),shared:_().default(!0)}).strict(),li=["owner","peer","channel-peer"],ci=r({scope:D(li).default("channel-peer")}).strict(),ui=r({type:T,id:T,allowFrom:E(n().min(1)).optional(),enabled:_().default(!0),role:T.optional()}).passthrough(),Qt=r({channel:T,to:n().min(1)}).strict(),hi=r({default:T.optional(),reply:D(["all","final"]).default("all"),targets:x(n(),Qt).default({})}).strict(),oe=js(()=>r({type:D(["string","number","integer","boolean","array","object"]),description:n().optional(),enum:E(pt([n(),s(),_()])).optional(),items:oe.optional(),properties:x(n(),oe).optional(),required:E(n()).optional()})),en=r({id:T,manifest:n().min(1),task:n().min(1),artifact:r({type:ft("object"),properties:x(n(),oe),required:E(n()).optional()}).strict()}).strict(),fi=r({members:E(en).min(1)}).strict(),mi=r({name:T,task:n().min(1),tools:E(n().min(1)).min(1),route:r({tools:E(n().min(1)).min(1)}).strict(),artifact:en.shape.artifact.optional(),model:n().min(1).optional(),maxSteps:s().int().positive().optional(),timeoutMs:s().int().positive().optional()}).strict(),be={provider:n().min(1),model:n().min(1).optional(),baseUrl:n().min(1).optional(),apiKeyEnv:n().min(1).optional(),options:x(n(),He()).optional()},pi=r({transcription:r({...be,timeoutMs:s().int().positive().default(60000),maxBytes:s().int().positive().default(26214400)}).strict().optional(),speech:r({...be,timeoutMs:s().int().positive().default(60000),maxCharacters:s().int().positive().default(3000)}).strict().optional(),image:r({...be,timeoutMs:s().int().positive().default(120000),size:n().regex(/^[0-9]+x[0-9]+$/).default("1024x1024")}).strict().optional()}).strict(),gi=r({enabled:_().default(!1),escalateAfterMs:s().int().nonnegative().default(0)}).strict(),yi=r({offer:r({task:n().min(1),artifact:r({type:ft("object"),properties:x(n(),oe),required:E(n()).optional()}).strict()}).strict().optional(),to:pt([ft("*"),E(T).min(1)]).optional(),ask:_().default(!1)}).strict(),tn=r({id:T,kind:D(["cron","every","at"]),expr:n().min(1),task:n().min(1),deliver:pt([ft("none"),Qt]),session:n().min(1).default("isolated"),role:T.optional(),tools:r({allow:E(n().min(1)).min(1)}).strict().optional(),timeoutMs:s().int().positive().optional(),maxSteps:s().int().positive().optional(),enabled:_().default(!0),timezone:n().min(1).optional()}).strict(),wi=pt([n().min(1),r({spec:n().min(1),config:x(n(),He()).default({})}).strict()]),bi=r({identicalCalls:s().int().min(2).default(3),sameTool:s().int().min(2).optional()}).strict(),vi=r({maxSteps:s().int().positive().default(40),noProgress:bi.prefault({}),turnTimeoutMs:s().int().positive().default(1800000),toolTimeoutMs:s().int().positive().default(120000),maxParallelTools:s().int().positive().default(4),maxConcurrentTurns:s().int().positive().optional(),reloadHoldMs:s().int().nonnegative().default(30000),maxHops:s().int().nonnegative().default(4),tokens:r({max:s().int().positive(),windowMs:s().int().positive()}).strict().optional()}).strict(),_i=r({enabled:_().default(!1),port:s().int().min(1).max(65535).default(7420),host:n().min(1).default("127.0.0.1"),tokenEnv:n().min(1).default(`${se.envPrefix}API_TOKEN`),allowedOrigins:E(n().min(1)).default([]),allowedHosts:E(n().min(1)).default([])}).strict(),Zr=r({apiVersion:n().min(1),id:T.refine((e)=>!e.startsWith("~"),{message:"An agent id may not start with `~`; that prefix is reserved for shared memory scopes."}),name:n().min(1).optional(),description:n().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:n().min(1).optional(),model:Ks,context:Js.prefault({}),tools:ri.prefault({}),phases:x(n(),oi).optional(),skills:ai.optional(),knowledge:Vs.optional(),memory:di.optional(),sessions:ci.optional(),channels:E(ui).default([]),delivery:hi.optional(),schedules:E(tn).default([]),team:fi.optional(),subagents:E(mi).optional(),media:pi.optional(),standIn:gi.optional(),delegation:yi.optional(),plugins:E(wi).default([]),limits:vi.prefault({}),server:_i.prefault({})}).strict(),B=["main","selector","compactor"];function Ti(e){return B.includes(e)}function ae(e){return Object.keys(e).filter((t)=>!Ti(t))}var Ei={nativeTools:!1,strictSchema:!1,thinking:"none",promptCache:"none",parallelToolCalls:!1,contextWindow:8192,maxOutput:4096},ve={nativeTools:!0,strictSchema:!1,thinking:"none",promptCache:"none",parallelToolCalls:!1,maxOutput:5000},_e={vision:!0,nativeTools:!0,strictSchema:!1,thinking:"anthropic",promptCache:"none",parallelToolCalls:!0},Te="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`).",Ad=[{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:{..._e,contextWindow:1e6,maxOutput:128000},note:Te})),{pattern:"claude-haiku-*",family:!0,capabilities:{..._e,contextWindow:200000,maxOutput:64000},note:Te},{pattern:"claude-*",family:!0,capabilities:{..._e,contextWindow:200000,maxOutput:8192},note:Te},{pattern:"nova-micro*",capabilities:{...ve,contextWindow:128000}},{pattern:"nova-lite*",capabilities:{...ve,contextWindow:300000,vision:!0}},{pattern:"nova-pro*",capabilities:{...ve,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:Ei}];var Ns={attempts:3,baseDelayMs:400,maxDelayMs:8000};var $t=/^(?:timeout\s+\S+|time|nice(?:\s+-n\s+\S+)?|stdbuf(?:\s+-\S+)*|command|builtin)\s+/i;function ki(e){let t=e.trim();for(let i=0;i<4&&$t.test(t);i+=1)t=t.replace($t,"").trim();return t}var Si=/&&|\|\||;|\||&|\n/;function Ms(e){return e.split(Si).map((t)=>ki(t)).filter((t)=>t!=="")}var Li=/^(?:[-*+]|\d+[.)])[ \t]+\S/,Mi=/\*\*(\d{4})-(\d{2})-\d{2}T/;function Se(e){let t=[],i=-1,o=(a)=>{if(i===-1)return;t.push({start:i,end:a,text:e.slice(i,a).join(`
|
|
38
|
+
`).trimEnd()}),i=-1};for(let a=0;a<e.length;a+=1){let d=e[a]??"";if(Li.test(d)){o(a),i=a;continue}if(i===-1)continue;if(d.trim()===""||/^[ \t]/.test(d))continue;o(a)}return o(e.length),t}function $e(e){return ot(xs(Is(e)))}function Di(e,t){let i=Mi.exec(e);if(i!==null)return`${i[1]}-${i[2]}.md`;let o=t.getUTCFullYear(),a=`${t.getUTCMonth()+1}`.padStart(2,"0");return`${o}-${a}.md`}function Ci(e,t){let i=e.split(/\r?\n/),o=Se(i),a=[],d=o,l=e,c=$e(l);while(c>t&&d.length>1){let u=d[0];if(u===void 0)break;a.push(u),d=d.slice(1),l=Ui(i,a),c=$e(l)}if(c<=t)return{evict:a,remaining:l,tokens:c};return{evict:a,remaining:l,tokens:c,shortfall:d.length<=1?`${c} tokens remain against a ${t}-token budget with one note left, so eviction cannot help`:`${c} tokens remain against a ${t}-token budget`}}function Ui(e,t){let i=new Set;for(let o of t)for(let a=o.start;a<o.end;a+=1)i.add(a);return e.filter((o,a)=>!i.has(a)).join(`
|
|
39
|
+
`).replace(/\n{3,}/g,`
|
|
40
|
+
|
|
41
|
+
`)}async function Pi(e){let t=e.tags.length===0?"":` _(${e.tags.join(", ")})_`,i=`
|
|
42
|
+
- **${e.now.toISOString()}**${t} ${e.text}
|
|
43
|
+
`;return await nn(e.path,i,"utf8"),await sn(e)}async function sn(e){let t=await Oi(e.path,"utf8"),i=Ci(t,e.budget);if(i.evict.length===0)return{file:e.name,evicted:0,archives:[],...i.shortfall===void 0?{}:{shortfall:i.shortfall}};let o=new Map;for(let a of i.evict){let d=Di(a.text,e.now);o.set(d,[...o.get(d)??[],a.text])}await Ii(e.archiveDir,{recursive:!0});for(let[a,d]of o)await nn(xi(e.archiveDir,a),`${d.join(`
|
|
44
|
+
`)}
|
|
45
|
+
`,"utf8");return await Ri(e.path,i.remaining,"utf8"),{file:e.name,evicted:i.evict.length,archives:[...o.keys()].sort(),...i.shortfall===void 0?{}:{shortfall:i.shortfall}}}var le="local",Rt="memory",xt="notes.md",Fi={spec:{slug:"now",provider:le,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 i=t.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(i)} (${o})`;if(o==="UTC")return i.toISOString();return`${ji(i,o)} (${o})`}};function ji(e,t){let i=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),o=(d)=>i.find((l)=>l.type===d)?.value??"",a=o("timeZoneName").replace("GMT","");return`${o("year")}-${o("month")}-${o("day")}T${o("hour")}:${o("minute")}:${o("second")}${a===""?"Z":a}`}var Wi={spec:{slug:"memory_write",provider:le,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 i=typeof e.text==="string"?e.text.trim():"",o=Array.isArray(e.tags)?e.tags.map((u)=>String(u)):[],a=t.now().toISOString(),d=o.length===0?"":` _(${o.join(", ")})_`,l=`
|
|
46
|
+
- **${a}**${d} ${i}
|
|
47
|
+
`;if(t.writeNote!==void 0)return await t.writeNote(o.length===0?i:`${i} (${o.join(", ")})`);let c=await Bi(i,o,l,t);if(t.shareNote===void 0)return c;return`${c} ${await t.shareNote(o.length===0?i:`${i} (${o.join(", ")})`)}`}};async function Bi(e,t,i,o){let a=o.writeTarget;if(a?.mode==="refused")throw Ke(a.name,a.reason??"none");if(a?.path!==void 0){if(a.budget!==void 0&&o.memoryDir!==void 0&&a.eviction==="oldest"){let l=await Pi({path:a.path,name:a.name,budget:a.budget,archiveDir:o.memoryDir,text:e,tags:t,now:o.now()});if(l.shortfall!==void 0)return`Saved to ${l.file}, but it is still over budget: ${l.shortfall}. Ask the person to raise the budget or shorten the file — the agent will not load until they do.`;if(l.evicted===0)return`Saved to ${l.file}.`;return`Saved to ${l.file}. Moved ${l.evicted} older ${l.evicted===1?"note":"notes"} into ${l.archives.join(", ")}, still searchable.`}if(await Nt(a.path,i,"utf8"),a.budget!==void 0){let l=$e(await Ni(a.path,"utf8"))-a.budget;if(l>0)return`Saved to ${a.name}, which is now ${l} tokens over its ${a.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 ${a.name}.`}let d=It(o.dir,Rt);return await $i(d,{recursive:!0}),await Nt(It(d,xt),i,"utf8"),`Saved to ${Rt}/${xt}.`}var Hi=1200,Ki=Hi*3,Xi={spec:{slug:"artifact_read",provider:le,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 i=typeof e.id==="string"?e.id.trim():"",o=typeof e.from==="number"&&e.from>0?Math.floor(e.from):0;if(t.readArtifact===void 0)throw qe();let a=await t.readArtifact(i);if(a===void 0)throw Ye(i);let d=a.slug===void 0?"observation":`${a.slug} observation`,l=a.content.slice(o,o+Ki),c=o+l.length,u=`Compacted ${d}, ${a.tokens} tokens${o===0?"":`, from character ${o}`}:`;if(c>=a.content.length)return`${u}
|
|
48
|
+
${l}`;return`${u}
|
|
49
|
+
${l}
|
|
50
|
+
|
|
51
|
+
[cut here — ${a.content.length-c} characters remain; continue with artifact_read(id, from: ${c})]`},trustOf:(e)=>rt(typeof e.id==="string"?e.id.trim():"")};var Gi=30,qi={spec:{slug:"memory_forget",provider:le,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,t){let i=typeof e.query==="string"?e.query.trim():"",o=Array.isArray(e.ids)?e.ids.map((u)=>String(u).trim()).filter((u)=>u!==""):[];if(i===""===(o.length===0))throw Xe();if(t.forgetMemory===void 0)throw Ge();let a=(u)=>u==="space"?"the team's shared memory":"your notes";if(i!==""){let u=await t.forgetMemory({query:i});if(u.notes.length===0)return`No note in ${a(u.scope)} contains "${i}".`;let f=u.notes.slice(0,Gi),g=u.notes.length>f.length?`
|
|
52
|
+
${u.notes.length-f.length} more match; use more words to narrow it down.`:"";return[`${u.notes.length} ${u.notes.length===1?"note":"notes"} in ${a(u.scope)} ${u.notes.length===1?"matches":"match"}. Nothing is deleted yet: show these to the person, then call memory_forget with the ids they confirm.`,...f.map((m)=>`- ${m.id} (${m.source}): ${m.text}`)].join(`
|
|
53
|
+
`)+g}let d=await t.forgetMemory({ids:o}),l=d.notes.length===0?`Nothing was deleted from ${a(d.scope)}.`:`Deleted ${d.notes.length} ${d.notes.length===1?"note":"notes"} from ${a(d.scope)}; they will not be recalled again.`,c=d.missing.length===0?"":` No note has ${d.missing.length===1?"the id":"the ids"} ${d.missing.join(", ")}: already gone, or not yours to delete here.`;return l+c}},Yi=[Fi,Wi,qi,Xi],Od=Yi.map((e)=>e.spec.slug);class qt extends te{static ERROR_NAME="MediaError"}function Ee(e,t,i,o){let a=i.get(t.provider);if(a===void 0)throw new h({code:"media_provider_unknown",message:`${e}.provider is "${t.provider}", and no media provider by that name is registered. Registered: ${[...i.keys()].sort().join(", ")}.`,hint:t.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 d=t.options;if(a.optionsSchema!==void 0&&t.options!==void 0){let f=a.optionsSchema.safeParse(t.options);if(!f.success)throw new h({code:"media_provider_options_invalid",message:`${e}.options are not valid for the ${t.provider} provider: ${f.error.issues?.[0]?.message??"invalid"}.`,hint:`See the ${t.provider} media provider's documentation for the fields it takes.`,field:`${e}.options`});d=f.data}let l=a.create({field:e,config:t,options:d,env:o.env,...o.fetch===void 0?{}:{fetch:o.fetch}}),[c,u]=e==="media.transcription"?[l.transcribe,"transcribe audio"]:e==="media.speech"?[l.synthesize,"speak text"]:[l.generateImage,"generate images"];if(c===void 0)throw new h({code:"media_provider_incapable",message:`The ${t.provider} media provider does not ${u}.`,hint:"Name a provider that does in this section; the two sections may name different providers.",field:`${e}.provider`});return l}var Qi={"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 er(e){return Qi[e.split(";")[0]?.trim().toLowerCase()??""]??"ogg"}async function ee(e,t,i){let o=(await e.text().catch(()=>"")).slice(0,300);return new qt({code:"media_provider_refused",message:`${t} was refused (${e.status}): ${o}`,hint:e.status===401||e.status===403?`Check the key in the env var ${i}.apiKeyEnv names, and that it may use this model.`:"The provider's own words are above.",field:i})}var tr={create(e){let{config:t,field:i}=e,o=ao(t.baseUrl??"https://api.openai.com/v1"),a=t.apiKeyEnv??"OPENAI_API_KEY",d=e.env[a];if(d===void 0||d==="")throw new h({code:"media_key_missing",message:`${i} needs ${a}, which is not set.`,hint:`Put the endpoint's key in ${a}, in the environment or the .env beside the manifest, or name another variable with ${i}.apiKeyEnv.`,field:`${i}.apiKeyEnv`});let l=e.fetch??((u,f)=>fetch(u,f)),c=`Bearer ${d}`;return{async transcribe(u,f){let g=new FormData;g.set("file",new Blob([u.bytes],{type:u.mimeType}),`voice.${er(u.mimeType)}`),g.set("model",t.model??"whisper-1");let m=await l(`${o}/audio/transcriptions`,{method:"POST",headers:{authorization:c},body:g,signal:f});if(!m.ok)throw await ee(m,"The transcription",i);let p=await m.json();return{text:typeof p.text==="string"?p.text:"",...typeof p.duration==="number"?{durationS:p.duration}:{}}},async synthesize(u,f){let g=t.options??{},m=await l(`${o}/audio/speech`,{method:"POST",headers:{authorization:c,"content-type":"application/json"},body:JSON.stringify({model:t.model??"gpt-4o-mini-tts",voice:typeof g.voice==="string"?g.voice:"alloy",input:u.text,response_format:"opus"}),signal:f});if(!m.ok)throw await ee(m,"The speech request",i);return{bytes:new Uint8Array(await m.arrayBuffer()),mimeType:"audio/ogg; codecs=opus",characters:u.text.length}},async generateImage(u,f){let g=await l(`${o}/images/generations`,{method:"POST",headers:{authorization:c,"content-type":"application/json"},body:JSON.stringify({model:t.model??"gpt-image-1",prompt:u.prompt,size:u.size,n:1}),signal:f});if(!g.ok)throw await ee(g,"The image request",i);let p=(await g.json()).data?.[0];if(p?.b64_json!==void 0)return{bytes:Buffer.from(p.b64_json,"base64"),mimeType:"image/png"};if(p?.url!==void 0){let y=await l(p.url,{signal:f});if(!y.ok)throw await ee(y,"Downloading the image",i);return{bytes:new Uint8Array(await y.arrayBuffer()),mimeType:y.headers.get("content-type")??"image/png"}}throw new qt({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:i})}}}},nr=new Map([["openai",tr]]);function sr(e,t){let i=new Map([...nr,...t.providers??[]]),o=e.media?.transcription,a=e.media?.image,d=e.media?.speech;return{...d===void 0?{}:{speech:{config:d,provider:Ee("media.speech",d,i,t)}},...o===void 0?{}:{transcription:{config:o,provider:Ee("media.transcription",o,i,t)}},...a===void 0?{}:{image:{config:a,provider:Ee("media.image",a,i,t)}}}}function rn(e){let t=e.providers??{},i=Object.keys(t),o=e.provider,a=e.providerConfig??{};if(i.length>0&&(o!==void 0||Object.keys(a).length>0))throw We(i,o);if(o!==void 0)return{selections:[{id:o,config:a,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 d=i.map((l)=>({id:l,config:t[l]??{},legacy:!1}));if(Object.keys(a).length>0)return{selections:d,warnings:[{code:"tools_provider_config_orphaned",message:`tools.providerConfig has ${Object.keys(a).length} setting(s) and no tools.provider names a provider to apply them to, so they do nothing.`,hint:"Move them into the matching tools.providers.<id> block and delete tools.providerConfig. Reported rather than ignored: a configuration that looks applied and is not is worse than one that fails.",field:"tools.providerConfig"}]};return{selections:d,warnings:[]}}var Lt=new Map;function on(e){let t=Lt.get(e);if(t!==void 0)return t;let i;try{i=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 h({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 Lt.set(e,i),i}function ir(e){on(e)}function de(e,t){let i=on(e).formatToParts(new Date(t)),o=(c)=>{let u=i.find((f)=>f.type===c);return u===void 0?0:Number(u.value)},a=o("year"),d=o("month"),l=o("day");return{year:a,month:d,day:l,hour:o("hour"),minute:o("minute"),second:o("second"),weekday:new Date(Date.UTC(a,d-1,l)).getUTCDay()}}function rr(e,t){return de(e,t)}function Mt(e,t){let i=de(e,t);return Date.UTC(i.year,i.month-1,i.day,i.hour,i.minute,i.second)-(t-t%1000)}function or(e,t){let i=Date.UTC(t.year,t.month-1,t.day,t.hour,t.minute,t.second),o=i-Mt(e,i);o=i-Mt(e,o);let a=de(e,o);if(!(a.year===t.year&&a.month===t.month&&a.day===t.day&&a.hour===t.hour&&a.minute===t.minute&&a.second===t.second))return;let l=o-3600000,c=de(e,l);return c.year===t.year&&c.month===t.month&&c.day===t.day&&c.hour===t.hour&&c.minute===t.minute&&c.second===t.second?l:o}function ar(){return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}var lr=1462,an=["jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"],cr=["sun","mon","tue","wed","thu","fri","sat"],F={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:an,label:"month"},dayOfWeek:{min:0,max:7,names:cr,label:"day of week"}};function M(e,t,i,o){throw new h({code:"schedule_cron_malformed",message:`"${e}" is not a valid cron expression: ${t}`,hint:i,field:o})}function ke(e,t,i,o){let a=t.names?.indexOf(e.toLowerCase());if(a!==void 0&&a!==-1)return a+(t.names===an?1:0);if(!/^\d+$/.test(e))M(i,`"${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(", ")}…).`,o);let d=Number(e);if(d<t.min||d>t.max)M(i,`${d} is outside the ${t.label} range ${t.min}-${t.max}.`,`Check the field order: ${t.label==="second"?"second minute hour day-of-month month day-of-week":"minute hour day-of-month month day-of-week"}.`,o);return d}function j(e,t,i,o){let a=new Set,d=!0;for(let l of e.split(",")){let c=l.trim();if(c==="")M(i,"an empty entry in a comma list.","Remove the stray comma.",o);let[u="",f]=c.split("/",2),g=f===void 0?1:Number(f);if(f!==void 0&&(!/^\d+$/.test(f)||g<1))M(i,`"${f}" is not a step.`,"A step is a whole number above zero, as in */15.",o);let m,p;if(u==="*"){if(m=t.min,p=t.max,g===1)d=!1}else if(u.includes("-")){let[y="",w=""]=u.split("-",2);if(m=ke(y,t,i,o),p=ke(w,t,i,o),m>p)M(i,`the range ${u} runs backwards.`,"Write the lower bound first, or use a comma list to wrap around.",o)}else m=ke(u,t,i,o),p=f===void 0?m:t.max;for(let y=m;y<=p;y+=g)a.add(y)}if(a.size===0)M(i,"it matches nothing.","Every field must admit at least one value.",o);return{values:a,restricted:d}}function mr(e,t){let i=e.trim();if(i.startsWith("@"))M(i,"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 o=i.split(/\s+/).filter((O)=>O!=="");if(o.length!==5&&o.length!==6)M(i,`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.",t);let a=o.length===6,[d,l,c,u,f,g]=a?o:["0",...o],m=j(d??"0",F.second,i,t),p=j(l??"",F.minute,i,t),y=j(c??"",F.hour,i,t),w=j(u??"",F.dayOfMonth,i,t),b=j(f??"",F.month,i,t),v=j(g??"",F.dayOfWeek,i,t),N=new Set;for(let O of v.values)N.add(O===7?0:O);return{seconds:m.values,minutes:p.values,hours:y.values,daysOfMonth:w.values,months:b.values,daysOfWeek:N,domRestricted:w.restricted,dowRestricted:v.restricted,source:i}}function gr(e,t,i){let o=e.daysOfMonth.has(t),a=e.daysOfWeek.has(i);if(e.domRestricted&&e.dowRestricted)return o||a;if(e.domRestricted)return o;if(e.dowRestricted)return a;return!0}function Dt(e,t,i,o){let a=new Date(Date.UTC(e,t-1,i+o));return[a.getUTCFullYear(),a.getUTCMonth()+1,a.getUTCDate()]}function wr(e,t,i){return new Date(Date.UTC(e,t-1,i)).getUTCDay()}function PA(e,t,i){let o=rr(i,t+1000),a=new Date(Date.UTC(o.year,o.month-1,o.day+lr)),[d,l,c]=[o.year,o.month,o.day],u=!0;while(Date.UTC(d,l-1,c)<=a.getTime()){if(!e.months.has(l)){[d,l,c]=l===12?[d+1,1,1]:[d,l+1,1],u=!1;continue}if(!gr(e,c,wr(d,l,c))){[d,l,c]=Dt(d,l,c,1),u=!1;continue}for(let f of[...e.hours].sort((g,m)=>g-m)){if(u&&f<o.hour)continue;for(let g of[...e.minutes].sort((m,p)=>m-p)){if(u&&f===o.hour&&g<o.minute)continue;for(let m of[...e.seconds].sort((p,y)=>p-y)){if(u&&f===o.hour&&g===o.minute&&m<o.second)continue;let p=or(i,{year:d,month:l,day:c,hour:f,minute:g,second:m});if(p!==void 0)return p}}}[d,l,c]=Dt(d,l,c,1),u=!1}return}var br=/^(\d+)(s|m|h|d)$/,vr={s:1000,m:60000,h:3600000,d:86400000},_r=1000,Tr=315360000000;function kr(e,t){let i=br.exec(e.trim());if(i===null)throw new h({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 o=Number(i[1]),a=i[2]??"",d=o*(vr[a]??0);if(d<_r)throw new h({code:"schedule_duration_too_small",message:`"${e}" is under the one-second minimum.`,hint:"An interval below a second is a busy loop rather than a schedule. If the intent is to run continuously, a schedule is the wrong mechanism.",field:t});if(d>Tr)throw new h({code:"schedule_duration_too_large",message:`"${e}" is over the ten-year maximum.`,hint:"An interval this long is almost always a unit typo — check whether d was meant where h was written.",field:t});return{ms:d,source:e.trim()}}var Ar=315360000000,Sr=900000,Ae=1000;function yr(e){let t=e.timezone??ar();ir(t);let i=e.expr.trim();if(e.kind==="cron"){let a=mr(i,e.field);if(PA(a,e.now,t)===void 0)throw new h({code:"schedule_cron_unsatisfiable",message:`"${i}" 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:a,zone:t,source:i}}if(e.kind==="every")return{kind:"every",every:kr(i,e.field),zone:t,source:i};let o=Date.parse(i);if(Number.isNaN(o))throw new h({code:"schedule_at_malformed",message:`"${i}" 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+Ar)throw new h({code:"schedule_at_too_far",message:`${i} 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:t,source:i}}function Nr(e){let t=2166136261;for(let i=0;i<e.length;i+=1)t^=e.charCodeAt(i),t=Math.imul(t,16777619)>>>0;return t}function $r(e,t){if(t===void 0||t<=0)return 0;let i=Math.min(Math.floor(t/10),Sr);return i<=0?0:Nr(e)%i}function Or(e,t){if(e.kind==="every")return e.every.ms;if(e.kind==="at")return;let i=PA(e.spec,t,e.zone);if(i===void 0)return;let o=PA(e.spec,i,e.zone);return o===void 0?void 0:o-i}function Rr(e,t,i,o,a={}){if(e.kind==="at"){if(a.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 d=$r(t,Or(e,i));if(e.kind==="every"){let f=o-i,g=f<=0?0:Math.floor(f/e.every.ms),m=Math.min(g,Ae),p=g+1,y=i+p*e.every.ms;return{runAt:y+d,anchor:y,missed:m,missedCapped:g>Ae,late:!1}}let l=i,c=0,u=!1;for(;;){let f=PA(e.spec,l,e.zone);if(f===void 0)return{runAt:void 0,anchor:void 0,missed:c,missedCapped:u,late:!1};if(f+d>o)return{runAt:f+d,anchor:f,missed:c,missedCapped:u,late:!1};if(l=f,c+=1,c>=Ae){u=!0;let g=PA(e.spec,o,e.zone);return{runAt:g===void 0?void 0:g+d,anchor:g,missed:c,missedCapped:!0,late:!1}}}}function xr(e,t,i){let o=[],a=Array.isArray(e.schedules)?e.schedules:[],d=new Set((Array.isArray(e.channels)?e.channels:[]).map((f)=>f!==null&&typeof f==="object"&&!Array.isArray(f)?f.id:void 0).filter((f)=>typeof f==="string")),l=new Set([...B,...ae(t.model)]),c=new Set,u=new Set;for(let[f,g]of a.entries()){if(g===null||typeof g!=="object"||Array.isArray(g))continue;let m=g,p=typeof m.id==="string"?m.id:`[${f}]`;if(u.has(p))o.push({code:"schedule_id_duplicate",message:`Two schedules share the id "${p}".`,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[${f}].id`});u.add(p);let y=m.deliver;if(y===void 0)o.push({code:"schedule_missing_delivery",message:`Schedule "${p}" has no delivery target.`,hint:'Set deliver to { channel, to }, or the literal "none" to return results only via the event stream.',field:`schedules[${f}].deliver`});else if(y!=="none"&&typeof y==="object"&&!Array.isArray(y)){let v=y.channel;if(typeof v==="string"&&!d.has(v))o.push({code:"schedule_delivery_channel_unknown",message:`Schedule "${p}" delivers to "${v}", which is not a channel id on this agent.${d.size===0?" The agent declares no channels.":` Declared: ${[...d].join(", ")}.`}`,hint:`A delivery target names a channel's id, not its type. Use deliver: "none" to return results through the event stream instead.`,field:`schedules[${f}].deliver.channel`})}let w=m.role;if(typeof w==="string"){if(c.add(w),!l.has(w))o.push({code:"schedule_role_unknown",message:`Schedule "${p}" names the model role "${w}", which is not declared under model:. Declared: ${[...l].join(", ")}.`,hint:"Add the role under model:, or point the schedule at one of the declared roles. Omit role entirely to use main.",field:`schedules[${f}].role`})}let b=t.schedules[f];if(b!==void 0)try{yr({id:b.id,kind:b.kind,expr:b.expr,timezone:b.timezone,now:i,field:`schedules[${f}].expr`})}catch(v){if(!(v instanceof te))throw v;o.push(v.toDetail())}}for(let f of t.subagents??[])c.add(f.model??"subagent");for(let f of ae(t.model)){if(c.has(f))continue;if(Yt(f,B)===void 0)continue;o.push({code:"model_role_unreferenced",message:`model.${f} is declared but no schedule names it, so nothing will ever use it.`,hint:`If "${f}" was meant to be one of ${B.join(", ")}, it is misspelled — and the misspelled one is silently falling back to main. Otherwise point a schedule at it with role: ${f}, or remove it.`,field:`model.${f}`})}return o}function Lr(e){let t=[],i=new Set([...e.tools.pinned,...e.tools.local]),o=new Set([...B,...ae(e.model)]),a=new Set,d=new Map;for(let[l,c]of(e.subagents??[]).entries()){let u=`subagents[${l}]`;if(a.has(c.name))t.push({code:"subagent_name_duplicate",message:`Two subagents are called "${c.name}".`,hint:"Give each subagent its own name: it is how events, sessions and usage rows say which child ran.",field:`${u}.name`});a.add(c.name);let f=c.tools.filter((g)=>!i.has(g));if(f.length>0)t.push({code:"subagent_tool_not_pinned",message:`Subagent "${c.name}" lists ${f.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:`${u}.tools`});for(let g of c.route.tools){if(!c.tools.includes(g))t.push({code:"subagent_route_outside_tools",message:`Subagent "${c.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[${l}].tools.`,field:`${u}.route.tools`});let m=d.get(g);if(m!==void 0&&m!==c.name)t.push({code:"subagent_route_duplicate",message:`${g} is routed to both "${m}" and "${c.name}".`,hint:"A routed call runs exactly one child. Route the slug from one subagent only.",field:`${u}.route.tools`});d.set(g,c.name)}if(c.model!==void 0&&!o.has(c.model))t.push({code:"subagent_role_unknown",message:`Subagent "${c.name}" names the model role "${c.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:`${u}.model`})}return t}function Mr(e){let t=new Set([...B,...ae(e.model)]);return(e.channels??[]).flatMap((i,o)=>i.role===void 0||t.has(i.role)?[]:[{code:"channel_role_unknown",message:`Channel "${i.id}" names the model role "${i.role}", which is not declared under model:. Declared: ${[...t].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 dn(e){if(typeof e!=="string")return String(e);let t=/^[A-Za-z0-9_./@~-]+$/.test(e),i=/^[A-Za-z0-9_./]/.test(e);if(!t||!i)return JSON.stringify(e);try{return ge(e)===e?e:JSON.stringify(e)}catch{return JSON.stringify(e)}}function Y(e){return e.length-e.trimStart().length}function Re(e){let t=e.trim();return t===""||t.startsWith("#")}function Le(e,t,i,o){let a=new RegExp(`^\\s{${i}}${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*:`);for(let d=o;d<e.length;d+=1){let l=e[d]??"";if(Re(l))continue;if(Y(l)<i)return;if(Y(l)===i&&a.test(l))return d}return}function ne(e,t,i){let o=t;for(let a=t+1;a<e.length;a+=1){let d=e[a]??"";if(Re(d))continue;if(Y(d)<=i)break;o=a}return o}function Dr(e){let t;for(let i=0;i<e.length;i+=1){let o=e[i];if(t!==void 0){if(o===t)t=void 0;continue}if(o==='"'||o==="'"){t=o;continue}if(o!=="#"||i===0||!/\s/.test(e[i-1]??""))continue;let a=i;while(a>0&&/\s/.test(e[a-1]??""))a-=1;return e.slice(a)}return""}function Me(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function H(e,t,i){let o=" ".repeat(i);if(Array.isArray(t)){if(t.length===0)return[`${o}${e}: []`];return[`${o}${e}:`,...t.flatMap((a)=>Ur(a,i+2))]}if(Me(t)){let a=Object.entries(t);if(a.length===0)return[`${o}${e}: {}`];return[`${o}${e}:`,...a.flatMap(([d,l])=>H(d,l,i+2))]}return[`${o}${e}: ${dn(t)}`]}function Ur(e,t){let i=" ".repeat(t);if(!Me(e))return[`${i}- ${dn(e)}`];let o=Object.entries(e);if(o.length===0)return[`${i}- {}`];let a=o.flatMap(([c,u])=>H(c,u,t+2)),[d,...l]=a;return[`${i}- ${(d??"").trimStart()}`,...l]}function ln(e,t){let i=0,o=0,a,d=0;for(;d<t.length-1;d+=1){let l=Le(e,t[d]??"",o,i);if(l===void 0)break;a=l,i=l+1;let c=e.slice(l+1).find((u)=>!Re(u)&&Y(u)>o);if(c===void 0)return;o=Y(c)}return{searchFrom:i,indent:o,parent:a,depth:d}}function cn(e,t){if(t.length===0)return;let i=e.split(`
|
|
58
|
+
`),o=ln(i,t);if(o===void 0)return;if(o.depth<t.length-1)return e;let a=Le(i,t[t.length-1]??"",o.indent,o.searchFrom);if(a===void 0)return e;let d=ne(i,a,o.indent),l=[...i.slice(0,a),...i.slice(d+1)].join(`
|
|
59
|
+
`),c=t.slice(0,-1);if(c.length>0&&z(l).getIn([...c])==null)return cn(l,c)??l;return l}function Pr(e,t,i){if(t.length===0)return;let o=e.split(`
|
|
60
|
+
`),a=ln(o,t);if(a===void 0)return;let{searchFrom:d,indent:l,parent:c,depth:u}=a;if(u<t.length-1){if(c===void 0)return;let p=ne(o,c,l-1)+1;return[...o.slice(0,p),...hn(t.slice(u),i,l),...o.slice(p)].join(`
|
|
61
|
+
`)}let f=t[t.length-1]??"",g=Le(o,f,l,d);if(g!==void 0){let p=o[g]??"",y=Array.isArray(i)||Me(i)?"":Dr(p),w=ne(o,g,l),b=H(f,i,l);if(y!=="")b[0]=`${b[0]}${y}`;return[...o.slice(0,g),...b,...o.slice(w+1)].join(`
|
|
62
|
+
`)}if(c===void 0)return;let m=ne(o,c,l-1)+1;return[...o.slice(0,m),...H(f,i,l),...o.slice(m)].join(`
|
|
63
|
+
`)}function hn(e,t,i){let[o,...a]=e;if(o===void 0)return[];if(a.length===0)return H(o,t,i);return[`${" ".repeat(i)}${o}:`,...hn(a,t,i+Fr)]}var Fr=2;function jr(e,t,i){let o=e.split(`
|
|
64
|
+
`),a=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),d=new RegExp(`^#\\s*${a}\\s*:`),l=o.findIndex((f)=>d.test(f));if(l===-1)return;let c=l;while(/^#\s{2,}\S/.test(o[c+1]??""))c+=1;let u=/^#\s*Phase \d/.test(o[l-1]??"")?l-1:l;return[...o.slice(0,u),...H(t,i,0),...o.slice(c+1)].join(`
|
|
65
|
+
`)}function Hr(e,t){let i=[...t.path],o=i.join("."),a=De(z(e),i),d=t.remove===!0?cn(e,i):Pr(e,i,t.value)??t.fallback?.(e)??(i.length===1?jr(e,i[0]??"",t.value):void 0),l;if(d===void 0){let m=z(e);if(t.remove===!0)m.deleteIn(i);else m.setIn(i,t.value);l=String(m)}else l=d;let c=z(l);if(c.errors.length>0)throw W(o,`the result is not valid YAML — ${c.errors[0]?.message??"unparseable"}`);let u=Zr.safeParse(c.toJS());if(!u.success){let m=u.error.issues[0];throw W(o,`${m?.path.join(".")??o}: ${m?.message??"does not fit the schema"}`)}let g=xr(c.toJS(),u.data,Date.now())[0]??Mr(u.data)[0]??Lr(u.data)[0];if(g!==void 0)throw W(o,`${g.message} ${g.hint}`);try{rn(u.data.tools)}catch(m){throw W(o,m instanceof Error?m.message:"the providers block does not resolve")}return{next:l,before:a,reflowed:d===void 0,manifest:u.data}}async function Ts(e){let{edits:t}=await Xr(e.file,[e]);return t[0]}async function Xr(e,t){let i;try{i=await zi(e,"utf8")}catch(d){throw Gr(e,d)}let o=Kr(i,e,t),a=o.next!==i;if(a)await Vi(e,o.next,"utf8");return{edits:o.edits,written:a}}function Kr(e,t,i){let o=e,a=[];for(let d of i){let l={...d,file:t},c=Hr(o,l),u=!Zi(c.before,De(z(c.next),l.path));if(u)Yr(l,c.manifest),Jr(l,c.manifest),o=c.next;a.push({before:c.before,after:l.remove===!0?void 0:l.value,reflowed:u&&c.reflowed,manifest:c.manifest,changed:u})}return{next:o,edits:a}}function go(e){let t=e.trim();if(t==="")return"";let i=z(t);if(i.errors.length>0)throw new te({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 i.toJS()}function ei(e,t){return De(z(e),t)}function Rs(e){return z(e).toJS()}function De(e,t){let i=e.getIn([...t],!1);if(i===void 0||i===null)return;return bt(i)||Ot(i)?i.toJS(e):i}function Gr(e,t){return new te({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 Yr(e,t){let i=e.providers;if(i===void 0||!e.path.join(".").startsWith("tools.provider"))return;for(let o of rn(t.tools).selections){let a=i[o.id];if(a===void 0)throw W(e.path.join("."),`no tool provider called "${o.id}" is available here. Available: ${Object.keys(i).join(", ")||"(none)"}.`);let d;try{d=a({dir:Ji(e.file),env:{},config:o.config,agentId:t.id})}catch(l){if(R(l))throw l;throw W(e.path.join("."),`the ${o.id} provider refused its config: ${l instanceof Error?l.message:String(l)}`)}d.stop?.()}}function Jr(e,t){if(e.mediaProviders===void 0||e.path[0]!=="media")return;for(let i of["transcription","image","speech"]){let o=t.media?.[i];if(o===void 0)continue;try{sr({...t,media:{[i]:o}},{env:{},providers:new Map(Object.entries(e.mediaProviders))})}catch(a){if(R(a)&&a.code==="media_key_missing")continue;throw a}}}function W(e,t){return new te({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 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 routed tool calls in their own context, as a list of {name, task, tools, route: {tools}, model?, maxSteps?, timeoutMs?}. 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((t)=>t.path===e)}var eo=/^model\.([A-Za-z][\w-]*)$/;function co(e){let t=un(e);if(t!==void 0)return GA.includes(t.path)?t:void 0;let i=eo.exec(e)?.[1];return i===void 0||i==="main"?void 0:un("model.<role>")}var ti=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 fn={kind:"public"};function mn(e){let t=e.split(".");if(t.length!==4)return;let i=[];for(let o of t){if(o.length===0||o.length>3||!/^[0-9]+$/.test(o))return;if(o.length>1&&o.startsWith("0"))return;let a=Number(o);if(a>255)return;i.push(a)}return i}function to(e){let t=e.split("%")[0]??"";if(t==="")return;if(!/^[0-9a-fA-F:.]+$/.test(t))return;let i=t.split("::");if(i.length>2)return;let o=(c)=>{if(c==="")return[];let u=c.split(":"),f=[];for(let g=0;g<u.length;g+=1){let m=u[g]??"";if(m.includes(".")){if(g!==u.length-1)return;let y=mn(m);if(y===void 0)return;f.push(...y);continue}if(m.length===0||m.length>4)return;let p=Number.parseInt(m,16);if(Number.isNaN(p))return;f.push(p>>8&255,p&255)}return f};if(i.length===1){let c=o(t);return c!==void 0&&c.length===16?c:void 0}let a=o(i[0]??""),d=o(i[1]??"");if(a===void 0||d===void 0)return;let l=16-a.length-d.length;if(l<0)return;return[...a,...Array(l).fill(0),...d]}function Ne(e){let[t=0,i=0,o=0,a=0]=e;if(t===0)return{kind:"unspecified",range:"0.0.0.0/8"};if(t===127)return{kind:"loopback",range:"127.0.0.0/8"};if(t===10)return{kind:"private",range:"10.0.0.0/8"};if(t===172&&i>=16&&i<=31)return{kind:"private",range:"172.16.0.0/12"};if(t===192&&i===168)return{kind:"private",range:"192.168.0.0/16"};if(t===100&&i>=64&&i<=127)return{kind:"cgnat",range:"100.64.0.0/10"};if(t===169&&i===254)return{kind:"link-local",range:"169.254.0.0/16"};if(t===192&&i===0&&o===0)return{kind:"reserved",range:"192.0.0.0/24"};if(t===192&&i===0&&o===2)return{kind:"reserved",range:"192.0.2.0/24 (TEST-NET-1)"};if(t===198&&(i===18||i===19))return{kind:"reserved",range:"198.18.0.0/15"};if(t===198&&i===51&&o===100)return{kind:"reserved",range:"198.51.100.0/24 (TEST-NET-2)"};if(t===203&&i===0&&o===113)return{kind:"reserved",range:"203.0.113.0/24 (TEST-NET-3)"};if(t>=224&&t<=239)return{kind:"multicast",range:"224.0.0.0/4"};if(t===255&&i===255&&o===255&&a===255)return{kind:"reserved",range:"255.255.255.255"};if(t>=240)return{kind:"reserved",range:"240.0.0.0/4"};return fn}function no(e){if(e.length!==16)return{kind:"reserved",range:"unparseable"};if(e.slice(0,10).every((d)=>d===0)&&e[10]===255&&e[11]===255)return Ne(e.slice(12));if(e[0]===0&&e[1]===100&&e[2]===255&&e[3]===155&&e.slice(4,12).every((d)=>d===0))return Ne(e.slice(12));if(e.every((d)=>d===0))return{kind:"unspecified",range:"::"};if(e.slice(0,15).every((d)=>d===0)&&e[15]===1)return{kind:"loopback",range:"::1"};let o=e[0]??0,a=e[1]??0;if((o&254)===252)return{kind:"private",range:"fc00::/7"};if(o===254&&(a&192)===128)return{kind:"link-local",range:"fe80::/10"};if(o===255)return{kind:"multicast",range:"ff00::/8"};if(o===32&&a===1&&e[2]===13&&e[3]===184)return{kind:"reserved",range:"2001:db8::/32"};return fn}function Qr(e){let t=e.startsWith("[")&&e.endsWith("]")?e.slice(1,-1):e,i=mn(t);if(i!==void 0)return Ne(i);let o=to(t);if(o!==void 0)return no(o);return}var Ai=["agent","model","day","sender"];var jd=["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 Ie=1,re=["MEMORY.md","memory/","knowledge/"],gn=/^[^/\\.][^/\\]*\.md$/;function C(e,t,i,o){return new te({code:e,message:t,hint:i,...o===void 0?{}:{field:o}})}function yn(e){let t=Cs(e.workspace),i=(o)=>lo(o)?o:uo(e.dir,o);return{...t?.path===void 0||t.mode==="refused"?{}:{carried:{path:t.path,name:t.name,...t.budget===void 0?{}:{budget:t.budget},...t.eviction===void 0?{}:{eviction:t.eviction}}},...e.manifest.memory===void 0?{}:{memoryDir:i(e.manifest.memory.dir)},...e.manifest.knowledge===void 0?{}:{knowledgeDir:i(e.manifest.knowledge.dir)}}}function Ce(e){if(e===void 0)return[];try{return oo(e).filter((t)=>gn.test(t)&&!Bt(t)&&!Ht(t)).sort()}catch{return[]}}function _s(e){if(e===void 0||e.length===0)return re;return e.map((t,i)=>{let o=re.find((a)=>a===t);if(o===void 0)throw C("bundle_path_not_allowed",`"${t}" is not something a bundle can carry.`,`A bundle carries ${re.join(", ")} and nothing else — never the manifest, secrets or skills.`,`paths.${i}`);return o})}function ks(e,t=re,i=new Date){let o=yn(e),a=[];if(t.includes("MEMORY.md")&&o.carried!==void 0&&pn(o.carried.path))a.push({path:"MEMORY.md",content:q(o.carried.path,"utf8")});for(let[d,l]of[["memory/",o.memoryDir],["knowledge/",o.knowledgeDir]]){if(!t.includes(d)||l===void 0)continue;for(let c of Ce(l))a.push({path:`${d}${c}`,content:q(ce(l,c),"utf8")})}return{version:Ie,agentId:e.id,exportedAt:i.toISOString(),files:a}}function ho(e,t,i){let o=`files.${t}.path`;if(e.path==="MEMORY.md"){if(i.carried===void 0)throw C("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:i.carried.path,kind:"carried"}}let a=e.path.indexOf("/"),d=e.path.slice(0,a+1),l=e.path.slice(a+1);if(!(d==="memory/"||d==="knowledge/")||!gn.test(l)||Bt(l)||Ht(l))throw C("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 u=d==="memory/"?i.memoryDir:i.knowledgeDir;if(u===void 0)throw C(d==="memory/"?"bundle_no_memory":"bundle_no_knowledge",`This agent has no ${d==="memory/"?"memory":"knowledge"} block, so "${e.path}" has nowhere to go.`,`Add a \`${d==="memory/"?"memory":"knowledge"}:\` block to the manifest, or export without ${d}.`,o);return{abs:ce(u,l),kind:d==="memory/"?"memory":"knowledge"}}function fo(e,t){let i=new Set(Se(e.split(/\r?\n/)).map((o)=>o.text));return Se(t.split(/\r?\n/)).map((o)=>o.text).filter((o)=>!i.has(o))}async function vs(e){let t=e.now??new Date,i=e.mode??"skip",o=po(e.bundle),a=yn(e.agent),d=o.map((w,b)=>({file:w,...ho(w,b,a)})),l=new Map,c=(w)=>{if(!l.has(w))l.set(w,pn(w)?q(w,"utf8"):void 0)};for(let w of d)c(w.abs);for(let w of Ce(a.memoryDir))c(ce(a.memoryDir??"",w));if(a.carried!==void 0)c(a.carried.path);let u=[],f=[],g=[],m=[],p=0,y=!1;try{for(let{file:v,abs:N,kind:O}of d){let V=l.get(N);if(O==="knowledge"){if(V===v.content||V!==void 0&&i==="skip"){g.push(v.path);continue}ie(N,v.content,"utf8"),(V===void 0?u:m).push(v.path),y=!0;continue}if(V===void 0){ie(N,v.content,"utf8"),u.push(v.path),y||=O==="carried";continue}let ue=fo(q(N,"utf8"),v.content);if(ue.length===0){g.push(v.path);continue}ie(N,`${q(N,"utf8").trimEnd()}
|
|
67
|
+
|
|
68
|
+
${ue.join(`
|
|
69
|
+
`)}
|
|
70
|
+
`,"utf8"),f.push({path:v.path,notes:ue.length}),y||=O==="carried"}let w=a.carried;if(y&&w?.eviction==="oldest"&&w.budget!==void 0&&a.memoryDir!==void 0)p=(await sn({path:w.path,name:w.name,budget:w.budget,archiveDir:a.memoryDir,now:t})).evicted;let b=y?await e.reload():"none";return{added:u,merged:f,skipped:g,overwritten:m,evicted:p,reload:b}}catch(w){if(mo(l,a.memoryDir),!R(w))throw w;throw new te({code:"bundle_import_refused",message:`Nothing was imported: the agent would not load with this bundle. ${w.message}`,hint:w.hint,...w.field===void 0?{}:{field:w.field}})}}function mo(e,t){for(let[i,o]of e)if(o===void 0)Ct(i,{force:!0});else ie(i,o,"utf8");for(let i of Ce(t)){let o=ce(t??"",i);if(!e.has(o))Ct(o,{force:!0})}}function po(e){let t=typeof e==="object"&&e!==null?e:{};if(t.version!==Ie)throw C("bundle_version_unsupported",`This bundle is version ${JSON.stringify(t.version)}; this build reads version ${Ie}.`,"Export the bundle again with GET /v1/agents/:id/export on a build that matches.","version");if(!Array.isArray(t.files))throw C("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 i=new Set;return t.files.map((o,a)=>{let d=typeof o==="object"&&o!==null?o:{};if(typeof d.path!=="string"||typeof d.content!=="string")throw C("bundle_files_invalid",`files.${a} needs a string \`path\` and a string \`content\`.`,"Each entry is { path, content }, as an export writes it.",`files.${a}`);if(i.has(d.path))throw C("bundle_files_invalid",`"${d.path}" appears twice.`,"A bundle names each path once.",`files.${a}.path`);return i.add(d.path),{path:d.path,content:d.content}})}var Ut="agent:";function ni(e){return e.startsWith(Ut)?e.slice(Ut.length):void 0}var Hd=(()=>{let e=Symbol.for(`${se.slug}.liveRuntimes`),t=globalThis;return t[e]??=new Set,t[e]})();var yo="id, session_key, turn_id, role, content, tool_calls, tool_call_id, origin, tainted, created_at",Kd=yo.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 wo="schedule";function Gs(e,t,i){if(e.startsWith("shared:")){let o=e.slice(7);if(o!=="")return o}return qr({channel:wo,peerId:t,thread:i})}function Fs(e){let t=tn.safeParse(e.body);if(!t.success){let u=t.error.issues[0];throw new h({code:"schedule_invalid",message:`Schedule rejected: ${u?.path.join(".")??"body"} ${u?.message??"is invalid"}.`,hint:"A schedule needs id, kind (cron|every|at), expr, task and deliver. See docs/02-SPEC-MANIFEST.md.",...u?.path.length===void 0||u.path.length===0?{}:{field:u.path.join(".")}})}let i=t.data;if(i.deliver!=="none"){if(!e.channelIds.includes(i.deliver.channel))throw new h({code:"schedule_delivery_channel_unknown",message:`Schedule "${i.id}" delivers to "${i.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(i.role!==void 0&&!e.roleNames.includes(i.role))throw new h({code:"schedule_role_unknown",message:`Schedule "${i.id}" names the model role "${i.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=i.tools?.allow;if(o!==void 0&&e.toolSpecs!==void 0){let u=gs(o,e.toolSpecs);if(u.length>0)throw ze(i.id,u,e.toolSpecs.map((f)=>f.slug),"tools.allow")}let a=yr({id:i.id,kind:i.kind,expr:i.expr,timezone:i.timezone,now:e.now,field:"expr"}),d=new Date(e.now).toISOString(),l=Rr(a,i.id,e.now,e.now),c=i.deliver==="none"?void 0:i.deliver;return{agentId:e.agentId,id:i.id,kind:i.kind,expr:i.expr,...i.timezone===void 0?{}:{timezone:i.timezone},task:i.task,...c===void 0?{}:{deliverChannel:c.channel,deliverTo:c.to},sessionMode:i.session,...i.role===void 0?{}:{role:i.role},toolsAllow:i.tools?.allow,timeoutMs:i.timeoutMs,maxSteps:i.maxSteps,enabled:i.enabled,origin:e.origin,anchorAt:l.anchor===void 0?d:new Date(l.anchor).toISOString(),nextRunAt:l.runAt===void 0?void 0:new Date(l.runAt).toISOString(),sourcePath:"",now:d}}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}}}var Xd=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{se,Yt,R,te,h,st,S,Ir,xe,dr,ur,jt,Jt,Er,Cr,ro,pr,fr,hr,Br,ys,qr,Vr,Qs,io,ms,so,Ss,ws,Ds,Wr,bs,iA,zr,ao,Os,Zr,Ns,Ms,qt,PA,yr,$r,Ts,Xr,go,ei,Rs,sA,un,co,ti,GA,Qr,Ai,_s,ks,vs,ni,Ls,Ps,Gs,Fs,Us};
|
|
72
|
+
|
|
73
|
+
//# debugId=2ACFA9675FBF023F64756E2164756E21
|
|
74
|
+
//# sourceMappingURL=index-r4ax3x4d.js.map
|