agentix-cli 0.48.0 → 0.50.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 +17 -0
- package/apps/mac-voice/Sources/AgentXVoice/AgentClient.swift +17 -5
- package/apps/mac-voice/Sources/AgentXVoice/Config.swift +6 -1
- package/apps/mac-voice/Sources/AgentXVoice/main.swift +5 -2
- package/dist/{App-EXB4HP3B.js → App-KE4SURSS.js} +2 -2
- package/dist/{ChatApp-XMNE3SPH.js → ChatApp-NNHIKXO2.js} +2 -2
- package/dist/{agent-ORYXXL5K.js → agent-RY7Z3IYY.js} +2 -2
- package/dist/{board-dashboard-2B3HYIXD.js → board-dashboard-RUOASCSQ.js} +6 -6
- package/dist/board-dashboard-RUOASCSQ.js.map +1 -0
- package/dist/{chunk-DLKRPK5M.js → chunk-4BNQSUWV.js} +7 -2
- package/dist/{chunk-DLKRPK5M.js.map → chunk-4BNQSUWV.js.map} +1 -1
- package/dist/{chunk-26OP3X5B.js → chunk-4NBWF4TL.js} +2 -2
- package/dist/{chunk-P7MR53U7.js → chunk-4TITGMPX.js} +2 -2
- package/dist/{chunk-XM7ZQW4F.js → chunk-5ALS7SVV.js} +2 -2
- package/dist/{chunk-3ZHMIWSV.js → chunk-5XQCGPQJ.js} +2 -2
- package/dist/{chunk-DVNIFP7S.js → chunk-6VKCUMCN.js} +2 -2
- package/dist/{chunk-GCHUE3TN.js → chunk-7WDJW37G.js} +2 -2
- package/dist/{chunk-FRHSQVFN.js → chunk-AQASR6KR.js} +3 -3
- package/dist/chunk-AQASR6KR.js.map +1 -0
- package/dist/{chunk-M5R3PWW5.js → chunk-B5XHX44Y.js} +2 -2
- package/dist/{chunk-4ZX4E7P3.js → chunk-BYD55JXH.js} +8 -8
- package/dist/chunk-BYD55JXH.js.map +1 -0
- package/dist/{chunk-DIV66W3N.js → chunk-EMI3VJLH.js} +10 -10
- package/dist/chunk-EMI3VJLH.js.map +1 -0
- package/dist/chunk-HRBKSZ34.js +2 -0
- package/dist/chunk-HRBKSZ34.js.map +1 -0
- package/dist/{chunk-MLLEOFX2.js → chunk-IXUEJBHD.js} +2 -2
- package/dist/{chunk-LDILAHMN.js → chunk-JVNFRS26.js} +2 -2
- package/dist/{chunk-GIK7S3OY.js → chunk-N2XXKFJ6.js} +7 -7
- package/dist/chunk-N2XXKFJ6.js.map +1 -0
- package/dist/{chunk-DJQA2CWD.js → chunk-N6EWZGIX.js} +6 -6
- package/dist/{chunk-DJQA2CWD.js.map → chunk-N6EWZGIX.js.map} +1 -1
- package/dist/{chunk-HEQPHUTR.js → chunk-NLZD2QKF.js} +2 -2
- package/dist/chunk-OHA3J5ZV.js +243 -0
- package/dist/chunk-OHA3J5ZV.js.map +1 -0
- package/dist/{chunk-P5JXQRBH.js → chunk-OTW5MPFT.js} +2 -2
- package/dist/{chunk-WMI5B36E.js → chunk-OUZ7YVQZ.js} +2 -2
- package/dist/{chunk-GAGVFSZM.js → chunk-P2ZYT5D6.js} +2 -2
- package/dist/chunk-P2ZYT5D6.js.map +1 -0
- package/dist/{chunk-2WPTP5HO.js → chunk-PZCTCCC5.js} +2 -2
- package/dist/chunk-Q7C3X3R6.js +61 -0
- package/dist/chunk-Q7C3X3R6.js.map +1 -0
- package/dist/{chunk-3WLO2UKI.js → chunk-QDE75R4U.js} +2 -2
- package/dist/{chunk-ZUZESPCH.js → chunk-TTL37CS5.js} +64 -64
- package/dist/chunk-TTL37CS5.js.map +1 -0
- package/dist/{chunk-2GSEEKQK.js → chunk-TUNQFPVA.js} +2 -2
- package/dist/{chunk-SL657MIM.js → chunk-WQLBJ2O5.js} +2 -2
- package/dist/{chunk-OZX7HVHC.js → chunk-Y6I3BYWV.js} +172 -165
- package/dist/chunk-Y6I3BYWV.js.map +1 -0
- package/dist/{chunk-SFLF64Q3.js → chunk-Z3IP66SL.js} +2 -2
- package/dist/cli.js +1 -1
- package/dist/client-JZTH46N2.js +2 -0
- package/dist/{compaction-U5SAYTX6.js → compaction-PIZINFHR.js} +2 -2
- package/dist/{config-ROQ4VEU3.js → config-R47ITLIY.js} +2 -2
- package/dist/config-mutator-T6JGXJ26.js +2 -0
- package/dist/context-planner-FJMU5WAT.js +17 -0
- package/dist/context-planner-FJMU5WAT.js.map +1 -0
- package/dist/doctor-2DMGAWMW.js +2 -0
- package/dist/failure-candidates-ARRMFXRY.js +8 -0
- package/dist/failure-candidates-ARRMFXRY.js.map +1 -0
- package/dist/index.d.ts +15 -1
- package/dist/index.js +1 -1
- package/dist/memory-extract-OWTI6MN5.js +2 -0
- package/dist/processes-KUJJ7XE7.js +2 -0
- package/dist/program-KY5ZYPFN.js +2 -0
- package/dist/promote-57YNOVXV.js +2 -0
- package/dist/proposals-TX2HBBYV.js +2 -0
- package/dist/query-ZT7WXY2F.js +2 -0
- package/dist/registry-LLAFJJN4.js +2 -0
- package/dist/{request-planner-FAFNFVFX.js → request-planner-PEAYYXAP.js} +2 -2
- package/dist/{review-candidates-2XKJ2R6U.js → review-candidates-W7NIHNAI.js} +2 -2
- package/dist/{routing-PUPVGJ77.js → routing-7LCO7UJ7.js} +2 -2
- package/dist/schedule-tool-ZD3VBUBW.js +2 -0
- package/dist/scheduler-GC3FQKXY.js +2 -0
- package/dist/{seat-2MW3DEXX.js → seat-HR6QMAR2.js} +2 -2
- package/dist/{select-Q3AGLQQX.js → select-4XYRIZ5L.js} +2 -2
- package/dist/{surface-usage-FM2ZHGYE.js → surface-usage-V2BX4SBD.js} +2 -2
- package/dist/{tool-IVUNSAXY.js → tool-PAQ47HV2.js} +2 -2
- package/dist/wiki-EREMPSAE.js +2 -0
- package/package.json +1 -1
- package/dist/board-dashboard-2B3HYIXD.js.map +0 -1
- package/dist/chunk-4ZX4E7P3.js.map +0 -1
- package/dist/chunk-7DXE264B.js +0 -2
- package/dist/chunk-7DXE264B.js.map +0 -1
- package/dist/chunk-DIV66W3N.js.map +0 -1
- package/dist/chunk-FRHSQVFN.js.map +0 -1
- package/dist/chunk-GAGVFSZM.js.map +0 -1
- package/dist/chunk-GIK7S3OY.js.map +0 -1
- package/dist/chunk-OZX7HVHC.js.map +0 -1
- package/dist/chunk-RYLTCOYE.js +0 -241
- package/dist/chunk-RYLTCOYE.js.map +0 -1
- package/dist/chunk-WZGABQ72.js +0 -59
- package/dist/chunk-WZGABQ72.js.map +0 -1
- package/dist/chunk-ZUZESPCH.js.map +0 -1
- package/dist/client-6HCY7UMW.js +0 -2
- package/dist/config-mutator-ML4BAOFT.js +0 -2
- package/dist/context-planner-AQHJMVY2.js +0 -17
- package/dist/context-planner-AQHJMVY2.js.map +0 -1
- package/dist/doctor-3HWGAPET.js +0 -2
- package/dist/memory-extract-YZI2QZVR.js +0 -2
- package/dist/processes-XWRGOLMT.js +0 -2
- package/dist/program-JLZOHWIU.js +0 -2
- package/dist/promote-YGNTKEXI.js +0 -2
- package/dist/proposals-MWMEXRDW.js +0 -2
- package/dist/query-V76JDSOC.js +0 -2
- package/dist/registry-DKN4HEI3.js +0 -2
- package/dist/schedule-tool-6J7AHAHH.js +0 -2
- package/dist/scheduler-ZHQBSSRH.js +0 -2
- package/dist/wiki-FPX2YBKS.js +0 -2
- /package/dist/{App-EXB4HP3B.js.map → App-KE4SURSS.js.map} +0 -0
- /package/dist/{ChatApp-XMNE3SPH.js.map → ChatApp-NNHIKXO2.js.map} +0 -0
- /package/dist/{agent-ORYXXL5K.js.map → agent-RY7Z3IYY.js.map} +0 -0
- /package/dist/{chunk-26OP3X5B.js.map → chunk-4NBWF4TL.js.map} +0 -0
- /package/dist/{chunk-P7MR53U7.js.map → chunk-4TITGMPX.js.map} +0 -0
- /package/dist/{chunk-XM7ZQW4F.js.map → chunk-5ALS7SVV.js.map} +0 -0
- /package/dist/{chunk-3ZHMIWSV.js.map → chunk-5XQCGPQJ.js.map} +0 -0
- /package/dist/{chunk-DVNIFP7S.js.map → chunk-6VKCUMCN.js.map} +0 -0
- /package/dist/{chunk-GCHUE3TN.js.map → chunk-7WDJW37G.js.map} +0 -0
- /package/dist/{chunk-M5R3PWW5.js.map → chunk-B5XHX44Y.js.map} +0 -0
- /package/dist/{chunk-MLLEOFX2.js.map → chunk-IXUEJBHD.js.map} +0 -0
- /package/dist/{chunk-LDILAHMN.js.map → chunk-JVNFRS26.js.map} +0 -0
- /package/dist/{chunk-HEQPHUTR.js.map → chunk-NLZD2QKF.js.map} +0 -0
- /package/dist/{chunk-P5JXQRBH.js.map → chunk-OTW5MPFT.js.map} +0 -0
- /package/dist/{chunk-WMI5B36E.js.map → chunk-OUZ7YVQZ.js.map} +0 -0
- /package/dist/{chunk-2WPTP5HO.js.map → chunk-PZCTCCC5.js.map} +0 -0
- /package/dist/{chunk-3WLO2UKI.js.map → chunk-QDE75R4U.js.map} +0 -0
- /package/dist/{chunk-2GSEEKQK.js.map → chunk-TUNQFPVA.js.map} +0 -0
- /package/dist/{chunk-SL657MIM.js.map → chunk-WQLBJ2O5.js.map} +0 -0
- /package/dist/{chunk-SFLF64Q3.js.map → chunk-Z3IP66SL.js.map} +0 -0
- /package/dist/{client-6HCY7UMW.js.map → client-JZTH46N2.js.map} +0 -0
- /package/dist/{compaction-U5SAYTX6.js.map → compaction-PIZINFHR.js.map} +0 -0
- /package/dist/{config-ROQ4VEU3.js.map → config-R47ITLIY.js.map} +0 -0
- /package/dist/{config-mutator-ML4BAOFT.js.map → config-mutator-T6JGXJ26.js.map} +0 -0
- /package/dist/{doctor-3HWGAPET.js.map → doctor-2DMGAWMW.js.map} +0 -0
- /package/dist/{memory-extract-YZI2QZVR.js.map → memory-extract-OWTI6MN5.js.map} +0 -0
- /package/dist/{processes-XWRGOLMT.js.map → processes-KUJJ7XE7.js.map} +0 -0
- /package/dist/{program-JLZOHWIU.js.map → program-KY5ZYPFN.js.map} +0 -0
- /package/dist/{promote-YGNTKEXI.js.map → promote-57YNOVXV.js.map} +0 -0
- /package/dist/{proposals-MWMEXRDW.js.map → proposals-TX2HBBYV.js.map} +0 -0
- /package/dist/{query-V76JDSOC.js.map → query-ZT7WXY2F.js.map} +0 -0
- /package/dist/{registry-DKN4HEI3.js.map → registry-LLAFJJN4.js.map} +0 -0
- /package/dist/{request-planner-FAFNFVFX.js.map → request-planner-PEAYYXAP.js.map} +0 -0
- /package/dist/{review-candidates-2XKJ2R6U.js.map → review-candidates-W7NIHNAI.js.map} +0 -0
- /package/dist/{routing-PUPVGJ77.js.map → routing-7LCO7UJ7.js.map} +0 -0
- /package/dist/{schedule-tool-6J7AHAHH.js.map → schedule-tool-ZD3VBUBW.js.map} +0 -0
- /package/dist/{scheduler-ZHQBSSRH.js.map → scheduler-GC3FQKXY.js.map} +0 -0
- /package/dist/{seat-2MW3DEXX.js.map → seat-HR6QMAR2.js.map} +0 -0
- /package/dist/{select-Q3AGLQQX.js.map → select-4XYRIZ5L.js.map} +0 -0
- /package/dist/{surface-usage-FM2ZHGYE.js.map → surface-usage-V2BX4SBD.js.map} +0 -0
- /package/dist/{tool-IVUNSAXY.js.map → tool-PAQ47HV2.js.map} +0 -0
- /package/dist/{wiki-FPX2YBKS.js.map → wiki-EREMPSAE.js.map} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as o}from"./chunk-
|
|
1
|
+
import{a as o}from"./chunk-N6EWZGIX.js";import{existsSync as s}from"fs";import{resolve as a}from"path";function u(){return!!(process.env.VITEST||process.env.NODE_ENV==="test"||process.env.AGENTX_NO_TELEMETRY)}function c(){let n=process.cwd();for(let t=0;t<5;t++){if(s(a(n,".agentx"))||s(a(n,"agentx.json")))return n;let e=a(n,"..");if(e===n)break;n=e}return null}function d(n=new Date){return n.toISOString().slice(0,10)}function m(n,t,e=new Date){try{if(!t||u()||!c())return;let r=o({quiet:!0});if(!r)return;r.prepare(`INSERT INTO surface_usage (kind, name, day, count, last_at)
|
|
2
2
|
VALUES (?, ?, ?, 1, ?)
|
|
3
3
|
ON CONFLICT(kind, name, day)
|
|
4
4
|
DO UPDATE SET count = count + 1, last_at = excluded.last_at`).run(n,t,d(e),e.toISOString())}catch{}}function g(n={}){try{let t=o({quiet:!0});if(!t)return[];let e=new Date(Date.now()-(n.sinceDays??30)*864e5).toISOString().slice(0,10),r=["day >= ?"],i=[e];return n.kind&&(r.push("kind = ?"),i.push(n.kind)),t.prepare(`SELECT kind, name, SUM(count) AS count, COUNT(DISTINCT day) AS days, MAX(last_at) AS last_at
|
|
@@ -6,4 +6,4 @@ import{a as o}from"./chunk-DJQA2CWD.js";import{existsSync as s}from"fs";import{r
|
|
|
6
6
|
WHERE ${r.join(" AND ")}
|
|
7
7
|
GROUP BY kind, name
|
|
8
8
|
ORDER BY count DESC`).all(...i)}catch{return[]}}function E(n){let t=[],e=n;for(;e&&typeof e.name=="function";){let r=e.name();e.parent&&t.unshift(r),e=e.parent}return t.join(" ")}var f=new Set(["guard check","completion","serve"]);function T(n){return!!n&&!f.has(n)}export{m as a,g as b,E as c,T as d};
|
|
9
|
-
//# sourceMappingURL=chunk-
|
|
9
|
+
//# sourceMappingURL=chunk-Z3IP66SL.js.map
|
package/dist/cli.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as n}from"./chunk-
|
|
2
|
+
import{a as n}from"./chunk-Y6I3BYWV.js";import"./chunk-OUZ7YVQZ.js";import"./chunk-TUNQFPVA.js";import"./chunk-Z3IP66SL.js";import"./chunk-4BNQSUWV.js";import"./chunk-OTW5MPFT.js";import"./chunk-RKPAVWXF.js";import"./chunk-GV7S5BAX.js";import"./chunk-GSX4NK2N.js";import"./chunk-SZDACK6O.js";import"./chunk-BYD55JXH.js";import"./chunk-EMI3VJLH.js";import"./chunk-PZCTCCC5.js";import"./chunk-LQRBGQIR.js";import"./chunk-ZVP6GB4G.js";import"./chunk-FULEQYM6.js";import"./chunk-OHA3J5ZV.js";import"./chunk-3SCPRYJB.js";import"./chunk-AQASR6KR.js";import"./chunk-L53FTKEP.js";import"./chunk-TTL37CS5.js";import"./chunk-N2XXKFJ6.js";import"./chunk-N6EWZGIX.js";import"./chunk-Q7C3X3R6.js";import"./chunk-DP7RTNDM.js";import"./chunk-WQLBJ2O5.js";import"./chunk-SFQUP3BP.js";import"./chunk-5XQCGPQJ.js";import"./chunk-B5XHX44Y.js";import"./chunk-WPMX3VGI.js";import"./chunk-K33GIBSE.js";import"./chunk-76Z4VHDX.js";import"./chunk-W4YR2RO2.js";import"./chunk-AFRHKA7B.js";import"./chunk-NLZD2QKF.js";import"./chunk-5ALS7SVV.js";import"./chunk-DWADWDMU.js";import"./chunk-6VKCUMCN.js";import"./chunk-HRBKSZ34.js";import"./chunk-VWTBHLMX.js";import"./chunk-IXUEJBHD.js";import"./chunk-JVNFRS26.js";import"./chunk-PNWNVOEZ.js";import"./chunk-64P4QHSZ.js";import"./chunk-QDE75R4U.js";import"./chunk-AJ5RMU7X.js";import"./chunk-2GIDVZ4H.js";import"./chunk-4NBWF4TL.js";import"./chunk-F4HZTZHW.js";import"./chunk-AJONZWLT.js";import"./chunk-ZTEU5JVQ.js";import"./chunk-QOYAX2FT.js";import"./chunk-LCIREYTD.js";import"./chunk-L2WSPY6S.js";import"./chunk-VDMYBPYB.js";import"./chunk-DSYKYZMT.js";import"./chunk-P2ZYT5D6.js";import"./chunk-BH3GTCZ6.js";import"./chunk-FIOB3MEX.js";var r=["SIGINT","SIGTERM"];function o(t=process){for(let i of r)t.on(i,()=>{t.listenerCount(i)<=1&&t.exit(0)})}o();async function s(){let t=await n();if(process.argv.slice(2).length===0){t.outputHelp();return}t.parse()}s();
|
|
3
3
|
//# sourceMappingURL=cli.js.map
|
|
@@ -17,7 +17,7 @@ Format as a structured summary:
|
|
|
17
17
|
Keep it under 500 words. Prioritize actionable information over conversational flow.
|
|
18
18
|
Do NOT include greetings, acknowledgments, or meta-commentary about the conversation.`;function G(t){return t.length<F?!1:t.reduce((n,e)=>n+e.content.length,0)>A}async function J(t,o,n,e){if(t.length<F)return{summary:"",compactedCount:0,keptCount:t.length,memoryFlushed:!1};let r=Math.max(0,t.length-K),s=t.slice(0,r),c=t.slice(r);if(s.length===0)return{summary:"",compactedCount:0,keptCount:c.length,memoryFlushed:!1};let a=d(s);M(o,a);let m=!1;if(n)try{await $(o,s,n,e),m=!0}catch{}let u=j(s),l=await z(u),{qualityScore:i,lostEntities:g}=B(u,l),p,x=[{role:"agent",content:l,timestamp:new Date().toISOString()}],D=d(x),h=v(o);return h&&(p=S(h,D)),{summary:l,compactedCount:s.length,keptCount:c.length,memoryFlushed:m,qualityScore:i,lostEntities:g.length>0?g:void 0,drift:p&&p.overallScore>.1?p:void 0}}function B(t,o){let n=_(t);if(n.length===0)return{qualityScore:100,lostEntities:[]};let e=o.toLowerCase(),r=[],s=[];for(let a of n)e.includes(a.toLowerCase())?r.push(a):s.push(a);return{qualityScore:Math.round(r.length/n.length*100),lostEntities:s}}function _(t){let o=[],n=new Set,e=i=>{let g=i.toLowerCase().trim();g.length<3||n.has(g)||(n.add(g),o.push(i.trim()))},r=t.match(/https?:\/\/[^\s<>)"]+/g)||[];for(let i of r)e(i.slice(0,80));let s=t.match(/(?:\/[\w.-]+){2,}/g)||[];for(let i of s)e(i);let c=t.match(/[#!]\d{2,}/g)||[];for(let i of c)e(i);let a=t.match(/[\w.-]+@[\w.-]+\.\w+/g)||[];for(let i of a)e(i);let m=t.match(/"([^"]{3,40})"/g)||[];for(let i of m)e(i.slice(1,-1));let u=t.match(/[A-Z][a-z]+(?:\s+[A-Z][a-z]+)+/g)||[];for(let i of u)e(i);let l=t.match(/[a-f0-9]{8,}/gi)||[];for(let i of l.slice(0,5))e(i);return o.slice(0,30)}function W(t,o){if(o.compactedCount===0)return t;let n=t.slice(-o.keptCount);return[{role:"agent",name:"system",content:`[Compacted conversation summary \u2014 ${o.compactedCount} earlier messages]
|
|
19
19
|
|
|
20
|
-
${o.summary}`,timestamp:new Date().toISOString()},...n]}async function $(t,o,n,e){let r=[],s=[];for(let a of o)a.role==="user"?r.push(`${a.name||"User"}: ${a.content}`):s.push(a.content);if(r.length===0||s.length===0)return;let{extractMemories:c}=await import("./memory-extract-
|
|
20
|
+
${o.summary}`,timestamp:new Date().toISOString()},...n]}async function $(t,o,n,e){let r=[],s=[];for(let a of o)a.role==="user"?r.push(`${a.name||"User"}: ${a.content}`):s.push(a.content);if(r.length===0||s.length===0)return;let{extractMemories:c}=await import("./memory-extract-OWTI6MN5.js");await c(t,r.join(`
|
|
21
21
|
`),s.join(`
|
|
22
22
|
`),{channel:e?.channel??"compaction",chatId:e?.chatId??"flush",sender:"compaction"},n)}function j(t){return t.map(o=>{let n=o.timestamp.slice(11,16),e=o.role==="user"?o.name||"User":o.name||"Agent";return`[${n}] ${e}: ${o.content}`}).join(`
|
|
23
23
|
|
|
@@ -25,4 +25,4 @@ ${o.summary}`,timestamp:new Date().toISOString()},...n]}async function $(t,o,n,e
|
|
|
25
25
|
`).slice(-20);return`[Summary unavailable \u2014 keeping last ${s.length} lines]
|
|
26
26
|
${s.join(`
|
|
27
27
|
`)}`}}export{W as applyCompaction,J as compactSession,G as needsCompaction};
|
|
28
|
-
//# sourceMappingURL=compaction-
|
|
28
|
+
//# sourceMappingURL=compaction-PIZINFHR.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{i as a,j as b,k as c,l as d,m as e,n as f,p as g}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=config-
|
|
1
|
+
import{i as a,j as b,k as c,l as d,m as e,n as f,p as g}from"./chunk-P2ZYT5D6.js";import"./chunk-FIOB3MEX.js";g();export{a as INTEGRATION_KINDS,b as approvalsConfigSchema,c as daemonConfigSchema,d as expandEnvVars,e as loadDaemonConfig,f as validateWorkspaces};
|
|
2
|
+
//# sourceMappingURL=config-R47ITLIY.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import{a as y,b as C}from"./chunk-AJONZWLT.js";import"./chunk-FIOB3MEX.js";C();var I="claude-haiku-4-5-20251001",M=`You are a context planner for an AI agent. Given the user's current message and recent conversation tail, decide what historical context the agent needs.
|
|
2
|
+
|
|
3
|
+
Output ONE JSON object on one line, no prose, no fences:
|
|
4
|
+
{ "recentTurns": number, "memory": { "include": boolean, "query": string }, "crossChat": boolean, "reasoning": string }
|
|
5
|
+
|
|
6
|
+
Rules:
|
|
7
|
+
- "recentTurns" in [0,6]. Short acknowledgments ("ok", "yes", "do it", "continue") need 2-3 turns to know what they refer to. New topics need 0. Technical follow-ups need 3-5.
|
|
8
|
+
- "memory.include" = true only when the message likely references a person, past event, decision, or project the agent should recall. "memory.query" = 3-8 words distilling what to search for (leave "" when include=false).
|
|
9
|
+
- "crossChat" = true only when the message references another chat ("DM", "the group", "earlier conversation", a peer agent's name). Most messages = false.
|
|
10
|
+
- "reasoning" = one short phrase explaining the plan.
|
|
11
|
+
|
|
12
|
+
Be conservative \u2014 unneeded context costs tokens. When in doubt, exclude.`;async function P(e){let c=Date.now(),i=e.timeoutMs??8e3,r=T(e.sessions,e.agentId,e.channel,e.chatId,4),o=[`Agent: ${e.agentId}`,`Channel: ${e.channel}`,r?`Recent conversation:
|
|
13
|
+
${r}`:"Recent conversation: (none \u2014 first message)","",`Current message: ${e.message.slice(0,1500)}`].join(`
|
|
14
|
+
`),n;try{let{createProvider:m}=await import("./providers-KO2DODIO.js"),b=m("claude"),p=new AbortController,x=setTimeout(()=>p.abort(),i);try{let S=await b.generate([{role:"system",content:M},{role:"user",content:o}],{model:I,maxTokens:256});n=y(S.content)}finally{clearTimeout(x)}}catch(m){return process.env.AGENTX_PLANNER_DEBUG&&console.error(`[planner] error: ${m?.message??m}`),null}if(!n||typeof n!="object")return null;let l=v(n.recentTurns,0,6,3),t=!!n.memory?.include,s=typeof n.memory?.query=="string"?n.memory.query:"",a=!!n.crossChat,g=typeof n.reasoning=="string"?n.reasoning:void 0,f=w(e.sessions,e.agentId,e.channel,e.chatId,l),u="",h=[];if(t&&s)try{let m=e.memoryStore.findRelevant(s,e.agentId,5);u=e.memoryStore.buildContext(m),h=e.memoryStore.contextFacts(m)}catch{}let d="";return a&&(d=e.sessions.getCrossSessionSummary(e.agentId,e.channel,e.chatId,"")),{sessionHistory:f,memoryContext:u,memoryFacts:h,crossChatContext:d,debug:{recentTurns:l,memoryIncluded:t,memoryQuery:s||void 0,crossChatIncluded:a,reasoning:g,planLatencyMs:Date.now()-c}}}function w(e,c,i,r,o){if(o<=0)return"";let n=e.getSession(c,i,r);if(n.messages.length===0)return"";let l=Math.min(n.messages.length,o*2),t=n.messages.slice(-l),s=[`[Recent exchange \u2014 last ${t.length} messages]`];for(let a of t){let g=a.name||(a.role==="user"?"User":"Agent");s.push(`${g}: ${a.content}`)}return s.push("[End recent exchange \u2014 respond to the latest message above]"),s.push(""),s.join(`
|
|
15
|
+
`)}function T(e,c,i,r,o){let n=e.getSession(c,i,r);return n.messages.length===0?"":n.messages.slice(-o).map(t=>{let s=t.name||(t.role==="user"?"User":"Agent"),a=t.content.length>200?t.content.slice(0,200)+"\u2026":t.content;return` ${s}: ${a}`}).join(`
|
|
16
|
+
`)}function v(e,c,i,r){let o=typeof e=="number"?Math.floor(e):Number.parseInt(String(e??""),10);return Number.isFinite(o)?Math.min(i,Math.max(c,o)):r}export{P as planContext};
|
|
17
|
+
//# sourceMappingURL=context-planner-FJMU5WAT.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/agents/context-planner.ts"],"sourcesContent":["// --- Context Planner ---\n//\n// A Haiku pre-call that decides what context to retrieve for the current\n// message, replacing the blind \"stack every layer\" approach of the layered\n// strategy. Drops --resume bloat by avoiding the full session history blob\n// on every turn; instead pulls only the specific facts / memory / cross-chat\n// the current message actually needs.\n//\n// Always-on core (handled by registry, not the planner): channel, scope,\n// landscape, identity, intent, and a small `recentTurns`-sized tail of the\n// session verbatim. The planner decides: how many tail turns to keep, and\n// whether to pull memory or cross-chat on top.\n//\n// Fail-open: any planner error returns null and the registry falls back to\n// the layered strategy. This keeps the feature safe to enable even when\n// the planner model is misbehaving.\n//\n// Cost model: one small Haiku call per message (~300 input / ~80 output\n// tokens, ~$0.0005). Win threshold is when it avoids shipping ≥5K tokens\n// of layered history/memory the agent didn't need — typical for short\n// \"ok / yes / do it\" messages where the layered path still dumps the\n// whole 12K-char session blob.\n\nimport type { SessionStore, SessionMessage } from \"./sessions\"\nimport { extractJson } from \"@/utils/extract-json\"\nimport type { MemoryFact, MemoryStore } from \"./memory-store\"\n\n/** Planner output. When `null`, the caller falls back to the layered\n * strategy. Otherwise each field overrides the corresponding context\n * layer — an empty string means \"skip this layer entirely\". */\nexport interface ContextPlan {\n /** Rendered session history (same shape buildHistoryContext returns),\n * truncated to the last N turns the planner picked. */\n sessionHistory: string\n /** Rendered memory context, or \"\" when the planner decided memory\n * isn't relevant to this message. */\n memoryContext: string\n /** The memory facts rendered into memoryContext. */\n memoryFacts: MemoryFact[]\n /** Rendered cross-chat summary, or \"\" when not needed. */\n crossChatContext: string\n /** Debug metadata — surfaced in logs + bench output so operators can\n * see what the planner chose. Not sent to the main agent. */\n debug: {\n recentTurns: number\n memoryIncluded: boolean\n memoryQuery?: string\n crossChatIncluded: boolean\n reasoning?: string\n planLatencyMs: number\n }\n}\n\nexport interface PlanContextInput {\n agentId: string\n channel: string\n chatId: string\n message: string\n sessions: SessionStore\n memoryStore: MemoryStore\n /** Caller-controlled timeout for the Haiku planner call. Defaults to\n * 8s — the planner is in the critical path before the main agent\n * runs, so we can't afford a long timeout. Fail-open if exceeded. */\n timeoutMs?: number\n}\n\nconst PLANNER_MODEL = \"claude-haiku-4-5-20251001\"\nconst PLANNER_PROMPT = `You are a context planner for an AI agent. Given the user's current message and recent conversation tail, decide what historical context the agent needs.\n\nOutput ONE JSON object on one line, no prose, no fences:\n { \"recentTurns\": number, \"memory\": { \"include\": boolean, \"query\": string }, \"crossChat\": boolean, \"reasoning\": string }\n\nRules:\n- \"recentTurns\" in [0,6]. Short acknowledgments (\"ok\", \"yes\", \"do it\", \"continue\") need 2-3 turns to know what they refer to. New topics need 0. Technical follow-ups need 3-5.\n- \"memory.include\" = true only when the message likely references a person, past event, decision, or project the agent should recall. \"memory.query\" = 3-8 words distilling what to search for (leave \"\" when include=false).\n- \"crossChat\" = true only when the message references another chat (\"DM\", \"the group\", \"earlier conversation\", a peer agent's name). Most messages = false.\n- \"reasoning\" = one short phrase explaining the plan.\n\nBe conservative — unneeded context costs tokens. When in doubt, exclude.`\n\nexport async function planContext(input: PlanContextInput): Promise<ContextPlan | null> {\n const start = Date.now()\n const timeoutMs = input.timeoutMs ?? 8_000\n\n // Snapshot the session tail for the planner prompt. Don't send the\n // whole session — the planner only needs enough to judge whether the\n // message is a follow-up, and we pay tokens for every line we ship.\n const recentTail = sessionTail(input.sessions, input.agentId, input.channel, input.chatId, 4)\n\n const userPrompt = [\n `Agent: ${input.agentId}`,\n `Channel: ${input.channel}`,\n recentTail ? `Recent conversation:\\n${recentTail}` : \"Recent conversation: (none — first message)\",\n ``,\n `Current message: ${input.message.slice(0, 1500)}`,\n ].join(\"\\n\")\n\n // Use the Anthropic SDK path — warm HTTP client, no subprocess cold-start.\n // resolveToken now recognizes CLAUDE_CODE_OAUTH_TOKEN so this works out\n // of the box for any operator who already has Claude CLI auth set up.\n // Planner timeout is tight (8s default) because plan latency is in the\n // critical path before the main agent runs.\n let planJson: any\n try {\n const { createProvider } = await import(\"@/agent/providers\")\n const provider = createProvider(\"claude\")\n const ac = new AbortController()\n const timer = setTimeout(() => ac.abort(), timeoutMs)\n try {\n const result = await provider.generate(\n [\n { role: \"system\", content: PLANNER_PROMPT },\n { role: \"user\", content: userPrompt },\n ],\n { model: PLANNER_MODEL, maxTokens: 256 },\n )\n planJson = extractJson(result.content)\n } finally {\n clearTimeout(timer)\n }\n } catch (err: any) {\n // Temporary: surface planner errors for debugging. Will silence once\n // we're confident the SDK path is stable.\n if (process.env.AGENTX_PLANNER_DEBUG) {\n // eslint-disable-next-line no-console\n console.error(`[planner] error: ${err?.message ?? err}`)\n }\n return null\n }\n\n if (!planJson || typeof planJson !== \"object\") return null\n\n const recentTurns = clampInt(planJson.recentTurns, 0, 6, 3)\n const memoryInclude = Boolean(planJson.memory?.include)\n const memoryQuery: string = typeof planJson.memory?.query === \"string\" ? planJson.memory.query : \"\"\n const crossChatInclude = Boolean(planJson.crossChat)\n const reasoning = typeof planJson.reasoning === \"string\" ? planJson.reasoning : undefined\n\n // Resolve the plan into actual retrieval strings.\n const sessionHistory = renderSessionTail(\n input.sessions,\n input.agentId,\n input.channel,\n input.chatId,\n recentTurns,\n )\n\n let memoryContext = \"\"\n let memoryFacts: MemoryFact[] = []\n if (memoryInclude && memoryQuery) {\n try {\n const relevant = input.memoryStore.findRelevant(memoryQuery, input.agentId, 5)\n memoryContext = input.memoryStore.buildContext(relevant)\n memoryFacts = input.memoryStore.contextFacts(relevant)\n } catch {\n // Memory retrieval is best-effort; planner proceeds with empty memory.\n }\n }\n\n let crossChatContext = \"\"\n if (crossChatInclude) {\n // Force-include via empty message arg — the planner already decided.\n crossChatContext = input.sessions.getCrossSessionSummary(\n input.agentId, input.channel, input.chatId, \"\",\n )\n }\n\n return {\n sessionHistory,\n memoryContext,\n memoryFacts,\n crossChatContext,\n debug: {\n recentTurns,\n memoryIncluded: memoryInclude,\n memoryQuery: memoryQuery || undefined,\n crossChatIncluded: crossChatInclude,\n reasoning,\n planLatencyMs: Date.now() - start,\n },\n }\n}\n\n/** Render the last N message pairs as a compact prompt tail. Returns \"\" when\n * there's no session on disk yet (first message). Format mirrors\n * SessionStore.buildHistoryContext but with an N-turn cap — the planner's\n * whole point is to cap this instead of dumping the full 12K-char log. */\nfunction renderSessionTail(\n sessions: SessionStore,\n agentId: string,\n channel: string,\n chatId: string,\n turns: number,\n): string {\n if (turns <= 0) return \"\"\n const session = sessions.getSession(agentId, channel, chatId)\n if (session.messages.length === 0) return \"\"\n // N \"turns\" = N*2 messages (user+agent pairs). Round to nearest message\n // count so a partial trailing user message still gets included.\n const msgCount = Math.min(session.messages.length, turns * 2)\n const tail = session.messages.slice(-msgCount)\n const lines: string[] = [`[Recent exchange — last ${tail.length} messages]`]\n for (const msg of tail) {\n const name = msg.name || (msg.role === \"user\" ? \"User\" : \"Agent\")\n lines.push(`${name}: ${msg.content}`)\n }\n lines.push(\"[End recent exchange — respond to the latest message above]\")\n lines.push(\"\")\n return lines.join(\"\\n\")\n}\n\n/** Very small tail for the planner's own prompt — enough for the planner to\n * decide whether this message is a follow-up, not enough to bloat the\n * planner call itself. Distinct from renderSessionTail (used for the main\n * agent) because we cap more aggressively here. */\nfunction sessionTail(\n sessions: SessionStore,\n agentId: string,\n channel: string,\n chatId: string,\n maxMessages: number,\n): string {\n const session = sessions.getSession(agentId, channel, chatId)\n if (session.messages.length === 0) return \"\"\n const tail = session.messages.slice(-maxMessages)\n return tail\n .map((m: SessionMessage) => {\n const name = m.name || (m.role === \"user\" ? \"User\" : \"Agent\")\n const content = m.content.length > 200 ? m.content.slice(0, 200) + \"…\" : m.content\n return ` ${name}: ${content}`\n })\n .join(\"\\n\")\n}\n\n/** Extract the first JSON object from a text response. Haiku sometimes\n * wraps output in backticks or prose despite the instructions, so we\n * scan for the first `{...}` span. */\n\nfunction clampInt(v: unknown, min: number, max: number, fallback: number): number {\n const n = typeof v === \"number\" ? Math.floor(v) : Number.parseInt(String(v ?? \"\"), 10)\n if (!Number.isFinite(n)) return fallback\n return Math.min(max, Math.max(min, n))\n}\n"],"mappings":"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","names":["init_extract_json","PLANNER_MODEL","PLANNER_PROMPT","planContext","input","start","timeoutMs","recentTail","sessionTail","userPrompt","planJson","createProvider","provider","ac","timer","result","extractJson","err","recentTurns","clampInt","memoryInclude","memoryQuery","crossChatInclude","reasoning","sessionHistory","renderSessionTail","memoryContext","memoryFacts","relevant","crossChatContext","sessions","agentId","channel","chatId","turns","session","msgCount","tail","lines","msg","name","maxMessages","m","content","v","min","max","fallback","n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import{f,k as I}from"./chunk-Q7C3X3R6.js";import"./chunk-ZTEU5JVQ.js";import"./chunk-FIOB3MEX.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
|
+
error: ${o}`});return[`**${t}** hit the same failure in ${e} separate sessions (${i.length} runs).`,`- Tool: \`${s}\`
|
|
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
|
+
${n.join(`
|
|
5
|
+
`)}`].join(`
|
|
6
|
+
|
|
7
|
+
`)}export{x as DEFAULT_MIN_SESSIONS,k as FAILURE_STAMP_PREFIX,p as MAX_FAILURE_EXAMPLES,h as errorClass,b as failingTool,y as failureSignature,w as failureStamp,C as failuresToCandidates,_ as loadFailedTraces,F as sessionOf};
|
|
8
|
+
//# sourceMappingURL=failure-candidates-ARRMFXRY.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/wiki/failure-candidates.ts"],"sourcesContent":["import { createHash } from \"crypto\"\nimport type Database from \"better-sqlite3\"\nimport { getTrace, listTraces, type TraceRecord, type TraceStepRecord } from \"@/storage/traces\"\nimport type { MemoryCandidate } from \"./promote\"\n\n// Failed traces → wiki promotion candidates.\n//\n// Every other learning pass reads successes: the procedure miner loads\n// `status: ok` traces, and promotion reads memories an agent chose to\n// write. A tool that keeps failing, or the same wrong turn taken in\n// session after session, never reaches either — nothing in a failed run\n// is written down as a memory, and the miner never looks at it.\n//\n// This groups failed and timed-out traces by a failure signature (agent\n// + tool + outcome + error class) and offers only the signatures that recur across\n// several sessions to `wiki promote`. They join the same pool as memories\n// and monitor findings, so the judge, the ledger and the proposal review\n// are shared rather than rebuilt. One failure is session state; the same\n// failure in five sessions is something the fleet should know.\n\nexport const FAILURE_STAMP_PREFIX = \"failure:\"\nexport const DEFAULT_MIN_SESSIONS = 3\n/** Example runs kept per signature; the counts carry the rest. */\nexport const MAX_FAILURE_EXAMPLES = 5\n\n/** Trace statuses that count as a failure. `cancelled` does not: an\n * operator or a daemon restart stopped the run, the agent did not fail. */\nconst FAILED_STATUSES = [\"error\", \"timeout\"]\n\n/** Chats a learning pass itself runs in. Learning from those would make\n * the system learn from itself (same rule as the procedure miner). */\nconst SELF_CHAT_PREFIXES = [\"memory-promote\", \"procedure-miner\"]\n\nexport interface FailedTrace {\n taskId: string\n agentId: string\n chatId: string | null\n /** The session the run belongs to — the provider session when one is\n * known, else the run itself. See sessionOf(). */\n sessionId: string\n status: string\n startedAt: number\n error: string | null\n messagePreview: string | null\n /** The failing tool — see failingTool(); null when the run failed\n * before or outside any tool. */\n tool: string | null\n}\n\nexport interface FailureCandidate extends MemoryCandidate {\n /** Distinct sessions that hit this signature. */\n occurrences: number\n /** Some of those sessions, newest first. */\n sessions: string[]\n /** Some of the failed runs (task ids), newest first. */\n tasks: string[]\n failure: { tool: string; errorClass: string; runs: number }\n}\n\n/**\n * Reduce an error message to its class: the words that stay the same\n * when the same thing breaks again. Ids, numbers, paths, URLs and quoted\n * values change every time and would split one failure into many.\n */\nexport function errorClass(status: string, error: string | null): string {\n const text = (error ?? \"\")\n .toLowerCase()\n .replace(/https?:\\/\\/\\S+/g, \"<url>\")\n .replace(/([\"'`]).*?\\1/g, \"<v>\")\n .replace(/(?:~|\\.{0,2})?\\/[\\w.@-]+(?:\\/[\\w.@-]+)*/g, \"<path>\")\n .replace(/\\b[0-9a-z]*\\d[0-9a-z]*\\b/g, \"<n>\")\n .replace(/[^a-z<>\\s]+/g, \" \")\n .replace(/\\s+/g, \" \")\n .trim()\n const words = text.split(\" \").filter(Boolean).slice(0, 8).join(\" \")\n return words || status\n}\n\n/** Agent + tool + outcome + error class. A timeout and an error in the\n * same tool are different failures with different fixes. */\nexport function failureSignature(t: Pick<FailedTrace, \"agentId\" | \"tool\" | \"status\" | \"error\">): string {\n return `${t.agentId}|${t.tool ?? \"no-tool\"}|${t.status}|${errorClass(t.status, t.error)}`\n}\n\nfunction digest(signature: string): string {\n return createHash(\"sha1\").update(signature).digest(\"hex\").slice(0, 10)\n}\n\n/**\n * The stamp changes only when recurrence doubles (2–3 → 4–7 → 8–15 …).\n * A lesson skipped or rejected at three sessions is offered again once\n * it has been seen in four, and next at eight; it is not re-offered every\n * night because one more session hit it.\n */\nexport function failureStamp(signature: string, sessions: number): string {\n return `${FAILURE_STAMP_PREFIX}${digest(signature)}@${Math.floor(Math.log2(Math.max(1, sessions)))}`\n}\n\n/**\n * Which session a run belongs to. The provider session is the honest\n * unit: two failures inside one continuing conversation are one session\n * going wrong, not two. A run that never got a session is its own. The\n * chat id is deliberately not used — a scheduled job reuses one chat id\n * forever, which would count a job failing every night as one session.\n */\nexport function sessionOf(t: Pick<TraceRecord, \"taskId\" | \"finalSessionId\" | \"resumeSessionId\">): string {\n return t.finalSessionId ?? t.resumeSessionId ?? t.taskId\n}\n\n/** Load failed and timed-out traces in the window, with their failing tool. */\nexport function loadFailedTraces(db: Database.Database, opts: { since?: number } = {}): FailedTrace[] {\n const traces = FAILED_STATUSES.flatMap((status) =>\n listTraces(db, { status, since: opts.since, limit: 1000 }))\n return traces\n .filter((t) => !SELF_CHAT_PREFIXES.some((p) => (t.chatId ?? \"\").startsWith(p)))\n .map((t) => {\n const { tool, error } = failingTool(getTrace(db, t.taskId)?.steps ?? [])\n return {\n taskId: t.taskId,\n agentId: t.agentId,\n chatId: t.chatId,\n sessionId: sessionOf(t),\n status: t.status,\n startedAt: t.startedAt,\n error: error ?? t.error,\n messagePreview: t.messagePreview,\n tool,\n }\n })\n}\n\n/**\n * The tool a run failed in, and that tool's error. The stream records a\n * call as a `tool_use` step (named, status in-flight) and its outcome as\n * a separate `tool_result` step that carries no tool name, so an errored\n * result is paired with the call before it. The last error wins; with no\n * errored call the run is attributed to the last tool it used, keeping\n * the run's own error.\n */\nexport function failingTool(\n steps: Array<Pick<TraceStepRecord, \"name\" | \"action\" | \"status\" | \"error\" | \"outputSummary\">>,\n): { tool: string | null; error: string | null } {\n let last: string | null = null\n let failing: { tool: string | null; error: string | null } | null = null\n for (const s of steps) {\n if (s.name === \"tool_use\" && s.action) {\n last = s.action\n if (s.status === \"error\") failing = { tool: s.action, error: s.error ?? s.outputSummary }\n } else if (s.name === \"tool_result\" && s.status === \"error\") {\n failing = { tool: s.action ?? last, error: s.error ?? s.outputSummary }\n }\n }\n return failing ?? { tool: last, error: null }\n}\n\n/** Group failures by signature; keep those seen in at least `minSessions`\n * distinct sessions (never fewer than 2 — one session is not a pattern).\n * Most recurrent first. */\nexport function failuresToCandidates(\n traces: FailedTrace[],\n opts: { minSessions?: number } = {},\n): FailureCandidate[] {\n const minSessions = Math.max(2, opts.minSessions ?? DEFAULT_MIN_SESSIONS)\n const groups = new Map<string, FailedTrace[]>()\n for (const t of traces) {\n const sig = failureSignature(t)\n groups.set(sig, [...(groups.get(sig) ?? []), t])\n }\n\n const out: FailureCandidate[] = []\n for (const [signature, list] of groups) {\n const sessions = [...new Set([...list].sort((a, b) => b.startedAt - a.startedAt).map((t) => t.sessionId))]\n if (sessions.length < minSessions) continue\n list.sort((a, b) => b.startedAt - a.startedAt)\n const latest = list[0]\n const tool = latest.tool ?? \"no tool\"\n const cls = errorClass(latest.status, latest.error)\n const name = `failure-${digest(signature)}`\n out.push({\n occurrences: sessions.length,\n sessions: sessions.slice(0, MAX_FAILURE_EXAMPLES),\n tasks: list.slice(0, MAX_FAILURE_EXAMPLES).map((t) => t.taskId),\n failure: { tool, errorClass: cls, runs: list.length },\n agentId: latest.agentId,\n key: `${latest.agentId}/feedback_${name}`,\n stamp: failureStamp(signature, sessions.length),\n memory: {\n name,\n type: \"feedback\",\n description: `${latest.agentId}: ${tool} keeps failing (${cls}) in ${sessions.length} sessions`.slice(0, 200),\n body: renderBody(latest.agentId, tool, cls, sessions.length, list),\n createdAt: new Date(list[list.length - 1].startedAt).toISOString(),\n updatedAt: new Date(latest.startedAt).toISOString(),\n },\n })\n }\n return out.sort((a, b) => b.occurrences - a.occurrences)\n}\n\nfunction renderBody(agent: string, tool: string, cls: string, sessions: number, list: FailedTrace[]): string {\n const examples = list.slice(0, MAX_FAILURE_EXAMPLES).map((t) => {\n const task = (t.messagePreview ?? \"\").replace(/\\s+/g, \" \").trim().slice(0, 120)\n const error = (t.error ?? t.status).replace(/\\s+/g, \" \").trim().slice(0, 160)\n return `- ${new Date(t.startedAt).toISOString().slice(0, 10)} \\`${t.taskId}\\` (${t.status})${task ? ` — task: ${task}` : \"\"}\\n error: ${error}`\n })\n return [\n `**${agent}** hit the same failure in ${sessions} separate sessions (${list.length} runs).`,\n `- Tool: \\`${tool}\\`\\n- Error class: \\`${cls}\\``,\n \"Recurrence across sessions is the finding: any one of these runs is session state. \" +\n \"Propose the fix that stops it recurring — what fails, the likely cause, and what to do instead \" +\n \"(a missing fact, a better approach, or a tool or configuration change to make) — \" +\n \"or skip it if the examples do not share a cause.\",\n `**Examples (newest first):**\\n${examples.join(\"\\n\")}`,\n ].join(\"\\n\\n\")\n}\n"],"mappings":"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","names":["createHash","FAILURE_STAMP_PREFIX","DEFAULT_MIN_SESSIONS","MAX_FAILURE_EXAMPLES","FAILED_STATUSES","SELF_CHAT_PREFIXES","errorClass","status","error","failureSignature","digest","signature","createHash","failureStamp","sessions","sessionOf","loadFailedTraces","db","opts","listTraces","t","p","tool","failingTool","getTrace","steps","last","failing","s","failuresToCandidates","traces","minSessions","groups","sig","out","list","a","b","latest","cls","name","renderBody","agent","examples","task"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -2894,6 +2894,10 @@ declare const daemonConfigSchema: z.ZodObject<{
|
|
|
2894
2894
|
keywords?: string[] | undefined;
|
|
2895
2895
|
node?: string | undefined;
|
|
2896
2896
|
}>, "many">>;
|
|
2897
|
+
/** Extra GitLab usernames each agent answers to, as prefixes. With
|
|
2898
|
+
* ["team-"], an agent with no agentMappings row answers to @<id> and
|
|
2899
|
+
* @team-<id>. Default: only @<id>. */
|
|
2900
|
+
agentUsernamePrefixes: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
2897
2901
|
}, "strip", z.ZodTypeAny, {
|
|
2898
2902
|
enabled: boolean;
|
|
2899
2903
|
host: string;
|
|
@@ -2910,6 +2914,7 @@ declare const daemonConfigSchema: z.ZodObject<{
|
|
|
2910
2914
|
token?: string | undefined;
|
|
2911
2915
|
node?: string | undefined;
|
|
2912
2916
|
}[];
|
|
2917
|
+
agentUsernamePrefixes: string[];
|
|
2913
2918
|
token?: string | undefined;
|
|
2914
2919
|
webhookSecret?: string | undefined;
|
|
2915
2920
|
}, {
|
|
@@ -2930,6 +2935,7 @@ declare const daemonConfigSchema: z.ZodObject<{
|
|
|
2930
2935
|
keywords?: string[] | undefined;
|
|
2931
2936
|
node?: string | undefined;
|
|
2932
2937
|
}[] | undefined;
|
|
2938
|
+
agentUsernamePrefixes?: string[] | undefined;
|
|
2933
2939
|
}>>;
|
|
2934
2940
|
github: z.ZodDefault<z.ZodObject<{
|
|
2935
2941
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
@@ -3225,6 +3231,7 @@ declare const daemonConfigSchema: z.ZodObject<{
|
|
|
3225
3231
|
token?: string | undefined;
|
|
3226
3232
|
node?: string | undefined;
|
|
3227
3233
|
}[];
|
|
3234
|
+
agentUsernamePrefixes: string[];
|
|
3228
3235
|
token?: string | undefined;
|
|
3229
3236
|
webhookSecret?: string | undefined;
|
|
3230
3237
|
};
|
|
@@ -3348,6 +3355,7 @@ declare const daemonConfigSchema: z.ZodObject<{
|
|
|
3348
3355
|
keywords?: string[] | undefined;
|
|
3349
3356
|
node?: string | undefined;
|
|
3350
3357
|
}[] | undefined;
|
|
3358
|
+
agentUsernamePrefixes?: string[] | undefined;
|
|
3351
3359
|
} | undefined;
|
|
3352
3360
|
whatsapp?: {
|
|
3353
3361
|
enabled?: boolean | undefined;
|
|
@@ -5629,6 +5637,7 @@ declare const daemonConfigSchema: z.ZodObject<{
|
|
|
5629
5637
|
token?: string | undefined;
|
|
5630
5638
|
node?: string | undefined;
|
|
5631
5639
|
}[];
|
|
5640
|
+
agentUsernamePrefixes: string[];
|
|
5632
5641
|
token?: string | undefined;
|
|
5633
5642
|
webhookSecret?: string | undefined;
|
|
5634
5643
|
};
|
|
@@ -6227,6 +6236,7 @@ declare const daemonConfigSchema: z.ZodObject<{
|
|
|
6227
6236
|
keywords?: string[] | undefined;
|
|
6228
6237
|
node?: string | undefined;
|
|
6229
6238
|
}[] | undefined;
|
|
6239
|
+
agentUsernamePrefixes?: string[] | undefined;
|
|
6230
6240
|
} | undefined;
|
|
6231
6241
|
whatsapp?: {
|
|
6232
6242
|
enabled?: boolean | undefined;
|
|
@@ -7804,7 +7814,7 @@ interface DriftReport {
|
|
|
7804
7814
|
}
|
|
7805
7815
|
|
|
7806
7816
|
type SourceTrust =
|
|
7807
|
-
/** Only the operator can reach it: CLI, dashboard, local voice and
|
|
7817
|
+
/** Only the operator can reach it: CLI, dashboard, local voice, TUI and Raycast. */
|
|
7808
7818
|
"operator"
|
|
7809
7819
|
/** Authenticated people or peers: allow-listed chat senders, forge
|
|
7810
7820
|
* project members, mesh callers. */
|
|
@@ -7849,6 +7859,10 @@ declare class MemoryStore {
|
|
|
7849
7859
|
getAll(agentId: string): MemoryFact[];
|
|
7850
7860
|
findRelevant(message: string, agentId: string, limit?: number): MemoryFact[];
|
|
7851
7861
|
buildContext(memories: MemoryFact[]): string;
|
|
7862
|
+
/** The facts buildContext actually renders — the rest fall past its
|
|
7863
|
+
* character budget. Trace capture records these ids, not the candidates. */
|
|
7864
|
+
contextFacts(memories: MemoryFact[]): MemoryFact[];
|
|
7865
|
+
private contextLines;
|
|
7852
7866
|
/**
|
|
7853
7867
|
* Record that memories were accessed (for spaced repetition tracking).
|
|
7854
7868
|
*/
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as L}from"./chunk-W5C2GDNC.js";import{a as St,b as kt,c as vt,d as xt,e as $t,f as Ct,g as Pt,
|
|
1
|
+
import{a as L}from"./chunk-W5C2GDNC.js";import{a as St,b as kt,c as vt,d as xt,e as $t,f as Ct,g as Pt,ia as bt,ja as Tt,ka as Mt}from"./chunk-BYD55JXH.js";import"./chunk-EMI3VJLH.js";import"./chunk-PZCTCCC5.js";import"./chunk-LQRBGQIR.js";import"./chunk-ZVP6GB4G.js";import"./chunk-FULEQYM6.js";import"./chunk-OHA3J5ZV.js";import"./chunk-3SCPRYJB.js";import"./chunk-AQASR6KR.js";import"./chunk-L53FTKEP.js";import{N as yt,l as lt,m as ct,n as dt,o as mt,p as pt}from"./chunk-TTL37CS5.js";import"./chunk-N2XXKFJ6.js";import"./chunk-N6EWZGIX.js";import"./chunk-Q7C3X3R6.js";import"./chunk-DP7RTNDM.js";import{A as D,B as z,C as V,a as ye,b as we,c as Se,d as Ae,e as Ie,f as Oe,g as Ne,h as He,i as je,j as Ue,k as _e,l as I,m as q,n as Be,o as qe,p as Ye,q as O,r as ze,s as Ve,t as Xe,u as x,v as Y,w as Qe,x as Ze,y as et,z as wt}from"./chunk-WQLBJ2O5.js";import{a as B,b as M,c as F}from"./chunk-SFQUP3BP.js";import"./chunk-5XQCGPQJ.js";import{m as ut}from"./chunk-B5XHX44Y.js";import"./chunk-WPMX3VGI.js";import"./chunk-K33GIBSE.js";import"./chunk-76Z4VHDX.js";import"./chunk-W4YR2RO2.js";import"./chunk-AFRHKA7B.js";import"./chunk-NLZD2QKF.js";import"./chunk-5ALS7SVV.js";import"./chunk-DWADWDMU.js";import"./chunk-6VKCUMCN.js";import"./chunk-HRBKSZ34.js";import"./chunk-VWTBHLMX.js";import"./chunk-IXUEJBHD.js";import{a as gt,b as ft,e as ht}from"./chunk-JVNFRS26.js";import"./chunk-PNWNVOEZ.js";import"./chunk-64P4QHSZ.js";import"./chunk-QDE75R4U.js";import"./chunk-AJ5RMU7X.js";import"./chunk-2GIDVZ4H.js";import{j as it,k as rt,l as at}from"./chunk-4NBWF4TL.js";import"./chunk-F4HZTZHW.js";import"./chunk-AJONZWLT.js";import"./chunk-ZTEU5JVQ.js";import"./chunk-QOYAX2FT.js";import{a as ke,b as ve,c as xe,d as $e,e as Ce,f as Pe,g as be,h as Te,i as Me,j as Re,l as Ee,m as Ge,o as T,p as W}from"./chunk-LCIREYTD.js";import{a as m,b as G}from"./chunk-L2WSPY6S.js";import{a as Fe,b as Le,c as A,d as De}from"./chunk-VDMYBPYB.js";import{a as Ke,b as Je,e as We}from"./chunk-DSYKYZMT.js";import{k as tt,m as st,n as ot,p as nt}from"./chunk-P2ZYT5D6.js";import"./chunk-BH3GTCZ6.js";import"./chunk-FIOB3MEX.js";W();G();import{execa as Rt}from"execa";import{existsSync as se,promises as X}from"fs";import S from"path";import ie from"node-fetch";async function Et(o,e){let t=o.split("/");if(t.length<2)throw new Error(`Invalid skill package ID: ${o}. Expected format: owner/repo`);let s=t[0],i=t[1],n=t[2];try{let a=n?`${s}/${i}/${n}`:`${s}/${i}`;await Rt("npx",["-y","skills","add",a],{cwd:e,stdio:"pipe"}),m.success(`Installed skill package: ${o}`);let r=S.resolve(e,".skills",`${s}_${i}`);if(se(r))return await ne(r,o);let d=S.resolve(e,".skills");return se(d)?await ne(d,o):[]}catch{return m.info(`Fetching skills directly from GitHub: ${s}/${i}`),await Gt(s,i,n,e)}}async function Gt(o,e,t,s){let i=[];try{let n=`https://api.github.com/repos/${o}/${e}/git/trees/main?recursive=1`,a=await ie(n);if(!a.ok)throw new Error(`GitHub API error: ${a.status}`);let d=(await a.json()).tree.filter(p=>p.type==="blob"&&p.path.endsWith("SKILL.md"));if(t){let p=d.find(f=>f.path.includes(`/${t}/`)||f.path===`${t}/SKILL.md`);if(p){let f=await oe(o,e,p.path,s);f&&i.push(f)}}else for(let p of d){let f=await oe(o,e,p.path,s);f&&i.push(f)}}catch(n){m.error(`Failed to fetch skills from GitHub: ${n.message}`)}return i}async function oe(o,e,t,s){try{let i=`https://raw.githubusercontent.com/${o}/${e}/main/${t}`,n=await ie(i);if(!n.ok)return null;let a=await n.text(),r=A(a);if(r){r.source="remote",r.packageId=`${o}/${e}`;let d=S.dirname(t),p=S.resolve(s,".skills",`${o}_${e}`,d);await X.mkdir(p,{recursive:!0}),await X.writeFile(S.resolve(p,"SKILL.md"),a),r.path=S.resolve(p,"SKILL.md")}return r}catch{return null}}async function ne(o,e){let t=[],{default:s}=await import("fast-glob"),i=await s.glob("**/SKILL.md",{cwd:o,deep:5});for(let n of i)try{let a=S.resolve(o,n),r=await X.readFile(a,"utf8"),d=A(r);d&&(d.source="remote",d.path=a,d.packageId=e,t.push(d))}catch{}return t}async function At(o,e,t,s,i){let n=["---",`name: ${o}`,`description: ${e}`];if(s?.length){n.push("tags:");for(let a of s)n.push(` - ${a}`)}if(i?.length){n.push("globs:");for(let a of i)n.push(` - ${a}`)}return n.push("---"),`${n.join(`
|
|
2
2
|
`)}
|
|
3
3
|
|
|
4
4
|
${t}`}async function It(o){let{loadLocalSkills:e}=await import("./loader-BOKE5M5S.js");return e(o)}async function Ot(o,e,t,s,i){let a=[{role:"system",content:`You are a skill author for the Agent Skills ecosystem (skills.sh).
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a}from"./chunk-Y6I3BYWV.js";import"./chunk-OUZ7YVQZ.js";import"./chunk-TUNQFPVA.js";import"./chunk-Z3IP66SL.js";import"./chunk-4BNQSUWV.js";import"./chunk-OTW5MPFT.js";import"./chunk-RKPAVWXF.js";import"./chunk-GV7S5BAX.js";import"./chunk-GSX4NK2N.js";import"./chunk-SZDACK6O.js";import"./chunk-BYD55JXH.js";import"./chunk-EMI3VJLH.js";import"./chunk-PZCTCCC5.js";import"./chunk-LQRBGQIR.js";import"./chunk-ZVP6GB4G.js";import"./chunk-FULEQYM6.js";import"./chunk-OHA3J5ZV.js";import"./chunk-3SCPRYJB.js";import"./chunk-AQASR6KR.js";import"./chunk-L53FTKEP.js";import"./chunk-TTL37CS5.js";import"./chunk-N2XXKFJ6.js";import"./chunk-N6EWZGIX.js";import"./chunk-Q7C3X3R6.js";import"./chunk-DP7RTNDM.js";import"./chunk-WQLBJ2O5.js";import"./chunk-SFQUP3BP.js";import"./chunk-5XQCGPQJ.js";import"./chunk-B5XHX44Y.js";import"./chunk-WPMX3VGI.js";import"./chunk-K33GIBSE.js";import"./chunk-76Z4VHDX.js";import"./chunk-W4YR2RO2.js";import"./chunk-AFRHKA7B.js";import"./chunk-NLZD2QKF.js";import"./chunk-5ALS7SVV.js";import"./chunk-DWADWDMU.js";import"./chunk-6VKCUMCN.js";import"./chunk-HRBKSZ34.js";import"./chunk-VWTBHLMX.js";import"./chunk-IXUEJBHD.js";import"./chunk-JVNFRS26.js";import"./chunk-PNWNVOEZ.js";import"./chunk-64P4QHSZ.js";import"./chunk-QDE75R4U.js";import"./chunk-AJ5RMU7X.js";import"./chunk-2GIDVZ4H.js";import"./chunk-4NBWF4TL.js";import"./chunk-F4HZTZHW.js";import"./chunk-AJONZWLT.js";import"./chunk-ZTEU5JVQ.js";import"./chunk-QOYAX2FT.js";import"./chunk-LCIREYTD.js";import"./chunk-L2WSPY6S.js";import"./chunk-VDMYBPYB.js";import"./chunk-DSYKYZMT.js";import"./chunk-P2ZYT5D6.js";import"./chunk-BH3GTCZ6.js";import"./chunk-FIOB3MEX.js";export{a as buildProgram};
|
|
2
|
+
//# sourceMappingURL=program-KY5ZYPFN.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{b as a,c as b,d as c,e as d,f as e,g as f,h as g,i as h,j as i,k as j,l as k,m as l,n as m,o as n,p as o,q as p,r as q,s as r,t as s,u as t}from"./chunk-OHA3J5ZV.js";import"./chunk-3SCPRYJB.js";import"./chunk-AQASR6KR.js";import"./chunk-DP7RTNDM.js";import"./chunk-JVNFRS26.js";import"./chunk-PNWNVOEZ.js";import"./chunk-64P4QHSZ.js";import"./chunk-AJ5RMU7X.js";import"./chunk-4NBWF4TL.js";import"./chunk-F4HZTZHW.js";import"./chunk-AJONZWLT.js";import"./chunk-ZTEU5JVQ.js";import"./chunk-QOYAX2FT.js";import"./chunk-LCIREYTD.js";import"./chunk-L2WSPY6S.js";import"./chunk-P2ZYT5D6.js";import"./chunk-BH3GTCZ6.js";import"./chunk-FIOB3MEX.js";export{b as DEFAULT_PROMOTE_TYPES,a as PROMOTER_OWNER,c as PROMOTION_LEDGER_FILE,j as appendPromotionLedger,s as approveProposal,n as callPromotionLlm,p as estimateTokens,r as evidenceFor,m as getUnpromotedMemories,k as groupCandidates,h as listAllAgentMemories,d as memoryKey,e as memoryStamp,g as mergeSources,f as parseMemoryStamp,l as parsePromotionResponse,i as readPromotionLedger,t as rejectProposal,o as runPromotion,q as sourceKind};
|
|
2
|
+
//# sourceMappingURL=promote-57YNOVXV.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a}from"./chunk-QDE75R4U.js";import"./chunk-AJ5RMU7X.js";import"./chunk-2GIDVZ4H.js";import"./chunk-4NBWF4TL.js";import"./chunk-F4HZTZHW.js";import"./chunk-AJONZWLT.js";import"./chunk-ZTEU5JVQ.js";import"./chunk-QOYAX2FT.js";import"./chunk-LCIREYTD.js";import"./chunk-L2WSPY6S.js";import"./chunk-P2ZYT5D6.js";import"./chunk-BH3GTCZ6.js";import"./chunk-FIOB3MEX.js";export{a as agenticQuery};
|
|
2
|
+
//# sourceMappingURL=query-ZT7WXY2F.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{E as a,F as b,G as c,H as d,I as e,J as f,K as g,L as h,M as i,N as j}from"./chunk-TTL37CS5.js";import"./chunk-N2XXKFJ6.js";import"./chunk-N6EWZGIX.js";import"./chunk-Q7C3X3R6.js";import"./chunk-DP7RTNDM.js";import"./chunk-B5XHX44Y.js";import"./chunk-WPMX3VGI.js";import"./chunk-K33GIBSE.js";import"./chunk-W4YR2RO2.js";import"./chunk-AFRHKA7B.js";import"./chunk-NLZD2QKF.js";import"./chunk-5ALS7SVV.js";import"./chunk-DWADWDMU.js";import"./chunk-6VKCUMCN.js";import"./chunk-HRBKSZ34.js";import"./chunk-VWTBHLMX.js";import"./chunk-IXUEJBHD.js";import"./chunk-JVNFRS26.js";import"./chunk-PNWNVOEZ.js";import"./chunk-64P4QHSZ.js";import"./chunk-QDE75R4U.js";import"./chunk-AJ5RMU7X.js";import"./chunk-2GIDVZ4H.js";import"./chunk-4NBWF4TL.js";import"./chunk-F4HZTZHW.js";import"./chunk-AJONZWLT.js";import"./chunk-ZTEU5JVQ.js";import"./chunk-QOYAX2FT.js";import"./chunk-LCIREYTD.js";import"./chunk-L2WSPY6S.js";import"./chunk-DSYKYZMT.js";import"./chunk-P2ZYT5D6.js";import"./chunk-BH3GTCZ6.js";import"./chunk-FIOB3MEX.js";export{j as AgentRegistry,e as TRACE_STEP_SUMMARY_BYTES,c as buildEntryMeta,d as buildWikiContext,f as clipForTrace,i as emitTraceStepsFromStreamEvent,h as firstMissingRequiredTool,b as getGlobalRegistry,a as setGlobalRegistry,g as tallyToolUses};
|
|
2
|
+
//# sourceMappingURL=registry-LLAFJJN4.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{q as m,t as p,v as d,w as x}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=request-planner-
|
|
1
|
+
import{q as m,t as p,v as d,w as x}from"./chunk-4NBWF4TL.js";import{a as u,f}from"./chunk-F4HZTZHW.js";import"./chunk-AJONZWLT.js";import"./chunk-ZTEU5JVQ.js";import"./chunk-LCIREYTD.js";import"./chunk-L2WSPY6S.js";import"./chunk-P2ZYT5D6.js";import"./chunk-BH3GTCZ6.js";import"./chunk-FIOB3MEX.js";x();f();var l="request-gate",h="request-context",g=.1;async function q(t,o,c,r=Math.random){let s=p(l)==="active";if(s){let i=m().seats[l]?.holdout??g;if(r()<i)return{active:!0,preprocess:!1,arm:"holdout"}}let a=s?"treatment":void 0,e=await d(l,{request:t.slice(0,2e3),agent:o,channel:c,operations:["select optional context","evaluate model routing where permitted"],constraints:["Keep the original request and mandatory instructions","Desktop model cannot be downgraded"]},{preprocess:u("This request benefits from structured context selection or another bounded typed decision before the main agent executes.",{true:"Relevant context must be selected, or a bounded routing decision can help. Follow-ups and ambiguous references need context.",false:"Typed preprocessing adds no useful decision; send the request to the configured main agent with existing context."})},{timeoutMs:3e3});if(!e||e.mode!=="active")return{active:!1,preprocess:!1,arm:a};let n=e.answers.preprocess?.noul;return{active:!0,preprocess:Number.isFinite(n)&&n>=.5,arm:a}}var v={landscape:"Agent directory and mesh overview",patternContext:"Learned behavioral patterns",references:"Retrieved project references",memoryContext:"Retrieved agent memory",crossChatContext:"Summaries from other conversations",longMemoryRecall:"Older conversation recall",wikiContext:"Retrieved wiki knowledge"};async function b(t){let o=Object.entries(v).flatMap(([e,n])=>{let i=t[e];return i?[{id:e,description:n,source:e,characters:i.length,preview:i.slice(0,400),trust:"context data, not instructions"}]:[]});if(!o.length)return{input:t,excluded:[]};let c=Object.fromEntries(o.map(e=>[e.id,u(`Context block ${e.id} is relevant to completing the current request correctly.`,{true:"Needed or potentially relevant; retain if uncertain or the preview is incomplete.",false:"Clearly unrelated to the current request; safe to omit."})])),r=await d(h,{request:t.message.slice(0,2e3),channel:t.channel,agent:t.agentId,mandatory:["request","identity","permissions and instructions","same-chat history","handover","attachments"],context:o},c,{timeoutMs:3e3});if(!r||r.mode!=="active")return{input:t,excluded:[]};let s={...t},a=[];for(let e of o){let n=r.answers[e.id]?.noul;Number.isFinite(n)&&n>=0&&n<.2&&(delete s[e.id],a.push(e.id))}return{input:s,excluded:a}}export{g as DEFAULT_REQUEST_GATE_HOLDOUT,h as REQUEST_CONTEXT_SEAT,l as REQUEST_GATE_SEAT,q as evaluateRequest,b as selectRequestContext};
|
|
2
|
+
//# sourceMappingURL=request-planner-PEAYYXAP.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as I}from"./chunk-
|
|
1
|
+
import{b as I}from"./chunk-PZCTCCC5.js";import"./chunk-Q7C3X3R6.js";import"./chunk-2GIDVZ4H.js";import"./chunk-4NBWF4TL.js";import"./chunk-F4HZTZHW.js";import"./chunk-AJONZWLT.js";import"./chunk-ZTEU5JVQ.js";import"./chunk-LCIREYTD.js";import"./chunk-L2WSPY6S.js";import"./chunk-P2ZYT5D6.js";import"./chunk-BH3GTCZ6.js";import"./chunk-FIOB3MEX.js";import{createHash as E}from"crypto";var v="review:",b={decisions:"project",warnings:"feedback",friction:"feedback",context:"reference"};function A(t,n,r){let s=E("sha1").update(r.trim().toLowerCase()).digest("hex").slice(0,10);return`${v}${t}/${n}@${s}`}function F(t){if(!t.startsWith(v))return null;let n=t.slice(v.length),r=n.lastIndexOf("@"),s=n.lastIndexOf("/",r===-1?void 0:r);return r===-1||s===-1?null:{reviewId:n.slice(0,s),kind:n.slice(s+1,r),digest:n.slice(r+1)}}var C=t=>t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,48)||"finding",L=5;function T(t,n){return`${t}|${I(n)}`}function K(t,n={}){let r=n.kinds??Object.keys(b),s=n.minLength??24,h=[],d=new Map,u=new Map,f=new Map,x=new Map;for(let e of t){let i;try{i=JSON.parse(e.result)}catch{continue}let o=e.updated_at?new Date(e.updated_at).toISOString():new Date().toISOString();for(let c of r){let l=b[c];if(!l)continue;let R=i[c];if(Array.isArray(R))for(let $ of R){let a=String($?.text??"").trim();if(a.length<s)continue;let g=A(e.id,c,a),_=g.slice(g.lastIndexOf("@")),w=`${c}${_}`,y=T(c,a),S=f.get(y)??new Set;if(S.add(e.session_id??e.id),f.set(y,S),d.has(w))continue;let O=String($?.evidence??"").trim(),k={occurrences:1,agentId:e.agent,key:`${e.agent}/${l}_${C(a)}`,stamp:g,memory:{name:C(a),type:l,description:a.slice(0,200),body:"",createdAt:o,updatedAt:o}};x.set(g,{text:a,evidence:O,agent:e.agent,source:e.source}),d.set(w,k),u.set(w,y),h.push(k)}}}for(let[e,i]of d){let o=f.get(u.get(e)??"");i.occurrences=o?.size??1,i.sessions=[...o??[]].slice(0,L);let c=x.get(i.stamp);i.memory.body=D(c,i.occurrences)}let m=new Map;for(let[e,i]of d){let o=u.get(e)??e,c=m.get(o)??[];c.push(i),m.set(o,c)}let M=[...m.values()].sort((e,i)=>i[0].occurrences-e[0].occurrences),p=[];for(let e=0;p.length<h.length;e++){let i=!1;for(let o of M)e<o.length&&(p.push(o[e]),i=!0);if(!i)break}return p}function D(t,n){let r=`${t.agent}${t.source?` via ${t.source}`:""}`,s=[];return n>1?(s.push(`Observed in ${n} separate sessions. Most recently stated as:`),s.push(`> ${t.text}`),s.push(`Recurring across ${n} sessions is what makes this worth recording \u2014 any single occurrence is session state, the repetition is the finding.`)):s.push(t.text),t.evidence&&s.push(`**Evidence:** ${t.evidence}`),s.push(`_From ${n>1?"session reviews":"a session review"} of ${r}._`),s.join(`
|
|
2
2
|
|
|
3
3
|
`)}export{L as MAX_EVIDENCE_SESSIONS,b as PROMOTABLE_KINDS,v as REVIEW_STAMP_PREFIX,F as parseReviewStamp,A as reviewStamp,K as reviewsToCandidates};
|
|
4
|
-
//# sourceMappingURL=review-candidates-
|
|
4
|
+
//# sourceMappingURL=review-candidates-W7NIHNAI.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a,b}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=routing-
|
|
1
|
+
import{a,b}from"./chunk-5ALS7SVV.js";import"./chunk-4NBWF4TL.js";import"./chunk-F4HZTZHW.js";import"./chunk-AJONZWLT.js";import"./chunk-ZTEU5JVQ.js";import"./chunk-LCIREYTD.js";import"./chunk-L2WSPY6S.js";import"./chunk-P2ZYT5D6.js";import"./chunk-BH3GTCZ6.js";import"./chunk-FIOB3MEX.js";export{a as cheapModelForEngine,b as routeTaskModel};
|
|
2
|
+
//# sourceMappingURL=routing-7LCO7UJ7.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a,b}from"./chunk-4TITGMPX.js";import"./chunk-RKPAVWXF.js";import"./chunk-5XQCGPQJ.js";import"./chunk-B5XHX44Y.js";import"./chunk-NLZD2QKF.js";import"./chunk-ZTEU5JVQ.js";import"./chunk-L2WSPY6S.js";import"./chunk-P2ZYT5D6.js";import"./chunk-FIOB3MEX.js";export{b as resolveScheduleCaller,a as runScheduleTool};
|
|
2
|
+
//# sourceMappingURL=schedule-tool-ZD3VBUBW.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{h as a,i as b,j as c,k as d,l as e,m as f}from"./chunk-B5XHX44Y.js";import"./chunk-NLZD2QKF.js";import"./chunk-ZTEU5JVQ.js";import"./chunk-L2WSPY6S.js";import"./chunk-P2ZYT5D6.js";import"./chunk-FIOB3MEX.js";export{a as AGENT_RUN_TIMEOUT_FLOOR,f as CronScheduler,b as agentRunTimeout,e as cronRunId,d as getNextCronDate,c as runLinkIds};
|
|
2
|
+
//# sourceMappingURL=scheduler-GC3FQKXY.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{o as a,p as b,q as c,r as d,s as e,t as f,u as g,v as h,w as i}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=seat-
|
|
1
|
+
import{o as a,p as b,q as c,r as d,s as e,t as f,u as g,v as h,w as i}from"./chunk-4NBWF4TL.js";import"./chunk-F4HZTZHW.js";import"./chunk-AJONZWLT.js";import"./chunk-ZTEU5JVQ.js";import"./chunk-LCIREYTD.js";import"./chunk-L2WSPY6S.js";import"./chunk-P2ZYT5D6.js";import"./chunk-BH3GTCZ6.js";import"./chunk-FIOB3MEX.js";i();export{h as askSeat,a as configureDecisions,c as decisionsRuntime,f as getSeatMode,d as parseSeatMode,g as recordSeatOutcome,b as resetDecisionsRuntime,e as seatEnvVar};
|
|
2
|
+
//# sourceMappingURL=seat-HR6QMAR2.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{v as S,w}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=select-
|
|
1
|
+
import{v as S,w}from"./chunk-4NBWF4TL.js";import{a as g,b as h,f as R}from"./chunk-F4HZTZHW.js";import"./chunk-AJONZWLT.js";import"./chunk-ZTEU5JVQ.js";import"./chunk-LCIREYTD.js";import"./chunk-L2WSPY6S.js";import{d as f}from"./chunk-VDMYBPYB.js";import"./chunk-P2ZYT5D6.js";import"./chunk-BH3GTCZ6.js";import"./chunk-FIOB3MEX.js";w();R();var p="skill-select";function y(l){return{task:d(l.task,1200),...l.agent?{agent:l.agent}:{},skills:l.candidates.map(t=>({name:t.name,purpose:d(t.description,300),...t.category?{category:t.category}:{},...t.tags?.length?{tags:t.tags.slice(0,8)}:{}}))}}function b(l){let t={};for(let i of l)t[i.name]=d(i.description,300);return{anyRelevant:g("At least one of these skills is about the task at hand.",{true:"The task is the kind of work one of these skills exists for, and following it would change how the work is done \u2014 it names the same system, the same procedure or the same kind of artefact.",false:"None of them is about this task. They may share vocabulary with it, mention the same tools, or belong to the same project without bearing on what is being asked. Sharing words with a task is not being about it."}),best:h(t,"Which skill is this task most about?")}}function v(l){let t=l.anyRelevant,i=l.best,o=Object.entries(i.probabilities??{}).map(([e,s])=>({name:e,p:Number(s)||0})).sort((e,s)=>s.p-e.p);return{anyRelevant:t.noul,name:i.choice,confidence:i.confidence,ranked:o}}function d(l,t){return l.length>t?`${l.slice(0,t)}\u2026`:l}var x=.1,A=12;async function E(l,t,i={}){let o=i.minRelevant??.6,e=f(l,t).filter(n=>n.relevance>=x).slice(0,A),s=e.map(n=>({name:n.skill.frontmatter.name,lexical:n.relevance}));if(e.length===0)return{skill:null,anyRelevant:0,confidence:0,shortlist:s,judged:!1,reason:"no skill mentions anything in this task"};if(e.length===1)return{skill:e[0].skill,anyRelevant:e[0].relevance,confidence:e[0].relevance,shortlist:s,judged:!1,reason:`only ${e[0].skill.frontmatter.name} matched (${e[0].matchReason})`};let r=e.map(n=>({name:n.skill.frontmatter.name,description:n.skill.frontmatter.description,category:n.skill.frontmatter.category??null,tags:n.skill.frontmatter.tags})),m=await S(p,y({task:t,agent:i.agent??null,candidates:r}),b(r),{incumbent:{best:r[0].name},features:{agent:i.agent??"unknown",candidates:r.length}});if(!m)return{skill:e[0].skill,anyRelevant:e[0].relevance,confidence:e[0].relevance,shortlist:s,judged:!1,reason:`seat off \u2014 lexical top match (${e[0].matchReason})`};let a=v(m.answers),c=s.map(n=>({...n,p:a.ranked.find(k=>k.name===n.name)?.p??0})).sort((n,k)=>(k.p??0)-(n.p??0));if(a.anyRelevant<o)return{skill:null,anyRelevant:a.anyRelevant,confidence:a.confidence,shortlist:c,judged:!0,reason:`nothing on the shortlist is about this task (${a.anyRelevant.toFixed(2)} below ${o})`};let u=e.find(n=>n.skill.frontmatter.name===a.name);return u?{skill:u.skill,anyRelevant:a.anyRelevant,confidence:a.confidence,shortlist:c,judged:!0,reason:`${a.name} (confidence ${a.confidence.toFixed(2)})`}:{skill:null,anyRelevant:a.anyRelevant,confidence:a.confidence,shortlist:c,judged:!0,reason:`seat chose "${a.name}", which was not on the shortlist`}}export{E as pickSkillForTask};
|
|
2
|
+
//# sourceMappingURL=select-4XYRIZ5L.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a,b,c,d}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=surface-usage-
|
|
1
|
+
import{a,b,c,d}from"./chunk-Z3IP66SL.js";import"./chunk-N6EWZGIX.js";import"./chunk-FIOB3MEX.js";export{c as commandPath,b as listSurfaceUse,a as recordSurfaceUse,d as shouldRecordCommand};
|
|
2
|
+
//# sourceMappingURL=surface-usage-V2BX4SBD.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as p}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=tool-
|
|
1
|
+
import{b as p}from"./chunk-4TITGMPX.js";import"./chunk-RKPAVWXF.js";import"./chunk-5XQCGPQJ.js";import"./chunk-B5XHX44Y.js";import"./chunk-NLZD2QKF.js";import"./chunk-ZTEU5JVQ.js";import"./chunk-L2WSPY6S.js";import"./chunk-P2ZYT5D6.js";import"./chunk-FIOB3MEX.js";var f=new Set(["cron","heartbeat","api","a2a","mesh","approvals"]);function u(t){return typeof t=="string"?t.trim():""}async function y(t,i){let c=i.fetch??fetch,d=i.daemonUrl.replace(/\/$/,""),s=(u(t.action)||"create").toLowerCase(),r=p(t,i.env??process.env);if(s==="status"){let o=u(t.id);if(!o)return"Error: `id` is required for status (the card id you got when you raised it).";try{let n=await c(`${d}/approvals/${encodeURIComponent(o)}`,{signal:AbortSignal.timeout(1e4)}),a=await n.json().catch(()=>({}));if(!n.ok)return`Error: ${a?.error||`HTTP ${n.status}`}`;let e=a.card;return r&&e.raised_by!==r.agentId?`Error: card "${o}" was raised by another agent.`:e.status==="pending"?`Card ${e.id} is still waiting for the operator. It expires ${e.expires}; then "${e.if_silent}" applies.`:e.status==="decided"?`Card ${e.id}: the operator said ${String(e.verdict).toUpperCase()}.${e.note?` Note: ${e.note}`:""}`:`Card ${e.id} expired unanswered; the default applied: ${e.outcome??e.if_silent}.`}catch(n){return`Error: couldn't reach the daemon (${n?.message??n}).`}}if(s!=="create")return`Error: unknown action "${s}". Use create or status.`;if(!r)return"Error: couldn't tell which agent you are. Pass callerAgentId.";let l=r.channel&&r.chatId&&!f.has(r.channel)?{channel:r.channel,chatId:r.chatId,...r.accountId?{accountId:r.accountId}:{}}:void 0,h={title:t.title,ask:t.ask,recommend:t.recommend,if_silent:t.if_silent,expires:t.expires,source:t.source,raised_by:r.agentId,...l?{reply:l}:{}};try{let o=await c(`${d}/approvals`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(h),signal:AbortSignal.timeout(1e4)}),n=await o.json().catch(()=>({}));if(!o.ok)return`Error: ${n?.error||`HTTP ${o.status}`}`;let a=n.card;return[`Decision card ${a.id} is in the operator's Approvals inbox.`,`If nobody answers by ${a.expires}, "${a.if_silent}" applies.`,"You will get a message with the result. Tell the requester it is waiting for approval; don't ask the operator again in chat."].join(" ")}catch(o){return`Error: couldn't reach the daemon (${o?.message??o}).`}}export{y as runApprovalTool};
|
|
2
|
+
//# sourceMappingURL=tool-PAQ47HV2.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import"./chunk-VWTBHLMX.js";import{a as b}from"./chunk-IXUEJBHD.js";import{e as a}from"./chunk-JVNFRS26.js";import"./chunk-PNWNVOEZ.js";import"./chunk-64P4QHSZ.js";import{a as c}from"./chunk-QDE75R4U.js";import"./chunk-AJ5RMU7X.js";import"./chunk-2GIDVZ4H.js";import"./chunk-4NBWF4TL.js";import"./chunk-F4HZTZHW.js";import"./chunk-AJONZWLT.js";import"./chunk-ZTEU5JVQ.js";import"./chunk-QOYAX2FT.js";import"./chunk-LCIREYTD.js";import"./chunk-L2WSPY6S.js";import"./chunk-P2ZYT5D6.js";import"./chunk-BH3GTCZ6.js";import"./chunk-FIOB3MEX.js";export{b as WikiHub,a as WikiStore,c as agenticQuery};
|
|
2
|
+
//# sourceMappingURL=wiki-EREMPSAE.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agentix-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.50.0",
|
|
4
4
|
"description": "AI operations layer for small and medium businesses. Routes Telegram, WhatsApp, GitLab, GitHub, crons, webhooks, and mesh tasks to AI agents. Web wizard for operators, CLI for engineers. Self-hosted.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|