@anuma/sdk 3.6.1 → 3.6.3
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-7TATXBC5.mjs → chunk-FKACNV6X.mjs} +809 -3
- package/dist/expo/index.cjs +909 -823
- package/dist/expo/index.mjs +7 -798
- package/dist/expo/{recall-IO4KJ5W7.mjs → recall-VZHV7ILE.mjs} +1 -1
- package/dist/react/{chunk-DDHTJGZN.mjs → chunk-ZGMHRWOR.mjs} +895 -3
- package/dist/react/index.cjs +1999 -1905
- package/dist/react/index.mjs +22 -869
- package/dist/react/{recall-OPKHWKZX.mjs → recall-JOLS3V4B.mjs} +1 -1
- package/dist/server/{chunk-V7SVKIXQ.mjs → chunk-66UWDXS3.mjs} +794 -3
- package/dist/server/index.cjs +886 -144
- package/dist/server/index.mjs +2 -128
- package/dist/server/{recall-IWY2MYHR.mjs → recall-UTVH2XPK.mjs} +1 -1
- package/dist/tools/selection/index.cjs +793 -3
- package/dist/tools/selection/index.mjs +791 -3
- package/package.json +3 -3
package/dist/server/index.mjs
CHANGED
|
@@ -33,6 +33,7 @@ import {
|
|
|
33
33
|
createLlmNeighborRefiner,
|
|
34
34
|
createMemoryVaultSearchTool,
|
|
35
35
|
createMessageOp,
|
|
36
|
+
createSseClient,
|
|
36
37
|
createSupersedingMemoryOp,
|
|
37
38
|
createVaultEmbeddingCache,
|
|
38
39
|
createVaultMemoriesBatchOp,
|
|
@@ -124,7 +125,7 @@ import {
|
|
|
124
125
|
updateVaultMemoryOp,
|
|
125
126
|
upsertMessageOp,
|
|
126
127
|
vaultMemoryToStored
|
|
127
|
-
} from "./chunk-
|
|
128
|
+
} from "./chunk-66UWDXS3.mjs";
|
|
128
129
|
import {
|
|
129
130
|
createStreamingDeAnonymizer,
|
|
130
131
|
resolvePiiRedactor
|
|
@@ -9177,133 +9178,6 @@ function createCryptoPricePreProcessor(options = {}) {
|
|
|
9177
9178
|
};
|
|
9178
9179
|
}
|
|
9179
9180
|
|
|
9180
|
-
// src/client/core/serverSentEvents.gen.ts
|
|
9181
|
-
function createSseClient({
|
|
9182
|
-
onRequest,
|
|
9183
|
-
onSseError,
|
|
9184
|
-
onSseEvent,
|
|
9185
|
-
responseTransformer,
|
|
9186
|
-
responseValidator,
|
|
9187
|
-
sseDefaultRetryDelay,
|
|
9188
|
-
sseMaxRetryAttempts,
|
|
9189
|
-
sseMaxRetryDelay,
|
|
9190
|
-
sseSleepFn,
|
|
9191
|
-
url,
|
|
9192
|
-
...options
|
|
9193
|
-
}) {
|
|
9194
|
-
let lastEventId;
|
|
9195
|
-
const sleep3 = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
9196
|
-
const createStream = async function* () {
|
|
9197
|
-
let retryDelay = sseDefaultRetryDelay ?? 3e3;
|
|
9198
|
-
let attempt = 0;
|
|
9199
|
-
const signal = options.signal ?? new AbortController().signal;
|
|
9200
|
-
while (true) {
|
|
9201
|
-
if (signal.aborted) break;
|
|
9202
|
-
attempt++;
|
|
9203
|
-
const headers = options.headers instanceof Headers ? options.headers : new Headers(options.headers);
|
|
9204
|
-
if (lastEventId !== void 0) {
|
|
9205
|
-
headers.set("Last-Event-ID", lastEventId);
|
|
9206
|
-
}
|
|
9207
|
-
try {
|
|
9208
|
-
const requestInit = {
|
|
9209
|
-
redirect: "follow",
|
|
9210
|
-
...options,
|
|
9211
|
-
body: options.serializedBody,
|
|
9212
|
-
headers,
|
|
9213
|
-
signal
|
|
9214
|
-
};
|
|
9215
|
-
let request = new Request(url, requestInit);
|
|
9216
|
-
if (onRequest) {
|
|
9217
|
-
request = await onRequest(url, requestInit);
|
|
9218
|
-
}
|
|
9219
|
-
const _fetch = options.fetch ?? globalThis.fetch;
|
|
9220
|
-
const response = await _fetch(request);
|
|
9221
|
-
if (!response.ok) throw new Error(`SSE failed: ${response.status} ${response.statusText}`);
|
|
9222
|
-
if (!response.body) throw new Error("No body in SSE response");
|
|
9223
|
-
const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
|
|
9224
|
-
let buffer = "";
|
|
9225
|
-
const abortHandler = () => {
|
|
9226
|
-
try {
|
|
9227
|
-
reader.cancel();
|
|
9228
|
-
} catch {
|
|
9229
|
-
}
|
|
9230
|
-
};
|
|
9231
|
-
signal.addEventListener("abort", abortHandler);
|
|
9232
|
-
try {
|
|
9233
|
-
while (true) {
|
|
9234
|
-
const { done, value } = await reader.read();
|
|
9235
|
-
if (done) break;
|
|
9236
|
-
buffer += value;
|
|
9237
|
-
buffer = buffer.replace(/\r\n?/g, "\n");
|
|
9238
|
-
const chunks = buffer.split("\n\n");
|
|
9239
|
-
buffer = chunks.pop() ?? "";
|
|
9240
|
-
for (const chunk of chunks) {
|
|
9241
|
-
const lines = chunk.split("\n");
|
|
9242
|
-
const dataLines = [];
|
|
9243
|
-
let eventName;
|
|
9244
|
-
for (const line of lines) {
|
|
9245
|
-
if (line.startsWith("data:")) {
|
|
9246
|
-
dataLines.push(line.replace(/^data:\s*/, ""));
|
|
9247
|
-
} else if (line.startsWith("event:")) {
|
|
9248
|
-
eventName = line.replace(/^event:\s*/, "");
|
|
9249
|
-
} else if (line.startsWith("id:")) {
|
|
9250
|
-
lastEventId = line.replace(/^id:\s*/, "");
|
|
9251
|
-
} else if (line.startsWith("retry:")) {
|
|
9252
|
-
const parsed = Number.parseInt(line.replace(/^retry:\s*/, ""), 10);
|
|
9253
|
-
if (!Number.isNaN(parsed)) {
|
|
9254
|
-
retryDelay = parsed;
|
|
9255
|
-
}
|
|
9256
|
-
}
|
|
9257
|
-
}
|
|
9258
|
-
let data;
|
|
9259
|
-
let parsedJson = false;
|
|
9260
|
-
if (dataLines.length) {
|
|
9261
|
-
const rawData = dataLines.join("\n");
|
|
9262
|
-
try {
|
|
9263
|
-
data = JSON.parse(rawData);
|
|
9264
|
-
parsedJson = true;
|
|
9265
|
-
} catch {
|
|
9266
|
-
data = rawData;
|
|
9267
|
-
}
|
|
9268
|
-
}
|
|
9269
|
-
if (parsedJson) {
|
|
9270
|
-
if (responseValidator) {
|
|
9271
|
-
await responseValidator(data);
|
|
9272
|
-
}
|
|
9273
|
-
if (responseTransformer) {
|
|
9274
|
-
data = await responseTransformer(data);
|
|
9275
|
-
}
|
|
9276
|
-
}
|
|
9277
|
-
onSseEvent?.({
|
|
9278
|
-
data,
|
|
9279
|
-
event: eventName,
|
|
9280
|
-
id: lastEventId,
|
|
9281
|
-
retry: retryDelay
|
|
9282
|
-
});
|
|
9283
|
-
if (dataLines.length) {
|
|
9284
|
-
yield data;
|
|
9285
|
-
}
|
|
9286
|
-
}
|
|
9287
|
-
}
|
|
9288
|
-
} finally {
|
|
9289
|
-
signal.removeEventListener("abort", abortHandler);
|
|
9290
|
-
reader.releaseLock();
|
|
9291
|
-
}
|
|
9292
|
-
break;
|
|
9293
|
-
} catch (error) {
|
|
9294
|
-
onSseError?.(error);
|
|
9295
|
-
if (sseMaxRetryAttempts !== void 0 && attempt >= sseMaxRetryAttempts) {
|
|
9296
|
-
break;
|
|
9297
|
-
}
|
|
9298
|
-
const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 3e4);
|
|
9299
|
-
await sleep3(backoff);
|
|
9300
|
-
}
|
|
9301
|
-
}
|
|
9302
|
-
};
|
|
9303
|
-
const stream = createStream();
|
|
9304
|
-
return { stream };
|
|
9305
|
-
}
|
|
9306
|
-
|
|
9307
9181
|
// src/lib/chat/runHooks.ts
|
|
9308
9182
|
function composeHooks(hooks) {
|
|
9309
9183
|
const handlers = hooks.filter((h) => h !== void 0 && h !== null);
|