wiki-graph-sdk 0.8.3 → 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/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,
@@ -2171,6 +2187,294 @@ async function writeWikiGraphArchiveLocation(location, operation, options = {})
2171
2187
  });
2172
2188
  }
2173
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
+
2174
2478
  // src/archive/archive.ts
2175
2479
  var WikiGraphArchiveExistsError = class extends Error {
2176
2480
  code = "WIKI_GRAPH_ARCHIVE_EXISTS";
@@ -2258,6 +2562,14 @@ var WikiGraphArchiveHandle = class {
2258
2562
  get target() {
2259
2563
  return this.#location.target;
2260
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
+ }
2261
2573
  async inspect(options = {}) {
2262
2574
  return await this.#readDocument(
2263
2575
  async (document) => await inspectWikiGraphArchive(document, {
@@ -2272,7 +2584,7 @@ var WikiGraphArchiveHandle = class {
2272
2584
  options.queryMode,
2273
2585
  options.signal
2274
2586
  );
2275
- return await this.#writeDocument(
2587
+ const result = await this.#writeDocument(
2276
2588
  async (document) => {
2277
2589
  const chapters = await this.#resolveQueryChapters(document, options, {
2278
2590
  embeddingProvider
@@ -2293,9 +2605,38 @@ var WikiGraphArchiveHandle = class {
2293
2605
  ...options.signal === void 0 ? {} : { signal: options.signal }
2294
2606
  }
2295
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
+ );
2296
2637
  }
2297
2638
  async list(options = {}) {
2298
- return await this.#readDocument(async (document) => {
2639
+ const result = await this.#readDocument(async (document) => {
2299
2640
  if ((0, import_wiki_graph_core7.isSourceLocatorScopeUri)(this.objectUri)) {
2300
2641
  return await (0, import_wiki_graph_core7.listArchiveSourceLocators)(document, this.objectUri, {
2301
2642
  ...options.cursor === void 0 ? {} : { cursor: options.cursor },
@@ -2308,6 +2649,53 @@ var WikiGraphArchiveHandle = class {
2308
2649
  ...chapters === void 0 ? {} : { chapters }
2309
2650
  });
2310
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
+ );
2311
2699
  }
2312
2700
  async ensureSearchIndex(options = {}) {
2313
2701
  const embeddingProvider = await this.#runtime.run(
@@ -2584,19 +2972,30 @@ var WikiGraphArchiveHandle = class {
2584
2972
  if (options.queryMode !== void 0) {
2585
2973
  throw new Error("`queryMode` requires `query`.");
2586
2974
  }
2587
- return await this.#readDocument(async (document) => {
2975
+ const result2 = await this.#readDocument(async (document) => {
2588
2976
  const chapters = await this.#resolveScope(document, {});
2589
2977
  return await (0, import_wiki_graph_core7.listRelatedArchiveObjects)(document, objectUri, {
2590
2978
  ...withoutOperation(options),
2591
2979
  ...chapters === void 0 ? {} : { chapters }
2592
2980
  });
2593
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
+ );
2594
2993
  }
2595
2994
  const embeddingProvider = await this.#resolveQueryEmbeddingProvider(
2596
2995
  options.queryMode,
2597
2996
  options.signal
2598
2997
  );
2599
- return await this.#writeDocument(
2998
+ const result = await this.#writeDocument(
2600
2999
  async (document) => {
2601
3000
  const chapters = await this.#resolveQueryChapters(document, options, {
2602
3001
  embeddingProvider
@@ -2616,25 +3015,47 @@ var WikiGraphArchiveHandle = class {
2616
3015
  ...options.signal === void 0 ? {} : { signal: options.signal }
2617
3016
  }
2618
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
+ );
2619
3029
  }
2620
3030
  async evidence(objectUri = this.objectUri, options = {}) {
2621
3031
  if (options.query === void 0) {
2622
3032
  if (options.queryMode !== void 0) {
2623
3033
  throw new Error("`queryMode` requires `query`.");
2624
3034
  }
2625
- return await this.#readDocument(async (document) => {
3035
+ const result2 = await this.#readDocument(async (document) => {
2626
3036
  const chapters = await this.#resolveScope(document, {});
2627
3037
  return await (0, import_wiki_graph_core7.listArchiveEvidence)(document, objectUri, {
2628
3038
  ...withoutOperation(options),
2629
3039
  ...chapters === void 0 ? {} : { chapters }
2630
3040
  });
2631
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
+ );
2632
3053
  }
2633
3054
  const embeddingProvider = await this.#resolveQueryEmbeddingProvider(
2634
3055
  options.queryMode,
2635
3056
  options.signal
2636
3057
  );
2637
- return await this.#writeDocument(
3058
+ const result = await this.#writeDocument(
2638
3059
  async (document) => {
2639
3060
  const chapters = await this.#resolveQueryChapters(document, options, {
2640
3061
  embeddingProvider
@@ -2654,6 +3075,17 @@ var WikiGraphArchiveHandle = class {
2654
3075
  ...options.signal === void 0 ? {} : { signal: options.signal }
2655
3076
  }
2656
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
+ );
2657
3089
  }
2658
3090
  async pack(objectUri = this.objectUri, budget = 5e3, options = {}) {
2659
3091
  return await this.#readDocument(
@@ -4781,7 +5213,7 @@ var WikiGraphLibraryManager = class {
4781
5213
  );
4782
5214
  }
4783
5215
  async search(target, query, options = {}) {
4784
- return await this.#runtime.run(async () => {
5216
+ const result = await this.#runtime.run(async () => {
4785
5217
  const embeddingProvider = await resolveQueryEmbeddingProvider(
4786
5218
  options.queryMode
4787
5219
  );
@@ -4794,9 +5226,70 @@ var WikiGraphLibraryManager = class {
4794
5226
  }
4795
5227
  );
4796
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
+ );
4797
5290
  }
4798
5291
  async searchArchiveMembers(target, query, options = {}) {
4799
- return await this.#runtime.run(async () => {
5292
+ const result = await this.#runtime.run(async () => {
4800
5293
  const embeddingProvider = await resolveQueryEmbeddingProvider(
4801
5294
  options.queryMode
4802
5295
  );
@@ -4809,22 +5302,53 @@ var WikiGraphLibraryManager = class {
4809
5302
  }
4810
5303
  );
4811
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
+ );
4812
5316
  }
4813
5317
  async objects(target, options = {}) {
4814
- return await this.#runtime.run(
5318
+ const result = await this.#runtime.run(
4815
5319
  async () => await (0, import_wiki_graph_core16.listWikiGraphLibraryObjects)(
4816
5320
  requireLibraryTarget(target),
4817
5321
  options
4818
5322
  )
4819
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
+ );
4820
5334
  }
4821
5335
  async archiveMembers(target, options = {}) {
4822
- return await this.#runtime.run(
5336
+ const result = await this.#runtime.run(
4823
5337
  async () => await (0, import_wiki_graph_core16.listWikiGraphLibraryArchiveMembers)(
4824
5338
  requireLibraryTarget(target),
4825
5339
  options
4826
5340
  )
4827
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
+ );
4828
5352
  }
4829
5353
  async page(target, objectUri, options = {}) {
4830
5354
  return await this.#runtime.run(
@@ -4840,7 +5364,7 @@ var WikiGraphLibraryManager = class {
4840
5364
  );
4841
5365
  }
4842
5366
  async related(target, objectUri, options = {}) {
4843
- return await this.#runtime.run(async () => {
5367
+ const result = await this.#runtime.run(async () => {
4844
5368
  if (options.query === void 0 && options.queryMode !== void 0) {
4845
5369
  throw new Error("`queryMode` requires `query`.");
4846
5370
  }
@@ -4854,9 +5378,20 @@ var WikiGraphLibraryManager = class {
4854
5378
  }
4855
5379
  );
4856
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
+ );
4857
5392
  }
4858
5393
  async evidence(target, objectUri, options = {}) {
4859
- return await this.#runtime.run(async () => {
5394
+ const result = await this.#runtime.run(async () => {
4860
5395
  if (options.query === void 0 && options.queryMode !== void 0) {
4861
5396
  throw new Error("`queryMode` requires `query`.");
4862
5397
  }
@@ -4870,6 +5405,17 @@ var WikiGraphLibraryManager = class {
4870
5405
  }
4871
5406
  );
4872
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
+ );
4873
5419
  }
4874
5420
  async pack(target, objectUri, budget = 5e3) {
4875
5421
  return await this.#runtime.run(
@@ -5169,6 +5715,11 @@ function createWikiGraphSDK(options = {}) {
5169
5715
  var import_wiki_graph_core19 = require("wiki-graph-core");
5170
5716
  // Annotate the CommonJS export names for ESM import in node:
5171
5717
  0 && (module.exports = {
5718
+ ArchiveCollectionPage,
5719
+ ArchiveEvidencePage,
5720
+ ArchiveFindPage,
5721
+ ArchiveRelatedPage,
5722
+ ArchiveSourceLocatorPage,
5172
5723
  DANGEROUS_RUNTIME_ENV_NAMES,
5173
5724
  DEFAULT_EXTRACTION_PROMPT,
5174
5725
  DEFAULT_GENERATION_JOB_CONCURRENCY,
@@ -5176,6 +5727,7 @@ var import_wiki_graph_core19 = require("wiki-graph-core");
5176
5727
  DEFAULT_KNOWLEDGE_GRAPH_RECALL_PROMPT,
5177
5728
  LLMPaymentRequiredError,
5178
5729
  LOCAL_CONFIG_SECTIONS,
5730
+ LibraryBucketPage,
5179
5731
  NodeDirectory,
5180
5732
  NodeFile,
5181
5733
  WIKI_GRAPH_URI_PREFIX,
@@ -5196,11 +5748,19 @@ var import_wiki_graph_core19 = require("wiki-graph-core");
5196
5748
  buildSearchIndexEmbeddingProvider,
5197
5749
  buildWikiGraphLLMOptions,
5198
5750
  clearLocalConfigSection,
5751
+ createArchiveCollectionPage,
5752
+ createArchiveEvidencePage,
5753
+ createArchiveFindPage,
5754
+ createArchiveRelatedPage,
5755
+ createArchiveSourceLocatorPage,
5756
+ createCursor,
5199
5757
  createEntryRuntimeContext,
5200
5758
  createGenerationPerformanceHints,
5759
+ createLibraryBucketPage,
5201
5760
  createNodeTemplateEnvironment,
5202
5761
  createNodeWikiGraphPlatform,
5203
5762
  createNodeWikiGraphStorage,
5763
+ createPageCursor,
5204
5764
  createStageLLM,
5205
5765
  createWikiGraphSDK,
5206
5766
  deleteLocalConfigValue,
@@ -5228,6 +5788,8 @@ var import_wiki_graph_core19 = require("wiki-graph-core");
5228
5788
  isWikiGraphJobUri,
5229
5789
  isWikiGraphLibraryUri,
5230
5790
  isWikiGraphUri,
5791
+ iterateItems,
5792
+ iteratePages,
5231
5793
  loadRequiredStageConfig,
5232
5794
  loadWikiGraphRuntimeConfig,
5233
5795
  maskLocalConfigSection,