@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/index.mjs
CHANGED
|
@@ -1488,12 +1488,28 @@ var noopLogger = {
|
|
|
1488
1488
|
error: () => {
|
|
1489
1489
|
}
|
|
1490
1490
|
};
|
|
1491
|
-
var
|
|
1491
|
+
var LOGGER_STATE_KEY = /* @__PURE__ */ Symbol.for("@anuma/sdk/logger/v1");
|
|
1492
|
+
var loggerGlobal = globalThis;
|
|
1493
|
+
var fallbackLoggerState = { logger: consoleLogger };
|
|
1494
|
+
var fallbackWarned = false;
|
|
1495
|
+
function getLoggerState() {
|
|
1496
|
+
try {
|
|
1497
|
+
return loggerGlobal[LOGGER_STATE_KEY] ?? (loggerGlobal[LOGGER_STATE_KEY] = fallbackLoggerState);
|
|
1498
|
+
} catch {
|
|
1499
|
+
if (!fallbackWarned) {
|
|
1500
|
+
fallbackWarned = true;
|
|
1501
|
+
fallbackLoggerState.logger.warn(
|
|
1502
|
+
"@anuma/sdk: the global object rejects new properties. This entrypoint keeps its own logger, so setLogger does not reach other entrypoints."
|
|
1503
|
+
);
|
|
1504
|
+
}
|
|
1505
|
+
return fallbackLoggerState;
|
|
1506
|
+
}
|
|
1507
|
+
}
|
|
1492
1508
|
function setLogger(logger) {
|
|
1493
|
-
|
|
1509
|
+
getLoggerState().logger = logger;
|
|
1494
1510
|
}
|
|
1495
1511
|
function getLogger() {
|
|
1496
|
-
return
|
|
1512
|
+
return getLoggerState().logger;
|
|
1497
1513
|
}
|
|
1498
1514
|
|
|
1499
1515
|
// src/lib/memoryEngine/chunking.ts
|
|
@@ -19,12 +19,28 @@ var noopLogger = {
|
|
|
19
19
|
error: () => {
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
|
-
var
|
|
22
|
+
var LOGGER_STATE_KEY = /* @__PURE__ */ Symbol.for("@anuma/sdk/logger/v1");
|
|
23
|
+
var loggerGlobal = globalThis;
|
|
24
|
+
var fallbackLoggerState = { logger: consoleLogger };
|
|
25
|
+
var fallbackWarned = false;
|
|
26
|
+
function getLoggerState() {
|
|
27
|
+
try {
|
|
28
|
+
return loggerGlobal[LOGGER_STATE_KEY] ?? (loggerGlobal[LOGGER_STATE_KEY] = fallbackLoggerState);
|
|
29
|
+
} catch {
|
|
30
|
+
if (!fallbackWarned) {
|
|
31
|
+
fallbackWarned = true;
|
|
32
|
+
fallbackLoggerState.logger.warn(
|
|
33
|
+
"@anuma/sdk: the global object rejects new properties. This entrypoint keeps its own logger, so setLogger does not reach other entrypoints."
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
return fallbackLoggerState;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
23
39
|
function setLogger(logger) {
|
|
24
|
-
|
|
40
|
+
getLoggerState().logger = logger;
|
|
25
41
|
}
|
|
26
42
|
function getLogger() {
|
|
27
|
-
return
|
|
43
|
+
return getLoggerState().logger;
|
|
28
44
|
}
|
|
29
45
|
|
|
30
46
|
// src/lib/pii/patterns.ts
|
package/dist/react/index.cjs
CHANGED
|
@@ -76,13 +76,26 @@ var init_clientConfig = __esm({
|
|
|
76
76
|
});
|
|
77
77
|
|
|
78
78
|
// src/lib/logger.ts
|
|
79
|
+
function getLoggerState() {
|
|
80
|
+
try {
|
|
81
|
+
return loggerGlobal[LOGGER_STATE_KEY] ?? (loggerGlobal[LOGGER_STATE_KEY] = fallbackLoggerState);
|
|
82
|
+
} catch {
|
|
83
|
+
if (!fallbackWarned) {
|
|
84
|
+
fallbackWarned = true;
|
|
85
|
+
fallbackLoggerState.logger.warn(
|
|
86
|
+
"@anuma/sdk: the global object rejects new properties. This entrypoint keeps its own logger, so setLogger does not reach other entrypoints."
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
return fallbackLoggerState;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
79
92
|
function setLogger(logger) {
|
|
80
|
-
|
|
93
|
+
getLoggerState().logger = logger;
|
|
81
94
|
}
|
|
82
95
|
function getLogger() {
|
|
83
|
-
return
|
|
96
|
+
return getLoggerState().logger;
|
|
84
97
|
}
|
|
85
|
-
var consoleLogger, noopLogger,
|
|
98
|
+
var consoleLogger, noopLogger, LOGGER_STATE_KEY, loggerGlobal, fallbackLoggerState, fallbackWarned;
|
|
86
99
|
var init_logger = __esm({
|
|
87
100
|
"src/lib/logger.ts"() {
|
|
88
101
|
"use strict";
|
|
@@ -102,7 +115,10 @@ var init_logger = __esm({
|
|
|
102
115
|
error: () => {
|
|
103
116
|
}
|
|
104
117
|
};
|
|
105
|
-
|
|
118
|
+
LOGGER_STATE_KEY = /* @__PURE__ */ Symbol.for("@anuma/sdk/logger/v1");
|
|
119
|
+
loggerGlobal = globalThis;
|
|
120
|
+
fallbackLoggerState = { logger: consoleLogger };
|
|
121
|
+
fallbackWarned = false;
|
|
106
122
|
}
|
|
107
123
|
});
|
|
108
124
|
|
|
@@ -4196,6 +4212,9 @@ async function updateMessageEmbeddingOp(ctx, uniqueId, vector, embeddingModel) {
|
|
|
4196
4212
|
await ctx.database.write(async () => {
|
|
4197
4213
|
await message.update((msg) => {
|
|
4198
4214
|
msg._setRaw("vector", JSON.stringify(vector));
|
|
4215
|
+
if (msg.origin === "chunks_discarded" && vector.length > 0) {
|
|
4216
|
+
msg._setRaw("origin", "message");
|
|
4217
|
+
}
|
|
4199
4218
|
msg._setRaw("embedding_model", embeddingModel);
|
|
4200
4219
|
});
|
|
4201
4220
|
});
|
|
@@ -4212,6 +4231,9 @@ async function updateMessageChunksOp(ctx, uniqueId, chunks, embeddingModel) {
|
|
|
4212
4231
|
await ctx.database.write(async () => {
|
|
4213
4232
|
await message.update((msg) => {
|
|
4214
4233
|
msg._setRaw("chunks", JSON.stringify(storedChunks));
|
|
4234
|
+
if (msg.origin === "chunks_discarded" && storedChunks.length > 0 && storedChunks.every((chunk) => chunk.vector.length > 0)) {
|
|
4235
|
+
msg._setRaw("origin", "message");
|
|
4236
|
+
}
|
|
4215
4237
|
msg._setRaw("embedding_model", embeddingModel);
|
|
4216
4238
|
});
|
|
4217
4239
|
});
|
|
@@ -6363,6 +6385,9 @@ function clientToolToResponsesFormat(tool) {
|
|
|
6363
6385
|
...toolConfig.removeAfterExecution !== void 0 && {
|
|
6364
6386
|
removeAfterExecution: toolConfig.removeAfterExecution
|
|
6365
6387
|
},
|
|
6388
|
+
...toolConfig.removeAfterResult !== void 0 && {
|
|
6389
|
+
removeAfterResult: toolConfig.removeAfterResult
|
|
6390
|
+
},
|
|
6366
6391
|
...toolConfig.executorTimeout !== void 0 && {
|
|
6367
6392
|
executorTimeout: toolConfig.executorTimeout
|
|
6368
6393
|
},
|
|
@@ -6396,6 +6421,9 @@ function clientToolToCompletionsFormat(tool) {
|
|
|
6396
6421
|
...toolConfig.removeAfterExecution !== void 0 && {
|
|
6397
6422
|
removeAfterExecution: toolConfig.removeAfterExecution
|
|
6398
6423
|
},
|
|
6424
|
+
...toolConfig.removeAfterResult !== void 0 && {
|
|
6425
|
+
removeAfterResult: toolConfig.removeAfterResult
|
|
6426
|
+
},
|
|
6399
6427
|
...toolConfig.executorTimeout !== void 0 && {
|
|
6400
6428
|
executorTimeout: toolConfig.executorTimeout
|
|
6401
6429
|
},
|
|
@@ -7378,6 +7406,7 @@ function toolsToApiFormat(tools, apiType) {
|
|
|
7378
7406
|
executor: _executor,
|
|
7379
7407
|
skipContinuation: _skipContinuation,
|
|
7380
7408
|
removeAfterExecution: _removeAfterExecution,
|
|
7409
|
+
removeAfterResult: _removeAfterResult,
|
|
7381
7410
|
executorTimeout: _executorTimeout,
|
|
7382
7411
|
dependsOn: _dependsOn,
|
|
7383
7412
|
deAnonymizeArgs: _deAnonymizeArgs,
|
|
@@ -9822,9 +9851,11 @@ Executing tool: ${toolInfo}
|
|
|
9822
9851
|
}
|
|
9823
9852
|
if (tools && apiTools) {
|
|
9824
9853
|
const successfullyExecutedNames = /* @__PURE__ */ new Set();
|
|
9854
|
+
const successfulResults = [];
|
|
9825
9855
|
for (const r of executionResults) {
|
|
9826
9856
|
if (!r.error && !isToolErrorResult(r.result) && "name" in r && r.name) {
|
|
9827
9857
|
successfullyExecutedNames.add(r.name);
|
|
9858
|
+
successfulResults.push(r.result);
|
|
9828
9859
|
}
|
|
9829
9860
|
}
|
|
9830
9861
|
if (successfullyExecutedNames.size > 0) {
|
|
@@ -9833,7 +9864,15 @@ Executing tool: ${toolInfo}
|
|
|
9833
9864
|
const tc = t;
|
|
9834
9865
|
const func = tc.function;
|
|
9835
9866
|
const toolName = typeof func?.name === "string" ? func.name : typeof tc.name === "string" ? tc.name : void 0;
|
|
9836
|
-
if (
|
|
9867
|
+
if (!toolName) continue;
|
|
9868
|
+
const removeAfterResult = tc.removeAfterResult;
|
|
9869
|
+
if (tc.removeAfterExecution === true && successfullyExecutedNames.has(toolName) || typeof removeAfterResult === "function" && successfulResults.some((result) => {
|
|
9870
|
+
try {
|
|
9871
|
+
return removeAfterResult(result);
|
|
9872
|
+
} catch {
|
|
9873
|
+
return false;
|
|
9874
|
+
}
|
|
9875
|
+
})) {
|
|
9837
9876
|
toolsToRemove.add(toolName);
|
|
9838
9877
|
}
|
|
9839
9878
|
}
|
|
@@ -14921,7 +14960,7 @@ async function getMemoriesNeedingTopicExtractionOp(ctx, options) {
|
|
|
14921
14960
|
const id = raw.id;
|
|
14922
14961
|
const topics = parseTopics(raw.topics);
|
|
14923
14962
|
const linked = linkedNames.get(id);
|
|
14924
|
-
if (topics !== null &&
|
|
14963
|
+
if (topics !== null && linksDivergeFromTopics(topics, linked ?? /* @__PURE__ */ new Set())) {
|
|
14925
14964
|
topicsToRelinkAll.push(id);
|
|
14926
14965
|
continue;
|
|
14927
14966
|
}
|
|
@@ -15015,18 +15054,20 @@ async function relinkMemoryTopicsOp(ctx, memoryIds) {
|
|
|
15015
15054
|
}
|
|
15016
15055
|
const relinked = [];
|
|
15017
15056
|
for (const id of Array.from(new Set(memoryIds))) {
|
|
15018
|
-
let record;
|
|
15019
15057
|
try {
|
|
15020
|
-
|
|
15021
|
-
|
|
15022
|
-
|
|
15023
|
-
|
|
15024
|
-
|
|
15025
|
-
|
|
15026
|
-
|
|
15027
|
-
|
|
15028
|
-
|
|
15029
|
-
|
|
15058
|
+
await ctx.database.write(async (writer) => {
|
|
15059
|
+
let record;
|
|
15060
|
+
try {
|
|
15061
|
+
record = await ctx.vaultMemoryCollection.find(id);
|
|
15062
|
+
} catch {
|
|
15063
|
+
return;
|
|
15064
|
+
}
|
|
15065
|
+
if (record.isDeleted || !isOwnedByCtxUser(ctx, record)) return;
|
|
15066
|
+
const topics = parseTopics(record.topics);
|
|
15067
|
+
if (topics === null) return;
|
|
15068
|
+
await writer.callWriter(() => relinkMemoryEntitiesFromTopicsOp(entityCtx, id, topics));
|
|
15069
|
+
relinked.push(id);
|
|
15070
|
+
});
|
|
15030
15071
|
} catch (err) {
|
|
15031
15072
|
getLogger().warn("[memory/topics] relink failed", err);
|
|
15032
15073
|
}
|
|
@@ -23787,14 +23828,14 @@ async function autoFilterClientTools(clientTools, promptEmbeddings, cache, embed
|
|
|
23787
23828
|
const alwaysInclude = clientTools.filter(isAlwaysIncluded);
|
|
23788
23829
|
const filterCandidates = clientTools.filter((t) => !isAlwaysIncluded(t));
|
|
23789
23830
|
if (filterCandidates.length === 0) {
|
|
23790
|
-
return { tools: clientTools, activatedSetNames: /* @__PURE__ */ new Set() };
|
|
23831
|
+
return { tools: clientTools, activatedSetNames: /* @__PURE__ */ new Set(), matchedSetNames: /* @__PURE__ */ new Set() };
|
|
23791
23832
|
}
|
|
23792
23833
|
if (!promptEmbeddings && noEmbeddingsReason === "error") {
|
|
23793
|
-
return { tools: clientTools, activatedSetNames: /* @__PURE__ */ new Set() };
|
|
23834
|
+
return { tools: clientTools, activatedSetNames: /* @__PURE__ */ new Set(), matchedSetNames: /* @__PURE__ */ new Set() };
|
|
23794
23835
|
}
|
|
23795
23836
|
if (!promptEmbeddings) {
|
|
23796
23837
|
if (activeToolSets.length === 0) {
|
|
23797
|
-
return { tools: [], activatedSetNames: /* @__PURE__ */ new Set() };
|
|
23838
|
+
return { tools: [], activatedSetNames: /* @__PURE__ */ new Set(), matchedSetNames: /* @__PURE__ */ new Set() };
|
|
23798
23839
|
}
|
|
23799
23840
|
const allSets = extraToolSets.length > 0 ? [...BUILT_IN_TOOL_SETS, ...extraToolSets] : BUILT_IN_TOOL_SETS;
|
|
23800
23841
|
const activeSets = allSets.filter((s) => activeToolSets.includes(s.name));
|
|
@@ -23804,7 +23845,8 @@ async function autoFilterClientTools(clientTools, promptEmbeddings, cache, embed
|
|
|
23804
23845
|
...alwaysInclude,
|
|
23805
23846
|
...filterCandidates.filter((t) => stickyMembers.has(getToolName2(t)))
|
|
23806
23847
|
],
|
|
23807
|
-
activatedSetNames: new Set(activeSets.map((s) => s.name))
|
|
23848
|
+
activatedSetNames: new Set(activeSets.map((s) => s.name)),
|
|
23849
|
+
matchedSetNames: /* @__PURE__ */ new Set()
|
|
23808
23850
|
};
|
|
23809
23851
|
}
|
|
23810
23852
|
const toolsNeedingEmbeddings = [];
|
|
@@ -23822,7 +23864,7 @@ async function autoFilterClientTools(clientTools, promptEmbeddings, cache, embed
|
|
|
23822
23864
|
cache.set(toolsNeedingEmbeddings[i].name, embeddings[i]);
|
|
23823
23865
|
}
|
|
23824
23866
|
} catch {
|
|
23825
|
-
return { tools: clientTools, activatedSetNames: /* @__PURE__ */ new Set() };
|
|
23867
|
+
return { tools: clientTools, activatedSetNames: /* @__PURE__ */ new Set(), matchedSetNames: /* @__PURE__ */ new Set() };
|
|
23826
23868
|
}
|
|
23827
23869
|
}
|
|
23828
23870
|
const pseudoServerTools = [];
|
|
@@ -23868,15 +23910,170 @@ async function autoFilterClientTools(clientTools, promptEmbeddings, cache, embed
|
|
|
23868
23910
|
activeSetNames
|
|
23869
23911
|
);
|
|
23870
23912
|
const activatedSetNames = activatedToolSetNames(scores, toolSets, activeSetNames);
|
|
23913
|
+
const matchedSetNames = activatedToolSetNames(scores, toolSets);
|
|
23871
23914
|
if (finalNames.size === 0) {
|
|
23872
|
-
return { tools: alwaysInclude, activatedSetNames };
|
|
23915
|
+
return { tools: alwaysInclude, activatedSetNames, matchedSetNames };
|
|
23873
23916
|
}
|
|
23874
23917
|
const filtered = filterCandidates.filter((t) => {
|
|
23875
23918
|
const name = getToolName2(t);
|
|
23876
23919
|
return name && finalNames.has(name);
|
|
23877
23920
|
});
|
|
23878
|
-
return { tools: [...alwaysInclude, ...filtered], activatedSetNames };
|
|
23921
|
+
return { tools: [...alwaysInclude, ...filtered], activatedSetNames, matchedSetNames };
|
|
23922
|
+
}
|
|
23923
|
+
|
|
23924
|
+
// src/lib/tools/toolCatalog.ts
|
|
23925
|
+
var TOOL_CATALOG = {
|
|
23926
|
+
// Gmail (src/tools/gmail.ts)
|
|
23927
|
+
gmail_search_messages: { label: "Search emails", provider: "gmail", connector: "Gmail" },
|
|
23928
|
+
gmail_get_message: { label: "Read an email", provider: "gmail", connector: "Gmail" },
|
|
23929
|
+
gmail_create_draft: { label: "Draft a reply", provider: "gmail", connector: "Gmail" },
|
|
23930
|
+
gmail_send_message: { label: "Send an email", provider: "gmail", connector: "Gmail" },
|
|
23931
|
+
// Google Calendar (src/tools/googleCalendar.ts)
|
|
23932
|
+
google_calendar_list_events: {
|
|
23933
|
+
label: "Search calendar events",
|
|
23934
|
+
provider: "gcalendar",
|
|
23935
|
+
connector: "Calendar"
|
|
23936
|
+
},
|
|
23937
|
+
google_calendar_create_event: {
|
|
23938
|
+
label: "Create calendar event",
|
|
23939
|
+
provider: "gcalendar",
|
|
23940
|
+
connector: "Calendar"
|
|
23941
|
+
},
|
|
23942
|
+
google_calendar_update_event: {
|
|
23943
|
+
label: "Update calendar event",
|
|
23944
|
+
provider: "gcalendar",
|
|
23945
|
+
connector: "Calendar"
|
|
23946
|
+
},
|
|
23947
|
+
// Google Drive (src/tools/googleDrive.ts)
|
|
23948
|
+
google_drive_search: { label: "Search files", provider: "gdrive", connector: "Drive" },
|
|
23949
|
+
google_drive_list_recent: { label: "List recent files", provider: "gdrive", connector: "Drive" },
|
|
23950
|
+
google_drive_get_content: { label: "Read file content", provider: "gdrive", connector: "Drive" },
|
|
23951
|
+
google_drive_create_file: {
|
|
23952
|
+
label: "Create a file in Drive",
|
|
23953
|
+
provider: "gdrive",
|
|
23954
|
+
connector: "Drive"
|
|
23955
|
+
},
|
|
23956
|
+
google_drive_update_file: {
|
|
23957
|
+
label: "Update a Drive file",
|
|
23958
|
+
provider: "gdrive",
|
|
23959
|
+
connector: "Drive"
|
|
23960
|
+
},
|
|
23961
|
+
// Notion (src/tools/notion.ts)
|
|
23962
|
+
"notion-search": { label: "Search", provider: "notion", connector: "Notion" },
|
|
23963
|
+
"notion-fetch": { label: "Read page", provider: "notion", connector: "Notion" },
|
|
23964
|
+
"notion-create-pages": { label: "Create page", provider: "notion", connector: "Notion" },
|
|
23965
|
+
"notion-update-page": { label: "Update page", provider: "notion", connector: "Notion" },
|
|
23966
|
+
"notion-move-pages": { label: "Move pages", provider: "notion", connector: "Notion" },
|
|
23967
|
+
"notion-duplicate-page": { label: "Duplicate page", provider: "notion", connector: "Notion" },
|
|
23968
|
+
"notion-create-database": { label: "Create database", provider: "notion", connector: "Notion" },
|
|
23969
|
+
"notion-update-data-source": {
|
|
23970
|
+
label: "Update data source",
|
|
23971
|
+
provider: "notion",
|
|
23972
|
+
connector: "Notion"
|
|
23973
|
+
},
|
|
23974
|
+
"notion-create-comment": { label: "Add a comment", provider: "notion", connector: "Notion" },
|
|
23975
|
+
"notion-get-comments": { label: "Read comments", provider: "notion", connector: "Notion" },
|
|
23976
|
+
"notion-get-users": {
|
|
23977
|
+
label: "List workspace members",
|
|
23978
|
+
provider: "notion",
|
|
23979
|
+
connector: "Notion"
|
|
23980
|
+
},
|
|
23981
|
+
"notion-get-teams": { label: "List teamspaces", provider: "notion", connector: "Notion" },
|
|
23982
|
+
// GitHub (src/tools/github.ts)
|
|
23983
|
+
github_api: { label: "Use GitHub", provider: "github", connector: "GitHub" },
|
|
23984
|
+
github_get_authenticated_user: {
|
|
23985
|
+
label: "Read GitHub profile",
|
|
23986
|
+
provider: "github",
|
|
23987
|
+
connector: "GitHub"
|
|
23988
|
+
},
|
|
23989
|
+
// X / Twitter (src/tools/x.ts)
|
|
23990
|
+
x_get_me: { label: "Get my X profile", provider: "x", connector: "X" },
|
|
23991
|
+
x_get_my_posts: { label: "Read my recent posts", provider: "x", connector: "X" },
|
|
23992
|
+
// Dropbox (src/tools/dropbox.ts)
|
|
23993
|
+
dropbox_list_folders: { label: "List files", provider: "dropbox", connector: "Dropbox" },
|
|
23994
|
+
dropbox_get_file_content: {
|
|
23995
|
+
label: "Read file content",
|
|
23996
|
+
provider: "dropbox",
|
|
23997
|
+
connector: "Dropbox"
|
|
23998
|
+
},
|
|
23999
|
+
dropbox_search: { label: "Search files", provider: "dropbox", connector: "Dropbox" },
|
|
24000
|
+
// Slack (src/tools/slack.ts)
|
|
24001
|
+
slack_get_me: { label: "Get my Slack profile", provider: "slack", connector: "Slack" },
|
|
24002
|
+
slack_list_channels: { label: "List channels", provider: "slack", connector: "Slack" },
|
|
24003
|
+
slack_list_dms: { label: "List direct messages", provider: "slack", connector: "Slack" },
|
|
24004
|
+
slack_search_messages: { label: "Search messages", provider: "slack", connector: "Slack" },
|
|
24005
|
+
slack_list_users: { label: "List members", provider: "slack", connector: "Slack" },
|
|
24006
|
+
slack_get_channel_history: {
|
|
24007
|
+
label: "Read channel history",
|
|
24008
|
+
provider: "slack",
|
|
24009
|
+
connector: "Slack"
|
|
24010
|
+
},
|
|
24011
|
+
slack_get_thread_replies: {
|
|
24012
|
+
label: "Read thread replies",
|
|
24013
|
+
provider: "slack",
|
|
24014
|
+
connector: "Slack"
|
|
24015
|
+
},
|
|
24016
|
+
slack_post_message: { label: "Post a message", provider: "slack", connector: "Slack" }
|
|
24017
|
+
};
|
|
24018
|
+
|
|
24019
|
+
// src/lib/tools/selection/activeToolSets.ts
|
|
24020
|
+
function mergeActiveToolSets(current, derived) {
|
|
24021
|
+
if (derived.length === 0) return current;
|
|
24022
|
+
const merged = Array.from(/* @__PURE__ */ new Set([...current, ...derived]));
|
|
24023
|
+
return merged.length === current.length ? current : merged;
|
|
24024
|
+
}
|
|
24025
|
+
|
|
24026
|
+
// src/lib/tools/selection/recentToolSets.ts
|
|
24027
|
+
var RECENT_TOOL_SET_TURNS = 2;
|
|
24028
|
+
var RECENT_TOOL_SET_CONVERSATION_LIMIT = 50;
|
|
24029
|
+
var CARRYABLE_TOOL_SETS = new Set(
|
|
24030
|
+
BUILT_IN_TOOL_SETS.filter(
|
|
24031
|
+
(s) => s.anchors.length > 0 && s.anchors.every((a) => a in TOOL_CATALOG)
|
|
24032
|
+
).map((s) => s.name)
|
|
24033
|
+
);
|
|
24034
|
+
var recentToolSets = /* @__PURE__ */ new WeakMap();
|
|
24035
|
+
function touch(conversations, conversationId) {
|
|
24036
|
+
const turns = conversations.get(conversationId);
|
|
24037
|
+
if (!turns) return void 0;
|
|
24038
|
+
conversations.delete(conversationId);
|
|
24039
|
+
conversations.set(conversationId, turns);
|
|
24040
|
+
return turns;
|
|
24041
|
+
}
|
|
24042
|
+
function carriedToolSets(database, conversationId) {
|
|
24043
|
+
if (!conversationId) return [];
|
|
24044
|
+
const conversations = recentToolSets.get(database);
|
|
24045
|
+
if (!conversations) return [];
|
|
24046
|
+
return [...touch(conversations, conversationId)?.keys() ?? []];
|
|
24047
|
+
}
|
|
24048
|
+
function recordToolSetTurn(database, conversationId, matched) {
|
|
24049
|
+
if (!conversationId) return;
|
|
24050
|
+
let conversations = recentToolSets.get(database);
|
|
24051
|
+
if (!conversations) {
|
|
24052
|
+
conversations = /* @__PURE__ */ new Map();
|
|
24053
|
+
recentToolSets.set(database, conversations);
|
|
24054
|
+
}
|
|
24055
|
+
const turns = touch(conversations, conversationId) ?? /* @__PURE__ */ new Map();
|
|
24056
|
+
for (const [name, left] of turns) {
|
|
24057
|
+
if (left > 1) turns.set(name, left - 1);
|
|
24058
|
+
else turns.delete(name);
|
|
24059
|
+
}
|
|
24060
|
+
for (const name of matched) {
|
|
24061
|
+
if (CARRYABLE_TOOL_SETS.has(name)) turns.set(name, RECENT_TOOL_SET_TURNS);
|
|
24062
|
+
}
|
|
24063
|
+
if (turns.size === 0) {
|
|
24064
|
+
conversations.delete(conversationId);
|
|
24065
|
+
return;
|
|
24066
|
+
}
|
|
24067
|
+
conversations.set(conversationId, turns);
|
|
24068
|
+
if (conversations.size > RECENT_TOOL_SET_CONVERSATION_LIMIT) {
|
|
24069
|
+
const oldest = conversations.keys().next().value;
|
|
24070
|
+
if (oldest !== void 0) conversations.delete(oldest);
|
|
24071
|
+
}
|
|
24072
|
+
}
|
|
24073
|
+
function resetRecentToolSets() {
|
|
24074
|
+
recentToolSets = /* @__PURE__ */ new WeakMap();
|
|
23879
24075
|
}
|
|
24076
|
+
onClearAllEncryptionState(resetRecentToolSets);
|
|
23880
24077
|
|
|
23881
24078
|
// src/react/useChatMedia.ts
|
|
23882
24079
|
var import_react4 = require("react");
|
|
@@ -25309,6 +25506,8 @@ function useChatStorage(options) {
|
|
|
25309
25506
|
}
|
|
25310
25507
|
let filteredClientTools2 = clientTools;
|
|
25311
25508
|
let clientActivatedSetNames2;
|
|
25509
|
+
let matchedToolSets2 = /* @__PURE__ */ new Set();
|
|
25510
|
+
const toolSetConversationId = explicitConversationId ?? currentConversationId;
|
|
25312
25511
|
if (clientToolsFilter && clientTools?.length) {
|
|
25313
25512
|
if (!skipStorageEmbeddingsFailed) {
|
|
25314
25513
|
const clientToolNames = clientToolsFilter(skipStorageEmbeddings, clientTools);
|
|
@@ -25325,11 +25524,15 @@ function useChatStorage(options) {
|
|
|
25325
25524
|
clientToolEmbeddingsCacheRef.current,
|
|
25326
25525
|
{ getToken, baseUrl, model: embeddingModel },
|
|
25327
25526
|
extraToolSets,
|
|
25328
|
-
|
|
25527
|
+
mergeActiveToolSets(
|
|
25528
|
+
activeToolSetsRef.current ?? [],
|
|
25529
|
+
carriedToolSets(database, toolSetConversationId)
|
|
25530
|
+
),
|
|
25329
25531
|
skipStorageEmbeddingsFailed ? "error" : "short-prompt"
|
|
25330
25532
|
);
|
|
25331
25533
|
filteredClientTools2 = clientFilterResult.tools;
|
|
25332
25534
|
clientActivatedSetNames2 = clientFilterResult.activatedSetNames;
|
|
25535
|
+
matchedToolSets2 = clientFilterResult.matchedSetNames;
|
|
25333
25536
|
}
|
|
25334
25537
|
if (filteredServerTools2.length > 0 || filteredClientTools2 && filteredClientTools2.length > 0) {
|
|
25335
25538
|
mergedTools2 = mergeTools(
|
|
@@ -25384,6 +25587,7 @@ function useChatStorage(options) {
|
|
|
25384
25587
|
error: result2.error || "Unknown error"
|
|
25385
25588
|
};
|
|
25386
25589
|
}
|
|
25590
|
+
recordToolSetTurn(database, toolSetConversationId, matchedToolSets2);
|
|
25387
25591
|
const refreshResponse = result2.data;
|
|
25388
25592
|
if (getToken) {
|
|
25389
25593
|
Promise.resolve().then(
|
|
@@ -25764,6 +25968,7 @@ function useChatStorage(options) {
|
|
|
25764
25968
|
}
|
|
25765
25969
|
let filteredClientTools = clientTools;
|
|
25766
25970
|
let clientActivatedSetNames;
|
|
25971
|
+
let matchedToolSets = /* @__PURE__ */ new Set();
|
|
25767
25972
|
if (clientToolsFilter && clientTools?.length) {
|
|
25768
25973
|
if (!userMessageEmbeddingsFailed) {
|
|
25769
25974
|
const clientToolNames = clientToolsFilter(userMessageEmbeddings ?? null, clientTools);
|
|
@@ -25780,11 +25985,12 @@ function useChatStorage(options) {
|
|
|
25780
25985
|
clientToolEmbeddingsCacheRef.current,
|
|
25781
25986
|
{ getToken, baseUrl, model: embeddingModel },
|
|
25782
25987
|
extraToolSets,
|
|
25783
|
-
activeToolSetsRef.current,
|
|
25988
|
+
mergeActiveToolSets(activeToolSetsRef.current ?? [], carriedToolSets(database, convId)),
|
|
25784
25989
|
userMessageEmbeddingsFailed ? "error" : "short-prompt"
|
|
25785
25990
|
);
|
|
25786
25991
|
filteredClientTools = clientFilterResult.tools;
|
|
25787
25992
|
clientActivatedSetNames = clientFilterResult.activatedSetNames;
|
|
25993
|
+
matchedToolSets = clientFilterResult.matchedSetNames;
|
|
25788
25994
|
}
|
|
25789
25995
|
if (!userMsgQueueId) {
|
|
25790
25996
|
if (userMessageEmbeddings && autoEmbedMessages) {
|
|
@@ -25909,6 +26115,7 @@ function useChatStorage(options) {
|
|
|
25909
26115
|
],
|
|
25910
26116
|
usage: void 0
|
|
25911
26117
|
};
|
|
26118
|
+
recordToolSetTurn(database, convId, matchedToolSets);
|
|
25912
26119
|
return {
|
|
25913
26120
|
data: responseData2,
|
|
25914
26121
|
error: null,
|
|
@@ -25946,6 +26153,7 @@ function useChatStorage(options) {
|
|
|
25946
26153
|
userMessage: { ...storedUserMessage, error: errorMessage }
|
|
25947
26154
|
};
|
|
25948
26155
|
}
|
|
26156
|
+
recordToolSetTurn(database, convId, matchedToolSets);
|
|
25949
26157
|
const responseData = result.data;
|
|
25950
26158
|
let assistantContent = "";
|
|
25951
26159
|
let thinkingContent;
|
package/dist/react/index.d.mts
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;
|