wiki-graph-sdk 0.8.2 → 0.8.4
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 +13 -3
- package/dist/archives.cjs +382 -25
- package/dist/archives.cjs.map +1 -1
- package/dist/archives.d.ts +4 -216
- package/dist/archives.js +372 -13
- package/dist/archives.js.map +1 -1
- package/dist/conversions.cjs +11 -12
- package/dist/conversions.cjs.map +1 -1
- package/dist/conversions.js +6 -7
- package/dist/conversions.js.map +1 -1
- package/dist/default-worker.cjs +40 -17
- package/dist/default-worker.cjs.map +1 -1
- package/dist/default-worker.js +37 -14
- package/dist/default-worker.js.map +1 -1
- package/dist/embedding.cjs +6 -7
- package/dist/embedding.cjs.map +1 -1
- package/dist/embedding.js +6 -7
- package/dist/embedding.js.map +1 -1
- package/dist/gc.cjs +61 -9
- package/dist/gc.cjs.map +1 -1
- package/dist/gc.d.ts +1 -1
- package/dist/gc.js +61 -9
- package/dist/gc.js.map +1 -1
- package/dist/host-IbqJ8WSV.d.ts +18 -0
- package/dist/index-DQzLAnjf.d.ts +346 -0
- package/dist/index.cjs +622 -40
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +20 -12
- package/dist/index.js +601 -31
- package/dist/index.js.map +1 -1
- package/dist/local-config.cjs +6 -7
- package/dist/local-config.cjs.map +1 -1
- package/dist/local-config.js +6 -7
- package/dist/local-config.js.map +1 -1
- package/dist/maintenance.cjs.map +1 -1
- package/dist/maintenance.js.map +1 -1
- package/dist/runtime-config.cjs +6 -7
- package/dist/runtime-config.cjs.map +1 -1
- package/dist/runtime-config.js +6 -7
- package/dist/runtime-config.js.map +1 -1
- package/dist/stage.cjs +6 -7
- package/dist/stage.cjs.map +1 -1
- package/dist/stage.js +6 -7
- package/dist/stage.js.map +1 -1
- package/dist/worker.cjs +55 -31
- package/dist/worker.cjs.map +1 -1
- package/dist/worker.d.ts +1 -1
- package/dist/worker.js +61 -37
- package/dist/worker.js.map +1 -1
- package/package.json +2 -2
- package/dist/host-pQiVAKEY.d.ts +0 -10
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,
|
|
@@ -129,7 +145,7 @@ module.exports = __toCommonJS(src_exports);
|
|
|
129
145
|
|
|
130
146
|
// src/archive/archive.ts
|
|
131
147
|
var import_crypto2 = require("crypto");
|
|
132
|
-
var
|
|
148
|
+
var import_promises5 = require("fs/promises");
|
|
133
149
|
var import_os3 = require("os");
|
|
134
150
|
var import_path5 = require("path");
|
|
135
151
|
var import_stream = require("stream");
|
|
@@ -138,7 +154,7 @@ var import_wiki_graph_core7 = require("wiki-graph-core");
|
|
|
138
154
|
// src/conversions.ts
|
|
139
155
|
var import_crypto = require("crypto");
|
|
140
156
|
var import_fs = require("fs");
|
|
141
|
-
var
|
|
157
|
+
var import_promises4 = require("fs/promises");
|
|
142
158
|
var import_path4 = require("path");
|
|
143
159
|
var import_wiki_graph_core3 = require("wiki-graph-core");
|
|
144
160
|
|
|
@@ -964,13 +980,15 @@ function getWikiGraphSDKRuntimeContext() {
|
|
|
964
980
|
};
|
|
965
981
|
}
|
|
966
982
|
function getWikiGraphSDKStateDir() {
|
|
967
|
-
|
|
983
|
+
const context = getWikiGraphSDKRuntimeContext();
|
|
984
|
+
return context.host?.stateDir ?? context.stateDir;
|
|
968
985
|
}
|
|
969
986
|
function getWikiGraphSDKProviders() {
|
|
970
987
|
return getWikiGraphSDKRuntimeContext().providers ?? {};
|
|
971
988
|
}
|
|
972
989
|
|
|
973
990
|
// src/local-config.ts
|
|
991
|
+
var import_promises2 = require("fs/promises");
|
|
974
992
|
var import_path = require("path");
|
|
975
993
|
var import_os = require("os");
|
|
976
994
|
var LOCAL_CONFIG_SECTIONS = [
|
|
@@ -1071,13 +1089,10 @@ function validateLocalConfigSection(section, value) {
|
|
|
1071
1089
|
}
|
|
1072
1090
|
}
|
|
1073
1091
|
async function withLocalConfigDatabase(operation) {
|
|
1092
|
+
const stateDir = getWikiGraphSDKStateDir() ?? (0, import_path.join)((0, import_os.homedir)(), ".wikigraph");
|
|
1093
|
+
await (0, import_promises2.mkdir)(stateDir, { recursive: true });
|
|
1074
1094
|
const database = await (0, import_wiki_graph_core.openSharedStateDatabase)(
|
|
1075
|
-
new NodeFile(
|
|
1076
|
-
(0, import_path.join)(
|
|
1077
|
-
getWikiGraphSDKStateDir() ?? (0, import_path.join)((0, import_os.homedir)(), ".wikigraph"),
|
|
1078
|
-
"core.sqlite"
|
|
1079
|
-
)
|
|
1080
|
-
),
|
|
1095
|
+
new NodeFile((0, import_path.join)(stateDir, "core.sqlite")),
|
|
1081
1096
|
LOCAL_CONFIG_SCHEMA_SQL
|
|
1082
1097
|
);
|
|
1083
1098
|
try {
|
|
@@ -1487,7 +1502,7 @@ function resolveWikiGraphRuntimePath(path) {
|
|
|
1487
1502
|
}
|
|
1488
1503
|
|
|
1489
1504
|
// src/archive/target.ts
|
|
1490
|
-
var
|
|
1505
|
+
var import_promises3 = require("fs/promises");
|
|
1491
1506
|
var import_path3 = require("path");
|
|
1492
1507
|
var import_wiki_graph_core2 = require("wiki-graph-core");
|
|
1493
1508
|
var WikiGraphArchiveOwnershipError = class extends Error {
|
|
@@ -1616,7 +1631,7 @@ function withObjectUri(archiveLocator, objectUri) {
|
|
|
1616
1631
|
}
|
|
1617
1632
|
async function canonicalPath(path) {
|
|
1618
1633
|
try {
|
|
1619
|
-
return await (0,
|
|
1634
|
+
return await (0, import_promises3.realpath)(path);
|
|
1620
1635
|
} catch {
|
|
1621
1636
|
const absolute = (0, import_path3.resolve)(path);
|
|
1622
1637
|
const parent = (0, import_path3.dirname)(absolute);
|
|
@@ -1667,7 +1682,7 @@ function requireUnambiguousManagedMatch(path, matches) {
|
|
|
1667
1682
|
}
|
|
1668
1683
|
async function readFileIdentity(path) {
|
|
1669
1684
|
try {
|
|
1670
|
-
const value = await (0,
|
|
1685
|
+
const value = await (0, import_promises3.stat)(path);
|
|
1671
1686
|
return `${value.dev}:${value.ino}`;
|
|
1672
1687
|
} catch {
|
|
1673
1688
|
return void 0;
|
|
@@ -1791,7 +1806,7 @@ async function prepareDigestDirectory(path, required) {
|
|
|
1791
1806
|
if (!required || normalized === void 0 || normalized === "")
|
|
1792
1807
|
return void 0;
|
|
1793
1808
|
const resolved = resolveWikiGraphRuntimePath(normalized);
|
|
1794
|
-
await (0,
|
|
1809
|
+
await (0, import_promises4.rm)(resolved, { force: true, recursive: true });
|
|
1795
1810
|
return new NodeDirectory(resolved);
|
|
1796
1811
|
}
|
|
1797
1812
|
async function writeArchive(archive, path, format) {
|
|
@@ -2172,6 +2187,294 @@ async function writeWikiGraphArchiveLocation(location, operation, options = {})
|
|
|
2172
2187
|
});
|
|
2173
2188
|
}
|
|
2174
2189
|
|
|
2190
|
+
// src/pages.ts
|
|
2191
|
+
function createCursor(implementation) {
|
|
2192
|
+
let released = false;
|
|
2193
|
+
const assertLive = () => {
|
|
2194
|
+
if (released) throw new Error("Cursor has been released.");
|
|
2195
|
+
};
|
|
2196
|
+
return {
|
|
2197
|
+
pageClass: implementation.pageClass,
|
|
2198
|
+
async next(options = {}) {
|
|
2199
|
+
assertLive();
|
|
2200
|
+
return await implementation.next(options);
|
|
2201
|
+
},
|
|
2202
|
+
async token() {
|
|
2203
|
+
assertLive();
|
|
2204
|
+
return await implementation.token();
|
|
2205
|
+
},
|
|
2206
|
+
async release() {
|
|
2207
|
+
if (released) return;
|
|
2208
|
+
released = true;
|
|
2209
|
+
await implementation.release?.();
|
|
2210
|
+
}
|
|
2211
|
+
};
|
|
2212
|
+
}
|
|
2213
|
+
function createPageCursor(implementation) {
|
|
2214
|
+
let token;
|
|
2215
|
+
return createCursor({
|
|
2216
|
+
pageClass: implementation.pageClass,
|
|
2217
|
+
next: async (options) => await implementation.next(implementation.rawCursor, options),
|
|
2218
|
+
token: async () => {
|
|
2219
|
+
token ??= await implementation.createToken(implementation.rawCursor);
|
|
2220
|
+
return token;
|
|
2221
|
+
},
|
|
2222
|
+
release: async () => {
|
|
2223
|
+
if (token !== void 0) await implementation.releaseToken?.(token);
|
|
2224
|
+
token = void 0;
|
|
2225
|
+
}
|
|
2226
|
+
});
|
|
2227
|
+
}
|
|
2228
|
+
async function* iteratePages(firstPage, options = {}) {
|
|
2229
|
+
let page = firstPage;
|
|
2230
|
+
while (true) {
|
|
2231
|
+
yield page;
|
|
2232
|
+
const cursor = page.nextCursor();
|
|
2233
|
+
if (cursor === null) return;
|
|
2234
|
+
try {
|
|
2235
|
+
const nextPage = await cursor.next(options);
|
|
2236
|
+
await cursor.release();
|
|
2237
|
+
page = nextPage;
|
|
2238
|
+
} catch (error) {
|
|
2239
|
+
await cursor.release();
|
|
2240
|
+
throw error;
|
|
2241
|
+
}
|
|
2242
|
+
}
|
|
2243
|
+
}
|
|
2244
|
+
async function* iterateItems(firstPage, options = {}) {
|
|
2245
|
+
for await (const page of iteratePages(firstPage, options)) {
|
|
2246
|
+
yield* page;
|
|
2247
|
+
}
|
|
2248
|
+
}
|
|
2249
|
+
|
|
2250
|
+
// src/result-pages.ts
|
|
2251
|
+
var ArchiveFindPage = class _ArchiveFindPage {
|
|
2252
|
+
result;
|
|
2253
|
+
chapters;
|
|
2254
|
+
items;
|
|
2255
|
+
lens;
|
|
2256
|
+
lensHint;
|
|
2257
|
+
limit;
|
|
2258
|
+
match;
|
|
2259
|
+
rawNextCursor;
|
|
2260
|
+
order;
|
|
2261
|
+
query;
|
|
2262
|
+
terms;
|
|
2263
|
+
types;
|
|
2264
|
+
#cursor;
|
|
2265
|
+
constructor(result, cursor = null) {
|
|
2266
|
+
this.result = result;
|
|
2267
|
+
this.chapters = result.chapters;
|
|
2268
|
+
this.items = result.items;
|
|
2269
|
+
this.lens = result.lens;
|
|
2270
|
+
this.lensHint = result.lensHint;
|
|
2271
|
+
this.limit = result.limit;
|
|
2272
|
+
this.match = result.match;
|
|
2273
|
+
this.rawNextCursor = result.nextCursor;
|
|
2274
|
+
this.order = result.order;
|
|
2275
|
+
this.query = result.query;
|
|
2276
|
+
this.terms = result.terms;
|
|
2277
|
+
this.types = result.types;
|
|
2278
|
+
this.#cursor = cursor;
|
|
2279
|
+
}
|
|
2280
|
+
static pageClass = _ArchiveFindPage;
|
|
2281
|
+
[Symbol.iterator]() {
|
|
2282
|
+
return this.items[Symbol.iterator]();
|
|
2283
|
+
}
|
|
2284
|
+
nextCursor() {
|
|
2285
|
+
return this.#cursor;
|
|
2286
|
+
}
|
|
2287
|
+
};
|
|
2288
|
+
var ArchiveCollectionPage = class _ArchiveCollectionPage {
|
|
2289
|
+
result;
|
|
2290
|
+
chapters;
|
|
2291
|
+
ids;
|
|
2292
|
+
items;
|
|
2293
|
+
limit;
|
|
2294
|
+
rawNextCursor;
|
|
2295
|
+
order;
|
|
2296
|
+
types;
|
|
2297
|
+
#cursor;
|
|
2298
|
+
constructor(result, cursor = null) {
|
|
2299
|
+
this.result = result;
|
|
2300
|
+
this.chapters = result.chapters;
|
|
2301
|
+
this.ids = result.ids;
|
|
2302
|
+
this.items = result.items;
|
|
2303
|
+
this.limit = result.limit;
|
|
2304
|
+
this.rawNextCursor = result.nextCursor;
|
|
2305
|
+
this.order = result.order;
|
|
2306
|
+
this.types = result.types;
|
|
2307
|
+
this.#cursor = cursor;
|
|
2308
|
+
}
|
|
2309
|
+
static pageClass = _ArchiveCollectionPage;
|
|
2310
|
+
[Symbol.iterator]() {
|
|
2311
|
+
return this.items[Symbol.iterator]();
|
|
2312
|
+
}
|
|
2313
|
+
nextCursor() {
|
|
2314
|
+
return this.#cursor;
|
|
2315
|
+
}
|
|
2316
|
+
};
|
|
2317
|
+
var ArchiveEvidencePage = class _ArchiveEvidencePage {
|
|
2318
|
+
result;
|
|
2319
|
+
items;
|
|
2320
|
+
limit;
|
|
2321
|
+
rawNextCursor;
|
|
2322
|
+
#cursor;
|
|
2323
|
+
constructor(result, cursor = null) {
|
|
2324
|
+
this.result = result;
|
|
2325
|
+
this.items = result.items;
|
|
2326
|
+
this.limit = result.limit;
|
|
2327
|
+
this.rawNextCursor = result.nextCursor;
|
|
2328
|
+
this.#cursor = cursor;
|
|
2329
|
+
}
|
|
2330
|
+
static pageClass = _ArchiveEvidencePage;
|
|
2331
|
+
[Symbol.iterator]() {
|
|
2332
|
+
return this.items[Symbol.iterator]();
|
|
2333
|
+
}
|
|
2334
|
+
nextCursor() {
|
|
2335
|
+
return this.#cursor;
|
|
2336
|
+
}
|
|
2337
|
+
};
|
|
2338
|
+
var ArchiveRelatedPage = class _ArchiveRelatedPage {
|
|
2339
|
+
result;
|
|
2340
|
+
items;
|
|
2341
|
+
limit;
|
|
2342
|
+
rawNextCursor;
|
|
2343
|
+
#cursor;
|
|
2344
|
+
constructor(result, cursor = null) {
|
|
2345
|
+
this.result = result;
|
|
2346
|
+
this.items = result.items;
|
|
2347
|
+
this.limit = result.limit;
|
|
2348
|
+
this.rawNextCursor = result.nextCursor;
|
|
2349
|
+
this.#cursor = cursor;
|
|
2350
|
+
}
|
|
2351
|
+
static pageClass = _ArchiveRelatedPage;
|
|
2352
|
+
[Symbol.iterator]() {
|
|
2353
|
+
return this.items[Symbol.iterator]();
|
|
2354
|
+
}
|
|
2355
|
+
nextCursor() {
|
|
2356
|
+
return this.#cursor;
|
|
2357
|
+
}
|
|
2358
|
+
};
|
|
2359
|
+
var ArchiveSourceLocatorPage = class _ArchiveSourceLocatorPage {
|
|
2360
|
+
result;
|
|
2361
|
+
items;
|
|
2362
|
+
limit;
|
|
2363
|
+
rawNextCursor;
|
|
2364
|
+
#cursor;
|
|
2365
|
+
constructor(result, cursor = null) {
|
|
2366
|
+
this.result = result;
|
|
2367
|
+
this.items = result.items;
|
|
2368
|
+
this.limit = result.limit;
|
|
2369
|
+
this.rawNextCursor = result.nextCursor;
|
|
2370
|
+
this.#cursor = cursor;
|
|
2371
|
+
}
|
|
2372
|
+
static pageClass = _ArchiveSourceLocatorPage;
|
|
2373
|
+
[Symbol.iterator]() {
|
|
2374
|
+
return this.items[Symbol.iterator]();
|
|
2375
|
+
}
|
|
2376
|
+
nextCursor() {
|
|
2377
|
+
return this.#cursor;
|
|
2378
|
+
}
|
|
2379
|
+
};
|
|
2380
|
+
function createArchiveFindPage(result, next, createToken, releaseToken) {
|
|
2381
|
+
return new ArchiveFindPage(
|
|
2382
|
+
result,
|
|
2383
|
+
result.nextCursor === null ? null : createPageCursor({
|
|
2384
|
+
pageClass: ArchiveFindPage,
|
|
2385
|
+
rawCursor: result.nextCursor,
|
|
2386
|
+
next,
|
|
2387
|
+
createToken,
|
|
2388
|
+
releaseToken
|
|
2389
|
+
})
|
|
2390
|
+
);
|
|
2391
|
+
}
|
|
2392
|
+
function createArchiveCollectionPage(result, next, createToken, releaseToken) {
|
|
2393
|
+
return new ArchiveCollectionPage(
|
|
2394
|
+
result,
|
|
2395
|
+
result.nextCursor === null ? null : createPageCursor({
|
|
2396
|
+
pageClass: ArchiveCollectionPage,
|
|
2397
|
+
rawCursor: result.nextCursor,
|
|
2398
|
+
next,
|
|
2399
|
+
createToken,
|
|
2400
|
+
releaseToken
|
|
2401
|
+
})
|
|
2402
|
+
);
|
|
2403
|
+
}
|
|
2404
|
+
function createArchiveEvidencePage(result, next, createToken, releaseToken) {
|
|
2405
|
+
return new ArchiveEvidencePage(
|
|
2406
|
+
result,
|
|
2407
|
+
result.nextCursor === null ? null : createPageCursor({
|
|
2408
|
+
pageClass: ArchiveEvidencePage,
|
|
2409
|
+
rawCursor: result.nextCursor,
|
|
2410
|
+
next,
|
|
2411
|
+
createToken,
|
|
2412
|
+
releaseToken
|
|
2413
|
+
})
|
|
2414
|
+
);
|
|
2415
|
+
}
|
|
2416
|
+
function createArchiveRelatedPage(result, next, createToken, releaseToken) {
|
|
2417
|
+
return new ArchiveRelatedPage(
|
|
2418
|
+
result,
|
|
2419
|
+
result.nextCursor === null ? null : createPageCursor({
|
|
2420
|
+
pageClass: ArchiveRelatedPage,
|
|
2421
|
+
rawCursor: result.nextCursor,
|
|
2422
|
+
next,
|
|
2423
|
+
createToken,
|
|
2424
|
+
releaseToken
|
|
2425
|
+
})
|
|
2426
|
+
);
|
|
2427
|
+
}
|
|
2428
|
+
function createArchiveSourceLocatorPage(result, next, createToken, releaseToken) {
|
|
2429
|
+
return new ArchiveSourceLocatorPage(
|
|
2430
|
+
result,
|
|
2431
|
+
result.nextCursor === null ? null : createPageCursor({
|
|
2432
|
+
pageClass: ArchiveSourceLocatorPage,
|
|
2433
|
+
rawCursor: result.nextCursor,
|
|
2434
|
+
next,
|
|
2435
|
+
createToken,
|
|
2436
|
+
releaseToken
|
|
2437
|
+
})
|
|
2438
|
+
);
|
|
2439
|
+
}
|
|
2440
|
+
var LibraryBucketPage = class _LibraryBucketPage {
|
|
2441
|
+
id;
|
|
2442
|
+
items;
|
|
2443
|
+
rawNextCursor;
|
|
2444
|
+
query;
|
|
2445
|
+
terms;
|
|
2446
|
+
types;
|
|
2447
|
+
#cursor;
|
|
2448
|
+
constructor(result, cursor = null) {
|
|
2449
|
+
this.id = result.id;
|
|
2450
|
+
this.items = result.items;
|
|
2451
|
+
this.rawNextCursor = result.nextCursor;
|
|
2452
|
+
this.query = result.query;
|
|
2453
|
+
this.terms = result.terms;
|
|
2454
|
+
this.types = result.types;
|
|
2455
|
+
this.#cursor = cursor;
|
|
2456
|
+
}
|
|
2457
|
+
static pageClass = _LibraryBucketPage;
|
|
2458
|
+
[Symbol.iterator]() {
|
|
2459
|
+
return this.items[Symbol.iterator]();
|
|
2460
|
+
}
|
|
2461
|
+
nextCursor() {
|
|
2462
|
+
return this.#cursor;
|
|
2463
|
+
}
|
|
2464
|
+
};
|
|
2465
|
+
function createLibraryBucketPage(result, next, createToken, releaseToken) {
|
|
2466
|
+
return new LibraryBucketPage(
|
|
2467
|
+
result,
|
|
2468
|
+
result.nextCursor === null ? null : createPageCursor({
|
|
2469
|
+
pageClass: LibraryBucketPage,
|
|
2470
|
+
rawCursor: result.nextCursor,
|
|
2471
|
+
next,
|
|
2472
|
+
createToken,
|
|
2473
|
+
releaseToken
|
|
2474
|
+
})
|
|
2475
|
+
);
|
|
2476
|
+
}
|
|
2477
|
+
|
|
2175
2478
|
// src/archive/archive.ts
|
|
2176
2479
|
var WikiGraphArchiveExistsError = class extends Error {
|
|
2177
2480
|
code = "WIKI_GRAPH_ARCHIVE_EXISTS";
|
|
@@ -2209,10 +2512,10 @@ var WikiGraphArchiveManager = class {
|
|
|
2209
2512
|
});
|
|
2210
2513
|
}
|
|
2211
2514
|
if (options.replace === true) {
|
|
2212
|
-
await (0,
|
|
2515
|
+
await (0, import_promises5.rename)(outputPath, path);
|
|
2213
2516
|
} else {
|
|
2214
2517
|
try {
|
|
2215
|
-
await (0,
|
|
2518
|
+
await (0, import_promises5.link)(outputPath, path);
|
|
2216
2519
|
} catch (error) {
|
|
2217
2520
|
if (isNodeEEXISTError(error)) {
|
|
2218
2521
|
throw new WikiGraphArchiveExistsError(path);
|
|
@@ -2222,7 +2525,7 @@ var WikiGraphArchiveManager = class {
|
|
|
2222
2525
|
}
|
|
2223
2526
|
return { locatedUri: (0, import_wiki_graph_core7.formatLocatedWikiGraphUri)(path), path };
|
|
2224
2527
|
} finally {
|
|
2225
|
-
await (0,
|
|
2528
|
+
await (0, import_promises5.rm)(outputPath, { force: true, recursive: true });
|
|
2226
2529
|
}
|
|
2227
2530
|
}, options.signal);
|
|
2228
2531
|
}
|
|
@@ -2259,6 +2562,14 @@ var WikiGraphArchiveHandle = class {
|
|
|
2259
2562
|
get target() {
|
|
2260
2563
|
return this.#location.target;
|
|
2261
2564
|
}
|
|
2565
|
+
async #persistCursor(cursor) {
|
|
2566
|
+
return await this.#runtime.run(
|
|
2567
|
+
async () => await (0, import_wiki_graph_core7.createContinuationCursor)(cursor)
|
|
2568
|
+
);
|
|
2569
|
+
}
|
|
2570
|
+
async #releaseCursor(cursor) {
|
|
2571
|
+
await this.#runtime.run(async () => await (0, import_wiki_graph_core7.deleteContinuationCursor)(cursor));
|
|
2572
|
+
}
|
|
2262
2573
|
async inspect(options = {}) {
|
|
2263
2574
|
return await this.#readDocument(
|
|
2264
2575
|
async (document) => await inspectWikiGraphArchive(document, {
|
|
@@ -2273,7 +2584,7 @@ var WikiGraphArchiveHandle = class {
|
|
|
2273
2584
|
options.queryMode,
|
|
2274
2585
|
options.signal
|
|
2275
2586
|
);
|
|
2276
|
-
|
|
2587
|
+
const result = await this.#writeDocument(
|
|
2277
2588
|
async (document) => {
|
|
2278
2589
|
const chapters = await this.#resolveQueryChapters(document, options, {
|
|
2279
2590
|
embeddingProvider
|
|
@@ -2294,9 +2605,38 @@ var WikiGraphArchiveHandle = class {
|
|
|
2294
2605
|
...options.signal === void 0 ? {} : { signal: options.signal }
|
|
2295
2606
|
}
|
|
2296
2607
|
);
|
|
2608
|
+
return createArchiveFindPage(
|
|
2609
|
+
result,
|
|
2610
|
+
async (cursor, nextOptions) => await this.search(query, {
|
|
2611
|
+
...options,
|
|
2612
|
+
cursor,
|
|
2613
|
+
...nextOptions.limit === void 0 ? {} : { limit: nextOptions.limit },
|
|
2614
|
+
...nextOptions.signal === void 0 ? {} : { signal: nextOptions.signal }
|
|
2615
|
+
}),
|
|
2616
|
+
(cursor) => this.#persistCursor({
|
|
2617
|
+
archiveKey: this.archiveKey,
|
|
2618
|
+
archivePath: this.path,
|
|
2619
|
+
chapters: options.chapters ?? null,
|
|
2620
|
+
cursor,
|
|
2621
|
+
format: "json",
|
|
2622
|
+
indexScope: this.indexScope,
|
|
2623
|
+
kind: "search",
|
|
2624
|
+
...options.backlinks === void 0 ? {} : { backlinks: options.backlinks },
|
|
2625
|
+
...options.evidenceLimit === void 0 ? {} : { evidenceLimit: options.evidenceLimit },
|
|
2626
|
+
...options.match === void 0 ? {} : { match: options.match },
|
|
2627
|
+
...options.order === void 0 ? {} : { order: options.order },
|
|
2628
|
+
query,
|
|
2629
|
+
...options.queryMode === void 0 ? {} : { queryMode: options.queryMode },
|
|
2630
|
+
...options.skipUnindexed === void 0 ? {} : { skipUnindexed: options.skipUnindexed },
|
|
2631
|
+
...options.sourceContext === void 0 ? {} : { sourceContext: options.sourceContext },
|
|
2632
|
+
...options.triplePattern === void 0 ? {} : { triplePattern: options.triplePattern },
|
|
2633
|
+
types: options.types ?? null
|
|
2634
|
+
}),
|
|
2635
|
+
(token) => this.#releaseCursor(token)
|
|
2636
|
+
);
|
|
2297
2637
|
}
|
|
2298
2638
|
async list(options = {}) {
|
|
2299
|
-
|
|
2639
|
+
const result = await this.#readDocument(async (document) => {
|
|
2300
2640
|
if ((0, import_wiki_graph_core7.isSourceLocatorScopeUri)(this.objectUri)) {
|
|
2301
2641
|
return await (0, import_wiki_graph_core7.listArchiveSourceLocators)(document, this.objectUri, {
|
|
2302
2642
|
...options.cursor === void 0 ? {} : { cursor: options.cursor },
|
|
@@ -2309,6 +2649,53 @@ var WikiGraphArchiveHandle = class {
|
|
|
2309
2649
|
...chapters === void 0 ? {} : { chapters }
|
|
2310
2650
|
});
|
|
2311
2651
|
}, options);
|
|
2652
|
+
if ((0, import_wiki_graph_core7.isSourceLocatorScopeUri)(this.objectUri)) {
|
|
2653
|
+
return createArchiveSourceLocatorPage(
|
|
2654
|
+
result,
|
|
2655
|
+
async (cursor, nextOptions) => await this.list({
|
|
2656
|
+
...options,
|
|
2657
|
+
cursor,
|
|
2658
|
+
...nextOptions.limit === void 0 ? {} : { limit: nextOptions.limit },
|
|
2659
|
+
...nextOptions.signal === void 0 ? {} : { signal: nextOptions.signal }
|
|
2660
|
+
}),
|
|
2661
|
+
(cursor) => this.#persistCursor({
|
|
2662
|
+
archiveKey: this.archiveKey,
|
|
2663
|
+
archivePath: this.path,
|
|
2664
|
+
cursor,
|
|
2665
|
+
format: "json",
|
|
2666
|
+
indexScope: this.indexScope,
|
|
2667
|
+
kind: "source-locators",
|
|
2668
|
+
targetUri: this.objectUri
|
|
2669
|
+
}),
|
|
2670
|
+
(token) => this.#releaseCursor(token)
|
|
2671
|
+
);
|
|
2672
|
+
}
|
|
2673
|
+
return createArchiveCollectionPage(
|
|
2674
|
+
result,
|
|
2675
|
+
async (cursor, nextOptions) => await this.list({
|
|
2676
|
+
...options,
|
|
2677
|
+
cursor,
|
|
2678
|
+
...nextOptions.limit === void 0 ? {} : { limit: nextOptions.limit },
|
|
2679
|
+
...nextOptions.signal === void 0 ? {} : { signal: nextOptions.signal }
|
|
2680
|
+
}),
|
|
2681
|
+
(cursor) => this.#persistCursor({
|
|
2682
|
+
archiveKey: this.archiveKey,
|
|
2683
|
+
archivePath: this.path,
|
|
2684
|
+
...options.backlinks === void 0 ? {} : { backlinks: options.backlinks },
|
|
2685
|
+
chapters: options.chapters ?? null,
|
|
2686
|
+
cursor,
|
|
2687
|
+
...options.evidenceLimit === void 0 ? {} : { evidenceLimit: options.evidenceLimit },
|
|
2688
|
+
format: "json",
|
|
2689
|
+
ids: options.ids ?? null,
|
|
2690
|
+
indexScope: this.indexScope,
|
|
2691
|
+
kind: "collection",
|
|
2692
|
+
order: options.order ?? "doc-asc",
|
|
2693
|
+
...options.sourceContext === void 0 ? {} : { sourceContext: options.sourceContext },
|
|
2694
|
+
...options.triplePattern === void 0 ? {} : { triplePattern: options.triplePattern },
|
|
2695
|
+
types: options.types ?? null
|
|
2696
|
+
}),
|
|
2697
|
+
(token) => this.#releaseCursor(token)
|
|
2698
|
+
);
|
|
2312
2699
|
}
|
|
2313
2700
|
async ensureSearchIndex(options = {}) {
|
|
2314
2701
|
const embeddingProvider = await this.#runtime.run(
|
|
@@ -2585,19 +2972,30 @@ var WikiGraphArchiveHandle = class {
|
|
|
2585
2972
|
if (options.queryMode !== void 0) {
|
|
2586
2973
|
throw new Error("`queryMode` requires `query`.");
|
|
2587
2974
|
}
|
|
2588
|
-
|
|
2975
|
+
const result2 = await this.#readDocument(async (document) => {
|
|
2589
2976
|
const chapters = await this.#resolveScope(document, {});
|
|
2590
2977
|
return await (0, import_wiki_graph_core7.listRelatedArchiveObjects)(document, objectUri, {
|
|
2591
2978
|
...withoutOperation(options),
|
|
2592
2979
|
...chapters === void 0 ? {} : { chapters }
|
|
2593
2980
|
});
|
|
2594
2981
|
}, options);
|
|
2982
|
+
return createArchiveRelatedPage(
|
|
2983
|
+
result2,
|
|
2984
|
+
async (cursor, nextOptions) => await this.related(objectUri, {
|
|
2985
|
+
...options,
|
|
2986
|
+
cursor,
|
|
2987
|
+
...nextOptions.limit === void 0 ? {} : { limit: nextOptions.limit },
|
|
2988
|
+
...nextOptions.signal === void 0 ? {} : { signal: nextOptions.signal }
|
|
2989
|
+
}),
|
|
2990
|
+
(cursor) => Promise.resolve(cursor),
|
|
2991
|
+
() => Promise.resolve()
|
|
2992
|
+
);
|
|
2595
2993
|
}
|
|
2596
2994
|
const embeddingProvider = await this.#resolveQueryEmbeddingProvider(
|
|
2597
2995
|
options.queryMode,
|
|
2598
2996
|
options.signal
|
|
2599
2997
|
);
|
|
2600
|
-
|
|
2998
|
+
const result = await this.#writeDocument(
|
|
2601
2999
|
async (document) => {
|
|
2602
3000
|
const chapters = await this.#resolveQueryChapters(document, options, {
|
|
2603
3001
|
embeddingProvider
|
|
@@ -2617,25 +3015,47 @@ var WikiGraphArchiveHandle = class {
|
|
|
2617
3015
|
...options.signal === void 0 ? {} : { signal: options.signal }
|
|
2618
3016
|
}
|
|
2619
3017
|
);
|
|
3018
|
+
return createArchiveRelatedPage(
|
|
3019
|
+
result,
|
|
3020
|
+
async (cursor, nextOptions) => await this.related(objectUri, {
|
|
3021
|
+
...options,
|
|
3022
|
+
cursor,
|
|
3023
|
+
...nextOptions.limit === void 0 ? {} : { limit: nextOptions.limit },
|
|
3024
|
+
...nextOptions.signal === void 0 ? {} : { signal: nextOptions.signal }
|
|
3025
|
+
}),
|
|
3026
|
+
(cursor) => Promise.resolve(cursor),
|
|
3027
|
+
() => Promise.resolve()
|
|
3028
|
+
);
|
|
2620
3029
|
}
|
|
2621
3030
|
async evidence(objectUri = this.objectUri, options = {}) {
|
|
2622
3031
|
if (options.query === void 0) {
|
|
2623
3032
|
if (options.queryMode !== void 0) {
|
|
2624
3033
|
throw new Error("`queryMode` requires `query`.");
|
|
2625
3034
|
}
|
|
2626
|
-
|
|
3035
|
+
const result2 = await this.#readDocument(async (document) => {
|
|
2627
3036
|
const chapters = await this.#resolveScope(document, {});
|
|
2628
3037
|
return await (0, import_wiki_graph_core7.listArchiveEvidence)(document, objectUri, {
|
|
2629
3038
|
...withoutOperation(options),
|
|
2630
3039
|
...chapters === void 0 ? {} : { chapters }
|
|
2631
3040
|
});
|
|
2632
3041
|
}, options);
|
|
3042
|
+
return createArchiveEvidencePage(
|
|
3043
|
+
result2,
|
|
3044
|
+
async (cursor, nextOptions) => await this.evidence(objectUri, {
|
|
3045
|
+
...options,
|
|
3046
|
+
cursor,
|
|
3047
|
+
...nextOptions.limit === void 0 ? {} : { limit: nextOptions.limit },
|
|
3048
|
+
...nextOptions.signal === void 0 ? {} : { signal: nextOptions.signal }
|
|
3049
|
+
}),
|
|
3050
|
+
(cursor) => Promise.resolve(cursor),
|
|
3051
|
+
() => Promise.resolve()
|
|
3052
|
+
);
|
|
2633
3053
|
}
|
|
2634
3054
|
const embeddingProvider = await this.#resolveQueryEmbeddingProvider(
|
|
2635
3055
|
options.queryMode,
|
|
2636
3056
|
options.signal
|
|
2637
3057
|
);
|
|
2638
|
-
|
|
3058
|
+
const result = await this.#writeDocument(
|
|
2639
3059
|
async (document) => {
|
|
2640
3060
|
const chapters = await this.#resolveQueryChapters(document, options, {
|
|
2641
3061
|
embeddingProvider
|
|
@@ -2655,6 +3075,17 @@ var WikiGraphArchiveHandle = class {
|
|
|
2655
3075
|
...options.signal === void 0 ? {} : { signal: options.signal }
|
|
2656
3076
|
}
|
|
2657
3077
|
);
|
|
3078
|
+
return createArchiveEvidencePage(
|
|
3079
|
+
result,
|
|
3080
|
+
async (cursor, nextOptions) => await this.evidence(objectUri, {
|
|
3081
|
+
...options,
|
|
3082
|
+
cursor,
|
|
3083
|
+
...nextOptions.limit === void 0 ? {} : { limit: nextOptions.limit },
|
|
3084
|
+
...nextOptions.signal === void 0 ? {} : { signal: nextOptions.signal }
|
|
3085
|
+
}),
|
|
3086
|
+
(cursor) => Promise.resolve(cursor),
|
|
3087
|
+
() => Promise.resolve()
|
|
3088
|
+
);
|
|
2658
3089
|
}
|
|
2659
3090
|
async pack(objectUri = this.objectUri, budget = 5e3, options = {}) {
|
|
2660
3091
|
return await this.#readDocument(
|
|
@@ -2843,7 +3274,7 @@ function selectChapterSubtree(chapters, rootChapterId, depth) {
|
|
|
2843
3274
|
);
|
|
2844
3275
|
}
|
|
2845
3276
|
async function createEmptyArchiveFile(path) {
|
|
2846
|
-
const directoryPath = await (0,
|
|
3277
|
+
const directoryPath = await (0, import_promises5.mkdtemp)(
|
|
2847
3278
|
(0, import_path5.join)((0, import_os3.tmpdir)(), "wikigraph-archive-write-")
|
|
2848
3279
|
);
|
|
2849
3280
|
try {
|
|
@@ -2858,7 +3289,7 @@ async function createEmptyArchiveFile(path) {
|
|
|
2858
3289
|
}
|
|
2859
3290
|
await (0, import_wiki_graph_core7.writeWikgArchive)(directory, new NodeFile(path));
|
|
2860
3291
|
} finally {
|
|
2861
|
-
await (0,
|
|
3292
|
+
await (0, import_promises5.rm)(directoryPath, { force: true, recursive: true });
|
|
2862
3293
|
}
|
|
2863
3294
|
}
|
|
2864
3295
|
function isNodeEEXISTError(error) {
|
|
@@ -2866,7 +3297,7 @@ function isNodeEEXISTError(error) {
|
|
|
2866
3297
|
}
|
|
2867
3298
|
async function nodePathExists(path) {
|
|
2868
3299
|
try {
|
|
2869
|
-
await (0,
|
|
3300
|
+
await (0, import_promises5.stat)(path);
|
|
2870
3301
|
return true;
|
|
2871
3302
|
} catch (error) {
|
|
2872
3303
|
if (isNodeENOENTError(error)) return false;
|
|
@@ -3642,19 +4073,40 @@ function prepareWikiGraphSDKHost(host) {
|
|
|
3642
4073
|
(0, import_platform2.installWikiGraphPlatform)(host.platform);
|
|
3643
4074
|
}
|
|
3644
4075
|
function assertWikiGraphSDKHostOptions(options) {
|
|
3645
|
-
if (options.host?.storage !== void 0 && options.stateDir
|
|
4076
|
+
if (options.host?.storage !== void 0 && options.host.stateDir === void 0) {
|
|
3646
4077
|
throw new TypeError(
|
|
3647
|
-
"Wiki Graph SDK host.storage
|
|
4078
|
+
"Wiki Graph SDK host.storage requires host.stateDir so SDK configuration cannot fall back to the default user state directory."
|
|
4079
|
+
);
|
|
4080
|
+
}
|
|
4081
|
+
if (options.stateDir !== void 0 && (options.host?.stateDir !== void 0 || options.host?.storage !== void 0)) {
|
|
4082
|
+
throw new TypeError(
|
|
4083
|
+
"Wiki Graph SDK host state/storage and top-level stateDir cannot be used together. Put the state directory in host.stateDir when providing host.storage."
|
|
3648
4084
|
);
|
|
3649
4085
|
}
|
|
3650
4086
|
}
|
|
3651
4087
|
async function withWikiGraphSDKHost(options, operation) {
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
4088
|
+
const current = getWikiGraphSDKRuntimeContext();
|
|
4089
|
+
const effective = {
|
|
4090
|
+
...options.host === void 0 ? current.host === void 0 ? {} : { host: current.host } : { host: options.host },
|
|
4091
|
+
...options.stateDir === void 0 ? current.stateDir === void 0 ? {} : { stateDir: current.stateDir } : { stateDir: options.stateDir }
|
|
4092
|
+
};
|
|
4093
|
+
assertWikiGraphSDKHostOptions(effective);
|
|
4094
|
+
prepareWikiGraphSDKHost(effective.host);
|
|
4095
|
+
const runWithContext = async () => await withWikiGraphSDKRuntimeContext(
|
|
4096
|
+
{
|
|
4097
|
+
...current,
|
|
4098
|
+
...effective.host === void 0 ? {} : { host: effective.host },
|
|
4099
|
+
...effective.stateDir === void 0 ? {} : { stateDir: effective.stateDir }
|
|
4100
|
+
},
|
|
4101
|
+
operation
|
|
4102
|
+
);
|
|
4103
|
+
if (effective.host?.storage !== void 0) {
|
|
4104
|
+
return await (0, import_platform2.withWikiGraphStorage)(effective.host.storage, runWithContext);
|
|
3656
4105
|
}
|
|
3657
|
-
return await withNodeWikiGraphStorage(
|
|
4106
|
+
return await withNodeWikiGraphStorage(
|
|
4107
|
+
effective.host?.stateDir ?? effective.stateDir,
|
|
4108
|
+
runWithContext
|
|
4109
|
+
);
|
|
3658
4110
|
}
|
|
3659
4111
|
|
|
3660
4112
|
// src/worker.ts
|
|
@@ -4556,7 +5008,7 @@ function forwardAbort(source, target) {
|
|
|
4556
5008
|
|
|
4557
5009
|
// src/libraries.ts
|
|
4558
5010
|
var import_wiki_graph_core16 = require("wiki-graph-core");
|
|
4559
|
-
var
|
|
5011
|
+
var import_promises6 = require("fs/promises");
|
|
4560
5012
|
async function resolveQueryEmbeddingProvider(queryMode) {
|
|
4561
5013
|
if (queryMode === "fts") return void 0;
|
|
4562
5014
|
const provider = await createConfiguredEmbeddingProvider();
|
|
@@ -4575,7 +5027,7 @@ var WikiGraphLibraryManager = class {
|
|
|
4575
5027
|
async create(folder) {
|
|
4576
5028
|
const record = await this.#runtime.run(async () => {
|
|
4577
5029
|
const path = resolveWikiGraphRuntimePath(folder);
|
|
4578
|
-
await (0,
|
|
5030
|
+
await (0, import_promises6.mkdir)(path);
|
|
4579
5031
|
return await (0, import_wiki_graph_core16.createWikiGraphLibrary)({ folder: new NodeDirectory(path) });
|
|
4580
5032
|
});
|
|
4581
5033
|
return new WikiGraphLibrary(this.#runtime, record);
|
|
@@ -4761,7 +5213,7 @@ var WikiGraphLibraryManager = class {
|
|
|
4761
5213
|
);
|
|
4762
5214
|
}
|
|
4763
5215
|
async search(target, query, options = {}) {
|
|
4764
|
-
|
|
5216
|
+
const result = await this.#runtime.run(async () => {
|
|
4765
5217
|
const embeddingProvider = await resolveQueryEmbeddingProvider(
|
|
4766
5218
|
options.queryMode
|
|
4767
5219
|
);
|
|
@@ -4774,9 +5226,70 @@ var WikiGraphLibraryManager = class {
|
|
|
4774
5226
|
}
|
|
4775
5227
|
);
|
|
4776
5228
|
});
|
|
5229
|
+
return createArchiveFindPage(
|
|
5230
|
+
result,
|
|
5231
|
+
async (cursor, nextOptions) => await this.search(target, query, {
|
|
5232
|
+
...options,
|
|
5233
|
+
cursor,
|
|
5234
|
+
...nextOptions.limit === void 0 ? {} : { limit: nextOptions.limit },
|
|
5235
|
+
...nextOptions.signal === void 0 ? {} : { signal: nextOptions.signal }
|
|
5236
|
+
}),
|
|
5237
|
+
(cursor) => Promise.resolve(cursor),
|
|
5238
|
+
() => Promise.resolve()
|
|
5239
|
+
);
|
|
5240
|
+
}
|
|
5241
|
+
async searchBuckets(target, query, options) {
|
|
5242
|
+
const result = await this.#runtime.run(async () => {
|
|
5243
|
+
const embeddingProvider = await resolveQueryEmbeddingProvider(
|
|
5244
|
+
options.queryMode
|
|
5245
|
+
);
|
|
5246
|
+
return await (0, import_wiki_graph_core16.findWikiGraphLibraryObjectBuckets)(
|
|
5247
|
+
requireLibraryTarget(target),
|
|
5248
|
+
query,
|
|
5249
|
+
{
|
|
5250
|
+
...options,
|
|
5251
|
+
...embeddingProvider === void 0 ? {} : { embeddingProvider }
|
|
5252
|
+
}
|
|
5253
|
+
);
|
|
5254
|
+
});
|
|
5255
|
+
return {
|
|
5256
|
+
buckets: result.buckets.map(
|
|
5257
|
+
(bucket) => createLibraryBucketPage(
|
|
5258
|
+
bucket,
|
|
5259
|
+
async (cursor, nextOptions) => await this.continueSearchBucket(target, cursor, {
|
|
5260
|
+
...nextOptions.limit === void 0 ? {} : { limit: nextOptions.limit }
|
|
5261
|
+
}),
|
|
5262
|
+
(cursor) => Promise.resolve(cursor),
|
|
5263
|
+
() => Promise.resolve()
|
|
5264
|
+
)
|
|
5265
|
+
),
|
|
5266
|
+
query: result.query
|
|
5267
|
+
};
|
|
5268
|
+
}
|
|
5269
|
+
async continueSearchBucket(target, cursor, options = {}) {
|
|
5270
|
+
const result = await this.#runtime.run(async () => {
|
|
5271
|
+
const embeddingProvider = await resolveQueryEmbeddingProvider(void 0);
|
|
5272
|
+
return await (0, import_wiki_graph_core16.continueWikiGraphLibraryObjectBucket)(
|
|
5273
|
+
requireLibraryTarget(target),
|
|
5274
|
+
cursor,
|
|
5275
|
+
{
|
|
5276
|
+
...options,
|
|
5277
|
+
...embeddingProvider === void 0 ? {} : { embeddingProvider }
|
|
5278
|
+
}
|
|
5279
|
+
);
|
|
5280
|
+
});
|
|
5281
|
+
return createLibraryBucketPage(
|
|
5282
|
+
result,
|
|
5283
|
+
async (nextCursor, nextOptions) => await this.continueSearchBucket(target, nextCursor, {
|
|
5284
|
+
...options,
|
|
5285
|
+
...nextOptions.limit === void 0 ? {} : { limit: nextOptions.limit }
|
|
5286
|
+
}),
|
|
5287
|
+
(cursor2) => Promise.resolve(cursor2),
|
|
5288
|
+
() => Promise.resolve()
|
|
5289
|
+
);
|
|
4777
5290
|
}
|
|
4778
5291
|
async searchArchiveMembers(target, query, options = {}) {
|
|
4779
|
-
|
|
5292
|
+
const result = await this.#runtime.run(async () => {
|
|
4780
5293
|
const embeddingProvider = await resolveQueryEmbeddingProvider(
|
|
4781
5294
|
options.queryMode
|
|
4782
5295
|
);
|
|
@@ -4789,22 +5302,53 @@ var WikiGraphLibraryManager = class {
|
|
|
4789
5302
|
}
|
|
4790
5303
|
);
|
|
4791
5304
|
});
|
|
5305
|
+
return createArchiveFindPage(
|
|
5306
|
+
result,
|
|
5307
|
+
async (cursor, nextOptions) => await this.searchArchiveMembers(target, query, {
|
|
5308
|
+
...options,
|
|
5309
|
+
cursor,
|
|
5310
|
+
...nextOptions.limit === void 0 ? {} : { limit: nextOptions.limit },
|
|
5311
|
+
...nextOptions.signal === void 0 ? {} : { signal: nextOptions.signal }
|
|
5312
|
+
}),
|
|
5313
|
+
(cursor) => Promise.resolve(cursor),
|
|
5314
|
+
() => Promise.resolve()
|
|
5315
|
+
);
|
|
4792
5316
|
}
|
|
4793
5317
|
async objects(target, options = {}) {
|
|
4794
|
-
|
|
5318
|
+
const result = await this.#runtime.run(
|
|
4795
5319
|
async () => await (0, import_wiki_graph_core16.listWikiGraphLibraryObjects)(
|
|
4796
5320
|
requireLibraryTarget(target),
|
|
4797
5321
|
options
|
|
4798
5322
|
)
|
|
4799
5323
|
);
|
|
5324
|
+
return createArchiveCollectionPage(
|
|
5325
|
+
result,
|
|
5326
|
+
async (cursor, nextOptions) => await this.objects(target, {
|
|
5327
|
+
...options,
|
|
5328
|
+
cursor,
|
|
5329
|
+
...nextOptions.limit === void 0 ? {} : { limit: nextOptions.limit }
|
|
5330
|
+
}),
|
|
5331
|
+
(cursor) => Promise.resolve(cursor),
|
|
5332
|
+
() => Promise.resolve()
|
|
5333
|
+
);
|
|
4800
5334
|
}
|
|
4801
5335
|
async archiveMembers(target, options = {}) {
|
|
4802
|
-
|
|
5336
|
+
const result = await this.#runtime.run(
|
|
4803
5337
|
async () => await (0, import_wiki_graph_core16.listWikiGraphLibraryArchiveMembers)(
|
|
4804
5338
|
requireLibraryTarget(target),
|
|
4805
5339
|
options
|
|
4806
5340
|
)
|
|
4807
5341
|
);
|
|
5342
|
+
return createArchiveCollectionPage(
|
|
5343
|
+
result,
|
|
5344
|
+
async (cursor, nextOptions) => await this.archiveMembers(target, {
|
|
5345
|
+
...options,
|
|
5346
|
+
cursor,
|
|
5347
|
+
...nextOptions.limit === void 0 ? {} : { limit: nextOptions.limit }
|
|
5348
|
+
}),
|
|
5349
|
+
(cursor) => Promise.resolve(cursor),
|
|
5350
|
+
() => Promise.resolve()
|
|
5351
|
+
);
|
|
4808
5352
|
}
|
|
4809
5353
|
async page(target, objectUri, options = {}) {
|
|
4810
5354
|
return await this.#runtime.run(
|
|
@@ -4820,7 +5364,7 @@ var WikiGraphLibraryManager = class {
|
|
|
4820
5364
|
);
|
|
4821
5365
|
}
|
|
4822
5366
|
async related(target, objectUri, options = {}) {
|
|
4823
|
-
|
|
5367
|
+
const result = await this.#runtime.run(async () => {
|
|
4824
5368
|
if (options.query === void 0 && options.queryMode !== void 0) {
|
|
4825
5369
|
throw new Error("`queryMode` requires `query`.");
|
|
4826
5370
|
}
|
|
@@ -4834,9 +5378,20 @@ var WikiGraphLibraryManager = class {
|
|
|
4834
5378
|
}
|
|
4835
5379
|
);
|
|
4836
5380
|
});
|
|
5381
|
+
return createArchiveRelatedPage(
|
|
5382
|
+
result,
|
|
5383
|
+
async (cursor, nextOptions) => await this.related(target, objectUri, {
|
|
5384
|
+
...options,
|
|
5385
|
+
cursor,
|
|
5386
|
+
...nextOptions.limit === void 0 ? {} : { limit: nextOptions.limit },
|
|
5387
|
+
...nextOptions.signal === void 0 ? {} : { signal: nextOptions.signal }
|
|
5388
|
+
}),
|
|
5389
|
+
(cursor) => Promise.resolve(cursor),
|
|
5390
|
+
() => Promise.resolve()
|
|
5391
|
+
);
|
|
4837
5392
|
}
|
|
4838
5393
|
async evidence(target, objectUri, options = {}) {
|
|
4839
|
-
|
|
5394
|
+
const result = await this.#runtime.run(async () => {
|
|
4840
5395
|
if (options.query === void 0 && options.queryMode !== void 0) {
|
|
4841
5396
|
throw new Error("`queryMode` requires `query`.");
|
|
4842
5397
|
}
|
|
@@ -4850,6 +5405,17 @@ var WikiGraphLibraryManager = class {
|
|
|
4850
5405
|
}
|
|
4851
5406
|
);
|
|
4852
5407
|
});
|
|
5408
|
+
return createArchiveEvidencePage(
|
|
5409
|
+
result,
|
|
5410
|
+
async (cursor, nextOptions) => await this.evidence(target, objectUri, {
|
|
5411
|
+
...options,
|
|
5412
|
+
cursor,
|
|
5413
|
+
...nextOptions.limit === void 0 ? {} : { limit: nextOptions.limit },
|
|
5414
|
+
...nextOptions.signal === void 0 ? {} : { signal: nextOptions.signal }
|
|
5415
|
+
}),
|
|
5416
|
+
(cursor) => Promise.resolve(cursor),
|
|
5417
|
+
() => Promise.resolve()
|
|
5418
|
+
);
|
|
4853
5419
|
}
|
|
4854
5420
|
async pack(target, objectUri, budget = 5e3) {
|
|
4855
5421
|
return await this.#runtime.run(
|
|
@@ -5149,6 +5715,11 @@ function createWikiGraphSDK(options = {}) {
|
|
|
5149
5715
|
var import_wiki_graph_core19 = require("wiki-graph-core");
|
|
5150
5716
|
// Annotate the CommonJS export names for ESM import in node:
|
|
5151
5717
|
0 && (module.exports = {
|
|
5718
|
+
ArchiveCollectionPage,
|
|
5719
|
+
ArchiveEvidencePage,
|
|
5720
|
+
ArchiveFindPage,
|
|
5721
|
+
ArchiveRelatedPage,
|
|
5722
|
+
ArchiveSourceLocatorPage,
|
|
5152
5723
|
DANGEROUS_RUNTIME_ENV_NAMES,
|
|
5153
5724
|
DEFAULT_EXTRACTION_PROMPT,
|
|
5154
5725
|
DEFAULT_GENERATION_JOB_CONCURRENCY,
|
|
@@ -5156,6 +5727,7 @@ var import_wiki_graph_core19 = require("wiki-graph-core");
|
|
|
5156
5727
|
DEFAULT_KNOWLEDGE_GRAPH_RECALL_PROMPT,
|
|
5157
5728
|
LLMPaymentRequiredError,
|
|
5158
5729
|
LOCAL_CONFIG_SECTIONS,
|
|
5730
|
+
LibraryBucketPage,
|
|
5159
5731
|
NodeDirectory,
|
|
5160
5732
|
NodeFile,
|
|
5161
5733
|
WIKI_GRAPH_URI_PREFIX,
|
|
@@ -5176,11 +5748,19 @@ var import_wiki_graph_core19 = require("wiki-graph-core");
|
|
|
5176
5748
|
buildSearchIndexEmbeddingProvider,
|
|
5177
5749
|
buildWikiGraphLLMOptions,
|
|
5178
5750
|
clearLocalConfigSection,
|
|
5751
|
+
createArchiveCollectionPage,
|
|
5752
|
+
createArchiveEvidencePage,
|
|
5753
|
+
createArchiveFindPage,
|
|
5754
|
+
createArchiveRelatedPage,
|
|
5755
|
+
createArchiveSourceLocatorPage,
|
|
5756
|
+
createCursor,
|
|
5179
5757
|
createEntryRuntimeContext,
|
|
5180
5758
|
createGenerationPerformanceHints,
|
|
5759
|
+
createLibraryBucketPage,
|
|
5181
5760
|
createNodeTemplateEnvironment,
|
|
5182
5761
|
createNodeWikiGraphPlatform,
|
|
5183
5762
|
createNodeWikiGraphStorage,
|
|
5763
|
+
createPageCursor,
|
|
5184
5764
|
createStageLLM,
|
|
5185
5765
|
createWikiGraphSDK,
|
|
5186
5766
|
deleteLocalConfigValue,
|
|
@@ -5208,6 +5788,8 @@ var import_wiki_graph_core19 = require("wiki-graph-core");
|
|
|
5208
5788
|
isWikiGraphJobUri,
|
|
5209
5789
|
isWikiGraphLibraryUri,
|
|
5210
5790
|
isWikiGraphUri,
|
|
5791
|
+
iterateItems,
|
|
5792
|
+
iteratePages,
|
|
5211
5793
|
loadRequiredStageConfig,
|
|
5212
5794
|
loadWikiGraphRuntimeConfig,
|
|
5213
5795
|
maskLocalConfigSection,
|