agentix-cli 0.131.0 → 0.133.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/dist/{App-WZ3HAKES.js → App-WQPA77VJ.js} +2 -2
- package/dist/{ChatApp-K4HDJL2S.js → ChatApp-TGW66I4Y.js} +2 -2
- package/dist/{absorb-eval-ER27DHHK.js → absorb-eval-37XZJACN.js} +2 -2
- package/dist/{agent-AQSVISXX.js → agent-FWHYHXWC.js} +2 -2
- package/dist/{board-dashboard-3AI2Z2SP.js → board-dashboard-GKE4KWJH.js} +435 -270
- package/dist/board-dashboard-GKE4KWJH.js.map +1 -0
- package/dist/{builtin-W6KNX7RS.js → builtin-YD7MC572.js} +2 -2
- package/dist/chunk-2BF6HJJD.js +54 -0
- package/dist/chunk-2BF6HJJD.js.map +1 -0
- package/dist/{chunk-MFIM5Y3J.js → chunk-3TETB22A.js} +2 -2
- package/dist/{chunk-7UPFZJIT.js → chunk-4NEO5KB2.js} +30 -30
- package/dist/chunk-4NEO5KB2.js.map +1 -0
- package/dist/{chunk-B2Q3PTPS.js → chunk-4XPVU3N2.js} +2 -2
- package/dist/chunk-57Y2WZT2.js +55 -0
- package/dist/chunk-57Y2WZT2.js.map +1 -0
- package/dist/{chunk-E2VDBT3T.js → chunk-ANC5QXFB.js} +2 -2
- package/dist/chunk-BI6VG4DV.js +37 -0
- package/dist/chunk-BI6VG4DV.js.map +1 -0
- package/dist/{chunk-YQRWUF4Y.js → chunk-D5IHICX3.js} +2 -2
- package/dist/{chunk-IA7INHXY.js → chunk-F5PVUB4Y.js} +2 -2
- package/dist/{chunk-CL33CRH5.js → chunk-F7GKG5ZO.js} +3 -3
- package/dist/chunk-F7GKG5ZO.js.map +1 -0
- package/dist/{chunk-L2WVQREN.js → chunk-GUEIF7ZF.js} +2 -2
- package/dist/{chunk-APZIH3AY.js → chunk-GZY5DYXT.js} +2 -2
- package/dist/chunk-HF5EF335.js +8 -0
- package/dist/chunk-HF5EF335.js.map +1 -0
- package/dist/{chunk-AKOXTIJS.js → chunk-HIUHKOKK.js} +2 -2
- package/dist/chunk-IDZXAOBC.js +156 -0
- package/dist/chunk-IDZXAOBC.js.map +1 -0
- package/dist/chunk-IZDKRNXC.js +52 -0
- package/dist/chunk-IZDKRNXC.js.map +1 -0
- package/dist/{chunk-CSWGYSC4.js → chunk-JA5Y4LDP.js} +2 -2
- package/dist/{chunk-ERNBJLIQ.js → chunk-KUOH5MFS.js} +2 -2
- package/dist/{chunk-YA6E47BR.js → chunk-OQV3LWJI.js} +2 -2
- package/dist/{chunk-2YB2G2BP.js → chunk-PHCWYKQW.js} +2 -2
- package/dist/{chunk-GLQLCBJS.js → chunk-QSKG754X.js} +6 -3
- package/dist/chunk-QSKG754X.js.map +1 -0
- package/dist/{chunk-6O6NW3ZG.js → chunk-RJFPCW7T.js} +2 -2
- package/dist/{chunk-YVR6652A.js → chunk-RTHZQGFC.js} +2 -2
- package/dist/{chunk-KRK7OOTK.js → chunk-S2UXDEGW.js} +2 -2
- package/dist/{chunk-L4ZS4HGJ.js → chunk-SJPQQ4OF.js} +255 -247
- package/dist/chunk-SJPQQ4OF.js.map +1 -0
- package/dist/{chunk-WKQQIYOE.js → chunk-V4IFJLQS.js} +2 -2
- package/dist/{chunk-L4ALHWII.js → chunk-VH2ASPFQ.js} +2 -2
- package/dist/{chunk-AD4QZZVN.js → chunk-YXFTUOZR.js} +2 -2
- package/dist/{chunk-KIYV4ZHG.js → chunk-ZN5DC6WS.js} +2 -2
- package/dist/cli.js +1 -1
- package/dist/{client-YIR3ELVN.js → client-7UW2ELPP.js} +2 -2
- package/dist/config-TNYVPT4R.js +2 -0
- package/dist/{config-mutate-KDRHKQE4.js → config-mutate-GV7BVG3I.js} +2 -2
- package/dist/config-mutator-AKCR3VKM.js +2 -0
- package/dist/{contributions-MTKXXLIP.js → contributions-J57B3KIX.js} +2 -2
- package/dist/{doctor-FJ5RCG4J.js → doctor-ROKIYJRT.js} +2 -2
- package/dist/{failure-candidates-JNGUVBDG.js → failure-candidates-XZSZP4HT.js} +2 -2
- package/dist/follow-up-tool-S2U7DFSW.js +7 -0
- package/dist/follow-up-tool-S2U7DFSW.js.map +1 -0
- package/dist/{hub-CF4VFSRT.js → hub-HOVJC4HR.js} +2 -2
- package/dist/index.d.ts +1432 -6
- package/dist/index.js +1 -1
- package/dist/{program-ZPNEAACQ.js → program-LAOU5DQ3.js} +225 -217
- package/dist/program-LAOU5DQ3.js.map +1 -0
- package/dist/{promote-G6BOY7K5.js → promote-FVWRM4BE.js} +2 -2
- package/dist/query-HBCL3FHO.js +2 -0
- package/dist/query-settings-RD6GEN2V.js +3 -0
- package/dist/query-settings-RD6GEN2V.js.map +1 -0
- package/dist/{registry-TAUHYJCK.js → registry-NT4H7HYP.js} +2 -2
- package/dist/{request-planner-V3R5J3V4.js → request-planner-JOXSAAHO.js} +2 -2
- package/dist/{review-candidates-TC7RJB4W.js → review-candidates-6N5435V7.js} +2 -2
- package/dist/{routing-XQD74ERK.js → routing-6G2QVFIG.js} +2 -2
- package/dist/schedule-tool-3NYUPKSC.js +2 -0
- package/dist/{scheduler-WOOXIOER.js → scheduler-WOH2O3EP.js} +2 -2
- package/dist/{seat-B75JIAS3.js → seat-I2FBJDTV.js} +2 -2
- package/dist/{select-I6BSBQXP.js → select-5YZQJLLD.js} +2 -2
- package/dist/{set-enabled-THNVITGU.js → set-enabled-CQEUZLHU.js} +2 -2
- package/dist/{tool-LFWTZHB7.js → tool-PIJXUBEC.js} +2 -2
- package/dist/{tool-CEBIS6GK.js → tool-R77KFLZ3.js} +2 -2
- package/dist/wiki-GCOFERTB.js +2 -0
- package/package.json +2 -1
- package/dist/board-dashboard-3AI2Z2SP.js.map +0 -1
- package/dist/chunk-2SXF66O6.js +0 -55
- package/dist/chunk-2SXF66O6.js.map +0 -1
- package/dist/chunk-2ZDV3DCT.js +0 -52
- package/dist/chunk-2ZDV3DCT.js.map +0 -1
- package/dist/chunk-76Z4VHDX.js +0 -8
- package/dist/chunk-76Z4VHDX.js.map +0 -1
- package/dist/chunk-7UPFZJIT.js.map +0 -1
- package/dist/chunk-CBFBGN7J.js +0 -54
- package/dist/chunk-CBFBGN7J.js.map +0 -1
- package/dist/chunk-CL33CRH5.js.map +0 -1
- package/dist/chunk-GLQLCBJS.js.map +0 -1
- package/dist/chunk-L4ZS4HGJ.js.map +0 -1
- package/dist/chunk-VSL2SSBH.js +0 -156
- package/dist/chunk-VSL2SSBH.js.map +0 -1
- package/dist/chunk-YPCZ5TNK.js +0 -37
- package/dist/chunk-YPCZ5TNK.js.map +0 -1
- package/dist/config-4DOJYA2K.js +0 -2
- package/dist/config-mutator-4PPBACWU.js +0 -2
- package/dist/follow-up-tool-SVZDSUIU.js +0 -6
- package/dist/follow-up-tool-SVZDSUIU.js.map +0 -1
- package/dist/program-ZPNEAACQ.js.map +0 -1
- package/dist/query-H24BI3BI.js +0 -2
- package/dist/query-settings-IJB3QMDW.js +0 -3
- package/dist/query-settings-IJB3QMDW.js.map +0 -1
- package/dist/schedule-tool-U6KLY5MT.js +0 -2
- package/dist/wiki-3ATPAHC2.js +0 -2
- /package/dist/{App-WZ3HAKES.js.map → App-WQPA77VJ.js.map} +0 -0
- /package/dist/{ChatApp-K4HDJL2S.js.map → ChatApp-TGW66I4Y.js.map} +0 -0
- /package/dist/{absorb-eval-ER27DHHK.js.map → absorb-eval-37XZJACN.js.map} +0 -0
- /package/dist/{agent-AQSVISXX.js.map → agent-FWHYHXWC.js.map} +0 -0
- /package/dist/{builtin-W6KNX7RS.js.map → builtin-YD7MC572.js.map} +0 -0
- /package/dist/{chunk-MFIM5Y3J.js.map → chunk-3TETB22A.js.map} +0 -0
- /package/dist/{chunk-B2Q3PTPS.js.map → chunk-4XPVU3N2.js.map} +0 -0
- /package/dist/{chunk-E2VDBT3T.js.map → chunk-ANC5QXFB.js.map} +0 -0
- /package/dist/{chunk-YQRWUF4Y.js.map → chunk-D5IHICX3.js.map} +0 -0
- /package/dist/{chunk-IA7INHXY.js.map → chunk-F5PVUB4Y.js.map} +0 -0
- /package/dist/{chunk-L2WVQREN.js.map → chunk-GUEIF7ZF.js.map} +0 -0
- /package/dist/{chunk-APZIH3AY.js.map → chunk-GZY5DYXT.js.map} +0 -0
- /package/dist/{chunk-AKOXTIJS.js.map → chunk-HIUHKOKK.js.map} +0 -0
- /package/dist/{chunk-CSWGYSC4.js.map → chunk-JA5Y4LDP.js.map} +0 -0
- /package/dist/{chunk-ERNBJLIQ.js.map → chunk-KUOH5MFS.js.map} +0 -0
- /package/dist/{chunk-YA6E47BR.js.map → chunk-OQV3LWJI.js.map} +0 -0
- /package/dist/{chunk-2YB2G2BP.js.map → chunk-PHCWYKQW.js.map} +0 -0
- /package/dist/{chunk-6O6NW3ZG.js.map → chunk-RJFPCW7T.js.map} +0 -0
- /package/dist/{chunk-YVR6652A.js.map → chunk-RTHZQGFC.js.map} +0 -0
- /package/dist/{chunk-KRK7OOTK.js.map → chunk-S2UXDEGW.js.map} +0 -0
- /package/dist/{chunk-WKQQIYOE.js.map → chunk-V4IFJLQS.js.map} +0 -0
- /package/dist/{chunk-L4ALHWII.js.map → chunk-VH2ASPFQ.js.map} +0 -0
- /package/dist/{chunk-AD4QZZVN.js.map → chunk-YXFTUOZR.js.map} +0 -0
- /package/dist/{chunk-KIYV4ZHG.js.map → chunk-ZN5DC6WS.js.map} +0 -0
- /package/dist/{client-YIR3ELVN.js.map → client-7UW2ELPP.js.map} +0 -0
- /package/dist/{config-4DOJYA2K.js.map → config-TNYVPT4R.js.map} +0 -0
- /package/dist/{config-mutate-KDRHKQE4.js.map → config-mutate-GV7BVG3I.js.map} +0 -0
- /package/dist/{config-mutator-4PPBACWU.js.map → config-mutator-AKCR3VKM.js.map} +0 -0
- /package/dist/{contributions-MTKXXLIP.js.map → contributions-J57B3KIX.js.map} +0 -0
- /package/dist/{doctor-FJ5RCG4J.js.map → doctor-ROKIYJRT.js.map} +0 -0
- /package/dist/{failure-candidates-JNGUVBDG.js.map → failure-candidates-XZSZP4HT.js.map} +0 -0
- /package/dist/{hub-CF4VFSRT.js.map → hub-HOVJC4HR.js.map} +0 -0
- /package/dist/{promote-G6BOY7K5.js.map → promote-FVWRM4BE.js.map} +0 -0
- /package/dist/{query-H24BI3BI.js.map → query-HBCL3FHO.js.map} +0 -0
- /package/dist/{registry-TAUHYJCK.js.map → registry-NT4H7HYP.js.map} +0 -0
- /package/dist/{request-planner-V3R5J3V4.js.map → request-planner-JOXSAAHO.js.map} +0 -0
- /package/dist/{review-candidates-TC7RJB4W.js.map → review-candidates-6N5435V7.js.map} +0 -0
- /package/dist/{routing-XQD74ERK.js.map → routing-6G2QVFIG.js.map} +0 -0
- /package/dist/{schedule-tool-U6KLY5MT.js.map → schedule-tool-3NYUPKSC.js.map} +0 -0
- /package/dist/{scheduler-WOOXIOER.js.map → scheduler-WOH2O3EP.js.map} +0 -0
- /package/dist/{seat-B75JIAS3.js.map → seat-I2FBJDTV.js.map} +0 -0
- /package/dist/{select-I6BSBQXP.js.map → select-5YZQJLLD.js.map} +0 -0
- /package/dist/{set-enabled-THNVITGU.js.map → set-enabled-CQEUZLHU.js.map} +0 -0
- /package/dist/{tool-LFWTZHB7.js.map → tool-PIJXUBEC.js.map} +0 -0
- /package/dist/{tool-CEBIS6GK.js.map → tool-R77KFLZ3.js.map} +0 -0
- /package/dist/{wiki-3ATPAHC2.js.map → wiki-GCOFERTB.js.map} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{d as h}from"./chunk-
|
|
1
|
+
import{d as h}from"./chunk-OQV3LWJI.js";var d=["main contact","primary contact","point of contact","billing contact","technical contact","decision maker"],f=/[\w.+-]+@[\w-]+(?:\.[\w-]+)+/g,w=/\b(role|title|position|job)\s*\**\s*[::]\s*\**\s*([^\n;|]+)/gi;function L(t,c,e=[]){let l=[c,...e].join(`
|
|
2
2
|
`),a=l.toLowerCase(),i=h(t,l);for(let s of p(t.match(f)??[]))a.includes(s.toLowerCase())||i.push(`email ${s}`);let m=t.toLowerCase();for(let s of d)m.includes(s)&&!a.includes(s)&&i.push(`marker "${s}"`);for(let s of t.matchAll(w)){let n=s[2].replace(/\*+/g,"").trim();n&&!a.includes(n.toLowerCase())&&i.push(`${s[1].toLowerCase()} "${n}"`)}return p(i)}function p(t){return[...new Set(t)]}var $=.9,g=/^\s*(?:wait\b|here(?:'s| is) the (?:updated|modified|patched|revised)|i (?:must|need to|will|should) (?:output|return|write)|(?:okay|ok|sure)[,.!]\s|let me\b|as requested\b)/im;function k(t,c){let e=[],l=t.split(`
|
|
3
3
|
`).filter(o=>o.trim()).length,a=c.split(`
|
|
4
4
|
`).filter(o=>o.trim()).length;l>=5&&a<Math.floor(l*$)&&e.push(`the article shrinks from ${l} to ${a} lines`);let i=c.match(g);i&&!t.match(g)&&e.push(`it contains the model's own commentary ("${i[0].trim().slice(0,40)}")`);let m=o=>{let r=new Map;for(let u of o.split(`
|
|
5
5
|
`))/^#{1,6} /.test(u)&&r.set(u.trim(),(r.get(u.trim())??0)+1);return r},s=m(t);for(let[o,r]of m(c))r>1&&r>(s.get(o)??0)&&e.push(`the heading "${o}" appears ${r} times`);let n=L(t,c);return n.length&&e.push(`it drops ${n.length} fact(s): ${n.slice(0,6).join(", ")}${n.length>6?", \u2026":""}`),e}export{L as a,k as b};
|
|
6
|
-
//# sourceMappingURL=chunk-
|
|
6
|
+
//# sourceMappingURL=chunk-V4IFJLQS.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{q as _,r as W}from"./chunk-2AXFYDWF.js";import{b as Y,c as I,d as O}from"./chunk-AQASR6KR.js";import{b as F}from"./chunk-MEFPXHQJ.js";import{a as E}from"./chunk-
|
|
1
|
+
import{q as _,r as W}from"./chunk-2AXFYDWF.js";import{b as Y,c as I,d as O}from"./chunk-AQASR6KR.js";import{b as F}from"./chunk-MEFPXHQJ.js";import{a as E}from"./chunk-RTHZQGFC.js";import{b as L}from"./chunk-4VVHGR7H.js";import{createHash as ee}from"crypto";import{existsSync as H,readdirSync as te,readFileSync as re,writeFileSync as ne}from"fs";import{resolve as P}from"path";function be(n,r,s,t,o,i,c="",p="",m=""){return Z(r,s,t,o,i,c,p,m)}function Z(n,r,s,t,o,i="",c="",p=""){let m=r?`
|
|
2
2
|
## Worldview
|
|
3
3
|
|
|
4
4
|
${r}
|
|
@@ -249,4 +249,4 @@ ${u}`}var x="memory-promoter",oe=["project","reference","feedback"],K="_memory-p
|
|
|
249
249
|
Re-emit the FULL corrected JSON object \u2014 same structure, fixed issues, valid JSON only.`:n,y=await t(`${a}/task`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({agent:r.viaAgent,message:h,freshSession:s===null,context:{channel:"api",chatId:r.chatId??"memory-promote"}}),signal:i.signal});if(!y.ok){let f=await y.text().catch(()=>"");throw new Error(`agent /task ${y.status}: ${f.slice(0,500)}`)}let w=await y.json();if(w.error)throw new Error(`agent reported error: ${w.error}`);let b=String(w.content??"").trim();if(!b)throw new Error("agent returned empty content");return b}if(!r.model)throw new Error("callPromotionLlm: viaAgent or model is required");let p=process.env.ANTHROPIC_API_KEY;if(!p)throw new Error("ANTHROPIC_API_KEY not set; use --via <agentId> instead");let m=[{role:"user",content:n}];s&&(m.push({role:"assistant",content:"(previous attempt; will retry with corrections)"}),m.push({role:"user",content:`Your previous response failed validation: ${s}
|
|
250
250
|
Re-emit the FULL corrected JSON object.`}));let u=await t(me,{method:"POST",headers:{"Content-Type":"application/json","x-api-key":p,"anthropic-version":ge},body:JSON.stringify({model:r.model,max_tokens:8e3,messages:m}),signal:i.signal});if(!u.ok){let a=await u.text().catch(()=>"");throw new Error(`anthropic API ${u.status}: ${a.slice(0,500)}`)}let d=await u.json(),e=(Array.isArray(d.content)?d.content:[]).filter(a=>a?.type==="text").map(a=>a.text).join(`
|
|
251
251
|
`).trim();if(!e)throw new Error("anthropic API returned no text content");return e}finally{clearTimeout(c)}}async function Se(n={}){let r=n.wikiDir??P(process.cwd(),".agentx","wiki"),s=n.memoryRoot??P(process.cwd(),".agentx"),t=n.log??(()=>{}),o=n.now??Date.now(),i={candidates:[],clusters:[],proposed:[],skipped:[],gaps:[],warnings:[],errors:[],dryRun:!n.commit},c=new E(r,(...l)=>t(l.map(String).join(" "))),p=c.rebuildIndex(),m=z(r),u=[...ce(s),...n.extraCandidates??[]];if(i.candidates=de(u,p,m,{types:n.types,sinceMs:n.sinceMs,agentFilter:n.agentFilter,now:o,max:n.max}),i.candidates.length===0)return t("no unpromoted memories in window"),i;if(i.clusters=le(i.candidates),i.dryRun)return i;let d=p.articles.map(l=>({title:l.title,path:l.path,type:l.type})),g=c.getWorldview()??"",e=n.budgetTokens??ue,a=i.clusters,h=D(x,a,d,g);for(;R(h)>e&&a.length>1;)a=a.slice(0,-1),h=D(x,a,d,g);if(R(h)>e)return i.errors.push(`judge prompt (~${R(h)} tokens) exceeds the ${e}-token budget even with one cluster`),i;a.length<i.clusters.length&&i.warnings.push(`token budget: judged ${a.length} of ${i.clusters.length} clusters; the rest wait for the next run`);let y=a.flatMap(l=>l.candidates),w=new Set(y.map(l=>l.stamp)),b=n.chatId??`memory-promote-${new Date(o).toISOString().slice(0,10)}`,f=B(await G(h,{...n,chatId:b}),w);if("error"in f&&(t(`parse failed (${f.error}) \u2014 retrying with feedback`),f=B(await G(h,{...n,chatId:b},f.error),w)),"error"in f)return i.errors.push(`LLM response unusable after retry: ${f.error}`),i;i.warnings.push(...f.warnings),i.gaps=f.gaps;let v=new Date(o).toISOString(),k=[],T=new Map(y.map(l=>[l.stamp,l]));for(let l of f.articles){let A=c.readArticle(l.path);if(A&&!c.canWrite(A.meta,x)){i.errors.push(`write denied for "${l.path}" (owned by ${A.meta.owner??"?"})`);continue}let M=fe(l.promotedFrom,T),S={id:Y(o,l.path),createdAt:v,status:"pending",article:l,evidence:M,...A?{replaces:{lastUpdated:A.meta.lastUpdated,contentHash:V(A.content)}}:{}};I(r,S),i.proposed.push({id:S.id,path:l.path,title:l.title,type:l.type,stamps:l.promotedFrom,agents:M.agents,occurrences:M.occurrences});for(let X of l.promotedFrom)k.push({stamp:X,decision:"proposed",article:l.path,proposal:S.id,at:v})}for(let l of f.skipped)k.push({stamp:l.stamp,decision:"skipped",reason:l.reason,at:v}),i.skipped.push(l);return k.length&&C(r,k),i}var ue=6e4;function R(n){return Math.ceil(n.length/4)}function V(n){return ee("sha256").update(n).digest("hex").slice(0,16)}var he=600;function ye(n){return n.startsWith("review:")?"review":n.startsWith(j)?"failure":"memory"}function fe(n,r){let s=[];for(let t of n){let o=r.get(t);o&&s.push({stamp:t,kind:ye(t),agentId:o.agentId,type:o.memory.type,name:o.memory.name,description:o.memory.description,...o.occurrences?{occurrences:o.occurrences}:{},...o.sessions?.length?{sessions:o.sessions}:{},...o.tasks?.length?{tasks:o.tasks}:{},...o.failure?{failure:o.failure}:{},...o.memory.author?{author:o.memory.author}:{},...o.memory.taskId?{taskId:o.memory.taskId}:{},updatedAt:o.memory.updatedAt,excerpt:o.memory.body.slice(0,he)})}return{agents:[...new Set(s.map(t=>t.agentId))].sort(),occurrences:Math.max(1,...s.map(t=>t.occurrences??1)),sources:s}}function Ee(n,r,s={}){let t=O(n,r);if(!t)return{ok:!1,error:`no proposal "${r}"`};if(t.status!=="pending")return{ok:!1,error:`proposal "${r}" is already ${t.status}`};let o=s.log??(()=>{}),i=new E(n,(...a)=>o(a.map(String).join(" "))),{article:c}=t,p=i.readArticle(c.path);if(!s.force){if(p&&!t.replaces)return{ok:!1,error:`"${c.path}" was created after this proposal; review it, then approve with --force`};if(p&&t.replaces&&V(p.content)!==t.replaces.contentHash)return{ok:!1,error:`"${c.path}" changed since this proposal; review it, then approve with --force`}}let m=s.now??Date.now(),u=new Date(m).toISOString().slice(0,10);if(!i.writeArticle(c.path,{title:c.title,type:L(c.type)?c.type:void 0,related:c.related,tags:c.tags,owner:x,access:"public",created:p?.meta.created??u,lastUpdated:u,sources:ae(p?.meta.sources,c.promotedFrom)},c.content,x))return{ok:!1,error:`write denied for "${c.path}" (owned by ${p?.meta.owner??"?"})`};let g=new Date(m).toISOString();C(n,c.promotedFrom.map(a=>({stamp:a,decision:"promoted",article:c.path,proposal:r,at:g}))),i.rebuildIndex();let e={...t,status:"approved",decidedBy:s.by??"operator",decidedAt:g};return I(n,e),{ok:!0,proposal:e}}function Oe(n,r,s={}){let t=O(n,r);if(!t)return{ok:!1,error:`no proposal "${r}"`};if(t.status!=="pending")return{ok:!1,error:`proposal "${r}" is already ${t.status}`};let o=new Date(s.now??Date.now()).toISOString();C(n,t.article.promotedFrom.map(c=>({stamp:c,decision:"rejected",article:t.article.path,proposal:r,reason:s.reason,at:o})));let i={...t,status:"rejected",decidedBy:s.by??"operator",decidedAt:o,...s.reason?{reason:s.reason}:{}};return I(n,i),{ok:!0,proposal:i}}export{be as a,x as b,oe as c,K as d,q as e,ie as f,$ as g,ae as h,ce as i,z as j,C as k,le as l,B as m,de as n,G as o,Se as p,R as q,ye as r,fe as s,Ee as t,Oe as u};
|
|
252
|
-
//# sourceMappingURL=chunk-
|
|
252
|
+
//# sourceMappingURL=chunk-VH2ASPFQ.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{f,k as I}from"./chunk-
|
|
1
|
+
import{f,k as I}from"./chunk-QSKG754X.js";import{createHash as $}from"crypto";var k="failure:",x=3,p=5,A=["error","timeout"],T=["memory-promote","procedure-miner"];function h(t,s){return(s??"").toLowerCase().replace(/https?:\/\/\S+/g,"<url>").replace(/(["'`]).*?\1/g,"<v>").replace(/(?:~|\.{0,2})?\/[\w.@-]+(?:\/[\w.@-]+)*/g,"<path>").replace(/\b[0-9a-z]*\d[0-9a-z]*\b/g,"<n>").replace(/[^a-z<>\s]+/g," ").replace(/\s+/g," ").trim().split(" ").filter(Boolean).slice(0,8).join(" ")||t}function y(t){return`${t.agentId}|${t.tool??"no-tool"}|${t.status}|${h(t.status,t.error)}`}function S(t){return $("sha1").update(t).digest("hex").slice(0,10)}function w(t,s){return`${k}${S(t)}@${Math.floor(Math.log2(Math.max(1,s)))}`}function F(t){return t.finalSessionId??t.resumeSessionId??t.taskId}function _(t,s={}){return A.flatMap(e=>I(t,{status:e,since:s.since,limit:1e3})).filter(e=>!T.some(i=>(e.chatId??"").startsWith(i))).map(e=>{let{tool:i,error:n}=b(f(t,e.taskId)?.steps??[]);return{taskId:e.taskId,agentId:e.agentId,chatId:e.chatId,sessionId:F(e),status:e.status,startedAt:e.startedAt,error:n??e.error,messagePreview:e.messagePreview,tool:i}})}function b(t){let s=null,a=null;for(let e of t)e.name==="tool_use"&&e.action?(s=e.action,e.status==="error"&&(a={tool:e.action,error:e.error??e.outputSummary})):e.name==="tool_result"&&e.status==="error"&&(a={tool:e.action??s,error:e.error??e.outputSummary});return a??{tool:s,error:null}}function C(t,s={}){let a=Math.max(2,s.minSessions??x),e=new Map;for(let n of t){let r=y(n);e.set(r,[...e.get(r)??[],n])}let i=[];for(let[n,r]of e){let l=[...new Set([...r].sort((c,g)=>g.startedAt-c.startedAt).map(c=>c.sessionId))];if(l.length<a)continue;r.sort((c,g)=>g.startedAt-c.startedAt);let o=r[0],u=o.tool??"no tool",d=h(o.status,o.error),m=`failure-${S(n)}`;i.push({occurrences:l.length,sessions:l.slice(0,p),tasks:r.slice(0,p).map(c=>c.taskId),failure:{tool:u,errorClass:d,runs:r.length},agentId:o.agentId,key:`${o.agentId}/feedback_${m}`,stamp:w(n,l.length),memory:{name:m,type:"feedback",description:`${o.agentId}: ${u} keeps failing (${d}) in ${l.length} sessions`.slice(0,200),body:E(o.agentId,u,d,l.length,r),createdAt:new Date(r[r.length-1].startedAt).toISOString(),updatedAt:new Date(o.startedAt).toISOString()}})}return i.sort((n,r)=>r.occurrences-n.occurrences)}function E(t,s,a,e,i){let n=i.slice(0,p).map(r=>{let l=(r.messagePreview??"").replace(/\s+/g," ").trim().slice(0,120),o=(r.error??r.status).replace(/\s+/g," ").trim().slice(0,160);return`- ${new Date(r.startedAt).toISOString().slice(0,10)} \`${r.taskId}\` (${r.status})${l?` \u2014 task: ${l}`:""}
|
|
2
2
|
error: ${o}`});return[`**${t}** hit the same failure in ${e} separate sessions (${i.length} runs).`,`- Tool: \`${s}\`
|
|
3
3
|
- Error class: \`${a}\``,"Recurrence across sessions is the finding: any one of these runs is session state. Propose the fix that stops it recurring \u2014 what fails, the likely cause, and what to do instead (a missing fact, a better approach, or a tool or configuration change to make) \u2014 or skip it if the examples do not share a cause.",`**Examples (newest first):**
|
|
4
4
|
${n.join(`
|
|
5
5
|
`)}`].join(`
|
|
6
6
|
|
|
7
7
|
`)}export{k as a,x as b,p as c,h as d,y as e,w as f,F as g,_ as h,b as i,C as j};
|
|
8
|
-
//# sourceMappingURL=chunk-
|
|
8
|
+
//# sourceMappingURL=chunk-YXFTUOZR.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{pa as m,xa as b}from"./chunk-2BF6HJJD.js";b();function w(t){let e=typeof t.node=="string"?t.node:"",n=typeof t.token=="string"?t.token:"";if(!e||!n)try{let o=m(t.config);e||(e=o.dashboard?.daemonUrl||""),n||(n=o.dashboard?.token||"")}catch{}return e||(e="http://localhost:18800"),{baseUrl:e.replace(/\/+$/,""),token:n}}async function d(t,e,n){let o={Accept:"application/json"};t.token&&(o.Authorization=`Bearer ${t.token}`);let r=await fetch(`${t.baseUrl}${e}`,{headers:o,signal:n});if(!r.ok)throw new Error(`GET ${e} \u2192 HTTP ${r.status}`);return await r.json()}function R(t,e){return d(t,"/agents",e)}async function S(t,e){return(await d(t,"/api/processes",e)).processes??[]}function P(t,e){return d(t,"/crons",e)}async function h(t,e,n,o){let r={Accept:"application/json","Content-Type":"application/json"};t.token&&(r.Authorization=`Bearer ${t.token}`);let s=await fetch(`${t.baseUrl}${e}`,{method:"POST",headers:r,body:JSON.stringify(n),signal:o}),a=await s.text(),i;try{i=a?JSON.parse(a):{}}catch{i={raw:a}}if(!s.ok)throw new Error(i?.error||`POST ${e} \u2192 HTTP ${s.status}`);return i}function A(t,e,n="tui"){return h(t,"/api/processes/kill",{...e,reason:n})}function C(t,e,n,o){return h(t,"/task",{agent:e,message:n,context:o??{channel:"tui",chatId:"tui:operator"}})}async function $(t,e,n,o={}){let r={Accept:"text/event-stream","Content-Type":"application/json"};t.token&&(r.Authorization=`Bearer ${t.token}`);let s=await fetch(`${t.baseUrl}/task`,{method:"POST",headers:r,body:JSON.stringify({agent:e,message:n,stream:!0,context:{channel:o.channel??"chat-cli",chatId:o.chatId??"chat-cli:operator"}}),signal:o.signal});if(!s.ok||!s.body){let g=await s.text().catch(()=>"");throw new Error(`POST /task (stream) \u2192 HTTP ${s.status}${g?`: ${g.slice(0,200)}`:""}`)}let a=s.body.getReader(),i=new TextDecoder,u={content:""},c="";try{for(;;){let{done:g,value:p}=await a.read();if(g)break;c+=i.decode(p,{stream:!0});let l;for(;(l=c.indexOf(`
|
|
2
2
|
|
|
3
3
|
`))>=0;){let k=c.slice(0,l);c=c.slice(l+2);let f=x(k);f&&T(f,o,u)}}}finally{try{a.releaseLock()}catch{}}return u}function T(t,e,n){let{event:o,data:r}=t;switch(o){case"text":r?.text&&(n.content+=r.text,e.onText?.(r.text));break;case"thinking":r?.text&&e.onThinking?.(r.text);break;case"tool":e.onTool?.(r);break;case"done":typeof r?.content=="string"&&(n.content=r.content),n.usage=r?.usage,n.duration=r?.duration;break;case"error":n.error=r?.error,n.errorKind=r?.errorKind;break}}function x(t){let e="message",n="";for(let r of t.split(`
|
|
4
4
|
`))r.startsWith("event: ")?e=r.slice(7).trim():r.startsWith("data: ")&&(n=r.slice(6));if(!n)return null;let o;try{o=JSON.parse(n)}catch{o=n}return{event:e,data:o}}export{w as a,R as b,S as c,P as d,A as e,C as f,$ as g};
|
|
5
|
-
//# sourceMappingURL=chunk-
|
|
5
|
+
//# sourceMappingURL=chunk-ZN5DC6WS.js.map
|
package/dist/cli.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{b as o}from"./chunk-JXF54PT7.js";import"./chunk-QIJLFPWE.js";var s=o(process.versions.node);s&&(console.error(s),process.exit(1));var{buildProgram:r}=await import("./program-
|
|
2
|
+
import{b as o}from"./chunk-JXF54PT7.js";import"./chunk-QIJLFPWE.js";var s=o(process.versions.node);s&&(console.error(s),process.exit(1));var{buildProgram:r}=await import("./program-LAOU5DQ3.js"),{installCliSignalExit:i}=await import("./signal-exit-WL7G3EEZ.js");i();var e=await r();process.argv.slice(2).length===0?e.outputHelp():e.parse();
|
|
3
3
|
//# sourceMappingURL=cli.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a,b,c,d,e,f,g}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=client-
|
|
1
|
+
import{a,b,c,d,e,f,g}from"./chunk-ZN5DC6WS.js";import"./chunk-2BF6HJJD.js";import"./chunk-BRK6M6LA.js";import"./chunk-UIBUZ2N3.js";import"./chunk-2QNT5JDS.js";import"./chunk-QIJLFPWE.js";export{b as fetchAgents,d as fetchCrons,c as fetchProcesses,e as killProcess,a as resolveConn,f as sendTask,g as streamTask};
|
|
2
|
+
//# sourceMappingURL=client-7UW2ELPP.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{ca as a,da as b,ea as c,fa as d,ga as e,ha as f,ia as g,ja as h,ka as i,la as j,ma as k,na as l,oa as m,pa as n,qa as o,ra as p,sa as q,ta as r,ua as s,va as t,xa as u}from"./chunk-2BF6HJJD.js";import"./chunk-BRK6M6LA.js";import"./chunk-UIBUZ2N3.js";import"./chunk-2QNT5JDS.js";import"./chunk-QIJLFPWE.js";u();export{a as INTEGRATION_KINDS,p as WIKI_CONTRIBUTE_JOB,q as WIKI_CONTRIBUTE_MERGE_JOB,s as WIKI_SUMMARIZE_JOB,k as approvalsConfigSchema,e as callsSchema,c as cameraBotSchema,l as daemonConfigSchema,b as eventSubscriptionSchema,m as expandEnvVars,d as isCronExpression,n as loadDaemonConfig,i as membersConfigSchema,h as peopleConfigSchema,g as personSchema,j as requestStatusConfigSchema,f as requestsConfigSchema,o as validateWorkspaces,r as withContributionJobs,t as withSummariesJob};
|
|
2
|
+
//# sourceMappingURL=config-TNYVPT4R.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a,b}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=config-mutate-
|
|
1
|
+
import{a,b}from"./chunk-GUEIF7ZF.js";import"./chunk-2BF6HJJD.js";import"./chunk-BRK6M6LA.js";import"./chunk-UIBUZ2N3.js";import"./chunk-2QNT5JDS.js";import"./chunk-QIJLFPWE.js";export{a as mutateAgentxConfig,b as writeAgentxConfig};
|
|
2
|
+
//# sourceMappingURL=config-mutate-GV7BVG3I.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a,b,c,d,e}from"./chunk-D5IHICX3.js";import"./chunk-2BF6HJJD.js";import"./chunk-BRK6M6LA.js";import"./chunk-UIBUZ2N3.js";import"./chunk-2QNT5JDS.js";import"./chunk-QIJLFPWE.js";export{b as applyConfigMutation,a as findConfigPath,d as getAtPath,c as setAtPath,e as unsetAtPath};
|
|
2
|
+
//# sourceMappingURL=config-mutator-AKCR3VKM.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as ee}from"./chunk-
|
|
1
|
+
import{a as ee}from"./chunk-V4IFJLQS.js";import"./chunk-OQV3LWJI.js";import{f as Q,k as V}from"./chunk-QSKG754X.js";import{c as O}from"./chunk-KA2UIZXG.js";import"./chunk-GQ76J72O.js";import{b as X}from"./chunk-4VVHGR7H.js";import"./chunk-57Y2WZT2.js";import"./chunk-IZDKRNXC.js";import"./chunk-JA5Y4LDP.js";import"./chunk-WPNRDEHW.js";import"./chunk-7VLLZQ3N.js";import"./chunk-BIJHMWXK.js";import"./chunk-ILEC3IAV.js";import"./chunk-F5PVUB4Y.js";import"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-MCI3DIWW.js";import"./chunk-6TURWSMN.js";import{b as N,c as H}from"./chunk-QOYAX2FT.js";import"./chunk-2PJKGZWP.js";import"./chunk-7I7IEX4S.js";import"./chunk-2BF6HJJD.js";import"./chunk-BRK6M6LA.js";import"./chunk-UIBUZ2N3.js";import"./chunk-2QNT5JDS.js";import"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.js";import{createHash as le}from"crypto";import{existsSync as z,mkdirSync as ne,readdirSync as re,readFileSync as ge,renameSync as se,writeFileSync as pe}from"fs";import{resolve as w}from"path";var _={maxPatches:30,maxCostUsd:.5,maxItems:60},he=12,fe=2e3,me=1500,M=8,U=300,be=12,B="## Checked facts";function S(n){return w(n,"_contributions")}function E(n,r){if(!z(n))return r;try{return JSON.parse(ge(n,"utf-8"))}catch(t){throw new Error(`${n} is not valid JSON: ${t.message}`)}}function L(n,r){ne(w(n,".."),{recursive:!0});let t=`${n}.${process.pid}.tmp`;pe(t,`${JSON.stringify(r,null,2)}
|
|
2
2
|
`),se(t,n)}function ie(n){return{agents:E(w(S(n),"state.json"),{agents:{}}).agents??{}}}function ye(n){let r=w(S(n),"pending");return z(r)?re(r).filter(t=>t.endsWith(".json")).sort().map(t=>E(w(r,t),null)).filter(t=>!!t):[]}function G(n){return w(S(n),"held.json")}function K(n,r={}){let t=E(G(n),[]);return r.all?t:t.filter(a=>a.status==="held")}function _e(n){let r=w(S(n),"reports");if(!z(r))return null;let t=re(r).filter(a=>a.endsWith(".json")).sort().pop();return t?E(w(r,t),null):null}function ke(n,r,t,a={}){let o=ie(r).agents[t],c=a.now??Date.now(),e=a.since??o?.lastRunAt??new Date(c-864e5).toISOString(),d=e.slice(0,10),u=new Set(o?.processed??[]),s=[];for(let g of n.getAgentEntries(t))g.date<d||u.has(g.id)||s.push({id:g.id,at:g.date,kind:"chat",title:[g.source,g.sourceContext].filter(Boolean).join(" \xB7 "),text:g.content});if(a.db){let g=Date.parse(e);for(let l of V(a.db,{agentId:t,since:Number.isFinite(g)?g:void 0,limit:500})){if(l.status==="in-flight"||u.has(l.taskId))continue;let k=(Q(a.db,l.taskId)?.steps??[]).filter(b=>b.name==="tool_use"||b.action).slice(0,be).map(b=>`- ${b.action??b.name}${b.inputSummary?` ${x(b.inputSummary,160)}`:""}${b.outputSummary?` \u2192 ${x(b.outputSummary,240)}`:""}${b.error?` \u2717 ${x(b.error,120)}`:""}`),y=[`Request: ${x(l.originalMessage??l.messagePreview??"",600)}`,k.length?`Tool calls:
|
|
3
3
|
${k.join(`
|
|
4
4
|
`)}`:"",l.finalResponse?`Reply: ${x(l.finalResponse,800)}`:""].filter(Boolean).join(`
|
|
@@ -54,4 +54,4 @@ _Sources: ${t.sources.join("; ")}._`,a);return n.writeArticle(r,{title:t.title,.
|
|
|
54
54
|
`).replace(/\n{3,}/g,`
|
|
55
55
|
|
|
56
56
|
`).trim(),superseded:d}}function Ce(n){let r=n.previous?` (previously: ${n.previous})`:"";return`- **${n.attribute}:** ${n.value} \u2014 ${n.source}; checked ${n.checkedAt.slice(0,10)} by ${n.by}${r}`}function Re(n){let r=n.match(/^- \*\*.+?:\*\* (.*?) — .*?; checked (\S+) by \S+(?: \(previously: (.*)\))?$/);return r?{value:r[1],checkedAt:r[2],...r[3]?{previous:r[3]}:{}}:void 0}function J(n,r){return`contribution:${n}@${r.slice(0,10)}`}var Te={person:"people",project:"projects",place:"places",concept:"concepts",event:"events",decision:"decisions",pattern:"patterns"};function de(n,r,t){let a=r.toLowerCase().replace(/[^\p{L}\p{N}]+/gu,"-").replace(/^-+|-+$/g,"").slice(0,60)||"page",o=t?Te[t]:"contributions",c=`${o}/${a}.md`;for(let e=2;n.readArticle(c);e++)c=`${o}/${a}-${e}.md`;return c}export{_ as DEFAULT_CONTRIBUTION_LIMITS,B as FACTS_HEADING,ue as applyFactLines,De as approveHeld,xe as buildContributionPrompt,S as contributionsDir,_e as latestReport,K as listHeld,ye as listPendingBatches,Be as mergeContributions,W as pageKey,Ae as parseContributionPatches,ke as pendingWork,Se as possibleDuplicate,Fe as rejectHeld,ce as replaceOnce,Me as runContribution};
|
|
57
|
-
//# sourceMappingURL=contributions-
|
|
57
|
+
//# sourceMappingURL=contributions-J57B3KIX.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as a,c as b,d as c,e as d,f as e}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=doctor-
|
|
1
|
+
import{b as a,c as b,d as c,e as d,f as e}from"./chunk-3TETB22A.js";import"./chunk-S2GAEH2F.js";import"./chunk-JXF54PT7.js";import"./chunk-2BF6HJJD.js";import"./chunk-BRK6M6LA.js";import"./chunk-UIBUZ2N3.js";import"./chunk-2QNT5JDS.js";import"./chunk-QIJLFPWE.js";export{e as daemonVoiceCheck,b as doctor,a as runDoctorChecks,c as runNotificationChecks,d as runReminderChecks};
|
|
2
|
+
//# sourceMappingURL=doctor-ROKIYJRT.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a,b,c,d,e,f,g,h,i,j}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=failure-candidates-
|
|
1
|
+
import{a,b,c,d,e,f,g,h,i,j}from"./chunk-YXFTUOZR.js";import"./chunk-QSKG754X.js";import"./chunk-FCPTN6NF.js";import"./chunk-QIJLFPWE.js";export{b as DEFAULT_MIN_SESSIONS,a as FAILURE_STAMP_PREFIX,c as MAX_FAILURE_EXAMPLES,d as errorClass,i as failingTool,e as failureSignature,f as failureStamp,j as failuresToCandidates,h as loadFailedTraces,g as sessionOf};
|
|
2
|
+
//# sourceMappingURL=failure-candidates-XZSZP4HT.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{b as h}from"./chunk-GZY5DYXT.js";import"./chunk-RKPAVWXF.js";import{b as I}from"./chunk-LLNPKE7H.js";import"./chunk-SHEUCITK.js";import"./chunk-RJFPCW7T.js";import"./chunk-S2UXDEGW.js";import"./chunk-D5IHICX3.js";import"./chunk-3UOTLMXD.js";import"./chunk-FCPTN6NF.js";import"./chunk-7I7IEX4S.js";import"./chunk-2BF6HJJD.js";import"./chunk-BRK6M6LA.js";import"./chunk-UIBUZ2N3.js";import"./chunk-2QNT5JDS.js";import"./chunk-QIJLFPWE.js";var p=t=>typeof t=="string"?t.trim():"";function $(t){return[`Run ${t.runId} "${t.title}" [${t.status}] on step ${t.step}: waiting on ${t.waitingOn}.`,t.tags?.length?`Tags: ${t.tags.join(", ")}`:"",...(t.steps??[]).slice(-8).map(s=>`- ${String(s.at).slice(0,16).replace("T"," ")} ${s.step} ${s.status}${s.note?`: ${s.note}`:""}`)].filter(Boolean).join(`
|
|
2
|
+
`)}async function T(t,c){let s=c.fetch??fetch,m=c.daemonUrl.replace(/\/$/,""),r=(p(t.action)||"list").toLowerCase(),f=c.env??process.env,w=async i=>{let l=await s(`${m}${i}`,{signal:AbortSignal.timeout(1e4)}),n=await l.json().catch(()=>({}));return{ok:l.ok,status:l.status,data:n}};try{if(r==="list"){let e=await w("/follow-up");if(!e.ok)return`Error: ${e.data?.error||`HTTP ${e.status}`}`;let o=e.data.groups??[];return o.length?o.map(d=>[`${d.tag}:`,...d.rows.map(a=>`- ${a.runId} "${a.title}" on ${a.step}: waiting on ${a.waitingOn} (since ${String(a.since).slice(0,16).replace("T"," ")} UTC)`)].join(`
|
|
3
|
+
`)).join(`
|
|
4
|
+
`):"No follow-up workflows are running."}if(r==="match"){let e=p(t.request)||p(t.title);if(!e)return"Error: match needs `request`: the owner's request in their words.";let o=h(t,f),d=await w(`/follow-up/match?q=${encodeURIComponent(e)}${o?`&agentId=${encodeURIComponent(o.agentId)}`:""}`);if(!d.ok)return`Error: ${d.data?.error||`HTTP ${d.status}`}`;let a=d.data.matches??[];return a.length?["Saved workflows, best fit first (confidence 0-1):",...a.map(u=>`- ${u.workflowId} "${u.title}" (${u.confidence}${u.autoStart?", starts without asking":""}): ${u.steps.map(k=>k.id).join(" \u2192 ")}`),'Start one with {action:"start", workflowId:"<id>", title:"\u2026", tags:["client:<name>"]}. Run its steps through the workflow, not by hand.'].join(`
|
|
5
|
+
`):"No saved workflow fits. If the request has several steps, build one: start with title and steps."}if(r==="status"){let e=p(t.runId);if(!e)return"Error: status needs runId.";let o=await w(`/follow-up/${encodeURIComponent(e)}`);return o.ok?$(o.data.run):`Error: ${o.data?.error||`HTTP ${o.status}`}`}let i=h(t,f);if(!i)return"Error: couldn't tell which agent you are. Pass callerAgentId.";let l=await s(`${m}/follow-up`,{method:"POST",headers:{"Content-Type":"application/json",...I(f)},body:JSON.stringify({action:r,agentId:i.agentId,workflowId:t.workflowId,title:t.title,description:t.description,tags:t.tags,inputs:t.inputs,steps:t.steps,edges:t.edges,approval:t.approval,autoStart:t.autoStart,requestId:t.requestId,runId:t.runId,step:t.step,evidence:t.evidence,note:t.note,reason:t.reason,fromRun:t.fromRun,status:t.status}),signal:AbortSignal.timeout(2e4)}),n=await l.json().catch(()=>({}));if(!l.ok)return`Error: ${n?.error||`HTTP ${l.status}`}`;if(r==="start"){let e=n.run;return[`Started run ${e.runId} "${e.title}"${n.built?" (built from the steps you gave; propose it with fromRun to keep it)":""}.`,n.awaitingApproval?"It waits for the owner's approval before the first step.":`It is on step ${e.step}: ${e.waitingOn}.`,"AgentX follows it from here: it starts each step, reminds whoever is slow, and tells the owner when it ends. Do not run its steps by hand.",...n.warning?[`Note: ${n.warning}`]:[]].join(" ")}return r==="plan"?[`Plan recorded on run ${n.run?.runId??t.runId}:`,...(n.plan??[]).map(e=>`- ${e.id} ${e.title}`),'Report each step with {action:"step", runId, step:"<id>", status:"started"|"done"|"failed"}.'].join(`
|
|
6
|
+
`):r==="step"?`Step recorded. ${n.run?$(n.run):""}`.trim():r==="done"?`Step recorded as done. ${n.run?$(n.run):""}`.trim():r==="blocked"?"The step is marked blocked and the owner is told. Nothing more happens on it until it is sorted.":`Saved ${n.workflowId} switched off, and asked the owner (card ${n.cardId}) whether to keep it as a reusable workflow.`}catch(i){return`Error: couldn't reach the daemon (${i?.message??i}).`}}export{T as runWorkflowTool};
|
|
7
|
+
//# sourceMappingURL=follow-up-tool-S2U7DFSW.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/workflows/follow-up-tool.ts"],"sourcesContent":["import { resolveScheduleCaller } from \"@/crons/schedule-tool\"\nimport { callerHeaders } from \"@/calls/service\"\n\n// --- Agent-facing `agentx_workflow` tool (#788) ---\n//\n// A request with several steps is run as a workflow, not by hand:\n// match saved workflows that fit the request in front of you\n// start start one (workflowId), or build one from the owner's words\n// (title + steps) and run it; tags say what it concerns\n// status one run: the step it is on and what it waits on\n// list every follow-up still going, grouped by tag\n// done the step you own is finished (evidence)\n// blocked your step cannot go on without the owner (reason)\n// propose ask the owner to keep a workflow as a reusable template\n// plan write or change the plan of the run your task is wrapped in\n// step report a step of that plan (started, done, failed)\n// It talks to the daemon's /follow-up endpoints.\n\nexport interface WorkflowToolDeps {\n daemonUrl: string\n fetch?: typeof fetch\n env?: NodeJS.ProcessEnv\n}\n\nconst str = (v: unknown) => (typeof v === \"string\" ? v.trim() : \"\")\n\nfunction describe(run: any): string {\n const lines = [\n `Run ${run.runId} \"${run.title}\" [${run.status}] on step ${run.step}: waiting on ${run.waitingOn}.`,\n run.tags?.length ? `Tags: ${run.tags.join(\", \")}` : \"\",\n ...(run.steps ?? []).slice(-8).map((s: any) => `- ${String(s.at).slice(0, 16).replace(\"T\", \" \")} ${s.step} ${s.status}${s.note ? `: ${s.note}` : \"\"}`),\n ]\n return lines.filter(Boolean).join(\"\\n\")\n}\n\n/** Returns the text the agent sees. Every refusal is text, never a throw. */\nexport async function runWorkflowTool(args: Record<string, unknown>, deps: WorkflowToolDeps): Promise<string> {\n const doFetch = deps.fetch ?? fetch\n const base = deps.daemonUrl.replace(/\\/$/, \"\")\n const action = (str(args.action) || \"list\").toLowerCase()\n const env = deps.env ?? process.env\n const read = async (path: string) => {\n const res = await doFetch(`${base}${path}`, { signal: AbortSignal.timeout(10_000) })\n const data = await res.json().catch(() => ({})) as any\n return { ok: res.ok, status: res.status, data }\n }\n\n try {\n if (action === \"list\") {\n const r = await read(\"/follow-up\")\n if (!r.ok) return `Error: ${r.data?.error || `HTTP ${r.status}`}`\n const groups = r.data.groups ?? []\n if (!groups.length) return \"No follow-up workflows are running.\"\n return groups.map((g: any) => [`${g.tag}:`, ...g.rows.map((row: any) => `- ${row.runId} \"${row.title}\" on ${row.step}: waiting on ${row.waitingOn} (since ${String(row.since).slice(0, 16).replace(\"T\", \" \")} UTC)`)].join(\"\\n\")).join(\"\\n\")\n }\n if (action === \"match\") {\n const q = str(args.request) || str(args.title)\n if (!q) return \"Error: match needs `request`: the owner's request in their words.\"\n const caller = resolveScheduleCaller(args, env)\n const r = await read(`/follow-up/match?q=${encodeURIComponent(q)}${caller ? `&agentId=${encodeURIComponent(caller.agentId)}` : \"\"}`)\n if (!r.ok) return `Error: ${r.data?.error || `HTTP ${r.status}`}`\n const matches = r.data.matches ?? []\n if (!matches.length) return \"No saved workflow fits. If the request has several steps, build one: start with title and steps.\"\n return [\n \"Saved workflows, best fit first (confidence 0-1):\",\n ...matches.map((x: any) => `- ${x.workflowId} \"${x.title}\" (${x.confidence}${x.autoStart ? \", starts without asking\" : \"\"}): ${x.steps.map((s: any) => s.id).join(\" → \")}`),\n `Start one with {action:\"start\", workflowId:\"<id>\", title:\"…\", tags:[\"client:<name>\"]}. Run its steps through the workflow, not by hand.`,\n ].join(\"\\n\")\n }\n if (action === \"status\") {\n const runId = str(args.runId)\n if (!runId) return \"Error: status needs runId.\"\n const r = await read(`/follow-up/${encodeURIComponent(runId)}`)\n if (!r.ok) return `Error: ${r.data?.error || `HTTP ${r.status}`}`\n return describe(r.data.run)\n }\n\n const caller = resolveScheduleCaller(args, env)\n if (!caller) return \"Error: couldn't tell which agent you are. Pass callerAgentId.\"\n const res = await doFetch(`${base}/follow-up`, {\n method: \"POST\",\n // The headers name this run: the daemon refuses a write that does\n // not come from a running turn of the agent.\n headers: { \"Content-Type\": \"application/json\", ...callerHeaders(env) },\n body: JSON.stringify({\n action, agentId: caller.agentId,\n workflowId: args.workflowId, title: args.title, description: args.description, tags: args.tags, inputs: args.inputs,\n steps: args.steps, edges: args.edges, approval: args.approval, autoStart: args.autoStart, requestId: args.requestId,\n runId: args.runId, step: args.step, evidence: args.evidence, note: args.note, reason: args.reason, fromRun: args.fromRun, status: args.status,\n }),\n signal: AbortSignal.timeout(20_000),\n })\n const data = await res.json().catch(() => ({})) as any\n if (!res.ok) return `Error: ${data?.error || `HTTP ${res.status}`}`\n if (action === \"start\") {\n const run = data.run\n return [\n `Started run ${run.runId} \"${run.title}\"${data.built ? \" (built from the steps you gave; propose it with fromRun to keep it)\" : \"\"}.`,\n data.awaitingApproval ? \"It waits for the owner's approval before the first step.\" : `It is on step ${run.step}: ${run.waitingOn}.`,\n \"AgentX follows it from here: it starts each step, reminds whoever is slow, and tells the owner when it ends. Do not run its steps by hand.\",\n ...(data.warning ? [`Note: ${data.warning}`] : []),\n ].join(\" \")\n }\n if (action === \"plan\") {\n return [\n `Plan recorded on run ${data.run?.runId ?? args.runId}:`,\n ...(data.plan ?? []).map((s: any) => `- ${s.id} ${s.title}`),\n `Report each step with {action:\"step\", runId, step:\"<id>\", status:\"started\"|\"done\"|\"failed\"}.`,\n ].join(\"\\n\")\n }\n if (action === \"step\") return `Step recorded. ${data.run ? describe(data.run) : \"\"}`.trim()\n if (action === \"done\") return `Step recorded as done. ${data.run ? describe(data.run) : \"\"}`.trim()\n if (action === \"blocked\") return \"The step is marked blocked and the owner is told. Nothing more happens on it until it is sorted.\"\n return `Saved ${data.workflowId} switched off, and asked the owner (card ${data.cardId}) whether to keep it as a reusable workflow.`\n } catch (e: any) {\n return `Error: couldn't reach the daemon (${e?.message ?? e}).`\n }\n}\n"],"mappings":"4bAwBA,IAAMA,EAAOC,GAAgB,OAAOA,GAAM,SAAWA,EAAE,KAAK,EAAI,GAEhE,SAASC,EAASC,EAAkB,CAMlC,MALc,CACZ,OAAOA,EAAI,UAAUA,EAAI,WAAWA,EAAI,mBAAmBA,EAAI,oBAAoBA,EAAI,aACvFA,EAAI,MAAM,OAAS,SAASA,EAAI,KA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","args","deps","doFetch","base","action","env","read","path","res","data","r","groups","g","row","q","caller","resolveScheduleCaller","matches","x","s","runId","callerHeaders","e"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=hub-
|
|
1
|
+
import{a}from"./chunk-HIUHKOKK.js";import"./chunk-RTHZQGFC.js";import"./chunk-JP5OAMWQ.js";import"./chunk-4VVHGR7H.js";import"./chunk-JA5Y4LDP.js";import"./chunk-WPNRDEHW.js";import"./chunk-F5PVUB4Y.js";import"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-MCI3DIWW.js";import"./chunk-QOYAX2FT.js";import"./chunk-2PJKGZWP.js";import"./chunk-7I7IEX4S.js";import"./chunk-2BF6HJJD.js";import"./chunk-BRK6M6LA.js";import"./chunk-UIBUZ2N3.js";import"./chunk-2QNT5JDS.js";import"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.js";export{a as WikiHub};
|
|
2
|
+
//# sourceMappingURL=hub-HOVJC4HR.js.map
|