wiki-graph 0.4.0 → 0.4.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.
@@ -107,7 +107,7 @@ Usage:
107
107
 
108
108
  Notes:
109
109
  - The status tells whether the library index is current, dirty, missing, or disabled.
110
- - Library-wide `--query` and naked scope enumeration require a current library index.
110
+ - Library-wide object `--query` and object scope enumeration require a current library index.
111
111
  - Run `enable` when the status says the index needs to be built or rebuilt.
112
112
  {% elif target.kind == "scope" and target.objectUri == "wikg://index" and predicate == "enable" %}
113
113
  Purpose:
@@ -133,7 +133,7 @@ Usage:
133
133
 
134
134
  Notes:
135
135
  - This does not delete the library registry, metadata, folder, or managed `.wikg` archives.
136
- - Library-wide `--query` and naked scope enumeration will fail until the index is enabled again.
136
+ - Library-wide object `--query` and object scope enumeration will fail until the index is enabled again.
137
137
  - Library indexes do not support archive-style `embed` or `external` modes.
138
138
  - Disable holds the library write lock and cannot run concurrently with membership changes or index rebuild for the same library.
139
139
  {% elif target.kind == "scope" and predicate == "add" %}
@@ -121,8 +121,9 @@ Predicate commands:
121
121
  Library archive membership
122
122
 
123
123
  Default behavior:
124
- - `{{ commandName }} {{ uri }}` reads the registry entry for this library archive member.
125
- - The membership entry identifies the archive id, relative path, status, and containing library.
124
+ - `{{ commandName }} {{ uri }}` reads the archive member page for this managed archive.
125
+ - The member page shows the member URI, readable label or relative path, status, and business entry URIs for `/chapter`, `/entity`, `/triple`, and `inspect`.
126
+ - Registry fields such as physical path, size, mtime, and mutation token are diagnostic metadata.
126
127
  - `{{ commandName }} {{ uri }} inspect` checks readiness for this managed archive's contents, not the library registry.
127
128
  - Add archive object suffixes such as `/chapter`, `/entity`, or `/triple` when you want to query the archive contents.
128
129
 
@@ -165,11 +166,12 @@ Related help:
165
166
  Library scope
166
167
 
167
168
  Default behavior:
168
- - `{{ commandName }} {{ uri }}` reads this library scope.
169
+ - `{{ commandName }} {{ uri }}` reads the library-wide scope collection.
169
170
  - Use `{{ commandName }} wikg://lib/registry` to list all library registries.
170
- - `{{ commandName }} {{ uri }} --query <query>` runs a broad library index search across indexed object types.
171
+ - `{{ commandName }} {{ uri }} --query <query>` searches library-wide objects through the library index.
171
172
  - `{{ commandName }} {{ uri }}/arc scan` reconciles membership with `.wikg` files currently under the library folder.
172
173
  - Library-wide object scopes such as `/entity` and `/triple` query one object type through the library index after it is enabled.
174
+ - Archive object search must use an explicit lens such as `/entity`, `/triple`, `/chapter`, or `/chunk`.
173
175
 
174
176
  Use when:
175
177
  - You need to manage a folder of `.wikg` archives as one library.
@@ -181,15 +183,15 @@ Use when:
181
183
  {% endif %}
182
184
 
183
185
  URI forms:
184
- - `{{ commandName }} wikg://lib` addresses the default library.
185
- - `{{ commandName }} wikg://lib/<lib-id>` addresses a non-default library.
186
+ - `{{ commandName }} wikg://lib` addresses the default library root scope.
187
+ - `{{ commandName }} wikg://lib/<lib-id>` addresses a non-default library root scope.
186
188
  - `{{ commandName }} wikg://lib/arc/<archive-id>/` addresses one archive membership in the default library.
187
189
  - `{{ commandName }} wikg://lib/<lib-id>/arc/<archive-id>/` addresses one archive membership in a non-default library.
188
190
 
189
191
  Usage:
190
192
  {% if target.isDefault %}
191
- {{ commandName }} wikg://lib
192
- {{ commandName }} wikg://lib --query <query>
193
+ {{ commandName }} wikg://lib [--json]
194
+ {{ commandName }} wikg://lib --query <query> [--limit <n>] [--cursor <cursor>] [--json]
193
195
  {{ commandName }} wikg://lib/chapter --query <query>
194
196
  {{ commandName }} wikg://lib/chunk --query <query>
195
197
  {{ commandName }} wikg://lib/registry add --path <folder> [--json]
@@ -202,8 +204,8 @@ Usage:
202
204
  {{ commandName }} wikg://lib/triple --query <query>
203
205
  {{ commandName }} wikg://lib/meta [--json]
204
206
  {% else %}
205
- {{ commandName }} {{ uri }}
206
- {{ commandName }} {{ uri }} --query <query>
207
+ {{ commandName }} {{ uri }} [--json]
208
+ {{ commandName }} {{ uri }} --query <query> [--limit <n>] [--cursor <cursor>] [--json]
207
209
  {{ commandName }} {{ uri }}/chapter --query <query>
208
210
  {{ commandName }} {{ uri }}/chunk --query <query>
209
211
  {{ commandName }} {{ uri }}/arc scan [--json|--jsonl]
@@ -380,7 +380,7 @@ Usage:
380
380
 
381
381
  Notes:
382
382
  - This does not delete the library registry, metadata, folder, or managed `.wikg` archives.
383
- - Library-wide `--query` and naked scope enumeration will fail until the index is enabled again.
383
+ - Library-wide object `--query` and object scope enumeration will fail until the index is enabled again.
384
384
  - Library indexes do not support archive-style `embed` or `external` modes.
385
385
  - Disable holds the library write lock and cannot run concurrently with membership changes or index rebuild for the same library.
386
386
  {% else %}
@@ -12,7 +12,8 @@ Core model:
12
12
  - The default library is addressed as `wikg://lib`.
13
13
  - A non-default library is addressed as `wikg://lib/<lib-id>`.
14
14
  - The `arc` reserved segment keeps library ids distinct from archive member ids.
15
- - `{{ commandName }} wikg://lib` reads the default library scope; it does not list all library registries or archive memberships.
15
+ - `{{ commandName }} wikg://lib` reads the default library root scope.
16
+ - `{{ commandName }} wikg://lib --query <query>` searches library-wide objects through the library index.
16
17
 
17
18
  Registry discovery:
18
19
  - `{{ commandName }} wikg://lib/registry add --path <folder>` prints the new non-default library URI.
@@ -30,15 +31,16 @@ Library folders:
30
31
  Archive memberships:
31
32
  - `{{ commandName }} wikg://lib/arc scan` recursively discovers `.wikg` files under the default library folder and reconciles registry state.
32
33
  - `{{ commandName }} wikg://lib/arc add --input <path> [--to <relative-wikg-path>]` copies one `.wikg` file into the default library folder and registers it.
33
- - `{{ commandName }} wikg://lib/arc/tree` shows the archive member file tree; use this instead of naked `wikg://lib` or `wikg://lib/arc` when you want to see archive members.
34
+ - `{{ commandName }} wikg://lib` and `{{ commandName }} wikg://lib/arc` separate the library root scope from archive membership management; use `{{ commandName }} wikg://lib/arc/tree` when you want a file tree visualization.
34
35
  - For a non-default library, replace `wikg://lib` with `wikg://lib/<lib-id>` in those `arc` commands.
35
36
  - `{{ commandName }} <library-archive-uri>/path set <relative-wikg-path>` moves or renames one managed archive inside the same folder.
36
37
  - `{{ commandName }} <library-archive-uri> remove --confirm` deletes one managed archive file and unregisters it.
37
38
  - Missing registered files remain visible as missing or stale until `arc scan`, archive `path set`, archive `remove`, or library `path set` resolves them.
38
39
 
39
40
  Library archive shortcuts:
40
- - `wikg://lib/arc/<archive-id>/` addresses one archive membership in the default library.
41
- - `wikg://lib/<lib-id>/arc/<archive-id>/` addresses one archive membership in a non-default library.
41
+ - `wikg://lib/arc/<archive-id>/` addresses one archive member page in the default library.
42
+ - `wikg://lib/<lib-id>/arc/<archive-id>/` addresses one archive member page in a non-default library.
43
+ - The archive member page exposes the managed archive's business entry URIs (`/chapter`, `/entity`, `/triple`, and `inspect`) and keeps registry fields as diagnostic metadata.
42
44
  - Add normal archive object suffixes after the trailing slash to query that archive's contents:
43
45
  {{ commandName }} wikg://lib/arc/<archive-id>/chapter
44
46
  {{ commandName }} wikg://lib/arc/<archive-id>/entity --query "term"
@@ -48,6 +50,7 @@ Library archive shortcuts:
48
50
  - `{{ commandName }} <library-archive-uri>/entity --help` explains the archive object scope reached through that library shortcut.
49
51
 
50
52
  Library-wide query:
53
+ - `{{ commandName }} wikg://lib --query <archive-term>` searches library-wide objects through the library index.
51
54
  - `{{ commandName }} wikg://lib/entity --query <query>` searches across present archive members through the library index.
52
55
  - `{{ commandName }} wikg://lib/triple --query <query>` searches library-wide Knowledge Graph triples.
53
56
  - `{{ commandName }} wikg://lib/chunk --query <query>` searches library-wide Reading Graph chunks.
@@ -68,7 +71,7 @@ Library index lifecycle:
68
71
  Concurrency:
69
72
  - Library registry and membership writes hold the library write lock.
70
73
  - `arc scan`, `arc add`, library `path set`, library archive `path set`, library archive `remove`, and library index `enable` or `disable` cannot run concurrently for the same library.
71
- - Library-wide `--query`, naked scope enumeration, evidence, related, and pack commands read the current aggregate index.
74
+ - Library-wide object `--query`, object scope enumeration, evidence, related, and pack commands read the current aggregate index.
72
75
  - If a write marks the aggregate index dirty, rebuild it with `{{ commandName }} <library-uri>/index enable` before relying on library-wide query results.
73
76
 
74
77
  Upgrade and cleanup:
@@ -23,6 +23,8 @@ Archive locator:
23
23
  Library locators:
24
24
  - `wikg://lib` addresses the default library.
25
25
  - `wikg://lib/<lib-id>` addresses a non-default library.
26
+ - Naked library scopes enumerate library-wide objects; `--query` on a naked library scope searches library-wide objects through the library index.
27
+ - Use explicit object lenses such as `/entity`, `/triple`, `/chapter`, or `/chunk` for archive object search.
26
28
  - `wikg://lib/arc/<archive-id>/` addresses one archive membership in the default library.
27
29
  - `wikg://lib/<lib-id>/arc/<archive-id>/` addresses one archive membership in a non-default library.
28
30
  - Add ordinary archive object suffixes after the trailing slash to query a managed archive:
package/dist/gc-worker.js CHANGED
@@ -497,7 +497,7 @@ WHERE state IN ('succeeded', 'failed', 'canceled')
497
497
  heartbeat_at INTEGER NOT NULL,
498
498
  created_at INTEGER NOT NULL
499
499
  );
500
- `,sI="library",ff=300*1e3});import{randomBytes as Ree}from"crypto";import{constants as Tee}from"fs";import{access as Cee,mkdir as Pee,stat as Aee}from"fs/promises";import{join as Oee,resolve as Nee}from"path";var Nt=i(()=>{"use strict";f();I();N();Pe();b();qr();ka()});import{createHash as $ee}from"crypto";import{mkdir as Jee,readdir as hI,rm as fI,stat as zee,writeFile as Qee}from"fs/promises";import{join as gf}from"path";async function bf(e){let t=gf(q(),"library"),r=await yI();if(r===void 0)return{freedBytes:0,removed:0,scanned:0};let n=new Set(r.map(d=>String(d))),a=await hI(t,{withFileTypes:!0}).catch(d=>{if(h(d)&&d.code==="ENOENT")return[];throw d}),o=0,s=0,c=0;for(let d of a){if(!d.isDirectory()||(o+=1,n.has(d.name)))continue;let m=Number(d.name);if(Number.isInteger(m)&&await yf(m))continue;let p=gf(t,d.name),S=await F(p);e.dryRun||await fI(p,{force:!0,recursive:!0}),s+=1,c+=S}return{freedBytes:c,removed:s,scanned:o}}async function yI(){let e=await v(j(),"");try{return await e.queryAll("SELECT id FROM libraries",void 0,t=>g(t,"id"))}catch{return}finally{await e.close()}}var Kr=i(()=>{"use strict";f();He();Xt();I();ue();rr();Tt();Wr();N();b();Jr();Nt();qr()});import{randomBytes as pte}from"crypto";import{constants as fte,copyFile as yte,mkdir as gte,opendir as bte,realpath as Ste,rename as wte,rm as Ete,stat as kte}from"fs/promises";import{dirname as xte,isAbsolute as Rte,join as vte,relative as Tte,resolve as _te}from"path";var bI,Fte,Jr=i(()=>{"use strict";f();I();N();Pe();ue();b();Nt();Kr();qr();bI=`
500
+ `,sI="library",ff=300*1e3});import{randomBytes as Ree}from"crypto";import{constants as Tee}from"fs";import{access as Cee,mkdir as Pee,stat as Aee}from"fs/promises";import{join as Oee,resolve as Nee}from"path";var Nt=i(()=>{"use strict";f();I();N();Pe();b();qr();ka()});import{createHash as $ee}from"crypto";import{mkdir as Jee,readdir as hI,rm as fI,stat as zee,writeFile as Qee}from"fs/promises";import{join as gf}from"path";async function bf(e){let t=gf(q(),"library"),r=await yI();if(r===void 0)return{freedBytes:0,removed:0,scanned:0};let n=new Set(r.map(d=>String(d))),a=await hI(t,{withFileTypes:!0}).catch(d=>{if(h(d)&&d.code==="ENOENT")return[];throw d}),o=0,s=0,c=0;for(let d of a){if(!d.isDirectory()||(o+=1,n.has(d.name)))continue;let m=Number(d.name);if(Number.isInteger(m)&&await yf(m))continue;let p=gf(t,d.name),S=await F(p);e.dryRun||await fI(p,{force:!0,recursive:!0}),s+=1,c+=S}return{freedBytes:c,removed:s,scanned:o}}async function yI(){let e=await v(j(),"");try{return await e.queryAll("SELECT id FROM libraries",void 0,t=>g(t,"id"))}catch{return}finally{await e.close()}}var Kr=i(()=>{"use strict";f();He();Xt();I();ue();rr();Tt();Wr();N();b();Jr();Nt();qr()});import{randomBytes as hte}from"crypto";import{constants as yte,copyFile as gte,mkdir as bte,opendir as Ste,realpath as wte,rename as Ete,rm as kte,stat as Ite}from"fs/promises";import{dirname as Rte,isAbsolute as vte,join as Tte,relative as _te,resolve as Cte}from"path";var bI,jte,Jr=i(()=>{"use strict";f();I();N();Pe();ue();b();Nt();Kr();qr();bI=`
501
501
  id INTEGER PRIMARY KEY AUTOINCREMENT,
502
502
  library_id INTEGER NOT NULL,
503
503
  public_id TEXT NOT NULL,
@@ -510,7 +510,7 @@ WHERE state IN ('succeeded', 'failed', 'canceled')
510
510
  created_at TEXT NOT NULL,
511
511
  updated_at TEXT NOT NULL,
512
512
  UNIQUE(library_id, public_id)
513
- `,Fte=`
513
+ `,jte=`
514
514
  CREATE TABLE IF NOT EXISTS library_archives (
515
515
  ${bI}
516
516
  );
@@ -542,7 +542,7 @@ CREATE TABLE IF NOT EXISTS gc_locks (
542
542
  created_at INTEGER NOT NULL
543
543
  );
544
544
  `,PI=6e4,AI=2e4});import{readdir as Rf,rm as FI,stat as jI}from"fs/promises";import{join as vf}from"path";async function Tf(e){let t=Vs(),r=0,n=0,a=0;for(let o of await BI(t)){r+=1;let s=await jI(o).catch(d=>{if(!(h(d)&&d.code==="ENOENT"))throw d});if(s===void 0||!e.force&&e.now-s.mtimeMs<GI)continue;let c=await F(o);e.dryRun||await FI(o,{force:!0,recursive:!0}),n+=1,a+=c}return{freedBytes:a,removed:n,scanned:r}}async function BI(e){try{let t=await Rf(e,{withFileTypes:!0}),r=[];for(let n of t){if(!n.isDirectory())continue;let a=vf(e,n.name),o=await Rf(a,{withFileTypes:!0});for(let s of o)r.push(vf(a,s.name))}return r}catch(t){if(h(t)&&t.code==="ENOENT")return[];throw t}}var GI,_f=i(()=>{"use strict";pe();b();Wr();GI=3600*1e3});import{mkdir as UI,readFile as HI,writeFile as qI}from"fs/promises";import{join as $I}from"path";async function Ri(e={}){let t=Date.now(),r=ct(),n=await If();if(n===void 0)return{finishedAt:Date.now(),freedBytes:0,jobs:[],removed:0,scanned:0,skipped:!0,startedAt:t};try{if(e.opportunistic===!0&&!await QI(r,t))return{finishedAt:Date.now(),freedBytes:0,jobs:[],removed:0,scanned:0,skipped:!0,startedAt:t};let a={dryRun:e.dryRun===!0,force:e.force===!0,now:t,stateDirectoryPath:r},o=[];for(let c of KI)o.push(await zI(c,a));let s={finishedAt:Date.now(),freedBytes:qs(o,"freedBytes"),jobs:o,removed:qs(o,"removed"),scanned:qs(o,"scanned"),skipped:!1,startedAt:t};return await XI(r,s.finishedAt).catch(()=>{}),s}finally{await n()}}async function zI(e,t){try{return{name:e.name,...await e.run(t)}}catch(r){return{error:Be(r),freedBytes:0,name:e.name,removed:0,scanned:0}}}function qs(e,t){return e.reduce((r,n)=>{let a=n[t];return r+(typeof a=="number"?a:0)},0)}async function QI(e,t){let r=Number((await HI(Cf(e),"utf8").catch(()=>"")).trim());return!Number.isFinite(r)||t-r>=JI}async function XI(e,t){await UI(e,{recursive:!0}),await qI(Cf(e),`${t}
545
- `,"utf8")}function Cf(e){return $I(e,"gc.last-run")}var KI,JI,Pf=i(()=>{"use strict";pe();yt();Fe();ue();Sr();xi();b();xf();_f();KI=[{name:"wikg-coordinator",run:hi},{name:"search-cache",run:sn},{name:"library-index",run:bf},{name:"wikipage-cache",run:ja},{name:"build-queue",run:wi},{name:"tmp",run:Tf}],JI=600*1e3});var Af=i(()=>{"use strict";Pf()});Af();Se();nn();b();import{mkdir as Vre,readFile as Yre,rm as Zre,writeFile as ene}from"fs/promises";import{join as rne,resolve as nne}from"path";import{z as zr}from"zod";var VI=1,sne=zr.object({completedAt:zr.string().optional(),startedAt:zr.string(),status:zr.enum(["running","succeeded"]),version:zr.literal(VI)});ho();Tr();V();Nn();Dn();xi();N();pe();gt();Sr();it();fs();Fe();ye();ue();I();Ke();yt();ri();xi();N();import{rm as Qie}from"fs/promises";import{homedir as Vie}from"os";import{resolve as Zie}from"path";pe();I();ue();import{rm as Mie}from"fs/promises";import{join as Fie,resolve as jie}from"path";import{createWriteStream as Tne}from"fs";import{mkdir as Cne}from"fs/promises";import{dirname as Ane,resolve as Lne}from"path";import{pipeline as Nne}from"stream/promises";import{posix as pne,resolve as hne,sep as fne}from"path";import{open as gne}from"yauzl";f();f();import{rm as Eie}from"fs/promises";import{join as Iie}from"path";b();import{readFile as Hne,readdir as qne}from"fs/promises";import{join as Kne}from"path";f();import{join as Xne}from"path";ua();b();import{readFile as tie,readdir as rie}from"fs/promises";import{join as iie}from"path";import{mkdir as die,writeFile as uie}from"fs/promises";import{join as mie}from"path";ue();ri();Tt();b();Fe();Tt();Fe();Fe();Fe();Fe();We();it();I();Ot();var ox=["WIKIGRAPH_DEV","WIKIGRAPH_ENV_POLICY","WIKIGRAPH_QUEUE_DISABLE_AUTOSTART","WIKIGRAPH_STATE_DIR"];function Of(e){let t=sx(e.env);if(e.envPolicy==="production"){let o=ox.filter(s=>t[s]!==void 0);if(o.length>0)throw new Error(`Wiki Graph production entries do not support runtime env overrides: ${o.join(", ")}. Use the development entry or explicit SDK options instead.`);return{env:t,envPolicy:e.envPolicy,stateDir:e.stateDir}}let r=t.WIKIGRAPH_DEV??t.WIKIGRAPH_STATE_DIR,n=Lf(e.stateDir??r);if(n===void 0)throw new Error("Wiki Graph development entries require an explicit runtime state directory.");let a=Lf(e.devProjectRoot);if(a===void 0)throw new Error("Wiki Graph development entries require an explicit project root.");return{devProjectRoot:a,env:t,envPolicy:e.envPolicy,stateDir:n}}function sx(e){return e===void 0?{...process.env}:{...process.env,...e}}function Lf(e){if(!(e===void 0||e.trim()===""))return e}var Nf="--wikigraph-internal-child",Df="--wikigraph-state-dir";async function Mf(e,t){let r=cx(process.argv.slice(2));if(r.internalChild!==e)throw new Error("This Wiki Graph worker entry is internal.");let n=Of({argv:r.argv,envPolicy:"production",stateDir:r.stateDir});return await vi(n.stateDir,()=>t(r))}function cx(e){let t=[],r,n;for(let a=0;a<e.length;a+=1){let o=e[a];if(o===Nf){if(a+1>=e.length)throw new Error(`${Nf} requires a value.`);r=e[a+1],a+=1;continue}if(o!==Df){t.push(o);continue}if(a+1>=e.length)throw new Error(`${Df} requires a value.`);n=e[a+1],a+=1}return{argv:t,internalChild:r??"",stateDir:n}}var dx={command:`${"wg"} --help`,config:`${"wg"} help config`,format:`${"wg"} help format`,readiness:`${"wg"} help readiness`,root:`${"wg"} --help`,runtime:`${"wg"} help runtime`,uri:`${"wg"} help uri`};import{extname as Goe}from"path";import{createReadStream as Voe}from"fs";import{rm as Zoe}from"fs/promises";import{join as tse}from"path";import{AsyncLocalStorage as ux}from"async_hooks";var qoe=new ux;var lx=new Map(["at","seq","uri","id","jobId","type","target","label","labels","title","state","name","qid","predicate","subjectLabel","objectLabel","subjectQid","objectQid","score","queueRank","chapter","chapterId","fragment","fragmentId","position","range","start","end","shown","total","count","mentionCount","nodeCount","edgeCount","summaryCount","limit","order","match","lens","terms","types","chapters","query","objects","items","nextCursor","archiveKey","archivePath","workspacePath","eventsPath","createdAt","updatedAt","finishedAt","currentStep","step","phase","phaseDetail","phaseDone","phaseTotal","phaseUnit","words","totalWords","outputTokens","authors","language","identifier","publisher","publishedAt","sourceFormat","snippet","summary","description","recommendation","risk","error","message","children","nodes","links","neighbors","incoming","outgoing","nodeGroups","sourceFragments","sources","tree","meta","evidence","content","source","text","prompt","llmJSON","errorJSON"].map((e,t)=>[e,t]));function Wf(e){return`${JSON.stringify($s(e),null,2)}
546
- `}function $s(e){if(e===null||typeof e=="boolean"||typeof e=="number"||typeof e=="string")return e;if(Array.isArray(e))return e.map(t=>$s(t)??null);if(typeof e=="object")return mx(e)}function mx(e){let t=Object.entries(e).map(([n,a],o)=>({index:o,key:n,priority:lx.get(n)??Number.MAX_SAFE_INTEGER,value:a})),r={};for(let n of t.sort((a,o)=>a.priority-o.priority||a.index-o.index)){let a=$s(n.value);a!==void 0&&(r[n.key]=a)}return r}import{existsSync as lse,readFileSync as mse}from"fs";import{dirname as hse,join as fse,parse as yse,resolve as gse}from"path";async function px(){await Mf("gc-worker",async({argv:e})=>{let t=hx(e);process.stdout.write(Wf(await Ri({dryRun:t.dryRun,force:t.force})))})}function hx(e){return{dryRun:e.includes("--dry-run"),force:e.includes("--force")}}px().catch(e=>{process.stderr.write(`${e instanceof Error?e.stack??e.message:String(e)}
545
+ `,"utf8")}function Cf(e){return $I(e,"gc.last-run")}var KI,JI,Pf=i(()=>{"use strict";pe();yt();Fe();ue();Sr();xi();b();xf();_f();KI=[{name:"wikg-coordinator",run:hi},{name:"search-cache",run:sn},{name:"library-index",run:bf},{name:"wikipage-cache",run:ja},{name:"build-queue",run:wi},{name:"tmp",run:Tf}],JI=600*1e3});var Af=i(()=>{"use strict";Pf()});Af();Se();nn();b();import{mkdir as Yre,readFile as Zre,rm as ene,writeFile as tne}from"fs/promises";import{join as nne,resolve as ine}from"path";import{z as zr}from"zod";var VI=1,cne=zr.object({completedAt:zr.string().optional(),startedAt:zr.string(),status:zr.enum(["running","succeeded"]),version:zr.literal(VI)});ho();Tr();V();Nn();Dn();xi();N();pe();gt();Sr();it();fs();Fe();ye();ue();I();Ke();yt();ri();xi();N();import{rm as Xie}from"fs/promises";import{homedir as Yie}from"os";import{resolve as eae}from"path";pe();I();ue();import{rm as Wie}from"fs/promises";import{join as jie,resolve as Gie}from"path";import{createWriteStream as _ne}from"fs";import{mkdir as Pne}from"fs/promises";import{dirname as Lne,resolve as One}from"path";import{pipeline as Dne}from"stream/promises";import{posix as hne,resolve as fne,sep as yne}from"path";import{open as bne}from"yauzl";f();f();import{rm as kie}from"fs/promises";import{join as xie}from"path";b();import{readFile as qne,readdir as $ne}from"fs/promises";import{join as Jne}from"path";f();import{join as Vne}from"path";ua();b();import{readFile as rie,readdir as nie}from"fs/promises";import{join as aie}from"path";import{mkdir as uie,writeFile as lie}from"fs/promises";import{join as pie}from"path";ue();ri();Tt();b();Fe();Tt();Fe();Fe();Fe();Fe();We();it();I();Ot();var ox=["WIKIGRAPH_DEV","WIKIGRAPH_ENV_POLICY","WIKIGRAPH_QUEUE_DISABLE_AUTOSTART","WIKIGRAPH_STATE_DIR"];function Of(e){let t=sx(e.env);if(e.envPolicy==="production"){let o=ox.filter(s=>t[s]!==void 0);if(o.length>0)throw new Error(`Wiki Graph production entries do not support runtime env overrides: ${o.join(", ")}. Use the development entry or explicit SDK options instead.`);return{env:t,envPolicy:e.envPolicy,stateDir:e.stateDir}}let r=t.WIKIGRAPH_DEV??t.WIKIGRAPH_STATE_DIR,n=Lf(e.stateDir??r);if(n===void 0)throw new Error("Wiki Graph development entries require an explicit runtime state directory.");let a=Lf(e.devProjectRoot);if(a===void 0)throw new Error("Wiki Graph development entries require an explicit project root.");return{devProjectRoot:a,env:t,envPolicy:e.envPolicy,stateDir:n}}function sx(e){return e===void 0?{...process.env}:{...process.env,...e}}function Lf(e){if(!(e===void 0||e.trim()===""))return e}var Nf="--wikigraph-internal-child",Df="--wikigraph-state-dir";async function Mf(e,t){let r=cx(process.argv.slice(2));if(r.internalChild!==e)throw new Error("This Wiki Graph worker entry is internal.");let n=Of({argv:r.argv,envPolicy:"production",stateDir:r.stateDir});return await vi(n.stateDir,()=>t(r))}function cx(e){let t=[],r,n;for(let a=0;a<e.length;a+=1){let o=e[a];if(o===Nf){if(a+1>=e.length)throw new Error(`${Nf} requires a value.`);r=e[a+1],a+=1;continue}if(o!==Df){t.push(o);continue}if(a+1>=e.length)throw new Error(`${Df} requires a value.`);n=e[a+1],a+=1}return{argv:t,internalChild:r??"",stateDir:n}}var dx={command:`${"wg"} --help`,config:`${"wg"} help config`,format:`${"wg"} help format`,readiness:`${"wg"} help readiness`,root:`${"wg"} --help`,runtime:`${"wg"} help runtime`,uri:`${"wg"} help uri`};import{extname as Hoe}from"path";import{createReadStream as ese}from"fs";import{rm as rse}from"fs/promises";import{join as ise}from"path";import{AsyncLocalStorage as ux}from"async_hooks";var Joe=new ux;var lx=new Map(["at","seq","uri","id","jobId","type","target","label","labels","title","state","name","qid","predicate","subjectLabel","objectLabel","subjectQid","objectQid","score","queueRank","chapter","chapterId","fragment","fragmentId","position","range","start","end","shown","total","count","mentionCount","nodeCount","edgeCount","summaryCount","limit","order","match","lens","terms","types","chapters","query","objects","items","nextCursor","archiveKey","archivePath","workspacePath","eventsPath","createdAt","updatedAt","finishedAt","currentStep","step","phase","phaseDetail","phaseDone","phaseTotal","phaseUnit","words","totalWords","outputTokens","authors","language","identifier","publisher","publishedAt","sourceFormat","snippet","summary","description","recommendation","risk","error","message","children","nodes","links","neighbors","incoming","outgoing","nodeGroups","sourceFragments","sources","tree","meta","evidence","content","source","text","prompt","llmJSON","errorJSON"].map((e,t)=>[e,t]));function Wf(e){return`${JSON.stringify($s(e),null,2)}
546
+ `}function $s(e){if(e===null||typeof e=="boolean"||typeof e=="number"||typeof e=="string")return e;if(Array.isArray(e))return e.map(t=>$s(t)??null);if(typeof e=="object")return mx(e)}function mx(e){let t=Object.entries(e).map(([n,a],o)=>({index:o,key:n,priority:lx.get(n)??Number.MAX_SAFE_INTEGER,value:a})),r={};for(let n of t.sort((a,o)=>a.priority-o.priority||a.index-o.index)){let a=$s(n.value);a!==void 0&&(r[n.key]=a)}return r}import{existsSync as hse,readFileSync as fse}from"fs";import{dirname as gse,join as bse,parse as Sse,resolve as wse}from"path";async function px(){await Mf("gc-worker",async({argv:e})=>{let t=hx(e);process.stdout.write(Wf(await Ri({dryRun:t.dryRun,force:t.force})))})}function hx(e){return{dryRun:e.includes("--dry-run"),force:e.includes("--force")}}px().catch(e=>{process.stderr.write(`${e instanceof Error?e.stack??e.message:String(e)}
547
547
  `),process.exitCode=1});
548
548
  //# sourceMappingURL=gc-worker.js.map