@anuma/sdk 6.30.1 → 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-N5CKISI3.mjs → chunk-XD6WOQ5I.mjs} +50 -7
- package/dist/expo/{consolidate-N56RXPCW.mjs → consolidate-7DBUHQRK.mjs} +1 -1
- package/dist/expo/index.cjs +173 -56
- package/dist/expo/index.d.mts +39 -19
- package/dist/expo/index.d.ts +39 -19
- package/dist/expo/index.mjs +124 -50
- 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-LBIKGBXE.mjs → chunk-XNQRJBIH.mjs} +50 -7
- package/dist/react/{consolidate-2NLZAEWR.mjs → consolidate-5DVINCUE.mjs} +1 -1
- package/dist/react/index.cjs +173 -56
- package/dist/react/index.d.mts +39 -19
- package/dist/react/index.d.ts +39 -19
- package/dist/react/index.mjs +124 -50
- package/dist/server/{chunk-Z2QBL4HB.mjs → chunk-KSYV7UO2.mjs} +49 -6
- package/dist/server/{consolidate-QWVI25WQ.mjs → consolidate-MCNBSUXD.mjs} +1 -1
- package/dist/server/index.cjs +157 -46
- package/dist/server/index.d.mts +35 -11
- package/dist/server/index.d.ts +35 -11
- package/dist/server/index.mjs +109 -41
- 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/server/index.mjs
CHANGED
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
taskTypeHeader,
|
|
14
14
|
validateEndpointOverride,
|
|
15
15
|
withInternalFlowMarker
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-KSYV7UO2.mjs";
|
|
17
17
|
import {
|
|
18
18
|
BASE_URL,
|
|
19
19
|
__commonJS,
|
|
@@ -19108,6 +19108,9 @@ async function updateMessageEmbeddingOp(ctx, uniqueId, vector, embeddingModel) {
|
|
|
19108
19108
|
await ctx.database.write(async () => {
|
|
19109
19109
|
await message.update((msg) => {
|
|
19110
19110
|
msg._setRaw("vector", JSON.stringify(vector));
|
|
19111
|
+
if (msg.origin === "chunks_discarded" && vector.length > 0) {
|
|
19112
|
+
msg._setRaw("origin", "message");
|
|
19113
|
+
}
|
|
19111
19114
|
msg._setRaw("embedding_model", embeddingModel);
|
|
19112
19115
|
});
|
|
19113
19116
|
});
|
|
@@ -19124,6 +19127,9 @@ async function updateMessageChunksOp(ctx, uniqueId, chunks, embeddingModel) {
|
|
|
19124
19127
|
await ctx.database.write(async () => {
|
|
19125
19128
|
await message.update((msg) => {
|
|
19126
19129
|
msg._setRaw("chunks", JSON.stringify(storedChunks));
|
|
19130
|
+
if (msg.origin === "chunks_discarded" && storedChunks.length > 0 && storedChunks.every((chunk) => chunk.vector.length > 0)) {
|
|
19131
|
+
msg._setRaw("origin", "message");
|
|
19132
|
+
}
|
|
19127
19133
|
msg._setRaw("embedding_model", embeddingModel);
|
|
19128
19134
|
});
|
|
19129
19135
|
});
|
|
@@ -21153,7 +21159,7 @@ async function getMemoriesNeedingTopicExtractionOp(ctx, options) {
|
|
|
21153
21159
|
const id = raw.id;
|
|
21154
21160
|
const topics = parseTopics(raw.topics);
|
|
21155
21161
|
const linked = linkedNames.get(id);
|
|
21156
|
-
if (topics !== null &&
|
|
21162
|
+
if (topics !== null && linksDivergeFromTopics(topics, linked ?? /* @__PURE__ */ new Set())) {
|
|
21157
21163
|
topicsToRelinkAll.push(id);
|
|
21158
21164
|
continue;
|
|
21159
21165
|
}
|
|
@@ -21247,18 +21253,20 @@ async function relinkMemoryTopicsOp(ctx, memoryIds) {
|
|
|
21247
21253
|
}
|
|
21248
21254
|
const relinked = [];
|
|
21249
21255
|
for (const id of Array.from(new Set(memoryIds))) {
|
|
21250
|
-
let record;
|
|
21251
|
-
try {
|
|
21252
|
-
record = await ctx.vaultMemoryCollection.find(id);
|
|
21253
|
-
} catch {
|
|
21254
|
-
continue;
|
|
21255
|
-
}
|
|
21256
|
-
if (record.isDeleted || !isOwnedByCtxUser(ctx, record)) continue;
|
|
21257
|
-
const topics = parseTopics(record.topics);
|
|
21258
|
-
if (topics === null || topics.length === 0) continue;
|
|
21259
21256
|
try {
|
|
21260
|
-
await
|
|
21261
|
-
|
|
21257
|
+
await ctx.database.write(async (writer) => {
|
|
21258
|
+
let record;
|
|
21259
|
+
try {
|
|
21260
|
+
record = await ctx.vaultMemoryCollection.find(id);
|
|
21261
|
+
} catch {
|
|
21262
|
+
return;
|
|
21263
|
+
}
|
|
21264
|
+
if (record.isDeleted || !isOwnedByCtxUser(ctx, record)) return;
|
|
21265
|
+
const topics = parseTopics(record.topics);
|
|
21266
|
+
if (topics === null) return;
|
|
21267
|
+
await writer.callWriter(() => relinkMemoryEntitiesFromTopicsOp(entityCtx, id, topics));
|
|
21268
|
+
relinked.push(id);
|
|
21269
|
+
});
|
|
21262
21270
|
} catch (err) {
|
|
21263
21271
|
getLogger().warn("[memory/topics] relink failed", err);
|
|
21264
21272
|
}
|
|
@@ -28020,7 +28028,7 @@ async function tryConsolidate(trimmed, ctx, options, prepared) {
|
|
|
28020
28028
|
content: m.content,
|
|
28021
28029
|
similarity: m.similarity
|
|
28022
28030
|
}));
|
|
28023
|
-
const { consolidateMemory: doConsolidate } = await import("./consolidate-
|
|
28031
|
+
const { consolidateMemory: doConsolidate } = await import("./consolidate-MCNBSUXD.mjs");
|
|
28024
28032
|
const decision = await doConsolidate(trimmed, candidates, consolidateOptions);
|
|
28025
28033
|
if (decision.action === "create") return decision.fallbackReason ? null : { create: true };
|
|
28026
28034
|
if (decision.action === "supersede" && decision.content) {
|
|
@@ -30682,6 +30690,28 @@ var BatchFailureError = class extends Error {
|
|
|
30682
30690
|
this.terminal = terminal;
|
|
30683
30691
|
}
|
|
30684
30692
|
};
|
|
30693
|
+
var FlaggedBatchError = class extends Error {
|
|
30694
|
+
};
|
|
30695
|
+
function extracted(result) {
|
|
30696
|
+
return result.failedCount === 0 && result.outcome !== "empty-after-retry";
|
|
30697
|
+
}
|
|
30698
|
+
function batchError(result) {
|
|
30699
|
+
const failure = result.failure;
|
|
30700
|
+
if (failure?.reason === "http-terminal") {
|
|
30701
|
+
const status = failure.httpStatus;
|
|
30702
|
+
if (status !== void 0 && REQUEST_REJECTED_STATUSES.has(status))
|
|
30703
|
+
return new BatchFailureError(
|
|
30704
|
+
`Extraction rejected the batch (HTTP ${status}); not retried this session`,
|
|
30705
|
+
true
|
|
30706
|
+
);
|
|
30707
|
+
return new AccountFailureError(
|
|
30708
|
+
`Extraction refused for the account (HTTP ${status ?? "unknown"}); retried next session`
|
|
30709
|
+
);
|
|
30710
|
+
}
|
|
30711
|
+
if (result.failedCount > 0 || failure !== void 0 && CONTENT_FAILURE_REASONS.has(failure.reason))
|
|
30712
|
+
return new BatchFailureError("Extraction batch incomplete; retained for retry", false);
|
|
30713
|
+
return new Error("Extraction batch incomplete; retained for retry");
|
|
30714
|
+
}
|
|
30685
30715
|
var AccountFailureError = class extends Error {
|
|
30686
30716
|
};
|
|
30687
30717
|
var LockedSourcesError = class extends Error {
|
|
@@ -30690,6 +30720,16 @@ var LockedSourcesError = class extends Error {
|
|
|
30690
30720
|
this.persistentIds = persistentIds;
|
|
30691
30721
|
}
|
|
30692
30722
|
};
|
|
30723
|
+
function splitTurns(messages) {
|
|
30724
|
+
const turns = [];
|
|
30725
|
+
for (const message of messages) {
|
|
30726
|
+
const last = turns[turns.length - 1];
|
|
30727
|
+
if (!last || message.role === "user" && last.some((m) => m.role === "user"))
|
|
30728
|
+
turns.push([message]);
|
|
30729
|
+
else last.push(message);
|
|
30730
|
+
}
|
|
30731
|
+
return turns;
|
|
30732
|
+
}
|
|
30693
30733
|
function idsOf(job) {
|
|
30694
30734
|
return JSON.parse(String(job._getRaw("message_ids")));
|
|
30695
30735
|
}
|
|
@@ -30840,6 +30880,10 @@ function createDurableAutoExtractor(options) {
|
|
|
30840
30880
|
skippedThisSession.add(job.id);
|
|
30841
30881
|
return false;
|
|
30842
30882
|
}
|
|
30883
|
+
if (error instanceof FlaggedBatchError) {
|
|
30884
|
+
await acknowledge(job, ids, loaded, true);
|
|
30885
|
+
return true;
|
|
30886
|
+
}
|
|
30843
30887
|
const counted = error instanceof BatchFailureError || error instanceof LockedSourcesError && error.persistentIds.length > 0;
|
|
30844
30888
|
if (!counted) return false;
|
|
30845
30889
|
const prior = sessionFailures.get(job.id);
|
|
@@ -30966,37 +31010,50 @@ function createDurableAutoExtractor(options) {
|
|
|
30966
31010
|
const messages = loaded.flatMap(
|
|
30967
31011
|
(m) => m && m.conversationId === conversationId && (m.role === "user" || m.role === "assistant") ? [{ id: m.uniqueId, role: m.role, content: m.content }] : []
|
|
30968
31012
|
);
|
|
30969
|
-
|
|
30970
|
-
|
|
30971
|
-
|
|
30972
|
-
result = await extractBatch(
|
|
30973
|
-
|
|
31013
|
+
const jobScope = currentScope() === "private" ? "private" : String(job._getRaw("scope"));
|
|
31014
|
+
const jobFolderId = job._getRaw("folder_id") ?? null;
|
|
31015
|
+
const runExtraction = async (batch, batchIds) => {
|
|
31016
|
+
const result = await extractBatch(
|
|
31017
|
+
batch,
|
|
30974
31018
|
conversationId,
|
|
30975
|
-
|
|
30976
|
-
|
|
30977
|
-
|
|
31019
|
+
batchIds,
|
|
31020
|
+
jobScope,
|
|
31021
|
+
jobFolderId
|
|
30978
31022
|
);
|
|
30979
|
-
success = result.failedCount === 0 && result.outcome !== "empty-after-retry";
|
|
30980
31023
|
options.onTurnComplete?.(result);
|
|
30981
|
-
|
|
30982
|
-
|
|
30983
|
-
|
|
30984
|
-
|
|
30985
|
-
|
|
30986
|
-
|
|
30987
|
-
|
|
30988
|
-
|
|
30989
|
-
|
|
31024
|
+
return result;
|
|
31025
|
+
};
|
|
31026
|
+
const flaggedIds = /* @__PURE__ */ new Set();
|
|
31027
|
+
if (messages.length) {
|
|
31028
|
+
const result = await runExtraction(messages, ids);
|
|
31029
|
+
if (result.failure?.reason === "content-flagged") {
|
|
31030
|
+
const turns = splitTurns(messages);
|
|
31031
|
+
if (turns.length < 2)
|
|
31032
|
+
throw new FlaggedBatchError("Extraction batch refused by moderation; abandoned");
|
|
31033
|
+
for (const turn of turns) {
|
|
31034
|
+
const turnResult = await runExtraction(
|
|
31035
|
+
turn,
|
|
31036
|
+
turn.map((m) => m.id)
|
|
30990
31037
|
);
|
|
30991
|
-
|
|
30992
|
-
|
|
30993
|
-
|
|
30994
|
-
|
|
30995
|
-
|
|
30996
|
-
|
|
30997
|
-
|
|
31038
|
+
if (turnResult.failure?.reason === "content-flagged")
|
|
31039
|
+
for (const m of turn) flaggedIds.add(m.id);
|
|
31040
|
+
else if (!extracted(turnResult)) throw batchError(turnResult);
|
|
31041
|
+
}
|
|
31042
|
+
if (flaggedIds.size)
|
|
31043
|
+
reportError(
|
|
31044
|
+
new Error(
|
|
31045
|
+
`Dropped ${flaggedIds.size} source id(s) of an extraction batch refused by moderation`
|
|
31046
|
+
),
|
|
31047
|
+
conversationId
|
|
31048
|
+
);
|
|
31049
|
+
} else if (!extracted(result)) throw batchError(result);
|
|
30998
31050
|
}
|
|
30999
|
-
await acknowledge(
|
|
31051
|
+
await acknowledge(
|
|
31052
|
+
job,
|
|
31053
|
+
ids,
|
|
31054
|
+
loaded,
|
|
31055
|
+
ids.slice(-2).some((id) => flaggedIds.has(id))
|
|
31056
|
+
);
|
|
31000
31057
|
scheduleAfterSuccess = true;
|
|
31001
31058
|
} catch (error) {
|
|
31002
31059
|
attempts.set(job.id, attempted + 1);
|
|
@@ -33871,6 +33928,7 @@ function toolsToApiFormat(tools, apiType) {
|
|
|
33871
33928
|
executor: _executor,
|
|
33872
33929
|
skipContinuation: _skipContinuation,
|
|
33873
33930
|
removeAfterExecution: _removeAfterExecution,
|
|
33931
|
+
removeAfterResult: _removeAfterResult,
|
|
33874
33932
|
executorTimeout: _executorTimeout,
|
|
33875
33933
|
dependsOn: _dependsOn,
|
|
33876
33934
|
deAnonymizeArgs: _deAnonymizeArgs,
|
|
@@ -36315,9 +36373,11 @@ Executing tool: ${toolInfo}
|
|
|
36315
36373
|
}
|
|
36316
36374
|
if (tools && apiTools) {
|
|
36317
36375
|
const successfullyExecutedNames = /* @__PURE__ */ new Set();
|
|
36376
|
+
const successfulResults = [];
|
|
36318
36377
|
for (const r of executionResults) {
|
|
36319
36378
|
if (!r.error && !isToolErrorResult(r.result) && "name" in r && r.name) {
|
|
36320
36379
|
successfullyExecutedNames.add(r.name);
|
|
36380
|
+
successfulResults.push(r.result);
|
|
36321
36381
|
}
|
|
36322
36382
|
}
|
|
36323
36383
|
if (successfullyExecutedNames.size > 0) {
|
|
@@ -36326,7 +36386,15 @@ Executing tool: ${toolInfo}
|
|
|
36326
36386
|
const tc = t;
|
|
36327
36387
|
const func = tc.function;
|
|
36328
36388
|
const toolName2 = typeof func?.name === "string" ? func.name : typeof tc.name === "string" ? tc.name : void 0;
|
|
36329
|
-
if (
|
|
36389
|
+
if (!toolName2) continue;
|
|
36390
|
+
const removeAfterResult = tc.removeAfterResult;
|
|
36391
|
+
if (tc.removeAfterExecution === true && successfullyExecutedNames.has(toolName2) || typeof removeAfterResult === "function" && successfulResults.some((result) => {
|
|
36392
|
+
try {
|
|
36393
|
+
return removeAfterResult(result);
|
|
36394
|
+
} catch {
|
|
36395
|
+
return false;
|
|
36396
|
+
}
|
|
36397
|
+
})) {
|
|
36330
36398
|
toolsToRemove.add(toolName2);
|
|
36331
36399
|
}
|
|
36332
36400
|
}
|
package/dist/tools/index.cjs
CHANGED
|
@@ -1170,9 +1170,25 @@ var consoleLogger = {
|
|
|
1170
1170
|
warn: console.warn.bind(console),
|
|
1171
1171
|
error: console.error.bind(console)
|
|
1172
1172
|
};
|
|
1173
|
-
var
|
|
1173
|
+
var LOGGER_STATE_KEY = /* @__PURE__ */ Symbol.for("@anuma/sdk/logger/v1");
|
|
1174
|
+
var loggerGlobal = globalThis;
|
|
1175
|
+
var fallbackLoggerState = { logger: consoleLogger };
|
|
1176
|
+
var fallbackWarned = false;
|
|
1177
|
+
function getLoggerState() {
|
|
1178
|
+
try {
|
|
1179
|
+
return loggerGlobal[LOGGER_STATE_KEY] ?? (loggerGlobal[LOGGER_STATE_KEY] = fallbackLoggerState);
|
|
1180
|
+
} catch {
|
|
1181
|
+
if (!fallbackWarned) {
|
|
1182
|
+
fallbackWarned = true;
|
|
1183
|
+
fallbackLoggerState.logger.warn(
|
|
1184
|
+
"@anuma/sdk: the global object rejects new properties. This entrypoint keeps its own logger, so setLogger does not reach other entrypoints."
|
|
1185
|
+
);
|
|
1186
|
+
}
|
|
1187
|
+
return fallbackLoggerState;
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1174
1190
|
function getLogger() {
|
|
1175
|
-
return
|
|
1191
|
+
return getLoggerState().logger;
|
|
1176
1192
|
}
|
|
1177
1193
|
|
|
1178
1194
|
// src/tools/googleDrive.ts
|
package/dist/tools/index.d.mts
CHANGED
|
@@ -40,6 +40,21 @@ type ToolConfig = LlmapiChatCompletionTool & {
|
|
|
40
40
|
* execution fails, allowing the model to retry.
|
|
41
41
|
*/
|
|
42
42
|
removeAfterExecution?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Remove this tool for the rest of the turn once ANY tool returns a
|
|
45
|
+
* successful result this predicate accepts — its own or another's. Errors
|
|
46
|
+
* never count, as for `removeAfterExecution`.
|
|
47
|
+
*
|
|
48
|
+
* Only results of tools executed on this client are offered; tools the
|
|
49
|
+
* portal runs server-side never reach the predicate. A predicate that throws
|
|
50
|
+
* is treated as not matching.
|
|
51
|
+
*
|
|
52
|
+
* For a family of tools that has to leave together: when one of them
|
|
53
|
+
* declines an out-of-scope request, the model otherwise works through its
|
|
54
|
+
* siblings round after round until the round cap. Give every member the same
|
|
55
|
+
* predicate and the first refusal removes the whole family.
|
|
56
|
+
*/
|
|
57
|
+
removeAfterResult?: (result: unknown) => boolean;
|
|
43
58
|
/**
|
|
44
59
|
* Timeout in milliseconds for this tool's executor.
|
|
45
60
|
* Overrides the default 30-second timeout.
|
package/dist/tools/index.d.ts
CHANGED
|
@@ -40,6 +40,21 @@ type ToolConfig = LlmapiChatCompletionTool & {
|
|
|
40
40
|
* execution fails, allowing the model to retry.
|
|
41
41
|
*/
|
|
42
42
|
removeAfterExecution?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Remove this tool for the rest of the turn once ANY tool returns a
|
|
45
|
+
* successful result this predicate accepts — its own or another's. Errors
|
|
46
|
+
* never count, as for `removeAfterExecution`.
|
|
47
|
+
*
|
|
48
|
+
* Only results of tools executed on this client are offered; tools the
|
|
49
|
+
* portal runs server-side never reach the predicate. A predicate that throws
|
|
50
|
+
* is treated as not matching.
|
|
51
|
+
*
|
|
52
|
+
* For a family of tools that has to leave together: when one of them
|
|
53
|
+
* declines an out-of-scope request, the model otherwise works through its
|
|
54
|
+
* siblings round after round until the round cap. Give every member the same
|
|
55
|
+
* predicate and the first refusal removes the whole family.
|
|
56
|
+
*/
|
|
57
|
+
removeAfterResult?: (result: unknown) => boolean;
|
|
43
58
|
/**
|
|
44
59
|
* Timeout in milliseconds for this tool's executor.
|
|
45
60
|
* Overrides the default 30-second timeout.
|
package/dist/tools/index.mjs
CHANGED
|
@@ -1014,9 +1014,25 @@ var consoleLogger = {
|
|
|
1014
1014
|
warn: console.warn.bind(console),
|
|
1015
1015
|
error: console.error.bind(console)
|
|
1016
1016
|
};
|
|
1017
|
-
var
|
|
1017
|
+
var LOGGER_STATE_KEY = /* @__PURE__ */ Symbol.for("@anuma/sdk/logger/v1");
|
|
1018
|
+
var loggerGlobal = globalThis;
|
|
1019
|
+
var fallbackLoggerState = { logger: consoleLogger };
|
|
1020
|
+
var fallbackWarned = false;
|
|
1021
|
+
function getLoggerState() {
|
|
1022
|
+
try {
|
|
1023
|
+
return loggerGlobal[LOGGER_STATE_KEY] ?? (loggerGlobal[LOGGER_STATE_KEY] = fallbackLoggerState);
|
|
1024
|
+
} catch {
|
|
1025
|
+
if (!fallbackWarned) {
|
|
1026
|
+
fallbackWarned = true;
|
|
1027
|
+
fallbackLoggerState.logger.warn(
|
|
1028
|
+
"@anuma/sdk: the global object rejects new properties. This entrypoint keeps its own logger, so setLogger does not reach other entrypoints."
|
|
1029
|
+
);
|
|
1030
|
+
}
|
|
1031
|
+
return fallbackLoggerState;
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1018
1034
|
function getLogger() {
|
|
1019
|
-
return
|
|
1035
|
+
return getLoggerState().logger;
|
|
1020
1036
|
}
|
|
1021
1037
|
|
|
1022
1038
|
// src/tools/googleDrive.ts
|
|
@@ -1270,9 +1270,25 @@ var consoleLogger = {
|
|
|
1270
1270
|
warn: console.warn.bind(console),
|
|
1271
1271
|
error: console.error.bind(console)
|
|
1272
1272
|
};
|
|
1273
|
-
var
|
|
1273
|
+
var LOGGER_STATE_KEY = /* @__PURE__ */ Symbol.for("@anuma/sdk/logger/v1");
|
|
1274
|
+
var loggerGlobal = globalThis;
|
|
1275
|
+
var fallbackLoggerState = { logger: consoleLogger };
|
|
1276
|
+
var fallbackWarned = false;
|
|
1277
|
+
function getLoggerState() {
|
|
1278
|
+
try {
|
|
1279
|
+
return loggerGlobal[LOGGER_STATE_KEY] ?? (loggerGlobal[LOGGER_STATE_KEY] = fallbackLoggerState);
|
|
1280
|
+
} catch {
|
|
1281
|
+
if (!fallbackWarned) {
|
|
1282
|
+
fallbackWarned = true;
|
|
1283
|
+
fallbackLoggerState.logger.warn(
|
|
1284
|
+
"@anuma/sdk: the global object rejects new properties. This entrypoint keeps its own logger, so setLogger does not reach other entrypoints."
|
|
1285
|
+
);
|
|
1286
|
+
}
|
|
1287
|
+
return fallbackLoggerState;
|
|
1288
|
+
}
|
|
1289
|
+
}
|
|
1274
1290
|
function getLogger() {
|
|
1275
|
-
return
|
|
1291
|
+
return getLoggerState().logger;
|
|
1276
1292
|
}
|
|
1277
1293
|
|
|
1278
1294
|
// src/lib/memoryEngine/chunking.ts
|
|
@@ -1662,6 +1678,9 @@ function clientToolToResponsesFormat(tool) {
|
|
|
1662
1678
|
...toolConfig.removeAfterExecution !== void 0 && {
|
|
1663
1679
|
removeAfterExecution: toolConfig.removeAfterExecution
|
|
1664
1680
|
},
|
|
1681
|
+
...toolConfig.removeAfterResult !== void 0 && {
|
|
1682
|
+
removeAfterResult: toolConfig.removeAfterResult
|
|
1683
|
+
},
|
|
1665
1684
|
...toolConfig.executorTimeout !== void 0 && {
|
|
1666
1685
|
executorTimeout: toolConfig.executorTimeout
|
|
1667
1686
|
},
|
|
@@ -1695,6 +1714,9 @@ function clientToolToCompletionsFormat(tool) {
|
|
|
1695
1714
|
...toolConfig.removeAfterExecution !== void 0 && {
|
|
1696
1715
|
removeAfterExecution: toolConfig.removeAfterExecution
|
|
1697
1716
|
},
|
|
1717
|
+
...toolConfig.removeAfterResult !== void 0 && {
|
|
1718
|
+
removeAfterResult: toolConfig.removeAfterResult
|
|
1719
|
+
},
|
|
1698
1720
|
...toolConfig.executorTimeout !== void 0 && {
|
|
1699
1721
|
executorTimeout: toolConfig.executorTimeout
|
|
1700
1722
|
},
|
|
@@ -32,6 +32,21 @@ type ToolConfig = LlmapiChatCompletionTool & {
|
|
|
32
32
|
* execution fails, allowing the model to retry.
|
|
33
33
|
*/
|
|
34
34
|
removeAfterExecution?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Remove this tool for the rest of the turn once ANY tool returns a
|
|
37
|
+
* successful result this predicate accepts — its own or another's. Errors
|
|
38
|
+
* never count, as for `removeAfterExecution`.
|
|
39
|
+
*
|
|
40
|
+
* Only results of tools executed on this client are offered; tools the
|
|
41
|
+
* portal runs server-side never reach the predicate. A predicate that throws
|
|
42
|
+
* is treated as not matching.
|
|
43
|
+
*
|
|
44
|
+
* For a family of tools that has to leave together: when one of them
|
|
45
|
+
* declines an out-of-scope request, the model otherwise works through its
|
|
46
|
+
* siblings round after round until the round cap. Give every member the same
|
|
47
|
+
* predicate and the first refusal removes the whole family.
|
|
48
|
+
*/
|
|
49
|
+
removeAfterResult?: (result: unknown) => boolean;
|
|
35
50
|
/**
|
|
36
51
|
* Timeout in milliseconds for this tool's executor.
|
|
37
52
|
* Overrides the default 30-second timeout.
|
|
@@ -32,6 +32,21 @@ type ToolConfig = LlmapiChatCompletionTool & {
|
|
|
32
32
|
* execution fails, allowing the model to retry.
|
|
33
33
|
*/
|
|
34
34
|
removeAfterExecution?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Remove this tool for the rest of the turn once ANY tool returns a
|
|
37
|
+
* successful result this predicate accepts — its own or another's. Errors
|
|
38
|
+
* never count, as for `removeAfterExecution`.
|
|
39
|
+
*
|
|
40
|
+
* Only results of tools executed on this client are offered; tools the
|
|
41
|
+
* portal runs server-side never reach the predicate. A predicate that throws
|
|
42
|
+
* is treated as not matching.
|
|
43
|
+
*
|
|
44
|
+
* For a family of tools that has to leave together: when one of them
|
|
45
|
+
* declines an out-of-scope request, the model otherwise works through its
|
|
46
|
+
* siblings round after round until the round cap. Give every member the same
|
|
47
|
+
* predicate and the first refusal removes the whole family.
|
|
48
|
+
*/
|
|
49
|
+
removeAfterResult?: (result: unknown) => boolean;
|
|
35
50
|
/**
|
|
36
51
|
* Timeout in milliseconds for this tool's executor.
|
|
37
52
|
* Overrides the default 30-second timeout.
|
|
@@ -1148,9 +1148,25 @@ var consoleLogger = {
|
|
|
1148
1148
|
warn: console.warn.bind(console),
|
|
1149
1149
|
error: console.error.bind(console)
|
|
1150
1150
|
};
|
|
1151
|
-
var
|
|
1151
|
+
var LOGGER_STATE_KEY = /* @__PURE__ */ Symbol.for("@anuma/sdk/logger/v1");
|
|
1152
|
+
var loggerGlobal = globalThis;
|
|
1153
|
+
var fallbackLoggerState = { logger: consoleLogger };
|
|
1154
|
+
var fallbackWarned = false;
|
|
1155
|
+
function getLoggerState() {
|
|
1156
|
+
try {
|
|
1157
|
+
return loggerGlobal[LOGGER_STATE_KEY] ?? (loggerGlobal[LOGGER_STATE_KEY] = fallbackLoggerState);
|
|
1158
|
+
} catch {
|
|
1159
|
+
if (!fallbackWarned) {
|
|
1160
|
+
fallbackWarned = true;
|
|
1161
|
+
fallbackLoggerState.logger.warn(
|
|
1162
|
+
"@anuma/sdk: the global object rejects new properties. This entrypoint keeps its own logger, so setLogger does not reach other entrypoints."
|
|
1163
|
+
);
|
|
1164
|
+
}
|
|
1165
|
+
return fallbackLoggerState;
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1152
1168
|
function getLogger() {
|
|
1153
|
-
return
|
|
1169
|
+
return getLoggerState().logger;
|
|
1154
1170
|
}
|
|
1155
1171
|
|
|
1156
1172
|
// src/lib/memoryEngine/chunking.ts
|
|
@@ -1540,6 +1556,9 @@ function clientToolToResponsesFormat(tool) {
|
|
|
1540
1556
|
...toolConfig.removeAfterExecution !== void 0 && {
|
|
1541
1557
|
removeAfterExecution: toolConfig.removeAfterExecution
|
|
1542
1558
|
},
|
|
1559
|
+
...toolConfig.removeAfterResult !== void 0 && {
|
|
1560
|
+
removeAfterResult: toolConfig.removeAfterResult
|
|
1561
|
+
},
|
|
1543
1562
|
...toolConfig.executorTimeout !== void 0 && {
|
|
1544
1563
|
executorTimeout: toolConfig.executorTimeout
|
|
1545
1564
|
},
|
|
@@ -1573,6 +1592,9 @@ function clientToolToCompletionsFormat(tool) {
|
|
|
1573
1592
|
...toolConfig.removeAfterExecution !== void 0 && {
|
|
1574
1593
|
removeAfterExecution: toolConfig.removeAfterExecution
|
|
1575
1594
|
},
|
|
1595
|
+
...toolConfig.removeAfterResult !== void 0 && {
|
|
1596
|
+
removeAfterResult: toolConfig.removeAfterResult
|
|
1597
|
+
},
|
|
1576
1598
|
...toolConfig.executorTimeout !== void 0 && {
|
|
1577
1599
|
executorTimeout: toolConfig.executorTimeout
|
|
1578
1600
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anuma/sdk",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.31.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -154,7 +154,7 @@
|
|
|
154
154
|
"check:excluded-suites": "node scripts/assert-excluded-suites-still-fail.mjs",
|
|
155
155
|
"knip": "knip",
|
|
156
156
|
"check:export-consumers": "node scripts/assert-export-consumers.mjs",
|
|
157
|
-
"check-exports": "publint && attw --pack --ignore-rules no-resolution false-cjs && node scripts/assert-no-client-self-import.mjs",
|
|
157
|
+
"check-exports": "publint && attw --pack --ignore-rules no-resolution false-cjs && node scripts/assert-no-client-self-import.mjs && node scripts/assert-shared-logger.mjs",
|
|
158
158
|
"check": "pnpm run lint && pnpm run knip && pnpm run check:export-consumers && pnpm run format && pnpm run generate",
|
|
159
159
|
"eval:extraction": "tsx test/memory/src/extraction/benchmark.test.ts",
|
|
160
160
|
"eval:topic": "tsx test/memory/src/topic/benchmark.ts",
|