@anuma/sdk 10.2.2 → 10.2.4
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-WRZTH4OS.mjs → chunk-ZIN4E7MR.mjs} +7 -0
- package/dist/expo/{consolidate-HKL5EGZT.mjs → consolidate-4WLZMXOS.mjs} +1 -1
- package/dist/expo/index.cjs +260 -113
- package/dist/expo/index.d.mts +3 -0
- package/dist/expo/index.d.ts +3 -0
- package/dist/expo/index.mjs +228 -89
- package/dist/index.cjs +7 -0
- package/dist/index.d.mts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.mjs +7 -0
- package/dist/react/{chunk-RSA3S6OA.mjs → chunk-7JYVPYGQ.mjs} +7 -0
- package/dist/react/{consolidate-WFTPBHDV.mjs → consolidate-3RQL75PJ.mjs} +1 -1
- package/dist/react/index.cjs +566 -419
- package/dist/react/index.d.mts +3 -0
- package/dist/react/index.d.ts +3 -0
- package/dist/react/index.mjs +418 -279
- package/dist/server/{chunk-QEROZ4VH.mjs → chunk-QK62YWBH.mjs} +7 -0
- package/dist/server/{consolidate-PYED62LW.mjs → consolidate-NW4UVA6T.mjs} +1 -1
- package/dist/server/index.cjs +67 -10
- package/dist/server/index.d.mts +3 -0
- package/dist/server/index.d.ts +3 -0
- package/dist/server/index.mjs +62 -12
- package/package.json +1 -1
|
@@ -109,6 +109,7 @@ function isWordChar(ch) {
|
|
|
109
109
|
}
|
|
110
110
|
var PiiRedactor = class {
|
|
111
111
|
constructor(options = {}) {
|
|
112
|
+
this.disposed = false;
|
|
112
113
|
/** Maps original PII value → placeholder tag. */
|
|
113
114
|
this.valueToPlaceholder = /* @__PURE__ */ new Map();
|
|
114
115
|
/** Maps placeholder tag → original PII value (reverse lookup for de-anonymization). */
|
|
@@ -183,6 +184,7 @@ var PiiRedactor = class {
|
|
|
183
184
|
* The same value always gets the same placeholder within a redactor instance.
|
|
184
185
|
*/
|
|
185
186
|
getPlaceholder(category, value) {
|
|
187
|
+
if (this.disposed) throw new Error("PII redactor session ended");
|
|
186
188
|
const normalizedValue = value.trim();
|
|
187
189
|
const existing = this.valueToPlaceholder.get(normalizedValue);
|
|
188
190
|
if (existing) return existing;
|
|
@@ -558,6 +560,11 @@ var PiiRedactor = class {
|
|
|
558
560
|
this.warnedNonText = false;
|
|
559
561
|
this.warnedNerFailure = false;
|
|
560
562
|
}
|
|
563
|
+
/** Clear the mappings and prevent new reversible mappings. */
|
|
564
|
+
dispose() {
|
|
565
|
+
this.disposed = true;
|
|
566
|
+
this.clear();
|
|
567
|
+
}
|
|
561
568
|
};
|
|
562
569
|
function isPiiRedactor(value) {
|
|
563
570
|
return typeof value === "object" && value !== null && typeof value.redactMessages === "function" && typeof value.deAnonymize === "function";
|
package/dist/server/index.cjs
CHANGED
|
@@ -15036,6 +15036,7 @@ var init_redactor = __esm({
|
|
|
15036
15036
|
init_patterns();
|
|
15037
15037
|
PiiRedactor = class {
|
|
15038
15038
|
constructor(options = {}) {
|
|
15039
|
+
this.disposed = false;
|
|
15039
15040
|
/** Maps original PII value → placeholder tag. */
|
|
15040
15041
|
this.valueToPlaceholder = /* @__PURE__ */ new Map();
|
|
15041
15042
|
/** Maps placeholder tag → original PII value (reverse lookup for de-anonymization). */
|
|
@@ -15110,6 +15111,7 @@ var init_redactor = __esm({
|
|
|
15110
15111
|
* The same value always gets the same placeholder within a redactor instance.
|
|
15111
15112
|
*/
|
|
15112
15113
|
getPlaceholder(category, value) {
|
|
15114
|
+
if (this.disposed) throw new Error("PII redactor session ended");
|
|
15113
15115
|
const normalizedValue = value.trim();
|
|
15114
15116
|
const existing = this.valueToPlaceholder.get(normalizedValue);
|
|
15115
15117
|
if (existing) return existing;
|
|
@@ -15485,6 +15487,11 @@ var init_redactor = __esm({
|
|
|
15485
15487
|
this.warnedNonText = false;
|
|
15486
15488
|
this.warnedNerFailure = false;
|
|
15487
15489
|
}
|
|
15490
|
+
/** Clear the mappings and prevent new reversible mappings. */
|
|
15491
|
+
dispose() {
|
|
15492
|
+
this.disposed = true;
|
|
15493
|
+
this.clear();
|
|
15494
|
+
}
|
|
15488
15495
|
};
|
|
15489
15496
|
}
|
|
15490
15497
|
});
|
|
@@ -23867,6 +23874,9 @@ var StreamSmoother = class {
|
|
|
23867
23874
|
this.rampDuration = config.rampDuration ?? 4e3;
|
|
23868
23875
|
}
|
|
23869
23876
|
}
|
|
23877
|
+
get hasPendingOutput() {
|
|
23878
|
+
return this.buffer.length > 0;
|
|
23879
|
+
}
|
|
23870
23880
|
/**
|
|
23871
23881
|
* Add text to the buffer. If smoothing is disabled, passes through immediately.
|
|
23872
23882
|
*/
|
|
@@ -24535,6 +24545,34 @@ async function runToolLoop(options) {
|
|
|
24535
24545
|
toolsChecksum: acc.toolsChecksum
|
|
24536
24546
|
};
|
|
24537
24547
|
};
|
|
24548
|
+
const drainSmoothers = async (acc, smoothers) => {
|
|
24549
|
+
let playbackAborted = false;
|
|
24550
|
+
const stopPlayback = () => {
|
|
24551
|
+
for (const smoother of smoothers) {
|
|
24552
|
+
if (isDetach()) smoother.flush();
|
|
24553
|
+
else smoother.destroy();
|
|
24554
|
+
}
|
|
24555
|
+
};
|
|
24556
|
+
const onAbort = () => {
|
|
24557
|
+
playbackAborted = !isDetach() && smoothers.some((smoother) => smoother.hasPendingOutput);
|
|
24558
|
+
stopPlayback();
|
|
24559
|
+
};
|
|
24560
|
+
combinedSignal?.addEventListener("abort", onAbort, { once: true });
|
|
24561
|
+
try {
|
|
24562
|
+
if (combinedSignal?.aborted) stopPlayback();
|
|
24563
|
+
await Promise.all(smoothers.map((smoother) => smoother.drain()));
|
|
24564
|
+
if (!playbackAborted) return;
|
|
24565
|
+
await fireAfterModelCall(buildModelCallEndPayload(acc, { error: "aborted" }));
|
|
24566
|
+
await fireRunError({ error: "Request aborted", stage: "model" });
|
|
24567
|
+
return {
|
|
24568
|
+
data: buildResponseFinal(acc),
|
|
24569
|
+
error: "Request aborted",
|
|
24570
|
+
toolsChecksum: acc.toolsChecksum
|
|
24571
|
+
};
|
|
24572
|
+
} finally {
|
|
24573
|
+
combinedSignal?.removeEventListener("abort", onAbort);
|
|
24574
|
+
}
|
|
24575
|
+
};
|
|
24538
24576
|
for (let attempt = 0; attempt < STREAM_RETRY_MAX_ATTEMPTS; attempt++) {
|
|
24539
24577
|
sseError = null;
|
|
24540
24578
|
if (combinedSignal?.aborted) {
|
|
@@ -24672,7 +24710,8 @@ async function runToolLoop(options) {
|
|
|
24672
24710
|
contentSmoother.flush();
|
|
24673
24711
|
thinkingSmoother.flush();
|
|
24674
24712
|
} else {
|
|
24675
|
-
await
|
|
24713
|
+
const interrupted = await drainSmoothers(accumulator, [contentSmoother, thinkingSmoother]);
|
|
24714
|
+
if (interrupted) return interrupted;
|
|
24676
24715
|
}
|
|
24677
24716
|
flushDeAnon();
|
|
24678
24717
|
await fireAfterModelCall(buildModelCallEndPayload(accumulator));
|
|
@@ -25191,7 +25230,11 @@ Executing tool: ${toolInfo}
|
|
|
25191
25230
|
contContentSmoother.flush();
|
|
25192
25231
|
contThinkingSmoother.flush();
|
|
25193
25232
|
} else {
|
|
25194
|
-
await
|
|
25233
|
+
const interrupted = await drainSmoothers(currentAccumulator, [
|
|
25234
|
+
contContentSmoother,
|
|
25235
|
+
contThinkingSmoother
|
|
25236
|
+
]);
|
|
25237
|
+
if (interrupted) return interrupted;
|
|
25195
25238
|
}
|
|
25196
25239
|
flushDeAnon();
|
|
25197
25240
|
await fireAfterModelCall(buildModelCallEndPayload(currentAccumulator));
|
|
@@ -25322,6 +25365,8 @@ async function resumeStream(options) {
|
|
|
25322
25365
|
let watchdog;
|
|
25323
25366
|
let idleFired = false;
|
|
25324
25367
|
let callerAborted = false;
|
|
25368
|
+
let playbackAborted = false;
|
|
25369
|
+
let draining = false;
|
|
25325
25370
|
let settled = false;
|
|
25326
25371
|
const idleEnabled = idleTimeoutMs > 0 && idleTimeoutMs !== Infinity && typeof setTimeout === "function";
|
|
25327
25372
|
const armWatchdog = () => {
|
|
@@ -25341,6 +25386,9 @@ async function resumeStream(options) {
|
|
|
25341
25386
|
const abortMessage = () => callerAborted ? "Resume aborted" : idleFired ? "Resume timed out" : "Resume aborted";
|
|
25342
25387
|
const onCallerAbort = () => {
|
|
25343
25388
|
callerAborted = true;
|
|
25389
|
+
playbackAborted = draining && (contentSmoother.hasPendingOutput || thinkingSmoother.hasPendingOutput);
|
|
25390
|
+
contentSmoother.destroy();
|
|
25391
|
+
thinkingSmoother.destroy();
|
|
25344
25392
|
disarmWatchdog();
|
|
25345
25393
|
idleController.abort();
|
|
25346
25394
|
};
|
|
@@ -25424,15 +25472,24 @@ async function resumeStream(options) {
|
|
|
25424
25472
|
statusCode
|
|
25425
25473
|
};
|
|
25426
25474
|
}
|
|
25427
|
-
|
|
25428
|
-
|
|
25429
|
-
|
|
25475
|
+
settled = true;
|
|
25476
|
+
disarmWatchdog();
|
|
25477
|
+
try {
|
|
25478
|
+
if (idleFired) return buildInterrupted(abortMessage());
|
|
25479
|
+
if (accumulator.toolCalls.size > 0) {
|
|
25480
|
+
return buildInterrupted("Stream ended with a pending tool request");
|
|
25481
|
+
}
|
|
25482
|
+
draining = true;
|
|
25483
|
+
await Promise.all([contentSmoother.drain(), thinkingSmoother.drain()]);
|
|
25484
|
+
if (playbackAborted) return buildInterrupted(abortMessage());
|
|
25485
|
+
const response = strategy.buildFinalResponse(accumulator);
|
|
25486
|
+
const deliveredOutput = emittedOutput || (accumulator.toolCallEvents?.length ?? 0) > 0;
|
|
25487
|
+
if (onFinish && deliveredOutput) onFinish(response);
|
|
25488
|
+
return { data: response, error: null, interrupted: false, empty: !deliveredOutput };
|
|
25489
|
+
} finally {
|
|
25490
|
+
draining = false;
|
|
25491
|
+
cleanup();
|
|
25430
25492
|
}
|
|
25431
|
-
await Promise.all([contentSmoother.drain(), thinkingSmoother.drain()]);
|
|
25432
|
-
const response = strategy.buildFinalResponse(accumulator);
|
|
25433
|
-
const deliveredOutput = emittedOutput || (accumulator.toolCallEvents?.length ?? 0) > 0;
|
|
25434
|
-
if (onFinish && deliveredOutput) onFinish(response);
|
|
25435
|
-
return { data: response, error: null, interrupted: false, empty: !deliveredOutput };
|
|
25436
25493
|
}
|
|
25437
25494
|
|
|
25438
25495
|
// src/lib/chat/stockPriceCentroids.ts
|
package/dist/server/index.d.mts
CHANGED
|
@@ -1476,6 +1476,7 @@ interface MessageRedactionResult {
|
|
|
1476
1476
|
* same email address throughout the conversation.
|
|
1477
1477
|
*/
|
|
1478
1478
|
declare class PiiRedactor {
|
|
1479
|
+
private disposed;
|
|
1479
1480
|
/** Maps original PII value → placeholder tag. */
|
|
1480
1481
|
private valueToPlaceholder;
|
|
1481
1482
|
/** Maps placeholder tag → original PII value (reverse lookup for de-anonymization). */
|
|
@@ -1675,6 +1676,8 @@ declare class PiiRedactor {
|
|
|
1675
1676
|
* Reset all state. Useful for testing or when starting a fresh conversation.
|
|
1676
1677
|
*/
|
|
1677
1678
|
clear(): void;
|
|
1679
|
+
/** Clear the mappings and prevent new reversible mappings. */
|
|
1680
|
+
dispose(): void;
|
|
1678
1681
|
}
|
|
1679
1682
|
|
|
1680
1683
|
type LlmTokenUsage = {
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1476,6 +1476,7 @@ interface MessageRedactionResult {
|
|
|
1476
1476
|
* same email address throughout the conversation.
|
|
1477
1477
|
*/
|
|
1478
1478
|
declare class PiiRedactor {
|
|
1479
|
+
private disposed;
|
|
1479
1480
|
/** Maps original PII value → placeholder tag. */
|
|
1480
1481
|
private valueToPlaceholder;
|
|
1481
1482
|
/** Maps placeholder tag → original PII value (reverse lookup for de-anonymization). */
|
|
@@ -1675,6 +1676,8 @@ declare class PiiRedactor {
|
|
|
1675
1676
|
* Reset all state. Useful for testing or when starting a fresh conversation.
|
|
1676
1677
|
*/
|
|
1677
1678
|
clear(): void;
|
|
1679
|
+
/** Clear the mappings and prevent new reversible mappings. */
|
|
1680
|
+
dispose(): void;
|
|
1678
1681
|
}
|
|
1679
1682
|
|
|
1680
1683
|
type LlmTokenUsage = {
|
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-QK62YWBH.mjs";
|
|
17
17
|
import {
|
|
18
18
|
BASE_URL,
|
|
19
19
|
__commonJS,
|
|
@@ -22143,6 +22143,9 @@ var StreamSmoother = class {
|
|
|
22143
22143
|
this.rampDuration = config.rampDuration ?? 4e3;
|
|
22144
22144
|
}
|
|
22145
22145
|
}
|
|
22146
|
+
get hasPendingOutput() {
|
|
22147
|
+
return this.buffer.length > 0;
|
|
22148
|
+
}
|
|
22146
22149
|
/**
|
|
22147
22150
|
* Add text to the buffer. If smoothing is disabled, passes through immediately.
|
|
22148
22151
|
*/
|
|
@@ -22811,6 +22814,34 @@ async function runToolLoop(options) {
|
|
|
22811
22814
|
toolsChecksum: acc.toolsChecksum
|
|
22812
22815
|
};
|
|
22813
22816
|
};
|
|
22817
|
+
const drainSmoothers = async (acc, smoothers) => {
|
|
22818
|
+
let playbackAborted = false;
|
|
22819
|
+
const stopPlayback = () => {
|
|
22820
|
+
for (const smoother of smoothers) {
|
|
22821
|
+
if (isDetach()) smoother.flush();
|
|
22822
|
+
else smoother.destroy();
|
|
22823
|
+
}
|
|
22824
|
+
};
|
|
22825
|
+
const onAbort = () => {
|
|
22826
|
+
playbackAborted = !isDetach() && smoothers.some((smoother) => smoother.hasPendingOutput);
|
|
22827
|
+
stopPlayback();
|
|
22828
|
+
};
|
|
22829
|
+
combinedSignal?.addEventListener("abort", onAbort, { once: true });
|
|
22830
|
+
try {
|
|
22831
|
+
if (combinedSignal?.aborted) stopPlayback();
|
|
22832
|
+
await Promise.all(smoothers.map((smoother) => smoother.drain()));
|
|
22833
|
+
if (!playbackAborted) return;
|
|
22834
|
+
await fireAfterModelCall(buildModelCallEndPayload(acc, { error: "aborted" }));
|
|
22835
|
+
await fireRunError({ error: "Request aborted", stage: "model" });
|
|
22836
|
+
return {
|
|
22837
|
+
data: buildResponseFinal(acc),
|
|
22838
|
+
error: "Request aborted",
|
|
22839
|
+
toolsChecksum: acc.toolsChecksum
|
|
22840
|
+
};
|
|
22841
|
+
} finally {
|
|
22842
|
+
combinedSignal?.removeEventListener("abort", onAbort);
|
|
22843
|
+
}
|
|
22844
|
+
};
|
|
22814
22845
|
for (let attempt = 0; attempt < STREAM_RETRY_MAX_ATTEMPTS; attempt++) {
|
|
22815
22846
|
sseError = null;
|
|
22816
22847
|
if (combinedSignal?.aborted) {
|
|
@@ -22948,7 +22979,8 @@ async function runToolLoop(options) {
|
|
|
22948
22979
|
contentSmoother.flush();
|
|
22949
22980
|
thinkingSmoother.flush();
|
|
22950
22981
|
} else {
|
|
22951
|
-
await
|
|
22982
|
+
const interrupted = await drainSmoothers(accumulator, [contentSmoother, thinkingSmoother]);
|
|
22983
|
+
if (interrupted) return interrupted;
|
|
22952
22984
|
}
|
|
22953
22985
|
flushDeAnon();
|
|
22954
22986
|
await fireAfterModelCall(buildModelCallEndPayload(accumulator));
|
|
@@ -23467,7 +23499,11 @@ Executing tool: ${toolInfo}
|
|
|
23467
23499
|
contContentSmoother.flush();
|
|
23468
23500
|
contThinkingSmoother.flush();
|
|
23469
23501
|
} else {
|
|
23470
|
-
await
|
|
23502
|
+
const interrupted = await drainSmoothers(currentAccumulator, [
|
|
23503
|
+
contContentSmoother,
|
|
23504
|
+
contThinkingSmoother
|
|
23505
|
+
]);
|
|
23506
|
+
if (interrupted) return interrupted;
|
|
23471
23507
|
}
|
|
23472
23508
|
flushDeAnon();
|
|
23473
23509
|
await fireAfterModelCall(buildModelCallEndPayload(currentAccumulator));
|
|
@@ -23598,6 +23634,8 @@ async function resumeStream(options) {
|
|
|
23598
23634
|
let watchdog;
|
|
23599
23635
|
let idleFired = false;
|
|
23600
23636
|
let callerAborted = false;
|
|
23637
|
+
let playbackAborted = false;
|
|
23638
|
+
let draining = false;
|
|
23601
23639
|
let settled = false;
|
|
23602
23640
|
const idleEnabled = idleTimeoutMs > 0 && idleTimeoutMs !== Infinity && typeof setTimeout === "function";
|
|
23603
23641
|
const armWatchdog = () => {
|
|
@@ -23617,6 +23655,9 @@ async function resumeStream(options) {
|
|
|
23617
23655
|
const abortMessage = () => callerAborted ? "Resume aborted" : idleFired ? "Resume timed out" : "Resume aborted";
|
|
23618
23656
|
const onCallerAbort = () => {
|
|
23619
23657
|
callerAborted = true;
|
|
23658
|
+
playbackAborted = draining && (contentSmoother.hasPendingOutput || thinkingSmoother.hasPendingOutput);
|
|
23659
|
+
contentSmoother.destroy();
|
|
23660
|
+
thinkingSmoother.destroy();
|
|
23620
23661
|
disarmWatchdog();
|
|
23621
23662
|
idleController.abort();
|
|
23622
23663
|
};
|
|
@@ -23700,15 +23741,24 @@ async function resumeStream(options) {
|
|
|
23700
23741
|
statusCode
|
|
23701
23742
|
};
|
|
23702
23743
|
}
|
|
23703
|
-
|
|
23704
|
-
|
|
23705
|
-
|
|
23744
|
+
settled = true;
|
|
23745
|
+
disarmWatchdog();
|
|
23746
|
+
try {
|
|
23747
|
+
if (idleFired) return buildInterrupted(abortMessage());
|
|
23748
|
+
if (accumulator.toolCalls.size > 0) {
|
|
23749
|
+
return buildInterrupted("Stream ended with a pending tool request");
|
|
23750
|
+
}
|
|
23751
|
+
draining = true;
|
|
23752
|
+
await Promise.all([contentSmoother.drain(), thinkingSmoother.drain()]);
|
|
23753
|
+
if (playbackAborted) return buildInterrupted(abortMessage());
|
|
23754
|
+
const response = strategy.buildFinalResponse(accumulator);
|
|
23755
|
+
const deliveredOutput = emittedOutput || (accumulator.toolCallEvents?.length ?? 0) > 0;
|
|
23756
|
+
if (onFinish && deliveredOutput) onFinish(response);
|
|
23757
|
+
return { data: response, error: null, interrupted: false, empty: !deliveredOutput };
|
|
23758
|
+
} finally {
|
|
23759
|
+
draining = false;
|
|
23760
|
+
cleanup();
|
|
23706
23761
|
}
|
|
23707
|
-
await Promise.all([contentSmoother.drain(), thinkingSmoother.drain()]);
|
|
23708
|
-
const response = strategy.buildFinalResponse(accumulator);
|
|
23709
|
-
const deliveredOutput = emittedOutput || (accumulator.toolCallEvents?.length ?? 0) > 0;
|
|
23710
|
-
if (onFinish && deliveredOutput) onFinish(response);
|
|
23711
|
-
return { data: response, error: null, interrupted: false, empty: !deliveredOutput };
|
|
23712
23762
|
}
|
|
23713
23763
|
|
|
23714
23764
|
// src/lib/chat/stockPriceCentroids.ts
|
|
@@ -31740,7 +31790,7 @@ async function tryConsolidate(trimmed, ctx, options, prepared) {
|
|
|
31740
31790
|
content: m.content,
|
|
31741
31791
|
similarity: m.similarity
|
|
31742
31792
|
}));
|
|
31743
|
-
const { consolidateMemory: doConsolidate } = await import("./consolidate-
|
|
31793
|
+
const { consolidateMemory: doConsolidate } = await import("./consolidate-NW4UVA6T.mjs");
|
|
31744
31794
|
const decision = await doConsolidate(trimmed, candidates, consolidateOptions);
|
|
31745
31795
|
if (decision.action === "create") return decision.fallbackReason ? null : { create: true };
|
|
31746
31796
|
if (decision.action === "supersede" && decision.content) {
|