@anuma/sdk 6.27.9 → 6.28.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.
@@ -505,6 +505,25 @@ declare function expandToolSetsAdditive(matchedNames: Set<string>, availableName
505
505
  * @param activeSetNames - Set names forced active regardless of score.
506
506
  */
507
507
  declare function activatedToolSetNames(scores: ReadonlyMap<string, number>, toolSets?: ToolSet[], activeSetNames?: ReadonlySet<string>): Set<string>;
508
+ /**
509
+ * Add the server-tool members of every set named in `activeToolSets` to a
510
+ * semantic server-tool selection.
511
+ *
512
+ * A semantic filter ranks only the latest prompt, so a terse follow-up inside a
513
+ * flow ("okay", "retry") drops the flow's server tools. This is the server-side
514
+ * half of what `autoFilterClientTools` does for client tools: an active set's
515
+ * members that are in the catalog are kept whatever the prompt scored, even
516
+ * below the short-prompt gate, where `selected` is empty. Exclusions tagged on
517
+ * the filter still win.
518
+ *
519
+ * @param selected - What the semantic filter picked (`[]` when it did not run).
520
+ * @param allServerTools - The full server-tool catalog.
521
+ * @param serverToolsFilter - The filter function, read only for its `excludeTools` tag.
522
+ * @param activeToolSets - Set names that are sticky for this conversation.
523
+ * @param extraToolSets - The caller's sets beyond {@link BUILT_IN_TOOL_SETS}.
524
+ * @returns `selected`, followed by any active-set members it was missing.
525
+ */
526
+ declare function withActiveToolSetServerTools(selected: ServerTool[], allServerTools: ServerTool[], serverToolsFilter: ServerToolsFilterFunction, activeToolSets?: readonly string[], extraToolSets?: readonly ToolSet[]): ServerTool[];
508
527
  /**
509
528
  * Collect the `systemPrompt` of every tool set that activated for a request,
510
529
  * for the caller to APPEND to its base system prompt.
@@ -679,6 +698,20 @@ interface SelectServerToolsForPromptOptions {
679
698
  * {@link resolveDeferredServerTools}). Omit/disabled → today's filtered selection.
680
699
  */
681
700
  deferLoading?: DeferLoadingConfig;
701
+ /**
702
+ * Tool-set names that are sticky for this conversation — the same list you
703
+ * pass to `useChatStorage`'s `activeToolSets`, e.g. from
704
+ * `deriveActiveToolSets`. With a filter function, the server-tool members of
705
+ * these sets are selected whatever the prompt scored, even on a prompt too
706
+ * short to embed. Omit for selection from the prompt alone.
707
+ */
708
+ activeToolSets?: string[];
709
+ /**
710
+ * The caller's sets beyond {@link BUILT_IN_TOOL_SETS} — the same list you pass
711
+ * to `useChatStorage`'s `extraToolSets` — so a custom set named in
712
+ * `activeToolSets` stays sticky here too.
713
+ */
714
+ extraToolSets?: ToolSet[];
682
715
  }
683
716
  /**
684
717
  * Select server-side tools for a prompt using the same path
@@ -1443,4 +1476,4 @@ declare function resolveServerTools(descriptor: ToolIntentDescriptor, catalog: S
1443
1476
  */
1444
1477
  declare function isCoercingIntent(creation: CreationIntent, catalog: ServerToolCatalog): boolean;
1445
1478
 
1446
- export { type AssembledToolsFilterFn, BUILT_IN_TOOL_SETS, CLIENT_TOOLS_MIN_SIMILARITY, CLIENT_TOOLS_RELEVANCE_RATIO, CREATION_INTENT_CLIENT_FACTORIES, CREATION_INTENT_CLIENT_FILTER, CREATION_INTENT_TOOL_SET, type CachedServerTools, type ClientFactoryBuilder, type ClientFactoryKey, type ClientToolsFilterMode, type ConnectorGuidance, type ConnectorGuidanceInput, type CouncilClientSelectionOptions, type CouncilClientToolsInput, type CreateServerToolsFilterOptions, type CreationIntent, DEFAULT_CACHE_EXPIRATION_MS, DEFAULT_EXCLUDED_SERVER_TOOLS, DEFAULT_SERVER_TOOLS_MATCH_OPTIONS, type DeferLoadingConfig, FULL_GENERATIVE_CLIENT_FACTORIES, MAX_CLIENT_TOOLS_AFTER_FILTER, MEMORY_SAVE_TOOL_NAME, MIN_CONTENT_LENGTH_FOR_TOOLS, type ParsedServerToolsResponse, type PostFilterKey, type ResolvePlanContext, SERVER_TOOL_DEPENDENCY_SETS, type SelectServerSideToolsOptions, type SelectServerToolsForPromptOptions, type SelectionLogger, type ServerTool, type ServerToolCatalog, type ServerToolCatalogEntry, type ServerToolsFilter, type ServerToolsFilterContext, type ServerToolsFilterFunction, type ServerToolsOptions, type ServerToolsResponse, TOOL_CATALOG, type ThinkingModeHint, type ToolActivationEvent, type ToolChoice, type ToolConfig, type ToolExecutor, type ToolIntentDescriptor, type ToolLane, type ToolMatchOptions, type ToolMatchResult, type ToolPlanSpec, type ToolSelectionAdapters, type ToolSet, type ToolsCacheBackend, activatedToolSetNames, applyToolSets, assembleClientTools, autoFilterClientTools, buildConnectorGuidance, buildDeniedToolsRider, clearServerToolsCache, composeCouncilClientTools, computeToolGuidance, createServerToolsFilter, defaultServerToolsFilter, deferFormattingConfig, deriveActiveToolSets, expandToolSetsAdditive, filterAssembledClientTools, filterServerTools, findMatchingTools, getCachedServerTools, getCatalogEntry, getMaxToolRounds, getServerTools, getThinkingMode, getToolDescription, getToolName, getToolsChecksum, isCoercingIntent, localStorageToolsCache, mergeActiveToolSets, mergeTools, resolveCouncilPlan, resolveCouncilServerTools, resolveDeferredServerTools, resolvePlan, resolveServerTools, resolveToolChoice, scoreTools, selectCouncilClientTools, selectServerSideTools, selectServerToolsForPrompt, shouldRefreshTools, stripCoercedMemoryWrite, toolSetSystemPrompts };
1479
+ export { type AssembledToolsFilterFn, BUILT_IN_TOOL_SETS, CLIENT_TOOLS_MIN_SIMILARITY, CLIENT_TOOLS_RELEVANCE_RATIO, CREATION_INTENT_CLIENT_FACTORIES, CREATION_INTENT_CLIENT_FILTER, CREATION_INTENT_TOOL_SET, type CachedServerTools, type ClientFactoryBuilder, type ClientFactoryKey, type ClientToolsFilterMode, type ConnectorGuidance, type ConnectorGuidanceInput, type CouncilClientSelectionOptions, type CouncilClientToolsInput, type CreateServerToolsFilterOptions, type CreationIntent, DEFAULT_CACHE_EXPIRATION_MS, DEFAULT_EXCLUDED_SERVER_TOOLS, DEFAULT_SERVER_TOOLS_MATCH_OPTIONS, type DeferLoadingConfig, FULL_GENERATIVE_CLIENT_FACTORIES, MAX_CLIENT_TOOLS_AFTER_FILTER, MEMORY_SAVE_TOOL_NAME, MIN_CONTENT_LENGTH_FOR_TOOLS, type ParsedServerToolsResponse, type PostFilterKey, type ResolvePlanContext, SERVER_TOOL_DEPENDENCY_SETS, type SelectServerSideToolsOptions, type SelectServerToolsForPromptOptions, type SelectionLogger, type ServerTool, type ServerToolCatalog, type ServerToolCatalogEntry, type ServerToolsFilter, type ServerToolsFilterContext, type ServerToolsFilterFunction, type ServerToolsOptions, type ServerToolsResponse, TOOL_CATALOG, type ThinkingModeHint, type ToolActivationEvent, type ToolChoice, type ToolConfig, type ToolExecutor, type ToolIntentDescriptor, type ToolLane, type ToolMatchOptions, type ToolMatchResult, type ToolPlanSpec, type ToolSelectionAdapters, type ToolSet, type ToolsCacheBackend, activatedToolSetNames, applyToolSets, assembleClientTools, autoFilterClientTools, buildConnectorGuidance, buildDeniedToolsRider, clearServerToolsCache, composeCouncilClientTools, computeToolGuidance, createServerToolsFilter, defaultServerToolsFilter, deferFormattingConfig, deriveActiveToolSets, expandToolSetsAdditive, filterAssembledClientTools, filterServerTools, findMatchingTools, getCachedServerTools, getCatalogEntry, getMaxToolRounds, getServerTools, getThinkingMode, getToolDescription, getToolName, getToolsChecksum, isCoercingIntent, localStorageToolsCache, mergeActiveToolSets, mergeTools, resolveCouncilPlan, resolveCouncilServerTools, resolveDeferredServerTools, resolvePlan, resolveServerTools, resolveToolChoice, scoreTools, selectCouncilClientTools, selectServerSideTools, selectServerToolsForPrompt, shouldRefreshTools, stripCoercedMemoryWrite, toolSetSystemPrompts, withActiveToolSetServerTools };
@@ -505,6 +505,25 @@ declare function expandToolSetsAdditive(matchedNames: Set<string>, availableName
505
505
  * @param activeSetNames - Set names forced active regardless of score.
506
506
  */
507
507
  declare function activatedToolSetNames(scores: ReadonlyMap<string, number>, toolSets?: ToolSet[], activeSetNames?: ReadonlySet<string>): Set<string>;
508
+ /**
509
+ * Add the server-tool members of every set named in `activeToolSets` to a
510
+ * semantic server-tool selection.
511
+ *
512
+ * A semantic filter ranks only the latest prompt, so a terse follow-up inside a
513
+ * flow ("okay", "retry") drops the flow's server tools. This is the server-side
514
+ * half of what `autoFilterClientTools` does for client tools: an active set's
515
+ * members that are in the catalog are kept whatever the prompt scored, even
516
+ * below the short-prompt gate, where `selected` is empty. Exclusions tagged on
517
+ * the filter still win.
518
+ *
519
+ * @param selected - What the semantic filter picked (`[]` when it did not run).
520
+ * @param allServerTools - The full server-tool catalog.
521
+ * @param serverToolsFilter - The filter function, read only for its `excludeTools` tag.
522
+ * @param activeToolSets - Set names that are sticky for this conversation.
523
+ * @param extraToolSets - The caller's sets beyond {@link BUILT_IN_TOOL_SETS}.
524
+ * @returns `selected`, followed by any active-set members it was missing.
525
+ */
526
+ declare function withActiveToolSetServerTools(selected: ServerTool[], allServerTools: ServerTool[], serverToolsFilter: ServerToolsFilterFunction, activeToolSets?: readonly string[], extraToolSets?: readonly ToolSet[]): ServerTool[];
508
527
  /**
509
528
  * Collect the `systemPrompt` of every tool set that activated for a request,
510
529
  * for the caller to APPEND to its base system prompt.
@@ -679,6 +698,20 @@ interface SelectServerToolsForPromptOptions {
679
698
  * {@link resolveDeferredServerTools}). Omit/disabled → today's filtered selection.
680
699
  */
681
700
  deferLoading?: DeferLoadingConfig;
701
+ /**
702
+ * Tool-set names that are sticky for this conversation — the same list you
703
+ * pass to `useChatStorage`'s `activeToolSets`, e.g. from
704
+ * `deriveActiveToolSets`. With a filter function, the server-tool members of
705
+ * these sets are selected whatever the prompt scored, even on a prompt too
706
+ * short to embed. Omit for selection from the prompt alone.
707
+ */
708
+ activeToolSets?: string[];
709
+ /**
710
+ * The caller's sets beyond {@link BUILT_IN_TOOL_SETS} — the same list you pass
711
+ * to `useChatStorage`'s `extraToolSets` — so a custom set named in
712
+ * `activeToolSets` stays sticky here too.
713
+ */
714
+ extraToolSets?: ToolSet[];
682
715
  }
683
716
  /**
684
717
  * Select server-side tools for a prompt using the same path
@@ -1443,4 +1476,4 @@ declare function resolveServerTools(descriptor: ToolIntentDescriptor, catalog: S
1443
1476
  */
1444
1477
  declare function isCoercingIntent(creation: CreationIntent, catalog: ServerToolCatalog): boolean;
1445
1478
 
1446
- export { type AssembledToolsFilterFn, BUILT_IN_TOOL_SETS, CLIENT_TOOLS_MIN_SIMILARITY, CLIENT_TOOLS_RELEVANCE_RATIO, CREATION_INTENT_CLIENT_FACTORIES, CREATION_INTENT_CLIENT_FILTER, CREATION_INTENT_TOOL_SET, type CachedServerTools, type ClientFactoryBuilder, type ClientFactoryKey, type ClientToolsFilterMode, type ConnectorGuidance, type ConnectorGuidanceInput, type CouncilClientSelectionOptions, type CouncilClientToolsInput, type CreateServerToolsFilterOptions, type CreationIntent, DEFAULT_CACHE_EXPIRATION_MS, DEFAULT_EXCLUDED_SERVER_TOOLS, DEFAULT_SERVER_TOOLS_MATCH_OPTIONS, type DeferLoadingConfig, FULL_GENERATIVE_CLIENT_FACTORIES, MAX_CLIENT_TOOLS_AFTER_FILTER, MEMORY_SAVE_TOOL_NAME, MIN_CONTENT_LENGTH_FOR_TOOLS, type ParsedServerToolsResponse, type PostFilterKey, type ResolvePlanContext, SERVER_TOOL_DEPENDENCY_SETS, type SelectServerSideToolsOptions, type SelectServerToolsForPromptOptions, type SelectionLogger, type ServerTool, type ServerToolCatalog, type ServerToolCatalogEntry, type ServerToolsFilter, type ServerToolsFilterContext, type ServerToolsFilterFunction, type ServerToolsOptions, type ServerToolsResponse, TOOL_CATALOG, type ThinkingModeHint, type ToolActivationEvent, type ToolChoice, type ToolConfig, type ToolExecutor, type ToolIntentDescriptor, type ToolLane, type ToolMatchOptions, type ToolMatchResult, type ToolPlanSpec, type ToolSelectionAdapters, type ToolSet, type ToolsCacheBackend, activatedToolSetNames, applyToolSets, assembleClientTools, autoFilterClientTools, buildConnectorGuidance, buildDeniedToolsRider, clearServerToolsCache, composeCouncilClientTools, computeToolGuidance, createServerToolsFilter, defaultServerToolsFilter, deferFormattingConfig, deriveActiveToolSets, expandToolSetsAdditive, filterAssembledClientTools, filterServerTools, findMatchingTools, getCachedServerTools, getCatalogEntry, getMaxToolRounds, getServerTools, getThinkingMode, getToolDescription, getToolName, getToolsChecksum, isCoercingIntent, localStorageToolsCache, mergeActiveToolSets, mergeTools, resolveCouncilPlan, resolveCouncilServerTools, resolveDeferredServerTools, resolvePlan, resolveServerTools, resolveToolChoice, scoreTools, selectCouncilClientTools, selectServerSideTools, selectServerToolsForPrompt, shouldRefreshTools, stripCoercedMemoryWrite, toolSetSystemPrompts };
1479
+ export { type AssembledToolsFilterFn, BUILT_IN_TOOL_SETS, CLIENT_TOOLS_MIN_SIMILARITY, CLIENT_TOOLS_RELEVANCE_RATIO, CREATION_INTENT_CLIENT_FACTORIES, CREATION_INTENT_CLIENT_FILTER, CREATION_INTENT_TOOL_SET, type CachedServerTools, type ClientFactoryBuilder, type ClientFactoryKey, type ClientToolsFilterMode, type ConnectorGuidance, type ConnectorGuidanceInput, type CouncilClientSelectionOptions, type CouncilClientToolsInput, type CreateServerToolsFilterOptions, type CreationIntent, DEFAULT_CACHE_EXPIRATION_MS, DEFAULT_EXCLUDED_SERVER_TOOLS, DEFAULT_SERVER_TOOLS_MATCH_OPTIONS, type DeferLoadingConfig, FULL_GENERATIVE_CLIENT_FACTORIES, MAX_CLIENT_TOOLS_AFTER_FILTER, MEMORY_SAVE_TOOL_NAME, MIN_CONTENT_LENGTH_FOR_TOOLS, type ParsedServerToolsResponse, type PostFilterKey, type ResolvePlanContext, SERVER_TOOL_DEPENDENCY_SETS, type SelectServerSideToolsOptions, type SelectServerToolsForPromptOptions, type SelectionLogger, type ServerTool, type ServerToolCatalog, type ServerToolCatalogEntry, type ServerToolsFilter, type ServerToolsFilterContext, type ServerToolsFilterFunction, type ServerToolsOptions, type ServerToolsResponse, TOOL_CATALOG, type ThinkingModeHint, type ToolActivationEvent, type ToolChoice, type ToolConfig, type ToolExecutor, type ToolIntentDescriptor, type ToolLane, type ToolMatchOptions, type ToolMatchResult, type ToolPlanSpec, type ToolSelectionAdapters, type ToolSet, type ToolsCacheBackend, activatedToolSetNames, applyToolSets, assembleClientTools, autoFilterClientTools, buildConnectorGuidance, buildDeniedToolsRider, clearServerToolsCache, composeCouncilClientTools, computeToolGuidance, createServerToolsFilter, defaultServerToolsFilter, deferFormattingConfig, deriveActiveToolSets, expandToolSetsAdditive, filterAssembledClientTools, filterServerTools, findMatchingTools, getCachedServerTools, getCatalogEntry, getMaxToolRounds, getServerTools, getThinkingMode, getToolDescription, getToolName, getToolsChecksum, isCoercingIntent, localStorageToolsCache, mergeActiveToolSets, mergeTools, resolveCouncilPlan, resolveCouncilServerTools, resolveDeferredServerTools, resolvePlan, resolveServerTools, resolveToolChoice, scoreTools, selectCouncilClientTools, selectServerSideTools, selectServerToolsForPrompt, shouldRefreshTools, stripCoercedMemoryWrite, toolSetSystemPrompts, withActiveToolSetServerTools };
@@ -1872,6 +1872,23 @@ var BUILT_IN_TOOL_SETS = [
1872
1872
  members: ["dropbox_list_folders", "dropbox_get_file_content", "dropbox_search"],
1873
1873
  anchors: ["dropbox_list_folders", "dropbox_search"],
1874
1874
  anchorMinSimilarity: 0.53
1875
+ },
1876
+ {
1877
+ // Server tools, so this set does its work through
1878
+ // withActiveToolSetServerTools: once a restaurant tool has run, terse
1879
+ // follow-ups ("okay", "same as before") keep the booking chain. Each tool
1880
+ // still reaches a fresh booking request on its own description.
1881
+ // Anchors are deliberately empty (like the client's Nearby set): the set
1882
+ // is only for stickiness, not a new way to activate on a prompt.
1883
+ // prompt_user_confirm is left out of members: autoFilterClientTools always
1884
+ // sends it, and as a member any unrelated confirmation would pin this set.
1885
+ name: "restaurant-booking",
1886
+ members: [
1887
+ "AnumaPaymentsMCP-anuma_find_restaurant",
1888
+ "AnumaPaymentsMCP-anuma_check_restaurant_availability",
1889
+ "AnumaPaymentsMCP-anuma_book_restaurant"
1890
+ ],
1891
+ anchors: []
1875
1892
  }
1876
1893
  ];
1877
1894
  function applyToolSets(matchedNames, availableNames, scores, toolSets = BUILT_IN_TOOL_SETS, independentThreshold = 0.65) {
@@ -1934,6 +1951,16 @@ function activatedToolSetNames(scores, toolSets = BUILT_IN_TOOL_SETS, activeSetN
1934
1951
  }
1935
1952
  return activated;
1936
1953
  }
1954
+ function withActiveToolSetServerTools(selected, allServerTools, serverToolsFilter, activeToolSets = [], extraToolSets = []) {
1955
+ if (activeToolSets.length === 0) return selected;
1956
+ const sticky = new Set(
1957
+ [...BUILT_IN_TOOL_SETS, ...extraToolSets].filter((ts) => activeToolSets.includes(ts.name)).flatMap((ts) => ts.members)
1958
+ );
1959
+ for (const name of serverToolsFilter.excludeTools ?? []) sticky.delete(name);
1960
+ for (const tool of selected) sticky.delete(tool.name);
1961
+ const added = allServerTools.filter((tool) => sticky.has(tool.name));
1962
+ return added.length > 0 ? [...selected, ...added] : selected;
1963
+ }
1937
1964
  function toolSetSystemPrompts(selectedToolNames, toolSets = BUILT_IN_TOOL_SETS, activatedSetNames) {
1938
1965
  const selected = selectedToolNames instanceof Set ? selectedToolNames : new Set(selectedToolNames);
1939
1966
  const prompts = [];
@@ -2047,7 +2074,9 @@ async function selectServerToolsForPrompt(options) {
2047
2074
  embeddingModel,
2048
2075
  cacheExpirationMs,
2049
2076
  cache,
2050
- deferLoading
2077
+ deferLoading,
2078
+ activeToolSets,
2079
+ extraToolSets
2051
2080
  } = options;
2052
2081
  if (serverToolsFilter === void 0) return [];
2053
2082
  if (Array.isArray(serverToolsFilter) && serverToolsFilter.length === 0) return [];
@@ -2061,7 +2090,14 @@ async function selectServerToolsForPrompt(options) {
2061
2090
  if (deferLoading?.enabled)
2062
2091
  return resolveDeferredServerTools(allServerTools, serverToolsFilter, deferLoading);
2063
2092
  if (typeof serverToolsFilter === "function") {
2064
- if (prompt.length < MIN_CONTENT_LENGTH_FOR_TOOLS) return [];
2093
+ const withSticky = (selected) => withActiveToolSetServerTools(
2094
+ selected,
2095
+ allServerTools,
2096
+ serverToolsFilter,
2097
+ activeToolSets,
2098
+ extraToolSets
2099
+ );
2100
+ if (prompt.length < MIN_CONTENT_LENGTH_FOR_TOOLS) return withSticky([]);
2065
2101
  let promptEmbedding;
2066
2102
  try {
2067
2103
  promptEmbedding = await generateEmbedding(prompt, {
@@ -2070,10 +2106,10 @@ async function selectServerToolsForPrompt(options) {
2070
2106
  model: embeddingModel
2071
2107
  });
2072
2108
  } catch {
2073
- return [];
2109
+ return withSticky([]);
2074
2110
  }
2075
2111
  const names = serverToolsFilter(promptEmbedding, allServerTools);
2076
- return filterServerTools(allServerTools, names);
2112
+ return withSticky(filterServerTools(allServerTools, names));
2077
2113
  }
2078
2114
  return filterServerTools(allServerTools, serverToolsFilter);
2079
2115
  }
@@ -2714,5 +2750,6 @@ export {
2714
2750
  selectServerToolsForPrompt,
2715
2751
  shouldRefreshTools,
2716
2752
  stripCoercedMemoryWrite,
2717
- toolSetSystemPrompts
2753
+ toolSetSystemPrompts,
2754
+ withActiveToolSetServerTools
2718
2755
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anuma/sdk",
3
- "version": "6.27.9",
3
+ "version": "6.28.0",
4
4
  "description": "",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",