agentix-cli 0.139.0 → 0.139.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 (62) hide show
  1. package/dist/{agent-PRHZGF6J.js → agent-5CEDGNDW.js} +2 -2
  2. package/dist/{board-dashboard-GBEBQUFJ.js → board-dashboard-F5GP2X22.js} +2 -2
  3. package/dist/{builtin-YD7MC572.js → builtin-U5S2XCNJ.js} +2 -2
  4. package/dist/chunk-3W2BHUGM.js +11 -0
  5. package/dist/chunk-3W2BHUGM.js.map +1 -0
  6. package/dist/{chunk-KO6BU3B3.js → chunk-4LNJR5PC.js} +2 -2
  7. package/dist/{chunk-34XYHSL6.js → chunk-65LN6GQP.js} +230 -229
  8. package/dist/chunk-65LN6GQP.js.map +1 -0
  9. package/dist/chunk-6TTGRTDO.js +3 -0
  10. package/dist/chunk-6TTGRTDO.js.map +1 -0
  11. package/dist/{chunk-MUC7MMTT.js → chunk-BUKXFZEO.js} +2 -2
  12. package/dist/{chunk-2BEZU5OF.js → chunk-HWYU6XG2.js} +2 -2
  13. package/dist/chunk-HWYU6XG2.js.map +1 -0
  14. package/dist/{chunk-RIYQNADV.js → chunk-LGB6ILTW.js} +3 -3
  15. package/dist/{chunk-JBYLG3CQ.js → chunk-P4TSZDVO.js} +2 -2
  16. package/dist/{chunk-HF5EF335.js → chunk-VE3SSOQX.js} +4 -4
  17. package/dist/chunk-VE3SSOQX.js.map +1 -0
  18. package/dist/{chunk-XQVL2RYG.js → chunk-WTMZW5X7.js} +2 -2
  19. package/dist/{chunk-H4NSB54D.js → chunk-XVTD6I34.js} +2 -2
  20. package/dist/{chunk-U6EJ53DA.js → chunk-YWEGKAE2.js} +2 -2
  21. package/dist/cli.js +1 -1
  22. package/dist/{enrich-R2LIDLPZ.js → enrich-FPK3OW77.js} +2 -2
  23. package/dist/{event-levels-WOYYEWSZ.js → event-levels-NBOMTB23.js} +2 -2
  24. package/dist/{follow-up-tool-QRECR3AH.js → follow-up-tool-M2KCLRQQ.js} +2 -2
  25. package/dist/index.d.ts +14 -1
  26. package/dist/index.js +1 -1
  27. package/dist/index.js.map +1 -1
  28. package/dist/{program-7VHY5RVZ.js → program-SJT7PIFO.js} +6 -6
  29. package/dist/program-SJT7PIFO.js.map +1 -0
  30. package/dist/{registry-B276QJ75.js → registry-Q7VNRLZA.js} +2 -2
  31. package/dist/{rules-UVUJTVOE.js → rules-5ZZQZLQA.js} +2 -2
  32. package/dist/send-answer-ZG7UHCVS.js +2 -0
  33. package/dist/{tool-UPXUWIMM.js → tool-DFPOFXGA.js} +2 -2
  34. package/dist/{tool-5WCC7SKQ.js → tool-GJ75MWV5.js} +2 -2
  35. package/dist/wiki-enrich-JNQ2RPWU.js +2 -0
  36. package/dist/wiki-enrich-JNQ2RPWU.js.map +1 -0
  37. package/package.json +1 -1
  38. package/dist/chunk-2BEZU5OF.js.map +0 -1
  39. package/dist/chunk-34XYHSL6.js.map +0 -1
  40. package/dist/chunk-HF5EF335.js.map +0 -1
  41. package/dist/chunk-Q4XP5TBI.js +0 -11
  42. package/dist/chunk-Q4XP5TBI.js.map +0 -1
  43. package/dist/program-7VHY5RVZ.js.map +0 -1
  44. package/dist/wiki-enrich-7SBCPK2E.js +0 -2
  45. /package/dist/{agent-PRHZGF6J.js.map → agent-5CEDGNDW.js.map} +0 -0
  46. /package/dist/{board-dashboard-GBEBQUFJ.js.map → board-dashboard-F5GP2X22.js.map} +0 -0
  47. /package/dist/{builtin-YD7MC572.js.map → builtin-U5S2XCNJ.js.map} +0 -0
  48. /package/dist/{chunk-KO6BU3B3.js.map → chunk-4LNJR5PC.js.map} +0 -0
  49. /package/dist/{chunk-MUC7MMTT.js.map → chunk-BUKXFZEO.js.map} +0 -0
  50. /package/dist/{chunk-RIYQNADV.js.map → chunk-LGB6ILTW.js.map} +0 -0
  51. /package/dist/{chunk-JBYLG3CQ.js.map → chunk-P4TSZDVO.js.map} +0 -0
  52. /package/dist/{chunk-XQVL2RYG.js.map → chunk-WTMZW5X7.js.map} +0 -0
  53. /package/dist/{chunk-H4NSB54D.js.map → chunk-XVTD6I34.js.map} +0 -0
  54. /package/dist/{chunk-U6EJ53DA.js.map → chunk-YWEGKAE2.js.map} +0 -0
  55. /package/dist/{enrich-R2LIDLPZ.js.map → enrich-FPK3OW77.js.map} +0 -0
  56. /package/dist/{event-levels-WOYYEWSZ.js.map → event-levels-NBOMTB23.js.map} +0 -0
  57. /package/dist/{follow-up-tool-QRECR3AH.js.map → follow-up-tool-M2KCLRQQ.js.map} +0 -0
  58. /package/dist/{registry-B276QJ75.js.map → registry-Q7VNRLZA.js.map} +0 -0
  59. /package/dist/{rules-UVUJTVOE.js.map → rules-5ZZQZLQA.js.map} +0 -0
  60. /package/dist/{wiki-enrich-7SBCPK2E.js.map → send-answer-ZG7UHCVS.js.map} +0 -0
  61. /package/dist/{tool-UPXUWIMM.js.map → tool-DFPOFXGA.js.map} +0 -0
  62. /package/dist/{tool-5WCC7SKQ.js.map → tool-GJ75MWV5.js.map} +0 -0
@@ -1,4 +1,4 @@
1
- import{f as j,g}from"./chunk-MTX4UPNB.js";import{f as h}from"./chunk-QAWKN2N4.js";import{a as z}from"./chunk-IMLAPB7G.js";function E(o,t){return o.ontology.types.find(e=>e.id===t)?.lens??[{panel:"notes",source:"notes",show:1}]}function v(o,t,e){let a=o.ontology.properties.find(n=>n.id===t);return a?e?a.inverse??a.label:a.label:t.replace(/_/g," ")}function G(o,t){let e=o.until??o.date??o.since??"",a=t.until??t.date??t.since??"";return e!==a?a.localeCompare(e):o.label.localeCompare(t.label)}function R(o,t,e,a,n){let r=a?n:e.target?o.entities.get(e.target):void 0,i=[v(o,e.property,a)];return e.role&&i.unshift(e.role.length>40?`${e.role.slice(0,39)}\u2026`:e.role),{label:r?.title??e.value,entityId:r?.id,type:r?.type,chips:i,since:e.since,until:e.until,status:e.status,private:e.access==="private",statement:a?void 0:t.statements.indexOf(e),sub:e.note}}function H(o,t,e){let a=new Set(j(e)),n=e.types?new Set(e.types):null,r=[],i=new Set,s=x=>!n||!!x&&n.has(x.type);for(let x of t.statements){if(!a.has(x.property))continue;let d=x.target?o.entities.get(x.target):void 0;s(d)&&(r.push(R(o,t,x,!1)),d&&i.add(d.id))}for(let x of o.incoming.get(t.id)??[]){if(!a.has(x.property))continue;let d=o.entities.get(x.from);!d||!s(d)||(x.statement?r.push(R(o,t,x.statement,!0,d)):i.has(d.id)||r.push({label:d.title,entityId:d.id,type:d.type,chips:[v(o,"related",!0)],date:d.updated}),i.add(d.id))}if(a.has("related"))for(let x of o.outgoing.get(t.id)??[]){if(x.property!=="related"||i.has(x.to))continue;let d=o.entities.get(x.to);!d||!s(d)||(r.push({label:d.title,entityId:d.id,type:d.type,chips:[v(o,"related",!1)],date:d.updated}),i.add(d.id))}let c=r.filter(x=>!x.chips.includes(v(o,"related",!1))),p=r.filter(x=>x.chips.includes(v(o,"related",!1)));return[...c.sort(G),...p.sort(G)]}function I(o,t,e){let a=new Set;for(let r of o.outgoing.get(t.id)??[])a.add(r.to);for(let r of o.incoming.get(t.id)??[])a.add(r.from);let n=[];for(let r of a){let i=o.entities.get(r);i&&(!e||e.has(i.type))&&n.push(i)}return n.sort((r,i)=>(i.date||i.updated).localeCompare(r.date||r.updated))}function M(o){return{label:o.title,entityId:o.id,type:o.type,chips:[],date:o.date,importance:o.importance}}function T(o,t,e){let a=I(o,t,new Set(["event"])).map(M),n=new Set(e.importance??["major","normal","minor"]),r=a.filter(p=>n.has(p.importance??o.ontology.importance.default)),i=e.fold?a.filter(p=>p.importance===e.fold):[],s=[],c=e.rollup??o.ontology.importance.rollup;if(i.length>=c.min&&i[0].date){let p=Date.parse(i[0].date),x=i.filter(d=>d.date&&p-Date.parse(d.date)<=c.days*864e5);x.length>=c.min&&s.push(`${x.length} minor events in ${c.days} days up to ${i[0].date}`)}return{shown:r,folded:i,rollups:s}}function V(o,t){let e=o.statements.map((r,i)=>({st:r,i})).filter(({st:r})=>r.property==="reading"||!!r.metric).sort((r,i)=>(i.st.at??"").localeCompare(r.st.at??"")),a=new Set,n=[];for(let{st:r,i}of e){let s=r.metric??"reading";t&&a.has(s)||(a.add(s),n.push({label:`${s.replace(/_/g," ")}: ${r.value}`,chips:[],date:r.at,statement:i,private:r.access==="private"}))}return n}function B(o,t){return t(o.sources).sort((e,a)=>a.date.localeCompare(e.date)).map(e=>{let a=e.content.split(`
1
+ import{f as h}from"./chunk-QAWKN2N4.js";import{f as j,g}from"./chunk-MTX4UPNB.js";import{a as z}from"./chunk-IMLAPB7G.js";function E(o,t){return o.ontology.types.find(e=>e.id===t)?.lens??[{panel:"notes",source:"notes",show:1}]}function v(o,t,e){let a=o.ontology.properties.find(n=>n.id===t);return a?e?a.inverse??a.label:a.label:t.replace(/_/g," ")}function G(o,t){let e=o.until??o.date??o.since??"",a=t.until??t.date??t.since??"";return e!==a?a.localeCompare(e):o.label.localeCompare(t.label)}function R(o,t,e,a,n){let r=a?n:e.target?o.entities.get(e.target):void 0,i=[v(o,e.property,a)];return e.role&&i.unshift(e.role.length>40?`${e.role.slice(0,39)}\u2026`:e.role),{label:r?.title??e.value,entityId:r?.id,type:r?.type,chips:i,since:e.since,until:e.until,status:e.status,private:e.access==="private",statement:a?void 0:t.statements.indexOf(e),sub:e.note}}function H(o,t,e){let a=new Set(j(e)),n=e.types?new Set(e.types):null,r=[],i=new Set,s=x=>!n||!!x&&n.has(x.type);for(let x of t.statements){if(!a.has(x.property))continue;let d=x.target?o.entities.get(x.target):void 0;s(d)&&(r.push(R(o,t,x,!1)),d&&i.add(d.id))}for(let x of o.incoming.get(t.id)??[]){if(!a.has(x.property))continue;let d=o.entities.get(x.from);!d||!s(d)||(x.statement?r.push(R(o,t,x.statement,!0,d)):i.has(d.id)||r.push({label:d.title,entityId:d.id,type:d.type,chips:[v(o,"related",!0)],date:d.updated}),i.add(d.id))}if(a.has("related"))for(let x of o.outgoing.get(t.id)??[]){if(x.property!=="related"||i.has(x.to))continue;let d=o.entities.get(x.to);!d||!s(d)||(r.push({label:d.title,entityId:d.id,type:d.type,chips:[v(o,"related",!1)],date:d.updated}),i.add(d.id))}let c=r.filter(x=>!x.chips.includes(v(o,"related",!1))),p=r.filter(x=>x.chips.includes(v(o,"related",!1)));return[...c.sort(G),...p.sort(G)]}function I(o,t,e){let a=new Set;for(let r of o.outgoing.get(t.id)??[])a.add(r.to);for(let r of o.incoming.get(t.id)??[])a.add(r.from);let n=[];for(let r of a){let i=o.entities.get(r);i&&(!e||e.has(i.type))&&n.push(i)}return n.sort((r,i)=>(i.date||i.updated).localeCompare(r.date||r.updated))}function M(o){return{label:o.title,entityId:o.id,type:o.type,chips:[],date:o.date,importance:o.importance}}function T(o,t,e){let a=I(o,t,new Set(["event"])).map(M),n=new Set(e.importance??["major","normal","minor"]),r=a.filter(p=>n.has(p.importance??o.ontology.importance.default)),i=e.fold?a.filter(p=>p.importance===e.fold):[],s=[],c=e.rollup??o.ontology.importance.rollup;if(i.length>=c.min&&i[0].date){let p=Date.parse(i[0].date),x=i.filter(d=>d.date&&p-Date.parse(d.date)<=c.days*864e5);x.length>=c.min&&s.push(`${x.length} minor events in ${c.days} days up to ${i[0].date}`)}return{shown:r,folded:i,rollups:s}}function V(o,t){let e=o.statements.map((r,i)=>({st:r,i})).filter(({st:r})=>r.property==="reading"||!!r.metric).sort((r,i)=>(i.st.at??"").localeCompare(r.st.at??"")),a=new Set,n=[];for(let{st:r,i}of e){let s=r.metric??"reading";t&&a.has(s)||(a.add(s),n.push({label:`${s.replace(/_/g," ")}: ${r.value}`,chips:[],date:r.at,statement:i,private:r.access==="private"}))}return n}function B(o,t){return t(o.sources).sort((e,a)=>a.date.localeCompare(e.date)).map(e=>{let a=e.content.split(`
2
2
  `).map(n=>n.trim()).find(Boolean)??"";return{label:a.length>120?`${a.slice(0,117)}\u2026`:a,chips:[],date:e.date,sub:`${e.date} \xB7 ${e.agentId} \xB7 ${e.source}`}})}function P(o,t,e,a){let n=g(e),r=[],i=[],s=[];if(n==="statements")r=H(o,t,e);else if(n==="linked")r=I(o,t,e.types?new Set(e.types):null).map(M);else if(n==="readings")r=V(t,!a.full&&e.latest!==!1);else if(n==="discussed")r=B(t,a.readEntries);else if(n==="history"){let p=T(o,t,e);r=a.full?I(o,t,new Set(["event"])).map(M):p.shown,i=a.full?[]:p.folded,s=p.rollups}let c=r.length;if(a.full){let p=a.pageSize??50,x=Math.max(1,a.page??1);r=r.slice((x-1)*p,x*p)}else r=r.slice(0,e.show??5);return{def:e,title:e.title??e.panel.replace(/_/g," "),items:r,total:c,folded:i,rollups:s,ownerOnly:e.access==="owner"}}function l(o){return String(o??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}var O={home:'<rect x="3" y="3" width="7" height="7" rx="1"/><rect x="14" y="3" width="7" height="7" rx="1"/><rect x="3" y="14" width="7" height="7" rx="1"/><rect x="14" y="14" width="7" height="7" rx="1"/>',person:'<circle cx="12" cy="8" r="4"/><path d="M4 21c0-4 4-6 8-6s8 2 8 6"/>',org:'<rect x="4" y="3" width="16" height="18" rx="2"/><path d="M9 7h2M13 7h2M9 11h2M13 11h2M9 15h2M13 15h2"/>',pin:'<path d="M12 21s-7-6.2-7-11a7 7 0 0 1 14 0c0 4.8-7 11-7 11z"/><circle cx="12" cy="10" r="2.5"/>',server:'<rect x="3" y="4" width="18" height="7" rx="2"/><rect x="3" y="13" width="18" height="7" rx="2"/><path d="M7 7.5h.01M7 16.5h.01"/>',device:'<rect x="4" y="5" width="16" height="11" rx="1.5"/><path d="M2 19h20"/>',app:'<rect x="4" y="4" width="16" height="16" rx="3"/><path d="M9 12h6M12 9v6"/>',globe:'<circle cx="12" cy="12" r="9"/><path d="M3 12h18M12 3c3 3.5 3 14.5 0 18M12 3c-3 3.5-3 14.5 0 18"/>',key:'<circle cx="8" cy="15" r="4"/><path d="M11 12l9-9M17 6l3 3"/>',agent:'<rect x="5" y="8" width="14" height="11" rx="3"/><path d="M12 4v4M9 13h.01M15 13h.01"/>',project:'<path d="M12 3l8 4.5v9L12 21l-8-4.5v-9z"/><path d="M4 7.5l8 4.5 8-4.5M12 12v9"/>',contract:'<path d="M7 3h7l5 5v13H7z"/><path d="M14 3v5h5M10 13h6M10 17h4"/>',law:'<path d="M12 3v18M5 21h14M6 7h12M6 7l-3 7a3 3 0 0 0 6 0zM18 7l-3 7a3 3 0 0 0 6 0z"/>',calendar:'<rect x="3" y="5" width="18" height="16" rx="2"/><path d="M3 10h18M8 3v4M16 3v4"/>',decision:'<path d="M12 3v18M12 8H6l-2 2 2 2h6M12 12h6l2 2-2 2h-6"/>',steps:'<path d="M9 6h11M9 12h11M9 18h11M4 6l1 1 2-2M4 12l1 1 2-2M4 18l1 1 2-2"/>',topic:'<path d="M4 7h16M4 12h10M4 17h7"/>',chat:'<path d="M4 5h16v11H9l-5 4z"/>',lock:'<rect x="5" y="11" width="14" height="10" rx="2"/><path d="M8 11V8a4 4 0 0 1 8 0v3"/>',arrow:'<path d="M5 12h14M13 6l6 6-6 6"/>',search:'<circle cx="11" cy="11" r="7"/><path d="M21 21l-4.3-4.3"/>',merge:'<circle cx="6" cy="6" r="2"/><circle cx="6" cy="18" r="2"/><circle cx="18" cy="12" r="2"/><path d="M6 8v8M8 6c6 0 8 2 8 6"/>'};function m(o){return`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${O[o??""]??O.topic}</svg>`}function u(o,t){return m(o.types.find(e=>e.id===t)?.icon)}function b(o,t){return o.types.find(e=>e.id===t)?.label??t??""}function f(o){return`/e/${encodeURIComponent(o)}`}function L(o){return`<nav class="ox-crumbs" aria-label="Breadcrumb">${[{label:"Wiki",href:"/"},...o].map((e,a,n)=>a===n.length-1||!e.href?`<b>${l(e.label)}</b>`:`<a href="${e.href}">${l(e.label)}</a>`).join('<span aria-hidden="true">/</span>')}</nav>`}function y(o){let t=["","Pillar","Overview","Panel","Statement"];return`<div class="ox-zoom" title="Zoom level">${[1,2,3,4].map(a=>`<span class="${a===o?"on":""}">Z${a}${a===o?` ${t[a]}`:""}</span>`).join("")}</div>`}function w(o,t){let e=o.ontology,a=`<a class="ox-nav${t.home?" on":""}" href="/">${m("home")}<span>Home</span></a>`,n=e.sidebar.pins.slice(0,e.sidebar.pins_max);if(n.length){a+='<div class="ox-side-h">Pinned</div>';for(let r of n){let i=o.names.get(h(r)),s=i?o.entities.get(i):void 0;s&&(a+=`<a class="ox-nav pin${t.entity===s.id?" on":""}" href="${f(s.id)}">${u(e,s.type)}<span>${l(s.title)}</span></a>`)}}a+='<div class="ox-side-h">Pillars</div>';for(let r of e.pillars)r.sidebar!==!1&&(a+=`<a class="ox-nav${t.pillar===r.id?" on":""}" href="/p/${encodeURIComponent(r.id)}">${m(r.icon)}<span>${l(r.label)}</span></a>`);return a+='<div class="ox-side-foot">Types, topics and agent wikis are one level down, on Home and the pillar pages.</div>',a}function $(o,t,e,a="",n=""){return`<!DOCTYPE html>
3
3
  <html lang="en">
4
4
  <head>
@@ -149,4 +149,4 @@ body>a[href="/admin"]+.ox-app .ox-top{padding-right:130px}
149
149
  `;var F=()=>new Date().toISOString().slice(0,10);function q(o){return o?`<span class="ox-st ${l(o)}">${l(o)}</span>`:""}function K(o){return o.private?`<span class="l"><span class="ox-mask">\u2022\u2022\u2022\u2022</span> ${m("lock")}</span>`:o.entityId?`<a href="${f(o.entityId)}">${l(o.label)}</a>`:`<span class="l">${l(o.label)}</span>`}function J(o,t){if(t.sub)return t.sub;let e=[];return t.type&&e.push(b(o.ontology,t.type).toLowerCase()),t.since||t.until?e.push(`${t.since??"\u2026"} \u2192 ${t.until??"now"}`):t.date&&e.push(t.date),e.join(" \xB7 ")}function Y(o,t,e){let a=J(o,e),n=e.chips.map(i=>`<span class="ox-chip">${l(i)}</span>`).join(""),r=e.statement!==void 0&&e.statement>=0?`<a class="ox-sub" href="${f(t.id)}/s/${e.statement}" title="Where this comes from (Z4)">Z4</a>`:"";return`<div class="ox-row"><span class="ox-ic">${e.type?u(o.ontology,e.type):m(e.private?"lock":"topic")}</span><div class="t">${K(e)}${a?`<div class="ox-sub">${l(a)}</div>`:""}</div><div class="r">${n}${q(e.status)}${r}</div></div>`}function U(o){let t=o.importance??"normal";return`<div class="ox-ev"><span class="d">${l(o.date??"")}</span><span class="ox-st ${t}">${t}</span><span>${o.entityId?`<a href="${f(o.entityId)}">${l(o.label)}</a>`:l(o.label)}</span></div>`}function Q(o){let t=o.flatMap(s=>[s.since,s.until]).filter(s=>!!s).map(s=>Number(s.slice(0,4))).filter(Boolean),e=Number(F().slice(0,4)),a=Math.min(...t,e-1),n=Math.max(1,e+1-a),r=(s,c)=>{if(!s)return c?100:0;let[p,x]=[Number(s.slice(0,4)),Number(s.slice(5,7))||(c?12:1)];return Math.min(100,Math.max(0,(p-a+(x-1)/12)/n*100))},i=`<div class="ox-tl-axis"><span></span><span class="yrs"><span>${a}</span><span>${e}</span></span></div>`;for(let s of o){let c=r(s.since,!1),p=r(s.until,!0),x=`${s.since??"\u2026"} \u2192 ${s.until??"now"}`;i+=`<div class="ox-tl-row"><div class="who">${s.chips.map(l).join(", ")}<small>${s.entityId?`<a href="${f(s.entityId)}">${l(s.label)}</a>`:l(s.label)}</small></div><div class="ox-track"><i class="${s.until?"past":""}" style="left:${c.toFixed(1)}%;width:${Math.max(4,p-c).toFixed(1)}%" title="${l(x)}">${l(x)}</i></div></div>`}return i}function S(o,t,e,a,n=""){let r=!a&&(e.total>e.items.length||e.def.source==="notes"||e.folded.length)?`<a class="zin" href="${f(t.id)}/${encodeURIComponent(e.def.panel)}">all ${e.total||""} (Z3) \u2192</a>`:"",s=e.def.source==="notes"||e.def.panel==="notes"?`${t.pages.length} page${t.pages.length===1?"":"s"}`:`${e.total} ${e.total===1?"item":"items"}`,c=`<span class="note">${e.ownerOnly?`${m("lock")} private to the owner \xB7 `:""}${s}</span>`,p="";e.def.source==="notes"||e.def.panel==="notes"?p=n||'<div class="ox-empty">No notes.</div>':e.items.length===0?p='<div class="ox-empty">Nothing recorded yet.</div>':e.def.display==="timeline"&&e.items.some(d=>d.since)?p=Q(e.items):e.def.source==="history"||e.items.every(d=>d.type==="event")?p=e.items.map(U).join(""):p=e.items.map(d=>Y(o,t,d)).join("");for(let d of e.rollups)p+=`<div class="ox-fold">\u21BB Recurring: ${l(d)}</div>`;return e.folded.length&&(p+=`<details class="ox-fold"><summary>+ ${e.folded.length} minor event${e.folded.length===1?"":"s"}</summary>${e.folded.slice(0,20).map(U).join("")}</details>`),`<section class="ox-card${e.def.display==="timeline"||e.def.source==="notes"||e.def.panel==="notes"?" wide":""}"><div class="ox-card-h"><h2>${l(e.title)}</h2>${c}${r}</div>${p}</section>`}function C(o,t){return z(t.replace(/<!--\s*tags?:[^>]*-->\s*\n?/gi,"").replace(/<!-- \/overview -->\s*\n?/g,""),{wikilink:(e,a)=>{let n=o.names.get(h(e));return n?`<a href="${f(n)}" class="wikilink">${a}</a>`:`<a href="/find?q=${encodeURIComponent(e)}" class="wikilink broken" title="No page yet">${a}</a>`}})}function k(o){return o.replace(/^---\n[\s\S]*?\n---\n?/,"").trim()}var X=/^##[ \t]+Overview[ \t]*$/im,N="<!-- /overview -->";function D(o){let t=X.exec(o);if(!t)return;let e=t.index+t[0].length,a=o.slice(e),n=a.indexOf(N),r=a.search(/^#{1,2}[ \t]/m),i=[n,r].filter(p=>p>=0),s=e+(i.length?Math.min(...i):a.length),c=n>=0&&e+n===s?s+N.length:s;return{start:t.index,textStart:e,end:s,after:c}}function ee(o){let t=k(o),e=D(t);return(e?t.slice(e.textStart,e.end).trim():"")||void 0}function te(o){let t=[...o.pages].sort((e,a)=>(a.article.meta.lastUpdated||"").localeCompare(e.article.meta.lastUpdated||""));for(let e of t){let a=ee(e.article.content);if(a)return a}}function oe(o,t){if(o.length<=t)return o;let e=o.slice(0,t),a=Math.max(...[". ","! ","? ","\u061F ","\u3002"].map(n=>e.lastIndexOf(n)));return a>t/3?e.slice(0,a+1):`${e.replace(/\s+\S*$/,"")}\u2026`}function ne(o,t=360){let n=(k(o.pages[0]?.article.content??"").split(/\n\s*\n/).map(r=>r.trim()).find(r=>r&&!r.startsWith("#")&&!r.startsWith("|")&&!r.startsWith("```"))??"").replace(/\[\[([^\]|]+)(?:\|([^\]]+))?\]\]/g,(r,i,s)=>s??i).replace(/\[([^\]]+)\]\([^)]*\)/g,"$1").replace(/^[-*]\s+/gm,"").replace(/[*_`]/g,"").replace(/\s+/g," ").trim();return oe(n,t)}function ae(o,t){return o.ontology.pillars.find(e=>e.id===t.pillar)}function W(o,t,e=[]){let a=ae(o,t);return L([{label:a?.label??t.pillar,href:`/p/${encodeURIComponent(t.pillar)}`},{label:b(o.ontology,t.type),href:`/p/${encodeURIComponent(t.pillar)}?kind=${encodeURIComponent(t.type)}`},{label:t.title,href:e.length?f(t.id):void 0},...e])}function _(o,t,e){if(!e){let a=t.pages[0];if(!a)return"";let n=k(a.article.content),r=D(n),i=(r?n.slice(0,r.start)+n.slice(r.after):n).trim(),s=i.length>1600?`${i.slice(0,1600).replace(/\n[^\n]*$/,"")}
150
150
 
151
151
  \u2026`:i;return`<div class="ox-prose">${C(o,s)}</div>`}return t.pages.map(a=>`<div class="ox-sub">from ${l(a.agentId)} \xB7 ${l(a.article.path)} \xB7 updated ${l(a.article.meta.lastUpdated||"\u2014")}</div><div class="ox-prose">${C(o,k(a.article.content))}</div>`).join('<hr style="border:0;border-top:1px solid var(--edge);margin:16px 0">')}function re(o,t,e){let a=o.ontology.types.find(i=>i.id===t.type),n=`<span class="ox-lbl">Lens for this type</span><div class="ox-annot"><b>${l(a?.label??t.type)}</b> opens with:<ol>`;n+=e.map(i=>`<li>${l(i.title??i.panel)}</li>`).join(""),n+=`</ol><span class="ox-sub">from ontology.yaml \xB7 types.${l(t.type)}.lens</span></div>`,n+='<span class="ox-lbl" style="margin-top:20px">Zoom in</span>';for(let i of e)n+=`<div class="ox-row"><span class="ox-ic">${m(g(i)==="history"?"calendar":g(i)==="discussed"?"chat":"arrow")}</span><div class="t"><a href="${f(t.id)}/${encodeURIComponent(i.panel)}">${l(i.title??i.panel)}</a><div class="ox-sub">Z3 \xB7 in full</div></div></div>`;n+='<span class="ox-lbl" style="margin-top:20px">Provenance</span>';let r=new Map;for(let i of t.pages)r.set(i.agentId,(r.get(i.agentId)??0)+1);for(let[i,s]of r){let c=t.pages.find(p=>p.agentId===i);n+=`<div class="ox-row"><span class="ox-ic">${m("agent")}</span><div class="t"><a href="/agent/${encodeURIComponent(i)}/article/${encodeURIComponent(c.article.path)}">${l(i)}</a><div class="ox-sub">${s} page${s===1?"":"s"} \xB7 ${t.statements.filter(p=>p.page.agentId===i).length} statements</div></div></div>`}return t.pages.length>1&&(n+=`<div class="ox-row"><span class="ox-ic">${m("merge")}</span><div class="t"><span class="l">${t.pages.length} pages merged</span><div class="ox-sub">same name, one entity</div></div></div>`),n}function ve(o,t){let{g:e}=o,a=E(e,t.type),n=e.ontology.types.find(p=>p.id===t.type),r=e.ontology.sidebar.pins.some(p=>e.names.get(h(p))===t.id),i=`<div class="ox-bar">${W(e,t)}${y(2)}</div>`;i+=`<div class="ox-head"><div class="ox-avatar">${u(e.ontology,t.type)}</div><div><h1>${l(t.title)}</h1><div class="ox-chips">`,i+=`<span class="ox-chip type">${u(e.ontology,t.type)}${l(n?.label??t.type)}</span>`,n?.schema&&(i+=`<span class="ox-chip mono">${l(n.schema.includes(" ")||n.schema.includes(":")?n.schema:`schema.org/${n.schema}`)}</span>`),t.type==="event"&&(i+=`<span class="ox-st ${t.importance}">${t.importance}</span>`),r&&(i+='<span class="ox-chip">pinned</span>'),t.pages.length>1&&(i+=`<span class="ox-chip">${m("merge")}merged from ${t.pages.length} pages</span>`),i+="</div></div></div>",t.review&&(i+=`<div class="ox-card ox-sub" style="border-color:var(--warn,#d97706)">Check the type: ${l(t.review)}</div>`);let s=te(t),c=s?"":ne(t);if((s||c)&&a[0]?.panel!=="notes"){let p=s?`<div class="ox-summary ox-prose">${C(e,s)}</div>`:`<p class="ox-summary">${l(c)}</p>`;i+=`<section class="ox-card">${p}<div class="ox-meta"><span>updated ${l(t.updated||"\u2014")}</span><span>sources: ${t.sources.length}</span><span>${t.statements.length} statements</span></div></section>`}i+='<div class="ox-grid2">';for(let p of a){let x=P(e,t,p,{full:!1,readEntries:o.readEntries}),d=g(p)==="notes";i+=S(e,t,x,!1,d?_(e,t,!1):"")}return i+="</div>",$(t.title,w(e,{pillar:t.pillar,entity:t.id}),i,re(e,t,a))}function be(o,t,e,a){let{g:n}=o,r=E(n,t.type).find(d=>d.panel===e);if(!r)return null;let i=P(n,t,r,{full:!0,page:a,pageSize:50,readEntries:o.readEntries}),s=r.title??r.panel,c=`<div class="ox-bar">${W(n,t,[{label:s}])}${y(3)}</div>`;c+=`<div class="ox-head"><div class="ox-avatar">${u(n.ontology,t.type)}</div><div><h1>${l(s)}</h1><p>${l(t.title)} \xB7 ${i.total} item${i.total===1?"":"s"}</p></div></div>`;let p=g(r)==="notes";c+=S(n,t,i,!0,p?_(n,t,!0):"");let x=Math.ceil(i.total/50);if(x>1){let d=`${f(t.id)}/${encodeURIComponent(e)}`;c+=`<div class="ox-pager">${a>1?`<a href="${d}?page=${a-1}">\u2190 newer</a>`:""}<span>page ${a} of ${x}</span>${a<x?`<a href="${d}?page=${a+1}">older \u2192</a>`:""}</div>`}return $(`${s} \xB7 ${t.title}`,w(n,{pillar:t.pillar,entity:t.id}),c)}function ye(o,t,e){let{g:a}=o,n=t.statements[e];if(!n)return null;let r=a.ontology.properties.find(d=>d.id===n.property),i=n.target?a.entities.get(n.target):void 0,s=n.page.article.meta,c=[["Subject",`<a href="${f(t.id)}">${l(t.title)}</a>`],["Property",`${l(r?.label??n.property)}${r?.wikidata?` <span class="ox-sub">wikidata ${l(r.wikidata)}</span>`:""}`],["Value",i?`<a href="${f(i.id)}">${l(i.title)}</a>`:l(n.value)]];n.role&&c.push(["Role",l(n.role)]),n.metric&&c.push(["Metric",l(n.metric)]),(n.since||n.until)&&c.push(["True",`${l(n.since??"\u2026")} \u2192 ${l(n.until??"now")}`]),n.at&&c.push(["Measured",l(n.at)]),c.push(["Recorded",l(s.lastUpdated||s.created||"\u2014")]),c.push(["Source",l(n.source??(s.sources.length?`${s.sources.length} conversation entries`:"not given"))]),c.push(["Written by",`${l(n.page.agentId)} \xB7 <a href="/agent/${encodeURIComponent(n.page.agentId)}/article/${encodeURIComponent(n.page.article.path)}">${l(n.page.article.path)}</a>`]),c.push(["Status",n.status?`<span class="ox-st ${l(n.status)}">${l(n.status)}</span>`:"not set"]),n.confirmed_by&&c.push(["Confirmed by",l(n.confirmed_by)]),n.checked_at&&c.push(["Checked",l(n.checked_at)]),c.push(["Access",l(n.access??s.access)]),n.note&&c.push(["Note",l(n.note)]);let p=o.versions(n.page.agentId,n.page.article.path);c.push(["Past versions",p.length?p.slice(0,8).map(d=>l(d.timestamp)).join("<br>"):"none saved"]);let x=`<div class="ox-bar">${W(a,t,[{label:r?.label??n.property}])}${y(4)}</div>`;return x+=`<div class="ox-head"><div class="ox-avatar">${m("key")}</div><div><h1>${l(r?.label??n.property)}</h1><p>${l(t.title)} \u2192 ${l(i?.title??n.value)}</p></div></div>`,x+=`<section class="ox-card">${c.map(([d,A])=>`<div class="ox-kv"><span class="k">${d}</span><span>${A}</span></div>`).join("")}</section>`,$(`${r?.label??n.property} \xB7 ${t.title}`,w(a,{pillar:t.pillar,entity:t.id}),x)}export{I as a,l as b,m as c,u as d,b as e,f,L as g,y as h,w as i,$ as j,k,N as l,D as m,ne as n,ve as o,be as p,ye as q};
152
- //# sourceMappingURL=chunk-H4NSB54D.js.map
152
+ //# sourceMappingURL=chunk-XVTD6I34.js.map
@@ -1,4 +1,4 @@
1
- import{a as _,k as O,l as M,m as D}from"./chunk-H4NSB54D.js";import{f as N,g as Y}from"./chunk-MTX4UPNB.js";import{f as v}from"./chunk-QAWKN2N4.js";import{c as G}from"./chunk-OWNQ2FD4.js";import{b as C}from"./chunk-KEXBEUSU.js";import{createHash as J}from"crypto";import{existsSync as B,mkdirSync as V,readFileSync as q,writeFileSync as K}from"fs";import{resolve as P}from"path";var H="wiki-enrich",$e=["person","organization","project","place","device","server","app","domain","account"],Q=new Set(["person","organization","project","place"]),F=3500,X=700;function Z(e,n){let s=e.ontology.types.find(r=>r.id===n)?.lens??[],t=new Map;for(let r of s)if(Y(r)==="statements")for(let i of N(r)){if(i==="related"||t.has(i))continue;let l=e.ontology.properties.find(u=>u.id===i);l?.domain&&!l.domain.includes(n)||t.set(i,l?.label??i.replace(/_/g," "))}return t}function T(e,n,s){let t=v(n.title);return t.length<4?[]:[...e.entities.values()].filter(r=>r.type===s&&r.id!==n.id&&` ${v(r.title)} `.includes(` ${t} `))}function L(e){return e.access==="public"?null:new Set([e.owner,...e.access==="shared"?e.sharedWith??[]:[]])}function ee(e,n){let s=L(e);if(!s)return!0;let t=L(n);return!!t&&[...t].every(r=>s.has(r))}function te(e,n,s,t){let r=a=>!t||ee(a.article.meta,t.article.meta),i=a=>a.pages.some(r),l=n.pages.filter(r),u=t?[...new Set(l.flatMap(a=>a.article.meta.sources??[]))]:n.sources,p=_(e,n,null).filter(i),f=a=>[...new Map(a.map(g=>[g.id,g])).values()],E=f([...p.filter(a=>a.type==="event"),...T(e,n,"event").filter(i)]).sort((a,g)=>(g.date||"").localeCompare(a.date||"")).slice(0,30),o=f([...p.filter(a=>a.type==="project"),...T(e,n,"project").filter(i)]).slice(0,12),d=p.filter(a=>a.type!=="event"&&a.type!=="project").filter(i).filter(a=>n.type!=="person"||Q.has(a.type)).slice(0,40),w=s(u).sort((a,g)=>g.date.localeCompare(a.date)).slice(0,14),c=Z(e,n.type),m=new Map;for(let a of c.keys()){let g=e.ontology.properties.find(h=>h.id===a)?.range;g?.length&&m.set(a,g)}return{entity:n,pages:l,properties:c,ranges:m,neighbours:d,events:E,projects:o,entries:w,sources:u,mentions:ne(e,n,12,r)}}function ne(e,n,s=12,t=()=>!0){let r=[n.title,...n.pages.flatMap(p=>p.article.meta.aliases??[])].filter(p=>p.trim().length>=3);if(r.length===0)return[];let i=r.map(p=>p.trim().replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),l=new RegExp(`(^|[^\\p{L}\\p{N}])(${i.join("|")})(?=$|[^\\p{L}\\p{N}])`,"iu"),u=[];for(let p of e.entities.values())if(!(p.id===n.id||p.type==="event"))for(let f of p.pages){if(!t(f))continue;let E=O(f.article.content),o=l.exec(E);if(!o)continue;let d=Math.max(0,o.index-250);u.push({page:f,excerpt:E.slice(d,o.index+450).replace(/\s+/g," ").trim(),at:f.article.meta.lastUpdated||""});break}return u.sort((p,f)=>f.at.localeCompare(p.at)).slice(0,s).map(({page:p,excerpt:f})=>({page:p,excerpt:f}))}function ie(e){let n=[...e.pages.map(s=>`${s.agentId}/${s.article.path}`),...e.sources,...e.events.map(s=>s.id),...e.projects.map(s=>s.id),...e.mentions.map(s=>`${s.page.agentId}/${s.page.article.path}`)].sort();return J("sha1").update(n.join(`
1
+ import{a as _,k as O,l as M,m as D}from"./chunk-XVTD6I34.js";import{f as v}from"./chunk-QAWKN2N4.js";import{f as N,g as Y}from"./chunk-MTX4UPNB.js";import{c as G}from"./chunk-OWNQ2FD4.js";import{b as C}from"./chunk-KEXBEUSU.js";import{createHash as J}from"crypto";import{existsSync as B,mkdirSync as V,readFileSync as q,writeFileSync as K}from"fs";import{resolve as P}from"path";var H="wiki-enrich",$e=["person","organization","project","place","device","server","app","domain","account"],Q=new Set(["person","organization","project","place"]),F=3500,X=700;function Z(e,n){let s=e.ontology.types.find(r=>r.id===n)?.lens??[],t=new Map;for(let r of s)if(Y(r)==="statements")for(let i of N(r)){if(i==="related"||t.has(i))continue;let l=e.ontology.properties.find(u=>u.id===i);l?.domain&&!l.domain.includes(n)||t.set(i,l?.label??i.replace(/_/g," "))}return t}function T(e,n,s){let t=v(n.title);return t.length<4?[]:[...e.entities.values()].filter(r=>r.type===s&&r.id!==n.id&&` ${v(r.title)} `.includes(` ${t} `))}function L(e){return e.access==="public"?null:new Set([e.owner,...e.access==="shared"?e.sharedWith??[]:[]])}function ee(e,n){let s=L(e);if(!s)return!0;let t=L(n);return!!t&&[...t].every(r=>s.has(r))}function te(e,n,s,t){let r=a=>!t||ee(a.article.meta,t.article.meta),i=a=>a.pages.some(r),l=n.pages.filter(r),u=t?[...new Set(l.flatMap(a=>a.article.meta.sources??[]))]:n.sources,p=_(e,n,null).filter(i),f=a=>[...new Map(a.map(g=>[g.id,g])).values()],E=f([...p.filter(a=>a.type==="event"),...T(e,n,"event").filter(i)]).sort((a,g)=>(g.date||"").localeCompare(a.date||"")).slice(0,30),o=f([...p.filter(a=>a.type==="project"),...T(e,n,"project").filter(i)]).slice(0,12),d=p.filter(a=>a.type!=="event"&&a.type!=="project").filter(i).filter(a=>n.type!=="person"||Q.has(a.type)).slice(0,40),w=s(u).sort((a,g)=>g.date.localeCompare(a.date)).slice(0,14),c=Z(e,n.type),m=new Map;for(let a of c.keys()){let g=e.ontology.properties.find(h=>h.id===a)?.range;g?.length&&m.set(a,g)}return{entity:n,pages:l,properties:c,ranges:m,neighbours:d,events:E,projects:o,entries:w,sources:u,mentions:ne(e,n,12,r)}}function ne(e,n,s=12,t=()=>!0){let r=[n.title,...n.pages.flatMap(p=>p.article.meta.aliases??[])].filter(p=>p.trim().length>=3);if(r.length===0)return[];let i=r.map(p=>p.trim().replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),l=new RegExp(`(^|[^\\p{L}\\p{N}])(${i.join("|")})(?=$|[^\\p{L}\\p{N}])`,"iu"),u=[];for(let p of e.entities.values())if(!(p.id===n.id||p.type==="event"))for(let f of p.pages){if(!t(f))continue;let E=O(f.article.content),o=l.exec(E);if(!o)continue;let d=Math.max(0,o.index-250);u.push({page:f,excerpt:E.slice(d,o.index+450).replace(/\s+/g," ").trim(),at:f.article.meta.lastUpdated||""});break}return u.sort((p,f)=>f.at.localeCompare(p.at)).slice(0,s).map(({page:p,excerpt:f})=>({page:p,excerpt:f}))}function ie(e){let n=[...e.pages.map(s=>`${s.agentId}/${s.article.path}`),...e.sources,...e.events.map(s=>s.id),...e.projects.map(s=>s.id),...e.mentions.map(s=>`${s.page.agentId}/${s.page.article.path}`)].sort();return J("sha1").update(n.join(`
2
2
  `)).digest("hex").slice(0,16)}var x=(e,n)=>e.length>n?`${e.slice(0,n)}\u2026`:e;function se(e,n,s){let t=e.entity,r=[`You are bringing one wiki page up to date. Today is ${s}.`,`Subject: "${t.title}" (${n}).`,"","## What the agents' pages say"];for(let i of e.pages)r.push(`### page ${i.agentId}/${i.article.path} (updated ${i.article.meta.lastUpdated||"?"})`,x(O(i.article.content),F),"");if(e.mentions.length){r.push("## Other pages that name the subject");for(let i of e.mentions)r.push(`### page ${i.page.agentId}/${i.page.article.path}: "${i.page.article.meta.title}"`,i.excerpt,"")}r.push("## Source entries (newest first)");for(let i of e.entries)r.push(`### entry ${i.id} (${i.date}, ${i.agentId}, ${i.source})`,x(i.content.trim(),X),"");return r.push("## Event pages",...e.events.map(i=>`- ${i.date||"?"} \xB7 ${i.title}`),""),r.push("## Project pages",...e.projects.map(i=>`- ${i.title}`),""),r.push("## Other pages it may name",...e.neighbours.map(i=>`- ${i.title} (${i.type})`),""),r.push(`## Properties you may use (the subject is always ${t.title})`,...[...e.properties].map(([i,l])=>`- ${i}: "${t.title} ${l} <value>"${e.ranges.get(i)?`, value is a ${e.ranges.get(i).join(" or ")}`:""}`),""),r.push("## Task","Return one JSON object and nothing else:",'{"overview": "\u2026", "statements": [{"property": "\u2026", "value": "\u2026", "role": "\u2026", "since": "YYYY-MM-DD", "until": "YYYY-MM-DD", "source": "\u2026"}], "history": ["event page title"], "projects": ["project page title"]}',"","Rules:",`- overview: 3 to 6 full sentences telling the story of the relationship: who ${t.title} is to us, how it started, what changed, and where it stands now, with dates. Plain prose. Link pages as [[Exact Title]] only when the title is listed above. Never stop mid-sentence.`,"- statements: only facts the pages or entries state. Use only the listed properties. value is a listed page title when it names one, else a short literal. role, since and until only when stated.","- source: the entry id, the page (agent/path) or the event title the fact comes from. A statement without one of these is dropped.","- Do not list an AI agent or bot as a person's relation.","- history: titles of the listed event pages that are about the subject. projects: listed project titles it takes part in.","- Leave out anything you could not verify. Do not write 'unknown' or 'not captured' as a fact.","- Write in the language the pages are written in."),r.join(`
3
3
  `)}function re(e){let n=e.match(/```(?:json)?\s*\n([\s\S]*?)\n```/),s=n?n[1]:e.slice(e.indexOf("{"),e.lastIndexOf("}")+1);try{let t=JSON.parse(s);return t&&typeof t=="object"&&!Array.isArray(t)?t:null}catch{return null}}var z=/^\d{4}-\d{2}(-\d{2})?$/,b=e=>typeof e=="string"?e.trim():"";function oe(e,n,s){let t=[],r=n.entity,i=b(e.overview);if(i&&!/[.!?؟)»"']$/.test(i)){let o=Math.max(i.lastIndexOf(". "),i.lastIndexOf("? "),i.lastIndexOf("! "));i=o>0?i.slice(0,o+1):"",t.push("overview: unfinished last sentence removed")}let l=[...n.entries.map(o=>o.id),...n.pages.map(o=>`${o.agentId}/${o.article.path}`),...n.pages.map(o=>o.article.path),...n.mentions.map(o=>`${o.page.agentId}/${o.page.article.path}`),...n.mentions.map(o=>o.page.article.path),...n.events.map(o=>o.title)],u=[],p=new Set;for(let o of Array.isArray(e.statements)?e.statements:[]){let d=o??{},w=b(d.property),c=b(d.value),m=b(d.source),a=`${w} ${c}`;if(!n.properties.has(w)){t.push(`${a}: property not allowed`);continue}if(!c||/^(unknown|not (given|known|captured|recorded))\b/i.test(c)){t.push(`${a}: no value`);continue}if(!m||!l.some(k=>m.includes(k))){t.push(`${a}: source not among those given`);continue}let g=s.names.get(v(c)),h=g?s.entities.get(g):void 0;if(h?.id===r.id){t.push(`${a}: points at itself`);continue}if(r.type==="person"&&h?.type==="agent"){t.push(`${a}: an agent is not a person's relation`);continue}let j=n.ranges.get(w);if(j&&h&&!j.includes(h.type)){t.push(`${a}: value is a ${h.type}, expected ${j.join(" or ")}`);continue}let A=`${w}
4
4
  ${v(c)}`;if(p.has(A))continue;p.add(A);let $={property:w,value:h?.title??c,source:x(m,200)},W=b(d.role);W&&($.role=x(W,80)),z.test(b(d.since))&&($.since=b(d.since)),z.test(b(d.until))&&($.until=b(d.until)),u.push($)}let f=new Map([...n.events,...n.projects].map(o=>[v(o.title),o.title])),E=[];for(let o of[...Array.isArray(e.history)?e.history:[],...Array.isArray(e.projects)?e.projects:[]]){let d=f.get(v(b(o).replace(/^\d{4}-\d{2}-\d{2}\s*·\s*/,"")));d&&!E.includes(d)?E.push(d):!d&&b(o)&&t.push(`link ${b(o)}: no such page`)}return{overview:i,statements:u,links:E,dropped:t}}function ae(e,n){let s=`## Overview
@@ -13,4 +13,4 @@ ${e.trim()}
13
13
  `}function ce(e,n,s){let t=p=>`${p.property}
14
14
  ${v(p.value)}`,r=(e.statements??[]).filter(p=>p.by!==H),i=new Set(r.map(t)),l=[...r,...n.statements.filter(p=>!i.has(t(p))).map(p=>({...p,checked_at:s,by:H}))],u=[...new Set([...e.related??[],...n.links])];return{...e,statements:l.length?l:void 0,related:u.length?u:void 0,lastUpdated:s}}function pe(e,n){return n.pages.filter(s=>!e.syncedFrom(s.agentId)).sort((s,t)=>(t.article.meta.sources?.length??0)-(s.article.meta.sources?.length??0)||t.article.content.length-s.article.content.length)[0]}var le={person:"people",organization:"organizations",project:"projects",place:"places"};function Ee(e,n,s,t,r){let i=n.replace(/\s+/g," ").trim(),l=e.getAgentWiki(t);if(l.listAllArticles().some(E=>v(E.meta.title)===v(i)))return null;let u=`${le[s]??`${s}s`}/${v(i).replace(/ /g,"-").slice(0,80)||"page"}.md`,p=C(s)?s:void 0,f={title:i,type:p,class:s,tags:[],owner:t,access:"shared",created:r,lastUpdated:r,sources:[]};return l.writeArticle(u,f,`${i}.
15
15
  `,t)?u:null}function ke(e){let n=P(e,"_enrich","state.json");if(!B(n))return{entities:{}};try{let s=JSON.parse(q(n,"utf-8"));return s&&typeof s.entities=="object"?s:{entities:{}}}catch{return{entities:{}}}}function be(e,n){V(P(e,"_enrich"),{recursive:!0}),K(P(e,"_enrich","state.json"),JSON.stringify(n,null,2))}async function Se(e,n,s,t,r){let i=new Set(t.types),l=new Set(t.only.map(v)),u=c=>c.sources.length+c.pages.length,p=c=>r.entities[c.id]?.failures??0,f=[...n.entities.values()].filter(c=>i.has(c.type)).filter(c=>l.size===0||l.has(v(c.id))||l.has(v(c.title))).sort((c,m)=>p(c)-p(m)||u(m)-u(c)),E=c=>e.getSharedStore().readEntries(c),o={outcomes:[],costUsd:0,capped:!1},d=0,w=(c,m,a,g=!1)=>{if(t.dryRun)return;let h=r.entities[c];r.entities[c]=g?{fingerprint:h?.fingerprint??"",at:new Date().toISOString(),costUsd:a,failures:(h?.failures??0)+1}:{fingerprint:m,at:new Date().toISOString(),costUsd:a},t.save?.(r)};for(let c of f){if(d>=t.max)break;let m={entity:c.id,title:c.title,statements:0,links:0,overview:!1,costUsd:0,dropped:[]},a=pe(e,c);if(!a){o.outcomes.push({...m,status:"no-page"});continue}let g=te(n,c,E,a),h=ie(g);if(!t.force&&r.entities[c.id]?.fingerprint===h){l.size&&o.outcomes.push({...m,status:"unchanged"});continue}if(o.costUsd>=t.maxCostUsd){o.capped=!0;break}d++;let j=n.ontology.types.find(y=>y.id===c.type)?.label??c.type,A=`${a.agentId}/${a.article.path}`,$;try{$=await s(se(g,j,t.today))}catch(y){o.outcomes.push({...m,page:A,status:"failed",dropped:[y.message.slice(0,200)]}),w(c.id,h,0,!0);continue}o.costUsd+=$.costUsd;let W=re($.text),k={...m,page:A,status:"no-reply",costUsd:$.costUsd};if(!W){o.outcomes.push(k),w(c.id,h,$.costUsd);continue}let S=oe(W,g,n);if(Object.assign(k,{statements:S.statements.length,links:S.links.length,overview:!!S.overview,dropped:S.dropped}),!S.overview&&S.statements.length===0&&S.links.length===0){k.status="nothing-new",o.outcomes.push(k),w(c.id,h,$.costUsd);continue}let U=y=>S.overview?ae(y.content,S.overview):y.content;if(t.dryRun){o.outcomes.push({...k,status:"dry-run",preview:U(a.article),facts:S.statements});continue}let R=e.getAgentWiki(a.agentId),I;try{I=R.withArticleLock(a.article.path,()=>{let y=R.readArticle(a.article.path);return y?R.writeArticle(a.article.path,ce(y.meta,S,t.today),U(y),y.meta.owner||a.agentId)?void 0:"write refused":"the page was moved or removed during the run"})}catch(y){if(!(y instanceof G))throw y;I="the page was busy; run again"}if(I){k.status="failed",k.dropped.push(I),o.outcomes.push(k),w(c.id,h,$.costUsd,!0);continue}R.rebuildIndex(),w(c.id,h,$.costUsd),k.status="written",o.outcomes.push(k)}return o}export{H as a,$e as b,Z as c,ee as d,te as e,ne as f,ie as g,se as h,re as i,oe as j,ae as k,ce as l,pe as m,Ee as n,ke as o,be as p,Se as q};
16
- //# sourceMappingURL=chunk-U6EJ53DA.js.map
16
+ //# sourceMappingURL=chunk-YWEGKAE2.js.map
package/dist/cli.js CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
- import{b as o}from"./chunk-JXF54PT7.js";import"./chunk-QIJLFPWE.js";var e=o(process.versions.node);e&&(console.error(e),process.exit(1));var{buildProgram:s}=await import("./program-7VHY5RVZ.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-JXF54PT7.js";import"./chunk-QIJLFPWE.js";var e=o(process.versions.node);e&&(console.error(e),process.exit(1));var{buildProgram:s}=await import("./program-SJT7PIFO.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-U6EJ53DA.js";import"./chunk-H4NSB54D.js";import"./chunk-MTX4UPNB.js";import"./chunk-QAWKN2N4.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-R2LIDLPZ.js.map
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,3 +1,3 @@
1
- import{a as A,k as R}from"./chunk-H4NSB54D.js";import"./chunk-MTX4UPNB.js";import{f as g}from"./chunk-QAWKN2N4.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-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(`
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-WOYYEWSZ.js.map
3
+ //# sourceMappingURL=event-levels-NBOMTB23.js.map
@@ -1,7 +1,7 @@
1
- import{b as h}from"./chunk-HGU5B7IY.js";import"./chunk-RKPAVWXF.js";import{b as I}from"./chunk-Q4XP5TBI.js";import"./chunk-SHEUCITK.js";import"./chunk-ANDEMOYE.js";import"./chunk-JS2LEURJ.js";import"./chunk-NMYPZR4W.js";import"./chunk-3UOTLMXD.js";import"./chunk-FCPTN6NF.js";import"./chunk-7I7IEX4S.js";import"./chunk-MGM33GOW.js";import"./chunk-BRK6M6LA.js";import"./chunk-UIBUZ2N3.js";import"./chunk-2QNT5JDS.js";import"./chunk-QIJLFPWE.js";var p=t=>typeof t=="string"?t.trim():"";function $(t){return[`Run ${t.runId} "${t.title}" [${t.status}] on step ${t.step}: waiting on ${t.waitingOn}.`,t.tags?.length?`Tags: ${t.tags.join(", ")}`:"",...(t.steps??[]).slice(-8).map(s=>`- ${String(s.at).slice(0,16).replace("T"," ")} ${s.step} ${s.status}${s.note?`: ${s.note}`:""}`)].filter(Boolean).join(`
1
+ import{b as h}from"./chunk-HGU5B7IY.js";import"./chunk-RKPAVWXF.js";import{b as I}from"./chunk-3W2BHUGM.js";import"./chunk-SHEUCITK.js";import"./chunk-ANDEMOYE.js";import"./chunk-JS2LEURJ.js";import"./chunk-NMYPZR4W.js";import"./chunk-3UOTLMXD.js";import"./chunk-FCPTN6NF.js";import"./chunk-7I7IEX4S.js";import"./chunk-MGM33GOW.js";import"./chunk-BRK6M6LA.js";import"./chunk-UIBUZ2N3.js";import"./chunk-2QNT5JDS.js";import"./chunk-QIJLFPWE.js";var p=t=>typeof t=="string"?t.trim():"";function $(t){return[`Run ${t.runId} "${t.title}" [${t.status}] on step ${t.step}: waiting on ${t.waitingOn}.`,t.tags?.length?`Tags: ${t.tags.join(", ")}`:"",...(t.steps??[]).slice(-8).map(s=>`- ${String(s.at).slice(0,16).replace("T"," ")} ${s.step} ${s.status}${s.note?`: ${s.note}`:""}`)].filter(Boolean).join(`
2
2
  `)}async function T(t,c){let s=c.fetch??fetch,m=c.daemonUrl.replace(/\/$/,""),r=(p(t.action)||"list").toLowerCase(),f=c.env??process.env,w=async i=>{let l=await s(`${m}${i}`,{signal:AbortSignal.timeout(1e4)}),n=await l.json().catch(()=>({}));return{ok:l.ok,status:l.status,data:n}};try{if(r==="list"){let e=await w("/follow-up");if(!e.ok)return`Error: ${e.data?.error||`HTTP ${e.status}`}`;let o=e.data.groups??[];return o.length?o.map(d=>[`${d.tag}:`,...d.rows.map(a=>`- ${a.runId} "${a.title}" on ${a.step}: waiting on ${a.waitingOn} (since ${String(a.since).slice(0,16).replace("T"," ")} UTC)`)].join(`
3
3
  `)).join(`
4
4
  `):"No follow-up workflows are running."}if(r==="match"){let e=p(t.request)||p(t.title);if(!e)return"Error: match needs `request`: the owner's request in their words.";let o=h(t,f),d=await w(`/follow-up/match?q=${encodeURIComponent(e)}${o?`&agentId=${encodeURIComponent(o.agentId)}`:""}`);if(!d.ok)return`Error: ${d.data?.error||`HTTP ${d.status}`}`;let a=d.data.matches??[];return a.length?["Saved workflows, best fit first (confidence 0-1):",...a.map(u=>`- ${u.workflowId} "${u.title}" (${u.confidence}${u.autoStart?", starts without asking":""}): ${u.steps.map(k=>k.id).join(" \u2192 ")}`),'Start one with {action:"start", workflowId:"<id>", title:"\u2026", tags:["client:<name>"]}. Run its steps through the workflow, not by hand.'].join(`
5
5
  `):"No saved workflow fits. If the request has several steps, build one: start with title and steps."}if(r==="status"){let e=p(t.runId);if(!e)return"Error: status needs runId.";let o=await w(`/follow-up/${encodeURIComponent(e)}`);return o.ok?$(o.data.run):`Error: ${o.data?.error||`HTTP ${o.status}`}`}let i=h(t,f);if(!i)return"Error: couldn't tell which agent you are. Pass callerAgentId.";let l=await s(`${m}/follow-up`,{method:"POST",headers:{"Content-Type":"application/json",...I(f)},body:JSON.stringify({action:r,agentId:i.agentId,workflowId:t.workflowId,title:t.title,description:t.description,tags:t.tags,inputs:t.inputs,steps:t.steps,edges:t.edges,approval:t.approval,autoStart:t.autoStart,requestId:t.requestId,runId:t.runId,step:t.step,evidence:t.evidence,note:t.note,reason:t.reason,fromRun:t.fromRun,status:t.status}),signal:AbortSignal.timeout(2e4)}),n=await l.json().catch(()=>({}));if(!l.ok)return`Error: ${n?.error||`HTTP ${l.status}`}`;if(r==="start"){let e=n.run;return[`Started run ${e.runId} "${e.title}"${n.built?" (built from the steps you gave; propose it with fromRun to keep it)":""}.`,n.awaitingApproval?"It waits for the owner's approval before the first step.":`It is on step ${e.step}: ${e.waitingOn}.`,"AgentX follows it from here: it starts each step, reminds whoever is slow, and tells the owner when it ends. Do not run its steps by hand.",...n.warning?[`Note: ${n.warning}`]:[]].join(" ")}return r==="plan"?[`Plan recorded on run ${n.run?.runId??t.runId}:`,...(n.plan??[]).map(e=>`- ${e.id} ${e.title}`),'Report each step with {action:"step", runId, step:"<id>", status:"started"|"done"|"failed"}.'].join(`
6
6
  `):r==="step"?`Step recorded. ${n.run?$(n.run):""}`.trim():r==="done"?`Step recorded as done. ${n.run?$(n.run):""}`.trim():r==="blocked"?"The step is marked blocked and the owner is told. Nothing more happens on it until it is sorted.":`Saved ${n.workflowId} switched off, and asked the owner (card ${n.cardId}) whether to keep it as a reusable workflow.`}catch(i){return`Error: couldn't reach the daemon (${i?.message??i}).`}}export{T as runWorkflowTool};
7
- //# sourceMappingURL=follow-up-tool-QRECR3AH.js.map
7
+ //# sourceMappingURL=follow-up-tool-M2KCLRQQ.js.map
package/dist/index.d.ts CHANGED
@@ -10807,6 +10807,12 @@ declare class AgentXDaemon {
10807
10807
  /** In-flight work the drain waits for: local agent tasks + mesh forwards. */
10808
10808
  /** The runs in flight, oldest first: what a restart would cut off. */
10809
10809
  private runningSummaries;
10810
+ /** Which token a GitLab write for this agent would use (#984). */
10811
+ private postingIdentity;
10812
+ /** GitLab token health for /health: absent when the channel is off. A
10813
+ * rejected global token is called out, since every agent without its
10814
+ * own token posts with it (#984). */
10815
+ private gitlabHealth;
10810
10816
  private inflightCounts;
10811
10817
  /** Set by start(): the same graceful path a SIGTERM takes. */
10812
10818
  private requestShutdown?;
@@ -16910,7 +16916,9 @@ declare class WhatsAppAdapter implements ChannelAdapter {
16910
16916
  private routes;
16911
16917
  private handler?;
16912
16918
  private sock;
16913
- private reconnectAttempts;
16919
+ private reconnect;
16920
+ /** Resets the reconnect counters once a connection has stayed open for a while. */
16921
+ private stableTimer;
16914
16922
  /** Generation counter — incremented on each start() to ignore stale socket events */
16915
16923
  private generation;
16916
16924
  private sentMessageIds;
@@ -16930,6 +16938,8 @@ declare class WhatsAppAdapter implements ChannelAdapter {
16930
16938
  private onQR?;
16931
16939
  /** Fires whenever the connection state changes (connecting / open / close). */
16932
16940
  private onStatus?;
16941
+ /** Fires once when the adapter stops reconnecting, so the owner hears about a silent channel. */
16942
+ private onGiveUp?;
16933
16943
  constructor(config: {
16934
16944
  sessionDir: string;
16935
16945
  defaultAgent?: string;
@@ -16937,6 +16947,7 @@ declare class WhatsAppAdapter implements ChannelAdapter {
16937
16947
  routes?: WhatsAppRoute[];
16938
16948
  onQR?: (qr: string | null) => void;
16939
16949
  onStatus?: (status: "connecting" | "open" | "close", detail?: string) => void;
16950
+ onGiveUp?: (message: string) => void;
16940
16951
  /** Throttle settings for live Baileys reads. Falls back to safe defaults. */
16941
16952
  throttle?: {
16942
16953
  minMsBetweenCalls?: number;
@@ -16957,6 +16968,8 @@ declare class WhatsAppAdapter implements ChannelAdapter {
16957
16968
  onMessage(handler: (msg: IncomingMessage) => Promise<void>): void;
16958
16969
  start(): Promise<void>;
16959
16970
  stop(): Promise<void>;
16971
+ private clearStableTimer;
16972
+ private resetReconnect;
16960
16973
  send(msg: OutgoingMessage): Promise<string>;
16961
16974
  editMessage(chatId: string, messageId: string, text: string): Promise<boolean>;
16962
16975
  sendTyping(chatId: string): Promise<void>;
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import{a as St,b as kt,c as vt,d as xt,e as $t,f as Ct,g as Pt,h as bt,la as Tt,ma as Mt}from"./chunk-34XYHSL6.js";import"./chunk-KO6BU3B3.js";import"./chunk-GTJIKXDB.js";import"./chunk-J7U3BASX.js";import"./chunk-7LN4VKDU.js";import"./chunk-IMLAPB7G.js";import"./chunk-ZVP6GB4G.js";import"./chunk-S2GAEH2F.js";import"./chunk-UNIXYV3U.js";import"./chunk-AKWBDCMU.js";import"./chunk-PPUN7YHA.js";import"./chunk-VZLIBDLH.js";import"./chunk-EKJG63EJ.js";import"./chunk-EMGB23H5.js";import"./chunk-JAML6222.js";import"./chunk-YMX3QCV7.js";import"./chunk-JWDJMFU6.js";import"./chunk-5HLD66CW.js";import"./chunk-IS2IWRP7.js";import"./chunk-LQE73AZR.js";import"./chunk-2D3RYIDU.js";import"./chunk-MRIVENBY.js";import"./chunk-A5GYG56I.js";import"./chunk-Z5IHT6RK.js";import"./chunk-2AXFYDWF.js";import"./chunk-AQASR6KR.js";import{ca as yt,m as lt,n as ct,o as dt,p as mt,q as pt}from"./chunk-RIYQNADV.js";import"./chunk-2BEZU5OF.js";import"./chunk-QSKG754X.js";import"./chunk-MEFPXHQJ.js";import{a as L}from"./chunk-UG2OF2EI.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-MUC7MMTT.js";import{a as B,b as M,c as F}from"./chunk-SFQUP3BP.js";import"./chunk-Y4CYQV7G.js";import"./chunk-Q4XP5TBI.js";import"./chunk-SHEUCITK.js";import"./chunk-ANDEMOYE.js";import"./chunk-SZDACK6O.js";import"./chunk-HF5EF335.js";import"./chunk-W4YR2RO2.js";import"./chunk-AFRHKA7B.js";import{s as ut}from"./chunk-JS2LEURJ.js";import"./chunk-NMYPZR4W.js";import"./chunk-3UOTLMXD.js";import"./chunk-36AXN6ZB.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-AXHP6TMT.js";import{a as ht}from"./chunk-STIZFWDJ.js";import"./chunk-OWNQ2FD4.js";import"./chunk-KEXBEUSU.js";import"./chunk-ROLSSYXE.js";import"./chunk-HXLB2XCT.js";import"./chunk-SKSYII3K.js";import{f as gt,g as ft}from"./chunk-7KAQHNLT.js";import"./chunk-WPNRDEHW.js";import"./chunk-MWNCS57L.js";import"./chunk-4LWFJ4MZ.js";import"./chunk-BIJHMWXK.js";import"./chunk-JJZVFDG6.js";import{j as it,k as rt,l as at}from"./chunk-LMZCB7TT.js";import"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-MCI3DIWW.js";import"./chunk-MYVHVJWZ.js";import"./chunk-6TURWSMN.js";import"./chunk-AV7T3SYT.js";import"./chunk-Y5MFVVTM.js";import"./chunk-QD6IICK7.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-2PJKGZWP.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{Aa as nt,qa as tt,sa as st,ta as ot}from"./chunk-MGM33GOW.js";import"./chunk-BRK6M6LA.js";import"./chunk-UIBUZ2N3.js";import"./chunk-2QNT5JDS.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 St,b as kt,c as vt,d as xt,e as $t,f as Ct,g as Pt,h as bt,la as Tt,ma as Mt}from"./chunk-65LN6GQP.js";import"./chunk-4LNJR5PC.js";import"./chunk-GTJIKXDB.js";import"./chunk-J7U3BASX.js";import"./chunk-S2GAEH2F.js";import"./chunk-7LN4VKDU.js";import"./chunk-IMLAPB7G.js";import"./chunk-ZVP6GB4G.js";import"./chunk-MRIVENBY.js";import"./chunk-UNIXYV3U.js";import"./chunk-AKWBDCMU.js";import"./chunk-PPUN7YHA.js";import"./chunk-VZLIBDLH.js";import"./chunk-EKJG63EJ.js";import"./chunk-Z5IHT6RK.js";import"./chunk-EMGB23H5.js";import"./chunk-JAML6222.js";import"./chunk-YMX3QCV7.js";import"./chunk-JWDJMFU6.js";import"./chunk-5HLD66CW.js";import"./chunk-IS2IWRP7.js";import"./chunk-LQE73AZR.js";import"./chunk-2D3RYIDU.js";import"./chunk-Y4CYQV7G.js";import"./chunk-3W2BHUGM.js";import"./chunk-SHEUCITK.js";import"./chunk-A5GYG56I.js";import"./chunk-2AXFYDWF.js";import"./chunk-AQASR6KR.js";import{ca as yt,m as lt,n as ct,o as dt,p as mt,q as pt}from"./chunk-LGB6ILTW.js";import"./chunk-HWYU6XG2.js";import"./chunk-QSKG754X.js";import"./chunk-MEFPXHQJ.js";import{a as L}from"./chunk-UG2OF2EI.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-BUKXFZEO.js";import{a as B,b as M,c as F}from"./chunk-SFQUP3BP.js";import"./chunk-6TTGRTDO.js";import"./chunk-ANDEMOYE.js";import"./chunk-SZDACK6O.js";import"./chunk-VE3SSOQX.js";import"./chunk-W4YR2RO2.js";import"./chunk-AFRHKA7B.js";import{s as ut}from"./chunk-JS2LEURJ.js";import"./chunk-NMYPZR4W.js";import"./chunk-3UOTLMXD.js";import"./chunk-36AXN6ZB.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-AXHP6TMT.js";import{a as ht}from"./chunk-STIZFWDJ.js";import"./chunk-OWNQ2FD4.js";import"./chunk-KEXBEUSU.js";import"./chunk-ROLSSYXE.js";import"./chunk-HXLB2XCT.js";import"./chunk-SKSYII3K.js";import{f as gt,g as ft}from"./chunk-7KAQHNLT.js";import"./chunk-WPNRDEHW.js";import"./chunk-MWNCS57L.js";import"./chunk-4LWFJ4MZ.js";import"./chunk-BIJHMWXK.js";import"./chunk-JJZVFDG6.js";import{j as it,k as rt,l as at}from"./chunk-LMZCB7TT.js";import"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-MCI3DIWW.js";import"./chunk-MYVHVJWZ.js";import"./chunk-6TURWSMN.js";import"./chunk-AV7T3SYT.js";import"./chunk-Y5MFVVTM.js";import"./chunk-QD6IICK7.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-2PJKGZWP.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{Aa as nt,qa as tt,sa as st,ta as ot}from"./chunk-MGM33GOW.js";import"./chunk-BRK6M6LA.js";import"./chunk-UIBUZ2N3.js";import"./chunk-2QNT5JDS.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).