@anuma/sdk 6.30.2 → 6.31.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/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 +58 -17
- package/dist/expo/index.d.mts +27 -16
- package/dist/expo/index.d.ts +27 -16
- package/dist/expo/index.mjs +40 -15
- 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 +58 -17
- package/dist/react/index.d.mts +27 -16
- package/dist/react/index.d.ts +27 -16
- package/dist/react/index.mjs +40 -15
- 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 +24 -2
- package/dist/tools/selection/index.d.mts +15 -0
- package/dist/tools/selection/index.d.ts +15 -0
- package/dist/tools/selection/index.mjs +24 -2
- 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
|
-
try {
|
|
15020
|
-
record = await ctx.vaultMemoryCollection.find(id);
|
|
15021
|
-
} catch {
|
|
15022
|
-
continue;
|
|
15023
|
-
}
|
|
15024
|
-
if (record.isDeleted || !isOwnedByCtxUser(ctx, record)) continue;
|
|
15025
|
-
const topics = parseTopics(record.topics);
|
|
15026
|
-
if (topics === null || topics.length === 0) continue;
|
|
15027
15057
|
try {
|
|
15028
|
-
await
|
|
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
|
}
|
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>;
|
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>;
|
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
13150
|
try {
|
|
13129
|
-
|
|
13130
|
-
|
|
13131
|
-
|
|
13132
|
-
|
|
13133
|
-
|
|
13134
|
-
|
|
13135
|
-
|
|
13136
|
-
|
|
13137
|
-
|
|
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) {
|
|
@@ -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
|