@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/expo/index.d.ts
CHANGED
|
@@ -2209,6 +2209,21 @@ type ToolConfig = LlmapiChatCompletionTool & {
|
|
|
2209
2209
|
* execution fails, allowing the model to retry.
|
|
2210
2210
|
*/
|
|
2211
2211
|
removeAfterExecution?: boolean;
|
|
2212
|
+
/**
|
|
2213
|
+
* Remove this tool for the rest of the turn once ANY tool returns a
|
|
2214
|
+
* successful result this predicate accepts — its own or another's. Errors
|
|
2215
|
+
* never count, as for `removeAfterExecution`.
|
|
2216
|
+
*
|
|
2217
|
+
* Only results of tools executed on this client are offered; tools the
|
|
2218
|
+
* portal runs server-side never reach the predicate. A predicate that throws
|
|
2219
|
+
* is treated as not matching.
|
|
2220
|
+
*
|
|
2221
|
+
* For a family of tools that has to leave together: when one of them
|
|
2222
|
+
* declines an out-of-scope request, the model otherwise works through its
|
|
2223
|
+
* siblings round after round until the round cap. Give every member the same
|
|
2224
|
+
* predicate and the first refusal removes the whole family.
|
|
2225
|
+
*/
|
|
2226
|
+
removeAfterResult?: (result: unknown) => boolean;
|
|
2212
2227
|
/**
|
|
2213
2228
|
* Timeout in milliseconds for this tool's executor.
|
|
2214
2229
|
* Overrides the default 30-second timeout.
|
|
@@ -3512,6 +3527,7 @@ type MessageFeedback = "like" | "dislike" | null;
|
|
|
3512
3527
|
* - `tool_result`: the hidden `[Tool Execution Results]` row built from a
|
|
3513
3528
|
* turn's auto-executed tool results. Skipped by the embedding sweep (see
|
|
3514
3529
|
* `memoryEngine/embeddings`) AND hidden from the transcript.
|
|
3530
|
+
* - `message`: an ordinary message with an index after explicit repair.
|
|
3515
3531
|
* - `chunks_discarded`: an ordinary, still-rendered message whose chunk vectors
|
|
3516
3532
|
* were built over `enc:v3:` ciphertext (sdk#864) and have been discarded
|
|
3517
3533
|
* rather than re-embedded at the user's own expense (client#5618). Skipped by
|
|
@@ -3524,7 +3540,7 @@ type MessageFeedback = "like" | "dislike" | null;
|
|
|
3524
3540
|
* encrypted flag would be unreadable exactly where it matters and the skip
|
|
3525
3541
|
* would fail open.
|
|
3526
3542
|
*/
|
|
3527
|
-
type MessageOrigin = "tool_result" | "chunks_discarded";
|
|
3543
|
+
type MessageOrigin = "tool_result" | "chunks_discarded" | "message";
|
|
3528
3544
|
/**
|
|
3529
3545
|
* Metadata for files attached to messages.
|
|
3530
3546
|
*
|
|
@@ -5202,7 +5218,12 @@ type PortalLlmFailureReason =
|
|
|
5202
5218
|
/** Content parsed to a literal `null`, which is never a valid response. */
|
|
5203
5219
|
| "null-completion"
|
|
5204
5220
|
/** `totalTimeoutMs` was spent before the next attempt could run. */
|
|
5205
|
-
| "time-budget-exhausted"
|
|
5221
|
+
| "time-budget-exhausted"
|
|
5222
|
+
/**
|
|
5223
|
+
* The portal's moderation gate refused the request. Terminal: the same input
|
|
5224
|
+
* is flagged again on every retry. See {@link isModerationResponse}.
|
|
5225
|
+
*/
|
|
5226
|
+
| "content-flagged";
|
|
5206
5227
|
/**
|
|
5207
5228
|
* One attempt of a {@link callPortalJsonCompletion} call, reported to
|
|
5208
5229
|
* `onAttempt` as it settles — success included. The wire-level diagnostic the
|
|
@@ -6439,7 +6460,9 @@ interface ExtractFactsOptions extends PortalLlmAuth {
|
|
|
6439
6460
|
* Optional per-call request path override, forwarded to
|
|
6440
6461
|
* {@link callPortalJsonCompletion}. When set, the extraction call POSTs to
|
|
6441
6462
|
* `baseUrl + endpointOverride` instead of the default
|
|
6442
|
-
* `/api/v1/chat/completions
|
|
6463
|
+
* `/api/v1/chat/completions`. The body follows the transport, not the path: a
|
|
6464
|
+
* model that needs the Responses API is moved from a `.../chat/completions`
|
|
6465
|
+
* override to its sibling `.../responses` with a Responses-shaped body. Lets callers route
|
|
6443
6466
|
* this internal-utility pass to a dedicated endpoint. Invalid values throw at
|
|
6444
6467
|
* call time (see {@link validateEndpointOverride}).
|
|
6445
6468
|
*
|
|
@@ -7292,7 +7315,8 @@ declare function stampTopicsExtractedAtOp(ctx: VaultMemoryOperationsContext, mem
|
|
|
7292
7315
|
* `topics_user_managed` in particular is left exactly as it arrived, so the
|
|
7293
7316
|
* autotagger stays off a curated memory whose links this just restored.
|
|
7294
7317
|
*
|
|
7295
|
-
* Skips deleted, foreign-user, and
|
|
7318
|
+
* Skips deleted rows, foreign-user rows, and rows with null topics.
|
|
7319
|
+
* Empty topics remove stale links. Returns the relinked IDs.
|
|
7296
7320
|
*/
|
|
7297
7321
|
declare function relinkMemoryTopicsOp(ctx: VaultMemoryOperationsContext, memoryIds: readonly string[]): Promise<string[]>;
|
|
7298
7322
|
/**
|
|
@@ -9121,7 +9145,9 @@ interface TopicExtractOptions extends PortalLlmAuth {
|
|
|
9121
9145
|
* Optional per-call request path override, forwarded to
|
|
9122
9146
|
* {@link callPortalJsonCompletion}. When set, topic extraction POSTs to
|
|
9123
9147
|
* `baseUrl + endpointOverride` instead of the default
|
|
9124
|
-
* `/api/v1/chat/completions
|
|
9148
|
+
* `/api/v1/chat/completions`. The body follows the transport, not the path: a
|
|
9149
|
+
* model that needs the Responses API is moved from a `.../chat/completions`
|
|
9150
|
+
* override to its sibling `.../responses` with a Responses-shaped body. Lets callers route
|
|
9125
9151
|
* this internal-utility pass to a dedicated endpoint. Invalid values throw at
|
|
9126
9152
|
* call time (see {@link validateEndpointOverride}).
|
|
9127
9153
|
*/
|
|
@@ -9747,14 +9773,10 @@ declare function generateEmbeddings(texts: string[], options: EmbeddingOptions):
|
|
|
9747
9773
|
* re-index. Off by default, so no background pass can spend a user's credits
|
|
9748
9774
|
* without being asked to.
|
|
9749
9775
|
*
|
|
9750
|
-
*
|
|
9751
|
-
*
|
|
9752
|
-
*
|
|
9753
|
-
*
|
|
9754
|
-
* before it can do anything, so the repaired rows stay on the old model, and
|
|
9755
|
-
* `searchChunksOp` already drops stale-model vectors — they go quiet with
|
|
9756
|
-
* nothing telling them apart from rows that were never repaired. Clearing the
|
|
9757
|
-
* marker on a successful re-index is the real fix, tracked in #879.
|
|
9776
|
+
* A successful repair replaces the marker with `message` in the index write.
|
|
9777
|
+
* The new marker preserves ordinary message provenance during chat replay.
|
|
9778
|
+
* Later model migrations can then include the repaired row without this flag.
|
|
9779
|
+
* Failed embedding requests and empty index data do not clear the marker.
|
|
9758
9780
|
*
|
|
9759
9781
|
* `satisfies MessageOrigin` so the constant and the union cannot drift apart
|
|
9760
9782
|
* silently — the column's type is the union, and a typo here would otherwise
|
|
@@ -9791,9 +9813,8 @@ declare function embedAllMessages(ctx: StorageOperationsContext, options: Embedd
|
|
|
9791
9813
|
* to an explicit user action, never to a background pass. Opens that marker
|
|
9792
9814
|
* only — `tool_result` rows stay excluded.
|
|
9793
9815
|
*
|
|
9794
|
-
*
|
|
9795
|
-
*
|
|
9796
|
-
* {@link CHUNKS_DISCARDED_ORIGIN}.
|
|
9816
|
+
* A successful repair clears the marker. Later model migrations include
|
|
9817
|
+
* the repaired row without this flag. See {@link CHUNKS_DISCARDED_ORIGIN}.
|
|
9797
9818
|
*/
|
|
9798
9819
|
reembedDiscarded?: boolean;
|
|
9799
9820
|
}): Promise<number>;
|
|
@@ -9851,9 +9872,8 @@ declare function chunkAndEmbedAllMessages(ctx: StorageOperationsContext, options
|
|
|
9851
9872
|
* chunks nor vector, so it never reaches that check and falls straight to the
|
|
9852
9873
|
* origin gate.
|
|
9853
9874
|
*
|
|
9854
|
-
*
|
|
9855
|
-
*
|
|
9856
|
-
* {@link CHUNKS_DISCARDED_ORIGIN}.
|
|
9875
|
+
* A successful repair clears the marker. Later model migrations include
|
|
9876
|
+
* the repaired row without this flag. See {@link CHUNKS_DISCARDED_ORIGIN}.
|
|
9857
9877
|
*/
|
|
9858
9878
|
reembedDiscarded?: boolean;
|
|
9859
9879
|
}): Promise<number>;
|
package/dist/expo/index.mjs
CHANGED
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
taskTypeHeader,
|
|
20
20
|
validateEndpointOverride,
|
|
21
21
|
withInternalFlowMarker
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-XD6WOQ5I.mjs";
|
|
23
23
|
import {
|
|
24
24
|
BASE_URL,
|
|
25
25
|
MCP_R2_DOMAIN,
|
|
@@ -2120,6 +2120,9 @@ async function updateMessageEmbeddingOp(ctx, uniqueId, vector, embeddingModel) {
|
|
|
2120
2120
|
await ctx.database.write(async () => {
|
|
2121
2121
|
await message.update((msg) => {
|
|
2122
2122
|
msg._setRaw("vector", JSON.stringify(vector));
|
|
2123
|
+
if (msg.origin === "chunks_discarded" && vector.length > 0) {
|
|
2124
|
+
msg._setRaw("origin", "message");
|
|
2125
|
+
}
|
|
2123
2126
|
msg._setRaw("embedding_model", embeddingModel);
|
|
2124
2127
|
});
|
|
2125
2128
|
});
|
|
@@ -2136,6 +2139,9 @@ async function updateMessageChunksOp(ctx, uniqueId, chunks, embeddingModel) {
|
|
|
2136
2139
|
await ctx.database.write(async () => {
|
|
2137
2140
|
await message.update((msg) => {
|
|
2138
2141
|
msg._setRaw("chunks", JSON.stringify(storedChunks));
|
|
2142
|
+
if (msg.origin === "chunks_discarded" && storedChunks.length > 0 && storedChunks.every((chunk) => chunk.vector.length > 0)) {
|
|
2143
|
+
msg._setRaw("origin", "message");
|
|
2144
|
+
}
|
|
2139
2145
|
msg._setRaw("embedding_model", embeddingModel);
|
|
2140
2146
|
});
|
|
2141
2147
|
});
|
|
@@ -4345,6 +4351,9 @@ function clientToolToResponsesFormat(tool) {
|
|
|
4345
4351
|
...toolConfig.removeAfterExecution !== void 0 && {
|
|
4346
4352
|
removeAfterExecution: toolConfig.removeAfterExecution
|
|
4347
4353
|
},
|
|
4354
|
+
...toolConfig.removeAfterResult !== void 0 && {
|
|
4355
|
+
removeAfterResult: toolConfig.removeAfterResult
|
|
4356
|
+
},
|
|
4348
4357
|
...toolConfig.executorTimeout !== void 0 && {
|
|
4349
4358
|
executorTimeout: toolConfig.executorTimeout
|
|
4350
4359
|
},
|
|
@@ -4378,6 +4387,9 @@ function clientToolToCompletionsFormat(tool) {
|
|
|
4378
4387
|
...toolConfig.removeAfterExecution !== void 0 && {
|
|
4379
4388
|
removeAfterExecution: toolConfig.removeAfterExecution
|
|
4380
4389
|
},
|
|
4390
|
+
...toolConfig.removeAfterResult !== void 0 && {
|
|
4391
|
+
removeAfterResult: toolConfig.removeAfterResult
|
|
4392
|
+
},
|
|
4381
4393
|
...toolConfig.executorTimeout !== void 0 && {
|
|
4382
4394
|
executorTimeout: toolConfig.executorTimeout
|
|
4383
4395
|
},
|
|
@@ -5308,6 +5320,7 @@ function toolsToApiFormat(tools, apiType) {
|
|
|
5308
5320
|
executor: _executor,
|
|
5309
5321
|
skipContinuation: _skipContinuation,
|
|
5310
5322
|
removeAfterExecution: _removeAfterExecution,
|
|
5323
|
+
removeAfterResult: _removeAfterResult,
|
|
5311
5324
|
executorTimeout: _executorTimeout,
|
|
5312
5325
|
dependsOn: _dependsOn,
|
|
5313
5326
|
deAnonymizeArgs: _deAnonymizeArgs,
|
|
@@ -7752,9 +7765,11 @@ Executing tool: ${toolInfo}
|
|
|
7752
7765
|
}
|
|
7753
7766
|
if (tools && apiTools) {
|
|
7754
7767
|
const successfullyExecutedNames = /* @__PURE__ */ new Set();
|
|
7768
|
+
const successfulResults = [];
|
|
7755
7769
|
for (const r of executionResults) {
|
|
7756
7770
|
if (!r.error && !isToolErrorResult(r.result) && "name" in r && r.name) {
|
|
7757
7771
|
successfullyExecutedNames.add(r.name);
|
|
7772
|
+
successfulResults.push(r.result);
|
|
7758
7773
|
}
|
|
7759
7774
|
}
|
|
7760
7775
|
if (successfullyExecutedNames.size > 0) {
|
|
@@ -7763,7 +7778,15 @@ Executing tool: ${toolInfo}
|
|
|
7763
7778
|
const tc = t;
|
|
7764
7779
|
const func = tc.function;
|
|
7765
7780
|
const toolName = typeof func?.name === "string" ? func.name : typeof tc.name === "string" ? tc.name : void 0;
|
|
7766
|
-
if (
|
|
7781
|
+
if (!toolName) continue;
|
|
7782
|
+
const removeAfterResult = tc.removeAfterResult;
|
|
7783
|
+
if (tc.removeAfterExecution === true && successfullyExecutedNames.has(toolName) || typeof removeAfterResult === "function" && successfulResults.some((result) => {
|
|
7784
|
+
try {
|
|
7785
|
+
return removeAfterResult(result);
|
|
7786
|
+
} catch {
|
|
7787
|
+
return false;
|
|
7788
|
+
}
|
|
7789
|
+
})) {
|
|
7767
7790
|
toolsToRemove.add(toolName);
|
|
7768
7791
|
}
|
|
7769
7792
|
}
|
|
@@ -11589,7 +11612,7 @@ async function getMemoriesNeedingTopicExtractionOp(ctx, options) {
|
|
|
11589
11612
|
const id = raw.id;
|
|
11590
11613
|
const topics = parseTopics(raw.topics);
|
|
11591
11614
|
const linked = linkedNames.get(id);
|
|
11592
|
-
if (topics !== null &&
|
|
11615
|
+
if (topics !== null && linksDivergeFromTopics(topics, linked ?? /* @__PURE__ */ new Set())) {
|
|
11593
11616
|
topicsToRelinkAll.push(id);
|
|
11594
11617
|
continue;
|
|
11595
11618
|
}
|
|
@@ -11683,18 +11706,20 @@ async function relinkMemoryTopicsOp(ctx, memoryIds) {
|
|
|
11683
11706
|
}
|
|
11684
11707
|
const relinked = [];
|
|
11685
11708
|
for (const id of Array.from(new Set(memoryIds))) {
|
|
11686
|
-
let record;
|
|
11687
11709
|
try {
|
|
11688
|
-
|
|
11689
|
-
|
|
11690
|
-
|
|
11691
|
-
|
|
11692
|
-
|
|
11693
|
-
|
|
11694
|
-
|
|
11695
|
-
|
|
11696
|
-
|
|
11697
|
-
|
|
11710
|
+
await ctx.database.write(async (writer) => {
|
|
11711
|
+
let record;
|
|
11712
|
+
try {
|
|
11713
|
+
record = await ctx.vaultMemoryCollection.find(id);
|
|
11714
|
+
} catch {
|
|
11715
|
+
return;
|
|
11716
|
+
}
|
|
11717
|
+
if (record.isDeleted || !isOwnedByCtxUser(ctx, record)) return;
|
|
11718
|
+
const topics = parseTopics(record.topics);
|
|
11719
|
+
if (topics === null) return;
|
|
11720
|
+
await writer.callWriter(() => relinkMemoryEntitiesFromTopicsOp(entityCtx, id, topics));
|
|
11721
|
+
relinked.push(id);
|
|
11722
|
+
});
|
|
11698
11723
|
} catch (err) {
|
|
11699
11724
|
getLogger().warn("[memory/topics] relink failed", err);
|
|
11700
11725
|
}
|
|
@@ -14952,7 +14977,7 @@ async function tryConsolidate(trimmed, ctx, options, prepared) {
|
|
|
14952
14977
|
content: m.content,
|
|
14953
14978
|
similarity: m.similarity
|
|
14954
14979
|
}));
|
|
14955
|
-
const { consolidateMemory: doConsolidate } = await import("./consolidate-
|
|
14980
|
+
const { consolidateMemory: doConsolidate } = await import("./consolidate-7DBUHQRK.mjs");
|
|
14956
14981
|
const decision = await doConsolidate(trimmed, candidates, consolidateOptions);
|
|
14957
14982
|
if (decision.action === "create") return decision.fallbackReason ? null : { create: true };
|
|
14958
14983
|
if (decision.action === "supersede" && decision.content) {
|
|
@@ -18599,6 +18624,28 @@ var BatchFailureError = class extends Error {
|
|
|
18599
18624
|
this.terminal = terminal;
|
|
18600
18625
|
}
|
|
18601
18626
|
};
|
|
18627
|
+
var FlaggedBatchError = class extends Error {
|
|
18628
|
+
};
|
|
18629
|
+
function extracted(result) {
|
|
18630
|
+
return result.failedCount === 0 && result.outcome !== "empty-after-retry";
|
|
18631
|
+
}
|
|
18632
|
+
function batchError(result) {
|
|
18633
|
+
const failure = result.failure;
|
|
18634
|
+
if (failure?.reason === "http-terminal") {
|
|
18635
|
+
const status = failure.httpStatus;
|
|
18636
|
+
if (status !== void 0 && REQUEST_REJECTED_STATUSES.has(status))
|
|
18637
|
+
return new BatchFailureError(
|
|
18638
|
+
`Extraction rejected the batch (HTTP ${status}); not retried this session`,
|
|
18639
|
+
true
|
|
18640
|
+
);
|
|
18641
|
+
return new AccountFailureError(
|
|
18642
|
+
`Extraction refused for the account (HTTP ${status ?? "unknown"}); retried next session`
|
|
18643
|
+
);
|
|
18644
|
+
}
|
|
18645
|
+
if (result.failedCount > 0 || failure !== void 0 && CONTENT_FAILURE_REASONS.has(failure.reason))
|
|
18646
|
+
return new BatchFailureError("Extraction batch incomplete; retained for retry", false);
|
|
18647
|
+
return new Error("Extraction batch incomplete; retained for retry");
|
|
18648
|
+
}
|
|
18602
18649
|
var AccountFailureError = class extends Error {
|
|
18603
18650
|
};
|
|
18604
18651
|
var LockedSourcesError = class extends Error {
|
|
@@ -18607,6 +18654,16 @@ var LockedSourcesError = class extends Error {
|
|
|
18607
18654
|
this.persistentIds = persistentIds;
|
|
18608
18655
|
}
|
|
18609
18656
|
};
|
|
18657
|
+
function splitTurns(messages) {
|
|
18658
|
+
const turns = [];
|
|
18659
|
+
for (const message of messages) {
|
|
18660
|
+
const last = turns[turns.length - 1];
|
|
18661
|
+
if (!last || message.role === "user" && last.some((m) => m.role === "user"))
|
|
18662
|
+
turns.push([message]);
|
|
18663
|
+
else last.push(message);
|
|
18664
|
+
}
|
|
18665
|
+
return turns;
|
|
18666
|
+
}
|
|
18610
18667
|
function idsOf(job) {
|
|
18611
18668
|
return JSON.parse(String(job._getRaw("message_ids")));
|
|
18612
18669
|
}
|
|
@@ -18757,6 +18814,10 @@ function createDurableAutoExtractor(options) {
|
|
|
18757
18814
|
skippedThisSession.add(job.id);
|
|
18758
18815
|
return false;
|
|
18759
18816
|
}
|
|
18817
|
+
if (error instanceof FlaggedBatchError) {
|
|
18818
|
+
await acknowledge(job, ids, loaded, true);
|
|
18819
|
+
return true;
|
|
18820
|
+
}
|
|
18760
18821
|
const counted = error instanceof BatchFailureError || error instanceof LockedSourcesError && error.persistentIds.length > 0;
|
|
18761
18822
|
if (!counted) return false;
|
|
18762
18823
|
const prior = sessionFailures.get(job.id);
|
|
@@ -18883,37 +18944,50 @@ function createDurableAutoExtractor(options) {
|
|
|
18883
18944
|
const messages = loaded.flatMap(
|
|
18884
18945
|
(m) => m && m.conversationId === conversationId && (m.role === "user" || m.role === "assistant") ? [{ id: m.uniqueId, role: m.role, content: m.content }] : []
|
|
18885
18946
|
);
|
|
18886
|
-
|
|
18887
|
-
|
|
18888
|
-
|
|
18889
|
-
result = await extractBatch(
|
|
18890
|
-
|
|
18947
|
+
const jobScope = currentScope() === "private" ? "private" : String(job._getRaw("scope"));
|
|
18948
|
+
const jobFolderId = job._getRaw("folder_id") ?? null;
|
|
18949
|
+
const runExtraction = async (batch, batchIds) => {
|
|
18950
|
+
const result = await extractBatch(
|
|
18951
|
+
batch,
|
|
18891
18952
|
conversationId,
|
|
18892
|
-
|
|
18893
|
-
|
|
18894
|
-
|
|
18953
|
+
batchIds,
|
|
18954
|
+
jobScope,
|
|
18955
|
+
jobFolderId
|
|
18895
18956
|
);
|
|
18896
|
-
success = result.failedCount === 0 && result.outcome !== "empty-after-retry";
|
|
18897
18957
|
options.onTurnComplete?.(result);
|
|
18898
|
-
|
|
18899
|
-
|
|
18900
|
-
|
|
18901
|
-
|
|
18902
|
-
|
|
18903
|
-
|
|
18904
|
-
|
|
18905
|
-
|
|
18906
|
-
|
|
18958
|
+
return result;
|
|
18959
|
+
};
|
|
18960
|
+
const flaggedIds = /* @__PURE__ */ new Set();
|
|
18961
|
+
if (messages.length) {
|
|
18962
|
+
const result = await runExtraction(messages, ids);
|
|
18963
|
+
if (result.failure?.reason === "content-flagged") {
|
|
18964
|
+
const turns = splitTurns(messages);
|
|
18965
|
+
if (turns.length < 2)
|
|
18966
|
+
throw new FlaggedBatchError("Extraction batch refused by moderation; abandoned");
|
|
18967
|
+
for (const turn of turns) {
|
|
18968
|
+
const turnResult = await runExtraction(
|
|
18969
|
+
turn,
|
|
18970
|
+
turn.map((m) => m.id)
|
|
18907
18971
|
);
|
|
18908
|
-
|
|
18909
|
-
|
|
18910
|
-
|
|
18911
|
-
|
|
18912
|
-
|
|
18913
|
-
|
|
18914
|
-
|
|
18972
|
+
if (turnResult.failure?.reason === "content-flagged")
|
|
18973
|
+
for (const m of turn) flaggedIds.add(m.id);
|
|
18974
|
+
else if (!extracted(turnResult)) throw batchError(turnResult);
|
|
18975
|
+
}
|
|
18976
|
+
if (flaggedIds.size)
|
|
18977
|
+
reportError(
|
|
18978
|
+
new Error(
|
|
18979
|
+
`Dropped ${flaggedIds.size} source id(s) of an extraction batch refused by moderation`
|
|
18980
|
+
),
|
|
18981
|
+
conversationId
|
|
18982
|
+
);
|
|
18983
|
+
} else if (!extracted(result)) throw batchError(result);
|
|
18915
18984
|
}
|
|
18916
|
-
await acknowledge(
|
|
18985
|
+
await acknowledge(
|
|
18986
|
+
job,
|
|
18987
|
+
ids,
|
|
18988
|
+
loaded,
|
|
18989
|
+
ids.slice(-2).some((id) => flaggedIds.has(id))
|
|
18990
|
+
);
|
|
18917
18991
|
scheduleAfterSuccess = true;
|
|
18918
18992
|
} catch (error) {
|
|
18919
18993
|
attempts.set(job.id, attempted + 1);
|
|
@@ -20568,10 +20642,10 @@ function useChatStorage(options) {
|
|
|
20568
20642
|
let mergedTools2 = void 0;
|
|
20569
20643
|
let filteredServerTools2 = [];
|
|
20570
20644
|
const isServerToolsFunction2 = typeof serverToolsFilter === "function";
|
|
20571
|
-
const
|
|
20645
|
+
const extracted3 = extractUserMessageFromMessages(messages);
|
|
20572
20646
|
const messageContent = resolveStoredUserContent(
|
|
20573
20647
|
storedUserContent,
|
|
20574
|
-
|
|
20648
|
+
extracted3?.content ?? ""
|
|
20575
20649
|
);
|
|
20576
20650
|
let skipUserEmbedding;
|
|
20577
20651
|
let skipEmbeddingFailed = false;
|
|
@@ -20737,15 +20811,15 @@ function useChatStorage(options) {
|
|
|
20737
20811
|
skipped: true
|
|
20738
20812
|
};
|
|
20739
20813
|
}
|
|
20740
|
-
const
|
|
20741
|
-
if (!
|
|
20814
|
+
const extracted2 = extractUserMessageFromMessages(messages);
|
|
20815
|
+
if (!extracted2 || !extracted2.content && !extracted2.files?.length) {
|
|
20742
20816
|
return {
|
|
20743
20817
|
data: null,
|
|
20744
20818
|
error: "No user message found in messages array"
|
|
20745
20819
|
};
|
|
20746
20820
|
}
|
|
20747
|
-
const contentForStorage = resolveStoredUserContent(storedUserContent,
|
|
20748
|
-
const filesForStorage = files ??
|
|
20821
|
+
const contentForStorage = resolveStoredUserContent(storedUserContent, extracted2.content);
|
|
20822
|
+
const filesForStorage = files ?? extracted2.files;
|
|
20749
20823
|
let convId;
|
|
20750
20824
|
try {
|
|
20751
20825
|
convId = await ensureConversation();
|
|
@@ -21073,9 +21147,9 @@ function useChatStorage(options) {
|
|
|
21073
21147
|
if (result.error || !result.data) {
|
|
21074
21148
|
const abortedResult = result;
|
|
21075
21149
|
if (abortedResult.error === "Request aborted") {
|
|
21076
|
-
const
|
|
21077
|
-
const assistantContent2 =
|
|
21078
|
-
const abortedThinkingContent =
|
|
21150
|
+
const extracted3 = abortedResult.data ? extractAssistantText(abortedResult.data) : { content: "", thinking: void 0 };
|
|
21151
|
+
const assistantContent2 = extracted3.content;
|
|
21152
|
+
const abortedThinkingContent = extracted3.thinking;
|
|
21079
21153
|
const responseModel = abortedResult.data?.model || model || "";
|
|
21080
21154
|
let storedAssistantMessage2;
|
|
21081
21155
|
try {
|
package/dist/index.cjs
CHANGED
|
@@ -1694,12 +1694,28 @@ var noopLogger = {
|
|
|
1694
1694
|
error: () => {
|
|
1695
1695
|
}
|
|
1696
1696
|
};
|
|
1697
|
-
var
|
|
1697
|
+
var LOGGER_STATE_KEY = /* @__PURE__ */ Symbol.for("@anuma/sdk/logger/v1");
|
|
1698
|
+
var loggerGlobal = globalThis;
|
|
1699
|
+
var fallbackLoggerState = { logger: consoleLogger };
|
|
1700
|
+
var fallbackWarned = false;
|
|
1701
|
+
function getLoggerState() {
|
|
1702
|
+
try {
|
|
1703
|
+
return loggerGlobal[LOGGER_STATE_KEY] ?? (loggerGlobal[LOGGER_STATE_KEY] = fallbackLoggerState);
|
|
1704
|
+
} catch {
|
|
1705
|
+
if (!fallbackWarned) {
|
|
1706
|
+
fallbackWarned = true;
|
|
1707
|
+
fallbackLoggerState.logger.warn(
|
|
1708
|
+
"@anuma/sdk: the global object rejects new properties. This entrypoint keeps its own logger, so setLogger does not reach other entrypoints."
|
|
1709
|
+
);
|
|
1710
|
+
}
|
|
1711
|
+
return fallbackLoggerState;
|
|
1712
|
+
}
|
|
1713
|
+
}
|
|
1698
1714
|
function setLogger(logger) {
|
|
1699
|
-
|
|
1715
|
+
getLoggerState().logger = logger;
|
|
1700
1716
|
}
|
|
1701
1717
|
function getLogger() {
|
|
1702
|
-
return
|
|
1718
|
+
return getLoggerState().logger;
|
|
1703
1719
|
}
|
|
1704
1720
|
|
|
1705
1721
|
// src/lib/memoryEngine/chunking.ts
|
package/dist/index.d.mts
CHANGED
|
@@ -7664,6 +7664,21 @@ type ToolConfig = LlmapiChatCompletionTool & {
|
|
|
7664
7664
|
* execution fails, allowing the model to retry.
|
|
7665
7665
|
*/
|
|
7666
7666
|
removeAfterExecution?: boolean;
|
|
7667
|
+
/**
|
|
7668
|
+
* Remove this tool for the rest of the turn once ANY tool returns a
|
|
7669
|
+
* successful result this predicate accepts — its own or another's. Errors
|
|
7670
|
+
* never count, as for `removeAfterExecution`.
|
|
7671
|
+
*
|
|
7672
|
+
* Only results of tools executed on this client are offered; tools the
|
|
7673
|
+
* portal runs server-side never reach the predicate. A predicate that throws
|
|
7674
|
+
* is treated as not matching.
|
|
7675
|
+
*
|
|
7676
|
+
* For a family of tools that has to leave together: when one of them
|
|
7677
|
+
* declines an out-of-scope request, the model otherwise works through its
|
|
7678
|
+
* siblings round after round until the round cap. Give every member the same
|
|
7679
|
+
* predicate and the first refusal removes the whole family.
|
|
7680
|
+
*/
|
|
7681
|
+
removeAfterResult?: (result: unknown) => boolean;
|
|
7667
7682
|
/**
|
|
7668
7683
|
* Timeout in milliseconds for this tool's executor.
|
|
7669
7684
|
* Overrides the default 30-second timeout.
|
|
@@ -8724,14 +8739,10 @@ interface LazyStoredConversation extends Omit<StoredConversation, "title"> {
|
|
|
8724
8739
|
* re-index. Off by default, so no background pass can spend a user's credits
|
|
8725
8740
|
* without being asked to.
|
|
8726
8741
|
*
|
|
8727
|
-
*
|
|
8728
|
-
*
|
|
8729
|
-
*
|
|
8730
|
-
*
|
|
8731
|
-
* before it can do anything, so the repaired rows stay on the old model, and
|
|
8732
|
-
* `searchChunksOp` already drops stale-model vectors — they go quiet with
|
|
8733
|
-
* nothing telling them apart from rows that were never repaired. Clearing the
|
|
8734
|
-
* marker on a successful re-index is the real fix, tracked in #879.
|
|
8742
|
+
* A successful repair replaces the marker with `message` in the index write.
|
|
8743
|
+
* The new marker preserves ordinary message provenance during chat replay.
|
|
8744
|
+
* Later model migrations can then include the repaired row without this flag.
|
|
8745
|
+
* Failed embedding requests and empty index data do not clear the marker.
|
|
8735
8746
|
*
|
|
8736
8747
|
* `satisfies MessageOrigin` so the constant and the union cannot drift apart
|
|
8737
8748
|
* silently — the column's type is the union, and a typo here would otherwise
|
package/dist/index.d.ts
CHANGED
|
@@ -7664,6 +7664,21 @@ type ToolConfig = LlmapiChatCompletionTool & {
|
|
|
7664
7664
|
* execution fails, allowing the model to retry.
|
|
7665
7665
|
*/
|
|
7666
7666
|
removeAfterExecution?: boolean;
|
|
7667
|
+
/**
|
|
7668
|
+
* Remove this tool for the rest of the turn once ANY tool returns a
|
|
7669
|
+
* successful result this predicate accepts — its own or another's. Errors
|
|
7670
|
+
* never count, as for `removeAfterExecution`.
|
|
7671
|
+
*
|
|
7672
|
+
* Only results of tools executed on this client are offered; tools the
|
|
7673
|
+
* portal runs server-side never reach the predicate. A predicate that throws
|
|
7674
|
+
* is treated as not matching.
|
|
7675
|
+
*
|
|
7676
|
+
* For a family of tools that has to leave together: when one of them
|
|
7677
|
+
* declines an out-of-scope request, the model otherwise works through its
|
|
7678
|
+
* siblings round after round until the round cap. Give every member the same
|
|
7679
|
+
* predicate and the first refusal removes the whole family.
|
|
7680
|
+
*/
|
|
7681
|
+
removeAfterResult?: (result: unknown) => boolean;
|
|
7667
7682
|
/**
|
|
7668
7683
|
* Timeout in milliseconds for this tool's executor.
|
|
7669
7684
|
* Overrides the default 30-second timeout.
|
|
@@ -8724,14 +8739,10 @@ interface LazyStoredConversation extends Omit<StoredConversation, "title"> {
|
|
|
8724
8739
|
* re-index. Off by default, so no background pass can spend a user's credits
|
|
8725
8740
|
* without being asked to.
|
|
8726
8741
|
*
|
|
8727
|
-
*
|
|
8728
|
-
*
|
|
8729
|
-
*
|
|
8730
|
-
*
|
|
8731
|
-
* before it can do anything, so the repaired rows stay on the old model, and
|
|
8732
|
-
* `searchChunksOp` already drops stale-model vectors — they go quiet with
|
|
8733
|
-
* nothing telling them apart from rows that were never repaired. Clearing the
|
|
8734
|
-
* marker on a successful re-index is the real fix, tracked in #879.
|
|
8742
|
+
* A successful repair replaces the marker with `message` in the index write.
|
|
8743
|
+
* The new marker preserves ordinary message provenance during chat replay.
|
|
8744
|
+
* Later model migrations can then include the repaired row without this flag.
|
|
8745
|
+
* Failed embedding requests and empty index data do not clear the marker.
|
|
8735
8746
|
*
|
|
8736
8747
|
* `satisfies MessageOrigin` so the constant and the union cannot drift apart
|
|
8737
8748
|
* silently — the column's type is the union, and a typo here would otherwise
|
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
|