@anuma/sdk 6.38.0 → 6.39.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6022,15 +6022,17 @@ Build ONLY when the user gives an explicit instruction to build, create, generat
6022
6022
 
6023
6023
  Once the user HAS given an explicit build instruction, you are in App Builder mode: you produce polished, production-quality React apps that feel designed \u2014 not generic.
6024
6024
 
6025
- DESIGN: on the initial build, before writing code, briefly state (2-3 sentences) what you want this app to feel like \u2014 name the specific fonts, the palette in hex, and one signature detail. Be concrete: "Fraunces display + Inter body + JetBrains Mono metadata, terracotta #b75432 accent on bone #f3efe6, paper-grain texture via inline SVG noise" is the kind of specificity that anchors the build. Default to nothing: don't pick "safe modern productivity" unless the brief literally asks for utilitarian. On later turns, state a design brief only when the change is visual (a restyle, new theme, or new UI); for a logic, data, or behavior-only change, skip the brief and just make the change.
6025
+ DESIGN: on the initial build, before writing code, briefly state (2-3 sentences) what you want this app to feel like \u2014 name the specific fonts, the palette in hex, and one signature detail. Be concrete: "Fraunces display + Inter body + JetBrains Mono metadata, terracotta #b75432 accent on bone #f3efe6, paper-grain texture via inline SVG noise" is the kind of specificity that anchors the build. Default to nothing: don't pick "safe modern productivity" unless the brief literally asks for utilitarian. On later turns, state a design brief only when the change is visual (a restyle, new theme, or new UI); for a text, logic, data, or behavior-only change, skip the brief and just make the change.
6026
+
6027
+ EDIT SCOPE: Change only the files and lines required by the current user request. A title rename is a text edit, not a design change. Preserve styles, dependencies, and unrelated logic on text edits. Design feedback does not authorize unrelated edits.
6026
6028
 
6027
6029
  WORKFLOW:
6028
6030
  1. NEVER output code as text or markdown. ALWAYS use tools.
6029
6031
  2. Initial build: state your design brief, then create_file with a "files" array writing ALL files in one call. The preview renders automatically.
6030
6032
  3. patch_file requires read_file for that path earlier in the conversation (or create_file in the same conversation, which counts). read_file output is numbered "42: <text>" \u2014 the prefix is display-only; never copy it into "find". Each "find" must match exactly one location \u2014 include 2-3 lines of surrounding context. Pass multiple patches per call to change distinct locations.
6031
6033
  4. Prefer patch_file for changes to existing files \u2014 surgical, reviewable, preserves surrounding code. Reserve create_file overwrites for substantial restructuring. Inserts: find the line before, replace with that line + the new line. Deletes: empty replace.
6032
- 5. After substantial changes, call critique_design first (taste, hierarchy, distinctiveness, weakest decision) and then audit_design (mechanical: tokens, focus states, aria-labels, alt, heading order). Patch what each surfaces. critique catches taste issues no checklist would; audit catches mechanics you'd miss. Run both; act on both.
6033
- 6. Before declaring done, call verify_app. The host's preview runtime reports whether your app actually mounted and surfaces any errors it captured \u2014 hallucinated imports, syntax the bundler rejected, undefined components, runtime crashes. If \`rendered\` is false or \`errors\` is non-empty, fix every error before the next message. If the response includes a \`note\` that verify_app isn't wired in this host, skip \u2014 audit + critique are your feedback in that case.
6034
+ 5. On the initial build, when adding new UI, or after user-requested design changes, call critique_design first and then audit_design. Critique checks taste, hierarchy, and distinctiveness. Audit checks tokens, focus states, aria-labels, alt text, and heading order. Patch only issues within the current user request. For text, logic, or data edits, skip both design tools.
6035
+ 6. Before declaring done, call verify_app. The host's preview runtime reports whether your app actually mounted and surfaces any errors it captured \u2014 hallucinated imports, syntax the bundler rejected, undefined components, runtime crashes. If \`rendered\` is false or \`errors\` is non-empty, fix every error before the next message. If the response includes a \`note\` that verify_app isn't wired in this host, skip runtime verification. An unavailable runtime verifier does not authorize design changes. Use audit_design and critique_design only for the initial build, adding new UI, or user-requested design changes.
6034
6036
  7. Keep responses to a sentence or two. Exception: when responding to critique_design, write a substantive paragraph per rubric question.
6035
6037
 
6036
6038
  STRUCTURE:
@@ -6196,12 +6198,13 @@ function isCacheExpired(cache, expirationMs = DEFAULT_CACHE_EXPIRATION_MS) {
6196
6198
  if (!cache) return true;
6197
6199
  return Date.now() - cache.timestamp > expirationMs;
6198
6200
  }
6199
- function buildCacheEntry(tools, checksum) {
6201
+ function buildCacheEntry(tools, checksum, etag) {
6200
6202
  return {
6201
6203
  tools,
6202
6204
  timestamp: Date.now(),
6203
6205
  version: CACHE_VERSION,
6204
- ...checksum && { checksum }
6206
+ ...checksum && { checksum },
6207
+ ...etag && { etag }
6205
6208
  };
6206
6209
  }
6207
6210
  function writeLocalStorageCache(entry) {
@@ -6236,19 +6239,36 @@ function shouldRefreshTools(responseChecksum, cache = localStorageToolsCache) {
6236
6239
  const cachedChecksum = getToolsChecksum2(cache);
6237
6240
  return cachedChecksum instanceof Promise ? cachedChecksum.then(decide) : decide(cachedChecksum);
6238
6241
  }
6239
- async function fetchServerToolsFromApi(baseUrl, token) {
6240
- const response = await fetch(`${baseUrl}/api/v1/tools`, {
6242
+ async function fetchServerToolsFromApi(baseUrl, authHeaders, etag) {
6243
+ const request = (validator) => fetch(`${baseUrl}/api/v1/tools`, {
6241
6244
  method: "GET",
6242
6245
  headers: {
6243
- Authorization: `Bearer ${token}`,
6244
- "Content-Type": "application/json"
6246
+ ...authHeaders,
6247
+ "Content-Type": "application/json",
6248
+ ...validator && { "If-None-Match": validator }
6245
6249
  }
6246
6250
  });
6251
+ let response;
6252
+ try {
6253
+ response = await request(etag);
6254
+ } catch (error) {
6255
+ if (!etag || !(error instanceof TypeError)) throw error;
6256
+ etag = void 0;
6257
+ response = await request();
6258
+ }
6259
+ if (etag && response.status === 304) {
6260
+ return { notModified: true };
6261
+ }
6247
6262
  if (!response.ok) {
6248
6263
  throw new Error(`Failed to fetch server tools: ${response.status}`);
6249
6264
  }
6250
6265
  const data = await response.json();
6251
- return convertServerToolsResponse(data);
6266
+ const responseEtag = response.headers?.get("ETag") ?? void 0;
6267
+ return {
6268
+ notModified: false,
6269
+ ...convertServerToolsResponse(data),
6270
+ ...responseEtag && { etag: responseEtag }
6271
+ };
6252
6272
  }
6253
6273
  async function getServerTools(options) {
6254
6274
  const {
@@ -6280,34 +6300,30 @@ async function getServerTools(options) {
6280
6300
  try {
6281
6301
  const { BASE_URL: BASE_URL2 } = await import("./clientConfig-VPOGQRNP.mjs");
6282
6302
  const effectiveBaseUrl = baseUrl ?? BASE_URL2;
6303
+ const validator = cached && !forceRefresh ? cached.etag : void 0;
6304
+ let authHeaders;
6283
6305
  if (apiKey) {
6284
- const response = await fetch(`${effectiveBaseUrl}/api/v1/tools`, {
6285
- method: "GET",
6286
- headers: {
6287
- "X-API-Key": apiKey,
6288
- "Content-Type": "application/json"
6289
- }
6290
- });
6291
- if (!response.ok) {
6292
- throw new Error(`Failed to fetch server tools: ${response.status}`);
6306
+ authHeaders = { "X-API-Key": apiKey };
6307
+ } else {
6308
+ if (!getToken) {
6309
+ getLogger().warn("[serverTools] No auth method available for fetching tools");
6310
+ return cached?.tools ?? [];
6293
6311
  }
6294
- const data = await response.json();
6295
- const { tools: tools2, checksum: checksum2 } = convertServerToolsResponse(data);
6296
- await persistCache(buildCacheEntry(tools2, checksum2));
6297
- return tools2;
6298
- }
6299
- if (!getToken) {
6300
- getLogger().warn("[serverTools] No auth method available for fetching tools");
6301
- return cached?.tools ?? [];
6312
+ const token = await getToken();
6313
+ if (!token) {
6314
+ getLogger().warn("[serverTools] No auth token available for fetching tools");
6315
+ return cached?.tools ?? [];
6316
+ }
6317
+ authHeaders = { Authorization: `Bearer ${token}` };
6302
6318
  }
6303
- const token = await getToken();
6304
- if (!token) {
6305
- getLogger().warn("[serverTools] No auth token available for fetching tools");
6306
- return cached?.tools ?? [];
6319
+ const result = await fetchServerToolsFromApi(effectiveBaseUrl, authHeaders, validator);
6320
+ if (result.notModified) {
6321
+ const confirmed = cached;
6322
+ await persistCache({ ...confirmed, timestamp: Date.now() });
6323
+ return confirmed.tools;
6307
6324
  }
6308
- const { tools, checksum } = await fetchServerToolsFromApi(effectiveBaseUrl, token);
6309
- await persistCache(buildCacheEntry(tools, checksum));
6310
- return tools;
6325
+ await persistCache(buildCacheEntry(result.tools, result.checksum, result.etag));
6326
+ return result.tools;
6311
6327
  } catch (error) {
6312
6328
  getLogger().error("[serverTools] Failed to fetch server tools:", error);
6313
6329
  if (cached?.tools) {
@@ -20184,7 +20200,6 @@ async function recall(query, ctx, options = {}) {
20184
20200
  }
20185
20201
  const needsChunkEmbedding = types.includes("chunk") && ctx.storageCtx;
20186
20202
  const wantsTemporal = types.includes("fact") && (ctx.factSource || ctx.vaultCtx);
20187
- const graphRefiner = flags.traverse && options.graphRefine && options.decomposeOptions ? createLlmNeighborRefiner(options.decomposeOptions) : void 0;
20188
20203
  const queryEmbedTotalTimeoutMs = options.queryEmbedTotalTimeoutMs ?? DEFAULT_QUERY_EMBED_TOTAL_TIMEOUT_MS;
20189
20204
  const prepStart = nowMs2();
20190
20205
  let sharedEmbedMs = 0;
@@ -20213,13 +20228,12 @@ async function recall(query, ctx, options = {}) {
20213
20228
  safeLane(
20214
20229
  "graph",
20215
20230
  () => graphLaneFailed = true,
20216
- () => ctx.factSource ? ctx.factSource.graphRanking(query, flags.traverse, options) : buildGraphLaneRanking(query, ctx, flags.traverse, {
20217
- ...options.maxHops !== void 0 && { maxHops: options.maxHops },
20218
- ...options.entityFanout !== void 0 && { entityFanout: options.entityFanout },
20219
- ...options.nodeBudget !== void 0 && { nodeBudget: options.nodeBudget },
20220
- ...options.rrfK !== void 0 && { rrfK: options.rrfK },
20221
- ...graphRefiner && { refineNeighbors: graphRefiner }
20222
- })
20231
+ () => ctx.factSource ? ctx.factSource.graphRanking(query, flags.traverse, options) : buildGraphLaneRanking(
20232
+ query,
20233
+ ctx,
20234
+ flags.traverse,
20235
+ graphTraversalOptions(options, flags.traverse)
20236
+ )
20223
20237
  ),
20224
20238
  wantsTemporal ? safeLane(
20225
20239
  "temporal",
@@ -20438,6 +20452,16 @@ function toFactMemory(r, now) {
20438
20452
  updatedAt: r.updatedAt ?? /* @__PURE__ */ new Date(0)
20439
20453
  };
20440
20454
  }
20455
+ function graphTraversalOptions(options, traverse) {
20456
+ const refineNeighbors = traverse && options.graphRefine && options.decomposeOptions ? createLlmNeighborRefiner(options.decomposeOptions) : void 0;
20457
+ return {
20458
+ ...options.maxHops !== void 0 && { maxHops: options.maxHops },
20459
+ ...options.entityFanout !== void 0 && { entityFanout: options.entityFanout },
20460
+ ...options.nodeBudget !== void 0 && { nodeBudget: options.nodeBudget },
20461
+ ...options.rrfK !== void 0 && { rrfK: options.rrfK },
20462
+ ...refineNeighbors && { refineNeighbors }
20463
+ };
20464
+ }
20441
20465
  async function buildGraphLaneRanking(query, ctx, traverse = false, traversalOptions = {}) {
20442
20466
  const entityCtx = ctx.entityCtx ?? ctx.vaultCtx?.entityCtx;
20443
20467
  if (!entityCtx) return [];
@@ -20603,24 +20627,33 @@ function isDumpQuery(query) {
20603
20627
  return false;
20604
20628
  }
20605
20629
  async function listRecentFacts(ctx, limit, toolOptions) {
20630
+ const store = toolOptions?.memoryStore;
20606
20631
  const vaultCtx = ctx.vaultCtx;
20607
- if (!vaultCtx) return [];
20608
- const ordered = await getVaultRankingProjectionsOp(vaultCtx, {
20632
+ if (!vaultCtx && !store) return [];
20633
+ const read = (ids) => store ? store.list({ memoryIds: ids }) : getVaultMemoriesByIdsOp(vaultCtx, ids);
20634
+ const filters = {
20609
20635
  ...toolOptions?.scopes && { scopes: toolOptions.scopes },
20610
- ...toolOptions?.memoryIds !== void 0 && { memoryIds: toolOptions.memoryIds },
20636
+ ...toolOptions?.memoryIds !== void 0 && { memoryIds: toolOptions.memoryIds }
20637
+ };
20638
+ const project = (size) => store ? store.listProjections({ ...filters, limit: size }) : getVaultRankingProjectionsOp(vaultCtx, {
20639
+ ...filters,
20611
20640
  ...toolOptions?.folderId !== void 0 && { folderId: toolOptions.folderId }
20612
20641
  });
20613
20642
  const readable = [];
20614
- for (let i = 0; i < ordered.length && readable.length < limit; i += limit) {
20615
- const batch = ordered.slice(i, i + limit).map((p) => p.uniqueId);
20616
- const byId = new Map(
20617
- (await getVaultMemoriesByIdsOp(vaultCtx, batch)).map((m) => [m.uniqueId, m])
20618
- );
20619
- for (const id of batch) {
20620
- const m = byId.get(id);
20621
- if (m && !isEncrypted(m.content)) readable.push(m);
20622
- if (readable.length >= limit) break;
20643
+ let start = 0;
20644
+ for (let size = limit; readable.length < limit; size *= 2) {
20645
+ const ordered = await project(size);
20646
+ for (let i = start; i < ordered.length && readable.length < limit; i += limit) {
20647
+ const batch = ordered.slice(i, i + limit).map((p) => p.uniqueId);
20648
+ const byId = new Map((await read(batch)).map((m) => [m.uniqueId, m]));
20649
+ for (const id of batch) {
20650
+ const m = byId.get(id);
20651
+ if (m && !isEncrypted(m.content)) readable.push(m);
20652
+ if (readable.length >= limit) break;
20653
+ }
20623
20654
  }
20655
+ if (!store || ordered.length < size) break;
20656
+ start = ordered.length;
20624
20657
  }
20625
20658
  return readable.map((m) => ({
20626
20659
  id: m.uniqueId,
@@ -20637,6 +20670,8 @@ async function listRecentFacts(ctx, limit, toolOptions) {
20637
20670
  }));
20638
20671
  }
20639
20672
  function createRecallTool(ctx, toolOptions, callbacks) {
20673
+ if (toolOptions?.memoryStore && toolOptions.folderId !== void 0)
20674
+ throw new Error("Folders are not supported with a memoryStore");
20640
20675
  const defaultTypes = toolOptions?.types ?? ["fact", "chunk"];
20641
20676
  const defaultLimit = toolOptions?.limit ?? DEFAULT_LIMIT2;
20642
20677
  const defaultBudget = toolOptions?.budget ?? DEFAULT_BUDGET2;
@@ -20708,7 +20743,7 @@ function createRecallTool(ctx, toolOptions, callbacks) {
20708
20743
  let surfaced = 0;
20709
20744
  try {
20710
20745
  let recallDegraded = [];
20711
- const wantsRecent = args.sort === "recent" && defaultTypes.includes("fact") && ctx.vaultCtx !== void 0;
20746
+ const wantsRecent = args.sort === "recent" && defaultTypes.includes("fact") && (ctx.vaultCtx !== void 0 || toolOptions?.memoryStore !== void 0);
20712
20747
  let result;
20713
20748
  if (wantsRecent) {
20714
20749
  result = { memories: await listRecentFacts(ctx, effectiveLimit, toolOptions) };
@@ -21210,6 +21245,7 @@ function createLocalMemoryStore(options) {
21210
21245
  });
21211
21246
  };
21212
21247
  return {
21248
+ masksEmbeddingInput: options.embeddingOptions.maskInput !== void 0,
21213
21249
  list: (listOptions) => getAllVaultMemoriesOp(vaultCtx, listOptions),
21214
21250
  get: (id) => getVaultMemoryOp(vaultCtx, id),
21215
21251
  listArchived: async () => {
@@ -21291,6 +21327,22 @@ function createLocalMemoryStore(options) {
21291
21327
  { vaultCtx, embeddingOptions: options.embeddingOptions, vaultCache },
21292
21328
  retainOptions
21293
21329
  ),
21330
+ factSource: {
21331
+ search: (query, searchOptions) => searchVaultMemoriesWithSize(
21332
+ query,
21333
+ vaultCtx,
21334
+ options.embeddingOptions,
21335
+ vaultCache,
21336
+ searchOptions
21337
+ ),
21338
+ graphRanking: (query, traverse, recallOptions) => buildGraphLaneRanking(
21339
+ query,
21340
+ { vaultCtx, entityCtx, embeddingOptions: options.embeddingOptions },
21341
+ traverse,
21342
+ graphTraversalOptions(recallOptions, traverse)
21343
+ ),
21344
+ temporalRanking: (query, now) => buildTemporalLaneRanking(query, vaultCtx, now)
21345
+ },
21294
21346
  subscribe: (onChange, subscribeOptions) => {
21295
21347
  const afterFirst = () => {
21296
21348
  let first = true;
@@ -22177,38 +22229,31 @@ function createRemoteMemoryPipeline(options) {
22177
22229
  };
22178
22230
  return { prepare, port };
22179
22231
  };
22180
- return {
22181
- recall: async (query, recallOptions = {}) => {
22232
+ const factSource = {
22233
+ graphRanking: options.graphRanking,
22234
+ temporalRanking: options.temporalRanking,
22235
+ search: async (text13, searchOptions) => {
22182
22236
  const { prepare } = operation("recall");
22183
- return recall(
22184
- query,
22185
- {
22186
- embeddingOptions,
22187
- factSource: {
22188
- graphRanking: options.graphRanking,
22189
- temporalRanking: options.temporalRanking,
22190
- search: async (text13, searchOptions) => {
22191
- const prepared = await prepare(text13, searchOptions);
22192
- const ranked = await rankPreparedVaultCandidates(
22193
- text13,
22194
- prepared,
22195
- embeddingOptions,
22196
- searchOptions
22197
- );
22198
- return {
22199
- ...ranked,
22200
- rankedOnCosine: prepared.memories.length > 0 && !prepared.embeddingsUnavailable,
22201
- decryptLast: true,
22202
- rowsDecrypted: prepared.rowsDecrypted,
22203
- queryEmbedMs: prepared.queryEmbedMs,
22204
- rowsEmbedded: 0
22205
- };
22206
- }
22207
- }
22208
- },
22209
- { ...recallOptions, types: ["fact"] }
22237
+ const prepared = await prepare(text13, searchOptions);
22238
+ const ranked = await rankPreparedVaultCandidates(
22239
+ text13,
22240
+ prepared,
22241
+ embeddingOptions,
22242
+ searchOptions
22210
22243
  );
22211
- },
22244
+ return {
22245
+ ...ranked,
22246
+ rankedOnCosine: prepared.memories.length > 0 && !prepared.embeddingsUnavailable,
22247
+ decryptLast: true,
22248
+ rowsDecrypted: prepared.rowsDecrypted,
22249
+ queryEmbedMs: prepared.queryEmbedMs,
22250
+ rowsEmbedded: 0
22251
+ };
22252
+ }
22253
+ };
22254
+ return {
22255
+ factSource,
22256
+ recall: async (query, recallOptions = {}) => recall(query, { embeddingOptions, factSource }, { ...recallOptions, types: ["fact"] }),
22212
22257
  retain: async (content, retainOptions) => {
22213
22258
  const { port } = operation("retain");
22214
22259
  return retainWithPersistence(
@@ -22569,6 +22614,7 @@ function createRemoteMemoryStore(options) {
22569
22614
  });
22570
22615
  };
22571
22616
  return {
22617
+ masksEmbeddingInput: embeddingOptions.maskInput !== void 0,
22572
22618
  list: async (listOptions = {}) => (await listRows(decrypted, listOptions, listFilters(listOptions), maxOf(listOptions))).map(
22573
22619
  (r) => stored(r.memory)
22574
22620
  ),
@@ -22764,6 +22810,7 @@ function createRemoteMemoryStore(options) {
22764
22810
  })
22765
22811
  ),
22766
22812
  recall: (query, recallOptions) => pipeline.recall(query, recallOptions),
22813
+ factSource: pipeline.factSource,
22767
22814
  retain: async (content, retainOptions) => {
22768
22815
  const result = await pipeline.retain(content, retainOptions);
22769
22816
  if (result.action === "create" || result.action === "supersede") notify("membership");
@@ -24527,19 +24574,20 @@ function createMemoryVaultSearchTool(vaultCtx, embeddingOptions, cache, searchOp
24527
24574
  const budget = wantsDecompose ? "high" : searchOptions?.rerank ? "mid" : "low";
24528
24575
  const folderId = searchOptions?.folderId ?? argFolderId;
24529
24576
  if (searchOptions?.useFusion === false) {
24530
- const { results: legacy, embeddingsUnavailable } = await searchVaultMemoriesWithSize(
24577
+ const legacyOptions = {
24578
+ limit: requestLimit,
24579
+ minSimilarity,
24580
+ useFusion: false,
24581
+ ...tuningForward,
24582
+ ...folderId !== void 0 && { folderId },
24583
+ ...searchOptions?.scopes && { scopes: searchOptions.scopes }
24584
+ };
24585
+ const { results: legacy, embeddingsUnavailable } = "retain" in vaultCtx ? await vaultCtx.factSource.search(query, legacyOptions) : await searchVaultMemoriesWithSize(
24531
24586
  query,
24532
24587
  vaultCtx,
24533
24588
  embeddingOptions,
24534
24589
  cache,
24535
- {
24536
- limit: requestLimit,
24537
- minSimilarity,
24538
- useFusion: false,
24539
- ...tuningForward,
24540
- ...folderId !== void 0 && { folderId },
24541
- ...searchOptions?.scopes && { scopes: searchOptions.scopes }
24542
- }
24590
+ legacyOptions
24543
24591
  );
24544
24592
  if (legacy.length === 0) {
24545
24593
  return embeddingsUnavailable ? EMBEDDINGS_DEGRADED_EMPTY_NO_LEXICAL : "No relevant memories found in the vault.";
@@ -24558,7 +24606,7 @@ function createMemoryVaultSearchTool(vaultCtx, embeddingOptions, cache, searchOp
24558
24606
  let recallDegraded = [];
24559
24607
  const result = await recall(
24560
24608
  query,
24561
- { vaultCtx, embeddingOptions, vaultCache: cache },
24609
+ "retain" in vaultCtx ? { factSource: vaultCtx.factSource, embeddingOptions } : { vaultCtx, embeddingOptions, vaultCache: cache },
24562
24610
  {
24563
24611
  onDiagnostics: (d) => {
24564
24612
  recallDegraded = d.degraded;
@@ -24638,8 +24686,10 @@ function describeWriteOutcome(outcome2) {
24638
24686
  }
24639
24687
  }
24640
24688
  function createMemoryVaultTool(vaultCtx, options, embeddingOptions, cache) {
24689
+ const store = "retain" in vaultCtx ? vaultCtx : void 0;
24690
+ const ctx = "retain" in vaultCtx ? void 0 : vaultCtx;
24641
24691
  const hasOnSave = !!options?.onSave;
24642
- const folderNames = options?.folderMap ? Array.from(options.folderMap.keys()) : [];
24692
+ const folderNames = !store && options?.folderMap ? Array.from(options.folderMap.keys()) : [];
24643
24693
  return {
24644
24694
  type: "function",
24645
24695
  function: {
@@ -24684,7 +24734,7 @@ function createMemoryVaultTool(vaultCtx, options, embeddingOptions, cache) {
24684
24734
  let previousContent;
24685
24735
  const scope = options?.scope ?? "private";
24686
24736
  if (isUpdate) {
24687
- const existing = await getVaultMemoryOp(vaultCtx, id);
24737
+ const existing = store ? await store.get(id) : await getVaultMemoryOp(ctx, id);
24688
24738
  if (!existing) {
24689
24739
  return `Error: Memory with ID "${id}" not found. Creating a new memory instead would require a separate call without an ID.`;
24690
24740
  }
@@ -24705,9 +24755,18 @@ function createMemoryVaultTool(vaultCtx, options, embeddingOptions, cache) {
24705
24755
  return isUpdate ? `Memory update was cancelled by the user. The memory "${id}" was not modified.` : "Memory save was cancelled by the user. No memory was created.";
24706
24756
  }
24707
24757
  }
24708
- if (isUpdate) {
24758
+ if (isUpdate && store) {
24759
+ const updated = await store.update(id, {
24760
+ content,
24761
+ ...factType !== void 0 && { factType }
24762
+ });
24763
+ if (!updated) {
24764
+ return `Error: Failed to update memory "${id}".`;
24765
+ }
24766
+ return `Memory updated successfully (ID: ${updated.uniqueId}).`;
24767
+ } else if (isUpdate) {
24709
24768
  const folderId = folderName ? options?.folderMap?.get(folderName) : void 0;
24710
- const updated = await updateVaultMemoryOp(vaultCtx, id, {
24769
+ const updated = await updateVaultMemoryOp(ctx, id, {
24711
24770
  content,
24712
24771
  embedding: null,
24713
24772
  folderId,
@@ -24722,7 +24781,7 @@ function createMemoryVaultTool(vaultCtx, options, embeddingOptions, cache) {
24722
24781
  content,
24723
24782
  embeddingOptions,
24724
24783
  cache,
24725
- vaultCtx,
24784
+ ctx,
24726
24785
  id,
24727
24786
  updated.updatedAt
24728
24787
  ).catch(() => {
@@ -24742,18 +24801,22 @@ function createMemoryVaultTool(vaultCtx, options, embeddingOptions, cache) {
24742
24801
  await notifyWritten(options, input, outcome2);
24743
24802
  return describeWriteOutcome(outcome2);
24744
24803
  }
24745
- const created = await createVaultMemoryOp(vaultCtx, {
24804
+ const created = store ? await store.create({
24805
+ content,
24806
+ scope,
24807
+ ...factType !== void 0 && { factType }
24808
+ }) : await createVaultMemoryOp(ctx, {
24746
24809
  content,
24747
24810
  scope,
24748
24811
  folderId,
24749
24812
  ...factType !== void 0 && { factType }
24750
24813
  });
24751
- if (embeddingOptions && cache) {
24814
+ if (ctx && embeddingOptions && cache) {
24752
24815
  eagerEmbedContent(
24753
24816
  content,
24754
24817
  embeddingOptions,
24755
24818
  cache,
24756
- vaultCtx,
24819
+ ctx,
24757
24820
  created.uniqueId,
24758
24821
  created.updatedAt
24759
24822
  ).catch(() => {
@@ -31725,6 +31788,8 @@ async function storedToLlmapiMessage(stored2, encryptionKey, resolveMediaByIds)
31725
31788
  }
31726
31789
  var CONVERSATION_REDACTOR_LIMIT = 50;
31727
31790
  var NO_CONVERSATION_KEY = "__no_conversation__";
31791
+ var NO_STORE_FOLDERS = "Folders are not supported with a memoryStore";
31792
+ var NO_STORE_MASK = "piiRedaction needs a memoryStore built with embeddingOptions.maskInput";
31728
31793
  var conversationRedactors = /* @__PURE__ */ new Map();
31729
31794
  function getConversationRedactor(conversationId, nerDetector) {
31730
31795
  const key = conversationId ?? NO_CONVERSATION_KEY;
@@ -31768,6 +31833,7 @@ function useChatStorage(options) {
31768
31833
  signMessage,
31769
31834
  embeddedWalletSigner,
31770
31835
  getWalletAddress,
31836
+ memoryStore,
31771
31837
  enableQueue = true,
31772
31838
  autoFlushOnKeyAvailable = true,
31773
31839
  extraToolSets,
@@ -31813,6 +31879,7 @@ function useChatStorage(options) {
31813
31879
  () => ({ getToken, baseUrl, model: embeddingModel, maskInput: maskEmbeddingInput }),
31814
31880
  [getToken, baseUrl, embeddingModel, maskEmbeddingInput]
31815
31881
  );
31882
+ const storeMaskMissing = memoryStore !== void 0 && maskEmbeddingInput !== void 0 && !memoryStore.masksEmbeddingInput;
31816
31883
  const blobManagerRef = useRef4(new BlobUrlManager());
31817
31884
  useEffect4(() => {
31818
31885
  const manager = blobManagerRef.current;
@@ -32089,6 +32156,15 @@ function useChatStorage(options) {
32089
32156
  );
32090
32157
  const retainVaultMemory = useCallback5(
32091
32158
  async (input) => {
32159
+ if (memoryStore) {
32160
+ if (storeMaskMissing) throw new Error(NO_STORE_MASK);
32161
+ if (input.folderId !== void 0) throw new Error(NO_STORE_FOLDERS);
32162
+ return memoryStore.retain(input.content, {
32163
+ source: "manual",
32164
+ scope: input.scope,
32165
+ ...input.factType !== void 0 && { factType: input.factType }
32166
+ });
32167
+ }
32092
32168
  if (!getToken) {
32093
32169
  throw new Error("getToken is required to retain a vault memory");
32094
32170
  }
@@ -32107,28 +32183,44 @@ function useChatStorage(options) {
32107
32183
  }
32108
32184
  );
32109
32185
  },
32110
- [vaultCtx, getToken, vaultEmbeddingOptions, vaultEmbeddingCache]
32186
+ [vaultCtx, getToken, vaultEmbeddingOptions, vaultEmbeddingCache, memoryStore, storeMaskMissing]
32111
32187
  );
32112
32188
  const createMemoryVaultTool2 = useCallback5(
32113
32189
  (options2) => {
32190
+ if (storeMaskMissing) throw new Error(NO_STORE_MASK);
32114
32191
  const embOpts = getToken ? vaultEmbeddingOptions : void 0;
32115
32192
  return createMemoryVaultTool(
32116
- vaultCtx,
32117
- embOpts ? { write: retainVaultMemory, ...options2 } : options2,
32193
+ memoryStore ?? vaultCtx,
32194
+ embOpts || memoryStore ? { write: retainVaultMemory, ...options2 } : options2,
32118
32195
  embOpts,
32119
32196
  embOpts ? vaultEmbeddingCache : void 0
32120
32197
  );
32121
32198
  },
32122
- [vaultCtx, getToken, vaultEmbeddingOptions, vaultEmbeddingCache, retainVaultMemory]
32199
+ [
32200
+ vaultCtx,
32201
+ getToken,
32202
+ vaultEmbeddingOptions,
32203
+ vaultEmbeddingCache,
32204
+ retainVaultMemory,
32205
+ memoryStore,
32206
+ storeMaskMissing
32207
+ ]
32123
32208
  );
32124
32209
  const getVaultMemories = useCallback5(
32125
32210
  (options2) => {
32126
- return getAllVaultMemoriesOp(vaultCtx, options2);
32211
+ if (!memoryStore) return getAllVaultMemoriesOp(vaultCtx, options2);
32212
+ const { folderId, levels, kinds, ...listOptions } = options2 ?? {};
32213
+ if (folderId !== void 0) throw new Error(NO_STORE_FOLDERS);
32214
+ if (levels !== void 0 || kinds !== void 0)
32215
+ throw new Error("level and kind filters are not supported with a memoryStore");
32216
+ return memoryStore.list(listOptions);
32127
32217
  },
32128
- [vaultCtx]
32218
+ [vaultCtx, memoryStore]
32129
32219
  );
32130
32220
  const createVaultMemory = useCallback5(
32131
32221
  async (content, scope) => {
32222
+ if (storeMaskMissing) throw new Error(NO_STORE_MASK);
32223
+ if (memoryStore) return memoryStore.create({ content, scope });
32132
32224
  const result = await createVaultMemoryOp(vaultCtx, { content, scope });
32133
32225
  if (getToken) {
32134
32226
  eagerEmbedContent(
@@ -32144,10 +32236,12 @@ function useChatStorage(options) {
32144
32236
  }
32145
32237
  return result;
32146
32238
  },
32147
- [vaultCtx, getToken, vaultEmbeddingOptions, vaultEmbeddingCache]
32239
+ [vaultCtx, getToken, vaultEmbeddingOptions, vaultEmbeddingCache, memoryStore, storeMaskMissing]
32148
32240
  );
32149
32241
  const updateVaultMemory = useCallback5(
32150
32242
  async (id, content, scope) => {
32243
+ if (storeMaskMissing) throw new Error(NO_STORE_MASK);
32244
+ if (memoryStore) return memoryStore.update(id, { content, scope });
32151
32245
  const existing = await getVaultMemoryOp(vaultCtx, id);
32152
32246
  const result = await updateVaultMemoryOp(vaultCtx, id, { content, scope, embedding: null });
32153
32247
  if (result && getToken) {
@@ -32167,10 +32261,11 @@ function useChatStorage(options) {
32167
32261
  }
32168
32262
  return result;
32169
32263
  },
32170
- [vaultCtx, getToken, vaultEmbeddingOptions, vaultEmbeddingCache]
32264
+ [vaultCtx, getToken, vaultEmbeddingOptions, vaultEmbeddingCache, memoryStore, storeMaskMissing]
32171
32265
  );
32172
32266
  const deleteVaultMemory = useCallback5(
32173
32267
  async (id) => {
32268
+ if (memoryStore) return memoryStore.delete(id);
32174
32269
  const existing = await getVaultMemoryOp(vaultCtx, id);
32175
32270
  const result = await deleteVaultMemoryOp(vaultCtx, id);
32176
32271
  if (result && existing) {
@@ -32178,19 +32273,19 @@ function useChatStorage(options) {
32178
32273
  }
32179
32274
  return result;
32180
32275
  },
32181
- [vaultCtx, vaultEmbeddingCache]
32276
+ [vaultCtx, vaultEmbeddingCache, memoryStore]
32182
32277
  );
32183
32278
  const chunkVectorCacheRef = useRef4(createChunkVectorCache());
32184
32279
  const clientToolEmbeddingsCacheRef = useRef4(/* @__PURE__ */ new Map());
32185
32280
  useEffect4(() => {
32186
- if (!getToken) return;
32281
+ if (!getToken || memoryStore) return;
32187
32282
  void (async () => {
32188
32283
  try {
32189
32284
  await preEmbedVaultMemories(vaultCtx, vaultEmbeddingOptions, vaultEmbeddingCache);
32190
32285
  } catch {
32191
32286
  }
32192
32287
  })();
32193
- }, [vaultCtx, getToken, vaultEmbeddingOptions, vaultEmbeddingCache]);
32288
+ }, [vaultCtx, getToken, vaultEmbeddingOptions, vaultEmbeddingCache, memoryStore]);
32194
32289
  useEffect4(() => {
32195
32290
  return onClearAllEncryptionState(() => {
32196
32291
  vaultEmbeddingCache.clear();
@@ -32199,26 +32294,35 @@ function useChatStorage(options) {
32199
32294
  }, [vaultEmbeddingCache]);
32200
32295
  const createMemoryVaultSearchTool2 = useCallback5(
32201
32296
  (searchOptions) => {
32202
- if (!getToken) {
32297
+ if (!getToken && !memoryStore) {
32203
32298
  throw new Error("getToken is required for memory vault search tool");
32204
32299
  }
32300
+ if (storeMaskMissing) throw new Error(NO_STORE_MASK);
32205
32301
  return createMemoryVaultSearchTool(
32206
- vaultCtx,
32302
+ memoryStore ?? vaultCtx,
32207
32303
  vaultEmbeddingOptions,
32208
32304
  vaultEmbeddingCache,
32209
32305
  searchOptions
32210
32306
  );
32211
32307
  },
32212
- [vaultCtx, getToken, vaultEmbeddingOptions, vaultEmbeddingCache]
32308
+ [vaultCtx, getToken, vaultEmbeddingOptions, vaultEmbeddingCache, memoryStore, storeMaskMissing]
32213
32309
  );
32214
32310
  const createRecallTool2 = useCallback5(
32215
32311
  (toolOptions, callbacks) => {
32216
- if (!getToken) {
32312
+ if (!getToken && !memoryStore) {
32217
32313
  throw new Error("getToken is required for recall tool");
32218
32314
  }
32315
+ if (storeMaskMissing) throw new Error(NO_STORE_MASK);
32219
32316
  const resolvedToolOptions = toolOptions?.excludeConversationId !== void 0 || !currentConversationId ? toolOptions : { ...toolOptions, excludeConversationId: currentConversationId };
32317
+ if (memoryStore && resolvedToolOptions?.folderId !== void 0)
32318
+ throw new Error(NO_STORE_FOLDERS);
32220
32319
  return createRecallTool(
32221
- {
32320
+ memoryStore ? {
32321
+ factSource: memoryStore.factSource,
32322
+ ...getToken && { storageCtx },
32323
+ embeddingOptions: vaultEmbeddingOptions,
32324
+ chunkCache: chunkVectorCacheRef.current
32325
+ } : {
32222
32326
  vaultCtx,
32223
32327
  storageCtx,
32224
32328
  embeddingOptions: vaultEmbeddingOptions,
@@ -32226,7 +32330,7 @@ function useChatStorage(options) {
32226
32330
  chunkCache: chunkVectorCacheRef.current,
32227
32331
  entityCtx
32228
32332
  },
32229
- resolvedToolOptions,
32333
+ memoryStore ? { ...resolvedToolOptions, memoryStore } : resolvedToolOptions,
32230
32334
  callbacks
32231
32335
  );
32232
32336
  },
@@ -32237,11 +32341,15 @@ function useChatStorage(options) {
32237
32341
  getToken,
32238
32342
  vaultEmbeddingOptions,
32239
32343
  vaultEmbeddingCache,
32240
- currentConversationId
32344
+ currentConversationId,
32345
+ memoryStore,
32346
+ storeMaskMissing
32241
32347
  ]
32242
32348
  );
32243
32349
  const searchVaultMemoriesFn = useCallback5(
32244
32350
  async (query, searchOptions) => {
32351
+ if (storeMaskMissing) throw new Error(NO_STORE_MASK);
32352
+ if (memoryStore) return (await memoryStore.factSource.search(query, searchOptions)).results;
32245
32353
  if (!getToken) return [];
32246
32354
  return searchVaultMemories(
32247
32355
  query,
@@ -32251,11 +32359,11 @@ function useChatStorage(options) {
32251
32359
  searchOptions
32252
32360
  );
32253
32361
  },
32254
- [vaultCtx, getToken, vaultEmbeddingOptions, vaultEmbeddingCache]
32362
+ [vaultCtx, getToken, vaultEmbeddingOptions, vaultEmbeddingCache, memoryStore, storeMaskMissing]
32255
32363
  );
32256
32364
  const recallFn = useCallback5(
32257
32365
  async (query, options2) => {
32258
- if (!getToken) {
32366
+ if (!getToken && !memoryStore) {
32259
32367
  return {
32260
32368
  memories: [],
32261
32369
  usedBudget: options2?.budget ?? "low",
@@ -32264,9 +32372,16 @@ function useChatStorage(options) {
32264
32372
  };
32265
32373
  }
32266
32374
  const resolvedOptions = options2?.excludeConversationId !== void 0 || !currentConversationId ? options2 : { ...options2, excludeConversationId: currentConversationId };
32375
+ if (storeMaskMissing) throw new Error(NO_STORE_MASK);
32376
+ if (memoryStore && resolvedOptions?.folderId !== void 0) throw new Error(NO_STORE_FOLDERS);
32267
32377
  return recall(
32268
32378
  query,
32269
- {
32379
+ memoryStore ? {
32380
+ factSource: memoryStore.factSource,
32381
+ ...getToken && { storageCtx },
32382
+ embeddingOptions: vaultEmbeddingOptions,
32383
+ chunkCache: chunkVectorCacheRef.current
32384
+ } : {
32270
32385
  vaultCtx,
32271
32386
  storageCtx,
32272
32387
  embeddingOptions: vaultEmbeddingOptions,
@@ -32284,7 +32399,9 @@ function useChatStorage(options) {
32284
32399
  getToken,
32285
32400
  currentConversationId,
32286
32401
  vaultEmbeddingOptions,
32287
- vaultEmbeddingCache
32402
+ vaultEmbeddingCache,
32403
+ memoryStore,
32404
+ storeMaskMissing
32288
32405
  ]
32289
32406
  );
32290
32407
  const {
@@ -34723,6 +34840,128 @@ function useICloudBackup(options) {
34723
34840
 
34724
34841
  // src/react/useModels.ts
34725
34842
  import { useCallback as useCallback15, useEffect as useEffect10, useRef as useRef6, useState as useState12 } from "react";
34843
+ var MODELS_CACHE_TTL_MS = 5 * 60 * 1e3;
34844
+ var modelsCache = /* @__PURE__ */ new Map();
34845
+ var modelsInFlight = /* @__PURE__ */ new Map();
34846
+ var cacheGeneration = 0;
34847
+ function clearModelsCache() {
34848
+ cacheGeneration++;
34849
+ modelsCache.clear();
34850
+ modelsInFlight.clear();
34851
+ }
34852
+ function pruneStaleTokenEntries(newKey) {
34853
+ const [newBaseUrl, newProvider] = JSON.parse(newKey);
34854
+ for (const existingKey of modelsCache.keys()) {
34855
+ if (existingKey === newKey) continue;
34856
+ const [existingBaseUrl, existingProvider] = JSON.parse(existingKey);
34857
+ if (existingBaseUrl === newBaseUrl && existingProvider === newProvider) {
34858
+ modelsCache.delete(existingKey);
34859
+ }
34860
+ }
34861
+ }
34862
+ function fingerprintToken(token) {
34863
+ if (!token) return "anon";
34864
+ let h1 = 3735928559;
34865
+ let h2 = 1103547991;
34866
+ for (let i = 0; i < token.length; i++) {
34867
+ const ch = token.charCodeAt(i);
34868
+ h1 = Math.imul(h1 ^ ch, 2654435761);
34869
+ h2 = Math.imul(h2 ^ ch, 1597334677);
34870
+ }
34871
+ h1 = Math.imul(h1 ^ h1 >>> 16, 2246822507) ^ Math.imul(h2 ^ h2 >>> 13, 3266489909);
34872
+ h2 = Math.imul(h2 ^ h2 >>> 16, 2246822507) ^ Math.imul(h1 ^ h1 >>> 13, 3266489909);
34873
+ return (4294967296 * (2097151 & h2) + (h1 >>> 0)).toString(36);
34874
+ }
34875
+ function modelsCacheKey(baseUrl, provider, token) {
34876
+ return JSON.stringify([baseUrl, provider ?? null, fingerprintToken(token)]);
34877
+ }
34878
+ async function fetchAllModelPages(baseUrl, provider, headers, previous, signal) {
34879
+ const pages = /* @__PURE__ */ new Map();
34880
+ const models = [];
34881
+ let pageToken;
34882
+ do {
34883
+ const pageKey = pageToken ?? "";
34884
+ const stored2 = previous?.pages.get(pageKey);
34885
+ const request = (etag) => getApiV1Models({
34886
+ baseUrl,
34887
+ headers: etag ? { ...headers, "If-None-Match": etag } : headers,
34888
+ query: { provider, page_token: pageToken },
34889
+ signal
34890
+ });
34891
+ let response = await request(stored2?.etag);
34892
+ if (stored2?.etag && !response.response && response.error) {
34893
+ response = await request();
34894
+ }
34895
+ let page;
34896
+ if (response.response?.status === 304) {
34897
+ if (!stored2) throw new Error("Failed to fetch models");
34898
+ page = stored2;
34899
+ } else {
34900
+ if (response.error) {
34901
+ const errorMsg = response.error.error ?? "Failed to fetch models";
34902
+ throw new Error(errorMsg);
34903
+ }
34904
+ page = {
34905
+ body: response.data ?? {},
34906
+ etag: response.response?.headers?.get("ETag") ?? void 0
34907
+ };
34908
+ }
34909
+ pages.set(pageKey, page);
34910
+ models.push(...page.body.data || []);
34911
+ pageToken = page.body.next_page_token;
34912
+ } while (pageToken);
34913
+ return { pages, models, fetchedAt: Date.now() };
34914
+ }
34915
+ function loadModels(key, baseUrl, provider, headers, force, signal) {
34916
+ const cached = modelsCache.get(key);
34917
+ if (cached && !force && Date.now() - cached.fetchedAt < MODELS_CACHE_TTL_MS) {
34918
+ return Promise.resolve([...cached.models]);
34919
+ }
34920
+ const shared = (force ? void 0 : modelsInFlight.get(key)) ?? startSharedRequest(key, baseUrl, provider, headers, cached);
34921
+ return waitForSharedRequest(key, shared, signal).then((models) => [...models]);
34922
+ }
34923
+ function startSharedRequest(key, baseUrl, provider, headers, previous) {
34924
+ const controller = new AbortController();
34925
+ const generation = cacheGeneration;
34926
+ const shared = {
34927
+ controller,
34928
+ waiters: 0,
34929
+ promise: Promise.resolve([])
34930
+ };
34931
+ shared.promise = fetchAllModelPages(baseUrl, provider, headers, previous, controller.signal).then((entry) => {
34932
+ if (modelsInFlight.get(key) === shared && generation === cacheGeneration) {
34933
+ pruneStaleTokenEntries(key);
34934
+ modelsCache.set(key, entry);
34935
+ }
34936
+ return entry.models;
34937
+ }).finally(() => {
34938
+ if (modelsInFlight.get(key) === shared) modelsInFlight.delete(key);
34939
+ });
34940
+ modelsInFlight.set(key, shared);
34941
+ return shared;
34942
+ }
34943
+ function waitForSharedRequest(key, shared, signal) {
34944
+ shared.waiters++;
34945
+ let left = false;
34946
+ const leave = () => {
34947
+ if (left) return;
34948
+ left = true;
34949
+ shared.waiters--;
34950
+ if (shared.waiters === 0) {
34951
+ shared.controller.abort();
34952
+ if (modelsInFlight.get(key) === shared) modelsInFlight.delete(key);
34953
+ }
34954
+ };
34955
+ if (signal.aborted) {
34956
+ leave();
34957
+ } else {
34958
+ signal.addEventListener("abort", leave, { once: true });
34959
+ }
34960
+ return shared.promise.finally(() => {
34961
+ left = true;
34962
+ signal.removeEventListener("abort", leave);
34963
+ });
34964
+ }
34726
34965
  function useModels(options = {}) {
34727
34966
  const { getToken, baseUrl = BASE_URL, provider, autoFetch = true } = options;
34728
34967
  const [models, setModels] = useState12([]);
@@ -34745,7 +34984,7 @@ function useModels(options = {}) {
34745
34984
  }
34746
34985
  };
34747
34986
  }, []);
34748
- const fetchModels = useCallback15(async () => {
34987
+ const fetchModels = useCallback15(async (force = false) => {
34749
34988
  if (abortControllerRef.current) {
34750
34989
  abortControllerRef.current.abort();
34751
34990
  }
@@ -34764,35 +35003,17 @@ function useModels(options = {}) {
34764
35003
  if (token) {
34765
35004
  headers["Authorization"] = `Bearer ${token}`;
34766
35005
  }
34767
- let allModels = [];
34768
- let nextPageToken;
34769
- do {
34770
- if (signal.aborted) return;
34771
- const response = await getApiV1Models({
34772
- baseUrl: baseUrlRef.current,
34773
- headers,
34774
- query: {
34775
- provider: providerRef.current,
34776
- page_token: nextPageToken
34777
- },
34778
- signal
34779
- });
34780
- if (response.error) {
34781
- const errorMsg = response.error.error ?? "Failed to fetch models";
34782
- throw new Error(errorMsg);
34783
- }
34784
- if (response.data) {
34785
- const newModels = response.data.data || [];
34786
- allModels = [...allModels, ...newModels];
34787
- nextPageToken = response.data.next_page_token;
34788
- }
34789
- } while (nextPageToken);
35006
+ const baseUrl2 = baseUrlRef.current;
35007
+ const provider2 = providerRef.current;
35008
+ const key = modelsCacheKey(baseUrl2, provider2, token);
35009
+ const allModels = await loadModels(key, baseUrl2, provider2, headers, force, signal);
34790
35010
  if (signal.aborted) return;
34791
35011
  setModels(allModels);
34792
35012
  } catch (err) {
34793
35013
  if (err instanceof Error && err.name === "AbortError") {
34794
35014
  return;
34795
35015
  }
35016
+ if (signal.aborted) return;
34796
35017
  setError(err instanceof Error ? err : new Error(String(err)));
34797
35018
  } finally {
34798
35019
  if (!signal.aborted) {
@@ -34805,7 +35026,7 @@ function useModels(options = {}) {
34805
35026
  }, []);
34806
35027
  const refetch = useCallback15(async () => {
34807
35028
  setModels([]);
34808
- await fetchModels();
35029
+ await fetchModels(true);
34809
35030
  }, [fetchModels]);
34810
35031
  const hasFetchedRef = useRef6(false);
34811
35032
  useEffect10(() => {
@@ -36857,6 +37078,7 @@ export {
36857
37078
  clearKeyPair,
36858
37079
  clearLazyTitleCache,
36859
37080
  clearMemoryTopicsOverrideOp,
37081
+ clearModelsCache,
36860
37082
  clearNotionToken,
36861
37083
  clearServerToolsCache,
36862
37084
  consoleLogger,