@anuma/sdk 6.39.0 → 6.39.2

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.
@@ -1448,6 +1448,7 @@ __export(index_exports, {
1448
1448
  clearConversationMemoriesOp: () => clearConversationMemoriesOp,
1449
1449
  clearEncryptionKey: () => clearEncryptionKey,
1450
1450
  clearLazyTitleCache: () => clearLazyTitleCache,
1451
+ clearModelsCache: () => clearModelsCache,
1451
1452
  clearServerToolsCache: () => clearServerToolsCache,
1452
1453
  consoleLogger: () => consoleLogger,
1453
1454
  conversationMemoryToStored: () => conversationMemoryToStored,
@@ -5878,15 +5879,17 @@ Build ONLY when the user gives an explicit instruction to build, create, generat
5878
5879
 
5879
5880
  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.
5880
5881
 
5881
- 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.
5882
+ 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.
5883
+
5884
+ 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.
5882
5885
 
5883
5886
  WORKFLOW:
5884
5887
  1. NEVER output code as text or markdown. ALWAYS use tools.
5885
5888
  2. Initial build: state your design brief, then create_file with a "files" array writing ALL files in one call. The preview renders automatically.
5886
5889
  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.
5887
5890
  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.
5888
- 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.
5889
- 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.
5891
+ 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.
5892
+ 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.
5890
5893
  7. Keep responses to a sentence or two. Exception: when responding to critique_design, write a substantive paragraph per rubric question.
5891
5894
 
5892
5895
  STRUCTURE:
@@ -6053,12 +6056,13 @@ function isCacheExpired(cache, expirationMs = DEFAULT_CACHE_EXPIRATION_MS) {
6053
6056
  if (!cache) return true;
6054
6057
  return Date.now() - cache.timestamp > expirationMs;
6055
6058
  }
6056
- function buildCacheEntry(tools, checksum) {
6059
+ function buildCacheEntry(tools, checksum, etag) {
6057
6060
  return {
6058
6061
  tools,
6059
6062
  timestamp: Date.now(),
6060
6063
  version: CACHE_VERSION,
6061
- ...checksum && { checksum }
6064
+ ...checksum && { checksum },
6065
+ ...etag && { etag }
6062
6066
  };
6063
6067
  }
6064
6068
  function writeLocalStorageCache(entry) {
@@ -6093,19 +6097,36 @@ function shouldRefreshTools(responseChecksum, cache = localStorageToolsCache) {
6093
6097
  const cachedChecksum = getToolsChecksum2(cache);
6094
6098
  return cachedChecksum instanceof Promise ? cachedChecksum.then(decide) : decide(cachedChecksum);
6095
6099
  }
6096
- async function fetchServerToolsFromApi(baseUrl, token) {
6097
- const response = await fetch(`${baseUrl}/api/v1/tools`, {
6100
+ async function fetchServerToolsFromApi(baseUrl, authHeaders, etag) {
6101
+ const request = (validator) => fetch(`${baseUrl}/api/v1/tools`, {
6098
6102
  method: "GET",
6099
6103
  headers: {
6100
- Authorization: `Bearer ${token}`,
6101
- "Content-Type": "application/json"
6104
+ ...authHeaders,
6105
+ "Content-Type": "application/json",
6106
+ ...validator && { "If-None-Match": validator }
6102
6107
  }
6103
6108
  });
6109
+ let response;
6110
+ try {
6111
+ response = await request(etag);
6112
+ } catch (error) {
6113
+ if (!etag || !(error instanceof TypeError)) throw error;
6114
+ etag = void 0;
6115
+ response = await request();
6116
+ }
6117
+ if (etag && response.status === 304) {
6118
+ return { notModified: true };
6119
+ }
6104
6120
  if (!response.ok) {
6105
6121
  throw new Error(`Failed to fetch server tools: ${response.status}`);
6106
6122
  }
6107
6123
  const data = await response.json();
6108
- return convertServerToolsResponse(data);
6124
+ const responseEtag = response.headers?.get("ETag") ?? void 0;
6125
+ return {
6126
+ notModified: false,
6127
+ ...convertServerToolsResponse(data),
6128
+ ...responseEtag && { etag: responseEtag }
6129
+ };
6109
6130
  }
6110
6131
  async function getServerTools(options) {
6111
6132
  const {
@@ -6137,34 +6158,30 @@ async function getServerTools(options) {
6137
6158
  try {
6138
6159
  const { BASE_URL: BASE_URL2 } = await Promise.resolve().then(() => (init_clientConfig(), clientConfig_exports));
6139
6160
  const effectiveBaseUrl = baseUrl ?? BASE_URL2;
6161
+ const validator = cached && !forceRefresh ? cached.etag : void 0;
6162
+ let authHeaders;
6140
6163
  if (apiKey) {
6141
- const response = await fetch(`${effectiveBaseUrl}/api/v1/tools`, {
6142
- method: "GET",
6143
- headers: {
6144
- "X-API-Key": apiKey,
6145
- "Content-Type": "application/json"
6146
- }
6147
- });
6148
- if (!response.ok) {
6149
- throw new Error(`Failed to fetch server tools: ${response.status}`);
6164
+ authHeaders = { "X-API-Key": apiKey };
6165
+ } else {
6166
+ if (!getToken) {
6167
+ getLogger().warn("[serverTools] No auth method available for fetching tools");
6168
+ return cached?.tools ?? [];
6150
6169
  }
6151
- const data = await response.json();
6152
- const { tools: tools2, checksum: checksum2 } = convertServerToolsResponse(data);
6153
- await persistCache(buildCacheEntry(tools2, checksum2));
6154
- return tools2;
6155
- }
6156
- if (!getToken) {
6157
- getLogger().warn("[serverTools] No auth method available for fetching tools");
6158
- return cached?.tools ?? [];
6170
+ const token = await getToken();
6171
+ if (!token) {
6172
+ getLogger().warn("[serverTools] No auth token available for fetching tools");
6173
+ return cached?.tools ?? [];
6174
+ }
6175
+ authHeaders = { Authorization: `Bearer ${token}` };
6159
6176
  }
6160
- const token = await getToken();
6161
- if (!token) {
6162
- getLogger().warn("[serverTools] No auth token available for fetching tools");
6163
- return cached?.tools ?? [];
6177
+ const result = await fetchServerToolsFromApi(effectiveBaseUrl, authHeaders, validator);
6178
+ if (result.notModified) {
6179
+ const confirmed = cached;
6180
+ await persistCache({ ...confirmed, timestamp: Date.now() });
6181
+ return confirmed.tools;
6164
6182
  }
6165
- const { tools, checksum } = await fetchServerToolsFromApi(effectiveBaseUrl, token);
6166
- await persistCache(buildCacheEntry(tools, checksum));
6167
- return tools;
6183
+ await persistCache(buildCacheEntry(result.tools, result.checksum, result.etag));
6184
+ return result.tools;
6168
6185
  } catch (error) {
6169
6186
  getLogger().error("[serverTools] Failed to fetch server tools:", error);
6170
6187
  if (cached?.tools) {
@@ -23675,6 +23692,128 @@ function useCredits(options = {}) {
23675
23692
  // src/react/useModels.ts
23676
23693
  var import_react3 = require("react");
23677
23694
  init_clientConfig();
23695
+ var MODELS_CACHE_TTL_MS = 5 * 60 * 1e3;
23696
+ var modelsCache = /* @__PURE__ */ new Map();
23697
+ var modelsInFlight = /* @__PURE__ */ new Map();
23698
+ var cacheGeneration = 0;
23699
+ function clearModelsCache() {
23700
+ cacheGeneration++;
23701
+ modelsCache.clear();
23702
+ modelsInFlight.clear();
23703
+ }
23704
+ function pruneStaleTokenEntries(newKey) {
23705
+ const [newBaseUrl, newProvider] = JSON.parse(newKey);
23706
+ for (const existingKey of modelsCache.keys()) {
23707
+ if (existingKey === newKey) continue;
23708
+ const [existingBaseUrl, existingProvider] = JSON.parse(existingKey);
23709
+ if (existingBaseUrl === newBaseUrl && existingProvider === newProvider) {
23710
+ modelsCache.delete(existingKey);
23711
+ }
23712
+ }
23713
+ }
23714
+ function fingerprintToken(token) {
23715
+ if (!token) return "anon";
23716
+ let h1 = 3735928559;
23717
+ let h2 = 1103547991;
23718
+ for (let i = 0; i < token.length; i++) {
23719
+ const ch = token.charCodeAt(i);
23720
+ h1 = Math.imul(h1 ^ ch, 2654435761);
23721
+ h2 = Math.imul(h2 ^ ch, 1597334677);
23722
+ }
23723
+ h1 = Math.imul(h1 ^ h1 >>> 16, 2246822507) ^ Math.imul(h2 ^ h2 >>> 13, 3266489909);
23724
+ h2 = Math.imul(h2 ^ h2 >>> 16, 2246822507) ^ Math.imul(h1 ^ h1 >>> 13, 3266489909);
23725
+ return (4294967296 * (2097151 & h2) + (h1 >>> 0)).toString(36);
23726
+ }
23727
+ function modelsCacheKey(baseUrl, provider, token) {
23728
+ return JSON.stringify([baseUrl, provider ?? null, fingerprintToken(token)]);
23729
+ }
23730
+ async function fetchAllModelPages(baseUrl, provider, headers, previous, signal) {
23731
+ const pages = /* @__PURE__ */ new Map();
23732
+ const models = [];
23733
+ let pageToken;
23734
+ do {
23735
+ const pageKey = pageToken ?? "";
23736
+ const stored2 = previous?.pages.get(pageKey);
23737
+ const request = (etag) => getApiV1Models({
23738
+ baseUrl,
23739
+ headers: etag ? { ...headers, "If-None-Match": etag } : headers,
23740
+ query: { provider, page_token: pageToken },
23741
+ signal
23742
+ });
23743
+ let response = await request(stored2?.etag);
23744
+ if (stored2?.etag && !response.response && response.error) {
23745
+ response = await request();
23746
+ }
23747
+ let page;
23748
+ if (response.response?.status === 304) {
23749
+ if (!stored2) throw new Error("Failed to fetch models");
23750
+ page = stored2;
23751
+ } else {
23752
+ if (response.error) {
23753
+ const errorMsg = response.error.error ?? "Failed to fetch models";
23754
+ throw new Error(errorMsg);
23755
+ }
23756
+ page = {
23757
+ body: response.data ?? {},
23758
+ etag: response.response?.headers?.get("ETag") ?? void 0
23759
+ };
23760
+ }
23761
+ pages.set(pageKey, page);
23762
+ models.push(...page.body.data || []);
23763
+ pageToken = page.body.next_page_token;
23764
+ } while (pageToken);
23765
+ return { pages, models, fetchedAt: Date.now() };
23766
+ }
23767
+ function loadModels(key, baseUrl, provider, headers, force, signal) {
23768
+ const cached = modelsCache.get(key);
23769
+ if (cached && !force && Date.now() - cached.fetchedAt < MODELS_CACHE_TTL_MS) {
23770
+ return Promise.resolve([...cached.models]);
23771
+ }
23772
+ const shared = (force ? void 0 : modelsInFlight.get(key)) ?? startSharedRequest(key, baseUrl, provider, headers, cached);
23773
+ return waitForSharedRequest(key, shared, signal).then((models) => [...models]);
23774
+ }
23775
+ function startSharedRequest(key, baseUrl, provider, headers, previous) {
23776
+ const controller = new AbortController();
23777
+ const generation = cacheGeneration;
23778
+ const shared = {
23779
+ controller,
23780
+ waiters: 0,
23781
+ promise: Promise.resolve([])
23782
+ };
23783
+ shared.promise = fetchAllModelPages(baseUrl, provider, headers, previous, controller.signal).then((entry) => {
23784
+ if (modelsInFlight.get(key) === shared && generation === cacheGeneration) {
23785
+ pruneStaleTokenEntries(key);
23786
+ modelsCache.set(key, entry);
23787
+ }
23788
+ return entry.models;
23789
+ }).finally(() => {
23790
+ if (modelsInFlight.get(key) === shared) modelsInFlight.delete(key);
23791
+ });
23792
+ modelsInFlight.set(key, shared);
23793
+ return shared;
23794
+ }
23795
+ function waitForSharedRequest(key, shared, signal) {
23796
+ shared.waiters++;
23797
+ let left = false;
23798
+ const leave = () => {
23799
+ if (left) return;
23800
+ left = true;
23801
+ shared.waiters--;
23802
+ if (shared.waiters === 0) {
23803
+ shared.controller.abort();
23804
+ if (modelsInFlight.get(key) === shared) modelsInFlight.delete(key);
23805
+ }
23806
+ };
23807
+ if (signal.aborted) {
23808
+ leave();
23809
+ } else {
23810
+ signal.addEventListener("abort", leave, { once: true });
23811
+ }
23812
+ return shared.promise.finally(() => {
23813
+ left = true;
23814
+ signal.removeEventListener("abort", leave);
23815
+ });
23816
+ }
23678
23817
  function useModels(options = {}) {
23679
23818
  const { getToken, baseUrl = BASE_URL, provider, autoFetch = true } = options;
23680
23819
  const [models, setModels] = (0, import_react3.useState)([]);
@@ -23697,7 +23836,7 @@ function useModels(options = {}) {
23697
23836
  }
23698
23837
  };
23699
23838
  }, []);
23700
- const fetchModels = (0, import_react3.useCallback)(async () => {
23839
+ const fetchModels = (0, import_react3.useCallback)(async (force = false) => {
23701
23840
  if (abortControllerRef.current) {
23702
23841
  abortControllerRef.current.abort();
23703
23842
  }
@@ -23716,35 +23855,17 @@ function useModels(options = {}) {
23716
23855
  if (token) {
23717
23856
  headers["Authorization"] = `Bearer ${token}`;
23718
23857
  }
23719
- let allModels = [];
23720
- let nextPageToken;
23721
- do {
23722
- if (signal.aborted) return;
23723
- const response = await getApiV1Models({
23724
- baseUrl: baseUrlRef.current,
23725
- headers,
23726
- query: {
23727
- provider: providerRef.current,
23728
- page_token: nextPageToken
23729
- },
23730
- signal
23731
- });
23732
- if (response.error) {
23733
- const errorMsg = response.error.error ?? "Failed to fetch models";
23734
- throw new Error(errorMsg);
23735
- }
23736
- if (response.data) {
23737
- const newModels = response.data.data || [];
23738
- allModels = [...allModels, ...newModels];
23739
- nextPageToken = response.data.next_page_token;
23740
- }
23741
- } while (nextPageToken);
23858
+ const baseUrl2 = baseUrlRef.current;
23859
+ const provider2 = providerRef.current;
23860
+ const key = modelsCacheKey(baseUrl2, provider2, token);
23861
+ const allModels = await loadModels(key, baseUrl2, provider2, headers, force, signal);
23742
23862
  if (signal.aborted) return;
23743
23863
  setModels(allModels);
23744
23864
  } catch (err) {
23745
23865
  if (err instanceof Error && err.name === "AbortError") {
23746
23866
  return;
23747
23867
  }
23868
+ if (signal.aborted) return;
23748
23869
  setError(err instanceof Error ? err : new Error(String(err)));
23749
23870
  } finally {
23750
23871
  if (!signal.aborted) {
@@ -23757,7 +23878,7 @@ function useModels(options = {}) {
23757
23878
  }, []);
23758
23879
  const refetch = (0, import_react3.useCallback)(async () => {
23759
23880
  setModels([]);
23760
- await fetchModels();
23881
+ await fetchModels(true);
23761
23882
  }, [fetchModels]);
23762
23883
  const hasFetchedRef = (0, import_react3.useRef)(false);
23763
23884
  (0, import_react3.useEffect)(() => {
@@ -24486,6 +24607,7 @@ function useChat(options) {
24486
24607
  apiType: defaultApiType = "auto",
24487
24608
  smoothing,
24488
24609
  preProcessors,
24610
+ hooks,
24489
24611
  piiRedaction,
24490
24612
  onPiiRedacted,
24491
24613
  resumable = false,
@@ -24739,6 +24861,7 @@ function useChat(options) {
24739
24861
  onToolCallArgumentsDelta,
24740
24862
  onStepFinish,
24741
24863
  preProcessors,
24864
+ hooks,
24742
24865
  piiRedaction: requestPiiRedaction ?? resolvedPiiRedaction,
24743
24866
  onPiiRedacted
24744
24867
  });
@@ -24778,6 +24901,7 @@ function useChat(options) {
24778
24901
  defaultApiType,
24779
24902
  smoothing,
24780
24903
  preProcessors,
24904
+ hooks,
24781
24905
  resolvedPiiRedaction,
24782
24906
  onPiiRedacted,
24783
24907
  resumable,
@@ -25748,6 +25872,7 @@ function useChatStorage(options) {
25748
25872
  embeddingModel = DEFAULT_API_EMBEDDING_MODEL,
25749
25873
  minContentLength = DEFAULT_MIN_CONTENT_LENGTH,
25750
25874
  preProcessors,
25875
+ hooks,
25751
25876
  smoothing,
25752
25877
  resumable = false,
25753
25878
  onCancelResult,
@@ -26207,6 +26332,7 @@ function useChatStorage(options) {
26207
26332
  onError,
26208
26333
  apiType,
26209
26334
  preProcessors,
26335
+ hooks,
26210
26336
  smoothing,
26211
26337
  resumable,
26212
26338
  onCancelResult,
@@ -27556,6 +27682,7 @@ function useChatStorage(options) {
27556
27682
  clearConversationMemoriesOp,
27557
27683
  clearEncryptionKey,
27558
27684
  clearLazyTitleCache,
27685
+ clearModelsCache,
27559
27686
  clearServerToolsCache,
27560
27687
  consoleLogger,
27561
27688
  conversationMemoryToStored,
@@ -2002,6 +2002,127 @@ declare function createStreamingDeAnonymizer(redactor: PiiRedactor, emit: (chunk
2002
2002
  flush: () => void;
2003
2003
  };
2004
2004
 
2005
+ type LlmTokenUsage = {
2006
+ inputTokens?: number;
2007
+ outputTokens?: number;
2008
+ };
2009
+ type ModelCallStartEvent = {
2010
+ runId: string;
2011
+ stepIndex: number;
2012
+ model: string;
2013
+ messages: Array<LlmapiMessage>;
2014
+ tools: Array<LlmapiChatCompletionTool>;
2015
+ requestBody: Record<string, unknown>;
2016
+ };
2017
+ type ModelCallEndEvent = {
2018
+ runId: string;
2019
+ stepIndex: number;
2020
+ content: string;
2021
+ toolCalls: Array<{
2022
+ id: string;
2023
+ name: string;
2024
+ arguments: string;
2025
+ }>;
2026
+ usage?: LlmTokenUsage;
2027
+ finishReason?: string;
2028
+ error?: string;
2029
+ };
2030
+ type ToolUseStartEvent = {
2031
+ runId: string;
2032
+ stepIndex: number;
2033
+ toolCallId: string;
2034
+ name: string;
2035
+ rawArguments: string;
2036
+ parsedArguments?: Record<string, unknown>;
2037
+ };
2038
+ type ToolUseEndEvent = {
2039
+ runId: string;
2040
+ stepIndex: number;
2041
+ toolCallId: string;
2042
+ name: string;
2043
+ result?: unknown;
2044
+ error?: string;
2045
+ errorType?: "parse" | "timeout" | "execution" | "cancelled";
2046
+ };
2047
+ type RunStartEvent = {
2048
+ runId: string;
2049
+ model: string;
2050
+ messages: Array<LlmapiMessage>;
2051
+ tools: Array<LlmapiChatCompletionTool>;
2052
+ };
2053
+ type RunEndEvent = {
2054
+ runId: string;
2055
+ finalContent: string;
2056
+ /** Number of LLM rounds executed. */
2057
+ totalSteps: number;
2058
+ };
2059
+ type RunErrorEvent = {
2060
+ runId: string;
2061
+ error: string;
2062
+ /**
2063
+ * Only `"model"` today. Tool failures surface on {@link RunHooks.afterToolUse}
2064
+ * with `errorType`, not on `onRunError`, so a tool stage isn't needed yet.
2065
+ * Left as a union to leave room for `"validation"` or `"tool"` later
2066
+ * without a breaking change.
2067
+ */
2068
+ stage: "model";
2069
+ /**
2070
+ * The underlying `Error` when one is available. `RunErrorEvent` predates
2071
+ * this field, so `error` (a string message) is kept for backwards
2072
+ * compatibility; new consumers should prefer `errorObject` when present
2073
+ * for stack traces and `cause`.
2074
+ */
2075
+ errorObject?: Error;
2076
+ };
2077
+ type RunHooks = {
2078
+ /**
2079
+ * Fires once per `runToolLoop` invocation, before any pre-processor or
2080
+ * model call. The `messages` payload is the raw caller-supplied
2081
+ * conversation — pre-processors that enrich it (e.g. web search context)
2082
+ * run afterwards, so `beforeModelCall.messages` reflects the
2083
+ * post-enrichment state.
2084
+ */
2085
+ onRunStart?: (e: RunStartEvent) => Promise<void> | void;
2086
+ /**
2087
+ * Fires exactly once per run on clean completion. Mutually exclusive
2088
+ * with `onRunError` — a run that completes fires `onRunEnd`; a run that
2089
+ * errors or is aborted fires `onRunError`. Consumers can rely on
2090
+ * exactly one terminal hook per `onRunStart`.
2091
+ */
2092
+ onRunEnd?: (e: RunEndEvent) => Promise<void> | void;
2093
+ /**
2094
+ * Fires exactly once per run when the loop errors or is aborted.
2095
+ * `stage` is `"model"` for stream/provider errors and for aborts;
2096
+ * tool execution failures surface as structured `{ error, errorType }`
2097
+ * results on `afterToolUse` rather than firing `onRunError`.
2098
+ * Mutually exclusive with `onRunEnd`.
2099
+ */
2100
+ onRunError?: (e: RunErrorEvent) => Promise<void> | void;
2101
+ beforeModelCall?: (e: ModelCallStartEvent) => Promise<void> | void;
2102
+ afterModelCall?: (e: ModelCallEndEvent) => Promise<void> | void;
2103
+ /**
2104
+ * Fires before each tool the model invoked — including server-side
2105
+ * tools that have no client executor. Today this is observe-only.
2106
+ * TODO(follow-up PR): allow returning { args?, abort?: { reason } } to
2107
+ * mutate arguments or short-circuit the tool call.
2108
+ *
2109
+ * Pairing with {@link afterToolUse} is asymmetric: server-side tools
2110
+ * routed via `onToolCall` get `beforeToolUse` but no `afterToolUse`,
2111
+ * because they don't execute in-process. Tools blocked by a failed
2112
+ * dependency or a dependency cycle DO get `afterToolUse` with
2113
+ * `errorType: "execution"` — consumers tallying matched pairs should
2114
+ * filter on executor-backed tools to avoid spurious imbalances.
2115
+ */
2116
+ beforeToolUse?: (e: ToolUseStartEvent) => Promise<void> | void;
2117
+ /**
2118
+ * Fires after each executor-backed tool finishes (success or failure)
2119
+ * and after each dependency-blocked tool is skipped (`errorType:
2120
+ * "execution"`). Does NOT fire for server-side tools routed via
2121
+ * `onToolCall`. See {@link beforeToolUse} for the pairing contract.
2122
+ */
2123
+ afterToolUse?: (e: ToolUseEndEvent) => Promise<void> | void;
2124
+ };
2125
+
2005
2126
  /**
2006
2127
  * Configuration for stream output smoothing.
2007
2128
  *
@@ -2196,6 +2317,8 @@ type BaseSendMessageArgs = ResponsesApiOptions & {
2196
2317
  type BaseUseChatOptions = {
2197
2318
  getToken?: () => Promise<string | null>;
2198
2319
  baseUrl?: string;
2320
+ /** Run lifecycle hooks for telemetry and tracing, for example from `createMetricsHooks` */
2321
+ hooks?: RunHooks | RunHooks[];
2199
2322
  /**
2200
2323
  * Callback function to be called when a new data chunk is received.
2201
2324
  */
@@ -6615,6 +6738,8 @@ interface CachedServerTools {
6615
6738
  version: string;
6616
6739
  /** Checksum from the server for cache invalidation */
6617
6740
  checksum?: string;
6741
+ /** ETag from the server. The next refresh sends it in an If-None-Match header. */
6742
+ etag?: string;
6618
6743
  }
6619
6744
  /**
6620
6745
  * Pluggable persistence for the fetched server-tools list.
@@ -6684,7 +6809,9 @@ declare function clearServerToolsCache(cache: ToolsCacheBackend): void | Promise
6684
6809
  * Flow:
6685
6810
  * 1. Check the cache backend (localStorage by default; override via `cache`)
6686
6811
  * 2. If cache valid and not force refresh, return cached tools
6687
- * 3. Otherwise, fetch from API, cache, and return
6812
+ * 3. Otherwise, fetch from API, cache, and return. When the cache holds an ETag,
6813
+ * the request sends If-None-Match. On 304 the cached tools stay and only the
6814
+ * stored timestamp changes.
6688
6815
  * 4. On fetch failure, return cached tools if available (stale-while-error)
6689
6816
  */
6690
6817
  declare function getServerTools(options: ServerToolsOptions): Promise<ServerTool[]>;
@@ -7131,6 +7258,8 @@ interface CreateConversationOptions {
7131
7258
  * @inline
7132
7259
  */
7133
7260
  interface BaseUseChatStorageOptions {
7261
+ /** Run lifecycle hooks for telemetry and tracing, for example from `createMetricsHooks` */
7262
+ hooks?: RunHooks | RunHooks[];
7134
7263
  /** WatermelonDB database instance for storing conversations and messages */
7135
7264
  database: Database;
7136
7265
  /** Route memory reads, writes, recall and the memory tools through this store instead of the database's vault; folders are unsupported. With `piiRedaction` on, build the store with `embeddingOptions.maskInput` (e.g. `(text) => redactor.maskText(text)` with any `PiiRedactor`) or its memory calls throw. */
@@ -10551,6 +10680,8 @@ type UseCreditsResult = {
10551
10680
  */
10552
10681
  declare function useCredits(options?: UseCreditsOptions): UseCreditsResult;
10553
10682
 
10683
+ /** Clear all cached model lists. */
10684
+ declare function clearModelsCache(): void;
10554
10685
  /**
10555
10686
  * @inline
10556
10687
  */
@@ -11147,4 +11278,4 @@ interface UseChatStorageResult extends BaseUseChatStorageResult {
11147
11278
  */
11148
11279
  declare function useChatStorage(options: UseChatStorageOptions): UseChatStorageResult;
11149
11280
 
11150
- export { type AutoExtractMessage, type AutoExtractor, type Budget, CHUNKS_DISCARDED_ORIGIN, type CachedChunkVectors, type CachedServerTools, Conversation as ChatConversation, Message as ChatMessage, type ChatRole, type ChunkVectorCache, type ChunkingOptions, type ConsolidationAction, type ConsolidationFallbackReason, type ConversationMemoryInput, ConversationMemory as ConversationMemoryModel, type ConversationMemoryOperationsContext, type CreateAutoExtractorOptions, type CreateConversationOptions, type CreateDecaySweeperOptions, type CreateMessageOptions, type CreateVaultFolderOptions, type CreateVaultMemoryOptions, type CryptoPriceClassification, type CryptoPricePreProcessorOptions, DEFAULT_CACHE_EXPIRATION_MS, DEFAULT_CHUNK_CACHE_SIZE, DEFAULT_CHUNK_OVERLAP, DEFAULT_CHUNK_SIZE, DEFAULT_DECAY_POLICY, DEFAULT_MAX_CLASSIFIER_CALLS_PER_SWEEP, DEFAULT_MIN_CHUNK_SIZE, DEFAULT_PROFILE_FACETS, DEFAULT_PROFILE_FACT_TYPE_WEIGHTS, DEFAULT_PROFILE_PROOF_ALPHA, DEFAULT_PROFILE_TREND_MULTIPLIERS, DEFAULT_VAULT_CACHE_SIZE, DatabaseManager, type DatabaseManagerLogger, type DatabaseManagerOptions, type DecayCandidateRaw, type DecayClassifier, type DecayInput, type DecayPolicy, type DecaySweepResult, type DecaySweeper, type DecayVerdict, type DurableAutoExtractorOptions, ENTITY_FANOUT, type EmbeddedWalletSignerFn, EncryptionKeyMissingError, type ExtractFactsOptions, type ExtractOutcome, type ExtractedCandidate, type ExtractedEntity, type ExtractionCursorStore, type ExtractionFunnel, type ExtractionTimings, type FactType, type FileMetadata, type FileProcessingReason, type FileProcessingStatus, type FlushResult, type GetConversationsPageOptions, type GetMessagesPageOptions, type GraphTraversalOptions, HARD_DELETE_WINDOW_MS, INFERENCE_ID_HEADER, type InjectionClassifierOptions, type InjectionReason, type LazyStoredConversation, type LlmDecayClassifierOptions, type LlmNeighborRefinerOptions, type LocalMemoryStoreOptions, type Logger, LoggerProvider, type LoggerProviderProps, MAX_HOPS, MEDIUM_TTL_MS, MEMORY_KINDS, MEMORY_LEVELS, type ManualFactType, type MemoriesNeedingTopicExtraction, type MemoryContextItem, type MemoryContextLane, type MemoryContextOptions, type MemoryContextResult, type MemoryCreate, type EmbeddingOptions as MemoryEngineEmbeddingOptions, type MemoryEngineResult, type MemoryEngineSearchOptions, type MemoryExtractedEvent, MemoryKeyError, type MemoryKeyRing, type MemoryKind, type MemoryLevel, MemoryLevelError, type MemoryListOptions, type MemoryMaintenance, type MemoryQuarantinedEvent, type MemoryRecallOptions, type MemoryRetainOptions, type MemoryStore, type MemorySubscribeOptions, type MemoryToVerify, type MemoryTopic, type MemoryUpdate, type MemoryVaultSearchOptions, type MemoryVaultToolOptions, type MemoryVerification, type MessageRedactionResult, type MessageSkeleton, NEVER_TTL_MS, NODE_BUDGET, NOTION_OAUTH_CONFIG, type NeighborRefiner, type NotionAuthUrlParams, type NotionClientRegistration, type NotionExchangeCodeParams, type NotionMcpCaller, type NotionOAuthEndpoints, type NotionPKCEChallenge, type NotionRefreshTokenParams, type NotionTokenResponse, type NowSource, type ObservationTrend, type ObservationTrendInput, PAST_EVENT_GRACE_MS, PII_PATTERNS, PROFILE_DOC_VERSION, type PhotoIngestResult, type PhotoMediaRef, type PiiCategory, type PiiMatch, type PiiPattern, PiiRedactor, type PiiRedactorOptions, type PlatformStorage, type PortalLlmAuth, type PortalLlmFailure, type PortalLlmFailureReason, type ProfileConfigFingerprint, type ProfileDoc, type ProfileFacet, type ProfileFacetKey, type ProfileSalienceInput, type ProfileSection, type PromptPreProcessor, type PromptPreProcessorContext, type PublishedPhotoMemory, type QuantizedEmbedding, type QuarantinedMemoryInfo, QueueManager, type QueueStatus, RECALL_MAX_LIMIT, RECALL_TOOL_NAME, type RankableVaultMemory, type RankedMemory, type RankedProfileCandidate, type RecallContext, type RecallDegradation, type RecallDiagnostics, type RecallEmptyReason, type RecallOptions, type RecallResult, type RecallToolCallbacks, type RecallToolOptions, type RecencyOptions, type RedactionResult, type ReflectOptions, type ReflectResult, type RemoteMemoryCandidateOptions, type RemoteMemoryDecodeFailure, RemoteMemoryError, type RemoteMemoryListOptions, type RemoteMemoryMetadataPage, type RemoteMemoryMetadataRecord, type RemoteMemoryPage, RemoteMemoryPartialCreateError, type RemoteMemoryPersistence, type RemoteMemoryPersistenceOptions, type RemoteMemoryPipeline, type RemoteMemoryPipelineOptions, type RemoteMemoryQueryOptions, type RemoteMemoryQueryPage, type RemoteMemoryReadFilters, type RemoteMemoryRecord, type RemoteMemoryRow, type RemoteMemoryStoreOptions, type RequestEncryptionKeyOptions, RerankerUnavailableError, type ReservationReceipt, type ResumeStreamOptions, type ResumeStreamResult, type ResumeStreamWithStorageResult, type RetainAction, type RetainContext, type RetainOptions, type RetainResult, type RetainSource, SDK_SCHEMA_VERSION, SHORT_TTL_MS, STREAM_RESUMABLE_HEADER, type ScoreBreakdown, type ScoreProfileSalienceOptions, type ScreenResult, type ScreenedCandidate, type SearchSource, type SendMessageWithStorageArgs, type SendMessageWithStorageDetachedResult, type SendMessageWithStorageResult, type ServerToolsOptions, type ServerToolsResponse, type SignMessageFn, type StockPriceClassification, type StockPricePreProcessorOptions, type ChatCompletionUsage as StoredChatCompletionUsage, type StoredConversation, type StoredConversationMemory, type StoredMessage, type StoredMessageWithSimilarity, type StoredVaultFolder, VaultFolder as StoredVaultFolderModel, type StoredVaultMemory, VaultMemory as StoredVaultMemoryModel, StreamExpiredError, type StreamMetaEvent, type StreamResumeHandle, type StreamSmoothingConfig, type SynthesizeProfileOptions, TOOL_RESULT_ORIGIN, TOPICS_EXTRACTION_VERSION, TOPIC_EXTRACTION_BATCH_SIZE, TREND_RECENT_WINDOW_DAYS, TREND_STALE_WINDOW_DAYS, type TextChunk, type TopicExtractOptions, type TopicExtractionInput, type TopicExtractionRunResult, type TopicSkipReason, type TurnCompleteEvent, type TurnSkippedEvent, type UncheckedReason, type UnverifiableReason, type UpdateVaultFolderOptions, type UpdateVaultMemoryOptions, type UseChatStorageOptions, type UseChatStorageResult, type UseCreditsOptions, type UseCreditsResult, type UseModelsOptions, type UseModelsResult, VAULT_SIZE_HOP_CAP, type VaultEmbeddingCache, type VaultEmbeddingExpectation, type VaultFolderOperationsContext, type VaultMemoryKind, type VaultMemoryOperationsContext, type VaultMemoryProjection, type VaultMemoryVisibility, type VaultMemoryWriter, type VaultSaveOperation, type VaultSearchResult, type VaultWriteAction, type VaultWriteInput, type VaultWriteOutcome, type VerificationSources, type VerifyMemoriesForPublishOptions, WalletPoller, type WeatherClassification, type WeatherPreProcessorOptions, type WebSearchClassification, type WebSearchPreProcessorOptions, addConversationMemoriesOp, archiveVaultMemoryOp, assembleMemoryContext, attachFileContextToLastUserMessage, backfillMemoryTopicsOp, buildAttachedFilesText, buildNotionAuthUrl, capHopsForDensity, chatStorageMigrations, chatStorageSchema, chunkAndEmbedAllMessages, chunkAndEmbedMessage, chunkText, classifyCryptoPrice, classifyCryptoPriceBatch, classifyDecay, classifyInjectionCandidates, classifyObservationTrend, classifyStockPrice, classifyStockPriceBatch, classifyWeather, classifyWeatherBatch, classifyWebSearch, classifyWebSearchBatch, clearAllEncryptionKeys, clearAllEncryptionState, clearConversationMemoriesOp, clearEncryptionKey, clearLazyTitleCache, clearServerToolsCache, consoleLogger, conversationMemoryToStored, cosineInt8, createAutoExtractor, createChunkVectorCache, createCryptoPricePreProcessor, createDecaySweeper, createDurableAutoExtractor, createLlmDecayClassifier, createLlmNeighborRefiner, createLocalMemoryStore, createMemoryEngineTool, createMemoryVaultSearchTool, createMemoryVaultTool, createMessageSourceResolver, createNotionProxyTools, createNotionTools, createPlatformCursorStore, createRecallTool, createRemoteMemoryPersistence, createRemoteMemoryPipeline, createRemoteMemoryStore, createStockPricePreProcessor, createStreamingDeAnonymizer, createVaultEmbeddingCache, createVaultFolderOp, createVaultMemoriesBatchOp, createVaultMemoryOp, createWeatherPreProcessor, createWebSearchPreProcessor, decodeChunkVector, decryptConversationTitle, deleteAllVaultMemoriesForUserOp, deleteMessageOp, deleteVaultFolderOp, deleteVaultMemoryOp, dequantizeEmbedding, deriveKeyFromSignatureBytes, deriveMemoryKeyRing, discoverNotionOAuthEndpoints, eagerEmbedContent, embedAllMessages, embedMessage, encodeChunkVector, ensureDefaultFoldersOp, exchangeNotionCode, extractAndLinkEntitiesForMemoriesOp, extractAndRetain, extractEntitiesForMemories, extractFacts, extractReservationReceipts, formatFileProcessingNotes, generateConversationId, generateEmbedding, generateEmbeddings, generateNotionPKCE, getAllVaultFoldersOp, getAllVaultMemoriesOp, getAllVaultMemoryContentsOp, getCachedServerTools, getConversationMemoriesOp, getConversationsByProjectLazyOp, getConversationsLazyOp, getConversationsPageOp, getDecayCandidatesRawOp, getLogger, getMemoriesNeedingTopicExtractionOp, getServerTools, getUnfiledVaultMemoriesOp, getVaultFolderMemoryCountOp, getVaultMemoriesByIdsOp, getVaultMemoryOp, getVaultRankingProjectionsOp, hardDeleteDecayedOp, hasEncryptionKey, ingestPublishedPhotoMemoriesOp, injectionSignatureCatalog, isAttachedFilesText, isDegradedTopicSkip, isEncrypted, isPiiRedactor, isRerankerAvailable, maskScopedEmbeddingCache, memoryCipher, moveMemoriesToFolderOp, noopLogger, onKeyAvailable, parseMedia, preEmbedVaultMemories, quantizeEmbedding, queueManager, rankProfileCandidates, recall, reencryptMemoryField, reflect, refreshEncryptionKeyIfMatches, refreshNotionAccessToken, registerNotionClient, relinkMemoryTopicsOp, requestEncryptionKey, resolvePiiRedactor, restoreVaultMemoryOp, resumeStream, retain, scoreProfileSalience, screenCandidatesForInjection, sdkMigrations, sdkModelClasses, sdkSchema, searchVaultMemories, seedEncryptionKeys, setLogger, setMemoryVisibilityOp, shouldChunkMessage, shouldRecallMemory, stampTopicsExtractedAtOp, streamCancelPath, streamReplayPath, stripLegacyChunkTextOp, summarizeObservationTrends, supersedeVaultMemoryOp, synthesizeProfile, traverseGraphLane, ttlForType, updateVaultFolderContextOp, updateVaultFolderOp, updateVaultMemoryEmbeddingOp, updateVaultMemoryOp, upsertMessageOp, useChat, useChatStorage, useCredits, useEncryption, useModels, verifyMemoriesForPublish, xhrTransport };
11281
+ export { type AutoExtractMessage, type AutoExtractor, type Budget, CHUNKS_DISCARDED_ORIGIN, type CachedChunkVectors, type CachedServerTools, Conversation as ChatConversation, Message as ChatMessage, type ChatRole, type ChunkVectorCache, type ChunkingOptions, type ConsolidationAction, type ConsolidationFallbackReason, type ConversationMemoryInput, ConversationMemory as ConversationMemoryModel, type ConversationMemoryOperationsContext, type CreateAutoExtractorOptions, type CreateConversationOptions, type CreateDecaySweeperOptions, type CreateMessageOptions, type CreateVaultFolderOptions, type CreateVaultMemoryOptions, type CryptoPriceClassification, type CryptoPricePreProcessorOptions, DEFAULT_CACHE_EXPIRATION_MS, DEFAULT_CHUNK_CACHE_SIZE, DEFAULT_CHUNK_OVERLAP, DEFAULT_CHUNK_SIZE, DEFAULT_DECAY_POLICY, DEFAULT_MAX_CLASSIFIER_CALLS_PER_SWEEP, DEFAULT_MIN_CHUNK_SIZE, DEFAULT_PROFILE_FACETS, DEFAULT_PROFILE_FACT_TYPE_WEIGHTS, DEFAULT_PROFILE_PROOF_ALPHA, DEFAULT_PROFILE_TREND_MULTIPLIERS, DEFAULT_VAULT_CACHE_SIZE, DatabaseManager, type DatabaseManagerLogger, type DatabaseManagerOptions, type DecayCandidateRaw, type DecayClassifier, type DecayInput, type DecayPolicy, type DecaySweepResult, type DecaySweeper, type DecayVerdict, type DurableAutoExtractorOptions, ENTITY_FANOUT, type EmbeddedWalletSignerFn, EncryptionKeyMissingError, type ExtractFactsOptions, type ExtractOutcome, type ExtractedCandidate, type ExtractedEntity, type ExtractionCursorStore, type ExtractionFunnel, type ExtractionTimings, type FactType, type FileMetadata, type FileProcessingReason, type FileProcessingStatus, type FlushResult, type GetConversationsPageOptions, type GetMessagesPageOptions, type GraphTraversalOptions, HARD_DELETE_WINDOW_MS, INFERENCE_ID_HEADER, type InjectionClassifierOptions, type InjectionReason, type LazyStoredConversation, type LlmDecayClassifierOptions, type LlmNeighborRefinerOptions, type LocalMemoryStoreOptions, type Logger, LoggerProvider, type LoggerProviderProps, MAX_HOPS, MEDIUM_TTL_MS, MEMORY_KINDS, MEMORY_LEVELS, type ManualFactType, type MemoriesNeedingTopicExtraction, type MemoryContextItem, type MemoryContextLane, type MemoryContextOptions, type MemoryContextResult, type MemoryCreate, type EmbeddingOptions as MemoryEngineEmbeddingOptions, type MemoryEngineResult, type MemoryEngineSearchOptions, type MemoryExtractedEvent, MemoryKeyError, type MemoryKeyRing, type MemoryKind, type MemoryLevel, MemoryLevelError, type MemoryListOptions, type MemoryMaintenance, type MemoryQuarantinedEvent, type MemoryRecallOptions, type MemoryRetainOptions, type MemoryStore, type MemorySubscribeOptions, type MemoryToVerify, type MemoryTopic, type MemoryUpdate, type MemoryVaultSearchOptions, type MemoryVaultToolOptions, type MemoryVerification, type MessageRedactionResult, type MessageSkeleton, NEVER_TTL_MS, NODE_BUDGET, NOTION_OAUTH_CONFIG, type NeighborRefiner, type NotionAuthUrlParams, type NotionClientRegistration, type NotionExchangeCodeParams, type NotionMcpCaller, type NotionOAuthEndpoints, type NotionPKCEChallenge, type NotionRefreshTokenParams, type NotionTokenResponse, type NowSource, type ObservationTrend, type ObservationTrendInput, PAST_EVENT_GRACE_MS, PII_PATTERNS, PROFILE_DOC_VERSION, type PhotoIngestResult, type PhotoMediaRef, type PiiCategory, type PiiMatch, type PiiPattern, PiiRedactor, type PiiRedactorOptions, type PlatformStorage, type PortalLlmAuth, type PortalLlmFailure, type PortalLlmFailureReason, type ProfileConfigFingerprint, type ProfileDoc, type ProfileFacet, type ProfileFacetKey, type ProfileSalienceInput, type ProfileSection, type PromptPreProcessor, type PromptPreProcessorContext, type PublishedPhotoMemory, type QuantizedEmbedding, type QuarantinedMemoryInfo, QueueManager, type QueueStatus, RECALL_MAX_LIMIT, RECALL_TOOL_NAME, type RankableVaultMemory, type RankedMemory, type RankedProfileCandidate, type RecallContext, type RecallDegradation, type RecallDiagnostics, type RecallEmptyReason, type RecallOptions, type RecallResult, type RecallToolCallbacks, type RecallToolOptions, type RecencyOptions, type RedactionResult, type ReflectOptions, type ReflectResult, type RemoteMemoryCandidateOptions, type RemoteMemoryDecodeFailure, RemoteMemoryError, type RemoteMemoryListOptions, type RemoteMemoryMetadataPage, type RemoteMemoryMetadataRecord, type RemoteMemoryPage, RemoteMemoryPartialCreateError, type RemoteMemoryPersistence, type RemoteMemoryPersistenceOptions, type RemoteMemoryPipeline, type RemoteMemoryPipelineOptions, type RemoteMemoryQueryOptions, type RemoteMemoryQueryPage, type RemoteMemoryReadFilters, type RemoteMemoryRecord, type RemoteMemoryRow, type RemoteMemoryStoreOptions, type RequestEncryptionKeyOptions, RerankerUnavailableError, type ReservationReceipt, type ResumeStreamOptions, type ResumeStreamResult, type ResumeStreamWithStorageResult, type RetainAction, type RetainContext, type RetainOptions, type RetainResult, type RetainSource, SDK_SCHEMA_VERSION, SHORT_TTL_MS, STREAM_RESUMABLE_HEADER, type ScoreBreakdown, type ScoreProfileSalienceOptions, type ScreenResult, type ScreenedCandidate, type SearchSource, type SendMessageWithStorageArgs, type SendMessageWithStorageDetachedResult, type SendMessageWithStorageResult, type ServerToolsOptions, type ServerToolsResponse, type SignMessageFn, type StockPriceClassification, type StockPricePreProcessorOptions, type ChatCompletionUsage as StoredChatCompletionUsage, type StoredConversation, type StoredConversationMemory, type StoredMessage, type StoredMessageWithSimilarity, type StoredVaultFolder, VaultFolder as StoredVaultFolderModel, type StoredVaultMemory, VaultMemory as StoredVaultMemoryModel, StreamExpiredError, type StreamMetaEvent, type StreamResumeHandle, type StreamSmoothingConfig, type SynthesizeProfileOptions, TOOL_RESULT_ORIGIN, TOPICS_EXTRACTION_VERSION, TOPIC_EXTRACTION_BATCH_SIZE, TREND_RECENT_WINDOW_DAYS, TREND_STALE_WINDOW_DAYS, type TextChunk, type TopicExtractOptions, type TopicExtractionInput, type TopicExtractionRunResult, type TopicSkipReason, type TurnCompleteEvent, type TurnSkippedEvent, type UncheckedReason, type UnverifiableReason, type UpdateVaultFolderOptions, type UpdateVaultMemoryOptions, type UseChatStorageOptions, type UseChatStorageResult, type UseCreditsOptions, type UseCreditsResult, type UseModelsOptions, type UseModelsResult, VAULT_SIZE_HOP_CAP, type VaultEmbeddingCache, type VaultEmbeddingExpectation, type VaultFolderOperationsContext, type VaultMemoryKind, type VaultMemoryOperationsContext, type VaultMemoryProjection, type VaultMemoryVisibility, type VaultMemoryWriter, type VaultSaveOperation, type VaultSearchResult, type VaultWriteAction, type VaultWriteInput, type VaultWriteOutcome, type VerificationSources, type VerifyMemoriesForPublishOptions, WalletPoller, type WeatherClassification, type WeatherPreProcessorOptions, type WebSearchClassification, type WebSearchPreProcessorOptions, addConversationMemoriesOp, archiveVaultMemoryOp, assembleMemoryContext, attachFileContextToLastUserMessage, backfillMemoryTopicsOp, buildAttachedFilesText, buildNotionAuthUrl, capHopsForDensity, chatStorageMigrations, chatStorageSchema, chunkAndEmbedAllMessages, chunkAndEmbedMessage, chunkText, classifyCryptoPrice, classifyCryptoPriceBatch, classifyDecay, classifyInjectionCandidates, classifyObservationTrend, classifyStockPrice, classifyStockPriceBatch, classifyWeather, classifyWeatherBatch, classifyWebSearch, classifyWebSearchBatch, clearAllEncryptionKeys, clearAllEncryptionState, clearConversationMemoriesOp, clearEncryptionKey, clearLazyTitleCache, clearModelsCache, clearServerToolsCache, consoleLogger, conversationMemoryToStored, cosineInt8, createAutoExtractor, createChunkVectorCache, createCryptoPricePreProcessor, createDecaySweeper, createDurableAutoExtractor, createLlmDecayClassifier, createLlmNeighborRefiner, createLocalMemoryStore, createMemoryEngineTool, createMemoryVaultSearchTool, createMemoryVaultTool, createMessageSourceResolver, createNotionProxyTools, createNotionTools, createPlatformCursorStore, createRecallTool, createRemoteMemoryPersistence, createRemoteMemoryPipeline, createRemoteMemoryStore, createStockPricePreProcessor, createStreamingDeAnonymizer, createVaultEmbeddingCache, createVaultFolderOp, createVaultMemoriesBatchOp, createVaultMemoryOp, createWeatherPreProcessor, createWebSearchPreProcessor, decodeChunkVector, decryptConversationTitle, deleteAllVaultMemoriesForUserOp, deleteMessageOp, deleteVaultFolderOp, deleteVaultMemoryOp, dequantizeEmbedding, deriveKeyFromSignatureBytes, deriveMemoryKeyRing, discoverNotionOAuthEndpoints, eagerEmbedContent, embedAllMessages, embedMessage, encodeChunkVector, ensureDefaultFoldersOp, exchangeNotionCode, extractAndLinkEntitiesForMemoriesOp, extractAndRetain, extractEntitiesForMemories, extractFacts, extractReservationReceipts, formatFileProcessingNotes, generateConversationId, generateEmbedding, generateEmbeddings, generateNotionPKCE, getAllVaultFoldersOp, getAllVaultMemoriesOp, getAllVaultMemoryContentsOp, getCachedServerTools, getConversationMemoriesOp, getConversationsByProjectLazyOp, getConversationsLazyOp, getConversationsPageOp, getDecayCandidatesRawOp, getLogger, getMemoriesNeedingTopicExtractionOp, getServerTools, getUnfiledVaultMemoriesOp, getVaultFolderMemoryCountOp, getVaultMemoriesByIdsOp, getVaultMemoryOp, getVaultRankingProjectionsOp, hardDeleteDecayedOp, hasEncryptionKey, ingestPublishedPhotoMemoriesOp, injectionSignatureCatalog, isAttachedFilesText, isDegradedTopicSkip, isEncrypted, isPiiRedactor, isRerankerAvailable, maskScopedEmbeddingCache, memoryCipher, moveMemoriesToFolderOp, noopLogger, onKeyAvailable, parseMedia, preEmbedVaultMemories, quantizeEmbedding, queueManager, rankProfileCandidates, recall, reencryptMemoryField, reflect, refreshEncryptionKeyIfMatches, refreshNotionAccessToken, registerNotionClient, relinkMemoryTopicsOp, requestEncryptionKey, resolvePiiRedactor, restoreVaultMemoryOp, resumeStream, retain, scoreProfileSalience, screenCandidatesForInjection, sdkMigrations, sdkModelClasses, sdkSchema, searchVaultMemories, seedEncryptionKeys, setLogger, setMemoryVisibilityOp, shouldChunkMessage, shouldRecallMemory, stampTopicsExtractedAtOp, streamCancelPath, streamReplayPath, stripLegacyChunkTextOp, summarizeObservationTrends, supersedeVaultMemoryOp, synthesizeProfile, traverseGraphLane, ttlForType, updateVaultFolderContextOp, updateVaultFolderOp, updateVaultMemoryEmbeddingOp, updateVaultMemoryOp, upsertMessageOp, useChat, useChatStorage, useCredits, useEncryption, useModels, verifyMemoriesForPublish, xhrTransport };