@anuma/sdk 6.12.0 → 6.13.0

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.
@@ -19670,6 +19670,20 @@ function clientToolToCompletionsFormat(tool) {
19670
19670
  }
19671
19671
  var TOOL_SEARCH_TOOL_TYPE = "tool_search_tool_regex_20251119";
19672
19672
  var TOOL_SEARCH_TOOL_NAME = "tool_search_tool_regex";
19673
+ function resolveDeferredServerTools(allServerTools, serverToolsFilter, config) {
19674
+ const allowed = serverToolsFilter === void 0 || typeof serverToolsFilter === "function" ? allServerTools : filterServerTools(allServerTools, [...serverToolsFilter]);
19675
+ const excluded = new Set(config.excludeTools ?? []);
19676
+ if (typeof serverToolsFilter === "function") {
19677
+ for (const name of serverToolsFilter.excludeTools ?? []) excluded.add(name);
19678
+ }
19679
+ if (excluded.size === 0) return allowed;
19680
+ return allowed.filter((tool) => !excluded.has(tool.name));
19681
+ }
19682
+ function deferFormattingConfig(serverToolsFilter, config) {
19683
+ if (!config?.enabled) return config;
19684
+ const isExplicitList = serverToolsFilter !== void 0 && typeof serverToolsFilter !== "function";
19685
+ return isExplicitList ? void 0 : config;
19686
+ }
19673
19687
  function byNameAscending(a, b) {
19674
19688
  if (a.name < b.name) return -1;
19675
19689
  if (a.name > b.name) return 1;
@@ -19996,7 +20010,7 @@ function createServerToolsFilter(options = {}) {
19996
20010
  const exclude = new Set(options.excludeTools ?? []);
19997
20011
  const sets = options.toolSets ?? [];
19998
20012
  const matchOpts = options.matchOptions;
19999
- return (embeddings, tools) => {
20013
+ const filter = (embeddings, tools) => {
20000
20014
  const matches = findMatchingTools(embeddings, tools, matchOpts);
20001
20015
  if (matches.length === 0) return [];
20002
20016
  const matchedNames = new Set(matches.map((m) => m.tool.name));
@@ -20014,6 +20028,10 @@ function createServerToolsFilter(options = {}) {
20014
20028
  for (const name of exclude) finalNames.delete(name);
20015
20029
  return [...finalNames];
20016
20030
  };
20031
+ return Object.defineProperty(filter, "excludeTools", {
20032
+ value: Object.freeze([...exclude]),
20033
+ enumerable: false
20034
+ });
20017
20035
  }
20018
20036
  var DEFAULT_EXCLUDED_SERVER_TOOLS = [
20019
20037
  "AnumaVisionMCP-anuma_analyze_image",
@@ -21014,7 +21032,11 @@ function useChatStorage(options) {
21014
21032
  cache: serverToolsConfig?.cache
21015
21033
  });
21016
21034
  if (serverToolsConfig?.deferLoading?.enabled) {
21017
- filteredServerTools2 = allServerTools;
21035
+ filteredServerTools2 = resolveDeferredServerTools(
21036
+ allServerTools,
21037
+ serverToolsFilter,
21038
+ serverToolsConfig.deferLoading
21039
+ );
21018
21040
  } else if (isServerToolsFunction2) {
21019
21041
  if (messageContent.length >= MIN_CONTENT_LENGTH_FOR_TOOLS) {
21020
21042
  skipUserEmbedding = await embedToolText(
@@ -21073,7 +21095,7 @@ function useChatStorage(options) {
21073
21095
  filteredServerTools2,
21074
21096
  narrowedClientTools2,
21075
21097
  effectiveApiType2,
21076
- serverToolsConfig?.deferLoading
21098
+ deferFormattingConfig(serverToolsFilter, serverToolsConfig?.deferLoading)
21077
21099
  );
21078
21100
  }
21079
21101
  if (onToolSelection) {
@@ -21286,7 +21308,11 @@ function useChatStorage(options) {
21286
21308
  if ("error" in settledTools) throw settledTools.error;
21287
21309
  const allServerTools = settledTools.tools;
21288
21310
  if (serverToolsConfig?.deferLoading?.enabled && effectiveApiType === "responses") {
21289
- filteredServerTools = allServerTools;
21311
+ filteredServerTools = resolveDeferredServerTools(
21312
+ allServerTools,
21313
+ serverToolsFilter,
21314
+ serverToolsConfig.deferLoading
21315
+ );
21290
21316
  } else if (isServerToolsFunction) {
21291
21317
  if (contentForStorage.length >= MIN_CONTENT_LENGTH_FOR_TOOLS) {
21292
21318
  const settledEmbedding = await (userMessageEmbeddingPromise ?? embedForToolsSettled(getTokenRef.current));
@@ -21306,7 +21332,7 @@ function useChatStorage(options) {
21306
21332
  filteredServerTools,
21307
21333
  clientTools,
21308
21334
  effectiveApiType,
21309
- serverToolsConfig?.deferLoading
21335
+ deferFormattingConfig(serverToolsFilter, serverToolsConfig?.deferLoading)
21310
21336
  );
21311
21337
  }
21312
21338
  } catch (error) {
@@ -21347,7 +21373,7 @@ function useChatStorage(options) {
21347
21373
  filteredServerTools,
21348
21374
  narrowedClientTools,
21349
21375
  effectiveApiType,
21350
- serverToolsConfig?.deferLoading
21376
+ deferFormattingConfig(serverToolsFilter, serverToolsConfig?.deferLoading)
21351
21377
  ) : void 0;
21352
21378
  } catch (error) {
21353
21379
  getLogger().warn("[useChatStorage] client tool filtering failed:", error);
@@ -3308,6 +3308,22 @@ interface DeferLoadingConfig {
3308
3308
  enabled: boolean;
3309
3309
  /** Server-tool names to keep non-deferred (besides the tool-search tool), in priority order. */
3310
3310
  hotToolNames: readonly string[];
3311
+ /**
3312
+ * Server-tool names to drop entirely while defer-loading is on.
3313
+ *
3314
+ * Defer widens the per-turn selection to the whole catalog, which also bypasses the `excludeTools`
3315
+ * baked into a caller's semantic filter. A filter built by {@link createServerToolsFilter} tags itself
3316
+ * with its own exclusions and those are honoured automatically — so most callers need nothing here.
3317
+ *
3318
+ * Set this when the filter's tag can't be seen: a hand-written filter, a filter wrapped in a plain
3319
+ * closure (the wrapper drops the tag), or a static-array `serverToolsFilter`. Anything excluded
3320
+ * UNCONDITIONALLY (a tool the app replaces with its own UI, a capability the model already has
3321
+ * natively) belongs in one of the two places, or defer quietly hands it back to the model.
3322
+ *
3323
+ * This list is UNIONED with the filter's own tag, never a replacement for it — so adding one name
3324
+ * here cannot re-admit the tools the filter already excludes.
3325
+ */
3326
+ excludeTools?: readonly string[];
3311
3327
  }
3312
3328
  /**
3313
3329
  * A tool set defines a group of tools that work together. When any "anchor"
@@ -3308,6 +3308,22 @@ interface DeferLoadingConfig {
3308
3308
  enabled: boolean;
3309
3309
  /** Server-tool names to keep non-deferred (besides the tool-search tool), in priority order. */
3310
3310
  hotToolNames: readonly string[];
3311
+ /**
3312
+ * Server-tool names to drop entirely while defer-loading is on.
3313
+ *
3314
+ * Defer widens the per-turn selection to the whole catalog, which also bypasses the `excludeTools`
3315
+ * baked into a caller's semantic filter. A filter built by {@link createServerToolsFilter} tags itself
3316
+ * with its own exclusions and those are honoured automatically — so most callers need nothing here.
3317
+ *
3318
+ * Set this when the filter's tag can't be seen: a hand-written filter, a filter wrapped in a plain
3319
+ * closure (the wrapper drops the tag), or a static-array `serverToolsFilter`. Anything excluded
3320
+ * UNCONDITIONALLY (a tool the app replaces with its own UI, a capability the model already has
3321
+ * natively) belongs in one of the two places, or defer quietly hands it back to the model.
3322
+ *
3323
+ * This list is UNIONED with the filter's own tag, never a replacement for it — so adding one name
3324
+ * here cannot re-admit the tools the filter already excludes.
3325
+ */
3326
+ excludeTools?: readonly string[];
3311
3327
  }
3312
3328
  /**
3313
3329
  * A tool set defines a group of tools that work together. When any "anchor"
@@ -9962,6 +9962,20 @@ function clientToolToCompletionsFormat(tool) {
9962
9962
  }
9963
9963
  var TOOL_SEARCH_TOOL_TYPE = "tool_search_tool_regex_20251119";
9964
9964
  var TOOL_SEARCH_TOOL_NAME = "tool_search_tool_regex";
9965
+ function resolveDeferredServerTools(allServerTools, serverToolsFilter, config) {
9966
+ const allowed = serverToolsFilter === void 0 || typeof serverToolsFilter === "function" ? allServerTools : filterServerTools(allServerTools, [...serverToolsFilter]);
9967
+ const excluded = new Set(config.excludeTools ?? []);
9968
+ if (typeof serverToolsFilter === "function") {
9969
+ for (const name of serverToolsFilter.excludeTools ?? []) excluded.add(name);
9970
+ }
9971
+ if (excluded.size === 0) return allowed;
9972
+ return allowed.filter((tool) => !excluded.has(tool.name));
9973
+ }
9974
+ function deferFormattingConfig(serverToolsFilter, config) {
9975
+ if (!config?.enabled) return config;
9976
+ const isExplicitList = serverToolsFilter !== void 0 && typeof serverToolsFilter !== "function";
9977
+ return isExplicitList ? void 0 : config;
9978
+ }
9965
9979
  function byNameAscending(a, b) {
9966
9980
  if (a.name < b.name) return -1;
9967
9981
  if (a.name > b.name) return 1;
@@ -10288,7 +10302,7 @@ function createServerToolsFilter(options = {}) {
10288
10302
  const exclude = new Set(options.excludeTools ?? []);
10289
10303
  const sets = options.toolSets ?? [];
10290
10304
  const matchOpts = options.matchOptions;
10291
- return (embeddings, tools) => {
10305
+ const filter = (embeddings, tools) => {
10292
10306
  const matches = findMatchingTools(embeddings, tools, matchOpts);
10293
10307
  if (matches.length === 0) return [];
10294
10308
  const matchedNames = new Set(matches.map((m) => m.tool.name));
@@ -10306,6 +10320,10 @@ function createServerToolsFilter(options = {}) {
10306
10320
  for (const name of exclude) finalNames.delete(name);
10307
10321
  return [...finalNames];
10308
10322
  };
10323
+ return Object.defineProperty(filter, "excludeTools", {
10324
+ value: Object.freeze([...exclude]),
10325
+ enumerable: false
10326
+ });
10309
10327
  }
10310
10328
  var DEFAULT_EXCLUDED_SERVER_TOOLS = [
10311
10329
  "AnumaVisionMCP-anuma_analyze_image",
@@ -11305,7 +11323,11 @@ function useChatStorage(options) {
11305
11323
  cache: serverToolsConfig?.cache
11306
11324
  });
11307
11325
  if (serverToolsConfig?.deferLoading?.enabled) {
11308
- filteredServerTools2 = allServerTools;
11326
+ filteredServerTools2 = resolveDeferredServerTools(
11327
+ allServerTools,
11328
+ serverToolsFilter,
11329
+ serverToolsConfig.deferLoading
11330
+ );
11309
11331
  } else if (isServerToolsFunction2) {
11310
11332
  if (messageContent.length >= MIN_CONTENT_LENGTH_FOR_TOOLS) {
11311
11333
  skipUserEmbedding = await embedToolText(
@@ -11364,7 +11386,7 @@ function useChatStorage(options) {
11364
11386
  filteredServerTools2,
11365
11387
  narrowedClientTools2,
11366
11388
  effectiveApiType2,
11367
- serverToolsConfig?.deferLoading
11389
+ deferFormattingConfig(serverToolsFilter, serverToolsConfig?.deferLoading)
11368
11390
  );
11369
11391
  }
11370
11392
  if (onToolSelection) {
@@ -11577,7 +11599,11 @@ function useChatStorage(options) {
11577
11599
  if ("error" in settledTools) throw settledTools.error;
11578
11600
  const allServerTools = settledTools.tools;
11579
11601
  if (serverToolsConfig?.deferLoading?.enabled && effectiveApiType === "responses") {
11580
- filteredServerTools = allServerTools;
11602
+ filteredServerTools = resolveDeferredServerTools(
11603
+ allServerTools,
11604
+ serverToolsFilter,
11605
+ serverToolsConfig.deferLoading
11606
+ );
11581
11607
  } else if (isServerToolsFunction) {
11582
11608
  if (contentForStorage.length >= MIN_CONTENT_LENGTH_FOR_TOOLS) {
11583
11609
  const settledEmbedding = await (userMessageEmbeddingPromise ?? embedForToolsSettled(getTokenRef.current));
@@ -11597,7 +11623,7 @@ function useChatStorage(options) {
11597
11623
  filteredServerTools,
11598
11624
  clientTools,
11599
11625
  effectiveApiType,
11600
- serverToolsConfig?.deferLoading
11626
+ deferFormattingConfig(serverToolsFilter, serverToolsConfig?.deferLoading)
11601
11627
  );
11602
11628
  }
11603
11629
  } catch (error) {
@@ -11638,7 +11664,7 @@ function useChatStorage(options) {
11638
11664
  filteredServerTools,
11639
11665
  narrowedClientTools,
11640
11666
  effectiveApiType,
11641
- serverToolsConfig?.deferLoading
11667
+ deferFormattingConfig(serverToolsFilter, serverToolsConfig?.deferLoading)
11642
11668
  ) : void 0;
11643
11669
  } catch (error) {
11644
11670
  getLogger().warn("[useChatStorage] client tool filtering failed:", error);
package/dist/index.cjs CHANGED
@@ -2293,7 +2293,7 @@ function createServerToolsFilter(options = {}) {
2293
2293
  const exclude = new Set(options.excludeTools ?? []);
2294
2294
  const sets = options.toolSets ?? [];
2295
2295
  const matchOpts = options.matchOptions;
2296
- return (embeddings, tools) => {
2296
+ const filter = (embeddings, tools) => {
2297
2297
  const matches = findMatchingTools(embeddings, tools, matchOpts);
2298
2298
  if (matches.length === 0) return [];
2299
2299
  const matchedNames = new Set(matches.map((m) => m.tool.name));
@@ -2311,6 +2311,10 @@ function createServerToolsFilter(options = {}) {
2311
2311
  for (const name of exclude) finalNames.delete(name);
2312
2312
  return [...finalNames];
2313
2313
  };
2314
+ return Object.defineProperty(filter, "excludeTools", {
2315
+ value: Object.freeze([...exclude]),
2316
+ enumerable: false
2317
+ });
2314
2318
  }
2315
2319
  var DEFAULT_EXCLUDED_SERVER_TOOLS = [
2316
2320
  "AnumaVisionMCP-anuma_analyze_image",
package/dist/index.d.mts CHANGED
@@ -7900,7 +7900,7 @@ interface CreateServerToolsFilterOptions {
7900
7900
  * });
7901
7901
  * ```
7902
7902
  */
7903
- declare function createServerToolsFilter(options?: CreateServerToolsFilterOptions): (embeddings: number[] | number[][], tools: ServerTool[]) => string[];
7903
+ declare function createServerToolsFilter(options?: CreateServerToolsFilterOptions): ServerToolsFilterFunction;
7904
7904
  /**
7905
7905
  * Default exclusions baked into `defaultServerToolsFilter`.
7906
7906
  *
@@ -7941,7 +7941,21 @@ declare const DEFAULT_SERVER_TOOLS_MATCH_OPTIONS: ToolMatchOptions;
7941
7941
  * If you need to customize (extra excludes, different limits, opt into
7942
7942
  * tool-set expansion), call `createServerToolsFilter` directly.
7943
7943
  */
7944
- declare const defaultServerToolsFilter: (embeddings: number[] | number[][], tools: ServerTool[]) => string[];
7944
+ declare const defaultServerToolsFilter: ServerToolsFilterFunction;
7945
+ /**
7946
+ * Type for a server-tools filter — a function that takes prompt embeddings
7947
+ * and the full server tool catalog and returns the names of tools to keep.
7948
+ * Matches `useChatStorage`'s `serverTools` callback signature.
7949
+ */
7950
+ type ServerToolsFilterFunction = ((embeddings: number[] | number[][], tools: ServerTool[]) => string[]) & {
7951
+ /**
7952
+ * The unconditional exclusions this filter applies, exposed by
7953
+ * {@link createServerToolsFilter} so defer-loading can honour them without the caller
7954
+ * repeating the list — see {@link resolveDeferredServerTools}. Absent on a hand-written
7955
+ * filter, or on one wrapped in a plain closure.
7956
+ */
7957
+ readonly excludeTools?: readonly string[];
7958
+ };
7945
7959
  /**
7946
7960
  * Options for selectServerSideTools
7947
7961
  */
package/dist/index.d.ts CHANGED
@@ -7900,7 +7900,7 @@ interface CreateServerToolsFilterOptions {
7900
7900
  * });
7901
7901
  * ```
7902
7902
  */
7903
- declare function createServerToolsFilter(options?: CreateServerToolsFilterOptions): (embeddings: number[] | number[][], tools: ServerTool[]) => string[];
7903
+ declare function createServerToolsFilter(options?: CreateServerToolsFilterOptions): ServerToolsFilterFunction;
7904
7904
  /**
7905
7905
  * Default exclusions baked into `defaultServerToolsFilter`.
7906
7906
  *
@@ -7941,7 +7941,21 @@ declare const DEFAULT_SERVER_TOOLS_MATCH_OPTIONS: ToolMatchOptions;
7941
7941
  * If you need to customize (extra excludes, different limits, opt into
7942
7942
  * tool-set expansion), call `createServerToolsFilter` directly.
7943
7943
  */
7944
- declare const defaultServerToolsFilter: (embeddings: number[] | number[][], tools: ServerTool[]) => string[];
7944
+ declare const defaultServerToolsFilter: ServerToolsFilterFunction;
7945
+ /**
7946
+ * Type for a server-tools filter — a function that takes prompt embeddings
7947
+ * and the full server tool catalog and returns the names of tools to keep.
7948
+ * Matches `useChatStorage`'s `serverTools` callback signature.
7949
+ */
7950
+ type ServerToolsFilterFunction = ((embeddings: number[] | number[][], tools: ServerTool[]) => string[]) & {
7951
+ /**
7952
+ * The unconditional exclusions this filter applies, exposed by
7953
+ * {@link createServerToolsFilter} so defer-loading can honour them without the caller
7954
+ * repeating the list — see {@link resolveDeferredServerTools}. Absent on a hand-written
7955
+ * filter, or on one wrapped in a plain closure.
7956
+ */
7957
+ readonly excludeTools?: readonly string[];
7958
+ };
7945
7959
  /**
7946
7960
  * Options for selectServerSideTools
7947
7961
  */
package/dist/index.mjs CHANGED
@@ -2091,7 +2091,7 @@ function createServerToolsFilter(options = {}) {
2091
2091
  const exclude = new Set(options.excludeTools ?? []);
2092
2092
  const sets = options.toolSets ?? [];
2093
2093
  const matchOpts = options.matchOptions;
2094
- return (embeddings, tools) => {
2094
+ const filter = (embeddings, tools) => {
2095
2095
  const matches = findMatchingTools(embeddings, tools, matchOpts);
2096
2096
  if (matches.length === 0) return [];
2097
2097
  const matchedNames = new Set(matches.map((m) => m.tool.name));
@@ -2109,6 +2109,10 @@ function createServerToolsFilter(options = {}) {
2109
2109
  for (const name of exclude) finalNames.delete(name);
2110
2110
  return [...finalNames];
2111
2111
  };
2112
+ return Object.defineProperty(filter, "excludeTools", {
2113
+ value: Object.freeze([...exclude]),
2114
+ enumerable: false
2115
+ });
2112
2116
  }
2113
2117
  var DEFAULT_EXCLUDED_SERVER_TOOLS = [
2114
2118
  "AnumaVisionMCP-anuma_analyze_image",
@@ -21700,6 +21700,20 @@ function clientToolToCompletionsFormat(tool) {
21700
21700
  }
21701
21701
  var TOOL_SEARCH_TOOL_TYPE = "tool_search_tool_regex_20251119";
21702
21702
  var TOOL_SEARCH_TOOL_NAME = "tool_search_tool_regex";
21703
+ function resolveDeferredServerTools(allServerTools, serverToolsFilter, config) {
21704
+ const allowed = serverToolsFilter === void 0 || typeof serverToolsFilter === "function" ? allServerTools : filterServerTools(allServerTools, [...serverToolsFilter]);
21705
+ const excluded = new Set(config.excludeTools ?? []);
21706
+ if (typeof serverToolsFilter === "function") {
21707
+ for (const name of serverToolsFilter.excludeTools ?? []) excluded.add(name);
21708
+ }
21709
+ if (excluded.size === 0) return allowed;
21710
+ return allowed.filter((tool) => !excluded.has(tool.name));
21711
+ }
21712
+ function deferFormattingConfig(serverToolsFilter, config) {
21713
+ if (!config?.enabled) return config;
21714
+ const isExplicitList = serverToolsFilter !== void 0 && typeof serverToolsFilter !== "function";
21715
+ return isExplicitList ? void 0 : config;
21716
+ }
21703
21717
  function byNameAscending(a, b) {
21704
21718
  if (a.name < b.name) return -1;
21705
21719
  if (a.name > b.name) return 1;
@@ -22026,7 +22040,7 @@ function createServerToolsFilter(options = {}) {
22026
22040
  const exclude = new Set(options.excludeTools ?? []);
22027
22041
  const sets = options.toolSets ?? [];
22028
22042
  const matchOpts = options.matchOptions;
22029
- return (embeddings, tools) => {
22043
+ const filter = (embeddings, tools) => {
22030
22044
  const matches = findMatchingTools(embeddings, tools, matchOpts);
22031
22045
  if (matches.length === 0) return [];
22032
22046
  const matchedNames = new Set(matches.map((m) => m.tool.name));
@@ -22044,6 +22058,10 @@ function createServerToolsFilter(options = {}) {
22044
22058
  for (const name of exclude) finalNames.delete(name);
22045
22059
  return [...finalNames];
22046
22060
  };
22061
+ return Object.defineProperty(filter, "excludeTools", {
22062
+ value: Object.freeze([...exclude]),
22063
+ enumerable: false
22064
+ });
22047
22065
  }
22048
22066
  var DEFAULT_EXCLUDED_SERVER_TOOLS = [
22049
22067
  "AnumaVisionMCP-anuma_analyze_image",
@@ -22125,7 +22143,8 @@ async function selectServerToolsForPrompt(options) {
22125
22143
  return [];
22126
22144
  }
22127
22145
  if (allServerTools.length === 0) return [];
22128
- if (deferLoading?.enabled) return allServerTools;
22146
+ if (deferLoading?.enabled)
22147
+ return resolveDeferredServerTools(allServerTools, serverToolsFilter, deferLoading);
22129
22148
  if (typeof serverToolsFilter === "function") {
22130
22149
  if (prompt.length < MIN_CONTENT_LENGTH_FOR_TOOLS) return [];
22131
22150
  let promptEmbedding;
@@ -22556,7 +22575,8 @@ async function previewToolSelection(options) {
22556
22575
  cache: serverToolsConfig?.cache
22557
22576
  });
22558
22577
  const allow = new Set(serverToolsFilter);
22559
- gatedServerNames = allServerTools.filter((t) => allow.has(t.name)).map((t) => t.name);
22578
+ const gated = allServerTools.filter((t) => allow.has(t.name));
22579
+ gatedServerNames = (serverToolsConfig?.deferLoading?.enabled ? resolveDeferredServerTools(gated, serverToolsFilter, serverToolsConfig.deferLoading) : gated).map((t) => t.name);
22560
22580
  } catch {
22561
22581
  }
22562
22582
  }
@@ -22605,7 +22625,11 @@ async function previewToolSelection(options) {
22605
22625
  cache: serverToolsConfig?.cache
22606
22626
  });
22607
22627
  if (serverToolsConfig?.deferLoading?.enabled) {
22608
- serverToolNames = allServerTools.map((t) => t.name);
22628
+ serverToolNames = resolveDeferredServerTools(
22629
+ allServerTools,
22630
+ serverToolsFilter,
22631
+ serverToolsConfig.deferLoading
22632
+ ).map((t) => t.name);
22609
22633
  } else if (typeof serverToolsFilter === "function") {
22610
22634
  serverToolNames = serverToolsFilter(promptEmbedding, allServerTools);
22611
22635
  } else {
@@ -23621,7 +23645,11 @@ function useChatStorage(options) {
23621
23645
  cache: serverToolsConfig?.cache
23622
23646
  });
23623
23647
  if (serverToolsConfig?.deferLoading?.enabled) {
23624
- filteredServerTools2 = allServerTools;
23648
+ filteredServerTools2 = resolveDeferredServerTools(
23649
+ allServerTools,
23650
+ serverToolsFilter,
23651
+ serverToolsConfig.deferLoading
23652
+ );
23625
23653
  } else if (isServerToolsFunction2) {
23626
23654
  if (skipStorageEmbeddings) {
23627
23655
  const toolNames = serverToolsFilter(skipStorageEmbeddings, allServerTools);
@@ -23662,7 +23690,7 @@ function useChatStorage(options) {
23662
23690
  filteredServerTools2,
23663
23691
  filteredClientTools2,
23664
23692
  effectiveApiType2,
23665
- serverToolsConfig?.deferLoading
23693
+ deferFormattingConfig(serverToolsFilter, serverToolsConfig?.deferLoading)
23666
23694
  );
23667
23695
  }
23668
23696
  if (onToolSelection) {
@@ -24021,7 +24049,11 @@ function useChatStorage(options) {
24021
24049
  if (allServerTools) {
24022
24050
  try {
24023
24051
  if (serverToolsConfig?.deferLoading?.enabled && effectiveApiType === "responses") {
24024
- filteredServerTools = allServerTools;
24052
+ filteredServerTools = resolveDeferredServerTools(
24053
+ allServerTools,
24054
+ serverToolsFilter,
24055
+ serverToolsConfig.deferLoading
24056
+ );
24025
24057
  } else if (isServerToolsFunction) {
24026
24058
  if (userMessageEmbeddings) {
24027
24059
  const toolNames = serverToolsFilter(userMessageEmbeddings, allServerTools);
@@ -24101,7 +24133,7 @@ function useChatStorage(options) {
24101
24133
  filteredServerTools,
24102
24134
  filteredClientTools,
24103
24135
  effectiveApiType,
24104
- serverToolsConfig?.deferLoading
24136
+ deferFormattingConfig(serverToolsFilter, serverToolsConfig?.deferLoading)
24105
24137
  );
24106
24138
  }
24107
24139
  if (onToolSelection) {
@@ -4465,6 +4465,22 @@ interface DeferLoadingConfig {
4465
4465
  enabled: boolean;
4466
4466
  /** Server-tool names to keep non-deferred (besides the tool-search tool), in priority order. */
4467
4467
  hotToolNames: readonly string[];
4468
+ /**
4469
+ * Server-tool names to drop entirely while defer-loading is on.
4470
+ *
4471
+ * Defer widens the per-turn selection to the whole catalog, which also bypasses the `excludeTools`
4472
+ * baked into a caller's semantic filter. A filter built by {@link createServerToolsFilter} tags itself
4473
+ * with its own exclusions and those are honoured automatically — so most callers need nothing here.
4474
+ *
4475
+ * Set this when the filter's tag can't be seen: a hand-written filter, a filter wrapped in a plain
4476
+ * closure (the wrapper drops the tag), or a static-array `serverToolsFilter`. Anything excluded
4477
+ * UNCONDITIONALLY (a tool the app replaces with its own UI, a capability the model already has
4478
+ * natively) belongs in one of the two places, or defer quietly hands it back to the model.
4479
+ *
4480
+ * This list is UNIONED with the filter's own tag, never a replacement for it — so adding one name
4481
+ * here cannot re-admit the tools the filter already excludes.
4482
+ */
4483
+ excludeTools?: readonly string[];
4468
4484
  }
4469
4485
  /**
4470
4486
  * Result of tool matching with similarity score
@@ -4642,7 +4658,7 @@ interface CreateServerToolsFilterOptions {
4642
4658
  * });
4643
4659
  * ```
4644
4660
  */
4645
- declare function createServerToolsFilter(options?: CreateServerToolsFilterOptions): (embeddings: number[] | number[][], tools: ServerTool[]) => string[];
4661
+ declare function createServerToolsFilter(options?: CreateServerToolsFilterOptions): ServerToolsFilterFunction;
4646
4662
  /**
4647
4663
  * Default exclusions baked into `defaultServerToolsFilter`.
4648
4664
  *
@@ -4708,13 +4724,21 @@ declare const SERVER_TOOL_DEPENDENCY_SETS: ToolSet[];
4708
4724
  * If you need to customize (extra excludes, different limits, opt into
4709
4725
  * tool-set expansion), call `createServerToolsFilter` directly.
4710
4726
  */
4711
- declare const defaultServerToolsFilter: (embeddings: number[] | number[][], tools: ServerTool[]) => string[];
4727
+ declare const defaultServerToolsFilter: ServerToolsFilterFunction;
4712
4728
  /**
4713
4729
  * Type for a server-tools filter — a function that takes prompt embeddings
4714
4730
  * and the full server tool catalog and returns the names of tools to keep.
4715
4731
  * Matches `useChatStorage`'s `serverTools` callback signature.
4716
4732
  */
4717
- type ServerToolsFilterFunction = (embeddings: number[] | number[][], tools: ServerTool[]) => string[];
4733
+ type ServerToolsFilterFunction = ((embeddings: number[] | number[][], tools: ServerTool[]) => string[]) & {
4734
+ /**
4735
+ * The unconditional exclusions this filter applies, exposed by
4736
+ * {@link createServerToolsFilter} so defer-loading can honour them without the caller
4737
+ * repeating the list — see {@link resolveDeferredServerTools}. Absent on a hand-written
4738
+ * filter, or on one wrapped in a plain closure.
4739
+ */
4740
+ readonly excludeTools?: readonly string[];
4741
+ };
4718
4742
  /**
4719
4743
  * Options for `selectServerToolsForPrompt`.
4720
4744
  */
@@ -4742,9 +4766,10 @@ interface SelectServerToolsForPromptOptions {
4742
4766
  */
4743
4767
  cache?: ToolsCacheBackend;
4744
4768
  /**
4745
- * Phase 3 defer-loading. When `enabled`, this helper returns the FULL catalog (skipping semantic/
4746
- * static filtering) to mirror useChatStorage's responses send path, which swaps in the full catalog
4747
- * for mergeTools + tool-search. Omit/disabled → today's filtered selection.
4769
+ * Phase 3 defer-loading. When `enabled`, this helper skips SEMANTIC filtering to mirror
4770
+ * useChatStorage's responses send path, which hands the catalog to mergeTools + tool-search. The
4771
+ * caller's unconditional constraints still apply — an explicit static array, and exclusions (see
4772
+ * {@link resolveDeferredServerTools}). Omit/disabled → today's filtered selection.
4748
4773
  */
4749
4774
  deferLoading?: DeferLoadingConfig;
4750
4775
  }
@@ -4465,6 +4465,22 @@ interface DeferLoadingConfig {
4465
4465
  enabled: boolean;
4466
4466
  /** Server-tool names to keep non-deferred (besides the tool-search tool), in priority order. */
4467
4467
  hotToolNames: readonly string[];
4468
+ /**
4469
+ * Server-tool names to drop entirely while defer-loading is on.
4470
+ *
4471
+ * Defer widens the per-turn selection to the whole catalog, which also bypasses the `excludeTools`
4472
+ * baked into a caller's semantic filter. A filter built by {@link createServerToolsFilter} tags itself
4473
+ * with its own exclusions and those are honoured automatically — so most callers need nothing here.
4474
+ *
4475
+ * Set this when the filter's tag can't be seen: a hand-written filter, a filter wrapped in a plain
4476
+ * closure (the wrapper drops the tag), or a static-array `serverToolsFilter`. Anything excluded
4477
+ * UNCONDITIONALLY (a tool the app replaces with its own UI, a capability the model already has
4478
+ * natively) belongs in one of the two places, or defer quietly hands it back to the model.
4479
+ *
4480
+ * This list is UNIONED with the filter's own tag, never a replacement for it — so adding one name
4481
+ * here cannot re-admit the tools the filter already excludes.
4482
+ */
4483
+ excludeTools?: readonly string[];
4468
4484
  }
4469
4485
  /**
4470
4486
  * Result of tool matching with similarity score
@@ -4642,7 +4658,7 @@ interface CreateServerToolsFilterOptions {
4642
4658
  * });
4643
4659
  * ```
4644
4660
  */
4645
- declare function createServerToolsFilter(options?: CreateServerToolsFilterOptions): (embeddings: number[] | number[][], tools: ServerTool[]) => string[];
4661
+ declare function createServerToolsFilter(options?: CreateServerToolsFilterOptions): ServerToolsFilterFunction;
4646
4662
  /**
4647
4663
  * Default exclusions baked into `defaultServerToolsFilter`.
4648
4664
  *
@@ -4708,13 +4724,21 @@ declare const SERVER_TOOL_DEPENDENCY_SETS: ToolSet[];
4708
4724
  * If you need to customize (extra excludes, different limits, opt into
4709
4725
  * tool-set expansion), call `createServerToolsFilter` directly.
4710
4726
  */
4711
- declare const defaultServerToolsFilter: (embeddings: number[] | number[][], tools: ServerTool[]) => string[];
4727
+ declare const defaultServerToolsFilter: ServerToolsFilterFunction;
4712
4728
  /**
4713
4729
  * Type for a server-tools filter — a function that takes prompt embeddings
4714
4730
  * and the full server tool catalog and returns the names of tools to keep.
4715
4731
  * Matches `useChatStorage`'s `serverTools` callback signature.
4716
4732
  */
4717
- type ServerToolsFilterFunction = (embeddings: number[] | number[][], tools: ServerTool[]) => string[];
4733
+ type ServerToolsFilterFunction = ((embeddings: number[] | number[][], tools: ServerTool[]) => string[]) & {
4734
+ /**
4735
+ * The unconditional exclusions this filter applies, exposed by
4736
+ * {@link createServerToolsFilter} so defer-loading can honour them without the caller
4737
+ * repeating the list — see {@link resolveDeferredServerTools}. Absent on a hand-written
4738
+ * filter, or on one wrapped in a plain closure.
4739
+ */
4740
+ readonly excludeTools?: readonly string[];
4741
+ };
4718
4742
  /**
4719
4743
  * Options for `selectServerToolsForPrompt`.
4720
4744
  */
@@ -4742,9 +4766,10 @@ interface SelectServerToolsForPromptOptions {
4742
4766
  */
4743
4767
  cache?: ToolsCacheBackend;
4744
4768
  /**
4745
- * Phase 3 defer-loading. When `enabled`, this helper returns the FULL catalog (skipping semantic/
4746
- * static filtering) to mirror useChatStorage's responses send path, which swaps in the full catalog
4747
- * for mergeTools + tool-search. Omit/disabled → today's filtered selection.
4769
+ * Phase 3 defer-loading. When `enabled`, this helper skips SEMANTIC filtering to mirror
4770
+ * useChatStorage's responses send path, which hands the catalog to mergeTools + tool-search. The
4771
+ * caller's unconditional constraints still apply — an explicit static array, and exclusions (see
4772
+ * {@link resolveDeferredServerTools}). Omit/disabled → today's filtered selection.
4748
4773
  */
4749
4774
  deferLoading?: DeferLoadingConfig;
4750
4775
  }