@anuma/sdk 6.27.9 → 6.28.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.
- package/dist/expo/index.cjs +14776 -14696
- package/dist/expo/index.mjs +14717 -14639
- package/dist/index.cjs +17 -0
- package/dist/index.mjs +17 -0
- package/dist/react/index.cjs +16490 -16384
- package/dist/react/index.d.mts +34 -1
- package/dist/react/index.d.ts +34 -1
- package/dist/react/index.mjs +16397 -16292
- package/dist/server/index.cjs +78 -4
- package/dist/server/index.d.mts +14 -0
- package/dist/server/index.d.ts +14 -0
- package/dist/server/index.mjs +78 -4
- package/dist/tools/selection/index.cjs +44 -6
- package/dist/tools/selection/index.d.mts +34 -1
- package/dist/tools/selection/index.d.ts +34 -1
- package/dist/tools/selection/index.mjs +42 -5
- package/package.json +1 -1
package/dist/server/index.cjs
CHANGED
|
@@ -32758,6 +32758,9 @@ function createDurableAutoExtractor(options) {
|
|
|
32758
32758
|
};
|
|
32759
32759
|
}
|
|
32760
32760
|
|
|
32761
|
+
// src/tools/confirmConstants.ts
|
|
32762
|
+
var CONFIRM_TOOL_NAME = "prompt_user_confirm";
|
|
32763
|
+
|
|
32761
32764
|
// src/tools/appBuilderPrompt.ts
|
|
32762
32765
|
var APP_BUILDER_PROMPT = `App Builder tools (create_file, patch_file, and the rest described below) are available this turn, but they are OPTIONAL \u2014 having them does not mean you should build anything.
|
|
32763
32766
|
|
|
@@ -33050,6 +33053,7 @@ function filterServerTools(serverTools, includeNames) {
|
|
|
33050
33053
|
const includeSet = new Set(includeNames);
|
|
33051
33054
|
return serverTools.filter((tool) => includeSet.has(tool.name));
|
|
33052
33055
|
}
|
|
33056
|
+
var TOOL_SEARCH_TOOL_NAME = "tool_search_tool_regex";
|
|
33053
33057
|
function resolveDeferredServerTools(allServerTools, serverToolsFilter, config) {
|
|
33054
33058
|
const allowed = serverToolsFilter === void 0 || typeof serverToolsFilter === "function" ? allServerTools : filterServerTools(allServerTools, [...serverToolsFilter]);
|
|
33055
33059
|
const excluded = new Set(config.excludeTools ?? []);
|
|
@@ -33283,8 +33287,30 @@ var BUILT_IN_TOOL_SETS = [
|
|
|
33283
33287
|
members: ["dropbox_list_folders", "dropbox_get_file_content", "dropbox_search"],
|
|
33284
33288
|
anchors: ["dropbox_list_folders", "dropbox_search"],
|
|
33285
33289
|
anchorMinSimilarity: 0.53
|
|
33290
|
+
},
|
|
33291
|
+
{
|
|
33292
|
+
// Server tools, so this set does its work through
|
|
33293
|
+
// withActiveToolSetServerTools: once a restaurant tool has run, terse
|
|
33294
|
+
// follow-ups ("okay", "same as before") keep the booking chain. Each tool
|
|
33295
|
+
// still reaches a fresh booking request on its own description.
|
|
33296
|
+
// Anchors are deliberately empty (like the client's Nearby set): the set
|
|
33297
|
+
// is only for stickiness, not a new way to activate on a prompt.
|
|
33298
|
+
// prompt_user_confirm is left out of members: autoFilterClientTools always
|
|
33299
|
+
// sends it, and as a member any unrelated confirmation would pin this set.
|
|
33300
|
+
name: "restaurant-booking",
|
|
33301
|
+
members: [
|
|
33302
|
+
"AnumaPaymentsMCP-anuma_find_restaurant",
|
|
33303
|
+
"AnumaPaymentsMCP-anuma_check_restaurant_availability",
|
|
33304
|
+
"AnumaPaymentsMCP-anuma_book_restaurant"
|
|
33305
|
+
],
|
|
33306
|
+
anchors: []
|
|
33286
33307
|
}
|
|
33287
33308
|
];
|
|
33309
|
+
var CONFIRMED_ACTION_TOOL_SETS = /* @__PURE__ */ new Map([
|
|
33310
|
+
["book_restaurant", "restaurant-booking"],
|
|
33311
|
+
["anuma_book_restaurant", "restaurant-booking"],
|
|
33312
|
+
["anumapaymentsmcp-anuma_book_restaurant", "restaurant-booking"]
|
|
33313
|
+
]);
|
|
33288
33314
|
function expandToolSetsAdditive(matchedNames, availableNames, scores, toolSets, activeSetNames) {
|
|
33289
33315
|
const result = new Set(matchedNames);
|
|
33290
33316
|
for (const ts of toolSets) {
|
|
@@ -33316,6 +33342,16 @@ function activatedToolSetNames(scores, toolSets = BUILT_IN_TOOL_SETS, activeSetN
|
|
|
33316
33342
|
}
|
|
33317
33343
|
return activated;
|
|
33318
33344
|
}
|
|
33345
|
+
function withActiveToolSetServerTools(selected, allServerTools, serverToolsFilter, activeToolSets = [], extraToolSets = []) {
|
|
33346
|
+
if (activeToolSets.length === 0) return selected;
|
|
33347
|
+
const sticky = new Set(
|
|
33348
|
+
[...BUILT_IN_TOOL_SETS, ...extraToolSets].filter((ts) => activeToolSets.includes(ts.name)).flatMap((ts) => ts.members)
|
|
33349
|
+
);
|
|
33350
|
+
for (const name of serverToolsFilter.excludeTools ?? []) sticky.delete(name);
|
|
33351
|
+
for (const tool of selected) sticky.delete(tool.name);
|
|
33352
|
+
const added = allServerTools.filter((tool) => sticky.has(tool.name));
|
|
33353
|
+
return added.length > 0 ? [...selected, ...added] : selected;
|
|
33354
|
+
}
|
|
33319
33355
|
function toolSetSystemPrompts(selectedToolNames, toolSets = BUILT_IN_TOOL_SETS, activatedSetNames) {
|
|
33320
33356
|
const selected = selectedToolNames instanceof Set ? selectedToolNames : new Set(selectedToolNames);
|
|
33321
33357
|
const prompts = [];
|
|
@@ -33429,7 +33465,9 @@ async function selectServerToolsForPrompt(options) {
|
|
|
33429
33465
|
embeddingModel,
|
|
33430
33466
|
cacheExpirationMs,
|
|
33431
33467
|
cache,
|
|
33432
|
-
deferLoading
|
|
33468
|
+
deferLoading,
|
|
33469
|
+
activeToolSets,
|
|
33470
|
+
extraToolSets
|
|
33433
33471
|
} = options;
|
|
33434
33472
|
if (serverToolsFilter === void 0) return [];
|
|
33435
33473
|
if (Array.isArray(serverToolsFilter) && serverToolsFilter.length === 0) return [];
|
|
@@ -33443,7 +33481,14 @@ async function selectServerToolsForPrompt(options) {
|
|
|
33443
33481
|
if (deferLoading?.enabled)
|
|
33444
33482
|
return resolveDeferredServerTools(allServerTools, serverToolsFilter, deferLoading);
|
|
33445
33483
|
if (typeof serverToolsFilter === "function") {
|
|
33446
|
-
|
|
33484
|
+
const withSticky = (selected) => withActiveToolSetServerTools(
|
|
33485
|
+
selected,
|
|
33486
|
+
allServerTools,
|
|
33487
|
+
serverToolsFilter,
|
|
33488
|
+
activeToolSets,
|
|
33489
|
+
extraToolSets
|
|
33490
|
+
);
|
|
33491
|
+
if (prompt.length < MIN_CONTENT_LENGTH_FOR_TOOLS) return withSticky([]);
|
|
33447
33492
|
let promptEmbedding;
|
|
33448
33493
|
try {
|
|
33449
33494
|
promptEmbedding = await generateEmbedding(prompt, {
|
|
@@ -33452,10 +33497,10 @@ async function selectServerToolsForPrompt(options) {
|
|
|
33452
33497
|
model: embeddingModel
|
|
33453
33498
|
});
|
|
33454
33499
|
} catch {
|
|
33455
|
-
return [];
|
|
33500
|
+
return withSticky([]);
|
|
33456
33501
|
}
|
|
33457
33502
|
const names = serverToolsFilter(promptEmbedding, allServerTools);
|
|
33458
|
-
return filterServerTools(allServerTools, names);
|
|
33503
|
+
return withSticky(filterServerTools(allServerTools, names));
|
|
33459
33504
|
}
|
|
33460
33505
|
return filterServerTools(allServerTools, serverToolsFilter);
|
|
33461
33506
|
}
|
|
@@ -37227,6 +37272,22 @@ function getToolName(tool) {
|
|
|
37227
37272
|
if (typeof flatName === "string") return flatName;
|
|
37228
37273
|
return void 0;
|
|
37229
37274
|
}
|
|
37275
|
+
function toolsAfterConfirmation(apiTools, executionResults) {
|
|
37276
|
+
const members = /* @__PURE__ */ new Set();
|
|
37277
|
+
for (const r of executionResults) {
|
|
37278
|
+
if (r.name !== CONFIRM_TOOL_NAME) continue;
|
|
37279
|
+
const answer = r.result;
|
|
37280
|
+
if (answer?.confirmed !== true || typeof answer.action !== "string") continue;
|
|
37281
|
+
const setName = CONFIRMED_ACTION_TOOL_SETS.get(answer.action.trim().toLowerCase());
|
|
37282
|
+
const set = BUILT_IN_TOOL_SETS.find((s) => s.name === setName);
|
|
37283
|
+
for (const member of set?.members ?? []) members.add(member);
|
|
37284
|
+
}
|
|
37285
|
+
if (!apiTools.some((t) => members.has(getToolName(t) ?? ""))) return void 0;
|
|
37286
|
+
return apiTools.filter((t) => {
|
|
37287
|
+
const name = getToolName(t) ?? "";
|
|
37288
|
+
return members.has(name) || name === CONFIRM_TOOL_NAME || name === TOOL_SEARCH_TOOL_NAME;
|
|
37289
|
+
});
|
|
37290
|
+
}
|
|
37230
37291
|
var STREAM_RESUMABLE_HEADER = "X-Stream-Resumable";
|
|
37231
37292
|
var INFERENCE_ID_HEADER = "X-Inference-ID";
|
|
37232
37293
|
var CONVERSATION_ID_HEADER = "X-Conversation-ID";
|
|
@@ -37912,6 +37973,19 @@ Executing tool: ${toolInfo}
|
|
|
37912
37973
|
}
|
|
37913
37974
|
}
|
|
37914
37975
|
}
|
|
37976
|
+
if (apiTools) {
|
|
37977
|
+
const confirmedTools = toolsAfterConfirmation(apiTools, executionResults);
|
|
37978
|
+
if (confirmedTools) {
|
|
37979
|
+
const kept = new Set(confirmedTools.map(getToolName));
|
|
37980
|
+
if (typeof toolChoice === "string" && !kept.has(toolChoice) && apiTools.some((t) => getToolName(t) === toolChoice)) {
|
|
37981
|
+
toolChoice = "auto";
|
|
37982
|
+
}
|
|
37983
|
+
apiTools = confirmedTools;
|
|
37984
|
+
for (const [name] of executorMap) {
|
|
37985
|
+
if (!kept.has(name)) executorMap.delete(name);
|
|
37986
|
+
}
|
|
37987
|
+
}
|
|
37988
|
+
}
|
|
37915
37989
|
if (onThinking) {
|
|
37916
37990
|
const thinkingResults = executionResults.filter(
|
|
37917
37991
|
(r) => !r.name || executorMap.get(r.name)?.skipContinuation !== true
|
package/dist/server/index.d.mts
CHANGED
|
@@ -3393,6 +3393,20 @@ interface SelectServerToolsForPromptOptions {
|
|
|
3393
3393
|
* {@link resolveDeferredServerTools}). Omit/disabled → today's filtered selection.
|
|
3394
3394
|
*/
|
|
3395
3395
|
deferLoading?: DeferLoadingConfig;
|
|
3396
|
+
/**
|
|
3397
|
+
* Tool-set names that are sticky for this conversation — the same list you
|
|
3398
|
+
* pass to `useChatStorage`'s `activeToolSets`, e.g. from
|
|
3399
|
+
* `deriveActiveToolSets`. With a filter function, the server-tool members of
|
|
3400
|
+
* these sets are selected whatever the prompt scored, even on a prompt too
|
|
3401
|
+
* short to embed. Omit for selection from the prompt alone.
|
|
3402
|
+
*/
|
|
3403
|
+
activeToolSets?: string[];
|
|
3404
|
+
/**
|
|
3405
|
+
* The caller's sets beyond {@link BUILT_IN_TOOL_SETS} — the same list you pass
|
|
3406
|
+
* to `useChatStorage`'s `extraToolSets` — so a custom set named in
|
|
3407
|
+
* `activeToolSets` stays sticky here too.
|
|
3408
|
+
*/
|
|
3409
|
+
extraToolSets?: ToolSet[];
|
|
3396
3410
|
}
|
|
3397
3411
|
/**
|
|
3398
3412
|
* Select server-side tools for a prompt using the same path
|
package/dist/server/index.d.ts
CHANGED
|
@@ -3393,6 +3393,20 @@ interface SelectServerToolsForPromptOptions {
|
|
|
3393
3393
|
* {@link resolveDeferredServerTools}). Omit/disabled → today's filtered selection.
|
|
3394
3394
|
*/
|
|
3395
3395
|
deferLoading?: DeferLoadingConfig;
|
|
3396
|
+
/**
|
|
3397
|
+
* Tool-set names that are sticky for this conversation — the same list you
|
|
3398
|
+
* pass to `useChatStorage`'s `activeToolSets`, e.g. from
|
|
3399
|
+
* `deriveActiveToolSets`. With a filter function, the server-tool members of
|
|
3400
|
+
* these sets are selected whatever the prompt scored, even on a prompt too
|
|
3401
|
+
* short to embed. Omit for selection from the prompt alone.
|
|
3402
|
+
*/
|
|
3403
|
+
activeToolSets?: string[];
|
|
3404
|
+
/**
|
|
3405
|
+
* The caller's sets beyond {@link BUILT_IN_TOOL_SETS} — the same list you pass
|
|
3406
|
+
* to `useChatStorage`'s `extraToolSets` — so a custom set named in
|
|
3407
|
+
* `activeToolSets` stays sticky here too.
|
|
3408
|
+
*/
|
|
3409
|
+
extraToolSets?: ToolSet[];
|
|
3396
3410
|
}
|
|
3397
3411
|
/**
|
|
3398
3412
|
* Select server-side tools for a prompt using the same path
|
package/dist/server/index.mjs
CHANGED
|
@@ -31023,6 +31023,9 @@ function createDurableAutoExtractor(options) {
|
|
|
31023
31023
|
};
|
|
31024
31024
|
}
|
|
31025
31025
|
|
|
31026
|
+
// src/tools/confirmConstants.ts
|
|
31027
|
+
var CONFIRM_TOOL_NAME = "prompt_user_confirm";
|
|
31028
|
+
|
|
31026
31029
|
// src/tools/appBuilderPrompt.ts
|
|
31027
31030
|
var APP_BUILDER_PROMPT = `App Builder tools (create_file, patch_file, and the rest described below) are available this turn, but they are OPTIONAL \u2014 having them does not mean you should build anything.
|
|
31028
31031
|
|
|
@@ -31314,6 +31317,7 @@ function filterServerTools(serverTools, includeNames) {
|
|
|
31314
31317
|
const includeSet = new Set(includeNames);
|
|
31315
31318
|
return serverTools.filter((tool) => includeSet.has(tool.name));
|
|
31316
31319
|
}
|
|
31320
|
+
var TOOL_SEARCH_TOOL_NAME = "tool_search_tool_regex";
|
|
31317
31321
|
function resolveDeferredServerTools(allServerTools, serverToolsFilter, config) {
|
|
31318
31322
|
const allowed = serverToolsFilter === void 0 || typeof serverToolsFilter === "function" ? allServerTools : filterServerTools(allServerTools, [...serverToolsFilter]);
|
|
31319
31323
|
const excluded = new Set(config.excludeTools ?? []);
|
|
@@ -31547,8 +31551,30 @@ var BUILT_IN_TOOL_SETS = [
|
|
|
31547
31551
|
members: ["dropbox_list_folders", "dropbox_get_file_content", "dropbox_search"],
|
|
31548
31552
|
anchors: ["dropbox_list_folders", "dropbox_search"],
|
|
31549
31553
|
anchorMinSimilarity: 0.53
|
|
31554
|
+
},
|
|
31555
|
+
{
|
|
31556
|
+
// Server tools, so this set does its work through
|
|
31557
|
+
// withActiveToolSetServerTools: once a restaurant tool has run, terse
|
|
31558
|
+
// follow-ups ("okay", "same as before") keep the booking chain. Each tool
|
|
31559
|
+
// still reaches a fresh booking request on its own description.
|
|
31560
|
+
// Anchors are deliberately empty (like the client's Nearby set): the set
|
|
31561
|
+
// is only for stickiness, not a new way to activate on a prompt.
|
|
31562
|
+
// prompt_user_confirm is left out of members: autoFilterClientTools always
|
|
31563
|
+
// sends it, and as a member any unrelated confirmation would pin this set.
|
|
31564
|
+
name: "restaurant-booking",
|
|
31565
|
+
members: [
|
|
31566
|
+
"AnumaPaymentsMCP-anuma_find_restaurant",
|
|
31567
|
+
"AnumaPaymentsMCP-anuma_check_restaurant_availability",
|
|
31568
|
+
"AnumaPaymentsMCP-anuma_book_restaurant"
|
|
31569
|
+
],
|
|
31570
|
+
anchors: []
|
|
31550
31571
|
}
|
|
31551
31572
|
];
|
|
31573
|
+
var CONFIRMED_ACTION_TOOL_SETS = /* @__PURE__ */ new Map([
|
|
31574
|
+
["book_restaurant", "restaurant-booking"],
|
|
31575
|
+
["anuma_book_restaurant", "restaurant-booking"],
|
|
31576
|
+
["anumapaymentsmcp-anuma_book_restaurant", "restaurant-booking"]
|
|
31577
|
+
]);
|
|
31552
31578
|
function expandToolSetsAdditive(matchedNames, availableNames, scores, toolSets, activeSetNames) {
|
|
31553
31579
|
const result = new Set(matchedNames);
|
|
31554
31580
|
for (const ts of toolSets) {
|
|
@@ -31580,6 +31606,16 @@ function activatedToolSetNames(scores, toolSets = BUILT_IN_TOOL_SETS, activeSetN
|
|
|
31580
31606
|
}
|
|
31581
31607
|
return activated;
|
|
31582
31608
|
}
|
|
31609
|
+
function withActiveToolSetServerTools(selected, allServerTools, serverToolsFilter, activeToolSets = [], extraToolSets = []) {
|
|
31610
|
+
if (activeToolSets.length === 0) return selected;
|
|
31611
|
+
const sticky = new Set(
|
|
31612
|
+
[...BUILT_IN_TOOL_SETS, ...extraToolSets].filter((ts) => activeToolSets.includes(ts.name)).flatMap((ts) => ts.members)
|
|
31613
|
+
);
|
|
31614
|
+
for (const name of serverToolsFilter.excludeTools ?? []) sticky.delete(name);
|
|
31615
|
+
for (const tool of selected) sticky.delete(tool.name);
|
|
31616
|
+
const added = allServerTools.filter((tool) => sticky.has(tool.name));
|
|
31617
|
+
return added.length > 0 ? [...selected, ...added] : selected;
|
|
31618
|
+
}
|
|
31583
31619
|
function toolSetSystemPrompts(selectedToolNames, toolSets = BUILT_IN_TOOL_SETS, activatedSetNames) {
|
|
31584
31620
|
const selected = selectedToolNames instanceof Set ? selectedToolNames : new Set(selectedToolNames);
|
|
31585
31621
|
const prompts = [];
|
|
@@ -31693,7 +31729,9 @@ async function selectServerToolsForPrompt(options) {
|
|
|
31693
31729
|
embeddingModel,
|
|
31694
31730
|
cacheExpirationMs,
|
|
31695
31731
|
cache,
|
|
31696
|
-
deferLoading
|
|
31732
|
+
deferLoading,
|
|
31733
|
+
activeToolSets,
|
|
31734
|
+
extraToolSets
|
|
31697
31735
|
} = options;
|
|
31698
31736
|
if (serverToolsFilter === void 0) return [];
|
|
31699
31737
|
if (Array.isArray(serverToolsFilter) && serverToolsFilter.length === 0) return [];
|
|
@@ -31707,7 +31745,14 @@ async function selectServerToolsForPrompt(options) {
|
|
|
31707
31745
|
if (deferLoading?.enabled)
|
|
31708
31746
|
return resolveDeferredServerTools(allServerTools, serverToolsFilter, deferLoading);
|
|
31709
31747
|
if (typeof serverToolsFilter === "function") {
|
|
31710
|
-
|
|
31748
|
+
const withSticky = (selected) => withActiveToolSetServerTools(
|
|
31749
|
+
selected,
|
|
31750
|
+
allServerTools,
|
|
31751
|
+
serverToolsFilter,
|
|
31752
|
+
activeToolSets,
|
|
31753
|
+
extraToolSets
|
|
31754
|
+
);
|
|
31755
|
+
if (prompt.length < MIN_CONTENT_LENGTH_FOR_TOOLS) return withSticky([]);
|
|
31711
31756
|
let promptEmbedding;
|
|
31712
31757
|
try {
|
|
31713
31758
|
promptEmbedding = await generateEmbedding(prompt, {
|
|
@@ -31716,10 +31761,10 @@ async function selectServerToolsForPrompt(options) {
|
|
|
31716
31761
|
model: embeddingModel
|
|
31717
31762
|
});
|
|
31718
31763
|
} catch {
|
|
31719
|
-
return [];
|
|
31764
|
+
return withSticky([]);
|
|
31720
31765
|
}
|
|
31721
31766
|
const names = serverToolsFilter(promptEmbedding, allServerTools);
|
|
31722
|
-
return filterServerTools(allServerTools, names);
|
|
31767
|
+
return withSticky(filterServerTools(allServerTools, names));
|
|
31723
31768
|
}
|
|
31724
31769
|
return filterServerTools(allServerTools, serverToolsFilter);
|
|
31725
31770
|
}
|
|
@@ -35473,6 +35518,22 @@ function getToolName(tool) {
|
|
|
35473
35518
|
if (typeof flatName === "string") return flatName;
|
|
35474
35519
|
return void 0;
|
|
35475
35520
|
}
|
|
35521
|
+
function toolsAfterConfirmation(apiTools, executionResults) {
|
|
35522
|
+
const members = /* @__PURE__ */ new Set();
|
|
35523
|
+
for (const r of executionResults) {
|
|
35524
|
+
if (r.name !== CONFIRM_TOOL_NAME) continue;
|
|
35525
|
+
const answer = r.result;
|
|
35526
|
+
if (answer?.confirmed !== true || typeof answer.action !== "string") continue;
|
|
35527
|
+
const setName = CONFIRMED_ACTION_TOOL_SETS.get(answer.action.trim().toLowerCase());
|
|
35528
|
+
const set = BUILT_IN_TOOL_SETS.find((s) => s.name === setName);
|
|
35529
|
+
for (const member of set?.members ?? []) members.add(member);
|
|
35530
|
+
}
|
|
35531
|
+
if (!apiTools.some((t) => members.has(getToolName(t) ?? ""))) return void 0;
|
|
35532
|
+
return apiTools.filter((t) => {
|
|
35533
|
+
const name = getToolName(t) ?? "";
|
|
35534
|
+
return members.has(name) || name === CONFIRM_TOOL_NAME || name === TOOL_SEARCH_TOOL_NAME;
|
|
35535
|
+
});
|
|
35536
|
+
}
|
|
35476
35537
|
var STREAM_RESUMABLE_HEADER = "X-Stream-Resumable";
|
|
35477
35538
|
var INFERENCE_ID_HEADER = "X-Inference-ID";
|
|
35478
35539
|
var CONVERSATION_ID_HEADER = "X-Conversation-ID";
|
|
@@ -36158,6 +36219,19 @@ Executing tool: ${toolInfo}
|
|
|
36158
36219
|
}
|
|
36159
36220
|
}
|
|
36160
36221
|
}
|
|
36222
|
+
if (apiTools) {
|
|
36223
|
+
const confirmedTools = toolsAfterConfirmation(apiTools, executionResults);
|
|
36224
|
+
if (confirmedTools) {
|
|
36225
|
+
const kept = new Set(confirmedTools.map(getToolName));
|
|
36226
|
+
if (typeof toolChoice === "string" && !kept.has(toolChoice) && apiTools.some((t) => getToolName(t) === toolChoice)) {
|
|
36227
|
+
toolChoice = "auto";
|
|
36228
|
+
}
|
|
36229
|
+
apiTools = confirmedTools;
|
|
36230
|
+
for (const [name] of executorMap) {
|
|
36231
|
+
if (!kept.has(name)) executorMap.delete(name);
|
|
36232
|
+
}
|
|
36233
|
+
}
|
|
36234
|
+
}
|
|
36161
36235
|
if (onThinking) {
|
|
36162
36236
|
const thinkingResults = executionResults.filter(
|
|
36163
36237
|
(r) => !r.name || executorMap.get(r.name)?.skipContinuation !== true
|
|
@@ -116,7 +116,8 @@ __export(index_exports, {
|
|
|
116
116
|
selectServerToolsForPrompt: () => selectServerToolsForPrompt,
|
|
117
117
|
shouldRefreshTools: () => shouldRefreshTools,
|
|
118
118
|
stripCoercedMemoryWrite: () => stripCoercedMemoryWrite,
|
|
119
|
-
toolSetSystemPrompts: () => toolSetSystemPrompts
|
|
119
|
+
toolSetSystemPrompts: () => toolSetSystemPrompts,
|
|
120
|
+
withActiveToolSetServerTools: () => withActiveToolSetServerTools
|
|
120
121
|
});
|
|
121
122
|
module.exports = __toCommonJS(index_exports);
|
|
122
123
|
|
|
@@ -1993,6 +1994,23 @@ var BUILT_IN_TOOL_SETS = [
|
|
|
1993
1994
|
members: ["dropbox_list_folders", "dropbox_get_file_content", "dropbox_search"],
|
|
1994
1995
|
anchors: ["dropbox_list_folders", "dropbox_search"],
|
|
1995
1996
|
anchorMinSimilarity: 0.53
|
|
1997
|
+
},
|
|
1998
|
+
{
|
|
1999
|
+
// Server tools, so this set does its work through
|
|
2000
|
+
// withActiveToolSetServerTools: once a restaurant tool has run, terse
|
|
2001
|
+
// follow-ups ("okay", "same as before") keep the booking chain. Each tool
|
|
2002
|
+
// still reaches a fresh booking request on its own description.
|
|
2003
|
+
// Anchors are deliberately empty (like the client's Nearby set): the set
|
|
2004
|
+
// is only for stickiness, not a new way to activate on a prompt.
|
|
2005
|
+
// prompt_user_confirm is left out of members: autoFilterClientTools always
|
|
2006
|
+
// sends it, and as a member any unrelated confirmation would pin this set.
|
|
2007
|
+
name: "restaurant-booking",
|
|
2008
|
+
members: [
|
|
2009
|
+
"AnumaPaymentsMCP-anuma_find_restaurant",
|
|
2010
|
+
"AnumaPaymentsMCP-anuma_check_restaurant_availability",
|
|
2011
|
+
"AnumaPaymentsMCP-anuma_book_restaurant"
|
|
2012
|
+
],
|
|
2013
|
+
anchors: []
|
|
1996
2014
|
}
|
|
1997
2015
|
];
|
|
1998
2016
|
function applyToolSets(matchedNames, availableNames, scores, toolSets = BUILT_IN_TOOL_SETS, independentThreshold = 0.65) {
|
|
@@ -2055,6 +2073,16 @@ function activatedToolSetNames(scores, toolSets = BUILT_IN_TOOL_SETS, activeSetN
|
|
|
2055
2073
|
}
|
|
2056
2074
|
return activated;
|
|
2057
2075
|
}
|
|
2076
|
+
function withActiveToolSetServerTools(selected, allServerTools, serverToolsFilter, activeToolSets = [], extraToolSets = []) {
|
|
2077
|
+
if (activeToolSets.length === 0) return selected;
|
|
2078
|
+
const sticky = new Set(
|
|
2079
|
+
[...BUILT_IN_TOOL_SETS, ...extraToolSets].filter((ts) => activeToolSets.includes(ts.name)).flatMap((ts) => ts.members)
|
|
2080
|
+
);
|
|
2081
|
+
for (const name of serverToolsFilter.excludeTools ?? []) sticky.delete(name);
|
|
2082
|
+
for (const tool of selected) sticky.delete(tool.name);
|
|
2083
|
+
const added = allServerTools.filter((tool) => sticky.has(tool.name));
|
|
2084
|
+
return added.length > 0 ? [...selected, ...added] : selected;
|
|
2085
|
+
}
|
|
2058
2086
|
function toolSetSystemPrompts(selectedToolNames, toolSets = BUILT_IN_TOOL_SETS, activatedSetNames) {
|
|
2059
2087
|
const selected = selectedToolNames instanceof Set ? selectedToolNames : new Set(selectedToolNames);
|
|
2060
2088
|
const prompts = [];
|
|
@@ -2168,7 +2196,9 @@ async function selectServerToolsForPrompt(options) {
|
|
|
2168
2196
|
embeddingModel,
|
|
2169
2197
|
cacheExpirationMs,
|
|
2170
2198
|
cache,
|
|
2171
|
-
deferLoading
|
|
2199
|
+
deferLoading,
|
|
2200
|
+
activeToolSets,
|
|
2201
|
+
extraToolSets
|
|
2172
2202
|
} = options;
|
|
2173
2203
|
if (serverToolsFilter === void 0) return [];
|
|
2174
2204
|
if (Array.isArray(serverToolsFilter) && serverToolsFilter.length === 0) return [];
|
|
@@ -2182,7 +2212,14 @@ async function selectServerToolsForPrompt(options) {
|
|
|
2182
2212
|
if (deferLoading?.enabled)
|
|
2183
2213
|
return resolveDeferredServerTools(allServerTools, serverToolsFilter, deferLoading);
|
|
2184
2214
|
if (typeof serverToolsFilter === "function") {
|
|
2185
|
-
|
|
2215
|
+
const withSticky = (selected) => withActiveToolSetServerTools(
|
|
2216
|
+
selected,
|
|
2217
|
+
allServerTools,
|
|
2218
|
+
serverToolsFilter,
|
|
2219
|
+
activeToolSets,
|
|
2220
|
+
extraToolSets
|
|
2221
|
+
);
|
|
2222
|
+
if (prompt.length < MIN_CONTENT_LENGTH_FOR_TOOLS) return withSticky([]);
|
|
2186
2223
|
let promptEmbedding;
|
|
2187
2224
|
try {
|
|
2188
2225
|
promptEmbedding = await generateEmbedding(prompt, {
|
|
@@ -2191,10 +2228,10 @@ async function selectServerToolsForPrompt(options) {
|
|
|
2191
2228
|
model: embeddingModel
|
|
2192
2229
|
});
|
|
2193
2230
|
} catch {
|
|
2194
|
-
return [];
|
|
2231
|
+
return withSticky([]);
|
|
2195
2232
|
}
|
|
2196
2233
|
const names = serverToolsFilter(promptEmbedding, allServerTools);
|
|
2197
|
-
return filterServerTools(allServerTools, names);
|
|
2234
|
+
return withSticky(filterServerTools(allServerTools, names));
|
|
2198
2235
|
}
|
|
2199
2236
|
return filterServerTools(allServerTools, serverToolsFilter);
|
|
2200
2237
|
}
|
|
@@ -2836,5 +2873,6 @@ async function selectCouncilClientTools(input, options) {
|
|
|
2836
2873
|
selectServerToolsForPrompt,
|
|
2837
2874
|
shouldRefreshTools,
|
|
2838
2875
|
stripCoercedMemoryWrite,
|
|
2839
|
-
toolSetSystemPrompts
|
|
2876
|
+
toolSetSystemPrompts,
|
|
2877
|
+
withActiveToolSetServerTools
|
|
2840
2878
|
});
|
|
@@ -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
|
-
|
|
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
|
};
|