dispach 0.2.0-pilot.2 → 0.2.0-pilot.4
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/dist/APEv2Parser-v1059sdf.js +5 -0
- package/dist/{APEv2Parser-e7k9bv13.js.map → APEv2Parser-v1059sdf.js.map} +1 -1
- package/dist/{AiffParser-btgza62h.js → AiffParser-d63xfxy7.js} +2 -2
- package/dist/App-7vmwg2rx.js +11 -0
- package/dist/{App-pg0dr8an.js.map → App-7vmwg2rx.js.map} +1 -1
- package/dist/{AsfParser-rxeats6m.js → AsfParser-e9qw1zww.js} +3 -3
- package/dist/{AsfParser-rxeats6m.js.map → AsfParser-e9qw1zww.js.map} +1 -1
- package/dist/{ConfigEditor-9qa0sktq.js → ConfigEditor-63sykb3e.js} +4 -4
- package/dist/{ConfigEditor-9qa0sktq.js.map → ConfigEditor-63sykb3e.js.map} +1 -1
- package/dist/{DsdiffParser-kv863bc1.js → DsdiffParser-g4e89wz9.js} +3 -3
- package/dist/{DsdiffParser-kv863bc1.js.map → DsdiffParser-g4e89wz9.js.map} +1 -1
- package/dist/{DsfParser-hjwbg1q5.js → DsfParser-qa5yh5p1.js} +3 -3
- package/dist/{DsfParser-hjwbg1q5.js.map → DsfParser-qa5yh5p1.js.map} +1 -1
- package/dist/FlacParser-nyx65j1q.js +5 -0
- package/dist/{KeyProbe-1ps2524b.js → KeyProbe-n5p1w903.js} +3 -3
- package/dist/{KeyProbe-1ps2524b.js.map → KeyProbe-n5p1w903.js.map} +1 -1
- package/dist/{MP4Parser-3che75e1.js → MP4Parser-4at4dbvx.js} +3 -3
- package/dist/{MP4Parser-3che75e1.js.map → MP4Parser-4at4dbvx.js.map} +1 -1
- package/dist/{MatroskaParser-8hmdtx8q.js → MatroskaParser-gg2gtj81.js} +3 -3
- package/dist/{MatroskaParser-8hmdtx8q.js.map → MatroskaParser-gg2gtj81.js.map} +1 -1
- package/dist/{MpegParser-71aj1y8y.js → MpegParser-5h5c2yvc.js} +2 -2
- package/dist/{MusepackParser-87r0dynk.js → MusepackParser-9qew0gyx.js} +3 -3
- package/dist/{MusepackParser-87r0dynk.js.map → MusepackParser-9qew0gyx.js.map} +1 -1
- package/dist/{OggParser-w42xrxch.js → OggParser-t2z5byqa.js} +3 -3
- package/dist/{OggParser-w42xrxch.js.map → OggParser-t2z5byqa.js.map} +1 -1
- package/dist/{Picker-vj5ynnq2.js → Picker-32jwxayd.js} +3 -3
- package/dist/{Picker-vj5ynnq2.js.map → Picker-32jwxayd.js.map} +1 -1
- package/dist/{SessionPicker-hfbpherr.js → SessionPicker-yjbqbstr.js} +3 -3
- package/dist/{SessionPicker-hfbpherr.js.map → SessionPicker-yjbqbstr.js.map} +1 -1
- package/dist/{SkillBrowser-1d1fm1xj.js → SkillBrowser-ry8bvw8y.js} +3 -3
- package/dist/{SkillBrowser-1d1fm1xj.js.map → SkillBrowser-ry8bvw8y.js.map} +1 -1
- package/dist/{WavPackParser-87x24j40.js → WavPackParser-p843j2sp.js} +3 -3
- package/dist/{WavPackParser-87x24j40.js.map → WavPackParser-p843j2sp.js.map} +1 -1
- package/dist/{WaveParser-dgrykdpk.js → WaveParser-fx5fb7kt.js} +2 -2
- package/dist/{WizardApp-b4q48t4z.js → WizardApp-f2rfq172.js} +3 -3
- package/dist/{WizardApp-b4q48t4z.js.map → WizardApp-f2rfq172.js.map} +1 -1
- package/dist/{channels-d4xkxfar.js → channels-yshcsfap.js} +5 -5
- package/dist/{channels-d4xkxfar.js.map → channels-yshcsfap.js.map} +1 -1
- package/dist/client.d.ts +1937 -18
- package/dist/{config-p97t4qmk.js → config-29kq9vdx.js} +12 -12
- package/dist/{config-p97t4qmk.js.map → config-29kq9vdx.js.map} +1 -1
- package/dist/{credential-pq5ckfn8.js → credential-3d0edjdj.js} +5 -5
- package/dist/{credential-pq5ckfn8.js.map → credential-3d0edjdj.js.map} +1 -1
- package/dist/{index-kqdrdn38.js → index-0za0pzfc.js} +6 -6
- package/dist/{index-kqdrdn38.js.map → index-0za0pzfc.js.map} +1 -1
- package/dist/{index-pckx0hsw.js → index-1744qpr9.js} +5 -5
- package/dist/{index-pckx0hsw.js.map → index-1744qpr9.js.map} +1 -1
- package/dist/{index-v9mmd35e.js → index-22wv6mv5.js} +4 -4
- package/dist/{index-v9mmd35e.js.map → index-22wv6mv5.js.map} +1 -1
- package/dist/{index-tn16vrgz.js → index-242qsp5x.js} +7 -7
- package/dist/{index-tn16vrgz.js.map → index-242qsp5x.js.map} +1 -1
- package/dist/{index-ry1zw01x.js → index-2c264w09.js} +11 -11
- package/dist/index-2c264w09.js.map +13 -0
- package/dist/{index-szet76ct.js → index-3et72809.js} +26 -26
- package/dist/{index-szet76ct.js.map → index-3et72809.js.map} +2 -2
- package/dist/{index-vkh83ncj.js → index-438j3bwz.js} +3 -3
- package/dist/{index-vkh83ncj.js.map → index-438j3bwz.js.map} +1 -1
- package/dist/{index-e36yxmj2.js → index-55w9ttsc.js} +15 -15
- package/dist/{index-e36yxmj2.js.map → index-55w9ttsc.js.map} +2 -2
- package/dist/index-5gb3jt0d.js +6 -0
- package/dist/{index-4kgtfze8.js.map → index-5gb3jt0d.js.map} +1 -1
- package/dist/{index-f1vcncyr.js → index-653bpmm7.js} +2 -2
- package/dist/{index-5sjysvn1.js → index-6xymgmbr.js} +4 -4
- package/dist/{index-5sjysvn1.js.map → index-6xymgmbr.js.map} +1 -1
- package/dist/{index-999yf0d2.js → index-7ccn530n.js} +169 -169
- package/dist/{index-999yf0d2.js.map → index-7ccn530n.js.map} +11 -11
- package/dist/{index-gp4z9cn5.js → index-81982mhh.js} +7 -7
- package/dist/{index-gp4z9cn5.js.map → index-81982mhh.js.map} +1 -1
- package/dist/index-8j2chqz9.js +6 -0
- package/dist/{index-p0wjy7d6.js.map → index-8j2chqz9.js.map} +1 -1
- package/dist/{index-pyajzr2x.js → index-8v9e6sg4.js} +7 -7
- package/dist/{index-pyajzr2x.js.map → index-8v9e6sg4.js.map} +1 -1
- package/dist/index-93x98xe2.js +5 -0
- package/dist/{index-7gcqnh4j.js.map → index-93x98xe2.js.map} +2 -2
- package/dist/{index-xm9pw8zm.js → index-a2xv0d12.js} +4 -4
- package/dist/{index-xm9pw8zm.js.map → index-a2xv0d12.js.map} +1 -1
- package/dist/{index-552k3p6x.js → index-afzr95s2.js} +4 -4
- package/dist/{index-552k3p6x.js.map → index-afzr95s2.js.map} +1 -1
- package/dist/{index-87hc4xtp.js → index-ah3edkkd.js} +5 -5
- package/dist/{index-87hc4xtp.js.map → index-ah3edkkd.js.map} +1 -1
- package/dist/index-b2cwz1p4.js +70 -0
- package/dist/index-b2cwz1p4.js.map +12 -0
- package/dist/{index-r9yr9z01.js → index-c20594s9.js} +10 -10
- package/dist/{index-r9yr9z01.js.map → index-c20594s9.js.map} +1 -1
- package/dist/index-c7k0tr9z.js +6 -0
- package/dist/{index-3wzageha.js.map → index-c7k0tr9z.js.map} +2 -2
- package/dist/{index-akyngwhg.js → index-d4ap27z8.js} +4 -4
- package/dist/{index-akyngwhg.js.map → index-d4ap27z8.js.map} +1 -1
- package/dist/index-dm2ydvh7.js +6 -0
- package/dist/{index-99arhztm.js.map → index-dm2ydvh7.js.map} +1 -1
- package/dist/{index-jq292533.js → index-dr4bmkvw.js} +4 -4
- package/dist/{index-jq292533.js.map → index-dr4bmkvw.js.map} +1 -1
- package/dist/{index-p82s92n0.js → index-ftqdrptv.js} +4 -4
- package/dist/{index-p82s92n0.js.map → index-ftqdrptv.js.map} +1 -1
- package/dist/{index-d05kzgz3.js → index-fzq4awfm.js} +6 -6
- package/dist/{index-d05kzgz3.js.map → index-fzq4awfm.js.map} +1 -1
- package/dist/index-gbz3n3zp.js +6 -0
- package/dist/{index-gznvv86v.js.map → index-gbz3n3zp.js.map} +1 -1
- package/dist/{index-mjxqf1s1.js → index-gq51j1v4.js} +2 -2
- package/dist/{index-5v2ynsw9.js → index-gqad9zr3.js} +6 -6
- package/dist/{index-5v2ynsw9.js.map → index-gqad9zr3.js.map} +1 -1
- package/dist/{index-7tws4a98.js → index-gta69aw8.js} +38 -38
- package/dist/{index-7tws4a98.js.map → index-gta69aw8.js.map} +5 -5
- package/dist/{index-mdhrmj2j.js → index-hgbpwf9n.js} +3 -3
- package/dist/{index-mdhrmj2j.js.map → index-hgbpwf9n.js.map} +1 -1
- package/dist/{index-7xefn7m0.js → index-jaw3fzhk.js} +4 -4
- package/dist/{index-7xefn7m0.js.map → index-jaw3fzhk.js.map} +1 -1
- package/dist/{index-q9gwzp5j.js → index-mhncbgvg.js} +4 -4
- package/dist/{index-q9gwzp5j.js.map → index-mhncbgvg.js.map} +1 -1
- package/dist/{index-96cf3zz4.js → index-n9hvdky5.js} +4 -4
- package/dist/{index-96cf3zz4.js.map → index-n9hvdky5.js.map} +1 -1
- package/dist/{index-1c7kcyfq.js → index-p2yxw774.js} +4 -4
- package/dist/{index-1c7kcyfq.js.map → index-p2yxw774.js.map} +1 -1
- package/dist/{index-tqrx302v.js → index-pnz56nvf.js} +5 -5
- package/dist/{index-tqrx302v.js.map → index-pnz56nvf.js.map} +1 -1
- package/dist/{index-0a07ca51.js → index-ppafg4wv.js} +22 -22
- package/dist/{index-0a07ca51.js.map → index-ppafg4wv.js.map} +2 -2
- package/dist/{index-rsc5p35w.js → index-r6rpt940.js} +6 -6
- package/dist/{index-rsc5p35w.js.map → index-r6rpt940.js.map} +1 -1
- package/dist/{index-kmaq9hx4.js → index-r8cpr3za.js} +4 -4
- package/dist/{index-kmaq9hx4.js.map → index-r8cpr3za.js.map} +1 -1
- package/dist/{index-7zrpcfhj.js → index-rgdredf1.js} +4 -4
- package/dist/{index-7zrpcfhj.js.map → index-rgdredf1.js.map} +1 -1
- package/dist/{index-b8d2y1cb.js → index-ryw27wwe.js} +4 -4
- package/dist/{index-b8d2y1cb.js.map → index-ryw27wwe.js.map} +1 -1
- package/dist/{index-7e78cat9.js → index-sa3y3qk9.js} +4 -4
- package/dist/{index-7e78cat9.js.map → index-sa3y3qk9.js.map} +1 -1
- package/dist/{index-8wd4ymdg.js → index-svkzkfn0.js} +3 -3
- package/dist/{index-8wd4ymdg.js.map → index-svkzkfn0.js.map} +1 -1
- package/dist/index-v700serf.js +5 -0
- package/dist/{index-8wqf1n2y.js.map → index-v700serf.js.map} +2 -2
- package/dist/{index-rhsrphzb.js → index-v7jvv9ng.js} +4 -4
- package/dist/{index-rhsrphzb.js.map → index-v7jvv9ng.js.map} +1 -1
- package/dist/{index-pk385zk4.js → index-vbr1kf2g.js} +2 -2
- package/dist/index-wzk2npdh.js +8 -0
- package/dist/{index-dpa6r43h.js.map → index-wzk2npdh.js.map} +2 -2
- package/dist/{index-k99avg4y.js → index-y3cmd2g8.js} +4 -4
- package/dist/{index-k99avg4y.js.map → index-y3cmd2g8.js.map} +1 -1
- package/dist/index.js +128 -128
- package/dist/index.js.map +4 -4
- package/dist/serve.d.ts +7 -0
- package/dist/serve.d.ts.map +1 -1
- package/dist/{web-t6d2vbx0.js → web-10856pm1.js} +4 -4
- package/dist/{web-t6d2vbx0.js.map → web-10856pm1.js.map} +1 -1
- package/dist/wire.d.ts +923 -7
- package/dist/wrapper-rgk1asmr.js +5 -0
- package/dist/{wrapper-8x4hpa5z.js.map → wrapper-rgk1asmr.js.map} +1 -1
- package/package.json +6 -5
- package/dist/APEv2Parser-e7k9bv13.js +0 -5
- package/dist/App-pg0dr8an.js +0 -11
- package/dist/FlacParser-7tvpty5w.js +0 -5
- package/dist/index-3wzageha.js +0 -6
- package/dist/index-4kgtfze8.js +0 -6
- package/dist/index-4t6mjaz9.js +0 -70
- package/dist/index-4t6mjaz9.js.map +0 -12
- package/dist/index-7gcqnh4j.js +0 -5
- package/dist/index-8wqf1n2y.js +0 -5
- package/dist/index-99arhztm.js +0 -6
- package/dist/index-dpa6r43h.js +0 -8
- package/dist/index-gznvv86v.js +0 -6
- package/dist/index-p0wjy7d6.js +0 -6
- package/dist/index-ry1zw01x.js.map +0 -13
- package/dist/wrapper-8x4hpa5z.js +0 -5
- /package/dist/{AiffParser-btgza62h.js.map → AiffParser-d63xfxy7.js.map} +0 -0
- /package/dist/{FlacParser-7tvpty5w.js.map → FlacParser-nyx65j1q.js.map} +0 -0
- /package/dist/{MpegParser-71aj1y8y.js.map → MpegParser-5h5c2yvc.js.map} +0 -0
- /package/dist/{WaveParser-dgrykdpk.js.map → WaveParser-fx5fb7kt.js.map} +0 -0
- /package/dist/{index-f1vcncyr.js.map → index-653bpmm7.js.map} +0 -0
- /package/dist/{index-mjxqf1s1.js.map → index-gq51j1v4.js.map} +0 -0
- /package/dist/{index-pk385zk4.js.map → index-vbr1kf2g.js.map} +0 -0
package/dist/index.js
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{A,
|
|
2
|
+
import{A,Y,f,t,hA,ro,jA,Ft,rt,fe,io,Jr,qr,it,so,yA,Vr,st,Ut,IA,ao,go,Ve,v,J,Zr,Xr,xt,j,lo,Io,ct,Ht,uo,lt,V,de,Ai,Ie,In,Eo,Co,ti,ni,R,Ss}from"./index-7ccn530n.js";import{nr,Je,or,rr,FA,ir,sr,ar}from"./index-b2cwz1p4.js";import{Ae,me,ce,le,se,pe,Lr}from"./index-gta69aw8.js";import{Ps}from"./index-rgdredf1.js";import{dn}from"./index-d4ap27z8.js";import{Mt,Tt,qn,Le,qi,Vi,Zo,kr,Xo,aA,$o,Rt,vA,er,GA,_t,Wi,zi}from"./index-3et72809.js";import{jo,Xt,kA,Mr,Jo,wt,qo,Pn,Dt,vn,$t,Gn,Fn,Pi,Un,xn,Hn}from"./index-ppafg4wv.js";import{kt,Lt,to,rn,no,Pt,Er,sn,tA,ot,xA,vt,Cr}from"./index-81982mhh.js";import{_r,Gi,en,Fi,Ui,xi,zA}from"./index-2c264w09.js";import{An,eA,tn,Yi}from"./index-r8cpr3za.js";import{_n,kn,zt,Ko,St,bi,Ln,Mi,Ti}from"./index-c20594s9.js";import"./index-6xymgmbr.js";import{Ho}from"./index-n9hvdky5.js";import{_A,Zt,ki,Li}from"./index-dr4bmkvw.js";import{bt,vi}from"./index-1744qpr9.js";import{He}from"./index-v7jvv9ng.js";import{Hi}from"./index-p2yxw774.js";import{ji,Wo,zo,Ke,Ye,LA,Ji,PA,ye,Nt,sA,Jn}from"./index-c7k0tr9z.js";import{Pe,AA}from"./index-svkzkfn0.js";import{zn,pA,Xi,F,es,je,gA,tr,As}from"./index-ah3edkkd.js";import{d,_,y,h,ZA,on,XA,$A}from"./index-gqad9zr3.js";import{HA,Oe,ne,Hr,G,oe,pr,an,gn,Kr,Bs,Gt,hs,z,ve}from"./index-wzk2npdh.js";import{_e}from"./index-dm2ydvh7.js";import{Ts,_s}from"./index-a2xv0d12.js";import{Qo,Ys,SA,De,So,No,n,u,En}from"./index-5gb3jt0d.js";async function nn(e){let r=await PA(e),o=[];for(let i of z()){let s=i.id??i.ref,a=await zo(s,e)??{enabled:!0},l=r.find((p)=>p.agentId===s),c=l===void 0?Number.NaN:Date.now()-Date.parse(l.startedAt);o.push({...i,enabled:a.enabled,...a.reason===void 0?{}:{reason:a.reason},...l===void 0?{}:{pid:l.pid,serving:`serving · ${l.mode} · pid ${l.pid}${Number.isFinite(c)?` · up ${on(c)}`:""}`}})}return o}function ln(e){if(e.length===0)return[{label:"agents",value:"none in the sandbox",note:"init creates one"}];return e.map((r)=>({label:r.ref,value:r.problem!==void 0?"broken":r.enabled?"on":"off",note:r.problem??r.serving??(r.enabled?`not hosted${r.modelId===void 0?"":` · ${r.modelId}`}`:`switched off${r.reason===void 0?"":` — ${r.reason}`}`)}))}async function et(e){if(e.manifestPaths.length===0){let a=await nn(e.store);if(e.json===!0)process.stdout.write(`${JSON.stringify({agents:a},null,2)}
|
|
3
3
|
`);else process.stdout.write(`${d(ln(a))}
|
|
4
|
-
`);return n}let r=await Ie.create({agents:[...e.manifestPaths],toolProviders:
|
|
4
|
+
`);return n}let r=await Ie.create({agents:[...e.manifestPaths],toolProviders:Ae,modelTransports:me,mediaProviders:ce,builtInPlugins:pe,pluginRoot:oe(),scriptRunner:le(),channels:se,env:R(e.manifestPaths),store:e.store??G(),lease:!1});F(()=>r.stop("cli-exit"));let o=r.list().map((a)=>a.describe()),i=new Map;for(let a of await r.store.leases.all()){if(a.runtimeId===r.runtimeId||!V(a.pid))continue;let l=Date.now()-Date.parse(a.startedAt);i.set(a.agentId,`serving · ${a.mode} · pid ${a.pid}${Number.isFinite(l)?` · up ${on(l)}`:""}`)}if(e.json===!0)return process.stdout.write(`${JSON.stringify({agents:o.map((a)=>({...a,serving:i.get(a.id)??null}))},null,2)}
|
|
5
5
|
`),n;let s=o.map((a)=>({label:a.id,value:`${a.model} ${String(a.window).padStart(7)} window`,note:i.get(a.id)??a.name}));return process.stdout.write(`${d(s)}
|
|
6
|
-
`),n}import{basename as hn,dirname as
|
|
6
|
+
`),n}import{basename as hn,dirname as Po,join as ie,resolve as Ro}from"node:path";import{rmSync as Yr}from"node:fs";import{isAbsolute as nt,join as eo,resolve as tt}from"node:path";var oo=3;async function at(e){if(e.answers.skills!=="find")return;let r=e.answers.skillsSearch?.trim()??"";if(r===""){process.stdout.write("\nno words to search for, so no skill was installed — `sources search <words>` when you know what you want\n");return}let o=Le(e.env);if(o.length===0){process.stdout.write("\nno skill sources are configured, so there was nothing to search\n\n `sources add <url>` adds one, then `skills install <agent> <source>/<skill>`.\n");return}process.stdout.write(`
|
|
7
7
|
searching ${o.length} skill source(s) for ${JSON.stringify(r)}
|
|
8
|
-
`);let i=[],s=[];for(let m of o){if(!aA(m.name,e.env))try{await
|
|
8
|
+
`);let i=[],s=[];for(let m of o){if(!aA(m.name,e.env))try{await Rt(m,{...e.env===void 0?{}:{env:e.env},...e.git===void 0?{}:{git:e.git}})}catch(w){s.push(`${m.name} — ${f(w)?w.message:String(w)}`);continue}i.push(...vA(m,e.env))}for(let m of s)process.stdout.write(h(`could not fetch ${m}
|
|
9
9
|
`));if(i.length===0){process.stdout.write(`${h("no source could be read, so no skill was installed — the directory is there and empty")}
|
|
10
10
|
${h("`sources update` reports why; `sources search <words>` when it works",4)}
|
|
11
|
-
`);return}let a=
|
|
11
|
+
`);return}let a=co(r,i);if(a.length===0){process.stdout.write(`${h(`nothing in ${i.length} skills matches those words, so none was installed`)}
|
|
12
12
|
${h("the ranking is lexical: try the words a skill's own description would use, with `sources search`",4)}
|
|
13
13
|
`);return}let l=a[0],c=`${l.source}/${l.skill}`;if(process.stdout.write(`${h(`best of ${i.length}: ${c}`)}
|
|
14
|
-
`),a.length>1)process.stdout.write(`${h(`also matched: ${a.slice(1,1+
|
|
14
|
+
`),a.length>1)process.stdout.write(`${h(`also matched: ${a.slice(1,1+oo).map((m)=>`${m.source}/${m.skill}`).join(", ")}`,4)}
|
|
15
15
|
`);if(process.stdout.write(`
|
|
16
|
-
`),
|
|
16
|
+
`),GA({action:"install",manifestPath:e.manifestPath,name:c,...e.env===void 0?{}:{sandboxEnv:e.env},...e.envOverlay===void 0?{}:{envOverlay:e.envOverlay}})!==n)return;let g=mo(e.manifestPath,e.envOverlay);if(g!==void 0)fo(e.manifestPath,l.skill,e.envOverlay),process.stdout.write(`
|
|
17
17
|
${y(`${c} was removed again: it does not load on this machine`)}
|
|
18
18
|
${h(g,4)}
|
|
19
19
|
${h("everything else is fine; `sources search` for one that needs no extra runtime",4)}
|
|
20
|
-
`)}function
|
|
21
|
-
`),n;return r.kind==="failed"?r.code:n}async function yn(e){return
|
|
22
|
-
`);let p=
|
|
20
|
+
`)}function co(e,r){let o=new Map,i=r.filter((s)=>s.problem===void 0).map((s)=>{let a=`${s.source}/${s.skill}`;return o.set(a,s),{name:a,dir:s.dir,tokens:s.tokens,scripts:[],ignoredScripts:[],frontmatter:{name:a,description:s.description,metadata:{}}}});return Ht(e,i).filter((s)=>s.score>0).map((s)=>o.get(s.skill.name)).filter((s)=>s!==void 0)}function mo(e,r){try{let o=J(e,{...r===void 0?{}:{env:{...process.env,...r}}}),i=o.manifest.skills;if(i===void 0)return;let s=fe(o.manifest.model.main.id,o.manifest.model.main.capabilities);ct({dir:nt(i.dir)?i.dir:tt(o.dir,i.dir),maxActive:i.maxActive,threshold:i.threshold,style:s.promptStyle,agentDir:o.dir,runner:le()});return}catch(o){return f(o)?o.message:String(o)}}function fo(e,r,o){try{let i=J(e,{...o===void 0?{}:{env:{...process.env,...o}}}),s=i.manifest.skills;if(s===void 0)return;let a=nt(s.dir)?s.dir:tt(i.dir,s.dir);Yr(eo(a,r),{recursive:!0,force:!0}),er(a,r)}catch{}}import{existsSync as po,mkdirSync as ho,writeFileSync as yo}from"node:fs";import{dirname as wo,join as cn,resolve as un,sep as bo}from"node:path";var Fe={user:"--user",name:"--name",purpose:"--purpose",preset:"--preset",model:"--model",baseUrl:"--base-url",apiKeyEnv:"--api-key-env",apiKey:"(asked at the prompt only)",system:"--system",web:"--web",webBackend:"--web-backend",webKey:"(asked at the prompt only)",composio:"--composio",composioKey:"(asked at the prompt only)",telegram:"--telegram",telegramAllow:"--telegram-allow",whatsapp:"--whatsapp",whatsappNumber:"--whatsapp-number",telegramToken:"(asked at the prompt only)",schedules:"--schedules",server:"--server",skills:"--skills",skillsSearch:"--skills",skillsPick:"--skills",daemon:"--daemon",serverToken:"(generated)",dirChoice:"--dir",dir:"--dir"};function mn(e,r,o){let i=[];for(;;){let s=ot(e,o);if(s===void 0)break;if(s.optional===!0){e[s.step]="";continue}if(s.fallback===""){i.push(s.step),e[s.step]="(missing)";continue}let a=xA(s.step,s.fallback);if(a.ok)e[s.step]=a.value}if(i.length>0){let s=i.map((a)=>Fe[a]).join(", ");throw new t({code:"cli_init_missing_answers",message:`Not interactive (${r}), and ${i.join(", ")} ${i.length===1?"has":"have"} no default.`,hint:`Pass ${s} — an agent's name is not something to guess — or run the command at a terminal to be asked. Everything with a sensible default (purpose, preset, endpoint, directory) already took it.`})}}function fn(e,r){let o=e,i=kt(o.preset),s=o.apiKeyEnv??i?.apiKeyEnv,a=o.server??"local",l=o.dir??Lt(o.dirChoice,o.name,r);if(l===void 0)throw new t({code:"cli_init_no_directory",message:`The directory answer was ${JSON.stringify(o.dirChoice)}, which resolves to no path.`,hint:"This is a bug in the CLI: every dirChoice except `custom` must derive a path in `dirFor`, and `custom` must have asked the dir question. Pass --dir <path> to get past it."});return{user:o.user,name:o.name,purpose:o.purpose,preset:o.preset,model:o.model,baseUrl:o.baseUrl,system:o.system,web:o.web,...o.webBackend===void 0?{}:{webBackend:o.webBackend},...o.webKey===void 0||o.webKey===""?{}:{webKey:o.webKey},composio:o.composio,...o.composioKey===void 0||o.composioKey===""?{}:{composioKey:o.composioKey},telegram:o.telegram,...o.telegramToken===void 0||o.telegramToken===""?{}:{telegramToken:o.telegramToken},...o.telegramAllow===void 0||o.telegramAllow===""?{}:{telegramAllow:o.telegramAllow},whatsapp:o.whatsapp??"none",...o.whatsappNumber===void 0||o.whatsappNumber===""?{}:{whatsappNumber:o.whatsappNumber},schedules:o.schedules??"none",server:a,skills:o.skills,...o.skillsSearch===void 0||o.skillsSearch===""?{}:{skillsSearch:o.skillsSearch},...o.skillsPick===void 0||o.skillsPick===""?{}:{skillsPick:o.skillsPick},daemon:o.daemon,...a==="local"?{serverToken:vo(l,r.agentDirBase)?Bs(r.agentDirBase,dt):dt()}:{},...s===void 0?{}:{apiKeyEnv:s},...o.apiKey===void 0||o.apiKey===""?{}:{apiKey:o.apiKey},...o.dirChoice===void 0?{}:{dirChoice:o.dirChoice},dir:l}}function vo(e,r){let o=un(e),i=un(r);return o===i||o.startsWith(i+bo)}function dt(){let e=new Uint8Array(32);return crypto.getRandomValues(e),[...e].map((r)=>r.toString(16).padStart(2,"0")).join("")}function Ee(e,r){let o=r.map((i)=>cn(e,i.relPath)).filter((i)=>po(i));if(o.length>0)throw new t({code:"cli_init_target_exists",message:`${o.length} of the files init would write already exist: ${o.join(", ")}`,hint:"Nothing is overwritten and there is no --force — replacing a personalised workspace is exactly the loss this command exists to prevent. Point init at a fresh directory, or delete the files first if they really are disposable."});for(let i of r){let s=cn(e,i.relPath);ho(wo(s),{recursive:!0}),yo(s,i.contents,{encoding:"utf8",...i.relPath===".env"?{mode:384}:{}})}}function Ue(e,r){let o=J(e,{...r===void 0?{}:{env:{...process.env,...r}}}),i=fe(o.manifest.model.main.id,o.manifest.model.main.capabilities),{workspace:s,warnings:a}=lt(o,i.promptStyle),l=jA(s,o.manifest.context.rules);if(l!==void 0&&o.manifest.context.rules.onExceed==="fail")throw l;return{distilled:a.some((c)=>c.code==="soul_distilled")}}var mt=new Map([["dir",{code:"provision_directory_refused",hint:"A provisioned agent lands in this host's sandbox, because where an agent lives on disk is the operator's decision rather than a caller's. Use `init --dir` at a terminal to put one somewhere else."}],["dirChoice",{code:"provision_directory_refused",hint:"A provisioned agent lands in this host's sandbox, because where an agent lives on disk is the operator's decision rather than a caller's. Use `init --dir` at a terminal to put one somewhere else."}],["daemon",{code:"provision_daemon_refused",hint:"This server is already hosting the agent you are creating — that is what `adopted` in the response means. Installing a service unit is `daemon install` at a terminal, and a route that writes one would be a web page installing a background process."}]]),pn=new Map([["skills",new Map([["find",{code:"provision_skills_search_refused",hint:"Searching the catalogues is an interactive picker, not an answer — over the wire it would write no skills and report success. Send `starter` or `none`, then `skills search` and `skills install` once the agent exists."}]])]]);function ft(e){let r=xA(e.step,e.fallback);return r.ok?r.value:e.fallback}function ko(e,r){let o=pn.get(e.step);return{step:e.step,prompt:e.prompt,fallback:ft(e),optional:e.optional===!0,secret:sn.has(e.step),...r===void 0?{}:{requires:r},...e.options===void 0?{}:{choices:e.options.filter((i)=>o?.has(i.value)!==!0).map((i)=>({value:i.value,label:i.label,...i.hint===void 0?{}:{hint:i.hint}}))}}}var ut=64;function pt(e){let r=new Map,o=new Set,i=(a,l)=>{let c={...a},p=[];for(let g=0;g<ut;g+=1){let m=ot(c,e);if(m===void 0)break;let w=ft(m);if(!mt.has(m.step)&&!r.has(m.step))r.set(m.step,ko(m,l));for(let b of m.options??[]){if(b.value===w)continue;if(pn.get(m.step)?.has(b.value)===!0)continue;p.push({seed:{...c,[m.step]:b.value},opened:{step:m.step,value:b.value}})}c[m.step]=w}return p},s=[...i({})];for(let a=0;a<ut&&s.length>0;a+=1){let l=s.splice(0,s.length);for(let c of l){let p=`${c.opened.step}=${c.opened.value}`;if(o.has(p))continue;o.add(p),s.push(...i(c.seed,c.opened))}}return[...r.values()].sort((a,l)=>Er.indexOf(a.step)-Er.indexOf(l.step))}function ht(e){let r={};for(let[c,p]of Object.entries(e.answers)){let g=c;if(!(g in Fe))throw new t({code:"provision_unknown_answer",message:`"${c}" is not a question this runtime asks.`,hint:"GET /v1/provision lists every step with its prompt, default and choices. It is generated from the same walk the terminal wizard uses, so it cannot be stale.",field:c});let m=mt.get(g);if(m!==void 0)throw new t({code:m.code,message:`"${c}" cannot be set over the API.`,hint:m.hint,field:c});let w=pn.get(g)?.get(p.trim().toLowerCase());if(w!==void 0)throw new t({code:w.code,message:`${c} is ${JSON.stringify(p)}, which this runtime cannot do over the API.`,hint:w.hint,field:c});let b=xA(g,p);if(!b.ok)throw new t({code:"provision_answer_invalid",message:`${c} is ${JSON.stringify(p)}, which ${b.reason}`,hint:"GET /v1/provision lists every step with its prompt, its default and its choices, generated from the same walk the terminal wizard uses.",field:c});r[g]=b.value}mn(r,"this is the provisioning API",e.defaults);let o=fn(r,e.defaults),i=tA(o.name),s=Lt("sandbox",o.name,e.defaults);if(s===void 0)throw new t({code:"provision_dir_unresolved",message:`No directory could be derived for ${JSON.stringify(o.name)}.`,hint:'This is a bug in the CLI: `dirFor("sandbox", …)` must always resolve a path. It returns undefined only when the name is missing, which `complete()` has already refused.',field:"name"});let a=un(s),l=Cr({...o,dir:a});return Ee(a,l),{agentId:i,dir:a,manifestPath:cn(a,"agent.yaml"),files:l.map((c)=>c.relPath)}}function xo(e){if(e.web!=="search")return;return to(e.webBackend??"tavily")?.apiKeyEnv}async function gt(e){let r=await yt(e);if(r.kind==="aborted")return process.stdout.write(`nothing written
|
|
21
|
+
`),n;return r.kind==="failed"?r.code:n}async function yn(e){return yt(e)}async function yt(e){let r=Ao(e),o=AA({json:!1,plain:e.plain===!0,oneShot:!1}),i=o.mode==="rich"&&e.yes!==!0,s={agentDirBase:ne()};if(i){let x=await Oo(r,s);if(x===void 0)return{kind:"aborted"};Object.assign(r,x)}else mn(r,e.yes===!0?"--yes was passed":o.because,s);let a=fn(r,s),l=Ro(process.cwd(),a.dir),c=hs(l);if(c!==void 0)process.stderr.write(`${c}
|
|
22
|
+
`);let p=ie(l,"agent.yaml"),g=Cr(a);Ee(l,g);let m=a.apiKeyEnv,b=m!==void 0&&a.apiKey===void 0&&(process.env[m]===void 0||process.env[m]==="")&&m!==void 0?{[m]:"(pending)"}:void 0,k=!1;try{k=Ue(ie(l,"agent.yaml"),b).distilled}catch(x){if(f(x))return process.stderr.write(`init wrote ${g.length} files to ${l}, but the result does not load:
|
|
23
23
|
${x.format()}
|
|
24
24
|
`),{kind:"failed",code:u};throw x}if(process.stdout.write(`wrote ${g.length} files to ${l} — validated ok
|
|
25
|
-
`),a.skills==="find"){let x=(a.skillsPick??"").split(",").map((M)=>M.trim()).filter((M)=>M!=="");if(x.length>0)
|
|
26
|
-
`);let{outcome:x,host:M}=await Pn({...e.installServer===void 0?{}:{install:e.installServer}}),
|
|
25
|
+
`),a.skills==="find"){let x=(a.skillsPick??"").split(",").map((M)=>M.trim()).filter((M)=>M!=="");if(x.length>0)Wi(x,p,{...b===void 0?{}:{envOverlay:b}});else if(!i)await at({answers:a,manifestPath:p,...b===void 0?{}:{envOverlay:b}})}let C;if(a.daemon==="service"){process.stdout.write(`
|
|
26
|
+
`);let{outcome:x,host:M}=await Pn({...e.installServer===void 0?{}:{install:e.installServer}}),q=wt(x);if(q!==void 0)process.stderr.write(q);if(M?.baseUrl!==void 0){let S=await Dt(M,p);if(S.ok)C=M.baseUrl;else process.stderr.write(`pid ${M.pid} did not adopt ${tA(a.name)}${S.detail===void 0?"":`: ${S.detail}`}
|
|
27
27
|
`)}}let P;if(a.whatsapp==="connected"&&(a.whatsappNumber??"")!==""&&i)P=C!==void 0?await Gn({manifestPath:p,channelId:"wa"}):await Fn({manifestPath:p,dir:l,number:a.whatsappNumber??"",channelId:"wa"});if(a.whatsapp==="connected"&&P!=="paired")process.stdout.write(`
|
|
28
|
-
${
|
|
28
|
+
${Pi(tA(a.name))}`);return process.stdout.write(_o(a,l,k,C)),{kind:"ok",manifestPath:ie(l,"agent.yaml")}}function To(e){if(e===void 0)return[];if(Pt.some((r)=>r.value===e))return[["skills",e]];return[["skills","find"],["skillsSearch",e]]}function Ao(e){let r={},o=[["user",e.user],["name",e.name],["purpose",e.purpose],["preset",e.preset],["model",e.model],["baseUrl",e.baseUrl],["apiKeyEnv",e.apiKeyEnv],["system",e.system],["web",e.web],["webBackend",e.webBackend],["composio",e.composio],["telegram",e.telegram],["telegramAllow",e.telegramAllow],["whatsapp",e.whatsapp],["whatsappNumber",e.whatsappNumber],["server",e.server],["schedules",e.schedules],...To(e.skills),["daemon",e.daemon],["dir",e.dir]];for(let[i,s]of o){if(s===void 0)continue;let a=xA(i,s);if(!a.ok)throw new t({code:"cli_init_flag_invalid",message:`${Fe[i]} is ${JSON.stringify(s)}, which ${a.reason}`,hint:"The flags take the same values the interactive questions do; run the command at a terminal without flags to be walked through them."});r[i]=a.value}return r}async function Oo(e,r){let[{render:o},{createElement:i},{WizardApp:s}]=await Promise.all([import("ink"),import("react"),import("./WizardApp-f2rfq172.js")]),a;zn();let l=o(i(s,{title:`${A.name} ${j}`,given:e,defaults:r,onDone:(c)=>{a=c}}),{exitOnCtrlC:!1,...Pe()});return F(()=>l.unmount()),await l.waitUntilExit(),l.unmount(),a}function _o(e,r,o,i){let s=i!==void 0,l=Po(r)===ne()?hn(r):ie(r,"agent.yaml"),c=ie(r,"agent.yaml"),p=[];if(e.apiKeyEnv!==void 0&&e.apiKey===void 0)p.push(`Add your key: edit ${ie(r,".env")} and set ${e.apiKeyEnv}=`);let g=xo(e);if(g!==void 0&&e.webKey===void 0)p.push(`Add your search key: edit ${ie(r,".env")} and set ${g}= — web_fetch works without it, web_search does not`);if(vt(e)&&e.composioKey===void 0)p.push(`Add your Composio key: edit ${ie(r,".env")} and set ${rn}=`);if(e.telegram==="connected"&&e.telegramToken===void 0)p.push(`Add your bot token: message @BotFather with /newbot, then edit ${ie(r,".env")} and set ${no}=`);let m=[...e.telegram==="connected"?["the Telegram bot"]:[],...e.whatsapp==="connected"?["WhatsApp"]:[]],w=m.length>0||e.server==="local",b=[...m,...e.server==="local"?["the HTTP API"]:[]].join(" and ");if(s)p.push(`open ${zA(i,hn(r))} — the web UI. The service is serving `+`${hn(r)} now; ${b} ${m.length+(e.server==="local"?1:0)===1?"is":"are"} up.`),p.push(`${A.slug} run ${l} — talks to it here, attached to that same service.`);else p.push(`${A.slug} run ${l}`);if(w&&!s){if(p.push(`${A.slug} serve ${l} — starts ${b}; \`run\` starts neither`),e.daemon==="service")p.push(`${A.slug} daemon install — the same thing, supervised: one service hosts `+"every agent, starts at login and survives a reboot.")}if(e.telegram==="connected"&&e.telegramAllow===void 0)p.push("Message the bot. Nobody is on its allowFrom yet, so it will refuse you — and print "+"the exact line to paste into agent.yaml.");if(vt(e))p.push('Ask it for an app — "connect my Gmail" — and it finds the tools, gives you the '+"sign-in link, and pins what you need. New tools go live on the next restart.");p.push(e.skills==="find"?`Add more skills: \`${A.slug} sources search <what it should do>\` ranks every skill in the catalogues, then \`${A.slug} skills install ${l} <source>/<skill>\`.`:e.skills==="starter"?`Fill in workspace-level skills/starter/SKILL.md, or take a real one — \`${A.slug} sources search <what it should do>\` searches 440+ from two catalogues.`:`Skills are off but the directory is there — \`${A.slug} sources search <what it should do>\` finds one, \`${A.slug} skills new ${l} <name>\` writes one.`),p.push("Make workspace/SOUL.md yours, then re-derive SOUL.compact.md to match — "+`\`${A.slug} workspace ${c}\` shows exactly what still reads as a template.`);let k=s?`
|
|
29
29
|
it is running in the background now — \`${A.slug} status\` at any time,
|
|
30
30
|
\`${A.slug} restart ${l}\` after editing it, and \`${A.slug} stop\` turns everything off.
|
|
31
31
|
`:"";return`${o?`
|
|
@@ -33,7 +33,7 @@ this model ships SOUL.compact.md — the full SOUL.md needs a 200k+ window on a
|
|
|
33
33
|
frontier-class model, and activates automatically if you upgrade.
|
|
34
34
|
`:""}${k}
|
|
35
35
|
`+p.map((P,x)=>` ${x+1}. ${P}
|
|
36
|
-
`).join("")}var Me=16;function Ge(e=process.stdin){let r=[],o=[],i=(s)=>{let a=typeof s==="string"?s:s.toString("utf8");if(o.push(a),o.length>Me)o.splice(0,o.length-Me);if(r.push(...
|
|
36
|
+
`).join("")}var Me=16;function Ge(e=process.stdin){let r=[],o=[],i=(s)=>{let a=typeof s==="string"?s:s.toString("utf8");if(o.push(a),o.length>Me)o.splice(0,o.length-Me);if(r.push(...Ts(a)),r.length>Me)r.splice(0,r.length-Me)};return e.on("data",i),{correct:(s,a)=>_s(s,a,r),takeRaw:()=>o.shift(),close:()=>{e.off("data",i)}}}var Et=[{id:"vscode",name:"VS Code's integrated terminal",how:"write",configPath:"Library/Application Support/Code/User/keybindings.json",line:'{ "key": "shift+enter", "command": "workbench.action.terminal.sendSequence", "args": { "text": "\\u001b[13;2u" } }',marker:"workbench.action.terminal.sendSequence"},{id:"ghostty",name:"Ghostty",how:"write",configPath:".config/ghostty/config",line:"keybind = shift+enter=text:\\x1b[13;2u",marker:"shift+enter=text:"},{id:"kitty",name:"kitty",how:"write",configPath:".config/kitty/kitty.conf",line:"map shift+enter send_text all \\x1b[13;2u",marker:"map shift+enter send_text"},{id:"wezterm",name:"WezTerm",how:"write",configPath:".wezterm.lua",line:"-- shift+enter: { key = 'Enter', mods = 'SHIFT', action = wezterm.action.SendString '\\x1b[13;2u' },",marker:"mods = 'SHIFT', action = wezterm.action.SendString"},{id:"warp",name:"Warp",how:"explain",reason:"Option is resolved to a character before the keyboard protocol sees it, so ⌥ plus a letter arrives as text like `®` unless Warp is told otherwise",steps:["Settings → Features → Keys → tick “Left and Right Option Key is Meta”","That is only needed for ⌥ plus a *letter*. ⌥ and cmd with arrows already work, and so does shift+⏎",`Every letter chord here has a control-key twin that needs none of this — \`${A.slug} keys\` shows exactly what your terminal sends`]},{id:"iterm2",name:"iTerm2",how:"explain",reason:"its preferences are a binary plist it rewrites on quit, so an edit made underneath it is discarded",steps:["Settings → Profiles → Keys → Key Mappings","Press +, then press shift and return together to capture the key","Set Action to “Send Hex Codes”","Enter: 0x1b 0x5b 0x31 0x33 0x3b 0x32 0x75"]},{id:"apple",name:"Terminal.app",how:"explain",reason:"its key bindings live in the same binary preferences file, and it caches them while running",steps:["Settings → Profiles → Keyboard","Press +, choose Return as the key and tick Shift","Set Action to “Send Text” and enter: \\033[13;2u"]}];function We(e){let r=e.TERM_PROGRAM??"";if(r==="vscode")return"vscode";if(r==="ghostty"||e.GHOSTTY_RESOURCES_DIR!==void 0)return"ghostty";if(e.KITTY_WINDOW_ID!==void 0||e.TERM==="xterm-kitty")return"kitty";if(e.WEZTERM_PANE!==void 0)return"wezterm";if(r==="WarpTerminal")return"warp";if(r==="iTerm.app")return"iterm2";if(r==="Apple_Terminal")return"apple";return"unknown"}function qe(e){return Et.find((r)=>r.id===e)}function It(){return Et}function At(e,r){return r.marker!==void 0&&e.includes(r.marker)}function Ot(e,r){let o=r.line;if(o===void 0)return;if(r.id!=="vscode"){let c=e.trimEnd();return c===""?`${o}
|
|
37
37
|
`:`${c}
|
|
38
38
|
${o}
|
|
39
39
|
`}let i=e.trim();if(i===""||i==="[]")return`[
|
|
@@ -41,12 +41,12 @@ ${o}
|
|
|
41
41
|
]
|
|
42
42
|
`;let s=i.indexOf("[");if(s===-1)return;let l=i.slice(s+1).trimStart().startsWith("]")?"":",";return`${i.slice(0,s+1)}
|
|
43
43
|
${o}${l}
|
|
44
|
-
${i.slice(s+1)}`}async function Ct(e={}){let r=AA({plain:!1,json:!1,oneShot:!1});if(r.mode!=="rich")throw new t({code:"cli_keys_needs_terminal",message:"The key probe needs a terminal — it has nothing to read on a pipe.",hint:`Not one here (${r.because}). Run it in the terminal whose keys you want to inspect; there is no scripted form, because the answer is a property of that terminal.`});let o=Pe(e.noEnhancedKeys),i=o.kittyKeyboard!==void 0,s=We(process.env),a=qe(s)?.name??s,[{render:l},{createElement:c},{KeyProbe:p}]=await Promise.all([import("ink"),import("react"),import("./KeyProbe-
|
|
45
|
-
delivery reads the channel back out of the key.`;function
|
|
44
|
+
${i.slice(s+1)}`}async function Ct(e={}){let r=AA({plain:!1,json:!1,oneShot:!1});if(r.mode!=="rich")throw new t({code:"cli_keys_needs_terminal",message:"The key probe needs a terminal — it has nothing to read on a pipe.",hint:`Not one here (${r.because}). Run it in the terminal whose keys you want to inspect; there is no scripted form, because the answer is a property of that terminal.`});let o=Pe(e.noEnhancedKeys),i=o.kittyKeyboard!==void 0,s=We(process.env),a=qe(s)?.name??s,[{render:l},{createElement:c},{KeyProbe:p}]=await Promise.all([import("ink"),import("react"),import("./KeyProbe-n5p1w903.js")]),g=()=>{},m=new Promise((k)=>{g=k}),w=Ge();F(()=>{w.close()}),pA(),process.stdout.write(SA);let b=l(c(p,{columns:_e(process.stdout.columns,De),asked:i,terminal:a,takeRaw:w.takeRaw,correctKeys:w.correct,onDone:g}),{exitOnCtrlC:!1,...o});return F(()=>b.unmount()),await m,b.unmount(),w.close(),je(),await gA(),n}var Fo=24,wn=22;function bn(e){let r=e.args.map((o)=>{let i=o.variadic===!0?`${o.name}...`:o.name;return o.required?`<${i}>`:`[${i}]`}).join(" ");return`${A.slug} ${e.name}${r===""?"":` ${r}`}`}function jt(e){let r=e.placeholder===void 0?`--${e.name}`:`--${e.name} <${e.placeholder}>`,o=e.short===void 0?r:`-${e.short}, ${r}`,i=e.defaultHelp===void 0?"":` (default ${e.defaultHelp})`;return` ${o.padEnd(Fo-1)} ${e.help}${i}`}var Kt=`Session keys are {channel}:{peerId}[:{thread}] | A bare word is refused, because outbound
|
|
45
|
+
delivery reads the channel back out of the key.`;function Lo(e){let r=[];for(let o of e.args){if(o.choices===void 0||o.choices.length===0)continue;let i=Math.max(...o.choices.map((s)=>s.value.length))+2;r.push("",`${o.name}:`);for(let s of o.choices)r.push(` ${s.value.padEnd(i)}${s.help}`)}return r}function $n(e){if(e!==void 0){let o=[e.summary,"","usage:",` ${bn(e)} [flags]`,...Lo(e),"","flags:",...tn(e).map(jt)];if(e.flags.some((i)=>i.name==="session"))o.push("",Kt);return`${o.join(`
|
|
46
46
|
`)}
|
|
47
|
-
`}let r=Math.max(...eA.map((o)=>bn(o).length))+2;return`${[`${A.name} — a lightweight, model-agnostic agent runtime`,"","usage:",...eA.map((o)=>` ${bn(o).padEnd(r)}${o.summary}`),` ${A.slug} --version`,` ${A.slug} --help`,"",`Per-command flags: ${A.slug} <command> --help`,"","global flags:",...
|
|
47
|
+
`}let r=Math.max(...eA.map((o)=>bn(o).length))+2;return`${[`${A.name} — a lightweight, model-agnostic agent runtime`,"","usage:",...eA.map((o)=>` ${bn(o).padEnd(r)}${o.summary}`),` ${A.slug} --version`,` ${A.slug} --help`,"",`Per-command flags: ${A.slug} <command> --help`,"","global flags:",...An.map(jt),"",Kt,"","environment:",` ${`${A.envPrefix}BRAND`.padEnd(wn)}rebrand every derived path, env prefix, and apiVersion`,` ${"NO_COLOR".padEnd(wn)}set to anything to force plain output`,` ${"DEBUG".padEnd(wn)}print stack traces on failure`].join(`
|
|
48
48
|
`)}
|
|
49
|
-
`}var
|
|
49
|
+
`}var Uo=[{name:"ExperimentalWarning",contains:"SQLite is an experimental feature",because:"node:sqlite is a declared soft-compat target with an adapter and a dual-runtime test suite; the experimental status is the reason the adapter exists, not news about this run."}];function Mo(e,r){return Uo.some((o)=>o.name===e&&r.includes(o.contains))}function Do(e){return e.execArgv.includes("--trace-warnings")||(e.nodeOptions??"").includes("--trace-warnings")}var Wt;function qt(e={execArgv:process.execArgv,nodeOptions:process.env.NODE_OPTIONS}){if(Wt)return;if(Do(e))return;let r=process.emitWarning;Wt=r,process.emitWarning=(o,...i)=>{let s=typeof o==="string"?Go(i):o.name,a=typeof o==="string"?o:o.message;if(Mo(s,a))return;Reflect.apply(r,process,[o,...i])}}function Go(e){let r=e[0];return typeof r==="string"?r:"Warning"}var Bt=96;async function Jt(e){let r=await Ie.create({agents:[e.manifestPath],store:e.store??G(),toolProviders:Ae,modelTransports:me,mediaProviders:ce,builtInPlugins:pe,pluginRoot:oe(),scriptRunner:le(),channels:se,env:R([e.manifestPath])});try{let o=r.list()[0];if(o===void 0)throw Error("The manifest produced no agent.");if(e.action==="rebuild"){let p=await o.rebuildMemory();if(e.json===!0)return process.stdout.write(`${JSON.stringify(p,null,2)}
|
|
50
50
|
`),n;return process.stdout.write(d([{label:"passages",value:String(p.passages)},{label:"files read",value:String(p.indexed.length)},{label:"conversations",value:p.sessions.length===0?"none indexed — memory.includeHistory is off, or there are no sessions yet":String(p.sessions.length)},{label:"shared scopes",value:p.scopes.length===0?"none":p.scopes.join(", ")},{label:"dropped",value:p.dropped.length===0?"":p.dropped.join(", ")}])),process.stdout.write(p.indexed.length===0&&p.sessions.length===0?"\nNothing to index. Memory files are written by `memory_write` and by hand, and conversations are indexed at the end of each turn.\n":`
|
|
51
51
|
Read: ${[...p.indexed,...p.sessions].join(", ")}
|
|
52
52
|
`),n}let i=e.query??"";if(i.trim()==="")return process.stderr.write(`memory search needs something to search for.
|
|
@@ -54,32 +54,32 @@ Read: ${[...p.indexed,...p.sessions].join(", ")}
|
|
|
54
54
|
`),n;if(process.stdout.write(d([{label:"corpus",value:`${s.corpus} passage${s.corpus===1?"":"s"}`},{label:"threshold",value:s.threshold.toFixed(2)},{label:"above it",value:String(a.length)}])),s.corpus===0)return process.stdout.write("\nNothing indexed. `memory_write` fills the carried file, and eviction moves older notes into the memory directory.\n"),n;if(l.length===0)return process.stdout.write(`
|
|
55
55
|
Nothing ${e.all===!0?"matched":`scored above ${s.threshold.toFixed(2)}`}. Try --all, or fewer words: a term present in more than half the corpus is dropped as uninformative.
|
|
56
56
|
`),n;let c=Math.max(6,...l.map((p)=>Vt(p,s.carried).length));process.stdout.write(`
|
|
57
|
-
${
|
|
58
|
-
`);for(let p of l){let g=p.score>=s.threshold?" ":"·";process.stdout.write(`${
|
|
57
|
+
${te("SCORE",6)} ${te("LEXICAL",7)} ${te("COVER",5)} ${te("SOURCE",c)} ${te("LEARNED",10)} PASSAGE
|
|
58
|
+
`);for(let p of l){let g=p.score>=s.threshold?" ":"·";process.stdout.write(`${te(p.score.toFixed(3),6)} ${te(p.lexical.toFixed(3),7)} ${te(p.coverage.toFixed(2),5)} ${te(Vt(p,s.carried),c)} ${te(p.passage.at.slice(0,10),10)} ${g}${Bo(p.passage.text)}
|
|
59
59
|
`)}if(e.all===!0&&a.length<l.length)process.stdout.write(`
|
|
60
60
|
${l.length-a.length} shown below the threshold; a turn would not inject those.
|
|
61
61
|
`);if(s.carried!==void 0&&l.some((p)=>p.passage.source===s.carried))process.stdout.write(`
|
|
62
62
|
${s.carried} is carried in every prompt already, so it is searchable here and deliberately absent from the retrieved block.
|
|
63
|
-
`);return n}finally{await r.stop("cli-exit")}}function
|
|
64
|
-
`)}function ss(e,r,o){return`measured ${r} against ${e} — ${o}`}function rs(e,r){let o=Math.max(1,e),i=0,s=0;while(o<r)i+=o,s+=1,o*=2;return i+=r,s+=1,{requests:s,tokens:i}}var
|
|
65
|
-
Reply with the single character x.`;try{let s=await is(e,r,i),a=await is(e,r,i);return ns(s,a,os)}catch(s){return o.push(`the caching probe failed: ${s instanceof Error?s.message:String(s)}`),{supported:void 0,detail:"the probe did not complete"}}}async function
|
|
63
|
+
`);return n}finally{await r.stop("cli-exit")}}function Bo(e){let r=e.replace(/\s+/g," ").trim();return r.length<=Bt?r:`${r.slice(0,Bt-1)}…`}function te(e,r){return e.length>=r?e:e+" ".repeat(r-e.length)}function Vt(e,r){return e.passage.source===r?`${e.passage.source} *`:e.passage.source}var Vo=["context_length","context_window","max_context_length","max_model_len"],Yo=[["prompt_cache_hit_tokens",(e)=>e.prompt_cache_hit_tokens],["prompt_tokens_details.cached_tokens",(e)=>{let r=e.prompt_tokens_details;return Be(r)?r.cached_tokens:void 0}],["cache_read_input_tokens",(e)=>e.cache_read_input_tokens]];function Be(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function Sn(e){if(typeof e!=="number"||!Number.isFinite(e))return;if(!Number.isInteger(e)||e<=0)return;return e}function Qt(e,r){let o=Be(e)?e.data:void 0,i=Array.isArray(o)?o:Array.isArray(e)?e:void 0;if(i===void 0)return;let s=r.toLowerCase();for(let a of i){if(!Be(a))continue;let l=typeof a.id==="string"?a.id.toLowerCase():void 0;if(l===void 0)continue;if(!(l===s||l.endsWith(`/${s}`)||s.endsWith(`/${l}`)))continue;for(let p of Vo){let g=Sn(a[p]);if(g!==void 0)return{technique:"metadata",tokens:g,bound:"ceiling",detail:`GET /models published ${p}: ${g}`}}return}return}function Rn(e){let r=[/(?:max_?tokens|context[\s_]?(?:length|window))[^[\]]{0,40}\[\s*\d[\d_,]*\s*,\s*(\d[\d_,]*)\s*\]/i,/maximum context length is (\d[\d_,]*)/i,/max_?tokens[^.\d]{0,40}?(\d[\d_,]*)/i,/context (?:length|window)(?: of)? (?:is )?(\d[\d_,]*)/i,/maximum (?:sequence|model) length (?:is )?(\d[\d_,]*)/i],o=[];for(let i of r){let s=i.exec(e);if(s?.[1]===void 0)continue;let a=Sn(Number(s[1].replaceAll(/[,_]/g,"")));if(a!==void 0)o.push(a)}if(o.length===0)return;return Math.max(...o)}function Yt(e){if(!Be(e))return;let r=Sn(e.prompt_tokens)??0;for(let[o,i]of Yo){let s=i(e);if(typeof s==="number"&&Number.isFinite(s))return{cached:s,promptTokens:r,field:o}}return{cached:void 0,promptTokens:r,field:void 0}}function ns(e,r,o){if(e===void 0||r===void 0)return{supported:void 0,detail:"no usage came back, so the question was not answered"};if(r.field===void 0)return{supported:void 0,detail:"the endpoint reported usage with no cache field in it — unknown, not absent"};let i=r.cached??0;if(i>0)return{supported:!0,detail:`the second identical call reported ${i} cached of ${r.promptTokens} prompt tokens, via ${r.field}`};return{supported:!1,detail:`${r.field} came back 0 on an identical repeat of a ${o}-token prefix — evidence of no caching, not proof: a longer prefix may still hit`}}function Re(e){let r=e.filter((i)=>i.bound==="ceiling");return(r.length>0?r:e).reduce((i,s)=>i===void 0||s.tokens>i.tokens?s:i,void 0)}function ts(e,r,o){return[" {",` pattern: "${`${e.split(":")[0]}*`}",`," capabilities: {",` contextWindow: ${r.toLocaleString("en-US").replaceAll(",","_")},`,...o===void 0?[]:[` maxOutput: ${o.toLocaleString("en-US").replaceAll(",","_")},`]," // the other fields are unchanged — this row reports only what was measured"," },"," },"].join(`
|
|
64
|
+
`)}function ss(e,r,o){return`measured ${r} against ${e} — ${o}`}function rs(e,r){let o=Math.max(1,e),i=0,s=0;while(o<r)i+=o,s+=1,o*=2;return i+=r,s+=1,{requests:s,tokens:i}}var ei=2000000000,os=1024,as=8192,ds=2097152;function ls(e){return"context ".repeat(Math.max(1,e))}async function xe(e){let r=await e.text();try{return{text:r,json:JSON.parse(r)}}catch{return{text:r,json:void 0}}}function cs(e,r){if(typeof e==="object"&&e!==null){let o=e,i=o.error;if(typeof i==="string")return i;if(typeof i==="object"&&i!==null){let s=i.message;if(typeof s==="string")return s}if(typeof o.message==="string")return o.message}return r}async function si(e,r,o){try{let i=await r(e.models,{headers:e.headers});if(!i.ok){o.push(`GET /models answered ${i.status}`);return}let{json:s}=await xe(i),a=Qt(s,e.modelId);if(a===void 0)o.push("GET /models published no context length");return a}catch(i){o.push(`GET /models failed: ${i instanceof Error?i.message:String(i)}`);return}}async function ri(e,r,o){try{let i=await r(e.chat,{method:"POST",headers:{"content-type":"application/json",...e.headers},body:JSON.stringify({model:e.modelId,messages:[{role:"user",content:"hi"}],max_tokens:ei})}),{text:s,json:a}=await xe(i);if(i.ok)return o.push("the endpoint accepted an impossible max_tokens rather than refusing it — it clamps silently, so this technique cannot measure it"),{window:void 0,outputCeiling:void 0};let l=cs(a,s.slice(0,400)),c=Rn(l);if(c===void 0)return o.push(`the refusal named no number: ${l.slice(0,160)}`),{window:void 0,outputCeiling:void 0};let p=/max_?tokens/i.test(l);return{window:p?void 0:{technique:"refusal",tokens:c,bound:"ceiling",detail:`refused an over-range request naming ${c}`},outputCeiling:p?c:void 0}}catch(i){return o.push(`the over-range request failed: ${i instanceof Error?i.message:String(i)}`),{window:void 0,outputCeiling:void 0}}}async function is(e,r,o){let i=await r(e.chat,{method:"POST",headers:{"content-type":"application/json",...e.headers},body:JSON.stringify({model:e.modelId,messages:[{role:"user",content:o}],max_tokens:1})});if(!i.ok)return;let{json:s}=await xe(i),a=typeof s==="object"&&s!==null?s.usage:void 0;return Yt(a)}async function oi(e,r,o){let i=`${ls(os)}
|
|
65
|
+
Reply with the single character x.`;try{let s=await is(e,r,i),a=await is(e,r,i);return ns(s,a,os)}catch(s){return o.push(`the caching probe failed: ${s instanceof Error?s.message:String(s)}`),{supported:void 0,detail:"the probe did not complete"}}}async function ii(e,r,o){let i=as,s=0;while(i<=ds){let a;try{a=await r(e.chat,{method:"POST",headers:{"content-type":"application/json",...e.headers},body:JSON.stringify({model:e.modelId,messages:[{role:"user",content:ls(i)}],max_tokens:1})})}catch(g){o.push(`the search stopped at ${i}: ${g instanceof Error?g.message:String(g)}`);break}if(a.ok){let{json:g}=await xe(a),m=typeof g==="object"&&g!==null?g.usage:void 0,w=typeof m==="object"&&m!==null?m.prompt_tokens:void 0;s=typeof w==="number"&&Number.isFinite(w)?w:s,i*=2;continue}let{text:l,json:c}=await xe(a),p=Rn(cs(c,l.slice(0,400)));if(p!==void 0)return{technique:"search",tokens:p,bound:"ceiling",detail:`refused a ${i}-token prompt and named ${p}`};break}if(s===0)return;return{technique:"search",tokens:s,bound:"floor",detail:`accepted a prompt the endpoint counted at ${s} tokens; nothing above it named a number`}}function ai(e,r){let o=Re(e.findings),i=o===void 0?"nothing measured — every technique came back empty":`${o.tokens} (${o.bound}) · ${o.detail}`,s=o===void 0?"":o.tokens===e.declared?"matches what is configured":o.bound==="ceiling"&&o.tokens>e.declared?`configured value is ${e.declared}, which is ${(o.tokens-e.declared).toLocaleString("en-US")} tokens short`:`configured value is ${e.declared}`,a=e.cache.supported===void 0?`unknown — ${e.cache.detail}`:e.cache.supported?`yes — ${e.cache.detail}`:`no — ${e.cache.detail}`;return[_(` ${e.role} · ${e.modelId}`),d([{label:"endpoint",value:e.baseUrl},{label:"configured",value:`${e.declared} (${e.declaredSource})`},{label:"measured",value:i},{label:"agreement",value:s},{label:"output cap",value:e.outputCeiling===void 0?"":String(e.outputCeiling)},{label:"prompt cache",value:a},...r===void 0?[]:[{label:"price",value:`$${r}/Mtok input, as given`}]]),...e.failures.length===0?[]:[" what did not answer:",...e.failures.map((l)=>` · ${l}`)],...o===void 0||o.bound!=="ceiling"?[]:[""," registry row, if this model should ship with it:",ts(e.modelId,o.tokens,e.outputCeiling).split(`
|
|
66
66
|
`).map((l)=>` ${l}`).join(`
|
|
67
67
|
`)]].join(`
|
|
68
|
-
`)}async function us(e){let r=e.fetch??globalThis.fetch;try{let o=
|
|
68
|
+
`)}async function us(e){let r=e.fetch??globalThis.fetch;try{let o=J(e.manifestPath,{env:R([e.manifestPath])}),{manifest:i}=o,s=yA(i).filter((p)=>p.role===p.configuredAs),a=!1;if(e.window){let p=rs(as,ds),g=p.tokens*s.length,m=e.price===void 0?"":` ≈ $${(g/1e6*e.price).toFixed(2)}`;process.stdout.write(`--window will send up to ${p.requests} requests per role, about ${g.toLocaleString("en-US")} input tokens in total${m}.
|
|
69
69
|
That is an upper bound: the search stops at the first refusal, and the refused request generates nothing.
|
|
70
70
|
Tokens rather than dollars unless --price says otherwise: a price table in this repo would be wrong within a quarter.
|
|
71
|
-
`),a=e.yes||await
|
|
71
|
+
`),a=e.yes||await bt("spend it?"),process.stdout.write(a?`
|
|
72
72
|
`:`
|
|
73
73
|
Skipping the search. The free techniques below still run — re-run with --window --yes to search without asking.
|
|
74
74
|
|
|
75
75
|
`)}let l=[];for(let p of s){let g=i.model[p.role]??i.model.main;if(g.baseUrl===void 0){process.stdout.write(`model.${p.role} uses the ${g.api??"chat-completions"} transport, which this probe does not speak. Its window comes from the capability registry: ${p.window.contextWindow.toLocaleString("en-US")} tokens (${p.window.source}).
|
|
76
|
-
`);continue}let m={chat:io(g.baseUrl),models:
|
|
77
|
-
`),n;let c=e.write?await
|
|
76
|
+
`);continue}let m={chat:io(g.baseUrl),models:Jr(g.baseUrl),headers:qr(g.apiKeyEnv,o.env,`model.${p.role}`),modelId:g.id},w=[],b=[],k=await si(m,r,w);if(k!==void 0)b.push(k);let C=await ri(m,r,w);if(C.window!==void 0)b.push(C.window);let P=await oi(m,r,w);if(a){let x=await ii(m,r,w);if(x!==void 0)b.push(x)}l.push({role:p.role,modelId:g.id,baseUrl:g.baseUrl,declared:p.window.contextWindow,declaredSource:p.window.source,findings:b,cache:P,outputCeiling:C.outputCeiling,failures:w})}if(e.json)return process.stdout.write(`${JSON.stringify({agent:i.id,probes:l},null,2)}
|
|
77
|
+
`),n;let c=e.write?await di(o.path,l):{written:[],refused:[]};return process.stdout.write([`probed ${i.id} · ${l.length} role${l.length===1?"":"s"}`,...l.map((p)=>ai(p,e.price)),"",...e.write?[...c.written.length===0?[]:[" written to the manifest:",...c.written.map((p)=>` ${p}`)],...c.refused.length===0?[]:[" not written:",...c.refused.map((p)=>` ${p}`)]," A restart picks it up — an agent's settings are fixed for its lifetime."]:[li(l)],""].join(`
|
|
78
78
|
`)),n}catch(o){if(f(o))return process.stderr.write(`${o.format()}
|
|
79
|
-
`),u;throw o}}async function
|
|
80
|
-
`)}import{existsSync as
|
|
81
|
-
`),{dir:i,commit:c}}function
|
|
82
|
-
`).slice(-3).join(" ");if(o)return new t({code:"plugin_fetch_timeout",message:`${e.name}: git did not finish in time`,hint:`Check the network and try again — the partial fetch was discarded, so whatever was installed as ${e.name} is untouched.`});return new t({code:"plugin_fetch_failed",message:`${e.name}: could not clone ${e.url}${i.length===0?"":` — ${i}`}`,hint:"A private repository needs a credential helper git can use without prompting. Check the URL and the --ref; nothing was written."})}async function
|
|
79
|
+
`),u;throw o}}async function di(e,r){let o=[],i=[];for(let s of r){let a=Re(s.findings);if(a===void 0){i.push(`${s.role}: nothing measured`);continue}if(a.bound!=="ceiling"){i.push(`${s.role}: ${a.tokens} is a floor, not a window — the endpoint accepted it and never said what it would refuse`);continue}if(a.tokens===s.declared){i.push(`${s.role}: already ${a.tokens}, nothing to change`);continue}await Ve({file:e,path:["model",s.role,"capabilities","contextWindow"],value:a.tokens}),o.push(`${s.role}: ${s.declared} → ${a.tokens}`)}return{written:o,refused:i}}function li(e){let r=e.filter((a)=>Re(a.findings)?.bound==="ceiling");if(r.length===0)return" Nothing measured a ceiling, so there is nothing worth writing down. A floor is not a window.";let o=r[0],i=o===void 0?void 0:Re(o.findings);if(o===void 0||i===void 0)return"";let s=new URL(o.baseUrl).host;return[" --write records this. By hand, it is one line under the role, and the comment is the point:",` contextWindow: ${i.tokens}`,` # ${ss(s,new Date().toISOString().slice(0,10),i.detail)}`].join(`
|
|
80
|
+
`)}import{existsSync as vs,rmSync as gi}from"node:fs";import{resolve as yi}from"node:path";var ci={debug:()=>{},info:()=>{},warn:()=>{},error:()=>{}};function ms(e){if(e===null||typeof e!=="object")return!1;let r=e.kind;return r==="network"||r==="env"||r==="fs"||r==="exec"||r==="store"}async function fs(e,r={}){let o=[],i=[],s=r.hostVersion??Je,a=(b,k,C)=>{o.push({level:"error",check:b,message:k,hint:C})},l=(b,k,C)=>{o.push({level:"warning",check:b,message:k,hint:C})};if(typeof e.name!=="string"||e.name==="")a("name","The plugin has no name.","`name` is how events, errors and `plugins` output refer to this plugin. It must be unique within a runtime.");if(or(e.version,"*")===void 0)a("version",`\`version\` is ${JSON.stringify(e.version)}, which is not a plain semver triple.`,"Write it as `major.minor.patch`. It is reported verbatim in `plugin.loaded`, and a version nobody can compare is a version nobody can act on.");let c=or(s,e.dispachApi);if(c===void 0)a("dispachApi",`\`dispachApi\` is ${JSON.stringify(e.dispachApi)}, which the host cannot check.`,"Supported: `*`, an exact version, `^`, `~`, space-separated comparators, and `||`. A range the host cannot parse is refused rather than assumed satisfied, so this plugin would not load.");else if(!c)l("dispachApi",`\`dispachApi\` ${e.dispachApi} does not admit this host (${s}).`,"Correct if you are testing against a host you do not support. A warning rather than an error, because running the suite on a newer host than the plugin targets is a normal thing to do.");if(e.dispachApi.trim()==="*")l("dispachApi","`dispachApi` is `*`, which accepts every host version including ones that do not exist yet.","Narrow it to the range you have actually tested. A plugin that never refuses to load is a plugin that fails at runtime instead, somewhere else, with nothing pointing back at the skew.");for(let[b,k]of(e.permissions??[]).entries())if(!ms(k))a("permissions",`\`permissions[${b}]\` is not one of the declared kinds.`,"Kinds are network, env, fs, exec and store. Advisory in v1 — but authors who declare accurately before enforcement lands are the ones who will not have to scramble afterwards.");let p=r.config??{};if(e.configSchema!==void 0){let b=e.configSchema.safeParse(p);if(b.success)p=b.data;else l("configSchema","The schema refused the config this suite passed.","Pass a valid `config` through `conformance(plugin, { config })`. The default is `{}`, which a schema with required fields correctly rejects.")}let g={defineChannel:(b)=>i.push(`channel:${b}`),defineToolProvider:(b)=>i.push(`toolProvider:${b}`),defineModelTransport:(b)=>i.push(`modelTransport:${b}`),defineMediaProvider:(b)=>i.push(`mediaProvider:${b}`),defineScriptRunner:()=>i.push("scriptRunner"),use:(b)=>i.push(`middleware:${b.name}`),defineRoute:(b)=>i.push(`route:${b.method} ${b.path}`),config:p,agentId:"conformance",paths:{workspace:"/nonexistent/conformance",state:"/nonexistent/conformance/.state",manifest:"/nonexistent/conformance/agent.yaml"},env:{},logger:ci,events:new nr({runtimeId:"conformance"})},m=performance.now();try{await e.setup(g)}catch(b){a("setup",`\`setup\` threw: ${b instanceof Error?b.message:String(b)}`,"`setup` registers capabilities and does no work, so it must succeed with an empty environment and a workspace that does not exist. Read a token in the factory you register, not here — that runs only when an agent actually uses the capability.")}let w=Math.round((performance.now()-m)*100)/100;if(w>rr)a("setup budget",`\`setup\` took ${w} ms against a ${rr} ms budget.`,"Move the work into the factory you register. A channel connects in `start()`, which runs after readiness; a provider resolves from its cache at boot and refreshes afterwards. Hard rule 4: no network I/O before `runtime.ready`.");if(i.length===0)l("setup","`setup` registered nothing.","A plugin that registers no channel, tool provider, script runner or middleware extends nothing. Every `define*` and `use` call is recorded, so registering something and still seeing this means the registration did not run — check for a branch in `setup` that skipped it.");return{ok:o.every((b)=>b.level!=="error"),findings:o,registered:i,setupMs:w,declared:{name:e.name,version:e.version,apiRange:e.dispachApi,permissions:(e.permissions??[]).filter(ms)}}}import{existsSync as ge,mkdirSync as ui,readdirSync as mi,readFileSync as Tn,renameSync as ps,rmSync as he,writeFileSync as fi}from"node:fs";import{join as Q}from"node:path";var gs=".origin.json";function pi(e){let r=Q(e,gs);if(!ge(r))return;try{return JSON.parse(Tn(r,"utf8"))}catch{return}}function On(e){let r=oe(e),o;try{o=mi(r)}catch{return[]}let i=[];for(let s of o.sort()){if(s.startsWith(".")||s.endsWith(".partial"))continue;let a=Q(r,s);if(!ge(Q(a,"package.json"))&&!ge(Q(a,"index.js")))continue;let l=pi(a);i.push({name:s,dir:a,...l===void 0?{}:{origin:l}})}return i}function ys(e){let r=Q(e,"package.json");if(!ge(r))return Q(e,"index.js");try{let o=JSON.parse(Tn(r,"utf8"));if(typeof o.main==="string"&&o.main!=="")return Q(e,o.main)}catch{}return Q(e,"index.js")}function ws(e){let r=Q(e,"package.json");if(!ge(r))return;let o;try{o=JSON.parse(Tn(r,"utf8"))}catch(a){return`its package.json is not valid JSON (${a instanceof Error?a.message:String(a)})`}let i=Object.keys(o.dependencies??{});if(i.length===0)return;if(ge(Q(e,"node_modules")))return;let s=i.slice(0,4).join(", ");return`it declares ${i.length} runtime ${i.length===1?"dependency":"dependencies"} (${s}${i.length>4?", …":""}) and ships no node_modules`}function bs(e,r){let i=((r??e).split("/").filter((s)=>s.length>0).pop()??"").replace(/\.git$/,"");if(!Tt(i))throw new t({code:"plugin_name_invalid",message:`${JSON.stringify(i||e)} is not a usable plugin directory name`,hint:"A plugin is installed into one lowercase path segment — letters, digits and single hyphens — because that segment is what the manifest's `plugins:` entry names. Pass `--name <name>` to choose it."});return i}async function $s(e,r={}){let o=r.git??kr,i=pr(e.name,r.env),s=`${i}.partial`;ui(oe(r.env),{recursive:!0}),he(s,{recursive:!0,force:!0});let a=await o(["clone","--depth","1","--single-branch",...e.ref===void 0?[]:["--branch",e.ref],e.url,s]);if(a.code!==0)throw he(s,{recursive:!0,force:!0}),hi(e,a.stderr,a.timedOut===!0);let l=await o(["rev-parse","--short","HEAD"],s),c=l.code===0?l.stdout.trim():"unknown",p=e.path===void 0?s:Q(s,e.path);if(!ge(p))throw he(s,{recursive:!0,force:!0}),new t({code:"plugin_path_missing",message:`${e.url} has no ${e.path} at ${c}`,hint:"The path comes from the URL you pasted — .../tree/<branch>/<subdir>. Check it against the repository, or pass the repository URL on its own."});he(Q(p,".git"),{recursive:!0,force:!0});try{await r.inspect?.(p)}catch(m){throw he(s,{recursive:!0,force:!0}),m}if(he(i,{recursive:!0,force:!0}),p===s)ps(s,i);else ps(p,i),he(s,{recursive:!0,force:!0});let g={url:e.url,...e.ref===void 0?{}:{ref:e.ref},...e.path===void 0?{}:{path:e.path},commit:c,fetchedAt:new Date().toISOString()};return fi(Q(i,gs),`${JSON.stringify(g,null,4)}
|
|
81
|
+
`),{dir:i,commit:c}}function hi(e,r,o){let i=r.trim().split(`
|
|
82
|
+
`).slice(-3).join(" ");if(o)return new t({code:"plugin_fetch_timeout",message:`${e.name}: git did not finish in time`,hint:`Check the network and try again — the partial fetch was discarded, so whatever was installed as ${e.name} is untouched.`});return new t({code:"plugin_fetch_failed",message:`${e.name}: could not clone ${e.url}${i.length===0?"":` — ${i}`}`,hint:"A private repository needs a credential helper git can use without prompting. Check the URL and the --ref; nothing was written."})}async function ks(e){switch(e.action){case"list":return await wi(e);case"add":return await Si(e);case"remove":return await Oi(e);default:throw new t({code:"cli_plugins_action_unknown",message:`plugins: ${JSON.stringify(e.action)} is not an action`,hint:`Actions are list, add and remove — \`${A.slug} plugins list <agent>\`.`})}}async function wi(e){let r=await Ie.create({agents:[e.manifestPath],toolProviders:Ae,modelTransports:me,mediaProviders:ce,builtInPlugins:pe,pluginRoot:oe(e.env),scriptRunner:le(),channels:se,env:R([e.manifestPath]),store:G(e.env),lease:!1});F(()=>r.stop("cli-exit"));let o=[...r.plugins.values()].flat(),i=On(e.env);if(e.json===!0)return process.stdout.write(`${JSON.stringify({plugins:o,installed:i,available:Lr},null,2)}
|
|
83
83
|
`),n;if(o.length===0){if(process.stdout.write(`No plugins. This binary can resolve these by name:
|
|
84
84
|
|
|
85
85
|
${Lr.map((c)=>` - "${c}"`).join(`
|
|
@@ -87,23 +87,23 @@ ${Lr.map((c)=>` - "${c}"`).join(`
|
|
|
87
87
|
|
|
88
88
|
Add a \`plugins:\` block to agent.yaml naming the ones you want, or fetch one with \`${A.slug} plugins add <agent> <repo>\`.
|
|
89
89
|
`),i.length>0)process.stdout.write(`
|
|
90
|
-
Installed in ${
|
|
90
|
+
Installed in ${oe(e.env)} and named by no agent:
|
|
91
91
|
${i.map((c)=>` - "${c.name}"`).join(`
|
|
92
92
|
`)}
|
|
93
|
-
`);return n}let s=o.map((c)=>({label:c.name,value:`${c.version} ${`${c.setupMs} ms`.padStart(9)}`,note:`${
|
|
93
|
+
`);return n}let s=o.map((c)=>({label:c.name,value:`${c.version} ${`${c.setupMs} ms`.padStart(9)}`,note:`${$i(c.spec,c.lookup,i)} — ${c.registered.length===0?"registered nothing":c.registered.join(", ")}`}));process.stdout.write(`${d(s)}
|
|
94
94
|
`);let a=o.filter((c)=>c.permissions.length>0);if(a.length>0){process.stdout.write(`
|
|
95
95
|
Declared access — advisory in v1, recorded and not enforced:
|
|
96
96
|
`);for(let c of a)for(let p of c.permissions)process.stdout.write(` ${c.name} ${p.kind} ${Es(p)}
|
|
97
97
|
`)}let l=i.filter((c)=>!o.some((p)=>p.spec===c.name));if(l.length>0)process.stdout.write(`
|
|
98
98
|
Also installed, named by no agent: ${l.map((c)=>c.name).join(", ")}
|
|
99
|
-
`);return n}function
|
|
100
|
-
`);let l,c=await
|
|
99
|
+
`);return n}function $i(e,r,o){if(r!=="installed")return r==="registry"?"built in":"imported";let i=o.find((s)=>s.name===e)?.origin;return i===void 0?"installed":`installed ${i.commit}`}function Es(e){switch(e.kind){case"network":return e.hosts.join(", ");case"env":return e.vars.join(", ");case"fs":return`${e.paths.join(", ")} (${e.mode})`;case"exec":return e.commands.join(", ");default:return e.tables.join(", ")}}async function Si(e){let r=e.rest?.[0];if(r===void 0||r==="")throw new t({code:"cli_plugins_add_needs_repo",message:"plugins add needs a repository",hint:`\`${A.slug} plugins add <agent> <owner/repo> [--ref v1.0.0]\`. A plugin is fetched with git — an owner/repo shorthand, a clone URL, the page URL you were reading (whose .../tree/<branch>/<subdir> is understood), or a local repository while you are writing one.`});let o=$o(r)?{url:yi(r.replace(/^file:\/\//,""))}:Zo(r),i=e.ref??o.ref,s=e.name===void 0?bs(o.url,o.path):Ei(e.name),a=On(e.env).find((w)=>w.name===s);if(a?.origin!==void 0&&a.origin.url!==o.url)throw new t({code:"plugin_name_taken",message:`A different plugin is already installed as "${s}" — from ${a.origin.url}`,hint:`Two repositories cannot share one directory, and the directory name is what a manifest's \`plugins:\` entry means. Pass \`--name <name>\`, or \`${A.slug} plugins remove <agent> ${s}\` first.`});process.stdout.write(`Fetching ${o.url}${i===void 0?"":` at ${i}`} as "${s}"…
|
|
100
|
+
`);let l,c=await $s({name:s,url:o.url,...i===void 0?{}:{ref:i},...o.path===void 0?{}:{path:o.path}},{...e.env===void 0?{}:{env:e.env},...e.git===void 0?{}:{git:e.git},inspect:async(w)=>{let b=ws(w);if(b!==void 0)throw new t({code:"plugin_not_self_contained",message:`${s} cannot be loaded as fetched: ${b}`,hint:"A plugin is distributed as one self-contained bundle. Nothing is installed while this runtime runs (hard rule 5), so a declared dependency would simply be missing at boot. Ask the author to bundle their dependencies, or commit node_modules in the distribution repository."});let k=ys(w);if(!vs(k))throw new t({code:"plugin_entry_missing",message:`${s} has no entry file — ${k.slice(w.length+1)} is not in the repository`,hint:"A plugin directory is entered through the `main` its package.json names, defaulting to index.js. A distribution repository commits its built entry file; a source checkout does not, which is usually what this means."});let C=await Ri(s,k);if(l=await fs(C),!l.ok)throw new t({code:"plugin_not_conformant",message:`${l.declared.name} does not meet the plugin contract:
|
|
101
101
|
${l.findings.filter((P)=>P.level==="error").map((P)=>` ${P.check}: ${P.message}`).join(`
|
|
102
|
-
`)}`,hint:`This is the same suite the plugin's own author runs — \`conformance()\` from ${A.packageScope}/core/testing. Nothing was installed. Report it upstream with the checks named above.`});if(lo(
|
|
102
|
+
`)}`,hint:`This is the same suite the plugin's own author runs — \`conformance()\` from ${A.packageScope}/core/testing. Nothing was installed. Report it upstream with the checks named above.`});if(lo(j,l.declared.apiRange)!==!0)throw new t({code:"plugin_api_mismatch",message:`${l.declared.name} ${l.declared.version} supports host ${l.declared.apiRange}, and this host is ${j}`,hint:"The loader refuses this at boot, so installing it would write an entry that stops the agent starting. Look for a newer release of the plugin, or a `--ref` that matches this host."})}}),p=l?.declared;if(process.stdout.write(`
|
|
103
103
|
${p?.name??s} ${p?.version??"?"} (${c.commit})
|
|
104
104
|
from ${o.url}${i===void 0?"":` at ${i}`}
|
|
105
105
|
installed ${c.dir}
|
|
106
|
-
host range ${p?.apiRange??"?"} — this host is ${
|
|
106
|
+
host range ${p?.apiRange??"?"} — this host is ${j}
|
|
107
107
|
registers ${l===void 0||l.registered.length===0?"nothing":l.registered.join(", ")}
|
|
108
108
|
`),p!==void 0&&p.permissions.length>0)process.stdout.write(`
|
|
109
109
|
It declares access to:
|
|
@@ -118,32 +118,32 @@ plugin that declares nothing can still do anything this process can. Install plu
|
|
|
118
118
|
note: ${w.check} — ${w.message}
|
|
119
119
|
`);if(p!==void 0&&p.name!==s)process.stdout.write(`
|
|
120
120
|
note: it calls itself "${p.name}"; the \`plugins:\` entry is the directory, "${s}".
|
|
121
|
-
`);let m=await
|
|
121
|
+
`);let m=await Ii(e.manifestPath,s);return process.stdout.write(m==="already"?`
|
|
122
122
|
${e.manifestPath} already names "${s}".
|
|
123
123
|
`:`
|
|
124
124
|
Added "${s}" to the plugins: block in ${e.manifestPath}.
|
|
125
125
|
It loads at the next start — an agent's plugins are fixed for its lifetime, so restart a running one.
|
|
126
|
-
`),n}function
|
|
126
|
+
`),n}function Ei(e){if(Tt(e))return e;throw new t({code:"plugin_name_invalid",message:`--name ${JSON.stringify(e)} is not a usable plugin directory name`,hint:"Lowercase letters, digits and single hyphens. That segment is what the manifest's `plugins:` entry names, so it has to be a directory name and a YAML scalar at once."})}async function Ri(e,r){let o;try{o=await import(r)}catch(s){throw new t({code:"plugin_import_failed",message:`${e}: ${r} could not be imported — ${s instanceof Error?s.message:String(s)}`,hint:"A plugin is one self-contained ES module. A bare `require` or an unresolved import is what this usually means, and neither can be fixed by installing anything: nothing is installed while this runtime runs. Nothing was installed.",cause:s})}let i=o.default;if(i===null||typeof i!=="object")throw new t({code:"plugin_malformed",message:`${e}: ${r} has no object as its default export`,hint:`A plugin is the module's default export: an object with \`name\`, \`version\`, a \`${A.slug}Api\` host range and \`setup\`. A named export is not searched for and a factory function is not called, because a wrong guess produces a plugin that registers nothing and reports success.`});if(typeof i.setup!=="function")throw new t({code:"plugin_malformed",message:`${e}: the default export of ${r} has no \`setup\` function`,hint:"`setup(context)` is the whole extension surface — it registers channels, tool providers, a script runner or middleware, and does no work."});return i}async function Ii(e,r){let i=v(e).plugins??[];if(i.some((a)=>(typeof a==="string"?a:a.spec)===r))return"already";return await Ve({file:e,path:["plugins"],value:[...i.map((a)=>typeof a==="string"?a:a.spec),r]}),"written"}async function Oi(e){let r=e.rest?.[0];if(r===void 0||r==="")throw new t({code:"cli_plugins_remove_needs_name",message:"plugins remove needs a name",hint:`\`${A.slug} plugins remove <agent> <name>\`, where the name is the \`plugins:\` entry — \`plugins list <agent>\` prints them.`});let i=(v(e.manifestPath).plugins??[]).map((l)=>typeof l==="string"?l:l.spec);if(i.includes(r))await Ve({file:e.manifestPath,path:["plugins"],value:i.filter((l)=>l!==r)}),process.stdout.write(`Dropped "${r}" from ${e.manifestPath}.
|
|
127
127
|
Run \`${A.slug} validate ${e.manifestPath}\` — a channel or tool provider it supplied is now unresolved.
|
|
128
128
|
`);else process.stdout.write(`${e.manifestPath} does not name "${r}".
|
|
129
|
-
`);let s=pr(r,e.env);if(!
|
|
130
|
-
`),n;let a=
|
|
129
|
+
`);let s=pr(r,e.env);if(!vs(s))return process.stdout.write(`Nothing installed at ${s}.
|
|
130
|
+
`),n;let a=_i(r,e.manifestPath,e.env);if(a.length>0)return process.stdout.write(`Kept ${s} — still named by ${a.join(", ")}.
|
|
131
131
|
Remove it from those agents first, or delete the directory by hand.
|
|
132
|
-
`),n;return
|
|
133
|
-
`),n}function
|
|
134
|
-
`)}function D(e,r){return`${e} ${r}${e===1?"":"s"}`}import{homedir as
|
|
132
|
+
`),n;return gi(s,{recursive:!0,force:!0}),process.stdout.write(`Deleted ${s}.
|
|
133
|
+
`),n}function _i(e,r,o){let i=[];for(let s of z(o)){if(s.manifestPath===r)continue;try{if((v(s.manifestPath).plugins??[]).map((c)=>typeof c==="string"?c:c.spec).includes(e))i.push(s.ref)}catch{}}return i}import{existsSync as na,readdirSync as js,rmSync as Cn,statSync as Fs}from"node:fs";import{homedir as ta}from"node:os";import{join as Ls}from"node:path";function Rs(e){if(e.filesOnly||e.sharesIdWith.length===0)return[];let r=e.sharesIdWith.join(", ");return[{code:"cli_agent_id_shared",message:`"${e.ref}" has the manifest id "${e.agentId}", which is also used by ${r} — removing its data would take that agent's sessions and memory too.`,hint:`Change one manifest's id and run \`memory rebuild\` for it, or pass --files-only to delete just the ${e.ref} directory and leave the store alone.`}]}function xs(e){let r=[];if(e.running!==void 0)r.push({kind:"stop",detail:`stop pid ${e.running.pid} (${e.running.mode}) — gracefully, so anything it left running in the background is reaped`});if(!e.filesOnly&&e.service!==void 0)r.push({kind:"service",detail:`disable and unload ${e.service}`});if(!e.filesOnly){let o=e.footprint;if(r.push({kind:"store",detail:`delete ${D(o.sessions,"conversation")}, ${D(o.messages,"message")}, ${D(o.passages,"memory passage")}`}),e.logs.length>0)r.push({kind:"logs",detail:`delete ${D(e.logs.length,"log file")}`})}return r.push({kind:"directory",detail:`delete ${e.dir}`}),r}function Is(e){let r=e.footprint,o=[{label:"directory",value:`${e.dir}`,note:`${D(e.files.count,"file")}, ${ZA(e.files.bytes)}`}];if(e.agentId!==e.ref)o.push({label:"manifest id",value:e.agentId,note:"keys the store, logs and service"});if(e.filesOnly)o.push({label:"keeping",value:`${D(r.sessions,"conversation")}, ${D(r.passages,"memory passage")}, and the logs`,note:"--files-only"});else o.push({label:"sessions",value:`${D(r.sessions,"conversation")}, ${D(r.messages,"message")}, ${D(r.turns,"turn")}`},{label:"memory",value:`${D(r.passages,"passage")} from ${D(r.memorySources,"source")}`},{label:"outbox",value:r.outbox===0?"nothing queued":`${D(r.outbox,"delivery")}${r.outboxPending===0?"":`, ${r.outboxPending} not yet sent`}`,...r.outboxPending===0?{}:{note:"abandoned"}},{label:"schedules",value:r.schedules===0?"none":D(r.schedules,"schedule"),...r.schedules===0?{}:{note:"stops firing"}},{label:"logs",value:e.logs.length===0?"none":`${D(e.logs.length,"file")}, ${ZA(e.logs.reduce((i,s)=>i+s.bytes,0))}`},{label:"service",value:e.service??"not installed"});return o.push({label:"running",value:e.running===void 0?"no":`pid ${e.running.pid} (${e.running.mode})`}),d(o)}function Os(e){if(e.length===0)return"";return e.map((r)=>{let o=r.footprint,i=[];if(o.sessions>0)i.push(`${D(o.sessions,"conversation")}, ${D(o.messages,"message")}`);if(o.passages>0)i.push(`${D(o.passages,"memory passage")}`);if(o.outbox>0)i.push(`${D(o.outbox,"queued delivery")}`);if(o.schedules>0)i.push(`${D(o.schedules,"schedule")}`);if(o.lease)i.push("a stale lease");if(r.logs.length>0)i.push(`${D(r.logs.length,"log file")}, ${ZA(r.logs.reduce((s,a)=>s+a.bytes,0))}`);return` ${r.agentId} ${i.length===0?"rows with no detail":i.join(" · ")}`}).join(`
|
|
134
|
+
`)}function D(e,r){return`${e} ${r}${e===1?"":"s"}`}import{homedir as Ci}from"node:os";var Cs=12000,Ni=250;async function ze(e){if(e.manifestPath!==void 0)return await Ki(e,e.manifestPath);return await Di(e)}async function Ki(e,r){let o=ea(r),i=[];if(e.dryRun===!0){let c=await Ke(o,e.store);return process.stdout.write(`would stop 1 agent:
|
|
135
135
|
${y(`${o} — ${c===void 0?"not running; would be switched off for the next start":c.baseUrl===void 0?`pid ${c.pid} (${c.mode}), which serves no HTTP — would be signalled`:`pid ${c.pid} (${c.mode}) at ${c.baseUrl}, which would drop it and keep serving`}`)}
|
|
136
136
|
`),n}await Wo(o,!1,e.reason,e.store),i.push("switched off for the next start");let s=await Ke(o,e.store),a=!0;if(s===void 0)i.push("nothing was running");else if(s.baseUrl===void 0){let c=await Xe(s.pid,"SIGTERM");a=c||await Xe(s.pid,"SIGKILL",!0),i.push(c?`pid ${s.pid} stopped cleanly`:a?`pid ${s.pid} had to be killed`:`pid ${s.pid} would not stop — check it by hand`)}else{let c=await sA(s,`/v1/agents/${encodeURIComponent(o)}/stop`,e.reason===void 0?{}:{reason:e.reason},r);if(c.ok)i.push(`pid ${s.pid} dropped it and kept serving`);else if(c.status===409)a=!1,i.push(c.detail??"a turn is running");else if(c.status===401)a=!1,i.push(`pid ${s.pid} refused the request — set ${A.envPrefix}API_TOKEN to the server's token`);else a=!1,i.push(`pid ${s.pid} at ${s.baseUrl} could not be reached${c.detail===void 0?"":`: ${c.detail}`}`)}let l={agentId:o,service:!1,...s===void 0?{}:{pid:s.pid,mode:s.mode},stopped:a,note:i.join(" · ")};if(e.json===!0)process.stdout.write(`${JSON.stringify({stopped:[l]},null,2)}
|
|
137
137
|
`);else process.stdout.write(`${d([{label:o,value:a?"stopped":"NOT FULLY STOPPED",note:l.note}])}
|
|
138
138
|
`),process.stdout.write(`
|
|
139
139
|
Stays off across restarts. \`${A.slug} start ${o}\` switches it back on.
|
|
140
|
-
`);return a?n:u}async function
|
|
140
|
+
`);return a?n:u}async function Di(e){let r=e.platform??process.platform,o=r==="darwin"?Xt(r,{home:Ci(),uid:process.getuid?.()??0,envPrefix:A.envPrefix,...e.exec===void 0?{}:{exec:e.exec}}):void 0,i=await Bi(o,e.store);if(i.length===0)return process.stdout.write(e.json===!0?`${JSON.stringify({stopped:[]})}
|
|
141
141
|
`:`Nothing is running — no service is installed and no process holds an agent.
|
|
142
142
|
`),n;if(e.dryRun===!0)return process.stdout.write(`would stop ${i.length} ${i.length===1?"agent":"agents"}:
|
|
143
|
-
${i.map((a)=>y(
|
|
143
|
+
${i.map((a)=>y(Zi(a))).join(`
|
|
144
144
|
`)}
|
|
145
|
-
`),n;let s=[];for(let a of i)s.push(await
|
|
146
|
-
`);else{let a=s.map((l)=>({label:
|
|
145
|
+
`),n;let s=[];for(let a of i)s.push(await Qi(a,o));if(e.json===!0)process.stdout.write(`${JSON.stringify({stopped:s},null,2)}
|
|
146
|
+
`);else{let a=s.map((l)=>({label:Ns(l.agentId),value:l.stopped?"stopped":"STILL RUNNING",note:l.note}));if(process.stdout.write(`${d(a)}
|
|
147
147
|
`),s.some((l)=>l.service&&l.stopped))process.stdout.write(`
|
|
148
148
|
Services are disabled as well as unloaded, so they stay stopped across a reboot.
|
|
149
149
|
Start one again with \`${A.slug} daemon start <agent>\`.
|
|
@@ -151,8 +151,8 @@ Start one again with \`${A.slug} daemon start <agent>\`.
|
|
|
151
151
|
Something had to be killed rather than asked. A forced stop skips the runtime's own
|
|
152
152
|
cleanup, so a command the agent had left running in the background may still be alive —
|
|
153
153
|
\`ps\` will show it if so.
|
|
154
|
-
`)}return s.every((a)=>a.stopped)?n:u}async function
|
|
155
|
-
${
|
|
154
|
+
`)}return s.every((a)=>a.stopped)?n:u}async function Bi(e,r){let o=`${A.slug}.agent.`,i=new Map;for(let s of e?.labels(o)??[]){let a=s.slice(o.length);i.set(a,{agentId:a,service:!0})}try{let s=await de.open({path:r??G()});for(let a of await s.leases.all()){if(a.pid===process.pid||!V(a.pid))continue;i.set(a.agentId,{agentId:a.agentId,service:i.get(a.agentId)?.service===!0,pid:a.pid,mode:a.mode})}await s.close()}catch{}return[...i.values()].sort((s,a)=>s.agentId.localeCompare(a.agentId))}async function Qi(e,r){let o=[];if(e.service&&r!==void 0)try{r.stop(jo(A.slug,e.agentId)),o.push("service disabled and unloaded")}catch(a){o.push(`service could not be unloaded: ${a instanceof Error?a.message:String(a)}`)}if(e.pid===void 0)return{...e,stopped:!0,note:o.join(" · ")||"no process was running"};if(!V(e.pid))return{...e,stopped:!0,note:o.join(" · ")||`pid ${e.pid} exited`};if(await Xe(e.pid,"SIGTERM"))return o.push(`pid ${e.pid} stopped cleanly`),{...e,stopped:!0,note:o.join(" · ")};let s=await Xe(e.pid,"SIGKILL",!0);return o.push(s?`pid ${e.pid} did not stop in ${Math.round(Cs/1000)}s and was killed`:`pid ${e.pid} would not stop, even killed — check it by hand`),{...e,stopped:s,forced:!0,note:o.join(" · ")}}async function Xe(e,r,o=!1){try{process.kill(o?-e:e,r)}catch(s){if(s.code==="ESRCH")return!0;if(o)try{process.kill(e,r)}catch{return!V(e)}}let i=Date.now()+(r==="SIGKILL"?3000:Cs);while(Date.now()<i){if(!V(e))return!0;await new Promise((s)=>setTimeout(s,Ni))}return!V(e)}function Zi(e){let r=[];if(e.service)r.push("background service");if(e.pid!==void 0)r.push(`pid ${e.pid}${e.mode===void 0?"":` (${e.mode})`}`);return`${Ns(e.agentId)} — ${r.join(", ")}`}function Ns(e){return e===LA?"(host, no agents)":e}function ea(e){let r=v(e);if(r.id===void 0||r.id==="")throw new t({code:"cli_stop_agent_id_missing",message:`${e} declares no id, so there is nothing to match a running agent against.`,hint:`Add \`id: <name>\` to the manifest, or run \`${A.slug} stop\` with no argument to stop everything.`});return r.id}async function Ks(e){let r=await de.open({path:e.store??G()});try{if(e.prune===!0)return await oa(e,r);if(e.all===!0)return await ra(e,r);if(e.ref===void 0)throw new t({code:"cli_remove_needs_agent",message:"remove needs an agent.",hint:`\`${A.slug} remove <name>\` takes a sandbox agent's name — the ones \`${A.slug} run\` lists. \`--prune\` clears data no agent claims; \`--all\` removes every agent.`});return await sa(e.ref,e,r)}finally{await r.close()}}async function sa(e,r,o){let i=await Ms(e,r,o),s=Rs(i);if(s.length>0){let c=s[0];throw new t({code:c.code,message:c.message,hint:c.hint})}let a=xs(i),l=`${_(`removing ${e} will:`,!0)}
|
|
155
|
+
${Is(i)}
|
|
156
156
|
|
|
157
157
|
${a.map((c)=>y(c.detail)).join(`
|
|
158
158
|
`)}
|
|
@@ -161,7 +161,7 @@ ${a.map((c)=>y(c.detail)).join(`
|
|
|
161
161
|
Nothing was deleted — this was --dry-run.
|
|
162
162
|
`),n;if(process.stdout.write(l),!await Nn(r,e,"type the agent's name to confirm:"))return process.stdout.write(`
|
|
163
163
|
Nothing was deleted.
|
|
164
|
-
`),n;return await
|
|
164
|
+
`),n;return await Us(i,r,o)}async function Us(e,r,o){let i=[];if(e.running!==void 0||!e.filesOnly&&e.service!==void 0){if(await ze({manifestPath:e.manifestPath,...r.exec===void 0?{}:{exec:r.exec},...r.platform===void 0?{}:{platform:r.platform}})!==n)return process.stderr.write(`
|
|
165
165
|
Stopping ${e.ref} did not succeed, so nothing was deleted. Its directory and data are untouched.
|
|
166
166
|
hint: check what is still running with \`${A.slug} stop --dry-run\`, then run remove again.
|
|
167
167
|
`),u;i.push({label:"stopped",value:e.ref})}if(!e.filesOnly&&e.service!==void 0){let s=Ds(r);try{s?.uninstall(e.service),i.push({label:"service",value:`${e.service} removed`})}catch(a){i.push({label:"service",value:`${e.service} could NOT be removed`,note:a instanceof Error?a.message:String(a)})}}if(!e.filesOnly){let s=await o.purgeAgent(e.agentId);i.push({label:"store",value:`${s.sessions} conversation(s), ${s.messages} message(s), ${s.passages} passage(s)`});for(let a of e.logs)Cn(a.path,{force:!0});if(e.logs.length>0)i.push({label:"logs",value:`${e.logs.length} file(s)`})}if(Cn(e.dir,{recursive:!0,force:!0}),i.push({label:"directory",value:e.dir}),r.json===!0)return process.stdout.write(`${JSON.stringify({removed:e.ref,agentId:e.agentId,filesOnly:e.filesOnly},null,2)}
|
|
@@ -170,18 +170,18 @@ ${e.ref} removed.
|
|
|
170
170
|
${d(i)}
|
|
171
171
|
`),e.filesOnly)process.stdout.write(`
|
|
172
172
|
Its sessions and memory are still in the store under the id "${e.agentId}", which another agent shares.
|
|
173
|
-
`);return n}async function ra(e,r){let o=
|
|
174
|
-
`),n;if(process.stdout.write(`${_(`removing every agent in ${
|
|
173
|
+
`);return n}async function ra(e,r){let o=z();if(o.length===0)return process.stdout.write(`The sandbox is empty — there is nothing to remove.
|
|
174
|
+
`),n;if(process.stdout.write(`${_(`removing every agent in ${ne()}:`,!0)}
|
|
175
175
|
${o.map((s)=>y(`${s.ref}${s.id===void 0||s.id===s.ref?"":` (id ${s.id})`}`)).join(`
|
|
176
176
|
`)}
|
|
177
177
|
`),e.dryRun===!0)return process.stdout.write(`
|
|
178
178
|
Nothing was deleted — this was --dry-run.
|
|
179
179
|
`),n;if(!await Nn(e,"all",`type \`all\` to remove all ${o.length}:`))return process.stdout.write(`
|
|
180
180
|
Nothing was deleted.
|
|
181
|
-
`),n;let i=n;for(let s of o){let a=await
|
|
182
|
-
`:`Nothing to prune — every agent id in the store and the log directory belongs to an agent in ${
|
|
181
|
+
`),n;let i=n;for(let s of o){let a=await Ms(s.ref,e,r),l=await Us({...a,sharesIdWith:[]},e,r);if(l!==n)i=l}return i}async function oa(e,r){let o=new Set(z().map((l)=>l.id??l.ref).filter((l)=>l!=="")),i=new Set((await r.agentIds()).filter((l)=>!o.has(l)));for(let l of aa())if(!o.has(l))i.add(l);let s=[];for(let l of[...i].sort())s.push({agentId:l,footprint:await r.agentFootprint(l),logs:Hs(l)});if(s.length===0)return process.stdout.write(e.json===!0?`${JSON.stringify({pruned:[]})}
|
|
182
|
+
`:`Nothing to prune — every agent id in the store and the log directory belongs to an agent in ${ne()}.
|
|
183
183
|
`),n;if(process.stdout.write(`${_("no sandbox directory claims these:",!0)}
|
|
184
|
-
${
|
|
184
|
+
${Os(s)}
|
|
185
185
|
`),e.dryRun===!0)return process.stdout.write(`
|
|
186
186
|
Nothing was deleted — this was --dry-run.
|
|
187
187
|
`),n;if(!await Nn(e,"prune","type `prune` to delete them:"))return process.stdout.write(`
|
|
@@ -190,26 +190,26 @@ Nothing was deleted.
|
|
|
190
190
|
`:`
|
|
191
191
|
pruned ${s.length} agent id(s).
|
|
192
192
|
${d(a)}
|
|
193
|
-
`),n}async function
|
|
193
|
+
`),n}async function Ms(e,r,o){if(e.includes("/")||e.endsWith(".yaml")||e.endsWith(".yml"))throw new t({code:"cli_remove_takes_a_name",message:`remove takes a sandbox agent's name, and "${e}" is a path.`,hint:`An agent outside ${ne()} is a directory you created and yours to delete — \`rm -rf\` it. This command only removes agents \`${A.slug} init\` made, because it also has to clear their sessions, memory, logs and service.`});let i=z(),s=i.find((b)=>b.ref===e);if(s===void 0){let b=i.map((k)=>k.ref);throw new t({code:"cli_agent_unknown",message:`No agent named "${e}" in the sandbox${b.length===0?", which is empty":""}.`,hint:b.length===0?`Nothing to remove. \`${A.slug} init\` creates one.`:`Known agents: ${b.join(", ")}. \`--prune\` clears data left by an agent whose directory is already gone.`})}let a=s.id;if(a===void 0)try{a=v(s.manifestPath).id}catch{}let l=r.filesOnly===!0||a===void 0,c=a??e,p=await o.agentFootprint(c),g=p.lease?await o.leases.get(c):void 0,m=Ds(r),w=jo(A.slug,c);return{ref:e,agentId:c,manifestPath:s.manifestPath,dir:s.dir,files:ia(s.dir),footprint:p,logs:Hs(c),sharesIdWith:i.filter((b)=>b.ref!==e&&(b.id??"")===c).map((b)=>b.ref),...g!==void 0&&V(g.pid)?{running:{pid:g.pid,mode:g.mode}}:{},...m?.state(w).installed===!0?{service:w}:{},filesOnly:l}}function Ds(e){let r=e.platform??process.platform;if(r!=="darwin")return;return Xt(r,{home:ta(),uid:process.getuid?.()??0,envPrefix:A.envPrefix,...e.exec===void 0?{}:{exec:e.exec}})}function ia(e){let r=0,o=0,i=(s)=>{let a;try{a=js(s)}catch{return}for(let l of a){let c=Ls(s,l);try{let p=Fs(c);if(p.isDirectory()){i(c);continue}r+=1,o+=p.size}catch{}}};return i(e),{count:r,bytes:o}}function Hs(e){let r=an(e),o=[];for(let i of[r.out,r.err])try{if(!na(i))continue;o.push({path:i,bytes:Fs(i).size})}catch{}return o}function aa(){let e;try{e=js(Ls(Oe(),"logs"))}catch{return[]}let r=new Set;for(let o of e)for(let i of[".out.log",".err.log"])if(o.endsWith(i))r.add(o.slice(0,-i.length));return[...r]}async function Nn(e,r,o){if(e.yes===!0)return!0;let i=e.confirm;if(i===void 0)return!1;return await i(o,r)}async function Gs(e){if(e.manifestPath===void 0)return await kA({action:"restart",...e.store===void 0?{}:{store:e.store},...e.json===void 0?{}:{json:e.json}});let r=ye(e.manifestPath),o=await vn(e.manifestPath,e.store),i,s,a=n;switch(o.kind){case"reloaded":i="reloaded",s=`pid ${o.pid} rebuilt it from disk${o.adopted.length>0?` · adopted ${o.adopted.join(", ")}`:""}`;break;case"pending":i="reload pending",s=`pid ${o.pid} applies it when its ${o.running} running turn(s) finish`;break;case"busy":i="not reloaded",s=`pid ${o.pid} has a turn in flight — try again when it finishes`,a=u;break;case"failed":i="not reloaded",s=`pid ${o.pid} answered ${o.status}${o.detail===void 0?"":`: ${o.detail}`}${o.hint===void 0?"":` — ${o.hint}`}`,a=u;break;case"no-host":{let l=await Ye(e.store);if(l===void 0)throw new t({code:"cli_restart_nothing_running",message:`Nothing is hosting ${r}, and no server is running to adopt it.`,hint:`\`${A.slug} serve ${r}\` runs it in this terminal; \`${A.slug} daemon install\` keeps a server running that hosts every agent. Then \`${A.slug} restart ${r}\` reloads it in place.`});let c=await Dt(l,e.manifestPath,e.store);if(c.ok)i="started",s=`nothing was hosting it — adopted by pid ${l.pid}`;else i="not started",s=`pid ${l.pid} did not adopt it${c.detail===void 0?"":`: ${c.detail}`}`,a=u;break}}if(e.json===!0)process.stdout.write(`${JSON.stringify({agentId:r,result:o,ok:a===n},null,2)}
|
|
194
194
|
`);else process.stdout.write(`${d([{label:r,value:i,note:s}])}
|
|
195
|
-
`);return a}import{randomBytes as Kn}from"node:crypto";import{existsSync as ha}from"node:fs";import{createInterface as
|
|
196
|
-
hint: ${e.hint}`);if(this.name="DispachError",this.code=e.code,this.hint=e.hint??"",this.field=e.field,this.status=r.status,this.request=r.method===void 0||r.path===void 0?void 0:{method:r.method,path:r.path},r.cause!==void 0)this.cause=r.cause}}function da(e,r){let o=e instanceof Error?e.message:String(e);return new be({code:"transport_failed",message:`${r.method} ${r.path} did not reach ${r.baseUrl}: ${o}`,hint:"Check the base URL, that the server is running, and that nothing between you and it is refusing the connection. `GET /v1/health` needs no token and is the cheapest probe."},{...r,cause:e})}async function la(e,r){let o;try{let i=await e.json();if(typeof i.error?.code==="string"&&typeof i.error.message==="string")o={code:i.error.code,message:i.error.message,...i.error.hint===void 0?{}:{hint:i.error.hint},...i.error.field===void 0?{}:{field:i.error.field}}}catch{}return new be(o??{code:`http_${e.status}`,message:`${r.method} ${r.path} returned ${e.status} with no error body.`,hint:"This is not a response this server produces, so something between you and it answered — a proxy, a gateway, or a load balancer. Check the URL and what is in front of it."},{status:e.status,...r})}var qs=new Set(FA);async function*Vs(e){for await(let r of ir(ca(e))){if(r.event===void 0||r.data==="")continue;let o;try{o=JSON.parse(r.data)}catch{continue}yield{name:r.event,data:o}}}async function*ca(e){let r=e.getReader();try{while(!0){let{done:o,value:i}=await r.read();if(o)return;if(i!==void 0)yield i}}finally{r.releaseLock()}}async function*ua(e){for await(let{name:r,data:o}of Vs(e)){if(qs.has(r)){yield{kind:"event",event:o};continue}let i=o??{};switch(r){case"turn.accepted":yield{kind:"accepted",turnId:String(i.turnId??""),sessionKey:String(i.sessionKey??"")};break;case"stream.replay":yield{kind:"replay",report:{state:i.state==="ended"?"ended":"running",events:Number(i.events??0),truncated:i.truncated===!0,dropped:Number(i.dropped??0),chunks:i.chunks==="start"||i.chunks==="partial"?i.chunks:"none"}};break;case"stream.ended":yield{kind:"ended",turnId:String(i.turnId??""),status:String(i.status??"unknown"),steps:typeof i.steps==="number"?i.steps:void 0,errorCode:typeof i.errorCode==="string"?i.errorCode:void 0};break;case"stream.unavailable":yield{kind:"unavailable",turnId:String(i.turnId??""),reason:String(i.reason??"not observable from this process")};break;default:break}}}async function*ma(e){for await(let{name:r,data:o}of Vs(e)){if(qs.has(r)){yield{kind:"event",event:o};continue}if(r==="stream.subscribed"){let i=o??{};yield{kind:"subscribed",report:{agentId:typeof i.agentId==="string"?i.agentId:null,types:Array.isArray(i.types)?i.types:null,chunks:i.chunks===!0,implied:typeof i.implied==="string"?i.implied:void 0}}}}}async function*fa(e,r={}){for await(let o of e){if(o.kind==="replay"&&o.report.truncated&&r.allowTruncated!==!0)throw new be({code:"replay_truncated",message:`This turn's replay is missing its oldest ${o.report.dropped} event(s), so the text reconstructed from it would be incomplete.`,hint:"Read the finished text from GET /v1/agents/:id/turns/:turnId, or pass { allowTruncated: true } to accept a fragment. Streaming from the start of a turn is never truncated — this only happens when reattaching to one that has already produced more events than the buffer holds."});if(o.kind==="unavailable")throw new be({code:"turn_not_observable",message:`Turn ${o.turnId} is recorded as running but is not observable here: ${o.reason}.`,hint:"Its events are buffered in whichever process is executing it. Poll GET /v1/agents/:id/turns/:turnId for the outcome."});if(o.kind!=="event")continue;if(o.event.type!=="model.chunk")continue;let i=o.event.data;if(i.kind==="reasoning")continue;if(typeof i.delta==="string")yield i.delta}}function Js(e){let r=e.baseUrl.replace(/\/+$/,""),o=e.fetch??fetch,i=(g={})=>({...e.token===void 0?{}:{authorization:`Bearer ${e.token}`},...g});async function s(g,m,w={}){let b;try{b=await o(`${r}${m}`,{method:g,headers:i({...w.body===void 0?{}:{"content-type":"application/json"},...w.accept===void 0?{}:{accept:w.accept},...w.headers}),...w.body===void 0?{}:{body:JSON.stringify(w.body)},...w.signal===void 0?{}:{signal:w.signal}})}catch(k){throw da(k,{method:g,path:m,baseUrl:r})}if(!b.ok)throw await la(b,{method:g,path:m});return b}async function a(g,m,w){return await(await s(g,m,w??{})).json()}async function l(g,m){let w=await s("GET",g,{accept:"text/event-stream",...m===void 0?{}:{signal:m}});if(w.body===null)throw new be({code:"no_response_body",message:`GET ${g} returned ${w.status} with no body to read.`,hint:"An SSE route always has a body. A missing one means something between you and the server buffered the response — commonly a proxy without streaming enabled."},{status:w.status,method:"GET",path:g});return w.body}function c(g,m,w,b={}){let k=(P)=>P?.chunks===!0?"?chunks=true":"",C={turnId:m,sessionKey:w,replayed:b.replayed===!0,async*stream(P){let x=await l(`/v1/agents/${encodeURIComponent(g)}/turns/${encodeURIComponent(m)}/stream${k(P)}`,P?.signal);yield*ua(x)},async*tokens(P){yield*fa(C.stream({chunks:!0,...P}),{...P?.allowTruncated===void 0?{}:{allowTruncated:P.allowTruncated}})},async text(){for await(let P of C.stream()){if(P.kind==="ended")break;if(P.kind==="unavailable")break;if(P.kind==="event"&&P.event.type==="turn.end")break}return(await C.get()).text},get:()=>a("GET",`/v1/agents/${encodeURIComponent(g)}/turns/${encodeURIComponent(m)}`),async stop(){await s("POST",`/v1/agents/${encodeURIComponent(g)}/turns/${encodeURIComponent(m)}/stop`)}};return C}function p(g){let m=(w)=>`/v1/agents/${encodeURIComponent(g)}${w}`;return{id:g,async send(w,b){let k=await a("POST",m("/messages"),{body:{text:w,...b?.sessionKey===void 0?{}:{sessionKey:b.sessionKey},...b?.deliver===void 0?{}:{deliver:b.deliver},...b?.from===void 0?{}:{from:b.from}},...b?.idempotencyKey===void 0?{}:{headers:{"idempotency-key":b.idempotencyKey}},...b?.signal===void 0?{}:{signal:b.signal}});return c(g,k.turnId,k.sessionKey,{replayed:k.replayed===!0})},turn:(w)=>c(g,w,""),describe:()=>a("GET",m("")),tools:()=>a("GET",m("/tools")),skills:()=>a("GET",m("/skills")),sessions:()=>a("GET",m("/sessions")),messages:(w,b)=>{let k=new URLSearchParams;if(b?.before!==void 0)k.set("before",String(b.before));if(b?.limit!==void 0)k.set("limit",String(b.limit));let C=k.size===0?"":`?${k.toString()}`;return a("GET",m(`/sessions/${encodeURIComponent(w)}/messages${C}`))},clearSession:(w)=>a("DELETE",m(`/sessions/${encodeURIComponent(w)}`)),reload:()=>a("POST",m("/reload"),{body:{}}),usage:(w)=>a("GET",m(`/usage${Ws(w)}`)),turns:(w)=>{let b=new URLSearchParams;if(w?.limit!==void 0)b.set("limit",String(w.limit));if(w?.before!==void 0)b.set("before",String(w.before));let k=b.size===0?"":`?${b.toString()}`;return a("GET",m(`/turns${k}`))},secrets:async()=>(await a("GET",m("/secrets"))).secrets,setSecrets:(w)=>a("PUT",m("/secrets"),{body:{values:w}}),schedules:async()=>(await a("GET",m("/schedules"))).schedules,approvals:async()=>(await a("GET",m("/approvals"))).approvals,createSchedule:(w)=>a("POST",m("/schedules"),{body:w}),updateSchedule:(w,b)=>a("PATCH",m(`/schedules/${encodeURIComponent(w)}`),{body:b}),deleteSchedule:async(w)=>{await a("DELETE",m(`/schedules/${encodeURIComponent(w)}`))},runSchedule:(w)=>a("POST",m(`/schedules/${encodeURIComponent(w)}/run`),{body:{}}),config:()=>a("GET",m("/config")),setConfig:(w,b,k)=>a("PATCH",m("/config"),{body:{path:w,value:b,...k?.confirm===void 0?{}:{confirm:k.confirm}}}),setChannel:(w,b)=>a("PATCH",m(`/channels/${encodeURIComponent(w)}`),{body:{...b}}),unpairChannel:(w)=>a("POST",m(`/channels/${encodeURIComponent(w)}/unpair`)),session:(w)=>a("GET",m(`/sessions/${encodeURIComponent(w)}`)),setPhase:(w,b)=>a("POST",m(`/sessions/${encodeURIComponent(w)}/phase`),{body:{phase:b}}),approve:async(w,b)=>{await a("POST",m(`/approvals/${encodeURIComponent(w)}`),{body:{granted:b}})},stop:(w)=>a("POST",m("/stop"),{body:w===void 0?{}:{reason:w}}),start:()=>a("POST",m("/start"),{body:{}}),assign:(w)=>a("PUT",m("/assignee"),{body:{participantId:w}}),unassign:()=>a("DELETE",m("/assignee")),exportBundle:(w)=>a("GET",m(`/export${w===void 0?"":`?paths=${encodeURIComponent(w.join(","))}`}`)),importBundle:(w,b)=>a("POST",m("/import"),{body:{bundle:w,...b===void 0?{}:{mode:b}}}),context:(w)=>{let b=new URLSearchParams;if(w?.sessionKey!==void 0)b.set("sessionKey",w.sessionKey);if(w?.input!==void 0)b.set("input",w.input);let k=b.size===0?"":`?${b.toString()}`;return a("GET",m(`/context${k}`))}}}return{agent:p,agents:()=>a("GET","/v1/agents"),health:()=>a("GET","/v1/health"),async ready(){try{return await s("GET","/v1/ready"),!0}catch(g){if(g instanceof be&&g.status===503)return!1;throw g}},provision:()=>a("GET","/v1/provision"),keys:()=>a("GET","/v1/keys"),createKey:(g)=>a("POST","/v1/keys",{body:g}),revokeKey:(g)=>a("DELETE",`/v1/keys/${encodeURIComponent(g)}`),createAgent:(g)=>a("POST","/v1/agents",{body:{answers:g}}),usage:(g)=>a("GET",`/v1/usage${Ws(g)}`),activity:()=>a("GET","/v1/activity"),participants:async()=>(await a("GET","/v1/participants")).participants,registerParticipant:(g)=>a("POST","/v1/participants",{body:g}),conversations:async()=>(await a("GET","/v1/conversations")).conversations,createConversation:(g)=>a("POST","/v1/conversations",{body:g}),conversation:(g)=>a("GET",`/v1/conversations/${encodeURIComponent(g)}`),setMembers:(g,m)=>a("PATCH",`/v1/conversations/${encodeURIComponent(g)}/members`,{body:m}),postMessage:(g,m)=>a("POST",`/v1/conversations/${encodeURIComponent(g)}/messages`,{body:m}),conversationMessages:(g,m={})=>{let w=new URLSearchParams;if(m.after!==void 0)w.set("after",String(m.after));if(m.limit!==void 0)w.set("limit",String(m.limit));let b=w.size===0?"":`?${w}`;return a("GET",`/v1/conversations/${encodeURIComponent(g)}/messages${b}`)},setPresence:(g,m)=>a("PUT",`/v1/participants/${encodeURIComponent(g)}/presence`,{body:{presence:m}}),actions:async(g={})=>(await a("GET",`/v1/actions${g.status===void 0?"":`?status=${g.status}`}`)).actions,decideAction:(g,m)=>a("POST",`/v1/actions/${encodeURIComponent(g)}`,{body:{approve:m}}),addNote:(g)=>a("POST","/v1/memory/notes",{body:g}),notes:async(g)=>(await a("GET",`/v1/memory/notes?scope=${encodeURIComponent(g)}`)).notes,deleteNote:(g)=>a("DELETE",`/v1/memory/notes/${encodeURIComponent(g)}`),memoryReads:async(g)=>(await a("GET",`/v1/participants/${encodeURIComponent(g)}/memory/reads`)).reads,projects:async()=>(await a("GET","/v1/projects")).projects,putProject:(g,m)=>a("PUT",`/v1/projects/${encodeURIComponent(g)}`,{body:m}),deleteProject:(g)=>a("DELETE",`/v1/projects/${encodeURIComponent(g)}`),setSpaceWriter:(g)=>a("PUT","/v1/memory/space/writer",{body:{writer:g}}),webhooks:async()=>(await a("GET","/v1/webhooks")).webhooks,createWebhook:(g)=>a("POST","/v1/webhooks",{body:g}),deleteWebhook:(g)=>a("DELETE",`/v1/webhooks/${encodeURIComponent(g)}`),templates:async()=>(await a("GET","/v1/templates")).templates,createAgentFromTemplate:(g)=>a("POST","/v1/agents",{body:g}),async*events(g){let m=new URLSearchParams;if(g?.agentId!==void 0)m.set("agentId",g.agentId);if(g?.types!==void 0&&g.types.length>0)m.set("types",g.types.join(","));if(g?.chunks===!0)m.set("chunks","true");let w=m.size===0?"":`?${m.toString()}`,b=await l(`/v1/events${w}`,g?.signal);yield*ma(b)}}}function Ws(e){let r=new URLSearchParams;if(e?.by!==void 0)r.set("by",e.by.join(","));if(e?.from!==void 0)r.set("from",e.from);if(e?.to!==void 0)r.set("to",e.to);return r.size===0?"":`?${r.toString()}`}function Ae(e,r){let o=[];for(let i of e){if(i.origin!==void 0&&i.origin!=="call")continue;if(i.role!=="user"&&i.role!=="assistant")continue;let s=Ai(i,r);if(s==="")continue;o.push({role:i.role,text:s})}return o}function Xs(e){let r=e.ref??"<your agent>",o=`${A.slug} run ${r} --session ${e.sessionKey}`;return`
|
|
197
|
-
${
|
|
195
|
+
`);return a}import{randomBytes as Kn}from"node:crypto";import{existsSync as ha}from"node:fs";import{createInterface as dr}from"node:readline";class we extends Error{code;hint;field;status;request;constructor(e,r={}){super(e.hint===void 0?e.message:`${e.message}
|
|
196
|
+
hint: ${e.hint}`);if(this.name="DispachError",this.code=e.code,this.hint=e.hint??"",this.field=e.field,this.status=r.status,this.request=r.method===void 0||r.path===void 0?void 0:{method:r.method,path:r.path},r.cause!==void 0)this.cause=r.cause}}function da(e,r){let o=e instanceof Error?e.message:String(e);return new we({code:"transport_failed",message:`${r.method} ${r.path} did not reach ${r.baseUrl}: ${o}`,hint:"Check the base URL, that the server is running, and that nothing between you and it is refusing the connection. `GET /v1/health` needs no token and is the cheapest probe."},{...r,cause:e})}async function la(e,r){let o;try{let i=await e.json();if(typeof i.error?.code==="string"&&typeof i.error.message==="string")o={code:i.error.code,message:i.error.message,...i.error.hint===void 0?{}:{hint:i.error.hint},...i.error.field===void 0?{}:{field:i.error.field}}}catch{}return new we(o??{code:`http_${e.status}`,message:`${r.method} ${r.path} returned ${e.status} with no error body.`,hint:"This is not a response this server produces, so something between you and it answered — a proxy, a gateway, or a load balancer. Check the URL and what is in front of it."},{status:e.status,...r})}var qs=new Set(FA);async function*Vs(e){for await(let r of ir(ca(e))){if(r.event===void 0||r.data==="")continue;let o;try{o=JSON.parse(r.data)}catch{continue}yield{name:r.event,data:o}}}async function*ca(e){let r=e.getReader();try{while(!0){let{done:o,value:i}=await r.read();if(o)return;if(i!==void 0)yield i}}finally{r.releaseLock()}}async function*ua(e){for await(let{name:r,data:o}of Vs(e)){if(qs.has(r)){yield{kind:"event",event:o};continue}let i=o??{};switch(r){case"turn.accepted":yield{kind:"accepted",turnId:String(i.turnId??""),sessionKey:String(i.sessionKey??"")};break;case"stream.replay":yield{kind:"replay",report:{state:i.state==="ended"?"ended":"running",events:Number(i.events??0),truncated:i.truncated===!0,dropped:Number(i.dropped??0),chunks:i.chunks==="start"||i.chunks==="partial"?i.chunks:"none"}};break;case"stream.ended":yield{kind:"ended",turnId:String(i.turnId??""),status:String(i.status??"unknown"),steps:typeof i.steps==="number"?i.steps:void 0,errorCode:typeof i.errorCode==="string"?i.errorCode:void 0};break;case"stream.unavailable":yield{kind:"unavailable",turnId:String(i.turnId??""),reason:String(i.reason??"not observable from this process")};break;default:break}}}async function*ma(e){for await(let{name:r,data:o}of Vs(e)){if(qs.has(r)){yield{kind:"event",event:o};continue}if(r==="stream.subscribed"){let i=o??{};yield{kind:"subscribed",report:{agentId:typeof i.agentId==="string"?i.agentId:null,types:Array.isArray(i.types)?i.types:null,chunks:i.chunks===!0,implied:typeof i.implied==="string"?i.implied:void 0}}}}}async function*fa(e,r={}){for await(let o of e){if(o.kind==="replay"&&o.report.truncated&&r.allowTruncated!==!0)throw new we({code:"replay_truncated",message:`This turn's replay is missing its oldest ${o.report.dropped} event(s), so the text reconstructed from it would be incomplete.`,hint:"Read the finished text from GET /v1/agents/:id/turns/:turnId, or pass { allowTruncated: true } to accept a fragment. Streaming from the start of a turn is never truncated — this only happens when reattaching to one that has already produced more events than the buffer holds."});if(o.kind==="unavailable")throw new we({code:"turn_not_observable",message:`Turn ${o.turnId} is recorded as running but is not observable here: ${o.reason}.`,hint:"Its events are buffered in whichever process is executing it. Poll GET /v1/agents/:id/turns/:turnId for the outcome."});if(o.kind!=="event")continue;if(o.event.type!=="model.chunk")continue;let i=o.event.data;if(i.kind==="reasoning")continue;if(typeof i.delta==="string")yield i.delta}}function Js(e){let r=e.baseUrl.replace(/\/+$/,""),o=e.fetch??fetch,i=(g={})=>({...e.token===void 0?{}:{authorization:`Bearer ${e.token}`},...g});async function s(g,m,w={}){let b;try{b=await o(`${r}${m}`,{method:g,headers:i({...w.body===void 0?{}:{"content-type":"application/json"},...w.accept===void 0?{}:{accept:w.accept},...w.headers}),...w.body===void 0?{}:{body:JSON.stringify(w.body)},...w.signal===void 0?{}:{signal:w.signal}})}catch(k){throw da(k,{method:g,path:m,baseUrl:r})}if(!b.ok)throw await la(b,{method:g,path:m});return b}async function a(g,m,w){return await(await s(g,m,w??{})).json()}async function l(g,m){let w=await s("GET",g,{accept:"text/event-stream",...m===void 0?{}:{signal:m}});if(w.body===null)throw new we({code:"no_response_body",message:`GET ${g} returned ${w.status} with no body to read.`,hint:"An SSE route always has a body. A missing one means something between you and the server buffered the response — commonly a proxy without streaming enabled."},{status:w.status,method:"GET",path:g});return w.body}function c(g,m,w,b={}){let k=(P)=>P?.chunks===!0?"?chunks=true":"",C={turnId:m,sessionKey:w,replayed:b.replayed===!0,async*stream(P){let x=await l(`/v1/agents/${encodeURIComponent(g)}/turns/${encodeURIComponent(m)}/stream${k(P)}`,P?.signal);yield*ua(x)},async*tokens(P){yield*fa(C.stream({chunks:!0,...P}),{...P?.allowTruncated===void 0?{}:{allowTruncated:P.allowTruncated}})},async text(){for await(let P of C.stream()){if(P.kind==="ended")break;if(P.kind==="unavailable")break;if(P.kind==="event"&&P.event.type==="turn.end")break}return(await C.get()).text},get:()=>a("GET",`/v1/agents/${encodeURIComponent(g)}/turns/${encodeURIComponent(m)}`),async stop(){await s("POST",`/v1/agents/${encodeURIComponent(g)}/turns/${encodeURIComponent(m)}/stop`)}};return C}function p(g){let m=(w)=>`/v1/agents/${encodeURIComponent(g)}${w}`;return{id:g,async send(w,b){let k=await a("POST",m("/messages"),{body:{text:w,...b?.sessionKey===void 0?{}:{sessionKey:b.sessionKey},...b?.deliver===void 0?{}:{deliver:b.deliver},...b?.from===void 0?{}:{from:b.from}},...b?.idempotencyKey===void 0?{}:{headers:{"idempotency-key":b.idempotencyKey}},...b?.signal===void 0?{}:{signal:b.signal}});return c(g,k.turnId,k.sessionKey,{replayed:k.replayed===!0})},turn:(w)=>c(g,w,""),describe:()=>a("GET",m("")),tools:()=>a("GET",m("/tools")),skills:()=>a("GET",m("/skills")),sessions:()=>a("GET",m("/sessions")),messages:(w,b)=>{let k=new URLSearchParams;if(b?.before!==void 0)k.set("before",String(b.before));if(b?.limit!==void 0)k.set("limit",String(b.limit));let C=k.size===0?"":`?${k.toString()}`;return a("GET",m(`/sessions/${encodeURIComponent(w)}/messages${C}`))},clearSession:(w)=>a("DELETE",m(`/sessions/${encodeURIComponent(w)}`)),reload:()=>a("POST",m("/reload"),{body:{}}),usage:(w)=>a("GET",m(`/usage${Ws(w)}`)),turns:(w)=>{let b=new URLSearchParams;if(w?.limit!==void 0)b.set("limit",String(w.limit));if(w?.before!==void 0)b.set("before",String(w.before));let k=b.size===0?"":`?${b.toString()}`;return a("GET",m(`/turns${k}`))},secrets:async()=>(await a("GET",m("/secrets"))).secrets,setSecrets:(w)=>a("PUT",m("/secrets"),{body:{values:w}}),schedules:async()=>(await a("GET",m("/schedules"))).schedules,approvals:async()=>(await a("GET",m("/approvals"))).approvals,createSchedule:(w)=>a("POST",m("/schedules"),{body:w}),updateSchedule:(w,b)=>a("PATCH",m(`/schedules/${encodeURIComponent(w)}`),{body:b}),deleteSchedule:async(w)=>{await a("DELETE",m(`/schedules/${encodeURIComponent(w)}`))},runSchedule:(w)=>a("POST",m(`/schedules/${encodeURIComponent(w)}/run`),{body:{}}),config:()=>a("GET",m("/config")),setConfig:(w,b,k)=>a("PATCH",m("/config"),{body:{path:w,value:b,...k?.confirm===void 0?{}:{confirm:k.confirm}}}),setChannel:(w,b)=>a("PATCH",m(`/channels/${encodeURIComponent(w)}`),{body:{...b}}),unpairChannel:(w)=>a("POST",m(`/channels/${encodeURIComponent(w)}/unpair`)),session:(w)=>a("GET",m(`/sessions/${encodeURIComponent(w)}`)),setPhase:(w,b)=>a("POST",m(`/sessions/${encodeURIComponent(w)}/phase`),{body:{phase:b}}),approve:async(w,b)=>{await a("POST",m(`/approvals/${encodeURIComponent(w)}`),{body:{granted:b}})},stop:(w)=>a("POST",m("/stop"),{body:w===void 0?{}:{reason:w}}),start:()=>a("POST",m("/start"),{body:{}}),assign:(w)=>a("PUT",m("/assignee"),{body:{participantId:w}}),unassign:()=>a("DELETE",m("/assignee")),exportBundle:(w)=>a("GET",m(`/export${w===void 0?"":`?paths=${encodeURIComponent(w.join(","))}`}`)),importBundle:(w,b)=>a("POST",m("/import"),{body:{bundle:w,...b===void 0?{}:{mode:b}}}),context:(w)=>{let b=new URLSearchParams;if(w?.sessionKey!==void 0)b.set("sessionKey",w.sessionKey);if(w?.input!==void 0)b.set("input",w.input);let k=b.size===0?"":`?${b.toString()}`;return a("GET",m(`/context${k}`))}}}return{agent:p,agents:()=>a("GET","/v1/agents"),health:()=>a("GET","/v1/health"),async ready(){try{return await s("GET","/v1/ready"),!0}catch(g){if(g instanceof we&&g.status===503)return!1;throw g}},provision:()=>a("GET","/v1/provision"),keys:()=>a("GET","/v1/keys"),createKey:(g)=>a("POST","/v1/keys",{body:g}),revokeKey:(g)=>a("DELETE",`/v1/keys/${encodeURIComponent(g)}`),createAgent:(g)=>a("POST","/v1/agents",{body:{answers:g}}),usage:(g)=>a("GET",`/v1/usage${Ws(g)}`),activity:()=>a("GET","/v1/activity"),participants:async()=>(await a("GET","/v1/participants")).participants,registerParticipant:(g)=>a("POST","/v1/participants",{body:g}),conversations:async()=>(await a("GET","/v1/conversations")).conversations,createConversation:(g)=>a("POST","/v1/conversations",{body:g}),conversation:(g)=>a("GET",`/v1/conversations/${encodeURIComponent(g)}`),setMembers:(g,m)=>a("PATCH",`/v1/conversations/${encodeURIComponent(g)}/members`,{body:m}),postMessage:(g,m)=>a("POST",`/v1/conversations/${encodeURIComponent(g)}/messages`,{body:m}),conversationMessages:(g,m={})=>{let w=new URLSearchParams;if(m.after!==void 0)w.set("after",String(m.after));if(m.limit!==void 0)w.set("limit",String(m.limit));let b=w.size===0?"":`?${w}`;return a("GET",`/v1/conversations/${encodeURIComponent(g)}/messages${b}`)},setPresence:(g,m)=>a("PUT",`/v1/participants/${encodeURIComponent(g)}/presence`,{body:{presence:m}}),actions:async(g={})=>(await a("GET",`/v1/actions${g.status===void 0?"":`?status=${g.status}`}`)).actions,decideAction:(g,m)=>a("POST",`/v1/actions/${encodeURIComponent(g)}`,{body:{approve:m}}),addNote:(g)=>a("POST","/v1/memory/notes",{body:g}),notes:async(g)=>(await a("GET",`/v1/memory/notes?scope=${encodeURIComponent(g)}`)).notes,deleteNote:(g)=>a("DELETE",`/v1/memory/notes/${encodeURIComponent(g)}`),memoryReads:async(g)=>(await a("GET",`/v1/participants/${encodeURIComponent(g)}/memory/reads`)).reads,projects:async()=>(await a("GET","/v1/projects")).projects,putProject:(g,m)=>a("PUT",`/v1/projects/${encodeURIComponent(g)}`,{body:m}),deleteProject:(g)=>a("DELETE",`/v1/projects/${encodeURIComponent(g)}`),setSpaceWriter:(g)=>a("PUT","/v1/memory/space/writer",{body:{writer:g}}),webhooks:async()=>(await a("GET","/v1/webhooks")).webhooks,createWebhook:(g)=>a("POST","/v1/webhooks",{body:g}),deleteWebhook:(g)=>a("DELETE",`/v1/webhooks/${encodeURIComponent(g)}`),templates:async()=>(await a("GET","/v1/templates")).templates,createAgentFromTemplate:(g)=>a("POST","/v1/agents",{body:g}),async*events(g){let m=new URLSearchParams;if(g?.agentId!==void 0)m.set("agentId",g.agentId);if(g?.types!==void 0&&g.types.length>0)m.set("types",g.types.join(","));if(g?.chunks===!0)m.set("chunks","true");let w=m.size===0?"":`?${m.toString()}`,b=await l(`/v1/events${w}`,g?.signal);yield*ma(b)}}}function Ws(e){let r=new URLSearchParams;if(e?.by!==void 0)r.set("by",e.by.join(","));if(e?.from!==void 0)r.set("from",e.from);if(e?.to!==void 0)r.set("to",e.to);return r.size===0?"":`?${r.toString()}`}function Te(e,r){let o=[];for(let i of e){if(i.origin!==void 0&&i.origin!=="call")continue;if(i.role!=="user"&&i.role!=="assistant")continue;let s=ti(i,r);if(s==="")continue;o.push({role:i.role,text:s})}return o}function Xs(e){let r=e.ref??"<your agent>",o=`${A.slug} run ${r} --session ${e.sessionKey}`;return`
|
|
197
|
+
${Ys}Resume this session with:
|
|
198
198
|
${o}${Qo}
|
|
199
|
-
`}function jn(e,r){switch(e){case"first":return;case"restart":return"restarted — the configuration on disk is now the one in force; the conversation continues from the store.";case"switch":return"switched conversation — the one you left is still in the store, under its own key.";case"new":return r===void 0?"new conversation — the one you left is still in the store, under its own key.":`new conversation — the one you left is ${r}, still in the store. /sessions goes back to it.`}}function pa(e){return e==="nlt"?ar():sr()}function zs(e){return{kind:"embedded",agentId:e.agent.id,describe:()=>e.description,subscribe:(r)=>e.bus.on("*",r,{chunks:!0}),send:(r,o)=>e.send(r,{...o,source:"repl"}),streamFilter:e.streamFilter,history:e.history,sessions:e.sessions,clearSession:e.clearSession,tools:async()=>Ko(e.agent),context:e.context,close:async()=>{}}}function Qs(e){let r=e.client.agent(e.agentId),o=new Set,i=new AbortController,s,a=()=>{if(s!==void 0)return;s=(async()=>{for await(let l of e.client.events({agentId:e.agentId,chunks:!0,signal:i.signal})){if(l.kind!=="event"||l.event===void 0)continue;for(let c of o)c(l.event)}})().catch(()=>{})};return{kind:"attached",agentId:e.agentId,host:e.host,describe:()=>e.description,subscribe:(l)=>(o.add(l),a(),()=>o.delete(l)),send:async(l,c)=>{let p=!1,g,m=()=>{if(p=!0,g!==void 0)r.turn(g).stop().catch(()=>{})};c.signal.addEventListener("abort",m,{once:!0});let w,b=new Promise((k)=>{let C=(P)=>{if(g!==void 0&&P.turnId!==void 0&&P.turnId!==g)return;if(P.type==="error"){w=P.data;return}if(P.type!=="turn.end")return;o.delete(C),k({text:"",reason:P.data.reason,steps:P.data.steps,durationMs:P.data.durationMs,tokens:P.data.tokens,...w===void 0?{}:{error:w}})};o.add(C),a()});try{if(g=(await r.send(l,{sessionKey:c.sessionKey})).turnId,p)r.turn(g).stop().catch(()=>{});return await b}finally{c.signal.removeEventListener("abort",m)}},streamFilter:()=>pa(e.description.dialect),history:async(l)=>{let c=await r.messages(l);return
|
|
199
|
+
`}function jn(e,r){switch(e){case"first":return;case"restart":return"restarted — the configuration on disk is now the one in force; the conversation continues from the store.";case"switch":return"switched conversation — the one you left is still in the store, under its own key.";case"new":return r===void 0?"new conversation — the one you left is still in the store, under its own key.":`new conversation — the one you left is ${r}, still in the store. /sessions goes back to it.`}}function pa(e){return e==="nlt"?ar():sr()}function zs(e){return{kind:"embedded",agentId:e.agent.id,describe:()=>e.description,subscribe:(r)=>e.bus.on("*",r,{chunks:!0}),send:(r,o)=>e.send(r,{...o,source:"repl"}),streamFilter:e.streamFilter,history:e.history,sessions:e.sessions,clearSession:e.clearSession,tools:async()=>Ko(e.agent),context:e.context,close:async()=>{}}}function Qs(e){let r=e.client.agent(e.agentId),o=new Set,i=new AbortController,s,a=()=>{if(s!==void 0)return;s=(async()=>{for await(let l of e.client.events({agentId:e.agentId,chunks:!0,signal:i.signal})){if(l.kind!=="event"||l.event===void 0)continue;for(let c of o)c(l.event)}})().catch(()=>{})};return{kind:"attached",agentId:e.agentId,host:e.host,describe:()=>e.description,subscribe:(l)=>(o.add(l),a(),()=>o.delete(l)),send:async(l,c)=>{let p=!1,g,m=()=>{if(p=!0,g!==void 0)r.turn(g).stop().catch(()=>{})};c.signal.addEventListener("abort",m,{once:!0});let w,b=new Promise((k)=>{let C=(P)=>{if(g!==void 0&&P.turnId!==void 0&&P.turnId!==g)return;if(P.type==="error"){w=P.data;return}if(P.type!=="turn.end")return;o.delete(C),k({text:"",reason:P.data.reason,steps:P.data.steps,durationMs:P.data.durationMs,tokens:P.data.tokens,...w===void 0?{}:{error:w}})};o.add(C),a()});try{if(g=(await r.send(l,{sessionKey:c.sessionKey})).turnId,p)r.turn(g).stop().catch(()=>{});return await b}finally{c.signal.removeEventListener("abort",m)}},streamFilter:()=>pa(e.description.dialect),history:async(l)=>{let c=await r.messages(l);return Te([...c.messages].reverse().map((p)=>({role:p.role,content:p.content,...p.origin===void 0?{}:{origin:p.origin}})),e.description.dialect)},sessions:()=>r.sessions(),clearSession:async(l)=>{await r.clearSession(l)},tools:async()=>{let l=await r.tools();return{dialect:e.description.dialect,catalogueTokens:e.description.catalogueTokens,tools:l.map((c)=>({slug:c.slug,mutating:c.mutating,trust:c.trust,...c.trustReason===void 0?{}:{trustReason:c.trustReason},summary:c.summary}))}},context:async(l)=>{let c=await r.context({sessionKey:l});return{...c,windowSource:"as the host resolved it",...c.lastCompaction===void 0&&c.compactions!==void 0?{lastCompaction:c.compactions===0?void 0:`${c.compactions} stage${c.compactions===1?"":"s"} run this session`}:{}}},reload:async()=>(await r.reload()).adopted,close:async()=>{i.abort(),o.clear()}}}function Zs(e){if(e?.baseUrl===void 0||e.baseUrl==="")return;return{baseUrl:e.baseUrl,pid:e.pid}}async function ga(e,r,o,i,s,a=[],l){let c=e.describe(),[p,g]=await Promise.all([e.turns(r,1),e.store.messages.count(e.id,r)]),m=[`${A.name} ${j} · ${c.id} · ${c.model}`,`session ${r} · ${g} message(s) · window ${c.window} · store ${o}`,`ready in ${i.toFixed(0)} ms · /help for commands and keys · /exit to leave`],w=jn(s,l);if(w!==void 0)m.push(w);if(p[0]?.errorCode==="turn_abandoned")m.push("note: the previous turn in this session did not finish — the process exited while it was generating.");for(let b of[...e.warnings,...e.tools.warnings])m.push(`note: ${b.message}
|
|
200
200
|
${b.hint}`);if(a.length>0)m.push(`note: ${a.join(", ")} in the .env here ${a.length===1?"was":"were"} ignored — this agent's own .env sets ${a.length===1?"it":"them"}.
|
|
201
|
-
A .env in the directory you launched from configures that project, not an agent living somewhere else. Export the variable to override the agent's own file.`);return m}async function Mn(e){let r=e.once!==void 0,o=AA({json:!1,plain:e.plain===!0,oneShot:r}),{mode:i}=o;if(e.manifestPath===void 0){let P=await wa(i,o.because,e);if(typeof P==="number")return P;return Mn({...e,manifestPath:P})}let s=
|
|
202
|
-
`);let a;F(()=>a?.stop("cli-exit"));let l={current:void 0},c={current:""},p={current:e.sessionKey},g={current:!1},m={current:void 0},w=e.quiet===!0,b="first",k={current:void 0},C=e.ephemeral===!0?void 0:
|
|
201
|
+
A .env in the directory you launched from configures that project, not an agent living somewhere else. Export the variable to override the agent's own file.`);return m}async function Mn(e){let r=e.once!==void 0,o=AA({json:!1,plain:e.plain===!0,oneShot:r}),{mode:i}=o;if(e.manifestPath===void 0){let P=await wa(i,o.because,e);if(typeof P==="number")return P;return Mn({...e,manifestPath:P})}let s=Ai();if(e.store===void 0&&e.ephemeral!==!0&&ha(s))process.stdout.write(`note: a session store exists at ${s} from an earlier version — pass --store ${s} to keep using it; the default is now ${G()}
|
|
202
|
+
`);let a;F(()=>a?.stop("cli-exit"));let l={current:void 0},c={current:""},p={current:e.sessionKey},g={current:!1},m={current:void 0},w=e.quiet===!0,b="first",k={current:void 0},C=e.ephemeral===!0?void 0:Zs(await Ke(ye(e.manifestPath),e.store));if(C!==void 0)return await ka({...e,host:C,mode:i==="rich"?"rich":"plain",quiet:w,oneShot:r,reader:l,draft:c,session:p,random:Kn});for(;;){let P=await Ie.create({agents:[e.manifestPath],toolProviders:Ae,modelTransports:me,mediaProviders:ce,builtInPlugins:pe,pluginRoot:oe(),scriptRunner:le(),channels:se,env:R([e.manifestPath]),store:e.ephemeral===!0?":memory:":e.store??G()});a=P;let x=P.list()[0];if(x===void 0)throw Error("The manifest produced no agent.");if(p.current===void 0||p.current===""){let W=await lr({list:()=>K.sessions(),mode:i,asked:p.current,wantsContinue:e.continueSession===!0,random:Kn});if(typeof W==="number")return await P.stop("cli-exit"),W;p.current=W.sessionKey,g.current=W.fresh}let M=p.current,q=x.roles.main.capabilities.thinking!=="none",S=e.noReasoning===!0?!1:q,I=w||r?[]:await ga(x,M,P.store.location,b==="first"?P.boot.processMs:P.boot.bootMs,b,Ss([e.manifestPath]),m.current),O=i==="rich"&&!w&&!r?Te(await x.history(M),x.describe().dialect):[],K=zs({agent:x,bus:P.bus,send:(W,ue)=>x.send(W,ue),history:async(W)=>Te(await x.history(W),x.describe().dialect),sessions:async()=>await x.store.sessions.list(x.id),clearSession:async(W)=>{await x.clearSession(W)},context:async(W)=>Sa(x,W),streamFilter:()=>x.streamFilter(),description:{agentId:x.id,name:x.describe().name,model:x.describe().model,dialect:x.describe().dialect,window:x.describe().window,catalogueTokens:x.describe().catalogueTokens,thinking:x.roles.main.capabilities.thinking,warnings:[...x.warnings,...x.tools.warnings]}}),U={...e,source:K,embedded:{agent:x,runtime:P},sessionKey:M,banner:I,prior:O,quiet:w,reader:l,draft:c,showReasoning:S,freshSession:g.current,switchTo:k,random:Kn},N=i==="rich"?await cr(U):await ur(U);if(await P.stop(N===be?"restart":"cli-exit"),N!==be)return N;if(k.current===void 0)b="restart";else b=k.current.reason,m.current=M,p.current=k.current.key,k.current=void 0;g.current=!1}}function ya(e,r){let o=[];for(let i of e)GA({action:"install",manifestPath:r,name:`${i.source}/${i.skill}`,quiet:!0,collect:o});return o}var be=Symbol("restart");async function wa(e,r,o){let i=z();if(i.length===0){if(e==="rich"){let m=await yn({plain:o.plain===!0});if(m.kind==="aborted")return process.stdout.write(`nothing to run
|
|
203
203
|
`),n;if(m.kind==="failed")return m.code;return m.manifestPath}throw new t({code:"cli_sandbox_empty",message:"No agent named, and the sandbox is empty.",hint:`Create one with \`${A.slug} init\`, or pass a path to an agent.yaml.`})}if(i.length===1&&i[0]!==void 0)return process.stdout.write(`running ${i[0].ref} — the only agent in the sandbox
|
|
204
204
|
`),i[0].manifestPath;if(e!=="rich"){for(let m of i)process.stdout.write(`${m.ref} ${m.problem??m.modelId??"?"} ${m.dir}
|
|
205
205
|
`);return process.stderr.write(`pass an agent name or a manifest path — the picker needs a terminal (${r})
|
|
206
|
-
`),u}let[{render:s},{createElement:a},{Picker:l}]=await Promise.all([import("ink"),import("react"),import("./Picker-
|
|
206
|
+
`),u}let[{render:s},{createElement:a},{Picker:l}]=await Promise.all([import("ink"),import("react"),import("./Picker-32jwxayd.js")]),c={kind:"quit"};zn();let p=s(a(l,{title:`${A.name} ${j}`,agents:i,onDone:(m)=>{c=m}}),{exitOnCtrlC:!1,...Pe(o.noEnhancedKeys)});F(()=>p.unmount()),await p.waitUntilExit(),p.unmount();let g=c;if(g.kind==="quit")return process.stdout.write(`nothing run
|
|
207
207
|
`),n;if(g.kind==="create"){let m=await yn({plain:o.plain===!0});if(m.kind==="aborted")return process.stdout.write(`nothing to run
|
|
208
|
-
`),n;if(m.kind==="failed")return m.code;return m.manifestPath}return g.manifestPath}async function
|
|
208
|
+
`),n;if(m.kind==="failed")return m.code;return m.manifestPath}return g.manifestPath}async function lr(e){let r=()=>({sessionKey:Ho(e.random),fresh:!0});if(e.wantsContinue&&e.asked==="")throw new t({code:"cli_session_ambiguous",message:"--continue and a bare --session ask for different things.",hint:"--continue takes the most recent conversation without asking; --session on its own opens the list. Pass one."});if(e.wantsContinue){let o=await e.list(),i=ba(o);if(i===void 0)return process.stdout.write(`no stored conversation with this agent yet — starting a new one
|
|
209
209
|
`),r();return{sessionKey:i.sessionKey,fresh:!1}}if(e.asked===""){let o=await e.list();if(o.length===0)return process.stdout.write(`no stored conversation with this agent yet — starting a new one
|
|
210
210
|
`),r();if(e.mode!=="rich"){for(let s of[...o].sort(Qe))process.stdout.write(`${s.sessionKey} ${s.messages} ${s.turns} ${s.lastActivityAt}
|
|
211
211
|
`);return process.stderr.write(`pass --session <key> — the picker needs a terminal, and --continue takes the most recent without one
|
|
212
|
-
`),u}let i=await $a([...o].sort(Qe));return i===void 0?r():{sessionKey:i,fresh:!1}}return e.asked===void 0?r():{sessionKey:e.asked,fresh:!1}}function Qe(e,r){return Date.parse(r.lastActivityAt)-Date.parse(e.lastActivityAt)}function ba(e){return[...e].sort(Qe)[0]}async function $a(e){let[{render:r},{createElement:o},{SessionPicker:i}]=await Promise.all([import("ink"),import("react"),import("./SessionPicker-
|
|
212
|
+
`),u}let i=await $a([...o].sort(Qe));return i===void 0?r():{sessionKey:i,fresh:!1}}return e.asked===void 0?r():{sessionKey:e.asked,fresh:!1}}function Qe(e,r){return Date.parse(r.lastActivityAt)-Date.parse(e.lastActivityAt)}function ba(e){return[...e].sort(Qe)[0]}async function $a(e){let[{render:r},{createElement:o},{SessionPicker:i}]=await Promise.all([import("ink"),import("react"),import("./SessionPicker-yjbqbstr.js")]),s;zn();let a=r(o(i,{sessions:e.map((l)=>({sessionKey:l.sessionKey,messages:l.messages,turns:l.turns,lastActivityAt:l.lastActivityAt,phase:l.phase})),now:Date.now(),columns:_e(process.stdout.columns,De),maxRows:En,onDone:(l)=>{s=l,a.unmount()}}),{exitOnCtrlC:!1,...Pe()});return F(()=>a.unmount()),await a.waitUntilExit(),s}function va(e,r,o,i,s){let a=e.describe(),l=[`${A.name} ${j} · ${a.agentId} · ${a.model}`,`session ${r} · window ${a.window} · attached to ${o.baseUrl} (pid ${o.pid})`,"a view — the agent keeps running when you leave · /help for commands · /exit to detach"],c=jn(i,s);if(c!==void 0)l.push(c);for(let p of a.warnings)l.push(`warning: ${p.message}`);return l}async function ka(e){let r=e.manifestPath??"",o=ye(r),i=Nt(r),s=Js({baseUrl:e.host.baseUrl,...i===void 0?{}:{token:i}}),a=await s.agent(o).describe(),l=Qs({client:s,agentId:o,host:e.host,description:{agentId:o,name:a.name,model:a.model??"unknown",dialect:a.dialect??"nlt",window:a.window??0,catalogueTokens:a.catalogueTokens??0,thinking:"unknown",warnings:a.warnings??[]}}),c={current:void 0},p="first",g={current:void 0},m={current:!1};for(;;){if(e.session.current===void 0||e.session.current===""){let x=await lr({list:()=>l.sessions(),mode:e.mode,asked:e.session.current,wantsContinue:e.continueSession===!0,random:e.random});if(typeof x==="number")return x;e.session.current=x.sessionKey,m.current=x.fresh}let w=e.session.current??"",b=e.quiet||e.oneShot?[]:va(l,w,e.host,p,g.current),k=e.mode==="rich"&&!e.quiet&&!e.oneShot?await l.history(w):[],C={...e,source:l,sessionKey:w,banner:b,prior:k,quiet:e.quiet,reader:e.reader,draft:e.draft,showReasoning:e.noReasoning!==!0,freshSession:m.current,switchTo:c,random:e.random},P=e.mode==="rich"?await cr(C):await ur(C);if(P!==be)return await l.close(),P;if(c.current===void 0)p="restart";else p=c.current.reason,g.current=w,e.session.current=c.current.key,c.current=void 0;m.current=!1}}async function cr(e){let[{render:r},{createElement:o},{App:i}]=await Promise.all([import("ink"),import("react"),import("./App-7vmwg2rx.js")]),s=Ge();F(()=>{s.close()}),pA(),Xi(),process.stdout.write(`${SA}${Ps}`);let a=!1,l=r(o(i,{source:e.source,onSwitch:(c,p)=>{a=!0,e.switchTo.current={key:c,reason:"switch"},e.draft.current=p},onNew:(c)=>{a=!0,e.switchTo.current={key:Ho(e.random),reason:"new"},e.draft.current=c},sessions:async()=>[...await e.source.sessions()].sort(Qe).map((p)=>({sessionKey:p.sessionKey,messages:p.messages,turns:p.turns,lastActivityAt:p.lastActivityAt,phase:p.phase})),onRestart:(c)=>{a=!0,e.draft.current=c},sessionKey:e.sessionKey,model:e.source.describe().model,agentName:e.source.describe().agentId,freshSession:e.freshSession,warnings:e.source.describe().warnings.map((c)=>c.message),initial:Ti(Mi(e.banner.slice(1)),e.prior),correctKeys:s.correct,showReasoning:e.showReasoning,quiet:e.quiet,...e.manifestPath===void 0?{}:{manifestPath:e.manifestPath},catalogue:{load:(c)=>_t({onStatus:c}),install:async(c,p)=>dn(ya(c,p))},status:()=>e.embedded===void 0?fr(e.source):mr(e.embedded),contextView:()=>hr(e,e.sessionKey),...e.draft.current===""?{}:{initialDraft:e.draft.current}}),{exitOnCtrlC:!1,...Pe(e.noEnhancedKeys)});if(F(()=>l.unmount()),await l.waitUntilExit(),je(),!a)process.stdout.write(Xs({ref:e.source.describe().agentId,sessionKey:e.sessionKey}));return a?be:n}async function ur(e){let{source:r,sessionKey:o,quiet:i}=e,s=!0,a=(I)=>{if(I==="")return;process.stdout.write(I),s=I.endsWith(`
|
|
213
213
|
`)},l=(I)=>{if(!s)a(`
|
|
214
214
|
`);a(`${I}
|
|
215
215
|
`)};if(e.banner.length>0)a(`${e.banner.join(`
|
|
@@ -220,30 +220,30 @@ ${o}${Qo}
|
|
|
220
220
|
`);if(e.showReasoning===!0)a(K==="reasoning"?`· reasoning ·
|
|
221
221
|
`:`· reply ·
|
|
222
222
|
`);g=K}if(K==="reasoning"){a(O),p=!0;return}w(m.push(O));return}case"tool.result":{if(!c)return;let{slug:O,ok:K,latencyMs:U,truncated:N}=I.data;l(` · ${O} — ${K?"ok":"failed"} · ${U} ms${N?" · observation trimmed":""}`);return}case"agent.warning":l(` · ${I.data.message}
|
|
223
|
-
${I.data.hint}`);return;case"tool.repair":if(c)l(` · ${I.data.slugs.join(", ")} — could not be used, asking again`);return;case"tool.gated":l(` · ${I.data.slug} — blocked: ${I.data.reason}`);return;case"context.dropped":l(` · context: ${I.data.messages} older message(s) did not fit the ${I.data.budget}-token budget and were left out`);return;default:return}}),k=async(I)=>{let O=_n(I,Ln());if(O===void 0)return"prompt";switch(O.kind){case"exit":return"exit";case"restart":{let K=r.reload;if(K===void 0)return"restart";try{let U=await K();l(`reloaded ${U.join(", ")} — this conversation continues`)}catch(U){l(`could not reload: ${U instanceof Error?U.message:String(U)}`)}return"handled"}case"new":return e.switchTo.current={key:Ho(e.random),reason:"new"},"restart";case"help":return l(kn()),"handled";case"tools":return l(
|
|
224
|
-
`)},
|
|
223
|
+
${I.data.hint}`);return;case"tool.repair":if(c)l(` · ${I.data.slugs.join(", ")} — could not be used, asking again`);return;case"tool.gated":l(` · ${I.data.slug} — blocked: ${I.data.reason}`);return;case"context.dropped":l(` · context: ${I.data.messages} older message(s) did not fit the ${I.data.budget}-token budget and were left out`);return;default:return}}),k=async(I)=>{let O=_n(I,Ln());if(O===void 0)return"prompt";switch(O.kind){case"exit":return"exit";case"restart":{let K=r.reload;if(K===void 0)return"restart";try{let U=await K();l(`reloaded ${U.join(", ")} — this conversation continues`)}catch(U){l(`could not reload: ${U instanceof Error?U.message:String(U)}`)}return"handled"}case"new":return e.switchTo.current={key:Ho(e.random),reason:"new"},"restart";case"help":return l(kn()),"handled";case"tools":return l(St(await r.tools())),"handled";case"status":return l(e.embedded===void 0?await fr(r):await mr(e.embedded)),"handled";case"context":return l(await hr(e,o)),"handled";case"reset":return await r.clearSession(o),l("session cleared — memory files on disk are untouched"),"handled";case"unknown":return l(zt(O)),"handled";case"command":return l(`${O.name} is a command, not a prompt — run it at a terminal, or in another shell as \`${A.slug} ${O.name}${O.rest===""?"":` ${O.rest}`}\``),"handled"}},C,P=0,x=n,M=(I=e.reader.current)=>{if(C!==void 0&&!C.signal.aborted){P=performance.now(),C.abort();return}I?.close(),a(`
|
|
224
|
+
`)},q=async(I)=>{C=new AbortController,p=!1,g=void 0,m=r.streamFilter();let O=await r.send(I,{sessionKey:o,signal:C.signal});if(C=void 0,w(m.end()),p&&!s)a(`
|
|
225
225
|
`);else if(!p&&O.text!=="")a(`${O.text}
|
|
226
|
-
`);let K=
|
|
226
|
+
`);let K=st(O.reason,{steps:O.steps,durationMs:O.durationMs,...P===0?{}:{cancelledAfterMs:performance.now()-P}});if(K!==void 0)a(`
|
|
227
227
|
(${K})
|
|
228
228
|
`);if(O.reason==="error"&&O.error!==void 0)process.stderr.write(`
|
|
229
229
|
${O.error.code}: ${O.error.message}
|
|
230
230
|
hint: ${O.error.hint}
|
|
231
|
-
`);if(
|
|
231
|
+
`);if(Vr(O.reason))x=u;if(!i&&O.reason==="final")a(` ${O.tokens.prompt} prompt · ${O.tokens.output} output · ${O.durationMs} ms
|
|
232
232
|
|
|
233
|
-
`);await gA()},S=()=>M();process.on("SIGINT",S);try{if(e.once!==void 0)return await
|
|
234
|
-
`);for(let a of e)process.stdout.write(`${
|
|
233
|
+
`);await gA()},S=()=>M();process.on("SIGINT",S);try{if(e.once!==void 0)return await q(e.once),x;if(process.stdin.isTTY!==!0){let O=e.reader.current??dr({input:process.stdin});e.reader.current=O;for await(let K of O){let U=K.trim();if(U==="")continue;let N=await k(U);if(N==="exit")break;if(N==="restart"){x=be;break}if(N==="handled")continue;await q(U)}return x}let I=e.reader.current??dr({input:process.stdin,output:process.stdout,prompt:So,terminal:!1});e.reader.current=I,I.prompt();for await(let O of I){let K=O.trim();if(K===""){I.prompt();continue}let U=await k(K);if(U==="exit")break;if(U==="restart"){x=be;break}if(U==="handled"){I.prompt();continue}await q(K),I.prompt()}if(x!==be)I.close(),e.reader.current=void 0;return x}finally{process.off("SIGINT",S),b()}}async function mr(e){let{agent:r,runtime:o}=e,i=r.describe(),s=r.manifest,a=s.channels.filter((m)=>m.enabled).map((m)=>`${m.id} (${m.type})`).join(", "),l=a===""?"none — reached through this session and the HTTP API only":o.channels.started?`${a} — connected in this session`:`${a} — configured, NOT running here; \`serve\` starts channels, \`run\` does not`,c=!s.server.enabled?"off":`enabled on ${s.server.host}:${s.server.port}, NOT bound here — \`serve\` binds it`,p=yA(s),g=p.filter((m)=>m.role!=="main"&&m.role===m.configuredAs);return d([{label:"agent",value:`${i.id} (${i.name})`},{label:"model",value:`${i.model} · ${s.tools.dialect} · ${i.window} token window (${rt(p[0]?.window)})`},...g.map((m)=>({label:m.role,value:`${m.modelId} · ${m.window.contextWindow} token window (${rt(m.window)})`})),{label:"channels",value:l},{label:"http api",value:c},{label:"store",value:o.store.location},{label:"background",value:await Ea(o,i.id)}])}async function fr(e){let r=e.describe(),o=e.host,[i,s]=await Promise.all([e.tools(),e.sessions()]);return d([{label:"agent",value:`${r.agentId} (${r.name})`},{label:"attached to",value:o===void 0?"a host":`${o.baseUrl} · pid ${o.pid}`},{label:"this session",value:"a view — the agent runs in the host, and stays running when this exits"},{label:"model",value:`${r.model} · ${r.window} token window`},{label:"dialect",value:r.dialect},{label:"tools",value:`${i.tools.length} pinned · ${i.catalogueTokens} catalogue tokens per turn`},{label:"conversations",value:`${s.length} on this agent`},{label:"warnings",value:r.warnings.length===0?"none":r.warnings.map((a)=>a.message).join("; ")}])}async function Sa(e,r){let o=await e.previewContext({sessionKey:r}),[i]=yA(e.manifest);return{slots:o.slots,history:o.history,cache:o.cache,total:o.total,window:o.window,windowSource:rt(i?.window),wireTokens:o.wireTokens,reserveOutput:o.reserveOutput,calibration:o.calibration,lastCompaction:o.compactions===0?void 0:`${o.compactions} stage${o.compactions===1?"":"s"} run this session`}}async function hr(e,r){return bi(await e.source.context(r))}async function Ea(e,r){if(e.owned.includes(r))return"this session is serving this agent";let o=await e.store.leases.get(r);if(o!==void 0&&V(o.pid))return o.mode==="daemon"?`running as a background service · pid ${o.pid} · \`${A.slug} daemon status ${r}\``:`served by another session · pid ${o.pid} (${o.mode})`;return`not supervised — \`${A.slug} daemon install ${r}\` keeps it running without a terminal`}function Z(e,r){return e.length>=r?e:e+" ".repeat(r-e.length)}function Pa(e,r){if(!e.enabled)return"off";if(e.nextRunAt===void 0)return"done";let o=Date.parse(e.nextRunAt)-r;if(o<=0)return"due";let i=Math.round(o/60000);if(i<60)return`in ${i}m`;let s=Math.round(o/3600000);return s<48?`in ${s}h`:`in ${Math.round(s/24)}d`}function Ra(e,r){if(e.lastFiredAt===void 0)return"never run";let o=$A(e.lastFiredAt,r);if(e.lastStatus==="error")return`FAILED ${o}`;return`ok ${o}`}function xa(e,r){if(e.length===0){process.stdout.write("no schedules — add a `schedules:` block to the manifest\n");return}let o=Math.max(8,...e.map((a)=>a.id.length)),i=Math.max(4,...e.map((a)=>`${a.kind} ${a.expr}`.length));process.stdout.write(`${Z("SCHEDULE",o)} ${Z("WHEN",i)} ${Z("NEXT",7)} LAST
|
|
234
|
+
`);for(let a of e)process.stdout.write(`${Z(a.id,o)} ${Z(`${a.kind} ${a.expr}`,i)} ${Z(Pa(a,r),7)} ${Ra(a,r)}
|
|
235
235
|
`);let s=e.filter((a)=>a.lastStatus==="error");if(s.length>0)process.stdout.write(`
|
|
236
236
|
${s.length} failing — \`schedules --id ${s[0]?.id}\` for the error
|
|
237
237
|
`)}function Ta(e){let r=[["kind",`${e.kind} ${e.expr}`],["timezone",e.timezone??"(host)"],["task",e.task],["deliver",e.deliverChannel===void 0?"none — the reply reaches the event stream only":`${e.deliverChannel} → ${e.deliverTo}`],["session",e.sessionMode],["model role",e.role??"main"],["enabled",e.enabled?"yes":"no"],["declared in",e.origin==="manifest"?"agent.yaml":"the API"],["next run",e.nextRunAt??"(never again)"],["runs",String(e.runs)],["last run",e.lastFiredAt??"never"],["last status",e.lastStatus??"-"]];if(e.lastError!==void 0)r.push(["last error",e.lastError]);let o=Math.max(...r.map(([i])=>i.length));process.stdout.write(`${e.id}
|
|
238
|
-
`);for(let[i,s]of r)process.stdout.write(` ${
|
|
238
|
+
`);for(let[i,s]of r)process.stdout.write(` ${Z(i,o)} ${s}
|
|
239
239
|
`)}function Ia(e,r){let o=new Set(r),i=new Map;for(let s of e){if(!o.has(s.channel))continue;let a=`${s.channel}\x00${s.peerId}`,l=i.get(a);if(l!==void 0&&l.lastSeen>=s.lastActivityAt)continue;i.set(a,{channelId:s.channel,address:s.peerId,lastSeen:s.lastActivityAt})}return[...i.values()].sort((s,a)=>s.channelId===a.channelId?a.lastSeen.localeCompare(s.lastSeen):s.channelId.localeCompare(a.channelId))}function Aa(e,r){if(e.length===0){process.stdout.write(`no addresses yet — this agent has had no conversation on a declared channel.
|
|
240
240
|
`+` An address appears here once a first message arrives on one.
|
|
241
|
-
`);return}let o=Math.max(7,...e.map((s)=>s.channelId.length)),i=Math.max(7,...e.map((s)=>s.address.length));process.stdout.write(`${
|
|
242
|
-
`);for(let s of e)process.stdout.write(`${
|
|
241
|
+
`);return}let o=Math.max(7,...e.map((s)=>s.channelId.length)),i=Math.max(7,...e.map((s)=>s.address.length));process.stdout.write(`${Z("CHANNEL",o)} ${Z("ADDRESS",i)} LAST SEEN
|
|
242
|
+
`);for(let s of e)process.stdout.write(`${Z(s.channelId,o)} ${Z(s.address,i)} ${$A(s.lastSeen,r)}
|
|
243
243
|
`);process.stdout.write(`
|
|
244
244
|
Use an ADDRESS in deliver.to. On Telegram an @name addresses a channel and
|
|
245
245
|
`+`never a person — a private chat is reached by the numeric id above.
|
|
246
|
-
`)}async function
|
|
246
|
+
`)}async function gr(e){let r=await Ie.create({agents:[e.manifestPath],store:e.store??G(),toolProviders:Ae,modelTransports:me,mediaProviders:ce,builtInPlugins:pe,pluginRoot:oe(),scriptRunner:le(),channels:se,env:R([e.manifestPath]),lease:!1});F(()=>r.stop("cli-exit"));let o=r.list()[0];if(o===void 0)throw Error("The manifest produced no agent.");let i=Date.now();for(let[a,l]of[[e.enable,!0],[e.disable,!1]]){if(a===void 0)continue;let c=await o.store.schedules.get(o.id,a);if(c===void 0)return process.stderr.write(`no schedule "${a}" on ${o.id}
|
|
247
247
|
hint: run \`schedules\` with no flags to see what this agent has.
|
|
248
248
|
`),u;if(c.origin==="manifest")return process.stderr.write(`${a} is declared in agent.yaml, so the manifest decides whether it runs.
|
|
249
249
|
`+` Writing it here would last until the next start — reconciliation restores every
|
|
@@ -256,7 +256,7 @@ Use an ADDRESS in deliver.to. On Telegram an @name addresses a channel and
|
|
|
256
256
|
`)}if(e.recipients===!0){let a=Ia(await o.store.sessions.list(o.id),o.manifest.channels.map((l)=>l.id));if(e.json===!0)return process.stdout.write(`${JSON.stringify({recipients:a},null,2)}
|
|
257
257
|
`),n;return Aa(a,i),n}let s=await o.store.schedules.list(o.id);if(e.json)return process.stdout.write(`${JSON.stringify({schedules:s},null,2)}
|
|
258
258
|
`),n;if(e.id!==void 0){let a=s.find((l)=>l.id===e.id);if(a===void 0)return process.stderr.write(`no schedule "${e.id}" on ${o.id}
|
|
259
|
-
`),u;return Ta(a),n}if(e.enable===void 0&&e.disable===void 0)xa(s,i);return n}import{
|
|
259
|
+
`),u;return Ta(a),n}if(e.enable===void 0&&e.disable===void 0)xa(s,i);return n}import{rmSync as Fa}from"node:fs";import{dirname as La}from"node:path";import{readFileSync as Oa}from"node:fs";var _a="server.tokenEnv";function Dn(e){let r=Oa(e,"utf8"),o=_A(e),i=new Map,s=new Set(xt(r).filter((a)=>a.path===_a).map((a)=>a.name));for(let a of xt(r)){if(s.has(a.name))continue;let l=i.get(a.name)??[];l.push(a.path),i.set(a.name,l)}return[...i].map(([a,l])=>({name:a,set:Zt(o,a),usedBy:l}))}function yr(e,r){let o=Dn(e).map((l)=>l.name);for(let[l,c]of Object.entries(r)){if(!o.includes(l))throw new t({code:"secret_not_referenced",message:`"${l}" is not a variable this agent's manifest reads.`,hint:o.length===0?"This agent's manifest reads no variables a caller may set.":`It reads ${o.join(", ")}. A variable is settable when the manifest names it, as \${NAME} or through an *Env field; the server's own token never is. GET /v1/agents/:id/secrets lists them.`,field:`values.${l}`});if(c==="")throw new t({code:"secret_value_empty",message:`An empty value for ${l} would not start the agent.`,hint:"A variable set to nothing fails the load exactly as a missing one does. Nothing was written.",field:`values.${l}`})}let i=R([e]),s=[],a=[];for(let[l,c]of Object.entries(r))if(He(e,l,c),s.push(l),Zt(i,l))a.push(l);return{written:s,shadowed:a}}import{existsSync as Wn,lstatSync as Vn,mkdirSync as wr,readdirSync as $r,readFileSync as vr,renameSync as Ca,rmSync as Na}from"node:fs";import{basename as Bn,dirname as ja,join as ae}from"node:path";var Ce="template.yaml",Sr=/^[a-z0-9][a-z0-9-]*$/;function Xn(e){let r;try{r=$r(e)}catch{return[]}let o=[];for(let i of r.sort()){if(!Sr.test(i))continue;let s=ae(e,i);if(!Vn(s).isDirectory())continue;try{let a=Pr(s);o.push({name:i,...a.description===void 0?{}:{description:a.description},vars:a.vars.map((l)=>({name:l.name,...l.description===void 0?{}:{description:l.description},required:l.required,...l.default===void 0?{}:{default:l.default},secret:l.secret!==void 0}))})}catch(a){if(!f(a))throw a;o.push({name:i,vars:[],problem:{code:a.code,message:a.message,hint:a.hint}})}}return o}function Pr(e){let r=ae(e,Ce);if(!Wn(r))throw new t({code:"template_spec_missing",message:`${Bn(e)} has no ${Ce}.`,hint:`A template is an agent directory with a ${Ce} beside agent.yaml declaring its variables. An empty one (\`vars: {}\`) is valid.`});return Zr(vr(r,"utf8"),`${Bn(e)}/${Ce}`)}function Rr(e,r=""){let o=[];for(let i of $r(ae(e,r)).sort()){let s=r===""?i:`${r}/${i}`;if(s===Ce)continue;let a=ae(e,s),l=Vn(a);if(l.isSymbolicLink())throw new t({code:"template_symlink",message:`${s} in the template is a symbolic link.`,hint:"A template is copied into every agent made from it, and a link would copy whatever it points at. Replace it with the file itself.",field:s});if(l.isDirectory()){o.push(...Rr(e,s));continue}let c=vr(a);if(c.includes(0))throw new t({code:"template_binary_file",message:`${s} in the template is not a text file.`,hint:"Templates are rendered by text substitution, which would corrupt a binary file. Leave it out of the template and add it to the agent afterwards.",field:s});o.push({relPath:s,contents:c.toString("utf8")})}return o}function xr(e){if(!Sr.test(e.template))throw br(e.template,e.templatesDir);let r=ae(e.templatesDir,e.template);if(!Wn(r)||!Vn(r).isDirectory())throw br(e.template,e.templatesDir);let o=e.name.trim();if(o==="")throw new t({code:"provision_name_required",message:"An agent made from a template needs a name.",hint:'Send { "template": "…", "name": "Acme store", "vars": {…} }. The id every route keys on is derived from the name, and a template can use it as {{agent.name}} and {{agent.id}}.',field:"name"});let i=tA(o),s=ae(e.agentDirBase,i);if(Wn(s))throw new t({code:"provision_agent_exists",message:`An agent directory named "${i}" already exists.`,hint:"The id is derived from the name, so pick a different name. Nothing is overwritten: replacing an agent's workspace is exactly the loss provisioning exists to prevent.",field:"name"});let a=Xr({spec:Pr(r),files:Rr(r),id:i,name:o,vars:e.vars}),l=ae(ja(e.agentDirBase),`.${Bn(e.agentDirBase)}-staging`,`${i}-${crypto.randomUUID().slice(0,8)}`);wr(l,{recursive:!0});try{Ee(l,a.files);let c=ae(l,"agent.yaml");for(let[m,w]of Object.entries(a.env))He(c,m,w);let p=a.files.find((m)=>m.relPath==="agent.yaml"),g={};for(let m of xt(p?.contents??""))if(a.env[m.name]===void 0)g[m.name]="(pending)";Ue(c,g),wr(e.agentDirBase,{recursive:!0}),Ca(l,s)}catch(c){throw Na(l,{recursive:!0,force:!0}),c}return{agentId:i,dir:s,manifestPath:ae(s,"agent.yaml"),files:[...a.files.map((c)=>c.relPath),...Object.keys(a.env).length>0?[".env"]:[]]}}function br(e,r){let o=Xn(r).map((i)=>i.name);return new t({code:"template_not_found",message:`No template called ${JSON.stringify(e)}.`,hint:o.length===0?`This server has no templates. An operator adds one as a directory under ${r}.`:`Templates here: ${o.join(", ")}. GET /v1/templates lists them with their variables.`,field:"template"})}function Ka(){return Ft.shape.server.parse({})}async function Tr(e){let r=R(e.manifestPaths),o=Ua(r),i=e.store??G(),s=await ji(e.manifestPaths,r,i),a=s.filter((E)=>!E.enabled),l=s.filter((E)=>E.enabled),c=e.manifestPaths.length===0,p=[],g=[];for(let E of l)try{p.push({path:E.manifestPath,loaded:J(E.manifestPath,{env:r})})}catch(T){if(!c)throw T;g.push({path:E.manifestPath,detail:f(T)?T.message:String(T),...f(T)&&T.hint!==void 0?{hint:T.hint}:{}})}let m=p[0],w=m?.loaded,b=w?.manifest.server??Ka();for(let E of p.slice(1)){let T=E.loaded.manifest.server;for(let[L,X,Ne,ke]of[["server.port",b.port,T.port,e.port!==void 0],["server.host",b.host,T.host,e.host!==void 0],["server.tokenEnv",b.tokenEnv,T.tokenEnv,!1]]){if(ke||X===Ne)continue;throw new t({code:"serve_bind_conflict",message:`${m?.path??"the first manifest"} sets ${L} to ${String(X)} and ${E.path} sets it to ${String(Ne)}.`,hint:"One process binds one socket with one token, so these have to agree. Make them match, or run the disagreeing agent in its own process — a second `serve` on its own port.",field:L})}}let k=e.port??b.port,C=e.port===void 0,P=e.host??b.host,x=w===void 0?r[b.tokenEnv]:w.env[b.tokenEnv],M=r[b.tokenEnv],q=p.every((E)=>Gt(La(E.path),r)),S=x;if(q&&(M===void 0||M==="")){let E=gn(ne(r));if(E!==void 0)S=E;else if(x!==void 0&&x!=="")Kr(ne(r),x)}let I=r[`${A.envPrefix}SERVICE`]!==void 0,O=new hA({runtimeId:`rt_${Date.now().toString(36)}`});if(e.json!==!0)O.on("agent.channel.status",(E)=>{let T=E.data,L=T.input===void 0?"":T.input.kind==="pairing_code"?`
|
|
260
260
|
|
|
261
261
|
${T.input.payload}
|
|
262
262
|
${T.input.expiresAt===void 0?"":`
|
|
@@ -266,19 +266,19 @@ ${T.input.expiresAt===void 0?"":`
|
|
|
266
266
|
`)}),O.on("error",(E)=>{let T=E.data,L=E.sessionKey===void 0?"":` [${E.sessionKey}]`;process.stderr.write(` turn failed${L}: ${T.code}: ${T.message}
|
|
267
267
|
hint: ${T.hint}
|
|
268
268
|
`)}),O.on("agent.channel.rejected",(E)=>{let T=E.data;process.stdout.write(` ${T.channelId}: ${T.reason} — ${T.detail}
|
|
269
|
-
`)});let K=_r(),U=(E)=>({agents:E,approve:K.approver,env:r,bus:O,toolProviders:
|
|
270
|
-
`);else{let E=`http://${
|
|
271
|
-
`),
|
|
269
|
+
`)});let K=_r(),U=(E)=>({agents:E,approve:K.approver,env:r,bus:O,toolProviders:Ae,modelTransports:me,mediaProviders:ce,builtInPlugins:pe,pluginRoot:oe(),scriptRunner:le(),channels:se,startChannels:!0,startSchedules:!0,store:i,mode:I?"daemon":"terminal"}),N;try{N=await Ie.create(U(p.map((E)=>E.path)))}catch(E){if(!c||p.length===0)throw E;let T=[];for(let L of p)try{await(await Ie.create({...U([L.path]),store:":memory:",startChannels:!1,startSchedules:!1})).stop(),T.push(L)}catch(X){g.push({path:L.path,detail:f(X)?X.message:String(X),...f(X)&&X.hint!==void 0?{hint:X.hint}:{}})}if(T.length===p.length)throw E;p.splice(0,p.length,...T),N=await Ie.create(U(T.map((L)=>L.path)))}es();let W=Ma(),ue=await N.store.operatorKeys.liveCount(),ee=ue===0||e.claim===!0?Gi():void 0,B,$e=[];try{B=await Ha(k,C,(E)=>($e.push(E),xi({runtime:N,host:P,port:E,approvals:K,allowedOrigins:b.allowedOrigins,allowedHosts:b.allowedHosts,resolveAgent:(T)=>Jn(T,r),provision:{steps:()=>pt({agentDirBase:ne(r)}),create:(T)=>ht({answers:T,defaults:{agentDirBase:ne(r)}}),templates:()=>Xn(Hr(r)),createFromTemplate:(T)=>xr({...T,templatesDir:Hr(r),agentDirBase:ne(r)})},secrets:{status:Dn,write:yr},remover:Wa(r),channels:{setEnabled:Un,setCredential:xn,unpair:Hn},...ee===void 0?{}:{claim:ee},...S===void 0||S===""?{}:{token:S}})))}catch(E){if(await N.stop("server failed to bind"),f(E))throw E;let T=$e.length>1?` — also tried ${$e.slice(1).join(", ")}`:"";throw new t({code:"server_bind_failed",message:`Could not bind ${P}:${k}${T}: ${E instanceof Error?E.message:String(E)}`,hint:C?`Every port in the range is taken. Pass --port to name a free one, or stop whatever is holding them — \`${A.slug} stop\` releases one this runtime started.`:"Another process is on that port, and --port was given explicitly so nothing else was tried. Drop the flag to let it walk to the next free port, or name a different one.",cause:E})}let zr=N.owned.length===0&&await Ji(N.store.leases,{runtimeId:N.runtimeId,mode:I?"daemon":"terminal"});await N.publishAddress(B.url);let re=N.list(),Qn=re[0];if(Qn!==void 0)process.title=re.length===1?`${A.slug} ${Qn.id}`:`${A.slug} ${re.length} agents`;for(let E of re)E.reportRuntimeState({serverListening:!0});if(e.json===!0)process.stdout.write(`${JSON.stringify({url:B.url,websocket:B.websocket,authenticated:S!==void 0&&S!=="",keys:ue,...ee===void 0?{}:{claim:ee.token},agents:re.map((E)=>({id:E.id,channels:N.channels.statusOf(E.id)})),declined:N.declined.map((E)=>({agentId:E.agentId,pid:E.pid,mode:E.mode,since:E.startedAt})),disabled:a.map((E)=>({agentId:E.agentId,...E.reason===void 0?{}:{reason:E.reason}})),broken:g.map((E)=>({path:E.path,detail:E.detail,...E.hint===void 0?{}:{hint:E.hint}}))})}
|
|
270
|
+
`);else{let E=`http://${en(P)}:${B.port}`,T=E===B.url?"":` (bound ${P} — every interface)`;if(process.stdout.write(`${A.name} serving on ${E}${T}
|
|
271
|
+
`),B.port!==k)process.stdout.write(` moved from ${k} — something else is on it. \`--port ${k}\` would refuse instead of moving.
|
|
272
272
|
`);process.stdout.write(` web UI ${E}/ · API reference ${E}/docs
|
|
273
|
-
`);for(let L of re){let X=N.channels.statusOf(L.id),Ne=X.length===0?"no channels":X.map((
|
|
273
|
+
`);for(let L of re){let X=N.channels.statusOf(L.id),Ne=X.length===0?"no channels":X.map((Se)=>`${Se.id} (${Se.type}${Se.status==="error"?", BROKEN":""})`).join(", "),ke=L.manifest.schedules.filter((Se)=>Se.enabled),Qr=L.manifest.schedules.length===0?"":`, ${ke.length} schedule${ke.length===1?"":"s"}${L.manifest.schedules.length>ke.length?` (+${L.manifest.schedules.length-ke.length} disabled)`:""}`;process.stdout.write(` ${L.id} — ${Ne}${Qr}
|
|
274
274
|
`)}for(let L of a)process.stdout.write(` ${L.agentId} — stopped${L.reason===void 0?"":` (${L.reason})`}, \`${A.slug} start ${L.agentId}\`
|
|
275
275
|
`);for(let L of g)if(process.stdout.write(` ${L.path} — NOT served: ${L.detail}
|
|
276
276
|
`),L.hint!==void 0)process.stdout.write(` hint: ${L.hint}
|
|
277
277
|
`);for(let L of N.declined)process.stdout.write(` ${L.agentId} — NOT served here: pid ${L.pid} (${L.mode}) already has it
|
|
278
278
|
`);if(N.declined.length>0)process.stdout.write(` \`${A.slug} stop <agent>\` ends the other one, or leave it — nothing here is broken.
|
|
279
|
-
`);if(
|
|
280
|
-
${
|
|
281
|
-
without a browser: ${
|
|
279
|
+
`);if(ee!==void 0){if(process.stdout.write(` open once to claim this server:
|
|
280
|
+
${Fi(P,B.port,ee.token)}
|
|
281
|
+
without a browser: ${Ui(P,B.port,ee.token)}
|
|
282
282
|
`),S===void 0||S==="")process.stdout.write(` the first key closes this server — every route then needs a credential.
|
|
283
283
|
`)}if(S===void 0||S==="")process.stdout.write(` unauthenticated — loopback only. Set ${b.tokenEnv} to bind a public host.
|
|
284
284
|
`);if(I)process.stdout.write(` running as a background service · ${A.slug} daemon status ${re[0]?.id??""}
|
|
@@ -287,81 +287,81 @@ ${T.input.expiresAt===void 0?"":`
|
|
|
287
287
|
`)}let Yn=!1,Zn=async()=>{if(Yn)return;if(Yn=!0,o>0&&N.all().some((E)=>E.inFlight>0)){let E=Date.now();process.stdout.write(`draining — waiting up to ${o} ms for running turns
|
|
288
288
|
`);let T=await N.drain(o);process.stdout.write(T===0?`drained in ${Date.now()-E} ms
|
|
289
289
|
`:`${T} turn(s) still running after ${o} ms; the next start marks them interrupted
|
|
290
|
-
`)}if(await
|
|
291
|
-
`),await Zn(),n}function
|
|
292
|
-
`);return}let r=
|
|
290
|
+
`)}if(await B.stop(),zr)await N.store.leases.release(LA,N.runtimeId).catch(()=>{});await N.stop("interrupted")};return F(Zn),await W,process.stdout.write(`stopping
|
|
291
|
+
`),await Zn(),n}function Ua(e){let r=`${A.envPrefix}DRAIN_MS`,o=e[r];if(o===void 0||o==="")return 0;if(!/^\d+$/.test(o))throw new t({code:"serve_drain_invalid",message:`${r} is "${o}", which is not a number of milliseconds.`,hint:"Set it to a whole number, a few seconds under the orchestrator's grace period — 25000 beside Kubernetes' default terminationGracePeriodSeconds of 30. Unset, a stop does not wait.",field:r});return Number(o)}function Ma(){return new Promise((e)=>{let r=()=>{process.off("SIGINT",r),process.off("SIGTERM",r),e()};process.once("SIGINT",r),process.once("SIGTERM",r)})}var Da=16;async function Ha(e,r,o){let i=r&&e!==0?e+Da:e;for(let s=e;;s+=1)try{return await o(s)}catch(a){if(s>=i||!Ga(a))throw a}}function Ga(e){if(typeof e==="object"&&e!==null&&"code"in e){if(e.code==="EADDRINUSE")return!0}let r=e instanceof Error?e.message:String(e);return r.includes("EADDRINUSE")||r.includes("in use")}function Wa(e){return{locate(r){let o=z(e).filter((s)=>s.id===r),i=o[0];if(i===void 0)return{ok:!1,status:404,error:{code:"agent_remove_not_in_sandbox",message:`No agent "${r}" in the sandbox, so there are no files here to delete.`,hint:"Only sandbox agents are deleted over the API. An agent elsewhere is removed by deleting its directory yourself."}};if(o.length>1)return{ok:!1,status:409,error:{code:"agent_remove_shared_id",message:`${o.length} sandbox directories declare id "${r}": ${o.map((s)=>s.dir).join(", ")}.`,hint:"They share one conversation history, so deleting either would delete the other's too. Give one a different id first."}};return{ok:!0,dir:i.dir}},async deleteDir(r){if(!Gt(r,e))throw Error(`refusing to delete ${r}: it is outside the sandbox`);Fa(r,{recursive:!0,force:!0})}}}function H(e,r){return e.length>=r?e:e+" ".repeat(r-e.length)}function qa(e){let r=new Map,o=[];for(let i of e){let s=i.sessionKey.split(":"),a={sessionKey:i.sessionKey,phase:i.phase,messages:i.messages,turns:i.turns,lastActivityAt:i.lastActivityAt};if(s.length!==3||s[0]!=="schedule"){o.push(a);continue}let l=`schedule:${s[1]}`,c=r.get(l);if(c===void 0){let p={...a,sessionKey:`${l}:*`,runs:1};r.set(l,p),o.push(p);continue}if(c.runs=(c.runs??1)+1,c.messages+=i.messages,c.turns+=i.turns,i.lastActivityAt>c.lastActivityAt)c.lastActivityAt=i.lastActivityAt}return o}function Ba(e){if(e.length===0){process.stdout.write(`no sessions yet
|
|
292
|
+
`);return}let r=qa(e),o=Math.max(7,...r.map((i)=>i.sessionKey.length));process.stdout.write(`${H("SESSION",o)} ${H("MSGS",5)} ${H("TURNS",5)} ${H("PHASE",8)} LAST
|
|
293
293
|
`);for(let i of r){let s=i.runs===void 0?"":` (${i.runs} run${i.runs===1?"":"s"})`;process.stdout.write(`${H(i.sessionKey,o)} ${H(String(i.messages),5)} ${H(String(i.turns),5)} ${H(i.phase??"-",8)} ${$A(i.lastActivityAt,Date.now())}${s}
|
|
294
|
-
`)}}async function
|
|
294
|
+
`)}}async function Va(e,r,o){let i=await e.store.messages.page(e.id,r,{limit:o});if(i.messages.length===0){process.stdout.write(`no messages in ${r}
|
|
295
295
|
`);return}for(let s of[...i.messages].reverse())process.stdout.write(`${s.role}: ${s.content}
|
|
296
296
|
`);if(i.nextBefore!==void 0)process.stdout.write(`
|
|
297
297
|
… older messages exist; raise --limit
|
|
298
|
-
`)}async function
|
|
298
|
+
`)}async function Ja(e,r,o){let i=await e.turns(r,o);if(i.length===0){process.stdout.write(`no turns in ${r}
|
|
299
299
|
`);return}process.stdout.write(`${H("TURN",22)} ${H("STATUS",9)} ${H("STEPS",5)} ${H("TOKENS",13)} ${H("MS",6)} SOURCE
|
|
300
300
|
`);for(let s of i)if(process.stdout.write(`${H(s.turnId,22)} ${H(s.status,9)} ${H(String(s.steps),5)} ${H(`${s.promptTokens}/${s.outputTokens}`,13)} ${H(String(s.durationMs??"-"),6)} ${s.source}
|
|
301
301
|
`),s.errorCode!==void 0){if(process.stdout.write(` ${s.errorCode}: ${s.errorMessage}
|
|
302
302
|
`),s.errorHint!==void 0)process.stdout.write(` hint: ${s.errorHint}
|
|
303
|
-
`)}}async function Ir(e){let r=await Ie.create({agents:[e.manifestPath],store:e.store??G(),toolProviders:
|
|
303
|
+
`)}}async function Ir(e){let r=await Ie.create({agents:[e.manifestPath],store:e.store??G(),toolProviders:Ae,modelTransports:me,mediaProviders:ce,builtInPlugins:pe,pluginRoot:oe(),scriptRunner:le(),channels:se,env:R([e.manifestPath])});F(()=>r.stop("cli-exit"));let o=r.list()[0];if(o===void 0)throw Error("The manifest produced no agent.");let i=e.limit??No;if(e.clear===!0){if(e.sessionKey===void 0)throw Error("--clear needs a session. hint: pass --session <key>; there is deliberately no way to clear every session at once.");let a=await o.store.messages.count(o.id,e.sessionKey);return await o.clearSession(e.sessionKey),process.stdout.write(`cleared ${e.sessionKey}: ${a} message(s) removed, memory files untouched
|
|
304
304
|
`),n}if(e.json===!0){let a=e.sessionKey===void 0?{store:r.store.location,sessions:await o.sessions()}:{store:r.store.location,session:await o.store.sessions.get(o.id,e.sessionKey),messages:(await o.store.messages.page(o.id,e.sessionKey,{limit:i})).messages,turns:await o.turns(e.sessionKey,i)};return process.stdout.write(`${JSON.stringify(a,null,2)}
|
|
305
305
|
`),n}if(process.stdout.write(`store: ${r.store.location}
|
|
306
306
|
|
|
307
|
-
`),e.sessionKey===void 0)return
|
|
307
|
+
`),e.sessionKey===void 0)return Ba(await o.sessions()),n;if(await o.store.sessions.get(o.id,e.sessionKey)===void 0)return process.stderr.write(`no session "${e.sessionKey}" for agent ${o.id}
|
|
308
308
|
hint: run \`sessions ${e.manifestPath}\` to list the keys that exist
|
|
309
|
-
`),u;if(e.turns===!0)await
|
|
309
|
+
`),u;if(e.turns===!0)await Ja(o,e.sessionKey,i);else await Va(o,e.sessionKey,i);return n}import{existsSync as Xa,readFileSync as za,writeFileSync as Qa}from"node:fs";import{basename as Ya,dirname as Za,join as ed}from"node:path";var nd=/^(#{1,6})\s+(.*)$/,td=/^[ \t]*<rules(?:\s[^>]*)?>[ \t]*$/,sd=/^[ \t]*<\/rules>[ \t]*$/,rd=/^\s*(?:```|~~~)/;function Ar(e){if(e.action!=="distill")throw new t({code:"cli_soul_unknown_action",message:`soul takes the action "distill", not "${e.action}".`,hint:"Usage: soul distill <file> [--out <path>]. It scaffolds a compact identity file from a long-form document; the scaffold is edited by hand and named in context.soul.distilled."});let r;try{r=za(e.file,"utf8")}catch{throw new t({code:"cli_soul_file_missing",message:`${e.file} is not readable.`,hint:"Point soul distill at the long-form identity document named by context.soul.file."})}let o=Ya(e.file),i=e.out??ed(Za(e.file),`${o.replace(/\.md$/i,"")}.compact.md`);if(Xa(i))throw new t({code:"cli_soul_out_exists",message:`${i} already exists, and a scaffold must not overwrite a file someone has edited.`,hint:"The compact file is the hand-edited artefact — regenerating it over someone's edits is exactly the loss automatic distillation would cause. Pass --out with a fresh path, or delete the file first if it really is disposable."});let{body:s}=ro(o,r),a=od(o,s);return Qa(i,a,"utf8"),process.stdout.write(`wrote ${i}
|
|
310
310
|
|
|
311
311
|
The scaffold copies ${o}'s headings and its <rules> blocks verbatim, and leaves a
|
|
312
312
|
{{PLACEHOLDER}} under each heading. Now:
|
|
313
313
|
`+` 1. Fill every placeholder by hand — two or three sentences that must survive, in the
|
|
314
314
|
`+` document's own voice. The workspace command warns until none are left.
|
|
315
315
|
2. Name the file in context.soul.distilled.
|
|
316
|
-
`),n}function
|
|
317
|
-
`)){if(
|
|
316
|
+
`),n}function od(e,r){let o=["---","tier: static","---","","<!--",`Compact identity scaffolded from ${e}. This file is the one small models actually`,"run on, so every sentence here is paid for on every turn — keep it to the few that","produce the voice. The long document stays the source of truth; edit it first, then","re-derive this by hand. These comments are stripped before injection and cost nothing.","-->",""],i=!1,s=!1,a=0,l=!1;for(let c of r.split(`
|
|
317
|
+
`)){if(rd.test(c)){if(i=!i,s)o.push(c);continue}if(i){if(s)o.push(c);continue}if(td.test(c)){s=!0,o.push(c);continue}if(s){if(o.push(c),sd.test(c))s=!1,o.push("");continue}if(nd.exec(c)!==null)l=!0,a+=1,o.push(c),o.push(""),o.push(`{{SECTION_${a}}}`),o.push("")}if(!l)o.push("{{ESSENCE}}"),o.push("");return`${o.join(`
|
|
318
318
|
`).replace(/\n{3,}/g,`
|
|
319
319
|
|
|
320
320
|
`).trimEnd()}
|
|
321
|
-
`}var
|
|
321
|
+
`}var id=["list","add","remove","update","search"],ad=12;async function Or(e){try{switch(e.action){case"list":return dd(e);case"add":return ld(e);case"remove":return ud(e);case"update":return await md(e);case"search":return await fd(e);default:throw new t({code:"sources_action_unknown",message:`${e.action} is not a sources action`,hint:`One of: ${id.join(", ")}.`})}}catch(r){if(f(r))return process.stdout.write(`${r.message}
|
|
322
322
|
|
|
323
323
|
${r.hint}
|
|
324
|
-
`),u;throw r}}function
|
|
324
|
+
`),u;throw r}}function dd(e){let o=Le(e.env).map((i)=>{let s=Xo(i.name,e.env);return{...i,cached:aA(i.name,e.env),commit:s.commit,fetchedAt:s.fetchedAt,skills:s.skills}});if(e.json===!0)return process.stdout.write(`${JSON.stringify({registry:qn(e.env),sources:o},null,2)}
|
|
325
325
|
`),n;if(o.length===0)return process.stdout.write(`every built-in source has been removed, and none has been added
|
|
326
326
|
|
|
327
|
-
\`sources add <name> <url>\` to add one, or \`sources add ${
|
|
327
|
+
\`sources add <name> <url>\` to add one, or \`sources add ${Mt[0]?.name??"anthropic"} ${Mt[0]?.url??""}\` to put a built-in back.
|
|
328
328
|
`),n;process.stdout.write(_("sources",!0));for(let i of o)process.stdout.write(`
|
|
329
329
|
${y(`${i.name}${i.builtin===!0?" (built-in)":""}`)}
|
|
330
330
|
`),process.stdout.write(h(d([{label:"url",value:i.url},...i.path===void 0?[]:[{label:"path",value:i.path}],...i.ref===void 0?[]:[{label:"branch",value:i.ref}],{label:"cached",value:i.cached?`${i.skills??"?"} skills at ${i.commit??"?"}, fetched ${i.fetchedAt??"at an unknown time"}`:"never fetched — `sources update` or just search, which fetches on demand"}]),4));return process.stdout.write(`
|
|
331
331
|
${_("registry")}
|
|
332
332
|
${h(qn(e.env))}
|
|
333
|
-
`),n}function
|
|
333
|
+
`),n}function ld(e){let[r,o]=e.rest;if(r===void 0)throw new t({code:"sources_add_incomplete",message:"sources add needs a repository",hint:"`sources add <url>` names it after the owner, or `sources add <name> <url>` to choose. A .../tree/<branch>/<subdir> page URL is understood."});let i=o!==void 0,s=i?o:r,a=Zo(s),l=i?r:cd(a.url);if(!Tt(l))throw new t({code:"sources_name_invalid",message:`${JSON.stringify(l)} is not usable as a source name`,hint:"Lowercase letters, digits and single hyphens — it becomes a directory in the cache and the prefix in `install <agent> <source>/<skill>`."});let c=Le(e.env).find((w)=>w.name===l);if(c!==void 0&&!i)throw new t({code:"sources_name_taken",message:`${l} is already a source, pointing at ${c.url}`,hint:`Give this one its own name: \`sources add <name> ${s}\`.`});let p=e.path??a.path,g=e.ref??a.ref,m={name:l,url:a.url,...p===void 0?{}:{path:p},...g===void 0?{}:{ref:g}};if(qi(m,e.env),e.json===!0)return process.stdout.write(`${JSON.stringify({added:m},null,2)}
|
|
334
334
|
`),n;return process.stdout.write(`${d([{label:c===void 0?"added":"replaced",value:l},{label:"url",value:m.url},...m.path===void 0?[{label:"path",value:"the whole repository — `--path skills` if the skills live in a subdirectory"}]:[{label:"path",value:m.path}],...m.ref===void 0?[]:[{label:"branch",value:m.ref}]])}
|
|
335
335
|
`),process.stdout.write(`${_("next")}
|
|
336
336
|
${y(`sources update ${l}`)}
|
|
337
337
|
${y("sources search <what you need>")}
|
|
338
|
-
`),n}function
|
|
338
|
+
`),n}function cd(e){let r=e.replace(/\.git$/,"").split(/[:/]/).filter((i)=>i.length>0);return(r[r.length-2]??"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function ud(e){let r=e.rest[0];if(r===void 0)throw new t({code:"sources_remove_incomplete",message:"sources remove needs a name",hint:"`sources list` shows them."});let o=Le(e.env).map((s)=>s.name);if(!Vi(r,e.env)){let s=Y(r,o);throw new t({code:"sources_unknown",message:`no source called ${r}`,hint:s===void 0?`Configured: ${o.join(", ")||"none"}.`:`Did you mean ${s}?`})}let i=Mt.some((s)=>s.name===r);return process.stdout.write(`removed ${r}${i?" — a built-in, so it stays out until `sources add` puts it back":""}
|
|
339
339
|
`),process.stdout.write(`
|
|
340
340
|
The cached copy is left on disk; nothing already installed into an agent is touched.
|
|
341
|
-
`),n}async function
|
|
341
|
+
`),n}async function md(e){let r=Le(e.env),o=e.rest.length===0?r:e.rest.map((a)=>{let l=r.find((c)=>c.name===a);if(l===void 0){let c=Y(a,r.map((p)=>p.name));throw new t({code:"sources_unknown",message:`no source called ${a}`,hint:c===void 0?`Configured: ${r.map((p)=>p.name).join(", ")||"none"}.`:`Did you mean ${c}?`})}return l});if(o.length===0)return process.stdout.write(`no sources configured
|
|
342
342
|
|
|
343
343
|
\`sources add <url>\` to add one.
|
|
344
|
-
`),n;let i=[],s=[];for(let a of o){if(e.json!==!0)process.stdout.write(`fetching ${a.name} … `);try{let l=await
|
|
344
|
+
`),n;let i=[],s=[];for(let a of o){if(e.json!==!0)process.stdout.write(`fetching ${a.name} … `);try{let l=await Rt(a,{...e.env===void 0?{}:{env:e.env},...e.git===void 0?{}:{git:e.git}});if(i.push({name:a.name,commit:l.commit,skills:l.skills}),e.json!==!0)process.stdout.write(`${l.skills} skills at ${l.commit}${l.unfiltered&&a.path!==void 0?" (full clone — the server refused a partial one)":""}
|
|
345
345
|
`)}catch(l){let c=l instanceof Error?l.message:String(l);if(s.push({name:a.name,reason:c}),e.json!==!0)process.stdout.write(`failed
|
|
346
346
|
`);if(e.json!==!0&&f(l))process.stdout.write(`${h(l.message)}
|
|
347
347
|
${h(l.hint,4)}
|
|
348
348
|
`)}}if(e.json===!0)process.stdout.write(`${JSON.stringify({updated:i,failed:s},null,2)}
|
|
349
|
-
`);return i.length===0?u:n}async function
|
|
349
|
+
`);return i.length===0?u:n}async function fd(e){let r=e.rest.join(" ").trim(),o=Le(e.env);if(o.length===0)return process.stdout.write(`no sources configured
|
|
350
350
|
|
|
351
351
|
\`sources add <url>\` to add one.
|
|
352
|
-
`),u;let i=o.filter((c)=>!aA(c.name,e.env));for(let c of i){if(e.json!==!0)process.stdout.write(`fetching ${c.name} for the first time … `);try{let p=await
|
|
352
|
+
`),u;let i=o.filter((c)=>!aA(c.name,e.env));for(let c of i){if(e.json!==!0)process.stdout.write(`fetching ${c.name} for the first time … `);try{let p=await Rt(c,{...e.env===void 0?{}:{env:e.env},...e.git===void 0?{}:{git:e.git}});if(e.json!==!0)process.stdout.write(`${p.skills} skills
|
|
353
353
|
`)}catch(p){if(e.json!==!0){if(process.stdout.write(`failed
|
|
354
354
|
`),f(p))process.stdout.write(`${h(p.message)}
|
|
355
|
-
`)}}}let s=o.flatMap((c)=>
|
|
355
|
+
`)}}}let s=o.flatMap((c)=>vA(c,e.env));if(s.length===0)return process.stdout.write(`
|
|
356
356
|
nothing to search — no source has been fetched successfully
|
|
357
357
|
|
|
358
358
|
\`sources update\` reports why.
|
|
359
|
-
`),u;let a=r.length===0?s:
|
|
359
|
+
`),u;let a=r.length===0?s:pd(r,s);if(a.length===0)return process.stdout.write(`
|
|
360
360
|
nothing in ${s.length} skills across ${o.length} sources matches ${JSON.stringify(r)}
|
|
361
361
|
|
|
362
362
|
Try the words a skill's own description would use — the ranking is lexical, not semantic. \`sources search\` with no query lists everything.
|
|
363
363
|
`),n;if(e.json===!0)return process.stdout.write(`${JSON.stringify({query:r,searched:s.length,results:a.map((c)=>({source:c.source,skill:c.skill,description:c.description,tokens:c.tokens,scripts:c.scripts.length,repoPath:c.repoPath,...c.problem===void 0?{}:{problem:c.problem}}))},null,2)}
|
|
364
|
-
`),n;let l=a.slice(0,
|
|
364
|
+
`),n;let l=a.slice(0,ad);process.stdout.write(`
|
|
365
365
|
${_(r.length===0?`${s.length} skills`:`${a.length} of ${s.length} skills match ${JSON.stringify(r)}`,!0)}
|
|
366
366
|
`);for(let c of l){process.stdout.write(`${y(`${c.source}/${c.skill}`)} ${c.tokens} tokens${c.scripts.length===0?"":`, ${c.scripts.length} runnable file${c.scripts.length===1?"":"s"}`}${c.problem===void 0?"":" — will not load"}
|
|
367
367
|
`);let p=c.problem??c.description;process.stdout.write(`${h(p.length>160?`${p.slice(0,157)}…`:p,4)}
|
|
@@ -370,15 +370,15 @@ ${h(`… and ${a.length-l.length} more; narrow the query or use --json`)}
|
|
|
370
370
|
`);return process.stdout.write(`
|
|
371
371
|
${_("install")}
|
|
372
372
|
${h(`skills install <agent> ${l[0]?.source}/${l[0]?.skill}`)}
|
|
373
|
-
`),n}function
|
|
373
|
+
`),n}function pd(e,r){let o=new Map,i=r.map((s)=>{let a=`${s.source}/${s.skill}`;return o.set(a,s),{name:a,dir:s.dir,tokens:s.tokens,scripts:[],ignoredScripts:[],frontmatter:{name:a,description:s.description,metadata:{}}}});return Ht(e,i).filter((s)=>s.score>0).map((s)=>o.get(s.skill.name)).filter((s)=>s!==void 0)}async function Nr(e){let r=hd(e.manifestPath),o=await zo(r,e.store),i=[];if(o?.enabled===!0)i.push("was already switched on");await Wo(r,!0,void 0,e.store);let s=await Ye(e.store),a=!1;if(s===void 0)i.push("nothing is serving yet — it will be hosted at the next start");else if(s.baseUrl===void 0)i.push(`pid ${s.pid} is a ${s.mode} session, which serves no HTTP to adopt into`);else{let l=await sA(s,`/v1/agents/${encodeURIComponent(r)}/start`,{},e.manifestPath);if(l.ok)a=!0,i.push(`adopted by pid ${s.pid}, live now`);else if(l.status===501)i.push(`pid ${s.pid} cannot look up manifests — restart it to pick this up`);else if(l.status===401)i.push(`pid ${s.pid} refused the request — set ${A.envPrefix}API_TOKEN to the server's token`);else i.push(`pid ${s.pid} could not adopt it${l.detail===void 0?"":`: ${l.detail}`}`)}if(e.json===!0)process.stdout.write(`${JSON.stringify({started:[{agentId:r,enabled:!0,running:a,...s===void 0?{}:{pid:s.pid,mode:s.mode},note:i.join(" · ")}]},null,2)}
|
|
374
374
|
`);else if(process.stdout.write(`${d([{label:r,value:a?"running":"switched on",note:i.join(" · ")}])}
|
|
375
375
|
`),!a&&s!==void 0&&s.baseUrl!==void 0)process.stdout.write(`
|
|
376
376
|
Switched on but not yet running. \`${A.slug} daemon restart\` picks it up.
|
|
377
|
-
`);return s!==void 0&&s.baseUrl!==void 0&&!a?u:n}function
|
|
378
|
-
`),n;let i=await
|
|
377
|
+
`);return s!==void 0&&s.baseUrl!==void 0&&!a?u:n}function hd(e){let r=v(e);if(r.id===void 0||r.id==="")throw new t({code:"cli_start_agent_id_missing",message:`${e} declares no id, so there is nothing to switch on.`,hint:"Add `id: <name>` to the manifest. The id is what the switch, the sessions and the API paths are all keyed by."});return r.id}async function jr(e){let r=await nn(e.store),o=new Map;for(let a of r){if(a.serving===void 0)continue;let l=await $t(a.manifestPath,e.store);if(l!==void 0)o.set(a.ref,l)}if(e.json===!0)return process.stdout.write(`${JSON.stringify({agents:r.map((a)=>({...a,channels:[...o.get(a.ref)?.values()??[]]}))},null,2)}
|
|
378
|
+
`),n;let i=await kA({action:"status",...e.store===void 0?{}:{store:e.store}});process.stdout.write(`${d(ln(r))}
|
|
379
379
|
`);let s=[];for(let[a,l]of o)for(let c of l.values())s.push({label:`${a} / ${c.id}`,value:c.status,note:c.input!==void 0?`${c.detail??"enter this code"}: ${c.input.payload}`:c.detail??""});if(s.length>0)process.stdout.write(`
|
|
380
380
|
${d(s)}
|
|
381
|
-
`);return i}import{copyFileSync as
|
|
381
|
+
`);return i}import{copyFileSync as gd,existsSync as yd,mkdirSync as wd,readFileSync as bd,writeFileSync as $d}from"node:fs";import{dirname as vd,join as Fr}from"node:path";async function Ur(e){let r=e.env??R([]),o=e.home??r.HOME??"",i=We(r),s=qe(i);if(e.json===!0)return process.stdout.write(`${JSON.stringify({terminal:i,how:s?.how??"unknown",configPath:s?.configPath===void 0?void 0:Fr(o,s.configPath),line:s?.line,steps:s?.steps},null,2)}
|
|
382
382
|
`),s===void 0?u:n;if(process.stdout.write(`${_("shift+enter",!0)}
|
|
383
383
|
${h("⌥ or ⇧ ⏎ already puts a new line in a message, everywhere, with no setup. This command is for shift+⏎, which a terminal can only send once it has been given a key binding.")}
|
|
384
384
|
`),s===void 0)return process.stdout.write(`
|
|
@@ -395,9 +395,9 @@ ${_(s.name)}
|
|
|
395
395
|
${y("⌥⏎ works here today — nothing has to be configured for it")}
|
|
396
396
|
`:`
|
|
397
397
|
${y("then restart the terminal and press shift+⏎ in a session to check it")}
|
|
398
|
-
`),n}return await
|
|
398
|
+
`),n}return await kd(s,{...e,env:r,home:o})}async function kd(e,r){let o=Fr(r.home,e.configPath??""),i=yd(o)?bd(o,"utf8"):"";if(At(i,e))return process.stdout.write(`${h("already configured — a binding for shift+enter is present")}
|
|
399
399
|
${h(XA(o,r.home),4)}
|
|
400
|
-
`),n;let s=
|
|
400
|
+
`),n;let s=Ot(i,e);if(s===void 0)return process.stdout.write(`${h("this file is not in a shape this command can edit safely:")}
|
|
401
401
|
${h(XA(o,r.home),4)}
|
|
402
402
|
${y("add the line below by hand:")}
|
|
403
403
|
${h(e.line??"",4)}
|
|
@@ -406,14 +406,14 @@ ${h(e.line??"",4)}
|
|
|
406
406
|
${y("--dry-run: nothing was written")}
|
|
407
407
|
`),n;if(r.yes!==!0){if(!(r.confirm===void 0?!1:await r.confirm("write this change?")))return process.stdout.write(`
|
|
408
408
|
${y("nothing was written")}
|
|
409
|
-
`),n}try{if(
|
|
409
|
+
`),n}try{if(wd(vd(o),{recursive:!0}),i!=="")gd(o,`${o}.${A.slug}-backup`);$d(o,s,"utf8")}catch(a){return process.stderr.write(`could not write ${o}: ${a instanceof Error?a.message:String(a)}
|
|
410
410
|
`),u}return process.stdout.write(`
|
|
411
411
|
${_("done")}
|
|
412
412
|
${i===""?"":`${h(`a copy of the old file is at ${XA(`${o}.${A.slug}-backup`,r.home)}`)}
|
|
413
413
|
`}${y("restart the terminal, then press shift+⏎ in a session to check it")}
|
|
414
|
-
`),n}async function Dr(e){return e.warm===!0?await
|
|
414
|
+
`),n}async function Dr(e){return e.warm===!0?await Sd(e):await Ed(e)}async function Sd(e){let r=J(e.manifestPath,{env:R([e.manifestPath])}),o=IA(r.manifest.tools).selections,i=r.manifest.tools.pinned;if(o.length===0)return process.stdout.write(`nothing to warm — this manifest configures no tools.providers, so every tool it pins resolves locally.
|
|
415
415
|
`),n;if(i.length===0)return process.stdout.write(`nothing to warm — ${o.map((c)=>c.id).join(", ")} configured but tools.pinned is empty, so there are no schemas to fetch.
|
|
416
|
-
`),n;let s=[],a=new Set;for(let c of o){let p=
|
|
416
|
+
`),n;let s=[],a=new Set;for(let c of o){let p=Ae[c.id];if(p===void 0)return u;let g;try{let m=p({dir:r.dir,env:r.env,config:c.config,agentId:r.manifest.id});if(m.refresh===void 0){for(let w of await m.resolve(i))a.add(w.spec.slug);if(e.json!==!0)process.stdout.write(`${c.id}: nothing to warm — it resolves without a cache.
|
|
417
417
|
`);continue}g=await m.refresh(i)}catch(m){let w=f(m)?`${m.message}
|
|
418
418
|
hint: ${m.hint}`:m instanceof Error?m.message:String(m);process.stdout.write(`${c.id}: not warmed — ${w}
|
|
419
419
|
`);continue}for(let m of i)if(!g.missing.includes(m))a.add(m);s.push({provider:c.id,fetched:g.fetched,changed:[...g.changed],missing:[...g.missing],cachePath:"cachePath"in g&&typeof g.cachePath==="string"?g.cachePath:""})}if(e.json===!0)process.stdout.write(`${JSON.stringify(s,null,2)}
|
|
@@ -421,17 +421,17 @@ ${i===""?"":`${h(`a copy of the old file is at ${XA(`${o}.${A.slug}-backup`,r.ho
|
|
|
421
421
|
`),c.changed.length>0)process.stdout.write(` changed: ${c.changed.join(", ")}
|
|
422
422
|
`);if(c.cachePath!=="")process.stdout.write(` cache: ${c.cachePath}
|
|
423
423
|
`)}let l=i.filter((c)=>!a.has(c));for(let c of l)process.stdout.write(` missing: ${c} — no configured provider has a tool with that slug
|
|
424
|
-
`);return l.length>0?u:n}async function
|
|
425
|
-
`:`${
|
|
426
|
-
`),n}finally{await r.stop("cli-exit")}}import{dirname as Gr,isAbsolute as
|
|
427
|
-
`),n;let P=
|
|
424
|
+
`);return l.length>0?u:n}async function Ed(e){let r=await Ie.create({agents:[e.manifestPath],toolProviders:Ae,modelTransports:me,mediaProviders:ce,builtInPlugins:pe,pluginRoot:oe(),scriptRunner:le(),channels:se,env:R([e.manifestPath])});try{let o=r.list()[0];if(o===void 0)throw Error("The manifest produced no agent.");let i=Ko(o);return process.stdout.write(e.json===!0?`${JSON.stringify(i,null,2)}
|
|
425
|
+
`:`${St(i)}
|
|
426
|
+
`),n}finally{await r.stop("cli-exit")}}import{dirname as Gr,isAbsolute as Pd,resolve as Ze}from"node:path";async function Wr(e){try{let r=v(e.manifestPath),o=await Io({refs:r.plugins??[],agentId:r.id??e.manifestPath,paths:{workspace:Gr(Ze(e.manifestPath)),state:Gr(Ze(e.manifestPath)),manifest:Ze(e.manifestPath)},env:R([e.manifestPath]),bus:new hA({runtimeId:"validate"}),builtIn:pe,pluginRoot:oe(),base:{toolProviders:Ae,modelTransports:me,mediaProviders:ce,channels:se}}),i=J(e.manifestPath,{env:R([e.manifestPath])}),{manifest:s}=i,a=fe(s.model.main.id,s.model.main.capabilities),{workspace:l,warnings:c}=lt(i,a.promptStyle),p=Co(Eo(i,{channels:o.channels})),g=await In(i,{toolProviders:o.toolProviders,modelTransports:o.modelTransports,mediaProviders:o.mediaProviders,channels:o.channels,scriptRunner:o.scriptRunner,middleware:o.middleware});for(let S of g.providers)await S.stop?.();let m=so(s,{env:i.env,transports:new Map([...it,...Object.entries(o.modelTransports)])});Ut(s,{env:i.env,providers:new Map(Object.entries(o.mediaProviders))});let w=jA(l,s.context.rules);if(w!==void 0&&s.context.rules.onExceed==="fail")throw w;let b=[...c,...o.failed,...g.warnings,...g.registry.warnings,...p,...go(s),...ao(s),...w===void 0?[]:[w.toDetail()]],k=s.knowledge===void 0?void 0:uo({dir:Pd(s.knowledge.dir)?s.knowledge.dir:Ze(i.dir,s.knowledge.dir),maxActive:s.knowledge.maxActive,budget:s.knowledge.budget,style:a.promptStyle}),C=["static","volatile","reminder"].map((S)=>{let I=l.files.filter((O)=>O.tier===S).map((O)=>O.name);if(I.length===0)return;return`${S}=${I.join(",")} (${l.tokens[S]}/${s.context.budgets[S]})`}).filter((S)=>S!==void 0).join(" ");if(e.json===!0)return process.stdout.write(`${JSON.stringify({ok:!0,path:i.path,id:s.id,model:s.model.main.id,window:i.window,capabilities:a,workspace:{files:l.files.map((S)=>({name:S.name,tier:S.tier,editable:S.editable,tokens:S.tokens,budget:S.budget})),tokens:l.tokens},knowledge:k===void 0?[]:k.entries.map((S)=>({name:S.name,keywords:S.keywords,tokens:S.tokens})),warnings:b},null,2)}
|
|
427
|
+
`),n;let P=yA(s),x=P.map((S)=>S.role===S.configuredAs?`${S.role}=${S.modelId}`:`${S.role}=→main`).join(" "),M=P.filter((S)=>S.role===S.configuredAs),q=Li({manifestPath:e.manifestPath,rawModelId:r.modelId,apiKeyEnv:s.model.main.apiKeyEnv}).flatMap((S)=>{let I=ki(S.origin);return I===void 0?[]:[` env ${S.variable} — ${I}
|
|
428
428
|
`]}).join("");return process.stdout.write(`ok ${i.path}
|
|
429
429
|
id ${s.id}${s.name===void 0?"":` (${s.name})`}
|
|
430
430
|
models ${x}
|
|
431
|
-
`+
|
|
432
|
-
`+(M.length<2?"":`${M.slice(1).map((S)=>` ${S.role.padEnd(12)} ${S.modelId} · window ${S.window.contextWindow} ${
|
|
431
|
+
`+q+` window ${i.window} ${rt(P[0]?.window)} (reserveOutput ${s.context.reserveOutput}, maxOutput ${a.maxOutput})
|
|
432
|
+
`+(M.length<2?"":`${M.slice(1).map((S)=>` ${S.role.padEnd(12)} ${S.modelId} · window ${S.window.contextWindow} ${rt(S.window)}
|
|
433
433
|
`).join("")}`)+` capabilities thinking=${m.main.capabilities.thinking} promptCache=${m.main.capabilities.promptCache} nativeTools=${m.main.capabilities.nativeTools} strictSchema=${m.main.capabilities.strictSchema}
|
|
434
|
-
`+
|
|
434
|
+
`+Rd(m.main.capabilities.promptCache,s.model.main.id)+` dialect ${s.tools.dialect}
|
|
435
435
|
workspace ${C===""?"(none)":C}
|
|
436
436
|
`+(k===void 0?"":` knowledge ${k.entries.length} entries, maxActive=${k.maxActive}, budget=${k.budget}
|
|
437
437
|
`)+` memory ${s.memory===void 0?"none — nothing is retrieved across sessions":`${s.memory.retriever} at ${s.memory.dir}, maxActive=${s.memory.maxActive}, threshold=${s.memory.threshold}, budget=${s.memory.budget}, history=${s.memory.includeHistory}`}
|
|
@@ -440,11 +440,11 @@ ${i===""?"":`${h(`a copy of the old file is at ${XA(`${o}.${A.slug}-backup`,r.ho
|
|
|
440
440
|
limits maxSteps=${s.limits.maxSteps} turnTimeoutMs=${s.limits.turnTimeoutMs}
|
|
441
441
|
`+b.map((S)=>` warning ${S.message}
|
|
442
442
|
`).join("")),n}catch(r){if(e.json===!0&&f(r))return process.stdout.write(`${JSON.stringify({ok:!1,error:r.toDetail(),details:r.details},null,2)}
|
|
443
|
-
`),u;throw r}}function
|
|
443
|
+
`),u;throw r}}function Rd(e,r){if(e!=="none")return"";return/(^|\/)claude-/i.test(r)?` promptCache none — Anthropic's OpenAI-compatible endpoint does not support
|
|
444
444
|
`+` caching at all, so no request field reaches it. Caching lives on the native
|
|
445
445
|
Messages API, which this runtime does not speak.
|
|
446
446
|
`:` promptCache none — this runtime sends no cache directives. Many endpoints cache
|
|
447
|
-
`+" a stable prefix anyway; `/context` reports what was actually charged.\n"}function Br(e){try{let r=
|
|
447
|
+
`+" a stable prefix anyway; `/context` reports what was actually charged.\n"}function Br(e){try{let r=J(e.manifestPath,{env:R([e.manifestPath])}),{manifest:o}=r,i=fe(o.model.main.id,o.model.main.capabilities),{workspace:s,warnings:a}=lt(r,i.promptStyle),l=[...a,...ni(s.files.map((g)=>({name:g.name,authored:g.authored,tier:g.tier,field:g.field})))],c=jA(s,o.context.rules);if(c!==void 0)l.push(c.toDetail());if(e.json===!0)return process.stdout.write(`${JSON.stringify({ok:l.length===0,path:r.path,promptStyle:i.promptStyle,files:s.files.map((g)=>({name:g.name,tier:g.tier,editable:g.editable,tokens:g.tokens,budget:g.budget})),tokens:s.tokens,findings:l},null,2)}
|
|
448
448
|
`),e.strict===!0&&l.length>0?u:n;let p=i.promptStyle;process.stdout.write(`${r.path}
|
|
449
449
|
rendering delimiters=${p.delimiters} intensity=${p.intensity} examplesIn=${p.examplesIn}
|
|
450
450
|
total ${s.tokens.total} tokens (static ${s.tokens.static}, volatile ${s.tokens.volatile}, reminder ${s.tokens.reminder})
|
|
@@ -457,12 +457,12 @@ no findings
|
|
|
457
457
|
`);return process.stdout.write(`
|
|
458
458
|
${l.length} finding(s)
|
|
459
459
|
`),e.strict===!0?u:n}catch(r){if(e.json===!0&&f(r))return process.stdout.write(`${JSON.stringify({ok:!1,error:r.toDetail(),details:r.details},null,2)}
|
|
460
|
-
`),u;throw r}}function
|
|
460
|
+
`),u;throw r}}function xd(e){if(f(e))process.stderr.write(`${e.format()}
|
|
461
461
|
`);else if(e instanceof Error){if(process.stderr.write(`${e.message}
|
|
462
462
|
`),HA().debug&&e.stack!==void 0)process.stderr.write(`${e.stack}
|
|
463
463
|
`)}else process.stderr.write(`${String(e)}
|
|
464
|
-
`);return u}async function
|
|
465
|
-
`),n;case"help":return process.stdout.write($n(r.command)),n;case"usage":return process.stdout.write($n()),u;case"command":break}let{command:o,positionals:i,flags:s}=r.parsed,a=i[0],l=()=>ve(a),c=o.flags.some((m)=>m.name==="store")?s.str("store"):void 0,p=await Jo({needsServer:o.needsServer,disabled:s.bool("no-bootstrap"),install:()=>qo(),...c===void 0?{}:{store:c}}),g=
|
|
464
|
+
`);return u}async function Td(e){let r=Hi(e);switch(r.kind){case"version":return process.stdout.write(`${j}
|
|
465
|
+
`),n;case"help":return process.stdout.write($n(r.command)),n;case"usage":return process.stdout.write($n()),u;case"command":break}let{command:o,positionals:i,flags:s}=r.parsed,a=i[0],l=()=>ve(a),c=o.flags.some((m)=>m.name==="store")?s.str("store"):void 0,p=await Jo({needsServer:o.needsServer,disabled:s.bool("no-bootstrap"),install:()=>qo(),...c===void 0?{}:{store:c}}),g=wt(p);if(g!==void 0)process.stderr.write(g);switch(o.name){case"init":{let m=s.str("dir"),w=s.str("user"),b=s.str("name"),k=s.str("purpose"),C=s.str("preset"),P=s.str("model"),x=s.str("base-url"),M=s.str("api-key-env"),q=s.str("system"),S=s.str("web"),I=s.str("web-backend"),O=s.str("composio"),K=s.str("telegram"),U=s.str("telegram-allow"),N=s.str("whatsapp"),W=s.str("whatsapp-number"),ue=s.str("server"),ee=s.str("schedules"),B=s.str("skills"),$e=s.str("daemon");return await gt({...m===void 0?{}:{dir:m},...w===void 0?{}:{user:w},...b===void 0?{}:{name:b},...k===void 0?{}:{purpose:k},...C===void 0?{}:{preset:C},...P===void 0?{}:{model:P},...x===void 0?{}:{baseUrl:x},...M===void 0?{}:{apiKeyEnv:M},...q===void 0?{}:{system:q},...S===void 0?{}:{web:S},...I===void 0?{}:{webBackend:I},...O===void 0?{}:{composio:O},...K===void 0?{}:{telegram:K},...ee===void 0?{}:{schedules:ee},...U===void 0?{}:{telegramAllow:U},...N===void 0?{}:{whatsapp:N},...W===void 0?{}:{whatsappNumber:W},...ue===void 0?{}:{server:ue},...B===void 0?{}:{skills:B},...$e===void 0?{}:{daemon:$e},yes:s.bool("yes"),plain:s.bool("plain"),installServer:qo})}case"run":{let m=s.str("session"),w=s.str("input"),b=s.str("store");return await Mn({...i[0]===void 0?{}:{manifestPath:l()},...m===void 0?{}:{sessionKey:m},continueSession:s.bool("continue"),...w===void 0?{}:{once:w},...b===void 0?{}:{store:b},ephemeral:s.bool("ephemeral"),quiet:s.bool("quiet"),showReasoning:s.bool("show-reasoning"),noReasoning:s.bool("no-reasoning"),...s.bool("no-enhanced-keys")?{noEnhancedKeys:!0}:{},plain:s.bool("plain")})}case"schedules":{let m=s.str("store"),w=s.str("id"),b=s.str("enable"),k=s.str("disable");return await gr({manifestPath:l(),...m===void 0?{}:{store:m},...w===void 0?{}:{id:w},...b===void 0?{}:{enable:b},...k===void 0?{}:{disable:k},recipients:s.bool("recipients"),json:s.bool("json")})}case"sessions":{let m=s.str("session"),w=s.str("store"),b=s.num("limit");return await Ir({manifestPath:l(),...m===void 0?{}:{sessionKey:m},...w===void 0?{}:{store:w},...b===void 0?{}:{limit:b},json:s.bool("json"),clear:s.bool("clear"),turns:s.bool("turns")})}case"memory":{let m=s.num("limit"),w=s.str("store");return await Jt({action:a,manifestPath:ve(i[1]??""),...i[2]===void 0?{}:{query:i[2]},...m===void 0?{}:{limit:m},...w===void 0?{}:{store:w},all:s.bool("all"),json:s.bool("json")})}case"config":{let{configCommand:m,readAction:w}=await import("./config-29kq9vdx.js"),b=w(a,i[1]);return await m({action:b.action,...b.ref===void 0?{}:{ref:b.ref},...i[2]===void 0?{}:{name:i[2]},...i[3]===void 0?{}:{value:i[3]},...s.str("channel")===void 0?{}:{channel:s.str("channel")},remove:s.bool("remove"),yes:s.bool("yes"),...s.str("store")===void 0?{}:{store:s.str("store")}})}case"validate":return await Wr({manifestPath:l(),json:s.bool("json")});case"workspace":return Br({manifestPath:l(),json:s.bool("json"),strict:s.bool("strict")});case"soul":{let m=s.str("out");return Ar({action:a,file:i[1],...m===void 0?{}:{out:m}})}case"skills":{if(i.length===0)return await zi({plain:s.bool("plain"),json:s.bool("json")});let m=i[2];return GA({action:a,manifestPath:ve(i[1]??""),...m===void 0?{}:{name:m},json:s.bool("json"),strict:s.bool("strict")})}case"sources":{let m=s.str("path"),w=s.str("ref");return await Or({action:a,rest:i.slice(1),...m===void 0?{}:{path:m},...w===void 0?{}:{ref:w},json:s.bool("json")})}case"channels":{let m=Yi("channels",a),w=m.ref??i[1]??"",{channelsCommand:b}=await import("./channels-yshcsfap.js");return await b({...m.action===void 0?{}:{action:m.action},manifestPath:ve(w),...i[2]===void 0?{}:{channelId:i[2]},json:s.bool("json"),installServer:qo})}case"plugins":{let m=s.str("ref"),w=s.str("name");return await ks({action:a,manifestPath:ve(i[1]??""),rest:i.slice(2),...m===void 0?{}:{ref:m},...w===void 0?{}:{name:w},json:s.bool("json")})}case"agents":{let m=s.str("store");return await et({manifestPaths:i.map((w)=>ve(w)),...m===void 0?{}:{store:m},json:s.bool("json")})}case"restart":{let m=s.str("store");return await Gs({...a===void 0?{}:{manifestPath:l()},...m===void 0?{}:{store:m},json:s.bool("json")})}case"status":{let m=s.str("store");return await jr({...m===void 0?{}:{store:m},json:s.bool("json")})}case"logs":{let m=s.num("lines"),w=s.str("store");return await kA({action:"logs",...a===void 0?{}:{manifestPath:l()},...m===void 0?{}:{lines:m},follow:s.bool("follow"),truncate:s.bool("truncate"),...w===void 0?{}:{store:w},json:s.bool("json")})}case"serve":{let m=s.num("port"),w=s.str("host"),b=s.str("store");return await Tr({manifestPaths:i.map((k)=>ve(k)),...m===void 0?{}:{port:m},...w===void 0?{}:{host:w},...b===void 0?{}:{store:b},claim:s.bool("claim"),json:s.bool("json")})}case"keys":return await Ct({noEnhancedKeys:s.bool("no-enhanced-keys")});case"terminal-setup":return await Ur({dryRun:s.bool("dry-run"),yes:s.bool("yes"),json:s.bool("json"),confirm:bt});case"remove":return await Ks({...a===void 0?{}:{ref:a},dryRun:s.bool("dry-run"),filesOnly:s.bool("files-only"),prune:s.bool("prune"),all:s.bool("all"),yes:s.bool("yes"),json:s.bool("json"),...s.str("store")===void 0?{}:{store:s.str("store")},confirm:vi});case"stop":{let m=s.str("reason");return await ze({...a===void 0?{}:{manifestPath:l()},dryRun:s.bool("dry-run"),...m===void 0?{}:{reason:m},...s.str("store")===void 0?{}:{store:s.str("store")},json:s.bool("json")})}case"start":return await Nr({manifestPath:l(),...s.str("store")===void 0?{}:{store:s.str("store")},json:s.bool("json")});case"web":{let{webCommand:m}=await import("./web-10856pm1.js");return await m({action:a,...i[1]===void 0?{}:{manifestPath:ve(i[1])},noOpen:s.bool("no-open"),...s.str("store")===void 0?{}:{store:s.str("store")},json:s.bool("json")})}case"credential":{let{credentialCommand:m}=await import("./credential-3d0edjdj.js");return await m({action:a??"",...i[1]===void 0?{}:{keyId:i[1]},...s.str("label")===void 0?{}:{label:s.str("label")},...s.str("agents")===void 0?{}:{agents:s.str("agents")},...s.str("sessions")===void 0?{}:{sessions:s.str("sessions")},...s.str("can")===void 0?{}:{can:s.str("can")},...s.str("expires")===void 0?{}:{expires:s.str("expires")},...s.str("store")===void 0?{}:{store:s.str("store")},json:s.bool("json")})}case"daemon":{let m=s.num("lines");return await kA({action:a,...i[1]===void 0?{}:{manifestPath:ve(i[1])},...m===void 0?{}:{lines:m},follow:s.bool("follow"),truncate:s.bool("truncate"),dryRun:s.bool("dry-run"),...s.str("store")===void 0?{}:{store:s.str("store")},json:s.bool("json")})}case"model":{let m=s.num("price");return await us({manifestPath:ve(i[1]),window:s.bool("window"),...m===void 0?{}:{price:m},write:s.bool("write"),yes:s.bool("yes"),json:s.bool("json")})}case"tools":return await Dr({manifestPath:l(),warm:s.bool("warm"),json:s.bool("json")});default:throw new t({code:"cli_command_unwired",message:`Command "${o.name}" is declared but not wired up.`,hint:"Add a case for it in src/index.ts."})}}qt();As();await Td(process.argv.slice(2)).catch(xd).then((e)=>tr(e));
|
|
466
466
|
|
|
467
|
-
//# debugId=
|
|
467
|
+
//# debugId=63C25D449BF754B864756E2164756E21
|
|
468
468
|
//# sourceMappingURL=index.js.map
|