agentix-cli 0.181.1 → 0.183.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/apps/mac-voice/Sources/AgentXVoice/Config.swift +9 -0
- package/apps/mac-voice/Sources/AgentXVoice/MiniOrbs.swift +19 -6
- package/apps/mac-voice/Sources/AgentXVoice/OpenRequests.swift +260 -0
- package/apps/mac-voice/Sources/AgentXVoice/Panel.swift +72 -5
- package/apps/mac-voice/Sources/AgentXVoice/PillBusy.swift +22 -4
- package/apps/mac-voice/Sources/AgentXVoice/PillPlacement.swift +24 -0
- package/apps/mac-voice/Sources/AgentXVoice/RequestsWindow.swift +401 -0
- package/apps/mac-voice/Sources/AgentXVoice/SettingsWindow.swift +1 -0
- package/apps/mac-voice/Sources/AgentXVoice/StatusMenu.swift +22 -1
- package/apps/mac-voice/Sources/AgentXVoice/main.swift +263 -4
- package/dist/{App-UXX5TGFF.js → App-777XBP22.js} +2 -2
- package/dist/{ChatApp-X635NOAE.js → ChatApp-ZYMF5HSR.js} +2 -2
- package/dist/{absorb-eval-4ZPDWNBA.js → absorb-eval-HYGBAPXS.js} +2 -2
- package/dist/{adapter-Z23K544D.js → adapter-VV626IYN.js} +2 -2
- package/dist/{agent-OBRH5BJZ.js → agent-BS5VSO5T.js} +2 -2
- package/dist/{board-dashboard-SFXVOICJ.js → board-dashboard-3CMB3NPI.js} +2445 -4218
- package/dist/board-dashboard-3CMB3NPI.js.map +1 -0
- package/dist/{chunk-UFUQQ5J5.js → chunk-3ENH7HAS.js} +2 -2
- package/dist/chunk-5ELIX7BQ.js +3 -0
- package/dist/chunk-5ELIX7BQ.js.map +1 -0
- package/dist/{chunk-NI2XD6P3.js → chunk-6D4RGQCU.js} +2 -2
- package/dist/{chunk-SD6UDSXV.js → chunk-6KWHQAXS.js} +2 -2
- package/dist/{chunk-IRZYRLXQ.js → chunk-6MY7VXQV.js} +2 -2
- package/dist/chunk-CZMVJP7O.js +2 -0
- package/dist/chunk-CZMVJP7O.js.map +1 -0
- package/dist/{chunk-WKU7YFDV.js → chunk-DOCAWXV5.js} +2 -2
- package/dist/{chunk-ZSY6PFHD.js → chunk-DYNXOYFN.js} +2 -2
- package/dist/{chunk-HMEFQL5P.js → chunk-GXOKZSCS.js} +4 -3
- package/dist/chunk-GXOKZSCS.js.map +1 -0
- package/dist/{chunk-J56YGKUO.js → chunk-JJ2WRGKI.js} +2 -2
- package/dist/chunk-KLWCVTBM.js +36 -0
- package/dist/chunk-KLWCVTBM.js.map +1 -0
- package/dist/{chunk-KOY3EOPH.js → chunk-M7V7NCX6.js} +36 -36
- package/dist/chunk-M7V7NCX6.js.map +1 -0
- package/dist/chunk-MLNA54RW.js +888 -0
- package/dist/chunk-MLNA54RW.js.map +1 -0
- package/dist/{chunk-7RVJWLIP.js → chunk-OIECBQ45.js} +2 -2
- package/dist/{chunk-QJXGJMHM.js → chunk-OTITQCEQ.js} +279 -279
- package/dist/chunk-OTITQCEQ.js.map +1 -0
- package/dist/{chunk-VK3M3TVL.js → chunk-PIVIOIEC.js} +3 -3
- package/dist/chunk-PIVIOIEC.js.map +1 -0
- package/dist/{chunk-IYITREE5.js → chunk-QSJA6S66.js} +2 -2
- package/dist/{chunk-LZY6YN2J.js → chunk-R2QFKEX5.js} +2 -2
- package/dist/{chunk-PCWXHXTM.js → chunk-RG6MO7G5.js} +2 -2
- package/dist/{chunk-FRVFRWFN.js → chunk-RQOMUGUM.js} +2 -2
- package/dist/{chunk-U5S6IP7Z.js → chunk-SBJHIBWX.js} +3 -3
- package/dist/{chunk-HBQRVCLU.js → chunk-TD2D4TGI.js} +2 -2
- package/dist/{chunk-TZ7GB7FI.js → chunk-UNZVDS3P.js} +2 -2
- package/dist/{chunk-UHTIZCKU.js → chunk-VDUMYEJH.js} +2 -2
- package/dist/{chunk-CF7CPE7K.js → chunk-XBQISUBE.js} +2 -2
- package/dist/chunk-XPE2WKPF.js +2903 -0
- package/dist/chunk-XPE2WKPF.js.map +1 -0
- package/dist/{chunk-OYCMFCME.js → chunk-YH7NALJ4.js} +2 -2
- package/dist/{chunk-33DLG4I2.js → chunk-YZCQDZCA.js} +5 -5
- package/dist/{chunk-SDINSYTN.js → chunk-ZOCRNNNG.js} +2 -2
- package/dist/{chunk-WZUY7VGL.js → chunk-ZSS3GL5A.js} +2 -2
- package/dist/cli.js +1 -1
- package/dist/{client-ILPJFCTF.js → client-CMQZO22V.js} +2 -2
- package/dist/{config-JVWOL233.js → config-BMYFEAO5.js} +2 -2
- package/dist/{config-mutate-WYCHP6VK.js → config-mutate-N6W52YXB.js} +2 -2
- package/dist/config-mutator-S5SGBNOG.js +2 -0
- package/dist/{contributions-XD66HYWE.js → contributions-KRES5F2V.js} +2 -2
- package/dist/{doctor-DYTYJQYC.js → doctor-2KACCIZU.js} +2 -2
- package/dist/{follow-up-tool-HPET6LZW.js → follow-up-tool-M57XXTPX.js} +2 -2
- package/dist/{hub-L5FFJPS3.js → hub-FVAPTKTF.js} +2 -2
- package/dist/index.d.ts +317 -216
- package/dist/index.js +1 -1
- package/dist/{program-24C3VBSD.js → program-BHDAV67G.js} +250 -249
- package/dist/program-BHDAV67G.js.map +1 -0
- package/dist/{promote-XI6W27JK.js → promote-LXKF6A24.js} +2 -2
- package/dist/push-bridge-NR7SLHGX.js +1 -1
- package/dist/{query-MGG5QKNC.js → query-W7OBMMVM.js} +2 -2
- package/dist/{query-settings-CALZYYWD.js → query-settings-PTA2SA63.js} +2 -2
- package/dist/{registry-XJWSLJ4O.js → registry-OHUOHAD2.js} +2 -2
- package/dist/{request-planner-JCRGGJUO.js → request-planner-T44RMVNO.js} +2 -2
- package/dist/{review-candidates-OEBEEAEZ.js → review-candidates-LKFIKTY6.js} +2 -2
- package/dist/{routing-CGH54RYG.js → routing-7HEUMP4R.js} +2 -2
- package/dist/schedule-tool-W6KPENHW.js +2 -0
- package/dist/{scheduler-2K5YEV2U.js → scheduler-I3UNKBBJ.js} +2 -2
- package/dist/{seat-DEL5YUOS.js → seat-DAMUB3CU.js} +2 -2
- package/dist/{select-MRTWSI7U.js → select-PMNHXNKI.js} +2 -2
- package/dist/self-SO6GCVYD.js +2 -0
- package/dist/{set-enabled-XTDCFCZY.js → set-enabled-36JN5ZRJ.js} +2 -2
- package/dist/signal-exit-C5EUGHKI.js +3 -0
- package/dist/signal-exit-C5EUGHKI.js.map +1 -0
- package/dist/{sprint-tool-N7WPDX5J.js → sprint-tool-Z4RRPK6I.js} +2 -2
- package/dist/{tool-NZTJZDSB.js → tool-B6I22BG2.js} +2 -2
- package/dist/{tool-KZHWJ7BC.js → tool-KTL4TLZP.js} +2 -2
- package/dist/{tool-BQEJOTF3.js → tool-SK3AAQYW.js} +2 -2
- package/dist/{wiki-YERCKD3E.js → wiki-H2CBE4SM.js} +2 -2
- package/dist/wiki-enrich-GTUSSLCD.js +2 -0
- package/package.json +4 -1
- package/dist/board-dashboard-SFXVOICJ.js.map +0 -1
- package/dist/chunk-DMCMV4UJ.js +0 -2035
- package/dist/chunk-DMCMV4UJ.js.map +0 -1
- package/dist/chunk-DOBTHQ32.js +0 -256
- package/dist/chunk-DOBTHQ32.js.map +0 -1
- package/dist/chunk-G6ZRPC6E.js +0 -36
- package/dist/chunk-G6ZRPC6E.js.map +0 -1
- package/dist/chunk-HMEFQL5P.js.map +0 -1
- package/dist/chunk-KOY3EOPH.js.map +0 -1
- package/dist/chunk-KVAWRQBA.js +0 -580
- package/dist/chunk-KVAWRQBA.js.map +0 -1
- package/dist/chunk-N6VBEITO.js +0 -310
- package/dist/chunk-N6VBEITO.js.map +0 -1
- package/dist/chunk-QJXGJMHM.js.map +0 -1
- package/dist/chunk-VK3M3TVL.js.map +0 -1
- package/dist/chunk-Z2UDWVZZ.js +0 -869
- package/dist/chunk-Z2UDWVZZ.js.map +0 -1
- package/dist/config-mutator-DKNHE6VP.js +0 -2
- package/dist/processes-EWARF6ZW.js +0 -2
- package/dist/program-24C3VBSD.js.map +0 -1
- package/dist/schedule-tool-UM3CAPDX.js +0 -2
- package/dist/signal-exit-WL7G3EEZ.js +0 -2
- package/dist/signal-exit-WL7G3EEZ.js.map +0 -1
- package/dist/wiki-enrich-K54LGNU3.js +0 -2
- /package/dist/{App-UXX5TGFF.js.map → App-777XBP22.js.map} +0 -0
- /package/dist/{ChatApp-X635NOAE.js.map → ChatApp-ZYMF5HSR.js.map} +0 -0
- /package/dist/{absorb-eval-4ZPDWNBA.js.map → absorb-eval-HYGBAPXS.js.map} +0 -0
- /package/dist/{adapter-Z23K544D.js.map → adapter-VV626IYN.js.map} +0 -0
- /package/dist/{agent-OBRH5BJZ.js.map → agent-BS5VSO5T.js.map} +0 -0
- /package/dist/{chunk-UFUQQ5J5.js.map → chunk-3ENH7HAS.js.map} +0 -0
- /package/dist/{chunk-NI2XD6P3.js.map → chunk-6D4RGQCU.js.map} +0 -0
- /package/dist/{chunk-SD6UDSXV.js.map → chunk-6KWHQAXS.js.map} +0 -0
- /package/dist/{chunk-IRZYRLXQ.js.map → chunk-6MY7VXQV.js.map} +0 -0
- /package/dist/{chunk-WKU7YFDV.js.map → chunk-DOCAWXV5.js.map} +0 -0
- /package/dist/{chunk-ZSY6PFHD.js.map → chunk-DYNXOYFN.js.map} +0 -0
- /package/dist/{chunk-J56YGKUO.js.map → chunk-JJ2WRGKI.js.map} +0 -0
- /package/dist/{chunk-7RVJWLIP.js.map → chunk-OIECBQ45.js.map} +0 -0
- /package/dist/{chunk-IYITREE5.js.map → chunk-QSJA6S66.js.map} +0 -0
- /package/dist/{chunk-LZY6YN2J.js.map → chunk-R2QFKEX5.js.map} +0 -0
- /package/dist/{chunk-PCWXHXTM.js.map → chunk-RG6MO7G5.js.map} +0 -0
- /package/dist/{chunk-FRVFRWFN.js.map → chunk-RQOMUGUM.js.map} +0 -0
- /package/dist/{chunk-U5S6IP7Z.js.map → chunk-SBJHIBWX.js.map} +0 -0
- /package/dist/{chunk-HBQRVCLU.js.map → chunk-TD2D4TGI.js.map} +0 -0
- /package/dist/{chunk-TZ7GB7FI.js.map → chunk-UNZVDS3P.js.map} +0 -0
- /package/dist/{chunk-UHTIZCKU.js.map → chunk-VDUMYEJH.js.map} +0 -0
- /package/dist/{chunk-CF7CPE7K.js.map → chunk-XBQISUBE.js.map} +0 -0
- /package/dist/{chunk-OYCMFCME.js.map → chunk-YH7NALJ4.js.map} +0 -0
- /package/dist/{chunk-33DLG4I2.js.map → chunk-YZCQDZCA.js.map} +0 -0
- /package/dist/{chunk-SDINSYTN.js.map → chunk-ZOCRNNNG.js.map} +0 -0
- /package/dist/{chunk-WZUY7VGL.js.map → chunk-ZSS3GL5A.js.map} +0 -0
- /package/dist/{client-ILPJFCTF.js.map → client-CMQZO22V.js.map} +0 -0
- /package/dist/{config-JVWOL233.js.map → config-BMYFEAO5.js.map} +0 -0
- /package/dist/{config-mutate-WYCHP6VK.js.map → config-mutate-N6W52YXB.js.map} +0 -0
- /package/dist/{config-mutator-DKNHE6VP.js.map → config-mutator-S5SGBNOG.js.map} +0 -0
- /package/dist/{contributions-XD66HYWE.js.map → contributions-KRES5F2V.js.map} +0 -0
- /package/dist/{doctor-DYTYJQYC.js.map → doctor-2KACCIZU.js.map} +0 -0
- /package/dist/{follow-up-tool-HPET6LZW.js.map → follow-up-tool-M57XXTPX.js.map} +0 -0
- /package/dist/{hub-L5FFJPS3.js.map → hub-FVAPTKTF.js.map} +0 -0
- /package/dist/{processes-EWARF6ZW.js.map → promote-LXKF6A24.js.map} +0 -0
- /package/dist/{promote-XI6W27JK.js.map → query-W7OBMMVM.js.map} +0 -0
- /package/dist/{query-settings-CALZYYWD.js.map → query-settings-PTA2SA63.js.map} +0 -0
- /package/dist/{query-MGG5QKNC.js.map → registry-OHUOHAD2.js.map} +0 -0
- /package/dist/{request-planner-JCRGGJUO.js.map → request-planner-T44RMVNO.js.map} +0 -0
- /package/dist/{review-candidates-OEBEEAEZ.js.map → review-candidates-LKFIKTY6.js.map} +0 -0
- /package/dist/{registry-XJWSLJ4O.js.map → routing-7HEUMP4R.js.map} +0 -0
- /package/dist/{routing-CGH54RYG.js.map → schedule-tool-W6KPENHW.js.map} +0 -0
- /package/dist/{schedule-tool-UM3CAPDX.js.map → scheduler-I3UNKBBJ.js.map} +0 -0
- /package/dist/{scheduler-2K5YEV2U.js.map → seat-DAMUB3CU.js.map} +0 -0
- /package/dist/{select-MRTWSI7U.js.map → select-PMNHXNKI.js.map} +0 -0
- /package/dist/{seat-DEL5YUOS.js.map → self-SO6GCVYD.js.map} +0 -0
- /package/dist/{set-enabled-XTDCFCZY.js.map → set-enabled-36JN5ZRJ.js.map} +0 -0
- /package/dist/{sprint-tool-N7WPDX5J.js.map → sprint-tool-Z4RRPK6I.js.map} +0 -0
- /package/dist/{tool-NZTJZDSB.js.map → tool-B6I22BG2.js.map} +0 -0
- /package/dist/{tool-KZHWJ7BC.js.map → tool-KTL4TLZP.js.map} +0 -0
- /package/dist/{tool-BQEJOTF3.js.map → tool-SK3AAQYW.js.map} +0 -0
- /package/dist/{wiki-YERCKD3E.js.map → wiki-H2CBE4SM.js.map} +0 -0
- /package/dist/{wiki-enrich-K54LGNU3.js.map → wiki-enrich-GTUSSLCD.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-6KWHQAXS.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-6D4RGQCU.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{ea as Me,pa as hr}from"./chunk-M7V7NCX6.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(`
|
|
@@ -9,7 +9,7 @@ import{c as Ct}from"./chunk-SZDACK6O.js";import{b as Le}from"./chunk-AFRHKA7B.js
|
|
|
9
9
|
`)+(o.length?`
|
|
10
10
|
`:""))}hasSimilar(e,t){let r=this.getAll(e),s=t.toLowerCase().split(/\s+/).filter(a=>a.length>3);return r.some(a=>{let i=a.content.toLowerCase();return s.filter(l=>i.includes(l)).length>=s.length*.7})}prune(e){let t=this.getAll(e);if(t.length===0)return;let r=Date.now(),o=Wr*24*60*60*1e3;t=t.filter(a=>a.category==="task-state"&&a.expiresAt?new Date(a.expiresAt).getTime()>r:a.category==="task-state"&&!a.expiresAt?r-new Date(a.createdAt).getTime()<o:!0),t.length>Xt&&(t=t.slice(-Xt));let s=this.filePath(e);Ue(s,t.map(a=>JSON.stringify(a)).join(`
|
|
11
11
|
`)+`
|
|
12
|
-
`)}};function tn(n){let e=(n||"").trim();for(let t=0;t<5;t++){let r=e;if(e=e.replace(/^Peer\s+"[^"]*"\s+\/task error:\s*\d{3}:\s*/i,"").replace(/^Peer\s+"[^"]*"\s+agent error:\s*/i,"").replace(/^mesh fallback failed:\s*/i,"").trim(),e===r)break}return e}var Or="__queued__";function Si(n,e){return`${Or}:${n}:${e}`}var Nr=/^__queued__(?::([A-Za-z-]+):(\d+))?$/;function Dr(n){if(!n)return null;let e=Nr.exec(tn(n));return e?{mode:e[1]||"collect",pending:e[2]?Number(e[2]):1}:null}function Ai(n){return Dr(n)!==null}var J="fleet",Be=n=>`project:${n}`,W={},M="",_=new Map,K=new Map,z=new Set,on=()=>null;function jr(n=Date.now()){return new Date(n).toISOString().slice(0,7)}function xi(n=Date.now()){let e=new Date(n);return Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),1)}function fe(n){let e=jr(n);e!==M&&(M=e,_.clear(),K.clear(),z.clear())}function B(n){return typeof n?.monthlyUsd=="number"&&n.monthlyUsd>0?n.monthlyUsd:void 0}function ge(n){let e=n?.warnRatio;return typeof e=="number"&&e>0&&e<=1?e:.8}function Ke(){let n=0;for(let e of _.values())n+=e;return n}function T(n){return`$${n<1?n.toFixed(4).replace(/0{1,2}$/,""):n.toFixed(2)}`}function Pi(n){W=n??{}}function Ti(n){on=n??(()=>null)}function Wi(n,e){return on(n,e)}function sn(n,e,t){let r=B(t);if(!r)return[];let o=[];return e>=r?o.push({kind:"cap",key:`${n}:cap:${r}`,cap:r}):e>=r*ge(t)&&o.push({kind:"warn",key:`${n}:warn:${r}`,cap:r}),o}function nn(n,e){e.clear();for(let[t,r]of Object.entries(n))Number.isFinite(r)&&r>0&&e.set(t,r)}function Oi(n,e=Date.now(),t={}){fe(e),nn(n,_),nn(t,K);let r=(o,s,a)=>{for(let i of sn(o,s,a))z.add(i.key),i.kind==="cap"&&z.add(`${o}:warn:${i.cap}`)};for(let[o,s]of _)r(o,s,W.agents?.[o]);for(let[o,s]of K)r(Be(o),s,W.projects?.[o]);r(J,Ke(),W.fleet)}function pe(n){return n===J?"the fleet cap on the Cost page
|
|
12
|
+
`)}};function tn(n){let e=(n||"").trim();for(let t=0;t<5;t++){let r=e;if(e=e.replace(/^Peer\s+"[^"]*"\s+\/task error:\s*\d{3}:\s*/i,"").replace(/^Peer\s+"[^"]*"\s+agent error:\s*/i,"").replace(/^mesh fallback failed:\s*/i,"").trim(),e===r)break}return e}var Or="__queued__";function Si(n,e){return`${Or}:${n}:${e}`}var Nr=/^__queued__(?::([A-Za-z-]+):(\d+))?$/;function Dr(n){if(!n)return null;let e=Nr.exec(tn(n));return e?{mode:e[1]||"collect",pending:e[2]?Number(e[2]):1}:null}function Ai(n){return Dr(n)!==null}var J="fleet",Be=n=>`project:${n}`,W={},M="",_=new Map,K=new Map,z=new Set,on=()=>null;function jr(n=Date.now()){return new Date(n).toISOString().slice(0,7)}function xi(n=Date.now()){let e=new Date(n);return Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),1)}function fe(n){let e=jr(n);e!==M&&(M=e,_.clear(),K.clear(),z.clear())}function B(n){return typeof n?.monthlyUsd=="number"&&n.monthlyUsd>0?n.monthlyUsd:void 0}function ge(n){let e=n?.warnRatio;return typeof e=="number"&&e>0&&e<=1?e:.8}function Ke(){let n=0;for(let e of _.values())n+=e;return n}function T(n){return`$${n<1?n.toFixed(4).replace(/0{1,2}$/,""):n.toFixed(2)}`}function Pi(n){W=n??{}}function Ti(n){on=n??(()=>null)}function Wi(n,e){return on(n,e)}function sn(n,e,t){let r=B(t);if(!r)return[];let o=[];return e>=r?o.push({kind:"cap",key:`${n}:cap:${r}`,cap:r}):e>=r*ge(t)&&o.push({kind:"warn",key:`${n}:warn:${r}`,cap:r}),o}function nn(n,e){e.clear();for(let[t,r]of Object.entries(n))Number.isFinite(r)&&r>0&&e.set(t,r)}function Oi(n,e=Date.now(),t={}){fe(e),nn(n,_),nn(t,K);let r=(o,s,a)=>{for(let i of sn(o,s,a))z.add(i.key),i.kind==="cap"&&z.add(`${o}:warn:${i.cap}`)};for(let[o,s]of _)r(o,s,W.agents?.[o]);for(let[o,s]of K)r(Be(o),s,W.projects?.[o]);r(J,Ke(),W.fleet)}function pe(n){return n===J?"the fleet cap on the Wall's Cost page or budget.monthlyUsd in agentx.json":n.startsWith("project:")?`the cap of project ${n.slice(8)} on the Wall's Cost page or its budget.monthlyUsd under dashboard.wall.projects in agentx.json`:`the cap on the Wall's Cost page or agents.${n}.budget.monthlyUsd in agentx.json`}function Mr(n,e,t,r,o){let s=e===J?"The fleet":e.startsWith("project:")?`Project ${e.slice(8)}`:`Agent ${e}`,a=pe(e);if(n==="warn")return{kind:n,scope:e,month:M,spentUsd:t,capUsd:r,title:`${s} is near its monthly budget`,message:`${s} has spent ${T(t)} of its ${T(r)} budget for ${M} (${Math.round(t/r*100)}%, warning at ${Math.round(ge(o)*100)}%). At ${T(r)} new runs stop until the month ends or you raise ${a}.`};let i=e===J?"Every agent is":e.startsWith("project:")?"Its work is":"It is";return{kind:n,scope:e,month:M,spentUsd:t,capUsd:r,title:`${s} reached its monthly budget`,message:`${s} has spent ${T(t)} of its ${T(r)} budget for ${M}. ${i} paused: new runs are refused until the month ends or you raise ${a} (applies on save).`}}function Ni(n,e,t=Date.now(),r){if(fe(t),typeof e!="number"||!Number.isFinite(e)||e<=0)return[];let o=(_.get(n)??0)+e;_.set(n,o);let s=[],a=(i,d,l)=>{for(let c of sn(i,d,l))z.has(c.key)||(z.add(c.key),c.kind==="cap"&&z.add(`${i}:warn:${c.cap}`),s.push(Mr(c.kind,i,d,c.cap,l)))};if(a(n,o,W.agents?.[n]),r){let i=(K.get(r)??0)+e;K.set(r,i),a(Be(r),i,W.projects?.[r])}return a(J,Ke(),W.fleet),s}function Di(n,e=Date.now(),t){fe(e);let r=B(W.agents?.[n]),o=_.get(n)??0;if(r&&o>=r)return{abort:!0,reason:"agent_budget",message:`Monthly budget reached: agent ${n} has spent ${T(o)} of its ${T(r)} budget for ${M}. New runs are paused until the month ends. To resume now, raise ${pe(n)} (applies on save).`};let s=t?B(W.projects?.[t]):void 0,a=t?K.get(t)??0:0;if(t&&s&&a>=s)return{abort:!0,reason:"project_budget",message:`Monthly project budget reached: project ${t} has spent ${T(a)} of its ${T(s)} budget for ${M}. New runs for it are paused until the month ends. To resume now, raise ${pe(Be(t))} (applies on save).`};let i=B(W.fleet),d=Ke();return i&&d>=i?{abort:!0,reason:"fleet_budget",message:`Monthly fleet budget reached: all agents together have spent ${T(d)} of the ${T(i)} budget for ${M}. New runs are paused until the month ends. To resume now, raise ${pe(J)} (applies on save).`}:null}function Er(n,e){let t=B(e);return t?n>=t?"paused":n>=t*ge(e)?"warn":"ok":"uncapped"}function He(n,e){let t=B(e);return{spentUsd:n,capUsd:t,warnRatio:ge(e),...t?{ratio:n/t}:{},state:Er(n,e)}}var rn=n=>(e,t)=>(t.ratio??-1)-(e.ratio??-1)||t.spentUsd-e.spentUsd||n(e).localeCompare(n(t));function Cr(n,e,t,r={},o={}){let a=[...new Set([...Object.keys(e),...Object.keys(o).filter(c=>o[c]>0),...Object.entries(n.agents??{}).filter(([,c])=>B(c)).map(([c])=>c)])].map(c=>({agentId:c,...He(e[c]??0,n.agents?.[c]),...o[c]>0?{unpricedRuns:o[c]}:{}})).sort(rn(c=>c.agentId)),i=Object.keys(n.projects??{}).map(c=>({name:c,...He(r[c]??0,n.projects?.[c])})).sort(rn(c=>c.name)),d=Object.values(e).reduce((c,p)=>c+(p>0?p:0),0),l=Object.values(o).reduce((c,p)=>c+(p>0?p:0),0);return{month:t,agents:a,projects:i,fleet:{...He(d,n.fleet),...l?{unpricedRuns:l}:{}}}}function ji(n=Date.now()){return fe(n),Cr(W,Object.fromEntries(_),M,Object.fromEntries(K))}function Mi(n){let e={};for(let[r,o]of Object.entries(n.agents??{}))o?.budget&&(e[r]=o.budget);let t={};for(let r of n.dashboard?.wall?.projects??[])r.name in t||(t[r.name]=r.budget);return{agents:e,projects:t,fleet:n.budget}}import{mkdirSync as Fr,readFileSync as _r,renameSync as Lr,statSync as Ur,writeFileSync as Hr}from"fs";import{dirname as Br,resolve as Kr}from"path";function _i(){return process.cwd()}function an(n){return Kr(n,".agentx","agent-holds.json")}var Y=null;function qe(n){let e=an(n),t;try{t=Ur(e).mtimeMs}catch{return{}}if(Y&&Y.path===e&&Y.mtimeMs===t)return Y.holds;let r={};try{r=JSON.parse(_r(e,"utf-8"))??{}}catch{r={}}return Y={path:e,mtimeMs:t,holds:r},r}function dn(n,e){let t=an(n);Fr(Br(t),{recursive:!0});let r=`${t}.${process.pid}.tmp`;Hr(r,JSON.stringify(e,null,2)+`
|
|
13
13
|
`),Lr(r,t),Y=null}function qr(n,e,t,r,o=new Date){let s={...qe(n)},a={kind:t,at:o.toISOString(),by:r};return s[e]=a,dn(n,s),a}function Li(n,e,t){let r={...qe(n)},o=r[e];return!o||t&&o.kind!==t?!1:(delete r[e],dn(n,r),!0)}function Ui(n,e){let t=qe(n)[e];return t?t.kind==="approval"?`Agent "${e}" was created by ${t.by} and waits for the owner's approval. It starts once the owner says yes in Approvals (agentx approvals approve agent:${e}).`:`Agent "${e}" is paused by ${t.by}. Resume it in the Org view, or with: agentx agent resume ${e}`:null}function zr(n=process.env){return n.AGENTX_AGENT_ID?.trim()||void 0}function Hi(n,e,t=process.env){let r=zr(t);if(r){for(let o of e)qr(n,o,"approval",r);return r}}import{basename as Jr,resolve as Yr}from"path";function ln(n){return n?Yr(n).replace(/\/+$/,""):null}function qi(n,e){return e?`${n||"?"}:${e}`:null}function zi(n,e){let t=new Set,r=n.filter(a=>t.has(a.runId)?!1:(t.add(a.runId),!0)).sort((a,i)=>a.startedAt-i.startedAt||a.runId.localeCompare(i.runId)),o=a=>a.endedAt??e,s=[];for(let a=0;a<r.length;a++){let i=r[a];for(let d=a+1;d<r.length;d++){let l=r[d];if(l.startedAt>=o(i))break;if(i.startedAt>=o(l))continue;let c=[];if(i.chat&&i.chat===l.chat&&c.push("chat"),i.worktree&&i.worktree===l.worktree&&i.agentId!==l.agentId&&c.push("worktree"),!c.length)continue;let p=i.endedAt===null,f=l.endedAt===null;s.push({on:c,chat:c.includes("chat")?i.chat:null,worktree:c.includes("worktree")?Jr(i.worktree):null,runs:[i.runId,l.runId],agents:[i.agentId,l.agentId],from:l.startedAt,to:p&&f?null:Math.min(o(i),o(l))})}}return s}hr();import{homedir as Gr}from"os";var Vr=36e5;function cn(n){let e=n?.match(/^([^:\s]+\/[^:\s]+):(?:issue|merge_request|pull)(?::|$)/);return e?e[1]:null}var un=n=>ln(n.startsWith("~/")?Gr()+n.slice(1):n);function pn(n,e,t=()=>null){let r=n?.projects??[],o=n?.rhythmHours??e,s=new Map,a=new Map,i=[];for(let c of r){for(let p of c.repos??[])s.has(p.toLowerCase())||s.set(p.toLowerCase(),c);for(let p of c.agents??[])a.has(p)||a.set(p,c);for(let p of c.workspaces??[]){let f=un(p);f&&i.push([f,c])}}let d=c=>{let p=t(c),f=p?un(p):null;return f?i.find(([g])=>f===g||f.startsWith(`${g}/`))?.[1]??null:null},l=(c,p)=>{let f=(p?s.get(p.toLowerCase()):void 0)??c.map(g=>a.get(g)).find(Boolean)??c.map(d).find(Boolean);return f?{name:f.name,rhythmHours:f.rhythmHours??o}:null};return{names:[...new Set(r.map(c=>c.name))],claim:l,of:(c,p)=>l([...new Set([c.askedAgent??c.agentId,c.agentId])],p)??{name:r.length?null:p,rhythmHours:o}}}function Qr(n,e){return Me.includes(n.state)&&e-n.lastMoveAt>2*n.rhythmHours*Vr}function Qi(n,e,t){let r=e?.claim([...new Set([n.owner,n.agentId])],n.repo??null);return r?{...n,project:r.name,rhythmHours:r.rhythmHours,stalled:Qr({state:n.state,lastMoveAt:n.lastMoveAt,rhythmHours:r.rhythmHours},t)}:n}function Zi(n,e=[]){let t=new Map,r=s=>{let a=t.get(s);return a||t.set(s,a={project:s,open:0,inProgress:0,blocked:0,stalled:0}),a};for(let s of e)r(s);for(let s of n){if(!Me.includes(s.state))continue;let a=r(s.project);a.open++,s.state==="in_progress"&&a.inProgress++,s.blocked&&a.blocked++,s.stalled&&a.stalled++}let o=new Map(e.map((s,a)=>[s,a]));return[...t.values()].sort((s,a)=>{if(s.project===null||a.project===null)return s.project===null?1:-1;let i=o.get(s.project)??1/0,d=o.get(a.project)??1/0;return i!==d?i-d:s.project.localeCompare(a.project)})}function ta(n){if(!n.dashboard?.wall?.projects?.length)return()=>null;let e=pn(n.dashboard.wall,24,t=>n.agents?.[t]?.workspace??null);return(t,r)=>e.claim([t],cn(r))?.name??null}function na(n,e){let t={};for(let r of n){let o=e(r.agentId,r.chatId??void 0);o&&r.usd>0&&(t[o]=(t[o]??0)+r.usd)}return t}import{existsSync as A,mkdirSync as Io,readdirSync as ye,readFileSync as ke,statSync as vo,unlinkSync as be,writeFileSync as Ye}from"fs";import{resolve as N,relative as Ge}from"path";import{z as u}from"zod";var Zr=u.enum(["trigger.channel","trigger.manual","trigger.cron","trigger.hook","trigger.form","trigger.poll","agent","transform","classify","branch","gateway.parallel","rule","action.send","action.createIssue","action.setLabel","action.readLabel","action.react","action.editMessage","action.logTime","action.callHTTP","action.run","action.builtin","subProcess","signal.emit","signal.wait","timer.boundary","owner.notify","owner.ask","person.message","person.wait","checkpoint","end"]),Xr=u.enum(["equals","contains","matches","exists"]),ze=u.object({kind:Xr,params:u.record(u.unknown()).default({})}),gn=u.object({maxAttempts:u.number().int().min(1).max(10).default(1),backoffMs:u.number().int().min(0).max(6e4).default(1e3)}).default({maxAttempts:1,backoffMs:1e3}),mn=u.object({id:u.string().min(1).regex(/^[a-zA-Z_][a-zA-Z0-9_-]*$/,"node id must be identifier-safe"),type:Zr,config:u.record(u.unknown()).default({}),retry:gn,position:u.object({x:u.number(),y:u.number()}).optional()}),hn=u.object({from:u.string(),fromPort:u.string().optional(),to:u.string(),toPort:u.string().optional(),label:u.string().optional()}),fn=u.union([u.string(),u.date().transform(n=>n.toISOString())]),O=u.object({id:u.string().regex(/^[a-z0-9][a-z0-9_-]*$/,"workflow id must be lower-kebab"),version:u.literal(2).default(2),title:u.string().min(1),description:u.string().optional(),status:u.enum(["draft","review","active","deprecated"]).default("active"),tags:u.array(u.string()).default([]),project:u.string().optional(),entity:u.string().optional(),intentPath:u.array(u.string()).default([]),generatedFrom:u.string().optional(),sourceTaskIds:u.array(u.string()).default([]),confidence:u.number().min(0).max(1).optional(),workflowVersion:u.string().optional(),ownerAgent:u.string().optional(),lastMatchedAt:u.string().optional(),matchCount:u.number().int().min(0).default(0),state:u.enum(["active","disabled","quarantined"]).default("active"),priority:u.number().int().default(0),fanOut:u.boolean().default(!1),nodes:u.array(mn).refine(n=>n.length>0,{message:"workflow must have at least one node"}),edges:u.array(hn).default([]),envAllow:u.array(u.string()).default([]),retention:u.object({maxRuns:u.number().int().positive().default(500),maxDays:u.number().int().positive().default(90)}).default({maxRuns:500,maxDays:90}),maxChildDepth:u.number().int().positive().default(5),mesh:u.object({allowRemote:u.boolean().default(!1),peers:u.array(u.string()).optional()}).default({allowRemote:!1}),created:fn.optional(),updated:fn.optional(),autoStart:u.boolean().default(!1),approval:u.enum(["start","step"]).optional(),followUp:u.object({stallMinutes:u.number().positive().max(7*24*60).optional(),maxNudges:u.number().int().min(0).max(20).optional()}).optional()}),me={"owner.ask":{main:"yes",other:["no","expired"]},"person.message":{main:"sent",other:["declined"]},"person.wait":{main:"reply",other:["timeout"]}};function te(n){let e=[],t=new Map(n.nodes.map(a=>[a.id,a])),r=n.nodes.filter(a=>a.type.startsWith("trigger."));r.length===0&&e.push("workflow must have exactly one trigger.* node (found 0)"),r.length>1&&e.push(`workflow has ${r.length} trigger.* nodes; v1 supports exactly one`);for(let a of n.edges)t.has(a.from)||e.push(`edge references missing node: from="${a.from}"`),t.has(a.to)||e.push(`edge references missing node: to="${a.to}"`);let o=r[0];if(o){let a=new Map;for(let l of n.edges)a.has(l.from)||a.set(l.from,[]),a.get(l.from).push(l.to);let i=new Set,d=[o.id];for(;d.length;){let l=d.pop();if(!i.has(l)){i.add(l);for(let c of a.get(l)??[])d.push(c)}}for(let l of n.nodes)i.has(l.id)||e.push(`node "${l.id}" is unreachable from trigger "${o.id}"`);n.nodes.some(l=>i.has(l.id)&&eo(l.type))||e.push("no reachable `end`, `checkpoint`, `subProcess`, `signal.wait`, or `timer.boundary` node \u2014 the run cannot terminate or pause")}for(let a of n.nodes){if(a.type!=="branch"&&a.type!=="rule")continue;let i=a.type==="branch"?a.config.cases??[]:(a.config.rules??[]).filter(p=>typeof p.to=="string"),d=a.type==="branch"?a.config.default:a.config.default?.to,l=new Set(i.map(p=>p.to));d&&l.add(d);let c=n.edges.filter(p=>p.from===a.id);for(let p of c){let f=p.fromPort??"";l.has(f)||e.push(`${a.type} "${a.id}" has outgoing edge with port "${f}" not declared in cases or default`)}}let s=no(n);for(let a of s)e.push(`cycle without agent/checkpoint: ${a.join(" -> ")}`);return e}function eo(n){return n==="end"||n==="checkpoint"||n==="subProcess"||n==="signal.wait"||n==="timer.boundary"}function to(n){return n==="agent"||n==="owner.ask"||n==="person.wait"||n==="checkpoint"||n==="subProcess"||n==="signal.wait"||n==="timer.boundary"}function no(n){let e=new Map;for(let i of n.edges)e.has(i.from)||e.set(i.from,[]),e.get(i.from).push(i.to);let t=new Map(n.nodes.map(i=>[i.id,i])),r=[],o=new Map,s=[],a=i=>{if(o.get(i)===1){let d=s.indexOf(i);if(d>=0){let l=s.slice(d).concat(i);l.some(p=>{let f=t.get(p)?.type;return f?to(f):!1})||r.push(l)}return}if(o.get(i)!==2){o.set(i,1),s.push(i);for(let d of e.get(i)??[])a(d);s.pop(),o.set(i,2)}};for(let i of n.nodes)o.get(i.id)!==2&&a(i.id);return r}var wn=u.enum(["running","paused","completed","failed","canceled"]),ro=u.enum(["ok","failed","timeout","skipped","paused","resumed"]),oo=u.object({at:u.string(),nodeId:u.string(),inputKeys:u.array(u.string()).default([]),status:ro,output:u.record(u.unknown()).optional(),idempotencyKey:u.string(),note:u.string().optional(),startedAt:u.string().optional(),durationMs:u.number().int().min(0).optional()}),so=u.object({backend:u.string(),id:u.string()}),io=u.discriminatedUnion("kind",[u.object({kind:u.literal("checkpoint"),nodeId:u.string(),checkpointName:u.string(),resumeMatch:u.record(u.unknown()).default({})}),u.object({kind:u.literal("subProcess"),nodeId:u.string(),childRunId:u.string(),childWorkflowId:u.string()}),u.object({kind:u.literal("signalWait"),nodeId:u.string(),signalName:u.string(),match:u.record(u.unknown()).default({}),scope:u.enum(["workflow","global"]).default("workflow")}),u.object({kind:u.literal("timerWait"),nodeId:u.string(),fireAt:u.string()}),u.object({kind:u.literal("ownerDecision"),nodeId:u.string(),cardId:u.string(),purpose:u.enum(["ask","send","start"]),message:u.object({channel:u.string(),chatId:u.string(),accountId:u.string().optional(),text:u.string(),to:u.string().optional()}).optional()}),u.object({kind:u.literal("replyWait"),nodeId:u.string(),channel:u.string(),chatId:u.string(),accountId:u.string().optional(),from:u.string().optional(),deadline:u.string(),nextRemindAt:u.string().optional(),remindEveryMs:u.number().optional(),reminders:u.number().int().default(0),maxReminders:u.number().int().default(0),reminds:u.string().optional()}),u.object({kind:u.literal("agentStep"),nodeId:u.string(),agentId:u.string(),nudges:u.number().int().default(0),maxNudges:u.number().int().default(0),stallMs:u.number(),nextNudgeAt:u.string().optional(),blocked:u.string().optional()}),u.object({kind:u.literal("agentStop"),nodeId:u.string(),agentId:u.string(),taskId:u.string().optional()})]),ao=u.object({id:u.string(),title:u.string()}),lo=u.object({at:u.string(),kind:u.enum(["plan","revise"]),reason:u.string().optional(),steps:u.array(u.string()),dropped:u.array(u.string()).default([])}),uo=u.object({steps:u.array(ao),current:u.object({id:u.string(),startedAt:u.string()}).optional(),revisions:u.array(lo).default([])}),co=u.object({title:u.string().optional(),tags:u.array(u.string()).default([]),startedBy:u.string().optional(),requestId:u.string().optional(),followUp:u.boolean().default(!1),approvedAtStart:u.boolean().default(!1),approved:u.record(u.string()).optional(),blocked:u.object({nodeId:u.string(),reason:u.string(),at:u.string()}).optional(),endNotifiedAt:u.string().optional(),wrap:u.object({agentId:u.string(),channel:u.string(),mode:u.enum(["linear","plan"]),taskId:u.string().optional()}).optional(),plan:uo.optional(),continues:u.string().optional()}),po=u.object({id:u.string(),workflowId:u.string(),workflowVersion:u.literal(2),homeNode:u.string(),status:wn,pausedAt:io.optional(),context:u.record(u.record(u.unknown())).default({}),pending:u.array(u.string()).default([]),joinCounters:u.record(u.array(u.string())).default({}),entityRef:so,history:u.array(oo).default([]),parentRunId:u.string().nullable().default(null),parentNodeId:u.string().nullable().default(null),rootRunId:u.string().nullable().default(null),depth:u.number().int().min(0).default(0),eventRootId:u.string().optional(),meta:co.optional(),createdAt:u.string(),updatedAt:u.string()});import kn from"js-yaml";var fo=new Set(["branch","gateway.parallel","rule","signal.wait","subProcess","timer.boundary","checkpoint"]),S=class extends Error{constructor(t,r){super(t);this.mark=r;this.name="WorkflowYamlError"}};function he(n,e={}){if(!n||n.trim()==="")throw new S(`${E(e)}empty file \u2014 workflow YAML must contain at least an id, version, title, and one node.`);let t;try{t=kn.loadAll(n)}catch(o){let s=o?.mark;throw new S(`${E(e)}YAML parse error: ${o?.reason??o?.message??o}`+(s?` (line ${s.line+1}, column ${s.column+1})`:""),s)}if(t.length===0||t.length===1&&t[0]==null)throw new S(`${E(e)}YAML produced no document.`);if(t.length>1)throw new S(`${E(e)}multi-document YAML is not supported in v1; one workflow per file.`);let r=t[0];if(typeof r!="object"||r===null||Array.isArray(r)){let o=Array.isArray(r)?"array":typeof r;throw new S(`${E(e)}top-level YAML must be a mapping (got ${o}).`)}return bn(r,e)}function bn(n,e={}){if(!("flow"in n))return n;let t=n.flow;if(t==null){let p={...n};return delete p.flow,p}if(!Array.isArray(t))throw new S(`${E(e)}flow must be an array of node ids (got ${typeof t}).`);for(let p of t)if(typeof p!="string")throw new S(`${E(e)}flow entries must be strings (got ${typeof p}).`);let r=t,o=Array.isArray(n.nodes)?n.nodes:[],s=new Map;for(let p of o)p&&typeof p=="object"&&typeof p.id=="string"&&typeof p.type=="string"&&s.set(p.id,p.type);for(let p of r){if(!s.has(p))throw new S(`${E(e)}flow references unknown node "${p}".`);let f=s.get(p);if(fo.has(f))throw new S(`${E(e)}flow cannot include ${f} node "${p}"; use explicit edges for ${f} nodes.`)}let a=[];for(let p=0;p<r.length-1;p++)a.push({from:r[p],to:r[p+1]});let i=Array.isArray(n.edges)?n.edges:[],d=new Set,l=[];for(let p of i){if(!p||typeof p!="object")continue;let f=yn(p.from,p.fromPort,p.to);f&&!d.has(f)?(d.add(f),l.push(p)):f||l.push(p)}for(let p of a){let f=yn(p.from,void 0,p.to);f&&!d.has(f)&&(d.add(f),l.push(p))}let c={...n,edges:l};return delete c.flow,c}function yn(n,e,t){return typeof n!="string"||typeof t!="string"?null:`${n}::${typeof e=="string"?e:""}::${t}`}function E(n){return n.filePath?`${n.filePath}: `:""}function go(n){return kn.dump(n,{noRefs:!0,lineWidth:100,sortKeys:!1})}import{Document as mo,isMap as we,isSeq as ho,isScalar as In,parseDocument as wo}from"yaml";function vn(n,e){let t=wo(n);if(!t.contents||!we(t.contents)){let r=new mo(e);return t.commentBefore&&(r.commentBefore=t.commentBefore),String(r)}return Je(t,t.contents,e),String(t)}function Je(n,e,t){let r=Object.keys(t),o=new Set(r),s=new Map;for(let i of e.items){let d=bo(i);d!==null&&s.set(d,i)}let a=[];for(let i of r){let d=t[i],l=s.get(i);l?(yo(n,l,d),a.push(l)):a.push(n.createPair(i,d))}e.items=a}function yo(n,e,t){let r=e.value;if(t==null){e.value=n.createNode(null);return}if(typeof t!="object"){e.value=n.createNode(t);return}if(Array.isArray(t)){ho(r)?ko(n,r,t):e.value=n.createNode(t);return}we(r)?Je(n,r,t):e.value=n.createNode(t)}function ko(n,e,t){if(!(t.length>0&&t.every(a=>a&&typeof a=="object"&&typeof a.id=="string"))){let a=n.createNode(t);e.items=a.items;return}let o=new Map;for(let a of e.items)if(we(a)){let i=a.get("id",!0);In(i)&&typeof i.value=="string"&&o.set(i.value,a)}let s=[];for(let a of t){let i=a.id,d=o.get(i);d&&we(d)?(Je(n,d,a),s.push(d)):s.push(n.createNode(a))}e.items=s}function bo(n){let e=n.key;return In(e)&&typeof e.value=="string"?e.value:typeof e=="string"?e:null}var $n=new Map,Ve=class{baseDir;constructor(e={}){this.baseDir=e.baseDir??N(process.cwd(),".agentx/workflows"),Io(this.baseDir,{recursive:!0})}pathFor(e){return this.pathForJson(e)}pathForJson(e){return N(this.baseDir,`${e}.json`)}pathForYaml(e){return N(this.baseDir,`${e}.yaml`)}isWorkflowFile(e){return e.startsWith("_")?!1:e.endsWith(".json")||e.endsWith(".yaml")||e.endsWith(".yml")}idFromFilename(e){return e.replace(/\.(json|ya?ml)$/,"")}readAndParse(e){let t=N(this.baseDir,e),r=ke(t,"utf-8");return e.endsWith(".json")?JSON.parse(r):he(r,{filePath:e})}list(){if(!A(this.baseDir))return[];let e=new Map,t=[];for(let i of ye(this.baseDir,{withFileTypes:!0})){if(!i.isFile()||!this.isWorkflowFile(i.name))continue;let d=this.idFromFilename(i.name),l=e.get(d)??[];l.push(i.name),e.set(d,l);try{let c=vo(N(this.baseDir,i.name));t.push(`${i.name}:${c.mtimeMs}:${c.size}`)}catch{t.push(`${i.name}:?`)}}let r=t.sort().join("|"),o=$n.get(this.baseDir);if(o&&o.signature===r)return o.workflows.slice();let s=[];for(let[,i]of e)if(!(i.length>1))try{let d=this.readAndParse(i[0]),l=O.safeParse(d);l.success&&s.push(l.data)}catch{}let a=s.sort((i,d)=>i.id.localeCompare(d.id));return $n.set(this.baseDir,{signature:r,workflows:a}),a.slice()}validateAll(){let e=[];if(!A(this.baseDir))return e;let t=new Map;for(let r of ye(this.baseDir,{withFileTypes:!0})){if(!r.isFile()||!this.isWorkflowFile(r.name))continue;let o=this.idFromFilename(r.name),s=t.get(o)??[];s.push(r.name),t.set(o,s)}for(let[r,o]of t){if(o.length>1){let p=[...o].sort();for(let f of p)e.push({id:r,path:Ge(this.baseDir,N(this.baseDir,f)),issues:[`duplicate workflow id "${r}" \u2014 found ${p.join(" and ")}; delete one to disambiguate`],isValid:!1});continue}let s=o[0],a=N(this.baseDir,s),i=Ge(this.baseDir,a),d;try{d=this.readAndParse(s)}catch(p){let f=p instanceof S?p.message:`parse error: ${p?.message??p}`;e.push({id:r,path:i,issues:[f],isValid:!1});continue}let l=O.safeParse(d);if(!l.success){let p=l.error.issues.map(f=>`${f.path.join(".")||"<root>"}: ${f.message}`);e.push({id:String(d?.id??r),path:i,issues:p,isValid:!1});continue}let c=te(l.data);e.push({workflow:l.data,issues:c,isValid:c.length===0})}return e}get(e){let t=this.pathForJson(e),r=this.pathForYaml(e),o=N(this.baseDir,`${e}.yml`),s=A(t),a=A(r)||A(o);if(s&&a)return null;if(s)try{let d=JSON.parse(ke(t,"utf-8")),l=O.safeParse(d);return l.success?l.data:null}catch{return null}let i=A(r)?r:A(o)?o:null;if(i)try{let d=ke(i,"utf-8"),l=he(d,{filePath:Ge(this.baseDir,i)}),c=O.safeParse(l);return c.success?c.data:null}catch{return null}if(!A(this.baseDir))return null;for(let d of ye(this.baseDir,{withFileTypes:!0}))if(!(!d.isFile()||!this.isWorkflowFile(d.name)||this.idFromFilename(d.name)===e))try{let c=this.readAndParse(d.name),p=O.safeParse(c);if(p.success&&p.data.id===e)return p.data}catch{}return null}save(e,t={}){let r=new Date().toISOString().slice(0,10),o=O.parse({...e,created:e.created||r,updated:r}),s=this.pathForYaml(o.id),a=N(this.baseDir,`${o.id}.yml`),i=A(s)?s:A(a)?a:null;if(!i&&A(this.baseDir)){for(let d of ye(this.baseDir,{withFileTypes:!0}))if(!(!d.isFile()||!this.isWorkflowFile(d.name))&&!d.name.endsWith(".json"))try{let l=this.readAndParse(d.name),c=O.safeParse(l);if(c.success&&c.data.id===o.id){i=N(this.baseDir,d.name);break}}catch{}}if(i&&t.convertFromYaml)return be(i),Ye(this.pathForJson(o.id),JSON.stringify(o,null,2)+`
|
|
14
14
|
`),o;if(i){let d=ke(i,"utf-8");try{let l=vn(d,o);return Ye(i,l),o}catch(l){let c=new Error(`yaml round-trip failed for "${o.id}" at ${i}: ${l?.message??l}`);throw c.yamlPath=i,c}}return Ye(this.pathForJson(o.id),JSON.stringify(o,null,2)+`
|
|
15
15
|
`),o}delete(e){let t=this.pathForJson(e),r=this.pathForYaml(e),o=N(this.baseDir,`${e}.yml`),s=!1;return A(t)&&(be(t),s=!0),A(r)&&(be(r),s=!0),A(o)&&(be(o),s=!0),s}};import{createHash as $o,randomUUID as So}from"crypto";import{appendFileSync as Sn,existsSync as D,mkdirSync as Qe,readdirSync as ne,readFileSync as re,renameSync as Ao,statSync as Ze,unlinkSync as oe,writeFileSync as An}from"fs";import{resolve as $}from"path";var L="task";function Ro(n){return n.replace(/[^a-zA-Z0-9._:#@-]/g,"_").slice(0,200)}function v(n,e,t){return $o("sha1").update(`${n}|${e}|${t}`).digest("hex").slice(0,16)}var Xe=class{baseDir;runsDir;indexDir;tasksDir;nodeId;constructor(e){this.baseDir=e.baseDir??$(process.cwd(),".agentx/workflows"),this.runsDir=$(this.baseDir,"_runs"),this.indexDir=$(this.baseDir,"_index"),this.tasksDir=$(this.baseDir,"_tasks"),this.nodeId=e.nodeId,Qe(this.runsDir,{recursive:!0}),Qe(this.indexDir,{recursive:!0}),Qe(this.tasksDir,{recursive:!0})}runPath(e,t){if(t!==void 0&&t!==L)return $(this.runsDir,`${e}.jsonl`);if(t===L){let o=$(this.runsDir,`${e}.jsonl`);return D(o)?o:$(this.tasksDir,`${e}.jsonl`)}let r=$(this.tasksDir,`${e}.jsonl`);return D(r)?r:$(this.runsDir,`${e}.jsonl`)}indexPath(e){return $(this.indexDir,`${e.backend}__${Ro(e.id)}.json`)}create(e){let t=new Date().toISOString(),r=e.id??So(),o={id:r,workflowId:e.workflowId,workflowVersion:2,homeNode:this.nodeId,status:"running",pausedAt:void 0,context:e.initialContext??{},pending:e.initialPending,entityRef:e.entityRef,history:[],parentRunId:e.parentRunId??null,parentNodeId:e.parentNodeId??null,rootRunId:e.rootRunId??r,depth:e.depth??0,eventRootId:e.eventRootId??jt()?.rootId,joinCounters:{},...e.meta?{meta:e.meta}:{},createdAt:t,updatedAt:t};return this.appendSnapshot(o),this.writeIndex(e.entityRef,o.id),o}get(e){return this.readRun(this.runPath(e))}readRun(e){let t;try{t=re(e,"utf-8").trim()}catch{return null}if(!t)return null;let r=null;for(let o of t.split(`
|
|
@@ -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-PIVIOIEC.js.map
|