agentix-cli 0.172.0 → 0.174.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/{App-56QIEQGH.js → App-DYS5IYTQ.js} +2 -2
- package/dist/{ChatApp-JNWIXMDN.js → ChatApp-ZZHEP2P7.js} +2 -2
- package/dist/{absorb-eval-BYYFZJCC.js → absorb-eval-YMRCIJCC.js} +2 -2
- package/dist/{adapter-YQ37MDPV.js → adapter-YTOLYEJ4.js} +2 -2
- package/dist/{agent-4637FJMD.js → agent-5FQHQ7NG.js} +2 -2
- package/dist/{board-dashboard-DJKRLABN.js → board-dashboard-ORELMK25.js} +469 -347
- package/dist/board-dashboard-ORELMK25.js.map +1 -0
- package/dist/{chunk-WVPFWUR2.js → chunk-2OGM6LGX.js} +2 -2
- package/dist/{chunk-WO4XKOMM.js → chunk-3KHPKKRT.js} +2 -2
- package/dist/{chunk-TAUXWIYB.js → chunk-5OPKQY36.js} +2 -2
- package/dist/{chunk-ES236GV6.js → chunk-6OXJGHWA.js} +2 -2
- package/dist/{chunk-5KVTIFRY.js → chunk-6VJLN66C.js} +2 -2
- package/dist/{chunk-XCYGF4RB.js → chunk-A4L7WH3R.js} +2 -2
- package/dist/{chunk-SP7VFTXO.js → chunk-A6SVCE62.js} +2 -2
- package/dist/chunk-AJ5HMDRW.js +11 -0
- package/dist/chunk-AJ5HMDRW.js.map +1 -0
- package/dist/{chunk-KE3KLMMK.js → chunk-C3RSVAKB.js} +2 -2
- package/dist/{chunk-MY7C6E4Y.js → chunk-DAILRO2V.js} +2 -2
- package/dist/{chunk-PD5BZYBO.js → chunk-DGWLDVU2.js} +2 -2
- package/dist/{chunk-IPHFWU2F.js → chunk-DMLES42J.js} +2 -2
- package/dist/{chunk-35I76HQS.js → chunk-EMIEBF5B.js} +2 -2
- package/dist/{chunk-VD2P4GWU.js → chunk-FRR6DRLY.js} +2 -2
- package/dist/{chunk-NR5IZJYS.js → chunk-H6I42JBS.js} +2 -2
- package/dist/{chunk-NGGEGY5K.js → chunk-ICXHX2QO.js} +16 -16
- package/dist/chunk-ICXHX2QO.js.map +1 -0
- package/dist/{chunk-35R7Y7BT.js → chunk-KZKTVGL7.js} +2 -2
- package/dist/{chunk-FOTAGQEL.js → chunk-LGAZ66CL.js} +2 -2
- package/dist/{chunk-AQGQLVCD.js → chunk-LWMKOWIX.js} +2 -2
- package/dist/{chunk-LB55Q3K4.js → chunk-MABUBCEL.js} +2 -2
- package/dist/{chunk-7FGJOVML.js → chunk-PBEO46ER.js} +2 -2
- package/dist/{chunk-TB3ZEMTC.js → chunk-SMKVNZVI.js} +2 -2
- package/dist/{chunk-I7EO2WXC.js → chunk-T3T4CT3A.js} +2 -2
- package/dist/{chunk-HZXLZIB4.js → chunk-VCGTZS3T.js} +2 -2
- package/dist/chunk-VQRY4IDI.js +4 -0
- package/dist/chunk-VQRY4IDI.js.map +1 -0
- package/dist/{chunk-GALI5ANI.js → chunk-W26TO6HY.js} +3 -3
- package/dist/{chunk-2BJ7NIGG.js → chunk-X3I2VJ5H.js} +2 -2
- package/dist/{chunk-YLQZFV6Y.js → chunk-XJA4ABH4.js} +2 -2
- package/dist/{chunk-7NA5VSQE.js → chunk-XPMDJJI4.js} +277 -273
- package/dist/chunk-XPMDJJI4.js.map +1 -0
- package/dist/{chunk-XUT4RBU6.js → chunk-Y7MYDM4V.js} +2 -2
- package/dist/{chunk-MH55YCUS.js → chunk-YBAGESBG.js} +97 -97
- package/dist/chunk-YBAGESBG.js.map +1 -0
- package/dist/cli.js +1 -1
- package/dist/client-HZKF3XY6.js +2 -0
- package/dist/{config-IBOY7BGF.js → config-WBW2WCS2.js} +2 -2
- package/dist/config-mutate-YJI2JEMP.js +2 -0
- package/dist/config-mutator-GOYUMGWG.js +2 -0
- package/dist/{contributions-NQ3OQ4O4.js → contributions-HJPRWHSN.js} +2 -2
- package/dist/{doctor-AMX2GRRN.js → doctor-NM45LR6S.js} +2 -2
- package/dist/{follow-up-tool-3XSPNZKM.js → follow-up-tool-S7GBNJE6.js} +2 -2
- package/dist/{grants-4O2VF2YX.js → grants-Z332LOTO.js} +2 -2
- package/dist/hub-QN4HRLGZ.js +2 -0
- package/dist/index.d.ts +115 -55
- package/dist/index.js +1 -1
- package/dist/{note-tool-EZWSB3J3.js → note-tool-ANQWBBZE.js} +2 -2
- package/dist/{program-XKQTHEQ3.js → program-MDS4XDAY.js} +98 -98
- package/dist/program-MDS4XDAY.js.map +1 -0
- package/dist/{promote-4F2H3WEB.js → promote-6BZBQZ2E.js} +2 -2
- package/dist/{query-25FU55U6.js → query-AFQMYQTS.js} +2 -2
- package/dist/{query-settings-5BLTPQQQ.js → query-settings-U32L6542.js} +2 -2
- package/dist/{registry-GROEORK6.js → registry-TRZF4LKY.js} +2 -2
- package/dist/{request-planner-7JLFVL6Y.js → request-planner-PAZEWNOG.js} +2 -2
- package/dist/{review-candidates-MHIKLDT7.js → review-candidates-C5BXFQLG.js} +2 -2
- package/dist/routing-2JCE3J3Q.js +2 -0
- package/dist/schedule-tool-GQ7DMQEV.js +2 -0
- package/dist/scheduler-OLAKDG7M.js +2 -0
- package/dist/{seat-WUEQNCSG.js → seat-G6YNXTEY.js} +2 -2
- package/dist/{select-ASFYQYDU.js → select-3QH2DHIN.js} +2 -2
- package/dist/{set-enabled-6NIDVEZF.js → set-enabled-N4FB3DTD.js} +2 -2
- package/dist/{sprint-tool-APMWCQF3.js → sprint-tool-ZESTW34W.js} +2 -2
- package/dist/{tool-2CKQKDU5.js → tool-CSZO7F77.js} +2 -2
- package/dist/{tool-MKUGBNSW.js → tool-G2DHKUGN.js} +2 -2
- package/dist/{tool-JPSOIPZZ.js → tool-RIUS7A5P.js} +2 -2
- package/dist/wiki-4CT7SXMO.js +2 -0
- package/dist/wiki-enrich-IN7UANOJ.js +2 -0
- package/package.json +1 -1
- package/dist/board-dashboard-DJKRLABN.js.map +0 -1
- package/dist/chunk-7NA5VSQE.js.map +0 -1
- package/dist/chunk-GZIHLADX.js +0 -4
- package/dist/chunk-GZIHLADX.js.map +0 -1
- package/dist/chunk-MH55YCUS.js.map +0 -1
- package/dist/chunk-NGGEGY5K.js.map +0 -1
- package/dist/chunk-PYHR4HXO.js +0 -11
- package/dist/chunk-PYHR4HXO.js.map +0 -1
- package/dist/client-LP4PURY2.js +0 -2
- package/dist/config-mutate-PETOQADF.js +0 -2
- package/dist/config-mutator-2NLZ37LL.js +0 -2
- package/dist/hub-DRCMPJMQ.js +0 -2
- package/dist/program-XKQTHEQ3.js.map +0 -1
- package/dist/routing-ZSGWR6ID.js +0 -2
- package/dist/schedule-tool-2VI5IWZD.js +0 -2
- package/dist/scheduler-J6BGTTMH.js +0 -2
- package/dist/wiki-JR6U5PSV.js +0 -2
- package/dist/wiki-enrich-KFVPA2JG.js +0 -2
- /package/dist/{App-56QIEQGH.js.map → App-DYS5IYTQ.js.map} +0 -0
- /package/dist/{ChatApp-JNWIXMDN.js.map → ChatApp-ZZHEP2P7.js.map} +0 -0
- /package/dist/{absorb-eval-BYYFZJCC.js.map → absorb-eval-YMRCIJCC.js.map} +0 -0
- /package/dist/{adapter-YQ37MDPV.js.map → adapter-YTOLYEJ4.js.map} +0 -0
- /package/dist/{agent-4637FJMD.js.map → agent-5FQHQ7NG.js.map} +0 -0
- /package/dist/{chunk-WVPFWUR2.js.map → chunk-2OGM6LGX.js.map} +0 -0
- /package/dist/{chunk-WO4XKOMM.js.map → chunk-3KHPKKRT.js.map} +0 -0
- /package/dist/{chunk-TAUXWIYB.js.map → chunk-5OPKQY36.js.map} +0 -0
- /package/dist/{chunk-ES236GV6.js.map → chunk-6OXJGHWA.js.map} +0 -0
- /package/dist/{chunk-5KVTIFRY.js.map → chunk-6VJLN66C.js.map} +0 -0
- /package/dist/{chunk-XCYGF4RB.js.map → chunk-A4L7WH3R.js.map} +0 -0
- /package/dist/{chunk-SP7VFTXO.js.map → chunk-A6SVCE62.js.map} +0 -0
- /package/dist/{chunk-KE3KLMMK.js.map → chunk-C3RSVAKB.js.map} +0 -0
- /package/dist/{chunk-MY7C6E4Y.js.map → chunk-DAILRO2V.js.map} +0 -0
- /package/dist/{chunk-PD5BZYBO.js.map → chunk-DGWLDVU2.js.map} +0 -0
- /package/dist/{chunk-IPHFWU2F.js.map → chunk-DMLES42J.js.map} +0 -0
- /package/dist/{chunk-35I76HQS.js.map → chunk-EMIEBF5B.js.map} +0 -0
- /package/dist/{chunk-VD2P4GWU.js.map → chunk-FRR6DRLY.js.map} +0 -0
- /package/dist/{chunk-NR5IZJYS.js.map → chunk-H6I42JBS.js.map} +0 -0
- /package/dist/{chunk-35R7Y7BT.js.map → chunk-KZKTVGL7.js.map} +0 -0
- /package/dist/{chunk-FOTAGQEL.js.map → chunk-LGAZ66CL.js.map} +0 -0
- /package/dist/{chunk-AQGQLVCD.js.map → chunk-LWMKOWIX.js.map} +0 -0
- /package/dist/{chunk-LB55Q3K4.js.map → chunk-MABUBCEL.js.map} +0 -0
- /package/dist/{chunk-7FGJOVML.js.map → chunk-PBEO46ER.js.map} +0 -0
- /package/dist/{chunk-TB3ZEMTC.js.map → chunk-SMKVNZVI.js.map} +0 -0
- /package/dist/{chunk-I7EO2WXC.js.map → chunk-T3T4CT3A.js.map} +0 -0
- /package/dist/{chunk-HZXLZIB4.js.map → chunk-VCGTZS3T.js.map} +0 -0
- /package/dist/{chunk-GALI5ANI.js.map → chunk-W26TO6HY.js.map} +0 -0
- /package/dist/{chunk-2BJ7NIGG.js.map → chunk-X3I2VJ5H.js.map} +0 -0
- /package/dist/{chunk-YLQZFV6Y.js.map → chunk-XJA4ABH4.js.map} +0 -0
- /package/dist/{chunk-XUT4RBU6.js.map → chunk-Y7MYDM4V.js.map} +0 -0
- /package/dist/{client-LP4PURY2.js.map → client-HZKF3XY6.js.map} +0 -0
- /package/dist/{config-IBOY7BGF.js.map → config-WBW2WCS2.js.map} +0 -0
- /package/dist/{config-mutate-PETOQADF.js.map → config-mutate-YJI2JEMP.js.map} +0 -0
- /package/dist/{config-mutator-2NLZ37LL.js.map → config-mutator-GOYUMGWG.js.map} +0 -0
- /package/dist/{contributions-NQ3OQ4O4.js.map → contributions-HJPRWHSN.js.map} +0 -0
- /package/dist/{doctor-AMX2GRRN.js.map → doctor-NM45LR6S.js.map} +0 -0
- /package/dist/{follow-up-tool-3XSPNZKM.js.map → follow-up-tool-S7GBNJE6.js.map} +0 -0
- /package/dist/{grants-4O2VF2YX.js.map → grants-Z332LOTO.js.map} +0 -0
- /package/dist/{hub-DRCMPJMQ.js.map → hub-QN4HRLGZ.js.map} +0 -0
- /package/dist/{note-tool-EZWSB3J3.js.map → note-tool-ANQWBBZE.js.map} +0 -0
- /package/dist/{promote-4F2H3WEB.js.map → promote-6BZBQZ2E.js.map} +0 -0
- /package/dist/{query-25FU55U6.js.map → query-AFQMYQTS.js.map} +0 -0
- /package/dist/{query-settings-5BLTPQQQ.js.map → query-settings-U32L6542.js.map} +0 -0
- /package/dist/{registry-GROEORK6.js.map → registry-TRZF4LKY.js.map} +0 -0
- /package/dist/{request-planner-7JLFVL6Y.js.map → request-planner-PAZEWNOG.js.map} +0 -0
- /package/dist/{review-candidates-MHIKLDT7.js.map → review-candidates-C5BXFQLG.js.map} +0 -0
- /package/dist/{routing-ZSGWR6ID.js.map → routing-2JCE3J3Q.js.map} +0 -0
- /package/dist/{schedule-tool-2VI5IWZD.js.map → schedule-tool-GQ7DMQEV.js.map} +0 -0
- /package/dist/{scheduler-J6BGTTMH.js.map → scheduler-OLAKDG7M.js.map} +0 -0
- /package/dist/{seat-WUEQNCSG.js.map → seat-G6YNXTEY.js.map} +0 -0
- /package/dist/{select-ASFYQYDU.js.map → select-3QH2DHIN.js.map} +0 -0
- /package/dist/{set-enabled-6NIDVEZF.js.map → set-enabled-N4FB3DTD.js.map} +0 -0
- /package/dist/{sprint-tool-APMWCQF3.js.map → sprint-tool-ZESTW34W.js.map} +0 -0
- /package/dist/{tool-2CKQKDU5.js.map → tool-CSZO7F77.js.map} +0 -0
- /package/dist/{tool-MKUGBNSW.js.map → tool-G2DHKUGN.js.map} +0 -0
- /package/dist/{tool-JPSOIPZZ.js.map → tool-RIUS7A5P.js.map} +0 -0
- /package/dist/{wiki-JR6U5PSV.js.map → wiki-4CT7SXMO.js.map} +0 -0
- /package/dist/{wiki-enrich-KFVPA2JG.js.map → wiki-enrich-IN7UANOJ.js.map} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as Ct}from"./chunk-SZDACK6O.js";import{b as Le}from"./chunk-AFRHKA7B.js";import{b as Ut,c as Ht}from"./chunk-VJVXEVZ7.js";import{b as Dt,e as jt,f as Mt,i as Ft,k as _t,l as Lt,r as Bt}from"./chunk-
|
|
1
|
+
import{c as Ct}from"./chunk-SZDACK6O.js";import{b as Le}from"./chunk-AFRHKA7B.js";import{b as Ut,c as Ht}from"./chunk-VJVXEVZ7.js";import{b as Dt,e as jt,f as Mt,i as Ft,k as _t,l as Lt,r as Bt}from"./chunk-MABUBCEL.js";import{b as Wt,d as Ot,e as Nt}from"./chunk-PE5V2LI7.js";import{e as xt,g as Pt,h as Tt,i as _e}from"./chunk-GQ76J72O.js";import{a as Et}from"./chunk-GV7S5BAX.js";import{y as St,z as yr}from"./chunk-6OXJGHWA.js";import{b as $t,f as wr}from"./chunk-72SZI2UW.js";import{a as At,b as Ee,d as Ce,e as Rt,f as Fe}from"./chunk-BERWTVG2.js";import{c as It,d as vt}from"./chunk-QOYAX2FT.js";import{Y as Me,ga as hr}from"./chunk-ICXHX2QO.js";import{j as je,r as mr}from"./chunk-UEEB3UTU.js";import{existsSync as kr,mkdirSync as Kt,readFileSync as br,writeFileSync as Ir,renameSync as vr}from"fs";import{resolve as qt,dirname as $r}from"path";var zt=class{filePath;log;constructor(e={}){let t=e.baseDir??qt(process.cwd(),".agentx");this.filePath=qt(t,"handover.json"),this.log=e.log??console.error.bind(console,"[handover]"),Kt(t,{recursive:!0})}key(e,t,r){return`${e}::${t}::${r||"-"}`}load(){if(!kr(this.filePath))return{version:1,overrides:{}};try{let e=br(this.filePath,"utf-8"),t=JSON.parse(e);return!t||typeof t!="object"?{version:1,overrides:{}}:(t.overrides||(t.overrides={}),t)}catch(e){return this.log(`load failed, starting empty: ${e?.message||e}`),{version:1,overrides:{}}}}save(e){Kt($r(this.filePath),{recursive:!0});let t=`${this.filePath}.tmp-${process.pid}`;Ir(t,JSON.stringify(e,null,2)),vr(t,this.filePath)}get(e,t,r){let s=this.load().overrides[this.key(e,t,r)];if(s&&!(s.expiresAt&&Date.parse(s.expiresAt)<Date.now()))return s}set(e){if(!e.channel||!e.chatId||!e.toAgent)throw new Error("channel, chatId and toAgent are required");let t=this.load(),r={...e,createdAt:e.createdAt??new Date().toISOString()};return t.overrides[this.key(r.channel,r.chatId,r.accountId)]=r,this.save(t),r}remove(e,t,r){let o=this.load(),s=this.key(e,t,r);return s in o.overrides?(delete o.overrides[s],this.save(o),!0):!1}consumeSummary(e,t,r){let o=this.load(),s=o.overrides[this.key(e,t,r)];if(!s||!s.summary||s.summaryConsumedAt)return;let a=s.summary;return s.summaryConsumedAt=new Date().toISOString(),this.save(o),a}listActive(){let e=this.load(),t=Date.now();return Object.values(e.overrides).filter(r=>!r.expiresAt||Date.parse(r.expiresAt)>=t)}listByAgent(e){let t=this.listActive();return{incoming:t.filter(r=>r.toAgent===e),outgoing:t.filter(r=>r.fromAgent===e)}}};import{readFileSync as Qt,writeFileSync as Ue,appendFileSync as xr,mkdirSync as Pr,existsSync as Zt,statSync as Tr}from"fs";import{resolve as ce}from"path";var Jt="[Agent Memory \u2014 persistent facts from past conversations]",Sr=2400;function Yt(n,e){return n?`UNVERIFIED (${e===null?"age unknown":`${e}d old`}) `:""}function Ar(n,e=Date.now()){let t=Ot(n,e),r=n.undated?"UNVERIFIED (never checked) ":Yt(t,xt(n.verifiedAt,e));return{line:`- [wiki ${n.id}] ${r}${n.subject} \xB7 ${n.attribute}: ${n.value} (${n.source}, checked ${n.verifiedAt.slice(0,10)} by ${n.verifiedBy})`,unverified:t}}function Rr(n,e){let r=!n.source.chatId.startsWith("-")&&/^\d+$/.test(n.source.chatId)?"DM":n.source.chatId,o=Tt(n,e);return{line:`- [${n.category}] ${Yt(o,Pt(n,e))}${n.content} (${r}, ${n.source.date})`,unverified:o}}function Gt(n,e=[],t=Date.now()){let r=[],o=new Set,s=Jt.length,a=!1;for(let i of n){let d=e.length>0?Nt(i.content,e):null,l,c,p=d&&Date.parse(i.createdAt)>Date.parse(d.verifiedAt)&&!i.content.toLowerCase().includes(d.value.toLowerCase());if(d&&!p){if(o.has(d.id))continue;o.add(d.id),l=Ar(d,t),c=d.id}else l=Rr(i,t),d&&(l.line+=` [differs from wiki ${d.id}]`);let f=l.unverified&&!a?_e.length:0;if(s+f+l.line.length>Sr)break;r.push({fact:i,...l,...c?{wikiRef:c}:{}}),s+=f+l.line.length,f&&(a=!0)}return r}function Vt(n){if(n.length===0)return"";let e=n.some(t=>t.unverified)?[_e]:[];return[Jt,...e,...n.map(t=>t.line),"[End Memory]"].join(`
|
|
2
2
|
`)}var Xt=200,Wr=7,en=class{memoryDir;ledger;constructor(e=process.cwd()){this.memoryDir=ce(e,".agentx/memory"),this.ledger=new Wt(ce(e,".agentx/wiki")),Zt(this.memoryDir)||Pr(this.memoryDir,{recursive:!0})}filePath(e){return ce(this.memoryDir,`${e}.jsonl`)}addMemory(e,t){if(t.category==="secret"||Ee(t.content))return!1;let r=t.source.trust??At(t.source.channel),o=t.review??Rt(r),s={...t,source:{...t.source,trust:r},...o?{review:o}:{},id:`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,6)}`,createdAt:new Date().toISOString()};return xr(this.filePath(e),JSON.stringify(s)+`
|
|
3
3
|
`),!0}parsedCache=new Map;getAll(e){let t=this.filePath(e);if(!Zt(t))return[];try{let{mtimeMs:r,size:o}=Tr(t),s=this.parsedCache.get(t);if(s&&s.mtimeMs===r&&s.size===o)return s.facts.slice();let i=Qt(t,"utf-8").split(`
|
|
4
4
|
`).filter(d=>d.trim()).map(d=>{try{return JSON.parse(d)}catch{return null}}).filter(d=>d!==null);return this.parsedCache.set(t,{mtimeMs:r,size:o,facts:i}),i.slice()}catch{return[]}}findRelevant(e,t,r=8){let o=this.getAll(t).filter(Fe);if(o.length===0)return[];let s=o.map(g=>`${g.keywords.join(" ")} ${g.content}`),a=ce(this.memoryDir,`${t}_bm25_cache.json`),i=vt(s,a),d=It(e,i),l=new Map(d.map(g=>[g.docIndex,g.score])),p=o.map((g,m)=>{let y=l.get(m)??0;return g.category==="commitment"&&(y+=1),{memory:g,score:y}}).filter(g=>g.score>0);if(p.length===0)return o.slice(-r);let f=p.sort((g,m)=>m.score-g.score).slice(0,r).map(g=>g.memory);if(f.length>0)try{this.recordAccess(t,f.map(g=>g.id))}catch{}return f}buildContext(e){return Vt(this.contextLines(e))}contextFacts(e){return this.contextLines(e).map(t=>t.fact)}contextLines(e){let t=[];try{t=this.ledger.list()}catch{}return Gt(e,t)}recordAccess(e,t){if(t.length===0)return;let r=this.getAll(e),o=new Set(t),s=!1;for(let a of r)if(o.has(a.id)){a.accessCount=(a.accessCount||0)+1,a.lastAccessed=new Date().toISOString();let i=a.intervalDays||1;a.intervalDays=Math.min(i*2,30),a.nextReview=new Date(Date.now()+a.intervalDays*864e5).toISOString(),s=!0}s&&Ue(this.filePath(e),r.map(a=>JSON.stringify(a)).join(`
|
|
@@ -39,4 +39,4 @@ ${n.text}`}async function xe(n,e){let t=n.channels[e.channel],r={channel:e.chann
|
|
|
39
39
|
`).filter(Boolean),o=[];for(let s=r.length-1;s>=0&&o.length<t;s--)try{let a=JSON.parse(r[s]);(!e||a.person===e)&&o.push(a)}catch{}return o}load(){if(ht(this.file))try{let e=JSON.parse(wt(this.file,"utf-8"));if(e&&Array.isArray(e.devices))return e}catch{}return{devices:[]}}save(e){Qn(er(this.file),{recursive:!0});let t=`${this.file}.${process.pid}.${nr(4).toString("hex")}.tmp`;Xn(t,JSON.stringify(e,null,2)+`
|
|
40
40
|
`,{encoding:"utf-8",mode:384}),Zn(t,this.file)}};import{extname as ti}from"path";var or=/<agentx-artifact>([\s\S]*?)<\/agentx-artifact>/gi,sr=/<agentx-artifact>[\s\S]*$/i;function Nl(n,e=1/0,t=!1){let r=[],o=String(n??"");if(!/<agentx-artifact>/i.test(o))return{text:o,artifacts:r};let s=o.replace(or,(a,i)=>{try{let d=JSON.parse(i.trim());if(d&&typeof d.filename=="string"&&typeof d.mime=="string"&&r.length<e){let l=d.mime,c=l.startsWith("image/")?"image":l==="application/pdf"?"pdf":l.startsWith("text/")?"text":"file";r.push({type:c,filename:d.filename,mime:l})}}catch{}return""});return{text:(t?s.replace(sr,""):s).trim(),artifacts:r}}function Dl(n,e=!1){let t=String(n??""),r=t;if(/<agentx-artifact>/i.test(t)){let o=t.replace(or,(s,a)=>{try{let i=JSON.parse(a.trim());return i&&typeof i.filename=="string"?i.filename:""}catch{return""}});r=(e?o.replace(sr,""):o).trim()}return r.replace(/```[\s\S]*?```|`[^`\n]*`|!\[([^\]\n]*)\]\(([^)\s]+)\)/g,(o,s,a)=>s===void 0||a===void 0?o:`[${s||a}](${a})`)}var ni={".png":{mime:"image/png",kind:"image"},".jpg":{mime:"image/jpeg",kind:"image"},".jpeg":{mime:"image/jpeg",kind:"image"},".gif":{mime:"image/gif",kind:"image"},".webp":{mime:"image/webp",kind:"image"},".svg":{mime:"image/svg+xml",kind:"file"},".pdf":{mime:"application/pdf",kind:"file"},".txt":{mime:"text/plain; charset=utf-8",kind:"file"},".md":{mime:"text/markdown; charset=utf-8",kind:"file"},".csv":{mime:"text/csv; charset=utf-8",kind:"file"},".json":{mime:"application/json",kind:"file"},".mp3":{mime:"audio/mpeg",kind:"audio"},".m4a":{mime:"audio/mp4",kind:"audio"},".wav":{mime:"audio/wav",kind:"audio"},".mp4":{mime:"video/mp4",kind:"video"},".webm":{mime:"video/webm",kind:"video"}},jl={bytes:20*1024*1024,perMessage:20,pathChars:512};function Ml(n){return ni[ti(n).toLowerCase()]??null}var ri=["[Phone app: showing files]","To show the owner a file you created (a chart, a screenshot, a PDF, a recording), save or copy it into .agentx/outbox/ in your workspace and end your reply with one line per file:",'<agentx-artifact>{"filename":".agentx/outbox/<name.ext>","mime":"<mime/type>"}</agentx-artifact>',"Files outside your workspace (/tmp, your home folder) are refused. Outbox files are removed after 7 days.","The line is removed from the text. Images show in the reply, audio and video get a player, other files an Open link. Allowed: png, jpg, gif, webp, svg, pdf, txt, md, csv, json, mp3, m4a, wav, mp4, webm; up to 20 MB and 20 files per reply.","A picture already on the web can go inline as ."].join(`
|
|
41
41
|
`);function El(n,e,t){return n==="app"&&e&&t!==!1?ri:void 0}import{lstatSync as kt,mkdirSync as oi,readdirSync as si,realpathSync as yt,unlinkSync as ii}from"fs";import{join as Ne,resolve as ir}from"path";var ar=".agentx/outbox",ai=7*24*60*60*1e3;function di(n,e){try{let t=yt(ir(e,n)),r=Ne(t,ar);return yt(r)===r&&kt(r).isDirectory()?r:null}catch{return null}}function Ll(n,e={}){let t=e.cwd??process.cwd();if(e.create!==!1)try{let o=yt(ir(t,n));kt(Ne(o,".agentx"),{throwIfNoEntry:!1})?.isSymbolicLink()||oi(Ne(o,ar),{recursive:!0})}catch{return 0}let r=di(n,t);return r?dr(r,(e.now??Date.now())-(e.maxAgeMs??ai)):0}function dr(n,e){let t=0;for(let r of si(n)){let o=Ne(n,r);try{let s=kt(o);s.isDirectory()?t+=dr(o,e):Math.max(s.mtimeMs,s.ctimeMs)<e&&(ii(o),t++)}catch{}}return t}export{zt as a,en as b,tn as c,Si as d,Dr as e,Ai as f,jr as g,xi as h,Pi as i,Ti as j,Wi as k,Oi as l,Ni as m,Di as n,Cr as o,ji as p,Mi as q,_i as r,qe as s,qr as t,Li as u,Ui as v,zr as w,Hi as x,ln as y,qi as z,zi as A,cn as B,pn as C,Qr as D,Qi as E,Zi as F,ta as G,na as H,O as I,te as J,S as K,he as L,go as M,Ve as N,L as O,Xe as P,tt as Q,pt as R,Is as S,xs as T,gt as U,No as V,Us as W,el as X,tl as Y,nl as Z,rl as _,ol as $,Hs as aa,Bs as ba,sl as ca,il as da,al as ea,dl as fa,cl as ga,pl as ha,fl as ia,gl as ja,ml as ka,hl as la,wl as ma,yl as na,kl as oa,bl as pa,Il as qa,Gs as ra,vl as sa,$l as ta,Sl as ua,Al as va,rr as wa,Nl as xa,Dl as ya,jl as za,Ml as Aa,El as Ba,ar as Ca,Ll as Da};
|
|
42
|
-
//# sourceMappingURL=chunk-
|
|
42
|
+
//# sourceMappingURL=chunk-DGWLDVU2.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{ob as l,xb as m}from"./chunk-ICXHX2QO.js";m();import{existsSync as g,readFileSync as u,writeFileSync as a,copyFileSync as y}from"fs";import{resolve as p}from"path";function P(e,n={}){let t=n.configPath||p(process.cwd(),"agentx.json");if(!g(t))throw new Error(`agentx.json not found at ${t}`);let i=JSON.parse(u(t,"utf-8")),o=e(i),s=typeof o=="string"?{summary:o}:o,c=JSON.stringify(i,null,2)+`
|
|
2
2
|
`,f=t+".tmp";a(f,c,"utf-8");try{JSON.parse(u(f,"utf-8"))}catch(d){throw new Error(`config did not round-trip cleanly: ${d.message}`)}let r;return n.skipBackup||(r=`${t}.bak.${Date.now()}`,y(t,r)),a(t,c,"utf-8"),n.skipReload||h().catch(()=>{}),{summary:s.summary,payload:s.payload,backupPath:r}}function S(e,n={}){let t=n.configPath||p(process.cwd(),"agentx.json");if(g(t)&&!n.overwrite)throw new Error(`agentx.json already exists at ${t}. Pass overwrite=true to replace it.`);return a(t,JSON.stringify(e,null,2)+`
|
|
3
3
|
`,"utf-8"),{file:t}}async function h(){try{let n=l().dashboard.daemonUrl?.replace(/\/+$/,"")||"http://127.0.0.1:18800";await fetch(`${n}/reload`,{method:"POST"}).catch(()=>null)}catch{}}export{P as a,S as b};
|
|
4
|
-
//# sourceMappingURL=chunk-
|
|
4
|
+
//# sourceMappingURL=chunk-DMLES42J.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{e as g}from"./chunk-
|
|
1
|
+
import{e as g}from"./chunk-W26TO6HY.js";async function $(e,i,r,n,o={}){let a=o.retrieve??g,c=o.perEntry??2,s=o.maxArticles??8,f=o.queryChars??1500,h=new Map;for(let t of e){let l=[];try{l=await a(t.content.slice(0,f),i,r,{pool:n,maxCandidates:c,maxHops:1,maxArticles:c*2,stage:"absorb-covering"})}catch{}for(let u of l){let p=h.get(u.path);p?(p.hop=Math.min(p.hop,u.hop),p.entries.includes(t.id)||p.entries.push(t.id)):h.set(u.path,{...u,entries:[t.id]})}}return[...h.values()].sort((t,l)=>t.hop-l.hop||l.entries.length-t.entries.length||t.path.localeCompare(l.path)).slice(0,s)}function x(e){if(e.length===0)return"";let i=e.map(r=>{let n=`### ${r.meta.title} \u2014 ${r.meta.type||"untyped"} (${r.path})`,o=`Found for entries: ${r.entries.join(", ")}${r.hop>0?" (linked from a match)":""}`,a=r.meta.related?.length?`Related: ${r.meta.related.join(", ")}`:"";return[n,o,a,"",r.content].filter(c=>c!=="").join(`
|
|
2
2
|
`)}).join(`
|
|
3
3
|
|
|
4
4
|
---
|
|
@@ -14,4 +14,4 @@ These ${e.length} articles were found by searching the wiki for each entry below
|
|
|
14
14
|
|
|
15
15
|
${i}
|
|
16
16
|
`}var d=/\bhttps?:\/\/[^\s<>"'`)\]]+/gi,y=/\[\[([^\]|]+)(?:\|[^\]]*)?\]\]/g,w=/(?<![\w-])(?=[0-9a-f]*[0-9])(?=[0-9a-f]*[a-f])[0-9a-f]{7,40}(?![\w-])/gi,k=/(?<![\w.,:/-])\d+(?:[.,:\-/]\d+)*(?![\w])/g,C=/^\s*\d+[.)]\s/gm;function A(e){let i=[...e.matchAll(d)].map(s=>s[0].replace(/[.,;:!?'"]+$/,"")),r=[...e.matchAll(y)].map(s=>s[1].trim()),n=e.replace(d," ").replace(y," ").replace(C," "),o=[...n.matchAll(w)].map(s=>s[0].toLowerCase()),c=[...n.replace(w," ").matchAll(k)].map(s=>v(s[0]));return{commits:m(o),urls:m(i),wikilinks:m(r),numbers:m(c)}}function R(e,i){let r=A(e),n=A(i),o=i.toLowerCase(),a=[];for(let t of r.commits)!o.includes(t)&&!n.commits.some(l=>l.startsWith(t)||t.startsWith(l))&&a.push(`commit ${t}`);let c=t=>t.toLowerCase().replace(/\/+$/,""),s=new Set(n.urls.map(c));for(let t of r.urls)s.has(c(t))||a.push(`link ${t}`);let f=new Set(n.wikilinks.map(t=>t.toLowerCase()));for(let t of r.wikilinks)f.has(t.toLowerCase())||a.push(`link [[${t}]]`);let h=new Set(n.numbers);for(let t of r.numbers)h.has(t)||a.push(`number ${t}`);return a}function v(e){return/^\d{1,3}(,\d{3})+$/.test(e)?e.replace(/,/g,""):e}function m(e){return[...new Set(e)]}function L(e,i){if(i.some(n=>n.path===e.path))return e.path;let r=b(e.title);return r?i.find(n=>b(n.title)===r)?.path??e.path:e.path}function b(e){return(e||"").toLowerCase().replace(/[^\p{L}\p{N}]+/gu," ").trim()}export{$ as a,x as b,A as c,R as d,L as e};
|
|
17
|
-
//# sourceMappingURL=chunk-
|
|
17
|
+
//# sourceMappingURL=chunk-EMIEBF5B.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{n as x,p as A}from"./chunk-LQS27HSV.js";import{a as w,e as D}from"./chunk-
|
|
1
|
+
import{n as x,p as A}from"./chunk-LQS27HSV.js";import{a as w,e as D}from"./chunk-VQRY4IDI.js";D();var h="guest:",b="guests",P=7,y=365,T=400;function I(e){let t=e.scopes.find(n=>n.startsWith(h));return t?t.slice(h.length):null}function _(e){return`g-${e.toString(36)}-${Math.random().toString(36).slice(2,6)}`}var l=e=>(Array.isArray(e)?e:typeof e=="string"?e.split(","):[]).map(t=>String(t).trim()).filter(Boolean).slice(0,50);function M(e,t){let n=(e.now??Date.now)(),o=String(t.name??"").trim().slice(0,120),s=String(t.guest??"").trim().slice(0,80);if(!o)return{ok:!1,error:'name is required: what you call this grant, e.g. "Support session for company X"'};if(!s)return{ok:!1,error:"guest is required: the other organisation's name"};if(!t.agentId||!e.hasAgent(t.agentId))return{ok:!1,error:`agent must be an agent on this node, got "${t.agentId??""}"`};let a=w.safeParse(t.level??"propose");if(!a.success)return{ok:!1,error:"level must be report, propose or act"};let r=t.days===void 0?P:Number(t.days);if(!Number.isFinite(r)||r<1||r>y)return{ok:!1,error:`days must be between 1 and ${y}`};let d=_(n),{token:u,record:g}=e.tokens.create({name:`guest ${s} (${o})`,scopes:[`${h}${d}`],expiresInDays:Math.ceil(r)}),{code:i,expiresAt:p}=e.codes.create({token:u,tokenId:g.id,name:d}),c={id:d,name:o,guest:s,agentId:t.agentId,folders:l(t.folders),skills:l(t.skills),commands:l(t.commands),level:a.data,state:"pending",tokenId:g.id,createdAt:new Date(n).toISOString(),expiresAt:new Date(n+r*864e5).toISOString(),usage:{turns:0,tokens:0}};return e.guests.add(c),e.guests.log({grant:d,event:"invited",detail:`${s}: ${o}`}),{ok:!0,code:i,codeExpiresAt:p,grant:c}}var j="That code didn't work. Ask the host for a new one.";async function Y(e,t,n){let o=Date.now(),s=n.now??Date.now,a=n.log??(f=>console.log(f)),r=n.limiter.retryAfter(t);if(r>0)return a(`[guests] join refused from ${t}: locked out for ${r}s more`),{status:429,body:{error:"too many attempts",retryAfter:r},retryAfter:r};let d=n.codes.redeem(e.code),u=d?n.tokens.verify(d.token):null,g=u?I(u):null,i=g?n.guests.get(g):null;if(await L(o,n.minMs??T),!d||!u||!i||i.tokenId!==u.id||i.state==="ended")return n.limiter.fail(t),a(`[guests] join failed from ${t}`),{status:401,body:{error:j}};n.limiter.succeed(t);let p=e.node&&typeof e.node=="object"?e.node:{},c=(f,S)=>typeof f=="string"&&f.trim()?f.replace(/\s+/g," ").trim().slice(0,S):void 0,m={id:c(p.id,80),name:c(p.name,80),address:t},$=i.expiresAt.slice(0,10),k=A(n.root,{title:`Guest mesh: ${i.guest} wants to join`,ask:`Let "${m.name??m.id??"a node"}" at ${t} use ${i.agentId} inside "${i.name}" (${i.level}, until ${$})?`,recommend:`Yes if ${i.guest} told you they are joining now. No if you did not expect it.`,if_silent:"discard",raised_by:b},{now:s()});return k.ok?(n.guests.update(i.id,{guestNode:m,cardId:k.card.id}),n.guests.log({grant:i.id,event:"joined",address:t,detail:m.name??m.id}),a(`[guests] ${i.id}: ${i.guest} joined from ${t}; waiting for the owner (card ${k.card.id})`),{status:200,body:{grant:i.id,name:i.name,agentId:i.agentId,level:i.level,expiresAt:i.expiresAt,state:"pending"},token:d.token}):(a(`[guests] ${i.id}: join from ${t} could not raise a card: ${k.error}`),{status:403,body:{error:"The host cannot take a join right now. Try again later."}})}var G="no grant opens this",R="waiting for the host to approve the join",O="the host paused this grant";function N(e,t){let n=e.now??Date.now,o=e.log??(r=>console.log(r));if(t.state==="ended")return t;if(Date.parse(t.expiresAt)<=n())return o(`[guests] ${t.id}: expired`),v({tokens:e.tokens,guests:e.guests,now:n},t.id,"expired")??t;if(t.state!=="pending")return t;let s=t.cardId?x(e.root,t.cardId):null,a=s?s.status==="decided"?s.verdict:s.status==="expired"?"no":null:null;if(a==="yes"){let r=e.guests.update(t.id,{state:"active",approvedAt:new Date(n()).toISOString()})??t;return e.guests.log({grant:t.id,event:"approved",detail:s?.decided_by}),o(`[guests] ${t.id}: join approved`),r}if(a==="no"){let r=s?.status==="expired"?"the host did not answer in time":"the host said no",d=v({tokens:e.tokens,guests:e.guests,now:n},t.id,r)??t;return e.guests.log({grant:t.id,event:"refused",detail:r}),o(`[guests] ${t.id}: join refused: ${r}`),d}return t}function J(e,t){let n=e?t.tokens.verify(e):null,o=n?I(n):null,s=o?t.guests.get(o):null;if(!n||!s||s.tokenId!==n.id)return{ok:!1,status:401,error:G};let a=N(t,s);return a.state==="ended"?{ok:!1,status:401,error:G}:a.state==="pending"?{ok:!1,status:403,error:R,waiting:!0}:a.state==="paused"?{ok:!1,status:403,error:O,paused:!0}:{ok:!0,grant:a}}function C(e){let t=(o,s)=>o.length?o.join(", "):`none named: do not touch ${s} unless the owner's own instructions already allow it for this work`,n=e.level==="report"?"report: read and answer only; change nothing":e.level==="propose"?"propose: you may prepare changes and open a merge request or draft; never merge, deploy or delete":"act: you may act inside the grant without asking";return[`[Guest mesh] You are working for a guest organisation, "${e.guest}", under the grant "${e.name}" that the owner of this node opened.`,`Stay inside it. Folders: ${t(e.folders,"files")}. Skills: ${t(e.skills,"skills")}. Commands: ${t(e.commands,"commands")}. Freedom: ${n}. The grant ends on ${e.expiresAt.slice(0,10)}.`,"Anything outside the grant: say it is not covered and stop. The guest sees only your answers: never reveal other chats, agents, people or files of this node."].join(`
|
|
2
2
|
`)}function q(e,t){return{agentId:e.agentId,message:t,context:{channel:"guest",chatId:`guest:${e.id}`,sender:`guest:${e.guest}`},systemPromptAppend:C(e),...e.level==="act"?{}:{autonomy:e.level}}}function B(e,t){let n=e.guests.get(t);if(!n||n.state!=="active")return null;let o=e.guests.update(t,{state:"paused",pausedAt:new Date((e.now??Date.now)()).toISOString()});return e.guests.log({grant:t,event:"paused"}),o}function U(e,t){let n=e.guests.get(t);if(!n||n.state!=="paused")return null;let o=e.guests.update(t,{state:"active",pausedAt:void 0});return e.guests.log({grant:t,event:"resumed"}),o}function v(e,t,n="ended by the host"){let o=e.guests.get(t);if(!o||o.state==="ended")return null;e.tokens.revoke(o.tokenId);let s=e.guests.update(t,{state:"ended",endedAt:new Date((e.now??Date.now)()).toISOString(),endedReason:n});return e.guests.log({grant:t,event:n==="expired"?"expired":"ended",detail:n}),s}function X(e,t,n){let o=e.guests.get(t);if(!o||o.state==="ended")return{ok:!1,error:`no open grant "${t}"`};let s={};if(n.folders!==void 0&&(s.folders=l(n.folders)),n.skills!==void 0&&(s.skills=l(n.skills)),n.commands!==void 0&&(s.commands=l(n.commands)),n.level!==void 0){let u=w.safeParse(n.level);if(!u.success)return{ok:!1,error:"level must be report, propose or act"};s.level=u.data}if(n.days!==void 0){let u=Number(n.days);if(!Number.isFinite(u)||u<1||u>y)return{ok:!1,error:`days must be between 1 and ${y}`};s.expiresAt=new Date((e.now??Date.now)()+u*864e5).toISOString()}let a=e.guests.update(t,s),r=["report","propose","act"],d=s.level&&r.indexOf(s.level)>r.indexOf(o.level)||s.folders&&s.folders.length>o.folders.length||s.skills&&s.skills.length>o.skills.length||s.commands&&s.commands.length>o.commands.length||s.expiresAt&&s.expiresAt>o.expiresAt;return e.guests.log({grant:t,event:d?"widened":"narrowed",detail:Object.keys(s).join(", ")}),{ok:!0,grant:a}}function W(e){return{grant:e.id,name:e.name,agentId:e.agentId,level:e.level,folders:e.folders,skills:e.skills,commands:e.commands,state:e.state,expiresAt:e.expiresAt,usage:e.usage}}async function L(e,t){let n=e+t-Date.now();n>0&&await new Promise(o=>setTimeout(o,n))}export{h as a,b,P as c,y as d,I as e,_ as f,M as g,j as h,Y as i,G as j,R as k,O as l,N as m,J as n,C as o,q as p,B as q,U as r,v as s,X as t,W as u};
|
|
3
|
-
//# sourceMappingURL=chunk-
|
|
3
|
+
//# sourceMappingURL=chunk-FRR6DRLY.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{a as _,b as q}from"./chunk-RKPAVWXF.js";import{a as R,b as O,c as B,d as b,f as k,g as z,h as v,i as w,j as S,k as m}from"./chunk-
|
|
1
|
+
import{a as _,b as q}from"./chunk-RKPAVWXF.js";import{a as R,b as O,c as B,d as b,f as k,g as z,h as v,i as w,j as S,k as m}from"./chunk-KZKTVGL7.js";import{a as x,b as C,c as E,d as P,e as D}from"./chunk-SMKVNZVI.js";import{existsSync as J,readFileSync as M}from"fs";var V=new Set(["cron","heartbeat","api","a2a","mesh"]),W=160;function s(n){return typeof n=="string"&&n.trim()?n.trim():void 0}function A(n,e=W){let t=n.replace(/\s+/g," ").trim();return t.length>e?`${t.slice(0,e-1)}\u2026`:t}function Y(n){let e=x(n);if(!J(e))throw new Error(`config not found at ${e}`);return JSON.parse(M(e,"utf-8"))}function Z(n,e){return n?.agents?.[e]?.admin===!0}function K(n,e,t){return Z(n,t.agentId)||e?.createdBy===t.agentId}function Q(n,e){let t=e?.createdBy?`agent "${e.createdBy}"`:"the operator";return`Not allowed: "${n}" was created by ${t}. Agents manage only schedules they created (unless configured admin).`}function j(n,e){let t=s(n.notify);if(t!=="none"){if(t&&t!=="here"){let r=t.split(":");return r.length<2||!r[0]||!r[1]?"invalid":{channel:r[0],chatId:r.slice(1).join(":")}}if(e.channel&&e.chatId&&!V.has(e.channel))return{channel:e.channel,chatId:e.chatId,...e.accountId?{accountId:e.accountId}:{}}}}function ee(n,e,t){let r=e.timezone||"UTC",d=e.enabled&&!m(e)?S(w(e.schedule,r,t),r):"\u2014",p=e.approval?`pending ${e.approval.action} approval`:e.enabled?"active":"paused",h=[`- ${n} [${p}] ${e.schedule} \u2014 ${v(e.schedule)} (${r})`,` agent: ${e.agent}; created by: ${e.createdBy||"operator"}; next: ${d}`];return e.notify&&h.push(` notify: ${e.notify.channel} ${e.notify.chatId} ${z(e)}`),e.command?h.push(` command: ${A(String(e.command))}`):e.prompt&&h.push(` prompt: ${A(String(e.prompt))}`),h.join(`
|
|
2
2
|
`)}async function L(n,e,t){let r=n?.notifications?.destination;if(!r?.channel||!r?.chatId)return"No operator notification destination is configured (notifications.destination); the operator must check `agentx schedule list`.";if(!e.notifyOperator)return"Operator notification is unavailable in this context.";try{return await e.notifyOperator({channel:r.channel,chatId:r.chatId,accountId:r.accountId},t),"The operator has been notified."}catch(d){return`Could not notify the operator (${d?.message??d}); the request is still recorded.`}}async function ae(n,e,t={}){let r=(s(n.action)||"list").toLowerCase(),d=t.now?t.now():new Date,p;try{p=Y(t.configPath)}catch(a){return`Error: ${a.message}`}let h=p.crons||{};if(r==="list"){let a=n.mine===!0,l=Object.entries(h).filter(([,i])=>!a||e&&i?.createdBy===e.agentId);return l.length?l.map(([i,f])=>ee(i,f,d)).join(`
|
|
3
3
|
`):a?"You have no schedules.":"No schedules."}if(!e?.agentId)return"Error: caller agent is unknown (AGENTX_AGENT_ID not set). Pass callerAgentId.";if(!p.agents?.[e.agentId])return`Error: caller "${e.agentId}" is not an agent on this node.`;let o=s(n.id),I=a=>C(a,{configPath:t.configPath,reload:t.reload});if(r==="create"){let a=s(n.when),l=s(n.prompt);if(!a||!l)return"Error: create needs `when` (plain English) and `prompt`.";let i=_(a);if(!i)return`Error: couldn't parse "${a}". ${O}.`;let f=s(n.agent)||e.agentId;if(!p.agents?.[f])return`Error: agent "${f}" not found on this node.`;let g=s(n.timezone)||R;if(!b(g))return`Error: unknown timezone "${g}".`;let u=o||q(i.matched,f);if(!B(u))return`Error: invalid id "${u}" (letters, digits, "-" and "_" only).`;if(h[u])return`Error: a schedule "${u}" already exists. Pick another \`id\`.`;let $=j(n,e);if($==="invalid")return'Error: `notify` must be "here", "none", or "channel:chatId".';let y=s(n.report);if(y&&y!=="always"&&y!=="exceptions")return'Error: `report` must be "always" or "exceptions".';let G={action:"create",requestedBy:e.agentId,requestedAt:d.toISOString()},H=k({parsed:i,agent:f,prompt:l,timezone:g,notify:$,report:y,enabled:!1,createdBy:e.agentId,approval:G}),N=await I(F=>E(F,`crons.${u}`,H));if(!N.success)return`Error: ${N.error}`;let T=S(w(i.cron,g,d),g),U=[`Schedule approval requested by ${e.agentId}`,`Create: ${u}`,`When: ${i.human} \u2014 cron \`${i.cron}\` (${g})`,`Next fire: ${T}`,`Agent: ${f}`,$?`${y==="exceptions"?"Exceptions":"Results"} and failures go to: ${$.channel} ${$.chatId}${$.channel==="voice"?" (as a push notification)":""}`:"Results go to: run log only (no chat)",`Prompt: ${A(l,400)}`,"",`Approve: agentx schedule approve ${u}`,`Reject: agentx schedule reject ${u}`].join(`
|
|
4
4
|
`),X=await L(p,t,U);return[`Requested schedule "${u}": ${i.human} (cron ${i.cron}, ${g}); next fire would be ${T}.`,"It is saved DISABLED and will not run until the operator approves it.",X].join(`
|
|
5
5
|
`)}if(!o)return`Error: ${r} needs \`id\`.`;let c=h[o];if(!c)return`Error: schedule "${o}" not found.`;if(!K(p,c,e))return Q(o,c);if(r==="pause"||r==="resume"){let a=r==="resume";if(a&&m(c))return`"${o}" is still awaiting operator approval; it can't be resumed until approved.`;if(c.enabled===a)return`"${o}" is already ${a?"active":"paused"}.`;let l=await I(i=>E(i,`crons.${o}.enabled`,a));return l.success?`"${o}" ${a?"resumed":"paused"}.`:`Error: ${l.error}`}if(r==="delete"){if(m(c)&&c.approval.requestedBy===e.agentId){let u=await I($=>D($,`crons.${o}`));return u.success?`Withdrew the pending request "${o}".`:`Error: ${u.error}`}if(m(c))return`"${o}" is a creation request still awaiting approval; only its requester or the operator (\`agentx schedule reject ${o}\`) can drop it.`;if(c.approval?.action==="delete")return`Deletion of "${o}" is already awaiting approval.`;let a={action:"delete",requestedBy:e.agentId,requestedAt:d.toISOString()},l=await I(u=>{if(!P(u,`crons.${o}`))throw new Error(`schedule "${o}" not found`);E(u,`crons.${o}.approval`,a)});if(!l.success)return`Error: ${l.error}`;let i=c.timezone||"UTC",f=[`Schedule approval requested by ${e.agentId}`,`Delete: ${o}`,`When: ${v(c.schedule)} \u2014 cron \`${c.schedule}\` (${i})`,`Next fire: ${c.enabled?S(w(c.schedule,i,d),i):"\u2014 (paused)"}`,`Agent: ${c.agent}`,"",`Approve: agentx schedule approve ${o}`,`Reject: agentx schedule reject ${o}`].join(`
|
|
6
6
|
`),g=await L(p,t,f);return[`Deletion of "${o}" requested. It keeps its current state until the operator approves.`,g].join(`
|
|
7
7
|
`)}return`Error: unknown action "${r}". Use list, create, pause, resume or delete.`}function ie(n,e=process.env){let t=s(e.AGENTX_AGENT_ID)||s(n.callerAgentId);if(!t)return null;let r=!!(s(e.AGENTX_CHANNEL)&&s(e.AGENTX_CHAT_ID)),d=s(r?e.AGENTX_CHANNEL:n.channel),p=s(r?e.AGENTX_CHAT_ID:n.chatId),h=s(n.accountId);return{agentId:t,channel:d,chatId:p,...h?{accountId:h}:{}}}export{ae as a,ie as b};
|
|
8
|
-
//# sourceMappingURL=chunk-
|
|
8
|
+
//# sourceMappingURL=chunk-H6I42JBS.js.map
|