agentix-cli 0.178.0 → 0.179.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/dist/{board-dashboard-I2S6CBKR.js → board-dashboard-J3SNLS2I.js} +420 -366
  2. package/dist/board-dashboard-J3SNLS2I.js.map +1 -0
  3. package/dist/{chunk-MTX4UPNB.js → chunk-DODL5POT.js} +3 -3
  4. package/dist/chunk-DODL5POT.js.map +1 -0
  5. package/dist/{chunk-XVTD6I34.js → chunk-EFGAPAYZ.js} +2 -2
  6. package/dist/{chunk-BU57BT5P.js → chunk-HYLVA6VA.js} +2 -2
  7. package/dist/{chunk-GQJMY5NH.js → chunk-QQ3YFYC2.js} +2 -2
  8. package/dist/{chunk-YWEGKAE2.js → chunk-S5A7QZVQ.js} +2 -2
  9. package/dist/{chunk-N4TDTQOQ.js → chunk-TLSMX7LZ.js} +2 -2
  10. package/dist/cli.js +1 -1
  11. package/dist/{enrich-FPK3OW77.js → enrich-MZMIQ3SV.js} +2 -2
  12. package/dist/{event-levels-NBOMTB23.js → event-levels-PCFARGKL.js} +2 -2
  13. package/dist/index.js +1 -1
  14. package/dist/{load-LQ2I2PQI.js → load-Q3HCFXDT.js} +2 -2
  15. package/dist/{program-CP4OE2OF.js → program-YXQEKD2W.js} +5 -5
  16. package/dist/{rules-5ZZQZLQA.js → rules-FBOLGE2S.js} +2 -2
  17. package/dist/wiki-enrich-7KX7YTZ4.js +2 -0
  18. package/package.json +1 -1
  19. package/dist/board-dashboard-I2S6CBKR.js.map +0 -1
  20. package/dist/chunk-MTX4UPNB.js.map +0 -1
  21. package/dist/wiki-enrich-DCTK64E4.js +0 -2
  22. /package/dist/{chunk-XVTD6I34.js.map → chunk-EFGAPAYZ.js.map} +0 -0
  23. /package/dist/{chunk-BU57BT5P.js.map → chunk-HYLVA6VA.js.map} +0 -0
  24. /package/dist/{chunk-GQJMY5NH.js.map → chunk-QQ3YFYC2.js.map} +0 -0
  25. /package/dist/{chunk-YWEGKAE2.js.map → chunk-S5A7QZVQ.js.map} +0 -0
  26. /package/dist/{chunk-N4TDTQOQ.js.map → chunk-TLSMX7LZ.js.map} +0 -0
  27. /package/dist/{enrich-FPK3OW77.js.map → enrich-MZMIQ3SV.js.map} +0 -0
  28. /package/dist/{event-levels-NBOMTB23.js.map → event-levels-PCFARGKL.js.map} +0 -0
  29. /package/dist/{load-LQ2I2PQI.js.map → load-Q3HCFXDT.js.map} +0 -0
  30. /package/dist/{program-CP4OE2OF.js.map → program-YXQEKD2W.js.map} +0 -0
  31. /package/dist/{rules-5ZZQZLQA.js.map → rules-FBOLGE2S.js.map} +0 -0
  32. /package/dist/{wiki-enrich-DCTK64E4.js.map → wiki-enrich-7KX7YTZ4.js.map} +0 -0
@@ -1,4 +1,4 @@
1
- import t from"chalk";import{spawn as S}from"child_process";import{resolve as j}from"path";var E=l=>l||j(process.cwd(),".agentx/wiki");function N(l){return async d=>{let{claudeCliEnv:e}=await import("./workspace-env-UOK5MMKD.js"),h=["-p","-","--output-format","json","--max-turns","1","--model",l,"--tools","","--strict-mcp-config","--mcp-config",'{"mcpServers":{}}',"--settings",'{"disableAllHooks":true}',"--setting-sources","","--no-session-persistence"],y=await new Promise(($,a)=>{let s=S("claude",h,{env:e(),stdio:["pipe","pipe","pipe"]}),p="",g="",i=setTimeout(()=>s.kill("SIGTERM"),24e4);s.stdout.on("data",r=>{p+=r}),s.stderr.on("data",r=>{g+=r}),s.on("error",r=>{clearTimeout(i),a(r)}),s.on("close",r=>{clearTimeout(i),r===0?$(p):a(new Error(`claude exited ${r}: ${g.trim().slice(0,200)}`))}),s.stdin.end(d)}),c=JSON.parse(y);if(c.is_error)throw new Error(`model error: ${String(c.result).slice(0,200)}`);return{text:String(c.result??""),costUsd:Number(c.total_cost_usd)||0}}}function I(l){l.command("enrich [entities...]").description("write a full overview, sourced typed facts and linked history on entity pages (person, organization, project, place, assets)").option("--dir <path>","wiki directory (default .agentx/wiki)").option("--types <list>","comma-separated entity types","person,organization,project,place,device,server,app,domain,account").option("--max <n>","most entities per run","10").option("--max-cost <usd>","stop before the next call once the run spent this much","1").option("--model <m>","model","sonnet").option("--force","redo entities whose sources did not change").option("--dry-run","show what would be written, write nothing").option("--create <title>","first create a page for a thing other pages only name, then enrich it (needs --as and --owner)").option("--as <type>","type of the page --create makes, e.g. organization").option("--owner <agent>","agent whose wiki gets the page --create makes").option("--json","print the run as JSON").action(async(d,e)=>{let{WikiHub:h}=await import("./hub-EBZO3VRY.js"),{GraphCache:y}=await import("./graph-ZVKV3JBD.js"),{loadOntology:c}=await import("./load-LQ2I2PQI.js"),{loadRoster:$}=await import("./roster-BZGKG2ZA.js"),{ENRICH_TYPES:a,loadEnrichState:s,runEnrich:p,saveEnrichState:g}=await import("./enrich-FPK3OW77.js"),i=E(e.dir),r=e.types.split(",").map(o=>o.trim()).filter(Boolean),b=r.filter(o=>!a.includes(o));if(b.length){console.error(t.red(` not an entity type this job handles: ${b.join(", ")} (use ${a.join(", ")})`)),process.exitCode=1;return}let x=Number(e.max);if(!Number.isInteger(x)||x<1){console.error(t.red(" --max must be a whole number of entities, 1 or more")),process.exitCode=1;return}let w=Number(e.maxCost);if(!Number.isFinite(w)||w<=0){console.error(t.red(" --max-cost must be a positive number of dollars")),process.exitCode=1;return}let m=new h(i,()=>{});if(e.create){let{createEntityPage:o}=await import("./enrich-FPK3OW77.js");if(!e.as||!a.includes(e.as)||!e.owner){console.error(t.red(` --create needs --as <${a.join("|")}> and --owner <agent>`)),process.exitCode=1;return}if(m.syncedFrom(e.owner)){console.error(t.red(` ${e.owner}'s pages are copied from another node; pick an agent that runs here`)),process.exitCode=1;return}if(e.dryRun)console.log(t.dim(` --dry-run: would create "${e.create}" (${e.as}) in ${e.owner}'s wiki`));else{let f=o(m,e.create,e.as,e.owner,new Date().toISOString().slice(0,10));console.log(f?t.green(` created ${e.owner}/${f}`):t.dim(` ${e.owner} already has a page titled "${e.create}"`))}d=[...d,e.create],r.includes(e.as)||r.push(e.as)}let{ontology:v}=c(i),k=new y().get(m,v,$(i,m.listAgents([]),v.agent_names)),C=s(i),u=await p(m,k,N(e.model),{types:r,only:d,max:x,maxCostUsd:w,dryRun:!!e.dryRun,force:!!e.force,today:new Date().toISOString().slice(0,10),save:o=>g(i,o)},C);if(e.json){console.log(JSON.stringify(u,null,2));return}for(let o of u.outcomes){let f=o.status==="written"?t.green("\u2713"):o.status==="dry-run"?t.cyan("~"):t.yellow("\xB7");console.log(` ${f} ${o.title} ${t.dim(`${o.status} \xB7 ${o.page??"no page"} \xB7 overview ${o.overview?"yes":"no"} \xB7 ${o.statements} facts \xB7 ${o.links} links \xB7 $${o.costUsd.toFixed(3)}`)}`);for(let n of o.facts??[])console.log(t.dim(` fact: ${n.property} \u2192 ${n.value}${n.role?` (${n.role})`:""} \xB7 source ${n.source}`));for(let n of o.dropped.slice(0,6))console.log(t.dim(` dropped: ${n}`));o.preview&&console.log(t.dim(o.preview.split(`
1
+ import t from"chalk";import{spawn as S}from"child_process";import{resolve as j}from"path";var E=l=>l||j(process.cwd(),".agentx/wiki");function N(l){return async d=>{let{claudeCliEnv:e}=await import("./workspace-env-UOK5MMKD.js"),h=["-p","-","--output-format","json","--max-turns","1","--model",l,"--tools","","--strict-mcp-config","--mcp-config",'{"mcpServers":{}}',"--settings",'{"disableAllHooks":true}',"--setting-sources","","--no-session-persistence"],y=await new Promise(($,a)=>{let s=S("claude",h,{env:e(),stdio:["pipe","pipe","pipe"]}),p="",g="",i=setTimeout(()=>s.kill("SIGTERM"),24e4);s.stdout.on("data",r=>{p+=r}),s.stderr.on("data",r=>{g+=r}),s.on("error",r=>{clearTimeout(i),a(r)}),s.on("close",r=>{clearTimeout(i),r===0?$(p):a(new Error(`claude exited ${r}: ${g.trim().slice(0,200)}`))}),s.stdin.end(d)}),c=JSON.parse(y);if(c.is_error)throw new Error(`model error: ${String(c.result).slice(0,200)}`);return{text:String(c.result??""),costUsd:Number(c.total_cost_usd)||0}}}function I(l){l.command("enrich [entities...]").description("write a full overview, sourced typed facts and linked history on entity pages (person, organization, project, place, assets)").option("--dir <path>","wiki directory (default .agentx/wiki)").option("--types <list>","comma-separated entity types","person,organization,project,place,device,server,app,domain,account").option("--max <n>","most entities per run","10").option("--max-cost <usd>","stop before the next call once the run spent this much","1").option("--model <m>","model","sonnet").option("--force","redo entities whose sources did not change").option("--dry-run","show what would be written, write nothing").option("--create <title>","first create a page for a thing other pages only name, then enrich it (needs --as and --owner)").option("--as <type>","type of the page --create makes, e.g. organization").option("--owner <agent>","agent whose wiki gets the page --create makes").option("--json","print the run as JSON").action(async(d,e)=>{let{WikiHub:h}=await import("./hub-EBZO3VRY.js"),{GraphCache:y}=await import("./graph-ZVKV3JBD.js"),{loadOntology:c}=await import("./load-Q3HCFXDT.js"),{loadRoster:$}=await import("./roster-BZGKG2ZA.js"),{ENRICH_TYPES:a,loadEnrichState:s,runEnrich:p,saveEnrichState:g}=await import("./enrich-MZMIQ3SV.js"),i=E(e.dir),r=e.types.split(",").map(o=>o.trim()).filter(Boolean),b=r.filter(o=>!a.includes(o));if(b.length){console.error(t.red(` not an entity type this job handles: ${b.join(", ")} (use ${a.join(", ")})`)),process.exitCode=1;return}let x=Number(e.max);if(!Number.isInteger(x)||x<1){console.error(t.red(" --max must be a whole number of entities, 1 or more")),process.exitCode=1;return}let w=Number(e.maxCost);if(!Number.isFinite(w)||w<=0){console.error(t.red(" --max-cost must be a positive number of dollars")),process.exitCode=1;return}let m=new h(i,()=>{});if(e.create){let{createEntityPage:o}=await import("./enrich-MZMIQ3SV.js");if(!e.as||!a.includes(e.as)||!e.owner){console.error(t.red(` --create needs --as <${a.join("|")}> and --owner <agent>`)),process.exitCode=1;return}if(m.syncedFrom(e.owner)){console.error(t.red(` ${e.owner}'s pages are copied from another node; pick an agent that runs here`)),process.exitCode=1;return}if(e.dryRun)console.log(t.dim(` --dry-run: would create "${e.create}" (${e.as}) in ${e.owner}'s wiki`));else{let f=o(m,e.create,e.as,e.owner,new Date().toISOString().slice(0,10));console.log(f?t.green(` created ${e.owner}/${f}`):t.dim(` ${e.owner} already has a page titled "${e.create}"`))}d=[...d,e.create],r.includes(e.as)||r.push(e.as)}let{ontology:v}=c(i),k=new y().get(m,v,$(i,m.listAgents([]),v.agent_names)),C=s(i),u=await p(m,k,N(e.model),{types:r,only:d,max:x,maxCostUsd:w,dryRun:!!e.dryRun,force:!!e.force,today:new Date().toISOString().slice(0,10),save:o=>g(i,o)},C);if(e.json){console.log(JSON.stringify(u,null,2));return}for(let o of u.outcomes){let f=o.status==="written"?t.green("\u2713"):o.status==="dry-run"?t.cyan("~"):t.yellow("\xB7");console.log(` ${f} ${o.title} ${t.dim(`${o.status} \xB7 ${o.page??"no page"} \xB7 overview ${o.overview?"yes":"no"} \xB7 ${o.statements} facts \xB7 ${o.links} links \xB7 $${o.costUsd.toFixed(3)}`)}`);for(let n of o.facts??[])console.log(t.dim(` fact: ${n.property} \u2192 ${n.value}${n.role?` (${n.role})`:""} \xB7 source ${n.source}`));for(let n of o.dropped.slice(0,6))console.log(t.dim(` dropped: ${n}`));o.preview&&console.log(t.dim(o.preview.split(`
2
2
  `).slice(0,12).map(n=>` | ${n}`).join(`
3
3
  `)))}u.outcomes.length===0&&console.log(t.dim(" nothing to do: no entity of these types changed since the last run (--force redoes them)")),console.log(t.dim(` spent $${u.costUsd.toFixed(3)} of $${w}${u.capped?" \xB7 stopped at the cap":""}`))})}export{N as a,I as b};
4
- //# sourceMappingURL=chunk-N4TDTQOQ.js.map
4
+ //# sourceMappingURL=chunk-TLSMX7LZ.js.map
package/dist/cli.js CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
- import{b as o}from"./chunk-OSH2PEBH.js";import"./chunk-QIJLFPWE.js";var e=o(process.versions.node);e&&(console.error(e),process.exit(1));var{buildProgram:s}=await import("./program-CP4OE2OF.js"),{installCliSignalExit:r}=await import("./signal-exit-WL7G3EEZ.js"),{applyConnectAttemptTimeout:i,configPathFromArgv:a,readConnectAttemptTimeout:n}=await import("./net-family-X2P3OVDP.js");r();i(n(process.cwd(),a(process.argv.slice(2))));var t=await s();process.argv.slice(2).length===0?t.outputHelp():t.parse();
2
+ import{b as o}from"./chunk-OSH2PEBH.js";import"./chunk-QIJLFPWE.js";var e=o(process.versions.node);e&&(console.error(e),process.exit(1));var{buildProgram:s}=await import("./program-YXQEKD2W.js"),{installCliSignalExit:r}=await import("./signal-exit-WL7G3EEZ.js"),{applyConnectAttemptTimeout:i,configPathFromArgv:a,readConnectAttemptTimeout:n}=await import("./net-family-X2P3OVDP.js");r();i(n(process.cwd(),a(process.argv.slice(2))));var t=await s();process.argv.slice(2).length===0?t.outputHelp():t.parse();
3
3
  //# sourceMappingURL=cli.js.map
@@ -1,2 +1,2 @@
1
- import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q}from"./chunk-YWEGKAE2.js";import"./chunk-XVTD6I34.js";import"./chunk-QAWKN2N4.js";import"./chunk-MTX4UPNB.js";import"./chunk-IMLAPB7G.js";import"./chunk-OWNQ2FD4.js";import"./chunk-KEXBEUSU.js";import"./chunk-ROLSSYXE.js";import"./chunk-QIJLFPWE.js";export{a as ENRICH_BY,b as ENRICH_TYPES,h as buildEnrichPrompt,j as checkEnrichment,n as createEntityPage,e as enrichContext,g as fingerprint,c as lensProperties,o as loadEnrichState,f as mentionsOf,l as mergedMeta,i as parseEnrichReply,d as readableAlongside,q as runEnrich,p as saveEnrichState,m as targetPage,k as withOverview};
2
- //# sourceMappingURL=enrich-FPK3OW77.js.map
1
+ import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q}from"./chunk-S5A7QZVQ.js";import"./chunk-EFGAPAYZ.js";import"./chunk-QAWKN2N4.js";import"./chunk-DODL5POT.js";import"./chunk-IMLAPB7G.js";import"./chunk-OWNQ2FD4.js";import"./chunk-KEXBEUSU.js";import"./chunk-ROLSSYXE.js";import"./chunk-QIJLFPWE.js";export{a as ENRICH_BY,b as ENRICH_TYPES,h as buildEnrichPrompt,j as checkEnrichment,n as createEntityPage,e as enrichContext,g as fingerprint,c as lensProperties,o as loadEnrichState,f as mentionsOf,l as mergedMeta,i as parseEnrichReply,d as readableAlongside,q as runEnrich,p as saveEnrichState,m as targetPage,k as withOverview};
2
+ //# sourceMappingURL=enrich-MZMIQ3SV.js.map
@@ -1,3 +1,3 @@
1
- import{a as A,k as R}from"./chunk-XVTD6I34.js";import{f as g}from"./chunk-QAWKN2N4.js";import"./chunk-MTX4UPNB.js";import"./chunk-IMLAPB7G.js";import{c as I}from"./chunk-OWNQ2FD4.js";import{a as E}from"./chunk-ROLSSYXE.js";import"./chunk-QIJLFPWE.js";var b="wiki-events",x="importance_set",S=new Set(["event","due_date","topic"]),L=10,j=320;function _(t,e,c){let o=new Set(c.map(r=>r.toLowerCase()));for(let r of t??[])if(!(!E.includes(r.level)||!r.title&&!r.tags?.length)){if(r.title){let i;try{i=new RegExp(r.title,"i")}catch{continue}if(!i.test(e))continue}if(r.unless){let i;try{i=new RegExp(r.unless,"i")}catch{continue}if(i.test(e))continue}if(!(r.tags?.length&&!r.tags.some(i=>o.has(i.toLowerCase()))))return r.level}}function O(t,e){let c=` ${g(e)} `,o=[];for(let r of t.entities.values()){if(S.has(r.type))continue;let i=g(r.title);i.length>=4&&c.includes(` ${i} `)&&o.push(r)}return o}function C(t,e){let c=A(t,e,null).filter(r=>!S.has(r.type)),o=O(t,e.title);return[...new Map([...o,...c].map(r=>[r.id,r])).values()].slice(0,L)}function W(t,e){return e.pages.find(c=>!t.syncedFrom(c.agentId))}function $(t){return(t.statements??[]).some(e=>e.by===b&&e.property===x)}function G(t){return t.pages.some(e=>e.article.meta.importance&&!$(e.article.meta))}function U(t,e,c){let o=new Set;for(let s of c.about){let l=e.names.get(g(s))??(e.entities.has(s)?s:void 0);l&&o.add(l)}let r=[],i=[],a=[...e.entities.values()].filter(s=>s.type==="event").sort((s,l)=>(l.date||"").localeCompare(s.date||""));for(let s of a){if(s.pages.some(n=>n.article.meta.importance)&&(!c.force||G(s)))continue;let f=C(e,s);if(c.about.length&&!f.some(n=>o.has(n.id)))continue;let d=W(t,s);if(!d){i.push(s);continue}r.push({event:s,page:d,candidates:f})}return{items:r,noPage:i}}var M=(t,e)=>t.length>e?`${t.slice(0,e)}\u2026`:t;function V(t,e){let c=["You are sorting the event pages of a company wiki by importance, and saying what each event is about.","","Levels:","- minor: routine upkeep or a small incident with no lasting effect (a disk filled and was cleaned, a job was restarted, a reminder was sent).","- normal: something a person would want in the history of the thing it is about (a delivery, a payment, an outage that was noticed, a meeting with an outcome).","- major: a turning point (a client won or lost, a contract signed, a legal or financial deadline missed, data lost, a decision that changes how things are done).","When unsure between two levels, pick the lower one.","","## Events"];return t.forEach((o,r)=>{let i=M(R(o.page.article.content).replace(/\s+/g," ").trim(),j);c.push(`### ${r+1}. ${o.event.title} (${o.event.date||"no date"})`,i||"(no text)"),c.push(o.candidates.length?`May be about: ${o.candidates.map(a=>`"${a.title}" (${a.type})`).join(", ")}`:"May be about: nothing listed","")}),c.push("## Task","Return one JSON object and nothing else:",'{"events": [{"n": 1, "importance": "minor", "about": ["Exact Title"], "why": "one short reason"}]}',"","Rules:",`- One item per event, with its number. importance is one of ${E.join(", ")}.`,`- about: only titles from that event's own "May be about" list, copied exactly, and only the ones the event really concerns: the machine that failed, the client it was for, the person it happened to. Often one, at most three. Leave it empty when none fits.`,"- why: under 15 words, in English.",...e.importance.major_set_by==="owner"?["- major is only a suggestion here: the owner confirms it."]:[]),c.join(`
1
+ import{a as A,k as R}from"./chunk-EFGAPAYZ.js";import{f as g}from"./chunk-QAWKN2N4.js";import"./chunk-DODL5POT.js";import"./chunk-IMLAPB7G.js";import{c as I}from"./chunk-OWNQ2FD4.js";import{a as E}from"./chunk-ROLSSYXE.js";import"./chunk-QIJLFPWE.js";var b="wiki-events",x="importance_set",S=new Set(["event","due_date","topic"]),L=10,j=320;function _(t,e,c){let o=new Set(c.map(r=>r.toLowerCase()));for(let r of t??[])if(!(!E.includes(r.level)||!r.title&&!r.tags?.length)){if(r.title){let i;try{i=new RegExp(r.title,"i")}catch{continue}if(!i.test(e))continue}if(r.unless){let i;try{i=new RegExp(r.unless,"i")}catch{continue}if(i.test(e))continue}if(!(r.tags?.length&&!r.tags.some(i=>o.has(i.toLowerCase()))))return r.level}}function O(t,e){let c=` ${g(e)} `,o=[];for(let r of t.entities.values()){if(S.has(r.type))continue;let i=g(r.title);i.length>=4&&c.includes(` ${i} `)&&o.push(r)}return o}function C(t,e){let c=A(t,e,null).filter(r=>!S.has(r.type)),o=O(t,e.title);return[...new Map([...o,...c].map(r=>[r.id,r])).values()].slice(0,L)}function W(t,e){return e.pages.find(c=>!t.syncedFrom(c.agentId))}function $(t){return(t.statements??[]).some(e=>e.by===b&&e.property===x)}function G(t){return t.pages.some(e=>e.article.meta.importance&&!$(e.article.meta))}function U(t,e,c){let o=new Set;for(let s of c.about){let l=e.names.get(g(s))??(e.entities.has(s)?s:void 0);l&&o.add(l)}let r=[],i=[],a=[...e.entities.values()].filter(s=>s.type==="event").sort((s,l)=>(l.date||"").localeCompare(s.date||""));for(let s of a){if(s.pages.some(n=>n.article.meta.importance)&&(!c.force||G(s)))continue;let f=C(e,s);if(c.about.length&&!f.some(n=>o.has(n.id)))continue;let d=W(t,s);if(!d){i.push(s);continue}r.push({event:s,page:d,candidates:f})}return{items:r,noPage:i}}var M=(t,e)=>t.length>e?`${t.slice(0,e)}\u2026`:t;function V(t,e){let c=["You are sorting the event pages of a company wiki by importance, and saying what each event is about.","","Levels:","- minor: routine upkeep or a small incident with no lasting effect (a disk filled and was cleaned, a job was restarted, a reminder was sent).","- normal: something a person would want in the history of the thing it is about (a delivery, a payment, an outage that was noticed, a meeting with an outcome).","- major: a turning point (a client won or lost, a contract signed, a legal or financial deadline missed, data lost, a decision that changes how things are done).","When unsure between two levels, pick the lower one.","","## Events"];return t.forEach((o,r)=>{let i=M(R(o.page.article.content).replace(/\s+/g," ").trim(),j);c.push(`### ${r+1}. ${o.event.title} (${o.event.date||"no date"})`,i||"(no text)"),c.push(o.candidates.length?`May be about: ${o.candidates.map(a=>`"${a.title}" (${a.type})`).join(", ")}`:"May be about: nothing listed","")}),c.push("## Task","Return one JSON object and nothing else:",'{"events": [{"n": 1, "importance": "minor", "about": ["Exact Title"], "why": "one short reason"}]}',"","Rules:",`- One item per event, with its number. importance is one of ${E.join(", ")}.`,`- about: only titles from that event's own "May be about" list, copied exactly, and only the ones the event really concerns: the machine that failed, the client it was for, the person it happened to. Often one, at most three. Leave it empty when none fits.`,"- why: under 15 words, in English.",...e.importance.major_set_by==="owner"?["- major is only a suggestion here: the owner confirms it."]:[]),c.join(`
2
2
  `)}function N(t){let e=t.match(/```(?:json)?\s*\n([\s\S]*?)\n```/),c=e?e[1]:t.slice(t.indexOf("{"),t.lastIndexOf("}")+1);try{let o=JSON.parse(c);return o&&typeof o=="object"&&!Array.isArray(o)?o:null}catch{return null}}function P(t,e){return t==="major"&&e.importance.major_set_by==="owner"?{importance:"normal",proposed:"major"}:{importance:t}}function T(t,e,c){let o=new Map,r=N(t);for(let i of Array.isArray(r?.events)?r.events:[]){let a=i??{},s=Number(a.n)-1,l=e[s];if(!Number.isInteger(s)||!l||o.has(s))continue;let f=String(a.importance??"").trim().toLowerCase();if(!E.includes(f))continue;let d=[],n=new Map(l.candidates.map(u=>[g(u.title),u.title])),p=[];for(let u of Array.isArray(a.about)?a.about:[]){let m=n.get(g(String(u??"")));m&&!p.includes(m)?p.push(m):!m&&String(u??"").trim()&&d.push(`about ${String(u).trim().slice(0,80)}: not in the list shown`)}p.length>3&&d.push(`about: kept the first 3 of ${p.length}`);let h=typeof a.why=="string"?M(a.why.trim(),160):void 0;o.set(s,{verdict:{...P(f,c),about:p.slice(0,3),why:h||void 0,by:"model"},dropped:d})}return o}function B(t,e,c){let o=(t.statements??[]).filter(a=>a.by!==b),r=new Set(o.filter(a=>a.property==="involves").map(a=>g(a.value))),i=e.about.filter(a=>!r.has(g(a))).map(a=>({property:"involves",value:a,checked_at:c,by:b}));return i.push({property:x,value:e.proposed??e.importance,checked_at:c,by:b,...e.why?{note:e.why}:{}}),{...t,importance:e.importance,importanceProposed:e.proposed,statements:[...o,...i]}}async function K(t,e,c,o){let r=e.ontology,{items:i,noPage:a}=U(t,e,o),s=i.slice(0,o.max),l={outcomes:[],costUsd:0,calls:0,capped:!1,left:i.length-s.length};for(let n of o.about.length?a:[])l.outcomes.push({event:n.id,title:n.title,date:n.date,status:"no-page",about:[],dropped:["its pages are copied from another node"]});let f=(n,p,h)=>{let u=`${n.page.agentId}/${n.page.article.path}`,m={event:n.event.id,title:n.event.title,date:n.event.date,page:u,status:"dry-run",importance:p.importance,proposed:p.proposed,about:p.about,by:p.by,why:p.why,dropped:h};if(o.dryRun){l.outcomes.push(m);return}let v=t.getAgentWiki(n.page.agentId),k=n.page.article.path,w;try{w=v.withArticleLock(k,()=>{let y=v.readArticle(k);return y?y.meta.importance&&!$(y.meta)?"a level was set on the page during the run":v.writeArticle(k,B(y.meta,p,o.today),y.content,y.meta.owner||n.page.agentId)?void 0:"write refused":"the page was moved or removed during the run"})}catch(y){if(!(y instanceof I))throw y;w="the page was busy; run again"}l.outcomes.push(w?{...m,status:"failed",dropped:[...h,w]}:{...m,status:"written"})},d=[];for(let n of s){let p=_(r.importance.rules,n.event.title,n.page.article.meta.tags??[]);if(!p){d.push(n);continue}let h=new Set(O(e,n.event.title).map(m=>m.id)),u=n.candidates.filter(m=>h.has(m.id)).slice(0,3).map(m=>m.title);f(n,{...P(p,r),about:u,why:"matched an importance rule",by:"rule"},[])}if(o.rulesOnly)return l.left+=d.length,l;for(let n=0;n<d.length;n+=o.batch){let p=d.slice(n,n+o.batch);if(l.costUsd>=o.maxCostUsd){l.capped=!0,l.left+=d.length-n;break}l.calls++;let h;try{let u=await c(V(p,r));l.costUsd+=u.costUsd,h=T(u.text,p,r)}catch(u){for(let m of p)l.outcomes.push({event:m.event.id,title:m.event.title,date:m.event.date,page:`${m.page.agentId}/${m.page.article.path}`,status:"failed",about:[],dropped:[u.message.slice(0,200)]});continue}p.forEach((u,m)=>{let v=h.get(m);v?f(u,v.verdict,v.dropped):l.outcomes.push({event:u.event.id,title:u.event.title,date:u.event.date,page:`${u.page.agentId}/${u.page.article.path}`,status:"no-answer",about:[],dropped:["the reply had no usable item for this event"]})})}if(!o.dryRun)for(let n of new Set(l.outcomes.filter(p=>p.status==="written").map(p=>p.page.split("/")[0])))t.getAgentWiki(n).rebuildIndex();return l}function z(t,e,c,o){let r=e.names.get(g(c))??(e.entities.has(c)?c:void 0),i=r?e.entities.get(r):void 0;if(!i)return{ok:!1,reason:`no page is titled "${c}"`};if(i.type!=="event")return{ok:!1,title:i.title,reason:`"${i.title}" is a ${i.type}, not an event`};let a=W(t,i);if(!a)return{ok:!1,title:i.title,reason:"its pages are copied from another node; set the level there"};let s=t.getAgentWiki(a.agentId),l,f="write refused";try{l=s.withArticleLock(a.article.path,()=>{let d=s.readArticle(a.article.path)??a.article,n=(d.meta.statements??[]).filter(h=>!(h.by===b&&h.property===x)),p={...d.meta,importance:o,importanceProposed:void 0,statements:n.length?n:void 0};return s.writeArticle(a.article.path,p,d.content,d.meta.owner||a.agentId)})}catch(d){if(!(d instanceof I))throw d;l=!1,f="the page was busy; run again"}return l&&s.rebuildIndex(),{ok:l,title:i.title,page:`${a.agentId}/${a.article.path}`,reason:l?void 0:f}}function X(t,e,c){let o=[],r=new Map(e.outcomes.filter(i=>i.importance).map(i=>[i.event,i]));for(let i of c){let a=t.names.get(g(i))??(t.entities.has(i)?i:void 0),s=a?t.entities.get(a):void 0;if(!s)continue;let l=new Set(A(t,s,new Set(["event"])).map(n=>n.id)),f={minor:0,normal:0,major:0},d=new Set;for(let n of t.entities.values()){if(n.type!=="event")continue;let p=r.get(n.id);!(l.has(n.id)||p?.about.some(u=>g(u)===g(s.title)))||d.has(n.id)||(d.add(n.id),f[p?.importance??n.importance]++)}o.push({title:s.title,type:s.type,before:l.size,after:f})}return o}export{b as EVENTS_BY,V as buildEventsPrompt,T as checkEventsReply,C as eventCandidates,B as eventMeta,U as pickEvents,_ as ruleLevel,K as runEvents,z as setEventLevel,X as summariseAbout};
3
- //# sourceMappingURL=event-levels-NBOMTB23.js.map
3
+ //# sourceMappingURL=event-levels-PCFARGKL.js.map
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import{Ia as Tt,Ja as Mt,a as St,b as kt,c as vt,d as xt,e as $t,f as Ct,g as Pt,h as bt}from"./chunk-GQJMY5NH.js";import"./chunk-FZMS4UFL.js";import"./chunk-GTJIKXDB.js";import"./chunk-YIR6FABW.js";import"./chunk-ZVP6GB4G.js";import"./chunk-6FNJ7GQ2.js";import"./chunk-EKJG63EJ.js";import"./chunk-PHT6HTAW.js";import"./chunk-N6VBEITO.js";import"./chunk-IMLAPB7G.js";import"./chunk-6V5JBHUN.js";import"./chunk-2VDO2HEK.js";import"./chunk-5HLD66CW.js";import"./chunk-LQE73AZR.js";import"./chunk-2D3RYIDU.js";import"./chunk-MRIVENBY.js";import"./chunk-FRR6DRLY.js";import"./chunk-LQS27HSV.js";import"./chunk-PPUN7YHA.js";import"./chunk-VZLIBDLH.js";import"./chunk-A5GYG56I.js";import"./chunk-3X2BFCOZ.js";import"./chunk-2AXFYDWF.js";import"./chunk-AQASR6KR.js";import"./chunk-UKUH662W.js";import"./chunk-JWDJMFU6.js";import"./chunk-IS2IWRP7.js";import"./chunk-MNG2AMKZ.js";import"./chunk-RX5O5637.js";import"./chunk-X7UQY7CH.js";import"./chunk-QPABR72X.js";import"./chunk-OHPCZOOM.js";import"./chunk-AJ5HMDRW.js";import"./chunk-KP7KDLZ2.js";import{m as lt,n as ct,o as dt,p as mt,q as pt,ya as yt}from"./chunk-S25OP23O.js";import"./chunk-M4BNVLGJ.js";import"./chunk-MEFPXHQJ.js";import{a as L}from"./chunk-BAXGL6TY.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-XXWSFJFZ.js";import{a as B,b as M,c as F}from"./chunk-SFQUP3BP.js";import"./chunk-6TTGRTDO.js";import"./chunk-SZDACK6O.js";import"./chunk-VE3SSOQX.js";import"./chunk-W4YR2RO2.js";import"./chunk-AFRHKA7B.js";import"./chunk-VJVXEVZ7.js";import{t as ut}from"./chunk-CVFQA3TH.js";import"./chunk-KUZATIJA.js";import"./chunk-3UOTLMXD.js";import"./chunk-BE64IJWM.js";import"./chunk-PE5V2LI7.js";import"./chunk-GQ76J72O.js";import"./chunk-ILEC3IAV.js";import"./chunk-J3SOEFRE.js";import"./chunk-SIU6STB2.js";import"./chunk-X5C5W3E4.js";import"./chunk-GV7S5BAX.js";import"./chunk-GSX4NK2N.js";import"./chunk-VWTBHLMX.js";import"./chunk-BCDC7BOQ.js";import{a as ht}from"./chunk-2BI43ZKI.js";import"./chunk-OWNQ2FD4.js";import"./chunk-KEXBEUSU.js";import"./chunk-ROLSSYXE.js";import"./chunk-5DJOGAS2.js";import"./chunk-JTFCU5LH.js";import{f as gt,g as ft}from"./chunk-3VZNOJJK.js";import"./chunk-WPNRDEHW.js";import"./chunk-LUOW2YHY.js";import"./chunk-4LWFJ4MZ.js";import"./chunk-BIJHMWXK.js";import"./chunk-DUWKRQKT.js";import{j as it,k as rt,l as at}from"./chunk-FXMUUDSH.js";import"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-MCI3DIWW.js";import"./chunk-MYVHVJWZ.js";import"./chunk-QUFIUXMQ.js";import"./chunk-AV7T3SYT.js";import"./chunk-LE3BXIUF.js";import"./chunk-BERWTVG2.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-DCIYOPJF.js";import{a as m,b as G}from"./chunk-7I7IEX4S.js";import{b as Fe,c as Le,d as A,e as De}from"./chunk-JHCI6XCJ.js";import{a as Ke,b as Je,e as We}from"./chunk-DSYKYZMT.js";import{nb as tt,pb as st,rb as ot,yb as nt}from"./chunk-P7FSTC5E.js";import"./chunk-VJ5HC63R.js";import"./chunk-UEEB3UTU.js";import"./chunk-VQRY4IDI.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{Ia as Tt,Ja as Mt,a as St,b as kt,c as vt,d as xt,e as $t,f as Ct,g as Pt,h as bt}from"./chunk-QQ3YFYC2.js";import"./chunk-FZMS4UFL.js";import"./chunk-GTJIKXDB.js";import"./chunk-YIR6FABW.js";import"./chunk-ZVP6GB4G.js";import"./chunk-6FNJ7GQ2.js";import"./chunk-EKJG63EJ.js";import"./chunk-PHT6HTAW.js";import"./chunk-N6VBEITO.js";import"./chunk-IMLAPB7G.js";import"./chunk-6V5JBHUN.js";import"./chunk-2VDO2HEK.js";import"./chunk-5HLD66CW.js";import"./chunk-LQE73AZR.js";import"./chunk-2D3RYIDU.js";import"./chunk-MRIVENBY.js";import"./chunk-FRR6DRLY.js";import"./chunk-LQS27HSV.js";import"./chunk-PPUN7YHA.js";import"./chunk-VZLIBDLH.js";import"./chunk-A5GYG56I.js";import"./chunk-3X2BFCOZ.js";import"./chunk-2AXFYDWF.js";import"./chunk-AQASR6KR.js";import"./chunk-UKUH662W.js";import"./chunk-JWDJMFU6.js";import"./chunk-IS2IWRP7.js";import"./chunk-MNG2AMKZ.js";import"./chunk-RX5O5637.js";import"./chunk-X7UQY7CH.js";import"./chunk-QPABR72X.js";import"./chunk-OHPCZOOM.js";import"./chunk-AJ5HMDRW.js";import"./chunk-KP7KDLZ2.js";import{m as lt,n as ct,o as dt,p as mt,q as pt,ya as yt}from"./chunk-S25OP23O.js";import"./chunk-M4BNVLGJ.js";import"./chunk-MEFPXHQJ.js";import{a as L}from"./chunk-BAXGL6TY.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-XXWSFJFZ.js";import{a as B,b as M,c as F}from"./chunk-SFQUP3BP.js";import"./chunk-6TTGRTDO.js";import"./chunk-SZDACK6O.js";import"./chunk-VE3SSOQX.js";import"./chunk-W4YR2RO2.js";import"./chunk-AFRHKA7B.js";import"./chunk-VJVXEVZ7.js";import{t as ut}from"./chunk-CVFQA3TH.js";import"./chunk-KUZATIJA.js";import"./chunk-3UOTLMXD.js";import"./chunk-BE64IJWM.js";import"./chunk-PE5V2LI7.js";import"./chunk-GQ76J72O.js";import"./chunk-ILEC3IAV.js";import"./chunk-J3SOEFRE.js";import"./chunk-SIU6STB2.js";import"./chunk-X5C5W3E4.js";import"./chunk-GV7S5BAX.js";import"./chunk-GSX4NK2N.js";import"./chunk-VWTBHLMX.js";import"./chunk-BCDC7BOQ.js";import{a as ht}from"./chunk-2BI43ZKI.js";import"./chunk-OWNQ2FD4.js";import"./chunk-KEXBEUSU.js";import"./chunk-ROLSSYXE.js";import"./chunk-5DJOGAS2.js";import"./chunk-JTFCU5LH.js";import{f as gt,g as ft}from"./chunk-3VZNOJJK.js";import"./chunk-WPNRDEHW.js";import"./chunk-LUOW2YHY.js";import"./chunk-4LWFJ4MZ.js";import"./chunk-BIJHMWXK.js";import"./chunk-DUWKRQKT.js";import{j as it,k as rt,l as at}from"./chunk-FXMUUDSH.js";import"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-MCI3DIWW.js";import"./chunk-MYVHVJWZ.js";import"./chunk-QUFIUXMQ.js";import"./chunk-AV7T3SYT.js";import"./chunk-LE3BXIUF.js";import"./chunk-BERWTVG2.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-DCIYOPJF.js";import{a as m,b as G}from"./chunk-7I7IEX4S.js";import{b as Fe,c as Le,d as A,e as De}from"./chunk-JHCI6XCJ.js";import{a as Ke,b as Je,e as We}from"./chunk-DSYKYZMT.js";import{nb as tt,pb as st,rb as ot,yb as nt}from"./chunk-P7FSTC5E.js";import"./chunk-VJ5HC63R.js";import"./chunk-UEEB3UTU.js";import"./chunk-VQRY4IDI.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-YFVSSYSL.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).
@@ -1,2 +1,2 @@
1
- import{a,b,c,d,e,f,g}from"./chunk-MTX4UPNB.js";import"./chunk-ROLSSYXE.js";import"./chunk-QIJLFPWE.js";export{a as ONTOLOGY_FILE,e as checkOntology,b as loadOntology,d as mergeOntology,f as panelFrom,g as panelSource,c as writeDefaultOntology};
2
- //# sourceMappingURL=load-LQ2I2PQI.js.map
1
+ import{a,b,c,d,e,f,g}from"./chunk-DODL5POT.js";import"./chunk-ROLSSYXE.js";import"./chunk-QIJLFPWE.js";export{a as ONTOLOGY_FILE,e as checkOntology,b as loadOntology,d as mergeOntology,f as panelFrom,g as panelSource,c as writeDefaultOntology};
2
+ //# sourceMappingURL=load-Q3HCFXDT.js.map