@anuma/sdk 6.33.1 → 6.34.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.
- package/dist/design/index.cjs +0 -2
- package/dist/design/index.d.mts +0 -7
- package/dist/design/index.d.ts +0 -7
- package/dist/design/index.mjs +0 -2
- package/dist/expo/{chunk-XD6WOQ5I.mjs → chunk-GQBTAM6Y.mjs} +0 -70
- package/dist/expo/{consolidate-7DBUHQRK.mjs → consolidate-3H2WY3FU.mjs} +1 -8
- package/dist/expo/index.cjs +15947 -16025
- package/dist/expo/index.d.mts +5934 -6646
- package/dist/expo/index.d.ts +5934 -6646
- package/dist/expo/index.mjs +15996 -15997
- package/dist/index.cjs +2289 -2430
- package/dist/index.d.mts +914 -1054
- package/dist/index.d.ts +914 -1054
- package/dist/index.mjs +2290 -2429
- package/dist/memory/context.d.mts +0 -73
- package/dist/memory/context.d.ts +0 -73
- package/dist/next/index.cjs +1 -8
- package/dist/next/index.mjs +1 -8
- package/dist/pii/transformers.d.mts +0 -32
- package/dist/pii/transformers.d.ts +0 -32
- package/dist/react/{chunk-XNQRJBIH.mjs → chunk-UFO4W3JX.mjs} +0 -70
- package/dist/react/{consolidate-5DVINCUE.mjs → consolidate-RHIAUBT4.mjs} +1 -8
- package/dist/react/index.cjs +33267 -33441
- package/dist/react/index.d.mts +13598 -14550
- package/dist/react/index.d.ts +13598 -14550
- package/dist/react/index.mjs +32920 -33019
- package/dist/server/{chunk-KSYV7UO2.mjs → chunk-4RGGAOAJ.mjs} +835 -905
- package/dist/server/{consolidate-MCNBSUXD.mjs → consolidate-YEGACWLR.mjs} +1 -8
- package/dist/server/index.cjs +22357 -23132
- package/dist/server/index.d.mts +7895 -8768
- package/dist/server/index.d.ts +7895 -8768
- package/dist/server/index.mjs +20548 -21258
- package/dist/telemetry/index.cjs +0 -9
- package/dist/telemetry/index.d.mts +86 -197
- package/dist/telemetry/index.d.ts +86 -197
- package/dist/telemetry/index.mjs +0 -9
- package/dist/tools/index.cjs +13036 -13347
- package/dist/tools/index.d.mts +2434 -2729
- package/dist/tools/index.d.ts +2434 -2729
- package/dist/tools/index.mjs +13036 -13347
- package/dist/tools/selection/index.cjs +18 -122
- package/dist/tools/selection/index.d.mts +0 -159
- package/dist/tools/selection/index.d.ts +0 -159
- package/dist/tools/selection/index.mjs +18 -122
- package/package.json +1 -1
|
@@ -1025,8 +1025,6 @@ async function embedOne(text, options, outer) {
|
|
|
1025
1025
|
(signal) => postApiV1Embeddings({
|
|
1026
1026
|
baseUrl,
|
|
1027
1027
|
body: {
|
|
1028
|
-
// Mask PII from the request body only — the cache above still keys on
|
|
1029
|
-
// the original `text`, so callers keep their original values.
|
|
1030
1028
|
input: options.maskInput ? options.maskInput(text) : text,
|
|
1031
1029
|
model: model ?? DEFAULT_API_EMBEDDING_MODEL
|
|
1032
1030
|
},
|
|
@@ -1060,19 +1058,20 @@ async function embedOne(text, options, outer) {
|
|
|
1060
1058
|
}
|
|
1061
1059
|
var DEFAULT_EMBEDDING_BATCH_SIZE = 100;
|
|
1062
1060
|
var DEFAULT_EMBEDDING_BATCH_CONCURRENCY = 3;
|
|
1063
|
-
async function generateEmbeddingsBatch(texts, headers, baseUrl, model, onUsage, maskInput, timeoutMs) {
|
|
1061
|
+
async function generateEmbeddingsBatch(texts, headers, baseUrl, model, onUsage, maskInput, timeoutMs, outer) {
|
|
1064
1062
|
const response = await withEmbeddingRetry(
|
|
1065
1063
|
() => withDeadline(
|
|
1066
1064
|
(signal) => postApiV1Embeddings({
|
|
1067
1065
|
baseUrl,
|
|
1068
|
-
// Mask PII from the request body only; cache/order still key on originals.
|
|
1069
1066
|
body: { input: maskInput ? texts.map(maskInput) : texts, model },
|
|
1070
1067
|
headers,
|
|
1071
1068
|
...signal && { signal }
|
|
1072
1069
|
}),
|
|
1073
1070
|
timeoutMs,
|
|
1074
|
-
"embedding batch request"
|
|
1075
|
-
|
|
1071
|
+
"embedding batch request",
|
|
1072
|
+
outer
|
|
1073
|
+
),
|
|
1074
|
+
outer
|
|
1076
1075
|
);
|
|
1077
1076
|
if (response.error) {
|
|
1078
1077
|
throw embeddingErrorFrom(response);
|
|
@@ -1090,6 +1089,11 @@ async function generateEmbeddingsBatch(texts, headers, baseUrl, model, onUsage,
|
|
|
1090
1089
|
}
|
|
1091
1090
|
async function generateEmbeddings(texts, options) {
|
|
1092
1091
|
if (texts.length === 0) return [];
|
|
1092
|
+
const total = options.totalTimeoutMs;
|
|
1093
|
+
if (total === void 0) return embedMany(texts, options, void 0);
|
|
1094
|
+
return withDeadline((signal) => embedMany(texts, options, signal), total, "embedding batch");
|
|
1095
|
+
}
|
|
1096
|
+
async function embedMany(texts, options, outer) {
|
|
1093
1097
|
const { baseUrl = BASE_URL, model, batchSize, cache } = options;
|
|
1094
1098
|
const timeoutMs = options.timeoutMs ?? DEFAULT_EMBEDDING_REQUEST_TIMEOUT_MS;
|
|
1095
1099
|
const chunkSize = batchSize ?? DEFAULT_EMBEDDING_BATCH_SIZE;
|
|
@@ -1110,7 +1114,8 @@ async function generateEmbeddings(texts, options) {
|
|
|
1110
1114
|
if (uncachedTexts.length === 0) {
|
|
1111
1115
|
return results;
|
|
1112
1116
|
}
|
|
1113
|
-
const headers = await resolveAuthHeaders(options);
|
|
1117
|
+
const headers = await resolveAuthHeaders(options, outer);
|
|
1118
|
+
if (outer?.aborted) throw outer.reason;
|
|
1114
1119
|
const embeddingModel = model ?? DEFAULT_API_EMBEDDING_MODEL;
|
|
1115
1120
|
let newEmbeddings;
|
|
1116
1121
|
if (uncachedTexts.length <= chunkSize) {
|
|
@@ -1121,7 +1126,8 @@ async function generateEmbeddings(texts, options) {
|
|
|
1121
1126
|
embeddingModel,
|
|
1122
1127
|
options.onUsage,
|
|
1123
1128
|
options.maskInput,
|
|
1124
|
-
timeoutMs
|
|
1129
|
+
timeoutMs,
|
|
1130
|
+
outer
|
|
1125
1131
|
);
|
|
1126
1132
|
} else {
|
|
1127
1133
|
const chunks = [];
|
|
@@ -1132,6 +1138,7 @@ async function generateEmbeddings(texts, options) {
|
|
|
1132
1138
|
let nextIndex = 0;
|
|
1133
1139
|
const worker = async () => {
|
|
1134
1140
|
while (nextIndex < chunks.length) {
|
|
1141
|
+
if (outer?.aborted) throw outer.reason;
|
|
1135
1142
|
const idx = nextIndex++;
|
|
1136
1143
|
allEmbeddings[idx] = await generateEmbeddingsBatch(
|
|
1137
1144
|
chunks[idx],
|
|
@@ -1140,7 +1147,8 @@ async function generateEmbeddings(texts, options) {
|
|
|
1140
1147
|
embeddingModel,
|
|
1141
1148
|
options.onUsage,
|
|
1142
1149
|
options.maskInput,
|
|
1143
|
-
timeoutMs
|
|
1150
|
+
timeoutMs,
|
|
1151
|
+
outer
|
|
1144
1152
|
);
|
|
1145
1153
|
}
|
|
1146
1154
|
};
|
|
@@ -1151,6 +1159,7 @@ async function generateEmbeddings(texts, options) {
|
|
|
1151
1159
|
await Promise.all(workers);
|
|
1152
1160
|
newEmbeddings = allEmbeddings.flat();
|
|
1153
1161
|
}
|
|
1162
|
+
if (outer?.aborted) throw outer.reason;
|
|
1154
1163
|
for (let i = 0; i < uncachedIndices.length; i++) {
|
|
1155
1164
|
const f32Embedding = Float32Array.from(newEmbeddings[i]);
|
|
1156
1165
|
results[uncachedIndices[i]] = Array.from(f32Embedding);
|
|
@@ -1668,9 +1677,7 @@ function clientToolToResponsesFormat(tool) {
|
|
|
1668
1677
|
type: "function",
|
|
1669
1678
|
name: func.name,
|
|
1670
1679
|
description: func.description,
|
|
1671
|
-
// Handle both 'parameters' and 'arguments' field names
|
|
1672
1680
|
parameters: func.parameters ?? func.arguments,
|
|
1673
|
-
// Preserve executor functions for client-side execution
|
|
1674
1681
|
...toolConfig.executor && { executor: toolConfig.executor },
|
|
1675
1682
|
...toolConfig.skipContinuation !== void 0 && {
|
|
1676
1683
|
skipContinuation: toolConfig.skipContinuation
|
|
@@ -1706,7 +1713,6 @@ function clientToolToCompletionsFormat(tool) {
|
|
|
1706
1713
|
...restFunc,
|
|
1707
1714
|
parameters: args ?? { type: "object", properties: {} }
|
|
1708
1715
|
},
|
|
1709
|
-
// Preserve executor functions for client-side execution
|
|
1710
1716
|
...toolConfig.executor && { executor: toolConfig.executor },
|
|
1711
1717
|
...toolConfig.skipContinuation !== void 0 && {
|
|
1712
1718
|
skipContinuation: toolConfig.skipContinuation
|
|
@@ -1869,17 +1875,7 @@ function scoreTools(promptEmbeddings, tools) {
|
|
|
1869
1875
|
var BUILT_IN_TOOL_SETS = [
|
|
1870
1876
|
{
|
|
1871
1877
|
name: "app-generation",
|
|
1872
|
-
// Appended to the base prompt (not replacing it) whenever this set
|
|
1873
|
-
// activates, so the App Builder guidance — including the window.app.complete
|
|
1874
|
-
// runtime-AI contract — rides in with the app-gen tools via the same
|
|
1875
|
-
// semantic selection that includes them. Collected by toolSetSystemPrompts.
|
|
1876
1878
|
systemPrompt: APP_BUILDER_PROMPT,
|
|
1877
|
-
// Must stay in sync with APP_FILE_TOOL_NAMES in src/tools/appGeneration.ts.
|
|
1878
|
-
// If a new app-gen tool ships there but isn't added here, semantic
|
|
1879
|
-
// selection will exclude it on every request — the model literally
|
|
1880
|
-
// doesn't see it. The quality tools (audit_design / critique_design /
|
|
1881
|
-
// verify_app) are non-obvious to a user prompt ("build me a kanban")
|
|
1882
|
-
// and rely entirely on set expansion to reach the model.
|
|
1883
1879
|
members: [
|
|
1884
1880
|
"create_file",
|
|
1885
1881
|
"patch_file",
|
|
@@ -1890,52 +1886,20 @@ var BUILT_IN_TOOL_SETS = [
|
|
|
1890
1886
|
"critique_design",
|
|
1891
1887
|
"verify_app"
|
|
1892
1888
|
],
|
|
1893
|
-
// Anchors stay limited to the primary entry-point tools. Users phrase
|
|
1894
|
-
// app intent as "build / make / fix" → semantic match on create_file
|
|
1895
|
-
// or patch_file → full set pulled in. The quality tools fire later in
|
|
1896
|
-
// the workflow and don't anchor on their own; including them as
|
|
1897
|
-
// anchors would risk pulling the set in on unrelated "audit my code"
|
|
1898
|
-
// prompts that have nothing to do with app generation.
|
|
1899
1889
|
anchors: ["create_file", "patch_file"],
|
|
1900
|
-
// 0.55: above the global filter floor (0.53) so a barely-relevant match
|
|
1901
|
-
// can't pull in the whole toolkit, but no higher — and we tried higher.
|
|
1902
|
-
// create_file scores chitchat ("what's up" ~0.56, "...about programming"
|
|
1903
|
-
// ~0.57) in the SAME band as legitimate app-EDIT prompts: "Edit the app to
|
|
1904
|
-
// change the background…" measured create_file 0.56 on one e2e run. Raising
|
|
1905
|
-
// the floor to 0.575 to exclude the chitchat therefore also stripped the
|
|
1906
|
-
// file tools from real edit requests — leaving the model unable to touch the
|
|
1907
|
-
// app at all. The bands genuinely overlap; there is no clean cut. So we keep
|
|
1908
|
-
// 0.55 (max recall) and rely on two safety nets instead: APP_BUILDER_PROMPT
|
|
1909
|
-
// is conditional (it no-ops unless the user is actually asking for an app),
|
|
1910
|
-
// and very short greetings ("hey") are filtered out earlier by the
|
|
1911
|
-
// MIN_CONTENT_LENGTH_FOR_TOOLS length gate before embeddings even run.
|
|
1912
1890
|
anchorMinSimilarity: 0.55
|
|
1913
1891
|
},
|
|
1914
1892
|
{
|
|
1915
1893
|
name: "slides",
|
|
1916
1894
|
members: ["plan_deck", "add_slide", "read_slides", "patch_slides"],
|
|
1917
1895
|
anchors: ["plan_deck", "patch_slides"],
|
|
1918
|
-
// Match the client-tool floor (0.53). Short colloquial prompts like
|
|
1919
|
-
// "make me a powerpoint about X" score plan_deck around 0.535 — above
|
|
1920
|
-
// the global floor but inside any anchor gap. plan_deck and patch_slides
|
|
1921
|
-
// are specific enough names that 0.53 won't false-positive in practice.
|
|
1922
1896
|
anchorMinSimilarity: 0.53
|
|
1923
1897
|
},
|
|
1924
1898
|
{
|
|
1925
1899
|
name: "documents",
|
|
1926
|
-
// Conditional rider (no-ops unless the user actually asks for a document),
|
|
1927
|
-
// attached so the Document Builder guidance rides in with the document
|
|
1928
|
-
// tools via the same semantic selection that includes them.
|
|
1929
1900
|
systemPrompt: DOCUMENT_BUILDER_PROMPT,
|
|
1930
1901
|
members: ["create_document", "read_document", "patch_document"],
|
|
1931
|
-
// Entry-point tools anchor; read_document rides in via set expansion.
|
|
1932
1902
|
anchors: ["create_document", "patch_document"],
|
|
1933
|
-
// 0.53: match the client-tool floor. "draft me a contract", "write a cover
|
|
1934
|
-
// letter", "make a memo" should pull the set in. Like app-gen's create_file,
|
|
1935
|
-
// document intent ("write me X") overlaps generic chitchat in this band, so
|
|
1936
|
-
// the same two safety nets apply: DOCUMENT_BUILDER_PROMPT is conditional and
|
|
1937
|
-
// the MIN_CONTENT_LENGTH_FOR_TOOLS gate drops bare greetings before
|
|
1938
|
-
// embeddings run. Tune empirically against the tool-selection parity suite.
|
|
1939
1903
|
anchorMinSimilarity: 0.53
|
|
1940
1904
|
},
|
|
1941
1905
|
{
|
|
@@ -1944,11 +1908,6 @@ var BUILT_IN_TOOL_SETS = [
|
|
|
1944
1908
|
anchors: ["github_api"],
|
|
1945
1909
|
anchorMinSimilarity: 0.55
|
|
1946
1910
|
},
|
|
1947
|
-
// Connector sets (#587). Connector chat tools belong to no set, so per-message
|
|
1948
|
-
// semantic filtering silently prunes them on vague prompts ("check my email").
|
|
1949
|
-
// Grouping each connector's tools behind a search/action anchor keeps the
|
|
1950
|
-
// whole connector reachable once any one of its tools matches. Mirrors github:
|
|
1951
|
-
// no systemPrompt rider — per-set prompt guidance is a follow-up.
|
|
1952
1911
|
{
|
|
1953
1912
|
name: "gmail",
|
|
1954
1913
|
members: [
|
|
@@ -2005,9 +1964,6 @@ var BUILT_IN_TOOL_SETS = [
|
|
|
2005
1964
|
"slack_get_thread_replies",
|
|
2006
1965
|
"slack_post_message"
|
|
2007
1966
|
],
|
|
2008
|
-
// search is the primary entry point; list_channels also anchors so "what
|
|
2009
|
-
// channels am I in" reaches the set without going through search. post_message
|
|
2010
|
-
// anchors too so post-only prompts surface the write tool past the cutoff.
|
|
2011
1967
|
anchors: ["slack_search_messages", "slack_list_channels", "slack_post_message"],
|
|
2012
1968
|
anchorMinSimilarity: 0.53
|
|
2013
1969
|
},
|
|
@@ -2018,15 +1974,6 @@ var BUILT_IN_TOOL_SETS = [
|
|
|
2018
1974
|
anchorMinSimilarity: 0.53
|
|
2019
1975
|
},
|
|
2020
1976
|
{
|
|
2021
|
-
// Server tools, so this set does its work through
|
|
2022
|
-
// withActiveToolSetServerTools: once any restaurant tool has run, terse
|
|
2023
|
-
// follow-ups ("okay", "same as before", "cancel it") keep every restaurant
|
|
2024
|
-
// tool — discovery, booking and cancelling. Each tool still reaches a fresh
|
|
2025
|
-
// request on its own description.
|
|
2026
|
-
// Anchors are deliberately empty (like the client's Nearby set): the set
|
|
2027
|
-
// is only for stickiness, not a new way to activate on a prompt.
|
|
2028
|
-
// prompt_user_confirm is left out of members: autoFilterClientTools always
|
|
2029
|
-
// sends it, and as a member any unrelated confirmation would pin this set.
|
|
2030
1977
|
name: "restaurant-booking",
|
|
2031
1978
|
members: [
|
|
2032
1979
|
"AnumaPaymentsMCP-anuma_find_restaurant",
|
|
@@ -2039,10 +1986,6 @@ var BUILT_IN_TOOL_SETS = [
|
|
|
2039
1986
|
anchors: []
|
|
2040
1987
|
},
|
|
2041
1988
|
{
|
|
2042
|
-
// What a confirmed booking card narrows the rest of the turn to (see
|
|
2043
|
-
// CONFIRMED_ACTION_TOOL_SETS): the booking chain only, without the
|
|
2044
|
-
// discovery and cancel tools that restaurant-booking keeps sticky.
|
|
2045
|
-
// Anchors are empty for the same reason as restaurant-cancel below.
|
|
2046
1989
|
name: "restaurant-book",
|
|
2047
1990
|
members: [
|
|
2048
1991
|
"AnumaPaymentsMCP-anuma_find_restaurant",
|
|
@@ -2052,12 +1995,6 @@ var BUILT_IN_TOOL_SETS = [
|
|
|
2052
1995
|
anchors: []
|
|
2053
1996
|
},
|
|
2054
1997
|
{
|
|
2055
|
-
// What a confirmed cancel card narrows the rest of the turn to (see
|
|
2056
|
-
// CONFIRMED_ACTION_TOOL_SETS). Anchors are empty for the same reason as
|
|
2057
|
-
// restaurant-booking: anchors here are scored against client tools only,
|
|
2058
|
-
// so a server-tool anchor could never fire. The "cancel brings list"
|
|
2059
|
-
// edge on a fresh prompt is restaurant-cancel-lookup in
|
|
2060
|
-
// SERVER_TOOL_DEPENDENCY_SETS.
|
|
2061
1998
|
name: "restaurant-cancel",
|
|
2062
1999
|
members: [
|
|
2063
2000
|
"AnumaPaymentsMCP-anuma_list_reservations",
|
|
@@ -2181,11 +2118,6 @@ function createServerToolsFilter(options = {}) {
|
|
|
2181
2118
|
var DEFAULT_EXCLUDED_SERVER_TOOLS = [
|
|
2182
2119
|
"AnumaVisionMCP-anuma_analyze_image",
|
|
2183
2120
|
"OpenMeteoMCP-weather_forecast",
|
|
2184
|
-
// Same native-capability argument as the vision tool: modern models reason
|
|
2185
|
-
// step-by-step natively (and reasoning-mode models do it structurally), so
|
|
2186
|
-
// a server-side sequential-thinking tool is a redundant hop. Its broad
|
|
2187
|
-
// description also embeds near virtually every prompt — observed live
|
|
2188
|
-
// riding into news-search, scheduling, and chitchat requests.
|
|
2189
2121
|
"AnumaSequentialThinkingMCP-sequentialthinking"
|
|
2190
2122
|
];
|
|
2191
2123
|
var DEFAULT_SERVER_TOOLS_MATCH_OPTIONS = {
|
|
@@ -2194,10 +2126,6 @@ var DEFAULT_SERVER_TOOLS_MATCH_OPTIONS = {
|
|
|
2194
2126
|
};
|
|
2195
2127
|
var SERVER_TOOL_DEPENDENCY_SETS = [
|
|
2196
2128
|
{
|
|
2197
|
-
// search finds links; reading them is always the next step. The reader now
|
|
2198
|
-
// lives on the search server — Jina's read_url / parallel_read_url were
|
|
2199
|
-
// removed in favour of anuma_scrape_url, which takes a batch of URLs — so
|
|
2200
|
-
// this edge deliberately spans two MCP servers.
|
|
2201
2129
|
name: "web-research",
|
|
2202
2130
|
members: [
|
|
2203
2131
|
"AnumaJinaMCP-search_web",
|
|
@@ -2205,22 +2133,9 @@ var SERVER_TOOL_DEPENDENCY_SETS = [
|
|
|
2205
2133
|
"AnumaJinaMCP-parallel_search_web"
|
|
2206
2134
|
],
|
|
2207
2135
|
anchors: ["AnumaJinaMCP-search_web"],
|
|
2208
|
-
// Activation floor = the selection floor (0.5), not the 0.6 ToolSet
|
|
2209
|
-
// default. A dependency edge has different semantics from a persona-style
|
|
2210
|
-
// tool set: if the entry tool is plausibly offered at all, the chain must
|
|
2211
|
-
// ride along — "Search the web for recent news…" scores search_web in the
|
|
2212
|
-
// 0.5–0.6 band, and shipping search without read would dead-end the model.
|
|
2213
2136
|
anchorMinSimilarity: 0.5
|
|
2214
2137
|
},
|
|
2215
2138
|
{
|
|
2216
|
-
// Every OpenMeteo data tool requires latitude/longitude (verified in the
|
|
2217
|
-
// catalog schemas), but users speak in place names — geocoding is the
|
|
2218
|
-
// mandatory first hop. Members deliberately contain ONLY the dependency:
|
|
2219
|
-
// the anchor that fired is already in the semantic matches, and pulling
|
|
2220
|
-
// sibling data tools in would re-create vendor-suite over-inclusion.
|
|
2221
|
-
// Excluded tools (e.g. weather_forecast under the default filter) can't
|
|
2222
|
-
// anchor this set — createServerToolsFilter drops them before expansion —
|
|
2223
|
-
// but the non-weather data tools still deliver geocoding when they match.
|
|
2224
2139
|
name: "openmeteo-geocode",
|
|
2225
2140
|
members: ["OpenMeteoMCP-geocoding"],
|
|
2226
2141
|
anchors: [
|
|
@@ -2235,10 +2150,6 @@ var SERVER_TOOL_DEPENDENCY_SETS = [
|
|
|
2235
2150
|
anchorMinSimilarity: 0.5
|
|
2236
2151
|
},
|
|
2237
2152
|
{
|
|
2238
|
-
// The cancel tool takes its resy_token and the other values only from a
|
|
2239
|
-
// live anuma_list_reservations result in the same turn, never from
|
|
2240
|
-
// memory, so the list tool must ride in whenever cancel is offered.
|
|
2241
|
-
// Members hold only the dependency, like openmeteo-geocode.
|
|
2242
2153
|
name: "restaurant-cancel-lookup",
|
|
2243
2154
|
members: ["AnumaPaymentsMCP-anuma_list_reservations"],
|
|
2244
2155
|
anchors: ["AnumaPaymentsMCP-anuma_cancel_reservation"],
|
|
@@ -2445,11 +2356,6 @@ async function autoFilterClientTools(clientTools, promptEmbeddings, cache, embed
|
|
|
2445
2356
|
limit: MAX_CLIENT_TOOLS_AFTER_FILTER,
|
|
2446
2357
|
minSimilarity: CLIENT_TOOLS_MIN_SIMILARITY,
|
|
2447
2358
|
filterAmbiguous: true,
|
|
2448
|
-
// See CLIENT_TOOLS_RELEVANCE_RATIO: 0.75 admits the second intent of a
|
|
2449
|
-
// multi-intent prompt (which lands ~75-80% of the dominant match), while
|
|
2450
|
-
// still trimming the loose tail. The earlier 0.9 made a second intent
|
|
2451
|
-
// structurally unselectable; the anchorMinSimilarity gates (0.53-0.55)
|
|
2452
|
-
// remain the guard against borderline anchors activating a whole set.
|
|
2453
2359
|
relevanceRatio: CLIENT_TOOLS_RELEVANCE_RATIO
|
|
2454
2360
|
});
|
|
2455
2361
|
const matchedNames = new Set(matches.map((m) => m.tool.name));
|
|
@@ -2478,12 +2384,10 @@ async function autoFilterClientTools(clientTools, promptEmbeddings, cache, embed
|
|
|
2478
2384
|
|
|
2479
2385
|
// src/lib/tools/toolCatalog.ts
|
|
2480
2386
|
var TOOL_CATALOG = {
|
|
2481
|
-
// Gmail (src/tools/gmail.ts)
|
|
2482
2387
|
gmail_search_messages: { label: "Search emails", provider: "gmail", connector: "Gmail" },
|
|
2483
2388
|
gmail_get_message: { label: "Read an email", provider: "gmail", connector: "Gmail" },
|
|
2484
2389
|
gmail_create_draft: { label: "Draft a reply", provider: "gmail", connector: "Gmail" },
|
|
2485
2390
|
gmail_send_message: { label: "Send an email", provider: "gmail", connector: "Gmail" },
|
|
2486
|
-
// Google Calendar (src/tools/googleCalendar.ts)
|
|
2487
2391
|
google_calendar_list_events: {
|
|
2488
2392
|
label: "Search calendar events",
|
|
2489
2393
|
provider: "gcalendar",
|
|
@@ -2499,7 +2403,6 @@ var TOOL_CATALOG = {
|
|
|
2499
2403
|
provider: "gcalendar",
|
|
2500
2404
|
connector: "Calendar"
|
|
2501
2405
|
},
|
|
2502
|
-
// Google Drive (src/tools/googleDrive.ts)
|
|
2503
2406
|
google_drive_search: { label: "Search files", provider: "gdrive", connector: "Drive" },
|
|
2504
2407
|
google_drive_list_recent: { label: "List recent files", provider: "gdrive", connector: "Drive" },
|
|
2505
2408
|
google_drive_get_content: { label: "Read file content", provider: "gdrive", connector: "Drive" },
|
|
@@ -2513,7 +2416,6 @@ var TOOL_CATALOG = {
|
|
|
2513
2416
|
provider: "gdrive",
|
|
2514
2417
|
connector: "Drive"
|
|
2515
2418
|
},
|
|
2516
|
-
// Notion (src/tools/notion.ts)
|
|
2517
2419
|
"notion-search": { label: "Search", provider: "notion", connector: "Notion" },
|
|
2518
2420
|
"notion-fetch": { label: "Read page", provider: "notion", connector: "Notion" },
|
|
2519
2421
|
"notion-create-pages": { label: "Create page", provider: "notion", connector: "Notion" },
|
|
@@ -2534,17 +2436,14 @@ var TOOL_CATALOG = {
|
|
|
2534
2436
|
connector: "Notion"
|
|
2535
2437
|
},
|
|
2536
2438
|
"notion-get-teams": { label: "List teamspaces", provider: "notion", connector: "Notion" },
|
|
2537
|
-
// GitHub (src/tools/github.ts)
|
|
2538
2439
|
github_api: { label: "Use GitHub", provider: "github", connector: "GitHub" },
|
|
2539
2440
|
github_get_authenticated_user: {
|
|
2540
2441
|
label: "Read GitHub profile",
|
|
2541
2442
|
provider: "github",
|
|
2542
2443
|
connector: "GitHub"
|
|
2543
2444
|
},
|
|
2544
|
-
// X / Twitter (src/tools/x.ts)
|
|
2545
2445
|
x_get_me: { label: "Get my X profile", provider: "x", connector: "X" },
|
|
2546
2446
|
x_get_my_posts: { label: "Read my recent posts", provider: "x", connector: "X" },
|
|
2547
|
-
// Dropbox (src/tools/dropbox.ts)
|
|
2548
2447
|
dropbox_list_folders: { label: "List files", provider: "dropbox", connector: "Dropbox" },
|
|
2549
2448
|
dropbox_get_file_content: {
|
|
2550
2449
|
label: "Read file content",
|
|
@@ -2552,7 +2451,6 @@ var TOOL_CATALOG = {
|
|
|
2552
2451
|
connector: "Dropbox"
|
|
2553
2452
|
},
|
|
2554
2453
|
dropbox_search: { label: "Search files", provider: "dropbox", connector: "Dropbox" },
|
|
2555
|
-
// Slack (src/tools/slack.ts)
|
|
2556
2454
|
slack_get_me: { label: "Get my Slack profile", provider: "slack", connector: "Slack" },
|
|
2557
2455
|
slack_list_channels: { label: "List channels", provider: "slack", connector: "Slack" },
|
|
2558
2456
|
slack_list_dms: { label: "List direct messages", provider: "slack", connector: "Slack" },
|
|
@@ -2723,8 +2621,6 @@ var CREATION_INTENT_CLIENT_FACTORIES = {
|
|
|
2723
2621
|
document: FULL_GENERATIVE_CLIENT_FACTORIES,
|
|
2724
2622
|
"web-search": FULL_GENERATIVE_CLIENT_FACTORIES,
|
|
2725
2623
|
"deep-research": FULL_GENERATIVE_CLIENT_FACTORIES,
|
|
2726
|
-
// Builder modes: restrict to their own toolkit; a `saved` toolkit rides
|
|
2727
|
-
// along on app builds (parity with web's app branch).
|
|
2728
2624
|
app: ["app", "saved"],
|
|
2729
2625
|
slides: ["slides"]
|
|
2730
2626
|
};
|
|
@@ -77,13 +77,6 @@ type ToolConfig = LlmapiChatCompletionTool & {
|
|
|
77
77
|
dependsOn?: string[];
|
|
78
78
|
};
|
|
79
79
|
|
|
80
|
-
/**
|
|
81
|
-
* Server-side tools caching module
|
|
82
|
-
*
|
|
83
|
-
* Fetches and caches tools from /api/v1/tools endpoint
|
|
84
|
-
* with configurable expiration and localStorage persistence.
|
|
85
|
-
*/
|
|
86
|
-
|
|
87
80
|
/** Tool parameters schema */
|
|
88
81
|
interface ToolParameters {
|
|
89
82
|
properties: Record<string, unknown>;
|
|
@@ -808,23 +801,6 @@ interface SelectServerSideToolsOptions {
|
|
|
808
801
|
*/
|
|
809
802
|
declare function selectServerSideTools(options: SelectServerSideToolsOptions): Promise<Array<Record<string, unknown>>>;
|
|
810
803
|
|
|
811
|
-
/**
|
|
812
|
-
* Client-tool selection — the per-turn semantic filter over a client-tool
|
|
813
|
-
* catalog.
|
|
814
|
-
*
|
|
815
|
-
* Extracted out of `../../react/useChatStorage` (a `"use client"` React +
|
|
816
|
-
* WatermelonDB file) so the identical selection can run anywhere the engine
|
|
817
|
-
* runs: the standalone council path that bypasses the hook, Node unit tests,
|
|
818
|
-
* and the node/RN-safe `@anuma/sdk/tools/selection` subpath. The hook re-imports
|
|
819
|
-
* these — behavior is unchanged from when they lived inline.
|
|
820
|
-
*
|
|
821
|
-
* Dependency-safe by construction: `generateEmbeddings` comes from the db-free
|
|
822
|
-
* `../memoryEngine/generate` core, `RECALL_TOOL_NAME` from the
|
|
823
|
-
* dependency-free `../memory/recallConstants`, and `CONFIRM_TOOL_NAME` from the
|
|
824
|
-
* dependency-free `../../tools/confirmConstants`, so nothing here drags in the
|
|
825
|
-
* WatermelonDB data layer.
|
|
826
|
-
*/
|
|
827
|
-
|
|
828
804
|
/** Typed accessor for client tool name (handles function-call style and flat). */
|
|
829
805
|
declare function getToolName(t: LlmapiChatCompletionTool): string;
|
|
830
806
|
/** Typed accessor for client tool description. */
|
|
@@ -868,35 +844,6 @@ noEmbeddingsReason?: "short-prompt" | "error"): Promise<{
|
|
|
868
844
|
matchedSetNames: ReadonlySet<string>;
|
|
869
845
|
}>;
|
|
870
846
|
|
|
871
|
-
/**
|
|
872
|
-
* Connector tool catalog + denied-tools system-prompt rider.
|
|
873
|
-
*
|
|
874
|
-
* Granular connector access works by ALLOW/DENY-ing individual SDK tools.
|
|
875
|
-
* Denying a tool means it's never handed to the model that turn, so it
|
|
876
|
-
* physically can't be called — bypass-proof at the model layer.
|
|
877
|
-
*
|
|
878
|
-
* Consumer contract (this PR ships the foundation only — it does NOT wire
|
|
879
|
-
* anything into runtime filtering or the client; those are later phases):
|
|
880
|
-
*
|
|
881
|
-
* 1. Hide the denied tools from the model — pass the denied tool names as
|
|
882
|
-
* `createServerToolsFilter({ excludeTools })` so they're dropped from the
|
|
883
|
-
* toolset before it reaches the LLM.
|
|
884
|
-
* 2. Tell the user how to re-enable — append `buildDeniedToolsRider(denied)`
|
|
885
|
-
* to the system prompt. Because the tool is absent, the model can't name
|
|
886
|
-
* it on its own and would give a generic "I don't have access". The rider
|
|
887
|
-
* gives it the specific capability names (grouped by connector) so it can
|
|
888
|
-
* tell the user to re-enable that exact tool in Connected Apps settings.
|
|
889
|
-
*
|
|
890
|
-
* `TOOL_CATALOG` is the single source of truth for connector tool → friendly
|
|
891
|
-
* label + provider. `provider` is the canonical logical-provider identifier the
|
|
892
|
-
* portal and SDK already key on (matches `internal/oauth/providers.go` and the
|
|
893
|
-
* `createConnectorTokenGetter` call sites) — Phase 2/3 use it to group and
|
|
894
|
-
* persist per-tool denial. `connector` is the human-facing UI display string.
|
|
895
|
-
* Consumers (portal, client) read this on a version bump rather than re-encoding
|
|
896
|
-
* tool names. Labels are placeholders that will be refined later — keep them
|
|
897
|
-
* sensible.
|
|
898
|
-
*/
|
|
899
|
-
|
|
900
847
|
interface ToolCatalogEntry {
|
|
901
848
|
label: string;
|
|
902
849
|
/** Canonical logical-provider id (e.g. "gmail", "gcalendar", "gdrive"). */
|
|
@@ -956,22 +903,6 @@ interface ConnectorGuidance {
|
|
|
956
903
|
*/
|
|
957
904
|
declare function buildConnectorGuidance(input: ConnectorGuidanceInput): ConnectorGuidance;
|
|
958
905
|
|
|
959
|
-
/**
|
|
960
|
-
* `deriveActiveToolSets` — event-shape-agnostic sticky tool-set derivation
|
|
961
|
-
* (issue #702, Phase 4).
|
|
962
|
-
*
|
|
963
|
-
* Web derived sticky sets by scanning `ChatMessage[]` for two web-specific
|
|
964
|
-
* signals: synthetic tool-result user messages (`Tool "<name>" returned: …`)
|
|
965
|
-
* and `ActivityPhase.id`s shaped `server-tool-<name>-<n>`. This module keeps the
|
|
966
|
-
* exact matching logic but keys on a neutral {@link ToolActivationEvent[]}, so
|
|
967
|
-
* both apps feed it through a tiny adapter that maps their own message/activity
|
|
968
|
-
* store to events. That closes the terse-follow-up gap on mobile: a 3-char
|
|
969
|
-
* "yes" inside a slide conversation keeps the slide toolkit because the set
|
|
970
|
-
* stays sticky.
|
|
971
|
-
*
|
|
972
|
-
* Pure and node/RN-safe.
|
|
973
|
-
*/
|
|
974
|
-
|
|
975
906
|
/**
|
|
976
907
|
* A neutral activation signal derived from conversation history.
|
|
977
908
|
*
|
|
@@ -1004,26 +935,6 @@ declare function deriveActiveToolSets(events: ToolActivationEvent[], sets?: read
|
|
|
1004
935
|
*/
|
|
1005
936
|
declare function mergeActiveToolSets(current: string[], derived: string[]): string[];
|
|
1006
937
|
|
|
1007
|
-
/**
|
|
1008
|
-
* Tool-selection vocabulary — the neutral, product-agnostic types that let the
|
|
1009
|
-
* SDK own the "which tools this turn" orchestration both `apps/web` and
|
|
1010
|
-
* `apps/mobile` previously hand-duplicated (see issue #702).
|
|
1011
|
-
*
|
|
1012
|
-
* The split of ownership is deliberate:
|
|
1013
|
-
*
|
|
1014
|
-
* - The SDK owns the neutral {@link CreationIntent}→client-factory mapping
|
|
1015
|
-
* ({@link CREATION_INTENT_CLIENT_FACTORIES}) and the send-policy rules.
|
|
1016
|
-
* - Each app owns its UI→{@link ToolIntentDescriptor} mapper and injects a
|
|
1017
|
-
* {@link ServerToolCatalog} (built from its own static server-tool lists) and
|
|
1018
|
-
* {@link ../assembleClientTools.ToolSelectionAdapters | adapters}. The SDK
|
|
1019
|
-
* never imports the app's tool lists — the dependency direction stays
|
|
1020
|
-
* app→SDK.
|
|
1021
|
-
*
|
|
1022
|
-
* This module has no runtime dependency on React, the DOM, WatermelonDB, or the
|
|
1023
|
-
* generated HTTP client, so it is safe to import from the node/RN-safe
|
|
1024
|
-
* `@anuma/sdk/tools/selection` subpath.
|
|
1025
|
-
*/
|
|
1026
|
-
|
|
1027
938
|
/**
|
|
1028
939
|
* Which orchestration path a turn runs through.
|
|
1029
940
|
*
|
|
@@ -1223,27 +1134,6 @@ declare const CREATION_INTENT_CLIENT_FILTER: Record<CreationIntent, ClientToolsF
|
|
|
1223
1134
|
*/
|
|
1224
1135
|
declare const CREATION_INTENT_TOOL_SET: Partial<Record<CreationIntent, string>>;
|
|
1225
1136
|
|
|
1226
|
-
/**
|
|
1227
|
-
* `assembleClientTools` — capability-gated client-tool assembly (issue #702,
|
|
1228
|
-
* Phase 3). Given a resolved plan's `clientFactories` and a set of adapters, it
|
|
1229
|
-
* instantiates only the factories whose adapter is present and concatenates
|
|
1230
|
-
* them in a canonical order.
|
|
1231
|
-
*
|
|
1232
|
-
* The presence of an adapter GATES its factory — the generalization of
|
|
1233
|
-
* `createDocumentTools` returning `[]` when `displayDocument` is absent
|
|
1234
|
-
* (src/tools/document/index.ts). This is what lets ONE unified plan produce
|
|
1235
|
-
* web's full toolkit and mobile's subset automatically: web wires every
|
|
1236
|
-
* builder, mobile wires only the ones its RN surface supports, and the absent
|
|
1237
|
-
* ones contribute nothing.
|
|
1238
|
-
*
|
|
1239
|
-
* The SDK deliberately owns the GATING, ORDER, and filter application — not the
|
|
1240
|
-
* per-factory wiring. Each app's factory instantiation (slide auto-display,
|
|
1241
|
-
* app-lineage tracking, RN-vs-web storage, logging instrumentation) is
|
|
1242
|
-
* genuinely app-specific and stays app-side, expressed as a builder here.
|
|
1243
|
-
*
|
|
1244
|
-
* Pure and node/RN-safe.
|
|
1245
|
-
*/
|
|
1246
|
-
|
|
1247
1137
|
/** Minimal logger the assembler uses when a builder throws. */
|
|
1248
1138
|
interface SelectionLogger {
|
|
1249
1139
|
warn(message: string, context?: unknown): void;
|
|
@@ -1300,18 +1190,6 @@ declare function filterAssembledClientTools<TTool = ToolConfig>(tools: TTool[],
|
|
|
1300
1190
|
getName?: (t: TTool) => string;
|
|
1301
1191
|
}): TTool[] | Promise<TTool[]>;
|
|
1302
1192
|
|
|
1303
|
-
/**
|
|
1304
|
-
* `resolvePlan` — the single source of truth for "which tools this turn"
|
|
1305
|
-
* (issue #702, Phase 2). Given a neutral {@link ToolIntentDescriptor} and an
|
|
1306
|
-
* app-injected {@link ServerToolCatalog}, it produces a fully-resolved
|
|
1307
|
-
* {@link ToolPlanSpec} that both web and mobile consume, replacing each app's
|
|
1308
|
-
* hand-written per-mode switch.
|
|
1309
|
-
*
|
|
1310
|
-
* Pure and node/RN-safe. The plan is data — the host feeds `clientFactories`
|
|
1311
|
-
* into `assembleClientTools`, and `serverTools`/`toolChoice`/`maxToolRounds`/
|
|
1312
|
-
* `thinkingMode` into its send layer.
|
|
1313
|
-
*/
|
|
1314
|
-
|
|
1315
1193
|
/** Context for {@link resolvePlan}: the injected catalog plus host defaults. */
|
|
1316
1194
|
interface ResolvePlanContext {
|
|
1317
1195
|
/** The app-built per-intent/-lane server-tool catalog. */
|
|
@@ -1343,23 +1221,6 @@ interface ResolvePlanContext {
|
|
|
1343
1221
|
*/
|
|
1344
1222
|
declare function resolvePlan(descriptor: ToolIntentDescriptor, ctx: ResolvePlanContext): ToolPlanSpec;
|
|
1345
1223
|
|
|
1346
|
-
/**
|
|
1347
|
-
* Council tool resolution (issue #702, Phase 6).
|
|
1348
|
-
*
|
|
1349
|
-
* The council path bypasses the per-mode chat switch: each worker sees the full
|
|
1350
|
-
* semantic server-tool filter and its OWN per-worker memory tools (built from
|
|
1351
|
-
* that worker's model so a private-capable model sees `['private','shared']`
|
|
1352
|
-
* and a standard model sees `['shared']` only). The aggregation ("unify")
|
|
1353
|
-
* worker must never persist — its `memory_vault_save` is dropped.
|
|
1354
|
-
*
|
|
1355
|
-
* This module composes each worker's client-tool candidate array and runs it
|
|
1356
|
-
* through the SAME `autoFilterClientTools` the chat hook uses, so council and
|
|
1357
|
-
* chat share one selection. Building this on the exported selector is what lets
|
|
1358
|
-
* mobile council gain per-worker memory tools without re-implementing anything.
|
|
1359
|
-
*
|
|
1360
|
-
* Pure and node/RN-safe.
|
|
1361
|
-
*/
|
|
1362
|
-
|
|
1363
1224
|
/**
|
|
1364
1225
|
* Resolve the council/aggregation server-tool plan. This is the chat resolver's
|
|
1365
1226
|
* council-lane path: a semantic server-tool filter, no per-mode client toolkit,
|
|
@@ -1414,16 +1275,6 @@ declare function selectCouncilClientTools<TTool extends LlmapiChatCompletionTool
|
|
|
1414
1275
|
activatedSetNames?: ReadonlySet<string>;
|
|
1415
1276
|
}>;
|
|
1416
1277
|
|
|
1417
|
-
/**
|
|
1418
|
-
* Send-policy primitives — the per-turn `tool_choice` / `maxToolRounds` /
|
|
1419
|
-
* thinking-mode / coerced-memory-write rules, unified so web and mobile stop
|
|
1420
|
-
* hand-duplicating them (issue #702, Phase 1).
|
|
1421
|
-
*
|
|
1422
|
-
* These were previously spread across web's `useChatSetup` + `useChatSubmitHandler`
|
|
1423
|
-
* + `webChatSendMessage` and mobile's `chatModeRouting`. They are pure and
|
|
1424
|
-
* node/RN-safe.
|
|
1425
|
-
*/
|
|
1426
|
-
|
|
1427
1278
|
/** The vault-save tool name — the one client tool stripped on a coerced turn. */
|
|
1428
1279
|
declare const MEMORY_SAVE_TOOL_NAME = "memory_vault_save";
|
|
1429
1280
|
/**
|
|
@@ -1465,16 +1316,6 @@ declare function getThinkingMode(entry: ServerToolCatalogEntry | undefined, fall
|
|
|
1465
1316
|
*/
|
|
1466
1317
|
declare function stripCoercedMemoryWrite<T extends LlmapiChatCompletionTool>(clientTools: T[], toolChoice: ToolChoice): T[];
|
|
1467
1318
|
|
|
1468
|
-
/**
|
|
1469
|
-
* Server-tools policy — resolve the concrete server-tools filter for a turn
|
|
1470
|
-
* from the app-injected {@link ServerToolCatalog} (issue #702, Phase 2).
|
|
1471
|
-
*
|
|
1472
|
-
* The catalog is opaque to the SDK: each app builds it from its own static
|
|
1473
|
-
* server-tool lists (`IMAGE_SERVER_TOOLS`, `SLIDE_SERVER_TOOLS`, …) and passes
|
|
1474
|
-
* it in. This module only knows how to pick the right entry and, when the entry
|
|
1475
|
-
* is an attachment-aware factory, apply it with the turn's context.
|
|
1476
|
-
*/
|
|
1477
|
-
|
|
1478
1319
|
/**
|
|
1479
1320
|
* Look up the catalog entry for a descriptor. Chat turns key on the creation
|
|
1480
1321
|
* intent; council/aggregation turns key on the lane.
|