@anuma/sdk 6.33.1 → 6.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/design/index.cjs +0 -2
- package/dist/design/index.d.mts +0 -7
- package/dist/design/index.d.ts +0 -7
- package/dist/design/index.mjs +0 -2
- package/dist/expo/{chunk-XD6WOQ5I.mjs → chunk-GQBTAM6Y.mjs} +0 -70
- package/dist/expo/{consolidate-7DBUHQRK.mjs → consolidate-3H2WY3FU.mjs} +1 -8
- package/dist/expo/index.cjs +15947 -16025
- package/dist/expo/index.d.mts +5934 -6646
- package/dist/expo/index.d.ts +5934 -6646
- package/dist/expo/index.mjs +15996 -15997
- package/dist/index.cjs +2289 -2430
- package/dist/index.d.mts +914 -1054
- package/dist/index.d.ts +914 -1054
- package/dist/index.mjs +2290 -2429
- package/dist/memory/context.d.mts +0 -73
- package/dist/memory/context.d.ts +0 -73
- package/dist/next/index.cjs +1 -8
- package/dist/next/index.mjs +1 -8
- package/dist/pii/transformers.d.mts +0 -32
- package/dist/pii/transformers.d.ts +0 -32
- package/dist/react/{chunk-XNQRJBIH.mjs → chunk-UFO4W3JX.mjs} +0 -70
- package/dist/react/{consolidate-5DVINCUE.mjs → consolidate-RHIAUBT4.mjs} +1 -8
- package/dist/react/index.cjs +33267 -33441
- package/dist/react/index.d.mts +13598 -14550
- package/dist/react/index.d.ts +13598 -14550
- package/dist/react/index.mjs +32920 -33019
- package/dist/server/{chunk-KSYV7UO2.mjs → chunk-4RGGAOAJ.mjs} +835 -905
- package/dist/server/{consolidate-MCNBSUXD.mjs → consolidate-YEGACWLR.mjs} +1 -8
- package/dist/server/index.cjs +22357 -23132
- package/dist/server/index.d.mts +7895 -8768
- package/dist/server/index.d.ts +7895 -8768
- package/dist/server/index.mjs +20548 -21258
- package/dist/telemetry/index.cjs +0 -9
- package/dist/telemetry/index.d.mts +86 -197
- package/dist/telemetry/index.d.ts +86 -197
- package/dist/telemetry/index.mjs +0 -9
- package/dist/tools/index.cjs +13036 -13347
- package/dist/tools/index.d.mts +2434 -2729
- package/dist/tools/index.d.ts +2434 -2729
- package/dist/tools/index.mjs +13036 -13347
- package/dist/tools/selection/index.cjs +18 -122
- package/dist/tools/selection/index.d.mts +0 -159
- package/dist/tools/selection/index.d.ts +0 -159
- package/dist/tools/selection/index.mjs +18 -122
- package/package.json +1 -1
|
@@ -77,13 +77,6 @@ type ToolConfig = LlmapiChatCompletionTool & {
|
|
|
77
77
|
dependsOn?: string[];
|
|
78
78
|
};
|
|
79
79
|
|
|
80
|
-
/**
|
|
81
|
-
* Server-side tools caching module
|
|
82
|
-
*
|
|
83
|
-
* Fetches and caches tools from /api/v1/tools endpoint
|
|
84
|
-
* with configurable expiration and localStorage persistence.
|
|
85
|
-
*/
|
|
86
|
-
|
|
87
80
|
/** Tool parameters schema */
|
|
88
81
|
interface ToolParameters {
|
|
89
82
|
properties: Record<string, unknown>;
|
|
@@ -808,23 +801,6 @@ interface SelectServerSideToolsOptions {
|
|
|
808
801
|
*/
|
|
809
802
|
declare function selectServerSideTools(options: SelectServerSideToolsOptions): Promise<Array<Record<string, unknown>>>;
|
|
810
803
|
|
|
811
|
-
/**
|
|
812
|
-
* Client-tool selection — the per-turn semantic filter over a client-tool
|
|
813
|
-
* catalog.
|
|
814
|
-
*
|
|
815
|
-
* Extracted out of `../../react/useChatStorage` (a `"use client"` React +
|
|
816
|
-
* WatermelonDB file) so the identical selection can run anywhere the engine
|
|
817
|
-
* runs: the standalone council path that bypasses the hook, Node unit tests,
|
|
818
|
-
* and the node/RN-safe `@anuma/sdk/tools/selection` subpath. The hook re-imports
|
|
819
|
-
* these — behavior is unchanged from when they lived inline.
|
|
820
|
-
*
|
|
821
|
-
* Dependency-safe by construction: `generateEmbeddings` comes from the db-free
|
|
822
|
-
* `../memoryEngine/generate` core, `RECALL_TOOL_NAME` from the
|
|
823
|
-
* dependency-free `../memory/recallConstants`, and `CONFIRM_TOOL_NAME` from the
|
|
824
|
-
* dependency-free `../../tools/confirmConstants`, so nothing here drags in the
|
|
825
|
-
* WatermelonDB data layer.
|
|
826
|
-
*/
|
|
827
|
-
|
|
828
804
|
/** Typed accessor for client tool name (handles function-call style and flat). */
|
|
829
805
|
declare function getToolName(t: LlmapiChatCompletionTool): string;
|
|
830
806
|
/** Typed accessor for client tool description. */
|
|
@@ -868,35 +844,6 @@ noEmbeddingsReason?: "short-prompt" | "error"): Promise<{
|
|
|
868
844
|
matchedSetNames: ReadonlySet<string>;
|
|
869
845
|
}>;
|
|
870
846
|
|
|
871
|
-
/**
|
|
872
|
-
* Connector tool catalog + denied-tools system-prompt rider.
|
|
873
|
-
*
|
|
874
|
-
* Granular connector access works by ALLOW/DENY-ing individual SDK tools.
|
|
875
|
-
* Denying a tool means it's never handed to the model that turn, so it
|
|
876
|
-
* physically can't be called — bypass-proof at the model layer.
|
|
877
|
-
*
|
|
878
|
-
* Consumer contract (this PR ships the foundation only — it does NOT wire
|
|
879
|
-
* anything into runtime filtering or the client; those are later phases):
|
|
880
|
-
*
|
|
881
|
-
* 1. Hide the denied tools from the model — pass the denied tool names as
|
|
882
|
-
* `createServerToolsFilter({ excludeTools })` so they're dropped from the
|
|
883
|
-
* toolset before it reaches the LLM.
|
|
884
|
-
* 2. Tell the user how to re-enable — append `buildDeniedToolsRider(denied)`
|
|
885
|
-
* to the system prompt. Because the tool is absent, the model can't name
|
|
886
|
-
* it on its own and would give a generic "I don't have access". The rider
|
|
887
|
-
* gives it the specific capability names (grouped by connector) so it can
|
|
888
|
-
* tell the user to re-enable that exact tool in Connected Apps settings.
|
|
889
|
-
*
|
|
890
|
-
* `TOOL_CATALOG` is the single source of truth for connector tool → friendly
|
|
891
|
-
* label + provider. `provider` is the canonical logical-provider identifier the
|
|
892
|
-
* portal and SDK already key on (matches `internal/oauth/providers.go` and the
|
|
893
|
-
* `createConnectorTokenGetter` call sites) — Phase 2/3 use it to group and
|
|
894
|
-
* persist per-tool denial. `connector` is the human-facing UI display string.
|
|
895
|
-
* Consumers (portal, client) read this on a version bump rather than re-encoding
|
|
896
|
-
* tool names. Labels are placeholders that will be refined later — keep them
|
|
897
|
-
* sensible.
|
|
898
|
-
*/
|
|
899
|
-
|
|
900
847
|
interface ToolCatalogEntry {
|
|
901
848
|
label: string;
|
|
902
849
|
/** Canonical logical-provider id (e.g. "gmail", "gcalendar", "gdrive"). */
|
|
@@ -956,22 +903,6 @@ interface ConnectorGuidance {
|
|
|
956
903
|
*/
|
|
957
904
|
declare function buildConnectorGuidance(input: ConnectorGuidanceInput): ConnectorGuidance;
|
|
958
905
|
|
|
959
|
-
/**
|
|
960
|
-
* `deriveActiveToolSets` — event-shape-agnostic sticky tool-set derivation
|
|
961
|
-
* (issue #702, Phase 4).
|
|
962
|
-
*
|
|
963
|
-
* Web derived sticky sets by scanning `ChatMessage[]` for two web-specific
|
|
964
|
-
* signals: synthetic tool-result user messages (`Tool "<name>" returned: …`)
|
|
965
|
-
* and `ActivityPhase.id`s shaped `server-tool-<name>-<n>`. This module keeps the
|
|
966
|
-
* exact matching logic but keys on a neutral {@link ToolActivationEvent[]}, so
|
|
967
|
-
* both apps feed it through a tiny adapter that maps their own message/activity
|
|
968
|
-
* store to events. That closes the terse-follow-up gap on mobile: a 3-char
|
|
969
|
-
* "yes" inside a slide conversation keeps the slide toolkit because the set
|
|
970
|
-
* stays sticky.
|
|
971
|
-
*
|
|
972
|
-
* Pure and node/RN-safe.
|
|
973
|
-
*/
|
|
974
|
-
|
|
975
906
|
/**
|
|
976
907
|
* A neutral activation signal derived from conversation history.
|
|
977
908
|
*
|
|
@@ -1004,26 +935,6 @@ declare function deriveActiveToolSets(events: ToolActivationEvent[], sets?: read
|
|
|
1004
935
|
*/
|
|
1005
936
|
declare function mergeActiveToolSets(current: string[], derived: string[]): string[];
|
|
1006
937
|
|
|
1007
|
-
/**
|
|
1008
|
-
* Tool-selection vocabulary — the neutral, product-agnostic types that let the
|
|
1009
|
-
* SDK own the "which tools this turn" orchestration both `apps/web` and
|
|
1010
|
-
* `apps/mobile` previously hand-duplicated (see issue #702).
|
|
1011
|
-
*
|
|
1012
|
-
* The split of ownership is deliberate:
|
|
1013
|
-
*
|
|
1014
|
-
* - The SDK owns the neutral {@link CreationIntent}→client-factory mapping
|
|
1015
|
-
* ({@link CREATION_INTENT_CLIENT_FACTORIES}) and the send-policy rules.
|
|
1016
|
-
* - Each app owns its UI→{@link ToolIntentDescriptor} mapper and injects a
|
|
1017
|
-
* {@link ServerToolCatalog} (built from its own static server-tool lists) and
|
|
1018
|
-
* {@link ../assembleClientTools.ToolSelectionAdapters | adapters}. The SDK
|
|
1019
|
-
* never imports the app's tool lists — the dependency direction stays
|
|
1020
|
-
* app→SDK.
|
|
1021
|
-
*
|
|
1022
|
-
* This module has no runtime dependency on React, the DOM, WatermelonDB, or the
|
|
1023
|
-
* generated HTTP client, so it is safe to import from the node/RN-safe
|
|
1024
|
-
* `@anuma/sdk/tools/selection` subpath.
|
|
1025
|
-
*/
|
|
1026
|
-
|
|
1027
938
|
/**
|
|
1028
939
|
* Which orchestration path a turn runs through.
|
|
1029
940
|
*
|
|
@@ -1223,27 +1134,6 @@ declare const CREATION_INTENT_CLIENT_FILTER: Record<CreationIntent, ClientToolsF
|
|
|
1223
1134
|
*/
|
|
1224
1135
|
declare const CREATION_INTENT_TOOL_SET: Partial<Record<CreationIntent, string>>;
|
|
1225
1136
|
|
|
1226
|
-
/**
|
|
1227
|
-
* `assembleClientTools` — capability-gated client-tool assembly (issue #702,
|
|
1228
|
-
* Phase 3). Given a resolved plan's `clientFactories` and a set of adapters, it
|
|
1229
|
-
* instantiates only the factories whose adapter is present and concatenates
|
|
1230
|
-
* them in a canonical order.
|
|
1231
|
-
*
|
|
1232
|
-
* The presence of an adapter GATES its factory — the generalization of
|
|
1233
|
-
* `createDocumentTools` returning `[]` when `displayDocument` is absent
|
|
1234
|
-
* (src/tools/document/index.ts). This is what lets ONE unified plan produce
|
|
1235
|
-
* web's full toolkit and mobile's subset automatically: web wires every
|
|
1236
|
-
* builder, mobile wires only the ones its RN surface supports, and the absent
|
|
1237
|
-
* ones contribute nothing.
|
|
1238
|
-
*
|
|
1239
|
-
* The SDK deliberately owns the GATING, ORDER, and filter application — not the
|
|
1240
|
-
* per-factory wiring. Each app's factory instantiation (slide auto-display,
|
|
1241
|
-
* app-lineage tracking, RN-vs-web storage, logging instrumentation) is
|
|
1242
|
-
* genuinely app-specific and stays app-side, expressed as a builder here.
|
|
1243
|
-
*
|
|
1244
|
-
* Pure and node/RN-safe.
|
|
1245
|
-
*/
|
|
1246
|
-
|
|
1247
1137
|
/** Minimal logger the assembler uses when a builder throws. */
|
|
1248
1138
|
interface SelectionLogger {
|
|
1249
1139
|
warn(message: string, context?: unknown): void;
|
|
@@ -1300,18 +1190,6 @@ declare function filterAssembledClientTools<TTool = ToolConfig>(tools: TTool[],
|
|
|
1300
1190
|
getName?: (t: TTool) => string;
|
|
1301
1191
|
}): TTool[] | Promise<TTool[]>;
|
|
1302
1192
|
|
|
1303
|
-
/**
|
|
1304
|
-
* `resolvePlan` — the single source of truth for "which tools this turn"
|
|
1305
|
-
* (issue #702, Phase 2). Given a neutral {@link ToolIntentDescriptor} and an
|
|
1306
|
-
* app-injected {@link ServerToolCatalog}, it produces a fully-resolved
|
|
1307
|
-
* {@link ToolPlanSpec} that both web and mobile consume, replacing each app's
|
|
1308
|
-
* hand-written per-mode switch.
|
|
1309
|
-
*
|
|
1310
|
-
* Pure and node/RN-safe. The plan is data — the host feeds `clientFactories`
|
|
1311
|
-
* into `assembleClientTools`, and `serverTools`/`toolChoice`/`maxToolRounds`/
|
|
1312
|
-
* `thinkingMode` into its send layer.
|
|
1313
|
-
*/
|
|
1314
|
-
|
|
1315
1193
|
/** Context for {@link resolvePlan}: the injected catalog plus host defaults. */
|
|
1316
1194
|
interface ResolvePlanContext {
|
|
1317
1195
|
/** The app-built per-intent/-lane server-tool catalog. */
|
|
@@ -1343,23 +1221,6 @@ interface ResolvePlanContext {
|
|
|
1343
1221
|
*/
|
|
1344
1222
|
declare function resolvePlan(descriptor: ToolIntentDescriptor, ctx: ResolvePlanContext): ToolPlanSpec;
|
|
1345
1223
|
|
|
1346
|
-
/**
|
|
1347
|
-
* Council tool resolution (issue #702, Phase 6).
|
|
1348
|
-
*
|
|
1349
|
-
* The council path bypasses the per-mode chat switch: each worker sees the full
|
|
1350
|
-
* semantic server-tool filter and its OWN per-worker memory tools (built from
|
|
1351
|
-
* that worker's model so a private-capable model sees `['private','shared']`
|
|
1352
|
-
* and a standard model sees `['shared']` only). The aggregation ("unify")
|
|
1353
|
-
* worker must never persist — its `memory_vault_save` is dropped.
|
|
1354
|
-
*
|
|
1355
|
-
* This module composes each worker's client-tool candidate array and runs it
|
|
1356
|
-
* through the SAME `autoFilterClientTools` the chat hook uses, so council and
|
|
1357
|
-
* chat share one selection. Building this on the exported selector is what lets
|
|
1358
|
-
* mobile council gain per-worker memory tools without re-implementing anything.
|
|
1359
|
-
*
|
|
1360
|
-
* Pure and node/RN-safe.
|
|
1361
|
-
*/
|
|
1362
|
-
|
|
1363
1224
|
/**
|
|
1364
1225
|
* Resolve the council/aggregation server-tool plan. This is the chat resolver's
|
|
1365
1226
|
* council-lane path: a semantic server-tool filter, no per-mode client toolkit,
|
|
@@ -1414,16 +1275,6 @@ declare function selectCouncilClientTools<TTool extends LlmapiChatCompletionTool
|
|
|
1414
1275
|
activatedSetNames?: ReadonlySet<string>;
|
|
1415
1276
|
}>;
|
|
1416
1277
|
|
|
1417
|
-
/**
|
|
1418
|
-
* Send-policy primitives — the per-turn `tool_choice` / `maxToolRounds` /
|
|
1419
|
-
* thinking-mode / coerced-memory-write rules, unified so web and mobile stop
|
|
1420
|
-
* hand-duplicating them (issue #702, Phase 1).
|
|
1421
|
-
*
|
|
1422
|
-
* These were previously spread across web's `useChatSetup` + `useChatSubmitHandler`
|
|
1423
|
-
* + `webChatSendMessage` and mobile's `chatModeRouting`. They are pure and
|
|
1424
|
-
* node/RN-safe.
|
|
1425
|
-
*/
|
|
1426
|
-
|
|
1427
1278
|
/** The vault-save tool name — the one client tool stripped on a coerced turn. */
|
|
1428
1279
|
declare const MEMORY_SAVE_TOOL_NAME = "memory_vault_save";
|
|
1429
1280
|
/**
|
|
@@ -1465,16 +1316,6 @@ declare function getThinkingMode(entry: ServerToolCatalogEntry | undefined, fall
|
|
|
1465
1316
|
*/
|
|
1466
1317
|
declare function stripCoercedMemoryWrite<T extends LlmapiChatCompletionTool>(clientTools: T[], toolChoice: ToolChoice): T[];
|
|
1467
1318
|
|
|
1468
|
-
/**
|
|
1469
|
-
* Server-tools policy — resolve the concrete server-tools filter for a turn
|
|
1470
|
-
* from the app-injected {@link ServerToolCatalog} (issue #702, Phase 2).
|
|
1471
|
-
*
|
|
1472
|
-
* The catalog is opaque to the SDK: each app builds it from its own static
|
|
1473
|
-
* server-tool lists (`IMAGE_SERVER_TOOLS`, `SLIDE_SERVER_TOOLS`, …) and passes
|
|
1474
|
-
* it in. This module only knows how to pick the right entry and, when the entry
|
|
1475
|
-
* is an attachment-aware factory, apply it with the turn's context.
|
|
1476
|
-
*/
|
|
1477
|
-
|
|
1478
1319
|
/**
|
|
1479
1320
|
* Look up the catalog entry for a descriptor. Chat turns key on the creation
|
|
1480
1321
|
* intent; council/aggregation turns key on the lane.
|
|
@@ -903,8 +903,6 @@ async function embedOne(text, options, outer) {
|
|
|
903
903
|
(signal) => postApiV1Embeddings({
|
|
904
904
|
baseUrl,
|
|
905
905
|
body: {
|
|
906
|
-
// Mask PII from the request body only — the cache above still keys on
|
|
907
|
-
// the original `text`, so callers keep their original values.
|
|
908
906
|
input: options.maskInput ? options.maskInput(text) : text,
|
|
909
907
|
model: model ?? DEFAULT_API_EMBEDDING_MODEL
|
|
910
908
|
},
|
|
@@ -938,19 +936,20 @@ async function embedOne(text, options, outer) {
|
|
|
938
936
|
}
|
|
939
937
|
var DEFAULT_EMBEDDING_BATCH_SIZE = 100;
|
|
940
938
|
var DEFAULT_EMBEDDING_BATCH_CONCURRENCY = 3;
|
|
941
|
-
async function generateEmbeddingsBatch(texts, headers, baseUrl, model, onUsage, maskInput, timeoutMs) {
|
|
939
|
+
async function generateEmbeddingsBatch(texts, headers, baseUrl, model, onUsage, maskInput, timeoutMs, outer) {
|
|
942
940
|
const response = await withEmbeddingRetry(
|
|
943
941
|
() => withDeadline(
|
|
944
942
|
(signal) => postApiV1Embeddings({
|
|
945
943
|
baseUrl,
|
|
946
|
-
// Mask PII from the request body only; cache/order still key on originals.
|
|
947
944
|
body: { input: maskInput ? texts.map(maskInput) : texts, model },
|
|
948
945
|
headers,
|
|
949
946
|
...signal && { signal }
|
|
950
947
|
}),
|
|
951
948
|
timeoutMs,
|
|
952
|
-
"embedding batch request"
|
|
953
|
-
|
|
949
|
+
"embedding batch request",
|
|
950
|
+
outer
|
|
951
|
+
),
|
|
952
|
+
outer
|
|
954
953
|
);
|
|
955
954
|
if (response.error) {
|
|
956
955
|
throw embeddingErrorFrom(response);
|
|
@@ -968,6 +967,11 @@ async function generateEmbeddingsBatch(texts, headers, baseUrl, model, onUsage,
|
|
|
968
967
|
}
|
|
969
968
|
async function generateEmbeddings(texts, options) {
|
|
970
969
|
if (texts.length === 0) return [];
|
|
970
|
+
const total = options.totalTimeoutMs;
|
|
971
|
+
if (total === void 0) return embedMany(texts, options, void 0);
|
|
972
|
+
return withDeadline((signal) => embedMany(texts, options, signal), total, "embedding batch");
|
|
973
|
+
}
|
|
974
|
+
async function embedMany(texts, options, outer) {
|
|
971
975
|
const { baseUrl = BASE_URL, model, batchSize, cache } = options;
|
|
972
976
|
const timeoutMs = options.timeoutMs ?? DEFAULT_EMBEDDING_REQUEST_TIMEOUT_MS;
|
|
973
977
|
const chunkSize = batchSize ?? DEFAULT_EMBEDDING_BATCH_SIZE;
|
|
@@ -988,7 +992,8 @@ async function generateEmbeddings(texts, options) {
|
|
|
988
992
|
if (uncachedTexts.length === 0) {
|
|
989
993
|
return results;
|
|
990
994
|
}
|
|
991
|
-
const headers = await resolveAuthHeaders(options);
|
|
995
|
+
const headers = await resolveAuthHeaders(options, outer);
|
|
996
|
+
if (outer?.aborted) throw outer.reason;
|
|
992
997
|
const embeddingModel = model ?? DEFAULT_API_EMBEDDING_MODEL;
|
|
993
998
|
let newEmbeddings;
|
|
994
999
|
if (uncachedTexts.length <= chunkSize) {
|
|
@@ -999,7 +1004,8 @@ async function generateEmbeddings(texts, options) {
|
|
|
999
1004
|
embeddingModel,
|
|
1000
1005
|
options.onUsage,
|
|
1001
1006
|
options.maskInput,
|
|
1002
|
-
timeoutMs
|
|
1007
|
+
timeoutMs,
|
|
1008
|
+
outer
|
|
1003
1009
|
);
|
|
1004
1010
|
} else {
|
|
1005
1011
|
const chunks = [];
|
|
@@ -1010,6 +1016,7 @@ async function generateEmbeddings(texts, options) {
|
|
|
1010
1016
|
let nextIndex = 0;
|
|
1011
1017
|
const worker = async () => {
|
|
1012
1018
|
while (nextIndex < chunks.length) {
|
|
1019
|
+
if (outer?.aborted) throw outer.reason;
|
|
1013
1020
|
const idx = nextIndex++;
|
|
1014
1021
|
allEmbeddings[idx] = await generateEmbeddingsBatch(
|
|
1015
1022
|
chunks[idx],
|
|
@@ -1018,7 +1025,8 @@ async function generateEmbeddings(texts, options) {
|
|
|
1018
1025
|
embeddingModel,
|
|
1019
1026
|
options.onUsage,
|
|
1020
1027
|
options.maskInput,
|
|
1021
|
-
timeoutMs
|
|
1028
|
+
timeoutMs,
|
|
1029
|
+
outer
|
|
1022
1030
|
);
|
|
1023
1031
|
}
|
|
1024
1032
|
};
|
|
@@ -1029,6 +1037,7 @@ async function generateEmbeddings(texts, options) {
|
|
|
1029
1037
|
await Promise.all(workers);
|
|
1030
1038
|
newEmbeddings = allEmbeddings.flat();
|
|
1031
1039
|
}
|
|
1040
|
+
if (outer?.aborted) throw outer.reason;
|
|
1032
1041
|
for (let i = 0; i < uncachedIndices.length; i++) {
|
|
1033
1042
|
const f32Embedding = Float32Array.from(newEmbeddings[i]);
|
|
1034
1043
|
results[uncachedIndices[i]] = Array.from(f32Embedding);
|
|
@@ -1546,9 +1555,7 @@ function clientToolToResponsesFormat(tool) {
|
|
|
1546
1555
|
type: "function",
|
|
1547
1556
|
name: func.name,
|
|
1548
1557
|
description: func.description,
|
|
1549
|
-
// Handle both 'parameters' and 'arguments' field names
|
|
1550
1558
|
parameters: func.parameters ?? func.arguments,
|
|
1551
|
-
// Preserve executor functions for client-side execution
|
|
1552
1559
|
...toolConfig.executor && { executor: toolConfig.executor },
|
|
1553
1560
|
...toolConfig.skipContinuation !== void 0 && {
|
|
1554
1561
|
skipContinuation: toolConfig.skipContinuation
|
|
@@ -1584,7 +1591,6 @@ function clientToolToCompletionsFormat(tool) {
|
|
|
1584
1591
|
...restFunc,
|
|
1585
1592
|
parameters: args ?? { type: "object", properties: {} }
|
|
1586
1593
|
},
|
|
1587
|
-
// Preserve executor functions for client-side execution
|
|
1588
1594
|
...toolConfig.executor && { executor: toolConfig.executor },
|
|
1589
1595
|
...toolConfig.skipContinuation !== void 0 && {
|
|
1590
1596
|
skipContinuation: toolConfig.skipContinuation
|
|
@@ -1747,17 +1753,7 @@ function scoreTools(promptEmbeddings, tools) {
|
|
|
1747
1753
|
var BUILT_IN_TOOL_SETS = [
|
|
1748
1754
|
{
|
|
1749
1755
|
name: "app-generation",
|
|
1750
|
-
// Appended to the base prompt (not replacing it) whenever this set
|
|
1751
|
-
// activates, so the App Builder guidance — including the window.app.complete
|
|
1752
|
-
// runtime-AI contract — rides in with the app-gen tools via the same
|
|
1753
|
-
// semantic selection that includes them. Collected by toolSetSystemPrompts.
|
|
1754
1756
|
systemPrompt: APP_BUILDER_PROMPT,
|
|
1755
|
-
// Must stay in sync with APP_FILE_TOOL_NAMES in src/tools/appGeneration.ts.
|
|
1756
|
-
// If a new app-gen tool ships there but isn't added here, semantic
|
|
1757
|
-
// selection will exclude it on every request — the model literally
|
|
1758
|
-
// doesn't see it. The quality tools (audit_design / critique_design /
|
|
1759
|
-
// verify_app) are non-obvious to a user prompt ("build me a kanban")
|
|
1760
|
-
// and rely entirely on set expansion to reach the model.
|
|
1761
1757
|
members: [
|
|
1762
1758
|
"create_file",
|
|
1763
1759
|
"patch_file",
|
|
@@ -1768,52 +1764,20 @@ var BUILT_IN_TOOL_SETS = [
|
|
|
1768
1764
|
"critique_design",
|
|
1769
1765
|
"verify_app"
|
|
1770
1766
|
],
|
|
1771
|
-
// Anchors stay limited to the primary entry-point tools. Users phrase
|
|
1772
|
-
// app intent as "build / make / fix" → semantic match on create_file
|
|
1773
|
-
// or patch_file → full set pulled in. The quality tools fire later in
|
|
1774
|
-
// the workflow and don't anchor on their own; including them as
|
|
1775
|
-
// anchors would risk pulling the set in on unrelated "audit my code"
|
|
1776
|
-
// prompts that have nothing to do with app generation.
|
|
1777
1767
|
anchors: ["create_file", "patch_file"],
|
|
1778
|
-
// 0.55: above the global filter floor (0.53) so a barely-relevant match
|
|
1779
|
-
// can't pull in the whole toolkit, but no higher — and we tried higher.
|
|
1780
|
-
// create_file scores chitchat ("what's up" ~0.56, "...about programming"
|
|
1781
|
-
// ~0.57) in the SAME band as legitimate app-EDIT prompts: "Edit the app to
|
|
1782
|
-
// change the background…" measured create_file 0.56 on one e2e run. Raising
|
|
1783
|
-
// the floor to 0.575 to exclude the chitchat therefore also stripped the
|
|
1784
|
-
// file tools from real edit requests — leaving the model unable to touch the
|
|
1785
|
-
// app at all. The bands genuinely overlap; there is no clean cut. So we keep
|
|
1786
|
-
// 0.55 (max recall) and rely on two safety nets instead: APP_BUILDER_PROMPT
|
|
1787
|
-
// is conditional (it no-ops unless the user is actually asking for an app),
|
|
1788
|
-
// and very short greetings ("hey") are filtered out earlier by the
|
|
1789
|
-
// MIN_CONTENT_LENGTH_FOR_TOOLS length gate before embeddings even run.
|
|
1790
1768
|
anchorMinSimilarity: 0.55
|
|
1791
1769
|
},
|
|
1792
1770
|
{
|
|
1793
1771
|
name: "slides",
|
|
1794
1772
|
members: ["plan_deck", "add_slide", "read_slides", "patch_slides"],
|
|
1795
1773
|
anchors: ["plan_deck", "patch_slides"],
|
|
1796
|
-
// Match the client-tool floor (0.53). Short colloquial prompts like
|
|
1797
|
-
// "make me a powerpoint about X" score plan_deck around 0.535 — above
|
|
1798
|
-
// the global floor but inside any anchor gap. plan_deck and patch_slides
|
|
1799
|
-
// are specific enough names that 0.53 won't false-positive in practice.
|
|
1800
1774
|
anchorMinSimilarity: 0.53
|
|
1801
1775
|
},
|
|
1802
1776
|
{
|
|
1803
1777
|
name: "documents",
|
|
1804
|
-
// Conditional rider (no-ops unless the user actually asks for a document),
|
|
1805
|
-
// attached so the Document Builder guidance rides in with the document
|
|
1806
|
-
// tools via the same semantic selection that includes them.
|
|
1807
1778
|
systemPrompt: DOCUMENT_BUILDER_PROMPT,
|
|
1808
1779
|
members: ["create_document", "read_document", "patch_document"],
|
|
1809
|
-
// Entry-point tools anchor; read_document rides in via set expansion.
|
|
1810
1780
|
anchors: ["create_document", "patch_document"],
|
|
1811
|
-
// 0.53: match the client-tool floor. "draft me a contract", "write a cover
|
|
1812
|
-
// letter", "make a memo" should pull the set in. Like app-gen's create_file,
|
|
1813
|
-
// document intent ("write me X") overlaps generic chitchat in this band, so
|
|
1814
|
-
// the same two safety nets apply: DOCUMENT_BUILDER_PROMPT is conditional and
|
|
1815
|
-
// the MIN_CONTENT_LENGTH_FOR_TOOLS gate drops bare greetings before
|
|
1816
|
-
// embeddings run. Tune empirically against the tool-selection parity suite.
|
|
1817
1781
|
anchorMinSimilarity: 0.53
|
|
1818
1782
|
},
|
|
1819
1783
|
{
|
|
@@ -1822,11 +1786,6 @@ var BUILT_IN_TOOL_SETS = [
|
|
|
1822
1786
|
anchors: ["github_api"],
|
|
1823
1787
|
anchorMinSimilarity: 0.55
|
|
1824
1788
|
},
|
|
1825
|
-
// Connector sets (#587). Connector chat tools belong to no set, so per-message
|
|
1826
|
-
// semantic filtering silently prunes them on vague prompts ("check my email").
|
|
1827
|
-
// Grouping each connector's tools behind a search/action anchor keeps the
|
|
1828
|
-
// whole connector reachable once any one of its tools matches. Mirrors github:
|
|
1829
|
-
// no systemPrompt rider — per-set prompt guidance is a follow-up.
|
|
1830
1789
|
{
|
|
1831
1790
|
name: "gmail",
|
|
1832
1791
|
members: [
|
|
@@ -1883,9 +1842,6 @@ var BUILT_IN_TOOL_SETS = [
|
|
|
1883
1842
|
"slack_get_thread_replies",
|
|
1884
1843
|
"slack_post_message"
|
|
1885
1844
|
],
|
|
1886
|
-
// search is the primary entry point; list_channels also anchors so "what
|
|
1887
|
-
// channels am I in" reaches the set without going through search. post_message
|
|
1888
|
-
// anchors too so post-only prompts surface the write tool past the cutoff.
|
|
1889
1845
|
anchors: ["slack_search_messages", "slack_list_channels", "slack_post_message"],
|
|
1890
1846
|
anchorMinSimilarity: 0.53
|
|
1891
1847
|
},
|
|
@@ -1896,15 +1852,6 @@ var BUILT_IN_TOOL_SETS = [
|
|
|
1896
1852
|
anchorMinSimilarity: 0.53
|
|
1897
1853
|
},
|
|
1898
1854
|
{
|
|
1899
|
-
// Server tools, so this set does its work through
|
|
1900
|
-
// withActiveToolSetServerTools: once any restaurant tool has run, terse
|
|
1901
|
-
// follow-ups ("okay", "same as before", "cancel it") keep every restaurant
|
|
1902
|
-
// tool — discovery, booking and cancelling. Each tool still reaches a fresh
|
|
1903
|
-
// request on its own description.
|
|
1904
|
-
// Anchors are deliberately empty (like the client's Nearby set): the set
|
|
1905
|
-
// is only for stickiness, not a new way to activate on a prompt.
|
|
1906
|
-
// prompt_user_confirm is left out of members: autoFilterClientTools always
|
|
1907
|
-
// sends it, and as a member any unrelated confirmation would pin this set.
|
|
1908
1855
|
name: "restaurant-booking",
|
|
1909
1856
|
members: [
|
|
1910
1857
|
"AnumaPaymentsMCP-anuma_find_restaurant",
|
|
@@ -1917,10 +1864,6 @@ var BUILT_IN_TOOL_SETS = [
|
|
|
1917
1864
|
anchors: []
|
|
1918
1865
|
},
|
|
1919
1866
|
{
|
|
1920
|
-
// What a confirmed booking card narrows the rest of the turn to (see
|
|
1921
|
-
// CONFIRMED_ACTION_TOOL_SETS): the booking chain only, without the
|
|
1922
|
-
// discovery and cancel tools that restaurant-booking keeps sticky.
|
|
1923
|
-
// Anchors are empty for the same reason as restaurant-cancel below.
|
|
1924
1867
|
name: "restaurant-book",
|
|
1925
1868
|
members: [
|
|
1926
1869
|
"AnumaPaymentsMCP-anuma_find_restaurant",
|
|
@@ -1930,12 +1873,6 @@ var BUILT_IN_TOOL_SETS = [
|
|
|
1930
1873
|
anchors: []
|
|
1931
1874
|
},
|
|
1932
1875
|
{
|
|
1933
|
-
// What a confirmed cancel card narrows the rest of the turn to (see
|
|
1934
|
-
// CONFIRMED_ACTION_TOOL_SETS). Anchors are empty for the same reason as
|
|
1935
|
-
// restaurant-booking: anchors here are scored against client tools only,
|
|
1936
|
-
// so a server-tool anchor could never fire. The "cancel brings list"
|
|
1937
|
-
// edge on a fresh prompt is restaurant-cancel-lookup in
|
|
1938
|
-
// SERVER_TOOL_DEPENDENCY_SETS.
|
|
1939
1876
|
name: "restaurant-cancel",
|
|
1940
1877
|
members: [
|
|
1941
1878
|
"AnumaPaymentsMCP-anuma_list_reservations",
|
|
@@ -2059,11 +1996,6 @@ function createServerToolsFilter(options = {}) {
|
|
|
2059
1996
|
var DEFAULT_EXCLUDED_SERVER_TOOLS = [
|
|
2060
1997
|
"AnumaVisionMCP-anuma_analyze_image",
|
|
2061
1998
|
"OpenMeteoMCP-weather_forecast",
|
|
2062
|
-
// Same native-capability argument as the vision tool: modern models reason
|
|
2063
|
-
// step-by-step natively (and reasoning-mode models do it structurally), so
|
|
2064
|
-
// a server-side sequential-thinking tool is a redundant hop. Its broad
|
|
2065
|
-
// description also embeds near virtually every prompt — observed live
|
|
2066
|
-
// riding into news-search, scheduling, and chitchat requests.
|
|
2067
1999
|
"AnumaSequentialThinkingMCP-sequentialthinking"
|
|
2068
2000
|
];
|
|
2069
2001
|
var DEFAULT_SERVER_TOOLS_MATCH_OPTIONS = {
|
|
@@ -2072,10 +2004,6 @@ var DEFAULT_SERVER_TOOLS_MATCH_OPTIONS = {
|
|
|
2072
2004
|
};
|
|
2073
2005
|
var SERVER_TOOL_DEPENDENCY_SETS = [
|
|
2074
2006
|
{
|
|
2075
|
-
// search finds links; reading them is always the next step. The reader now
|
|
2076
|
-
// lives on the search server — Jina's read_url / parallel_read_url were
|
|
2077
|
-
// removed in favour of anuma_scrape_url, which takes a batch of URLs — so
|
|
2078
|
-
// this edge deliberately spans two MCP servers.
|
|
2079
2007
|
name: "web-research",
|
|
2080
2008
|
members: [
|
|
2081
2009
|
"AnumaJinaMCP-search_web",
|
|
@@ -2083,22 +2011,9 @@ var SERVER_TOOL_DEPENDENCY_SETS = [
|
|
|
2083
2011
|
"AnumaJinaMCP-parallel_search_web"
|
|
2084
2012
|
],
|
|
2085
2013
|
anchors: ["AnumaJinaMCP-search_web"],
|
|
2086
|
-
// Activation floor = the selection floor (0.5), not the 0.6 ToolSet
|
|
2087
|
-
// default. A dependency edge has different semantics from a persona-style
|
|
2088
|
-
// tool set: if the entry tool is plausibly offered at all, the chain must
|
|
2089
|
-
// ride along — "Search the web for recent news…" scores search_web in the
|
|
2090
|
-
// 0.5–0.6 band, and shipping search without read would dead-end the model.
|
|
2091
2014
|
anchorMinSimilarity: 0.5
|
|
2092
2015
|
},
|
|
2093
2016
|
{
|
|
2094
|
-
// Every OpenMeteo data tool requires latitude/longitude (verified in the
|
|
2095
|
-
// catalog schemas), but users speak in place names — geocoding is the
|
|
2096
|
-
// mandatory first hop. Members deliberately contain ONLY the dependency:
|
|
2097
|
-
// the anchor that fired is already in the semantic matches, and pulling
|
|
2098
|
-
// sibling data tools in would re-create vendor-suite over-inclusion.
|
|
2099
|
-
// Excluded tools (e.g. weather_forecast under the default filter) can't
|
|
2100
|
-
// anchor this set — createServerToolsFilter drops them before expansion —
|
|
2101
|
-
// but the non-weather data tools still deliver geocoding when they match.
|
|
2102
2017
|
name: "openmeteo-geocode",
|
|
2103
2018
|
members: ["OpenMeteoMCP-geocoding"],
|
|
2104
2019
|
anchors: [
|
|
@@ -2113,10 +2028,6 @@ var SERVER_TOOL_DEPENDENCY_SETS = [
|
|
|
2113
2028
|
anchorMinSimilarity: 0.5
|
|
2114
2029
|
},
|
|
2115
2030
|
{
|
|
2116
|
-
// The cancel tool takes its resy_token and the other values only from a
|
|
2117
|
-
// live anuma_list_reservations result in the same turn, never from
|
|
2118
|
-
// memory, so the list tool must ride in whenever cancel is offered.
|
|
2119
|
-
// Members hold only the dependency, like openmeteo-geocode.
|
|
2120
2031
|
name: "restaurant-cancel-lookup",
|
|
2121
2032
|
members: ["AnumaPaymentsMCP-anuma_list_reservations"],
|
|
2122
2033
|
anchors: ["AnumaPaymentsMCP-anuma_cancel_reservation"],
|
|
@@ -2323,11 +2234,6 @@ async function autoFilterClientTools(clientTools, promptEmbeddings, cache, embed
|
|
|
2323
2234
|
limit: MAX_CLIENT_TOOLS_AFTER_FILTER,
|
|
2324
2235
|
minSimilarity: CLIENT_TOOLS_MIN_SIMILARITY,
|
|
2325
2236
|
filterAmbiguous: true,
|
|
2326
|
-
// See CLIENT_TOOLS_RELEVANCE_RATIO: 0.75 admits the second intent of a
|
|
2327
|
-
// multi-intent prompt (which lands ~75-80% of the dominant match), while
|
|
2328
|
-
// still trimming the loose tail. The earlier 0.9 made a second intent
|
|
2329
|
-
// structurally unselectable; the anchorMinSimilarity gates (0.53-0.55)
|
|
2330
|
-
// remain the guard against borderline anchors activating a whole set.
|
|
2331
2237
|
relevanceRatio: CLIENT_TOOLS_RELEVANCE_RATIO
|
|
2332
2238
|
});
|
|
2333
2239
|
const matchedNames = new Set(matches.map((m) => m.tool.name));
|
|
@@ -2356,12 +2262,10 @@ async function autoFilterClientTools(clientTools, promptEmbeddings, cache, embed
|
|
|
2356
2262
|
|
|
2357
2263
|
// src/lib/tools/toolCatalog.ts
|
|
2358
2264
|
var TOOL_CATALOG = {
|
|
2359
|
-
// Gmail (src/tools/gmail.ts)
|
|
2360
2265
|
gmail_search_messages: { label: "Search emails", provider: "gmail", connector: "Gmail" },
|
|
2361
2266
|
gmail_get_message: { label: "Read an email", provider: "gmail", connector: "Gmail" },
|
|
2362
2267
|
gmail_create_draft: { label: "Draft a reply", provider: "gmail", connector: "Gmail" },
|
|
2363
2268
|
gmail_send_message: { label: "Send an email", provider: "gmail", connector: "Gmail" },
|
|
2364
|
-
// Google Calendar (src/tools/googleCalendar.ts)
|
|
2365
2269
|
google_calendar_list_events: {
|
|
2366
2270
|
label: "Search calendar events",
|
|
2367
2271
|
provider: "gcalendar",
|
|
@@ -2377,7 +2281,6 @@ var TOOL_CATALOG = {
|
|
|
2377
2281
|
provider: "gcalendar",
|
|
2378
2282
|
connector: "Calendar"
|
|
2379
2283
|
},
|
|
2380
|
-
// Google Drive (src/tools/googleDrive.ts)
|
|
2381
2284
|
google_drive_search: { label: "Search files", provider: "gdrive", connector: "Drive" },
|
|
2382
2285
|
google_drive_list_recent: { label: "List recent files", provider: "gdrive", connector: "Drive" },
|
|
2383
2286
|
google_drive_get_content: { label: "Read file content", provider: "gdrive", connector: "Drive" },
|
|
@@ -2391,7 +2294,6 @@ var TOOL_CATALOG = {
|
|
|
2391
2294
|
provider: "gdrive",
|
|
2392
2295
|
connector: "Drive"
|
|
2393
2296
|
},
|
|
2394
|
-
// Notion (src/tools/notion.ts)
|
|
2395
2297
|
"notion-search": { label: "Search", provider: "notion", connector: "Notion" },
|
|
2396
2298
|
"notion-fetch": { label: "Read page", provider: "notion", connector: "Notion" },
|
|
2397
2299
|
"notion-create-pages": { label: "Create page", provider: "notion", connector: "Notion" },
|
|
@@ -2412,17 +2314,14 @@ var TOOL_CATALOG = {
|
|
|
2412
2314
|
connector: "Notion"
|
|
2413
2315
|
},
|
|
2414
2316
|
"notion-get-teams": { label: "List teamspaces", provider: "notion", connector: "Notion" },
|
|
2415
|
-
// GitHub (src/tools/github.ts)
|
|
2416
2317
|
github_api: { label: "Use GitHub", provider: "github", connector: "GitHub" },
|
|
2417
2318
|
github_get_authenticated_user: {
|
|
2418
2319
|
label: "Read GitHub profile",
|
|
2419
2320
|
provider: "github",
|
|
2420
2321
|
connector: "GitHub"
|
|
2421
2322
|
},
|
|
2422
|
-
// X / Twitter (src/tools/x.ts)
|
|
2423
2323
|
x_get_me: { label: "Get my X profile", provider: "x", connector: "X" },
|
|
2424
2324
|
x_get_my_posts: { label: "Read my recent posts", provider: "x", connector: "X" },
|
|
2425
|
-
// Dropbox (src/tools/dropbox.ts)
|
|
2426
2325
|
dropbox_list_folders: { label: "List files", provider: "dropbox", connector: "Dropbox" },
|
|
2427
2326
|
dropbox_get_file_content: {
|
|
2428
2327
|
label: "Read file content",
|
|
@@ -2430,7 +2329,6 @@ var TOOL_CATALOG = {
|
|
|
2430
2329
|
connector: "Dropbox"
|
|
2431
2330
|
},
|
|
2432
2331
|
dropbox_search: { label: "Search files", provider: "dropbox", connector: "Dropbox" },
|
|
2433
|
-
// Slack (src/tools/slack.ts)
|
|
2434
2332
|
slack_get_me: { label: "Get my Slack profile", provider: "slack", connector: "Slack" },
|
|
2435
2333
|
slack_list_channels: { label: "List channels", provider: "slack", connector: "Slack" },
|
|
2436
2334
|
slack_list_dms: { label: "List direct messages", provider: "slack", connector: "Slack" },
|
|
@@ -2601,8 +2499,6 @@ var CREATION_INTENT_CLIENT_FACTORIES = {
|
|
|
2601
2499
|
document: FULL_GENERATIVE_CLIENT_FACTORIES,
|
|
2602
2500
|
"web-search": FULL_GENERATIVE_CLIENT_FACTORIES,
|
|
2603
2501
|
"deep-research": FULL_GENERATIVE_CLIENT_FACTORIES,
|
|
2604
|
-
// Builder modes: restrict to their own toolkit; a `saved` toolkit rides
|
|
2605
|
-
// along on app builds (parity with web's app branch).
|
|
2606
2502
|
app: ["app", "saved"],
|
|
2607
2503
|
slides: ["slides"]
|
|
2608
2504
|
};
|