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.js CHANGED
@@ -15,6 +15,8 @@ import {
15
15
  assertNoActiveBuildJobConflicts,
16
16
  assertNoActiveBuildJobs,
17
17
  deleteArchiveSearchSessions,
18
+ createContinuationCursor,
19
+ deleteContinuationCursor,
18
20
  DirectoryDocument,
19
21
  findArchiveObjects,
20
22
  formatLocatedWikiGraphUri as formatLocatedWikiGraphUri2,
@@ -2108,6 +2110,294 @@ async function writeWikiGraphArchiveLocation(location, operation, options = {})
2108
2110
  });
2109
2111
  }
2110
2112
 
2113
+ // src/pages.ts
2114
+ function createCursor(implementation) {
2115
+ let released = false;
2116
+ const assertLive = () => {
2117
+ if (released) throw new Error("Cursor has been released.");
2118
+ };
2119
+ return {
2120
+ pageClass: implementation.pageClass,
2121
+ async next(options = {}) {
2122
+ assertLive();
2123
+ return await implementation.next(options);
2124
+ },
2125
+ async token() {
2126
+ assertLive();
2127
+ return await implementation.token();
2128
+ },
2129
+ async release() {
2130
+ if (released) return;
2131
+ released = true;
2132
+ await implementation.release?.();
2133
+ }
2134
+ };
2135
+ }
2136
+ function createPageCursor(implementation) {
2137
+ let token;
2138
+ return createCursor({
2139
+ pageClass: implementation.pageClass,
2140
+ next: async (options) => await implementation.next(implementation.rawCursor, options),
2141
+ token: async () => {
2142
+ token ??= await implementation.createToken(implementation.rawCursor);
2143
+ return token;
2144
+ },
2145
+ release: async () => {
2146
+ if (token !== void 0) await implementation.releaseToken?.(token);
2147
+ token = void 0;
2148
+ }
2149
+ });
2150
+ }
2151
+ async function* iteratePages(firstPage, options = {}) {
2152
+ let page = firstPage;
2153
+ while (true) {
2154
+ yield page;
2155
+ const cursor = page.nextCursor();
2156
+ if (cursor === null) return;
2157
+ try {
2158
+ const nextPage = await cursor.next(options);
2159
+ await cursor.release();
2160
+ page = nextPage;
2161
+ } catch (error) {
2162
+ await cursor.release();
2163
+ throw error;
2164
+ }
2165
+ }
2166
+ }
2167
+ async function* iterateItems(firstPage, options = {}) {
2168
+ for await (const page of iteratePages(firstPage, options)) {
2169
+ yield* page;
2170
+ }
2171
+ }
2172
+
2173
+ // src/result-pages.ts
2174
+ var ArchiveFindPage = class _ArchiveFindPage {
2175
+ result;
2176
+ chapters;
2177
+ items;
2178
+ lens;
2179
+ lensHint;
2180
+ limit;
2181
+ match;
2182
+ rawNextCursor;
2183
+ order;
2184
+ query;
2185
+ terms;
2186
+ types;
2187
+ #cursor;
2188
+ constructor(result, cursor = null) {
2189
+ this.result = result;
2190
+ this.chapters = result.chapters;
2191
+ this.items = result.items;
2192
+ this.lens = result.lens;
2193
+ this.lensHint = result.lensHint;
2194
+ this.limit = result.limit;
2195
+ this.match = result.match;
2196
+ this.rawNextCursor = result.nextCursor;
2197
+ this.order = result.order;
2198
+ this.query = result.query;
2199
+ this.terms = result.terms;
2200
+ this.types = result.types;
2201
+ this.#cursor = cursor;
2202
+ }
2203
+ static pageClass = _ArchiveFindPage;
2204
+ [Symbol.iterator]() {
2205
+ return this.items[Symbol.iterator]();
2206
+ }
2207
+ nextCursor() {
2208
+ return this.#cursor;
2209
+ }
2210
+ };
2211
+ var ArchiveCollectionPage = class _ArchiveCollectionPage {
2212
+ result;
2213
+ chapters;
2214
+ ids;
2215
+ items;
2216
+ limit;
2217
+ rawNextCursor;
2218
+ order;
2219
+ types;
2220
+ #cursor;
2221
+ constructor(result, cursor = null) {
2222
+ this.result = result;
2223
+ this.chapters = result.chapters;
2224
+ this.ids = result.ids;
2225
+ this.items = result.items;
2226
+ this.limit = result.limit;
2227
+ this.rawNextCursor = result.nextCursor;
2228
+ this.order = result.order;
2229
+ this.types = result.types;
2230
+ this.#cursor = cursor;
2231
+ }
2232
+ static pageClass = _ArchiveCollectionPage;
2233
+ [Symbol.iterator]() {
2234
+ return this.items[Symbol.iterator]();
2235
+ }
2236
+ nextCursor() {
2237
+ return this.#cursor;
2238
+ }
2239
+ };
2240
+ var ArchiveEvidencePage = class _ArchiveEvidencePage {
2241
+ result;
2242
+ items;
2243
+ limit;
2244
+ rawNextCursor;
2245
+ #cursor;
2246
+ constructor(result, cursor = null) {
2247
+ this.result = result;
2248
+ this.items = result.items;
2249
+ this.limit = result.limit;
2250
+ this.rawNextCursor = result.nextCursor;
2251
+ this.#cursor = cursor;
2252
+ }
2253
+ static pageClass = _ArchiveEvidencePage;
2254
+ [Symbol.iterator]() {
2255
+ return this.items[Symbol.iterator]();
2256
+ }
2257
+ nextCursor() {
2258
+ return this.#cursor;
2259
+ }
2260
+ };
2261
+ var ArchiveRelatedPage = class _ArchiveRelatedPage {
2262
+ result;
2263
+ items;
2264
+ limit;
2265
+ rawNextCursor;
2266
+ #cursor;
2267
+ constructor(result, cursor = null) {
2268
+ this.result = result;
2269
+ this.items = result.items;
2270
+ this.limit = result.limit;
2271
+ this.rawNextCursor = result.nextCursor;
2272
+ this.#cursor = cursor;
2273
+ }
2274
+ static pageClass = _ArchiveRelatedPage;
2275
+ [Symbol.iterator]() {
2276
+ return this.items[Symbol.iterator]();
2277
+ }
2278
+ nextCursor() {
2279
+ return this.#cursor;
2280
+ }
2281
+ };
2282
+ var ArchiveSourceLocatorPage = class _ArchiveSourceLocatorPage {
2283
+ result;
2284
+ items;
2285
+ limit;
2286
+ rawNextCursor;
2287
+ #cursor;
2288
+ constructor(result, cursor = null) {
2289
+ this.result = result;
2290
+ this.items = result.items;
2291
+ this.limit = result.limit;
2292
+ this.rawNextCursor = result.nextCursor;
2293
+ this.#cursor = cursor;
2294
+ }
2295
+ static pageClass = _ArchiveSourceLocatorPage;
2296
+ [Symbol.iterator]() {
2297
+ return this.items[Symbol.iterator]();
2298
+ }
2299
+ nextCursor() {
2300
+ return this.#cursor;
2301
+ }
2302
+ };
2303
+ function createArchiveFindPage(result, next, createToken, releaseToken) {
2304
+ return new ArchiveFindPage(
2305
+ result,
2306
+ result.nextCursor === null ? null : createPageCursor({
2307
+ pageClass: ArchiveFindPage,
2308
+ rawCursor: result.nextCursor,
2309
+ next,
2310
+ createToken,
2311
+ releaseToken
2312
+ })
2313
+ );
2314
+ }
2315
+ function createArchiveCollectionPage(result, next, createToken, releaseToken) {
2316
+ return new ArchiveCollectionPage(
2317
+ result,
2318
+ result.nextCursor === null ? null : createPageCursor({
2319
+ pageClass: ArchiveCollectionPage,
2320
+ rawCursor: result.nextCursor,
2321
+ next,
2322
+ createToken,
2323
+ releaseToken
2324
+ })
2325
+ );
2326
+ }
2327
+ function createArchiveEvidencePage(result, next, createToken, releaseToken) {
2328
+ return new ArchiveEvidencePage(
2329
+ result,
2330
+ result.nextCursor === null ? null : createPageCursor({
2331
+ pageClass: ArchiveEvidencePage,
2332
+ rawCursor: result.nextCursor,
2333
+ next,
2334
+ createToken,
2335
+ releaseToken
2336
+ })
2337
+ );
2338
+ }
2339
+ function createArchiveRelatedPage(result, next, createToken, releaseToken) {
2340
+ return new ArchiveRelatedPage(
2341
+ result,
2342
+ result.nextCursor === null ? null : createPageCursor({
2343
+ pageClass: ArchiveRelatedPage,
2344
+ rawCursor: result.nextCursor,
2345
+ next,
2346
+ createToken,
2347
+ releaseToken
2348
+ })
2349
+ );
2350
+ }
2351
+ function createArchiveSourceLocatorPage(result, next, createToken, releaseToken) {
2352
+ return new ArchiveSourceLocatorPage(
2353
+ result,
2354
+ result.nextCursor === null ? null : createPageCursor({
2355
+ pageClass: ArchiveSourceLocatorPage,
2356
+ rawCursor: result.nextCursor,
2357
+ next,
2358
+ createToken,
2359
+ releaseToken
2360
+ })
2361
+ );
2362
+ }
2363
+ var LibraryBucketPage = class _LibraryBucketPage {
2364
+ id;
2365
+ items;
2366
+ rawNextCursor;
2367
+ query;
2368
+ terms;
2369
+ types;
2370
+ #cursor;
2371
+ constructor(result, cursor = null) {
2372
+ this.id = result.id;
2373
+ this.items = result.items;
2374
+ this.rawNextCursor = result.nextCursor;
2375
+ this.query = result.query;
2376
+ this.terms = result.terms;
2377
+ this.types = result.types;
2378
+ this.#cursor = cursor;
2379
+ }
2380
+ static pageClass = _LibraryBucketPage;
2381
+ [Symbol.iterator]() {
2382
+ return this.items[Symbol.iterator]();
2383
+ }
2384
+ nextCursor() {
2385
+ return this.#cursor;
2386
+ }
2387
+ };
2388
+ function createLibraryBucketPage(result, next, createToken, releaseToken) {
2389
+ return new LibraryBucketPage(
2390
+ result,
2391
+ result.nextCursor === null ? null : createPageCursor({
2392
+ pageClass: LibraryBucketPage,
2393
+ rawCursor: result.nextCursor,
2394
+ next,
2395
+ createToken,
2396
+ releaseToken
2397
+ })
2398
+ );
2399
+ }
2400
+
2111
2401
  // src/archive/archive.ts
2112
2402
  var WikiGraphArchiveExistsError = class extends Error {
2113
2403
  code = "WIKI_GRAPH_ARCHIVE_EXISTS";
@@ -2195,6 +2485,14 @@ var WikiGraphArchiveHandle = class {
2195
2485
  get target() {
2196
2486
  return this.#location.target;
2197
2487
  }
2488
+ async #persistCursor(cursor) {
2489
+ return await this.#runtime.run(
2490
+ async () => await createContinuationCursor(cursor)
2491
+ );
2492
+ }
2493
+ async #releaseCursor(cursor) {
2494
+ await this.#runtime.run(async () => await deleteContinuationCursor(cursor));
2495
+ }
2198
2496
  async inspect(options = {}) {
2199
2497
  return await this.#readDocument(
2200
2498
  async (document) => await inspectWikiGraphArchive(document, {
@@ -2209,7 +2507,7 @@ var WikiGraphArchiveHandle = class {
2209
2507
  options.queryMode,
2210
2508
  options.signal
2211
2509
  );
2212
- return await this.#writeDocument(
2510
+ const result = await this.#writeDocument(
2213
2511
  async (document) => {
2214
2512
  const chapters = await this.#resolveQueryChapters(document, options, {
2215
2513
  embeddingProvider
@@ -2230,9 +2528,38 @@ var WikiGraphArchiveHandle = class {
2230
2528
  ...options.signal === void 0 ? {} : { signal: options.signal }
2231
2529
  }
2232
2530
  );
2531
+ return createArchiveFindPage(
2532
+ result,
2533
+ async (cursor, nextOptions) => await this.search(query, {
2534
+ ...options,
2535
+ cursor,
2536
+ ...nextOptions.limit === void 0 ? {} : { limit: nextOptions.limit },
2537
+ ...nextOptions.signal === void 0 ? {} : { signal: nextOptions.signal }
2538
+ }),
2539
+ (cursor) => this.#persistCursor({
2540
+ archiveKey: this.archiveKey,
2541
+ archivePath: this.path,
2542
+ chapters: options.chapters ?? null,
2543
+ cursor,
2544
+ format: "json",
2545
+ indexScope: this.indexScope,
2546
+ kind: "search",
2547
+ ...options.backlinks === void 0 ? {} : { backlinks: options.backlinks },
2548
+ ...options.evidenceLimit === void 0 ? {} : { evidenceLimit: options.evidenceLimit },
2549
+ ...options.match === void 0 ? {} : { match: options.match },
2550
+ ...options.order === void 0 ? {} : { order: options.order },
2551
+ query,
2552
+ ...options.queryMode === void 0 ? {} : { queryMode: options.queryMode },
2553
+ ...options.skipUnindexed === void 0 ? {} : { skipUnindexed: options.skipUnindexed },
2554
+ ...options.sourceContext === void 0 ? {} : { sourceContext: options.sourceContext },
2555
+ ...options.triplePattern === void 0 ? {} : { triplePattern: options.triplePattern },
2556
+ types: options.types ?? null
2557
+ }),
2558
+ (token) => this.#releaseCursor(token)
2559
+ );
2233
2560
  }
2234
2561
  async list(options = {}) {
2235
- return await this.#readDocument(async (document) => {
2562
+ const result = await this.#readDocument(async (document) => {
2236
2563
  if (isSourceLocatorScopeUri(this.objectUri)) {
2237
2564
  return await listArchiveSourceLocators(document, this.objectUri, {
2238
2565
  ...options.cursor === void 0 ? {} : { cursor: options.cursor },
@@ -2245,6 +2572,53 @@ var WikiGraphArchiveHandle = class {
2245
2572
  ...chapters === void 0 ? {} : { chapters }
2246
2573
  });
2247
2574
  }, options);
2575
+ if (isSourceLocatorScopeUri(this.objectUri)) {
2576
+ return createArchiveSourceLocatorPage(
2577
+ result,
2578
+ async (cursor, nextOptions) => await this.list({
2579
+ ...options,
2580
+ cursor,
2581
+ ...nextOptions.limit === void 0 ? {} : { limit: nextOptions.limit },
2582
+ ...nextOptions.signal === void 0 ? {} : { signal: nextOptions.signal }
2583
+ }),
2584
+ (cursor) => this.#persistCursor({
2585
+ archiveKey: this.archiveKey,
2586
+ archivePath: this.path,
2587
+ cursor,
2588
+ format: "json",
2589
+ indexScope: this.indexScope,
2590
+ kind: "source-locators",
2591
+ targetUri: this.objectUri
2592
+ }),
2593
+ (token) => this.#releaseCursor(token)
2594
+ );
2595
+ }
2596
+ return createArchiveCollectionPage(
2597
+ result,
2598
+ async (cursor, nextOptions) => await this.list({
2599
+ ...options,
2600
+ cursor,
2601
+ ...nextOptions.limit === void 0 ? {} : { limit: nextOptions.limit },
2602
+ ...nextOptions.signal === void 0 ? {} : { signal: nextOptions.signal }
2603
+ }),
2604
+ (cursor) => this.#persistCursor({
2605
+ archiveKey: this.archiveKey,
2606
+ archivePath: this.path,
2607
+ ...options.backlinks === void 0 ? {} : { backlinks: options.backlinks },
2608
+ chapters: options.chapters ?? null,
2609
+ cursor,
2610
+ ...options.evidenceLimit === void 0 ? {} : { evidenceLimit: options.evidenceLimit },
2611
+ format: "json",
2612
+ ids: options.ids ?? null,
2613
+ indexScope: this.indexScope,
2614
+ kind: "collection",
2615
+ order: options.order ?? "doc-asc",
2616
+ ...options.sourceContext === void 0 ? {} : { sourceContext: options.sourceContext },
2617
+ ...options.triplePattern === void 0 ? {} : { triplePattern: options.triplePattern },
2618
+ types: options.types ?? null
2619
+ }),
2620
+ (token) => this.#releaseCursor(token)
2621
+ );
2248
2622
  }
2249
2623
  async ensureSearchIndex(options = {}) {
2250
2624
  const embeddingProvider = await this.#runtime.run(
@@ -2521,19 +2895,30 @@ var WikiGraphArchiveHandle = class {
2521
2895
  if (options.queryMode !== void 0) {
2522
2896
  throw new Error("`queryMode` requires `query`.");
2523
2897
  }
2524
- return await this.#readDocument(async (document) => {
2898
+ const result2 = await this.#readDocument(async (document) => {
2525
2899
  const chapters = await this.#resolveScope(document, {});
2526
2900
  return await listRelatedArchiveObjects(document, objectUri, {
2527
2901
  ...withoutOperation(options),
2528
2902
  ...chapters === void 0 ? {} : { chapters }
2529
2903
  });
2530
2904
  }, options);
2905
+ return createArchiveRelatedPage(
2906
+ result2,
2907
+ async (cursor, nextOptions) => await this.related(objectUri, {
2908
+ ...options,
2909
+ cursor,
2910
+ ...nextOptions.limit === void 0 ? {} : { limit: nextOptions.limit },
2911
+ ...nextOptions.signal === void 0 ? {} : { signal: nextOptions.signal }
2912
+ }),
2913
+ (cursor) => Promise.resolve(cursor),
2914
+ () => Promise.resolve()
2915
+ );
2531
2916
  }
2532
2917
  const embeddingProvider = await this.#resolveQueryEmbeddingProvider(
2533
2918
  options.queryMode,
2534
2919
  options.signal
2535
2920
  );
2536
- return await this.#writeDocument(
2921
+ const result = await this.#writeDocument(
2537
2922
  async (document) => {
2538
2923
  const chapters = await this.#resolveQueryChapters(document, options, {
2539
2924
  embeddingProvider
@@ -2553,25 +2938,47 @@ var WikiGraphArchiveHandle = class {
2553
2938
  ...options.signal === void 0 ? {} : { signal: options.signal }
2554
2939
  }
2555
2940
  );
2941
+ return createArchiveRelatedPage(
2942
+ result,
2943
+ async (cursor, nextOptions) => await this.related(objectUri, {
2944
+ ...options,
2945
+ cursor,
2946
+ ...nextOptions.limit === void 0 ? {} : { limit: nextOptions.limit },
2947
+ ...nextOptions.signal === void 0 ? {} : { signal: nextOptions.signal }
2948
+ }),
2949
+ (cursor) => Promise.resolve(cursor),
2950
+ () => Promise.resolve()
2951
+ );
2556
2952
  }
2557
2953
  async evidence(objectUri = this.objectUri, options = {}) {
2558
2954
  if (options.query === void 0) {
2559
2955
  if (options.queryMode !== void 0) {
2560
2956
  throw new Error("`queryMode` requires `query`.");
2561
2957
  }
2562
- return await this.#readDocument(async (document) => {
2958
+ const result2 = await this.#readDocument(async (document) => {
2563
2959
  const chapters = await this.#resolveScope(document, {});
2564
2960
  return await listArchiveEvidence(document, objectUri, {
2565
2961
  ...withoutOperation(options),
2566
2962
  ...chapters === void 0 ? {} : { chapters }
2567
2963
  });
2568
2964
  }, options);
2965
+ return createArchiveEvidencePage(
2966
+ result2,
2967
+ async (cursor, nextOptions) => await this.evidence(objectUri, {
2968
+ ...options,
2969
+ cursor,
2970
+ ...nextOptions.limit === void 0 ? {} : { limit: nextOptions.limit },
2971
+ ...nextOptions.signal === void 0 ? {} : { signal: nextOptions.signal }
2972
+ }),
2973
+ (cursor) => Promise.resolve(cursor),
2974
+ () => Promise.resolve()
2975
+ );
2569
2976
  }
2570
2977
  const embeddingProvider = await this.#resolveQueryEmbeddingProvider(
2571
2978
  options.queryMode,
2572
2979
  options.signal
2573
2980
  );
2574
- return await this.#writeDocument(
2981
+ const result = await this.#writeDocument(
2575
2982
  async (document) => {
2576
2983
  const chapters = await this.#resolveQueryChapters(document, options, {
2577
2984
  embeddingProvider
@@ -2591,6 +2998,17 @@ var WikiGraphArchiveHandle = class {
2591
2998
  ...options.signal === void 0 ? {} : { signal: options.signal }
2592
2999
  }
2593
3000
  );
3001
+ return createArchiveEvidencePage(
3002
+ result,
3003
+ async (cursor, nextOptions) => await this.evidence(objectUri, {
3004
+ ...options,
3005
+ cursor,
3006
+ ...nextOptions.limit === void 0 ? {} : { limit: nextOptions.limit },
3007
+ ...nextOptions.signal === void 0 ? {} : { signal: nextOptions.signal }
3008
+ }),
3009
+ (cursor) => Promise.resolve(cursor),
3010
+ () => Promise.resolve()
3011
+ );
2594
3012
  }
2595
3013
  async pack(objectUri = this.objectUri, budget = 5e3, options = {}) {
2596
3014
  return await this.#readDocument(
@@ -3074,7 +3492,7 @@ function parseProvider(value) {
3074
3492
 
3075
3493
  // src/continuations.ts
3076
3494
  import {
3077
- createContinuationCursor,
3495
+ createContinuationCursor as createContinuationCursor2,
3078
3496
  findArchiveObjects as findArchiveObjects2,
3079
3497
  findWikiGraphLibraryArchiveMembers,
3080
3498
  findWikiGraphLibraryObjects,
@@ -3104,7 +3522,7 @@ var WikiGraphContinuationManager = class {
3104
3522
  async create(context, cursor) {
3105
3523
  if (cursor === null || cursor === void 0) return null;
3106
3524
  return await this.#runtime.run(
3107
- async () => await createContinuationCursor(
3525
+ async () => await createContinuationCursor2(
3108
3526
  createContinuationPayload(context, cursor)
3109
3527
  )
3110
3528
  );
@@ -3297,7 +3715,7 @@ function getCursorArchivePath(cursor) {
3297
3715
  }
3298
3716
  async function persistResultCursor(cursor, result) {
3299
3717
  if (result.nextCursor === null) return result;
3300
- const nextCursor = await createContinuationCursor({
3718
+ const nextCursor = await createContinuationCursor2({
3301
3719
  ...cursor,
3302
3720
  cursor: result.nextCursor
3303
3721
  });
@@ -4581,9 +4999,11 @@ import {
4581
4999
  assertWikiGraphLibrarySchemaCurrent,
4582
5000
  cleanWikiGraphLibraryIndex,
4583
5001
  clearWikiGraphLibraryMetadata,
5002
+ continueWikiGraphLibraryObjectBucket,
4584
5003
  createWikiGraphLibrary,
4585
5004
  deleteWikiGraphLibraryMetadataKey,
4586
5005
  findWikiGraphLibraryObjects as findWikiGraphLibraryObjects2,
5006
+ findWikiGraphLibraryObjectBuckets,
4587
5007
  findWikiGraphLibraryArchiveMembers as findWikiGraphLibraryArchiveMembers2,
4588
5008
  formatWikiGraphLibraryUri as formatWikiGraphLibraryUri2,
4589
5009
  getWikiGraphLibraryArchive,
@@ -4815,7 +5235,7 @@ var WikiGraphLibraryManager = class {
4815
5235
  );
4816
5236
  }
4817
5237
  async search(target, query, options = {}) {
4818
- return await this.#runtime.run(async () => {
5238
+ const result = await this.#runtime.run(async () => {
4819
5239
  const embeddingProvider = await resolveQueryEmbeddingProvider(
4820
5240
  options.queryMode
4821
5241
  );
@@ -4828,9 +5248,70 @@ var WikiGraphLibraryManager = class {
4828
5248
  }
4829
5249
  );
4830
5250
  });
5251
+ return createArchiveFindPage(
5252
+ result,
5253
+ async (cursor, nextOptions) => await this.search(target, query, {
5254
+ ...options,
5255
+ cursor,
5256
+ ...nextOptions.limit === void 0 ? {} : { limit: nextOptions.limit },
5257
+ ...nextOptions.signal === void 0 ? {} : { signal: nextOptions.signal }
5258
+ }),
5259
+ (cursor) => Promise.resolve(cursor),
5260
+ () => Promise.resolve()
5261
+ );
5262
+ }
5263
+ async searchBuckets(target, query, options) {
5264
+ const result = await this.#runtime.run(async () => {
5265
+ const embeddingProvider = await resolveQueryEmbeddingProvider(
5266
+ options.queryMode
5267
+ );
5268
+ return await findWikiGraphLibraryObjectBuckets(
5269
+ requireLibraryTarget(target),
5270
+ query,
5271
+ {
5272
+ ...options,
5273
+ ...embeddingProvider === void 0 ? {} : { embeddingProvider }
5274
+ }
5275
+ );
5276
+ });
5277
+ return {
5278
+ buckets: result.buckets.map(
5279
+ (bucket) => createLibraryBucketPage(
5280
+ bucket,
5281
+ async (cursor, nextOptions) => await this.continueSearchBucket(target, cursor, {
5282
+ ...nextOptions.limit === void 0 ? {} : { limit: nextOptions.limit }
5283
+ }),
5284
+ (cursor) => Promise.resolve(cursor),
5285
+ () => Promise.resolve()
5286
+ )
5287
+ ),
5288
+ query: result.query
5289
+ };
5290
+ }
5291
+ async continueSearchBucket(target, cursor, options = {}) {
5292
+ const result = await this.#runtime.run(async () => {
5293
+ const embeddingProvider = await resolveQueryEmbeddingProvider(void 0);
5294
+ return await continueWikiGraphLibraryObjectBucket(
5295
+ requireLibraryTarget(target),
5296
+ cursor,
5297
+ {
5298
+ ...options,
5299
+ ...embeddingProvider === void 0 ? {} : { embeddingProvider }
5300
+ }
5301
+ );
5302
+ });
5303
+ return createLibraryBucketPage(
5304
+ result,
5305
+ async (nextCursor, nextOptions) => await this.continueSearchBucket(target, nextCursor, {
5306
+ ...options,
5307
+ ...nextOptions.limit === void 0 ? {} : { limit: nextOptions.limit }
5308
+ }),
5309
+ (cursor2) => Promise.resolve(cursor2),
5310
+ () => Promise.resolve()
5311
+ );
4831
5312
  }
4832
5313
  async searchArchiveMembers(target, query, options = {}) {
4833
- return await this.#runtime.run(async () => {
5314
+ const result = await this.#runtime.run(async () => {
4834
5315
  const embeddingProvider = await resolveQueryEmbeddingProvider(
4835
5316
  options.queryMode
4836
5317
  );
@@ -4843,22 +5324,53 @@ var WikiGraphLibraryManager = class {
4843
5324
  }
4844
5325
  );
4845
5326
  });
5327
+ return createArchiveFindPage(
5328
+ result,
5329
+ async (cursor, nextOptions) => await this.searchArchiveMembers(target, query, {
5330
+ ...options,
5331
+ cursor,
5332
+ ...nextOptions.limit === void 0 ? {} : { limit: nextOptions.limit },
5333
+ ...nextOptions.signal === void 0 ? {} : { signal: nextOptions.signal }
5334
+ }),
5335
+ (cursor) => Promise.resolve(cursor),
5336
+ () => Promise.resolve()
5337
+ );
4846
5338
  }
4847
5339
  async objects(target, options = {}) {
4848
- return await this.#runtime.run(
5340
+ const result = await this.#runtime.run(
4849
5341
  async () => await listWikiGraphLibraryObjects2(
4850
5342
  requireLibraryTarget(target),
4851
5343
  options
4852
5344
  )
4853
5345
  );
5346
+ return createArchiveCollectionPage(
5347
+ result,
5348
+ async (cursor, nextOptions) => await this.objects(target, {
5349
+ ...options,
5350
+ cursor,
5351
+ ...nextOptions.limit === void 0 ? {} : { limit: nextOptions.limit }
5352
+ }),
5353
+ (cursor) => Promise.resolve(cursor),
5354
+ () => Promise.resolve()
5355
+ );
4854
5356
  }
4855
5357
  async archiveMembers(target, options = {}) {
4856
- return await this.#runtime.run(
5358
+ const result = await this.#runtime.run(
4857
5359
  async () => await listWikiGraphLibraryArchiveMembers2(
4858
5360
  requireLibraryTarget(target),
4859
5361
  options
4860
5362
  )
4861
5363
  );
5364
+ return createArchiveCollectionPage(
5365
+ result,
5366
+ async (cursor, nextOptions) => await this.archiveMembers(target, {
5367
+ ...options,
5368
+ cursor,
5369
+ ...nextOptions.limit === void 0 ? {} : { limit: nextOptions.limit }
5370
+ }),
5371
+ (cursor) => Promise.resolve(cursor),
5372
+ () => Promise.resolve()
5373
+ );
4862
5374
  }
4863
5375
  async page(target, objectUri, options = {}) {
4864
5376
  return await this.#runtime.run(
@@ -4874,7 +5386,7 @@ var WikiGraphLibraryManager = class {
4874
5386
  );
4875
5387
  }
4876
5388
  async related(target, objectUri, options = {}) {
4877
- return await this.#runtime.run(async () => {
5389
+ const result = await this.#runtime.run(async () => {
4878
5390
  if (options.query === void 0 && options.queryMode !== void 0) {
4879
5391
  throw new Error("`queryMode` requires `query`.");
4880
5392
  }
@@ -4888,9 +5400,20 @@ var WikiGraphLibraryManager = class {
4888
5400
  }
4889
5401
  );
4890
5402
  });
5403
+ return createArchiveRelatedPage(
5404
+ result,
5405
+ async (cursor, nextOptions) => await this.related(target, objectUri, {
5406
+ ...options,
5407
+ cursor,
5408
+ ...nextOptions.limit === void 0 ? {} : { limit: nextOptions.limit },
5409
+ ...nextOptions.signal === void 0 ? {} : { signal: nextOptions.signal }
5410
+ }),
5411
+ (cursor) => Promise.resolve(cursor),
5412
+ () => Promise.resolve()
5413
+ );
4891
5414
  }
4892
5415
  async evidence(target, objectUri, options = {}) {
4893
- return await this.#runtime.run(async () => {
5416
+ const result = await this.#runtime.run(async () => {
4894
5417
  if (options.query === void 0 && options.queryMode !== void 0) {
4895
5418
  throw new Error("`queryMode` requires `query`.");
4896
5419
  }
@@ -4904,6 +5427,17 @@ var WikiGraphLibraryManager = class {
4904
5427
  }
4905
5428
  );
4906
5429
  });
5430
+ return createArchiveEvidencePage(
5431
+ result,
5432
+ async (cursor, nextOptions) => await this.evidence(target, objectUri, {
5433
+ ...options,
5434
+ cursor,
5435
+ ...nextOptions.limit === void 0 ? {} : { limit: nextOptions.limit },
5436
+ ...nextOptions.signal === void 0 ? {} : { signal: nextOptions.signal }
5437
+ }),
5438
+ (cursor) => Promise.resolve(cursor),
5439
+ () => Promise.resolve()
5440
+ );
4907
5441
  }
4908
5442
  async pack(target, objectUri, budget = 5e3) {
4909
5443
  return await this.#runtime.run(
@@ -5234,6 +5768,11 @@ import {
5234
5768
  requireLocatedObjectUri
5235
5769
  } from "wiki-graph-core";
5236
5770
  export {
5771
+ ArchiveCollectionPage,
5772
+ ArchiveEvidencePage,
5773
+ ArchiveFindPage,
5774
+ ArchiveRelatedPage,
5775
+ ArchiveSourceLocatorPage,
5237
5776
  DANGEROUS_RUNTIME_ENV_NAMES,
5238
5777
  DEFAULT_EXTRACTION_PROMPT,
5239
5778
  DEFAULT_GENERATION_JOB_CONCURRENCY,
@@ -5241,6 +5780,7 @@ export {
5241
5780
  DEFAULT_KNOWLEDGE_GRAPH_RECALL_PROMPT,
5242
5781
  LLMPaymentRequiredError,
5243
5782
  LOCAL_CONFIG_SECTIONS,
5783
+ LibraryBucketPage,
5244
5784
  NodeDirectory,
5245
5785
  NodeFile,
5246
5786
  WIKI_GRAPH_URI_PREFIX,
@@ -5261,11 +5801,19 @@ export {
5261
5801
  buildSearchIndexEmbeddingProvider,
5262
5802
  buildWikiGraphLLMOptions,
5263
5803
  clearLocalConfigSection,
5804
+ createArchiveCollectionPage,
5805
+ createArchiveEvidencePage,
5806
+ createArchiveFindPage,
5807
+ createArchiveRelatedPage,
5808
+ createArchiveSourceLocatorPage,
5809
+ createCursor,
5264
5810
  createEntryRuntimeContext,
5265
5811
  createGenerationPerformanceHints,
5812
+ createLibraryBucketPage,
5266
5813
  createNodeTemplateEnvironment,
5267
5814
  createNodeWikiGraphPlatform,
5268
5815
  createNodeWikiGraphStorage,
5816
+ createPageCursor,
5269
5817
  createStageLLM,
5270
5818
  createWikiGraphSDK,
5271
5819
  deleteLocalConfigValue,
@@ -5293,6 +5841,8 @@ export {
5293
5841
  isWikiGraphJobUri,
5294
5842
  isWikiGraphLibraryUri,
5295
5843
  isWikiGraphUri,
5844
+ iterateItems,
5845
+ iteratePages,
5296
5846
  loadRequiredStageConfig,
5297
5847
  loadWikiGraphRuntimeConfig,
5298
5848
  maskLocalConfigSection,