@anuma/sdk 6.31.0 → 6.31.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -23828,14 +23828,14 @@ async function autoFilterClientTools(clientTools, promptEmbeddings, cache, embed
23828
23828
  const alwaysInclude = clientTools.filter(isAlwaysIncluded);
23829
23829
  const filterCandidates = clientTools.filter((t) => !isAlwaysIncluded(t));
23830
23830
  if (filterCandidates.length === 0) {
23831
- return { tools: clientTools, activatedSetNames: /* @__PURE__ */ new Set() };
23831
+ return { tools: clientTools, activatedSetNames: /* @__PURE__ */ new Set(), matchedSetNames: /* @__PURE__ */ new Set() };
23832
23832
  }
23833
23833
  if (!promptEmbeddings && noEmbeddingsReason === "error") {
23834
- return { tools: clientTools, activatedSetNames: /* @__PURE__ */ new Set() };
23834
+ return { tools: clientTools, activatedSetNames: /* @__PURE__ */ new Set(), matchedSetNames: /* @__PURE__ */ new Set() };
23835
23835
  }
23836
23836
  if (!promptEmbeddings) {
23837
23837
  if (activeToolSets.length === 0) {
23838
- return { tools: [], activatedSetNames: /* @__PURE__ */ new Set() };
23838
+ return { tools: [], activatedSetNames: /* @__PURE__ */ new Set(), matchedSetNames: /* @__PURE__ */ new Set() };
23839
23839
  }
23840
23840
  const allSets = extraToolSets.length > 0 ? [...BUILT_IN_TOOL_SETS, ...extraToolSets] : BUILT_IN_TOOL_SETS;
23841
23841
  const activeSets = allSets.filter((s) => activeToolSets.includes(s.name));
@@ -23845,7 +23845,8 @@ async function autoFilterClientTools(clientTools, promptEmbeddings, cache, embed
23845
23845
  ...alwaysInclude,
23846
23846
  ...filterCandidates.filter((t) => stickyMembers.has(getToolName2(t)))
23847
23847
  ],
23848
- activatedSetNames: new Set(activeSets.map((s) => s.name))
23848
+ activatedSetNames: new Set(activeSets.map((s) => s.name)),
23849
+ matchedSetNames: /* @__PURE__ */ new Set()
23849
23850
  };
23850
23851
  }
23851
23852
  const toolsNeedingEmbeddings = [];
@@ -23863,7 +23864,7 @@ async function autoFilterClientTools(clientTools, promptEmbeddings, cache, embed
23863
23864
  cache.set(toolsNeedingEmbeddings[i].name, embeddings[i]);
23864
23865
  }
23865
23866
  } catch {
23866
- return { tools: clientTools, activatedSetNames: /* @__PURE__ */ new Set() };
23867
+ return { tools: clientTools, activatedSetNames: /* @__PURE__ */ new Set(), matchedSetNames: /* @__PURE__ */ new Set() };
23867
23868
  }
23868
23869
  }
23869
23870
  const pseudoServerTools = [];
@@ -23909,15 +23910,170 @@ async function autoFilterClientTools(clientTools, promptEmbeddings, cache, embed
23909
23910
  activeSetNames
23910
23911
  );
23911
23912
  const activatedSetNames = activatedToolSetNames(scores, toolSets, activeSetNames);
23913
+ const matchedSetNames = activatedToolSetNames(scores, toolSets);
23912
23914
  if (finalNames.size === 0) {
23913
- return { tools: alwaysInclude, activatedSetNames };
23915
+ return { tools: alwaysInclude, activatedSetNames, matchedSetNames };
23914
23916
  }
23915
23917
  const filtered = filterCandidates.filter((t) => {
23916
23918
  const name = getToolName2(t);
23917
23919
  return name && finalNames.has(name);
23918
23920
  });
23919
- return { tools: [...alwaysInclude, ...filtered], activatedSetNames };
23921
+ return { tools: [...alwaysInclude, ...filtered], activatedSetNames, matchedSetNames };
23922
+ }
23923
+
23924
+ // src/lib/tools/toolCatalog.ts
23925
+ var TOOL_CATALOG = {
23926
+ // Gmail (src/tools/gmail.ts)
23927
+ gmail_search_messages: { label: "Search emails", provider: "gmail", connector: "Gmail" },
23928
+ gmail_get_message: { label: "Read an email", provider: "gmail", connector: "Gmail" },
23929
+ gmail_create_draft: { label: "Draft a reply", provider: "gmail", connector: "Gmail" },
23930
+ gmail_send_message: { label: "Send an email", provider: "gmail", connector: "Gmail" },
23931
+ // Google Calendar (src/tools/googleCalendar.ts)
23932
+ google_calendar_list_events: {
23933
+ label: "Search calendar events",
23934
+ provider: "gcalendar",
23935
+ connector: "Calendar"
23936
+ },
23937
+ google_calendar_create_event: {
23938
+ label: "Create calendar event",
23939
+ provider: "gcalendar",
23940
+ connector: "Calendar"
23941
+ },
23942
+ google_calendar_update_event: {
23943
+ label: "Update calendar event",
23944
+ provider: "gcalendar",
23945
+ connector: "Calendar"
23946
+ },
23947
+ // Google Drive (src/tools/googleDrive.ts)
23948
+ google_drive_search: { label: "Search files", provider: "gdrive", connector: "Drive" },
23949
+ google_drive_list_recent: { label: "List recent files", provider: "gdrive", connector: "Drive" },
23950
+ google_drive_get_content: { label: "Read file content", provider: "gdrive", connector: "Drive" },
23951
+ google_drive_create_file: {
23952
+ label: "Create a file in Drive",
23953
+ provider: "gdrive",
23954
+ connector: "Drive"
23955
+ },
23956
+ google_drive_update_file: {
23957
+ label: "Update a Drive file",
23958
+ provider: "gdrive",
23959
+ connector: "Drive"
23960
+ },
23961
+ // Notion (src/tools/notion.ts)
23962
+ "notion-search": { label: "Search", provider: "notion", connector: "Notion" },
23963
+ "notion-fetch": { label: "Read page", provider: "notion", connector: "Notion" },
23964
+ "notion-create-pages": { label: "Create page", provider: "notion", connector: "Notion" },
23965
+ "notion-update-page": { label: "Update page", provider: "notion", connector: "Notion" },
23966
+ "notion-move-pages": { label: "Move pages", provider: "notion", connector: "Notion" },
23967
+ "notion-duplicate-page": { label: "Duplicate page", provider: "notion", connector: "Notion" },
23968
+ "notion-create-database": { label: "Create database", provider: "notion", connector: "Notion" },
23969
+ "notion-update-data-source": {
23970
+ label: "Update data source",
23971
+ provider: "notion",
23972
+ connector: "Notion"
23973
+ },
23974
+ "notion-create-comment": { label: "Add a comment", provider: "notion", connector: "Notion" },
23975
+ "notion-get-comments": { label: "Read comments", provider: "notion", connector: "Notion" },
23976
+ "notion-get-users": {
23977
+ label: "List workspace members",
23978
+ provider: "notion",
23979
+ connector: "Notion"
23980
+ },
23981
+ "notion-get-teams": { label: "List teamspaces", provider: "notion", connector: "Notion" },
23982
+ // GitHub (src/tools/github.ts)
23983
+ github_api: { label: "Use GitHub", provider: "github", connector: "GitHub" },
23984
+ github_get_authenticated_user: {
23985
+ label: "Read GitHub profile",
23986
+ provider: "github",
23987
+ connector: "GitHub"
23988
+ },
23989
+ // X / Twitter (src/tools/x.ts)
23990
+ x_get_me: { label: "Get my X profile", provider: "x", connector: "X" },
23991
+ x_get_my_posts: { label: "Read my recent posts", provider: "x", connector: "X" },
23992
+ // Dropbox (src/tools/dropbox.ts)
23993
+ dropbox_list_folders: { label: "List files", provider: "dropbox", connector: "Dropbox" },
23994
+ dropbox_get_file_content: {
23995
+ label: "Read file content",
23996
+ provider: "dropbox",
23997
+ connector: "Dropbox"
23998
+ },
23999
+ dropbox_search: { label: "Search files", provider: "dropbox", connector: "Dropbox" },
24000
+ // Slack (src/tools/slack.ts)
24001
+ slack_get_me: { label: "Get my Slack profile", provider: "slack", connector: "Slack" },
24002
+ slack_list_channels: { label: "List channels", provider: "slack", connector: "Slack" },
24003
+ slack_list_dms: { label: "List direct messages", provider: "slack", connector: "Slack" },
24004
+ slack_search_messages: { label: "Search messages", provider: "slack", connector: "Slack" },
24005
+ slack_list_users: { label: "List members", provider: "slack", connector: "Slack" },
24006
+ slack_get_channel_history: {
24007
+ label: "Read channel history",
24008
+ provider: "slack",
24009
+ connector: "Slack"
24010
+ },
24011
+ slack_get_thread_replies: {
24012
+ label: "Read thread replies",
24013
+ provider: "slack",
24014
+ connector: "Slack"
24015
+ },
24016
+ slack_post_message: { label: "Post a message", provider: "slack", connector: "Slack" }
24017
+ };
24018
+
24019
+ // src/lib/tools/selection/activeToolSets.ts
24020
+ function mergeActiveToolSets(current, derived) {
24021
+ if (derived.length === 0) return current;
24022
+ const merged = Array.from(/* @__PURE__ */ new Set([...current, ...derived]));
24023
+ return merged.length === current.length ? current : merged;
24024
+ }
24025
+
24026
+ // src/lib/tools/selection/recentToolSets.ts
24027
+ var RECENT_TOOL_SET_TURNS = 2;
24028
+ var RECENT_TOOL_SET_CONVERSATION_LIMIT = 50;
24029
+ var CARRYABLE_TOOL_SETS = new Set(
24030
+ BUILT_IN_TOOL_SETS.filter(
24031
+ (s) => s.anchors.length > 0 && s.anchors.every((a) => a in TOOL_CATALOG)
24032
+ ).map((s) => s.name)
24033
+ );
24034
+ var recentToolSets = /* @__PURE__ */ new WeakMap();
24035
+ function touch(conversations, conversationId) {
24036
+ const turns = conversations.get(conversationId);
24037
+ if (!turns) return void 0;
24038
+ conversations.delete(conversationId);
24039
+ conversations.set(conversationId, turns);
24040
+ return turns;
24041
+ }
24042
+ function carriedToolSets(database, conversationId) {
24043
+ if (!conversationId) return [];
24044
+ const conversations = recentToolSets.get(database);
24045
+ if (!conversations) return [];
24046
+ return [...touch(conversations, conversationId)?.keys() ?? []];
24047
+ }
24048
+ function recordToolSetTurn(database, conversationId, matched) {
24049
+ if (!conversationId) return;
24050
+ let conversations = recentToolSets.get(database);
24051
+ if (!conversations) {
24052
+ conversations = /* @__PURE__ */ new Map();
24053
+ recentToolSets.set(database, conversations);
24054
+ }
24055
+ const turns = touch(conversations, conversationId) ?? /* @__PURE__ */ new Map();
24056
+ for (const [name, left] of turns) {
24057
+ if (left > 1) turns.set(name, left - 1);
24058
+ else turns.delete(name);
24059
+ }
24060
+ for (const name of matched) {
24061
+ if (CARRYABLE_TOOL_SETS.has(name)) turns.set(name, RECENT_TOOL_SET_TURNS);
24062
+ }
24063
+ if (turns.size === 0) {
24064
+ conversations.delete(conversationId);
24065
+ return;
24066
+ }
24067
+ conversations.set(conversationId, turns);
24068
+ if (conversations.size > RECENT_TOOL_SET_CONVERSATION_LIMIT) {
24069
+ const oldest = conversations.keys().next().value;
24070
+ if (oldest !== void 0) conversations.delete(oldest);
24071
+ }
24072
+ }
24073
+ function resetRecentToolSets() {
24074
+ recentToolSets = /* @__PURE__ */ new WeakMap();
23920
24075
  }
24076
+ onClearAllEncryptionState(resetRecentToolSets);
23921
24077
 
23922
24078
  // src/react/useChatMedia.ts
23923
24079
  var import_react4 = require("react");
@@ -25350,6 +25506,8 @@ function useChatStorage(options) {
25350
25506
  }
25351
25507
  let filteredClientTools2 = clientTools;
25352
25508
  let clientActivatedSetNames2;
25509
+ let matchedToolSets2 = /* @__PURE__ */ new Set();
25510
+ const toolSetConversationId = explicitConversationId ?? currentConversationId;
25353
25511
  if (clientToolsFilter && clientTools?.length) {
25354
25512
  if (!skipStorageEmbeddingsFailed) {
25355
25513
  const clientToolNames = clientToolsFilter(skipStorageEmbeddings, clientTools);
@@ -25366,11 +25524,15 @@ function useChatStorage(options) {
25366
25524
  clientToolEmbeddingsCacheRef.current,
25367
25525
  { getToken, baseUrl, model: embeddingModel },
25368
25526
  extraToolSets,
25369
- activeToolSetsRef.current,
25527
+ mergeActiveToolSets(
25528
+ activeToolSetsRef.current ?? [],
25529
+ carriedToolSets(database, toolSetConversationId)
25530
+ ),
25370
25531
  skipStorageEmbeddingsFailed ? "error" : "short-prompt"
25371
25532
  );
25372
25533
  filteredClientTools2 = clientFilterResult.tools;
25373
25534
  clientActivatedSetNames2 = clientFilterResult.activatedSetNames;
25535
+ matchedToolSets2 = clientFilterResult.matchedSetNames;
25374
25536
  }
25375
25537
  if (filteredServerTools2.length > 0 || filteredClientTools2 && filteredClientTools2.length > 0) {
25376
25538
  mergedTools2 = mergeTools(
@@ -25425,6 +25587,7 @@ function useChatStorage(options) {
25425
25587
  error: result2.error || "Unknown error"
25426
25588
  };
25427
25589
  }
25590
+ recordToolSetTurn(database, toolSetConversationId, matchedToolSets2);
25428
25591
  const refreshResponse = result2.data;
25429
25592
  if (getToken) {
25430
25593
  Promise.resolve().then(
@@ -25805,6 +25968,7 @@ function useChatStorage(options) {
25805
25968
  }
25806
25969
  let filteredClientTools = clientTools;
25807
25970
  let clientActivatedSetNames;
25971
+ let matchedToolSets = /* @__PURE__ */ new Set();
25808
25972
  if (clientToolsFilter && clientTools?.length) {
25809
25973
  if (!userMessageEmbeddingsFailed) {
25810
25974
  const clientToolNames = clientToolsFilter(userMessageEmbeddings ?? null, clientTools);
@@ -25821,11 +25985,12 @@ function useChatStorage(options) {
25821
25985
  clientToolEmbeddingsCacheRef.current,
25822
25986
  { getToken, baseUrl, model: embeddingModel },
25823
25987
  extraToolSets,
25824
- activeToolSetsRef.current,
25988
+ mergeActiveToolSets(activeToolSetsRef.current ?? [], carriedToolSets(database, convId)),
25825
25989
  userMessageEmbeddingsFailed ? "error" : "short-prompt"
25826
25990
  );
25827
25991
  filteredClientTools = clientFilterResult.tools;
25828
25992
  clientActivatedSetNames = clientFilterResult.activatedSetNames;
25993
+ matchedToolSets = clientFilterResult.matchedSetNames;
25829
25994
  }
25830
25995
  if (!userMsgQueueId) {
25831
25996
  if (userMessageEmbeddings && autoEmbedMessages) {
@@ -25950,6 +26115,7 @@ function useChatStorage(options) {
25950
26115
  ],
25951
26116
  usage: void 0
25952
26117
  };
26118
+ recordToolSetTurn(database, convId, matchedToolSets);
25953
26119
  return {
25954
26120
  data: responseData2,
25955
26121
  error: null,
@@ -25987,6 +26153,7 @@ function useChatStorage(options) {
25987
26153
  userMessage: { ...storedUserMessage, error: errorMessage }
25988
26154
  };
25989
26155
  }
26156
+ recordToolSetTurn(database, convId, matchedToolSets);
25990
26157
  const responseData = result.data;
25991
26158
  let assistantContent = "";
25992
26159
  let thinkingContent;
@@ -11765,6 +11765,8 @@ declare function preprocessFiles(files: FileMetadata[] | undefined, options?: Pr
11765
11765
  * - Embedding generation hits the same `/embeddings` endpoint as the
11766
11766
  * real request; pass a shared `clientToolEmbeddingsCache` if you call
11767
11767
  * this repeatedly to avoid re-embedding tool descriptions.
11768
+ * - A real follow-up may also include connector tool sets carried from the
11769
+ * previous two turns of the conversation, which this preview does not model.
11768
11770
  */
11769
11771
  declare function previewToolSelection(options: {
11770
11772
  prompt: string;
@@ -11765,6 +11765,8 @@ declare function preprocessFiles(files: FileMetadata[] | undefined, options?: Pr
11765
11765
  * - Embedding generation hits the same `/embeddings` endpoint as the
11766
11766
  * real request; pass a shared `clientToolEmbeddingsCache` if you call
11767
11767
  * this repeatedly to avoid re-embedding tool descriptions.
11768
+ * - A real follow-up may also include connector tool sets carried from the
11769
+ * previous two turns of the conversation, which this preview does not model.
11768
11770
  */
11769
11771
  declare function previewToolSelection(options: {
11770
11772
  prompt: string;
@@ -21859,14 +21859,14 @@ async function autoFilterClientTools(clientTools, promptEmbeddings, cache, embed
21859
21859
  const alwaysInclude = clientTools.filter(isAlwaysIncluded);
21860
21860
  const filterCandidates = clientTools.filter((t) => !isAlwaysIncluded(t));
21861
21861
  if (filterCandidates.length === 0) {
21862
- return { tools: clientTools, activatedSetNames: /* @__PURE__ */ new Set() };
21862
+ return { tools: clientTools, activatedSetNames: /* @__PURE__ */ new Set(), matchedSetNames: /* @__PURE__ */ new Set() };
21863
21863
  }
21864
21864
  if (!promptEmbeddings && noEmbeddingsReason === "error") {
21865
- return { tools: clientTools, activatedSetNames: /* @__PURE__ */ new Set() };
21865
+ return { tools: clientTools, activatedSetNames: /* @__PURE__ */ new Set(), matchedSetNames: /* @__PURE__ */ new Set() };
21866
21866
  }
21867
21867
  if (!promptEmbeddings) {
21868
21868
  if (activeToolSets.length === 0) {
21869
- return { tools: [], activatedSetNames: /* @__PURE__ */ new Set() };
21869
+ return { tools: [], activatedSetNames: /* @__PURE__ */ new Set(), matchedSetNames: /* @__PURE__ */ new Set() };
21870
21870
  }
21871
21871
  const allSets = extraToolSets.length > 0 ? [...BUILT_IN_TOOL_SETS, ...extraToolSets] : BUILT_IN_TOOL_SETS;
21872
21872
  const activeSets = allSets.filter((s) => activeToolSets.includes(s.name));
@@ -21876,7 +21876,8 @@ async function autoFilterClientTools(clientTools, promptEmbeddings, cache, embed
21876
21876
  ...alwaysInclude,
21877
21877
  ...filterCandidates.filter((t) => stickyMembers.has(getToolName2(t)))
21878
21878
  ],
21879
- activatedSetNames: new Set(activeSets.map((s) => s.name))
21879
+ activatedSetNames: new Set(activeSets.map((s) => s.name)),
21880
+ matchedSetNames: /* @__PURE__ */ new Set()
21880
21881
  };
21881
21882
  }
21882
21883
  const toolsNeedingEmbeddings = [];
@@ -21894,7 +21895,7 @@ async function autoFilterClientTools(clientTools, promptEmbeddings, cache, embed
21894
21895
  cache.set(toolsNeedingEmbeddings[i].name, embeddings[i]);
21895
21896
  }
21896
21897
  } catch {
21897
- return { tools: clientTools, activatedSetNames: /* @__PURE__ */ new Set() };
21898
+ return { tools: clientTools, activatedSetNames: /* @__PURE__ */ new Set(), matchedSetNames: /* @__PURE__ */ new Set() };
21898
21899
  }
21899
21900
  }
21900
21901
  const pseudoServerTools = [];
@@ -21940,15 +21941,170 @@ async function autoFilterClientTools(clientTools, promptEmbeddings, cache, embed
21940
21941
  activeSetNames
21941
21942
  );
21942
21943
  const activatedSetNames = activatedToolSetNames(scores, toolSets, activeSetNames);
21944
+ const matchedSetNames = activatedToolSetNames(scores, toolSets);
21943
21945
  if (finalNames.size === 0) {
21944
- return { tools: alwaysInclude, activatedSetNames };
21946
+ return { tools: alwaysInclude, activatedSetNames, matchedSetNames };
21945
21947
  }
21946
21948
  const filtered = filterCandidates.filter((t) => {
21947
21949
  const name = getToolName2(t);
21948
21950
  return name && finalNames.has(name);
21949
21951
  });
21950
- return { tools: [...alwaysInclude, ...filtered], activatedSetNames };
21952
+ return { tools: [...alwaysInclude, ...filtered], activatedSetNames, matchedSetNames };
21953
+ }
21954
+
21955
+ // src/lib/tools/toolCatalog.ts
21956
+ var TOOL_CATALOG = {
21957
+ // Gmail (src/tools/gmail.ts)
21958
+ gmail_search_messages: { label: "Search emails", provider: "gmail", connector: "Gmail" },
21959
+ gmail_get_message: { label: "Read an email", provider: "gmail", connector: "Gmail" },
21960
+ gmail_create_draft: { label: "Draft a reply", provider: "gmail", connector: "Gmail" },
21961
+ gmail_send_message: { label: "Send an email", provider: "gmail", connector: "Gmail" },
21962
+ // Google Calendar (src/tools/googleCalendar.ts)
21963
+ google_calendar_list_events: {
21964
+ label: "Search calendar events",
21965
+ provider: "gcalendar",
21966
+ connector: "Calendar"
21967
+ },
21968
+ google_calendar_create_event: {
21969
+ label: "Create calendar event",
21970
+ provider: "gcalendar",
21971
+ connector: "Calendar"
21972
+ },
21973
+ google_calendar_update_event: {
21974
+ label: "Update calendar event",
21975
+ provider: "gcalendar",
21976
+ connector: "Calendar"
21977
+ },
21978
+ // Google Drive (src/tools/googleDrive.ts)
21979
+ google_drive_search: { label: "Search files", provider: "gdrive", connector: "Drive" },
21980
+ google_drive_list_recent: { label: "List recent files", provider: "gdrive", connector: "Drive" },
21981
+ google_drive_get_content: { label: "Read file content", provider: "gdrive", connector: "Drive" },
21982
+ google_drive_create_file: {
21983
+ label: "Create a file in Drive",
21984
+ provider: "gdrive",
21985
+ connector: "Drive"
21986
+ },
21987
+ google_drive_update_file: {
21988
+ label: "Update a Drive file",
21989
+ provider: "gdrive",
21990
+ connector: "Drive"
21991
+ },
21992
+ // Notion (src/tools/notion.ts)
21993
+ "notion-search": { label: "Search", provider: "notion", connector: "Notion" },
21994
+ "notion-fetch": { label: "Read page", provider: "notion", connector: "Notion" },
21995
+ "notion-create-pages": { label: "Create page", provider: "notion", connector: "Notion" },
21996
+ "notion-update-page": { label: "Update page", provider: "notion", connector: "Notion" },
21997
+ "notion-move-pages": { label: "Move pages", provider: "notion", connector: "Notion" },
21998
+ "notion-duplicate-page": { label: "Duplicate page", provider: "notion", connector: "Notion" },
21999
+ "notion-create-database": { label: "Create database", provider: "notion", connector: "Notion" },
22000
+ "notion-update-data-source": {
22001
+ label: "Update data source",
22002
+ provider: "notion",
22003
+ connector: "Notion"
22004
+ },
22005
+ "notion-create-comment": { label: "Add a comment", provider: "notion", connector: "Notion" },
22006
+ "notion-get-comments": { label: "Read comments", provider: "notion", connector: "Notion" },
22007
+ "notion-get-users": {
22008
+ label: "List workspace members",
22009
+ provider: "notion",
22010
+ connector: "Notion"
22011
+ },
22012
+ "notion-get-teams": { label: "List teamspaces", provider: "notion", connector: "Notion" },
22013
+ // GitHub (src/tools/github.ts)
22014
+ github_api: { label: "Use GitHub", provider: "github", connector: "GitHub" },
22015
+ github_get_authenticated_user: {
22016
+ label: "Read GitHub profile",
22017
+ provider: "github",
22018
+ connector: "GitHub"
22019
+ },
22020
+ // X / Twitter (src/tools/x.ts)
22021
+ x_get_me: { label: "Get my X profile", provider: "x", connector: "X" },
22022
+ x_get_my_posts: { label: "Read my recent posts", provider: "x", connector: "X" },
22023
+ // Dropbox (src/tools/dropbox.ts)
22024
+ dropbox_list_folders: { label: "List files", provider: "dropbox", connector: "Dropbox" },
22025
+ dropbox_get_file_content: {
22026
+ label: "Read file content",
22027
+ provider: "dropbox",
22028
+ connector: "Dropbox"
22029
+ },
22030
+ dropbox_search: { label: "Search files", provider: "dropbox", connector: "Dropbox" },
22031
+ // Slack (src/tools/slack.ts)
22032
+ slack_get_me: { label: "Get my Slack profile", provider: "slack", connector: "Slack" },
22033
+ slack_list_channels: { label: "List channels", provider: "slack", connector: "Slack" },
22034
+ slack_list_dms: { label: "List direct messages", provider: "slack", connector: "Slack" },
22035
+ slack_search_messages: { label: "Search messages", provider: "slack", connector: "Slack" },
22036
+ slack_list_users: { label: "List members", provider: "slack", connector: "Slack" },
22037
+ slack_get_channel_history: {
22038
+ label: "Read channel history",
22039
+ provider: "slack",
22040
+ connector: "Slack"
22041
+ },
22042
+ slack_get_thread_replies: {
22043
+ label: "Read thread replies",
22044
+ provider: "slack",
22045
+ connector: "Slack"
22046
+ },
22047
+ slack_post_message: { label: "Post a message", provider: "slack", connector: "Slack" }
22048
+ };
22049
+
22050
+ // src/lib/tools/selection/activeToolSets.ts
22051
+ function mergeActiveToolSets(current, derived) {
22052
+ if (derived.length === 0) return current;
22053
+ const merged = Array.from(/* @__PURE__ */ new Set([...current, ...derived]));
22054
+ return merged.length === current.length ? current : merged;
22055
+ }
22056
+
22057
+ // src/lib/tools/selection/recentToolSets.ts
22058
+ var RECENT_TOOL_SET_TURNS = 2;
22059
+ var RECENT_TOOL_SET_CONVERSATION_LIMIT = 50;
22060
+ var CARRYABLE_TOOL_SETS = new Set(
22061
+ BUILT_IN_TOOL_SETS.filter(
22062
+ (s) => s.anchors.length > 0 && s.anchors.every((a) => a in TOOL_CATALOG)
22063
+ ).map((s) => s.name)
22064
+ );
22065
+ var recentToolSets = /* @__PURE__ */ new WeakMap();
22066
+ function touch(conversations, conversationId) {
22067
+ const turns = conversations.get(conversationId);
22068
+ if (!turns) return void 0;
22069
+ conversations.delete(conversationId);
22070
+ conversations.set(conversationId, turns);
22071
+ return turns;
22072
+ }
22073
+ function carriedToolSets(database, conversationId) {
22074
+ if (!conversationId) return [];
22075
+ const conversations = recentToolSets.get(database);
22076
+ if (!conversations) return [];
22077
+ return [...touch(conversations, conversationId)?.keys() ?? []];
22078
+ }
22079
+ function recordToolSetTurn(database, conversationId, matched) {
22080
+ if (!conversationId) return;
22081
+ let conversations = recentToolSets.get(database);
22082
+ if (!conversations) {
22083
+ conversations = /* @__PURE__ */ new Map();
22084
+ recentToolSets.set(database, conversations);
22085
+ }
22086
+ const turns = touch(conversations, conversationId) ?? /* @__PURE__ */ new Map();
22087
+ for (const [name, left] of turns) {
22088
+ if (left > 1) turns.set(name, left - 1);
22089
+ else turns.delete(name);
22090
+ }
22091
+ for (const name of matched) {
22092
+ if (CARRYABLE_TOOL_SETS.has(name)) turns.set(name, RECENT_TOOL_SET_TURNS);
22093
+ }
22094
+ if (turns.size === 0) {
22095
+ conversations.delete(conversationId);
22096
+ return;
22097
+ }
22098
+ conversations.set(conversationId, turns);
22099
+ if (conversations.size > RECENT_TOOL_SET_CONVERSATION_LIMIT) {
22100
+ const oldest = conversations.keys().next().value;
22101
+ if (oldest !== void 0) conversations.delete(oldest);
22102
+ }
22103
+ }
22104
+ function resetRecentToolSets() {
22105
+ recentToolSets = /* @__PURE__ */ new WeakMap();
21951
22106
  }
22107
+ onClearAllEncryptionState(resetRecentToolSets);
21952
22108
 
21953
22109
  // src/react/useChatMedia.ts
21954
22110
  import { useCallback as useCallback3 } from "react";
@@ -23380,6 +23536,8 @@ function useChatStorage(options) {
23380
23536
  }
23381
23537
  let filteredClientTools2 = clientTools;
23382
23538
  let clientActivatedSetNames2;
23539
+ let matchedToolSets2 = /* @__PURE__ */ new Set();
23540
+ const toolSetConversationId = explicitConversationId ?? currentConversationId;
23383
23541
  if (clientToolsFilter && clientTools?.length) {
23384
23542
  if (!skipStorageEmbeddingsFailed) {
23385
23543
  const clientToolNames = clientToolsFilter(skipStorageEmbeddings, clientTools);
@@ -23396,11 +23554,15 @@ function useChatStorage(options) {
23396
23554
  clientToolEmbeddingsCacheRef.current,
23397
23555
  { getToken, baseUrl, model: embeddingModel },
23398
23556
  extraToolSets,
23399
- activeToolSetsRef.current,
23557
+ mergeActiveToolSets(
23558
+ activeToolSetsRef.current ?? [],
23559
+ carriedToolSets(database, toolSetConversationId)
23560
+ ),
23400
23561
  skipStorageEmbeddingsFailed ? "error" : "short-prompt"
23401
23562
  );
23402
23563
  filteredClientTools2 = clientFilterResult.tools;
23403
23564
  clientActivatedSetNames2 = clientFilterResult.activatedSetNames;
23565
+ matchedToolSets2 = clientFilterResult.matchedSetNames;
23404
23566
  }
23405
23567
  if (filteredServerTools2.length > 0 || filteredClientTools2 && filteredClientTools2.length > 0) {
23406
23568
  mergedTools2 = mergeTools(
@@ -23455,6 +23617,7 @@ function useChatStorage(options) {
23455
23617
  error: result2.error || "Unknown error"
23456
23618
  };
23457
23619
  }
23620
+ recordToolSetTurn(database, toolSetConversationId, matchedToolSets2);
23458
23621
  const refreshResponse = result2.data;
23459
23622
  if (getToken) {
23460
23623
  Promise.resolve().then(
@@ -23835,6 +23998,7 @@ function useChatStorage(options) {
23835
23998
  }
23836
23999
  let filteredClientTools = clientTools;
23837
24000
  let clientActivatedSetNames;
24001
+ let matchedToolSets = /* @__PURE__ */ new Set();
23838
24002
  if (clientToolsFilter && clientTools?.length) {
23839
24003
  if (!userMessageEmbeddingsFailed) {
23840
24004
  const clientToolNames = clientToolsFilter(userMessageEmbeddings ?? null, clientTools);
@@ -23851,11 +24015,12 @@ function useChatStorage(options) {
23851
24015
  clientToolEmbeddingsCacheRef.current,
23852
24016
  { getToken, baseUrl, model: embeddingModel },
23853
24017
  extraToolSets,
23854
- activeToolSetsRef.current,
24018
+ mergeActiveToolSets(activeToolSetsRef.current ?? [], carriedToolSets(database, convId)),
23855
24019
  userMessageEmbeddingsFailed ? "error" : "short-prompt"
23856
24020
  );
23857
24021
  filteredClientTools = clientFilterResult.tools;
23858
24022
  clientActivatedSetNames = clientFilterResult.activatedSetNames;
24023
+ matchedToolSets = clientFilterResult.matchedSetNames;
23859
24024
  }
23860
24025
  if (!userMsgQueueId) {
23861
24026
  if (userMessageEmbeddings && autoEmbedMessages) {
@@ -23980,6 +24145,7 @@ function useChatStorage(options) {
23980
24145
  ],
23981
24146
  usage: void 0
23982
24147
  };
24148
+ recordToolSetTurn(database, convId, matchedToolSets);
23983
24149
  return {
23984
24150
  data: responseData2,
23985
24151
  error: null,
@@ -24017,6 +24183,7 @@ function useChatStorage(options) {
24017
24183
  userMessage: { ...storedUserMessage, error: errorMessage }
24018
24184
  };
24019
24185
  }
24186
+ recordToolSetTurn(database, convId, matchedToolSets);
24020
24187
  const responseData = result.data;
24021
24188
  let assistantContent = "";
24022
24189
  let thinkingContent;
@@ -2383,14 +2383,14 @@ async function autoFilterClientTools(clientTools, promptEmbeddings, cache, embed
2383
2383
  const alwaysInclude = clientTools.filter(isAlwaysIncluded);
2384
2384
  const filterCandidates = clientTools.filter((t) => !isAlwaysIncluded(t));
2385
2385
  if (filterCandidates.length === 0) {
2386
- return { tools: clientTools, activatedSetNames: /* @__PURE__ */ new Set() };
2386
+ return { tools: clientTools, activatedSetNames: /* @__PURE__ */ new Set(), matchedSetNames: /* @__PURE__ */ new Set() };
2387
2387
  }
2388
2388
  if (!promptEmbeddings && noEmbeddingsReason === "error") {
2389
- return { tools: clientTools, activatedSetNames: /* @__PURE__ */ new Set() };
2389
+ return { tools: clientTools, activatedSetNames: /* @__PURE__ */ new Set(), matchedSetNames: /* @__PURE__ */ new Set() };
2390
2390
  }
2391
2391
  if (!promptEmbeddings) {
2392
2392
  if (activeToolSets.length === 0) {
2393
- return { tools: [], activatedSetNames: /* @__PURE__ */ new Set() };
2393
+ return { tools: [], activatedSetNames: /* @__PURE__ */ new Set(), matchedSetNames: /* @__PURE__ */ new Set() };
2394
2394
  }
2395
2395
  const allSets = extraToolSets.length > 0 ? [...BUILT_IN_TOOL_SETS, ...extraToolSets] : BUILT_IN_TOOL_SETS;
2396
2396
  const activeSets = allSets.filter((s) => activeToolSets.includes(s.name));
@@ -2400,7 +2400,8 @@ async function autoFilterClientTools(clientTools, promptEmbeddings, cache, embed
2400
2400
  ...alwaysInclude,
2401
2401
  ...filterCandidates.filter((t) => stickyMembers.has(getToolName(t)))
2402
2402
  ],
2403
- activatedSetNames: new Set(activeSets.map((s) => s.name))
2403
+ activatedSetNames: new Set(activeSets.map((s) => s.name)),
2404
+ matchedSetNames: /* @__PURE__ */ new Set()
2404
2405
  };
2405
2406
  }
2406
2407
  const toolsNeedingEmbeddings = [];
@@ -2418,7 +2419,7 @@ async function autoFilterClientTools(clientTools, promptEmbeddings, cache, embed
2418
2419
  cache.set(toolsNeedingEmbeddings[i].name, embeddings[i]);
2419
2420
  }
2420
2421
  } catch {
2421
- return { tools: clientTools, activatedSetNames: /* @__PURE__ */ new Set() };
2422
+ return { tools: clientTools, activatedSetNames: /* @__PURE__ */ new Set(), matchedSetNames: /* @__PURE__ */ new Set() };
2422
2423
  }
2423
2424
  }
2424
2425
  const pseudoServerTools = [];
@@ -2464,14 +2465,15 @@ async function autoFilterClientTools(clientTools, promptEmbeddings, cache, embed
2464
2465
  activeSetNames
2465
2466
  );
2466
2467
  const activatedSetNames = activatedToolSetNames(scores, toolSets, activeSetNames);
2468
+ const matchedSetNames = activatedToolSetNames(scores, toolSets);
2467
2469
  if (finalNames.size === 0) {
2468
- return { tools: alwaysInclude, activatedSetNames };
2470
+ return { tools: alwaysInclude, activatedSetNames, matchedSetNames };
2469
2471
  }
2470
2472
  const filtered = filterCandidates.filter((t) => {
2471
2473
  const name = getToolName(t);
2472
2474
  return name && finalNames.has(name);
2473
2475
  });
2474
- return { tools: [...alwaysInclude, ...filtered], activatedSetNames };
2476
+ return { tools: [...alwaysInclude, ...filtered], activatedSetNames, matchedSetNames };
2475
2477
  }
2476
2478
 
2477
2479
  // src/lib/tools/toolCatalog.ts
@@ -846,6 +846,9 @@ declare function computeToolGuidance(selectedServerTools: ServerTool[], selected
846
846
  * definitions that eat up the context window.
847
847
  *
848
848
  * @returns Filtered client tools, or the original array if filtering fails/skips.
849
+ * `activatedSetNames` is every set that activated, forced ones included.
850
+ * `matchedSetNames` is only the sets whose anchors cleared their floor on THIS
851
+ * prompt, ignoring `activeToolSets`; it is empty whenever no scoring ran.
849
852
  */
850
853
  declare function autoFilterClientTools(clientTools: LlmapiChatCompletionTool[], promptEmbeddings: number[] | number[][] | null, cache: Map<string, number[]>, embeddingOptions: {
851
854
  getToken?: () => Promise<string | null>;
@@ -862,6 +865,7 @@ declare function autoFilterClientTools(clientTools: LlmapiChatCompletionTool[],
862
865
  noEmbeddingsReason?: "short-prompt" | "error"): Promise<{
863
866
  tools: LlmapiChatCompletionTool[];
864
867
  activatedSetNames?: ReadonlySet<string>;
868
+ matchedSetNames: ReadonlySet<string>;
865
869
  }>;
866
870
 
867
871
  /**
@@ -846,6 +846,9 @@ declare function computeToolGuidance(selectedServerTools: ServerTool[], selected
846
846
  * definitions that eat up the context window.
847
847
  *
848
848
  * @returns Filtered client tools, or the original array if filtering fails/skips.
849
+ * `activatedSetNames` is every set that activated, forced ones included.
850
+ * `matchedSetNames` is only the sets whose anchors cleared their floor on THIS
851
+ * prompt, ignoring `activeToolSets`; it is empty whenever no scoring ran.
849
852
  */
850
853
  declare function autoFilterClientTools(clientTools: LlmapiChatCompletionTool[], promptEmbeddings: number[] | number[][] | null, cache: Map<string, number[]>, embeddingOptions: {
851
854
  getToken?: () => Promise<string | null>;
@@ -862,6 +865,7 @@ declare function autoFilterClientTools(clientTools: LlmapiChatCompletionTool[],
862
865
  noEmbeddingsReason?: "short-prompt" | "error"): Promise<{
863
866
  tools: LlmapiChatCompletionTool[];
864
867
  activatedSetNames?: ReadonlySet<string>;
868
+ matchedSetNames: ReadonlySet<string>;
865
869
  }>;
866
870
 
867
871
  /**