@anuma/sdk 6.11.0 → 6.12.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/{chunk-ZO7S3TBT.mjs → chunk-732ZLOLA.mjs} +11 -8
- package/dist/expo/index.cjs +77 -31
- package/dist/expo/index.d.mts +83 -0
- package/dist/expo/index.d.ts +83 -0
- package/dist/expo/index.mjs +66 -24
- package/dist/expo/{recall-OALPGL3H.mjs → recall-PIATJ336.mjs} +1 -1
- package/dist/index.cjs +5 -1
- package/dist/index.d.mts +31 -3
- package/dist/index.d.ts +31 -3
- package/dist/index.mjs +5 -1
- package/dist/react/{chunk-HNQ2ZEFF.mjs → chunk-6IBFFWCE.mjs} +11 -8
- package/dist/react/index.cjs +85 -33
- package/dist/react/index.d.mts +98 -6
- package/dist/react/index.d.ts +98 -6
- package/dist/react/index.mjs +74 -26
- package/dist/react/{recall-F5DBVCU2.mjs → recall-QUWN7DJ7.mjs} +1 -1
- package/dist/server/{chunk-BKB6AT7Z.mjs → chunk-7YTEE6JT.mjs} +11 -8
- package/dist/server/index.cjs +61 -27
- package/dist/server/index.d.mts +98 -6
- package/dist/server/index.d.ts +98 -6
- package/dist/server/index.mjs +50 -20
- package/dist/server/{recall-HVIEAH7J.mjs → recall-HOVWMT4Q.mjs} +1 -1
- package/dist/tools/selection/index.cjs +25 -2
- package/dist/tools/selection/index.d.mts +72 -7
- package/dist/tools/selection/index.d.ts +72 -7
- package/dist/tools/selection/index.mjs +23 -2
- package/package.json +1 -1
package/dist/server/index.d.ts
CHANGED
|
@@ -3013,6 +3013,22 @@ interface DeferLoadingConfig {
|
|
|
3013
3013
|
enabled: boolean;
|
|
3014
3014
|
/** Server-tool names to keep non-deferred (besides the tool-search tool), in priority order. */
|
|
3015
3015
|
hotToolNames: readonly string[];
|
|
3016
|
+
/**
|
|
3017
|
+
* Server-tool names to drop entirely while defer-loading is on.
|
|
3018
|
+
*
|
|
3019
|
+
* Defer widens the per-turn selection to the whole catalog, which also bypasses the `excludeTools`
|
|
3020
|
+
* baked into a caller's semantic filter. A filter built by {@link createServerToolsFilter} tags itself
|
|
3021
|
+
* with its own exclusions and those are honoured automatically — so most callers need nothing here.
|
|
3022
|
+
*
|
|
3023
|
+
* Set this when the filter's tag can't be seen: a hand-written filter, a filter wrapped in a plain
|
|
3024
|
+
* closure (the wrapper drops the tag), or a static-array `serverToolsFilter`. Anything excluded
|
|
3025
|
+
* UNCONDITIONALLY (a tool the app replaces with its own UI, a capability the model already has
|
|
3026
|
+
* natively) belongs in one of the two places, or defer quietly hands it back to the model.
|
|
3027
|
+
*
|
|
3028
|
+
* This list is UNIONED with the filter's own tag, never a replacement for it — so adding one name
|
|
3029
|
+
* here cannot re-admit the tools the filter already excludes.
|
|
3030
|
+
*/
|
|
3031
|
+
excludeTools?: readonly string[];
|
|
3016
3032
|
}
|
|
3017
3033
|
/**
|
|
3018
3034
|
* Result of tool matching with similarity score
|
|
@@ -3192,7 +3208,7 @@ interface CreateServerToolsFilterOptions {
|
|
|
3192
3208
|
* });
|
|
3193
3209
|
* ```
|
|
3194
3210
|
*/
|
|
3195
|
-
declare function createServerToolsFilter(options?: CreateServerToolsFilterOptions):
|
|
3211
|
+
declare function createServerToolsFilter(options?: CreateServerToolsFilterOptions): ServerToolsFilterFunction;
|
|
3196
3212
|
/**
|
|
3197
3213
|
* Default exclusions baked into `defaultServerToolsFilter`.
|
|
3198
3214
|
*
|
|
@@ -3258,13 +3274,21 @@ declare const SERVER_TOOL_DEPENDENCY_SETS: ToolSet[];
|
|
|
3258
3274
|
* If you need to customize (extra excludes, different limits, opt into
|
|
3259
3275
|
* tool-set expansion), call `createServerToolsFilter` directly.
|
|
3260
3276
|
*/
|
|
3261
|
-
declare const defaultServerToolsFilter:
|
|
3277
|
+
declare const defaultServerToolsFilter: ServerToolsFilterFunction;
|
|
3262
3278
|
/**
|
|
3263
3279
|
* Type for a server-tools filter — a function that takes prompt embeddings
|
|
3264
3280
|
* and the full server tool catalog and returns the names of tools to keep.
|
|
3265
3281
|
* Matches `useChatStorage`'s `serverTools` callback signature.
|
|
3266
3282
|
*/
|
|
3267
|
-
type ServerToolsFilterFunction = (embeddings: number[] | number[][], tools: ServerTool[]) => string[]
|
|
3283
|
+
type ServerToolsFilterFunction = ((embeddings: number[] | number[][], tools: ServerTool[]) => string[]) & {
|
|
3284
|
+
/**
|
|
3285
|
+
* The unconditional exclusions this filter applies, exposed by
|
|
3286
|
+
* {@link createServerToolsFilter} so defer-loading can honour them without the caller
|
|
3287
|
+
* repeating the list — see {@link resolveDeferredServerTools}. Absent on a hand-written
|
|
3288
|
+
* filter, or on one wrapped in a plain closure.
|
|
3289
|
+
*/
|
|
3290
|
+
readonly excludeTools?: readonly string[];
|
|
3291
|
+
};
|
|
3268
3292
|
/**
|
|
3269
3293
|
* Options for `selectServerToolsForPrompt`.
|
|
3270
3294
|
*/
|
|
@@ -3292,9 +3316,10 @@ interface SelectServerToolsForPromptOptions {
|
|
|
3292
3316
|
*/
|
|
3293
3317
|
cache?: ToolsCacheBackend;
|
|
3294
3318
|
/**
|
|
3295
|
-
* Phase 3 defer-loading. When `enabled`, this helper
|
|
3296
|
-
*
|
|
3297
|
-
*
|
|
3319
|
+
* Phase 3 defer-loading. When `enabled`, this helper skips SEMANTIC filtering to mirror
|
|
3320
|
+
* useChatStorage's responses send path, which hands the catalog to mergeTools + tool-search. The
|
|
3321
|
+
* caller's unconditional constraints still apply — an explicit static array, and exclusions (see
|
|
3322
|
+
* {@link resolveDeferredServerTools}). Omit/disabled → today's filtered selection.
|
|
3298
3323
|
*/
|
|
3299
3324
|
deferLoading?: DeferLoadingConfig;
|
|
3300
3325
|
}
|
|
@@ -4698,6 +4723,51 @@ interface EntityOperationsContext {
|
|
|
4698
4723
|
allowUnscopedRows?: boolean;
|
|
4699
4724
|
}
|
|
4700
4725
|
|
|
4726
|
+
/**
|
|
4727
|
+
* Class-B task types — the vocabulary of the `X-Anuma-Task-Type` header.
|
|
4728
|
+
*
|
|
4729
|
+
* A Class-B flow has ONE fixed purpose and no conversation: extract memories
|
|
4730
|
+
* from a snippet, pick a topic, consolidate duplicates, classify a query. Today
|
|
4731
|
+
* each of those builds its own system prompt on the client and sends it as a
|
|
4732
|
+
* `role:system` message, which makes the prompt a suggestion rather than a
|
|
4733
|
+
* contract — a caller can reword it into "you are a general assistant" and get
|
|
4734
|
+
* general chat at internal-endpoint prices.
|
|
4735
|
+
*
|
|
4736
|
+
* The fix is that the SERVER owns the text and the client only names the task.
|
|
4737
|
+
* This header is the name. The portal allowlists it against its own copy of this
|
|
4738
|
+
* enum (ai-portal `internal/systemprompt/tasks.go`) and DROPS anything it does
|
|
4739
|
+
* not recognise, so an unknown value degrades to "no task declared" rather than
|
|
4740
|
+
* failing the request.
|
|
4741
|
+
*
|
|
4742
|
+
* ⚠ These string values are a wire contract with ai-portal. Adding one here
|
|
4743
|
+
* before the portal knows it is harmless (it is dropped); renaming or removing
|
|
4744
|
+
* one silently stops that flow being counted. Keep them in step with
|
|
4745
|
+
* `AllTaskTypes` on the portal side, and see ai-portal
|
|
4746
|
+
* `docs/BACKEND_OWNED_TASK_PROMPTS.md` for the rollout.
|
|
4747
|
+
*
|
|
4748
|
+
* ⚠ RELEASE ORDER. This union is a PUBLIC type, so a split is breaking in both
|
|
4749
|
+
* directions and has to be sequenced:
|
|
4750
|
+
*
|
|
4751
|
+
* 1. merge + publish this package;
|
|
4752
|
+
* 2. bump `@anuma/sdk` in the consumer and switch its call sites to the new
|
|
4753
|
+
* names in the same commit.
|
|
4754
|
+
*
|
|
4755
|
+
* A consumer on the OLD version cannot compile the new names, and a consumer on
|
|
4756
|
+
* the NEW version cannot compile the retired ones (`app_inspiration` is gone
|
|
4757
|
+
* here, replaced by the three `app_inspiration_*` names). Both halves of that
|
|
4758
|
+
* are type-only — the wire itself always degrades safely, because the portal
|
|
4759
|
+
* drops any value it does not recognise. Concretely: ai-memoryless-client#5782
|
|
4760
|
+
* is blocked on this publish for exactly that reason.
|
|
4761
|
+
*
|
|
4762
|
+
* Deliberately ABSENT: agent personas, `reflect()` when it answers the user, and
|
|
4763
|
+
* the app-idea chat. Those carry an open conversation with the user, so a fixed
|
|
4764
|
+
* server-owned prompt would be wrong rather than merely premature — the same
|
|
4765
|
+
* boundary {@link INTERNAL_FLOW_MARKER} draws.
|
|
4766
|
+
*
|
|
4767
|
+
* @public
|
|
4768
|
+
*/
|
|
4769
|
+
type TaskType = "title" | "commit_message" | "memory_extract" | "memory_dedup" | "memory_decay" | "memory_injection_check" | "memory_verify_support" | "memory_autosort" | "memory_topic" | "memory_consolidate" | "memory_decompose" | "memory_profile_synth" | "memory_graph" | "folder_context" | "selection_memory" | "summarize" | "style_analysis" | "classify_search" | "app_inspiration_generate" | "app_inspiration_trends" | "app_inspiration_remix" | "spotlight_image" | "slide_image" | "slide_video" | "slide_music" | "slide_sfx" | "media_video" | "media_audio" | "media_bg_removal" | "media_image_preset" | "tool_app_builder" | "tool_document_builder" | "tool_slides" | "tool_slides_image_gen" | "connector_guidance" | "cf_task" | "xbot_intent" | "xbot_council" | "scheduled_task";
|
|
4770
|
+
|
|
4701
4771
|
/**
|
|
4702
4772
|
* Shared portal LLM call for the memory pipeline.
|
|
4703
4773
|
*
|
|
@@ -8799,6 +8869,28 @@ interface ReflectOptions extends RecallOptions, PortalLlmAuth {
|
|
|
8799
8869
|
maxTokens?: number;
|
|
8800
8870
|
/** Override the grounding system prompt. */
|
|
8801
8871
|
systemPrompt?: string;
|
|
8872
|
+
/**
|
|
8873
|
+
* Extra caller instruction to carry on the USER turn, between the question and
|
|
8874
|
+
* the evidence block (see the `userMessage` assembly below). This is the slot a
|
|
8875
|
+
* background caller uses to keep its per-request data OUT of the system message
|
|
8876
|
+
* without colliding with the numbered evidence list — profile-facet synthesis
|
|
8877
|
+
* puts its section label, guidance and response-field hint here so its system
|
|
8878
|
+
* half can stay fixed and server-ownable.
|
|
8879
|
+
*/
|
|
8880
|
+
userInstructions?: string;
|
|
8881
|
+
/**
|
|
8882
|
+
* Class-B task name for the `X-Anuma-Task-Type` header, or nothing.
|
|
8883
|
+
*
|
|
8884
|
+
* Deliberately OPTIONAL and unset by default. reflect() also answers the user's
|
|
8885
|
+
* OWN question, and that traffic is chat, not an internal flow — declaring a
|
|
8886
|
+
* task type unconditionally here would put an internal-flow name on real
|
|
8887
|
+
* conversation, which is the same boundary `INTERNAL_FLOW_MARKER` draws
|
|
8888
|
+
* (reflect is deliberately unmarked; its background caller marks its own
|
|
8889
|
+
* prompt — see ../internalFlowMarker.ts). So the name is per call: only a
|
|
8890
|
+
* caller with ONE fixed purpose passes
|
|
8891
|
+
* one, and today that is profile-facet synthesis (`memory_profile_synth`).
|
|
8892
|
+
*/
|
|
8893
|
+
taskType?: TaskType;
|
|
8802
8894
|
/** Endpoint for the answer LLM. */
|
|
8803
8895
|
baseUrl?: string;
|
|
8804
8896
|
/** Override fetch (for tests). */
|
package/dist/server/index.mjs
CHANGED
|
@@ -141,7 +141,7 @@ import {
|
|
|
141
141
|
updateVaultMemoryOp,
|
|
142
142
|
upsertMessageOp,
|
|
143
143
|
vaultMemoryToStored
|
|
144
|
-
} from "./chunk-
|
|
144
|
+
} from "./chunk-7YTEE6JT.mjs";
|
|
145
145
|
import {
|
|
146
146
|
createStreamingDeAnonymizer,
|
|
147
147
|
notifyConsolidationFallback,
|
|
@@ -6963,11 +6963,13 @@ Respond with ONLY a single JSON object conforming to this JSON Schema, with no p
|
|
|
6963
6963
|
${JSON.stringify(
|
|
6964
6964
|
options.responseSchema
|
|
6965
6965
|
)}` : basePrompt;
|
|
6966
|
-
const userMessage =
|
|
6967
|
-
|
|
6968
|
-
|
|
6969
|
-
|
|
6970
|
-
|
|
6966
|
+
const userMessage = [
|
|
6967
|
+
`Question:
|
|
6968
|
+
${trimmed}`,
|
|
6969
|
+
...options.userInstructions ? [options.userInstructions] : [],
|
|
6970
|
+
`Memories (use only these as evidence):
|
|
6971
|
+
${evidence}`
|
|
6972
|
+
].join("\n\n");
|
|
6971
6973
|
const maxTokens = options.maxTokens ?? DEFAULT_MAX_TOKENS;
|
|
6972
6974
|
const fetchImpl = options.fetchFn ?? fetch;
|
|
6973
6975
|
const log = getLogger();
|
|
@@ -6981,7 +6983,13 @@ ${evidence}`;
|
|
|
6981
6983
|
try {
|
|
6982
6984
|
response = await fetchImpl(`${baseUrl}/api/v1/chat/completions`, {
|
|
6983
6985
|
method: "POST",
|
|
6984
|
-
|
|
6986
|
+
// No task type unless the caller named one — an undeclared task adds no
|
|
6987
|
+
// header at all, which is what keeps user-facing reflect() unlabelled.
|
|
6988
|
+
headers: {
|
|
6989
|
+
...authHeaders,
|
|
6990
|
+
...taskTypeHeader(options.taskType),
|
|
6991
|
+
"Content-Type": "application/json"
|
|
6992
|
+
},
|
|
6985
6993
|
body: JSON.stringify({
|
|
6986
6994
|
model,
|
|
6987
6995
|
// Modern OpenAI field; the portal reads only `max_completion_tokens`
|
|
@@ -7421,10 +7429,15 @@ async function synthesizeFacet(facet, ctx, options, prior) {
|
|
|
7421
7429
|
limit,
|
|
7422
7430
|
types: ["fact"],
|
|
7423
7431
|
maxTokens: DEFAULT_FACET_MAX_TOKENS,
|
|
7424
|
-
// Profile-facet synthesis is a background op, so it marks its own prompt
|
|
7425
|
-
// reflect() itself must
|
|
7426
|
-
// and that traffic is chat, not an internal flow. See
|
|
7427
|
-
|
|
7432
|
+
// Profile-facet synthesis is a background op, so it marks its own prompt AND
|
|
7433
|
+
// names its own task. reflect() itself must do neither — it also serves the
|
|
7434
|
+
// user's own questions, and that traffic is chat, not an internal flow. See
|
|
7435
|
+
// ../internalFlowMarker and ReflectOptions.taskType.
|
|
7436
|
+
taskType: "memory_profile_synth",
|
|
7437
|
+
systemPrompt: withInternalFlowMarker(FACET_SYSTEM_PROMPT),
|
|
7438
|
+
// The facet's label/guidance/response-fields, on the user turn — what keeps
|
|
7439
|
+
// the system half fixed and therefore server-ownable.
|
|
7440
|
+
userInstructions: buildFacetUserInstructions(facet),
|
|
7428
7441
|
responseSchema: facetResponseSchema(facet.key),
|
|
7429
7442
|
memories
|
|
7430
7443
|
});
|
|
@@ -7482,19 +7495,22 @@ function fallbackSection(facet, prior) {
|
|
|
7482
7495
|
stale: true
|
|
7483
7496
|
};
|
|
7484
7497
|
}
|
|
7485
|
-
|
|
7486
|
-
const structuredField = FACET_STRUCTURED_RESPONSE_HINT[facet.key] ?? "";
|
|
7487
|
-
return `You are writing the "${facet.label}" section of a person's shareable profile, using their private memories (supplied as evidence) as the only source of truth.
|
|
7488
|
-
|
|
7489
|
-
Task for this section:
|
|
7490
|
-
${facet.guidance}
|
|
7498
|
+
var FACET_SYSTEM_PROMPT = `You are writing one section of a person's shareable profile, using their private memories (supplied as evidence) as the only source of truth. The user turn names the section, states the task for it, and gives the exact JSON shape to respond in.
|
|
7491
7499
|
|
|
7492
7500
|
Rules:
|
|
7493
7501
|
- Ground every claim in the supplied memories \u2014 never invent, infer beyond, or embellish what they support.
|
|
7494
7502
|
- If the memories don't cover this section, return an empty summary with hasEvidence=false. Do not pad or guess.
|
|
7495
7503
|
- Write in third person about the person, in a natural voice suitable for a public profile (no "I"/"you", no name repetition).
|
|
7496
7504
|
- Be concise and specific; no preamble, hedging, or meta-commentary.
|
|
7497
|
-
- Respond as JSON
|
|
7505
|
+
- Respond as JSON in exactly the shape the user turn states, with no extra fields.`;
|
|
7506
|
+
function buildFacetUserInstructions(facet) {
|
|
7507
|
+
const structuredField = FACET_STRUCTURED_RESPONSE_HINT[facet.key] ?? "";
|
|
7508
|
+
return `Section: "${facet.label}"
|
|
7509
|
+
|
|
7510
|
+
Task for this section:
|
|
7511
|
+
${facet.guidance}
|
|
7512
|
+
|
|
7513
|
+
Respond as JSON: { "summary": <the section text, or "">, "hasEvidence": <true|false>${structuredField} }.`;
|
|
7498
7514
|
}
|
|
7499
7515
|
function extractFacetText(structured) {
|
|
7500
7516
|
if (structured && typeof structured === "object") {
|
|
@@ -8286,6 +8302,15 @@ function filterServerTools(serverTools, includeNames) {
|
|
|
8286
8302
|
const includeSet = new Set(includeNames);
|
|
8287
8303
|
return serverTools.filter((tool) => includeSet.has(tool.name));
|
|
8288
8304
|
}
|
|
8305
|
+
function resolveDeferredServerTools(allServerTools, serverToolsFilter, config) {
|
|
8306
|
+
const allowed = serverToolsFilter === void 0 || typeof serverToolsFilter === "function" ? allServerTools : filterServerTools(allServerTools, [...serverToolsFilter]);
|
|
8307
|
+
const excluded = new Set(config.excludeTools ?? []);
|
|
8308
|
+
if (typeof serverToolsFilter === "function") {
|
|
8309
|
+
for (const name of serverToolsFilter.excludeTools ?? []) excluded.add(name);
|
|
8310
|
+
}
|
|
8311
|
+
if (excluded.size === 0) return allowed;
|
|
8312
|
+
return allowed.filter((tool) => !excluded.has(tool.name));
|
|
8313
|
+
}
|
|
8289
8314
|
var DEFAULT_TOOL_MATCH_OPTIONS = {
|
|
8290
8315
|
limit: 5,
|
|
8291
8316
|
minSimilarity: 0.3,
|
|
@@ -8562,7 +8587,7 @@ function createServerToolsFilter(options = {}) {
|
|
|
8562
8587
|
const exclude = new Set(options.excludeTools ?? []);
|
|
8563
8588
|
const sets = options.toolSets ?? [];
|
|
8564
8589
|
const matchOpts = options.matchOptions;
|
|
8565
|
-
|
|
8590
|
+
const filter = (embeddings, tools) => {
|
|
8566
8591
|
const matches = findMatchingTools(embeddings, tools, matchOpts);
|
|
8567
8592
|
if (matches.length === 0) return [];
|
|
8568
8593
|
const matchedNames = new Set(matches.map((m) => m.tool.name));
|
|
@@ -8580,6 +8605,10 @@ function createServerToolsFilter(options = {}) {
|
|
|
8580
8605
|
for (const name of exclude) finalNames.delete(name);
|
|
8581
8606
|
return [...finalNames];
|
|
8582
8607
|
};
|
|
8608
|
+
return Object.defineProperty(filter, "excludeTools", {
|
|
8609
|
+
value: Object.freeze([...exclude]),
|
|
8610
|
+
enumerable: false
|
|
8611
|
+
});
|
|
8583
8612
|
}
|
|
8584
8613
|
var DEFAULT_EXCLUDED_SERVER_TOOLS = [
|
|
8585
8614
|
"AnumaVisionMCP-anuma_analyze_image",
|
|
@@ -8661,7 +8690,8 @@ async function selectServerToolsForPrompt(options) {
|
|
|
8661
8690
|
return [];
|
|
8662
8691
|
}
|
|
8663
8692
|
if (allServerTools.length === 0) return [];
|
|
8664
|
-
if (deferLoading?.enabled)
|
|
8693
|
+
if (deferLoading?.enabled)
|
|
8694
|
+
return resolveDeferredServerTools(allServerTools, serverToolsFilter, deferLoading);
|
|
8665
8695
|
if (typeof serverToolsFilter === "function") {
|
|
8666
8696
|
if (prompt.length < MIN_CONTENT_LENGTH_FOR_TOOLS) return [];
|
|
8667
8697
|
let promptEmbedding;
|
|
@@ -86,6 +86,7 @@ __export(index_exports, {
|
|
|
86
86
|
computeToolGuidance: () => computeToolGuidance,
|
|
87
87
|
createServerToolsFilter: () => createServerToolsFilter,
|
|
88
88
|
defaultServerToolsFilter: () => defaultServerToolsFilter,
|
|
89
|
+
deferFormattingConfig: () => deferFormattingConfig,
|
|
89
90
|
deriveActiveToolSets: () => deriveActiveToolSets,
|
|
90
91
|
expandToolSetsAdditive: () => expandToolSetsAdditive,
|
|
91
92
|
filterAssembledClientTools: () => filterAssembledClientTools,
|
|
@@ -105,6 +106,7 @@ __export(index_exports, {
|
|
|
105
106
|
mergeTools: () => mergeTools,
|
|
106
107
|
resolveCouncilPlan: () => resolveCouncilPlan,
|
|
107
108
|
resolveCouncilServerTools: () => resolveCouncilServerTools,
|
|
109
|
+
resolveDeferredServerTools: () => resolveDeferredServerTools,
|
|
108
110
|
resolvePlan: () => resolvePlan,
|
|
109
111
|
resolveServerTools: () => resolveServerTools,
|
|
110
112
|
resolveToolChoice: () => resolveToolChoice,
|
|
@@ -1658,6 +1660,20 @@ function clientToolToCompletionsFormat(tool) {
|
|
|
1658
1660
|
}
|
|
1659
1661
|
var TOOL_SEARCH_TOOL_TYPE = "tool_search_tool_regex_20251119";
|
|
1660
1662
|
var TOOL_SEARCH_TOOL_NAME = "tool_search_tool_regex";
|
|
1663
|
+
function resolveDeferredServerTools(allServerTools, serverToolsFilter, config) {
|
|
1664
|
+
const allowed = serverToolsFilter === void 0 || typeof serverToolsFilter === "function" ? allServerTools : filterServerTools(allServerTools, [...serverToolsFilter]);
|
|
1665
|
+
const excluded = new Set(config.excludeTools ?? []);
|
|
1666
|
+
if (typeof serverToolsFilter === "function") {
|
|
1667
|
+
for (const name of serverToolsFilter.excludeTools ?? []) excluded.add(name);
|
|
1668
|
+
}
|
|
1669
|
+
if (excluded.size === 0) return allowed;
|
|
1670
|
+
return allowed.filter((tool) => !excluded.has(tool.name));
|
|
1671
|
+
}
|
|
1672
|
+
function deferFormattingConfig(serverToolsFilter, config) {
|
|
1673
|
+
if (!config?.enabled) return config;
|
|
1674
|
+
const isExplicitList = serverToolsFilter !== void 0 && typeof serverToolsFilter !== "function";
|
|
1675
|
+
return isExplicitList ? void 0 : config;
|
|
1676
|
+
}
|
|
1661
1677
|
function byNameAscending(a, b) {
|
|
1662
1678
|
if (a.name < b.name) return -1;
|
|
1663
1679
|
if (a.name > b.name) return 1;
|
|
@@ -2013,7 +2029,7 @@ function createServerToolsFilter(options = {}) {
|
|
|
2013
2029
|
const exclude = new Set(options.excludeTools ?? []);
|
|
2014
2030
|
const sets = options.toolSets ?? [];
|
|
2015
2031
|
const matchOpts = options.matchOptions;
|
|
2016
|
-
|
|
2032
|
+
const filter = (embeddings, tools) => {
|
|
2017
2033
|
const matches = findMatchingTools(embeddings, tools, matchOpts);
|
|
2018
2034
|
if (matches.length === 0) return [];
|
|
2019
2035
|
const matchedNames = new Set(matches.map((m) => m.tool.name));
|
|
@@ -2031,6 +2047,10 @@ function createServerToolsFilter(options = {}) {
|
|
|
2031
2047
|
for (const name of exclude) finalNames.delete(name);
|
|
2032
2048
|
return [...finalNames];
|
|
2033
2049
|
};
|
|
2050
|
+
return Object.defineProperty(filter, "excludeTools", {
|
|
2051
|
+
value: Object.freeze([...exclude]),
|
|
2052
|
+
enumerable: false
|
|
2053
|
+
});
|
|
2034
2054
|
}
|
|
2035
2055
|
var DEFAULT_EXCLUDED_SERVER_TOOLS = [
|
|
2036
2056
|
"AnumaVisionMCP-anuma_analyze_image",
|
|
@@ -2112,7 +2132,8 @@ async function selectServerToolsForPrompt(options) {
|
|
|
2112
2132
|
return [];
|
|
2113
2133
|
}
|
|
2114
2134
|
if (allServerTools.length === 0) return [];
|
|
2115
|
-
if (deferLoading?.enabled)
|
|
2135
|
+
if (deferLoading?.enabled)
|
|
2136
|
+
return resolveDeferredServerTools(allServerTools, serverToolsFilter, deferLoading);
|
|
2116
2137
|
if (typeof serverToolsFilter === "function") {
|
|
2117
2138
|
if (prompt.length < MIN_CONTENT_LENGTH_FOR_TOOLS) return [];
|
|
2118
2139
|
let promptEmbedding;
|
|
@@ -2738,6 +2759,7 @@ async function selectCouncilClientTools(input, options) {
|
|
|
2738
2759
|
computeToolGuidance,
|
|
2739
2760
|
createServerToolsFilter,
|
|
2740
2761
|
defaultServerToolsFilter,
|
|
2762
|
+
deferFormattingConfig,
|
|
2741
2763
|
deriveActiveToolSets,
|
|
2742
2764
|
expandToolSetsAdditive,
|
|
2743
2765
|
filterAssembledClientTools,
|
|
@@ -2757,6 +2779,7 @@ async function selectCouncilClientTools(input, options) {
|
|
|
2757
2779
|
mergeTools,
|
|
2758
2780
|
resolveCouncilPlan,
|
|
2759
2781
|
resolveCouncilServerTools,
|
|
2782
|
+
resolveDeferredServerTools,
|
|
2760
2783
|
resolvePlan,
|
|
2761
2784
|
resolveServerTools,
|
|
2762
2785
|
resolveToolChoice,
|
|
@@ -272,7 +272,63 @@ interface DeferLoadingConfig {
|
|
|
272
272
|
enabled: boolean;
|
|
273
273
|
/** Server-tool names to keep non-deferred (besides the tool-search tool), in priority order. */
|
|
274
274
|
hotToolNames: readonly string[];
|
|
275
|
+
/**
|
|
276
|
+
* Server-tool names to drop entirely while defer-loading is on.
|
|
277
|
+
*
|
|
278
|
+
* Defer widens the per-turn selection to the whole catalog, which also bypasses the `excludeTools`
|
|
279
|
+
* baked into a caller's semantic filter. A filter built by {@link createServerToolsFilter} tags itself
|
|
280
|
+
* with its own exclusions and those are honoured automatically — so most callers need nothing here.
|
|
281
|
+
*
|
|
282
|
+
* Set this when the filter's tag can't be seen: a hand-written filter, a filter wrapped in a plain
|
|
283
|
+
* closure (the wrapper drops the tag), or a static-array `serverToolsFilter`. Anything excluded
|
|
284
|
+
* UNCONDITIONALLY (a tool the app replaces with its own UI, a capability the model already has
|
|
285
|
+
* natively) belongs in one of the two places, or defer quietly hands it back to the model.
|
|
286
|
+
*
|
|
287
|
+
* This list is UNIONED with the filter's own tag, never a replacement for it — so adding one name
|
|
288
|
+
* here cannot re-admit the tools the filter already excludes.
|
|
289
|
+
*/
|
|
290
|
+
excludeTools?: readonly string[];
|
|
275
291
|
}
|
|
292
|
+
/**
|
|
293
|
+
* The server-tool set defer-loading should format for one turn.
|
|
294
|
+
*
|
|
295
|
+
* Defer changes how tools are SENT (full definitions + `defer_loading` + a tool-search tool, for a
|
|
296
|
+
* byte-stable cacheable prefix). It must not change WHICH tools the caller allowed, so two things
|
|
297
|
+
* survive that a plain "just use the whole catalog" discards:
|
|
298
|
+
*
|
|
299
|
+
* 1. **an explicit static array** — `serverToolsFilter: ['x']` is a deliberate scoping, and callers
|
|
300
|
+
* commonly pair it with `tool_choice:'required'`. Replacing it with the catalog turns "you must
|
|
301
|
+
* call x" into "you must call something, here is everything". Defer still applies, within the array.
|
|
302
|
+
* 2. **unconditional exclusions** — see {@link DeferLoadingConfig.excludeTools}.
|
|
303
|
+
*
|
|
304
|
+
* A filter FUNCTION is deliberately NOT consulted: it is per-prompt semantic narrowing, and skipping it
|
|
305
|
+
* is the whole point of defer (the model reaches everything else through tool-search). Only the
|
|
306
|
+
* caller's unconditional constraints survive.
|
|
307
|
+
*/
|
|
308
|
+
declare function resolveDeferredServerTools(allServerTools: ServerTool[], serverToolsFilter: readonly string[] | ServerToolsFilterFunction | undefined, config: DeferLoadingConfig): ServerTool[];
|
|
309
|
+
/**
|
|
310
|
+
* The defer config {@link mergeTools} should FORMAT this request with — `undefined` when defer
|
|
311
|
+
* formatting must be skipped even though defer-loading is enabled.
|
|
312
|
+
*
|
|
313
|
+
* Scoping the selection to a caller's explicit static array (see {@link resolveDeferredServerTools})
|
|
314
|
+
* is only half the job. `formatServerToolsWithDefer` still marks every non-hot tool `defer_loading`
|
|
315
|
+
* and prepends the tool-search tool, so for a one-tool array whose tool isn't hot — every creation
|
|
316
|
+
* mode: video, music, sfx, image, slides — the search tool becomes the ONLY directly callable entry
|
|
317
|
+
* in the request. Callers pair those arrays with `tool_choice:'required'`, so "you must call the video
|
|
318
|
+
* generator" silently degrades to "you must call tool-search", and a caller scanning tool-call events
|
|
319
|
+
* for the generator's name never sees it.
|
|
320
|
+
*
|
|
321
|
+
* An explicit array is a closed set the caller already narrowed: there is nothing left to discover, so
|
|
322
|
+
* defer has no work to do and its formatting is pure downside. Sending those tools normally is exactly
|
|
323
|
+
* today's (defer-off) behavior for that request.
|
|
324
|
+
*
|
|
325
|
+
* Note this is NOT the same as treating the array as `hotToolNames`: hot tools are non-deferred, but
|
|
326
|
+
* `formatServerToolsWithDefer` prepends the tool-search tool unconditionally, so a `required` turn
|
|
327
|
+
* could still satisfy the constraint by calling it. Skipping the formatting is what actually fixes it.
|
|
328
|
+
*
|
|
329
|
+
* The catalog path (a filter function, or no filter) is untouched — full tool-search + hot + deferred.
|
|
330
|
+
*/
|
|
331
|
+
declare function deferFormattingConfig(serverToolsFilter: readonly string[] | ServerToolsFilterFunction | undefined, config: DeferLoadingConfig | undefined): DeferLoadingConfig | undefined;
|
|
276
332
|
declare function mergeTools(serverTools: ServerTool[], clientTools: Array<LlmapiChatCompletionTool | ToolConfig> | undefined, apiType?: "responses" | "completions", deferConfig?: DeferLoadingConfig): Array<Record<string, unknown>>;
|
|
277
333
|
/**
|
|
278
334
|
* Result of tool matching with similarity score
|
|
@@ -509,7 +565,7 @@ interface CreateServerToolsFilterOptions {
|
|
|
509
565
|
* });
|
|
510
566
|
* ```
|
|
511
567
|
*/
|
|
512
|
-
declare function createServerToolsFilter(options?: CreateServerToolsFilterOptions):
|
|
568
|
+
declare function createServerToolsFilter(options?: CreateServerToolsFilterOptions): ServerToolsFilterFunction;
|
|
513
569
|
/**
|
|
514
570
|
* Default exclusions baked into `defaultServerToolsFilter`.
|
|
515
571
|
*
|
|
@@ -575,13 +631,21 @@ declare const SERVER_TOOL_DEPENDENCY_SETS: ToolSet[];
|
|
|
575
631
|
* If you need to customize (extra excludes, different limits, opt into
|
|
576
632
|
* tool-set expansion), call `createServerToolsFilter` directly.
|
|
577
633
|
*/
|
|
578
|
-
declare const defaultServerToolsFilter:
|
|
634
|
+
declare const defaultServerToolsFilter: ServerToolsFilterFunction;
|
|
579
635
|
/**
|
|
580
636
|
* Type for a server-tools filter — a function that takes prompt embeddings
|
|
581
637
|
* and the full server tool catalog and returns the names of tools to keep.
|
|
582
638
|
* Matches `useChatStorage`'s `serverTools` callback signature.
|
|
583
639
|
*/
|
|
584
|
-
type ServerToolsFilterFunction = (embeddings: number[] | number[][], tools: ServerTool[]) => string[]
|
|
640
|
+
type ServerToolsFilterFunction = ((embeddings: number[] | number[][], tools: ServerTool[]) => string[]) & {
|
|
641
|
+
/**
|
|
642
|
+
* The unconditional exclusions this filter applies, exposed by
|
|
643
|
+
* {@link createServerToolsFilter} so defer-loading can honour them without the caller
|
|
644
|
+
* repeating the list — see {@link resolveDeferredServerTools}. Absent on a hand-written
|
|
645
|
+
* filter, or on one wrapped in a plain closure.
|
|
646
|
+
*/
|
|
647
|
+
readonly excludeTools?: readonly string[];
|
|
648
|
+
};
|
|
585
649
|
/**
|
|
586
650
|
* Options for `selectServerToolsForPrompt`.
|
|
587
651
|
*/
|
|
@@ -609,9 +673,10 @@ interface SelectServerToolsForPromptOptions {
|
|
|
609
673
|
*/
|
|
610
674
|
cache?: ToolsCacheBackend;
|
|
611
675
|
/**
|
|
612
|
-
* Phase 3 defer-loading. When `enabled`, this helper
|
|
613
|
-
*
|
|
614
|
-
*
|
|
676
|
+
* Phase 3 defer-loading. When `enabled`, this helper skips SEMANTIC filtering to mirror
|
|
677
|
+
* useChatStorage's responses send path, which hands the catalog to mergeTools + tool-search. The
|
|
678
|
+
* caller's unconditional constraints still apply — an explicit static array, and exclusions (see
|
|
679
|
+
* {@link resolveDeferredServerTools}). Omit/disabled → today's filtered selection.
|
|
615
680
|
*/
|
|
616
681
|
deferLoading?: DeferLoadingConfig;
|
|
617
682
|
}
|
|
@@ -1377,4 +1442,4 @@ declare function resolveServerTools(descriptor: ToolIntentDescriptor, catalog: S
|
|
|
1377
1442
|
*/
|
|
1378
1443
|
declare function isCoercingIntent(creation: CreationIntent, catalog: ServerToolCatalog): boolean;
|
|
1379
1444
|
|
|
1380
|
-
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, deriveActiveToolSets, expandToolSetsAdditive, filterAssembledClientTools, filterServerTools, findMatchingTools, getCachedServerTools, getCatalogEntry, getMaxToolRounds, getServerTools, getThinkingMode, getToolDescription, getToolName, getToolsChecksum, isCoercingIntent, localStorageToolsCache, mergeActiveToolSets, mergeTools, resolveCouncilPlan, resolveCouncilServerTools, resolvePlan, resolveServerTools, resolveToolChoice, scoreTools, selectCouncilClientTools, selectServerSideTools, selectServerToolsForPrompt, shouldRefreshTools, stripCoercedMemoryWrite, toolSetSystemPrompts };
|
|
1445
|
+
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 };
|
|
@@ -272,7 +272,63 @@ interface DeferLoadingConfig {
|
|
|
272
272
|
enabled: boolean;
|
|
273
273
|
/** Server-tool names to keep non-deferred (besides the tool-search tool), in priority order. */
|
|
274
274
|
hotToolNames: readonly string[];
|
|
275
|
+
/**
|
|
276
|
+
* Server-tool names to drop entirely while defer-loading is on.
|
|
277
|
+
*
|
|
278
|
+
* Defer widens the per-turn selection to the whole catalog, which also bypasses the `excludeTools`
|
|
279
|
+
* baked into a caller's semantic filter. A filter built by {@link createServerToolsFilter} tags itself
|
|
280
|
+
* with its own exclusions and those are honoured automatically — so most callers need nothing here.
|
|
281
|
+
*
|
|
282
|
+
* Set this when the filter's tag can't be seen: a hand-written filter, a filter wrapped in a plain
|
|
283
|
+
* closure (the wrapper drops the tag), or a static-array `serverToolsFilter`. Anything excluded
|
|
284
|
+
* UNCONDITIONALLY (a tool the app replaces with its own UI, a capability the model already has
|
|
285
|
+
* natively) belongs in one of the two places, or defer quietly hands it back to the model.
|
|
286
|
+
*
|
|
287
|
+
* This list is UNIONED with the filter's own tag, never a replacement for it — so adding one name
|
|
288
|
+
* here cannot re-admit the tools the filter already excludes.
|
|
289
|
+
*/
|
|
290
|
+
excludeTools?: readonly string[];
|
|
275
291
|
}
|
|
292
|
+
/**
|
|
293
|
+
* The server-tool set defer-loading should format for one turn.
|
|
294
|
+
*
|
|
295
|
+
* Defer changes how tools are SENT (full definitions + `defer_loading` + a tool-search tool, for a
|
|
296
|
+
* byte-stable cacheable prefix). It must not change WHICH tools the caller allowed, so two things
|
|
297
|
+
* survive that a plain "just use the whole catalog" discards:
|
|
298
|
+
*
|
|
299
|
+
* 1. **an explicit static array** — `serverToolsFilter: ['x']` is a deliberate scoping, and callers
|
|
300
|
+
* commonly pair it with `tool_choice:'required'`. Replacing it with the catalog turns "you must
|
|
301
|
+
* call x" into "you must call something, here is everything". Defer still applies, within the array.
|
|
302
|
+
* 2. **unconditional exclusions** — see {@link DeferLoadingConfig.excludeTools}.
|
|
303
|
+
*
|
|
304
|
+
* A filter FUNCTION is deliberately NOT consulted: it is per-prompt semantic narrowing, and skipping it
|
|
305
|
+
* is the whole point of defer (the model reaches everything else through tool-search). Only the
|
|
306
|
+
* caller's unconditional constraints survive.
|
|
307
|
+
*/
|
|
308
|
+
declare function resolveDeferredServerTools(allServerTools: ServerTool[], serverToolsFilter: readonly string[] | ServerToolsFilterFunction | undefined, config: DeferLoadingConfig): ServerTool[];
|
|
309
|
+
/**
|
|
310
|
+
* The defer config {@link mergeTools} should FORMAT this request with — `undefined` when defer
|
|
311
|
+
* formatting must be skipped even though defer-loading is enabled.
|
|
312
|
+
*
|
|
313
|
+
* Scoping the selection to a caller's explicit static array (see {@link resolveDeferredServerTools})
|
|
314
|
+
* is only half the job. `formatServerToolsWithDefer` still marks every non-hot tool `defer_loading`
|
|
315
|
+
* and prepends the tool-search tool, so for a one-tool array whose tool isn't hot — every creation
|
|
316
|
+
* mode: video, music, sfx, image, slides — the search tool becomes the ONLY directly callable entry
|
|
317
|
+
* in the request. Callers pair those arrays with `tool_choice:'required'`, so "you must call the video
|
|
318
|
+
* generator" silently degrades to "you must call tool-search", and a caller scanning tool-call events
|
|
319
|
+
* for the generator's name never sees it.
|
|
320
|
+
*
|
|
321
|
+
* An explicit array is a closed set the caller already narrowed: there is nothing left to discover, so
|
|
322
|
+
* defer has no work to do and its formatting is pure downside. Sending those tools normally is exactly
|
|
323
|
+
* today's (defer-off) behavior for that request.
|
|
324
|
+
*
|
|
325
|
+
* Note this is NOT the same as treating the array as `hotToolNames`: hot tools are non-deferred, but
|
|
326
|
+
* `formatServerToolsWithDefer` prepends the tool-search tool unconditionally, so a `required` turn
|
|
327
|
+
* could still satisfy the constraint by calling it. Skipping the formatting is what actually fixes it.
|
|
328
|
+
*
|
|
329
|
+
* The catalog path (a filter function, or no filter) is untouched — full tool-search + hot + deferred.
|
|
330
|
+
*/
|
|
331
|
+
declare function deferFormattingConfig(serverToolsFilter: readonly string[] | ServerToolsFilterFunction | undefined, config: DeferLoadingConfig | undefined): DeferLoadingConfig | undefined;
|
|
276
332
|
declare function mergeTools(serverTools: ServerTool[], clientTools: Array<LlmapiChatCompletionTool | ToolConfig> | undefined, apiType?: "responses" | "completions", deferConfig?: DeferLoadingConfig): Array<Record<string, unknown>>;
|
|
277
333
|
/**
|
|
278
334
|
* Result of tool matching with similarity score
|
|
@@ -509,7 +565,7 @@ interface CreateServerToolsFilterOptions {
|
|
|
509
565
|
* });
|
|
510
566
|
* ```
|
|
511
567
|
*/
|
|
512
|
-
declare function createServerToolsFilter(options?: CreateServerToolsFilterOptions):
|
|
568
|
+
declare function createServerToolsFilter(options?: CreateServerToolsFilterOptions): ServerToolsFilterFunction;
|
|
513
569
|
/**
|
|
514
570
|
* Default exclusions baked into `defaultServerToolsFilter`.
|
|
515
571
|
*
|
|
@@ -575,13 +631,21 @@ declare const SERVER_TOOL_DEPENDENCY_SETS: ToolSet[];
|
|
|
575
631
|
* If you need to customize (extra excludes, different limits, opt into
|
|
576
632
|
* tool-set expansion), call `createServerToolsFilter` directly.
|
|
577
633
|
*/
|
|
578
|
-
declare const defaultServerToolsFilter:
|
|
634
|
+
declare const defaultServerToolsFilter: ServerToolsFilterFunction;
|
|
579
635
|
/**
|
|
580
636
|
* Type for a server-tools filter — a function that takes prompt embeddings
|
|
581
637
|
* and the full server tool catalog and returns the names of tools to keep.
|
|
582
638
|
* Matches `useChatStorage`'s `serverTools` callback signature.
|
|
583
639
|
*/
|
|
584
|
-
type ServerToolsFilterFunction = (embeddings: number[] | number[][], tools: ServerTool[]) => string[]
|
|
640
|
+
type ServerToolsFilterFunction = ((embeddings: number[] | number[][], tools: ServerTool[]) => string[]) & {
|
|
641
|
+
/**
|
|
642
|
+
* The unconditional exclusions this filter applies, exposed by
|
|
643
|
+
* {@link createServerToolsFilter} so defer-loading can honour them without the caller
|
|
644
|
+
* repeating the list — see {@link resolveDeferredServerTools}. Absent on a hand-written
|
|
645
|
+
* filter, or on one wrapped in a plain closure.
|
|
646
|
+
*/
|
|
647
|
+
readonly excludeTools?: readonly string[];
|
|
648
|
+
};
|
|
585
649
|
/**
|
|
586
650
|
* Options for `selectServerToolsForPrompt`.
|
|
587
651
|
*/
|
|
@@ -609,9 +673,10 @@ interface SelectServerToolsForPromptOptions {
|
|
|
609
673
|
*/
|
|
610
674
|
cache?: ToolsCacheBackend;
|
|
611
675
|
/**
|
|
612
|
-
* Phase 3 defer-loading. When `enabled`, this helper
|
|
613
|
-
*
|
|
614
|
-
*
|
|
676
|
+
* Phase 3 defer-loading. When `enabled`, this helper skips SEMANTIC filtering to mirror
|
|
677
|
+
* useChatStorage's responses send path, which hands the catalog to mergeTools + tool-search. The
|
|
678
|
+
* caller's unconditional constraints still apply — an explicit static array, and exclusions (see
|
|
679
|
+
* {@link resolveDeferredServerTools}). Omit/disabled → today's filtered selection.
|
|
615
680
|
*/
|
|
616
681
|
deferLoading?: DeferLoadingConfig;
|
|
617
682
|
}
|
|
@@ -1377,4 +1442,4 @@ declare function resolveServerTools(descriptor: ToolIntentDescriptor, catalog: S
|
|
|
1377
1442
|
*/
|
|
1378
1443
|
declare function isCoercingIntent(creation: CreationIntent, catalog: ServerToolCatalog): boolean;
|
|
1379
1444
|
|
|
1380
|
-
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, deriveActiveToolSets, expandToolSetsAdditive, filterAssembledClientTools, filterServerTools, findMatchingTools, getCachedServerTools, getCatalogEntry, getMaxToolRounds, getServerTools, getThinkingMode, getToolDescription, getToolName, getToolsChecksum, isCoercingIntent, localStorageToolsCache, mergeActiveToolSets, mergeTools, resolveCouncilPlan, resolveCouncilServerTools, resolvePlan, resolveServerTools, resolveToolChoice, scoreTools, selectCouncilClientTools, selectServerSideTools, selectServerToolsForPrompt, shouldRefreshTools, stripCoercedMemoryWrite, toolSetSystemPrompts };
|
|
1445
|
+
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 };
|