agentix-cli 0.135.0 → 0.135.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{absorb-eval-WY3YMLS4.js → absorb-eval-YT5TOTC7.js} +2 -2
- package/dist/{agent-3R5NY7I3.js → agent-DRUIMWF5.js} +2 -2
- package/dist/{board-dashboard-U3ZSCO62.js → board-dashboard-2524GN5N.js} +2 -2
- package/dist/chunk-32LIPTHM.js +55 -0
- package/dist/chunk-32LIPTHM.js.map +1 -0
- package/dist/{chunk-5NT44FKL.js → chunk-3D5XUOBL.js} +2 -2
- package/dist/{chunk-EEBK4F6E.js → chunk-3F4GPRGQ.js} +2 -2
- package/dist/{chunk-BQIWMQNU.js → chunk-H4NSB54D.js} +2 -2
- package/dist/chunk-MTX4UPNB.js +3 -0
- package/dist/chunk-MTX4UPNB.js.map +1 -0
- package/dist/{chunk-NY7NHGVT.js → chunk-MUVE3UAS.js} +2 -2
- package/dist/chunk-MWNCS57L.js +2 -0
- package/dist/chunk-MWNCS57L.js.map +1 -0
- package/dist/{chunk-GSKJ57XY.js → chunk-NG72DYJR.js} +80 -80
- package/dist/chunk-NG72DYJR.js.map +1 -0
- package/dist/{chunk-ZGVVYJIK.js → chunk-R6ECKZLE.js} +2 -2
- package/dist/{chunk-MI7WOGH6.js → chunk-R6KLH34H.js} +2 -2
- package/dist/{chunk-RGZARSHV.js → chunk-ROLSSYXE.js} +1 -1
- package/dist/{chunk-RGZARSHV.js.map → chunk-ROLSSYXE.js.map} +1 -1
- package/dist/{chunk-YA3P77LV.js → chunk-SKSYII3K.js} +2 -2
- package/dist/{chunk-6WF56ME6.js → chunk-SN7YH4E4.js} +2 -2
- package/dist/{chunk-RVEMX5MJ.js → chunk-TTG3ZW3W.js} +2 -2
- package/dist/{chunk-ZFRXFUP7.js → chunk-UTW56K5I.js} +2 -2
- package/dist/{chunk-H6VWU2HN.js → chunk-UXOGNBGL.js} +2 -2
- package/dist/{chunk-L5UGH4T4.js → chunk-WYEWNN76.js} +3 -3
- package/dist/{chunk-LU7GDHGD.js → chunk-ZEAT2B5B.js} +2 -2
- package/dist/cli.js +1 -1
- package/dist/{contributions-KLRJ4ZXV.js → contributions-ZD6ZGTJR.js} +2 -2
- package/dist/enrich-EFIPWA3P.js +16 -0
- package/dist/{enrich-ZB5I7KHN.js.map → enrich-EFIPWA3P.js.map} +1 -1
- package/dist/event-levels-7CY7AJLY.js +3 -0
- package/dist/event-levels-7CY7AJLY.js.map +1 -0
- package/dist/{hub-TILTOOSS.js → hub-MVX3U6A2.js} +2 -2
- package/dist/index.js +1 -1
- package/dist/load-LQ2I2PQI.js +2 -0
- package/dist/model-call-J7JATTMW.js +2 -0
- package/dist/{program-U3HJY7E5.js → program-WOQXOAYQ.js} +194 -194
- package/dist/program-WOQXOAYQ.js.map +1 -0
- package/dist/{promote-RHVZB2QZ.js → promote-X2XQEEQP.js} +2 -2
- package/dist/push-bridge-325SXDGN.js +1 -1
- package/dist/query-RRHYPXOM.js +2 -0
- package/dist/query-runs-WYRNBLLC.js +6 -0
- package/dist/query-runs-WYRNBLLC.js.map +1 -0
- package/dist/{query-settings-2MGUS6AY.js → query-settings-WKVLQEVZ.js} +2 -2
- package/dist/{registry-LZLIPP7N.js → registry-VXK36CCL.js} +2 -2
- package/dist/score-LNJ46A67.js +3 -0
- package/dist/score-LNJ46A67.js.map +1 -0
- package/dist/types-YZX46RES.js +2 -0
- package/dist/{wiki-GCRRINW3.js → wiki-QZ7XNAMJ.js} +2 -2
- package/dist/wiki-enrich-PMG4T6PP.js +2 -0
- package/package.json +1 -1
- package/dist/chunk-GSKJ57XY.js.map +0 -1
- package/dist/chunk-JRS5QRZG.js +0 -2
- package/dist/chunk-JRS5QRZG.js.map +0 -1
- package/dist/chunk-JTDUTCUE.js +0 -3
- package/dist/chunk-JTDUTCUE.js.map +0 -1
- package/dist/chunk-WWDYDLY2.js +0 -55
- package/dist/chunk-WWDYDLY2.js.map +0 -1
- package/dist/enrich-ZB5I7KHN.js +0 -16
- package/dist/event-levels-CQWHSLMT.js +0 -3
- package/dist/event-levels-CQWHSLMT.js.map +0 -1
- package/dist/load-EOZUZK7U.js +0 -2
- package/dist/model-call-PKV5UAQ7.js +0 -2
- package/dist/program-U3HJY7E5.js.map +0 -1
- package/dist/query-OZXZVLO7.js +0 -2
- package/dist/query-runs-7VX3YAC3.js +0 -4
- package/dist/query-runs-7VX3YAC3.js.map +0 -1
- package/dist/score-DZGPLHCL.js +0 -3
- package/dist/score-DZGPLHCL.js.map +0 -1
- package/dist/types-LJZ2YY5W.js +0 -2
- package/dist/wiki-enrich-P5TNWACZ.js +0 -2
- /package/dist/{absorb-eval-WY3YMLS4.js.map → absorb-eval-YT5TOTC7.js.map} +0 -0
- /package/dist/{agent-3R5NY7I3.js.map → agent-DRUIMWF5.js.map} +0 -0
- /package/dist/{board-dashboard-U3ZSCO62.js.map → board-dashboard-2524GN5N.js.map} +0 -0
- /package/dist/{chunk-5NT44FKL.js.map → chunk-3D5XUOBL.js.map} +0 -0
- /package/dist/{chunk-EEBK4F6E.js.map → chunk-3F4GPRGQ.js.map} +0 -0
- /package/dist/{chunk-BQIWMQNU.js.map → chunk-H4NSB54D.js.map} +0 -0
- /package/dist/{chunk-NY7NHGVT.js.map → chunk-MUVE3UAS.js.map} +0 -0
- /package/dist/{chunk-ZGVVYJIK.js.map → chunk-R6ECKZLE.js.map} +0 -0
- /package/dist/{chunk-MI7WOGH6.js.map → chunk-R6KLH34H.js.map} +0 -0
- /package/dist/{chunk-YA3P77LV.js.map → chunk-SKSYII3K.js.map} +0 -0
- /package/dist/{chunk-6WF56ME6.js.map → chunk-SN7YH4E4.js.map} +0 -0
- /package/dist/{chunk-RVEMX5MJ.js.map → chunk-TTG3ZW3W.js.map} +0 -0
- /package/dist/{chunk-ZFRXFUP7.js.map → chunk-UTW56K5I.js.map} +0 -0
- /package/dist/{chunk-H6VWU2HN.js.map → chunk-UXOGNBGL.js.map} +0 -0
- /package/dist/{chunk-L5UGH4T4.js.map → chunk-WYEWNN76.js.map} +0 -0
- /package/dist/{chunk-LU7GDHGD.js.map → chunk-ZEAT2B5B.js.map} +0 -0
- /package/dist/{contributions-KLRJ4ZXV.js.map → contributions-ZD6ZGTJR.js.map} +0 -0
- /package/dist/{hub-TILTOOSS.js.map → hub-MVX3U6A2.js.map} +0 -0
- /package/dist/{load-EOZUZK7U.js.map → load-LQ2I2PQI.js.map} +0 -0
- /package/dist/{model-call-PKV5UAQ7.js.map → model-call-J7JATTMW.js.map} +0 -0
- /package/dist/{promote-RHVZB2QZ.js.map → promote-X2XQEEQP.js.map} +0 -0
- /package/dist/{query-OZXZVLO7.js.map → query-RRHYPXOM.js.map} +0 -0
- /package/dist/{query-settings-2MGUS6AY.js.map → query-settings-WKVLQEVZ.js.map} +0 -0
- /package/dist/{registry-LZLIPP7N.js.map → registry-VXK36CCL.js.map} +0 -0
- /package/dist/{types-LJZ2YY5W.js.map → types-YZX46RES.js.map} +0 -0
- /package/dist/{wiki-GCRRINW3.js.map → wiki-QZ7XNAMJ.js.map} +0 -0
- /package/dist/{wiki-enrich-P5TNWACZ.js.map → wiki-enrich-PMG4T6PP.js.map} +0 -0
package/dist/chunk-JRS5QRZG.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{g as m}from"./chunk-6TURWSMN.js";import{spawn as f}from"child_process";var b=async(r,n,e)=>(await p(r,n,e)).text;function w(r){return async(n,e,c)=>{r.calls++;let{text:l,costUsd:t}=await p(n,e,c);return t===void 0?r.unpriced++:r.usd+=t,l}}async function p(r,n,e){let c=["-p","-","--output-format","json","--max-turns","1","--model",n,"--tools","","--strict-mcp-config","--mcp-config",'{"mcpServers":{}}',"--settings",'{"disableAllHooks":true}',"--setting-sources","","--no-session-persistence"],l=await new Promise((t,s)=>{let i=f("claude",c,{env:m(),stdio:["pipe","pipe","pipe"]}),u="",a="",d=setTimeout(()=>i.kill("SIGTERM"),e);i.stdout.on("data",o=>{u+=o}),i.stderr.on("data",o=>{a+=o}),i.on("error",o=>{clearTimeout(d),s(o)}),i.on("close",o=>{clearTimeout(d),o===0?t(u):s(new Error(`claude exited ${o}: ${a.trim().slice(0,200)}`))}),i.stdin.end(r)});try{let t=JSON.parse(l);if(t.is_error)throw new Error(`model error: ${String(t.result).slice(0,200)}`);let s=t.total_cost_usd;return{text:String(t.result??""),costUsd:typeof s=="number"&&Number.isFinite(s)?s:void 0}}catch(t){if(t instanceof SyntaxError)return{text:l};throw t}}function y(r){let n=r.match(/\{[\s\S]*\}/);if(!n)return null;try{let e=JSON.parse(n[0]);return e&&typeof e=="object"&&!Array.isArray(e)?e:null}catch{return null}}export{b as a,w as b,y as c};
|
|
2
|
-
//# sourceMappingURL=chunk-JRS5QRZG.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/wiki/model-call.ts"],"sourcesContent":["import { spawn } from \"child_process\"\nimport { claudeCliEnv } from \"@/utils/workspace-env\"\n\n/** One model call: prompt in, text out. Tests pass their own. */\nexport type ModelCall = (prompt: string, model: string, timeoutMs: number) => Promise<string>\n\n/**\n * One `claude -p` call with no tools. The prompt carries wiki text and\n * lines read from outside systems, so no built-in tool, MCP server, hook\n * or settings file is loaded: an instruction hidden in that text has\n * nothing to run, write or send with. No shell either: the prompt goes\n * in on stdin.\n */\nexport const claudeModelCall: ModelCall = async (prompt, model, timeoutMs) => (await claudeCall(prompt, model, timeoutMs)).text\n\n/** What the calls of a metered ModelCall spent. */\nexport interface ModelSpend {\n calls: number\n usd: number\n /** Calls whose reply named no cost: `usd` then counts low. */\n unpriced: number\n}\n\n/** claudeModelCall, adding each call's reported cost to `spend`. */\nexport function meteredModelCall(spend: ModelSpend): ModelCall {\n return async (prompt, model, timeoutMs) => {\n spend.calls++\n const { text, costUsd } = await claudeCall(prompt, model, timeoutMs)\n if (costUsd === undefined) spend.unpriced++\n else spend.usd += costUsd\n return text\n }\n}\n\nasync function claudeCall(prompt: string, model: string, timeoutMs: number): Promise<{ text: string; costUsd?: number }> {\n const args = [\"-p\", \"-\", \"--output-format\", \"json\", \"--max-turns\", \"1\", \"--model\", model,\n \"--tools\", \"\", \"--strict-mcp-config\", \"--mcp-config\", '{\"mcpServers\":{}}',\n \"--settings\", '{\"disableAllHooks\":true}', \"--setting-sources\", \"\", \"--no-session-persistence\"]\n const out = await new Promise<string>((ok, fail) => {\n const child = spawn(\"claude\", args, { env: claudeCliEnv(), stdio: [\"pipe\", \"pipe\", \"pipe\"] })\n let stdout = \"\"\n let stderr = \"\"\n const timer = setTimeout(() => child.kill(\"SIGTERM\"), timeoutMs)\n child.stdout.on(\"data\", (d) => { stdout += d })\n child.stderr.on(\"data\", (d) => { stderr += d })\n child.on(\"error\", (err) => { clearTimeout(timer); fail(err) })\n child.on(\"close\", (code) => {\n clearTimeout(timer)\n if (code === 0) ok(stdout)\n else fail(new Error(`claude exited ${code}: ${stderr.trim().slice(0, 200)}`))\n })\n child.stdin.end(prompt)\n })\n try {\n const envelope = JSON.parse(out) as { result?: string; is_error?: boolean; total_cost_usd?: unknown }\n if (envelope.is_error) throw new Error(`model error: ${String(envelope.result).slice(0, 200)}`)\n const cost = envelope.total_cost_usd\n return { text: String(envelope.result ?? \"\"), costUsd: typeof cost === \"number\" && Number.isFinite(cost) ? cost : undefined }\n } catch (err) {\n if (err instanceof SyntaxError) return { text: out }\n throw err\n }\n}\n\n/** The first JSON object in a model reply, or null. */\nexport function firstJsonObject(reply: string): Record<string, unknown> | null {\n const m = reply.match(/\\{[\\s\\S]*\\}/)\n if (!m) return null\n try {\n const parsed = JSON.parse(m[0])\n return parsed && typeof parsed === \"object\" && !Array.isArray(parsed) ? parsed as Record<string, unknown> : null\n } catch {\n return null\n }\n}\n"],"mappings":"wCAAA,OAAS,SAAAA,MAAa,gBAaf,IAAMC,EAA6B,MAAOC,EAAQC,EAAOC,KAAe,MAAMC,EAAWH,EAAQC,EAAOC,CAAS,GAAG,KAWpH,SAASE,EAAiBC,EAA8B,CAC7D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,EAAG,GAAG,GAAG,EAC9F,IAAMC,EAAOD,EAAS,eACtB,MAAO,CAAE,KAAM,OAAOA,EAAS,QAAU,EAAE,EAAG,QAAS,OAAOC,GAAS,UAAY,OAAO,SAASA,CAAI,EAAIA,EAAO,MAAU,CAC9H,OAASH,EAAP,CACA,GAAIA,aAAe,YAAa,MAAO,CAAE,KAAMV,CAAI,EACnD,MAAMU,CACR,CACF,CAGO,SAASI,EAAgBC,EAA+C,CAC7E,IAAMC,EAAID,EAAM,MAAM,aAAa,EACnC,GAAI,CAACC,EAAG,OAAO,KACf,GAAI,CACF,IAAMC,EAAS,KAAK,MAAMD,EAAE,CAAC,CAAC,EAC9B,OAAOC,GAAU,OAAOA,GAAW,UAAY,CAAC,MAAM,QAAQA,CAAM,EAAIA,EAAoC,IAC9G,MAAE,CACA,OAAO,IACT,CACF","names":["spawn","claudeModelCall","prompt","model","timeoutMs","claudeCall","meteredModelCall","spend","text","costUsd","args","out","ok","fail","child","spawn","claudeCliEnv","stdout","stderr","timer","d","err","code","envelope","cost","firstJsonObject","reply","m","parsed"]}
|
package/dist/chunk-JTDUTCUE.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{a as d}from"./chunk-RGZARSHV.js";import{existsSync as b,readFileSync as k,statSync as P,writeFileSync as O}from"fs";import{resolve as g}from"path";import h from"js-yaml";var n=(e=5)=>({panel:"history",title:"History",source:"history",show:e,importance:["major","normal"],fold:"minor",rollup:{min:5,days:30}}),c={panel:"discussed",title:"Discussed",source:"discussed",show:3,access:"owner"},s=(e=1)=>({panel:"notes",title:"Notes",source:"notes",show:e}),_=["device","server","app","domain","account","agent"],v=[{id:"person",label:"Person",plural:"People",pillar:"parties",schema:"Person",icon:"person",lens:[{panel:"roles",title:"Roles over time",from:["role_at","member_of","founded"],show:6,display:"timeline"},{panel:"relations",title:"Relations",from:["works_with","reports_to","client_of","works_on","related"],types:["person","organization","project"],show:5,group_by:"role"},{panel:"belongings",title:"Belongings",from:["owns","uses","related"],types:_.filter(e=>e!=="agent"),show:5},{panel:"obligations",title:"Obligations they carry",from:["subject_to"],show:3},n(),c,s()]},{id:"organization",label:"Organization",plural:"Organizations",pillar:"parties",schema:"Organization",icon:"org",lens:[{panel:"people",title:"People and roles",from:["role_at","member_of","founded"],show:6,group_by:"role"},{panel:"facts",title:"Key facts",from:["registered_with","located_in","identifier","legal_form"],show:6},{panel:"obligations",title:"Obligations and next due dates",from:["subject_to"],show:4},{panel:"agreements",title:"Agreements",source:"linked",types:["contract"],show:4},{panel:"decisions",title:"Decisions",source:"linked",types:["decision","policy"],show:4},n(),c,s()]},{id:"place",label:"Place",plural:"Places",pillar:"places",schema:"Place",icon:"pin",lens:[{panel:"here",title:"What is here",from:["located_in","related"],show:6},{panel:"laws",title:"Laws that apply here",from:["applies_in"],show:5},n(),s()]},{id:"jurisdiction",label:"Jurisdiction",plural:"Jurisdictions",pillar:"places",schema:"AdministrativeArea",icon:"pin",lens:[{panel:"laws",title:"Laws in force",from:["applies_in"],show:6},{panel:"authorities",title:"Authorities with reach",from:["jurisdiction_of"],show:5},{panel:"here",title:"What is here",from:["located_in"],show:5},s()]},{id:"device",label:"Device",plural:"Devices",pillar:"assets",schema:"Product",icon:"device",lens:[{panel:"state",title:"State now",source:"readings",latest:!0,show:6},n(),{panel:"apps",title:"Installed apps",from:["installed_on"],show:5},c,{panel:"parties",title:"Owner, user, location",from:["owns","uses","located_in","related"],types:["person","organization","place"],show:5},s()]},{id:"server",label:"Server",plural:"Servers",pillar:"assets",schema:"Product",icon:"server",lens:[{panel:"state",title:"State now",source:"readings",latest:!0,show:6},n(),{panel:"hosts",title:"Hosted services",from:["installed_on","runs_on"],show:6},c,{panel:"parties",title:"Owner and location",from:["owns","uses","located_in"],show:4},s()]},{id:"app",label:"App or system",plural:"Apps",pillar:"assets",schema:"SoftwareApplication",icon:"app",lens:[{panel:"installs",title:"Where it runs",from:["installed_on","runs_on"],show:5},{panel:"licence",title:"Licence or subscription",from:["party_to","licensed_by"],show:3},n(),c,s()]},{id:"domain",label:"Domain",plural:"Domains",pillar:"assets",schema:"WebSite",icon:"globe",lens:[{panel:"holder",title:"Holder",from:["owns","registrar"],show:3},{panel:"dues",title:"Renewal and due dates",source:"linked",types:["due_date"],show:4},{panel:"services",title:"Linked services",from:["related"],show:5},n(),s()]},{id:"account",label:"Account",plural:"Accounts",pillar:"assets",schema:"Service",icon:"key",lens:[{panel:"holder",title:"Holder",from:["owns","uses"],show:3},{panel:"dues",title:"Renewal and due dates",source:"linked",types:["due_date"],show:4},n(),s()]},{id:"agent",label:"Agent",plural:"Agents",pillar:"assets",schema:"SoftwareApplication",icon:"agent",lens:[{panel:"runs",title:"Where it runs",from:["runs_on","installed_on","related"],types:["server","device"],show:4},{panel:"works",title:"Works for",from:["works_for","uses","related"],types:["person","organization","project"],show:5},n(),c,s()]},{id:"project",label:"Project",plural:"Projects",pillar:"offerings",schema:"Project",icon:"project",lens:[{panel:"people",title:"Client and people",from:["client","client_of","works_on","related"],types:["person","organization","agent"],show:6,group_by:"role"},{panel:"agreements",title:"Agreements",source:"linked",types:["contract"],show:3},{panel:"decisions",title:"Decisions",source:"linked",types:["decision","policy"],show:4},n(6),c,s()]},{id:"offering",label:"Offering",plural:"Offerings",pillar:"offerings",schema:"Offer",icon:"project",lens:[{panel:"clients",title:"Clients",from:["client_of","related"],types:["organization","person"],show:5},n(),s()]},{id:"contract",label:"Agreement",plural:"Agreements",pillar:"agreements",schema:"Contract",icon:"contract",lens:[{panel:"parties",title:"Parties and roles",from:["party_to"],show:5,group_by:"role"},{panel:"terms",title:"Key terms and dates",from:["starts","renews","notice","amount"],show:6},{panel:"obligations",title:"Obligations it creates",from:["creates"],show:5},{panel:"amendments",title:"Amendments",from:["amends"],show:4},n(),s()]},{id:"legal_source",label:"Legal source",plural:"Legal sources",pillar:"law",schema:"Legislation",icon:"law",lens:[{panel:"reference",title:"Gazette reference and dates",from:["identifier","published_in","in_force_from","legal_force","issued_by"],show:6},{panel:"creates",title:"Obligations, penalties and reliefs it creates",from:["creates","created_by"],show:6},{panel:"amends",title:"Amends and amended by",from:["amends","repeals","implements"],show:5},{panel:"applies",title:"Where it applies",from:["applies_in"],show:3},s()]},{id:"obligation",label:"Obligation",plural:"Obligations",pillar:"law",schema:"LegalRuleML Obligation",icon:"law",lens:[{panel:"rule",title:"Who must do what, by when",from:["action","bearer","due_rule","amount_rule","authority","status"],show:6},{panel:"dues",title:"Next due dates",source:"linked",types:["due_date"],show:4},{panel:"sources",title:"Source articles",from:["created_by","changed_by"],show:4},{panel:"penalties",title:"Penalties and reliefs",from:["penalty_for","relieves"],show:4},{panel:"procedure",title:"Procedure",from:["procedure"],show:2},{panel:"bearers",title:"Who carries it",from:["subject_to"],show:5},n(4),s()]},{id:"penalty",label:"Penalty",plural:"Penalties",pillar:"law",schema:"LegalRuleML Penalty",icon:"law",lens:[{panel:"rule",title:"For which failure, how much",from:["penalty_for","kind","amount_rule","created_by"],show:6},s()]},{id:"relief",label:"Relief",plural:"Reliefs",pillar:"law",schema:"LegalRuleML Permission",icon:"law",lens:[{panel:"rule",title:"What it relieves, for whom, until when",from:["relieves","bearer","condition","created_by"],show:6},s()]},{id:"due_date",label:"Due date",plural:"Due dates",pillar:"law",schema:"Event",icon:"calendar",lens:[{panel:"due",title:"Due",from:["due_for","bearer","due","status","fulfilled_by"],show:6},s()]},{id:"event",label:"Event",plural:"Events",pillar:"events",schema:"Event",icon:"calendar",lens:[s(1),{panel:"involved",title:"Who and what was involved",from:["involves","affects","related"],show:8},{panel:"followed",title:"What followed",source:"linked",types:["event","decision"],show:4},c]},{id:"decision",label:"Decision",plural:"Decisions",pillar:"decisions",schema:"ChooseAction",icon:"decision",lens:[s(1),{panel:"affects",title:"What it affects",from:["affects","creates","related"],show:6},{panel:"replaced",title:"Replaced by",from:["replaced_by"],show:2},c]},{id:"policy",label:"Policy",plural:"Policies",pillar:"decisions",schema:"LegalRuleML Obligation",icon:"decision",lens:[{panel:"rule",title:"Rule",from:["action","bearer","creates","created_by"],show:6},{panel:"affects",title:"What it affects",from:["affects","related"],show:6},s()]},{id:"procedure",label:"Procedure",plural:"Procedures",pillar:"procedures",schema:"HowTo",icon:"steps",lens:[s(1),{panel:"triggers",title:"What triggers it",from:["procedure","triggered_by","related"],show:5},{panel:"runs",title:"Last runs",source:"linked",types:["event"],show:4}]},{id:"topic",label:"Topic",plural:"Topics",pillar:"topics",schema:"skos:Concept",icon:"topic",lens:[s(1),{panel:"related",title:"Related",from:["related"],show:8},n(4)]}],u={version:1,pillars:[{id:"parties",label:"Parties",description:"People and organisations, and the roles between them",icon:"person"},{id:"places",label:"Places & Jurisdictions",description:"Where things are, and whose rules apply there",icon:"pin"},{id:"assets",label:"Assets",description:"What is owned or run: devices, servers, apps, domains, accounts, agents",icon:"server"},{id:"offerings",label:"Offerings & Projects",description:"What is sold, built or delivered",icon:"project"},{id:"agreements",label:"Agreements",description:"Contracts, subscriptions and their terms",icon:"contract"},{id:"law",label:"Law & Obligations",description:"Legal sources, the obligations they create, penalties, reliefs and due dates",icon:"law"},{id:"events",label:"Events",description:"What happened, by importance",icon:"calendar"},{id:"decisions",label:"Decisions & Policies",description:"Why things are the way they are",icon:"decision"},{id:"procedures",label:"Procedures",description:"How things are done",icon:"steps"},{id:"topics",label:"Topics",description:"Pages no type fits yet. A growing count means a type is missing.",icon:"topic",sidebar:!1}],types:v,properties:[{id:"related",label:"related to",inverse:"related to"},{id:"role_at",label:"role at",inverse:"people",wikidata:"P108",range:["organization"],domain:["person"]},{id:"member_of",label:"member of",inverse:"members",wikidata:"P463",range:["organization"],domain:["person","organization"]},{id:"founded",label:"founded",inverse:"founded by",wikidata:"P112",domain:["person","organization"]},{id:"works_with",label:"works with",inverse:"works with",domain:["person","organization"]},{id:"reports_to",label:"reports to",inverse:"manages",domain:["person"]},{id:"client_of",label:"client of",inverse:"clients",wikidata:"P1972",domain:["person","organization"]},{id:"client",label:"is for client",inverse:"projects",range:["organization","person"],domain:["project","offering","contract"]},{id:"works_on",label:"works on",inverse:"people",range:["project"],domain:["person","organization","agent"]},{id:"works_for",label:"works for",inverse:"agents",wikidata:"P108",domain:["agent","person"]},{id:"owns",label:"owns",inverse:"owned by",wikidata:"P1830"},{id:"uses",label:"uses",inverse:"used by",wikidata:"P2283"},{id:"located_in",label:"located in",inverse:"here",wikidata:"P276"},{id:"installed_on",label:"installed on",inverse:"installed apps",range:["device","server"]},{id:"runs_on",label:"runs on",inverse:"hosts"},{id:"registered_with",label:"registered with",inverse:"registered"},{id:"identifier",label:"identifier",wikidata:"P1448"},{id:"legal_form",label:"legal form",wikidata:"P1454"},{id:"registrar",label:"registrar"},{id:"licensed_by",label:"licensed by",inverse:"licences"},{id:"party_to",label:"party to",inverse:"parties"},{id:"starts",label:"starts"},{id:"renews",label:"renews"},{id:"notice",label:"notice period"},{id:"amount",label:"amount"},{id:"creates",label:"creates",inverse:"created by"},{id:"created_by",label:"created by",inverse:"creates"},{id:"changed_by",label:"changed by",inverse:"changes"},{id:"amends",label:"amends",inverse:"amended by",wikidata:"P144"},{id:"repeals",label:"repeals",inverse:"repealed by"},{id:"implements",label:"implements",inverse:"implemented by"},{id:"issued_by",label:"issued by",inverse:"issues"},{id:"published_in",label:"published in",wikidata:"P1433"},{id:"in_force_from",label:"in force from",wikidata:"P7588"},{id:"legal_force",label:"legal force"},{id:"applies_in",label:"applies in",inverse:"laws that apply",wikidata:"P1001"},{id:"jurisdiction_of",label:"authority in",inverse:"authorities"},{id:"subject_to",label:"subject to",inverse:"carried by"},{id:"action",label:"action"},{id:"bearer",label:"bearer"},{id:"due_rule",label:"due"},{id:"amount_rule",label:"amount"},{id:"authority",label:"authority",inverse:"collects"},{id:"status",label:"status"},{id:"penalty_for",label:"penalty for",inverse:"penalties"},{id:"relieves",label:"relieves",inverse:"reliefs"},{id:"condition",label:"condition"},{id:"kind",label:"kind"},{id:"procedure",label:"procedure",inverse:"carries out"},{id:"due_for",label:"due for",inverse:"due dates"},{id:"due",label:"due on"},{id:"fulfilled_by",label:"fulfilled by",inverse:"fulfils"},{id:"involves",label:"involves",inverse:"events",wikidata:"P710"},{id:"affects",label:"affects",inverse:"affected by"},{id:"replaced_by",label:"replaced by",inverse:"replaces",wikidata:"P1366"},{id:"triggered_by",label:"triggered by",inverse:"triggers"},{id:"mentions",label:"mentions",inverse:"discussed in"},{id:"reading",label:"reading"},{id:"importance_set",label:"importance set"}],importance:{default:"normal",major_set_by:"owner",rollup:{min:5,days:30},rules:[{level:"minor",title:"\\b(disk|storage) (is |was |almost |nearly )?(full|pressure|cleanup|clean-up|usage|space)\\b"},{level:"minor",title:"\\b(cache|logs?|temp files?) (was |were )?(cleared|cleaned|purged|rotated|pruned)\\b"},{level:"minor",title:"\\b(restart(ed)?|reboot(ed)?|health ?check|heartbeat)\\b"}]},sidebar:{pins_max:5,pins:[]},classify:[{type:"agent",legacy:["person","concept","project"],title:"\\bagents?\\b|\\bbot\\b"},{type:"server",legacy:["place","concept"],title:"\\b(server|vps|host|node)\\b"},{type:"device",legacy:["place","concept"],title:"\\b(laptop|macbook|desktop|phone|tablet|printer|router)\\b"},{type:"person",legacy:["person"]},{type:"event",legacy:["event"]},{type:"decision",legacy:["decision"]},{type:"procedure",legacy:["pattern"]},{type:"place",legacy:["place"]},{type:"project",legacy:["project"]},{type:"organization",path:["clients","customers","vendors","suppliers","organizations","orgs","companies"]},{type:"organization",tags:["organization","company","client","vendor","supplier","agency","bank"]},{type:"server",path:["servers","hosts","infrastructure"]},{type:"server",tags:["server","vps","host"]},{type:"device",path:["devices"]},{type:"device",tags:["device","laptop","phone","printer"]},{type:"agent",tags:["agent"],title:"\\bagent\\b"},{type:"app",path:["apps","systems","services"]},{type:"domain",tags:["domain","dns"]},{type:"contract",path:["contracts","agreements"]},{type:"contract",tags:["contract","agreement","subscription"]},{type:"legal_source",path:["laws","legislation"]},{type:"legal_source",tags:["law","legislation","decree"]},{type:"obligation",path:["obligations","compliance"]},{type:"obligation",tags:["obligation","compliance"]},{type:"policy",path:["policies"]},{type:"policy",tags:["policy"]},{type:"procedure",path:["runbooks","procedures"]},{type:"procedure",tags:["runbook","procedure","how-to"]}],fallback_type:"topic"};var m="ontology.yaml",y=new Map;function E(e){let i=g(e,m);if(!b(i))return{ontology:u,errors:[],file:null};let r=P(i).mtimeMs,a=y.get(i);if(a&&a.mtimeMs===r)return a.loaded;let l,t=[];try{l=h.load(k(i,"utf-8"))}catch(w){t.push(`${m} is not valid YAML: ${w.message}`),l={}}let o=A(u,f(l)?l:{},t);t.push(...j(o));let p={ontology:o,errors:t,file:i};return y.set(i,{mtimeMs:r,loaded:p}),p}function T(e){let i=g(e,m);if(b(i))throw new Error(`${i} already exists`);let r=["# Wiki ontology: pillars, types, typed relations, event importance and lenses.","# Edit any section; what you leave out falls back to the built-in defaults.","# Check it with: agentx wiki ontology check",""].join(`
|
|
2
|
-
`);return O(i,r+h.dump(u,{lineWidth:120,noRefs:!0})),i}function A(e,i,r=[]){let a=structuredClone(e);typeof i.version=="number"&&(a.version=i.version);for(let l of["pillars","types","properties"]){let t=i[l];if(t!==void 0){if(!Array.isArray(t)){r.push(`${l} must be a list`);continue}a[l]=L(a[l],t,l,r)}}return f(i.importance)&&(a.importance={...a.importance,...i.importance}),f(i.sidebar)&&(a.sidebar={...a.sidebar,...i.sidebar}),i.classify!==void 0&&(Array.isArray(i.classify)?a.classify=i.classify:r.push("classify must be a list")),typeof i.fallback_type=="string"&&(a.fallback_type=i.fallback_type),i.agent_names!==void 0&&(Array.isArray(i.agent_names)?a.agent_names=i.agent_names.filter(l=>typeof l=="string"&&!!l.trim()):r.push("agent_names must be a list")),a}function L(e,i,r,a){let l=e.map(t=>({...t}));for(let t of i){if(!f(t)||typeof t.id!="string"){a.push(`every item in ${r} needs an id`);continue}let o=l.findIndex(p=>p.id===t.id);o===-1?l.push(t):l[o]={...l[o],...t}}return l}function j(e){let i=[],r=new Set(e.pillars.map(t=>t.id)),a=new Set(e.types.map(t=>t.id)),l=new Set(e.properties.map(t=>t.id));for(let t of e.types){r.has(t.pillar)||i.push(`type ${t.id}: unknown pillar "${t.pillar}"`);for(let o of t.lens??[]){for(let p of $(o))l.has(p)||i.push(`type ${t.id}, panel ${o.panel}: unknown property "${p}"`);for(let p of o.types??[])a.has(p)||i.push(`type ${t.id}, panel ${o.panel}: unknown type "${p}"`);for(let p of o.importance??[])d.includes(p)||i.push(`type ${t.id}, panel ${o.panel}: unknown importance "${p}"`)}}for(let t of e.classify)if(a.has(t.type)||i.push(`classify: unknown type "${t.type}"`),t.title)try{new RegExp(t.title,"i")}catch{i.push(`classify: bad title pattern "${t.title}"`)}a.has(e.fallback_type)||i.push(`fallback_type: unknown type "${e.fallback_type}"`),d.includes(e.importance.default)||i.push(`importance.default: unknown level "${e.importance.default}"`);for(let t of e.importance.rules??[])if(d.includes(t.level)||i.push(`importance.rules: unknown level "${t.level}"`),!t.title&&!t.tags?.length&&i.push(`importance.rules: a rule for "${t.level}" needs a title or tags`),t.title)try{new RegExp(t.title,"i")}catch{i.push(`importance.rules: bad title pattern "${t.title}"`)}return e.sidebar.pins.length>e.sidebar.pins_max&&i.push(`sidebar.pins: ${e.sidebar.pins.length} pins, only the first ${e.sidebar.pins_max} are shown`),i}function $(e){return e.from?Array.isArray(e.from)?e.from:[e.from]:[]}function M(e){return e.source?e.source:e.panel==="history"||e.panel==="discussed"||e.panel==="notes"?e.panel:e.latest?"readings":e.from?"statements":"linked"}function f(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}export{m as a,E as b,T as c,A as d,j as e,$ as f,M as g};
|
|
3
|
-
//# sourceMappingURL=chunk-JTDUTCUE.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/wiki/ontology/load.ts","../src/wiki/ontology/defaults.ts"],"sourcesContent":["// --- Load and check `ontology.yaml` (#811) ---\n//\n// The file is optional. Each section the owner writes is merged over the\n// defaults: pillars, types and properties by `id` (a listed id replaces\n// the fields it sets, a new id is added), `importance` and `sidebar`\n// field by field, and `classify` as a whole list. Problems are reported,\n// never thrown, so a typo in the file cannot take the wiki down.\n\nimport { existsSync, readFileSync, statSync, writeFileSync } from \"fs\"\nimport { resolve } from \"path\"\nimport yaml from \"js-yaml\"\nimport { DEFAULT_ONTOLOGY } from \"./defaults\"\nimport { IMPORTANCE_LEVELS, type LensPanel, type Ontology, type PanelSource } from \"./types\"\n\nexport const ONTOLOGY_FILE = \"ontology.yaml\"\n\nexport interface LoadedOntology {\n ontology: Ontology\n /** Problems found in the file. The defaults are used where they apply. */\n errors: string[]\n /** Path of the file read, or null when the defaults were used as they are. */\n file: string | null\n}\n\nconst cache = new Map<string, { mtimeMs: number; loaded: LoadedOntology }>()\n\nexport function loadOntology(wikiDir: string): LoadedOntology {\n const file = resolve(wikiDir, ONTOLOGY_FILE)\n if (!existsSync(file)) return { ontology: DEFAULT_ONTOLOGY, errors: [], file: null }\n\n const mtimeMs = statSync(file).mtimeMs\n const hit = cache.get(file)\n if (hit && hit.mtimeMs === mtimeMs) return hit.loaded\n\n let raw: unknown\n const errors: string[] = []\n try {\n raw = yaml.load(readFileSync(file, \"utf-8\"))\n } catch (err) {\n errors.push(`${ONTOLOGY_FILE} is not valid YAML: ${(err as Error).message}`)\n raw = {}\n }\n const ontology = mergeOntology(DEFAULT_ONTOLOGY, isObject(raw) ? raw : {}, errors)\n errors.push(...checkOntology(ontology))\n const loaded = { ontology, errors, file }\n cache.set(file, { mtimeMs, loaded })\n return loaded\n}\n\n/** Write the defaults as a starting `ontology.yaml`. Refuses to overwrite. */\nexport function writeDefaultOntology(wikiDir: string): string {\n const file = resolve(wikiDir, ONTOLOGY_FILE)\n if (existsSync(file)) throw new Error(`${file} already exists`)\n const header = [\n \"# Wiki ontology: pillars, types, typed relations, event importance and lenses.\",\n \"# Edit any section; what you leave out falls back to the built-in defaults.\",\n \"# Check it with: agentx wiki ontology check\",\n \"\",\n ].join(\"\\n\")\n writeFileSync(file, header + yaml.dump(DEFAULT_ONTOLOGY, { lineWidth: 120, noRefs: true }))\n return file\n}\n\nexport function mergeOntology(base: Ontology, over: Record<string, unknown>, errors: string[] = []): Ontology {\n const out: Ontology = structuredClone(base)\n if (typeof over.version === \"number\") out.version = over.version\n for (const key of [\"pillars\", \"types\", \"properties\"] as const) {\n const list = over[key]\n if (list === undefined) continue\n if (!Array.isArray(list)) { errors.push(`${key} must be a list`); continue }\n out[key] = mergeById(out[key] as Array<{ id: string }>, list, key, errors) as never\n }\n if (isObject(over.importance)) out.importance = { ...out.importance, ...over.importance } as Ontology[\"importance\"]\n if (isObject(over.sidebar)) out.sidebar = { ...out.sidebar, ...over.sidebar } as Ontology[\"sidebar\"]\n if (over.classify !== undefined) {\n if (Array.isArray(over.classify)) out.classify = over.classify as Ontology[\"classify\"]\n else errors.push(\"classify must be a list\")\n }\n if (typeof over.fallback_type === \"string\") out.fallback_type = over.fallback_type\n if (over.agent_names !== undefined) {\n if (Array.isArray(over.agent_names)) out.agent_names = over.agent_names.filter((n): n is string => typeof n === \"string\" && !!n.trim())\n else errors.push(\"agent_names must be a list\")\n }\n return out\n}\n\nfunction mergeById(base: Array<{ id: string }>, list: unknown[], key: string, errors: string[]): Array<{ id: string }> {\n const out = base.map(x => ({ ...x }))\n for (const item of list) {\n if (!isObject(item) || typeof item.id !== \"string\") { errors.push(`every item in ${key} needs an id`); continue }\n const at = out.findIndex(x => x.id === item.id)\n if (at === -1) out.push(item as { id: string })\n else out[at] = { ...out[at], ...item }\n }\n return out\n}\n\n/** Problems that make part of the ontology unusable. */\nexport function checkOntology(o: Ontology): string[] {\n const errors: string[] = []\n const pillars = new Set(o.pillars.map(p => p.id))\n const types = new Set(o.types.map(t => t.id))\n const props = new Set(o.properties.map(p => p.id))\n for (const t of o.types) {\n if (!pillars.has(t.pillar)) errors.push(`type ${t.id}: unknown pillar \"${t.pillar}\"`)\n for (const p of t.lens ?? []) {\n for (const f of panelFrom(p)) if (!props.has(f)) errors.push(`type ${t.id}, panel ${p.panel}: unknown property \"${f}\"`)\n for (const ty of p.types ?? []) if (!types.has(ty)) errors.push(`type ${t.id}, panel ${p.panel}: unknown type \"${ty}\"`)\n for (const lv of p.importance ?? []) if (!IMPORTANCE_LEVELS.includes(lv)) errors.push(`type ${t.id}, panel ${p.panel}: unknown importance \"${lv}\"`)\n }\n }\n for (const r of o.classify) {\n if (!types.has(r.type)) errors.push(`classify: unknown type \"${r.type}\"`)\n if (r.title) {\n try { new RegExp(r.title, \"i\") } catch { errors.push(`classify: bad title pattern \"${r.title}\"`) }\n }\n }\n if (!types.has(o.fallback_type)) errors.push(`fallback_type: unknown type \"${o.fallback_type}\"`)\n if (!IMPORTANCE_LEVELS.includes(o.importance.default)) errors.push(`importance.default: unknown level \"${o.importance.default}\"`)\n for (const r of o.importance.rules ?? []) {\n if (!IMPORTANCE_LEVELS.includes(r.level)) errors.push(`importance.rules: unknown level \"${r.level}\"`)\n if (!r.title && !r.tags?.length) errors.push(`importance.rules: a rule for \"${r.level}\" needs a title or tags`)\n if (r.title) {\n try { new RegExp(r.title, \"i\") } catch { errors.push(`importance.rules: bad title pattern \"${r.title}\"`) }\n }\n }\n if (o.sidebar.pins.length > o.sidebar.pins_max) {\n errors.push(`sidebar.pins: ${o.sidebar.pins.length} pins, only the first ${o.sidebar.pins_max} are shown`)\n }\n return errors\n}\n\nexport function panelFrom(p: LensPanel): string[] {\n if (!p.from) return []\n return Array.isArray(p.from) ? p.from : [p.from]\n}\n\nexport function panelSource(p: LensPanel): PanelSource {\n if (p.source) return p.source\n if (p.panel === \"history\" || p.panel === \"discussed\" || p.panel === \"notes\") return p.panel\n if (p.latest) return \"readings\"\n if (p.from) return \"statements\"\n return \"linked\"\n}\n\nfunction isObject(v: unknown): v is Record<string, unknown> {\n return typeof v === \"object\" && v !== null && !Array.isArray(v)\n}\n","// --- Default wiki ontology (#811) ---\n//\n// Generic starting point: nine pillars, the types inside them, the typed\n// relations between them and a lens for every type. An owner overrides\n// any section in `<wiki>/ontology.yaml`; `agentx wiki ontology init`\n// writes this file out as a starting point. Keep it free of any\n// particular organisation, person, country or product.\n\nimport type { LensPanel, Ontology, TypeDef } from \"./types\"\n\nconst history = (show = 5): LensPanel => ({\n panel: \"history\", title: \"History\", source: \"history\", show,\n importance: [\"major\", \"normal\"], fold: \"minor\", rollup: { min: 5, days: 30 },\n})\nconst discussed: LensPanel = { panel: \"discussed\", title: \"Discussed\", source: \"discussed\", show: 3, access: \"owner\" }\nconst notes = (show = 1): LensPanel => ({ panel: \"notes\", title: \"Notes\", source: \"notes\", show })\n\nconst ASSET_TYPES = [\"device\", \"server\", \"app\", \"domain\", \"account\", \"agent\"]\n\nconst types: TypeDef[] = [\n // Parties\n {\n id: \"person\", label: \"Person\", plural: \"People\", pillar: \"parties\", schema: \"Person\", icon: \"person\",\n lens: [\n { panel: \"roles\", title: \"Roles over time\", from: [\"role_at\", \"member_of\", \"founded\"], show: 6, display: \"timeline\" },\n { panel: \"relations\", title: \"Relations\", from: [\"works_with\", \"reports_to\", \"client_of\", \"works_on\", \"related\"], types: [\"person\", \"organization\", \"project\"], show: 5, group_by: \"role\" },\n // Agents are not a person's belongings or relations (#819).\n { panel: \"belongings\", title: \"Belongings\", from: [\"owns\", \"uses\", \"related\"], types: ASSET_TYPES.filter(t => t !== \"agent\"), show: 5 },\n { panel: \"obligations\", title: \"Obligations they carry\", from: [\"subject_to\"], show: 3 },\n history(),\n discussed,\n notes(),\n ],\n },\n {\n id: \"organization\", label: \"Organization\", plural: \"Organizations\", pillar: \"parties\", schema: \"Organization\", icon: \"org\",\n lens: [\n { panel: \"people\", title: \"People and roles\", from: [\"role_at\", \"member_of\", \"founded\"], show: 6, group_by: \"role\" },\n { panel: \"facts\", title: \"Key facts\", from: [\"registered_with\", \"located_in\", \"identifier\", \"legal_form\"], show: 6 },\n { panel: \"obligations\", title: \"Obligations and next due dates\", from: [\"subject_to\"], show: 4 },\n { panel: \"agreements\", title: \"Agreements\", source: \"linked\", types: [\"contract\"], show: 4 },\n { panel: \"decisions\", title: \"Decisions\", source: \"linked\", types: [\"decision\", \"policy\"], show: 4 },\n history(),\n discussed,\n notes(),\n ],\n },\n // Places & Jurisdictions\n {\n id: \"place\", label: \"Place\", plural: \"Places\", pillar: \"places\", schema: \"Place\", icon: \"pin\",\n lens: [\n { panel: \"here\", title: \"What is here\", from: [\"located_in\", \"related\"], show: 6 },\n { panel: \"laws\", title: \"Laws that apply here\", from: [\"applies_in\"], show: 5 },\n history(),\n notes(),\n ],\n },\n {\n id: \"jurisdiction\", label: \"Jurisdiction\", plural: \"Jurisdictions\", pillar: \"places\", schema: \"AdministrativeArea\", icon: \"pin\",\n lens: [\n { panel: \"laws\", title: \"Laws in force\", from: [\"applies_in\"], show: 6 },\n { panel: \"authorities\", title: \"Authorities with reach\", from: [\"jurisdiction_of\"], show: 5 },\n { panel: \"here\", title: \"What is here\", from: [\"located_in\"], show: 5 },\n notes(),\n ],\n },\n // Assets\n {\n id: \"device\", label: \"Device\", plural: \"Devices\", pillar: \"assets\", schema: \"Product\", icon: \"device\",\n lens: [\n { panel: \"state\", title: \"State now\", source: \"readings\", latest: true, show: 6 },\n history(),\n { panel: \"apps\", title: \"Installed apps\", from: [\"installed_on\"], show: 5 },\n discussed,\n { panel: \"parties\", title: \"Owner, user, location\", from: [\"owns\", \"uses\", \"located_in\", \"related\"], types: [\"person\", \"organization\", \"place\"], show: 5 },\n notes(),\n ],\n },\n {\n id: \"server\", label: \"Server\", plural: \"Servers\", pillar: \"assets\", schema: \"Product\", icon: \"server\",\n lens: [\n { panel: \"state\", title: \"State now\", source: \"readings\", latest: true, show: 6 },\n history(),\n { panel: \"hosts\", title: \"Hosted services\", from: [\"installed_on\", \"runs_on\"], show: 6 },\n discussed,\n { panel: \"parties\", title: \"Owner and location\", from: [\"owns\", \"uses\", \"located_in\"], show: 4 },\n notes(),\n ],\n },\n {\n id: \"app\", label: \"App or system\", plural: \"Apps\", pillar: \"assets\", schema: \"SoftwareApplication\", icon: \"app\",\n lens: [\n { panel: \"installs\", title: \"Where it runs\", from: [\"installed_on\", \"runs_on\"], show: 5 },\n { panel: \"licence\", title: \"Licence or subscription\", from: [\"party_to\", \"licensed_by\"], show: 3 },\n history(),\n discussed,\n notes(),\n ],\n },\n {\n id: \"domain\", label: \"Domain\", plural: \"Domains\", pillar: \"assets\", schema: \"WebSite\", icon: \"globe\",\n lens: [\n { panel: \"holder\", title: \"Holder\", from: [\"owns\", \"registrar\"], show: 3 },\n { panel: \"dues\", title: \"Renewal and due dates\", source: \"linked\", types: [\"due_date\"], show: 4 },\n { panel: \"services\", title: \"Linked services\", from: [\"related\"], show: 5 },\n history(),\n notes(),\n ],\n },\n {\n id: \"account\", label: \"Account\", plural: \"Accounts\", pillar: \"assets\", schema: \"Service\", icon: \"key\",\n lens: [\n { panel: \"holder\", title: \"Holder\", from: [\"owns\", \"uses\"], show: 3 },\n { panel: \"dues\", title: \"Renewal and due dates\", source: \"linked\", types: [\"due_date\"], show: 4 },\n history(),\n notes(),\n ],\n },\n {\n id: \"agent\", label: \"Agent\", plural: \"Agents\", pillar: \"assets\", schema: \"SoftwareApplication\", icon: \"agent\",\n lens: [\n { panel: \"runs\", title: \"Where it runs\", from: [\"runs_on\", \"installed_on\", \"related\"], types: [\"server\", \"device\"], show: 4 },\n { panel: \"works\", title: \"Works for\", from: [\"works_for\", \"uses\", \"related\"], types: [\"person\", \"organization\", \"project\"], show: 5 },\n history(),\n discussed,\n notes(),\n ],\n },\n // Offerings & Projects\n {\n id: \"project\", label: \"Project\", plural: \"Projects\", pillar: \"offerings\", schema: \"Project\", icon: \"project\",\n lens: [\n { panel: \"people\", title: \"Client and people\", from: [\"client\", \"client_of\", \"works_on\", \"related\"], types: [\"person\", \"organization\", \"agent\"], show: 6, group_by: \"role\" },\n { panel: \"agreements\", title: \"Agreements\", source: \"linked\", types: [\"contract\"], show: 3 },\n { panel: \"decisions\", title: \"Decisions\", source: \"linked\", types: [\"decision\", \"policy\"], show: 4 },\n history(6),\n discussed,\n notes(),\n ],\n },\n {\n id: \"offering\", label: \"Offering\", plural: \"Offerings\", pillar: \"offerings\", schema: \"Offer\", icon: \"project\",\n lens: [\n { panel: \"clients\", title: \"Clients\", from: [\"client_of\", \"related\"], types: [\"organization\", \"person\"], show: 5 },\n history(),\n notes(),\n ],\n },\n // Agreements\n {\n id: \"contract\", label: \"Agreement\", plural: \"Agreements\", pillar: \"agreements\", schema: \"Contract\", icon: \"contract\",\n lens: [\n { panel: \"parties\", title: \"Parties and roles\", from: [\"party_to\"], show: 5, group_by: \"role\" },\n { panel: \"terms\", title: \"Key terms and dates\", from: [\"starts\", \"renews\", \"notice\", \"amount\"], show: 6 },\n { panel: \"obligations\", title: \"Obligations it creates\", from: [\"creates\"], show: 5 },\n { panel: \"amendments\", title: \"Amendments\", from: [\"amends\"], show: 4 },\n history(),\n notes(),\n ],\n },\n // Law & Obligations\n {\n id: \"legal_source\", label: \"Legal source\", plural: \"Legal sources\", pillar: \"law\", schema: \"Legislation\", icon: \"law\",\n lens: [\n { panel: \"reference\", title: \"Gazette reference and dates\", from: [\"identifier\", \"published_in\", \"in_force_from\", \"legal_force\", \"issued_by\"], show: 6 },\n { panel: \"creates\", title: \"Obligations, penalties and reliefs it creates\", from: [\"creates\", \"created_by\"], show: 6 },\n { panel: \"amends\", title: \"Amends and amended by\", from: [\"amends\", \"repeals\", \"implements\"], show: 5 },\n { panel: \"applies\", title: \"Where it applies\", from: [\"applies_in\"], show: 3 },\n notes(),\n ],\n },\n {\n id: \"obligation\", label: \"Obligation\", plural: \"Obligations\", pillar: \"law\", schema: \"LegalRuleML Obligation\", icon: \"law\",\n lens: [\n { panel: \"rule\", title: \"Who must do what, by when\", from: [\"action\", \"bearer\", \"due_rule\", \"amount_rule\", \"authority\", \"status\"], show: 6 },\n { panel: \"dues\", title: \"Next due dates\", source: \"linked\", types: [\"due_date\"], show: 4 },\n { panel: \"sources\", title: \"Source articles\", from: [\"created_by\", \"changed_by\"], show: 4 },\n { panel: \"penalties\", title: \"Penalties and reliefs\", from: [\"penalty_for\", \"relieves\"], show: 4 },\n { panel: \"procedure\", title: \"Procedure\", from: [\"procedure\"], show: 2 },\n { panel: \"bearers\", title: \"Who carries it\", from: [\"subject_to\"], show: 5 },\n history(4),\n notes(),\n ],\n },\n {\n id: \"penalty\", label: \"Penalty\", plural: \"Penalties\", pillar: \"law\", schema: \"LegalRuleML Penalty\", icon: \"law\",\n lens: [\n { panel: \"rule\", title: \"For which failure, how much\", from: [\"penalty_for\", \"kind\", \"amount_rule\", \"created_by\"], show: 6 },\n notes(),\n ],\n },\n {\n id: \"relief\", label: \"Relief\", plural: \"Reliefs\", pillar: \"law\", schema: \"LegalRuleML Permission\", icon: \"law\",\n lens: [\n { panel: \"rule\", title: \"What it relieves, for whom, until when\", from: [\"relieves\", \"bearer\", \"condition\", \"created_by\"], show: 6 },\n notes(),\n ],\n },\n {\n id: \"due_date\", label: \"Due date\", plural: \"Due dates\", pillar: \"law\", schema: \"Event\", icon: \"calendar\",\n lens: [\n { panel: \"due\", title: \"Due\", from: [\"due_for\", \"bearer\", \"due\", \"status\", \"fulfilled_by\"], show: 6 },\n notes(),\n ],\n },\n // Events\n {\n id: \"event\", label: \"Event\", plural: \"Events\", pillar: \"events\", schema: \"Event\", icon: \"calendar\",\n lens: [\n notes(1),\n { panel: \"involved\", title: \"Who and what was involved\", from: [\"involves\", \"affects\", \"related\"], show: 8 },\n { panel: \"followed\", title: \"What followed\", source: \"linked\", types: [\"event\", \"decision\"], show: 4 },\n discussed,\n ],\n },\n // Decisions & Policies\n {\n id: \"decision\", label: \"Decision\", plural: \"Decisions\", pillar: \"decisions\", schema: \"ChooseAction\", icon: \"decision\",\n lens: [\n notes(1),\n { panel: \"affects\", title: \"What it affects\", from: [\"affects\", \"creates\", \"related\"], show: 6 },\n { panel: \"replaced\", title: \"Replaced by\", from: [\"replaced_by\"], show: 2 },\n discussed,\n ],\n },\n {\n id: \"policy\", label: \"Policy\", plural: \"Policies\", pillar: \"decisions\", schema: \"LegalRuleML Obligation\", icon: \"decision\",\n lens: [\n { panel: \"rule\", title: \"Rule\", from: [\"action\", \"bearer\", \"creates\", \"created_by\"], show: 6 },\n { panel: \"affects\", title: \"What it affects\", from: [\"affects\", \"related\"], show: 6 },\n notes(),\n ],\n },\n // Procedures\n {\n id: \"procedure\", label: \"Procedure\", plural: \"Procedures\", pillar: \"procedures\", schema: \"HowTo\", icon: \"steps\",\n lens: [\n notes(1),\n { panel: \"triggers\", title: \"What triggers it\", from: [\"procedure\", \"triggered_by\", \"related\"], show: 5 },\n { panel: \"runs\", title: \"Last runs\", source: \"linked\", types: [\"event\"], show: 4 },\n ],\n },\n // Topics (fallback, not in the sidebar)\n {\n id: \"topic\", label: \"Topic\", plural: \"Topics\", pillar: \"topics\", schema: \"skos:Concept\", icon: \"topic\",\n lens: [\n notes(1),\n { panel: \"related\", title: \"Related\", from: [\"related\"], show: 8 },\n history(4),\n ],\n },\n]\n\nexport const DEFAULT_ONTOLOGY: Ontology = {\n version: 1,\n pillars: [\n { id: \"parties\", label: \"Parties\", description: \"People and organisations, and the roles between them\", icon: \"person\" },\n { id: \"places\", label: \"Places & Jurisdictions\", description: \"Where things are, and whose rules apply there\", icon: \"pin\" },\n { id: \"assets\", label: \"Assets\", description: \"What is owned or run: devices, servers, apps, domains, accounts, agents\", icon: \"server\" },\n { id: \"offerings\", label: \"Offerings & Projects\", description: \"What is sold, built or delivered\", icon: \"project\" },\n { id: \"agreements\", label: \"Agreements\", description: \"Contracts, subscriptions and their terms\", icon: \"contract\" },\n { id: \"law\", label: \"Law & Obligations\", description: \"Legal sources, the obligations they create, penalties, reliefs and due dates\", icon: \"law\" },\n { id: \"events\", label: \"Events\", description: \"What happened, by importance\", icon: \"calendar\" },\n { id: \"decisions\", label: \"Decisions & Policies\", description: \"Why things are the way they are\", icon: \"decision\" },\n { id: \"procedures\", label: \"Procedures\", description: \"How things are done\", icon: \"steps\" },\n { id: \"topics\", label: \"Topics\", description: \"Pages no type fits yet. A growing count means a type is missing.\", icon: \"topic\", sidebar: false },\n ],\n types,\n properties: [\n { id: \"related\", label: \"related to\", inverse: \"related to\" },\n { id: \"role_at\", label: \"role at\", inverse: \"people\", wikidata: \"P108\", range: [\"organization\"], domain: [\"person\"] },\n { id: \"member_of\", label: \"member of\", inverse: \"members\", wikidata: \"P463\", range: [\"organization\"], domain: [\"person\", \"organization\"] },\n { id: \"founded\", label: \"founded\", inverse: \"founded by\", wikidata: \"P112\", domain: [\"person\", \"organization\"] },\n { id: \"works_with\", label: \"works with\", inverse: \"works with\", domain: [\"person\", \"organization\"] },\n { id: \"reports_to\", label: \"reports to\", inverse: \"manages\", domain: [\"person\"] },\n { id: \"client_of\", label: \"client of\", inverse: \"clients\", wikidata: \"P1972\", domain: [\"person\", \"organization\"] },\n { id: \"client\", label: \"is for client\", inverse: \"projects\", range: [\"organization\", \"person\"], domain: [\"project\", \"offering\", \"contract\"] },\n { id: \"works_on\", label: \"works on\", inverse: \"people\", range: [\"project\"], domain: [\"person\", \"organization\", \"agent\"] },\n { id: \"works_for\", label: \"works for\", inverse: \"agents\", wikidata: \"P108\", domain: [\"agent\", \"person\"] },\n { id: \"owns\", label: \"owns\", inverse: \"owned by\", wikidata: \"P1830\" },\n { id: \"uses\", label: \"uses\", inverse: \"used by\", wikidata: \"P2283\" },\n { id: \"located_in\", label: \"located in\", inverse: \"here\", wikidata: \"P276\" },\n { id: \"installed_on\", label: \"installed on\", inverse: \"installed apps\", range: [\"device\", \"server\"] },\n { id: \"runs_on\", label: \"runs on\", inverse: \"hosts\" },\n { id: \"registered_with\", label: \"registered with\", inverse: \"registered\" },\n { id: \"identifier\", label: \"identifier\", wikidata: \"P1448\" },\n { id: \"legal_form\", label: \"legal form\", wikidata: \"P1454\" },\n { id: \"registrar\", label: \"registrar\" },\n { id: \"licensed_by\", label: \"licensed by\", inverse: \"licences\" },\n { id: \"party_to\", label: \"party to\", inverse: \"parties\" },\n { id: \"starts\", label: \"starts\" },\n { id: \"renews\", label: \"renews\" },\n { id: \"notice\", label: \"notice period\" },\n { id: \"amount\", label: \"amount\" },\n { id: \"creates\", label: \"creates\", inverse: \"created by\" },\n { id: \"created_by\", label: \"created by\", inverse: \"creates\" },\n { id: \"changed_by\", label: \"changed by\", inverse: \"changes\" },\n { id: \"amends\", label: \"amends\", inverse: \"amended by\", wikidata: \"P144\" },\n { id: \"repeals\", label: \"repeals\", inverse: \"repealed by\" },\n { id: \"implements\", label: \"implements\", inverse: \"implemented by\" },\n { id: \"issued_by\", label: \"issued by\", inverse: \"issues\" },\n { id: \"published_in\", label: \"published in\", wikidata: \"P1433\" },\n { id: \"in_force_from\", label: \"in force from\", wikidata: \"P7588\" },\n { id: \"legal_force\", label: \"legal force\" },\n { id: \"applies_in\", label: \"applies in\", inverse: \"laws that apply\", wikidata: \"P1001\" },\n { id: \"jurisdiction_of\", label: \"authority in\", inverse: \"authorities\" },\n { id: \"subject_to\", label: \"subject to\", inverse: \"carried by\" },\n { id: \"action\", label: \"action\" },\n { id: \"bearer\", label: \"bearer\" },\n { id: \"due_rule\", label: \"due\" },\n { id: \"amount_rule\", label: \"amount\" },\n { id: \"authority\", label: \"authority\", inverse: \"collects\" },\n { id: \"status\", label: \"status\" },\n { id: \"penalty_for\", label: \"penalty for\", inverse: \"penalties\" },\n { id: \"relieves\", label: \"relieves\", inverse: \"reliefs\" },\n { id: \"condition\", label: \"condition\" },\n { id: \"kind\", label: \"kind\" },\n { id: \"procedure\", label: \"procedure\", inverse: \"carries out\" },\n { id: \"due_for\", label: \"due for\", inverse: \"due dates\" },\n { id: \"due\", label: \"due on\" },\n { id: \"fulfilled_by\", label: \"fulfilled by\", inverse: \"fulfils\" },\n { id: \"involves\", label: \"involves\", inverse: \"events\", wikidata: \"P710\" },\n { id: \"affects\", label: \"affects\", inverse: \"affected by\" },\n { id: \"replaced_by\", label: \"replaced by\", inverse: \"replaces\", wikidata: \"P1366\" },\n { id: \"triggered_by\", label: \"triggered by\", inverse: \"triggers\" },\n { id: \"mentions\", label: \"mentions\", inverse: \"discussed in\" },\n { id: \"reading\", label: \"reading\" },\n { id: \"importance_set\", label: \"importance set\" },\n ],\n importance: {\n default: \"normal\",\n major_set_by: \"owner\",\n rollup: { min: 5, days: 30 },\n // Routine machine upkeep: true for any fleet, so safe as a default.\n rules: [\n { level: \"minor\", title: \"\\\\b(disk|storage) (is |was |almost |nearly )?(full|pressure|cleanup|clean-up|usage|space)\\\\b\" },\n { level: \"minor\", title: \"\\\\b(cache|logs?|temp files?) (was |were )?(cleared|cleaned|purged|rotated|pruned)\\\\b\" },\n { level: \"minor\", title: \"\\\\b(restart(ed)?|reboot(ed)?|health ?check|heartbeat)\\\\b\" },\n ],\n },\n sidebar: { pins_max: 5, pins: [] },\n classify: [\n // Old pages filed agents as people and machines as places; the title\n // tells them apart until absorb writes `class` on the page.\n { type: \"agent\", legacy: [\"person\", \"concept\", \"project\"], title: \"\\\\bagents?\\\\b|\\\\bbot\\\\b\" },\n { type: \"server\", legacy: [\"place\", \"concept\"], title: \"\\\\b(server|vps|host|node)\\\\b\" },\n { type: \"device\", legacy: [\"place\", \"concept\"], title: \"\\\\b(laptop|macbook|desktop|phone|tablet|printer|router)\\\\b\" },\n { type: \"person\", legacy: [\"person\"] },\n { type: \"event\", legacy: [\"event\"] },\n { type: \"decision\", legacy: [\"decision\"] },\n { type: \"procedure\", legacy: [\"pattern\"] },\n { type: \"place\", legacy: [\"place\"] },\n // Folder and tag rules below refine untyped and concept pages only.\n { type: \"project\", legacy: [\"project\"] },\n { type: \"organization\", path: [\"clients\", \"customers\", \"vendors\", \"suppliers\", \"organizations\", \"orgs\", \"companies\"] },\n { type: \"organization\", tags: [\"organization\", \"company\", \"client\", \"vendor\", \"supplier\", \"agency\", \"bank\"] },\n { type: \"server\", path: [\"servers\", \"hosts\", \"infrastructure\"] },\n { type: \"server\", tags: [\"server\", \"vps\", \"host\"] },\n { type: \"device\", path: [\"devices\"] },\n { type: \"device\", tags: [\"device\", \"laptop\", \"phone\", \"printer\"] },\n { type: \"agent\", tags: [\"agent\"], title: \"\\\\bagent\\\\b\" },\n { type: \"app\", path: [\"apps\", \"systems\", \"services\"] },\n { type: \"domain\", tags: [\"domain\", \"dns\"] },\n { type: \"contract\", path: [\"contracts\", \"agreements\"] },\n { type: \"contract\", tags: [\"contract\", \"agreement\", \"subscription\"] },\n { type: \"legal_source\", path: [\"laws\", \"legislation\"] },\n { type: \"legal_source\", tags: [\"law\", \"legislation\", \"decree\"] },\n { type: \"obligation\", path: [\"obligations\", \"compliance\"] },\n { type: \"obligation\", tags: [\"obligation\", \"compliance\"] },\n { type: \"policy\", path: [\"policies\"] },\n { type: \"policy\", tags: [\"policy\"] },\n { type: \"procedure\", path: [\"runbooks\", \"procedures\"] },\n { type: \"procedure\", tags: [\"runbook\", \"procedure\", \"how-to\"] },\n ],\n fallback_type: \"topic\",\n}\n"],"mappings":"wCAQA,OAAS,cAAAA,EAAY,gBAAAC,EAAc,YAAAC,EAAU,iBAAAC,MAAqB,KAClE,OAAS,WAAAC,MAAe,OACxB,OAAOC,MAAU,UCAjB,IAAMC,EAAU,CAACC,EAAO,KAAkB,CACxC,MAAO,UAAW,MAAO,UAAW,OAAQ,UAAW,KAAAA,EACvD,WAAY,CAAC,QAAS,QAAQ,EAAG,KAAM,QAAS,OAAQ,CAAE,IAAK,EAAG,KAAM,EAAG,CAC7E,GACMC,EAAuB,CAAE,MAAO,YAAa,MAAO,YAAa,OAAQ,YAAa,KAAM,EAAG,OAAQ,OAAQ,EAC/GC,EAAQ,CAACF,EAAO,KAAkB,CAAE,MAAO,QAAS,MAAO,QAAS,OAAQ,QAAS,KAAAA,CAAK,GAE1FG,EAAc,CAAC,SAAU,SAAU,MAAO,SAAU,UAAW,OAAO,EAEtEC,EAAmB,CAEvB,CACE,GAAI,SAAU,MAAO,SAAU,OAAQ,SAAU,OAAQ,UAAW,OAAQ,SAAU,KAAM,SAC5F,KAAM,CACJ,CAAE,MAAO,QAAS,MAAO,kBAAmB,KAAM,CAAC,UAAW,YAAa,SAAS,EAAG,KAAM,EAAG,QAAS,UAAW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A,EAAE,OACnBA,EAAE,QAAU,WAAaA,EAAE,QAAU,aAAeA,EAAE,QAAU,QAAgBA,EAAE,MAClFA,EAAE,OAAe,WACjBA,EAAE,KAAa,aACZ,QACT,CAEA,SAASlB,EAAS4B,EAA0C,CAC1D,OAAO,OAAOA,GAAM,UAAYA,IAAM,MAAQ,CAAC,MAAM,QAAQA,CAAC,CAChE","names":["existsSync","readFileSync","statSync","writeFileSync","resolve","yaml","history","show","discussed","notes","ASSET_TYPES","types","t","DEFAULT_ONTOLOGY","ONTOLOGY_FILE","cache","loadOntology","wikiDir","file","resolve","existsSync","DEFAULT_ONTOLOGY","mtimeMs","statSync","hit","raw","errors","yaml","readFileSync","err","ontology","mergeOntology","isObject","checkOntology","loaded","writeDefaultOntology","header","writeFileSync","base","over","out","key","list","mergeById","n","x","item","at","o","pillars","p","types","props","f","panelFrom","ty","lv","IMPORTANCE_LEVELS","r","panelSource","v"]}
|
package/dist/chunk-WWDYDLY2.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import{a as R,b as G,c as K,d as z,e as J}from"./chunk-YA3P77LV.js";import{a as N,b as I,c as V,d as Y,e as B,j as F}from"./chunk-ERULJ2ZL.js";import{a as H}from"./chunk-JRS5QRZG.js";import{y as T,z as ot}from"./chunk-4XMALK7X.js";import{g as j}from"./chunk-6TURWSMN.js";import{b as E,c as L}from"./chunk-QOYAX2FT.js";import{readFileSync as lt,existsSync as X}from"fs";ot();import{resolve as _}from"path";import{execSync as ct}from"child_process";var ht=.8;function dt(e,r,o,t){if(t.size===0)return 0;let c=e.listArticles(r||"").map(l=>l.path).filter(l=>!l.includes("/_versions/"));return c.length===0&&(c=o.sharedPool.map(l=>l.path)),c.length===0?0:c.filter(l=>t.has(l)).length/c.length}async function Et(e,r,o,t={}){let c=t.selectorModel??"haiku",l=t.synthModel??"sonnet",m=t.maxCandidates??3,g=t.maxHops??2,d=t.maxArticles??8,i=t.timeoutMs??6e4,s=t.log??console.error.bind(console,"[wiki-query]"),h=t.messagePath?.length?t.messagePath:void 0,n=t.graphWeight??W,a=_(r.baseDir,"_index.md"),p=tt(r,o,t.shared),b=t.method??"catalog";if(b!=="catalog"){let u=z(r,t.shared);if(b==="summaries"||dt(r,o,p,u)>=ht){let f=t.summaries??K,P=t.notes&&o&&t.notes.owner===o?G(t.notes):void 0,y=await J(e,P?pt(p,P):p,P?new Map([...u,...P.summaries]):u,{...f,navigatorModel:t.selectorModel??f.navigatorModel,answerModel:t.synthModel??f.answerModel},{call:t.call??H,fetch:t.fetch,timeoutMs:i,log:s}),$=y.picked.map(w=>({title:w.meta.title,path:w.path,type:R(w.path)?"note":w.meta.type,hop:w.hop}));return{answer:y.answer,citations:y.status==="ok"?$.map(({hop:w,...v})=>v):[],candidates:$.filter(w=>w.hop===0).map(({title:w,path:v})=>({title:w,path:v})),walked:$,status:y.status,method:"summaries",basis:y.basis,live:y.live,liveAsked:y.liveAsked,trace:y.trace,...y.error?{error:y.error}:{}}}}if(!X(a)&&p.sharedPool.length===0)return M("no-catalog",e,"No _index.md found \u2014 run `agentx wiki status` to rebuild.");let it=(X(a)?lt(a,"utf-8"):"")+ut(e,p.sharedPool,h,n),U=Date.now(),A=[],S="";try{let u=await nt(e,p.pool,o,m,h,n);u?(A=u,S=`[wiki-rerank seat] ${u.map(f=>f.title).join(" | ")}`):(S=await Z(ft(e,it,m,h),c,i),A=wt(S))}catch(u){return s("selector failed:",u?.message),{...M("error",e,`Selector: ${u?.message||"unknown"}`),trace:{selectorMs:Date.now()-U,synthesisMs:0,selectorOutput:S}}}let x=Date.now()-U;if(A.length===0)return{...M("no-candidates",e,"Selector returned no candidates."),trace:{selectorMs:x,synthesisMs:0,selectorOutput:S}};let C=rt(A,p,g,d);if(C.length===0)return{...M("no-candidates",e,"Candidates did not resolve to readable articles."),candidates:A,trace:{selectorMs:x,synthesisMs:0,selectorOutput:S}};let D=Date.now(),Q="";try{Q=await Z(yt(e,C),l,i*2)}catch(u){return s("synthesis failed:",u?.message),{...M("error",e,`Synthesis: ${u?.message||"unknown"}`),candidates:A,walked:C.map(f=>({title:f.meta.title,path:f.path,type:f.meta.type,hop:f.hop??0})),trace:{selectorMs:x,synthesisMs:Date.now()-D,selectorOutput:S}}}let st=Date.now()-D;return{answer:Q.trim(),citations:C.map(u=>({title:u.meta.title,path:u.path,type:u.meta.type})),candidates:A,walked:C.map(u=>({title:u.meta.title,path:u.path,type:u.meta.type,hop:u.hop??0})),status:"ok",trace:{selectorMs:x,synthesisMs:st,selectorOutput:S}}}async function Lt(e,r,o,t={}){let c=t.maxCandidates??3,l=t.graphWeight??W,m=t.messagePath?.length?t.messagePath:void 0,g=t.pool??q(r);if(g.length===0||!e.trim())return[];let d=await nt(e,g,o,c,m,l,t.stage??"retrieve");if(!d){let i=new Set(L(e,E(g.map(at))).map(s=>s.docIndex));d=O(e,g,m,l).filter(s=>i.has(s)).slice(0,c).map(s=>({title:g[s].title,path:g[s].path}))}return d.length===0?[]:rt(d,tt(r,o),t.maxHops??1,t.maxArticles??6)}function q(e){try{return(e.rebuildIndex().articles??[]).filter(r=>r.path&&!r.path.includes("/_versions/"))}catch{return[]}}function M(e,r,o){return{answer:"",citations:[],candidates:[],walked:[],status:e,error:o}}function tt(e,r,o=[]){let t=new Map,c=[];for(let i of e.listArticles(r||""))t.set(i.meta.title.toLowerCase(),i.path),c.push({path:i.path,related:i.meta.related??[],lastUpdated:i.meta.lastUpdated??""});let l=[],m=new Map;for(let i of o)if(i.store.baseDir!==e.baseDir){m.set(i.id,i);for(let s of i.store.listArticles(r||"")){if(s.path.includes("/_versions/")||i.skip?.(s.path))continue;let h=`@${i.id}/${s.path}`;l.push(mt(s,h)),c.push({path:h,related:s.meta.related??[],lastUpdated:s.meta.lastUpdated??""});let n=s.meta.title.toLowerCase();t.has(n)||t.set(n,h)}}let g=new Map;if(m.size>0)for(let i of[...c].sort((s,h)=>h.lastUpdated.localeCompare(s.lastUpdated)))for(let s of i.related){let h=s.toLowerCase(),n=g.get(h)??[];n.includes(i.path)||n.push(i.path),g.set(h,n)}let d;return{backlinks:g,readable:new Set(c.map(i=>i.path)),get pool(){return d??=[...q(e),...l]},sharedPool:l,titleIndex:t,read(i){let s=i.match(/^@([^/]+)\/(.+)$/),h=s?m.get(s[1]):void 0;if(s&&!h)return null;let n=h?.store??e,a=s?s[2]:i,p=r?n.readArticleAs(a,r):n.readArticle(a);return p?{...p,path:i}:null},links(i){let s=(i.meta.related??[]).map(a=>t.get(a.toLowerCase())).filter(a=>!!a),h=[i.meta.title,...i.meta.aliases??[]].map(a=>a.toLowerCase()),n=[...new Set(h.flatMap(a=>g.get(a)??[]))].filter(a=>a!==i.path).slice(0,et);return[...new Set([...s,...n])].filter(a=>a!==i.path)}}}function pt(e,r){return{...e,pool:[...e.pool,...r.pool],readable:new Set([...e.readable,...r.pool.map(o=>o.path)]),read:o=>R(o)?r.read(o):e.read(o)}}function mt(e,r){return{path:r,title:e.meta.title,type:e.meta.type,related:e.meta.related,tags:e.meta.tags||[],owner:e.meta.owner,access:e.meta.access,sharedWith:e.meta.sharedWith,aliases:[e.meta.title.toLowerCase(),...(e.meta.aliases??[]).map(o=>o.toLowerCase())],backlinks:0,sources:e.meta.sources,lastUpdated:e.meta.lastUpdated,graphPath:e.meta.graphPath}}var gt=150;function ut(e,r,o,t){return r.length===0?"":`
|
|
2
|
-
|
|
3
|
-
## Shared wiki (other agents' articles)
|
|
4
|
-
|
|
5
|
-
${O(e,r,o,t).slice(0,gt).map(l=>`- ${r[l].title}${r[l].type?` [${r[l].type}]`:""} (${r[l].path})`).join(`
|
|
6
|
-
`)}
|
|
7
|
-
`}var et=3;function rt(e,r,o,t){let c=r.titleIndex,l=n=>n.startsWith("@"),m=[...e.filter(n=>!l(n.path)),...e.filter(n=>l(n.path))],g=m.length>0&&!l(m[0].path)?Math.floor(t/2):t,d=new Map,i=0,s=m.map(n=>({path:n.path,hop:0})),h=[];for(;d.size<t;){if(!s.length){if(!h.length||g>=t)break;g=t,s=h.splice(0)}let n=s.shift();if(d.has(n.path)||n.hop>o)continue;if(l(n.path)&&i>=g){h.push(n);continue}let a=r.read(n.path);if(a&&(d.set(n.path,{...a,hop:n.hop}),l(n.path)&&i++,!(n.hop>=o))){if(n.hop===0){let p=[a.meta.title,...a.meta.aliases??[]].map(k=>k.toLowerCase()),b=[...new Set(p.flatMap(k=>r.backlinks.get(k)??[]))].filter(k=>k!==n.path&&!d.has(k)).slice(0,et);for(let k of b)s.push({path:k,hop:1})}for(let p of a.meta.related||[]){let b=c.get(p.toLowerCase());b&&!d.has(b)&&s.push({path:b,hop:n.hop+1})}}}return Array.from(d.values())}async function nt(e,r,o,t,c,l=W,m="catalog-selector"){try{if(r.length<2)return null;let d=O(e,r,c,l).slice(0,I).map(n=>({id:`k${n}`,title:r[n].title||r[n].path,tags:r[n].tags,excerpt:[r[n].type?`type: ${r[n].type}`:"",(r[n].related??[]).length?`related: ${(r[n].related??[]).join(", ")}`:"",(r[n].graphPath??[]).length?`graph: ${(r[n].graphPath??[]).join(" \u203A ")}`:""].filter(Boolean).join(" \xB7 ")})),i=await T(N,V({query:e,candidates:d,excerptChars:300}),Y(d),{features:{agent:o??"unknown",stage:m}});if(!i||i.mode!=="active")return null;let h=B(i.answers,d).ranked.slice(0,t).map(n=>r[Number(n.slice(1))]).filter(Boolean).map(n=>({title:n.title,path:n.path}));return h.length>0?h:null}catch{return null}}var W=.6;function O(e,r,o,t=W){let c=L(e,E(r.map(at))),l=c.reduce((a,p)=>Math.max(a,p.score),0),m=new Map(c.map(a=>[a.docIndex,l>0?a.score/l:0])),g=!!o?.length,d=a=>g&&a.graphPath?.length?F(o,a.graphPath):0,i=(a,p)=>p.score-a.score||a.i-p.i,s=r.map((a,p)=>({i:p,score:(m.get(p)??0)*(1+t*d(a))})).filter(a=>m.has(a.i)).sort(i),h=r.map((a,p)=>({i:p,score:d(a)})).filter(a=>!m.has(a.i)&&a.score>0).sort(i),n=[...s,...h].map(a=>a.i);for(let a=0;a<r.length;a++)n.includes(a)||n.push(a);return n}function at(e){return[e.title,(e.tags??[]).join(" "),(e.related??[]).join(" ")].join(" ")}function ft(e,r,o,t){let c=t?.length?`
|
|
8
|
-
## Intent
|
|
9
|
-
|
|
10
|
-
The request was classified under the intent-graph path "${t.join(" \u203A ")}". Prefer articles filed under the same branch when their titles are equally plausible.
|
|
11
|
-
`:"";return`You are picking candidate articles from a wiki catalog to answer a question. You do NOT answer the question. You pick which articles the answer is likely to come from.
|
|
12
|
-
|
|
13
|
-
## Question
|
|
14
|
-
|
|
15
|
-
${e}
|
|
16
|
-
${c}
|
|
17
|
-
## Catalog (_index.md \u2014 articles grouped by type, with wikilink previews)
|
|
18
|
-
|
|
19
|
-
${r}
|
|
20
|
-
|
|
21
|
-
## Your task
|
|
22
|
-
|
|
23
|
-
Pick up to ${o} articles from the catalog that are most likely to answer the question. Prefer:
|
|
24
|
-
- Articles whose title directly names a subject in the question.
|
|
25
|
-
- Articles of the right type (e.g. a "who owns X" question \u2192 person or project; a "what happened on DATE" \u2192 event).
|
|
26
|
-
- Articles whose wikilinks suggest they sit at the center of a relevant subgraph.
|
|
27
|
-
|
|
28
|
-
Return ONLY valid JSON, no markdown fencing, no prose:
|
|
29
|
-
|
|
30
|
-
[
|
|
31
|
-
{"title": "Exact Article Title", "path": "path/from/catalog.md"},
|
|
32
|
-
...
|
|
33
|
-
]
|
|
34
|
-
|
|
35
|
-
If none of the articles match, return [].`}function yt(e,r){let o=r.map(t=>{let c=[t.meta.owner?`owner: ${t.meta.owner}`:"",t.meta.lastUpdated?`updated: ${t.meta.lastUpdated}`:""].filter(Boolean).join(", "),l=`### ${t.meta.title} \u2014 ${t.meta.type||"untyped"} (${t.path}) [hop ${t.hop}]${c?` {${c}}`:""}`,m=t.meta.related?.length?`Related: ${t.meta.related.join(", ")}`:"";return[l,m,"",t.content].filter(Boolean).join(`
|
|
36
|
-
`)}).join(`
|
|
37
|
-
|
|
38
|
-
---
|
|
39
|
-
|
|
40
|
-
`);return`You are answering a question using a small subgraph of wiki articles. The articles were walked from the catalog; trust them over your prior knowledge.
|
|
41
|
-
|
|
42
|
-
## Question
|
|
43
|
-
|
|
44
|
-
${e}
|
|
45
|
-
|
|
46
|
-
## Articles (${r.length} walked from the catalog)
|
|
47
|
-
|
|
48
|
-
${o}
|
|
49
|
-
|
|
50
|
-
## Your task
|
|
51
|
-
|
|
52
|
-
Answer the question in 2\u20136 sentences. Cite articles by their title in square brackets like [Article Title]. When two articles disagree, prefer the one updated more recently, and say which agent's page and date the answer comes from. If the articles do not answer the question, say so plainly (do not invent). Prefer concrete facts over hedging.
|
|
53
|
-
|
|
54
|
-
Output ONLY the answer \u2014 no preamble, no "here is my answer:", no markdown fencing.`}function wt(e){let r=e.match(/\[[\s\S]*?\]/);if(!r)return[];try{let o=JSON.parse(r[0]);return Array.isArray(o)?o.filter(t=>t&&typeof t.title=="string"&&typeof t.path=="string").map(t=>({title:t.title,path:t.path})):[]}catch{return[]}}async function Z(e,r,o){let{writeFileSync:t,mkdirSync:c,rmSync:l}=await import("fs"),{tmpdir:m}=await import("os"),g=_(m(),`agentx-wiki-query-${process.pid}`);c(g,{recursive:!0});let d=_(g,`prompt-${Date.now()}.txt`);t(d,e);try{let i=`cat '${d}' | claude -p - --output-format json --max-turns 1 --model ${r} --disallowedTools "Bash Read Write Edit Glob Grep Agent WebSearch WebFetch NotebookEdit"`,s=ct(i,{env:j(),encoding:"utf-8",timeout:o,maxBuffer:4*1024*1024});try{let h=JSON.parse(s);return String(h.result||h.content||"")}catch{return s}}finally{try{l(d,{force:!0})}catch{}}}async function Rt(e){try{let{loadDaemonConfig:r}=await import("./config-GHMRBRDL.js");return r(e).wiki.query.shared}catch{return!0}}export{ht as a,Et as b,Lt as c,q as d,gt as e,W as f,O as g,Rt as h};
|
|
55
|
-
//# sourceMappingURL=chunk-WWDYDLY2.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/wiki/query.ts"],"sourcesContent":["import { readFileSync, existsSync } from \"fs\"\nimport { buildIndex, scoreAll } from \"@/memory/bm25\"\nimport { askSeat } from \"@/decisions/seat\"\nimport { ancestryScore } from \"@/graph\"\nimport {\n DEFAULT_SHORTLIST,\n WIKI_RERANK_SEAT,\n rerankQuestions,\n rerankState,\n toRanking,\n type RerankCandidate,\n} from \"@/decisions/seats/wiki-rerank\"\nimport { claudeCliEnv } from \"@/utils/workspace-env\"\nimport { resolve } from \"path\"\nimport { execSync } from \"child_process\"\nimport type { WikiArticle, WikiIndex } from \"./types\"\nimport type { WikiStore } from \"./store\"\nimport { claudeModelCall, type ModelCall } from \"./model-call\"\nimport type { FetchLike, LiveLine } from \"./live-read\"\nimport { DEFAULT_SUMMARIES_QUERY, collectSummaries, summariesQuery, type PageView, type SummariesQuerySettings } from \"./query-summaries\"\nimport { isNotePath, notePool, type NoteSource } from \"./query-notes\"\nimport type { QueryMethod } from \"./query-settings\"\n\n/**\n * Agentic wiki query — the \"Farzapedia-faithful\" retrieval path.\n *\n * Two LLM calls + a deterministic graph walk:\n * 1. Selector (cheap): read `_index.md` + question → pick up to `maxCandidates`\n * candidate articles by title + type.\n * 2. Walk (pure code): starting from candidates, follow `related` wikilinks\n * up to `maxHops`, capped at `maxArticles` total.\n * 3. Synthesis (main): answer the question from the walked subgraph.\n *\n * Returns an answer with citations and a trace of which articles were walked,\n * so callers can audit the retrieval path.\n */\n\nexport interface AgenticQueryOptions {\n /** Candidate-selection model (cheap). Defaults to \"haiku\". */\n selectorModel?: string\n /** Synthesis model (main). Defaults to \"sonnet\". */\n synthModel?: string\n /** Number of candidates the selector is asked to return. Default 3. */\n maxCandidates?: number\n /** Wikilink hops from candidates. Default 2. */\n maxHops?: number\n /** Hard cap on total articles walked. Default 8. */\n maxArticles?: number\n /** Timeout per LLM call, ms. Default 60_000. */\n timeoutMs?: number\n /** Logger — defaults to console.error. */\n log?: (...args: unknown[]) => void\n /** Intent-graph path the question's request was classified under.\n * Articles on the same branch rank higher in candidate selection. */\n messagePath?: string[]\n /** Weight of the branch match against the text match, 0–1. Default 0.6\n * (`graph.retrievalWeights.graph`). */\n graphWeight?: number\n /** Other wikis to search besides `store`: the shared wiki (#824). Only\n * articles the requester may read are offered. Their paths come back\n * as `@<id>/<path>`. */\n shared?: SharedWikiStore[]\n /** How pages are picked (#855). `summaries`: from the one-line page\n * summaries, then a live read (query-summaries.ts). `auto`: that, once\n * most of the requester's own pages have a summary\n * (AUTO_SUMMARY_COVERAGE). Default \"catalog\". */\n method?: QueryMethod\n /** Settings of the summaries method. An explicit `selectorModel` or\n * `synthModel` overrides its models. */\n summaries?: SummariesQuerySettings\n /** The requester's own notes, searched beside its pages by the\n * summaries method (#862). A note is private to the agent that wrote\n * it: notes of any other agent are ignored. */\n notes?: NoteSource\n /** Model call and HTTP GET of the summaries method; tests pass their own. */\n call?: ModelCall\n fetch?: FetchLike\n}\n\n/** Share of the requester's own pages that must have a summary before\n * `auto` picks pages from summaries. Below it, an unsummarised page\n * would be ranked on its title and tags alone, so the catalog walk is\n * kept: one `wiki summarize --agent <id>` or `--limit` run must not\n * switch every agent that can read that store. */\nexport const AUTO_SUMMARY_COVERAGE = 0.8\n\n/** Share of the pages in reach that have a summary: the requester's own\n * pages, or the shared pages when the requester has none. */\nfunction summaryCoverage(store: WikiStore, requesterId: string | undefined, view: ScopeView, summaries: Map<string, string>): number {\n if (summaries.size === 0) return 0\n let paths = store.listArticles(requesterId || \"\").map((a) => a.path).filter((p) => !p.includes(\"/_versions/\"))\n if (paths.length === 0) paths = view.sharedPool.map((e) => e.path)\n if (paths.length === 0) return 0\n return paths.filter((p) => summaries.has(p)).length / paths.length\n}\n\n/** A wiki searched alongside the requester's own. */\nexport interface SharedWikiStore {\n /** Shown in citations as `@<id>/<path>`: an agent id, or \"shared\". */\n id: string\n store: WikiStore\n /** Paths to leave out, e.g. the agents/ tree under the root store. */\n skip?: (path: string) => boolean\n}\n\nexport interface AgenticQueryResult {\n answer: string\n citations: Array<{ title: string; path: string; type?: string }>\n /** Titles/paths the selector picked. */\n candidates: Array<{ title: string; path: string }>\n /** Full article subgraph the walk produced. */\n walked: Array<{ title: string; path: string; type?: string; hop: number }>\n /** \"no-catalog\" | \"no-candidates\" | \"ok\" */\n status: \"ok\" | \"no-catalog\" | \"no-candidates\" | \"error\"\n /** How the pages were picked. */\n method?: \"summaries\" | \"catalog\"\n /** Lines read at the source for this answer (summaries method). */\n live?: LiveLine[]\n /** Live reads the model named and the config allowed. */\n liveAsked?: number\n /** \"search\": no wiki page was used; the answer comes from a search at\n * the source (#861). */\n basis?: \"pages\" | \"search\"\n /** For operator debugging only. */\n trace?: {\n selectorMs: number\n synthesisMs: number\n selectorOutput?: string\n planMs?: number\n liveMs?: number\n }\n error?: string\n}\n\n/**\n * Run an agentic query against a specific agent's WikiStore.\n *\n * `requesterId` is used for permission checks — only articles the requester\n * can read will be included in the synthesis input.\n */\nexport async function agenticQuery(\n question: string,\n store: WikiStore,\n requesterId: string | undefined,\n opts: AgenticQueryOptions = {},\n): Promise<AgenticQueryResult> {\n const selectorModel = opts.selectorModel ?? \"haiku\"\n const synthModel = opts.synthModel ?? \"sonnet\"\n const maxCandidates = opts.maxCandidates ?? 3\n const maxHops = opts.maxHops ?? 2\n const maxArticles = opts.maxArticles ?? 8\n const timeoutMs = opts.timeoutMs ?? 60_000\n const log = opts.log ?? console.error.bind(console, \"[wiki-query]\")\n const messagePath = opts.messagePath?.length ? opts.messagePath : undefined\n const graphWeight = opts.graphWeight ?? DEFAULT_GRAPH_WEIGHT\n\n // --- Step 1: Load the catalog ---\n const catalogPath = resolve(store.baseDir, \"_index.md\")\n const view = scopeView(store, requesterId, opts.shared)\n\n const method = opts.method ?? \"catalog\"\n if (method !== \"catalog\") {\n const summaries = collectSummaries(store, opts.shared)\n if (method === \"summaries\" || summaryCoverage(store, requesterId, view, summaries) >= AUTO_SUMMARY_COVERAGE) {\n const base = opts.summaries ?? DEFAULT_SUMMARIES_QUERY\n const notes = opts.notes && requesterId && opts.notes.owner === requesterId ? notePool(opts.notes) : undefined\n const out = await summariesQuery(question, notes ? withNotes(view, notes) : view, notes ? new Map([...summaries, ...notes.summaries]) : summaries, {\n ...base,\n navigatorModel: opts.selectorModel ?? base.navigatorModel,\n answerModel: opts.synthModel ?? base.answerModel,\n }, { call: opts.call ?? claudeModelCall, fetch: opts.fetch, timeoutMs, log })\n const pages = out.picked.map((a) => ({ title: a.meta.title, path: a.path, type: isNotePath(a.path) ? \"note\" : a.meta.type, hop: a.hop }))\n return {\n answer: out.answer,\n citations: out.status === \"ok\" ? pages.map(({ hop: _, ...p }) => p) : [],\n candidates: pages.filter((p) => p.hop === 0).map(({ title, path }) => ({ title, path })),\n walked: pages,\n status: out.status,\n method: \"summaries\",\n basis: out.basis,\n live: out.live,\n liveAsked: out.liveAsked,\n trace: out.trace,\n ...(out.error ? { error: out.error } : {}),\n }\n }\n }\n\n if (!existsSync(catalogPath) && view.sharedPool.length === 0) {\n return emptyResult(\"no-catalog\", question, \"No _index.md found — run `agentx wiki status` to rebuild.\")\n }\n const ownCatalog = existsSync(catalogPath) ? readFileSync(catalogPath, \"utf-8\") : \"\"\n const catalog = ownCatalog + renderSharedCatalog(question, view.sharedPool, messagePath, graphWeight)\n\n // --- Step 2: Selector — pick candidates ---\n const selectorStart = Date.now()\n let candidates: Array<{ title: string; path: string }> = []\n let selectorOutput = \"\"\n try {\n const viaSeat = await selectCandidatesViaSeat(question, view.pool, requesterId, maxCandidates, messagePath, graphWeight)\n if (viaSeat) {\n candidates = viaSeat\n selectorOutput = `[wiki-rerank seat] ${viaSeat.map((c) => c.title).join(\" | \")}`\n } else {\n selectorOutput = await runClaude(\n buildSelectorPrompt(question, catalog, maxCandidates, messagePath),\n selectorModel,\n timeoutMs,\n )\n candidates = parseCandidates(selectorOutput)\n }\n } catch (e: any) {\n log(\"selector failed:\", e?.message)\n return { ...emptyResult(\"error\", question, `Selector: ${e?.message || \"unknown\"}`), trace: { selectorMs: Date.now() - selectorStart, synthesisMs: 0, selectorOutput } }\n }\n const selectorMs = Date.now() - selectorStart\n\n if (candidates.length === 0) {\n return { ...emptyResult(\"no-candidates\", question, \"Selector returned no candidates.\"), trace: { selectorMs, synthesisMs: 0, selectorOutput } }\n }\n\n // --- Step 3: Walk the subgraph via `related` wikilinks ---\n const walked = walkSubgraph(candidates, view, maxHops, maxArticles)\n\n if (walked.length === 0) {\n return { ...emptyResult(\"no-candidates\", question, \"Candidates did not resolve to readable articles.\"), candidates, trace: { selectorMs, synthesisMs: 0, selectorOutput } }\n }\n\n // --- Step 4: Synthesize the answer ---\n const synthStart = Date.now()\n let answer = \"\"\n try {\n answer = await runClaude(\n buildSynthesisPrompt(question, walked),\n synthModel,\n timeoutMs * 2,\n )\n } catch (e: any) {\n log(\"synthesis failed:\", e?.message)\n return { ...emptyResult(\"error\", question, `Synthesis: ${e?.message || \"unknown\"}`), candidates, walked: walked.map(w => ({ title: w.meta.title, path: w.path, type: w.meta.type, hop: (w as any).hop ?? 0 })), trace: { selectorMs, synthesisMs: Date.now() - synthStart, selectorOutput } }\n }\n const synthesisMs = Date.now() - synthStart\n\n return {\n answer: answer.trim(),\n citations: walked.map(a => ({ title: a.meta.title, path: a.path, type: a.meta.type })),\n candidates,\n walked: walked.map(w => ({ title: w.meta.title, path: w.path, type: w.meta.type, hop: (w as any).hop ?? 0 })),\n status: \"ok\",\n trace: { selectorMs, synthesisMs, selectorOutput },\n }\n}\n\nexport interface RetrieveOptions {\n /** Articles picked before the walk. Default 3. */\n maxCandidates?: number\n /** Wikilink hops from the picked articles. Default 1. */\n maxHops?: number\n /** Hard cap on articles returned. Default 6. */\n maxArticles?: number\n messagePath?: string[]\n graphWeight?: number\n /** The catalog to pick from. Pass it when retrieving many times in a row,\n * so the index is not rebuilt for every call. */\n pool?: CatalogEntry[]\n /** Seat telemetry label. */\n stage?: string\n}\n\n/**\n * The retrieval half of agenticQuery, without the synthesis call: BM25\n * shortlist, rerank seat, then the `related` wikilink walk. Returns the\n * walked articles, hop 0 first.\n *\n * When the seat is off or fails, the BM25 order decides on its own, and\n * only articles the text matched are picked: an article chosen for\n * nothing but its catalog position is noise here, not a candidate. There\n * is no CLI fallback, so this never spends an LLM call.\n */\nexport async function retrieveArticles(\n question: string,\n store: WikiStore,\n requesterId: string | undefined,\n opts: RetrieveOptions = {},\n): Promise<Array<WikiArticle & { hop: number }>> {\n const maxCandidates = opts.maxCandidates ?? 3\n const graphWeight = opts.graphWeight ?? DEFAULT_GRAPH_WEIGHT\n const messagePath = opts.messagePath?.length ? opts.messagePath : undefined\n const pool = opts.pool ?? catalogPool(store)\n if (pool.length === 0 || !question.trim()) return []\n\n let candidates = await selectCandidatesViaSeat(\n question, pool, requesterId, maxCandidates, messagePath, graphWeight, opts.stage ?? \"retrieve\",\n )\n if (!candidates) {\n const matched = new Set(scoreAll(question, buildIndex(pool.map(catalogDoc))).map((r) => r.docIndex))\n candidates = rankCatalogPool(question, pool, messagePath, graphWeight)\n .filter((i) => matched.has(i))\n .slice(0, maxCandidates)\n .map((i) => ({ title: pool[i].title, path: pool[i].path }))\n }\n if (candidates.length === 0) return []\n return walkSubgraph(candidates, scopeView(store, requesterId), opts.maxHops ?? 1, opts.maxArticles ?? 6)\n}\n\nexport type CatalogEntry = WikiIndex[\"articles\"][number]\n\n/** The catalog retrieval picks from: every indexed article but old versions. */\nexport function catalogPool(store: WikiStore): CatalogEntry[] {\n try {\n return (store.rebuildIndex().articles ?? []).filter((a) => a.path && !a.path.includes(\"/_versions/\"))\n } catch {\n return []\n }\n}\n\n// --- Helpers ---\n\nfunction emptyResult(\n status: AgenticQueryResult[\"status\"],\n _question: string,\n error?: string,\n): AgenticQueryResult {\n return {\n answer: \"\",\n citations: [],\n candidates: [],\n walked: [],\n status,\n error,\n }\n}\n\n/**\n * The articles a query may open: the requester's own wiki first, then\n * each shared one. Shared paths carry an `@<id>/` prefix so the walk\n * knows which store to read; a title the own wiki has resolves there.\n */\ninterface ScopeView {\n /** Own catalog, then the shared articles. */\n pool: CatalogEntry[]\n sharedPool: CatalogEntry[]\n titleIndex: Map<string, string>\n /** Title (lowercased) → pages whose `related` names it, newest first.\n * Built only when shared wikis are searched. */\n backlinks: Map<string, string[]>\n /** Paths the requester may read, own and shared. */\n readable: Set<string>\n read(path: string): WikiArticle | null\n /** Pages `article` names in `related`, then the newest that name it. */\n links(article: WikiArticle): string[]\n}\n\nfunction scopeView(store: WikiStore, requesterId: string | undefined, shared: SharedWikiStore[] = []): ScopeView {\n const titleIndex = new Map<string, string>()\n const linking: Array<{ path: string; related: string[]; lastUpdated: string }> = []\n for (const article of store.listArticles(requesterId || \"\")) {\n titleIndex.set(article.meta.title.toLowerCase(), article.path)\n linking.push({ path: article.path, related: article.meta.related ?? [], lastUpdated: article.meta.lastUpdated ?? \"\" })\n }\n const sharedPool: CatalogEntry[] = []\n const byId = new Map<string, SharedWikiStore>()\n for (const s of shared) {\n if (s.store.baseDir === store.baseDir) continue\n byId.set(s.id, s)\n // listArticles is cached and already drops what the requester can't\n // read; rebuilding every agent's index per query would not be.\n for (const a of s.store.listArticles(requesterId || \"\")) {\n if (a.path.includes(\"/_versions/\") || s.skip?.(a.path)) continue\n const path = `@${s.id}/${a.path}`\n sharedPool.push(catalogEntry(a, path))\n linking.push({ path, related: a.meta.related ?? [], lastUpdated: a.meta.lastUpdated ?? \"\" })\n const key = a.meta.title.toLowerCase()\n if (!titleIndex.has(key)) titleIndex.set(key, path)\n }\n }\n // In a fleet's shared pool the page that answers a question often links\n // TO the page the selector picked (a decision about a person), and the\n // forward walk never reaches it (#824 review: ranked 103rd of ~5,700).\n const backlinks = new Map<string, string[]>()\n if (byId.size > 0) {\n for (const l of [...linking].sort((a, b) => b.lastUpdated.localeCompare(a.lastUpdated))) {\n for (const t of l.related) {\n const key = t.toLowerCase()\n const list = backlinks.get(key) ?? []\n if (!list.includes(l.path)) list.push(l.path)\n backlinks.set(key, list)\n }\n }\n }\n let pool: CatalogEntry[] | undefined\n return {\n backlinks,\n readable: new Set(linking.map((l) => l.path)),\n // Lazy: retrieveArticles brings its own pool, and building this one\n // rebuilds the index.\n get pool() { return (pool ??= [...catalogPool(store), ...sharedPool]) },\n sharedPool,\n titleIndex,\n read(path) {\n const m = path.match(/^@([^/]+)\\/(.+)$/)\n const target = m ? byId.get(m[1]) : undefined\n if (m && !target) return null\n const s = target?.store ?? store\n const rel = m ? m[2] : path\n const article = requesterId ? s.readArticleAs(rel, requesterId) : s.readArticle(rel)\n return article ? { ...article, path } : null\n },\n links(article) {\n const forward = (article.meta.related ?? []).map((t) => titleIndex.get(t.toLowerCase())).filter((p): p is string => !!p)\n const names = [article.meta.title, ...(article.meta.aliases ?? [])].map((n) => n.toLowerCase())\n const back = [...new Set(names.flatMap((n) => backlinks.get(n) ?? []))].filter((p) => p !== article.path).slice(0, BACKLINKS_PER_PICK)\n return [...new Set([...forward, ...back])].filter((p) => p !== article.path)\n },\n }\n}\n\n/** The view with the requester's notes added: in the pool, readable,\n * and opened from the notes folder. Everything else the view carries\n * (such as the title index linked pages follow) is kept. */\nfunction withNotes(view: ScopeView, notes: ReturnType<typeof notePool>): PageView {\n return {\n ...view,\n pool: [...view.pool, ...notes.pool],\n readable: new Set([...view.readable, ...notes.pool.map((n) => n.path)]),\n read: (path) => (isNotePath(path) ? notes.read(path) : view.read(path)),\n }\n}\n\nfunction catalogEntry(a: WikiArticle, path: string): CatalogEntry {\n return {\n path,\n title: a.meta.title,\n type: a.meta.type,\n related: a.meta.related,\n tags: a.meta.tags || [],\n owner: a.meta.owner,\n access: a.meta.access,\n sharedWith: a.meta.sharedWith,\n aliases: [a.meta.title.toLowerCase(), ...(a.meta.aliases ?? []).map((x) => x.toLowerCase())],\n backlinks: 0,\n sources: a.meta.sources,\n lastUpdated: a.meta.lastUpdated,\n graphPath: a.meta.graphPath,\n }\n}\n\n/** Shared articles most related to the question, for the CLI selector.\n * Capped: a fleet's shared catalog would not fit one prompt. */\nexport const SHARED_CATALOG_LINES = 150\n\nfunction renderSharedCatalog(question: string, pool: CatalogEntry[], messagePath: string[] | undefined, graphWeight: number): string {\n if (pool.length === 0) return \"\"\n const lines = rankCatalogPool(question, pool, messagePath, graphWeight)\n .slice(0, SHARED_CATALOG_LINES)\n .map((i) => `- ${pool[i].title}${pool[i].type ? ` [${pool[i].type}]` : \"\"} (${pool[i].path})`)\n return `\\n\\n## Shared wiki (other agents' articles)\\n\\n${lines.join(\"\\n\")}\\n`\n}\n\n/** Pages that link to a picked page, opened per picked page. */\nconst BACKLINKS_PER_PICK = 3\n\nfunction walkSubgraph(\n candidates: Array<{ title: string; path: string }>,\n view: ScopeView,\n maxHops: number,\n maxArticles: number,\n): Array<WikiArticle & { hop: number }> {\n const titleIndex = view.titleIndex\n const isShared = (path: string) => path.startsWith(\"@\")\n\n // The agent's own pages come first, and shared pages may take at most\n // half the walk when it has any: in the #824 trial shared pages took\n // the slots of the agent's own correct pages and its score dropped.\n const ordered = [...candidates.filter((c) => !isShared(c.path)), ...candidates.filter((c) => isShared(c.path))]\n let sharedCap = ordered.length > 0 && !isShared(ordered[0].path) ? Math.floor(maxArticles / 2) : maxArticles\n\n const opened = new Map<string, WikiArticle & { hop: number }>()\n let sharedOpened = 0\n let frontier: Array<{ path: string; hop: number }> = ordered.map((c) => ({ path: c.path, hop: 0 }))\n // Shared pages turned away by the cap, in walk order. When the agent's\n // own pages run out first they get the slots left: an own pick with no\n // own neighbours must not leave the walk short of shared pages that answer.\n const deferred: Array<{ path: string; hop: number }> = []\n\n while (opened.size < maxArticles) {\n if (!frontier.length) {\n if (!deferred.length || sharedCap >= maxArticles) break\n sharedCap = maxArticles\n frontier = deferred.splice(0)\n }\n const next = frontier.shift()!\n if (opened.has(next.path)) continue\n if (next.hop > maxHops) continue\n if (isShared(next.path) && sharedOpened >= sharedCap) { deferred.push(next); continue }\n\n const article = view.read(next.path)\n if (!article) continue\n\n opened.set(next.path, { ...article, hop: next.hop })\n if (isShared(next.path)) sharedOpened++\n if (next.hop >= maxHops) continue\n\n if (next.hop === 0) {\n // Pages link to a subject by any of its names; skip what is already\n // open before taking the newest few, or an opened page uses a slot.\n const names = [article.meta.title, ...(article.meta.aliases ?? [])].map((n) => n.toLowerCase())\n const linking = [...new Set(names.flatMap((n) => view.backlinks.get(n) ?? []))]\n .filter((path) => path !== next.path && !opened.has(path))\n .slice(0, BACKLINKS_PER_PICK)\n for (const path of linking) frontier.push({ path, hop: 1 })\n }\n for (const target of article.meta.related || []) {\n const path = titleIndex.get(target.toLowerCase())\n if (path && !opened.has(path)) {\n frontier.push({ path, hop: next.hop + 1 })\n }\n }\n }\n\n return Array.from(opened.values())\n}\n\n// --- Prompts ---\n\n/**\n * Pick candidates with the wiki-rerank seat instead of a Claude CLI call.\n *\n * The selector is 56% of a wiki query — 14.1s of a 25s total, measured —\n * and its whole job is \"pick 3 articles from this catalog\", which is a\n * Choice with per-option probabilities. Jev answers that in about a\n * second. Synthesis stays on Sonnet; it writes prose, which Jev cannot.\n *\n * BM25 shortlists first because the shared catalog carries 971 entries,\n * past the 255-option cap. Same two-stage shape as findRelevantReranked,\n * and it reuses that seat rather than introducing a second one.\n *\n * Returns null whenever the seat is off, errors, or has nothing to rank,\n * and the caller falls back to the CLI selector — so this is strictly an\n * accelerator, never a new way to fail.\n */\nasync function selectCandidatesViaSeat(\n question: string,\n pool: CatalogEntry[],\n requesterId: string | undefined,\n maxCandidates: number,\n messagePath?: string[],\n graphWeight: number = DEFAULT_GRAPH_WEIGHT,\n stage = \"catalog-selector\",\n): Promise<Array<{ title: string; path: string }> | null> {\n try {\n if (pool.length < 2) return null\n\n const shortlist = rankCatalogPool(question, pool, messagePath, graphWeight).slice(0, DEFAULT_SHORTLIST)\n\n const candidates: RerankCandidate[] = shortlist.map((i) => ({\n id: `k${i}`,\n title: pool[i].title || pool[i].path,\n tags: pool[i].tags,\n // The catalog has no body — a title, its type, its wikilinks and its\n // branch of the intent graph are what the selector chooses on.\n excerpt: [\n pool[i].type ? `type: ${pool[i].type}` : \"\",\n (pool[i].related ?? []).length ? `related: ${(pool[i].related ?? []).join(\", \")}` : \"\",\n (pool[i].graphPath ?? []).length ? `graph: ${(pool[i].graphPath ?? []).join(\" › \")}` : \"\",\n ].filter(Boolean).join(\" · \"),\n }))\n\n const result = await askSeat(\n WIKI_RERANK_SEAT,\n rerankState({ query: question, candidates, excerptChars: 300 }),\n rerankQuestions(candidates),\n { features: { agent: requesterId ?? \"unknown\", stage } },\n )\n if (!result || result.mode !== \"active\") return null\n\n const ranking = toRanking(result.answers as never, candidates)\n const picked = ranking.ranked\n .slice(0, maxCandidates)\n .map((id) => pool[Number(id.slice(1))])\n .filter(Boolean)\n .map((a) => ({ title: a.title, path: a.path }))\n return picked.length > 0 ? picked : null\n } catch {\n return null\n }\n}\n\n/** Weight of the intent-graph branch match against the text match when\n * shortlisting catalog candidates. Mirrors `graph.retrievalWeights.graph`. */\nexport const DEFAULT_GRAPH_WEIGHT = 0.6\n\n/**\n * Order the catalog pool for a question. Three bands, never mixed:\n *\n * 1. articles the text match scored, ordered by `text * (1 + w * branch)`\n * when the request was classified: the branch reorders text matches\n * but cannot lift an unrelated article above one;\n * 2. articles on the request's branch that the text never matched, by\n * how much of the path they share;\n * 3. the rest, in catalog order.\n *\n * Band 1 comes first in full because the shortlist the reranker sees is\n * finite (DEFAULT_SHORTLIST): a busy category holds more same-branch\n * articles than that, and a blended score let them push the article that\n * actually answers the question out of the list.\n *\n * Exported for tests; the seat and the CLI selector both consume the order.\n */\nexport function rankCatalogPool(\n question: string,\n pool: Array<{ title: string; tags?: string[]; related?: string[]; graphPath?: string[] }>,\n messagePath?: string[],\n graphWeight: number = DEFAULT_GRAPH_WEIGHT,\n): number[] {\n const bm25 = scoreAll(question, buildIndex(pool.map(catalogDoc)))\n const maxBm25 = bm25.reduce((m, r) => Math.max(m, r.score), 0)\n const text = new Map(bm25.map((r) => [r.docIndex, maxBm25 > 0 ? r.score / maxBm25 : 0]))\n const useGraph = !!messagePath?.length\n const branch = (a: { graphPath?: string[] }) =>\n useGraph && a.graphPath?.length ? ancestryScore(messagePath!, a.graphPath) : 0\n\n const byScore = (x: { i: number; score: number }, y: { i: number; score: number }) => y.score - x.score || x.i - y.i\n const matched = pool\n .map((a, i) => ({ i, score: (text.get(i) ?? 0) * (1 + graphWeight * branch(a)) }))\n .filter((c) => text.has(c.i))\n .sort(byScore)\n const branchOnly = pool\n .map((a, i) => ({ i, score: branch(a) }))\n .filter((c) => !text.has(c.i) && c.score > 0)\n .sort(byScore)\n const ranked = [...matched, ...branchOnly].map((c) => c.i)\n for (let i = 0; i < pool.length; i++) if (!ranked.includes(i)) ranked.push(i)\n return ranked\n}\n\n/** What BM25 sees of a catalog entry: the catalog carries no body. */\nfunction catalogDoc(a: { title: string; tags?: string[]; related?: string[] }): string {\n return [a.title, (a.tags ?? []).join(\" \"), (a.related ?? []).join(\" \")].join(\" \")\n}\n\nfunction buildSelectorPrompt(question: string, catalog: string, maxCandidates: number, messagePath?: string[]): string {\n const branch = messagePath?.length\n ? `\\n## Intent\\n\\nThe request was classified under the intent-graph path \"${messagePath.join(\" › \")}\". Prefer articles filed under the same branch when their titles are equally plausible.\\n`\n : \"\"\n return `You are picking candidate articles from a wiki catalog to answer a question. You do NOT answer the question. You pick which articles the answer is likely to come from.\n\n## Question\n\n${question}\n${branch}\n## Catalog (_index.md — articles grouped by type, with wikilink previews)\n\n${catalog}\n\n## Your task\n\nPick up to ${maxCandidates} articles from the catalog that are most likely to answer the question. Prefer:\n- Articles whose title directly names a subject in the question.\n- Articles of the right type (e.g. a \"who owns X\" question → person or project; a \"what happened on DATE\" → event).\n- Articles whose wikilinks suggest they sit at the center of a relevant subgraph.\n\nReturn ONLY valid JSON, no markdown fencing, no prose:\n\n[\n {\"title\": \"Exact Article Title\", \"path\": \"path/from/catalog.md\"},\n ...\n]\n\nIf none of the articles match, return [].`\n}\n\nfunction buildSynthesisPrompt(\n question: string,\n articles: Array<WikiArticle & { hop: number }>,\n): string {\n const articlesBlock = articles\n .map(a => {\n // Owner and date let the answer say where a fact came from and pick\n // the newer page when two disagree (#824).\n const from = [a.meta.owner ? `owner: ${a.meta.owner}` : \"\", a.meta.lastUpdated ? `updated: ${a.meta.lastUpdated}` : \"\"].filter(Boolean).join(\", \")\n const header = `### ${a.meta.title} — ${a.meta.type || \"untyped\"} (${a.path}) [hop ${a.hop}]${from ? ` {${from}}` : \"\"}`\n const related = a.meta.related?.length ? `Related: ${a.meta.related.join(\", \")}` : \"\"\n return [header, related, \"\", a.content].filter(Boolean).join(\"\\n\")\n })\n .join(\"\\n\\n---\\n\\n\")\n\n return `You are answering a question using a small subgraph of wiki articles. The articles were walked from the catalog; trust them over your prior knowledge.\n\n## Question\n\n${question}\n\n## Articles (${articles.length} walked from the catalog)\n\n${articlesBlock}\n\n## Your task\n\nAnswer the question in 2–6 sentences. Cite articles by their title in square brackets like [Article Title]. When two articles disagree, prefer the one updated more recently, and say which agent's page and date the answer comes from. If the articles do not answer the question, say so plainly (do not invent). Prefer concrete facts over hedging.\n\nOutput ONLY the answer — no preamble, no \"here is my answer:\", no markdown fencing.`\n}\n\nfunction parseCandidates(raw: string): Array<{ title: string; path: string }> {\n const match = raw.match(/\\[[\\s\\S]*?\\]/)\n if (!match) return []\n try {\n const parsed = JSON.parse(match[0])\n if (!Array.isArray(parsed)) return []\n return parsed\n .filter((x: any) => x && typeof x.title === \"string\" && typeof x.path === \"string\")\n .map((x: any) => ({ title: x.title, path: x.path }))\n } catch {\n return []\n }\n}\n\nasync function runClaude(prompt: string, model: string, timeoutMs: number): Promise<string> {\n // Use stdin via a temp-file pipe to avoid shell-escaping a huge prompt.\n // Prompts can exceed the `-E` arg buffer on macOS, so we always pipe.\n const { writeFileSync, mkdirSync, rmSync } = await import(\"fs\")\n const { tmpdir } = await import(\"os\")\n const dir = resolve(tmpdir(), `agentx-wiki-query-${process.pid}`)\n mkdirSync(dir, { recursive: true })\n const promptPath = resolve(dir, `prompt-${Date.now()}.txt`)\n writeFileSync(promptPath, prompt)\n try {\n const cmd = `cat '${promptPath}' | claude -p - --output-format json --max-turns 1 --model ${model} --disallowedTools \"Bash Read Write Edit Glob Grep Agent WebSearch WebFetch NotebookEdit\"`\n const raw = execSync(cmd, { env: claudeCliEnv(), encoding: \"utf-8\", timeout: timeoutMs, maxBuffer: 4 * 1024 * 1024 })\n try {\n const envelope = JSON.parse(raw)\n return String(envelope.result || envelope.content || \"\")\n } catch {\n return raw\n }\n } finally {\n try { rmSync(promptPath, { force: true }) } catch {}\n }\n}\n\n/** `wiki.query.shared` from agentx.json: whether a query also searches the\n * shared wiki. On when there is no config to read. The CLI and the\n * `agentx_wiki_query` tool both ask here, so the switch reaches both. */\nexport async function sharedQueryEnabled(configPath?: string): Promise<boolean> {\n try {\n const { loadDaemonConfig } = await import(\"@/daemon/config\")\n return loadDaemonConfig(configPath).wiki.query.shared\n } catch {\n return true\n }\n}\n"],"mappings":"8TAAA,OAAS,gBAAAA,GAAc,cAAAC,MAAkB,KAEzCC,KAWA,OAAS,WAAAC,MAAe,OACxB,OAAS,YAAAC,OAAgB,gBAsElB,IAAMC,GAAwB,GAIrC,SAASC,GAAgBC,EAAkBC,EAAiCC,EAAiBC,EAAwC,CACnI,GAAIA,EAAU,OAAS,EAAG,MAAO,GACjC,IAAIC,EAAQJ,EAAM,aAAaC,GAAe,EAAE,EAAE,IAAKI,GAAMA,EAAE,IAAI,EAAE,OAAQC,GAAM,CAACA,EAAE,SAAS,aAAa,CAAC,EAE7G,OADIF,EAAM,SAAW,IAAGA,EAAQF,EAAK,WAAW,IAAKK,GAAMA,EAAE,IAAI,GAC7DH,EAAM,SAAW,EAAU,EACxBA,EAAM,OAAQE,GAAMH,EAAU,IAAIG,CAAC,CAAC,EAAE,OAASF,EAAM,MAC9D,CA8CA,eAAsBI,GACpBC,EACAT,EACAC,EACAS,EAA4B,CAAC,EACA,CAC7B,IAAMC,EAAgBD,EAAK,eAAiB,QACtCE,EAAaF,EAAK,YAAc,SAChCG,EAAgBH,EAAK,eAAiB,EACtCI,EAAUJ,EAAK,SAAW,EAC1BK,EAAcL,EAAK,aAAe,EA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e,UAAAC,EAAW,OAAAC,CAAO,EAAI,KAAM,QAAO,IAAI,EACxD,CAAE,OAAAC,CAAO,EAAI,KAAM,QAAO,IAAI,EAC9BC,EAAMtH,EAAQqH,EAAO,EAAG,qBAAqB,QAAQ,KAAK,EAChEF,EAAUG,EAAK,CAAE,UAAW,EAAK,CAAC,EAClC,IAAMC,EAAavH,EAAQsH,EAAK,UAAU,KAAK,IAAI,OAAO,EAC1DJ,EAAcK,EAAYP,CAAM,EAChC,GAAI,CACF,IAAMQ,EAAM,QAAQD,+DAAwEN,6FACtFJ,EAAMY,GAASD,EAAK,CAAE,IAAKE,EAAa,EAAG,SAAU,QAAS,QAAShI,EAAW,UAAW,EAAI,KAAO,IAAK,CAAC,EACpH,GAAI,CACF,IAAMiI,EAAW,KAAK,MAAMd,CAAG,EAC/B,OAAO,OAAOc,EAAS,QAAUA,EAAS,SAAW,EAAE,CACzD,MAAE,CACA,OAAOd,CACT,CACF,QAAE,CACA,GAAI,CAAEO,EAAOG,EAAY,CAAE,MAAO,EAAK,CAAC,CAAE,MAAE,CAAO,CACrD,CACF,CAKA,eAAsBK,GAAmBC,EAAuC,CAC9E,GAAI,CACF,GAAM,CAAE,iBAAAC,CAAiB,EAAI,KAAM,QAAO,sBAAiB,EAC3D,OAAOA,EAAiBD,CAAU,EAAE,KAAK,MAAM,MACjD,MAAE,CACA,MAAO,EACT,CACF","names":["readFileSync","existsSync","init_seat","resolve","execSync","AUTO_SUMMARY_COVERAGE","summaryCoverage","store","requesterId","view","summaries","paths","a","p","e","agenticQuery","question","opts","selectorModel","synthModel","maxCandidates","maxHops","maxArticles","timeoutMs","log","messagePath","graphWeight","DEFAULT_GRAPH_WEIGHT","catalogPath","resolve","scopeView","method","collectSummaries","base","DEFAULT_SUMMARIES_QUERY","notes","notePool","out","summariesQuery","withNotes","claudeModelCall","pages","isNotePath","_","title","path","existsSync","emptyResult","catalog","readFileSync","renderSharedCatalog","selectorStart","candidates","selectorOutput","viaSeat","selectCandidatesViaSeat","c","runClaude","buildSelectorPrompt","parseCandidates","selectorMs","walked","walkSubgraph","synthStart","answer","buildSynthesisPrompt","w","synthesisMs","retrieveArticles","pool","catalogPool","matched","scoreAll","buildIndex","catalogDoc","r","rankCatalogPool","i","status","_question","error","shared","titleIndex","linking","article","sharedPool","byId","s","catalogEntry","key","backlinks","l","b","t","list","m","target","rel","forward","names","n","back","BACKLINKS_PER_PICK","x","SHARED_CATALOG_LINES","isShared","ordered","sharedCap","opened","sharedOpened","frontier","deferred","next","stage","DEFAULT_SHORTLIST","result","askSeat","WIKI_RERANK_SEAT","rerankState","rerankQuestions","picked","toRanking","id","bm25","maxBm25","text","useGraph","branch","ancestryScore","byScore","y","branchOnly","ranked","articles","articlesBlock","from","header","related","raw","match","parsed","prompt","model","writeFileSync","mkdirSync","rmSync","tmpdir","dir","promptPath","cmd","execSync","claudeCliEnv","envelope","sharedQueryEnabled","configPath","loadDaemonConfig"]}
|
package/dist/enrich-ZB5I7KHN.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import{a as N,k as A,l as O,m as Y}from"./chunk-BQIWMQNU.js";import{f as y}from"./chunk-QAWKN2N4.js";import{f as C,g as G}from"./chunk-JTDUTCUE.js";import"./chunk-IMLAPB7G.js";import{b as U}from"./chunk-KEXBEUSU.js";import"./chunk-RGZARSHV.js";import"./chunk-QIJLFPWE.js";import{createHash as L}from"crypto";import{existsSync as J,mkdirSync as V,readFileSync as B,writeFileSync as q}from"fs";import{resolve as x}from"path";var _="wiki-enrich",$e=["person","organization","project","place","device","server","app","domain","account"],K=new Set(["person","organization","project","place"]),z=3500,Q=700;function X(e,n){let i=e.ontology.types.find(r=>r.id===n)?.lens??[],t=new Map;for(let r of i)if(G(r)==="statements")for(let s of C(r)){if(s==="related"||t.has(s))continue;let l=e.ontology.properties.find(u=>u.id===s);l?.domain&&!l.domain.includes(n)||t.set(s,l?.label??s.replace(/_/g," "))}return t}function D(e,n,i){let t=y(n.title);return t.length<4?[]:[...e.entities.values()].filter(r=>r.type===i&&r.id!==n.id&&` ${y(r.title)} `.includes(` ${t} `))}function H(e){return e.access==="public"?null:new Set([e.owner,...e.access==="shared"?e.sharedWith??[]:[]])}function Z(e,n){let i=H(e);if(!i)return!0;let t=H(n);return!!t&&[...t].every(r=>i.has(r))}function ee(e,n,i,t){let r=o=>!t||Z(o.article.meta,t.article.meta),s=o=>o.pages.some(r),l=n.pages.filter(r),u=t?[...new Set(l.flatMap(o=>o.article.meta.sources??[]))]:n.sources,p=N(e,n,null).filter(s),f=o=>[...new Map(o.map(d=>[d.id,d])).values()],k=f([...p.filter(o=>o.type==="event"),...D(e,n,"event").filter(s)]).sort((o,d)=>(d.date||"").localeCompare(o.date||"")).slice(0,30),a=f([...p.filter(o=>o.type==="project"),...D(e,n,"project").filter(s)]).slice(0,12),g=p.filter(o=>o.type!=="event"&&o.type!=="project").filter(s).filter(o=>n.type!=="person"||K.has(o.type)).slice(0,40),v=i(u).sort((o,d)=>d.date.localeCompare(o.date)).slice(0,14),c=X(e,n.type),m=new Map;for(let o of c.keys()){let d=e.ontology.properties.find(h=>h.id===o)?.range;d?.length&&m.set(o,d)}return{entity:n,pages:l,properties:c,ranges:m,neighbours:g,events:k,projects:a,entries:v,sources:u,mentions:te(e,n,12,r)}}function te(e,n,i=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 s=r.map(p=>p.trim().replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),l=new RegExp(`(^|[^\\p{L}\\p{N}])(${s.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 k=A(f.article.content),a=l.exec(k);if(!a)continue;let g=Math.max(0,a.index-250);u.push({page:f,excerpt:k.slice(g,a.index+450).replace(/\s+/g," ").trim(),at:f.article.meta.lastUpdated||""});break}return u.sort((p,f)=>f.at.localeCompare(p.at)).slice(0,i).map(({page:p,excerpt:f})=>({page:p,excerpt:f}))}function ne(e){let n=[...e.pages.map(i=>`${i.agentId}/${i.article.path}`),...e.sources,...e.events.map(i=>i.id),...e.projects.map(i=>i.id),...e.mentions.map(i=>`${i.page.agentId}/${i.page.article.path}`)].sort();return L("sha1").update(n.join(`
|
|
2
|
-
`)).digest("hex").slice(0,16)}var R=(e,n)=>e.length>n?`${e.slice(0,n)}\u2026`:e;function se(e,n,i){let t=e.entity,r=[`You are bringing one wiki page up to date. Today is ${i}.`,`Subject: "${t.title}" (${n}).`,"","## What the agents' pages say"];for(let s of e.pages)r.push(`### page ${s.agentId}/${s.article.path} (updated ${s.article.meta.lastUpdated||"?"})`,R(A(s.article.content),z),"");if(e.mentions.length){r.push("## Other pages that name the subject");for(let s of e.mentions)r.push(`### page ${s.page.agentId}/${s.page.article.path}: "${s.page.article.meta.title}"`,s.excerpt,"")}r.push("## Source entries (newest first)");for(let s of e.entries)r.push(`### entry ${s.id} (${s.date}, ${s.agentId}, ${s.source})`,R(s.content.trim(),Q),"");return r.push("## Event pages",...e.events.map(s=>`- ${s.date||"?"} \xB7 ${s.title}`),""),r.push("## Project pages",...e.projects.map(s=>`- ${s.title}`),""),r.push("## Other pages it may name",...e.neighbours.map(s=>`- ${s.title} (${s.type})`),""),r.push(`## Properties you may use (the subject is always ${t.title})`,...[...e.properties].map(([s,l])=>`- ${s}: "${t.title} ${l} <value>"${e.ranges.get(s)?`, value is a ${e.ranges.get(s).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
|
-
`)}function ie(e){let n=e.match(/```(?:json)?\s*\n([\s\S]*?)\n```/),i=n?n[1]:e.slice(e.indexOf("{"),e.lastIndexOf("}")+1);try{let t=JSON.parse(i);return t&&typeof t=="object"&&!Array.isArray(t)?t:null}catch{return null}}var T=/^\d{4}-\d{2}(-\d{2})?$/,w=e=>typeof e=="string"?e.trim():"";function re(e,n,i){let t=[],r=n.entity,s=w(e.overview);if(s&&!/[.!?؟)»"']$/.test(s)){let a=Math.max(s.lastIndexOf(". "),s.lastIndexOf("? "),s.lastIndexOf("! "));s=a>0?s.slice(0,a+1):"",t.push("overview: unfinished last sentence removed")}let l=[...n.entries.map(a=>a.id),...n.pages.map(a=>`${a.agentId}/${a.article.path}`),...n.pages.map(a=>a.article.path),...n.mentions.map(a=>`${a.page.agentId}/${a.page.article.path}`),...n.mentions.map(a=>a.page.article.path),...n.events.map(a=>a.title)],u=[],p=new Set;for(let a of Array.isArray(e.statements)?e.statements:[]){let g=a??{},v=w(g.property),c=w(g.value),m=w(g.source),o=`${v} ${c}`;if(!n.properties.has(v)){t.push(`${o}: property not allowed`);continue}if(!c||/^(unknown|not (given|known|captured|recorded))\b/i.test(c)){t.push(`${o}: no value`);continue}if(!m||!l.some(E=>m.includes(E))){t.push(`${o}: source not among those given`);continue}let d=i.names.get(y(c)),h=d?i.entities.get(d):void 0;if(h?.id===r.id){t.push(`${o}: points at itself`);continue}if(r.type==="person"&&h?.type==="agent"){t.push(`${o}: an agent is not a person's relation`);continue}let S=n.ranges.get(v);if(S&&h&&!S.includes(h.type)){t.push(`${o}: value is a ${h.type}, expected ${S.join(" or ")}`);continue}let j=`${v}
|
|
4
|
-
${y(c)}`;if(p.has(j))continue;p.add(j);let $={property:v,value:h?.title??c,source:R(m,200)},W=w(g.role);W&&($.role=R(W,80)),T.test(w(g.since))&&($.since=w(g.since)),T.test(w(g.until))&&($.until=w(g.until)),u.push($)}let f=new Map([...n.events,...n.projects].map(a=>[y(a.title),a.title])),k=[];for(let a of[...Array.isArray(e.history)?e.history:[],...Array.isArray(e.projects)?e.projects:[]]){let g=f.get(y(w(a).replace(/^\d{4}-\d{2}-\d{2}\s*·\s*/,"")));g&&!k.includes(g)?k.push(g):!g&&w(a)&&t.push(`link ${w(a)}: no such page`)}return{overview:s,statements:u,links:k,dropped:t}}function oe(e,n){let i=`## Overview
|
|
5
|
-
|
|
6
|
-
${n.trim()}
|
|
7
|
-
|
|
8
|
-
${O}
|
|
9
|
-
`,t=Y(e);if(t){let r=e.slice(t.end,t.after)===O,s=/^#{1,2}[ \t]/m.test(e.slice(t.end,t.end+4)),u=(r||s&&A(e).length<=z?e.slice(t.after):e.slice(t.textStart)).trim();return`${e.slice(0,t.start)}${i}${u?`
|
|
10
|
-
${u}
|
|
11
|
-
`:""}`}return`${i}
|
|
12
|
-
${e.trim()}
|
|
13
|
-
`}function ae(e,n,i){let t=p=>`${p.property}
|
|
14
|
-
${y(p.value)}`,r=(e.statements??[]).filter(p=>p.by!==_),s=new Set(r.map(t)),l=[...r,...n.statements.filter(p=>!s.has(t(p))).map(p=>({...p,checked_at:i,by:_}))],u=[...new Set([...e.related??[],...n.links])];return{...e,statements:l.length?l:void 0,related:u.length?u:void 0,lastUpdated:i}}function ce(e,n){return n.pages.filter(i=>!e.syncedFrom(i.agentId)).sort((i,t)=>(t.article.meta.sources?.length??0)-(i.article.meta.sources?.length??0)||t.article.content.length-i.article.content.length)[0]}var pe={person:"people",organization:"organizations",project:"projects",place:"places"};function ke(e,n,i,t,r){let s=n.replace(/\s+/g," ").trim(),l=e.getAgentWiki(t);if(l.listAllArticles().some(k=>y(k.meta.title)===y(s)))return null;let u=`${pe[i]??`${i}s`}/${y(s).replace(/ /g,"-").slice(0,80)||"page"}.md`,p=U(i)?i:void 0,f={title:s,type:p,class:i,tags:[],owner:t,access:"shared",created:r,lastUpdated:r,sources:[]};return l.writeArticle(u,f,`${s}.
|
|
15
|
-
`,t)?u:null}function Ee(e){let n=x(e,"_enrich","state.json");if(!J(n))return{entities:{}};try{let i=JSON.parse(B(n,"utf-8"));return i&&typeof i.entities=="object"?i:{entities:{}}}catch{return{entities:{}}}}function we(e,n){V(x(e,"_enrich"),{recursive:!0}),q(x(e,"_enrich","state.json"),JSON.stringify(n,null,2))}async function be(e,n,i,t,r){let s=new Set(t.types),l=new Set(t.only.map(y)),u=c=>c.sources.length+c.pages.length,p=c=>r.entities[c.id]?.failures??0,f=[...n.entities.values()].filter(c=>s.has(c.type)).filter(c=>l.size===0||l.has(y(c.id))||l.has(y(c.title))).sort((c,m)=>p(c)-p(m)||u(m)-u(c)),k=c=>e.getSharedStore().readEntries(c),a={outcomes:[],costUsd:0,capped:!1},g=0,v=(c,m,o,d=!1)=>{if(t.dryRun)return;let h=r.entities[c];r.entities[c]=d?{fingerprint:h?.fingerprint??"",at:new Date().toISOString(),costUsd:o,failures:(h?.failures??0)+1}:{fingerprint:m,at:new Date().toISOString(),costUsd:o},t.save?.(r)};for(let c of f){if(g>=t.max)break;let m={entity:c.id,title:c.title,statements:0,links:0,overview:!1,costUsd:0,dropped:[]},o=ce(e,c);if(!o){a.outcomes.push({...m,status:"no-page"});continue}let d=ee(n,c,k,o),h=ne(d);if(!t.force&&r.entities[c.id]?.fingerprint===h){l.size&&a.outcomes.push({...m,status:"unchanged"});continue}if(a.costUsd>=t.maxCostUsd){a.capped=!0;break}g++;let S=n.ontology.types.find(I=>I.id===c.type)?.label??c.type,j=`${o.agentId}/${o.article.path}`,$;try{$=await i(se(d,S,t.today))}catch(I){a.outcomes.push({...m,page:j,status:"failed",dropped:[I.message.slice(0,200)]}),v(c.id,h,0,!0);continue}a.costUsd+=$.costUsd;let W=ie($.text),E={...m,page:j,status:"no-reply",costUsd:$.costUsd};if(!W){a.outcomes.push(E),v(c.id,h,$.costUsd);continue}let b=re(W,d,n);if(Object.assign(E,{statements:b.statements.length,links:b.links.length,overview:!!b.overview,dropped:b.dropped}),!b.overview&&b.statements.length===0&&b.links.length===0){E.status="nothing-new",a.outcomes.push(E),v(c.id,h,$.costUsd);continue}let M=b.overview?oe(o.article.content,b.overview):o.article.content,F=ae(o.article.meta,b,t.today);if(t.dryRun){a.outcomes.push({...E,status:"dry-run",preview:M,facts:b.statements});continue}let P=e.getAgentWiki(o.agentId);if(!P.writeArticle(o.article.path,F,M,o.article.meta.owner||o.agentId)){E.status="failed",E.dropped.push("write refused"),a.outcomes.push(E),v(c.id,h,$.costUsd,!0);continue}P.rebuildIndex(),v(c.id,h,$.costUsd),E.status="written",a.outcomes.push(E)}return a}export{_ as ENRICH_BY,$e as ENRICH_TYPES,se as buildEnrichPrompt,re as checkEnrichment,ke as createEntityPage,ee as enrichContext,ne as fingerprint,X as lensProperties,Ee as loadEnrichState,te as mentionsOf,ae as mergedMeta,ie as parseEnrichReply,Z as readableAlongside,be as runEnrich,we as saveEnrichState,ce as targetPage,oe as withOverview};
|
|
16
|
-
//# sourceMappingURL=enrich-ZB5I7KHN.js.map
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{a as w,k as I}from"./chunk-BQIWMQNU.js";import{f as g}from"./chunk-QAWKN2N4.js";import"./chunk-JTDUTCUE.js";import"./chunk-IMLAPB7G.js";import{a as b}from"./chunk-RGZARSHV.js";import"./chunk-QIJLFPWE.js";var y="wiki-events",E="importance_set",A=new Set(["event","due_date","topic"]),$=10,W=320;function P(n,t,a){let o=new Set(a.map(r=>r.toLowerCase()));for(let r of n??[])if(!(!b.includes(r.level)||!r.title&&!r.tags?.length)){if(r.title){let c;try{c=new RegExp(r.title,"i")}catch{continue}if(!c.test(t))continue}if(!(r.tags?.length&&!r.tags.some(c=>o.has(c.toLowerCase()))))return r.level}}function x(n,t){let a=` ${g(t)} `,o=[];for(let r of n.entities.values()){if(A.has(r.type))continue;let c=g(r.title);c.length>=4&&a.includes(` ${c} `)&&o.push(r)}return o}function M(n,t){let a=w(n,t,null).filter(r=>!A.has(r.type)),o=x(n,t.title);return[...new Map([...o,...a].map(r=>[r.id,r])).values()].slice(0,$)}function R(n,t){return t.pages.find(a=>!n.syncedFrom(a.agentId))}function j(n){return n.pages.some(t=>t.article.meta.importance&&!(t.article.meta.statements??[]).some(a=>a.by===y&&a.property===E))}function _(n,t,a){let o=new Set;for(let i of a.about){let l=t.names.get(g(i))??(t.entities.has(i)?i:void 0);l&&o.add(l)}let r=[],c=[],s=[...t.entities.values()].filter(i=>i.type==="event").sort((i,l)=>(l.date||"").localeCompare(i.date||""));for(let i of s){if(i.pages.some(e=>e.article.meta.importance)&&(!a.force||j(i)))continue;let f=M(t,i);if(a.about.length&&!f.some(e=>o.has(e.id)))continue;let m=R(n,i);if(!m){c.push(i);continue}r.push({event:i,page:m,candidates:f})}return{items:r,noPage:c}}var S=(n,t)=>n.length>t?`${n.slice(0,t)}\u2026`:n;function L(n,t){let a=["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 n.forEach((o,r)=>{let c=S(I(o.page.article.content).replace(/\s+/g," ").trim(),W);a.push(`### ${r+1}. ${o.event.title} (${o.event.date||"no date"})`,c||"(no text)"),a.push(o.candidates.length?`May be about: ${o.candidates.map(s=>`"${s.title}" (${s.type})`).join(", ")}`:"May be about: nothing listed","")}),a.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 ${b.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.",...t.importance.major_set_by==="owner"?["- major is only a suggestion here: the owner confirms it."]:[]),a.join(`
|
|
2
|
-
`)}function C(n){let t=n.match(/```(?:json)?\s*\n([\s\S]*?)\n```/),a=t?t[1]:n.slice(n.indexOf("{"),n.lastIndexOf("}")+1);try{let o=JSON.parse(a);return o&&typeof o=="object"&&!Array.isArray(o)?o:null}catch{return null}}function O(n,t){return n==="major"&&t.importance.major_set_by==="owner"?{importance:"normal",proposed:"major"}:{importance:n}}function U(n,t,a){let o=new Map,r=C(n);for(let c of Array.isArray(r?.events)?r.events:[]){let s=c??{},i=Number(s.n)-1,l=t[i];if(!Number.isInteger(i)||!l||o.has(i))continue;let f=String(s.importance??"").trim().toLowerCase();if(!b.includes(f))continue;let m=[],e=new Map(l.candidates.map(d=>[g(d.title),d.title])),p=[];for(let d of Array.isArray(s.about)?s.about:[]){let u=e.get(g(String(d??"")));u&&!p.includes(u)?p.push(u):!u&&String(d??"").trim()&&m.push(`about ${String(d).trim().slice(0,80)}: not in the list shown`)}p.length>3&&m.push(`about: kept the first 3 of ${p.length}`);let h=typeof s.why=="string"?S(s.why.trim(),160):void 0;o.set(i,{verdict:{...O(f,a),about:p.slice(0,3),why:h||void 0,by:"model"},dropped:m})}return o}function G(n,t,a){let o=(n.statements??[]).filter(s=>s.by!==y),r=new Set(o.filter(s=>s.property==="involves").map(s=>g(s.value))),c=t.about.filter(s=>!r.has(g(s))).map(s=>({property:"involves",value:s,checked_at:a,by:y}));return c.push({property:E,value:t.proposed??t.importance,checked_at:a,by:y,...t.why?{note:t.why}:{}}),{...n,importance:t.importance,importanceProposed:t.proposed,statements:[...o,...c],lastUpdated:a}}async function B(n,t,a,o){let r=t.ontology,{items:c,noPage:s}=_(n,t,o),i=c.slice(0,o.max),l={outcomes:[],costUsd:0,calls:0,capped:!1,left:c.length-i.length};for(let e of o.about.length?s:[])l.outcomes.push({event:e.id,title:e.title,date:e.date,status:"no-page",about:[],dropped:["its pages are copied from another node"]});let f=(e,p,h)=>{let d=`${e.page.agentId}/${e.page.article.path}`,u={event:e.event.id,title:e.event.title,date:e.event.date,page:d,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(u);return}let k=n.getAgentWiki(e.page.agentId).writeArticle(e.page.article.path,G(e.page.article.meta,p,o.today),e.page.article.content,e.page.article.meta.owner||e.page.agentId);l.outcomes.push({...u,status:k?"written":"failed",dropped:k?h:[...h,"write refused"]})},m=[];for(let e of i){let p=P(r.importance.rules,e.event.title,e.page.article.meta.tags??[]);if(!p){m.push(e);continue}let h=new Set(x(t,e.event.title).map(u=>u.id)),d=e.candidates.filter(u=>h.has(u.id)).slice(0,3).map(u=>u.title);f(e,{...O(p,r),about:d,why:"matched an importance rule",by:"rule"},[])}if(o.rulesOnly)return l.left+=m.length,l;for(let e=0;e<m.length;e+=o.batch){let p=m.slice(e,e+o.batch);if(l.costUsd>=o.maxCostUsd){l.capped=!0,l.left+=m.length-e;break}l.calls++;let h;try{let d=await a(L(p,r));l.costUsd+=d.costUsd,h=U(d.text,p,r)}catch(d){for(let u of p)l.outcomes.push({event:u.event.id,title:u.event.title,date:u.event.date,page:`${u.page.agentId}/${u.page.article.path}`,status:"failed",about:[],dropped:[d.message.slice(0,200)]});continue}p.forEach((d,u)=>{let v=h.get(u);v?f(d,v.verdict,v.dropped):l.outcomes.push({event:d.event.id,title:d.event.title,date:d.event.date,page:`${d.page.agentId}/${d.page.article.path}`,status:"no-answer",about:[],dropped:["the reply had no usable item for this event"]})})}if(!o.dryRun)for(let e of new Set(l.outcomes.filter(p=>p.status==="written").map(p=>p.page.split("/")[0])))n.getAgentWiki(e).rebuildIndex();return l}function D(n,t,a,o,r){let c=t.names.get(g(a))??(t.entities.has(a)?a:void 0),s=c?t.entities.get(c):void 0;if(!s)return{ok:!1,reason:`no page is titled "${a}"`};if(s.type!=="event")return{ok:!1,title:s.title,reason:`"${s.title}" is a ${s.type}, not an event`};let i=R(n,s);if(!i)return{ok:!1,title:s.title,reason:"its pages are copied from another node; set the level there"};let l=(i.article.meta.statements??[]).filter(p=>!(p.by===y&&p.property===E)),f={...i.article.meta,importance:o,importanceProposed:void 0,statements:l.length?l:void 0,lastUpdated:r},m=n.getAgentWiki(i.agentId),e=m.writeArticle(i.article.path,f,i.article.content,i.article.meta.owner||i.agentId);return e&&m.rebuildIndex(),{ok:e,title:s.title,page:`${i.agentId}/${i.article.path}`,reason:e?void 0:"write refused"}}function F(n,t,a){let o=[],r=new Map(t.outcomes.filter(c=>c.importance).map(c=>[c.event,c]));for(let c of a){let s=n.names.get(g(c))??(n.entities.has(c)?c:void 0),i=s?n.entities.get(s):void 0;if(!i)continue;let l=new Set(w(n,i,new Set(["event"])).map(e=>e.id)),f={minor:0,normal:0,major:0},m=new Set;for(let e of n.entities.values()){if(e.type!=="event")continue;let p=r.get(e.id);!(l.has(e.id)||p?.about.some(d=>g(d)===g(i.title)))||m.has(e.id)||(m.add(e.id),f[p?.importance??e.importance]++)}o.push({title:i.title,type:i.type,before:l.size,after:f})}return o}export{y as EVENTS_BY,L as buildEventsPrompt,U as checkEventsReply,M as eventCandidates,G as eventMeta,_ as pickEvents,P as ruleLevel,B as runEvents,D as setEventLevel,F as summariseAbout};
|
|
3
|
-
//# sourceMappingURL=event-levels-CQWHSLMT.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/wiki/event-levels.ts"],"sourcesContent":["// --- Give each event an importance level and the pages it is about (#811) ---\n//\n// Event pages are half the wiki, and until a level is set they all show\n// as `normal` beside decisions and client events. This pass reads the\n// event pages (never the raw entries) and writes, per event:\n// - `importance`: minor, normal or major;\n// - `involves` statements: the people, organisations, assets or\n// projects the event is about, so it shows in their History.\n// The ontology's `importance.rules` decide first, for free. What they\n// leave is sent to a model in batches. Each answer is checked against\n// what the call was shown before a page is written through the store,\n// which keeps the old version. Where only the owner may set `major`, a\n// suggested `major` is stored as a proposal and the event stays `normal`.\n\nimport type { WikiHub } from \"./hub\"\nimport type { WikiArticleMeta } from \"./types\"\nimport { normName, type Entity, type GraphPage, type WikiGraph } from \"./ontology/graph\"\nimport { linkedEntities } from \"./ontology/lens\"\nimport { IMPORTANCE_LEVELS, type Importance, type ImportanceRule, type Ontology, type WikiStatement } from \"./ontology/types\"\nimport { bodyOf } from \"./ontology/view-entity\"\n\nexport const EVENTS_BY = \"wiki-events\"\n/** Statement that records this job set the level; the owner's `set` removes it. */\nconst LEVEL_MARK = \"importance_set\"\n\n/** Types an event can be about. Events, due dates and topics are not. */\nconst ABOUT_SKIP = new Set([\"event\", \"due_date\", \"topic\"])\nconst MAX_CANDIDATES = 10\nconst BODY_CHARS = 320\n\nexport interface EventItem {\n event: Entity\n /** The page the result is written to: one this node owns. */\n page: GraphPage\n /** Entities the event may be about: linked to it, or named in its title. */\n candidates: Entity[]\n}\n\nexport interface EventVerdict {\n importance: Importance\n /** Set when `major` was suggested but only the owner may set it. */\n proposed?: Importance\n /** Titles of the candidates the event is about. */\n about: string[]\n why?: string\n by: \"rule\" | \"model\"\n}\n\nexport interface EventOutcome {\n event: string\n title: string\n date: string\n page?: string\n status: \"written\" | \"dry-run\" | \"no-page\" | \"no-answer\" | \"failed\"\n importance?: Importance\n proposed?: Importance\n about: string[]\n by?: \"rule\" | \"model\"\n why?: string\n dropped: string[]\n}\n\nexport interface EventsRun {\n outcomes: EventOutcome[]\n costUsd: number\n calls: number\n /** Set when the run stopped at its spending cap. */\n capped: boolean\n /** Events without a level that this run did not reach. */\n left: number\n}\n\nexport interface EventsCall {\n (prompt: string): Promise<{ text: string; costUsd: number }>\n}\n\nexport interface EventsOptions {\n /** Entity ids or titles: only events linked to or naming them. */\n about: string[]\n /** Most events per run. */\n max: number\n /** Events per model call. */\n batch: number\n maxCostUsd: number\n dryRun: boolean\n /** Redo events that already have a level set by this job. */\n force: boolean\n /** Skip the model: only the ontology's rules decide. */\n rulesOnly: boolean\n today: string\n}\n\n/** The first rule that matches the event, if any. */\nexport function ruleLevel(rules: ImportanceRule[] | undefined, title: string, tags: string[]): Importance | undefined {\n const have = new Set(tags.map(t => t.toLowerCase()))\n for (const r of rules ?? []) {\n if (!IMPORTANCE_LEVELS.includes(r.level) || (!r.title && !r.tags?.length)) continue\n if (r.title) {\n let re: RegExp\n try { re = new RegExp(r.title, \"i\") } catch { continue } // reported by checkOntology\n if (!re.test(title)) continue\n }\n if (r.tags?.length && !r.tags.some(t => have.has(t.toLowerCase()))) continue\n return r.level\n }\n return undefined\n}\n\n/** Entities whose name appears as whole words in `text`. */\nfunction namedEntities(g: WikiGraph, text: string): Entity[] {\n const hay = ` ${normName(text)} `\n const out: Entity[] = []\n for (const e of g.entities.values()) {\n if (ABOUT_SKIP.has(e.type)) continue\n const name = normName(e.title)\n if (name.length >= 4 && hay.includes(` ${name} `)) out.push(e)\n }\n return out\n}\n\n/** What the event may be about: pages it links to or that link to it,\n * then pages its title names. Linked ones first. */\nexport function eventCandidates(g: WikiGraph, ev: Entity): Entity[] {\n const linked = linkedEntities(g, ev, null).filter(x => !ABOUT_SKIP.has(x.type))\n const named = namedEntities(g, ev.title)\n return [...new Map([...named, ...linked].map(x => [x.id, x])).values()].slice(0, MAX_CANDIDATES)\n}\n\nfunction localPage(hub: Pick<WikiHub, \"syncedFrom\">, e: Entity): GraphPage | undefined {\n return e.pages.find(p => !hub.syncedFrom(p.agentId))\n}\n\n/** True when the level on the event was set by a person or another job. */\nfunction setByOthers(ev: Entity): boolean {\n return ev.pages.some(p => p.article.meta.importance && !(p.article.meta.statements ?? []).some(s => s.by === EVENTS_BY && s.property === LEVEL_MARK))\n}\n\n/** Events this run should look at, newest first. */\nexport function pickEvents(hub: Pick<WikiHub, \"syncedFrom\">, g: WikiGraph, opts: Pick<EventsOptions, \"about\" | \"force\">): { items: EventItem[]; noPage: Entity[] } {\n const scope = new Set<string>()\n for (const name of opts.about) {\n const id = g.names.get(normName(name)) ?? (g.entities.has(name) ? name : undefined)\n if (id) scope.add(id)\n }\n const items: EventItem[] = []\n const noPage: Entity[] = []\n const events = [...g.entities.values()].filter(e => e.type === \"event\").sort((a, b) => (b.date || \"\").localeCompare(a.date || \"\"))\n for (const ev of events) {\n const hasLevel = ev.pages.some(p => p.article.meta.importance)\n // A level a person set is never redone; --force redoes only this job's.\n if (hasLevel && (!opts.force || setByOthers(ev))) continue\n const candidates = eventCandidates(g, ev)\n if (opts.about.length && !candidates.some(c => scope.has(c.id))) continue\n const page = localPage(hub, ev)\n if (!page) { noPage.push(ev); continue }\n items.push({ event: ev, page, candidates })\n }\n return { items, noPage }\n}\n\nconst clip = (s: string, n: number) => (s.length > n ? `${s.slice(0, n)}…` : s)\n\nexport function buildEventsPrompt(items: EventItem[], o: Ontology): string {\n const lines: string[] = [\n \"You are sorting the event pages of a company wiki by importance, and saying what each event is about.\",\n \"\",\n \"Levels:\",\n \"- 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).\",\n \"- 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).\",\n \"- 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).\",\n \"When unsure between two levels, pick the lower one.\",\n \"\",\n \"## Events\",\n ]\n items.forEach((it, i) => {\n const body = clip(bodyOf(it.page.article.content).replace(/\\s+/g, \" \").trim(), BODY_CHARS)\n lines.push(`### ${i + 1}. ${it.event.title} (${it.event.date || \"no date\"})`, body || \"(no text)\")\n lines.push(it.candidates.length ? `May be about: ${it.candidates.map(c => `\"${c.title}\" (${c.type})`).join(\", \")}` : \"May be about: nothing listed\", \"\")\n })\n lines.push(\n \"## Task\",\n \"Return one JSON object and nothing else:\",\n `{\"events\": [{\"n\": 1, \"importance\": \"minor\", \"about\": [\"Exact Title\"], \"why\": \"one short reason\"}]}`,\n \"\",\n \"Rules:\",\n `- One item per event, with its number. importance is one of ${IMPORTANCE_LEVELS.join(\", \")}.`,\n \"- 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.\",\n \"- why: under 15 words, in English.\",\n ...(o.importance.major_set_by === \"owner\" ? [\"- major is only a suggestion here: the owner confirms it.\"] : []),\n )\n return lines.join(\"\\n\")\n}\n\n/** The JSON object in the reply, fenced or not. */\nfunction parseReply(text: string): Record<string, unknown> | null {\n const fenced = text.match(/```(?:json)?\\s*\\n([\\s\\S]*?)\\n```/)\n const raw = fenced ? fenced[1] : text.slice(text.indexOf(\"{\"), text.lastIndexOf(\"}\") + 1)\n try {\n const v = JSON.parse(raw)\n return v && typeof v === \"object\" && !Array.isArray(v) ? v as Record<string, unknown> : null\n } catch {\n return null\n }\n}\n\n/** Keep `major` for the owner where the ontology says so. */\nfunction withOwnerRule(level: Importance, o: Ontology): Pick<EventVerdict, \"importance\" | \"proposed\"> {\n if (level === \"major\" && o.importance.major_set_by === \"owner\") return { importance: \"normal\", proposed: \"major\" }\n return { importance: level }\n}\n\n/** Per-event verdicts from one reply, keeping only what the call was shown. */\nexport function checkEventsReply(text: string, items: EventItem[], o: Ontology): Map<number, { verdict: EventVerdict; dropped: string[] }> {\n const out = new Map<number, { verdict: EventVerdict; dropped: string[] }>()\n const parsed = parseReply(text)\n for (const raw of Array.isArray(parsed?.events) ? parsed!.events as unknown[] : []) {\n const r = (raw ?? {}) as Record<string, unknown>\n const at = Number(r.n) - 1\n const it = items[at]\n if (!Number.isInteger(at) || !it || out.has(at)) continue\n const level = String(r.importance ?? \"\").trim().toLowerCase() as Importance\n if (!IMPORTANCE_LEVELS.includes(level)) continue\n const dropped: string[] = []\n const allowed = new Map(it.candidates.map(c => [normName(c.title), c.title]))\n const about: string[] = []\n for (const t of Array.isArray(r.about) ? r.about : []) {\n const title = allowed.get(normName(String(t ?? \"\")))\n if (title && !about.includes(title)) about.push(title)\n else if (!title && String(t ?? \"\").trim()) dropped.push(`about ${String(t).trim().slice(0, 80)}: not in the list shown`)\n }\n if (about.length > 3) dropped.push(`about: kept the first 3 of ${about.length}`)\n const why = typeof r.why === \"string\" ? clip(r.why.trim(), 160) : undefined\n out.set(at, { verdict: { ...withOwnerRule(level, o), about: about.slice(0, 3), why: why || undefined, by: \"model\" }, dropped })\n }\n return out\n}\n\n/** Page meta with the level and this job's `involves` facts replaced. */\nexport function eventMeta(meta: WikiArticleMeta, v: EventVerdict, today: string): WikiArticleMeta {\n const kept = (meta.statements ?? []).filter(s => s.by !== EVENTS_BY)\n const taken = new Set(kept.filter(s => s.property === \"involves\").map(s => normName(s.value)))\n const added: WikiStatement[] = v.about\n .filter(t => !taken.has(normName(t)))\n .map(t => ({ property: \"involves\", value: t, checked_at: today, by: EVENTS_BY }))\n // The marker records that this job set the level, so --force may redo it.\n added.push({ property: LEVEL_MARK, value: v.proposed ?? v.importance, checked_at: today, by: EVENTS_BY, ...(v.why ? { note: v.why } : {}) })\n return { ...meta, importance: v.importance, importanceProposed: v.proposed, statements: [...kept, ...added], lastUpdated: today }\n}\n\nexport async function runEvents(hub: WikiHub, g: WikiGraph, call: EventsCall, opts: EventsOptions): Promise<EventsRun> {\n const o = g.ontology\n const { items: all, noPage } = pickEvents(hub, g, opts)\n const items = all.slice(0, opts.max)\n const run: EventsRun = { outcomes: [], costUsd: 0, calls: 0, capped: false, left: all.length - items.length }\n for (const ev of opts.about.length ? noPage : []) {\n run.outcomes.push({ event: ev.id, title: ev.title, date: ev.date, status: \"no-page\", about: [], dropped: [\"its pages are copied from another node\"] })\n }\n\n const write = (it: EventItem, v: EventVerdict, dropped: string[]): void => {\n const where = `${it.page.agentId}/${it.page.article.path}`\n const base: EventOutcome = { event: it.event.id, title: it.event.title, date: it.event.date, page: where, status: \"dry-run\", importance: v.importance, proposed: v.proposed, about: v.about, by: v.by, why: v.why, dropped }\n if (opts.dryRun) { run.outcomes.push(base); return }\n const store = hub.getAgentWiki(it.page.agentId)\n const ok = store.writeArticle(it.page.article.path, eventMeta(it.page.article.meta, v, opts.today), it.page.article.content, it.page.article.meta.owner || it.page.agentId)\n run.outcomes.push({ ...base, status: ok ? \"written\" : \"failed\", dropped: ok ? dropped : [...dropped, \"write refused\"] })\n }\n\n // Rules first: free, and the same answer every run.\n const forModel: EventItem[] = []\n for (const it of items) {\n const level = ruleLevel(o.importance.rules, it.event.title, it.page.article.meta.tags ?? [])\n if (!level) { forModel.push(it); continue }\n // A rule gives the level only; what the title names is what it is about.\n const named = new Set(namedEntities(g, it.event.title).map(e => e.id))\n const about = it.candidates.filter(c => named.has(c.id)).slice(0, 3).map(c => c.title)\n write(it, { ...withOwnerRule(level, o), about, why: \"matched an importance rule\", by: \"rule\" }, [])\n }\n if (opts.rulesOnly) {\n run.left += forModel.length\n return run\n }\n\n for (let i = 0; i < forModel.length; i += opts.batch) {\n const batch = forModel.slice(i, i + opts.batch)\n if (run.costUsd >= opts.maxCostUsd) {\n run.capped = true\n run.left += forModel.length - i\n break\n }\n run.calls++\n let verdicts: ReturnType<typeof checkEventsReply>\n try {\n const reply = await call(buildEventsPrompt(batch, o))\n run.costUsd += reply.costUsd\n verdicts = checkEventsReply(reply.text, batch, o)\n } catch (err) {\n for (const it of batch) {\n run.outcomes.push({ event: it.event.id, title: it.event.title, date: it.event.date, page: `${it.page.agentId}/${it.page.article.path}`, status: \"failed\", about: [], dropped: [(err as Error).message.slice(0, 200)] })\n }\n continue\n }\n batch.forEach((it, at) => {\n const v = verdicts.get(at)\n if (v) write(it, v.verdict, v.dropped)\n else run.outcomes.push({ event: it.event.id, title: it.event.title, date: it.event.date, page: `${it.page.agentId}/${it.page.article.path}`, status: \"no-answer\", about: [], dropped: [\"the reply had no usable item for this event\"] })\n })\n }\n if (!opts.dryRun) {\n for (const agentId of new Set(run.outcomes.filter(x => x.status === \"written\").map(x => x.page!.split(\"/\")[0]))) {\n hub.getAgentWiki(agentId).rebuildIndex()\n }\n }\n return run\n}\n\n/** The owner's own word: set a level on an event and clear any proposal. */\nexport function setEventLevel(hub: WikiHub, g: WikiGraph, name: string, level: Importance, today: string): { ok: boolean; title?: string; page?: string; reason?: string } {\n const id = g.names.get(normName(name)) ?? (g.entities.has(name) ? name : undefined)\n const ev = id ? g.entities.get(id) : undefined\n if (!ev) return { ok: false, reason: `no page is titled \"${name}\"` }\n if (ev.type !== \"event\") return { ok: false, title: ev.title, reason: `\"${ev.title}\" is a ${ev.type}, not an event` }\n const page = localPage(hub, ev)\n if (!page) return { ok: false, title: ev.title, reason: \"its pages are copied from another node; set the level there\" }\n // Dropping this job's marker makes the level the owner's: no run redoes it.\n const statements = (page.article.meta.statements ?? []).filter(s => !(s.by === EVENTS_BY && s.property === LEVEL_MARK))\n const meta: WikiArticleMeta = { ...page.article.meta, importance: level, importanceProposed: undefined, statements: statements.length ? statements : undefined, lastUpdated: today }\n const store = hub.getAgentWiki(page.agentId)\n const ok = store.writeArticle(page.article.path, meta, page.article.content, page.article.meta.owner || page.agentId)\n if (ok) store.rebuildIndex()\n return { ok, title: ev.title, page: `${page.agentId}/${page.article.path}`, reason: ok ? undefined : \"write refused\" }\n}\n\nexport interface AboutSummary {\n title: string\n type: string\n /** Events in its History before this run, and how they split after. */\n before: number\n after: Record<Importance, number>\n}\n\n/** For a pilot: what each named page's History looks like after the run. */\nexport function summariseAbout(g: WikiGraph, run: EventsRun, about: string[]): AboutSummary[] {\n const out: AboutSummary[] = []\n const byEvent = new Map(run.outcomes.filter(x => x.importance).map(x => [x.event, x]))\n for (const name of about) {\n const id = g.names.get(normName(name)) ?? (g.entities.has(name) ? name : undefined)\n const e = id ? g.entities.get(id) : undefined\n if (!e) continue\n const linkedBefore = new Set(linkedEntities(g, e, new Set([\"event\"])).map(x => x.id))\n const after: Record<Importance, number> = { minor: 0, normal: 0, major: 0 }\n const seen = new Set<string>()\n for (const ev of g.entities.values()) {\n if (ev.type !== \"event\") continue\n const o = byEvent.get(ev.id)\n const linkedAfter = linkedBefore.has(ev.id) || !!o?.about.some(t => normName(t) === normName(e.title))\n if (!linkedAfter || seen.has(ev.id)) continue\n seen.add(ev.id)\n after[o?.importance ?? ev.importance]++\n }\n out.push({ title: e.title, type: e.type, before: linkedBefore.size, after })\n }\n return out\n}\n"],"mappings":"mNAqBO,IAAMA,EAAY,cAEnBC,EAAa,iBAGbC,EAAa,IAAI,IAAI,CAAC,QAAS,WAAY,OAAO,CAAC,EACnDC,EAAiB,GACjBC,EAAa,IAiEZ,SAASC,EAAUC,EAAqCC,EAAeC,EAAwC,CACpH,IAAMC,EAAO,IAAI,IAAID,EAAK,IAAIE,GAAKA,EAAE,YAAY,CAAC,CAAC,EACnD,QAAW,KAAKJ,GAAS,CAAC,EACxB,GAAI,GAACK,EAAkB,SAAS,EAAE,KAAK,GAAM,CAAC,EAAE,OAAS,CAAC,EAAE,MAAM,QAClE,IAAI,EAAE,MAAO,CACX,IAAIC,EACJ,GAAI,CAAEA,EAAK,IAAI,OAAO,EAAE,MAAO,GAAG,CAAE,MAAE,CAAQ,QAAS,CACvD,GAAI,CAACA,EAAG,KAAKL,CAAK,EAAG,SAEvB,GAAI,IAAE,MAAM,QAAU,CAAC,EAAE,KAAK,KAAKG,GAAKD,EAAK,IAAIC,EAAE,YAAY,CAAC,CAAC,GACjE,OAAO,EAAE,MAGb,CAGA,SAASG,EAAcC,EAAcC,EAAwB,CAC3D,IAAMC,EAAM,IAAIC,EAASF,CAAI,KACvBG,EAAgB,CAAC,EACvB,QAAWC,KAAKL,EAAE,SAAS,OAAO,EAAG,CACnC,GAAIZ,EAAW,IAAIiB,EAAE,IAAI,EAAG,SAC5B,IAAMC,EAAOH,EAASE,EAAE,KAAK,EACzBC,EAAK,QAAU,GAAKJ,EAAI,SAAS,IAAII,IAAO,GAAGF,EAAI,KAAKC,CAAC,EAE/D,OAAOD,CACT,CA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rB,EAAE,SAAS,IAAIqB,CAAE,EAAI,OACpC,GAAI,CAAChB,EAAG,SACR,IAAMyE,EAAe,IAAI,IAAIpE,EAAeV,EAAGK,EAAG,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC,EAAE,IAAIM,GAAKA,EAAE,EAAE,CAAC,EAC9EoE,EAAoC,CAAE,MAAO,EAAG,OAAQ,EAAG,MAAO,CAAE,EACpEC,EAAO,IAAI,IACjB,QAAWxE,KAAMR,EAAE,SAAS,OAAO,EAAG,CACpC,GAAIQ,EAAG,OAAS,QAAS,SACzB,IAAMyB,EAAI4C,EAAQ,IAAIrE,EAAG,EAAE,EAEvB,EADgBsE,EAAa,IAAItE,EAAG,EAAE,GAAOyB,GAAG,MAAM,KAAKrC,GAAKO,EAASP,CAAC,IAAMO,EAASE,EAAE,KAAK,CAAC,IACjF2E,EAAK,IAAIxE,EAAG,EAAE,IAClCwE,EAAK,IAAIxE,EAAG,EAAE,EACduE,EAAM9C,GAAG,YAAczB,EAAG,UAAU,KAEtCJ,EAAI,KAAK,CAAE,MAAOC,EAAE,MAAO,KAAMA,EAAE,KAAM,OAAQyE,EAAa,KAAM,MAAAC,CAAM,CAAC,EAE7E,OAAO3E,CACT","names":["EVENTS_BY","LEVEL_MARK","ABOUT_SKIP","MAX_CANDIDATES","BODY_CHARS","ruleLevel","rules","title","tags","have","t","IMPORTANCE_LEVELS","re","namedEntities","g","text","hay","normName","out","e","name","eventCandidates","ev","linked","linkedEntities","x","named","localPage","hub","p","setByOthers","s","pickEvents","opts","scope","id","items","noPage","events","a","b","candidates","c","page","clip","n","buildEventsPrompt","o","lines","it","i","body","bodyOf","parseReply","fenced","raw","v","withOwnerRule","level","checkEventsReply","parsed","r","at","dropped","allowed","about","why","eventMeta","meta","today","kept","taken","added","runEvents","call","all","run","write","where","base","ok","forModel","batch","verdicts","reply","err","agentId","setEventLevel","statements","store","summariseAbout","byEvent","linkedBefore","after","seen"]}
|
package/dist/load-EOZUZK7U.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a,b,c,d,e,f,g}from"./chunk-JTDUTCUE.js";import"./chunk-RGZARSHV.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-EOZUZK7U.js.map
|