agentix-cli 0.213.3 → 0.215.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/dist/{agent-KUCECPSZ.js → agent-KOKQSRAH.js} +2 -2
  2. package/dist/{board-dashboard-RWX4F43G.js → board-dashboard-NVQUQSWI.js} +3 -3
  3. package/dist/{board-dashboard-RWX4F43G.js.map → board-dashboard-NVQUQSWI.js.map} +1 -1
  4. package/dist/chunk-4BYJN2A3.js +4 -0
  5. package/dist/chunk-4BYJN2A3.js.map +1 -0
  6. package/dist/{chunk-SPXXLPAS.js → chunk-4DCQIHWU.js} +2 -2
  7. package/dist/{chunk-SMZQLUJH.js → chunk-4ZD2C76P.js} +2 -2
  8. package/dist/{chunk-YR6GDF4W.js → chunk-7AFXLWWW.js} +87 -147
  9. package/dist/chunk-7AFXLWWW.js.map +1 -0
  10. package/dist/chunk-7YOLZGB5.js +2 -0
  11. package/dist/chunk-7YOLZGB5.js.map +1 -0
  12. package/dist/chunk-CSC45PA7.js +62 -0
  13. package/dist/chunk-CSC45PA7.js.map +1 -0
  14. package/dist/chunk-GGAEFVXL.js +42 -0
  15. package/dist/chunk-GGAEFVXL.js.map +1 -0
  16. package/dist/chunk-HVMUYEQP.js +4 -0
  17. package/dist/chunk-HVMUYEQP.js.map +1 -0
  18. package/dist/{chunk-SBFMNAJG.js → chunk-JLH73NRM.js} +88 -88
  19. package/dist/chunk-JLH73NRM.js.map +1 -0
  20. package/dist/{chunk-3GWIV2YO.js → chunk-OQNJIIR2.js} +2 -2
  21. package/dist/{chunk-3GWIV2YO.js.map → chunk-OQNJIIR2.js.map} +1 -1
  22. package/dist/{chunk-3327JD6L.js → chunk-Q7Y5VQGX.js} +2 -2
  23. package/dist/{chunk-UNVZUWOY.js → chunk-QMICGPM6.js} +3 -3
  24. package/dist/{chunk-UNVZUWOY.js.map → chunk-QMICGPM6.js.map} +1 -1
  25. package/dist/{chunk-D7B35QCZ.js → chunk-QOGZD6Z3.js} +323 -323
  26. package/dist/chunk-QOGZD6Z3.js.map +1 -0
  27. package/dist/chunk-Z5CMA4JN.js +6 -0
  28. package/dist/chunk-Z5CMA4JN.js.map +1 -0
  29. package/dist/cli.js +1 -1
  30. package/dist/decision-approvals-SWZ4RWFI.js +2 -0
  31. package/dist/{doctor-TK7LVXJ6.js → doctor-GP2KVKWE.js} +2 -2
  32. package/dist/hub-V2AGLA7T.js +2 -0
  33. package/dist/index.d.ts +93 -0
  34. package/dist/index.js +1 -1
  35. package/dist/index.js.map +1 -1
  36. package/dist/{program-GXEVAQRW.js → program-WSGVQTFM.js} +255 -255
  37. package/dist/program-WSGVQTFM.js.map +1 -0
  38. package/dist/{query-runs-AENEZOM6.js → query-runs-2F6KHFBZ.js} +2 -2
  39. package/dist/{registry-D727ZQUP.js → registry-KRU6AWVW.js} +2 -2
  40. package/dist/timers-LAT4ZVXJ.js +2 -0
  41. package/dist/{tool-2VRNH43W.js → tool-ZCSGJ2ZF.js} +9 -9
  42. package/dist/tool-ZCSGJ2ZF.js.map +1 -0
  43. package/dist/wiki-IDLRJ6WL.js +2 -0
  44. package/dist/wiki-enrich-XWLDJAZI.js +2 -0
  45. package/package.json +1 -1
  46. package/dist/chunk-AFRHKA7B.js +0 -2
  47. package/dist/chunk-AFRHKA7B.js.map +0 -1
  48. package/dist/chunk-D7B35QCZ.js.map +0 -1
  49. package/dist/chunk-FR4DTMCA.js +0 -42
  50. package/dist/chunk-FR4DTMCA.js.map +0 -1
  51. package/dist/chunk-HPRLRD4P.js +0 -6
  52. package/dist/chunk-HPRLRD4P.js.map +0 -1
  53. package/dist/chunk-LIY5CHUV.js +0 -4
  54. package/dist/chunk-LIY5CHUV.js.map +0 -1
  55. package/dist/chunk-RMXG5GNW.js +0 -4
  56. package/dist/chunk-RMXG5GNW.js.map +0 -1
  57. package/dist/chunk-SBFMNAJG.js.map +0 -1
  58. package/dist/chunk-YR6GDF4W.js.map +0 -1
  59. package/dist/decision-approvals-NJS2ARAF.js +0 -2
  60. package/dist/hub-PPQGFC35.js +0 -2
  61. package/dist/program-GXEVAQRW.js.map +0 -1
  62. package/dist/timers-KK7GF77Y.js +0 -2
  63. package/dist/tool-2VRNH43W.js.map +0 -1
  64. package/dist/wiki-FP4JMCYP.js +0 -2
  65. package/dist/wiki-enrich-3SPIVYSG.js +0 -2
  66. /package/dist/{agent-KUCECPSZ.js.map → agent-KOKQSRAH.js.map} +0 -0
  67. /package/dist/{chunk-SPXXLPAS.js.map → chunk-4DCQIHWU.js.map} +0 -0
  68. /package/dist/{chunk-SMZQLUJH.js.map → chunk-4ZD2C76P.js.map} +0 -0
  69. /package/dist/{chunk-3327JD6L.js.map → chunk-Q7Y5VQGX.js.map} +0 -0
  70. /package/dist/{decision-approvals-NJS2ARAF.js.map → decision-approvals-SWZ4RWFI.js.map} +0 -0
  71. /package/dist/{doctor-TK7LVXJ6.js.map → doctor-GP2KVKWE.js.map} +0 -0
  72. /package/dist/{hub-PPQGFC35.js.map → hub-V2AGLA7T.js.map} +0 -0
  73. /package/dist/{query-runs-AENEZOM6.js.map → query-runs-2F6KHFBZ.js.map} +0 -0
  74. /package/dist/{registry-D727ZQUP.js.map → registry-KRU6AWVW.js.map} +0 -0
  75. /package/dist/{timers-KK7GF77Y.js.map → timers-LAT4ZVXJ.js.map} +0 -0
  76. /package/dist/{wiki-FP4JMCYP.js.map → wiki-IDLRJ6WL.js.map} +0 -0
  77. /package/dist/{wiki-enrich-3SPIVYSG.js.map → wiki-enrich-XWLDJAZI.js.map} +0 -0
@@ -1,6 +0,0 @@
1
- import{appendFileSync as c,readFileSync as l,renameSync as y,statSync as p,writeFileSync as m}from"fs";var R="_query-runs.jsonl",g=1e6;function f(e){return e==="error"||e==="no-catalog"}function d(e,o,n){c(e,`${JSON.stringify(o)}
2
- `),p(e).size>n&&b(e,Math.floor(n/2))}function S(e,o,n=g){try{d(e,o,n)}catch{}}function b(e,o){let n=l(e,"utf-8").split(`
3
- `).filter(Boolean),a=[],i=0;for(let r=n.length-1;r>=0&&(i+=Buffer.byteLength(n[r])+1,!(i>o));r--)a.push(n[r]);let s=`${e}.${process.pid}.tmp`;m(s,a.reverse().map(r=>`${r}
4
- `).join("")),y(s,e)}async function h(e,o,n,a){let i=Date.now(),s=(r,t)=>S(e,{at:new Date().toISOString(),agent:o,status:r,method:t,source:n,wallMs:Date.now()-i});try{let r=await a();return s(r.status,r.method),r}catch(r){throw s("error"),r}}function w(e,o){let n=e.split(`
5
- `).filter(Boolean).flatMap(t=>{try{let u=JSON.parse(t);return u&&typeof u.status=="string"&&typeof u.at=="string"?[u]:[]}catch{return[]}}).filter(t=>!o||t.at>=o),a={},i={};for(let t of n){a[t.status]=(a[t.status]??0)+1;let u=t.source??"cli";i[u]=(i[u]??0)+1}let s=n.filter(t=>t.status!=="no-catalog").map(t=>Number(t.wallMs)||0).sort((t,u)=>t-u),r=t=>s.length?s[Math.min(s.length-1,Math.floor(t*s.length))]:0;return{total:n.length,failed:n.filter(t=>f(t.status)).length,byStatus:a,bySource:i,wallMsP50:r(.5),wallMsP95:r(.95)}}export{R as a,g as b,f as c,d,S as e,h as f,w as g};
6
- //# sourceMappingURL=chunk-HPRLRD4P.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/wiki/query-runs.ts"],"sourcesContent":["/**\n * `wiki query` outcomes, one line per query in `_query-runs.jsonl` (#603).\n *\n * A failed query used to print plain text and exit 0, so nothing counted\n * it. Each query now appends its status and timing here, and\n * `wiki query-runs` counts them. No question, answer or error text goes\n * in the file.\n */\nimport { appendFileSync, readFileSync, renameSync, statSync, writeFileSync } from \"fs\"\nimport type { AgenticQueryResult } from \"./query\"\n\nexport const QUERY_RUNS_FILE = \"_query-runs.jsonl\"\n\n/** Past this size the file is cut to its newest half, so it never grows without a limit. */\nexport const QUERY_RUNS_MAX_BYTES = 1_000_000\n\nexport type QueryStatus = AgenticQueryResult[\"status\"]\n\n/** Where the query came from: the `wiki query` command or the `agentx_wiki_query` tool. */\nexport type QuerySource = \"cli\" | \"tool\"\n\nexport interface QueryRunRecord {\n at: string\n agent: string\n status: QueryStatus\n method?: string\n /** Missing on lines written before the tool was counted; those came from the CLI. */\n source?: QuerySource\n wallMs: number\n}\n\n/** Statuses that mean the query could not run, not that the wiki had no answer. */\nexport function queryFailed(status: QueryStatus): boolean {\n return status === \"error\" || status === \"no-catalog\"\n}\n\n/** Append one JSON line; past `maxBytes` the file is cut to its newest half. Throws on a write error. */\nexport function appendCappedLine(file: string, record: unknown, maxBytes: number): void {\n appendFileSync(file, `${JSON.stringify(record)}\\n`)\n if (statSync(file).size > maxBytes) trimToNewest(file, Math.floor(maxBytes / 2))\n}\n\n/** Append one record. Never throws: logging must not fail a query. */\nexport function recordQueryRun(file: string, record: QueryRunRecord, maxBytes = QUERY_RUNS_MAX_BYTES): void {\n try {\n appendCappedLine(file, record, maxBytes)\n } catch {\n // best-effort\n }\n}\n\n/** Keep the newest whole lines that fit in `bytes`. Written to a temp file and renamed, so a reader never sees half a file. */\nfunction trimToNewest(file: string, bytes: number): void {\n const lines = readFileSync(file, \"utf-8\").split(\"\\n\").filter(Boolean)\n const kept: string[] = []\n let size = 0\n for (let i = lines.length - 1; i >= 0; i--) {\n size += Buffer.byteLength(lines[i]) + 1\n if (size > bytes) break\n kept.push(lines[i])\n }\n const tmp = `${file}.${process.pid}.tmp`\n writeFileSync(tmp, kept.reverse().map((l) => `${l}\\n`).join(\"\"))\n renameSync(tmp, file)\n}\n\n/**\n * Run one query and record how it ended. A query that throws is recorded\n * as `error` and the error is thrown on, so no query goes uncounted.\n */\nexport async function timedQuery<T extends { status: QueryStatus; method?: string }>(\n file: string,\n agent: string,\n source: QuerySource,\n run: () => Promise<T>,\n): Promise<T> {\n const start = Date.now()\n const record = (status: QueryStatus, method?: string) =>\n recordQueryRun(file, { at: new Date().toISOString(), agent, status, method, source, wallMs: Date.now() - start })\n try {\n const result = await run()\n record(result.status, result.method)\n return result\n } catch (e) {\n record(\"error\")\n throw e\n }\n}\n\nexport interface QueryRunSummary {\n total: number\n failed: number\n byStatus: Record<string, number>\n bySource: Record<string, number>\n /** Over queries that ran: `no-catalog` lines are left out. */\n wallMsP50: number\n wallMsP95: number\n}\n\n/** Count queries by status, on or after `since` (an ISO date or time) when given. */\nexport function summariseQueryRuns(text: string, since?: string): QueryRunSummary {\n const records: QueryRunRecord[] = text.split(\"\\n\").filter(Boolean).flatMap((l) => {\n try {\n const r = JSON.parse(l)\n return r && typeof r.status === \"string\" && typeof r.at === \"string\" ? [r] : []\n } catch { return [] }\n }).filter((r) => !since || r.at >= since)\n const byStatus: Record<string, number> = {}\n const bySource: Record<string, number> = {}\n for (const r of records) {\n byStatus[r.status] = (byStatus[r.status] ?? 0) + 1\n const source = r.source ?? \"cli\"\n bySource[source] = (bySource[source] ?? 0) + 1\n }\n // A `no-catalog` line never ran a query (the tool writes it with wallMs 0), so it would only pull the times down.\n const ms = records.filter((r) => r.status !== \"no-catalog\").map((r) => Number(r.wallMs) || 0).sort((a, b) => a - b)\n const pick = (q: number) => (ms.length ? ms[Math.min(ms.length - 1, Math.floor(q * ms.length))] : 0)\n return {\n total: records.length,\n failed: records.filter((r) => queryFailed(r.status)).length,\n byStatus,\n bySource,\n wallMsP50: pick(0.5),\n wallMsP95: pick(0.95),\n }\n}\n"],"mappings":"AAQA,OAAS,kBAAAA,EAAgB,gBAAAC,EAAc,cAAAC,EAAY,YAAAC,EAAU,iBAAAC,MAAqB,KAG3E,IAAMC,EAAkB,oBAGlBC,EAAuB,IAkB7B,SAASC,EAAYC,EAA8B,CACxD,OAAOA,IAAW,SAAWA,IAAW,YAC1C,CAGO,SAASC,EAAiBC,EAAcC,EAAiBC,EAAwB,CACtFZ,EAAeU,EAAM,GAAG,KAAK,UAAUC,CAAM;AAAA,CAAK,EAC9CR,EAASO,CAAI,EAAE,KAAOE,GAAUC,EAAaH,EAAM,KAAK,MAAME,EAAW,CAAC,CAAC,CACjF,CAGO,SAASE,EAAeJ,EAAcC,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EAAE,IAAO,SAAW,CAACA,CAAC,EAAI,CAAC,CAChF,MAAE,CAAQ,MAAO,CAAC,CAAE,CACtB,CAAC,EAAE,OAAQA,GAAM,CAACF,GAASE,EAAE,IAAMF,CAAK,EAClCG,EAAmC,CAAC,EACpCC,EAAmC,CAAC,EAC1C,QAAWF,KAAKD,EAAS,CACvBE,EAASD,EAAE,MAAM,GAAKC,EAASD,EAAE,MAAM,GAAK,GAAK,EACjD,IAAMV,EAASU,EAAE,QAAU,MAC3BE,EAASZ,CAAM,GAAKY,EAASZ,CAAM,GAAK,GAAK,EAG/C,IAAMa,EAAKJ,EAAQ,OAAQC,GAAMA,EAAE,SAAW,YAAY,EAAE,IAAKA,GAAM,OAAOA,EAAE,MAAM,GAAK,CAAC,EAAE,KAAK,CAACI,EAAGC,IAAMD,EAAIC,CAAC,EAC5GC,EAAQC,GAAeJ,EAAG,OAASA,EAAG,KAAK,IAAIA,EAAG,OAAS,EAAG,KAAK,MAAMI,EAAIJ,EAAG,MAAM,CAAC,CAAC,EAAI,EAClG,MAAO,CACL,MAAOJ,EAAQ,OACf,OAAQA,EAAQ,OAAQC,GAAM3B,EAAY2B,EAAE,MAAM,CAAC,EAAE,OACrD,SAAAC,EACA,SAAAC,EACA,UAAWI,EAAK,EAAG,EACnB,UAAWA,EAAK,GAAI,CACtB,CACF","names":["appendFileSync","readFileSync","renameSync","statSync","writeFileSync","QUERY_RUNS_FILE","QUERY_RUNS_MAX_BYTES","queryFailed","status","appendCappedLine","file","record","maxBytes","trimToNewest","recordQueryRun","bytes","lines","kept","size","i","tmp","l","timedQuery","agent","source","run","start","method","result","e","summariseQueryRuns","text","since","records","r","byStatus","bySource","ms","a","b","pick","q"]}
@@ -1,4 +0,0 @@
1
- import{createHash as c}from"crypto";import{existsSync as l,mkdirSync as d,readFileSync as u,renameSync as f,writeFileSync as v}from"fs";import{dirname as g,resolve as A}from"path";function s(e){return A(e,"_decisions","approved.json")}function p(e){return c("sha256").update(`${e.meta.title??""}
2
- ${(e.content??"").trim()}`).digest("hex")}function i(e){let n=s(e);if(!l(n))return{};try{let t=JSON.parse(u(n,"utf-8"));return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}catch{return{}}}function a(e,n){let t=s(e);d(g(t),{recursive:!0});let r=`${t}.${process.pid}.tmp`;v(r,JSON.stringify(n,null,2)+`
3
- `),f(r,t)}function m(e,n){let t=n[e.path];return t?t.hash===p(e)?"approved":"changed":"waiting"}function y(e,n){return e.filter(t=>t.meta.type!=="decision"||m(t,n)==="approved")}function S(e,n,t){return t?y(e,i(n)):e}function k(e=process.env){return e.AGENTX_AGENT_ID?.trim()||e.AGENTX_TASK_ID?.trim()?"decision pages are approved by the owner from a terminal, not from inside an agent's run":null}function w(e,n,t={}){if(n.meta.type!=="decision")throw new Error(`${n.path} is not a decision page (type: ${n.meta.type??"none"})`);let r=i(e),o={hash:p(n),approvedAt:new Date(t.now??Date.now()).toISOString(),by:t.by||"owner",lastUpdated:n.meta.lastUpdated||void 0,...t.note?{note:t.note}:{}};return r[n.path]=o,a(e,r),o}function b(e,n){let t=i(e);return t[n]?(delete t[n],a(e,t),!0):!1}export{s as a,p as b,i as c,m as d,y as e,S as f,k as g,w as h,b as i};
4
- //# sourceMappingURL=chunk-LIY5CHUV.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/wiki/decision-approvals.ts"],"sourcesContent":["// --- Owner approval for decision pages (#1778) ---\n//\n// A fresh session puts the newest wiki `decision` pages ahead of the chat\n// history and says they win (agents/owner-decisions.ts, #1777). Until now\n// any write could make such a page: the absorb job types pages from raw\n// chat and cron entries (a client's message included), `wiki patch` and\n// `wiki interview` take an agent id from the caller, the daily\n// contributions can create pages, and mesh sync copies a peer's pages.\n// None of them asks the owner. So one unreviewed write could steer every\n// fresh session of that agent.\n//\n// The gate is off unless `wiki.decisionApprovals.required` is set. When on,\n// a decision page reaches that block only while its title and\n// body are exactly what the owner approved. The approval is kept outside\n// the pages, in `_decisions/approved.json` of the agent's wiki, which no\n// page write touches and the article index skips (`_` prefix). Any later\n// edit, by anyone, changes the hash, and the page waits for a new\n// approval. The owner approves from a terminal; the command refuses inside\n// an agent's run.\n\nimport { createHash } from \"crypto\"\nimport { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from \"fs\"\nimport { dirname, resolve } from \"path\"\nimport type { WikiArticle } from \"./types\"\n\nexport interface DecisionApproval {\n /** Hash of the title and body the owner approved. */\n hash: string\n approvedAt: string\n by: string\n /** The page's own `last_updated` when approved, for the listing. */\n lastUpdated?: string\n note?: string\n}\n\nexport type DecisionApprovals = Record<string, DecisionApproval>\n\n/** Where a wiki's approvals live. */\nexport function approvalsFile(wikiBaseDir: string): string {\n return resolve(wikiBaseDir, \"_decisions\", \"approved.json\")\n}\n\n/** What an approval covers: the title and the body, whitespace at the ends\n * ignored. Frontmatter dates and tags are not part of it. */\nexport function decisionHash(article: Pick<WikiArticle, \"meta\" | \"content\">): string {\n return createHash(\"sha256\")\n .update(`${article.meta.title ?? \"\"}\\n${(article.content ?? \"\").trim()}`)\n .digest(\"hex\")\n}\n\nexport function readApprovals(wikiBaseDir: string): DecisionApprovals {\n const file = approvalsFile(wikiBaseDir)\n if (!existsSync(file)) return {}\n try {\n const parsed = JSON.parse(readFileSync(file, \"utf-8\"))\n return parsed && typeof parsed === \"object\" && !Array.isArray(parsed) ? parsed as DecisionApprovals : {}\n } catch {\n return {} // unreadable: nothing counts as approved\n }\n}\n\nfunction writeApprovals(wikiBaseDir: string, all: DecisionApprovals): void {\n const file = approvalsFile(wikiBaseDir)\n mkdirSync(dirname(file), { recursive: true })\n const tmp = `${file}.${process.pid}.tmp`\n writeFileSync(tmp, JSON.stringify(all, null, 2) + \"\\n\")\n renameSync(tmp, file)\n}\n\nexport type DecisionState = \"approved\" | \"changed\" | \"waiting\"\n\n/** approved: the page is what the owner approved. changed: approved once,\n * edited since. waiting: never approved. */\nexport function decisionState(article: WikiArticle, approvals: DecisionApprovals): DecisionState {\n const a = approvals[article.path]\n if (!a) return \"waiting\"\n return a.hash === decisionHash(article) ? \"approved\" : \"changed\"\n}\n\n/** Decision pages as they may reach the owner-decisions block: approved\n * ones only. Other page types pass through unchanged. */\nexport function approvedDecisionsOnly(articles: WikiArticle[], approvals: DecisionApprovals): WikiArticle[] {\n return articles.filter((a) => a.meta.type !== \"decision\" || decisionState(a, approvals) === \"approved\")\n}\n\n/** What the owner-decisions block may read. With approvals not required\n * (the default, `wiki.decisionApprovals.required`), every page passes as\n * #1776 specifies; required, decision pages need the owner's approval. */\nexport function decisionsForBlock(articles: WikiArticle[], wikiBaseDir: string, required: boolean): WikiArticle[] {\n return required ? approvedDecisionsOnly(articles, readApprovals(wikiBaseDir)) : articles\n}\n\n/** Why the current process may not approve: inside an agent's run. */\nexport function approvalRefusal(env: NodeJS.ProcessEnv = process.env): string | null {\n if (env.AGENTX_AGENT_ID?.trim() || env.AGENTX_TASK_ID?.trim()) {\n return \"decision pages are approved by the owner from a terminal, not from inside an agent's run\"\n }\n return null\n}\n\nexport function approveDecision(\n wikiBaseDir: string,\n article: WikiArticle,\n opts: { by?: string; now?: number; note?: string } = {},\n): DecisionApproval {\n if (article.meta.type !== \"decision\") throw new Error(`${article.path} is not a decision page (type: ${article.meta.type ?? \"none\"})`)\n const all = readApprovals(wikiBaseDir)\n const approval: DecisionApproval = {\n hash: decisionHash(article),\n approvedAt: new Date(opts.now ?? Date.now()).toISOString(),\n by: opts.by || \"owner\",\n lastUpdated: article.meta.lastUpdated || undefined,\n ...(opts.note ? { note: opts.note } : {}),\n }\n all[article.path] = approval\n writeApprovals(wikiBaseDir, all)\n return approval\n}\n\n/** Remove an approval. True when there was one. */\nexport function revokeDecision(wikiBaseDir: string, path: string): boolean {\n const all = readApprovals(wikiBaseDir)\n if (!all[path]) return false\n delete all[path]\n writeApprovals(wikiBaseDir, all)\n return true\n}\n"],"mappings":"AAoBA,OAAS,cAAAA,MAAkB,SAC3B,OAAS,cAAAC,EAAY,aAAAC,EAAW,gBAAAC,EAAc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AsBC,EAAUV,EAAcH,CAAW,CAAC,EAAIa,CAClF,CAGO,SAASG,EAAgBC,EAAyB,QAAQ,IAAoB,CACnF,OAAIA,EAAI,iBAAiB,KAAK,GAAKA,EAAI,gBAAgB,KAAK,EACnD,2FAEF,IACT,CAEO,SAASC,EACdlB,EACAE,EACAiB,EAAqD,CAAC,EACpC,CAClB,GAAIjB,EAAQ,KAAK,OAAS,WAAY,MAAM,IAAI,MAAM,GAAGA,EAAQ,sCAAsCA,EAAQ,KAAK,MAAQ,SAAS,EACrI,IAAMK,EAAMJ,EAAcH,CAAW,EAC/BoB,EAA6B,CACjC,KAAMnB,EAAaC,CAAO,EAC1B,WAAY,IAAI,KAAKiB,EAAK,KAAO,KAAK,IAAI,CAAC,EAAE,YAAY,EACzD,GAAIA,EAAK,IAAM,QACf,YAAajB,EAAQ,KAAK,aAAe,OACzC,GAAIiB,EAAK,KAAO,CAAE,KAAMA,EAAK,IAAK,EAAI,CAAC,CACzC,EACA,OAAAZ,EAAIL,EAAQ,IAAI,EAAIkB,EACpBd,EAAeN,EAAaO,CAAG,EACxBa,CACT,CAGO,SAASC,EAAerB,EAAqBsB,EAAuB,CACzE,IAAMf,EAAMJ,EAAcH,CAAW,EACrC,OAAKO,EAAIe,CAAI,GACb,OAAOf,EAAIe,CAAI,EACfhB,EAAeN,EAAaO,CAAG,EACxB,IAHgB,EAIzB","names":["createHash","existsSync","mkdirSync","readFileSync","renameSync","writeFileSync","dirname","resolve","approvalsFile","wikiBaseDir","decisionHash","article","readApprovals","file","parsed","writeApprovals","all","tmp","decisionState","approvals","a","approvedDecisionsOnly","articles","decisionsForBlock","required","approvalRefusal","env","approveDecision","opts","approval","revokeDecision","path"]}
@@ -1,4 +0,0 @@
1
- import{a as h}from"./chunk-ZRBTLW2B.js";import{resolve as n}from"path";import{existsSync as c,readdirSync as u,mkdirSync as l,readFileSync as p,writeFileSync as f,renameSync as S}from"fs";var m=class{baseDir;agentsDir;mode;sharedStore;agentStores=new Map;log;constructor(e=n(process.cwd(),".agentx/wiki"),r=console.error.bind(console,"[wiki-hub]"),t="graph"){this.baseDir=e,this.agentsDir=n(e,"agents"),this.mode=t,this.log=r,l(this.agentsDir,{recursive:!0}),this.sharedStore=new h(e,r)}getMode(){return this.mode}getAgentWiki(e){let r=`${e}:${this.mode}`;if(this.agentStores.has(r))return this.agentStores.get(r);let t=n(this.agentsDir,e,this.mode),s=new h(t,this.log);return this.agentStores.set(r,s),s}getBaseDir(){return this.baseDir}getSharedStore(){return this.sharedStore}sharedScope(e){return[...this.listAgentDirs().filter(t=>t!==e).map(t=>({id:t,store:this.getAgentWiki(t)})),{id:"shared",store:this.sharedStore,skip:t=>t.startsWith("agents/")}]}listAgentDirs(){return c(this.agentsDir)?u(this.agentsDir).filter(e=>!e.startsWith("_")&&!e.startsWith(".")&&c(n(this.agentsDir,e,this.mode))).sort():[]}listAgents(e=this.sharedStore.listEntries()){let r=new Set;for(let t of e)r.add(t.agentId);if(c(this.agentsDir))for(let t of u(this.agentsDir))!t.startsWith("_")&&!t.startsWith(".")&&r.add(t);return[...r].sort()}getAgentEntries(e){return this.sharedStore.listEntries({agentId:e})}getUnabsorbedEntries(e){return this.classifyEntries(e).pending}markProcessed(e,r,t){let s=new Set(t),g=this.readLedger(e),d=new Date().toISOString();for(let i of r)g.entries[i]={at:d,cited:s.has(i)};let o=this.ledgerPath(e);l(n(o,".."),{recursive:!0});let a=`${o}.tmp`;f(a,`${JSON.stringify(g,null,2)}
2
- `),S(a,o)}summary(){let e=this.sharedStore.listEntries(),r=new Map;for(let t of e){let s=r.get(t.agentId);s?s.push(t):r.set(t.agentId,[t])}return this.listAgents(e).map(t=>{let{all:s,cited:g,read:d,pending:o,articles:a}=this.classifyEntries(t,r.get(t)??[]);return{agentId:t,totalEntries:s.length,totalArticles:a.length,cited:g.length,readNotCited:d.length,unabsorbed:o.length,articles:a}})}classifyEntries(e,r=this.getAgentEntries(e)){let t=this.getAgentWiki(e).rebuildIndex().articles,s=new Set;for(let i of t)if(i.sources)for(let y of i.sources)s.add(y);let g=this.readLedger(e).entries,d=[],o=[],a=[];for(let i of r)s.has(i.id)?d.push(i):g[i.id]?o.push(i):a.push(i);return{all:r,cited:d,read:o,pending:a,articles:t}}syncedFrom(e){let r=n(this.agentsDir,e,"_synced.json");if(!c(r))return null;try{return JSON.parse(p(r,"utf-8"))}catch(t){return this.log(`synced marker ${r} is not valid JSON: ${t.message}`),{node:"unknown",peerUrl:"",at:""}}}markSynced(e,r){let t=n(this.agentsDir,e,"_synced.json");l(n(t,".."),{recursive:!0});let s=`${t}.tmp`;f(s,`${JSON.stringify(r,null,2)}
3
- `),S(s,t)}ledgerPath(e){return n(this.agentsDir,e,"_absorbed.json")}readLedger(e){let r=this.ledgerPath(e);if(!c(r))return{entries:{}};try{return{entries:JSON.parse(p(r,"utf-8")).entries??{}}}catch(t){throw new Error(`absorb ledger ${r} is not valid JSON: ${t.message}`)}}};export{m as a};
4
- //# sourceMappingURL=chunk-RMXG5GNW.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/wiki/hub.ts"],"sourcesContent":["import { WikiStore } from \"./store\"\nimport { resolve } from \"path\"\nimport { existsSync, readdirSync, mkdirSync, readFileSync, writeFileSync, renameSync } from \"fs\"\nimport type { WikiEntry } from \"./types\"\nimport type { SharedWikiStore } from \"./query\"\n\nexport type WikiMode = \"flat\" | \"graph\" | \"unified\"\n\n/**\n * WikiHub: manages per-agent wikis with a shared raw entry pool.\n * Supports two compilation modes:\n * - flat: Karpathy pattern — tags, LLM-chosen paths, worldview, gap detection\n * - graph: Knowledge graph — kind, parent, hierarchy, events, entities\n *\n * Both modes share the same raw entries. Articles stored separately:\n * agents/<id>/flat/ ← Karpathy compilation\n * agents/<id>/graph/ ← Knowledge graph compilation\n */\nexport class WikiHub {\n private baseDir: string\n private agentsDir: string\n private mode: WikiMode\n private sharedStore: WikiStore\n private agentStores: Map<string, WikiStore> = new Map()\n private log: (...args: unknown[]) => void\n\n constructor(\n baseDir: string = resolve(process.cwd(), \".agentx/wiki\"),\n log: (...args: unknown[]) => void = console.error.bind(console, \"[wiki-hub]\"),\n mode: WikiMode = \"graph\",\n ) {\n this.baseDir = baseDir\n this.agentsDir = resolve(baseDir, \"agents\")\n this.mode = mode\n this.log = log\n\n mkdirSync(this.agentsDir, { recursive: true })\n this.sharedStore = new WikiStore(baseDir, log)\n }\n\n getMode(): WikiMode { return this.mode }\n\n /**\n * Get or create the wiki store for a specific agent (mode-aware).\n * flat: agents/<id>/flat/\n * graph: agents/<id>/graph/\n */\n getAgentWiki(agentId: string): WikiStore {\n const key = `${agentId}:${this.mode}`\n if (this.agentStores.has(key)) return this.agentStores.get(key)!\n\n const agentDir = resolve(this.agentsDir, agentId, this.mode)\n const store = new WikiStore(agentDir, this.log)\n this.agentStores.set(key, store)\n return store\n }\n\n /** The wiki root: shared sidecars (_facts.json, _questions.json) live here. */\n getBaseDir(): string {\n return this.baseDir\n }\n\n getSharedStore(): WikiStore {\n return this.sharedStore\n }\n\n /**\n * The wikis a query by `agentId` reads besides its own: every other\n * agent's articles and the root store's own (promoted lessons). Which\n * articles of theirs it may read is still decided per article by access.\n * Without this an agent's query missed answers the shared wiki had (#824).\n */\n sharedScope(agentId: string): SharedWikiStore[] {\n const others = this.listAgentDirs()\n .filter((id) => id !== agentId)\n .map((id) => ({ id, store: this.getAgentWiki(id) }))\n // The root store's walk also reaches agents/<id>/…; those are read\n // through their own store above.\n return [...others, { id: \"shared\", store: this.sharedStore, skip: (p: string) => p.startsWith(\"agents/\") }]\n }\n\n /** Agents with a wiki folder here, without reading the raw entries. */\n private listAgentDirs(): string[] {\n if (!existsSync(this.agentsDir)) return []\n return readdirSync(this.agentsDir)\n .filter((d) => !d.startsWith(\"_\") && !d.startsWith(\".\") && existsSync(resolve(this.agentsDir, d, this.mode)))\n .sort()\n }\n\n listAgents(entries: WikiEntry[] = this.sharedStore.listEntries()): string[] {\n const agents = new Set<string>()\n\n for (const e of entries) agents.add(e.agentId)\n\n if (existsSync(this.agentsDir)) {\n for (const dir of readdirSync(this.agentsDir)) {\n if (!dir.startsWith(\"_\") && !dir.startsWith(\".\")) {\n agents.add(dir)\n }\n }\n }\n\n return [...agents].sort()\n }\n\n getAgentEntries(agentId: string): WikiEntry[] {\n return this.sharedStore.listEntries({ agentId })\n }\n\n /**\n * Entries absorb has not dealt with yet: no article cites them and no\n * successful absorb run has read them. Without the second check an\n * entry absorb read and chose not to cite came back on every run, and\n * a backfill kept re-reading the head of the queue (#762).\n */\n getUnabsorbedEntries(agentId: string): WikiEntry[] {\n return this.classifyEntries(agentId).pending\n }\n\n /**\n * Record every entry handed to the model in a successful absorb run,\n * cited or not. Callers must not call this for a failed run, so those\n * entries are offered again.\n */\n markProcessed(agentId: string, entryIds: string[], citedIds: Iterable<string>): void {\n const cited = new Set(citedIds)\n const ledger = this.readLedger(agentId)\n const at = new Date().toISOString()\n for (const id of entryIds) ledger.entries[id] = { at, cited: cited.has(id) }\n\n const file = this.ledgerPath(agentId)\n mkdirSync(resolve(file, \"..\"), { recursive: true })\n const tmp = `${file}.tmp`\n writeFileSync(tmp, `${JSON.stringify(ledger, null, 2)}\\n`)\n renameSync(tmp, file)\n }\n\n /**\n * Counts and articles per agent, for `GET /wiki/agents` and the mesh.\n * The raw entries are read once and grouped here: reading them again\n * per agent made the endpoint take 25 to 75 s on a fleet with 30\n * agents and 10k entries, past the mesh client's 5 s timeout (#603).\n */\n summary(): AgentWikiSummary[] {\n const entries = this.sharedStore.listEntries()\n const byAgent = new Map<string, WikiEntry[]>()\n for (const e of entries) {\n const list = byAgent.get(e.agentId)\n if (list) list.push(e)\n else byAgent.set(e.agentId, [e])\n }\n return this.listAgents(entries).map(agentId => {\n const { all, cited, read, pending, articles } = this.classifyEntries(agentId, byAgent.get(agentId) ?? [])\n return {\n agentId,\n totalEntries: all.length,\n totalArticles: articles.length,\n cited: cited.length,\n readNotCited: read.length,\n unabsorbed: pending.length,\n articles,\n }\n })\n }\n\n /** Split an agent's entries into cited by an article, read but not cited, and pending. */\n private classifyEntries(agentId: string, all: WikiEntry[] = this.getAgentEntries(agentId)) {\n const articles = this.getAgentWiki(agentId).rebuildIndex().articles\n\n const citedIds = new Set<string>()\n for (const article of articles) {\n if (article.sources) {\n for (const s of article.sources) citedIds.add(s)\n }\n }\n const ledger = this.readLedger(agentId).entries\n\n const cited: WikiEntry[] = []\n const read: WikiEntry[] = []\n const pending: WikiEntry[] = []\n for (const e of all) {\n if (citedIds.has(e.id)) cited.push(e)\n else if (ledger[e.id]) read.push(e)\n else pending.push(e)\n }\n return { all, cited, read, pending, articles }\n }\n\n /**\n * The peer an agent's articles were copied from by `wiki sync --articles`,\n * or null for an agent this node absorbs itself. A copied agent is\n * read-only here: absorb and patch leave it to its home node.\n */\n syncedFrom(agentId: string): SyncedFrom | null {\n const file = resolve(this.agentsDir, agentId, \"_synced.json\")\n if (!existsSync(file)) return null\n try {\n return JSON.parse(readFileSync(file, \"utf-8\")) as SyncedFrom\n } catch (err) {\n // A damaged marker still means the agent lives elsewhere.\n this.log(`synced marker ${file} is not valid JSON: ${(err as Error).message}`)\n return { node: \"unknown\", peerUrl: \"\", at: \"\" }\n }\n }\n\n markSynced(agentId: string, from: SyncedFrom): void {\n const file = resolve(this.agentsDir, agentId, \"_synced.json\")\n mkdirSync(resolve(file, \"..\"), { recursive: true })\n const tmp = `${file}.tmp`\n writeFileSync(tmp, `${JSON.stringify(from, null, 2)}\\n`)\n renameSync(tmp, file)\n }\n\n /** agents/<id>/_absorbed.json — shared by every mode, like the raw entries. */\n private ledgerPath(agentId: string): string {\n return resolve(this.agentsDir, agentId, \"_absorbed.json\")\n }\n\n private readLedger(agentId: string): AbsorbLedger {\n const file = this.ledgerPath(agentId)\n if (!existsSync(file)) return { entries: {} }\n try {\n const parsed = JSON.parse(readFileSync(file, \"utf-8\")) as AbsorbLedger\n return { entries: parsed.entries ?? {} }\n } catch (err) {\n // Treating a damaged ledger as empty would let the next run\n // overwrite it and re-queue everything it recorded.\n throw new Error(`absorb ledger ${file} is not valid JSON: ${(err as Error).message}`)\n }\n }\n}\n\nexport interface SyncedFrom {\n /** The peer's node id. */\n node: string\n peerUrl: string\n /** When the last copy finished. */\n at: string\n}\n\ninterface AbsorbLedger {\n entries: Record<string, { at: string; cited: boolean }>\n}\n\nexport interface AgentWikiSummary {\n agentId: string\n totalEntries: number\n totalArticles: number\n /** Entries an article cites. */\n cited: number\n /** Entries a successful absorb run read and did not cite. */\n readNotCited: number\n /** Entries absorb has not read yet. */\n unabsorbed: number\n articles: Array<{ title: string; path: string; tags?: string[] }>\n}\n"],"mappings":"wCACA,OAAS,WAAAA,MAAe,OACxB,OAAS,cAAAC,EAAY,eAAAC,EAAa,aAAAC,EAAW,gBAAAC,EAAc,iBAAAC,EAAe,cAAAC,MAAkB,KAgBrF,IAAMC,EAAN,KAAc,CACX,QACA,UACA,KACA,YACA,YAAsC,IAAI,IAC1C,IAER,YACEC,EAAkBR,EAAQ,QAAQ,IAAI,EAAG,cAAc,EACvDS,EAAoC,QAAQ,MAAM,KAAK,QAAS,YAAY,EAC5EC,EAAiB,QACjB,CACA,KAAK,QAAUF,EACf,KAAK,UAAYR,EAAQQ,EAAS,QAAQ,EAC1C,KAAK,KAAOE,EACZ,KAAK,IAAMD,EAEXN,EAAU,KAAK,UAAW,CAAE,UAAW,EAAK,CAAC,EAC7C,KAAK,YAAc,IAAIQ,EAAUH,EAASC,CAAG,CAC/C,CAEA,SAAoB,CAAE,OAAO,KAAK,IAAK,CAOvC,aAAaG,EAA4B,CACvC,IAAMC,EAAM,GAAGD,KAAW,KAAK,OAC/B,GAAI,KAAK,YAAY,IAAIC,CAAG,EAAG,OAAO,KAAK,YAAY,IAAIA,CAAG,EAE9D,IAAMC,EAAWd,EAAQ,KAAK,UAAWY,EAAS,KAAK,IAAI,EACrDG,EAAQ,IAAIJ,EAAUG,EAAU,KAAK,GAAG,EAC9C,YAAK,YAAY,IAAID,EAAKE,CAAK,EACxBA,CACT,CAGA,YAAqB,CAC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A,MAAM,IAAI,MAAM,iBAAiBV,wBAA4BU,EAAc,SAAS,CACtF,CACF,CACF","names":["resolve","existsSync","readdirSync","mkdirSync","readFileSync","writeFileSync","renameSync","WikiHub","baseDir","log","mode","WikiStore","agentId","key","agentDir","store","id","p","d","entries","agents","e","dir","entryIds","citedIds","cited","ledger","at","file","tmp","byAgent","list","all","read","pending","articles","article","s","err","from"]}