wiki-graph-sdk 0.8.3 → 0.9.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.
- package/README.md +5 -0
- package/dist/archives.cjs +405 -25
- package/dist/archives.cjs.map +1 -1
- package/dist/archives.d.ts +4 -216
- package/dist/archives.js +409 -25
- package/dist/archives.js.map +1 -1
- package/dist/conversions.cjs +3 -2
- package/dist/conversions.cjs.map +1 -1
- package/dist/conversions.js +3 -2
- package/dist/conversions.js.map +1 -1
- package/dist/default-worker.cjs +22 -9
- package/dist/default-worker.cjs.map +1 -1
- package/dist/default-worker.js +23 -9
- package/dist/default-worker.js.map +1 -1
- package/dist/index-DQzLAnjf.d.ts +346 -0
- package/dist/index.cjs +690 -90
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +19 -11
- package/dist/index.js +686 -94
- package/dist/index.js.map +1 -1
- package/dist/maintenance.cjs +3 -2
- package/dist/maintenance.cjs.map +1 -1
- package/dist/maintenance.js +3 -2
- package/dist/maintenance.js.map +1 -1
- package/dist/worker.cjs +22 -9
- package/dist/worker.cjs.map +1 -1
- package/dist/worker.js +23 -9
- package/dist/worker.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -31,6 +31,11 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
// src/index.ts
|
|
32
32
|
var src_exports = {};
|
|
33
33
|
__export(src_exports, {
|
|
34
|
+
ArchiveCollectionPage: () => ArchiveCollectionPage,
|
|
35
|
+
ArchiveEvidencePage: () => ArchiveEvidencePage,
|
|
36
|
+
ArchiveFindPage: () => ArchiveFindPage,
|
|
37
|
+
ArchiveRelatedPage: () => ArchiveRelatedPage,
|
|
38
|
+
ArchiveSourceLocatorPage: () => ArchiveSourceLocatorPage,
|
|
34
39
|
DANGEROUS_RUNTIME_ENV_NAMES: () => DANGEROUS_RUNTIME_ENV_NAMES,
|
|
35
40
|
DEFAULT_EXTRACTION_PROMPT: () => import_wiki_graph_core10.DEFAULT_EXTRACTION_PROMPT,
|
|
36
41
|
DEFAULT_GENERATION_JOB_CONCURRENCY: () => DEFAULT_GENERATION_JOB_CONCURRENCY,
|
|
@@ -38,6 +43,7 @@ __export(src_exports, {
|
|
|
38
43
|
DEFAULT_KNOWLEDGE_GRAPH_RECALL_PROMPT: () => import_wiki_graph_core10.DEFAULT_KNOWLEDGE_GRAPH_RECALL_PROMPT,
|
|
39
44
|
LLMPaymentRequiredError: () => import_wiki_graph_core19.LLMPaymentRequiredError,
|
|
40
45
|
LOCAL_CONFIG_SECTIONS: () => LOCAL_CONFIG_SECTIONS,
|
|
46
|
+
LibraryBucketPage: () => LibraryBucketPage,
|
|
41
47
|
NodeDirectory: () => NodeDirectory,
|
|
42
48
|
NodeFile: () => NodeFile,
|
|
43
49
|
WIKI_GRAPH_URI_PREFIX: () => import_wiki_graph_core19.WIKI_GRAPH_URI_PREFIX,
|
|
@@ -58,11 +64,19 @@ __export(src_exports, {
|
|
|
58
64
|
buildSearchIndexEmbeddingProvider: () => buildSearchIndexEmbeddingProvider,
|
|
59
65
|
buildWikiGraphLLMOptions: () => buildWikiGraphLLMOptions,
|
|
60
66
|
clearLocalConfigSection: () => clearLocalConfigSection,
|
|
67
|
+
createArchiveCollectionPage: () => createArchiveCollectionPage,
|
|
68
|
+
createArchiveEvidencePage: () => createArchiveEvidencePage,
|
|
69
|
+
createArchiveFindPage: () => createArchiveFindPage,
|
|
70
|
+
createArchiveRelatedPage: () => createArchiveRelatedPage,
|
|
71
|
+
createArchiveSourceLocatorPage: () => createArchiveSourceLocatorPage,
|
|
72
|
+
createCursor: () => createCursor,
|
|
61
73
|
createEntryRuntimeContext: () => createEntryRuntimeContext,
|
|
62
74
|
createGenerationPerformanceHints: () => createGenerationPerformanceHints,
|
|
75
|
+
createLibraryBucketPage: () => createLibraryBucketPage,
|
|
63
76
|
createNodeTemplateEnvironment: () => createNodeTemplateEnvironment,
|
|
64
77
|
createNodeWikiGraphPlatform: () => createNodeWikiGraphPlatform,
|
|
65
78
|
createNodeWikiGraphStorage: () => createNodeWikiGraphStorage,
|
|
79
|
+
createPageCursor: () => createPageCursor,
|
|
66
80
|
createStageLLM: () => createStageLLM,
|
|
67
81
|
createWikiGraphSDK: () => createWikiGraphSDK,
|
|
68
82
|
deleteLocalConfigValue: () => deleteLocalConfigValue,
|
|
@@ -90,6 +104,8 @@ __export(src_exports, {
|
|
|
90
104
|
isWikiGraphJobUri: () => import_wiki_graph_core19.isWikiGraphJobUri,
|
|
91
105
|
isWikiGraphLibraryUri: () => import_wiki_graph_core19.isWikiGraphLibraryUri,
|
|
92
106
|
isWikiGraphUri: () => import_wiki_graph_core19.isWikiGraphUri,
|
|
107
|
+
iterateItems: () => iterateItems,
|
|
108
|
+
iteratePages: () => iteratePages,
|
|
93
109
|
loadRequiredStageConfig: () => loadRequiredStageConfig,
|
|
94
110
|
loadWikiGraphRuntimeConfig: () => loadWikiGraphRuntimeConfig,
|
|
95
111
|
maskLocalConfigSection: () => maskLocalConfigSection,
|
|
@@ -1489,6 +1505,9 @@ function resolveWikiGraphRuntimePath(path) {
|
|
|
1489
1505
|
var import_promises3 = require("fs/promises");
|
|
1490
1506
|
var import_path3 = require("path");
|
|
1491
1507
|
var import_wiki_graph_core2 = require("wiki-graph-core");
|
|
1508
|
+
function requireWikiGraphArchiveFile(location) {
|
|
1509
|
+
return location.archiveFile;
|
|
1510
|
+
}
|
|
1492
1511
|
var WikiGraphArchiveOwnershipError = class extends Error {
|
|
1493
1512
|
code = "WIKI_GRAPH_ARCHIVE_OWNERSHIP_MISMATCH";
|
|
1494
1513
|
constructor(message) {
|
|
@@ -1635,11 +1654,12 @@ async function findMatchingMembers(libraries, candidate, candidateIdentity) {
|
|
|
1635
1654
|
...library.isDefault ? {} : { publicId: library.publicId }
|
|
1636
1655
|
});
|
|
1637
1656
|
for (const archive of archives) {
|
|
1638
|
-
|
|
1657
|
+
const physical = archive.file ?? archive.directory;
|
|
1658
|
+
if (physical === void 0) continue;
|
|
1639
1659
|
members.push({
|
|
1640
1660
|
archive,
|
|
1641
1661
|
library,
|
|
1642
|
-
memberPath: getNodeResourcePath(
|
|
1662
|
+
memberPath: getNodeResourcePath(physical)
|
|
1643
1663
|
});
|
|
1644
1664
|
}
|
|
1645
1665
|
}
|
|
@@ -2150,13 +2170,25 @@ function formatLocatedChapterUri(archiveUri, chapter) {
|
|
|
2150
2170
|
var import_wiki_graph_core6 = require("wiki-graph-core");
|
|
2151
2171
|
async function writeWikiGraphArchiveLocation(location, operation, options = {}) {
|
|
2152
2172
|
const cacheOnly = options.searchIndexWritebackPolicy === "cache";
|
|
2153
|
-
const write = async (archiveFile = location.archiveFile) =>
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
invalidateContinuationCursors:
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2173
|
+
const write = async (archiveFile = location.archiveFile) => {
|
|
2174
|
+
const writeOptions = {
|
|
2175
|
+
...cacheOnly ? {} : { derivedStateKeys: [location.archiveKey, location.archivePath] },
|
|
2176
|
+
...options.invalidateContinuationCursors === void 0 ? {} : {
|
|
2177
|
+
invalidateContinuationCursors: options.invalidateContinuationCursors
|
|
2178
|
+
},
|
|
2179
|
+
...options.searchIndexWritebackPolicy === void 0 ? {} : { searchIndexWritebackPolicy: options.searchIndexWritebackPolicy }
|
|
2180
|
+
};
|
|
2181
|
+
if (archiveFile.kind === "directory") {
|
|
2182
|
+
return await new import_wiki_graph_core6.WikiGraphDirectoryFile(archiveFile).write(
|
|
2183
|
+
operation,
|
|
2184
|
+
writeOptions
|
|
2185
|
+
);
|
|
2186
|
+
}
|
|
2187
|
+
return await new import_wiki_graph_core6.WikiGraphArchiveFile(archiveFile).write(
|
|
2188
|
+
operation,
|
|
2189
|
+
writeOptions
|
|
2190
|
+
);
|
|
2191
|
+
};
|
|
2160
2192
|
if (location.libraryArchiveTarget === void 0 || cacheOnly || options.refreshLibraryIndex === false) {
|
|
2161
2193
|
return await write();
|
|
2162
2194
|
}
|
|
@@ -2171,6 +2203,294 @@ async function writeWikiGraphArchiveLocation(location, operation, options = {})
|
|
|
2171
2203
|
});
|
|
2172
2204
|
}
|
|
2173
2205
|
|
|
2206
|
+
// src/pages.ts
|
|
2207
|
+
function createCursor(implementation) {
|
|
2208
|
+
let released = false;
|
|
2209
|
+
const assertLive = () => {
|
|
2210
|
+
if (released) throw new Error("Cursor has been released.");
|
|
2211
|
+
};
|
|
2212
|
+
return {
|
|
2213
|
+
pageClass: implementation.pageClass,
|
|
2214
|
+
async next(options = {}) {
|
|
2215
|
+
assertLive();
|
|
2216
|
+
return await implementation.next(options);
|
|
2217
|
+
},
|
|
2218
|
+
async token() {
|
|
2219
|
+
assertLive();
|
|
2220
|
+
return await implementation.token();
|
|
2221
|
+
},
|
|
2222
|
+
async release() {
|
|
2223
|
+
if (released) return;
|
|
2224
|
+
released = true;
|
|
2225
|
+
await implementation.release?.();
|
|
2226
|
+
}
|
|
2227
|
+
};
|
|
2228
|
+
}
|
|
2229
|
+
function createPageCursor(implementation) {
|
|
2230
|
+
let token;
|
|
2231
|
+
return createCursor({
|
|
2232
|
+
pageClass: implementation.pageClass,
|
|
2233
|
+
next: async (options) => await implementation.next(implementation.rawCursor, options),
|
|
2234
|
+
token: async () => {
|
|
2235
|
+
token ??= await implementation.createToken(implementation.rawCursor);
|
|
2236
|
+
return token;
|
|
2237
|
+
},
|
|
2238
|
+
release: async () => {
|
|
2239
|
+
if (token !== void 0) await implementation.releaseToken?.(token);
|
|
2240
|
+
token = void 0;
|
|
2241
|
+
}
|
|
2242
|
+
});
|
|
2243
|
+
}
|
|
2244
|
+
async function* iteratePages(firstPage, options = {}) {
|
|
2245
|
+
let page = firstPage;
|
|
2246
|
+
while (true) {
|
|
2247
|
+
yield page;
|
|
2248
|
+
const cursor = page.nextCursor();
|
|
2249
|
+
if (cursor === null) return;
|
|
2250
|
+
try {
|
|
2251
|
+
const nextPage = await cursor.next(options);
|
|
2252
|
+
await cursor.release();
|
|
2253
|
+
page = nextPage;
|
|
2254
|
+
} catch (error) {
|
|
2255
|
+
await cursor.release();
|
|
2256
|
+
throw error;
|
|
2257
|
+
}
|
|
2258
|
+
}
|
|
2259
|
+
}
|
|
2260
|
+
async function* iterateItems(firstPage, options = {}) {
|
|
2261
|
+
for await (const page of iteratePages(firstPage, options)) {
|
|
2262
|
+
yield* page;
|
|
2263
|
+
}
|
|
2264
|
+
}
|
|
2265
|
+
|
|
2266
|
+
// src/result-pages.ts
|
|
2267
|
+
var ArchiveFindPage = class _ArchiveFindPage {
|
|
2268
|
+
result;
|
|
2269
|
+
chapters;
|
|
2270
|
+
items;
|
|
2271
|
+
lens;
|
|
2272
|
+
lensHint;
|
|
2273
|
+
limit;
|
|
2274
|
+
match;
|
|
2275
|
+
rawNextCursor;
|
|
2276
|
+
order;
|
|
2277
|
+
query;
|
|
2278
|
+
terms;
|
|
2279
|
+
types;
|
|
2280
|
+
#cursor;
|
|
2281
|
+
constructor(result, cursor = null) {
|
|
2282
|
+
this.result = result;
|
|
2283
|
+
this.chapters = result.chapters;
|
|
2284
|
+
this.items = result.items;
|
|
2285
|
+
this.lens = result.lens;
|
|
2286
|
+
this.lensHint = result.lensHint;
|
|
2287
|
+
this.limit = result.limit;
|
|
2288
|
+
this.match = result.match;
|
|
2289
|
+
this.rawNextCursor = result.nextCursor;
|
|
2290
|
+
this.order = result.order;
|
|
2291
|
+
this.query = result.query;
|
|
2292
|
+
this.terms = result.terms;
|
|
2293
|
+
this.types = result.types;
|
|
2294
|
+
this.#cursor = cursor;
|
|
2295
|
+
}
|
|
2296
|
+
static pageClass = _ArchiveFindPage;
|
|
2297
|
+
[Symbol.iterator]() {
|
|
2298
|
+
return this.items[Symbol.iterator]();
|
|
2299
|
+
}
|
|
2300
|
+
nextCursor() {
|
|
2301
|
+
return this.#cursor;
|
|
2302
|
+
}
|
|
2303
|
+
};
|
|
2304
|
+
var ArchiveCollectionPage = class _ArchiveCollectionPage {
|
|
2305
|
+
result;
|
|
2306
|
+
chapters;
|
|
2307
|
+
ids;
|
|
2308
|
+
items;
|
|
2309
|
+
limit;
|
|
2310
|
+
rawNextCursor;
|
|
2311
|
+
order;
|
|
2312
|
+
types;
|
|
2313
|
+
#cursor;
|
|
2314
|
+
constructor(result, cursor = null) {
|
|
2315
|
+
this.result = result;
|
|
2316
|
+
this.chapters = result.chapters;
|
|
2317
|
+
this.ids = result.ids;
|
|
2318
|
+
this.items = result.items;
|
|
2319
|
+
this.limit = result.limit;
|
|
2320
|
+
this.rawNextCursor = result.nextCursor;
|
|
2321
|
+
this.order = result.order;
|
|
2322
|
+
this.types = result.types;
|
|
2323
|
+
this.#cursor = cursor;
|
|
2324
|
+
}
|
|
2325
|
+
static pageClass = _ArchiveCollectionPage;
|
|
2326
|
+
[Symbol.iterator]() {
|
|
2327
|
+
return this.items[Symbol.iterator]();
|
|
2328
|
+
}
|
|
2329
|
+
nextCursor() {
|
|
2330
|
+
return this.#cursor;
|
|
2331
|
+
}
|
|
2332
|
+
};
|
|
2333
|
+
var ArchiveEvidencePage = class _ArchiveEvidencePage {
|
|
2334
|
+
result;
|
|
2335
|
+
items;
|
|
2336
|
+
limit;
|
|
2337
|
+
rawNextCursor;
|
|
2338
|
+
#cursor;
|
|
2339
|
+
constructor(result, cursor = null) {
|
|
2340
|
+
this.result = result;
|
|
2341
|
+
this.items = result.items;
|
|
2342
|
+
this.limit = result.limit;
|
|
2343
|
+
this.rawNextCursor = result.nextCursor;
|
|
2344
|
+
this.#cursor = cursor;
|
|
2345
|
+
}
|
|
2346
|
+
static pageClass = _ArchiveEvidencePage;
|
|
2347
|
+
[Symbol.iterator]() {
|
|
2348
|
+
return this.items[Symbol.iterator]();
|
|
2349
|
+
}
|
|
2350
|
+
nextCursor() {
|
|
2351
|
+
return this.#cursor;
|
|
2352
|
+
}
|
|
2353
|
+
};
|
|
2354
|
+
var ArchiveRelatedPage = class _ArchiveRelatedPage {
|
|
2355
|
+
result;
|
|
2356
|
+
items;
|
|
2357
|
+
limit;
|
|
2358
|
+
rawNextCursor;
|
|
2359
|
+
#cursor;
|
|
2360
|
+
constructor(result, cursor = null) {
|
|
2361
|
+
this.result = result;
|
|
2362
|
+
this.items = result.items;
|
|
2363
|
+
this.limit = result.limit;
|
|
2364
|
+
this.rawNextCursor = result.nextCursor;
|
|
2365
|
+
this.#cursor = cursor;
|
|
2366
|
+
}
|
|
2367
|
+
static pageClass = _ArchiveRelatedPage;
|
|
2368
|
+
[Symbol.iterator]() {
|
|
2369
|
+
return this.items[Symbol.iterator]();
|
|
2370
|
+
}
|
|
2371
|
+
nextCursor() {
|
|
2372
|
+
return this.#cursor;
|
|
2373
|
+
}
|
|
2374
|
+
};
|
|
2375
|
+
var ArchiveSourceLocatorPage = class _ArchiveSourceLocatorPage {
|
|
2376
|
+
result;
|
|
2377
|
+
items;
|
|
2378
|
+
limit;
|
|
2379
|
+
rawNextCursor;
|
|
2380
|
+
#cursor;
|
|
2381
|
+
constructor(result, cursor = null) {
|
|
2382
|
+
this.result = result;
|
|
2383
|
+
this.items = result.items;
|
|
2384
|
+
this.limit = result.limit;
|
|
2385
|
+
this.rawNextCursor = result.nextCursor;
|
|
2386
|
+
this.#cursor = cursor;
|
|
2387
|
+
}
|
|
2388
|
+
static pageClass = _ArchiveSourceLocatorPage;
|
|
2389
|
+
[Symbol.iterator]() {
|
|
2390
|
+
return this.items[Symbol.iterator]();
|
|
2391
|
+
}
|
|
2392
|
+
nextCursor() {
|
|
2393
|
+
return this.#cursor;
|
|
2394
|
+
}
|
|
2395
|
+
};
|
|
2396
|
+
function createArchiveFindPage(result, next, createToken, releaseToken) {
|
|
2397
|
+
return new ArchiveFindPage(
|
|
2398
|
+
result,
|
|
2399
|
+
result.nextCursor === null ? null : createPageCursor({
|
|
2400
|
+
pageClass: ArchiveFindPage,
|
|
2401
|
+
rawCursor: result.nextCursor,
|
|
2402
|
+
next,
|
|
2403
|
+
createToken,
|
|
2404
|
+
releaseToken
|
|
2405
|
+
})
|
|
2406
|
+
);
|
|
2407
|
+
}
|
|
2408
|
+
function createArchiveCollectionPage(result, next, createToken, releaseToken) {
|
|
2409
|
+
return new ArchiveCollectionPage(
|
|
2410
|
+
result,
|
|
2411
|
+
result.nextCursor === null ? null : createPageCursor({
|
|
2412
|
+
pageClass: ArchiveCollectionPage,
|
|
2413
|
+
rawCursor: result.nextCursor,
|
|
2414
|
+
next,
|
|
2415
|
+
createToken,
|
|
2416
|
+
releaseToken
|
|
2417
|
+
})
|
|
2418
|
+
);
|
|
2419
|
+
}
|
|
2420
|
+
function createArchiveEvidencePage(result, next, createToken, releaseToken) {
|
|
2421
|
+
return new ArchiveEvidencePage(
|
|
2422
|
+
result,
|
|
2423
|
+
result.nextCursor === null ? null : createPageCursor({
|
|
2424
|
+
pageClass: ArchiveEvidencePage,
|
|
2425
|
+
rawCursor: result.nextCursor,
|
|
2426
|
+
next,
|
|
2427
|
+
createToken,
|
|
2428
|
+
releaseToken
|
|
2429
|
+
})
|
|
2430
|
+
);
|
|
2431
|
+
}
|
|
2432
|
+
function createArchiveRelatedPage(result, next, createToken, releaseToken) {
|
|
2433
|
+
return new ArchiveRelatedPage(
|
|
2434
|
+
result,
|
|
2435
|
+
result.nextCursor === null ? null : createPageCursor({
|
|
2436
|
+
pageClass: ArchiveRelatedPage,
|
|
2437
|
+
rawCursor: result.nextCursor,
|
|
2438
|
+
next,
|
|
2439
|
+
createToken,
|
|
2440
|
+
releaseToken
|
|
2441
|
+
})
|
|
2442
|
+
);
|
|
2443
|
+
}
|
|
2444
|
+
function createArchiveSourceLocatorPage(result, next, createToken, releaseToken) {
|
|
2445
|
+
return new ArchiveSourceLocatorPage(
|
|
2446
|
+
result,
|
|
2447
|
+
result.nextCursor === null ? null : createPageCursor({
|
|
2448
|
+
pageClass: ArchiveSourceLocatorPage,
|
|
2449
|
+
rawCursor: result.nextCursor,
|
|
2450
|
+
next,
|
|
2451
|
+
createToken,
|
|
2452
|
+
releaseToken
|
|
2453
|
+
})
|
|
2454
|
+
);
|
|
2455
|
+
}
|
|
2456
|
+
var LibraryBucketPage = class _LibraryBucketPage {
|
|
2457
|
+
id;
|
|
2458
|
+
items;
|
|
2459
|
+
rawNextCursor;
|
|
2460
|
+
query;
|
|
2461
|
+
terms;
|
|
2462
|
+
types;
|
|
2463
|
+
#cursor;
|
|
2464
|
+
constructor(result, cursor = null) {
|
|
2465
|
+
this.id = result.id;
|
|
2466
|
+
this.items = result.items;
|
|
2467
|
+
this.rawNextCursor = result.nextCursor;
|
|
2468
|
+
this.query = result.query;
|
|
2469
|
+
this.terms = result.terms;
|
|
2470
|
+
this.types = result.types;
|
|
2471
|
+
this.#cursor = cursor;
|
|
2472
|
+
}
|
|
2473
|
+
static pageClass = _LibraryBucketPage;
|
|
2474
|
+
[Symbol.iterator]() {
|
|
2475
|
+
return this.items[Symbol.iterator]();
|
|
2476
|
+
}
|
|
2477
|
+
nextCursor() {
|
|
2478
|
+
return this.#cursor;
|
|
2479
|
+
}
|
|
2480
|
+
};
|
|
2481
|
+
function createLibraryBucketPage(result, next, createToken, releaseToken) {
|
|
2482
|
+
return new LibraryBucketPage(
|
|
2483
|
+
result,
|
|
2484
|
+
result.nextCursor === null ? null : createPageCursor({
|
|
2485
|
+
pageClass: LibraryBucketPage,
|
|
2486
|
+
rawCursor: result.nextCursor,
|
|
2487
|
+
next,
|
|
2488
|
+
createToken,
|
|
2489
|
+
releaseToken
|
|
2490
|
+
})
|
|
2491
|
+
);
|
|
2492
|
+
}
|
|
2493
|
+
|
|
2174
2494
|
// src/archive/archive.ts
|
|
2175
2495
|
var WikiGraphArchiveExistsError = class extends Error {
|
|
2176
2496
|
code = "WIKI_GRAPH_ARCHIVE_EXISTS";
|
|
@@ -2258,6 +2578,14 @@ var WikiGraphArchiveHandle = class {
|
|
|
2258
2578
|
get target() {
|
|
2259
2579
|
return this.#location.target;
|
|
2260
2580
|
}
|
|
2581
|
+
async #persistCursor(cursor) {
|
|
2582
|
+
return await this.#runtime.run(
|
|
2583
|
+
async () => await (0, import_wiki_graph_core7.createContinuationCursor)(cursor)
|
|
2584
|
+
);
|
|
2585
|
+
}
|
|
2586
|
+
async #releaseCursor(cursor) {
|
|
2587
|
+
await this.#runtime.run(async () => await (0, import_wiki_graph_core7.deleteContinuationCursor)(cursor));
|
|
2588
|
+
}
|
|
2261
2589
|
async inspect(options = {}) {
|
|
2262
2590
|
return await this.#readDocument(
|
|
2263
2591
|
async (document) => await inspectWikiGraphArchive(document, {
|
|
@@ -2272,7 +2600,7 @@ var WikiGraphArchiveHandle = class {
|
|
|
2272
2600
|
options.queryMode,
|
|
2273
2601
|
options.signal
|
|
2274
2602
|
);
|
|
2275
|
-
|
|
2603
|
+
const result = await this.#writeDocument(
|
|
2276
2604
|
async (document) => {
|
|
2277
2605
|
const chapters = await this.#resolveQueryChapters(document, options, {
|
|
2278
2606
|
embeddingProvider
|
|
@@ -2293,9 +2621,38 @@ var WikiGraphArchiveHandle = class {
|
|
|
2293
2621
|
...options.signal === void 0 ? {} : { signal: options.signal }
|
|
2294
2622
|
}
|
|
2295
2623
|
);
|
|
2624
|
+
return createArchiveFindPage(
|
|
2625
|
+
result,
|
|
2626
|
+
async (cursor, nextOptions) => await this.search(query, {
|
|
2627
|
+
...options,
|
|
2628
|
+
cursor,
|
|
2629
|
+
...nextOptions.limit === void 0 ? {} : { limit: nextOptions.limit },
|
|
2630
|
+
...nextOptions.signal === void 0 ? {} : { signal: nextOptions.signal }
|
|
2631
|
+
}),
|
|
2632
|
+
(cursor) => this.#persistCursor({
|
|
2633
|
+
archiveKey: this.archiveKey,
|
|
2634
|
+
archivePath: this.path,
|
|
2635
|
+
chapters: options.chapters ?? null,
|
|
2636
|
+
cursor,
|
|
2637
|
+
format: "json",
|
|
2638
|
+
indexScope: this.indexScope,
|
|
2639
|
+
kind: "search",
|
|
2640
|
+
...options.backlinks === void 0 ? {} : { backlinks: options.backlinks },
|
|
2641
|
+
...options.evidenceLimit === void 0 ? {} : { evidenceLimit: options.evidenceLimit },
|
|
2642
|
+
...options.match === void 0 ? {} : { match: options.match },
|
|
2643
|
+
...options.order === void 0 ? {} : { order: options.order },
|
|
2644
|
+
query,
|
|
2645
|
+
...options.queryMode === void 0 ? {} : { queryMode: options.queryMode },
|
|
2646
|
+
...options.skipUnindexed === void 0 ? {} : { skipUnindexed: options.skipUnindexed },
|
|
2647
|
+
...options.sourceContext === void 0 ? {} : { sourceContext: options.sourceContext },
|
|
2648
|
+
...options.triplePattern === void 0 ? {} : { triplePattern: options.triplePattern },
|
|
2649
|
+
types: options.types ?? null
|
|
2650
|
+
}),
|
|
2651
|
+
(token) => this.#releaseCursor(token)
|
|
2652
|
+
);
|
|
2296
2653
|
}
|
|
2297
2654
|
async list(options = {}) {
|
|
2298
|
-
|
|
2655
|
+
const result = await this.#readDocument(async (document) => {
|
|
2299
2656
|
if ((0, import_wiki_graph_core7.isSourceLocatorScopeUri)(this.objectUri)) {
|
|
2300
2657
|
return await (0, import_wiki_graph_core7.listArchiveSourceLocators)(document, this.objectUri, {
|
|
2301
2658
|
...options.cursor === void 0 ? {} : { cursor: options.cursor },
|
|
@@ -2308,6 +2665,53 @@ var WikiGraphArchiveHandle = class {
|
|
|
2308
2665
|
...chapters === void 0 ? {} : { chapters }
|
|
2309
2666
|
});
|
|
2310
2667
|
}, options);
|
|
2668
|
+
if ((0, import_wiki_graph_core7.isSourceLocatorScopeUri)(this.objectUri)) {
|
|
2669
|
+
return createArchiveSourceLocatorPage(
|
|
2670
|
+
result,
|
|
2671
|
+
async (cursor, nextOptions) => await this.list({
|
|
2672
|
+
...options,
|
|
2673
|
+
cursor,
|
|
2674
|
+
...nextOptions.limit === void 0 ? {} : { limit: nextOptions.limit },
|
|
2675
|
+
...nextOptions.signal === void 0 ? {} : { signal: nextOptions.signal }
|
|
2676
|
+
}),
|
|
2677
|
+
(cursor) => this.#persistCursor({
|
|
2678
|
+
archiveKey: this.archiveKey,
|
|
2679
|
+
archivePath: this.path,
|
|
2680
|
+
cursor,
|
|
2681
|
+
format: "json",
|
|
2682
|
+
indexScope: this.indexScope,
|
|
2683
|
+
kind: "source-locators",
|
|
2684
|
+
targetUri: this.objectUri
|
|
2685
|
+
}),
|
|
2686
|
+
(token) => this.#releaseCursor(token)
|
|
2687
|
+
);
|
|
2688
|
+
}
|
|
2689
|
+
return createArchiveCollectionPage(
|
|
2690
|
+
result,
|
|
2691
|
+
async (cursor, nextOptions) => await this.list({
|
|
2692
|
+
...options,
|
|
2693
|
+
cursor,
|
|
2694
|
+
...nextOptions.limit === void 0 ? {} : { limit: nextOptions.limit },
|
|
2695
|
+
...nextOptions.signal === void 0 ? {} : { signal: nextOptions.signal }
|
|
2696
|
+
}),
|
|
2697
|
+
(cursor) => this.#persistCursor({
|
|
2698
|
+
archiveKey: this.archiveKey,
|
|
2699
|
+
archivePath: this.path,
|
|
2700
|
+
...options.backlinks === void 0 ? {} : { backlinks: options.backlinks },
|
|
2701
|
+
chapters: options.chapters ?? null,
|
|
2702
|
+
cursor,
|
|
2703
|
+
...options.evidenceLimit === void 0 ? {} : { evidenceLimit: options.evidenceLimit },
|
|
2704
|
+
format: "json",
|
|
2705
|
+
ids: options.ids ?? null,
|
|
2706
|
+
indexScope: this.indexScope,
|
|
2707
|
+
kind: "collection",
|
|
2708
|
+
order: options.order ?? "doc-asc",
|
|
2709
|
+
...options.sourceContext === void 0 ? {} : { sourceContext: options.sourceContext },
|
|
2710
|
+
...options.triplePattern === void 0 ? {} : { triplePattern: options.triplePattern },
|
|
2711
|
+
types: options.types ?? null
|
|
2712
|
+
}),
|
|
2713
|
+
(token) => this.#releaseCursor(token)
|
|
2714
|
+
);
|
|
2311
2715
|
}
|
|
2312
2716
|
async ensureSearchIndex(options = {}) {
|
|
2313
2717
|
const embeddingProvider = await this.#runtime.run(
|
|
@@ -2496,7 +2900,7 @@ var WikiGraphArchiveHandle = class {
|
|
|
2496
2900
|
return await this.#writeDocument(async (document) => {
|
|
2497
2901
|
const chapterId = await (0, import_wiki_graph_core7.resolveChapterPathReadonly)(document, path);
|
|
2498
2902
|
await assertChapterResetAllowed(
|
|
2499
|
-
this.#location
|
|
2903
|
+
requireWikiGraphArchiveFile(this.#location),
|
|
2500
2904
|
chapterId,
|
|
2501
2905
|
stage
|
|
2502
2906
|
);
|
|
@@ -2584,19 +2988,30 @@ var WikiGraphArchiveHandle = class {
|
|
|
2584
2988
|
if (options.queryMode !== void 0) {
|
|
2585
2989
|
throw new Error("`queryMode` requires `query`.");
|
|
2586
2990
|
}
|
|
2587
|
-
|
|
2991
|
+
const result2 = await this.#readDocument(async (document) => {
|
|
2588
2992
|
const chapters = await this.#resolveScope(document, {});
|
|
2589
2993
|
return await (0, import_wiki_graph_core7.listRelatedArchiveObjects)(document, objectUri, {
|
|
2590
2994
|
...withoutOperation(options),
|
|
2591
2995
|
...chapters === void 0 ? {} : { chapters }
|
|
2592
2996
|
});
|
|
2593
2997
|
}, options);
|
|
2998
|
+
return createArchiveRelatedPage(
|
|
2999
|
+
result2,
|
|
3000
|
+
async (cursor, nextOptions) => await this.related(objectUri, {
|
|
3001
|
+
...options,
|
|
3002
|
+
cursor,
|
|
3003
|
+
...nextOptions.limit === void 0 ? {} : { limit: nextOptions.limit },
|
|
3004
|
+
...nextOptions.signal === void 0 ? {} : { signal: nextOptions.signal }
|
|
3005
|
+
}),
|
|
3006
|
+
(cursor) => Promise.resolve(cursor),
|
|
3007
|
+
() => Promise.resolve()
|
|
3008
|
+
);
|
|
2594
3009
|
}
|
|
2595
3010
|
const embeddingProvider = await this.#resolveQueryEmbeddingProvider(
|
|
2596
3011
|
options.queryMode,
|
|
2597
3012
|
options.signal
|
|
2598
3013
|
);
|
|
2599
|
-
|
|
3014
|
+
const result = await this.#writeDocument(
|
|
2600
3015
|
async (document) => {
|
|
2601
3016
|
const chapters = await this.#resolveQueryChapters(document, options, {
|
|
2602
3017
|
embeddingProvider
|
|
@@ -2616,25 +3031,47 @@ var WikiGraphArchiveHandle = class {
|
|
|
2616
3031
|
...options.signal === void 0 ? {} : { signal: options.signal }
|
|
2617
3032
|
}
|
|
2618
3033
|
);
|
|
3034
|
+
return createArchiveRelatedPage(
|
|
3035
|
+
result,
|
|
3036
|
+
async (cursor, nextOptions) => await this.related(objectUri, {
|
|
3037
|
+
...options,
|
|
3038
|
+
cursor,
|
|
3039
|
+
...nextOptions.limit === void 0 ? {} : { limit: nextOptions.limit },
|
|
3040
|
+
...nextOptions.signal === void 0 ? {} : { signal: nextOptions.signal }
|
|
3041
|
+
}),
|
|
3042
|
+
(cursor) => Promise.resolve(cursor),
|
|
3043
|
+
() => Promise.resolve()
|
|
3044
|
+
);
|
|
2619
3045
|
}
|
|
2620
3046
|
async evidence(objectUri = this.objectUri, options = {}) {
|
|
2621
3047
|
if (options.query === void 0) {
|
|
2622
3048
|
if (options.queryMode !== void 0) {
|
|
2623
3049
|
throw new Error("`queryMode` requires `query`.");
|
|
2624
3050
|
}
|
|
2625
|
-
|
|
3051
|
+
const result2 = await this.#readDocument(async (document) => {
|
|
2626
3052
|
const chapters = await this.#resolveScope(document, {});
|
|
2627
3053
|
return await (0, import_wiki_graph_core7.listArchiveEvidence)(document, objectUri, {
|
|
2628
3054
|
...withoutOperation(options),
|
|
2629
3055
|
...chapters === void 0 ? {} : { chapters }
|
|
2630
3056
|
});
|
|
2631
3057
|
}, options);
|
|
3058
|
+
return createArchiveEvidencePage(
|
|
3059
|
+
result2,
|
|
3060
|
+
async (cursor, nextOptions) => await this.evidence(objectUri, {
|
|
3061
|
+
...options,
|
|
3062
|
+
cursor,
|
|
3063
|
+
...nextOptions.limit === void 0 ? {} : { limit: nextOptions.limit },
|
|
3064
|
+
...nextOptions.signal === void 0 ? {} : { signal: nextOptions.signal }
|
|
3065
|
+
}),
|
|
3066
|
+
(cursor) => Promise.resolve(cursor),
|
|
3067
|
+
() => Promise.resolve()
|
|
3068
|
+
);
|
|
2632
3069
|
}
|
|
2633
3070
|
const embeddingProvider = await this.#resolveQueryEmbeddingProvider(
|
|
2634
3071
|
options.queryMode,
|
|
2635
3072
|
options.signal
|
|
2636
3073
|
);
|
|
2637
|
-
|
|
3074
|
+
const result = await this.#writeDocument(
|
|
2638
3075
|
async (document) => {
|
|
2639
3076
|
const chapters = await this.#resolveQueryChapters(document, options, {
|
|
2640
3077
|
embeddingProvider
|
|
@@ -2654,6 +3091,17 @@ var WikiGraphArchiveHandle = class {
|
|
|
2654
3091
|
...options.signal === void 0 ? {} : { signal: options.signal }
|
|
2655
3092
|
}
|
|
2656
3093
|
);
|
|
3094
|
+
return createArchiveEvidencePage(
|
|
3095
|
+
result,
|
|
3096
|
+
async (cursor, nextOptions) => await this.evidence(objectUri, {
|
|
3097
|
+
...options,
|
|
3098
|
+
cursor,
|
|
3099
|
+
...nextOptions.limit === void 0 ? {} : { limit: nextOptions.limit },
|
|
3100
|
+
...nextOptions.signal === void 0 ? {} : { signal: nextOptions.signal }
|
|
3101
|
+
}),
|
|
3102
|
+
(cursor) => Promise.resolve(cursor),
|
|
3103
|
+
() => Promise.resolve()
|
|
3104
|
+
);
|
|
2657
3105
|
}
|
|
2658
3106
|
async pack(objectUri = this.objectUri, budget = 5e3, options = {}) {
|
|
2659
3107
|
return await this.#readDocument(
|
|
@@ -2698,14 +3146,18 @@ var WikiGraphArchiveHandle = class {
|
|
|
2698
3146
|
}, options);
|
|
2699
3147
|
}
|
|
2700
3148
|
async readCover(options = {}) {
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
3149
|
+
return await this.#runtime.run(async () => {
|
|
3150
|
+
if (this.#location.archiveFile.kind === "directory") {
|
|
3151
|
+
return await this.#readDocument(
|
|
3152
|
+
async (document) => await document.readCover()
|
|
3153
|
+
);
|
|
3154
|
+
}
|
|
3155
|
+
const app = new import_wiki_graph_core7.WikiGraph({});
|
|
3156
|
+
return await app.openSession(
|
|
2704
3157
|
this.#location.archiveFile,
|
|
2705
3158
|
async (archive) => await archive.readCover()
|
|
2706
|
-
)
|
|
2707
|
-
|
|
2708
|
-
);
|
|
3159
|
+
);
|
|
3160
|
+
}, options.signal);
|
|
2709
3161
|
}
|
|
2710
3162
|
async replaceMetadata(objectPath, value, options = {}) {
|
|
2711
3163
|
return await this.#writeDocument(async (document) => {
|
|
@@ -2746,9 +3198,11 @@ var WikiGraphArchiveHandle = class {
|
|
|
2746
3198
|
}
|
|
2747
3199
|
async #readDocument(operation, options = {}) {
|
|
2748
3200
|
return await this.#runtime.run(
|
|
2749
|
-
async () => await new import_wiki_graph_core7.
|
|
2750
|
-
|
|
2751
|
-
)
|
|
3201
|
+
async () => this.#location.archiveFile.kind === "directory" ? await new import_wiki_graph_core7.WikiGraphDirectoryFile(
|
|
3202
|
+
this.#location.archiveFile
|
|
3203
|
+
).readDocument(operation) : await new import_wiki_graph_core7.WikiGraphArchiveFile(
|
|
3204
|
+
this.#location.archiveFile
|
|
3205
|
+
).readDocument(operation),
|
|
2752
3206
|
options.signal
|
|
2753
3207
|
);
|
|
2754
3208
|
}
|
|
@@ -3185,54 +3639,53 @@ async function continueArchiveCursor(cursor, limit) {
|
|
|
3185
3639
|
const location = await resolveWikiGraphArchiveLocation(
|
|
3186
3640
|
archiveTargetFromLogicalLocator(getCursorArchivePath(cursor))
|
|
3187
3641
|
);
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
});
|
|
3233
|
-
}
|
|
3642
|
+
const read = async (document) => {
|
|
3643
|
+
switch (cursor.kind) {
|
|
3644
|
+
case "source-locators":
|
|
3645
|
+
return await (0, import_wiki_graph_core9.listArchiveSourceLocators)(document, cursor.targetUri, {
|
|
3646
|
+
cursor: cursor.cursor,
|
|
3647
|
+
limit
|
|
3648
|
+
});
|
|
3649
|
+
case "collection":
|
|
3650
|
+
return await (0, import_wiki_graph_core9.listArchiveCollection)(
|
|
3651
|
+
document,
|
|
3652
|
+
createCollectionOptions(cursor, limit)
|
|
3653
|
+
);
|
|
3654
|
+
case "search":
|
|
3655
|
+
return await (0, import_wiki_graph_core9.findArchiveObjects)(
|
|
3656
|
+
document,
|
|
3657
|
+
cursor.query ?? "",
|
|
3658
|
+
await createFindOptions(cursor, limit)
|
|
3659
|
+
);
|
|
3660
|
+
case "evidence":
|
|
3661
|
+
return await (0, import_wiki_graph_core9.listArchiveEvidence)(document, cursor.targetUri, {
|
|
3662
|
+
...cursor.chapters === null ? {} : { chapters: cursor.chapters },
|
|
3663
|
+
cursor: cursor.cursor,
|
|
3664
|
+
limit,
|
|
3665
|
+
order: cursor.order,
|
|
3666
|
+
...cursor.query === void 0 ? {} : { query: cursor.query },
|
|
3667
|
+
...cursor.queryMode === void 0 ? {} : { queryMode: cursor.queryMode },
|
|
3668
|
+
...embeddingProvider === void 0 ? {} : { embeddingProvider },
|
|
3669
|
+
...cursor.skipUnindexed === void 0 ? {} : { skipUnindexed: cursor.skipUnindexed },
|
|
3670
|
+
...cursor.sourceContext === void 0 ? {} : { sourceContext: cursor.sourceContext }
|
|
3671
|
+
});
|
|
3672
|
+
case "related":
|
|
3673
|
+
return await (0, import_wiki_graph_core9.listRelatedArchiveObjects)(document, cursor.targetUri, {
|
|
3674
|
+
...cursor.chapters === null ? {} : { chapters: cursor.chapters },
|
|
3675
|
+
cursor: cursor.cursor,
|
|
3676
|
+
...cursor.evidenceLimit === void 0 ? {} : { evidenceLimit: cursor.evidenceLimit },
|
|
3677
|
+
limit,
|
|
3678
|
+
order: cursor.order,
|
|
3679
|
+
...cursor.query === void 0 ? {} : { query: cursor.query },
|
|
3680
|
+
...cursor.queryMode === void 0 ? {} : { queryMode: cursor.queryMode },
|
|
3681
|
+
...embeddingProvider === void 0 ? {} : { embeddingProvider },
|
|
3682
|
+
...cursor.role === void 0 ? {} : { role: cursor.role },
|
|
3683
|
+
...cursor.skipUnindexed === void 0 ? {} : { skipUnindexed: cursor.skipUnindexed },
|
|
3684
|
+
...cursor.sourceContext === void 0 ? {} : { sourceContext: cursor.sourceContext }
|
|
3685
|
+
});
|
|
3234
3686
|
}
|
|
3235
|
-
|
|
3687
|
+
};
|
|
3688
|
+
return location.archiveFile.kind === "directory" ? await new import_wiki_graph_core9.WikiGraphDirectoryFile(location.archiveFile).readDocument(read) : await new import_wiki_graph_core9.WikiGraphArchiveFile(location.archiveFile).readDocument(read);
|
|
3236
3689
|
}
|
|
3237
3690
|
async function continueLibraryCursor(cursor, limit) {
|
|
3238
3691
|
const embeddingProvider = cursor.kind === "evidence" || cursor.kind === "related" ? await resolveCursorEmbeddingProvider(cursor) : void 0;
|
|
@@ -4072,7 +4525,7 @@ var WikiGraphJobManager = class {
|
|
|
4072
4525
|
return {
|
|
4073
4526
|
job: await this.#backend.add({
|
|
4074
4527
|
...options,
|
|
4075
|
-
archive: location
|
|
4528
|
+
archive: requireWikiGraphArchiveFile(location)
|
|
4076
4529
|
}),
|
|
4077
4530
|
target: location.target
|
|
4078
4531
|
};
|
|
@@ -4104,7 +4557,9 @@ var WikiGraphJobManager = class {
|
|
|
4104
4557
|
...options.activeOnly === void 0 ? {} : { activeOnly: options.activeOnly },
|
|
4105
4558
|
...options.all === void 0 ? {} : { all: options.all },
|
|
4106
4559
|
...options.archive === void 0 ? {} : {
|
|
4107
|
-
archive: (
|
|
4560
|
+
archive: requireWikiGraphArchiveFile(
|
|
4561
|
+
await resolveWikiGraphArchiveLocation(options.archive)
|
|
4562
|
+
)
|
|
4108
4563
|
}
|
|
4109
4564
|
};
|
|
4110
4565
|
const jobs = await this.#backend.list(normalized);
|
|
@@ -4129,7 +4584,7 @@ var WikiGraphJobManager = class {
|
|
|
4129
4584
|
archiveJobs[0].archive
|
|
4130
4585
|
);
|
|
4131
4586
|
const chapters = await new import_wiki_graph_core15.WikiGraphArchiveFile(
|
|
4132
|
-
location
|
|
4587
|
+
requireWikiGraphArchiveFile(location)
|
|
4133
4588
|
).readDocument(async (document) => await (0, import_wiki_graph_core15.listChapters)(document));
|
|
4134
4589
|
const chaptersById = new Map(
|
|
4135
4590
|
chapters.map((chapter) => [chapter.chapterId, chapter])
|
|
@@ -4172,7 +4627,7 @@ var WikiGraphJobManager = class {
|
|
|
4172
4627
|
await validateQueueTargetConfig(target, llmJSON);
|
|
4173
4628
|
const selectedExplicitly = options.chapterId !== void 0 || options.chapterIds !== void 0 || options.chapterPath !== void 0 || options.depth !== void 0;
|
|
4174
4629
|
const candidates = await new import_wiki_graph_core15.WikiGraphArchiveFile(
|
|
4175
|
-
location
|
|
4630
|
+
requireWikiGraphArchiveFile(location)
|
|
4176
4631
|
).readDocument(async (document) => {
|
|
4177
4632
|
const chapters = await (0, import_wiki_graph_core15.listChapters)(document);
|
|
4178
4633
|
const selected = await selectQueueChapters(
|
|
@@ -4216,7 +4671,7 @@ var WikiGraphJobManager = class {
|
|
|
4216
4671
|
chapter: candidate.chapter,
|
|
4217
4672
|
job: await this.#createHandle(
|
|
4218
4673
|
await this.#backend.add({
|
|
4219
|
-
archive: location
|
|
4674
|
+
archive: requireWikiGraphArchiveFile(location),
|
|
4220
4675
|
boost: options.boost ?? false,
|
|
4221
4676
|
chapterId: candidate.chapter.chapterId,
|
|
4222
4677
|
...llmJSON === void 0 ? {} : { llmJSON },
|
|
@@ -4247,7 +4702,7 @@ var WikiGraphJobManager = class {
|
|
|
4247
4702
|
await validateQueueTargetConfig(target, llmJSON);
|
|
4248
4703
|
const selectedExplicitly = options.chapterId !== void 0 || options.chapterIds !== void 0 || options.chapterPath !== void 0 || options.depth !== void 0;
|
|
4249
4704
|
const candidates = await new import_wiki_graph_core15.WikiGraphArchiveFile(
|
|
4250
|
-
location
|
|
4705
|
+
requireWikiGraphArchiveFile(location)
|
|
4251
4706
|
).readDocument(async (document) => {
|
|
4252
4707
|
const chapters = await (0, import_wiki_graph_core15.listChapters)(document);
|
|
4253
4708
|
const selected = await selectQueueChapters(document, chapters, options);
|
|
@@ -4577,6 +5032,8 @@ function forwardAbort(source, target) {
|
|
|
4577
5032
|
// src/libraries.ts
|
|
4578
5033
|
var import_wiki_graph_core16 = require("wiki-graph-core");
|
|
4579
5034
|
var import_promises6 = require("fs/promises");
|
|
5035
|
+
var import_os4 = require("os");
|
|
5036
|
+
var import_path6 = require("path");
|
|
4580
5037
|
async function resolveQueryEmbeddingProvider(queryMode) {
|
|
4581
5038
|
if (queryMode === "fts") return void 0;
|
|
4582
5039
|
const provider = await createConfiguredEmbeddingProvider();
|
|
@@ -4666,7 +5123,18 @@ var WikiGraphLibraryManager = class {
|
|
|
4666
5123
|
async () => {
|
|
4667
5124
|
throwIfAborted(options.signal);
|
|
4668
5125
|
const archive = await (0, import_wiki_graph_core16.getWikiGraphLibraryArchive)(parsedTarget);
|
|
4669
|
-
const
|
|
5126
|
+
const source = requireReadableLibraryArchiveFile(archive);
|
|
5127
|
+
let temporaryDirectory;
|
|
5128
|
+
const file = source.kind === "directory" ? await (async () => {
|
|
5129
|
+
temporaryDirectory = await (0, import_promises6.mkdtemp)(
|
|
5130
|
+
(0, import_path6.join)((0, import_os4.tmpdir)(), "wikigraph-library-read-")
|
|
5131
|
+
);
|
|
5132
|
+
const output = new NodeFile(
|
|
5133
|
+
(0, import_path6.join)(temporaryDirectory, "archive.wikg")
|
|
5134
|
+
);
|
|
5135
|
+
await (0, import_wiki_graph_core16.writeWikgArchive)(source, output);
|
|
5136
|
+
return output;
|
|
5137
|
+
})() : source;
|
|
4670
5138
|
const reader = await file.openReader();
|
|
4671
5139
|
let active = true;
|
|
4672
5140
|
try {
|
|
@@ -4687,6 +5155,8 @@ var WikiGraphLibraryManager = class {
|
|
|
4687
5155
|
} finally {
|
|
4688
5156
|
active = false;
|
|
4689
5157
|
await reader.close();
|
|
5158
|
+
if (temporaryDirectory !== void 0)
|
|
5159
|
+
await (0, import_promises6.rm)(temporaryDirectory, { force: true, recursive: true });
|
|
4690
5160
|
}
|
|
4691
5161
|
},
|
|
4692
5162
|
options.signal === void 0 ? {} : { signal: options.signal }
|
|
@@ -4781,7 +5251,7 @@ var WikiGraphLibraryManager = class {
|
|
|
4781
5251
|
);
|
|
4782
5252
|
}
|
|
4783
5253
|
async search(target, query, options = {}) {
|
|
4784
|
-
|
|
5254
|
+
const result = await this.#runtime.run(async () => {
|
|
4785
5255
|
const embeddingProvider = await resolveQueryEmbeddingProvider(
|
|
4786
5256
|
options.queryMode
|
|
4787
5257
|
);
|
|
@@ -4794,9 +5264,70 @@ var WikiGraphLibraryManager = class {
|
|
|
4794
5264
|
}
|
|
4795
5265
|
);
|
|
4796
5266
|
});
|
|
5267
|
+
return createArchiveFindPage(
|
|
5268
|
+
result,
|
|
5269
|
+
async (cursor, nextOptions) => await this.search(target, query, {
|
|
5270
|
+
...options,
|
|
5271
|
+
cursor,
|
|
5272
|
+
...nextOptions.limit === void 0 ? {} : { limit: nextOptions.limit },
|
|
5273
|
+
...nextOptions.signal === void 0 ? {} : { signal: nextOptions.signal }
|
|
5274
|
+
}),
|
|
5275
|
+
(cursor) => Promise.resolve(cursor),
|
|
5276
|
+
() => Promise.resolve()
|
|
5277
|
+
);
|
|
5278
|
+
}
|
|
5279
|
+
async searchBuckets(target, query, options) {
|
|
5280
|
+
const result = await this.#runtime.run(async () => {
|
|
5281
|
+
const embeddingProvider = await resolveQueryEmbeddingProvider(
|
|
5282
|
+
options.queryMode
|
|
5283
|
+
);
|
|
5284
|
+
return await (0, import_wiki_graph_core16.findWikiGraphLibraryObjectBuckets)(
|
|
5285
|
+
requireLibraryTarget(target),
|
|
5286
|
+
query,
|
|
5287
|
+
{
|
|
5288
|
+
...options,
|
|
5289
|
+
...embeddingProvider === void 0 ? {} : { embeddingProvider }
|
|
5290
|
+
}
|
|
5291
|
+
);
|
|
5292
|
+
});
|
|
5293
|
+
return {
|
|
5294
|
+
buckets: result.buckets.map(
|
|
5295
|
+
(bucket) => createLibraryBucketPage(
|
|
5296
|
+
bucket,
|
|
5297
|
+
async (cursor, nextOptions) => await this.continueSearchBucket(target, cursor, {
|
|
5298
|
+
...nextOptions.limit === void 0 ? {} : { limit: nextOptions.limit }
|
|
5299
|
+
}),
|
|
5300
|
+
(cursor) => Promise.resolve(cursor),
|
|
5301
|
+
() => Promise.resolve()
|
|
5302
|
+
)
|
|
5303
|
+
),
|
|
5304
|
+
query: result.query
|
|
5305
|
+
};
|
|
5306
|
+
}
|
|
5307
|
+
async continueSearchBucket(target, cursor, options = {}) {
|
|
5308
|
+
const result = await this.#runtime.run(async () => {
|
|
5309
|
+
const embeddingProvider = await resolveQueryEmbeddingProvider(void 0);
|
|
5310
|
+
return await (0, import_wiki_graph_core16.continueWikiGraphLibraryObjectBucket)(
|
|
5311
|
+
requireLibraryTarget(target),
|
|
5312
|
+
cursor,
|
|
5313
|
+
{
|
|
5314
|
+
...options,
|
|
5315
|
+
...embeddingProvider === void 0 ? {} : { embeddingProvider }
|
|
5316
|
+
}
|
|
5317
|
+
);
|
|
5318
|
+
});
|
|
5319
|
+
return createLibraryBucketPage(
|
|
5320
|
+
result,
|
|
5321
|
+
async (nextCursor, nextOptions) => await this.continueSearchBucket(target, nextCursor, {
|
|
5322
|
+
...options,
|
|
5323
|
+
...nextOptions.limit === void 0 ? {} : { limit: nextOptions.limit }
|
|
5324
|
+
}),
|
|
5325
|
+
(cursor2) => Promise.resolve(cursor2),
|
|
5326
|
+
() => Promise.resolve()
|
|
5327
|
+
);
|
|
4797
5328
|
}
|
|
4798
5329
|
async searchArchiveMembers(target, query, options = {}) {
|
|
4799
|
-
|
|
5330
|
+
const result = await this.#runtime.run(async () => {
|
|
4800
5331
|
const embeddingProvider = await resolveQueryEmbeddingProvider(
|
|
4801
5332
|
options.queryMode
|
|
4802
5333
|
);
|
|
@@ -4809,22 +5340,53 @@ var WikiGraphLibraryManager = class {
|
|
|
4809
5340
|
}
|
|
4810
5341
|
);
|
|
4811
5342
|
});
|
|
5343
|
+
return createArchiveFindPage(
|
|
5344
|
+
result,
|
|
5345
|
+
async (cursor, nextOptions) => await this.searchArchiveMembers(target, query, {
|
|
5346
|
+
...options,
|
|
5347
|
+
cursor,
|
|
5348
|
+
...nextOptions.limit === void 0 ? {} : { limit: nextOptions.limit },
|
|
5349
|
+
...nextOptions.signal === void 0 ? {} : { signal: nextOptions.signal }
|
|
5350
|
+
}),
|
|
5351
|
+
(cursor) => Promise.resolve(cursor),
|
|
5352
|
+
() => Promise.resolve()
|
|
5353
|
+
);
|
|
4812
5354
|
}
|
|
4813
5355
|
async objects(target, options = {}) {
|
|
4814
|
-
|
|
5356
|
+
const result = await this.#runtime.run(
|
|
4815
5357
|
async () => await (0, import_wiki_graph_core16.listWikiGraphLibraryObjects)(
|
|
4816
5358
|
requireLibraryTarget(target),
|
|
4817
5359
|
options
|
|
4818
5360
|
)
|
|
4819
5361
|
);
|
|
5362
|
+
return createArchiveCollectionPage(
|
|
5363
|
+
result,
|
|
5364
|
+
async (cursor, nextOptions) => await this.objects(target, {
|
|
5365
|
+
...options,
|
|
5366
|
+
cursor,
|
|
5367
|
+
...nextOptions.limit === void 0 ? {} : { limit: nextOptions.limit }
|
|
5368
|
+
}),
|
|
5369
|
+
(cursor) => Promise.resolve(cursor),
|
|
5370
|
+
() => Promise.resolve()
|
|
5371
|
+
);
|
|
4820
5372
|
}
|
|
4821
5373
|
async archiveMembers(target, options = {}) {
|
|
4822
|
-
|
|
5374
|
+
const result = await this.#runtime.run(
|
|
4823
5375
|
async () => await (0, import_wiki_graph_core16.listWikiGraphLibraryArchiveMembers)(
|
|
4824
5376
|
requireLibraryTarget(target),
|
|
4825
5377
|
options
|
|
4826
5378
|
)
|
|
4827
5379
|
);
|
|
5380
|
+
return createArchiveCollectionPage(
|
|
5381
|
+
result,
|
|
5382
|
+
async (cursor, nextOptions) => await this.archiveMembers(target, {
|
|
5383
|
+
...options,
|
|
5384
|
+
cursor,
|
|
5385
|
+
...nextOptions.limit === void 0 ? {} : { limit: nextOptions.limit }
|
|
5386
|
+
}),
|
|
5387
|
+
(cursor) => Promise.resolve(cursor),
|
|
5388
|
+
() => Promise.resolve()
|
|
5389
|
+
);
|
|
4828
5390
|
}
|
|
4829
5391
|
async page(target, objectUri, options = {}) {
|
|
4830
5392
|
return await this.#runtime.run(
|
|
@@ -4840,7 +5402,7 @@ var WikiGraphLibraryManager = class {
|
|
|
4840
5402
|
);
|
|
4841
5403
|
}
|
|
4842
5404
|
async related(target, objectUri, options = {}) {
|
|
4843
|
-
|
|
5405
|
+
const result = await this.#runtime.run(async () => {
|
|
4844
5406
|
if (options.query === void 0 && options.queryMode !== void 0) {
|
|
4845
5407
|
throw new Error("`queryMode` requires `query`.");
|
|
4846
5408
|
}
|
|
@@ -4854,9 +5416,20 @@ var WikiGraphLibraryManager = class {
|
|
|
4854
5416
|
}
|
|
4855
5417
|
);
|
|
4856
5418
|
});
|
|
5419
|
+
return createArchiveRelatedPage(
|
|
5420
|
+
result,
|
|
5421
|
+
async (cursor, nextOptions) => await this.related(target, objectUri, {
|
|
5422
|
+
...options,
|
|
5423
|
+
cursor,
|
|
5424
|
+
...nextOptions.limit === void 0 ? {} : { limit: nextOptions.limit },
|
|
5425
|
+
...nextOptions.signal === void 0 ? {} : { signal: nextOptions.signal }
|
|
5426
|
+
}),
|
|
5427
|
+
(cursor) => Promise.resolve(cursor),
|
|
5428
|
+
() => Promise.resolve()
|
|
5429
|
+
);
|
|
4857
5430
|
}
|
|
4858
5431
|
async evidence(target, objectUri, options = {}) {
|
|
4859
|
-
|
|
5432
|
+
const result = await this.#runtime.run(async () => {
|
|
4860
5433
|
if (options.query === void 0 && options.queryMode !== void 0) {
|
|
4861
5434
|
throw new Error("`queryMode` requires `query`.");
|
|
4862
5435
|
}
|
|
@@ -4870,6 +5443,17 @@ var WikiGraphLibraryManager = class {
|
|
|
4870
5443
|
}
|
|
4871
5444
|
);
|
|
4872
5445
|
});
|
|
5446
|
+
return createArchiveEvidencePage(
|
|
5447
|
+
result,
|
|
5448
|
+
async (cursor, nextOptions) => await this.evidence(target, objectUri, {
|
|
5449
|
+
...options,
|
|
5450
|
+
cursor,
|
|
5451
|
+
...nextOptions.limit === void 0 ? {} : { limit: nextOptions.limit },
|
|
5452
|
+
...nextOptions.signal === void 0 ? {} : { signal: nextOptions.signal }
|
|
5453
|
+
}),
|
|
5454
|
+
(cursor) => Promise.resolve(cursor),
|
|
5455
|
+
() => Promise.resolve()
|
|
5456
|
+
);
|
|
4873
5457
|
}
|
|
4874
5458
|
async pack(target, objectUri, budget = 5e3) {
|
|
4875
5459
|
return await this.#runtime.run(
|
|
@@ -4934,7 +5518,7 @@ function toLibrarySnapshot(record) {
|
|
|
4934
5518
|
};
|
|
4935
5519
|
}
|
|
4936
5520
|
function toArchiveSnapshot(record) {
|
|
4937
|
-
const { file: _file, ...snapshot } = record;
|
|
5521
|
+
const { file: _file, directory: _directory, ...snapshot } = record;
|
|
4938
5522
|
return snapshot;
|
|
4939
5523
|
}
|
|
4940
5524
|
function toScanSnapshot(result) {
|
|
@@ -4967,12 +5551,12 @@ function requireReadableLibraryArchiveFile(archive) {
|
|
|
4967
5551
|
`Wiki Graph library archive has a conflict and cannot be read: ${archive.uri}`
|
|
4968
5552
|
);
|
|
4969
5553
|
}
|
|
4970
|
-
if (archive.file === void 0) {
|
|
5554
|
+
if (archive.file === void 0 && archive.directory === void 0) {
|
|
4971
5555
|
throw new Error(
|
|
4972
5556
|
`Wiki Graph library archive is unavailable: ${archive.uri}`
|
|
4973
5557
|
);
|
|
4974
5558
|
}
|
|
4975
|
-
return archive.file;
|
|
5559
|
+
return archive.file ?? archive.directory;
|
|
4976
5560
|
}
|
|
4977
5561
|
var ARCHIVE_STREAM_CHUNK_SIZE = 64 * 1024;
|
|
4978
5562
|
function createCallbackScopedArchiveStream(reader, isActive, signal) {
|
|
@@ -5045,7 +5629,7 @@ function abortReason(signal) {
|
|
|
5045
5629
|
|
|
5046
5630
|
// src/maintenance.ts
|
|
5047
5631
|
var import_wiki_graph_core17 = require("wiki-graph-core");
|
|
5048
|
-
var
|
|
5632
|
+
var import_path7 = require("path");
|
|
5049
5633
|
var WikiGraphMaintenanceManager = class {
|
|
5050
5634
|
#runtime;
|
|
5051
5635
|
constructor(runtime) {
|
|
@@ -5085,7 +5669,7 @@ var WikiGraphMaintenanceManager = class {
|
|
|
5085
5669
|
const resolvedOutputPath = resolveWikiGraphRuntimePath(outputPath);
|
|
5086
5670
|
await (0, import_wiki_graph_core17.migrateLegacySdpubToWikg)(
|
|
5087
5671
|
new NodeFile(resolvedInputPath),
|
|
5088
|
-
new NodeFile(resolvedOutputPath, (0,
|
|
5672
|
+
new NodeFile(resolvedOutputPath, (0, import_path7.basename)(resolvedOutputPath))
|
|
5089
5673
|
);
|
|
5090
5674
|
return {
|
|
5091
5675
|
inputPath: resolvedInputPath,
|
|
@@ -5169,6 +5753,11 @@ function createWikiGraphSDK(options = {}) {
|
|
|
5169
5753
|
var import_wiki_graph_core19 = require("wiki-graph-core");
|
|
5170
5754
|
// Annotate the CommonJS export names for ESM import in node:
|
|
5171
5755
|
0 && (module.exports = {
|
|
5756
|
+
ArchiveCollectionPage,
|
|
5757
|
+
ArchiveEvidencePage,
|
|
5758
|
+
ArchiveFindPage,
|
|
5759
|
+
ArchiveRelatedPage,
|
|
5760
|
+
ArchiveSourceLocatorPage,
|
|
5172
5761
|
DANGEROUS_RUNTIME_ENV_NAMES,
|
|
5173
5762
|
DEFAULT_EXTRACTION_PROMPT,
|
|
5174
5763
|
DEFAULT_GENERATION_JOB_CONCURRENCY,
|
|
@@ -5176,6 +5765,7 @@ var import_wiki_graph_core19 = require("wiki-graph-core");
|
|
|
5176
5765
|
DEFAULT_KNOWLEDGE_GRAPH_RECALL_PROMPT,
|
|
5177
5766
|
LLMPaymentRequiredError,
|
|
5178
5767
|
LOCAL_CONFIG_SECTIONS,
|
|
5768
|
+
LibraryBucketPage,
|
|
5179
5769
|
NodeDirectory,
|
|
5180
5770
|
NodeFile,
|
|
5181
5771
|
WIKI_GRAPH_URI_PREFIX,
|
|
@@ -5196,11 +5786,19 @@ var import_wiki_graph_core19 = require("wiki-graph-core");
|
|
|
5196
5786
|
buildSearchIndexEmbeddingProvider,
|
|
5197
5787
|
buildWikiGraphLLMOptions,
|
|
5198
5788
|
clearLocalConfigSection,
|
|
5789
|
+
createArchiveCollectionPage,
|
|
5790
|
+
createArchiveEvidencePage,
|
|
5791
|
+
createArchiveFindPage,
|
|
5792
|
+
createArchiveRelatedPage,
|
|
5793
|
+
createArchiveSourceLocatorPage,
|
|
5794
|
+
createCursor,
|
|
5199
5795
|
createEntryRuntimeContext,
|
|
5200
5796
|
createGenerationPerformanceHints,
|
|
5797
|
+
createLibraryBucketPage,
|
|
5201
5798
|
createNodeTemplateEnvironment,
|
|
5202
5799
|
createNodeWikiGraphPlatform,
|
|
5203
5800
|
createNodeWikiGraphStorage,
|
|
5801
|
+
createPageCursor,
|
|
5204
5802
|
createStageLLM,
|
|
5205
5803
|
createWikiGraphSDK,
|
|
5206
5804
|
deleteLocalConfigValue,
|
|
@@ -5228,6 +5826,8 @@ var import_wiki_graph_core19 = require("wiki-graph-core");
|
|
|
5228
5826
|
isWikiGraphJobUri,
|
|
5229
5827
|
isWikiGraphLibraryUri,
|
|
5230
5828
|
isWikiGraphUri,
|
|
5829
|
+
iterateItems,
|
|
5830
|
+
iteratePages,
|
|
5231
5831
|
loadRequiredStageConfig,
|
|
5232
5832
|
loadWikiGraphRuntimeConfig,
|
|
5233
5833
|
maskLocalConfigSection,
|