agentix-cli 0.18.0 → 0.20.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 +75 -27
- package/dist/{agent-RDVGL2TW.js → agent-57MG4LBM.js} +2 -2
- package/dist/{audit-Z47AQFFD.js → audit-JU3HWISB.js} +2 -2
- package/dist/{board-dashboard-KX2CNOSY.js → board-dashboard-HXDOYGIG.js} +2237 -69
- package/dist/board-dashboard-HXDOYGIG.js.map +1 -0
- package/dist/chunk-23AUU4S2.js +102 -0
- package/dist/chunk-23AUU4S2.js.map +1 -0
- package/dist/chunk-4MREHZP5.js +111 -0
- package/dist/chunk-4MREHZP5.js.map +1 -0
- package/dist/chunk-4YCH6IZV.js +2 -0
- package/dist/chunk-6B74TO2J.js +743 -0
- package/dist/chunk-6B74TO2J.js.map +1 -0
- package/dist/chunk-7GVXCOLO.js +440 -0
- package/dist/chunk-7GVXCOLO.js.map +1 -0
- package/dist/chunk-7P5QRX5W.js +108 -0
- package/dist/chunk-7P5QRX5W.js.map +1 -0
- package/dist/chunk-A6BKSZQA.js +3 -0
- package/dist/chunk-A6BKSZQA.js.map +1 -0
- package/dist/{chunk-6PPIFDOQ.js → chunk-CNNLREHD.js} +67 -22
- package/dist/{chunk-6PPIFDOQ.js.map → chunk-CNNLREHD.js.map} +1 -1
- package/dist/{chunk-J4WKMKTP.js → chunk-DLVOHCTA.js} +2 -2
- package/dist/chunk-E4ZZILAK.js +15 -0
- package/dist/chunk-E4ZZILAK.js.map +1 -0
- package/dist/{chunk-TRQSP67X.js → chunk-IKBHHTIT.js} +2 -2
- package/dist/chunk-JTJIPNXY.js +2 -0
- package/dist/chunk-JTJIPNXY.js.map +1 -0
- package/dist/chunk-MBOLXKA2.js +6 -0
- package/dist/chunk-MBOLXKA2.js.map +1 -0
- package/dist/{inbox-O5UB3YQN.js → chunk-MTRWXRFF.js} +69 -4
- package/dist/chunk-MTRWXRFF.js.map +1 -0
- package/dist/{processes-7W27G3J3.js → chunk-NOF4HSGK.js} +3 -3
- package/dist/{processes-7W27G3J3.js.map → chunk-NOF4HSGK.js.map} +1 -1
- package/dist/chunk-QW2OYR3N.js +7 -0
- package/dist/chunk-QW2OYR3N.js.map +1 -0
- package/dist/{chunk-JXEPJ3YD.js → chunk-TC3BSUP7.js} +5 -5
- package/dist/chunk-VWTBHLMX.js +1 -0
- package/dist/chunk-WFHIIVLL.js +719 -0
- package/dist/chunk-WFHIIVLL.js.map +1 -0
- package/dist/chunk-WPPUOTY6.js +6 -0
- package/dist/chunk-WPPUOTY6.js.map +1 -0
- package/dist/cli.js +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/{compaction-S5H6DTOR.js → compaction-BTUJJ3LJ.js} +4 -4
- package/dist/config-QXWKEQON.js +2 -0
- package/dist/config-mutator-53XGR2NT.js +2 -0
- package/dist/conflict-detector-D7VIYPDI.js +2 -0
- package/dist/conflict-detector-D7VIYPDI.js.map +1 -0
- package/dist/{context-planner-2RGHJHSO.js → context-planner-I7ID7XF3.js} +3 -3
- package/dist/debug-N3B5NVJU.js +2 -0
- package/dist/{discover-OATU7SHI.js → discover-XJXQXXIO.js} +2 -2
- package/dist/doctor-SEOUFHSL.js +2 -0
- package/dist/{editor-chat-FUBQLMAQ.js → editor-chat-RVLCKKB7.js} +2 -2
- package/dist/{heal-YP7QI7D3.js → heal-YEQYWX2L.js} +2 -2
- package/dist/inbox-BIN2S5XN.js +2 -0
- package/dist/index.d.ts +830 -100
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/{ingest-whatsapp-C3O5UPBX.js → ingest-whatsapp-LZE62INA.js} +2 -2
- package/dist/loader-5CA3O5GM.js +2 -0
- package/dist/loader-6IHUCPVO.js +2 -0
- package/dist/memory-extract-KRCHD3OP.js +2 -0
- package/dist/migrate-v2-QO7SLKIM.js +4 -0
- package/dist/migrate-v2-QO7SLKIM.js.map +1 -0
- package/dist/processes-RJ6RDP32.js +2 -0
- package/dist/program-WWCXMRU2.js +2 -0
- package/dist/{providers-WCQSKTNP.js → providers-WVCMIW67.js} +2 -2
- package/dist/query-HZYYRCLU.js +2 -0
- package/dist/recipes-EPLE2SNT.js +2 -0
- package/dist/registry-HM4ELSXS.js +2 -0
- package/dist/rotation-memo-GMTZPMNE.js +13 -0
- package/dist/rotation-memo-GMTZPMNE.js.map +1 -0
- package/dist/scheduler-XVFIK4XH.js +2 -0
- package/dist/{slack-D27BE37Q.js → slack-6P7ZJ32Y.js} +2 -2
- package/dist/store-BAPDZHXE.js +2 -0
- package/dist/{subagent-EPOT3QDM.js → subagent-WV7QKQ3L.js} +2 -2
- package/dist/{task-store-3NUWLYRY.js → task-store-RHISEU6V.js} +2 -2
- package/dist/{telegram-UWV67KWG.js → telegram-PIYDRM46.js} +2 -2
- package/dist/timers-5LPZN55J.js +2 -0
- package/dist/types-VECTMYTO.js +2 -0
- package/dist/types-VECTMYTO.js.map +1 -0
- package/dist/types-ZRLHHCGB.js +2 -0
- package/dist/types-ZRLHHCGB.js.map +1 -0
- package/dist/web/activity-graph.global.js +654 -0
- package/dist/web/activity-graph.global.js.map +1 -0
- package/dist/web/workflow-editor.global.js +1 -1
- package/dist/web/workflow-editor.global.js.map +1 -1
- package/dist/{whatsapp-KJ2NRKKQ.js → whatsapp-PFRDMUMT.js} +2 -2
- package/dist/{whatsapp-state-3ZVQ6MQD.js → whatsapp-state-XMTCSRXU.js} +2 -2
- package/dist/wiki-53W5NLZV.js +2 -0
- package/dist/wiki-53W5NLZV.js.map +1 -0
- package/dist/workspace-setup-FPGN5VNY.js +2 -0
- package/dist/workspace-setup-FPGN5VNY.js.map +1 -0
- package/package.json +3 -2
- package/dist/board-dashboard-KX2CNOSY.js.map +0 -1
- package/dist/chunk-34NG7UDX.js +0 -11
- package/dist/chunk-34NG7UDX.js.map +0 -1
- package/dist/chunk-ASSJ4Z6Z.js +0 -164
- package/dist/chunk-ASSJ4Z6Z.js.map +0 -1
- package/dist/chunk-BLUXL6HR.js +0 -854
- package/dist/chunk-BLUXL6HR.js.map +0 -1
- package/dist/chunk-BTAEYL3P.js +0 -72
- package/dist/chunk-BTAEYL3P.js.map +0 -1
- package/dist/chunk-DSCMCVTV.js +0 -7
- package/dist/chunk-DSCMCVTV.js.map +0 -1
- package/dist/chunk-HPDHNIA3.js +0 -2
- package/dist/chunk-IM376SD6.js +0 -13
- package/dist/chunk-IM376SD6.js.map +0 -1
- package/dist/chunk-LEIYC3BF.js +0 -104
- package/dist/chunk-LEIYC3BF.js.map +0 -1
- package/dist/chunk-LY7JGDV7.js +0 -6
- package/dist/chunk-LY7JGDV7.js.map +0 -1
- package/dist/chunk-U364GNQX.js +0 -719
- package/dist/chunk-U364GNQX.js.map +0 -1
- package/dist/chunk-WZEYII2S.js +0 -6
- package/dist/chunk-WZEYII2S.js.map +0 -1
- package/dist/config-UOHEG4BW.js +0 -2
- package/dist/config-mutator-KSEBWKJH.js +0 -2
- package/dist/debug-TGAP7E7W.js +0 -2
- package/dist/inbox-O5UB3YQN.js.map +0 -1
- package/dist/loader-BGWA7IRY.js +0 -2
- package/dist/loader-LBHKSXBK.js +0 -2
- package/dist/memory-extract-KKPKAOPH.js +0 -2
- package/dist/program-2MDELQLX.js +0 -2
- package/dist/query-FZAL7AQD.js +0 -2
- package/dist/recipes-LZ56TA3X.js +0 -2
- package/dist/registry-ONJSILH4.js +0 -2
- package/dist/scheduler-XRM2RJIV.js +0 -2
- package/dist/store-4UCO56K2.js +0 -2
- package/dist/timers-QB4KYNAE.js +0 -2
- package/dist/types-ECMEC5BZ.js +0 -2
- package/dist/types-TTB6DJUE.js +0 -2
- package/dist/usage-dashboard-FQGPPABD.js +0 -803
- package/dist/usage-dashboard-FQGPPABD.js.map +0 -1
- package/dist/wiki-OUYKM7MB.js +0 -2
- package/dist/workspace-setup-6GDBEORT.js +0 -2
- /package/dist/{agent-RDVGL2TW.js.map → agent-57MG4LBM.js.map} +0 -0
- /package/dist/{audit-Z47AQFFD.js.map → audit-JU3HWISB.js.map} +0 -0
- /package/dist/{chunk-HPDHNIA3.js.map → chunk-4YCH6IZV.js.map} +0 -0
- /package/dist/{chunk-J4WKMKTP.js.map → chunk-DLVOHCTA.js.map} +0 -0
- /package/dist/{chunk-TRQSP67X.js.map → chunk-IKBHHTIT.js.map} +0 -0
- /package/dist/{chunk-JXEPJ3YD.js.map → chunk-TC3BSUP7.js.map} +0 -0
- /package/dist/{config-UOHEG4BW.js.map → chunk-VWTBHLMX.js.map} +0 -0
- /package/dist/{compaction-S5H6DTOR.js.map → compaction-BTUJJ3LJ.js.map} +0 -0
- /package/dist/{config-mutator-KSEBWKJH.js.map → config-QXWKEQON.js.map} +0 -0
- /package/dist/{debug-TGAP7E7W.js.map → config-mutator-53XGR2NT.js.map} +0 -0
- /package/dist/{context-planner-2RGHJHSO.js.map → context-planner-I7ID7XF3.js.map} +0 -0
- /package/dist/{heal-YP7QI7D3.js.map → debug-N3B5NVJU.js.map} +0 -0
- /package/dist/{discover-OATU7SHI.js.map → discover-XJXQXXIO.js.map} +0 -0
- /package/dist/{loader-BGWA7IRY.js.map → doctor-SEOUFHSL.js.map} +0 -0
- /package/dist/{editor-chat-FUBQLMAQ.js.map → editor-chat-RVLCKKB7.js.map} +0 -0
- /package/dist/{loader-LBHKSXBK.js.map → heal-YEQYWX2L.js.map} +0 -0
- /package/dist/{memory-extract-KKPKAOPH.js.map → inbox-BIN2S5XN.js.map} +0 -0
- /package/dist/{ingest-whatsapp-C3O5UPBX.js.map → ingest-whatsapp-LZE62INA.js.map} +0 -0
- /package/dist/{program-2MDELQLX.js.map → loader-5CA3O5GM.js.map} +0 -0
- /package/dist/{providers-WCQSKTNP.js.map → loader-6IHUCPVO.js.map} +0 -0
- /package/dist/{query-FZAL7AQD.js.map → memory-extract-KRCHD3OP.js.map} +0 -0
- /package/dist/{recipes-LZ56TA3X.js.map → processes-RJ6RDP32.js.map} +0 -0
- /package/dist/{registry-ONJSILH4.js.map → program-WWCXMRU2.js.map} +0 -0
- /package/dist/{scheduler-XRM2RJIV.js.map → providers-WVCMIW67.js.map} +0 -0
- /package/dist/{store-4UCO56K2.js.map → query-HZYYRCLU.js.map} +0 -0
- /package/dist/{task-store-3NUWLYRY.js.map → recipes-EPLE2SNT.js.map} +0 -0
- /package/dist/{timers-QB4KYNAE.js.map → registry-HM4ELSXS.js.map} +0 -0
- /package/dist/{types-ECMEC5BZ.js.map → scheduler-XVFIK4XH.js.map} +0 -0
- /package/dist/{slack-D27BE37Q.js.map → slack-6P7ZJ32Y.js.map} +0 -0
- /package/dist/{types-TTB6DJUE.js.map → store-BAPDZHXE.js.map} +0 -0
- /package/dist/{subagent-EPOT3QDM.js.map → subagent-WV7QKQ3L.js.map} +0 -0
- /package/dist/{wiki-OUYKM7MB.js.map → task-store-RHISEU6V.js.map} +0 -0
- /package/dist/{telegram-UWV67KWG.js.map → telegram-PIYDRM46.js.map} +0 -0
- /package/dist/{workspace-setup-6GDBEORT.js.map → timers-5LPZN55J.js.map} +0 -0
- /package/dist/{whatsapp-KJ2NRKKQ.js.map → whatsapp-PFRDMUMT.js.map} +0 -0
- /package/dist/{whatsapp-state-3ZVQ6MQD.js.map → whatsapp-state-XMTCSRXU.js.map} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import"./chunk-
|
|
1
|
+
import"./chunk-4YCH6IZV.js";import{createHash as C}from"crypto";function $(e,n){if(!e.enabled)return[];let t=n.listContacts(),d=n.listChats(),i=[],a=r=>r.replace(/^\+/,"").toLowerCase(),s=e.allowContacts.map(a),o=e.allowGroups.map(a),c=e.denyContacts.map(a),u=e.denyGroups.map(a),m=(r,g)=>{if(g.length===0)return!1;let f=a(r);return g.some(p=>f.includes(p)||p.includes(f))};for(let r of t){let g=`${r.phone}|${r.jid}`;if(m(g,c)||!m(g,s))continue;let f=d.find(p=>!p.isGroup&&p.jid===r.jid);i.push({kind:"contact",jid:r.jid,contact:r,chat:f})}for(let r of d)r.isGroup&&(m(r.jid,u)||m(r.jid,o)&&i.push({kind:"group",jid:r.jid,chat:r}));return i}var h=(e=new Date)=>e.toISOString().slice(0,10),l=(e=new Date)=>h(e).replace(/-/g,"");function w(e){return C("sha1").update(e).digest("hex").slice(0,10)}function R(e,n,t=new Date){let d=h(t),i=`wa-contact-${w(e.jid)}-${l(t)}`,s=[`# Contact: ${e.savedName||e.pushName||e.phone||e.jid}`,""];return s.push(`- **JID**: ${e.jid}`),e.phone&&s.push(`- **Phone**: +${e.phone}`),e.savedName&&s.push(`- **Saved name**: ${e.savedName}`),e.pushName&&e.pushName!==e.savedName&&s.push(`- **Push name**: ${e.pushName}`),e.status&&s.push(`- **Status**: ${e.status}`),e.updatedAt&&s.push(`- **Last observed**: ${e.updatedAt}`),{id:i,date:d,agentId:n,source:"whatsapp:contact",sourceContext:e.jid,content:s.join(`
|
|
2
2
|
`),meta:{jid:e.jid,phone:e.phone,kind:"contact",profileHash:x(e)}}}function k(e,n,t=new Date){let d=h(t),i=`wa-group-meta-${w(e.jid)}-${l(t)}`,a=[`# Group: ${e.subject||"(unnamed)"}`,""];a.push(`- **JID**: ${e.jid}`),e.description&&a.push(`- **Description**: ${e.description}`),e.owner&&a.push(`- **Owner**: ${e.owner}`),a.push(`- **Members (${e.memberCount})**:`);let s=e.members.slice(0,50);for(let o of s){let c=o.admin?` (${o.admin})`:"";a.push(` - ${o.jid}${c}`)}return e.members.length>s.length&&a.push(` - \u2026and ${e.members.length-s.length} more`),{id:i,date:d,agentId:n,source:"whatsapp:group-meta",sourceContext:e.jid,content:a.join(`
|
|
3
3
|
`),meta:{jid:e.jid,subject:e.subject,memberCount:e.memberCount,kind:"group-meta"}}}function D(e,n,t,d,i=new Date){if(t.length===0)return null;let a=t[t.length-1].id,s=h(i),o=`wa-dm-${w(e.jid)}-${l(i)}-${b(a)}`,c=n?.savedName||n?.pushName||e.name||e.jid,u=[`# Chat with ${c}`,""];u.push(`- **JID**: ${e.jid}`),n?.phone&&u.push(`- **Phone**: +${n.phone}`),u.push(`- **Messages**: ${t.length}`),u.push("");for(let m of t)u.push(y(m,c));return{id:o,date:s,agentId:d,source:"whatsapp:dm",sourceContext:e.jid,content:u.join(`
|
|
4
4
|
`),meta:{jid:e.jid,kind:"dm",messageCount:t.length,oldestMsgTs:t[0]?.timestamp,newestMsgTs:t[t.length-1]?.timestamp,lastMsgId:a}}}function M(e,n,t,d,i=new Date){if(t.length===0)return null;let a=t[t.length-1].id,s=h(i),o=`wa-group-${w(e.jid)}-${l(i)}-${b(a)}`,c=[`# Group chat: ${n.subject||e.name}`,""];c.push(`- **JID**: ${e.jid}`),c.push(`- **Members**: ${n.memberCount}`),c.push(`- **Messages**: ${t.length}`),c.push("");for(let u of t)c.push(y(u,u.fromJid));return{id:o,date:s,agentId:d,source:"whatsapp:group",sourceContext:e.jid,content:c.join(`
|
|
5
5
|
`),meta:{jid:e.jid,kind:"group",messageCount:t.length,lastMsgId:a}}}function y(e,n){let t=e.timestamp?G(e.timestamp):"",d=e.fromMe?"me":n,i=e.text;return!i&&e.media&&(e.media.kind==="image"?i=`[image${e.media.caption?`: ${e.media.caption}`:""}]`:e.media.kind==="audio"?i="[voice message]":e.media.kind==="video"?i=`[video${e.media.caption?`: ${e.media.caption}`:""}]`:e.media.kind==="document"?i=`[document: ${e.media.filename??"unnamed"}]`:e.media.kind==="sticker"&&(i="[sticker]")),`[${t}] ${d}: ${i}`}function G(e){try{return new Date(e*1e3).toISOString().replace("T"," ").slice(0,16)}catch{return String(e)}}function b(e){return e.replace(/[^A-Za-z0-9]/g,"").slice(-10)}function x(e){let n=C("sha1");return n.update(e.jid),n.update("|"),n.update(e.savedName||""),n.update("|"),n.update(e.pushName||""),n.update("|"),n.update(e.status||""),n.digest("hex").slice(0,10)}async function I(e){let n=e.now??new Date,t={scannedContacts:0,scannedGroups:0,wroteContacts:0,wroteGroups:0,wroteDmWindows:0,wroteGroupWindows:0,skippedUnchanged:0,errors:[]},d=[],i=s=>{if(e.dryRun){d.push(s);return}e.store.addEntry(s)};if(!e.source.isConnected()&&!e.dryRun)return t.errors.push({jid:"-",kind:"source",message:"WhatsApp socket not connected"}),{...t,dryRunEntries:e.dryRun?d:void 0};let a=$(e.config,e.source);a.length>e.config.throttle.maxChatsPerSweep&&(a=a.slice(0,e.config.throttle.maxChatsPerSweep));for(let s of a)try{if(s.kind==="contact"){t.scannedContacts++;let o=s.contact??await e.source.getContactProfile(s.jid);if(!o)continue;let c=R(o,e.agentId,n);if(i(c),t.wroteContacts++,e.config.mode==="messages"){let u=await e.source.getHistory(s.jid,{limit:e.config.messageCap}),m=j(u,e.config.historyDays,n);if(m.length>0&&s.chat){let r=D(s.chat,o,m,e.agentId,n);r&&(i(r),t.wroteDmWindows++)}}}else{t.scannedGroups++;let o=await e.source.getGroupMetadata(s.jid);if(!o)continue;let c=k(o,e.agentId,n);if(i(c),t.wroteGroups++,e.config.mode==="messages"&&s.chat){let u=await e.source.getHistory(s.jid,{limit:e.config.messageCap}),m=j(u,e.config.historyDays,n);if(m.length>0){let r=M(s.chat,o,m,e.agentId,n);r&&(i(r),t.wroteGroupWindows++)}}}}catch(o){t.errors.push({jid:s.jid,kind:s.kind,message:o?.message??String(o)})}return{...t,dryRunEntries:e.dryRun?d:void 0}}function j(e,n,t){let d=Math.floor((t.getTime()-n*864e5)/1e3);return e.filter(i=>!i.timestamp||i.timestamp>=d)}export{x as hashProfile,$ as resolveScope,I as runSweep,R as transformContact,D as transformDm,M as transformGroupMessages,k as transformGroupMeta};
|
|
6
|
-
//# sourceMappingURL=ingest-whatsapp-
|
|
6
|
+
//# sourceMappingURL=ingest-whatsapp-LZE62INA.js.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{b as g,d as l}from"./chunk-JTJIPNXY.js";import"./chunk-4YCH6IZV.js";import{readFileSync as m,writeFileSync as y,existsSync as v,copyFileSync as f}from"fs";import{join as _}from"path";var w=new Set(["code","ops","support","admin","knowledge","social","system"]),x=[{test:/\b(review[-_.]?(merge[-_.]?request|mr|pull[-_.]?request|pr))\b/i,category:"code",verb:"review.merge-request"},{test:/\breview[-_.]?(code|change|diff|snippet)\b/i,category:"code",verb:"review.code-change"},{test:/\b(fix|patch)[-_.]/i,category:"code",verb:"fix.bug"},{test:/\b(implement|build|add)[-_.]?(feature|cli|api|endpoint)\b/i,category:"code",verb:"implement.feature"},{test:/\bimplement[-_.]/i,category:"code",verb:"implement.feature"},{test:/\b(debug|investigate)[-_.]/i,category:"code",verb:"investigate.error"},{test:/\brefactor\b/i,category:"code",verb:"refactor.code"},{test:/\b(plan|spec|rfc|design)[-_.]/i,category:"code",verb:"spec.feature"},{test:/\b(handle|triage)[-_.]?(github|gitlab)?[-_.]?(issue|push|pr|mr|webhook|comment)\b/i,category:"code",verb:"triage.issue"},{test:/\btriage[-_.]?(issue|ticket)?\b/i,category:"code",verb:"triage.issue"},{test:/\banswer[-_.]?(code[-_.]?question|technical[-_.]?question)\b/i,category:"code",verb:"answer.code-question"},{test:/\b(commit|push|checkout|sync|merge)[-_.]/i,category:"code",verb:"refactor.code"},{test:/\bauthor[-_.]?(workflow|spec|rfc)\b/i,category:"code",verb:"spec.feature"},{test:/\bdeploy[-_.]?(staging|preview|qa|test)\b/i,category:"ops",verb:"deploy.staging"},{test:/\bdeploy[-_.]?(prod|production|live|release)\b/i,category:"ops",verb:"deploy.production"},{test:/\bdeploy[-_.]/i,category:"ops",verb:"deploy.staging"},{test:/\brollback\b/i,category:"ops",verb:"rollback.release"},{test:/\binvestigate[-_.]?incident\b/i,category:"ops",verb:"investigate.incident"},{test:/\b(monitor|status|health[-_.]?check|metrics)\b/i,category:"ops",verb:"monitor.system"},{test:/\b(restart|stop|start)[-_.]?(daemon|service|server)\b/i,category:"ops",verb:"monitor.system"},{test:/\brun[-_.]?(server|infra)?[-_.]?(security|audit)\b/i,category:"ops",verb:"audit.security"},{test:/\brotate[-_.]?(token|tokens|credential|credentials|key|cert|secret)s?\b/i,category:"ops",verb:"rotate.credential"},{test:/\baudit\b/i,category:"ops",verb:"audit.security"},{test:/\bsetup[-_.]/i,category:"ops",verb:"monitor.system"},{test:/\b(greet(ing)?|hello|hi[-_.]?there)\b/i,category:"support",verb:"chat.greeting"},{test:/\b(support[-_.]?request|help[-_.]?request|customer[-_.]?question)\b/i,category:"support",verb:"chat.support-request"},{test:/\b(casual|chitchat|smalltalk)\b/i,category:"support",verb:"chat.casual"},{test:/\b(query|ask|clarify|confirm)[-_.]/i,category:"support",verb:"answer.question"},{test:/\b(reply|respond)[-_.]/i,category:"support",verb:"route.request"},{test:/\banswer[-_.]?question\b/i,category:"support",verb:"answer.question"},{test:/\broute[-_.]?(request|message|to[-_.]?agent)\b/i,category:"support",verb:"route.request"},{test:/\bconfig[-_.]?(change|update|edit)?\b/i,category:"admin",verb:"config.change"},{test:/\bconfigure[-_.]/i,category:"admin",verb:"config.change"},{test:/\b(schedule|cron)[-_.]?(add|create|new)\b/i,category:"admin",verb:"schedule.add"},{test:/\b(reminder|remind)\b/i,category:"admin",verb:"schedule.add"},{test:/\b(schedule|cron)[-_.]?(remove|delete|disable)\b/i,category:"admin",verb:"schedule.remove"},{test:/\b(provide|assign|copy)[-_.]?(token|tokens|credential|credentials|cert|secret)s?\b/i,category:"admin",verb:"token.create"},{test:/\b(token[-_.]?(create|mint|issue)|mint[-_.]?token)\b/i,category:"admin",verb:"token.create"},{test:/\bagent[-_.]?(add|onboard|new|configure)\b/i,category:"admin",verb:"agent.add"},{test:/\bchannel[-_.]?(add|wire|new|configure)\b/i,category:"admin",verb:"channel.add"},{test:/\bauthorize[-_.]/i,category:"admin",verb:"config.change"},{test:/\bcorrect[-_.]/i,category:"admin",verb:"config.change"},{test:/\b(document|docs|readme|wiki[-_.]?write)\b/i,category:"knowledge",verb:"document.feature"},{test:/\bsummariz?e\b/i,category:"knowledge",verb:"summarize.thread"},{test:/\b(research|analyze|compare|investigate[-_.]?repo)\b/i,category:"knowledge",verb:"research.topic"},{test:/\bwiki[-_.]?(absorb|ingest|import|run)\b/i,category:"knowledge",verb:"wiki.absorb"},{test:/\bcompile[-_.]?(brief|report|digest)\b/i,category:"knowledge",verb:"summarize.thread"},{test:/\b(daily[-_.]?brief|brief[-_.]?daily|morning[-_.]?digest)\b/i,category:"social",verb:"brief.daily"},{test:/\b(draft[-_.]?(social|post|tweet|announcement|blog|article)|social[-_.]?post)\b/i,category:"social",verb:"draft.post"},{test:/\bcreate[-_.]?(blog|article|post)\b/i,category:"social",verb:"draft.post"},{test:/\bcompile[-_.]?(marketing|social)\b/i,category:"social",verb:"brief.daily"},{test:/\b(weekly[-_.]?report|report[-_.]?weekly|status[-_.]?report)\b/i,category:"social",verb:"report.weekly"},{test:/\b(classify[-_.]?intent|graph[-_.]?classify)\b/i,category:"system",verb:"classify.intent"}];function q(i,n={}){let c=n.log??console.error.bind(console,"[graph-migrate]"),s=i.baseDir,e={indexRemapped:0,indexSkippedV2:0,indexUnmapped:0,jsonlRemapped:0,jsonlSkippedV2:0,jsonlUnmapped:0,backups:[],patternHits:{}},b=_(s,"index.json");if(v(b)){let u=m(b,"utf-8"),d=l.parse(JSON.parse(u)),r={version:d.version,entries:{}};for(let[t,o]of Object.entries(d.entries)){let a=h(o.path,e.patternHits);if(a==="v2"){r.entries[t]=o,e.indexSkippedV2++;continue}if(a===null){r.entries[t]=o,e.indexUnmapped++;continue}r.entries[t]={...o,path:a,updatedAt:new Date().toISOString()},e.indexRemapped++}if(!n.dryRun){let t=`${b}.v1.bak.${Date.now()}.json`;f(b,t),e.backups.push(t),y(b,JSON.stringify(r,null,2),"utf-8")}}let p=_(s,"classifications.jsonl");if(v(p)){let d=m(p,"utf-8").split(`
|
|
2
|
+
`),r=[];for(let t of d){if(!t.trim()){r.push(t);continue}let o;try{o=g.parse(JSON.parse(t))}catch{r.push(t);continue}let a=h(o.path,e.patternHits);if(a==="v2"){e.jsonlSkippedV2++,r.push(t);continue}if(a===null){e.jsonlUnmapped++,r.push(t);continue}let k={...o,path:a,proposedAxes:{}};r.push(JSON.stringify(k)),e.jsonlRemapped++}if(!n.dryRun){let t=`${p}.v1.bak.${Date.now()}.jsonl`;f(p,t),e.backups.push(t),y(p,r.join(`
|
|
3
|
+
`),"utf-8")}}return c(`index: ${e.indexRemapped} remapped, ${e.indexSkippedV2} already v2, ${e.indexUnmapped} unmapped`),c(`jsonl: ${e.jsonlRemapped} remapped, ${e.jsonlSkippedV2} already v2, ${e.jsonlUnmapped} unmapped`),n.dryRun?c("(dry-run \u2014 no files written)"):c(`backups: ${e.backups.join(", ")}`),e}function h(i,n){if(!Array.isArray(i)||i.length===0)return null;if(w.has(i[0]))return"v2";let c=`${i.join(" ")} ${i[i.length-1]??""}`;for(let s of x)if(s.test.test(c))return n[s.verb]=(n[s.verb]??0)+1,[s.category,s.verb];return null}export{q as migrateV2};
|
|
4
|
+
//# sourceMappingURL=migrate-v2-QO7SLKIM.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/graph/migrate-v2.ts"],"sourcesContent":["import { readFileSync, writeFileSync, existsSync, copyFileSync } from \"fs\"\nimport { join } from \"path\"\nimport type { GraphStore } from \"./store\"\nimport { type IndexFile, indexFileSchema, type Classification, classificationSchema } from \"./types\"\n\n// --- Phase 2 of classifier-retire — bulk remap of past classifications ---\n//\n// The Phase 1 schema migration auto-converts schema.json + nodes.json from\n// v1 (scope/location/org/unit/activity) → v2 (category/verb). It does NOT\n// touch the two stores that hold real classification history:\n//\n// classifications.jsonl — append-only audit log of every decision\n// index.json — fingerprint → path cache used at hot-path\n//\n// Without remapping those, every recurring message keeps hitting the cache\n// and resolving to a v1 path that no longer exists in nodes.json. The UI\n// then renders raw ids (\"activity-rotate-tokens\") instead of the verb\n// label (\"Rotate credential\"). This module rewrites them in-place via\n// keyword heuristics — no LLM calls, no paid path.\n//\n// Idempotent: re-running on already-v2 data is a no-op.\n\nconst CATEGORY_SET = new Set([\n \"code\", \"ops\", \"support\", \"admin\", \"knowledge\", \"social\", \"system\",\n])\n\n/** Best-effort keyword mapping from a v1 leaf slug to a v2 (category, verb)\n * pair. Patterns are checked in order; first match wins. Anything that\n * doesn't hit a pattern is left alone (the next live classification will\n * re-classify the fingerprint with the new prompt). */\nconst PATTERNS: Array<{ test: RegExp; category: string; verb: string }> = [\n // --- code ---\n { test: /\\b(review[-_.]?(merge[-_.]?request|mr|pull[-_.]?request|pr))\\b/i, category: \"code\", verb: \"review.merge-request\" },\n { test: /\\breview[-_.]?(code|change|diff|snippet)\\b/i, category: \"code\", verb: \"review.code-change\" },\n { test: /\\b(fix|patch)[-_.]/i, category: \"code\", verb: \"fix.bug\" },\n { test: /\\b(implement|build|add)[-_.]?(feature|cli|api|endpoint)\\b/i, category: \"code\", verb: \"implement.feature\" },\n { test: /\\bimplement[-_.]/i, category: \"code\", verb: \"implement.feature\" },\n { test: /\\b(debug|investigate)[-_.]/i, category: \"code\", verb: \"investigate.error\" },\n { test: /\\brefactor\\b/i, category: \"code\", verb: \"refactor.code\" },\n { test: /\\b(plan|spec|rfc|design)[-_.]/i, category: \"code\", verb: \"spec.feature\" },\n { test: /\\b(handle|triage)[-_.]?(github|gitlab)?[-_.]?(issue|push|pr|mr|webhook|comment)\\b/i, category: \"code\", verb: \"triage.issue\" },\n { test: /\\btriage[-_.]?(issue|ticket)?\\b/i, category: \"code\", verb: \"triage.issue\" },\n { test: /\\banswer[-_.]?(code[-_.]?question|technical[-_.]?question)\\b/i, category: \"code\", verb: \"answer.code-question\" },\n { test: /\\b(commit|push|checkout|sync|merge)[-_.]/i, category: \"code\", verb: \"refactor.code\" },\n { test: /\\bauthor[-_.]?(workflow|spec|rfc)\\b/i, category: \"code\", verb: \"spec.feature\" },\n\n // --- ops ---\n { test: /\\bdeploy[-_.]?(staging|preview|qa|test)\\b/i, category: \"ops\", verb: \"deploy.staging\" },\n { test: /\\bdeploy[-_.]?(prod|production|live|release)\\b/i, category: \"ops\", verb: \"deploy.production\" },\n { test: /\\bdeploy[-_.]/i, category: \"ops\", verb: \"deploy.staging\" },\n { test: /\\brollback\\b/i, category: \"ops\", verb: \"rollback.release\" },\n { test: /\\binvestigate[-_.]?incident\\b/i, category: \"ops\", verb: \"investigate.incident\" },\n { test: /\\b(monitor|status|health[-_.]?check|metrics)\\b/i, category: \"ops\", verb: \"monitor.system\" },\n { test: /\\b(restart|stop|start)[-_.]?(daemon|service|server)\\b/i, category: \"ops\", verb: \"monitor.system\" },\n { test: /\\brun[-_.]?(server|infra)?[-_.]?(security|audit)\\b/i, category: \"ops\", verb: \"audit.security\" },\n { test: /\\brotate[-_.]?(token|tokens|credential|credentials|key|cert|secret)s?\\b/i, category: \"ops\", verb: \"rotate.credential\" },\n { test: /\\baudit\\b/i, category: \"ops\", verb: \"audit.security\" },\n { test: /\\bsetup[-_.]/i, category: \"ops\", verb: \"monitor.system\" },\n\n // --- support ---\n { test: /\\b(greet(ing)?|hello|hi[-_.]?there)\\b/i, category: \"support\", verb: \"chat.greeting\" },\n { test: /\\b(support[-_.]?request|help[-_.]?request|customer[-_.]?question)\\b/i, category: \"support\", verb: \"chat.support-request\" },\n { test: /\\b(casual|chitchat|smalltalk)\\b/i, category: \"support\", verb: \"chat.casual\" },\n { test: /\\b(query|ask|clarify|confirm)[-_.]/i, category: \"support\", verb: \"answer.question\" },\n { test: /\\b(reply|respond)[-_.]/i, category: \"support\", verb: \"route.request\" },\n { test: /\\banswer[-_.]?question\\b/i, category: \"support\", verb: \"answer.question\" },\n { test: /\\broute[-_.]?(request|message|to[-_.]?agent)\\b/i, category: \"support\", verb: \"route.request\" },\n\n // --- admin ---\n { test: /\\bconfig[-_.]?(change|update|edit)?\\b/i, category: \"admin\", verb: \"config.change\" },\n { test: /\\bconfigure[-_.]/i, category: \"admin\", verb: \"config.change\" },\n { test: /\\b(schedule|cron)[-_.]?(add|create|new)\\b/i, category: \"admin\", verb: \"schedule.add\" },\n { test: /\\b(reminder|remind)\\b/i, category: \"admin\", verb: \"schedule.add\" },\n { test: /\\b(schedule|cron)[-_.]?(remove|delete|disable)\\b/i, category: \"admin\", verb: \"schedule.remove\" },\n { test: /\\b(provide|assign|copy)[-_.]?(token|tokens|credential|credentials|cert|secret)s?\\b/i, category: \"admin\", verb: \"token.create\" },\n { test: /\\b(token[-_.]?(create|mint|issue)|mint[-_.]?token)\\b/i, category: \"admin\", verb: \"token.create\" },\n { test: /\\bagent[-_.]?(add|onboard|new|configure)\\b/i, category: \"admin\", verb: \"agent.add\" },\n { test: /\\bchannel[-_.]?(add|wire|new|configure)\\b/i, category: \"admin\", verb: \"channel.add\" },\n { test: /\\bauthorize[-_.]/i, category: \"admin\", verb: \"config.change\" },\n { test: /\\bcorrect[-_.]/i, category: \"admin\", verb: \"config.change\" },\n\n // --- knowledge ---\n { test: /\\b(document|docs|readme|wiki[-_.]?write)\\b/i, category: \"knowledge\", verb: \"document.feature\" },\n { test: /\\bsummariz?e\\b/i, category: \"knowledge\", verb: \"summarize.thread\" },\n { test: /\\b(research|analyze|compare|investigate[-_.]?repo)\\b/i, category: \"knowledge\", verb: \"research.topic\" },\n { test: /\\bwiki[-_.]?(absorb|ingest|import|run)\\b/i, category: \"knowledge\", verb: \"wiki.absorb\" },\n { test: /\\bcompile[-_.]?(brief|report|digest)\\b/i, category: \"knowledge\", verb: \"summarize.thread\" },\n\n // --- social ---\n { test: /\\b(daily[-_.]?brief|brief[-_.]?daily|morning[-_.]?digest)\\b/i, category: \"social\", verb: \"brief.daily\" },\n { test: /\\b(draft[-_.]?(social|post|tweet|announcement|blog|article)|social[-_.]?post)\\b/i, category: \"social\", verb: \"draft.post\" },\n { test: /\\bcreate[-_.]?(blog|article|post)\\b/i, category: \"social\", verb: \"draft.post\" },\n { test: /\\bcompile[-_.]?(marketing|social)\\b/i, category: \"social\", verb: \"brief.daily\" },\n { test: /\\b(weekly[-_.]?report|report[-_.]?weekly|status[-_.]?report)\\b/i, category: \"social\", verb: \"report.weekly\" },\n\n // --- system ---\n { test: /\\b(classify[-_.]?intent|graph[-_.]?classify)\\b/i, category: \"system\", verb: \"classify.intent\" },\n]\n\nexport interface MigrateOptions {\n /** When true, log the would-be changes and exit without writing. */\n dryRun?: boolean\n log?: (...args: unknown[]) => void\n}\n\nexport interface MigrateResult {\n /** How many fingerprint cache entries we touched. */\n indexRemapped: number\n /** Cache entries already in v2 shape (no change). */\n indexSkippedV2: number\n /** Cache entries we couldn't map (left untouched; will re-classify on next event). */\n indexUnmapped: number\n /** Classification log rows rewritten. */\n jsonlRemapped: number\n jsonlSkippedV2: number\n jsonlUnmapped: number\n /** Backup file paths created. */\n backups: string[]\n /** Per-pattern hit counts, useful for tuning the heuristic. */\n patternHits: Record<string, number>\n}\n\n/** Run the v1 → v2 remap on the given graph store dir. */\nexport function migrateV2(store: GraphStore, opts: MigrateOptions = {}): MigrateResult {\n const log = opts.log ?? console.error.bind(console, \"[graph-migrate]\")\n const baseDir = store.baseDir\n\n const result: MigrateResult = {\n indexRemapped: 0,\n indexSkippedV2: 0,\n indexUnmapped: 0,\n jsonlRemapped: 0,\n jsonlSkippedV2: 0,\n jsonlUnmapped: 0,\n backups: [],\n patternHits: {},\n }\n\n // ----- index.json -----\n const indexPath = join(baseDir, \"index.json\")\n if (existsSync(indexPath)) {\n const raw = readFileSync(indexPath, \"utf-8\")\n const parsed = indexFileSchema.parse(JSON.parse(raw))\n const updated: IndexFile = { version: parsed.version, entries: {} }\n for (const [fp, entry] of Object.entries(parsed.entries)) {\n const remapped = remapPath(entry.path, result.patternHits)\n if (remapped === \"v2\") {\n updated.entries[fp] = entry\n result.indexSkippedV2++\n continue\n }\n if (remapped === null) {\n updated.entries[fp] = entry\n result.indexUnmapped++\n continue\n }\n updated.entries[fp] = {\n ...entry,\n path: remapped,\n updatedAt: new Date().toISOString(),\n }\n result.indexRemapped++\n }\n if (!opts.dryRun) {\n const backup = `${indexPath}.v1.bak.${Date.now()}.json`\n copyFileSync(indexPath, backup)\n result.backups.push(backup)\n writeFileSync(indexPath, JSON.stringify(updated, null, 2), \"utf-8\")\n }\n }\n\n // ----- classifications.jsonl -----\n const jsonlPath = join(baseDir, \"classifications.jsonl\")\n if (existsSync(jsonlPath)) {\n const raw = readFileSync(jsonlPath, \"utf-8\")\n const lines = raw.split(\"\\n\")\n const out: string[] = []\n for (const line of lines) {\n if (!line.trim()) { out.push(line); continue }\n let parsed: Classification\n try {\n parsed = classificationSchema.parse(JSON.parse(line))\n } catch {\n // Pass through anything we can't parse — better to keep the audit\n // log intact than drop unrecognized rows.\n out.push(line)\n continue\n }\n const remapped = remapPath(parsed.path, result.patternHits)\n if (remapped === \"v2\") {\n result.jsonlSkippedV2++\n out.push(line)\n continue\n }\n if (remapped === null) {\n result.jsonlUnmapped++\n out.push(line)\n continue\n }\n const next: Classification = {\n ...parsed,\n path: remapped,\n // Strip v1 axes — they reference nodes that no longer exist post-migration.\n proposedAxes: {},\n }\n out.push(JSON.stringify(next))\n result.jsonlRemapped++\n }\n if (!opts.dryRun) {\n const backup = `${jsonlPath}.v1.bak.${Date.now()}.jsonl`\n copyFileSync(jsonlPath, backup)\n result.backups.push(backup)\n writeFileSync(jsonlPath, out.join(\"\\n\"), \"utf-8\")\n }\n }\n\n log(\n `index: ${result.indexRemapped} remapped, ${result.indexSkippedV2} already v2, ${result.indexUnmapped} unmapped`,\n )\n log(\n `jsonl: ${result.jsonlRemapped} remapped, ${result.jsonlSkippedV2} already v2, ${result.jsonlUnmapped} unmapped`,\n )\n if (opts.dryRun) log(\"(dry-run — no files written)\")\n else log(`backups: ${result.backups.join(\", \")}`)\n return result\n}\n\n/** Map a v1 path to a v2 path, OR detect that it's already v2, OR give up.\n * \"v2\" → path is already in v2 shape (length 1–2, root in CATEGORY_SET)\n * null → no pattern matched; caller should leave the entry alone\n * array → the new v2 path */\nfunction remapPath(path: string[], hits: Record<string, number>): string[] | \"v2\" | null {\n if (!Array.isArray(path) || path.length === 0) return null\n // Already v2 if the root is one of the closed categories.\n if (CATEGORY_SET.has(path[0])) return \"v2\"\n\n // The leaf carries the verb information in v1 (e.g. \"activity-review-mr\").\n // We also try the full path joined, because some leaves are just numeric ids.\n const haystack = `${path.join(\" \")} ${path[path.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ACH,EAAK,OAAQ,CAChB,IAAMgB,EAAS,GAAGG,YAAoB,KAAK,IAAI,UAC/CF,EAAaE,EAAWH,CAAM,EAC9Bb,EAAO,QAAQ,KAAKa,CAAM,EAC1BE,EAAcC,EAAWE,EAAI,KAAK;AAAA,CAAI,EAAG,OAAO,GAIpD,OAAApB,EACE,UAAUE,EAAO,2BAA2BA,EAAO,8BAA8BA,EAAO,wBAC1F,EACAF,EACE,UAAUE,EAAO,2BAA2BA,EAAO,8BAA8BA,EAAO,wBAC1F,EACIH,EAAK,OAAQC,EAAI,mCAA8B,EAC9CA,EAAI,YAAYE,EAAO,QAAQ,KAAK,IAAI,GAAG,EACzCA,CACT,CAMA,SAASY,EAAUU,EAAgBC,EAAsD,CACvF,GAAI,CAAC,MAAM,QAAQD,CAAI,GAAKA,EAAK,SAAW,EAAG,OAAO,KAEtD,GAAI7B,EAAa,IAAI6B,EAAK,CAAC,CAAC,EAAG,MAAO,KAItC,IAAME,EAAW,GAAGF,EAAK,KAAK,GAAG,KAAKA,EAAKA,EAAK,OAAS,CAAC,GAAK,KAC/D,QAAWG,KAAK/B,EACd,GAAI+B,EAAE,KAAK,KAAKD,CAAQ,EACtB,OAAAD,EAAKE,EAAE,IAAI,GAAKF,EAAKE,EAAE,IAAI,GAAK,GAAK,EAC9B,CAACA,EAAE,SAAUA,EAAE,IAAI,EAG9B,OAAO,IACT","names":["readFileSync","writeFileSync","existsSync","copyFileSync","join","CATEGORY_SET","PATTERNS","migrateV2","store","opts","log","baseDir","result","indexPath","join","existsSync","raw","readFileSync","parsed","indexFileSchema","updated","fp","entry","remapped","remapPath","backup","copyFileSync","writeFileSync","jsonlPath","lines","out","line","classificationSchema","next","path","hits","haystack","p"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a}from"./chunk-7GVXCOLO.js";import"./chunk-WPPUOTY6.js";import"./chunk-WFHIIVLL.js";import"./chunk-CNNLREHD.js";import"./chunk-6B74TO2J.js";import"./chunk-E4ZZILAK.js";import"./chunk-EW27SCCC.js";import"./chunk-ZE2YFX4K.js";import"./chunk-TC3BSUP7.js";import"./chunk-SFQUP3BP.js";import"./chunk-QW2OYR3N.js";import"./chunk-DLVOHCTA.js";import"./chunk-MBOLXKA2.js";import"./chunk-N67JZAXU.js";import"./chunk-CDNWCYF7.js";import"./chunk-AFRHKA7B.js";import"./chunk-23AUU4S2.js";import"./chunk-5F3J55LG.js";import"./chunk-WJXU5F4Z.js";import"./chunk-4MREHZP5.js";import"./chunk-VWTBHLMX.js";import"./chunk-7P5QRX5W.js";import"./chunk-JTJIPNXY.js";import"./chunk-64P4QHSZ.js";import"./chunk-BFZUG66X.js";import"./chunk-SR3X25TN.js";import"./chunk-53NRX2NA.js";import"./chunk-A6BKSZQA.js";import"./chunk-JGXE2YNV.js";import"./chunk-VJUTQAPJ.js";import"./chunk-DJEZ2HVU.js";import"./chunk-DSYKYZMT.js";import"./chunk-IKBHHTIT.js";import"./chunk-QOYAX2FT.js";import"./chunk-4YCH6IZV.js";export{a as buildProgram};
|
|
2
|
+
//# sourceMappingURL=program-WWCXMRU2.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{j as a,k as b,l as c}from"./chunk-JGXE2YNV.js";import"./chunk-VJUTQAPJ.js";import"./chunk-
|
|
2
|
-
//# sourceMappingURL=providers-
|
|
1
|
+
import{j as a,k as b,l as c}from"./chunk-JGXE2YNV.js";import"./chunk-VJUTQAPJ.js";import"./chunk-4YCH6IZV.js";export{b as ClaudeCodeProvider,a as ClaudeProvider,c as createProvider};
|
|
2
|
+
//# sourceMappingURL=providers-WVCMIW67.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{g as a,h as b,i as c}from"./chunk-23AUU4S2.js";import"./chunk-5F3J55LG.js";import"./chunk-WJXU5F4Z.js";import"./chunk-4MREHZP5.js";import"./chunk-VWTBHLMX.js";import"./chunk-7P5QRX5W.js";import"./chunk-JTJIPNXY.js";import"./chunk-64P4QHSZ.js";import"./chunk-BFZUG66X.js";import"./chunk-SR3X25TN.js";import"./chunk-53NRX2NA.js";import"./chunk-A6BKSZQA.js";import"./chunk-JGXE2YNV.js";import"./chunk-VJUTQAPJ.js";import"./chunk-DSYKYZMT.js";import"./chunk-IKBHHTIT.js";import"./chunk-QOYAX2FT.js";import"./chunk-4YCH6IZV.js";export{c as AgentRegistry,b as getGlobalRegistry,a as setGlobalRegistry};
|
|
2
|
+
//# sourceMappingURL=registry-HM4ELSXS.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import{a as l}from"./chunk-A6BKSZQA.js";import"./chunk-4YCH6IZV.js";import{execFile as f}from"child_process";var h=3e4,g="haiku",w=`You are about to lose this working session due to context-size rotation. Before that happens, write a compact memo of what you should carry forward to your next session on the same conversation.
|
|
2
|
+
|
|
3
|
+
Include only durable facts a future turn would otherwise have to rediscover:
|
|
4
|
+
- Names, handles, agent ids, telegram/whatsapp/gitlab usernames
|
|
5
|
+
- File paths, URLs, project namespaces, ssh hosts, ports
|
|
6
|
+
- Decisions made and their reasoning
|
|
7
|
+
- Open tasks or commitments to follow up on
|
|
8
|
+
- Identifiers (issue numbers, PR numbers, ticket ids) the user referred to
|
|
9
|
+
|
|
10
|
+
Format: 3-12 short bullet points. Each \u2264120 chars. No prose, no preamble, no header. If the session was uninformative or just casual chat, reply with exactly the literal text "(no memo)".
|
|
11
|
+
|
|
12
|
+
Begin the memo now.`;async function k(n,r){let m=Date.now();if(!r)return{memo:null,reason:"no-resume",durationMs:0};let i=["-p",w,"--output-format","json","--resume",r,"--model",g];n.permissionMode==="bypassPermissions"&&i.push("--dangerously-skip-permissions");let c=l(n.workspace);return new Promise(p=>{let a=!1,e=(t,s)=>{a||(a=!0,p({memo:t,reason:s,durationMs:Date.now()-m}))};f("claude",i,{cwd:n.workspace,env:c,timeout:h,maxBuffer:1024*1024},(t,s,y)=>{if(t)return t.killed?e(null,"timeout"):e(null,`error:${t.message.slice(0,80)}`);try{let u=JSON.parse(s||"{}"),o=typeof u.result=="string"?u.result.trim():"";if(!o||o==="(no memo)")return e(null,"empty");let d=o.length>4096?o.slice(0,4096)+"\u2026":o;return e(d,"ok")}catch{return e(null,"parse-error")}}).on("error",()=>e(null,"spawn-error"))})}export{k as extractRotationMemo};
|
|
13
|
+
//# sourceMappingURL=rotation-memo-GMTZPMNE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/agents/rotation-memo.ts"],"sourcesContent":["import { execFile } from \"child_process\"\nimport type { AgentDef } from \"@/daemon/config\"\nimport { buildAgentEnv } from \"@/utils/workspace-env\"\n\n// --- Pre-rotation memo extraction ---\n//\n// Just before agentx clears `claudeSessionId` (tier-2 / max-turns / stale\n// rotation), we ask the dying Claude session to dump the facts and\n// decisions it should carry forward. The agent has full working-memory\n// of its tool-use history at this moment — the only chance to capture\n// it before --resume is dropped and the next turn starts with a blank\n// session.\n//\n// The memo persists into MemoryStore, where the existing findRelevant\n// path injects it into future turns naturally. No new wiring on the\n// read side; one-shot LLM call on the write side.\n//\n// Hard rule: never block rotation. Timeout, errors, empty memos all\n// mean \"skip this round of memo capture\". Memory continuity is a\n// best-effort enhancement, not a correctness requirement.\n\nconst MEMO_TIMEOUT_MS = 30_000\nconst MEMO_MODEL = \"haiku\" // cheapest fast model — memo is summarisation, not reasoning\n\nconst MEMO_PROMPT =\n \"You are about to lose this working session due to context-size rotation. \" +\n \"Before that happens, write a compact memo of what you should carry forward \" +\n \"to your next session on the same conversation.\\n\\n\" +\n \"Include only durable facts a future turn would otherwise have to rediscover:\\n\" +\n \"- Names, handles, agent ids, telegram/whatsapp/gitlab usernames\\n\" +\n \"- File paths, URLs, project namespaces, ssh hosts, ports\\n\" +\n \"- Decisions made and their reasoning\\n\" +\n \"- Open tasks or commitments to follow up on\\n\" +\n \"- Identifiers (issue numbers, PR numbers, ticket ids) the user referred to\\n\\n\" +\n \"Format: 3-12 short bullet points. Each ≤120 chars. No prose, no preamble, \" +\n \"no header. If the session was uninformative or just casual chat, reply with \" +\n \"exactly the literal text \\\"(no memo)\\\".\\n\\n\" +\n \"Begin the memo now.\"\n\nexport interface RotationMemoResult {\n /** The extracted memo text, or null when extraction failed/skipped. */\n memo: string | null\n /** Why we skipped or what happened — \"ok\", \"timeout\", \"error\", \"empty\", \"no-resume\". */\n reason: string\n /** Wall-clock time spent in the extractor. */\n durationMs: number\n}\n\n/** Ask the dying Claude session for a carry-forward memo. Spawns one\n * short claude CLI call with --resume on the about-to-be-dropped\n * session id, asks for a compact memo, returns the text. Never throws\n * — every failure mode resolves with `memo=null` so the caller can\n * proceed with the rotation regardless. */\nexport async function extractRotationMemo(\n agent: AgentDef,\n resumeSessionId: string | undefined,\n): Promise<RotationMemoResult> {\n const start = Date.now()\n if (!resumeSessionId) {\n return { memo: null, reason: \"no-resume\", durationMs: 0 }\n }\n\n const args: string[] = [\n \"-p\", MEMO_PROMPT,\n \"--output-format\", \"json\",\n \"--resume\", resumeSessionId,\n \"--model\", MEMO_MODEL,\n ]\n if (agent.permissionMode === \"bypassPermissions\") {\n args.push(\"--dangerously-skip-permissions\")\n }\n\n const env = buildAgentEnv(agent.workspace)\n\n return new Promise<RotationMemoResult>((resolve) => {\n let settled = false\n const finish = (memo: string | null, reason: string) => {\n if (settled) return\n settled = true\n resolve({ memo, reason, durationMs: Date.now() - start })\n }\n\n const child = execFile(\n \"claude\",\n args,\n {\n cwd: agent.workspace,\n env,\n timeout: MEMO_TIMEOUT_MS,\n maxBuffer: 1024 * 1024, // 1 MB; the memo itself is tiny\n },\n (err, stdout, _stderr) => {\n if (err) {\n // execFile signals timeout via signal SIGTERM + err.killed\n if ((err as NodeJS.ErrnoException & { killed?: boolean }).killed) {\n return finish(null, \"timeout\")\n }\n return finish(null, `error:${err.message.slice(0, 80)}`)\n }\n try {\n const data = JSON.parse(stdout || \"{}\")\n // claude -p --output-format json yields { result, ... }\n const text = typeof data.result === \"string\" ? data.result.trim() : \"\"\n if (!text || text === \"(no memo)\") return finish(null, \"empty\")\n // Defensive cap: memos > 4 KB are almost certainly the LLM\n // ignoring instructions and dumping prose. Truncate.\n const capped = text.length > 4096 ? text.slice(0, 4096) + \"…\" : text\n return finish(capped, \"ok\")\n } catch {\n return finish(null, \"parse-error\")\n }\n },\n )\n child.on(\"error\", () => finish(null, \"spawn-error\"))\n })\n}\n"],"mappings":"oEAAA,OAAS,YAAAA,MAAgB,gBAqBzB,IAAMC,EAAkB,IAClBC,EAAa,QAEbC,EACJ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBA4BF,eAAsBC,EACpBC,EACAC,EAC6B,CAC7B,IAAMC,EAAQ,KAAK,IAAI,EACvB,GAAI,CAACD,EACH,MAAO,CAAE,KAAM,KAAM,OAAQ,YAAa,WAAY,CAAE,EAG1D,IAAME,EAAiB,CACrB,KAAML,EACN,kBAAmB,OACnB,WAAYG,EACZ,UAAWJ,CACb,EACIG,EAAM,iBAAmB,qBAC3BG,EAAK,KAAK,gCAAgC,EAG5C,IAAMC,EAAMC,EAAcL,EAAM,SAAS,EAEzC,OAAO,IAAI,QAA6BM,GAAY,CAClD,IAAIC,EAAU,GACRC,EAAS,CAACC,EAAqBC,IAAmB,CAClDH,IACJA,EAAU,GACVD,EAAQ,CAAE,KAAAG,EAAM,OAAAC,EAAQ,WAAY,KAAK,IAAI,EAAIR,CAAM,CAAC,EAC1D,EAEcS,EACZ,SACAR,EACA,CACE,IAAKH,EAAM,UACX,IAAAI,EACA,QAASR,EACT,UAAW,KAAO,IACpB,EACA,CAACgB,EAAKC,EAAQC,IAAY,CACxB,GAAIF,EAEF,OAAKA,EAAqD,OACjDJ,EAAO,KAAM,SAAS,EAExBA,EAAO,KAAM,SAASI,EAAI,QAAQ,MAAM,EAAG,EAAE,GAAG,EAEzD,GAAI,CACF,IAAMG,EAAO,KAAK,MAAMF,GAAU,IAAI,EAEhCG,EAAO,OAAOD,EAAK,QAAW,SAAWA,EAAK,OAAO,KAAK,EAAI,GACpE,GAAI,CAACC,GAAQA,IAAS,YAAa,OAAOR,EAAO,KAAM,OAAO,EAG9D,IAAMS,EAASD,EAAK,OAAS,KAAOA,EAAK,MAAM,EAAG,IAAI,EAAI,SAAMA,EAChE,OAAOR,EAAOS,EAAQ,IAAI,CAC5B,MAAE,CACA,OAAOT,EAAO,KAAM,aAAa,CACnC,CACF,CACF,EACM,GAAG,QAAS,IAAMA,EAAO,KAAM,aAAa,CAAC,CACrD,CAAC,CACH","names":["execFile","MEMO_TIMEOUT_MS","MEMO_MODEL","MEMO_PROMPT","extractRotationMemo","agent","resumeSessionId","start","args","env","buildAgentEnv","resolve","settled","finish","memo","reason","execFile","err","stdout","_stderr","data","text","capped"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{e as a,f as b}from"./chunk-QW2OYR3N.js";import"./chunk-DLVOHCTA.js";import"./chunk-MBOLXKA2.js";import"./chunk-4MREHZP5.js";import"./chunk-VJUTQAPJ.js";import"./chunk-4YCH6IZV.js";export{b as CronScheduler,a as getNextCronDate};
|
|
2
|
+
//# sourceMappingURL=scheduler-XVFIK4XH.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import"./chunk-
|
|
1
|
+
import"./chunk-4YCH6IZV.js";function m(e){let r=e.log??(()=>{});return async function(o){let n=e.inboxBaseUrl??"",s=f(o);for(let d of o.assignedTo){let c=e.actors.channelFor(d,"slack");if(!c)continue;let a=u(o,d,n,s);try{let t=await e.adapter.send({channel:"slack",chatId:c,text:a,parseMode:"markdown"}),l=[...o.delivered??[],{channel:"slack",handle:c,messageId:typeof t=="string"?t:void 0,at:new Date().toISOString()}];e.tasks.save({...o,delivered:l})}catch(t){r(`[task:${o.id}] slack delivery to ${d}@${c} failed: ${t?.message??t}`)}}}}function f(e){if(!e.form.secondaryAction)return!1;for(let r of e.form.fields??[])if(r.required&&r.defaultValue===void 0)return!1;return!0}function u(e,r,i,o){let n=[];if(n.push(`*${e.title}*`),e.description&&n.push("",e.description),!o&&e.form.fields?.length){n.push("","*Fields*:");for(let s of e.form.fields)n.push(`\u2022 ${s.label}${s.required?" (required)":""}`)}return e.dueAt&&n.push("",`:clock3: Due: ${new Date(e.dueAt).toLocaleString()}`),o?(n.push("",`:white_check_mark: <${i}/t/${encodeURIComponent(e.id)}/primary?actor=${encodeURIComponent(r)}|${e.form.submitLabel||"Approve"}>`),e.form.secondaryAction&&n.push(`:x: <${i}/t/${encodeURIComponent(e.id)}/secondary?actor=${encodeURIComponent(r)}|${e.form.secondaryAction.label}>`)):n.push("",`<${i}/inbox?actor=${encodeURIComponent(r)}|Open form>`),n.join(`
|
|
2
2
|
`)}export{m as createSlackTaskRenderer};
|
|
3
|
-
//# sourceMappingURL=slack-
|
|
3
|
+
//# sourceMappingURL=slack-6P7ZJ32Y.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import"./chunk-
|
|
1
|
+
import"./chunk-4YCH6IZV.js";var g=class{registry;activeRuns=new Map;runCounter=0;log;depthMap=new Map;constructor(t,e=console.error.bind(console,"[subagent]")){this.registry=t,this.log=e}async spawn(t){let e=this.depthMap.get(t.parentAgentId)||0;if(e>=3)return{runId:"",targetAgentId:t.targetAgentId,success:!1,content:"",error:`Sub-agent spawn depth exceeded (max: 3). Cannot spawn "${t.targetAgentId}" from "${t.parentAgentId}".`,duration:0};let n=`sub-${++this.runCounter}-${Date.now().toString(36)}`,r={request:t,runId:n,startedAt:Date.now()};this.activeRuns.set(n,r),this.depthMap.set(t.targetAgentId,e+1),this.log(`Spawning sub-agent: ${t.targetAgentId} (parent: ${t.parentAgentId}, depth: ${e+1}, blocking: ${t.blocking??!1})`);let o={message:this.buildSubAgentPrompt(t),agentId:t.targetAgentId,context:{channel:"subagent",sender:`agent:${t.parentAgentId}`,chatId:`subagent:${n}`}},i=t.timeout??3e5;try{let a=await Promise.race([this.registry.execute(o),this.timeoutPromise(i,t.targetAgentId)]),s={runId:n,targetAgentId:t.targetAgentId,success:!a.error,content:a.content,error:a.error,duration:Date.now()-r.startedAt};return this.log(`Sub-agent ${t.targetAgentId} completed in ${s.duration}ms (${s.success?"success":"error"})`),s}catch(a){return{runId:n,targetAgentId:t.targetAgentId,success:!1,content:"",error:a.message,duration:Date.now()-r.startedAt}}finally{this.activeRuns.delete(n),this.depthMap.delete(t.targetAgentId)}}async spawnParallel(t){return Promise.all(t.map(e=>this.spawn(e)))}listActive(){return Array.from(this.activeRuns.values()).map(t=>({runId:t.runId,targetAgentId:t.request.targetAgentId,parentAgentId:t.request.parentAgentId,duration:Date.now()-t.startedAt}))}buildSubAgentPrompt(t){return[`[Sub-agent task from ${t.parentAgentId}]`,"You have been spawned as a background sub-agent to handle a specific task.","Focus on completing the task below and provide a clear, actionable response.","",t.prompt].join(`
|
|
2
2
|
`)}timeoutPromise(t,e){return new Promise((n,r)=>{setTimeout(()=>{r(new Error(`Sub-agent "${e}" timed out after ${Math.round(t/1e3)}s`))},t)})}};export{g as SubAgentManager};
|
|
3
|
-
//# sourceMappingURL=subagent-
|
|
3
|
+
//# sourceMappingURL=subagent-WV7QKQ3L.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a,b,c,d}from"./chunk-N67JZAXU.js";import"./chunk-CDNWCYF7.js";import"./chunk-
|
|
2
|
-
//# sourceMappingURL=task-store-
|
|
1
|
+
import{a,b,c,d}from"./chunk-N67JZAXU.js";import"./chunk-CDNWCYF7.js";import"./chunk-4YCH6IZV.js";export{c as TaskStore,d as computeKpis,a as taskStatusSchema,b as userTaskRecordSchema};
|
|
2
|
+
//# sourceMappingURL=task-store-RHISEU6V.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import"./chunk-
|
|
1
|
+
import"./chunk-4YCH6IZV.js";function p(e){let i=e.log??(()=>{});return async function(n){let d=e.inboxBaseUrl??"",r=g(n.form);for(let t of n.assignedTo){let o=e.actors.channelFor(t,"telegram");if(!o)continue;let l=m(n,t,d,r);try{let s;if(r&&e.adapter.sendWithInlineButtons){let a=[{label:n.form.submitLabel||"Approve",url:`${d}/t/${encodeURIComponent(n.id)}/primary?actor=${encodeURIComponent(t)}`},...n.form.secondaryAction?[{label:n.form.secondaryAction.label,url:`${d}/t/${encodeURIComponent(n.id)}/secondary?actor=${encodeURIComponent(t)}`}]:[]],f=await e.adapter.sendWithInlineButtons({chatId:o,text:l,parseMode:"markdown",buttons:a});s=typeof f=="string"?f:void 0}else{let a=await e.adapter.sendMessage({chatId:o,text:l,parseMode:"markdown"});s=typeof a=="string"?a:void 0}let u=[...n.delivered??[],{channel:"telegram",handle:o,messageId:s,at:new Date().toISOString()}];e.tasks.save({...n,delivered:u})}catch(s){i(`[task:${n.id}] telegram delivery to ${t}@${o} failed: ${s?.message??s}`)}}}}function g(e){if(!e.secondaryAction)return!1;for(let i of e.fields??[])if(i.required&&i.defaultValue===void 0)return!1;return!0}function m(e,i,c,n){let d=`${c}/inbox?actor=${encodeURIComponent(i)}`,r=[];if(r.push(`\u{1F4CB} **${e.title}**`),e.description&&r.push("",e.description),!n&&e.form.fields?.length){r.push("","_Fields_:");for(let t of e.form.fields){let o=t.required?" *(required)*":"";r.push(`\u2022 ${t.label}${o}`)}}return e.dueAt&&r.push("",`\u23F0 Due: ${new Date(e.dueAt).toLocaleString()}`),n||r.push("",`[Open form \u2192](${d})`),r.join(`
|
|
2
2
|
`)}export{p as createTelegramTaskRenderer};
|
|
3
|
-
//# sourceMappingURL=telegram-
|
|
3
|
+
//# sourceMappingURL=telegram-PIYDRM46.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|