agentix-cli 0.69.0 → 0.69.2

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.
Files changed (79) hide show
  1. package/dist/{agent-VQIC7O5T.js → agent-P2UO35ZW.js} +2 -2
  2. package/dist/{board-dashboard-ZPJHXX3U.js → board-dashboard-3WVKEGRZ.js} +6 -5
  3. package/dist/{board-dashboard-ZPJHXX3U.js.map → board-dashboard-3WVKEGRZ.js.map} +1 -1
  4. package/dist/{chunk-ART666G6.js → chunk-2V7IQUEA.js} +2 -2
  5. package/dist/{chunk-PNWNVOEZ.js → chunk-4DRNEOOW.js} +2 -2
  6. package/dist/{chunk-NVJHA63C.js → chunk-4UMYRIEI.js} +10 -10
  7. package/dist/chunk-4UMYRIEI.js.map +1 -0
  8. package/dist/{chunk-HEJOWP7O.js → chunk-56AQBWEJ.js} +2 -2
  9. package/dist/{chunk-JHWBCDD2.js → chunk-A5ZCMRB3.js} +12 -9
  10. package/dist/chunk-A5ZCMRB3.js.map +1 -0
  11. package/dist/{chunk-BYKF3UTL.js → chunk-AIV547JW.js} +2 -2
  12. package/dist/chunk-ILEC3IAV.js +3 -0
  13. package/dist/chunk-ILEC3IAV.js.map +1 -0
  14. package/dist/{chunk-B65FS265.js → chunk-JSF2THM4.js} +2 -2
  15. package/dist/chunk-KA2UIZXG.js +3 -0
  16. package/dist/chunk-KA2UIZXG.js.map +1 -0
  17. package/dist/chunk-KXR6GVL7.js +5 -0
  18. package/dist/chunk-KXR6GVL7.js.map +1 -0
  19. package/dist/{chunk-QDRAKJSY.js → chunk-L2K4N3DA.js} +4 -4
  20. package/dist/chunk-M6HJDSLS.js +109 -0
  21. package/dist/chunk-M6HJDSLS.js.map +1 -0
  22. package/dist/{chunk-4NXIJEYU.js → chunk-U3XQ7USK.js} +9 -9
  23. package/dist/{chunk-4NXIJEYU.js.map → chunk-U3XQ7USK.js.map} +1 -1
  24. package/dist/{chunk-S4ASFOJU.js → chunk-VXDM7JAT.js} +2 -2
  25. package/dist/{chunk-5AMQFDLE.js → chunk-X4FD5OBK.js} +63 -63
  26. package/dist/{chunk-5AMQFDLE.js.map → chunk-X4FD5OBK.js.map} +1 -1
  27. package/dist/{chunk-NEC4RXFT.js → chunk-XMW422NO.js} +2 -2
  28. package/dist/{chunk-LPWPFEIE.js → chunk-YBLITM6C.js} +2 -2
  29. package/dist/cli.js +1 -1
  30. package/dist/fact-proposals-LZWS5KFO.js +2 -0
  31. package/dist/index.d.ts +12 -0
  32. package/dist/index.js +1 -1
  33. package/dist/ledger-CH7R756S.js +2 -0
  34. package/dist/{migrate-v2-5VGHWPBW.js → migrate-v2-KOMPDC6U.js} +2 -2
  35. package/dist/{program-6PFRDQFT.js → program-GUBHJFZS.js} +2 -2
  36. package/dist/{promote-XRKH73IB.js → promote-7FMPZKXN.js} +2 -2
  37. package/dist/questions-ZATLU5AW.js +2 -0
  38. package/dist/{registry-KP3C4EZ4.js → registry-MUMQPZDM.js} +2 -2
  39. package/dist/{rotation-memo-store-X63HYIMV.js → rotation-memo-store-A4YW6FSK.js} +2 -2
  40. package/dist/{schedule-tool-ZVKBZOVG.js → schedule-tool-BY72YNNU.js} +2 -2
  41. package/dist/{scheduler-5NBO3J2G.js → scheduler-XWYFGG2S.js} +2 -2
  42. package/dist/{tool-ZENVUVBO.js → tool-ZUGNQZGI.js} +2 -2
  43. package/dist/{wiki-W6WI6HL3.js → wiki-LLL7VWRJ.js} +2 -2
  44. package/package.json +1 -1
  45. package/dist/chunk-AU6FFC4I.js +0 -5
  46. package/dist/chunk-AU6FFC4I.js.map +0 -1
  47. package/dist/chunk-CUZWGTXT.js +0 -109
  48. package/dist/chunk-CUZWGTXT.js.map +0 -1
  49. package/dist/chunk-JHWBCDD2.js.map +0 -1
  50. package/dist/chunk-NVJHA63C.js.map +0 -1
  51. package/dist/chunk-ST6KPQOY.js +0 -3
  52. package/dist/chunk-ST6KPQOY.js.map +0 -1
  53. package/dist/chunk-ZXR6GNEK.js +0 -3
  54. package/dist/chunk-ZXR6GNEK.js.map +0 -1
  55. package/dist/fact-proposals-ERRQXV2J.js +0 -2
  56. package/dist/ledger-DHYRP4TN.js +0 -2
  57. package/dist/questions-QGITDLJY.js +0 -2
  58. /package/dist/{agent-VQIC7O5T.js.map → agent-P2UO35ZW.js.map} +0 -0
  59. /package/dist/{chunk-ART666G6.js.map → chunk-2V7IQUEA.js.map} +0 -0
  60. /package/dist/{chunk-PNWNVOEZ.js.map → chunk-4DRNEOOW.js.map} +0 -0
  61. /package/dist/{chunk-HEJOWP7O.js.map → chunk-56AQBWEJ.js.map} +0 -0
  62. /package/dist/{chunk-BYKF3UTL.js.map → chunk-AIV547JW.js.map} +0 -0
  63. /package/dist/{chunk-B65FS265.js.map → chunk-JSF2THM4.js.map} +0 -0
  64. /package/dist/{chunk-QDRAKJSY.js.map → chunk-L2K4N3DA.js.map} +0 -0
  65. /package/dist/{chunk-S4ASFOJU.js.map → chunk-VXDM7JAT.js.map} +0 -0
  66. /package/dist/{chunk-NEC4RXFT.js.map → chunk-XMW422NO.js.map} +0 -0
  67. /package/dist/{chunk-LPWPFEIE.js.map → chunk-YBLITM6C.js.map} +0 -0
  68. /package/dist/{fact-proposals-ERRQXV2J.js.map → fact-proposals-LZWS5KFO.js.map} +0 -0
  69. /package/dist/{ledger-DHYRP4TN.js.map → ledger-CH7R756S.js.map} +0 -0
  70. /package/dist/{migrate-v2-5VGHWPBW.js.map → migrate-v2-KOMPDC6U.js.map} +0 -0
  71. /package/dist/{program-6PFRDQFT.js.map → program-GUBHJFZS.js.map} +0 -0
  72. /package/dist/{promote-XRKH73IB.js.map → promote-7FMPZKXN.js.map} +0 -0
  73. /package/dist/{questions-QGITDLJY.js.map → questions-ZATLU5AW.js.map} +0 -0
  74. /package/dist/{registry-KP3C4EZ4.js.map → registry-MUMQPZDM.js.map} +0 -0
  75. /package/dist/{rotation-memo-store-X63HYIMV.js.map → rotation-memo-store-A4YW6FSK.js.map} +0 -0
  76. /package/dist/{schedule-tool-ZVKBZOVG.js.map → schedule-tool-BY72YNNU.js.map} +0 -0
  77. /package/dist/{scheduler-5NBO3J2G.js.map → scheduler-XWYFGG2S.js.map} +0 -0
  78. /package/dist/{tool-ZENVUVBO.js.map → tool-ZUGNQZGI.js.map} +0 -0
  79. /package/dist/{wiki-W6WI6HL3.js.map → wiki-LLL7VWRJ.js.map} +0 -0
@@ -1,2 +1,2 @@
1
- import{q as p}from"./chunk-JHWBCDD2.js";import{b as i,c as u,d as l,e as c}from"./chunk-APKAW7LU.js";import d from"cronstrue";var f=Intl.DateTimeFormat().resolvedOptions().timeZone,m=600,E='Try: "every morning at 9", "weekdays at 6pm", "every 15 minutes", "every monday at 10am", "1st of every month at noon", "daily at 9:30am", "every hour"',g=/^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/;function w(e){return g.test(e)}function x(e){try{return new Intl.DateTimeFormat("en-US",{timeZone:e}),!0}catch{return!1}}function $(e){return e?e.split(",").map(r=>r.trim().toLowerCase()).filter(r=>r==="log"||r==="notify"||r==="disable"):["log"]}function S(e){let r=[...e.onError??["log"]];e.notify&&!r.includes("notify")&&r.push("notify");let t={enabled:e.enabled??!0,schedule:e.parsed.cron,timezone:e.timezone||f,agent:e.agent,prompt:e.prompt,timeout:e.timeout??m,onError:r};return e.model&&(t.model=e.model),e.notify&&(t.notify=e.notify),e.createdBy&&(t.createdBy=e.createdBy),e.approval&&(t.approval=e.approval),t}function P(e){try{return d.toString(e,{use24HourTimeFormat:!1})}catch{return e}}function T(e,r,t=new Date){try{return p(e,t,r)}catch{return null}}function A(e,r){if(!e)return"unknown (no match within a year)";try{return`${new Intl.DateTimeFormat("en-GB",{timeZone:r,weekday:"short",day:"2-digit",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}).format(e)} (${r})`}catch{return e.toISOString()}}function h(e){return e?.approval?.action==="create"}async function D(e,r={}){let t="",o=await i(n=>{let a=l(n,`crons.${e}`);if(!a)throw new Error(`cron "${e}" not found`);let s=a.approval;if(!s)throw new Error(`cron "${e}" has no pending request`);s.action==="create"?(delete a.approval,a.enabled=!0,t=`${e} approved and enabled (requested by ${s.requestedBy})`):(c(n,`crons.${e}`),t=`${e} deletion approved; job removed (requested by ${s.requestedBy})`)},{configPath:r.configPath,reload:r.reload});return o.success?{success:!0,message:t,result:o}:{success:!1,message:o.error||"failed",result:o}}async function I(e,r={}){let t="",o=await i(n=>{let a=l(n,`crons.${e}`);if(!a)throw new Error(`cron "${e}" not found`);let s=a.approval;if(!s)throw new Error(`cron "${e}" has no pending request`);s.action==="create"?(c(n,`crons.${e}`),t=`${e} rejected; pending job removed`):(delete a.approval,t=`${e} deletion rejected; job kept`)},{configPath:r.configPath,reload:r.reload});return o.success?{success:!0,message:t,result:o}:{success:!1,message:o.error||"failed",result:o}}async function O(e,r,t={}){return i(o=>{let n=l(o,`crons.${e}`);if(!n)throw new Error(`cron "${e}" not found`);if(r&&h(n))throw new Error(`cron "${e}" is awaiting approval; run \`agentx schedule approve ${e}\``);u(o,`crons.${e}.enabled`,r)},{configPath:t.configPath,reload:t.reload})}export{f as a,E as b,w as c,x as d,$ as e,S as f,P as g,T as h,A as i,h as j,D as k,I as l,O as m};
2
- //# sourceMappingURL=chunk-NEC4RXFT.js.map
1
+ import{q as p}from"./chunk-A5ZCMRB3.js";import{b as i,c as u,d as l,e as c}from"./chunk-APKAW7LU.js";import d from"cronstrue";var f=Intl.DateTimeFormat().resolvedOptions().timeZone,m=600,E='Try: "every morning at 9", "weekdays at 6pm", "every 15 minutes", "every monday at 10am", "1st of every month at noon", "daily at 9:30am", "every hour"',g=/^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/;function w(e){return g.test(e)}function x(e){try{return new Intl.DateTimeFormat("en-US",{timeZone:e}),!0}catch{return!1}}function $(e){return e?e.split(",").map(r=>r.trim().toLowerCase()).filter(r=>r==="log"||r==="notify"||r==="disable"):["log"]}function S(e){let r=[...e.onError??["log"]];e.notify&&!r.includes("notify")&&r.push("notify");let t={enabled:e.enabled??!0,schedule:e.parsed.cron,timezone:e.timezone||f,agent:e.agent,prompt:e.prompt,timeout:e.timeout??m,onError:r};return e.model&&(t.model=e.model),e.notify&&(t.notify=e.notify),e.createdBy&&(t.createdBy=e.createdBy),e.approval&&(t.approval=e.approval),t}function P(e){try{return d.toString(e,{use24HourTimeFormat:!1})}catch{return e}}function T(e,r,t=new Date){try{return p(e,t,r)}catch{return null}}function A(e,r){if(!e)return"unknown (no match within a year)";try{return`${new Intl.DateTimeFormat("en-GB",{timeZone:r,weekday:"short",day:"2-digit",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}).format(e)} (${r})`}catch{return e.toISOString()}}function h(e){return e?.approval?.action==="create"}async function D(e,r={}){let t="",o=await i(n=>{let a=l(n,`crons.${e}`);if(!a)throw new Error(`cron "${e}" not found`);let s=a.approval;if(!s)throw new Error(`cron "${e}" has no pending request`);s.action==="create"?(delete a.approval,a.enabled=!0,t=`${e} approved and enabled (requested by ${s.requestedBy})`):(c(n,`crons.${e}`),t=`${e} deletion approved; job removed (requested by ${s.requestedBy})`)},{configPath:r.configPath,reload:r.reload});return o.success?{success:!0,message:t,result:o}:{success:!1,message:o.error||"failed",result:o}}async function I(e,r={}){let t="",o=await i(n=>{let a=l(n,`crons.${e}`);if(!a)throw new Error(`cron "${e}" not found`);let s=a.approval;if(!s)throw new Error(`cron "${e}" has no pending request`);s.action==="create"?(c(n,`crons.${e}`),t=`${e} rejected; pending job removed`):(delete a.approval,t=`${e} deletion rejected; job kept`)},{configPath:r.configPath,reload:r.reload});return o.success?{success:!0,message:t,result:o}:{success:!1,message:o.error||"failed",result:o}}async function O(e,r,t={}){return i(o=>{let n=l(o,`crons.${e}`);if(!n)throw new Error(`cron "${e}" not found`);if(r&&h(n))throw new Error(`cron "${e}" is awaiting approval; run \`agentx schedule approve ${e}\``);u(o,`crons.${e}.enabled`,r)},{configPath:t.configPath,reload:t.reload})}export{f as a,E as b,w as c,x as d,$ as e,S as f,P as g,T as h,A as i,h as j,D as k,I as l,O as m};
2
+ //# sourceMappingURL=chunk-XMW422NO.js.map
@@ -1,8 +1,8 @@
1
- import{a as D,b as _}from"./chunk-RKPAVWXF.js";import{a as q,b as O,c as R,d as B,f as b,g as S,h as E,i as w,j as y}from"./chunk-NEC4RXFT.js";import{a as T,b as C,c as I,d as x,e as P}from"./chunk-APKAW7LU.js";import{existsSync as X,readFileSync as F}from"fs";var J=new Set(["cron","heartbeat","api","a2a","mesh"]),M=160;function s(n){return typeof n=="string"&&n.trim()?n.trim():void 0}function A(n,e=M){let t=n.replace(/\s+/g," ").trim();return t.length>e?`${t.slice(0,e-1)}\u2026`:t}function V(n){let e=T(n);if(!X(e))throw new Error(`config not found at ${e}`);return JSON.parse(F(e,"utf-8"))}function W(n,e){return n?.agents?.[e]?.admin===!0}function Y(n,e,t){return W(n,t.agentId)||e?.createdBy===t.agentId}function Z(n,e){let t=e?.createdBy?`agent "${e.createdBy}"`:"the operator";return`Not allowed: "${n}" was created by ${t}. Agents manage only schedules they created (unless configured admin).`}function K(n,e){let t=s(n.notify);if(t!=="none"){if(t&&t!=="here"){let r=t.split(":");return r.length<2||!r[0]||!r[1]?"invalid":{channel:r[0],chatId:r.slice(1).join(":")}}if(e.channel&&e.chatId&&!J.has(e.channel))return{channel:e.channel,chatId:e.chatId,...e.accountId?{accountId:e.accountId}:{}}}}function Q(n,e,t){let r=e.timezone||"UTC",u=e.enabled&&!y(e)?w(E(e.schedule,r,t),r):"\u2014",h=e.approval?`pending ${e.approval.action} approval`:e.enabled?"active":"paused",p=[`- ${n} [${h}] ${e.schedule} \u2014 ${S(e.schedule)} (${r})`,` agent: ${e.agent}; created by: ${e.createdBy||"operator"}; next: ${u}`];return e.notify&&p.push(` notify: ${e.notify.channel} ${e.notify.chatId}`),e.command?p.push(` command: ${A(String(e.command))}`):e.prompt&&p.push(` prompt: ${A(String(e.prompt))}`),p.join(`
1
+ import{a as D,b as _}from"./chunk-RKPAVWXF.js";import{a as q,b as O,c as R,d as B,f as b,g as S,h as E,i as w,j as y}from"./chunk-XMW422NO.js";import{a as T,b as C,c as I,d as x,e as P}from"./chunk-APKAW7LU.js";import{existsSync as X,readFileSync as F}from"fs";var J=new Set(["cron","heartbeat","api","a2a","mesh"]),M=160;function s(n){return typeof n=="string"&&n.trim()?n.trim():void 0}function A(n,e=M){let t=n.replace(/\s+/g," ").trim();return t.length>e?`${t.slice(0,e-1)}\u2026`:t}function V(n){let e=T(n);if(!X(e))throw new Error(`config not found at ${e}`);return JSON.parse(F(e,"utf-8"))}function W(n,e){return n?.agents?.[e]?.admin===!0}function Y(n,e,t){return W(n,t.agentId)||e?.createdBy===t.agentId}function Z(n,e){let t=e?.createdBy?`agent "${e.createdBy}"`:"the operator";return`Not allowed: "${n}" was created by ${t}. Agents manage only schedules they created (unless configured admin).`}function K(n,e){let t=s(n.notify);if(t!=="none"){if(t&&t!=="here"){let r=t.split(":");return r.length<2||!r[0]||!r[1]?"invalid":{channel:r[0],chatId:r.slice(1).join(":")}}if(e.channel&&e.chatId&&!J.has(e.channel))return{channel:e.channel,chatId:e.chatId,...e.accountId?{accountId:e.accountId}:{}}}}function Q(n,e,t){let r=e.timezone||"UTC",u=e.enabled&&!y(e)?w(E(e.schedule,r,t),r):"\u2014",h=e.approval?`pending ${e.approval.action} approval`:e.enabled?"active":"paused",p=[`- ${n} [${h}] ${e.schedule} \u2014 ${S(e.schedule)} (${r})`,` agent: ${e.agent}; created by: ${e.createdBy||"operator"}; next: ${u}`];return e.notify&&p.push(` notify: ${e.notify.channel} ${e.notify.chatId}`),e.command?p.push(` command: ${A(String(e.command))}`):e.prompt&&p.push(` prompt: ${A(String(e.prompt))}`),p.join(`
2
2
  `)}async function k(n,e,t){let r=n?.notifications?.destination;if(!r?.channel||!r?.chatId)return"No operator notification destination is configured (notifications.destination); the operator must check `agentx schedule list`.";if(!e.notifyOperator)return"Operator notification is unavailable in this context.";try{return await e.notifyOperator({channel:r.channel,chatId:r.chatId,accountId:r.accountId},t),"The operator has been notified."}catch(u){return`Could not notify the operator (${u?.message??u}); the request is still recorded.`}}async function re(n,e,t={}){let r=(s(n.action)||"list").toLowerCase(),u=t.now?t.now():new Date,h;try{h=V(t.configPath)}catch(a){return`Error: ${a.message}`}let p=h.crons||{};if(r==="list"){let a=n.mine===!0,l=Object.entries(p).filter(([,i])=>!a||e&&i?.createdBy===e.agentId);return l.length?l.map(([i,f])=>Q(i,f,u)).join(`
3
3
  `):a?"You have no schedules.":"No schedules."}if(!e?.agentId)return"Error: caller agent is unknown (AGENTX_AGENT_ID not set). Pass callerAgentId.";if(!h.agents?.[e.agentId])return`Error: caller "${e.agentId}" is not an agent on this node.`;let o=s(n.id),m=a=>C(a,{configPath:t.configPath,reload:t.reload});if(r==="create"){let a=s(n.when),l=s(n.prompt);if(!a||!l)return"Error: create needs `when` (plain English) and `prompt`.";let i=D(a);if(!i)return`Error: couldn't parse "${a}". ${O}.`;let f=s(n.agent)||e.agentId;if(!h.agents?.[f])return`Error: agent "${f}" not found on this node.`;let g=s(n.timezone)||q;if(!B(g))return`Error: unknown timezone "${g}".`;let d=o||_(i.matched,f);if(!R(d))return`Error: invalid id "${d}" (letters, digits, "-" and "_" only).`;if(p[d])return`Error: a schedule "${d}" already exists. Pick another \`id\`.`;let $=K(n,e);if($==="invalid")return'Error: `notify` must be "here", "none", or "channel:chatId".';let z={action:"create",requestedBy:e.agentId,requestedAt:u.toISOString()},L=b({parsed:i,agent:f,prompt:l,timezone:g,notify:$,enabled:!1,createdBy:e.agentId,approval:z}),v=await m(U=>I(U,`crons.${d}`,L));if(!v.success)return`Error: ${v.error}`;let N=w(E(i.cron,g,u),g),G=[`Schedule approval requested by ${e.agentId}`,`Create: ${d}`,`When: ${i.human} \u2014 cron \`${i.cron}\` (${g})`,`Next fire: ${N}`,`Agent: ${f}`,$?`Notify: ${$.channel} ${$.chatId}`:"Notify: none",`Prompt: ${A(l,400)}`,"",`Approve: agentx schedule approve ${d}`,`Reject: agentx schedule reject ${d}`].join(`
4
4
  `),H=await k(h,t,G);return[`Requested schedule "${d}": ${i.human} (cron ${i.cron}, ${g}); next fire would be ${N}.`,"It is saved DISABLED and will not run until the operator approves it.",H].join(`
5
5
  `)}if(!o)return`Error: ${r} needs \`id\`.`;let c=p[o];if(!c)return`Error: schedule "${o}" not found.`;if(!Y(h,c,e))return Z(o,c);if(r==="pause"||r==="resume"){let a=r==="resume";if(a&&y(c))return`"${o}" is still awaiting operator approval; it can't be resumed until approved.`;if(c.enabled===a)return`"${o}" is already ${a?"active":"paused"}.`;let l=await m(i=>I(i,`crons.${o}.enabled`,a));return l.success?`"${o}" ${a?"resumed":"paused"}.`:`Error: ${l.error}`}if(r==="delete"){if(y(c)&&c.approval.requestedBy===e.agentId){let d=await m($=>P($,`crons.${o}`));return d.success?`Withdrew the pending request "${o}".`:`Error: ${d.error}`}if(y(c))return`"${o}" is a creation request still awaiting approval; only its requester or the operator (\`agentx schedule reject ${o}\`) can drop it.`;if(c.approval?.action==="delete")return`Deletion of "${o}" is already awaiting approval.`;let a={action:"delete",requestedBy:e.agentId,requestedAt:u.toISOString()},l=await m(d=>{if(!x(d,`crons.${o}`))throw new Error(`schedule "${o}" not found`);I(d,`crons.${o}.approval`,a)});if(!l.success)return`Error: ${l.error}`;let i=c.timezone||"UTC",f=[`Schedule approval requested by ${e.agentId}`,`Delete: ${o}`,`When: ${S(c.schedule)} \u2014 cron \`${c.schedule}\` (${i})`,`Next fire: ${c.enabled?w(E(c.schedule,i,u),i):"\u2014 (paused)"}`,`Agent: ${c.agent}`,"",`Approve: agentx schedule approve ${o}`,`Reject: agentx schedule reject ${o}`].join(`
6
6
  `),g=await k(h,t,f);return[`Deletion of "${o}" requested. It keeps its current state until the operator approves.`,g].join(`
7
7
  `)}return`Error: unknown action "${r}". Use list, create, pause, resume or delete.`}function oe(n,e=process.env){let t=s(e.AGENTX_AGENT_ID)||s(n.callerAgentId);if(!t)return null;let r=!!(s(e.AGENTX_CHANNEL)&&s(e.AGENTX_CHAT_ID)),u=s(r?e.AGENTX_CHANNEL:n.channel),h=s(r?e.AGENTX_CHAT_ID:n.chatId),p=s(n.accountId);return{agentId:t,channel:u,chatId:h,...p?{accountId:p}:{}}}export{re as a,oe as b};
8
- //# sourceMappingURL=chunk-LPWPFEIE.js.map
8
+ //# sourceMappingURL=chunk-YBLITM6C.js.map
package/dist/cli.js CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
- import{a as n}from"./chunk-5AMQFDLE.js";import"./chunk-G3SOCQII.js";import"./chunk-APKKQGTG.js";import"./chunk-HEJOWP7O.js";import"./chunk-Z3IP66SL.js";import"./chunk-C4CDVE2E.js";import"./chunk-RKPAVWXF.js";import"./chunk-GV7S5BAX.js";import"./chunk-GSX4NK2N.js";import"./chunk-SZDACK6O.js";import"./chunk-4NXIJEYU.js";import"./chunk-B65FS265.js";import"./chunk-BYJ3A55Y.js";import"./chunk-NMFXY3QU.js";import"./chunk-F2DEKA2Q.js";import"./chunk-LQRBGQIR.js";import"./chunk-ZVP6GB4G.js";import"./chunk-ART666G6.js";import"./chunk-2D3RYIDU.js";import"./chunk-L53FTKEP.js";import"./chunk-QDRAKJSY.js";import"./chunk-NVJHA63C.js";import"./chunk-N6EWZGIX.js";import"./chunk-WP6KLXTP.js";import"./chunk-DP7RTNDM.js";import"./chunk-BYKF3UTL.js";import"./chunk-SFQUP3BP.js";import"./chunk-NEC4RXFT.js";import"./chunk-2AXFYDWF.js";import"./chunk-AQASR6KR.js";import"./chunk-76Z4VHDX.js";import"./chunk-W4YR2RO2.js";import"./chunk-AFRHKA7B.js";import"./chunk-JHWBCDD2.js";import"./chunk-APKAW7LU.js";import"./chunk-ST6KPQOY.js";import"./chunk-GQ76J72O.js";import"./chunk-ZXR6GNEK.js";import"./chunk-J3SOEFRE.js";import"./chunk-SIU6STB2.js";import"./chunk-X5C5W3E4.js";import"./chunk-Q2WW2HF4.js";import"./chunk-DWADWDMU.js";import"./chunk-NO2HOK4B.js";import"./chunk-QD6IICK7.js";import"./chunk-VWTBHLMX.js";import"./chunk-S4ASFOJU.js";import"./chunk-CUZWGTXT.js";import"./chunk-PNWNVOEZ.js";import"./chunk-64P4QHSZ.js";import"./chunk-KSDVKLHN.js";import"./chunk-TFVUOC2C.js";import"./chunk-2GIDVZ4H.js";import"./chunk-VOS2IW4V.js";import"./chunk-FX3D7YON.js";import"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-QOYAX2FT.js";import"./chunk-SZJMS7K4.js";import"./chunk-7I7IEX4S.js";import"./chunk-VDMYBPYB.js";import"./chunk-DSYKYZMT.js";import"./chunk-N5NPJ6DJ.js";import"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.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();
2
+ import{a as n}from"./chunk-X4FD5OBK.js";import"./chunk-G3SOCQII.js";import"./chunk-APKKQGTG.js";import"./chunk-56AQBWEJ.js";import"./chunk-Z3IP66SL.js";import"./chunk-C4CDVE2E.js";import"./chunk-RKPAVWXF.js";import"./chunk-GV7S5BAX.js";import"./chunk-GSX4NK2N.js";import"./chunk-SZDACK6O.js";import"./chunk-U3XQ7USK.js";import"./chunk-JSF2THM4.js";import"./chunk-BYJ3A55Y.js";import"./chunk-NMFXY3QU.js";import"./chunk-F2DEKA2Q.js";import"./chunk-LQRBGQIR.js";import"./chunk-ZVP6GB4G.js";import"./chunk-2V7IQUEA.js";import"./chunk-2D3RYIDU.js";import"./chunk-L53FTKEP.js";import"./chunk-L2K4N3DA.js";import"./chunk-4UMYRIEI.js";import"./chunk-N6EWZGIX.js";import"./chunk-WP6KLXTP.js";import"./chunk-DP7RTNDM.js";import"./chunk-AIV547JW.js";import"./chunk-SFQUP3BP.js";import"./chunk-XMW422NO.js";import"./chunk-2AXFYDWF.js";import"./chunk-AQASR6KR.js";import"./chunk-76Z4VHDX.js";import"./chunk-W4YR2RO2.js";import"./chunk-AFRHKA7B.js";import"./chunk-A5ZCMRB3.js";import"./chunk-APKAW7LU.js";import"./chunk-KA2UIZXG.js";import"./chunk-GQ76J72O.js";import"./chunk-ILEC3IAV.js";import"./chunk-J3SOEFRE.js";import"./chunk-SIU6STB2.js";import"./chunk-X5C5W3E4.js";import"./chunk-Q2WW2HF4.js";import"./chunk-DWADWDMU.js";import"./chunk-NO2HOK4B.js";import"./chunk-QD6IICK7.js";import"./chunk-VWTBHLMX.js";import"./chunk-VXDM7JAT.js";import"./chunk-M6HJDSLS.js";import"./chunk-4DRNEOOW.js";import"./chunk-64P4QHSZ.js";import"./chunk-KSDVKLHN.js";import"./chunk-TFVUOC2C.js";import"./chunk-2GIDVZ4H.js";import"./chunk-VOS2IW4V.js";import"./chunk-FX3D7YON.js";import"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-QOYAX2FT.js";import"./chunk-SZJMS7K4.js";import"./chunk-7I7IEX4S.js";import"./chunk-VDMYBPYB.js";import"./chunk-DSYKYZMT.js";import"./chunk-N5NPJ6DJ.js";import"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.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
@@ -0,0 +1,2 @@
1
+ import{a,b,c,d,e,f}from"./chunk-KXR6GVL7.js";import"./chunk-KA2UIZXG.js";import"./chunk-GQ76J72O.js";import"./chunk-ILEC3IAV.js";import"./chunk-QIJLFPWE.js";export{d as approveFactProposal,c as listFactProposals,a as parseClaim,b as proposeFacts,e as rejectFactProposal,f as routeMemo};
2
+ //# sourceMappingURL=fact-proposals-LZWS5KFO.js.map
package/dist/index.d.ts CHANGED
@@ -9898,6 +9898,10 @@ interface GraphStoreOptions {
9898
9898
  declare class GraphStore {
9899
9899
  readonly baseDir: string;
9900
9900
  private log;
9901
+ /** Parsed nodes/index files, keyed by path. The classifier reads both
9902
+ * several times per message and they grow without bound, so re-reading
9903
+ * and re-validating them each time blocked the daemon for seconds. */
9904
+ private parsed;
9901
9905
  constructor(opts?: GraphStoreOptions);
9902
9906
  schemaPath(): string;
9903
9907
  nodesPath(): string;
@@ -9914,6 +9918,12 @@ declare class GraphStore {
9914
9918
  saveSchema(schema: GraphSchema): void;
9915
9919
  loadNodes(): NodesFile;
9916
9920
  saveNodes(file: NodesFile): void;
9921
+ /** The parsed file, re-read only when its mtime or size changes, so a
9922
+ * write from another process (CLI, dashboard) is still picked up. */
9923
+ private readParsed;
9924
+ /** Write the file and keep the parsed copy, so the writer never re-reads
9925
+ * what it just wrote. `data` must not be mutated afterwards. */
9926
+ private writeParsed;
9917
9927
  /** Validate a node against the schema AND uniqueness within the nodes file. */
9918
9928
  validateNode(node: GraphNode, schema: GraphSchema, all: GraphNode[]): void;
9919
9929
  /**
@@ -9974,6 +9984,8 @@ declare class GraphStore {
9974
9984
  }): string;
9975
9985
  loadIndex(): IndexFile;
9976
9986
  saveIndex(file: IndexFile): void;
9987
+ /** The cached index. Read-only: copy before handing it to a caller. */
9988
+ private index;
9977
9989
  getFingerprint(fp: string): FingerprintEntry | undefined;
9978
9990
  setFingerprint(fp: string, entry: Omit<FingerprintEntry, "fingerprint" | "updatedAt">): void;
9979
9991
  /** Update the axes on an existing node. Schema-validates the result. */
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import{a as L}from"./chunk-Y57CULGE.js";import{a as St,b as kt,c as vt,d as xt,da as Tt,e as $t,ea as Mt,f as Ct,g as Pt,h as bt}from"./chunk-4NXIJEYU.js";import"./chunk-B65FS265.js";import"./chunk-BYJ3A55Y.js";import"./chunk-NMFXY3QU.js";import"./chunk-F2DEKA2Q.js";import"./chunk-LQRBGQIR.js";import"./chunk-ZVP6GB4G.js";import"./chunk-ART666G6.js";import"./chunk-2D3RYIDU.js";import"./chunk-L53FTKEP.js";import{S as yt,l as lt,m as ct,n as dt,o as mt,p as pt}from"./chunk-QDRAKJSY.js";import"./chunk-NVJHA63C.js";import"./chunk-N6EWZGIX.js";import"./chunk-WP6KLXTP.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-BYKF3UTL.js";import{a as B,b as M,c as F}from"./chunk-SFQUP3BP.js";import"./chunk-NEC4RXFT.js";import"./chunk-2AXFYDWF.js";import"./chunk-AQASR6KR.js";import"./chunk-76Z4VHDX.js";import"./chunk-W4YR2RO2.js";import"./chunk-AFRHKA7B.js";import{s as ut}from"./chunk-JHWBCDD2.js";import"./chunk-APKAW7LU.js";import"./chunk-ST6KPQOY.js";import"./chunk-GQ76J72O.js";import"./chunk-ZXR6GNEK.js";import"./chunk-J3SOEFRE.js";import"./chunk-SIU6STB2.js";import"./chunk-X5C5W3E4.js";import"./chunk-Q2WW2HF4.js";import"./chunk-DWADWDMU.js";import"./chunk-NO2HOK4B.js";import"./chunk-QD6IICK7.js";import"./chunk-VWTBHLMX.js";import"./chunk-S4ASFOJU.js";import{a as gt,b as ft,e as ht}from"./chunk-CUZWGTXT.js";import"./chunk-PNWNVOEZ.js";import"./chunk-64P4QHSZ.js";import"./chunk-KSDVKLHN.js";import"./chunk-TFVUOC2C.js";import"./chunk-2GIDVZ4H.js";import{j as it,k as rt,l as at}from"./chunk-VOS2IW4V.js";import"./chunk-FX3D7YON.js";import"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.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-SZJMS7K4.js";import{a as m,b as G}from"./chunk-7I7IEX4S.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{u as tt,w as st,x as ot,z as nt}from"./chunk-N5NPJ6DJ.js";import"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.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(`
1
+ import{a as L}from"./chunk-Y57CULGE.js";import{a as St,b as kt,c as vt,d as xt,da as Tt,e as $t,ea as Mt,f as Ct,g as Pt,h as bt}from"./chunk-U3XQ7USK.js";import"./chunk-JSF2THM4.js";import"./chunk-BYJ3A55Y.js";import"./chunk-NMFXY3QU.js";import"./chunk-F2DEKA2Q.js";import"./chunk-LQRBGQIR.js";import"./chunk-ZVP6GB4G.js";import"./chunk-2V7IQUEA.js";import"./chunk-2D3RYIDU.js";import"./chunk-L53FTKEP.js";import{S as yt,l as lt,m as ct,n as dt,o as mt,p as pt}from"./chunk-L2K4N3DA.js";import"./chunk-4UMYRIEI.js";import"./chunk-N6EWZGIX.js";import"./chunk-WP6KLXTP.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-AIV547JW.js";import{a as B,b as M,c as F}from"./chunk-SFQUP3BP.js";import"./chunk-XMW422NO.js";import"./chunk-2AXFYDWF.js";import"./chunk-AQASR6KR.js";import"./chunk-76Z4VHDX.js";import"./chunk-W4YR2RO2.js";import"./chunk-AFRHKA7B.js";import{s as ut}from"./chunk-A5ZCMRB3.js";import"./chunk-APKAW7LU.js";import"./chunk-KA2UIZXG.js";import"./chunk-GQ76J72O.js";import"./chunk-ILEC3IAV.js";import"./chunk-J3SOEFRE.js";import"./chunk-SIU6STB2.js";import"./chunk-X5C5W3E4.js";import"./chunk-Q2WW2HF4.js";import"./chunk-DWADWDMU.js";import"./chunk-NO2HOK4B.js";import"./chunk-QD6IICK7.js";import"./chunk-VWTBHLMX.js";import"./chunk-VXDM7JAT.js";import{a as gt,b as ft,e as ht}from"./chunk-M6HJDSLS.js";import"./chunk-4DRNEOOW.js";import"./chunk-64P4QHSZ.js";import"./chunk-KSDVKLHN.js";import"./chunk-TFVUOC2C.js";import"./chunk-2GIDVZ4H.js";import{j as it,k as rt,l as at}from"./chunk-VOS2IW4V.js";import"./chunk-FX3D7YON.js";import"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.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-SZJMS7K4.js";import{a as m,b as G}from"./chunk-7I7IEX4S.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{u as tt,w as st,x as ot,z as nt}from"./chunk-N5NPJ6DJ.js";import"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.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-EVHZ2R73.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{b,c,d,e,f}from"./chunk-KA2UIZXG.js";import"./chunk-GQ76J72O.js";import{a}from"./chunk-ILEC3IAV.js";import"./chunk-QIJLFPWE.js";export{c as FactLedger,a as assertPerson,d as factContradictions,b as factId,e as isStaleFact,f as matchFact};
2
+ //# sourceMappingURL=ledger-CH7R756S.js.map
@@ -1,4 +1,4 @@
1
- import{b as g,d as l}from"./chunk-PNWNVOEZ.js";import"./chunk-QIJLFPWE.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(`
1
+ import{b as g,e as l}from"./chunk-4DRNEOOW.js";import"./chunk-QIJLFPWE.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
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
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-5VGHWPBW.js.map
4
+ //# sourceMappingURL=migrate-v2-KOMPDC6U.js.map
@@ -1,2 +1,2 @@
1
- import{a}from"./chunk-5AMQFDLE.js";import"./chunk-G3SOCQII.js";import"./chunk-APKKQGTG.js";import"./chunk-HEJOWP7O.js";import"./chunk-Z3IP66SL.js";import"./chunk-C4CDVE2E.js";import"./chunk-RKPAVWXF.js";import"./chunk-GV7S5BAX.js";import"./chunk-GSX4NK2N.js";import"./chunk-SZDACK6O.js";import"./chunk-4NXIJEYU.js";import"./chunk-B65FS265.js";import"./chunk-BYJ3A55Y.js";import"./chunk-NMFXY3QU.js";import"./chunk-F2DEKA2Q.js";import"./chunk-LQRBGQIR.js";import"./chunk-ZVP6GB4G.js";import"./chunk-ART666G6.js";import"./chunk-2D3RYIDU.js";import"./chunk-L53FTKEP.js";import"./chunk-QDRAKJSY.js";import"./chunk-NVJHA63C.js";import"./chunk-N6EWZGIX.js";import"./chunk-WP6KLXTP.js";import"./chunk-DP7RTNDM.js";import"./chunk-BYKF3UTL.js";import"./chunk-SFQUP3BP.js";import"./chunk-NEC4RXFT.js";import"./chunk-2AXFYDWF.js";import"./chunk-AQASR6KR.js";import"./chunk-76Z4VHDX.js";import"./chunk-W4YR2RO2.js";import"./chunk-AFRHKA7B.js";import"./chunk-JHWBCDD2.js";import"./chunk-APKAW7LU.js";import"./chunk-ST6KPQOY.js";import"./chunk-GQ76J72O.js";import"./chunk-ZXR6GNEK.js";import"./chunk-J3SOEFRE.js";import"./chunk-SIU6STB2.js";import"./chunk-X5C5W3E4.js";import"./chunk-Q2WW2HF4.js";import"./chunk-DWADWDMU.js";import"./chunk-NO2HOK4B.js";import"./chunk-QD6IICK7.js";import"./chunk-VWTBHLMX.js";import"./chunk-S4ASFOJU.js";import"./chunk-CUZWGTXT.js";import"./chunk-PNWNVOEZ.js";import"./chunk-64P4QHSZ.js";import"./chunk-KSDVKLHN.js";import"./chunk-TFVUOC2C.js";import"./chunk-2GIDVZ4H.js";import"./chunk-VOS2IW4V.js";import"./chunk-FX3D7YON.js";import"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-QOYAX2FT.js";import"./chunk-SZJMS7K4.js";import"./chunk-7I7IEX4S.js";import"./chunk-VDMYBPYB.js";import"./chunk-DSYKYZMT.js";import"./chunk-N5NPJ6DJ.js";import"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.js";export{a as buildProgram};
2
- //# sourceMappingURL=program-6PFRDQFT.js.map
1
+ import{a}from"./chunk-X4FD5OBK.js";import"./chunk-G3SOCQII.js";import"./chunk-APKKQGTG.js";import"./chunk-56AQBWEJ.js";import"./chunk-Z3IP66SL.js";import"./chunk-C4CDVE2E.js";import"./chunk-RKPAVWXF.js";import"./chunk-GV7S5BAX.js";import"./chunk-GSX4NK2N.js";import"./chunk-SZDACK6O.js";import"./chunk-U3XQ7USK.js";import"./chunk-JSF2THM4.js";import"./chunk-BYJ3A55Y.js";import"./chunk-NMFXY3QU.js";import"./chunk-F2DEKA2Q.js";import"./chunk-LQRBGQIR.js";import"./chunk-ZVP6GB4G.js";import"./chunk-2V7IQUEA.js";import"./chunk-2D3RYIDU.js";import"./chunk-L53FTKEP.js";import"./chunk-L2K4N3DA.js";import"./chunk-4UMYRIEI.js";import"./chunk-N6EWZGIX.js";import"./chunk-WP6KLXTP.js";import"./chunk-DP7RTNDM.js";import"./chunk-AIV547JW.js";import"./chunk-SFQUP3BP.js";import"./chunk-XMW422NO.js";import"./chunk-2AXFYDWF.js";import"./chunk-AQASR6KR.js";import"./chunk-76Z4VHDX.js";import"./chunk-W4YR2RO2.js";import"./chunk-AFRHKA7B.js";import"./chunk-A5ZCMRB3.js";import"./chunk-APKAW7LU.js";import"./chunk-KA2UIZXG.js";import"./chunk-GQ76J72O.js";import"./chunk-ILEC3IAV.js";import"./chunk-J3SOEFRE.js";import"./chunk-SIU6STB2.js";import"./chunk-X5C5W3E4.js";import"./chunk-Q2WW2HF4.js";import"./chunk-DWADWDMU.js";import"./chunk-NO2HOK4B.js";import"./chunk-QD6IICK7.js";import"./chunk-VWTBHLMX.js";import"./chunk-VXDM7JAT.js";import"./chunk-M6HJDSLS.js";import"./chunk-4DRNEOOW.js";import"./chunk-64P4QHSZ.js";import"./chunk-KSDVKLHN.js";import"./chunk-TFVUOC2C.js";import"./chunk-2GIDVZ4H.js";import"./chunk-VOS2IW4V.js";import"./chunk-FX3D7YON.js";import"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-QOYAX2FT.js";import"./chunk-SZJMS7K4.js";import"./chunk-7I7IEX4S.js";import"./chunk-VDMYBPYB.js";import"./chunk-DSYKYZMT.js";import"./chunk-N5NPJ6DJ.js";import"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.js";export{a as buildProgram};
2
+ //# sourceMappingURL=program-GUBHJFZS.js.map
@@ -1,2 +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-ART666G6.js";import"./chunk-DP7RTNDM.js";import"./chunk-2AXFYDWF.js";import"./chunk-AQASR6KR.js";import"./chunk-CUZWGTXT.js";import"./chunk-PNWNVOEZ.js";import"./chunk-64P4QHSZ.js";import"./chunk-TFVUOC2C.js";import"./chunk-VOS2IW4V.js";import"./chunk-FX3D7YON.js";import"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-QOYAX2FT.js";import"./chunk-SZJMS7K4.js";import"./chunk-7I7IEX4S.js";import"./chunk-N5NPJ6DJ.js";import"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.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-XRKH73IB.js.map
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-2V7IQUEA.js";import"./chunk-DP7RTNDM.js";import"./chunk-2AXFYDWF.js";import"./chunk-AQASR6KR.js";import"./chunk-M6HJDSLS.js";import"./chunk-4DRNEOOW.js";import"./chunk-64P4QHSZ.js";import"./chunk-TFVUOC2C.js";import"./chunk-VOS2IW4V.js";import"./chunk-FX3D7YON.js";import"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-QOYAX2FT.js";import"./chunk-SZJMS7K4.js";import"./chunk-7I7IEX4S.js";import"./chunk-N5NPJ6DJ.js";import"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.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-7FMPZKXN.js.map
@@ -0,0 +1,2 @@
1
+ import{b as a,c as b}from"./chunk-ILEC3IAV.js";import"./chunk-QIJLFPWE.js";export{b as QuestionStore,a as questionId};
2
+ //# sourceMappingURL=questions-ZATLU5AW.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,O as g,P as h,Q as i,R as j,S as k,T as l}from"./chunk-QDRAKJSY.js";import"./chunk-NVJHA63C.js";import"./chunk-N6EWZGIX.js";import"./chunk-WP6KLXTP.js";import"./chunk-DP7RTNDM.js";import"./chunk-W4YR2RO2.js";import"./chunk-AFRHKA7B.js";import"./chunk-JHWBCDD2.js";import"./chunk-APKAW7LU.js";import"./chunk-ST6KPQOY.js";import"./chunk-GQ76J72O.js";import"./chunk-ZXR6GNEK.js";import"./chunk-J3SOEFRE.js";import"./chunk-SIU6STB2.js";import"./chunk-X5C5W3E4.js";import"./chunk-Q2WW2HF4.js";import"./chunk-DWADWDMU.js";import"./chunk-NO2HOK4B.js";import"./chunk-QD6IICK7.js";import"./chunk-VWTBHLMX.js";import"./chunk-S4ASFOJU.js";import"./chunk-CUZWGTXT.js";import"./chunk-PNWNVOEZ.js";import"./chunk-64P4QHSZ.js";import"./chunk-KSDVKLHN.js";import"./chunk-TFVUOC2C.js";import"./chunk-2GIDVZ4H.js";import"./chunk-VOS2IW4V.js";import"./chunk-FX3D7YON.js";import"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-QOYAX2FT.js";import"./chunk-SZJMS7K4.js";import"./chunk-7I7IEX4S.js";import"./chunk-DSYKYZMT.js";import"./chunk-N5NPJ6DJ.js";import"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.js";export{k as AgentRegistry,f as TRACE_STEP_SUMMARY_BYTES,c as buildEntryMeta,d as buildEventDigest,e as buildWikiContext,g as clipForTrace,j as emitTraceStepsFromStreamEvent,i as firstMissingRequiredTool,b as getGlobalRegistry,l as richReplyPrompt,a as setGlobalRegistry,h as tallyToolUses};
2
- //# sourceMappingURL=registry-KP3C4EZ4.js.map
1
+ import{I as a,J as b,K as c,L as d,M as e,N as f,O as g,P as h,Q as i,R as j,S as k,T as l}from"./chunk-L2K4N3DA.js";import"./chunk-4UMYRIEI.js";import"./chunk-N6EWZGIX.js";import"./chunk-WP6KLXTP.js";import"./chunk-DP7RTNDM.js";import"./chunk-W4YR2RO2.js";import"./chunk-AFRHKA7B.js";import"./chunk-A5ZCMRB3.js";import"./chunk-APKAW7LU.js";import"./chunk-KA2UIZXG.js";import"./chunk-GQ76J72O.js";import"./chunk-ILEC3IAV.js";import"./chunk-J3SOEFRE.js";import"./chunk-SIU6STB2.js";import"./chunk-X5C5W3E4.js";import"./chunk-Q2WW2HF4.js";import"./chunk-DWADWDMU.js";import"./chunk-NO2HOK4B.js";import"./chunk-QD6IICK7.js";import"./chunk-VWTBHLMX.js";import"./chunk-VXDM7JAT.js";import"./chunk-M6HJDSLS.js";import"./chunk-4DRNEOOW.js";import"./chunk-64P4QHSZ.js";import"./chunk-KSDVKLHN.js";import"./chunk-TFVUOC2C.js";import"./chunk-2GIDVZ4H.js";import"./chunk-VOS2IW4V.js";import"./chunk-FX3D7YON.js";import"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-QOYAX2FT.js";import"./chunk-SZJMS7K4.js";import"./chunk-7I7IEX4S.js";import"./chunk-DSYKYZMT.js";import"./chunk-N5NPJ6DJ.js";import"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.js";export{k as AgentRegistry,f as TRACE_STEP_SUMMARY_BYTES,c as buildEntryMeta,d as buildEventDigest,e as buildWikiContext,g as clipForTrace,j as emitTraceStepsFromStreamEvent,i as firstMissingRequiredTool,b as getGlobalRegistry,l as richReplyPrompt,a as setGlobalRegistry,h as tallyToolUses};
2
+ //# sourceMappingURL=registry-MUMQPZDM.js.map
@@ -1,2 +1,2 @@
1
- import{f as o}from"./chunk-AU6FFC4I.js";import"./chunk-ST6KPQOY.js";import"./chunk-GQ76J72O.js";import"./chunk-ZXR6GNEK.js";import"./chunk-QIJLFPWE.js";function s(r,n,t){let e=o(t.wikiDir,t.memo,{agentId:t.agentId,origin:t.reason==="continuity"?"continuity-memo":`rotation-memo:${t.reason}`,chat:`${t.channel}:${t.chatId}`});if(e.workState.trim()){let a=t.chatId.split(/[:@.]/).filter(Boolean).slice(0,4);r.addMemory(t.agentId,{agentId:t.agentId,category:"task-state",content:`[Rotation memo \xB7 ${t.reason}] ${e.workState}`,keywords:["rotation-memo",t.channel,...a],source:{channel:t.channel,chatId:t.chatId,sender:"system:rotation",date:new Date().toISOString().slice(0,10)}})}return n.setRotationMemo(t.agentId,t.channel,t.chatId,e.pinned,t.reason),{proposals:e.proposals.length,...e.error?{error:e.error}:{}}}export{s as storeRotationMemo};
2
- //# sourceMappingURL=rotation-memo-store-X63HYIMV.js.map
1
+ import{f as o}from"./chunk-KXR6GVL7.js";import"./chunk-KA2UIZXG.js";import"./chunk-GQ76J72O.js";import"./chunk-ILEC3IAV.js";import"./chunk-QIJLFPWE.js";function s(r,n,t){let e=o(t.wikiDir,t.memo,{agentId:t.agentId,origin:t.reason==="continuity"?"continuity-memo":`rotation-memo:${t.reason}`,chat:`${t.channel}:${t.chatId}`});if(e.workState.trim()){let a=t.chatId.split(/[:@.]/).filter(Boolean).slice(0,4);r.addMemory(t.agentId,{agentId:t.agentId,category:"task-state",content:`[Rotation memo \xB7 ${t.reason}] ${e.workState}`,keywords:["rotation-memo",t.channel,...a],source:{channel:t.channel,chatId:t.chatId,sender:"system:rotation",date:new Date().toISOString().slice(0,10)}})}return n.setRotationMemo(t.agentId,t.channel,t.chatId,e.pinned,t.reason),{proposals:e.proposals.length,...e.error?{error:e.error}:{}}}export{s as storeRotationMemo};
2
+ //# sourceMappingURL=rotation-memo-store-A4YW6FSK.js.map
@@ -1,2 +1,2 @@
1
- import{a,b}from"./chunk-LPWPFEIE.js";import"./chunk-RKPAVWXF.js";import"./chunk-NEC4RXFT.js";import"./chunk-JHWBCDD2.js";import"./chunk-APKAW7LU.js";import"./chunk-FCPTN6NF.js";import"./chunk-7I7IEX4S.js";import"./chunk-N5NPJ6DJ.js";import"./chunk-QIJLFPWE.js";export{b as resolveScheduleCaller,a as runScheduleTool};
2
- //# sourceMappingURL=schedule-tool-ZVKBZOVG.js.map
1
+ import{a,b}from"./chunk-YBLITM6C.js";import"./chunk-RKPAVWXF.js";import"./chunk-XMW422NO.js";import"./chunk-A5ZCMRB3.js";import"./chunk-APKAW7LU.js";import"./chunk-FCPTN6NF.js";import"./chunk-7I7IEX4S.js";import"./chunk-N5NPJ6DJ.js";import"./chunk-QIJLFPWE.js";export{b as resolveScheduleCaller,a as runScheduleTool};
2
+ //# sourceMappingURL=schedule-tool-BY72YNNU.js.map
@@ -1,2 +1,2 @@
1
- import{n as a,o as b,p as c,q as d,r as e,s as f}from"./chunk-JHWBCDD2.js";import"./chunk-APKAW7LU.js";import"./chunk-FCPTN6NF.js";import"./chunk-7I7IEX4S.js";import"./chunk-N5NPJ6DJ.js";import"./chunk-QIJLFPWE.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-5NBO3J2G.js.map
1
+ import{n as a,o as b,p as c,q as d,r as e,s as f}from"./chunk-A5ZCMRB3.js";import"./chunk-APKAW7LU.js";import"./chunk-FCPTN6NF.js";import"./chunk-7I7IEX4S.js";import"./chunk-N5NPJ6DJ.js";import"./chunk-QIJLFPWE.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-XWYFGG2S.js.map
@@ -1,2 +1,2 @@
1
- import{b as p}from"./chunk-LPWPFEIE.js";import"./chunk-RKPAVWXF.js";import"./chunk-NEC4RXFT.js";import"./chunk-JHWBCDD2.js";import"./chunk-APKAW7LU.js";import"./chunk-FCPTN6NF.js";import"./chunk-7I7IEX4S.js";import"./chunk-N5NPJ6DJ.js";import"./chunk-QIJLFPWE.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-ZENVUVBO.js.map
1
+ import{b as p}from"./chunk-YBLITM6C.js";import"./chunk-RKPAVWXF.js";import"./chunk-XMW422NO.js";import"./chunk-A5ZCMRB3.js";import"./chunk-APKAW7LU.js";import"./chunk-FCPTN6NF.js";import"./chunk-7I7IEX4S.js";import"./chunk-N5NPJ6DJ.js";import"./chunk-QIJLFPWE.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-ZUGNQZGI.js.map
@@ -1,2 +1,2 @@
1
- import"./chunk-VWTBHLMX.js";import{a as b}from"./chunk-S4ASFOJU.js";import{e as a}from"./chunk-CUZWGTXT.js";import"./chunk-PNWNVOEZ.js";import"./chunk-64P4QHSZ.js";import{a as c}from"./chunk-KSDVKLHN.js";import"./chunk-TFVUOC2C.js";import"./chunk-2GIDVZ4H.js";import"./chunk-VOS2IW4V.js";import"./chunk-FX3D7YON.js";import"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-QOYAX2FT.js";import"./chunk-SZJMS7K4.js";import"./chunk-7I7IEX4S.js";import"./chunk-N5NPJ6DJ.js";import"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.js";export{b as WikiHub,a as WikiStore,c as agenticQuery};
2
- //# sourceMappingURL=wiki-W6WI6HL3.js.map
1
+ import"./chunk-VWTBHLMX.js";import{a as b}from"./chunk-VXDM7JAT.js";import{e as a}from"./chunk-M6HJDSLS.js";import"./chunk-4DRNEOOW.js";import"./chunk-64P4QHSZ.js";import{a as c}from"./chunk-KSDVKLHN.js";import"./chunk-TFVUOC2C.js";import"./chunk-2GIDVZ4H.js";import"./chunk-VOS2IW4V.js";import"./chunk-FX3D7YON.js";import"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-QOYAX2FT.js";import"./chunk-SZJMS7K4.js";import"./chunk-7I7IEX4S.js";import"./chunk-N5NPJ6DJ.js";import"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.js";export{b as WikiHub,a as WikiStore,c as agenticQuery};
2
+ //# sourceMappingURL=wiki-LLL7VWRJ.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentix-cli",
3
- "version": "0.69.0",
3
+ "version": "0.69.2",
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": {
@@ -1,5 +0,0 @@
1
- import{b as g}from"./chunk-ST6KPQOY.js";import{c as l,j as u,k as d}from"./chunk-GQ76J72O.js";import{createHash as w}from"crypto";var v=(t,r)=>"fp-"+w("sha1").update(`${t}\0${r.toLowerCase().replace(/\s+/g," ").trim()}`).digest("hex").slice(0,10);function P(t){let r=t.replace(/^[-*•]\s*/,"").replace(/\s*\((?:[^)]*)\)\s*$/,"").trim(),s=r.match(/^(.{2,60}?)\s+(?:is|are|was|were|has been|went|got)\s+(.{1,80})$/i);if(!s)return{};let a=l(r);return{subject:s[1].trim(),attribute:a==="stable"?"state":`${a} status`,value:s[2].trim()}}function m(t,r,s){let a=t.at??new Date().toISOString(),e=d(s),o=l(s);return{id:r,status:"pending",claim:s,...P(s),volatility:o==="stable"?"work-state":o,source:e?.source??`${t.origin} (unchecked summary)`,verifiedAt:e?.verifiedAt??a,verifiedBy:t.agentId,origin:t.origin,agentId:t.agentId,...t.chat?{chat:t.chat}:{},createdAt:a}}function b(t,r){return r.length===0?[]:t.update(s=>{let a=[],e=!1;for(let o of r){let i=o.claim.replace(/^[-*•]\s*/,"").trim();if(!i)continue;let c=v(o.agentId,i),n=s.proposals.find(h=>h.id===c);if(n){a.push(n);continue}let p=m(o,c,i);s.proposals.push(p),a.push(p),e=!0}return{save:e,result:a}})}function S(t,r){return t.load().proposals.filter(s=>!r||s.status===r)}var f=(t,r)=>t.id===r||r.length>=6&&t.id.startsWith(r);function y(t,r){return t.load().proposals.find(s=>f(s,r))}function F(t,r,s){return t.update(a=>{let e=a.proposals.find(o=>f(o,r));if(!e)throw new Error(`no fact proposal "${r}"`);if(e.status!=="pending")throw new Error(`proposal ${e.id} is already ${e.status}`);return Object.assign(e,s),{save:!0,result:e}})}function k(t,r,s,a={}){let e=y(t,r);if(!e)throw new Error(`no fact proposal "${r}"`);if(e.status!=="pending")throw new Error(`proposal ${e.id} is already ${e.status}`);let o=a.subject??e.subject,i=a.attribute??e.attribute,c=a.value??e.value;if(!o||!i||!c)throw new Error("could not read a subject, attribute and value from the claim; pass --subject, --attribute and --value");let n=t.write({subject:o,attribute:i,value:c,source:a.source??e.source,verifiedBy:e.verifiedBy,verifiedAt:e.verifiedAt,volatility:e.volatility},{confirmedBy:s});return{proposal:F(t,e.id,{status:"approved",decidedAt:new Date().toISOString(),decidedBy:s}),write:n}}function x(t,r,s,a){return F(t,r,{status:"rejected",decidedAt:new Date().toISOString(),decidedBy:s,...a?{reason:a}:{}})}function A(t,r,s){let{workState:a,claims:e}=u(r);if(e.length===0)return{workState:a.join(`
2
- `),pinned:r,proposals:[]};let o=[],i;try{o=b(new g(t),e.map(n=>({claim:n,...s})))}catch(n){i=String(n?.message??n)}let c=e.map((n,p)=>`- UNVERIFIED claim (${o[p]?`wiki proposal ${o[p].id}`:"not checked"}): ${n.replace(/^[-*•]\s*/,"")}`);return{workState:a.join(`
3
- `),pinned:[...a,...c].join(`
4
- `),proposals:o,...i?{error:i}:{}}}export{P as a,b,S as c,k as d,x as e,A as f};
5
- //# sourceMappingURL=chunk-AU6FFC4I.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/wiki/facts/fact-proposals.ts"],"sourcesContent":["import { createHash } from \"crypto\"\nimport { citedCheck, classifyFact, splitMemo, type FactClass } from \"@/agents/fact-freshness\"\nimport { FactLedger, type FactInput, type WriteResult } from \"./ledger\"\n\n// --- Fact proposals: what a session summary claims, waiting for a check ---\n//\n// A rotation or continuity memo is a model's summary of a session. When it\n// says \"the vendor account is past due\", that is a claim nobody checked in\n// this form, and storing it as memory is how a stale note became a stated\n// fact (#273). So memo claims about outside systems come here instead,\n// with where they came from. They reach the ledger only when a person\n// approves one (a confirmation), never on their own.\n\nexport type FactProposalStatus = \"pending\" | \"approved\" | \"rejected\"\n\nexport interface FactProposal {\n id: string\n status: FactProposalStatus\n /** The line as the memo stated it. */\n claim: string\n /** Best guess at the structured fact, editable on approval. */\n subject?: string\n attribute?: string\n value?: string\n volatility: FactClass\n /** The check the memo cited, or where the claim came from. */\n source: string\n /** When that check happened, or when the memo was written. */\n verifiedAt: string\n verifiedBy: string\n /** e.g. \"rotation-memo:tier-2\" or \"continuity-memo\". */\n origin: string\n agentId: string\n chat?: string\n createdAt: string\n decidedAt?: string\n decidedBy?: string\n reason?: string\n}\n\nexport interface ProposalInput {\n claim: string\n agentId: string\n origin: string\n chat?: string\n at?: string\n}\n\nconst proposalId = (agentId: string, claim: string) =>\n \"fp-\" + createHash(\"sha1\").update(`${agentId}\\u0000${claim.toLowerCase().replace(/\\s+/g, \" \").trim()}`).digest(\"hex\").slice(0, 10)\n\n/** \"X is Y\" → subject X, value Y, attribute named after the class. */\nexport function parseClaim(claim: string): { subject?: string; attribute?: string; value?: string } {\n const text = claim.replace(/^[-*•]\\s*/, \"\").replace(/\\s*\\((?:[^)]*)\\)\\s*$/, \"\").trim()\n const m = text.match(/^(.{2,60}?)\\s+(?:is|are|was|were|has been|went|got)\\s+(.{1,80})$/i)\n if (!m) return {}\n const cls = classifyFact(text)\n return { subject: m[1].trim(), attribute: cls === \"stable\" ? \"state\" : `${cls} status`, value: m[2].trim() }\n}\n\nfunction newProposal(it: ProposalInput, id: string, claim: string): FactProposal {\n const at = it.at ?? new Date().toISOString()\n const cited = citedCheck(claim)\n const cls = classifyFact(claim)\n return {\n id, status: \"pending\", claim, ...parseClaim(claim),\n // A summary's claim is never stable: at best it was true that day.\n volatility: cls === \"stable\" ? \"work-state\" : cls,\n source: cited?.source ?? `${it.origin} (unchecked summary)`,\n verifiedAt: cited?.verifiedAt ?? at,\n verifiedBy: it.agentId,\n origin: it.origin, agentId: it.agentId,\n ...(it.chat ? { chat: it.chat } : {}),\n createdAt: at,\n }\n}\n\n/** Queue claims, under the ledger's lock. The same claim from the same\n * agent is kept once. Throws on an unreadable ledger rather than\n * writing over it. */\nexport function proposeFacts(ledger: FactLedger, items: ProposalInput[]): FactProposal[] {\n if (items.length === 0) return []\n return ledger.update((data) => {\n const out: FactProposal[] = []\n let added = false\n for (const it of items) {\n const claim = it.claim.replace(/^[-*•]\\s*/, \"\").trim()\n if (!claim) continue\n const id = proposalId(it.agentId, claim)\n const seen = data.proposals.find((p) => p.id === id)\n if (seen) { out.push(seen); continue }\n const p = newProposal(it, id, claim)\n data.proposals.push(p)\n out.push(p)\n added = true\n }\n return { save: added, result: out }\n })\n}\n\nexport function listFactProposals(ledger: FactLedger, status?: FactProposalStatus): FactProposal[] {\n return ledger.load().proposals.filter((p) => !status || p.status === status)\n}\n\nconst matches = (x: FactProposal, id: string) => x.id === id || (id.length >= 6 && x.id.startsWith(id))\n\nfunction findProposal(ledger: FactLedger, id: string): FactProposal | undefined {\n return ledger.load().proposals.find((x) => matches(x, id))\n}\n\n/** Decide a pending proposal under the ledger's lock. */\nfunction decide(ledger: FactLedger, id: string, fields: Partial<FactProposal>): FactProposal {\n return ledger.update((data) => {\n const p = data.proposals.find((x) => matches(x, id))\n if (!p) throw new Error(`no fact proposal \"${id}\"`)\n if (p.status !== \"pending\") throw new Error(`proposal ${p.id} is already ${p.status}`)\n Object.assign(p, fields)\n return { save: true, result: p }\n })\n}\n\n/**\n * Approve a claim: a person confirms it, so it is written to the ledger\n * with their name, even over a newer-dated value.\n */\nexport function approveFactProposal(\n ledger: FactLedger, id: string, by: string,\n edit: Partial<Pick<FactInput, \"subject\" | \"attribute\" | \"value\" | \"source\">> = {},\n): { proposal: FactProposal; write: WriteResult } {\n const p = findProposal(ledger, id)\n if (!p) throw new Error(`no fact proposal \"${id}\"`)\n if (p.status !== \"pending\") throw new Error(`proposal ${p.id} is already ${p.status}`)\n const subject = edit.subject ?? p.subject\n const attribute = edit.attribute ?? p.attribute\n const value = edit.value ?? p.value\n if (!subject || !attribute || !value) {\n throw new Error(\"could not read a subject, attribute and value from the claim; pass --subject, --attribute and --value\")\n }\n const write = ledger.write(\n { subject, attribute, value, source: edit.source ?? p.source, verifiedBy: p.verifiedBy, verifiedAt: p.verifiedAt, volatility: p.volatility },\n { confirmedBy: by },\n )\n const proposal = decide(ledger, p.id, { status: \"approved\", decidedAt: new Date().toISOString(), decidedBy: by })\n return { proposal, write }\n}\n\nexport function rejectFactProposal(ledger: FactLedger, id: string, by: string, reason?: string): FactProposal {\n return decide(ledger, id, { status: \"rejected\", decidedAt: new Date().toISOString(), decidedBy: by, ...(reason ? { reason } : {}) })\n}\n\n/**\n * Route a session memo: claims about outside systems become proposals;\n * the rest is work state. `pinned` is what the next fresh session reads,\n * with each claim marked unverified and pointing at its proposal.\n */\nexport function routeMemo(\n wikiDir: string, memo: string, ctx: { agentId: string; origin: string; chat?: string },\n): { workState: string; pinned: string; proposals: FactProposal[]; error?: string } {\n const { workState, claims } = splitMemo(memo)\n if (claims.length === 0) return { workState: workState.join(\"\\n\"), pinned: memo, proposals: [] }\n let proposals: FactProposal[] = []\n let error: string | undefined\n try {\n proposals = proposeFacts(new FactLedger(wikiDir), claims.map((claim) => ({ claim, ...ctx })))\n } catch (e) {\n // An unwritable wiki must not lose the memo: claims stay out of\n // memory and are pinned for this chat only, still marked.\n error = String((e as Error)?.message ?? e)\n }\n const flagged = claims.map((c, i) =>\n `- UNVERIFIED claim (${proposals[i] ? `wiki proposal ${proposals[i].id}` : \"not checked\"}): ${c.replace(/^[-*•]\\s*/, \"\")}`)\n return { workState: workState.join(\"\\n\"), pinned: [...workState, ...flagged].join(\"\\n\"), proposals, ...(error ? { error } : {}) }\n}\n"],"mappings":"8FAAA,OAAS,cAAAA,MAAkB,SAgD3B,IAAMC,EAAa,CAACC,EAAiBC,IACnC,MAAQC,EAAW,MAAM,EAAE,OAAO,GAAGF,MAAgBC,EAAM,YAAY,EAAE,QAAQ,OAAQ,GAAG,EAAE,KAAK,GAAG,EAAE,OAAO,KAAK,EAAE,MAAM,EAAG,EAAE,EAG5H,SAASE,EAAWF,EAAyE,CAClG,IAAMG,EAAOH,EAAM,QAAQ,YAAa,EAAE,EAAE,QAAQ,uBAAwB,EAAE,EAAE,KAAK,EAC/EI,EAAID,EAAK,MAAM,mEAAmE,EACxF,GAAI,CAACC,EAAG,MAAO,CAAC,EAChB,IAAMC,EAAMC,EAAaH,CAAI,EAC7B,MAAO,CAAE,QAASC,EAAE,CAAC,EAAE,KAAK,EAAG,UAAWC,IAAQ,SAAW,QAAU,GAAGA,WAAc,MAAOD,EAAE,CAAC,EAAE,KAAK,CAAE,CAC7G,CAEA,SAASG,EAAYC,EAAmBC,EAAYT,EAA6B,CAC/E,IAAMU,EAAKF,EAAG,IAAM,IAAI,KAAK,EAAE,YAAY,EACrCG,EAAQC,EAAWZ,CAAK,EACxBK,EAAMC,EAAaN,CAAK,EAC9B,MAAO,CACL,GAAAS,EAAI,OAAQ,UAAW,MAAAT,EAAO,GAAGE,EAAWF,CAAK,EAEjD,WAAYK,IAAQ,SAAW,aAAeA,EAC9C,OAAQM,GAAO,QAAU,GAAGH,EAAG,6BAC/B,WAAYG,GAAO,YAAcD,EACjC,WAAYF,EAAG,QACf,OAAQA,EAAG,OAAQ,QAASA,EAAG,QAC/B,GAAIA,EAAG,KAAO,CAAE,KAAMA,EAAG,IAAK,EAAI,CAAC,EACnC,UAAWE,CACb,CACF,CAKO,SAASG,EAAaC,EAAoBC,EAAwC,CACvF,OAAIA,EAAM,SAAW,EAAU,CAAC,EACzBD,EAAO,OAAQE,GAAS,CAC7B,IAAMC,EAAsB,CAAC,EACzBC,EAAQ,GACZ,QAAWV,KAAMO,EAAO,CACtB,IAAMf,EAAQQ,EAAG,MAAM,QAAQ,YAAa,EAAE,EAAE,KAAK,EACrD,GAAI,CAACR,EAAO,SACZ,IAAMS,EAAKX,EAAWU,EAAG,QAASR,CAAK,EACjCmB,EAAOH,EAAK,UAAU,KAAMI,GAAMA,EAAE,KAAOX,CAAE,EACnD,GAAIU,EAAM,CAAEF,EAAI,KAAKE,CAAI,EAAG,SAC5B,IAAM,EAAIZ,EAAYC,EAAIC,EAAIT,CAAK,EACnCgB,EAAK,UAAU,KAAK,CAAC,EACrBC,EAAI,KAAK,CAAC,EACVC,EAAQ,GAEV,MAAO,CAAE,KAAMA,EAAO,OAAQD,CAAI,CACpC,CAAC,CACH,CAEO,SAASI,EAAkBP,EAAoBQ,EAA6C,CACjG,OAAOR,EAAO,KAAK,EAAE,UAAU,OAAQM,GAAM,CAACE,GAAUF,EAAE,SAAWE,CAAM,CAC7E,CAEA,IAAMC,EAAU,CAACC,EAAiBf,IAAee,EAAE,KAAOf,GAAOA,EAAG,QAAU,GAAKe,EAAE,GAAG,WAAWf,CAAE,EAErG,SAASgB,EAAaX,EAAoBL,EAAsC,CAC9E,OAAOK,EAAO,KAAK,EAAE,UAAU,KAAMU,GAAMD,EAAQC,EAAGf,CAAE,CAAC,CAC3D,CAGA,SAASiB,EAAOZ,EAAoBL,EAAYkB,EAA6C,CAC3F,OAAOb,EAAO,OAAQE,GAAS,CAC7B,IAAMI,EAAIJ,EAAK,UAAU,KAAMQ,GAAMD,EAAQC,EAAGf,CAAE,CAAC,EACnD,GAAI,CAACW,EAAG,MAAM,IAAI,MAAM,qBAAqBX,IAAK,EAClD,GAAIW,EAAE,SAAW,UAAW,MAAM,IAAI,MAAM,YAAYA,EAAE,iBAAiBA,EAAE,QAAQ,EACrF,cAAO,OAAOA,EAAGO,CAAM,EAChB,CAAE,KAAM,GAAM,OAAQP,CAAE,CACjC,CAAC,CACH,CAMO,SAASQ,EACdd,EAAoBL,EAAYoB,EAChCC,EAA+E,CAAC,EAChC,CAChD,IAAMV,EAAIK,EAAaX,EAAQL,CAAE,EACjC,GAAI,CAACW,EAAG,MAAM,IAAI,MAAM,qBAAqBX,IAAK,EAClD,GAAIW,EAAE,SAAW,UAAW,MAAM,IAAI,MAAM,YAAYA,EAAE,iBAAiBA,EAAE,QAAQ,EACrF,IAAMW,EAAUD,EAAK,SAAWV,EAAE,QAC5BY,EAAYF,EAAK,WAAaV,EAAE,UAChCa,EAAQH,EAAK,OAASV,EAAE,MAC9B,GAAI,CAACW,GAAW,CAACC,GAAa,CAACC,EAC7B,MAAM,IAAI,MAAM,uGAAuG,EAEzH,IAAMC,EAAQpB,EAAO,MACnB,CAAE,QAAAiB,EAAS,UAAAC,EAAW,MAAAC,EAAO,OAAQH,EAAK,QAAUV,EAAE,OAAQ,WAAYA,EAAE,WAAY,WAAYA,EAAE,WAAY,WAAYA,EAAE,UAAW,EAC3I,CAAE,YAAaS,CAAG,CACpB,EAEA,MAAO,CAAE,SADQH,EAAOZ,EAAQM,EAAE,GAAI,CAAE,OAAQ,WAAY,UAAW,IAAI,KAAK,EAAE,YAAY,EAAG,UAAWS,CAAG,CAAC,EAC7F,MAAAK,CAAM,CAC3B,CAEO,SAASC,EAAmBrB,EAAoBL,EAAYoB,EAAYO,EAA+B,CAC5G,OAAOV,EAAOZ,EAAQL,EAAI,CAAE,OAAQ,WAAY,UAAW,IAAI,KAAK,EAAE,YAAY,EAAG,UAAWoB,EAAI,GAAIO,EAAS,CAAE,OAAAA,CAAO,EAAI,CAAC,CAAG,CAAC,CACrI,CAOO,SAASC,EACdC,EAAiBC,EAAcC,EACmD,CAClF,GAAM,CAAE,UAAAC,EAAW,OAAAC,CAAO,EAAIC,EAAUJ,CAAI,EAC5C,GAAIG,EAAO,SAAW,EAAG,MAAO,CAAE,UAAWD,EAAU,KAAK;AAAA,CAAI,EAAG,OAAQF,EAAM,UAAW,CAAC,CAAE,EAC/F,IAAIK,EAA4B,CAAC,EAC7BC,EACJ,GAAI,CACFD,EAAY/B,EAAa,IAAIiC,EAAWR,CAAO,EAAGI,EAAO,IAAK1C,IAAW,CAAE,MAAAA,EAAO,GAAGwC,CAAI,EAAE,CAAC,CAC9F,OAASO,EAAP,CAGAF,EAAQ,OAAQE,GAAa,SAAWA,CAAC,CAC3C,CACA,IAAMC,EAAUN,EAAO,IAAI,CAACO,EAAGC,IAC7B,uBAAuBN,EAAUM,CAAC,EAAI,iBAAiBN,EAAUM,CAAC,EAAE,KAAO,mBAAmBD,EAAE,QAAQ,YAAa,EAAE,GAAG,EAC5H,MAAO,CAAE,UAAWR,EAAU,KAAK;AAAA,CAAI,EAAG,OAAQ,CAAC,GAAGA,EAAW,GAAGO,CAAO,EAAE,KAAK;AAAA,CAAI,EAAG,UAAAJ,EAAW,GAAIC,EAAQ,CAAE,MAAAA,CAAM,EAAI,CAAC,CAAG,CAClI","names":["createHash","proposalId","agentId","claim","createHash","parseClaim","text","m","cls","classifyFact","newProposal","it","id","at","cited","citedCheck","proposeFacts","ledger","items","data","out","added","seen","p","listFactProposals","status","matches","x","findProposal","decide","fields","approveFactProposal","by","edit","subject","attribute","value","write","rejectFactProposal","reason","routeMemo","wikiDir","memo","ctx","workState","claims","splitMemo","proposals","error","FactLedger","e","flagged","c","i"]}
@@ -1,109 +0,0 @@
1
- import{a as T,b as P,c as _,d as M}from"./chunk-PNWNVOEZ.js";import{b as Q}from"./chunk-64P4QHSZ.js";import{a as Z,b as ee,c as te,d as se,e as re}from"./chunk-TFVUOC2C.js";import{v as X,w as de}from"./chunk-VOS2IW4V.js";import{a as Y,b as le}from"./chunk-FX3D7YON.js";import{c as E,d as L}from"./chunk-QOYAX2FT.js";import{o as V,p as ce}from"./chunk-SZJMS7K4.js";var A={version:2,levels:[{id:"category",description:"Top-level kind of work. Closed set \u2014 pick the closest fit.",axes:[{name:"kind",type:"enum",values:["code","ops","support","admin","knowledge","social","system"],description:"Which category this work belongs in."}]},{id:"verb",description:"Specific intent \u2014 verb-level only, NOT client/project-bound.",axes:[{name:"name",type:"free",description:"Lower-kebab dot-namespaced verb. Examples: review.merge-request, fix.bug, investigate.error, deploy.staging, deploy.production, rollback.release, spec.feature, triage.issue, document.feature, chat.greeting, chat.support-request, schedule.add, config.change, ingest.contact, transcribe.audio, brief.daily, summarize.thread, plan.work."}]}],leafInput:{name:"input",type:"enum",values:["telegram","whatsapp","slack","discord","gitlab-mr","gitlab-issue","github-issue","github-pr","cron","webhook","mesh","http"],description:"Where the message entered the system."},leafOutput:{name:"output",type:"free",description:"One short sentence describing what the agent is expected to produce. Generic \u2014 refers to the verb's outcome, not the specific client/project (those are on the event metadata already)."}},G=[{category:"code",verb:"review.merge-request",description:"Review a GitLab MR or GitHub PR"},{category:"code",verb:"review.code-change",description:"General code review (snippet, diff)"},{category:"code",verb:"fix.bug",description:"Fix a reported bug"},{category:"code",verb:"implement.feature",description:"Build a new feature"},{category:"code",verb:"investigate.error",description:"Investigate a failing test, exception, pipeline"},{category:"code",verb:"refactor.code",description:"Restructure existing code without behaviour change"},{category:"code",verb:"spec.feature",description:"Write or update a feature spec / RFC"},{category:"code",verb:"triage.issue",description:"Classify, label, or assign an issue"},{category:"code",verb:"answer.code-question",description:"Answer a code-related question"},{category:"ops",verb:"deploy.staging",description:"Deploy to a staging/preview environment"},{category:"ops",verb:"deploy.production",description:"Deploy to production"},{category:"ops",verb:"rollback.release",description:"Roll back a release"},{category:"ops",verb:"investigate.incident",description:"Investigate a production incident"},{category:"ops",verb:"monitor.system",description:"Check system status / metrics"},{category:"ops",verb:"rotate.credential",description:"Rotate a token, key, certificate"},{category:"ops",verb:"audit.security",description:"Review for security issues"},{category:"support",verb:"chat.greeting",description:"A casual hello, no actionable request"},{category:"support",verb:"chat.support-request",description:"End-user / customer asking for help"},{category:"support",verb:"chat.casual",description:"Informal back-and-forth chat"},{category:"support",verb:"answer.question",description:"Answer an open-ended question"},{category:"support",verb:"route.request",description:"Forward a request to the right agent"},{category:"admin",verb:"config.change",description:"Change agentx.json / environment / config"},{category:"admin",verb:"schedule.add",description:"Add a new cron / scheduled task"},{category:"admin",verb:"schedule.remove",description:"Remove or disable a schedule"},{category:"admin",verb:"token.create",description:"Mint a scoped API token"},{category:"admin",verb:"agent.add",description:"Configure a new agent"},{category:"admin",verb:"channel.add",description:"Wire up a new channel"},{category:"knowledge",verb:"document.feature",description:"Write or update documentation"},{category:"knowledge",verb:"summarize.thread",description:"Summarize a long conversation/thread"},{category:"knowledge",verb:"research.topic",description:"Investigate / gather info on a topic"},{category:"knowledge",verb:"wiki.absorb",description:"Roll raw entries into typed wiki articles"},{category:"social",verb:"brief.daily",description:"Compose a daily brief / digest"},{category:"social",verb:"draft.post",description:"Draft a marketing post / announcement"},{category:"social",verb:"report.weekly",description:"Compose a weekly status report"},{category:"system",verb:"classify.intent",description:"Internal: graph-classifier sub-call"}];import{readFileSync as C,writeFileSync as B,appendFileSync as pe,existsSync as N,mkdirSync as J,renameSync as he}from"fs";import{resolve as R,dirname as ne}from"path";import{createHash as ge}from"crypto";var H=class{baseDir;log;constructor(e={}){this.baseDir=e.baseDir??R(process.cwd(),".agentx/graph"),this.log=e.log??console.error.bind(console,"[graph]"),J(this.baseDir,{recursive:!0})}schemaPath(){return R(this.baseDir,"schema.json")}nodesPath(){return R(this.baseDir,"nodes.json")}indexPath(){return R(this.baseDir,"index.json")}classificationsPath(){return R(this.baseDir,"classifications.jsonl")}loadSchema(){let e=this.schemaPath();if(!N(e))return this.saveSchema(A),this.log("seeded starter schema at",e),A;let t=C(e,"utf-8"),s=T.safeParse(JSON.parse(t));if(!s.success)throw new Error(`Invalid ${e}: ${s.error.issues.map(r=>r.message).join("; ")}`);if((s.data.version??1)<(A.version??2)){let r=e.replace(/\.json$/,`.v${s.data.version??1}.bak.json`);try{B(r,t),this.log(`migrated graph schema v${s.data.version??1} -> v${A.version}; old saved at ${r}`)}catch(n){this.log(`could not back up old schema: ${n?.message??n}`)}this.saveSchema(A);let a=this.nodesPath();if(N(a)){let n=a.replace(/\.json$/,".v1.bak.json");try{B(n,C(a,"utf-8")),this.log(`archived v1 nodes.json -> ${n}`)}catch(i){this.log(`could not back up old nodes: ${i?.message??i}`)}try{let i=ie();this.saveNodes(i)}catch(i){this.log(`could not seed v2 nodes: ${i?.message??i}`)}}return A}return s.data}saveSchema(e){let t=T.safeParse(e);if(!t.success)throw new Error(`Refusing to save invalid schema: ${t.error.issues.map(s=>s.message).join("; ")}`);F(this.schemaPath(),t.data)}loadNodes(){let e=this.nodesPath();if(!N(e)){let r=ie();return this.saveNodes(r),r}let t=C(e,"utf-8"),s=_.safeParse(JSON.parse(t));if(!s.success)throw new Error(`Invalid ${e}: ${s.error.issues.map(r=>r.message).join("; ")}`);return s.data}saveNodes(e){let t=_.safeParse(e);if(!t.success)throw new Error(`Refusing to save invalid nodes file: ${t.error.issues.map(s=>s.message).join("; ")}`);F(this.nodesPath(),t.data)}validateNode(e,t,s){let r=t.levels.find(i=>i.id===e.level);if(!r)throw new Error(`Unknown level: "${e.level}"`);let a=r.axes.filter(i=>!i.optional).filter(i=>!(i.name in e.axes));if(a.length)throw new Error(`Node ${e.id} (${e.level}) missing required axes: ${a.map(i=>i.name).join(", ")}`);for(let i of r.axes){let o=e.axes[i.name];if(o!=null){if(i.type==="enum"&&i.values&&!i.values.includes(o))throw new Error(`Node ${e.id}: axis ${i.name}="${o}" not in enum ${JSON.stringify(i.values)}`);if(i.type==="ref"){if(!s.some(c=>c.id===o))throw new Error(`Node ${e.id}: axis ${i.name}="${o}" refers to unknown node`);if(i.refLevel){let c=s.find(l=>l.id===o);if(c.level!==i.refLevel)throw new Error(`Node ${e.id}: axis ${i.name} expected level "${i.refLevel}" but got "${c.level}"`)}}}}let n=t.levels.findIndex(i=>i.id===e.level);if(n===0){if(e.parentId!==null)throw new Error(`Root-level node ${e.id} must have parentId: null`)}else{if(!e.parentId)throw new Error(`Non-root node ${e.id} must have a parentId`);let i=s.find(c=>c.id===e.parentId);if(!i)throw new Error(`Node ${e.id}: parent "${e.parentId}" not found`);let o=t.levels.findIndex(c=>c.id===i.level);if(o<0||o>=n)throw new Error(`Node ${e.id} at level "${e.level}" has parent at level "${i.level}" \u2014 parent must be at a higher level`)}}commitNodesAlongPath(e,t,s,r){let a=[],n=[],i=new Date().toISOString();for(let o=0;o<e.length;o++){let c=e[o],l=this.loadNodes().nodes;if(l.find(m=>m.id===c)){n.push(c);continue}let p=0;for(let m=o-1;m>=0;m--){let b=e[m],W=l.find(k=>k.id===b)||a.find(k=>k.id===b);if(W){p=s.levels.findIndex(k=>k.id===W.level)+1;break}}let g=t[c]??{},d=null;for(let m=p;m<s.levels.length;m++){let b=s.levels[m];if(b.axes.filter(k=>!k.optional).filter(k=>!(k.name in g)).length===0){d=b.id,p=m+1;break}}if(!d&&p<s.levels.length&&(d=s.levels[p].id,p++),!d)throw new Error(`Can't place node ${c} \u2014 no schema level left (cursor=${p}, levels=${s.levels.length})`);let h=null,f=s.levels.findIndex(m=>m.id===d);for(let m=o-1;m>=0;m--){let b=e[m],W=l.find(D=>D.id===b)||a.find(D=>D.id===b);if(!W)continue;let k=s.levels.findIndex(D=>D.id===W.level);if(k>=0&&k<f){h=b;break}}let u={id:c,level:d,parentId:h,axes:g,createdAt:i,createdBy:r};this.addNode(u),a.push(u)}return{added:a,skipped:n}}addNode(e){let t=this.loadSchema(),s=this.loadNodes();if(s.nodes.some(r=>r.id===e.id))throw new Error(`Node id already exists: ${e.id}`);return this.validateNode(e,t,[...s.nodes,e]),s.nodes.push(e),this.saveNodes(s),e}appendClassification(e){let t=P.safeParse(e);if(!t.success){let a=t.error.issues.map(n=>`${n.path.join(".")}: ${n.message}`).join(" \xB7 ");return this.log(`skipped invalid classification \u2014 ${a} \xB7`,`path=${JSON.stringify(e.path)}`,`axes-keys=${JSON.stringify(Object.keys(e.proposedAxes||{}))}`),!1}let s=JSON.stringify(t.data)+`
2
- `,r=this.classificationsPath();return N(r)||J(ne(r),{recursive:!0}),pe(r,s),!0}listPendingClassifications(e=200){return this.listByStatus("pending",e)}listAllClassifications(){return this.readAllCollapsed()}listByStatus(e,t=200){return this.readAllCollapsed().filter(r=>r.status===e).slice(0,t)}readAllCollapsed(){let e=this.classificationsPath();if(!N(e))return[];let s=C(e,"utf-8").split(`
3
- `).filter(Boolean),r=new Map;for(let a of s)try{let n=P.safeParse(JSON.parse(a));if(!n.success)continue;r.set(n.data.msgHash,n.data)}catch{}return Array.from(r.values()).sort((a,n)=>a.ts<n.ts?1:-1)}updateClassificationStatus(e,t){let r=this.readAllCollapsed().find(n=>n.msgHash===e);if(!r)return null;let a={...r,status:t.status,ts:new Date().toISOString()};if(t.reviewer||t.reviewReason){let n=` \xB7 ${t.reviewer?`reviewer=${t.reviewer}`:""}${t.reviewReason?` \xB7 ${t.reviewReason}`:""}`;a.preview=((r.preview||"")+n).slice(0,500)}return this.appendClassification(a),a}readRecentClassifications(e=50){let t=this.classificationsPath();if(!N(t))return[];let r=C(t,"utf-8").split(`
4
- `).filter(Boolean),a=[];for(let n=r.length-1;n>=0&&a.length<e;n--)try{let i=P.safeParse(JSON.parse(r[n]));i.success&&a.push(i.data)}catch{}return a}fingerprint(e){let s=[e.text.toLowerCase().replace(/\s+/g," ").trim(),e.channel??"",e.sender??""].join("");return ge("sha256").update(s).digest("hex").slice(0,32)}loadIndex(){let e=this.indexPath();if(!N(e))return{version:1,entries:{}};let t=C(e,"utf-8"),s=M.safeParse(JSON.parse(t));if(!s.success)throw new Error(`Invalid ${e}: ${s.error.issues.map(r=>r.message).join("; ")}`);return s.data}saveIndex(e){let t=M.safeParse(e);if(!t.success)throw new Error(`Refusing to save invalid index: ${t.error.issues.map(s=>s.message).join("; ")}`);F(this.indexPath(),t.data)}getFingerprint(e){return this.loadIndex().entries[e]}setFingerprint(e,t){let s=this.loadIndex();s.entries[e]={...t,fingerprint:e,updatedAt:new Date().toISOString()},this.saveIndex(s)}updateNodeAxes(e,t){let s=this.loadSchema(),r=this.loadNodes(),a=r.nodes.find(i=>i.id===e);if(!a)throw new Error(`Node not found: ${e}`);let n={...a,axes:t};return this.validateNode(n,s,r.nodes.map(i=>i.id===e?n:i)),r.nodes=r.nodes.map(i=>i.id===e?n:i),this.saveNodes(r),n}deleteNode(e){let t=this.loadNodes(),s=t.nodes.find(a=>a.parentId===e);if(s)throw new Error(`Cannot delete "${e}" \u2014 child node "${s.id}" still points to it`);let r=t.nodes.find(a=>Object.values(a.axes).some(n=>n===e));if(r)throw new Error(`Cannot delete "${e}" \u2014 node "${r.id}" references it via an axis`);t.nodes=t.nodes.filter(a=>a.id!==e),this.saveNodes(t)}approveClassification(e){if(this.getFingerprint(e.msgHash))return;let t=this.loadSchema(),s=new Set(this.loadNodes().nodes.map(r=>r.id));for(let r=0;r<e.path.length;r++){let a=e.path[r];if(s.has(a))continue;let n=t.levels[r]?.id;if(!n)break;let i=e.proposedAxes?.[a]??{},o=r===0?null:e.path[r-1];this.addNode({id:a,level:n,parentId:o,axes:i,createdAt:new Date().toISOString(),createdBy:e.agentId}),s.add(a)}this.setFingerprint(e.msgHash,{path:e.path,leaf:e.leaf}),this.appendClassification({...e,status:"approved",ts:new Date().toISOString()})}rejectClassification(e){this.appendClassification({...e,status:"rejected",ts:new Date().toISOString()})}};function F(w,e){J(ne(w),{recursive:!0});let t=`${w}.tmp-${process.pid}`;B(t,JSON.stringify(e,null,2)),he(t,w)}function ie(){let w=new Date().toISOString(),e=[],t=new Set;for(let s of G)t.has(s.category)||(e.push({id:s.category,level:"category",parentId:null,axes:{kind:s.category},createdAt:w,createdBy:"starter"}),t.add(s.category));for(let s of G)e.push({id:s.verb,level:"verb",parentId:s.category,axes:{name:s.verb,...s.description?{description:s.description}:{}},createdAt:w,createdBy:"starter"});return{version:1,nodes:e}}le();ce();import{createHash as ue}from"crypto";var U=class{store;daemonUrl;token;draftAgent;autoApprove;autoApproveStructure;classifierModel;classifierProviderName;providerInstance;log;constructor(e){this.store=e.store,this.daemonUrl=e.daemonUrl.replace(/\/+$/,""),this.token=e.token,this.draftAgent=e.draftAgent,this.autoApprove=e.autoApproveConfidence??1,this.autoApproveStructure=e.autoApproveStructure??"extend-leaves",this.classifierModel=e.classifierModel??"claude-haiku-4-5-20251001",this.classifierProviderName=e.classifierProvider??"claude-code",this.log=e.log??console.error.bind(console,"[classifier]")}getProvider(){return this.providerInstance||(this.providerInstance=V(this.classifierProviderName)),this.providerInstance}async classify(e){let t=this.store.fingerprint({text:e.text,channel:e.channel,sender:e.sender}),s=this.store.getFingerprint(t);if(s)return this.store.appendClassification({ts:new Date().toISOString(),msgHash:t,agentId:e.agentId,channel:e.channel,sender:e.sender,path:s.path,proposedAxes:{},leaf:s.leaf,source:"cache",status:"approved",preview:e.text.slice(0,200)}),{path:s.path,pathId:q(s.path),pathLabel:z(s.path,this.store.loadNodes().nodes),axes:{},leaf:s.leaf,source:"cache",status:"approved"};let r=this.store.loadSchema(),a=this.store.loadNodes().nodes,n=await this.proposePath(e,r,a).catch(u=>(this.log("LLM proposal failed:",u?.message||u),null));if(!n)return null;let{path:i,proposedAxes:o,confidence:c,leaf:l}=n;if(i.length===0)return null;let v={ts:new Date().toISOString(),msgHash:t,agentId:e.agentId,channel:e.channel,sender:e.sender,path:i,proposedAxes:o,leaf:l,source:"llm",status:"pending",confidence:c,preview:e.text.slice(0,200)},p=new Set(a.map(u=>u.id)),g=i.map((u,m)=>p.has(u)?-1:m).filter(u=>u>=0),d=!1;if(this.autoApproveStructure==="any")d=!0;else if(this.autoApproveStructure==="extend-leaves"){let u=g.length===0,m=g.length===1&&g[0]===i.length-1;d=u||m}let h=c!==void 0&&c>=this.autoApprove,f="pending";if(d||h)try{this.commitNewNodes(i,o,r,a,e.sender),this.store.setFingerprint(t,{path:i,leaf:l}),f="approved"}catch(u){this.log("auto-approve failed \u2014 staying pending \xB7",`path=${JSON.stringify(i)}`,`reason=${(u?.message||u).toString().slice(0,200)}`)}return v.status=f,this.store.appendClassification(v),{path:i,pathId:q(i),pathLabel:z(i,this.store.loadNodes().nodes),axes:o,leaf:l,source:"llm",status:f,confidence:c}}async proposePath(e,t,s){let r=s.map(d=>({id:d.id,level:d.level,parentId:d.parentId,axes:d.axes})),a=["You are the intent classifier for AgentX. You answer ONE question:",'"what kind of work does this message describe?" \u2014 verb-level only.',"","IMPORTANT \u2014 what NOT to encode in the path:","- Client / company / project / team names. Those are already on the event"," metadata (project, channel, agentId). Embedding them in the path causes"," duplicate nodes (one per client) for the same verb.","- The specific subject (issue number, file name, person name). Same reason.","- The agent's name or role. Pick the verb the *requester* intended.","","SCHEMA (fixed levels \u2014 pick one node per level):","```json",JSON.stringify(t,null,2),"```","","EXISTING NODES (prefer reusing these; only invent a new node when no","existing one fits):","```json",JSON.stringify(r,null,2),"```","","MESSAGE:","```",e.text.slice(0,2e3),"```",`channel: ${e.channel??"?"}`,`sender: ${e.sender??"?"}`,"","TASK:","1. Classify into 'category' (closed enum): code, ops, support, admin,"," knowledge, social, system. Pick the closest fit.","2. Pick or propose a 'verb' node. Verb ids are dot-namespaced lower-kebab,",' e.g. "review.merge-request", "deploy.staging", "investigate.error",',' "chat.greeting", "fix.bug". Reuse an existing verb when the message is'," the same kind of work as something already classified, even when the"," client / project / subject differs.","","Examples (right vs wrong):",'- "Please review MR #957 on globex/system" \u2192 ["code", "review.merge-request"]',' NOT ["business", "acme", "globex-v2", "review-mr-957-system"]','- "Deploy initech-v2 to staging please" \u2192 ["ops", "deploy.staging"]',' NOT ["business", "acme", "initech-v2", "deploy-initech-v2-to-staging"]','- "Hello Atlas" \u2192 ["support", "chat.greeting"]',"","NODE ID RULES (strict \u2014 invalid ids get dropped):","- lowercase-kebab + dots only: [a-z0-9][a-z0-9._-]*","- no spaces, no uppercase, no Arabic/other non-Latin",'- verb ids should use a "category.specific" or "verb.modifier" shape',"","Return ONE JSON object on one line, no prose, no fences:",' { "path": string[], "proposedAxes": { [nodeId]: { [axisName]: string } }, "leaf": { "input"?: string, "output"?: string }, "confidence": number }',"confidence in [0,1]. Prefer low confidence over guessing."].join(`
5
- `),n=await this.callProvider(a),i=Y(n);if(!i||!Array.isArray(i.path))return null;let o=/^[a-z0-9][a-z0-9._-]*$/,c=new Map,l=i.path.filter(d=>typeof d=="string"&&d.length>0).map(d=>{let h=d.trim(),f=ae(h);return h!==f&&c.set(h,f),f}).filter(d=>o.test(d));if(l.length===0)return null;let v={};if(i.proposedAxes&&typeof i.proposedAxes=="object")for(let[d,h]of Object.entries(i.proposedAxes)){if(!h||typeof h!="object")continue;let f=c.get(d)??ae(d);if(!f)continue;let u={};for(let[m,b]of Object.entries(h))typeof b=="string"&&(u[m]=b);!u.name&&d!==f&&(u.name=d.trim()),v[f]=u}let p={};i.leaf&&typeof i.leaf=="object"&&(typeof i.leaf.input=="string"&&(p.input=i.leaf.input),typeof i.leaf.output=="string"&&(p.output=i.leaf.output));let g=typeof i.confidence=="number"?Math.max(0,Math.min(1,i.confidence)):void 0;return{path:l,proposedAxes:v,confidence:g,leaf:p}}commitNewNodes(e,t,s,r,a){this.store.commitNodesAlongPath(e,t,s,a)}async callProvider(e){let t=this.getProvider(),s=new AbortController,r=setTimeout(()=>s.abort(),3e4);try{return(await t.generate([{role:"system",content:"You are a taxonomy classifier. Respond with a single JSON object on one line. No prose, no code fences."},{role:"user",content:e}],{model:this.classifierModel,maxTokens:800})).content||""}finally{clearTimeout(r)}}};function ae(w){let e=w.trim().toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/^[-_]+|[-_]+$/g,"").replace(/-{2,}/g,"-");return e?/^[a-z0-9]/.test(e)?e:`n-${e}`.replace(/[-_]+$/,""):""}function q(w){return ue("sha1").update(w.join("")).digest("hex").slice(0,16)}function z(w,e){return w.map(t=>{let s=e.find(a=>a.id===t);return s&&(s.axes?.name||s.axes?.what)||t}).join(" \u203A ")}function K(w,e){if(w.length===0||e.length===0)return 0;let t=0;for(let r=0;r<Math.min(w.length,e.length)&&w[r]===e[r];r++)t++;if(t===0)return 0;let s=Math.max(w.length,e.length);return t/s}import{readFileSync as I,writeFileSync as x,appendFileSync as fe,existsSync as $,mkdirSync as j,readdirSync as O,statSync as me}from"fs";import{resolve as y,join as ve,relative as S,dirname as ye}from"path";de();var oe=class{baseDir;rawDir;log;constructor(e=y(process.cwd(),".agentx/wiki"),t=console.error.bind(console,"[wiki]")){this.baseDir=e,this.rawDir=y(e,"raw/entries"),this.log=t,j(this.rawDir,{recursive:!0}),j(y(e,"raw"),{recursive:!0}),this.ensureSchema()}canRead(e,t){return e.access==="public"?!0:t?!!(e.owner===t||e.access==="shared"&&e.sharedWith?.includes(t)):!1}canWrite(e,t){return e.owner===t}addEntry(e){let t=`${e.date}_${e.id}.md`,s=y(this.rawDir,t),r=["---",`id: ${e.id}`,`date: ${e.date}`,`agent: ${e.agentId}`,`source: ${e.source}`];if(e.sourceContext&&r.push(`context: ${e.sourceContext}`),e.meta)for(let[a,n]of Object.entries(e.meta))r.push(`${a}: ${JSON.stringify(n)}`);return r.push("---","",e.content),x(s,r.join(`
6
- `)),this.appendLog("ingest",`${e.id} from ${e.agentId} via ${e.source}`),t}listEntries(e){if(!$(this.rawDir))return[];let t=O(this.rawDir).filter(r=>r.endsWith(".md")).sort(),s=[];for(let r of t){let a=I(y(this.rawDir,r),"utf-8"),n=this.parseEntry(a,r);n&&(e?.agentId&&n.agentId!==e.agentId||e?.after&&n.date<e.after||e?.before&&n.date>e.before||s.push(n))}return s}parseEntry(e,t){let s=e.match(/^---\n([\s\S]*?)\n---\n([\s\S]*)$/);if(!s)return null;let r=s[1],a=s[2].trim(),n=c=>r.match(new RegExp(`^${c}:\\s*(.+)$`,"m"))?.[1]?.trim()||"",i=new Set(["id","date","agent","source","context"]),o={};for(let c of r.split(`
7
- `)){let l=c.match(/^(\w+):\s*(.+)$/);if(!(!l||i.has(l[1])))try{o[l[1]]=JSON.parse(l[2])}catch{o[l[1]]=l[2].trim()}}return{id:n("id")||t.replace(".md",""),date:n("date"),agentId:n("agent"),source:n("source"),sourceContext:n("context")||void 0,content:a,meta:Object.keys(o).length>0?o:void 0}}writeArticle(e,t,s,r){let a=this.readArticle(e);if(a&&!this.canWrite(a.meta,r))return this.log(`Permission denied: "${r}" cannot write "${e}" (owner: ${a.meta.owner})`),!1;t.type&&!Q(t.type)&&(this.log(`Dropping invalid article type "${t.type}" for "${e}" \u2014 enum is [person, project, place, concept, event, decision, pattern]`),t={...t,type:void 0});let n=y(this.baseDir,e);a&&this.saveVersion(e,n),j(ye(n),{recursive:!0});let i=["---",`title: "${t.title}"`];t.type&&i.push(`type: ${t.type}`),t.related?.length&&i.push(`related: [${t.related.map(c=>`"${c}"`).join(", ")}]`),i.push(`tags: [${(t.tags||[]).map(c=>`"${c}"`).join(", ")}]`,`owner: ${t.owner}`,`access: ${t.access}`),t.sharedWith?.length&&i.push(`shared_with: [${t.sharedWith.map(c=>`"${c}"`).join(", ")}]`),i.push(`created: ${t.created}`,`last_updated: ${t.lastUpdated}`,`sources: [${t.sources.map(c=>`"${c}"`).join(", ")}]`),t.graphPath?.length&&i.push(`graph_path: [${t.graphPath.map(c=>`"${c}"`).join(", ")}]`),i.push("---","",s),x(n,i.join(`
8
- `));let o=a?"update":"create";return this.appendLog(o,`${t.title} [${(t.tags||[]).slice(0,5).join(", ")}] by ${r} at ${e}`),!0}saveVersion(e,t){try{if(!$(t))return;let s=I(t,"utf-8"),r=new Date().toISOString().replace(/[:.]/g,"-"),a=y(this.baseDir,"_versions",e.replace(/\.md$/,""));j(a,{recursive:!0}),x(y(a,`${r}.md`),s)}catch{}}getVersions(e){let t=y(this.baseDir,"_versions",e.replace(/\.md$/,""));if(!$(t))return[];try{return O(t).filter(s=>s.endsWith(".md")).sort().reverse().map(s=>({timestamp:s.replace(/\.md$/,"").replace(/-/g,(r,a)=>a<19?a===10?"T":a===13||a===16?":":"-":r),path:y(t,s)}))}catch{return[]}}restoreVersion(e,t){let r=this.getVersions(e).find(a=>a.timestamp.startsWith(t));if(!r)return!1;try{let a=I(r.path,"utf-8"),n=y(this.baseDir,e);return this.saveVersion(e,n),x(n,a),this.appendLog("restore",`${e} restored to ${t}`),!0}catch{return!1}}readArticle(e){let t=y(this.baseDir,e);if(!$(t))return null;let s=I(t,"utf-8");return this.parseArticle(s,e)}readArticleAs(e,t){let s=this.readArticle(e);return!s||!this.canRead(s.meta,t)?null:s}parseArticle(e,t){let s=e.match(/^---\n([\s\S]*?)\n---\n([\s\S]*)$/);if(!s)return null;let r=s[1],a=s[2].trim(),n=d=>r.match(new RegExp(`^${d}:\\s*(.+)$`,"m"))?.[1]?.trim().replace(/^"(.*)"$/,"$1")||"",i=d=>{let h=r.match(new RegExp(`^${d}:\\s*\\[(.*)\\]$`,"m"));return h?h[1].split(",").map(f=>f.trim().replace(/^"(.*)"$/,"$1")).filter(Boolean):[]},o=n("type")||n("kind"),l=new Set(["person","project","place","concept","event","decision","pattern"]).has(o)?o:void 0,v=i("tags").filter((d,h,f)=>d&&f.indexOf(d)===h),p=i("related"),g=i("graph_path");return{meta:{title:n("title"),type:l,related:p.length?p:void 0,tags:v,owner:n("owner"),access:n("access")||"public",sharedWith:i("shared_with"),created:n("created"),lastUpdated:n("last_updated"),sources:i("sources"),graphPath:g.length?g:void 0},content:a,path:t}}listArticles(e){let t=[];return this.walkDir(this.baseDir,s=>{if(!s.endsWith(".md"))return;let r=S(this.baseDir,s);if(r.startsWith("raw/")||r.startsWith("_"))return;let a=this.readArticle(r);a&&this.canRead(a.meta,e)&&t.push(a)}),t}search(e,t,s=10){let r=e.toLowerCase(),a=[];if(this.walkDir(this.baseDir,p=>{if(!p.endsWith(".md"))return;let g=S(this.baseDir,p);if(g.startsWith("raw/")||g.startsWith("_"))return;let d=this.readArticle(g);!d||!this.canRead(d.meta,t)||a.push(d)}),a.length===0)return[];let n=a.map(p=>p.content),i=y(this.baseDir,"_bm25_cache.json"),o=L(n,i),c=E(e,o),l=new Map(c.map(p=>[p.docIndex,p.score]));return a.map((p,g)=>{let d=l.get(g)??0;return p.meta.title.toLowerCase().includes(r)&&(d+=10),p.meta.tags?.some(h=>h.toLowerCase().includes(r))&&(d+=5),{article:p,score:d}}).filter(p=>p.score>0).sort((p,g)=>g.score-p.score).slice(0,s).map(p=>p.article)}async findRelevantReranked(e,t,s=10,r={}){let a=Math.max(s,r.shortlist??ee),n=this.findRelevant(e,t,a);if(n.length<2)return n.slice(0,s);let i=n.map((l,v)=>({id:`c${v}`,title:l.meta.title||`(untitled ${v})`,tags:l.meta.tags,excerpt:l.content})),o=await X(Z,te({query:e,candidates:i,excerptChars:r.excerptChars}),se(i),{incumbent:{best:i[0].id},features:{agent:t??"unknown"}});return!o||o.mode!=="active"?n.slice(0,s):re(o.answers,i).ranked.map(l=>n[Number(l.slice(1))]).filter(l=>!!l).slice(0,s)}findRelevant(e,t,s=3,r,a={graph:.6,bm25:.4}){let n=[];if(this.walkDir(this.baseDir,h=>{if(!h.endsWith(".md"))return;let f=S(this.baseDir,h);if(f.startsWith("raw/")||f.startsWith("_"))return;let u=this.readArticle(f);!u||!this.canRead(u.meta,t)||n.push(u)}),n.length===0)return[];let i=n.map(h=>`${h.meta.title} ${(h.meta.tags||[]).join(" ")} ${h.content}`),o=y(this.baseDir,"_bm25_relevance_cache.json"),c=L(i,o),l=E(e,c),v=l.reduce((h,f)=>Math.max(h,f.score),0)||1,p=new Map(l.map(h=>[h.docIndex,h.score/v])),g=!!(r&&r.length>0);return n.map((h,f)=>{let u=p.get(f)??0,m=0;g&&h.meta.graphPath?.length&&(m=K(r,h.meta.graphPath));let b=g?a.graph*m+a.bm25*u:u;return{article:h,score:b}}).filter(h=>h.score>0).sort((h,f)=>f.score-h.score).slice(0,s).map(h=>h.article)}buildContext(e,t=4e3){if(e.length===0)return"";let s=["[Wiki Knowledge]"],r=0;for(let a of e){let n=`
9
- ## ${a.meta.title} [${(a.meta.tags||[]).slice(0,3).join(", ")}]`,i=a.content.length>600?a.content.slice(0,600)+"...":a.content,o=n+`
10
- `+i;if(r+o.length>t)break;s.push(o),r+=o.length}return s.push(`
11
- [End Wiki Knowledge]`),s.join(`
12
- `)}rebuildIndex(){let e=[],t=new Map;this.walkDir(this.baseDir,n=>{if(!n.endsWith(".md"))return;let i=S(this.baseDir,n);if(i.startsWith("raw/")||i.startsWith("_"))return;let o=this.readArticle(i);if(!o)return;let c=o.content.match(/\[\[([^\]]+)\]\]/g)||[];for(let v of c){let p=v.replace(/\[\[|\]\]/g,"");t.set(p,(t.get(p)||0)+1)}let l=[o.meta.title.toLowerCase()];o.meta.tags&&l.push(...o.meta.tags.map(v=>v.toLowerCase())),e.push({path:i,title:o.meta.title,type:o.meta.type,related:o.meta.related,tags:o.meta.tags||[],owner:o.meta.owner,access:o.meta.access,sharedWith:o.meta.sharedWith,aliases:l,backlinks:t.get(o.meta.title)||0,sources:o.meta.sources,lastUpdated:o.meta.lastUpdated})});let s={articles:e,lastRebuilt:new Date().toISOString()};x(y(this.baseDir,"_index.json"),JSON.stringify(s,null,2)),this.writeCatalog(e,s.lastRebuilt);let r=["# Wiki Index","",`Last rebuilt: ${s.lastRebuilt}`,""],a=new Map;for(let n of e){let i=n.access||"public",o=a.get(i)||[];o.push(n),a.set(i,o)}for(let[n,i]of Array.from(a.entries()).sort()){r.push(`## ${n}`,"");for(let o of i.sort((c,l)=>c.title.localeCompare(l.title))){let c=o.type?` [${o.type}]`:"";r.push(`- [${o.title}](${o.path})${c} \u2014 owner: ${o.owner}`)}r.push("")}return x(y(this.baseDir,"WIKI.md"),r.join(`
13
- `)),this.log(`Index rebuilt: ${e.length} articles`),this.appendLog("rebuild-index",`${e.length} articles indexed`),s}writeCatalog(e,t){let s=["person","project","place","concept","event","decision","pattern","untyped"],r={person:"## People",project:"## Projects",place:"## Places",concept:"## Concepts",event:"## Events",decision:"## Decisions",pattern:"## Patterns",untyped:"## Untyped (needs migration)"},a=new Map;for(let i of e){let o=i.type||"untyped",c=a.get(o)||[];c.push(i),a.set(o,c)}let n=["# Wiki Content Catalog","",`_Last rebuilt: ${t}_`,"","Articles grouped by type. Agentic query walks this file first to pick candidates.",""];for(let i of s){let o=a.get(i);if(!(!o||o.length===0)){n.push(r[i]||`## ${i}`,"");for(let c of o.sort((l,v)=>l.title.localeCompare(v.title))){let l=c.access==="private"?" (private)":c.access==="shared"?" (shared)":"",v=c.related?.length?` \u2192 [[${c.related.slice(0,3).join("]], [[")}]]${c.related.length>3?", \u2026":""}`:"";n.push(`- [${c.title}](${c.path})${l}${v}`)}n.push("")}}x(y(this.baseDir,"_index.md"),n.join(`
14
- `))}stats(){let e=0,t={},s={},r={};this.walkDir(this.baseDir,n=>{if(!n.endsWith(".md"))return;let i=S(this.baseDir,n);if(i.startsWith("raw/")||i.startsWith("_")||i==="WIKI.md")return;let o=this.readArticle(i);if(o){e++;for(let c of o.meta.tags||[])t[c]=(t[c]||0)+1;s[o.meta.access]=(s[o.meta.access]||0)+1,r[o.meta.owner]=(r[o.meta.owner]||0)+1}});let a=$(this.rawDir)?O(this.rawDir).filter(n=>n.endsWith(".md")).length:0;return{totalArticles:e,totalEntries:a,articlesByType:t,articlesByAccess:s,articlesByOwner:r}}appendLog(e,t){let s=y(this.baseDir,"log.md"),a=`## [${new Date().toISOString().replace("T"," ").slice(0,16)}] ${e} | ${t}
15
-
16
- `;$(s)||x(s,`# Wiki Log
17
-
18
- Chronological record of all wiki operations.
19
-
20
- `),fe(s,a)}getLog(e=20){let t=y(this.baseDir,"log.md");return $(t)?I(t,"utf-8").split(/^## /m).filter(a=>a.startsWith("[")).slice(-e).map(a=>a.trim()):[]}ensureSchema(){let e=y(this.baseDir,"_schema.md");if($(e))return;x(e,`# Wiki Schema
21
-
22
- A personal wiki maintained by LLMs. Karpathy pattern: plain files, aggressive tagging,
23
- structure emerges from data. The wiki is a compounding artifact.
24
-
25
- ## Structure
26
-
27
- \`\`\`
28
- wiki/
29
- _schema.md # This file
30
- worldview.md # YOUR mental model \u2014 the LLM reads this during absorb
31
- raw/entries/ # Immutable raw sources (conversations, imports, anything)
32
- [LLM-chosen dirs] # Structure emerges from data \u2014 the LLM picks paths
33
- \`\`\`
34
-
35
- The LLM decides how to organize articles. You describe YOUR world in worldview.md.
36
-
37
- ## Article Format
38
-
39
- \`\`\`yaml
40
- ---
41
- title: "Staging Deployment Process"
42
- tags: ["deploy", "staging", "devops", "process", "2026-04-06"]
43
- owner: devops-agent
44
- access: public
45
- created: 2026-04-06
46
- last_updated: 2026-04-06
47
- sources: ["entry-id-1", "entry-id-2"]
48
- ---
49
-
50
- Article content with [[wikilinks]] and section tags.
51
-
52
- ## Deploy Steps
53
- <!-- tags: process, runbook, staging -->
54
- Content specific to this section...
55
- \`\`\`
56
-
57
- ## Tags
58
-
59
- Tags are the primary context-narrowing mechanism. The more tags, the better.
60
-
61
- Tag aggressively:
62
- - **Who**: people, agents, teams involved
63
- - **What**: project, client, topic, technology
64
- - **When**: dates, periods, milestones
65
- - **Where**: server, environment, channel
66
- - **How**: process, decision, pattern
67
- - **Your terms**: whatever vocabulary makes sense in YOUR world
68
-
69
- Section tags (\`<!-- tags: ... -->\`) let different parts of an article
70
- match different queries. A deploy article might have sections tagged
71
- "runbook" and "incident" separately.
72
-
73
- ## Operations
74
-
75
- ### Absorb
76
- Read raw entries \u2192 read worldview.md \u2192 tag aggressively \u2192 create/update articles.
77
- Also identify GAPS: "We mention X but have no article for it."
78
-
79
- ### Query
80
- Match by tags first \u2192 then keyword within matched articles \u2192 synthesize.
81
- If agent is working on a specific project, only send content tagged for that project.
82
-
83
- ### Lint
84
- Check for: orphan articles, broken [[wikilinks]], untagged articles,
85
- articles over 100 lines that should split, mentioned-but-missing topics.
86
-
87
- ## Worldview
88
-
89
- Edit \`worldview.md\` to describe YOUR world. This is not a schema \u2014 it's your
90
- mental model. The LLM reads it during absorb to understand where things go.
91
-
92
- Example worldview.md:
93
- \`\`\`
94
- I'm the founder of Acme Corp.
95
- We build software products.
96
- Our agents: Marketing Bot, DevOps Bot, Coordinator.
97
- Clients: ClientA (enterprise), ClientB (startup).
98
- Infrastructure: local dev machine, cloud server.
99
- We use GitLab for version control.
100
- \`\`\`
101
- `),this.log("Created _schema.md")}extractWikilinks(e){return(e.match(/\[\[([^\]]+)\]\]/g)||[]).map(s=>s.replace(/\[\[|\]\]/g,""))}buildBacklinks(){let e={};return this.walkDir(this.baseDir,t=>{if(!t.endsWith(".md"))return;let s=S(this.baseDir,t);if(s.startsWith("raw/")||s.startsWith("_")||s==="WIKI.md"||s==="log.md")return;let r=I(t,"utf-8"),a=this.extractWikilinks(r);for(let n of a)e[n]||(e[n]=[]),e[n].push(s)}),x(y(this.baseDir,"_backlinks.json"),JSON.stringify(e,null,2)),e}getBacklinks(e){let t=y(this.baseDir,"_backlinks.json");if(!$(t))return[];try{return JSON.parse(I(t,"utf-8"))[e]||[]}catch{return[]}}findByTags(e,t,s=10){let r=e.map(n=>n.toLowerCase()),a=[];return this.walkDir(this.baseDir,n=>{if(!n.endsWith(".md"))return;let i=S(this.baseDir,n);if(i.startsWith("raw/")||i.startsWith("_"))return;let o=this.readArticle(i);if(!o||t&&!this.canRead(o.meta,t))return;let c=(o.meta.tags||[]).map(g=>g.toLowerCase()),l=(o.content.match(/<!--\s*tags?:\s*([^>]+)\s*-->/gi)||[]).flatMap(g=>g.replace(/<!--\s*tags?:\s*|\s*-->/gi,"").split(",").map(d=>d.trim().toLowerCase())),v=[...c,...l],p=r.filter(g=>v.includes(g)).length;p>0&&a.push({article:o,score:p})}),a.sort((n,i)=>i.score-n.score).slice(0,s).map(n=>n.article)}getAllTags(){let e=new Map;return this.walkDir(this.baseDir,t=>{if(!t.endsWith(".md"))return;let s=S(this.baseDir,t);if(s.startsWith("raw/")||s.startsWith("_"))return;let r=this.readArticle(s);if(r?.meta.tags)for(let a of r.meta.tags)e.set(a,(e.get(a)||0)+1)}),e}getWorldview(){let e=y(this.baseDir,"worldview.md");return $(e)?I(e,"utf-8"):null}setWorldview(e){x(y(this.baseDir,"worldview.md"),e),this.appendLog("worldview","Updated worldview")}lint(){let e=[],t=new Set,s=new Map,r=new Map;this.walkDir(this.baseDir,n=>{if(!n.endsWith(".md"))return;let i=S(this.baseDir,n);if(i.startsWith("raw/")||i.startsWith("_")||i==="WIKI.md"||i==="log.md")return;let o=this.readArticle(i);if(!o)return;t.add(o.meta.title),r.set(o.meta.title,i);let c=this.extractWikilinks(o.content);s.set(i,c);let l=o.content.split(`
102
- `).length;l>100&&e.push({type:"bloated",article:i,message:`${l} lines \u2014 consider splitting`}),o.meta.sources?.length||e.push({type:"unsourced",article:i,message:"No sources listed in frontmatter"}),l<10&&o.content.trim().length<100&&e.push({type:"stub",article:i,message:"Very short article \u2014 needs enrichment"})});for(let[n,i]of s)for(let o of i)t.has(o)||e.push({type:"broken-link",article:n,message:`[[${o}]] \u2014 target article not found`});let a=this.buildBacklinks();for(let[n,i]of r)(!a[n]||a[n].length===0)&&e.push({type:"orphan",article:i,message:`No other articles link to "${n}"`});return this.appendLog("lint",`Found ${e.length} issues`),e}getUnabsorbedEntries(){let e=new Set;return this.walkDir(this.baseDir,s=>{if(!s.endsWith(".md"))return;let r=S(this.baseDir,s);if(r.startsWith("raw/")||r.startsWith("_"))return;let a=this.readArticle(r);if(a?.meta.sources)for(let n of a.meta.sources)e.add(n)}),this.listEntries().filter(s=>!e.has(s.id))}buildAbsorbPrompt(e=20){let t=this.getUnabsorbedEntries().slice(0,e);if(t.length===0)return null;let s=t.map(r=>`[${r.date} ${r.agentId} via ${r.source}] ${r.content.slice(0,200)}`).join(`
103
-
104
- `);return`/wiki absorb
105
-
106
- There are ${t.length} unprocessed entries. Read each, understand what it means, and create or update wiki articles.
107
-
108
- ${s}`}walkDir(e,t){if($(e))for(let s of O(e)){let r=ve(e,s);me(r).isDirectory()?this.walkDir(r,t):t(r)}}};export{A as a,H as b,U as c,z as d,oe as e};
109
- //# sourceMappingURL=chunk-CUZWGTXT.js.map