@anuma/sdk 3.11.6 → 3.12.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-Y7XT2VNQ.mjs → chunk-WV7C7VHF.mjs} +19 -1
- package/dist/expo/{consolidate-HYIEFPFA.mjs → consolidate-AURTG64H.mjs} +4 -12
- package/dist/expo/index.cjs +74 -19
- package/dist/expo/index.d.mts +68 -5
- package/dist/expo/index.d.ts +68 -5
- package/dist/expo/index.mjs +55 -11
- package/dist/react/{chunk-TP6CJZ25.mjs → chunk-3NPDZZGO.mjs} +19 -1
- package/dist/react/{consolidate-DOY3ZWTE.mjs → consolidate-R6FH7XMV.mjs} +4 -12
- package/dist/react/index.cjs +74 -19
- package/dist/react/index.d.mts +28 -5
- package/dist/react/index.d.ts +28 -5
- package/dist/react/index.mjs +55 -11
- package/dist/server/{chunk-PXN5Q3MD.mjs → chunk-RT75PNSJ.mjs} +19 -1
- package/dist/server/{consolidate-JMGL3MXG.mjs → consolidate-4VEAS3YN.mjs} +4 -12
- package/dist/server/index.cjs +74 -19
- package/dist/server/index.d.mts +69 -6
- package/dist/server/index.d.ts +69 -6
- package/dist/server/index.mjs +55 -11
- package/package.json +1 -1
package/dist/server/index.mjs
CHANGED
|
@@ -134,8 +134,9 @@ import {
|
|
|
134
134
|
} from "./chunk-FXGG7JA5.mjs";
|
|
135
135
|
import {
|
|
136
136
|
createStreamingDeAnonymizer,
|
|
137
|
+
notifyConsolidationFallback,
|
|
137
138
|
resolvePiiRedactor
|
|
138
|
-
} from "./chunk-
|
|
139
|
+
} from "./chunk-RT75PNSJ.mjs";
|
|
139
140
|
import {
|
|
140
141
|
callPortalJsonCompletion,
|
|
141
142
|
extractJsonCandidate,
|
|
@@ -5311,6 +5312,11 @@ async function retain(content, ctx, options = {}) {
|
|
|
5311
5312
|
proofCount: 1
|
|
5312
5313
|
};
|
|
5313
5314
|
}
|
|
5315
|
+
notifyConsolidationFallback(
|
|
5316
|
+
"target_vanished",
|
|
5317
|
+
options.consolidateOptions?.onFallback,
|
|
5318
|
+
`supersede: primary target ${primaryTargetId} retired or deleted inside the atomic write`
|
|
5319
|
+
);
|
|
5314
5320
|
}
|
|
5315
5321
|
const created = await createVaultMemoryOp(ctx.vaultCtx, createOpts);
|
|
5316
5322
|
ctx.vaultCache.set(created.uniqueId, Float32Array.from(embedding));
|
|
@@ -5362,6 +5368,10 @@ function pickFactTypeUpdate(existing, incoming) {
|
|
|
5362
5368
|
function resurrectFields(existing) {
|
|
5363
5369
|
return typeof existing.archivedAt === "number" ? { restore: true } : { preserveUpdatedAt: true };
|
|
5364
5370
|
}
|
|
5371
|
+
function abandonToRace(options, detail) {
|
|
5372
|
+
notifyConsolidationFallback("target_vanished", options.consolidateOptions?.onFallback, detail);
|
|
5373
|
+
return null;
|
|
5374
|
+
}
|
|
5365
5375
|
async function tryConsolidate(trimmed, ctx, options, prepared) {
|
|
5366
5376
|
const consolidateOptions = options.consolidateOptions;
|
|
5367
5377
|
if (!consolidateOptions) return null;
|
|
@@ -5383,7 +5393,7 @@ async function tryConsolidate(trimmed, ctx, options, prepared) {
|
|
|
5383
5393
|
content: m.content,
|
|
5384
5394
|
similarity: m.similarity
|
|
5385
5395
|
}));
|
|
5386
|
-
const { consolidateMemory: doConsolidate } = await import("./consolidate-
|
|
5396
|
+
const { consolidateMemory: doConsolidate } = await import("./consolidate-4VEAS3YN.mjs");
|
|
5387
5397
|
const decision = await doConsolidate(trimmed, candidates, consolidateOptions);
|
|
5388
5398
|
if (decision.action === "create") return null;
|
|
5389
5399
|
if (decision.action === "supersede" && decision.content) {
|
|
@@ -5394,12 +5404,22 @@ async function tryConsolidate(trimmed, ctx, options, prepared) {
|
|
|
5394
5404
|
const existing = await getVaultMemoryOp(ctx.vaultCtx, id);
|
|
5395
5405
|
if (existing && !existing.supersededBy) valid.push(id);
|
|
5396
5406
|
}
|
|
5397
|
-
if (valid.length === 0)
|
|
5407
|
+
if (valid.length === 0) {
|
|
5408
|
+
return abandonToRace(
|
|
5409
|
+
options,
|
|
5410
|
+
`supersede: all ${requestedIds.length} target(s) deleted or already superseded`
|
|
5411
|
+
);
|
|
5412
|
+
}
|
|
5398
5413
|
return { supersede: valid, content: decision.content };
|
|
5399
5414
|
}
|
|
5400
5415
|
if (decision.action === "noop" && decision.targetId) {
|
|
5401
5416
|
const existing = await getVaultMemoryOp(ctx.vaultCtx, decision.targetId);
|
|
5402
|
-
if (!existing || existing.supersededBy)
|
|
5417
|
+
if (!existing || existing.supersededBy) {
|
|
5418
|
+
return abandonToRace(
|
|
5419
|
+
options,
|
|
5420
|
+
`noop: target ${decision.targetId} ${existing ? "superseded" : "deleted"} before the write`
|
|
5421
|
+
);
|
|
5422
|
+
}
|
|
5403
5423
|
const mergedSourceIds = unionStrings(
|
|
5404
5424
|
existing.sourceChunkIds ?? [],
|
|
5405
5425
|
options.sourceChunkIds ?? []
|
|
@@ -5424,7 +5444,10 @@ async function tryConsolidate(trimmed, ctx, options, prepared) {
|
|
|
5424
5444
|
});
|
|
5425
5445
|
if (!updated) {
|
|
5426
5446
|
await assertMergeTargetGoneOrThrow(ctx, decision.targetId);
|
|
5427
|
-
return
|
|
5447
|
+
return abandonToRace(
|
|
5448
|
+
options,
|
|
5449
|
+
`noop: target ${decision.targetId} deleted mid-write (proof-count bump lost)`
|
|
5450
|
+
);
|
|
5428
5451
|
}
|
|
5429
5452
|
return {
|
|
5430
5453
|
done: {
|
|
@@ -5437,7 +5460,12 @@ async function tryConsolidate(trimmed, ctx, options, prepared) {
|
|
|
5437
5460
|
}
|
|
5438
5461
|
if (decision.action === "update" && decision.targetId && decision.content) {
|
|
5439
5462
|
const existing = await getVaultMemoryOp(ctx.vaultCtx, decision.targetId);
|
|
5440
|
-
if (!existing || existing.supersededBy)
|
|
5463
|
+
if (!existing || existing.supersededBy) {
|
|
5464
|
+
return abandonToRace(
|
|
5465
|
+
options,
|
|
5466
|
+
`update: target ${decision.targetId} ${existing ? "superseded" : "deleted"} before the write`
|
|
5467
|
+
);
|
|
5468
|
+
}
|
|
5441
5469
|
const mergedSourceIds = unionStrings(
|
|
5442
5470
|
existing.sourceChunkIds ?? [],
|
|
5443
5471
|
options.sourceChunkIds ?? []
|
|
@@ -5468,7 +5496,10 @@ async function tryConsolidate(trimmed, ctx, options, prepared) {
|
|
|
5468
5496
|
});
|
|
5469
5497
|
if (!updated) {
|
|
5470
5498
|
await assertMergeTargetGoneOrThrow(ctx, decision.targetId);
|
|
5471
|
-
return
|
|
5499
|
+
return abandonToRace(
|
|
5500
|
+
options,
|
|
5501
|
+
`update: target ${decision.targetId} deleted mid-write (consolidated rewrite lost)`
|
|
5502
|
+
);
|
|
5472
5503
|
}
|
|
5473
5504
|
ctx.vaultCache.set(decision.targetId, Float32Array.from(newEmbedding));
|
|
5474
5505
|
return {
|
|
@@ -5480,6 +5511,11 @@ async function tryConsolidate(trimmed, ctx, options, prepared) {
|
|
|
5480
5511
|
}
|
|
5481
5512
|
};
|
|
5482
5513
|
}
|
|
5514
|
+
notifyConsolidationFallback(
|
|
5515
|
+
"invalid_response",
|
|
5516
|
+
options.consolidateOptions?.onFallback,
|
|
5517
|
+
`unapplicable ${decision.action} decision reached the applier \u2014 validate() should have rejected it`
|
|
5518
|
+
);
|
|
5483
5519
|
return null;
|
|
5484
5520
|
}
|
|
5485
5521
|
async function assertMergeTargetGoneOrThrow(ctx, targetId) {
|
|
@@ -12329,13 +12365,18 @@ Executing tool: ${toolInfo}
|
|
|
12329
12365
|
}
|
|
12330
12366
|
const truncatedToNothing = (acc) => acc.finishReason === "length" && acc.toolCalls.size === 0 && acc.content.trim() === "";
|
|
12331
12367
|
const TRUNCATION_ERROR = "Model response was truncated at the output-token limit before it produced any usable content or tool call. Retry with a higher `maxOutputTokens`, or prompt for fewer/smaller tool calls per turn.";
|
|
12368
|
+
const terminalStateOf = (acc) => ({
|
|
12369
|
+
...acc.finishReason !== void 0 && { finishReason: acc.finishReason },
|
|
12370
|
+
finalToolCallCount: acc.toolCalls.size
|
|
12371
|
+
});
|
|
12332
12372
|
if (toolIteration > 0) {
|
|
12333
12373
|
if (truncatedToNothing(currentAccumulator)) {
|
|
12334
12374
|
await fireRunError({ error: TRUNCATION_ERROR, stage: "model" });
|
|
12335
12375
|
return {
|
|
12336
12376
|
data: buildResponseFinal(currentAccumulator),
|
|
12337
12377
|
error: TRUNCATION_ERROR,
|
|
12338
|
-
toolsChecksum: currentAccumulator.toolsChecksum
|
|
12378
|
+
toolsChecksum: currentAccumulator.toolsChecksum,
|
|
12379
|
+
terminalState: terminalStateOf(currentAccumulator)
|
|
12339
12380
|
};
|
|
12340
12381
|
}
|
|
12341
12382
|
const finalResponse = buildResponseFinal(currentAccumulator);
|
|
@@ -12348,7 +12389,8 @@ Executing tool: ${toolInfo}
|
|
|
12348
12389
|
data: finalResponse,
|
|
12349
12390
|
error: null,
|
|
12350
12391
|
toolsChecksum: currentAccumulator.toolsChecksum,
|
|
12351
|
-
autoExecutedToolResults: accumulatedToolResults
|
|
12392
|
+
autoExecutedToolResults: accumulatedToolResults,
|
|
12393
|
+
terminalState: terminalStateOf(currentAccumulator)
|
|
12352
12394
|
};
|
|
12353
12395
|
}
|
|
12354
12396
|
if (truncatedToNothing(accumulator)) {
|
|
@@ -12356,7 +12398,8 @@ Executing tool: ${toolInfo}
|
|
|
12356
12398
|
return {
|
|
12357
12399
|
data: response,
|
|
12358
12400
|
error: TRUNCATION_ERROR,
|
|
12359
|
-
toolsChecksum: accumulator.toolsChecksum
|
|
12401
|
+
toolsChecksum: accumulator.toolsChecksum,
|
|
12402
|
+
terminalState: terminalStateOf(accumulator)
|
|
12360
12403
|
};
|
|
12361
12404
|
}
|
|
12362
12405
|
if (onFinish) onFinish(response);
|
|
@@ -12367,7 +12410,8 @@ Executing tool: ${toolInfo}
|
|
|
12367
12410
|
return {
|
|
12368
12411
|
data: response,
|
|
12369
12412
|
error: null,
|
|
12370
|
-
toolsChecksum: accumulator.toolsChecksum
|
|
12413
|
+
toolsChecksum: accumulator.toolsChecksum,
|
|
12414
|
+
terminalState: terminalStateOf(accumulator)
|
|
12371
12415
|
};
|
|
12372
12416
|
} catch (err) {
|
|
12373
12417
|
if (isAbortError(err)) {
|