@anuma/sdk 6.30.2 → 6.31.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/expo/{chunk-VD5M6QAI.mjs → chunk-XD6WOQ5I.mjs} +19 -3
- package/dist/expo/{consolidate-6J5HHAJY.mjs → consolidate-7DBUHQRK.mjs} +1 -1
- package/dist/expo/index.cjs +248 -28
- package/dist/expo/index.d.mts +27 -16
- package/dist/expo/index.d.ts +27 -16
- package/dist/expo/index.mjs +230 -26
- package/dist/index.cjs +19 -3
- package/dist/index.d.mts +19 -8
- package/dist/index.d.ts +19 -8
- package/dist/index.mjs +19 -3
- package/dist/react/{chunk-NLTO6Q36.mjs → chunk-XNQRJBIH.mjs} +19 -3
- package/dist/react/{consolidate-MYS55OAB.mjs → consolidate-5DVINCUE.mjs} +1 -1
- package/dist/react/index.cjs +234 -26
- package/dist/react/index.d.mts +29 -16
- package/dist/react/index.d.ts +29 -16
- package/dist/react/index.mjs +216 -24
- package/dist/server/{chunk-7GHESNOH.mjs → chunk-KSYV7UO2.mjs} +18 -2
- package/dist/server/{consolidate-3RNRDM75.mjs → consolidate-MCNBSUXD.mjs} +1 -1
- package/dist/server/index.cjs +51 -16
- package/dist/server/index.d.mts +23 -8
- package/dist/server/index.d.ts +23 -8
- package/dist/server/index.mjs +34 -15
- package/dist/tools/index.cjs +18 -2
- package/dist/tools/index.d.mts +15 -0
- package/dist/tools/index.d.ts +15 -0
- package/dist/tools/index.mjs +18 -2
- package/dist/tools/selection/index.cjs +33 -9
- package/dist/tools/selection/index.d.mts +19 -0
- package/dist/tools/selection/index.d.ts +19 -0
- package/dist/tools/selection/index.mjs +33 -9
- package/package.json +2 -2
package/dist/react/index.d.ts
CHANGED
|
@@ -2138,6 +2138,21 @@ type ToolConfig = LlmapiChatCompletionTool & {
|
|
|
2138
2138
|
* execution fails, allowing the model to retry.
|
|
2139
2139
|
*/
|
|
2140
2140
|
removeAfterExecution?: boolean;
|
|
2141
|
+
/**
|
|
2142
|
+
* Remove this tool for the rest of the turn once ANY tool returns a
|
|
2143
|
+
* successful result this predicate accepts — its own or another's. Errors
|
|
2144
|
+
* never count, as for `removeAfterExecution`.
|
|
2145
|
+
*
|
|
2146
|
+
* Only results of tools executed on this client are offered; tools the
|
|
2147
|
+
* portal runs server-side never reach the predicate. A predicate that throws
|
|
2148
|
+
* is treated as not matching.
|
|
2149
|
+
*
|
|
2150
|
+
* For a family of tools that has to leave together: when one of them
|
|
2151
|
+
* declines an out-of-scope request, the model otherwise works through its
|
|
2152
|
+
* siblings round after round until the round cap. Give every member the same
|
|
2153
|
+
* predicate and the first refusal removes the whole family.
|
|
2154
|
+
*/
|
|
2155
|
+
removeAfterResult?: (result: unknown) => boolean;
|
|
2141
2156
|
/**
|
|
2142
2157
|
* Timeout in milliseconds for this tool's executor.
|
|
2143
2158
|
* Overrides the default 30-second timeout.
|
|
@@ -4995,6 +5010,7 @@ type MessageFeedback = "like" | "dislike" | null;
|
|
|
4995
5010
|
* - `tool_result`: the hidden `[Tool Execution Results]` row built from a
|
|
4996
5011
|
* turn's auto-executed tool results. Skipped by the embedding sweep (see
|
|
4997
5012
|
* `memoryEngine/embeddings`) AND hidden from the transcript.
|
|
5013
|
+
* - `message`: an ordinary message with an index after explicit repair.
|
|
4998
5014
|
* - `chunks_discarded`: an ordinary, still-rendered message whose chunk vectors
|
|
4999
5015
|
* were built over `enc:v3:` ciphertext (sdk#864) and have been discarded
|
|
5000
5016
|
* rather than re-embedded at the user's own expense (client#5618). Skipped by
|
|
@@ -5007,7 +5023,7 @@ type MessageFeedback = "like" | "dislike" | null;
|
|
|
5007
5023
|
* encrypted flag would be unreadable exactly where it matters and the skip
|
|
5008
5024
|
* would fail open.
|
|
5009
5025
|
*/
|
|
5010
|
-
type MessageOrigin = "tool_result" | "chunks_discarded";
|
|
5026
|
+
type MessageOrigin = "tool_result" | "chunks_discarded" | "message";
|
|
5011
5027
|
/**
|
|
5012
5028
|
* Metadata for files attached to messages.
|
|
5013
5029
|
*
|
|
@@ -8713,7 +8729,8 @@ declare function stampTopicsExtractedAtOp(ctx: VaultMemoryOperationsContext, mem
|
|
|
8713
8729
|
* `topics_user_managed` in particular is left exactly as it arrived, so the
|
|
8714
8730
|
* autotagger stays off a curated memory whose links this just restored.
|
|
8715
8731
|
*
|
|
8716
|
-
* Skips deleted, foreign-user, and
|
|
8732
|
+
* Skips deleted rows, foreign-user rows, and rows with null topics.
|
|
8733
|
+
* Empty topics remove stale links. Returns the relinked IDs.
|
|
8717
8734
|
*/
|
|
8718
8735
|
declare function relinkMemoryTopicsOp(ctx: VaultMemoryOperationsContext, memoryIds: readonly string[]): Promise<string[]>;
|
|
8719
8736
|
/**
|
|
@@ -11049,14 +11066,10 @@ declare function generateEmbeddings(texts: string[], options: EmbeddingOptions):
|
|
|
11049
11066
|
* re-index. Off by default, so no background pass can spend a user's credits
|
|
11050
11067
|
* without being asked to.
|
|
11051
11068
|
*
|
|
11052
|
-
*
|
|
11053
|
-
*
|
|
11054
|
-
*
|
|
11055
|
-
*
|
|
11056
|
-
* before it can do anything, so the repaired rows stay on the old model, and
|
|
11057
|
-
* `searchChunksOp` already drops stale-model vectors — they go quiet with
|
|
11058
|
-
* nothing telling them apart from rows that were never repaired. Clearing the
|
|
11059
|
-
* marker on a successful re-index is the real fix, tracked in #879.
|
|
11069
|
+
* A successful repair replaces the marker with `message` in the index write.
|
|
11070
|
+
* The new marker preserves ordinary message provenance during chat replay.
|
|
11071
|
+
* Later model migrations can then include the repaired row without this flag.
|
|
11072
|
+
* Failed embedding requests and empty index data do not clear the marker.
|
|
11060
11073
|
*
|
|
11061
11074
|
* `satisfies MessageOrigin` so the constant and the union cannot drift apart
|
|
11062
11075
|
* silently — the column's type is the union, and a typo here would otherwise
|
|
@@ -11093,9 +11106,8 @@ declare function embedAllMessages(ctx: StorageOperationsContext, options: Embedd
|
|
|
11093
11106
|
* to an explicit user action, never to a background pass. Opens that marker
|
|
11094
11107
|
* only — `tool_result` rows stay excluded.
|
|
11095
11108
|
*
|
|
11096
|
-
*
|
|
11097
|
-
*
|
|
11098
|
-
* {@link CHUNKS_DISCARDED_ORIGIN}.
|
|
11109
|
+
* A successful repair clears the marker. Later model migrations include
|
|
11110
|
+
* the repaired row without this flag. See {@link CHUNKS_DISCARDED_ORIGIN}.
|
|
11099
11111
|
*/
|
|
11100
11112
|
reembedDiscarded?: boolean;
|
|
11101
11113
|
}): Promise<number>;
|
|
@@ -11153,9 +11165,8 @@ declare function chunkAndEmbedAllMessages(ctx: StorageOperationsContext, options
|
|
|
11153
11165
|
* chunks nor vector, so it never reaches that check and falls straight to the
|
|
11154
11166
|
* origin gate.
|
|
11155
11167
|
*
|
|
11156
|
-
*
|
|
11157
|
-
*
|
|
11158
|
-
* {@link CHUNKS_DISCARDED_ORIGIN}.
|
|
11168
|
+
* A successful repair clears the marker. Later model migrations include
|
|
11169
|
+
* the repaired row without this flag. See {@link CHUNKS_DISCARDED_ORIGIN}.
|
|
11159
11170
|
*/
|
|
11160
11171
|
reembedDiscarded?: boolean;
|
|
11161
11172
|
}): Promise<number>;
|
|
@@ -11754,6 +11765,8 @@ declare function preprocessFiles(files: FileMetadata[] | undefined, options?: Pr
|
|
|
11754
11765
|
* - Embedding generation hits the same `/embeddings` endpoint as the
|
|
11755
11766
|
* real request; pass a shared `clientToolEmbeddingsCache` if you call
|
|
11756
11767
|
* this repeatedly to avoid re-embedding tool descriptions.
|
|
11768
|
+
* - A real follow-up may also include connector tool sets carried from the
|
|
11769
|
+
* previous two turns of the conversation, which this preview does not model.
|
|
11757
11770
|
*/
|
|
11758
11771
|
declare function previewToolSelection(options: {
|
|
11759
11772
|
prompt: string;
|
package/dist/react/index.mjs
CHANGED
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
taskTypeHeader,
|
|
19
19
|
validateEndpointOverride,
|
|
20
20
|
withInternalFlowMarker
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-XNQRJBIH.mjs";
|
|
22
22
|
import {
|
|
23
23
|
BASE_URL,
|
|
24
24
|
MCP_R2_DOMAIN,
|
|
@@ -2316,6 +2316,9 @@ async function updateMessageEmbeddingOp(ctx, uniqueId, vector, embeddingModel) {
|
|
|
2316
2316
|
await ctx.database.write(async () => {
|
|
2317
2317
|
await message.update((msg) => {
|
|
2318
2318
|
msg._setRaw("vector", JSON.stringify(vector));
|
|
2319
|
+
if (msg.origin === "chunks_discarded" && vector.length > 0) {
|
|
2320
|
+
msg._setRaw("origin", "message");
|
|
2321
|
+
}
|
|
2319
2322
|
msg._setRaw("embedding_model", embeddingModel);
|
|
2320
2323
|
});
|
|
2321
2324
|
});
|
|
@@ -2332,6 +2335,9 @@ async function updateMessageChunksOp(ctx, uniqueId, chunks, embeddingModel) {
|
|
|
2332
2335
|
await ctx.database.write(async () => {
|
|
2333
2336
|
await message.update((msg) => {
|
|
2334
2337
|
msg._setRaw("chunks", JSON.stringify(storedChunks));
|
|
2338
|
+
if (msg.origin === "chunks_discarded" && storedChunks.length > 0 && storedChunks.every((chunk) => chunk.vector.length > 0)) {
|
|
2339
|
+
msg._setRaw("origin", "message");
|
|
2340
|
+
}
|
|
2335
2341
|
msg._setRaw("embedding_model", embeddingModel);
|
|
2336
2342
|
});
|
|
2337
2343
|
});
|
|
@@ -4474,6 +4480,9 @@ function clientToolToResponsesFormat(tool) {
|
|
|
4474
4480
|
...toolConfig.removeAfterExecution !== void 0 && {
|
|
4475
4481
|
removeAfterExecution: toolConfig.removeAfterExecution
|
|
4476
4482
|
},
|
|
4483
|
+
...toolConfig.removeAfterResult !== void 0 && {
|
|
4484
|
+
removeAfterResult: toolConfig.removeAfterResult
|
|
4485
|
+
},
|
|
4477
4486
|
...toolConfig.executorTimeout !== void 0 && {
|
|
4478
4487
|
executorTimeout: toolConfig.executorTimeout
|
|
4479
4488
|
},
|
|
@@ -4507,6 +4516,9 @@ function clientToolToCompletionsFormat(tool) {
|
|
|
4507
4516
|
...toolConfig.removeAfterExecution !== void 0 && {
|
|
4508
4517
|
removeAfterExecution: toolConfig.removeAfterExecution
|
|
4509
4518
|
},
|
|
4519
|
+
...toolConfig.removeAfterResult !== void 0 && {
|
|
4520
|
+
removeAfterResult: toolConfig.removeAfterResult
|
|
4521
|
+
},
|
|
4510
4522
|
...toolConfig.executorTimeout !== void 0 && {
|
|
4511
4523
|
executorTimeout: toolConfig.executorTimeout
|
|
4512
4524
|
},
|
|
@@ -5485,6 +5497,7 @@ function toolsToApiFormat(tools, apiType) {
|
|
|
5485
5497
|
executor: _executor,
|
|
5486
5498
|
skipContinuation: _skipContinuation,
|
|
5487
5499
|
removeAfterExecution: _removeAfterExecution,
|
|
5500
|
+
removeAfterResult: _removeAfterResult,
|
|
5488
5501
|
executorTimeout: _executorTimeout,
|
|
5489
5502
|
dependsOn: _dependsOn,
|
|
5490
5503
|
deAnonymizeArgs: _deAnonymizeArgs,
|
|
@@ -7929,9 +7942,11 @@ Executing tool: ${toolInfo}
|
|
|
7929
7942
|
}
|
|
7930
7943
|
if (tools && apiTools) {
|
|
7931
7944
|
const successfullyExecutedNames = /* @__PURE__ */ new Set();
|
|
7945
|
+
const successfulResults = [];
|
|
7932
7946
|
for (const r of executionResults) {
|
|
7933
7947
|
if (!r.error && !isToolErrorResult(r.result) && "name" in r && r.name) {
|
|
7934
7948
|
successfullyExecutedNames.add(r.name);
|
|
7949
|
+
successfulResults.push(r.result);
|
|
7935
7950
|
}
|
|
7936
7951
|
}
|
|
7937
7952
|
if (successfullyExecutedNames.size > 0) {
|
|
@@ -7940,7 +7955,15 @@ Executing tool: ${toolInfo}
|
|
|
7940
7955
|
const tc = t;
|
|
7941
7956
|
const func = tc.function;
|
|
7942
7957
|
const toolName = typeof func?.name === "string" ? func.name : typeof tc.name === "string" ? tc.name : void 0;
|
|
7943
|
-
if (
|
|
7958
|
+
if (!toolName) continue;
|
|
7959
|
+
const removeAfterResult = tc.removeAfterResult;
|
|
7960
|
+
if (tc.removeAfterExecution === true && successfullyExecutedNames.has(toolName) || typeof removeAfterResult === "function" && successfulResults.some((result) => {
|
|
7961
|
+
try {
|
|
7962
|
+
return removeAfterResult(result);
|
|
7963
|
+
} catch {
|
|
7964
|
+
return false;
|
|
7965
|
+
}
|
|
7966
|
+
})) {
|
|
7944
7967
|
toolsToRemove.add(toolName);
|
|
7945
7968
|
}
|
|
7946
7969
|
}
|
|
@@ -13030,7 +13053,7 @@ async function getMemoriesNeedingTopicExtractionOp(ctx, options) {
|
|
|
13030
13053
|
const id = raw.id;
|
|
13031
13054
|
const topics = parseTopics(raw.topics);
|
|
13032
13055
|
const linked = linkedNames.get(id);
|
|
13033
|
-
if (topics !== null &&
|
|
13056
|
+
if (topics !== null && linksDivergeFromTopics(topics, linked ?? /* @__PURE__ */ new Set())) {
|
|
13034
13057
|
topicsToRelinkAll.push(id);
|
|
13035
13058
|
continue;
|
|
13036
13059
|
}
|
|
@@ -13124,18 +13147,20 @@ async function relinkMemoryTopicsOp(ctx, memoryIds) {
|
|
|
13124
13147
|
}
|
|
13125
13148
|
const relinked = [];
|
|
13126
13149
|
for (const id of Array.from(new Set(memoryIds))) {
|
|
13127
|
-
let record;
|
|
13128
|
-
try {
|
|
13129
|
-
record = await ctx.vaultMemoryCollection.find(id);
|
|
13130
|
-
} catch {
|
|
13131
|
-
continue;
|
|
13132
|
-
}
|
|
13133
|
-
if (record.isDeleted || !isOwnedByCtxUser(ctx, record)) continue;
|
|
13134
|
-
const topics = parseTopics(record.topics);
|
|
13135
|
-
if (topics === null || topics.length === 0) continue;
|
|
13136
13150
|
try {
|
|
13137
|
-
await
|
|
13138
|
-
|
|
13151
|
+
await ctx.database.write(async (writer) => {
|
|
13152
|
+
let record;
|
|
13153
|
+
try {
|
|
13154
|
+
record = await ctx.vaultMemoryCollection.find(id);
|
|
13155
|
+
} catch {
|
|
13156
|
+
return;
|
|
13157
|
+
}
|
|
13158
|
+
if (record.isDeleted || !isOwnedByCtxUser(ctx, record)) return;
|
|
13159
|
+
const topics = parseTopics(record.topics);
|
|
13160
|
+
if (topics === null) return;
|
|
13161
|
+
await writer.callWriter(() => relinkMemoryEntitiesFromTopicsOp(entityCtx, id, topics));
|
|
13162
|
+
relinked.push(id);
|
|
13163
|
+
});
|
|
13139
13164
|
} catch (err) {
|
|
13140
13165
|
getLogger().warn("[memory/topics] relink failed", err);
|
|
13141
13166
|
}
|
|
@@ -16054,7 +16079,7 @@ async function tryConsolidate(trimmed, ctx, options, prepared) {
|
|
|
16054
16079
|
content: m.content,
|
|
16055
16080
|
similarity: m.similarity
|
|
16056
16081
|
}));
|
|
16057
|
-
const { consolidateMemory: doConsolidate } = await import("./consolidate-
|
|
16082
|
+
const { consolidateMemory: doConsolidate } = await import("./consolidate-5DVINCUE.mjs");
|
|
16058
16083
|
const decision = await doConsolidate(trimmed, candidates, consolidateOptions);
|
|
16059
16084
|
if (decision.action === "create") return decision.fallbackReason ? null : { create: true };
|
|
16060
16085
|
if (decision.action === "supersede" && decision.content) {
|
|
@@ -21834,14 +21859,14 @@ async function autoFilterClientTools(clientTools, promptEmbeddings, cache, embed
|
|
|
21834
21859
|
const alwaysInclude = clientTools.filter(isAlwaysIncluded);
|
|
21835
21860
|
const filterCandidates = clientTools.filter((t) => !isAlwaysIncluded(t));
|
|
21836
21861
|
if (filterCandidates.length === 0) {
|
|
21837
|
-
return { tools: clientTools, activatedSetNames: /* @__PURE__ */ new Set() };
|
|
21862
|
+
return { tools: clientTools, activatedSetNames: /* @__PURE__ */ new Set(), matchedSetNames: /* @__PURE__ */ new Set() };
|
|
21838
21863
|
}
|
|
21839
21864
|
if (!promptEmbeddings && noEmbeddingsReason === "error") {
|
|
21840
|
-
return { tools: clientTools, activatedSetNames: /* @__PURE__ */ new Set() };
|
|
21865
|
+
return { tools: clientTools, activatedSetNames: /* @__PURE__ */ new Set(), matchedSetNames: /* @__PURE__ */ new Set() };
|
|
21841
21866
|
}
|
|
21842
21867
|
if (!promptEmbeddings) {
|
|
21843
21868
|
if (activeToolSets.length === 0) {
|
|
21844
|
-
return { tools: [], activatedSetNames: /* @__PURE__ */ new Set() };
|
|
21869
|
+
return { tools: [], activatedSetNames: /* @__PURE__ */ new Set(), matchedSetNames: /* @__PURE__ */ new Set() };
|
|
21845
21870
|
}
|
|
21846
21871
|
const allSets = extraToolSets.length > 0 ? [...BUILT_IN_TOOL_SETS, ...extraToolSets] : BUILT_IN_TOOL_SETS;
|
|
21847
21872
|
const activeSets = allSets.filter((s) => activeToolSets.includes(s.name));
|
|
@@ -21851,7 +21876,8 @@ async function autoFilterClientTools(clientTools, promptEmbeddings, cache, embed
|
|
|
21851
21876
|
...alwaysInclude,
|
|
21852
21877
|
...filterCandidates.filter((t) => stickyMembers.has(getToolName2(t)))
|
|
21853
21878
|
],
|
|
21854
|
-
activatedSetNames: new Set(activeSets.map((s) => s.name))
|
|
21879
|
+
activatedSetNames: new Set(activeSets.map((s) => s.name)),
|
|
21880
|
+
matchedSetNames: /* @__PURE__ */ new Set()
|
|
21855
21881
|
};
|
|
21856
21882
|
}
|
|
21857
21883
|
const toolsNeedingEmbeddings = [];
|
|
@@ -21869,7 +21895,7 @@ async function autoFilterClientTools(clientTools, promptEmbeddings, cache, embed
|
|
|
21869
21895
|
cache.set(toolsNeedingEmbeddings[i].name, embeddings[i]);
|
|
21870
21896
|
}
|
|
21871
21897
|
} catch {
|
|
21872
|
-
return { tools: clientTools, activatedSetNames: /* @__PURE__ */ new Set() };
|
|
21898
|
+
return { tools: clientTools, activatedSetNames: /* @__PURE__ */ new Set(), matchedSetNames: /* @__PURE__ */ new Set() };
|
|
21873
21899
|
}
|
|
21874
21900
|
}
|
|
21875
21901
|
const pseudoServerTools = [];
|
|
@@ -21915,15 +21941,170 @@ async function autoFilterClientTools(clientTools, promptEmbeddings, cache, embed
|
|
|
21915
21941
|
activeSetNames
|
|
21916
21942
|
);
|
|
21917
21943
|
const activatedSetNames = activatedToolSetNames(scores, toolSets, activeSetNames);
|
|
21944
|
+
const matchedSetNames = activatedToolSetNames(scores, toolSets);
|
|
21918
21945
|
if (finalNames.size === 0) {
|
|
21919
|
-
return { tools: alwaysInclude, activatedSetNames };
|
|
21946
|
+
return { tools: alwaysInclude, activatedSetNames, matchedSetNames };
|
|
21920
21947
|
}
|
|
21921
21948
|
const filtered = filterCandidates.filter((t) => {
|
|
21922
21949
|
const name = getToolName2(t);
|
|
21923
21950
|
return name && finalNames.has(name);
|
|
21924
21951
|
});
|
|
21925
|
-
return { tools: [...alwaysInclude, ...filtered], activatedSetNames };
|
|
21952
|
+
return { tools: [...alwaysInclude, ...filtered], activatedSetNames, matchedSetNames };
|
|
21953
|
+
}
|
|
21954
|
+
|
|
21955
|
+
// src/lib/tools/toolCatalog.ts
|
|
21956
|
+
var TOOL_CATALOG = {
|
|
21957
|
+
// Gmail (src/tools/gmail.ts)
|
|
21958
|
+
gmail_search_messages: { label: "Search emails", provider: "gmail", connector: "Gmail" },
|
|
21959
|
+
gmail_get_message: { label: "Read an email", provider: "gmail", connector: "Gmail" },
|
|
21960
|
+
gmail_create_draft: { label: "Draft a reply", provider: "gmail", connector: "Gmail" },
|
|
21961
|
+
gmail_send_message: { label: "Send an email", provider: "gmail", connector: "Gmail" },
|
|
21962
|
+
// Google Calendar (src/tools/googleCalendar.ts)
|
|
21963
|
+
google_calendar_list_events: {
|
|
21964
|
+
label: "Search calendar events",
|
|
21965
|
+
provider: "gcalendar",
|
|
21966
|
+
connector: "Calendar"
|
|
21967
|
+
},
|
|
21968
|
+
google_calendar_create_event: {
|
|
21969
|
+
label: "Create calendar event",
|
|
21970
|
+
provider: "gcalendar",
|
|
21971
|
+
connector: "Calendar"
|
|
21972
|
+
},
|
|
21973
|
+
google_calendar_update_event: {
|
|
21974
|
+
label: "Update calendar event",
|
|
21975
|
+
provider: "gcalendar",
|
|
21976
|
+
connector: "Calendar"
|
|
21977
|
+
},
|
|
21978
|
+
// Google Drive (src/tools/googleDrive.ts)
|
|
21979
|
+
google_drive_search: { label: "Search files", provider: "gdrive", connector: "Drive" },
|
|
21980
|
+
google_drive_list_recent: { label: "List recent files", provider: "gdrive", connector: "Drive" },
|
|
21981
|
+
google_drive_get_content: { label: "Read file content", provider: "gdrive", connector: "Drive" },
|
|
21982
|
+
google_drive_create_file: {
|
|
21983
|
+
label: "Create a file in Drive",
|
|
21984
|
+
provider: "gdrive",
|
|
21985
|
+
connector: "Drive"
|
|
21986
|
+
},
|
|
21987
|
+
google_drive_update_file: {
|
|
21988
|
+
label: "Update a Drive file",
|
|
21989
|
+
provider: "gdrive",
|
|
21990
|
+
connector: "Drive"
|
|
21991
|
+
},
|
|
21992
|
+
// Notion (src/tools/notion.ts)
|
|
21993
|
+
"notion-search": { label: "Search", provider: "notion", connector: "Notion" },
|
|
21994
|
+
"notion-fetch": { label: "Read page", provider: "notion", connector: "Notion" },
|
|
21995
|
+
"notion-create-pages": { label: "Create page", provider: "notion", connector: "Notion" },
|
|
21996
|
+
"notion-update-page": { label: "Update page", provider: "notion", connector: "Notion" },
|
|
21997
|
+
"notion-move-pages": { label: "Move pages", provider: "notion", connector: "Notion" },
|
|
21998
|
+
"notion-duplicate-page": { label: "Duplicate page", provider: "notion", connector: "Notion" },
|
|
21999
|
+
"notion-create-database": { label: "Create database", provider: "notion", connector: "Notion" },
|
|
22000
|
+
"notion-update-data-source": {
|
|
22001
|
+
label: "Update data source",
|
|
22002
|
+
provider: "notion",
|
|
22003
|
+
connector: "Notion"
|
|
22004
|
+
},
|
|
22005
|
+
"notion-create-comment": { label: "Add a comment", provider: "notion", connector: "Notion" },
|
|
22006
|
+
"notion-get-comments": { label: "Read comments", provider: "notion", connector: "Notion" },
|
|
22007
|
+
"notion-get-users": {
|
|
22008
|
+
label: "List workspace members",
|
|
22009
|
+
provider: "notion",
|
|
22010
|
+
connector: "Notion"
|
|
22011
|
+
},
|
|
22012
|
+
"notion-get-teams": { label: "List teamspaces", provider: "notion", connector: "Notion" },
|
|
22013
|
+
// GitHub (src/tools/github.ts)
|
|
22014
|
+
github_api: { label: "Use GitHub", provider: "github", connector: "GitHub" },
|
|
22015
|
+
github_get_authenticated_user: {
|
|
22016
|
+
label: "Read GitHub profile",
|
|
22017
|
+
provider: "github",
|
|
22018
|
+
connector: "GitHub"
|
|
22019
|
+
},
|
|
22020
|
+
// X / Twitter (src/tools/x.ts)
|
|
22021
|
+
x_get_me: { label: "Get my X profile", provider: "x", connector: "X" },
|
|
22022
|
+
x_get_my_posts: { label: "Read my recent posts", provider: "x", connector: "X" },
|
|
22023
|
+
// Dropbox (src/tools/dropbox.ts)
|
|
22024
|
+
dropbox_list_folders: { label: "List files", provider: "dropbox", connector: "Dropbox" },
|
|
22025
|
+
dropbox_get_file_content: {
|
|
22026
|
+
label: "Read file content",
|
|
22027
|
+
provider: "dropbox",
|
|
22028
|
+
connector: "Dropbox"
|
|
22029
|
+
},
|
|
22030
|
+
dropbox_search: { label: "Search files", provider: "dropbox", connector: "Dropbox" },
|
|
22031
|
+
// Slack (src/tools/slack.ts)
|
|
22032
|
+
slack_get_me: { label: "Get my Slack profile", provider: "slack", connector: "Slack" },
|
|
22033
|
+
slack_list_channels: { label: "List channels", provider: "slack", connector: "Slack" },
|
|
22034
|
+
slack_list_dms: { label: "List direct messages", provider: "slack", connector: "Slack" },
|
|
22035
|
+
slack_search_messages: { label: "Search messages", provider: "slack", connector: "Slack" },
|
|
22036
|
+
slack_list_users: { label: "List members", provider: "slack", connector: "Slack" },
|
|
22037
|
+
slack_get_channel_history: {
|
|
22038
|
+
label: "Read channel history",
|
|
22039
|
+
provider: "slack",
|
|
22040
|
+
connector: "Slack"
|
|
22041
|
+
},
|
|
22042
|
+
slack_get_thread_replies: {
|
|
22043
|
+
label: "Read thread replies",
|
|
22044
|
+
provider: "slack",
|
|
22045
|
+
connector: "Slack"
|
|
22046
|
+
},
|
|
22047
|
+
slack_post_message: { label: "Post a message", provider: "slack", connector: "Slack" }
|
|
22048
|
+
};
|
|
22049
|
+
|
|
22050
|
+
// src/lib/tools/selection/activeToolSets.ts
|
|
22051
|
+
function mergeActiveToolSets(current, derived) {
|
|
22052
|
+
if (derived.length === 0) return current;
|
|
22053
|
+
const merged = Array.from(/* @__PURE__ */ new Set([...current, ...derived]));
|
|
22054
|
+
return merged.length === current.length ? current : merged;
|
|
22055
|
+
}
|
|
22056
|
+
|
|
22057
|
+
// src/lib/tools/selection/recentToolSets.ts
|
|
22058
|
+
var RECENT_TOOL_SET_TURNS = 2;
|
|
22059
|
+
var RECENT_TOOL_SET_CONVERSATION_LIMIT = 50;
|
|
22060
|
+
var CARRYABLE_TOOL_SETS = new Set(
|
|
22061
|
+
BUILT_IN_TOOL_SETS.filter(
|
|
22062
|
+
(s) => s.anchors.length > 0 && s.anchors.every((a) => a in TOOL_CATALOG)
|
|
22063
|
+
).map((s) => s.name)
|
|
22064
|
+
);
|
|
22065
|
+
var recentToolSets = /* @__PURE__ */ new WeakMap();
|
|
22066
|
+
function touch(conversations, conversationId) {
|
|
22067
|
+
const turns = conversations.get(conversationId);
|
|
22068
|
+
if (!turns) return void 0;
|
|
22069
|
+
conversations.delete(conversationId);
|
|
22070
|
+
conversations.set(conversationId, turns);
|
|
22071
|
+
return turns;
|
|
22072
|
+
}
|
|
22073
|
+
function carriedToolSets(database, conversationId) {
|
|
22074
|
+
if (!conversationId) return [];
|
|
22075
|
+
const conversations = recentToolSets.get(database);
|
|
22076
|
+
if (!conversations) return [];
|
|
22077
|
+
return [...touch(conversations, conversationId)?.keys() ?? []];
|
|
22078
|
+
}
|
|
22079
|
+
function recordToolSetTurn(database, conversationId, matched) {
|
|
22080
|
+
if (!conversationId) return;
|
|
22081
|
+
let conversations = recentToolSets.get(database);
|
|
22082
|
+
if (!conversations) {
|
|
22083
|
+
conversations = /* @__PURE__ */ new Map();
|
|
22084
|
+
recentToolSets.set(database, conversations);
|
|
22085
|
+
}
|
|
22086
|
+
const turns = touch(conversations, conversationId) ?? /* @__PURE__ */ new Map();
|
|
22087
|
+
for (const [name, left] of turns) {
|
|
22088
|
+
if (left > 1) turns.set(name, left - 1);
|
|
22089
|
+
else turns.delete(name);
|
|
22090
|
+
}
|
|
22091
|
+
for (const name of matched) {
|
|
22092
|
+
if (CARRYABLE_TOOL_SETS.has(name)) turns.set(name, RECENT_TOOL_SET_TURNS);
|
|
22093
|
+
}
|
|
22094
|
+
if (turns.size === 0) {
|
|
22095
|
+
conversations.delete(conversationId);
|
|
22096
|
+
return;
|
|
22097
|
+
}
|
|
22098
|
+
conversations.set(conversationId, turns);
|
|
22099
|
+
if (conversations.size > RECENT_TOOL_SET_CONVERSATION_LIMIT) {
|
|
22100
|
+
const oldest = conversations.keys().next().value;
|
|
22101
|
+
if (oldest !== void 0) conversations.delete(oldest);
|
|
22102
|
+
}
|
|
22103
|
+
}
|
|
22104
|
+
function resetRecentToolSets() {
|
|
22105
|
+
recentToolSets = /* @__PURE__ */ new WeakMap();
|
|
21926
22106
|
}
|
|
22107
|
+
onClearAllEncryptionState(resetRecentToolSets);
|
|
21927
22108
|
|
|
21928
22109
|
// src/react/useChatMedia.ts
|
|
21929
22110
|
import { useCallback as useCallback3 } from "react";
|
|
@@ -23355,6 +23536,8 @@ function useChatStorage(options) {
|
|
|
23355
23536
|
}
|
|
23356
23537
|
let filteredClientTools2 = clientTools;
|
|
23357
23538
|
let clientActivatedSetNames2;
|
|
23539
|
+
let matchedToolSets2 = /* @__PURE__ */ new Set();
|
|
23540
|
+
const toolSetConversationId = explicitConversationId ?? currentConversationId;
|
|
23358
23541
|
if (clientToolsFilter && clientTools?.length) {
|
|
23359
23542
|
if (!skipStorageEmbeddingsFailed) {
|
|
23360
23543
|
const clientToolNames = clientToolsFilter(skipStorageEmbeddings, clientTools);
|
|
@@ -23371,11 +23554,15 @@ function useChatStorage(options) {
|
|
|
23371
23554
|
clientToolEmbeddingsCacheRef.current,
|
|
23372
23555
|
{ getToken, baseUrl, model: embeddingModel },
|
|
23373
23556
|
extraToolSets,
|
|
23374
|
-
|
|
23557
|
+
mergeActiveToolSets(
|
|
23558
|
+
activeToolSetsRef.current ?? [],
|
|
23559
|
+
carriedToolSets(database, toolSetConversationId)
|
|
23560
|
+
),
|
|
23375
23561
|
skipStorageEmbeddingsFailed ? "error" : "short-prompt"
|
|
23376
23562
|
);
|
|
23377
23563
|
filteredClientTools2 = clientFilterResult.tools;
|
|
23378
23564
|
clientActivatedSetNames2 = clientFilterResult.activatedSetNames;
|
|
23565
|
+
matchedToolSets2 = clientFilterResult.matchedSetNames;
|
|
23379
23566
|
}
|
|
23380
23567
|
if (filteredServerTools2.length > 0 || filteredClientTools2 && filteredClientTools2.length > 0) {
|
|
23381
23568
|
mergedTools2 = mergeTools(
|
|
@@ -23430,6 +23617,7 @@ function useChatStorage(options) {
|
|
|
23430
23617
|
error: result2.error || "Unknown error"
|
|
23431
23618
|
};
|
|
23432
23619
|
}
|
|
23620
|
+
recordToolSetTurn(database, toolSetConversationId, matchedToolSets2);
|
|
23433
23621
|
const refreshResponse = result2.data;
|
|
23434
23622
|
if (getToken) {
|
|
23435
23623
|
Promise.resolve().then(
|
|
@@ -23810,6 +23998,7 @@ function useChatStorage(options) {
|
|
|
23810
23998
|
}
|
|
23811
23999
|
let filteredClientTools = clientTools;
|
|
23812
24000
|
let clientActivatedSetNames;
|
|
24001
|
+
let matchedToolSets = /* @__PURE__ */ new Set();
|
|
23813
24002
|
if (clientToolsFilter && clientTools?.length) {
|
|
23814
24003
|
if (!userMessageEmbeddingsFailed) {
|
|
23815
24004
|
const clientToolNames = clientToolsFilter(userMessageEmbeddings ?? null, clientTools);
|
|
@@ -23826,11 +24015,12 @@ function useChatStorage(options) {
|
|
|
23826
24015
|
clientToolEmbeddingsCacheRef.current,
|
|
23827
24016
|
{ getToken, baseUrl, model: embeddingModel },
|
|
23828
24017
|
extraToolSets,
|
|
23829
|
-
activeToolSetsRef.current,
|
|
24018
|
+
mergeActiveToolSets(activeToolSetsRef.current ?? [], carriedToolSets(database, convId)),
|
|
23830
24019
|
userMessageEmbeddingsFailed ? "error" : "short-prompt"
|
|
23831
24020
|
);
|
|
23832
24021
|
filteredClientTools = clientFilterResult.tools;
|
|
23833
24022
|
clientActivatedSetNames = clientFilterResult.activatedSetNames;
|
|
24023
|
+
matchedToolSets = clientFilterResult.matchedSetNames;
|
|
23834
24024
|
}
|
|
23835
24025
|
if (!userMsgQueueId) {
|
|
23836
24026
|
if (userMessageEmbeddings && autoEmbedMessages) {
|
|
@@ -23955,6 +24145,7 @@ function useChatStorage(options) {
|
|
|
23955
24145
|
],
|
|
23956
24146
|
usage: void 0
|
|
23957
24147
|
};
|
|
24148
|
+
recordToolSetTurn(database, convId, matchedToolSets);
|
|
23958
24149
|
return {
|
|
23959
24150
|
data: responseData2,
|
|
23960
24151
|
error: null,
|
|
@@ -23992,6 +24183,7 @@ function useChatStorage(options) {
|
|
|
23992
24183
|
userMessage: { ...storedUserMessage, error: errorMessage }
|
|
23993
24184
|
};
|
|
23994
24185
|
}
|
|
24186
|
+
recordToolSetTurn(database, convId, matchedToolSets);
|
|
23995
24187
|
const responseData = result.data;
|
|
23996
24188
|
let assistantContent = "";
|
|
23997
24189
|
let thinkingContent;
|
|
@@ -35,9 +35,25 @@ var consoleLogger = {
|
|
|
35
35
|
warn: console.warn.bind(console),
|
|
36
36
|
error: console.error.bind(console)
|
|
37
37
|
};
|
|
38
|
-
var
|
|
38
|
+
var LOGGER_STATE_KEY = /* @__PURE__ */ Symbol.for("@anuma/sdk/logger/v1");
|
|
39
|
+
var loggerGlobal = globalThis;
|
|
40
|
+
var fallbackLoggerState = { logger: consoleLogger };
|
|
41
|
+
var fallbackWarned = false;
|
|
42
|
+
function getLoggerState() {
|
|
43
|
+
try {
|
|
44
|
+
return loggerGlobal[LOGGER_STATE_KEY] ?? (loggerGlobal[LOGGER_STATE_KEY] = fallbackLoggerState);
|
|
45
|
+
} catch {
|
|
46
|
+
if (!fallbackWarned) {
|
|
47
|
+
fallbackWarned = true;
|
|
48
|
+
fallbackLoggerState.logger.warn(
|
|
49
|
+
"@anuma/sdk: the global object rejects new properties. This entrypoint keeps its own logger, so setLogger does not reach other entrypoints."
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
return fallbackLoggerState;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
39
55
|
function getLogger() {
|
|
40
|
-
return
|
|
56
|
+
return getLoggerState().logger;
|
|
41
57
|
}
|
|
42
58
|
|
|
43
59
|
// src/lib/taskType.ts
|