@anuma/sdk 2.7.0 → 3.1.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-TCRDSUC6.mjs → chunk-22CSPJLL.mjs} +164 -891
- package/dist/expo/index.cjs +1812 -1112
- package/dist/expo/index.d.mts +226 -12
- package/dist/expo/index.d.ts +226 -12
- package/dist/expo/index.mjs +1558 -68
- package/dist/expo/{recall-FQU3NUTL.mjs → recall-LICO3TJ7.mjs} +1 -1
- package/dist/index.cjs +418 -395
- package/dist/index.mjs +415 -392
- package/dist/react/{chunk-ZXS3KOY4.mjs → chunk-FD5MB73N.mjs} +158 -1030
- package/dist/react/index.cjs +1839 -1742
- package/dist/react/index.d.mts +150 -14
- package/dist/react/index.d.ts +150 -14
- package/dist/react/index.mjs +1235 -229
- package/dist/react/{recall-PV7L3SN3.mjs → recall-FPACUZGD.mjs} +1 -1
- package/dist/server/{chunk-Z6II54I7.mjs → chunk-RKUNGNBF.mjs} +163 -842
- package/dist/server/index.cjs +392 -970
- package/dist/server/index.d.mts +170 -14
- package/dist/server/index.d.ts +170 -14
- package/dist/server/index.mjs +198 -27
- package/dist/server/{recall-CQT24XLH.mjs → recall-WT5HY2IA.mjs} +1 -1
- package/dist/tools/selection/chunk-4ETHWSXJ.mjs +25 -0
- package/dist/tools/selection/clientConfig-WITO4T6L.mjs +12 -0
- package/dist/tools/selection/index.cjs +1977 -0
- package/dist/tools/selection/index.d.mts +1380 -0
- package/dist/tools/selection/index.d.ts +1380 -0
- package/dist/tools/selection/index.mjs +1859 -0
- package/package.json +8 -1
|
@@ -5,8 +5,7 @@ import {
|
|
|
5
5
|
import {
|
|
6
6
|
BASE_URL,
|
|
7
7
|
__commonJS,
|
|
8
|
-
__toESM
|
|
9
|
-
createClientConfig
|
|
8
|
+
__toESM
|
|
10
9
|
} from "./chunk-3RPGXXPZ.mjs";
|
|
11
10
|
|
|
12
11
|
// node_modules/.pnpm/@babel+runtime@7.26.0/node_modules/@babel/runtime/helpers/interopRequireDefault.js
|
|
@@ -14553,6 +14552,15 @@ async function encryptData(plaintext, address) {
|
|
|
14553
14552
|
const key = await getEncryptionKey(address);
|
|
14554
14553
|
return encryptDataWithKey(plaintext, key);
|
|
14555
14554
|
}
|
|
14555
|
+
async function encryptDataBytes(plaintext, address) {
|
|
14556
|
+
if (!isValidWalletAddress(address)) {
|
|
14557
|
+
throw new Error(
|
|
14558
|
+
`Invalid wallet address: ${address}. Address must start with 0x and be 42 characters (0x + 40 hex characters).`
|
|
14559
|
+
);
|
|
14560
|
+
}
|
|
14561
|
+
const key = await getEncryptionKey(address);
|
|
14562
|
+
return encryptBytesWithKey(plaintext, key);
|
|
14563
|
+
}
|
|
14556
14564
|
async function decryptData(encryptedHex, address, version = "v3") {
|
|
14557
14565
|
const key = await getEncryptionKey(address, version);
|
|
14558
14566
|
return decryptDataWithKey(encryptedHex, key);
|
|
@@ -14572,6 +14580,20 @@ async function decryptDataBytes(encryptedHex, address, version = "v3") {
|
|
|
14572
14580
|
);
|
|
14573
14581
|
return new Uint8Array(decryptedData);
|
|
14574
14582
|
}
|
|
14583
|
+
async function decryptDataBytesFromBytes(encrypted, address, version = "v3") {
|
|
14584
|
+
const key = await getEncryptionKey(address, version);
|
|
14585
|
+
const iv = encrypted.subarray(0, 12);
|
|
14586
|
+
const encryptedData = encrypted.subarray(12);
|
|
14587
|
+
const decryptedData = await crypto.subtle.decrypt(
|
|
14588
|
+
{
|
|
14589
|
+
name: "AES-GCM",
|
|
14590
|
+
iv
|
|
14591
|
+
},
|
|
14592
|
+
key,
|
|
14593
|
+
encryptedData
|
|
14594
|
+
);
|
|
14595
|
+
return new Uint8Array(decryptedData);
|
|
14596
|
+
}
|
|
14575
14597
|
function hasEncryptionKey(address) {
|
|
14576
14598
|
return getStoredKey(address) !== null;
|
|
14577
14599
|
}
|
|
@@ -15209,6 +15231,67 @@ async function messageToStored(message, walletAddress, signMessage, embeddedWall
|
|
|
15209
15231
|
}
|
|
15210
15232
|
return baseMessage;
|
|
15211
15233
|
}
|
|
15234
|
+
function rawDate(value) {
|
|
15235
|
+
return new Date(typeof value === "number" ? value : 0);
|
|
15236
|
+
}
|
|
15237
|
+
function messageRawToStoredRaw(raw, projection) {
|
|
15238
|
+
const parseJsonField = (rawValue) => {
|
|
15239
|
+
if (!rawValue) return void 0;
|
|
15240
|
+
if (typeof rawValue === "string") {
|
|
15241
|
+
if (rawValue.startsWith("enc:")) return rawValue;
|
|
15242
|
+
try {
|
|
15243
|
+
return JSON.parse(rawValue);
|
|
15244
|
+
} catch {
|
|
15245
|
+
return void 0;
|
|
15246
|
+
}
|
|
15247
|
+
}
|
|
15248
|
+
return rawValue;
|
|
15249
|
+
};
|
|
15250
|
+
const skipEmbeddings = projection?.skipEmbeddings === true;
|
|
15251
|
+
const vectorRaw = skipEmbeddings ? null : raw.vector;
|
|
15252
|
+
const chunksRaw = skipEmbeddings ? null : raw.chunks;
|
|
15253
|
+
return {
|
|
15254
|
+
uniqueId: raw.id,
|
|
15255
|
+
messageId: raw.message_id,
|
|
15256
|
+
conversationId: raw.conversation_id ?? "",
|
|
15257
|
+
role: raw.role ?? "",
|
|
15258
|
+
content: raw.content ?? "",
|
|
15259
|
+
model: raw.model,
|
|
15260
|
+
imageModel: raw.image_model,
|
|
15261
|
+
files: parseJsonField(raw.files),
|
|
15262
|
+
fileIds: parseJsonField(raw.file_ids),
|
|
15263
|
+
createdAt: rawDate(raw.created_at),
|
|
15264
|
+
updatedAt: rawDate(raw.updated_at),
|
|
15265
|
+
vector: skipEmbeddings ? void 0 : parseJsonField(vectorRaw),
|
|
15266
|
+
embeddingModel: raw.embedding_model,
|
|
15267
|
+
chunks: skipEmbeddings ? void 0 : parseJsonField(chunksRaw),
|
|
15268
|
+
usage: parseJsonField(raw.usage),
|
|
15269
|
+
sources: parseJsonField(raw.sources),
|
|
15270
|
+
responseDuration: raw.response_duration,
|
|
15271
|
+
// `was_stopped` is an OPTIONAL boolean: an unset row sanitizes to null, and the Model path
|
|
15272
|
+
// (message.wasStopped) returns that null verbatim. Preserve it (don't collapse to false) so the
|
|
15273
|
+
// raw path is byte-identical. When set, coerce SQLite 0/1 and LokiJS true/false alike.
|
|
15274
|
+
wasStopped: raw.was_stopped === null || raw.was_stopped === void 0 ? raw.was_stopped : raw.was_stopped === true || raw.was_stopped === 1,
|
|
15275
|
+
error: raw.error,
|
|
15276
|
+
thoughtProcess: parseJsonField(raw.thought_process),
|
|
15277
|
+
thinking: raw.thinking,
|
|
15278
|
+
parentMessageId: raw.parent_message_id,
|
|
15279
|
+
feedback: raw.feedback || null,
|
|
15280
|
+
toolCallEvents: parseJsonField(raw.tool_call_events)
|
|
15281
|
+
};
|
|
15282
|
+
}
|
|
15283
|
+
async function messageRawToStored(raw, walletAddress, signMessage, embeddedWalletSigner, projection) {
|
|
15284
|
+
const baseMessage = messageRawToStoredRaw(raw, projection);
|
|
15285
|
+
if (walletAddress) {
|
|
15286
|
+
return await decryptMessageFields(
|
|
15287
|
+
baseMessage,
|
|
15288
|
+
walletAddress,
|
|
15289
|
+
signMessage,
|
|
15290
|
+
embeddedWalletSigner
|
|
15291
|
+
);
|
|
15292
|
+
}
|
|
15293
|
+
return baseMessage;
|
|
15294
|
+
}
|
|
15212
15295
|
function conversationToStoredRaw(conversation) {
|
|
15213
15296
|
return {
|
|
15214
15297
|
uniqueId: conversation.id,
|
|
@@ -15233,6 +15316,33 @@ async function conversationToStored(conversation, walletAddress, signMessage, em
|
|
|
15233
15316
|
}
|
|
15234
15317
|
return baseConversation;
|
|
15235
15318
|
}
|
|
15319
|
+
function conversationRawToStoredRaw(raw) {
|
|
15320
|
+
const pinnedAt = raw.pinned_at;
|
|
15321
|
+
return {
|
|
15322
|
+
uniqueId: raw.id,
|
|
15323
|
+
conversationId: raw.conversation_id ?? "",
|
|
15324
|
+
title: raw.title ?? "",
|
|
15325
|
+
projectId: raw.project_id,
|
|
15326
|
+
createdAt: rawDate(raw.created_at),
|
|
15327
|
+
updatedAt: rawDate(raw.updated_at),
|
|
15328
|
+
// SQLite stores booleans as 0/1, LokiJS as true/false — coerce both.
|
|
15329
|
+
isDeleted: raw.is_deleted === true || raw.is_deleted === 1,
|
|
15330
|
+
// @date maps a non-number raw column (incl. an explicit unpin null) to null; a number → Date.
|
|
15331
|
+
pinnedAt: typeof pinnedAt === "number" ? new Date(pinnedAt) : null
|
|
15332
|
+
};
|
|
15333
|
+
}
|
|
15334
|
+
async function conversationRawToStored(raw, walletAddress, signMessage, embeddedWalletSigner) {
|
|
15335
|
+
const baseConversation = conversationRawToStoredRaw(raw);
|
|
15336
|
+
if (walletAddress) {
|
|
15337
|
+
return await decryptConversationFields(
|
|
15338
|
+
baseConversation,
|
|
15339
|
+
walletAddress,
|
|
15340
|
+
signMessage,
|
|
15341
|
+
embeddedWalletSigner
|
|
15342
|
+
);
|
|
15343
|
+
}
|
|
15344
|
+
return baseConversation;
|
|
15345
|
+
}
|
|
15236
15346
|
async function createConversationOp(ctx, opts, defaultTitle = "New Conversation") {
|
|
15237
15347
|
const convId = opts?.conversationId || generateConversationId();
|
|
15238
15348
|
const title = opts?.title || defaultTitle;
|
|
@@ -15272,36 +15382,51 @@ async function getConversationOp(ctx, id) {
|
|
|
15272
15382
|
) : null;
|
|
15273
15383
|
}
|
|
15274
15384
|
async function getConversationsOp(ctx) {
|
|
15275
|
-
const results = await ctx.conversationsCollection.query(import_watermelondb.Q.where("is_deleted", false), import_watermelondb.Q.sortBy("created_at", import_watermelondb.Q.desc)).
|
|
15385
|
+
const results = await ctx.conversationsCollection.query(import_watermelondb.Q.where("is_deleted", false), import_watermelondb.Q.sortBy("created_at", import_watermelondb.Q.desc)).unsafeFetchRaw();
|
|
15276
15386
|
return Promise.all(
|
|
15277
15387
|
results.map(
|
|
15278
|
-
(
|
|
15388
|
+
(raw) => conversationRawToStored(raw, ctx.walletAddress, ctx.signMessage, ctx.embeddedWalletSigner)
|
|
15279
15389
|
)
|
|
15280
15390
|
);
|
|
15281
15391
|
}
|
|
15282
|
-
function
|
|
15392
|
+
function conversationRawToLazyStored(raw) {
|
|
15393
|
+
const pinnedAt = raw.pinned_at;
|
|
15283
15394
|
return {
|
|
15284
|
-
uniqueId:
|
|
15285
|
-
conversationId:
|
|
15286
|
-
encryptedTitle:
|
|
15287
|
-
projectId:
|
|
15288
|
-
createdAt:
|
|
15289
|
-
updatedAt:
|
|
15290
|
-
isDeleted:
|
|
15291
|
-
pinnedAt:
|
|
15395
|
+
uniqueId: raw.id,
|
|
15396
|
+
conversationId: raw.conversation_id ?? "",
|
|
15397
|
+
encryptedTitle: raw.title ?? "",
|
|
15398
|
+
projectId: raw.project_id,
|
|
15399
|
+
createdAt: rawDate(raw.created_at),
|
|
15400
|
+
updatedAt: rawDate(raw.updated_at),
|
|
15401
|
+
isDeleted: raw.is_deleted === true || raw.is_deleted === 1,
|
|
15402
|
+
pinnedAt: typeof pinnedAt === "number" ? new Date(pinnedAt) : null
|
|
15292
15403
|
};
|
|
15293
15404
|
}
|
|
15294
15405
|
async function getConversationsLazyOp(ctx) {
|
|
15295
|
-
const results = await ctx.conversationsCollection.query(import_watermelondb.Q.where("is_deleted", false), import_watermelondb.Q.sortBy("created_at", import_watermelondb.Q.desc)).
|
|
15296
|
-
return results.map(
|
|
15406
|
+
const results = await ctx.conversationsCollection.query(import_watermelondb.Q.where("is_deleted", false), import_watermelondb.Q.sortBy("created_at", import_watermelondb.Q.desc)).unsafeFetchRaw();
|
|
15407
|
+
return results.map(conversationRawToLazyStored);
|
|
15408
|
+
}
|
|
15409
|
+
async function getConversationsPageOp(ctx, options) {
|
|
15410
|
+
const limit = Math.floor(options?.limit ?? 200);
|
|
15411
|
+
if (!Number.isFinite(limit) || limit < 1) return [];
|
|
15412
|
+
const exclude = new Set(options?.boundaryExcludeUniqueIds ?? []);
|
|
15413
|
+
const clauses = [import_watermelondb.Q.where("is_deleted", false)];
|
|
15414
|
+
if (options?.before !== void 0) {
|
|
15415
|
+
clauses.push(
|
|
15416
|
+
exclude.size > 0 ? import_watermelondb.Q.where("created_at", import_watermelondb.Q.lte(options.before)) : import_watermelondb.Q.where("created_at", import_watermelondb.Q.lt(options.before))
|
|
15417
|
+
);
|
|
15418
|
+
}
|
|
15419
|
+
const fetched = await ctx.conversationsCollection.query(...clauses, import_watermelondb.Q.sortBy("created_at", import_watermelondb.Q.desc), import_watermelondb.Q.take(limit + exclude.size)).unsafeFetchRaw();
|
|
15420
|
+
const results = exclude.size > 0 ? fetched.filter((raw) => !exclude.has(raw.id)) : fetched;
|
|
15421
|
+
return results.slice(0, limit).map(conversationRawToLazyStored);
|
|
15297
15422
|
}
|
|
15298
15423
|
async function getConversationsByProjectLazyOp(ctx, projectId) {
|
|
15299
15424
|
const results = await ctx.conversationsCollection.query(
|
|
15300
15425
|
import_watermelondb.Q.where("project_id", projectId === null ? "" : projectId),
|
|
15301
15426
|
import_watermelondb.Q.where("is_deleted", false),
|
|
15302
15427
|
import_watermelondb.Q.sortBy("created_at", import_watermelondb.Q.desc)
|
|
15303
|
-
).
|
|
15304
|
-
return results.map(
|
|
15428
|
+
).unsafeFetchRaw();
|
|
15429
|
+
return results.map(conversationRawToLazyStored);
|
|
15305
15430
|
}
|
|
15306
15431
|
async function updateConversationTitleOp(ctx, id, title) {
|
|
15307
15432
|
const results = await ctx.conversationsCollection.query(import_watermelondb.Q.where("conversation_id", id), import_watermelondb.Q.where("is_deleted", false)).fetch();
|
|
@@ -15351,18 +15476,18 @@ async function getConversationsByProjectOp(ctx, projectId) {
|
|
|
15351
15476
|
import_watermelondb.Q.where("project_id", projectId === null ? "" : projectId),
|
|
15352
15477
|
import_watermelondb.Q.where("is_deleted", false),
|
|
15353
15478
|
import_watermelondb.Q.sortBy("created_at", import_watermelondb.Q.desc)
|
|
15354
|
-
).
|
|
15479
|
+
).unsafeFetchRaw();
|
|
15355
15480
|
return Promise.all(
|
|
15356
15481
|
results.map(
|
|
15357
|
-
(
|
|
15482
|
+
(raw) => conversationRawToStored(raw, ctx.walletAddress, ctx.signMessage, ctx.embeddedWalletSigner)
|
|
15358
15483
|
)
|
|
15359
15484
|
);
|
|
15360
15485
|
}
|
|
15361
15486
|
async function getMessagesOp(ctx, convId) {
|
|
15362
|
-
const results = await ctx.messagesCollection.query(import_watermelondb.Q.where("conversation_id", convId), import_watermelondb.Q.sortBy("message_id", import_watermelondb.Q.asc)).
|
|
15487
|
+
const results = await ctx.messagesCollection.query(import_watermelondb.Q.where("conversation_id", convId), import_watermelondb.Q.sortBy("message_id", import_watermelondb.Q.asc)).unsafeFetchRaw();
|
|
15363
15488
|
return Promise.all(
|
|
15364
15489
|
results.map(
|
|
15365
|
-
(
|
|
15490
|
+
(raw) => messageRawToStored(raw, ctx.walletAddress, ctx.signMessage, ctx.embeddedWalletSigner)
|
|
15366
15491
|
)
|
|
15367
15492
|
);
|
|
15368
15493
|
}
|
|
@@ -16649,817 +16774,6 @@ async function updateVaultMemoryEmbeddingOp(ctx, id, embedding, embeddingModel)
|
|
|
16649
16774
|
// src/lib/memoryEngine/constants.ts
|
|
16650
16775
|
var DEFAULT_API_EMBEDDING_MODEL = "qwen/qwen3-embedding-8b";
|
|
16651
16776
|
|
|
16652
|
-
// src/client/core/bodySerializer.gen.ts
|
|
16653
|
-
var jsonBodySerializer = {
|
|
16654
|
-
bodySerializer: (body) => JSON.stringify(
|
|
16655
|
-
body,
|
|
16656
|
-
(_key, value) => typeof value === "bigint" ? value.toString() : value
|
|
16657
|
-
)
|
|
16658
|
-
};
|
|
16659
|
-
|
|
16660
|
-
// src/client/core/serverSentEvents.gen.ts
|
|
16661
|
-
var createSseClient = ({
|
|
16662
|
-
onRequest,
|
|
16663
|
-
onSseError,
|
|
16664
|
-
onSseEvent,
|
|
16665
|
-
responseTransformer,
|
|
16666
|
-
responseValidator,
|
|
16667
|
-
sseDefaultRetryDelay,
|
|
16668
|
-
sseMaxRetryAttempts,
|
|
16669
|
-
sseMaxRetryDelay,
|
|
16670
|
-
sseSleepFn,
|
|
16671
|
-
url,
|
|
16672
|
-
...options
|
|
16673
|
-
}) => {
|
|
16674
|
-
let lastEventId;
|
|
16675
|
-
const sleep = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
16676
|
-
const createStream = async function* () {
|
|
16677
|
-
let retryDelay = sseDefaultRetryDelay ?? 3e3;
|
|
16678
|
-
let attempt = 0;
|
|
16679
|
-
const signal = options.signal ?? new AbortController().signal;
|
|
16680
|
-
while (true) {
|
|
16681
|
-
if (signal.aborted) break;
|
|
16682
|
-
attempt++;
|
|
16683
|
-
const headers = options.headers instanceof Headers ? options.headers : new Headers(options.headers);
|
|
16684
|
-
if (lastEventId !== void 0) {
|
|
16685
|
-
headers.set("Last-Event-ID", lastEventId);
|
|
16686
|
-
}
|
|
16687
|
-
try {
|
|
16688
|
-
const requestInit = {
|
|
16689
|
-
redirect: "follow",
|
|
16690
|
-
...options,
|
|
16691
|
-
body: options.serializedBody,
|
|
16692
|
-
headers,
|
|
16693
|
-
signal
|
|
16694
|
-
};
|
|
16695
|
-
let request = new Request(url, requestInit);
|
|
16696
|
-
if (onRequest) {
|
|
16697
|
-
request = await onRequest(url, requestInit);
|
|
16698
|
-
}
|
|
16699
|
-
const _fetch = options.fetch ?? globalThis.fetch;
|
|
16700
|
-
const response = await _fetch(request);
|
|
16701
|
-
if (!response.ok)
|
|
16702
|
-
throw new Error(
|
|
16703
|
-
`SSE failed: ${response.status} ${response.statusText}`
|
|
16704
|
-
);
|
|
16705
|
-
if (!response.body) throw new Error("No body in SSE response");
|
|
16706
|
-
const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
|
|
16707
|
-
let buffer = "";
|
|
16708
|
-
const abortHandler = () => {
|
|
16709
|
-
try {
|
|
16710
|
-
reader.cancel();
|
|
16711
|
-
} catch {
|
|
16712
|
-
}
|
|
16713
|
-
};
|
|
16714
|
-
signal.addEventListener("abort", abortHandler);
|
|
16715
|
-
try {
|
|
16716
|
-
while (true) {
|
|
16717
|
-
const { done, value } = await reader.read();
|
|
16718
|
-
if (done) break;
|
|
16719
|
-
buffer += value;
|
|
16720
|
-
const chunks = buffer.split("\n\n");
|
|
16721
|
-
buffer = chunks.pop() ?? "";
|
|
16722
|
-
for (const chunk of chunks) {
|
|
16723
|
-
const lines = chunk.split("\n");
|
|
16724
|
-
const dataLines = [];
|
|
16725
|
-
let eventName;
|
|
16726
|
-
for (const line of lines) {
|
|
16727
|
-
if (line.startsWith("data:")) {
|
|
16728
|
-
dataLines.push(line.replace(/^data:\s*/, ""));
|
|
16729
|
-
} else if (line.startsWith("event:")) {
|
|
16730
|
-
eventName = line.replace(/^event:\s*/, "");
|
|
16731
|
-
} else if (line.startsWith("id:")) {
|
|
16732
|
-
lastEventId = line.replace(/^id:\s*/, "");
|
|
16733
|
-
} else if (line.startsWith("retry:")) {
|
|
16734
|
-
const parsed = Number.parseInt(
|
|
16735
|
-
line.replace(/^retry:\s*/, ""),
|
|
16736
|
-
10
|
|
16737
|
-
);
|
|
16738
|
-
if (!Number.isNaN(parsed)) {
|
|
16739
|
-
retryDelay = parsed;
|
|
16740
|
-
}
|
|
16741
|
-
}
|
|
16742
|
-
}
|
|
16743
|
-
let data;
|
|
16744
|
-
let parsedJson = false;
|
|
16745
|
-
if (dataLines.length) {
|
|
16746
|
-
const rawData = dataLines.join("\n");
|
|
16747
|
-
try {
|
|
16748
|
-
data = JSON.parse(rawData);
|
|
16749
|
-
parsedJson = true;
|
|
16750
|
-
} catch {
|
|
16751
|
-
data = rawData;
|
|
16752
|
-
}
|
|
16753
|
-
}
|
|
16754
|
-
if (parsedJson) {
|
|
16755
|
-
if (responseValidator) {
|
|
16756
|
-
await responseValidator(data);
|
|
16757
|
-
}
|
|
16758
|
-
if (responseTransformer) {
|
|
16759
|
-
data = await responseTransformer(data);
|
|
16760
|
-
}
|
|
16761
|
-
}
|
|
16762
|
-
onSseEvent?.({
|
|
16763
|
-
data,
|
|
16764
|
-
event: eventName,
|
|
16765
|
-
id: lastEventId,
|
|
16766
|
-
retry: retryDelay
|
|
16767
|
-
});
|
|
16768
|
-
if (dataLines.length) {
|
|
16769
|
-
yield data;
|
|
16770
|
-
}
|
|
16771
|
-
}
|
|
16772
|
-
}
|
|
16773
|
-
} finally {
|
|
16774
|
-
signal.removeEventListener("abort", abortHandler);
|
|
16775
|
-
reader.releaseLock();
|
|
16776
|
-
}
|
|
16777
|
-
break;
|
|
16778
|
-
} catch (error) {
|
|
16779
|
-
onSseError?.(error);
|
|
16780
|
-
if (sseMaxRetryAttempts !== void 0 && attempt >= sseMaxRetryAttempts) {
|
|
16781
|
-
break;
|
|
16782
|
-
}
|
|
16783
|
-
const backoff = Math.min(
|
|
16784
|
-
retryDelay * 2 ** (attempt - 1),
|
|
16785
|
-
sseMaxRetryDelay ?? 3e4
|
|
16786
|
-
);
|
|
16787
|
-
await sleep(backoff);
|
|
16788
|
-
}
|
|
16789
|
-
}
|
|
16790
|
-
};
|
|
16791
|
-
const stream = createStream();
|
|
16792
|
-
return { stream };
|
|
16793
|
-
};
|
|
16794
|
-
|
|
16795
|
-
// src/client/core/pathSerializer.gen.ts
|
|
16796
|
-
var separatorArrayExplode = (style) => {
|
|
16797
|
-
switch (style) {
|
|
16798
|
-
case "label":
|
|
16799
|
-
return ".";
|
|
16800
|
-
case "matrix":
|
|
16801
|
-
return ";";
|
|
16802
|
-
case "simple":
|
|
16803
|
-
return ",";
|
|
16804
|
-
default:
|
|
16805
|
-
return "&";
|
|
16806
|
-
}
|
|
16807
|
-
};
|
|
16808
|
-
var separatorArrayNoExplode = (style) => {
|
|
16809
|
-
switch (style) {
|
|
16810
|
-
case "form":
|
|
16811
|
-
return ",";
|
|
16812
|
-
case "pipeDelimited":
|
|
16813
|
-
return "|";
|
|
16814
|
-
case "spaceDelimited":
|
|
16815
|
-
return "%20";
|
|
16816
|
-
default:
|
|
16817
|
-
return ",";
|
|
16818
|
-
}
|
|
16819
|
-
};
|
|
16820
|
-
var separatorObjectExplode = (style) => {
|
|
16821
|
-
switch (style) {
|
|
16822
|
-
case "label":
|
|
16823
|
-
return ".";
|
|
16824
|
-
case "matrix":
|
|
16825
|
-
return ";";
|
|
16826
|
-
case "simple":
|
|
16827
|
-
return ",";
|
|
16828
|
-
default:
|
|
16829
|
-
return "&";
|
|
16830
|
-
}
|
|
16831
|
-
};
|
|
16832
|
-
var serializeArrayParam = ({
|
|
16833
|
-
allowReserved,
|
|
16834
|
-
explode,
|
|
16835
|
-
name,
|
|
16836
|
-
style,
|
|
16837
|
-
value
|
|
16838
|
-
}) => {
|
|
16839
|
-
if (!explode) {
|
|
16840
|
-
const joinedValues2 = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join(separatorArrayNoExplode(style));
|
|
16841
|
-
switch (style) {
|
|
16842
|
-
case "label":
|
|
16843
|
-
return `.${joinedValues2}`;
|
|
16844
|
-
case "matrix":
|
|
16845
|
-
return `;${name}=${joinedValues2}`;
|
|
16846
|
-
case "simple":
|
|
16847
|
-
return joinedValues2;
|
|
16848
|
-
default:
|
|
16849
|
-
return `${name}=${joinedValues2}`;
|
|
16850
|
-
}
|
|
16851
|
-
}
|
|
16852
|
-
const separator = separatorArrayExplode(style);
|
|
16853
|
-
const joinedValues = value.map((v) => {
|
|
16854
|
-
if (style === "label" || style === "simple") {
|
|
16855
|
-
return allowReserved ? v : encodeURIComponent(v);
|
|
16856
|
-
}
|
|
16857
|
-
return serializePrimitiveParam({
|
|
16858
|
-
allowReserved,
|
|
16859
|
-
name,
|
|
16860
|
-
value: v
|
|
16861
|
-
});
|
|
16862
|
-
}).join(separator);
|
|
16863
|
-
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
|
|
16864
|
-
};
|
|
16865
|
-
var serializePrimitiveParam = ({
|
|
16866
|
-
allowReserved,
|
|
16867
|
-
name,
|
|
16868
|
-
value
|
|
16869
|
-
}) => {
|
|
16870
|
-
if (value === void 0 || value === null) {
|
|
16871
|
-
return "";
|
|
16872
|
-
}
|
|
16873
|
-
if (typeof value === "object") {
|
|
16874
|
-
throw new Error(
|
|
16875
|
-
"Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these."
|
|
16876
|
-
);
|
|
16877
|
-
}
|
|
16878
|
-
return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
|
|
16879
|
-
};
|
|
16880
|
-
var serializeObjectParam = ({
|
|
16881
|
-
allowReserved,
|
|
16882
|
-
explode,
|
|
16883
|
-
name,
|
|
16884
|
-
style,
|
|
16885
|
-
value,
|
|
16886
|
-
valueOnly
|
|
16887
|
-
}) => {
|
|
16888
|
-
if (value instanceof Date) {
|
|
16889
|
-
return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
|
|
16890
|
-
}
|
|
16891
|
-
if (style !== "deepObject" && !explode) {
|
|
16892
|
-
let values = [];
|
|
16893
|
-
Object.entries(value).forEach(([key, v]) => {
|
|
16894
|
-
values = [
|
|
16895
|
-
...values,
|
|
16896
|
-
key,
|
|
16897
|
-
allowReserved ? v : encodeURIComponent(v)
|
|
16898
|
-
];
|
|
16899
|
-
});
|
|
16900
|
-
const joinedValues2 = values.join(",");
|
|
16901
|
-
switch (style) {
|
|
16902
|
-
case "form":
|
|
16903
|
-
return `${name}=${joinedValues2}`;
|
|
16904
|
-
case "label":
|
|
16905
|
-
return `.${joinedValues2}`;
|
|
16906
|
-
case "matrix":
|
|
16907
|
-
return `;${name}=${joinedValues2}`;
|
|
16908
|
-
default:
|
|
16909
|
-
return joinedValues2;
|
|
16910
|
-
}
|
|
16911
|
-
}
|
|
16912
|
-
const separator = separatorObjectExplode(style);
|
|
16913
|
-
const joinedValues = Object.entries(value).map(
|
|
16914
|
-
([key, v]) => serializePrimitiveParam({
|
|
16915
|
-
allowReserved,
|
|
16916
|
-
name: style === "deepObject" ? `${name}[${key}]` : key,
|
|
16917
|
-
value: v
|
|
16918
|
-
})
|
|
16919
|
-
).join(separator);
|
|
16920
|
-
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
|
|
16921
|
-
};
|
|
16922
|
-
|
|
16923
|
-
// src/client/core/utils.gen.ts
|
|
16924
|
-
function getValidRequestBody(options) {
|
|
16925
|
-
const hasBody = options.body !== void 0;
|
|
16926
|
-
const isSerializedBody = hasBody && options.bodySerializer;
|
|
16927
|
-
if (isSerializedBody) {
|
|
16928
|
-
if ("serializedBody" in options) {
|
|
16929
|
-
const hasSerializedBody = options.serializedBody !== void 0 && options.serializedBody !== "";
|
|
16930
|
-
return hasSerializedBody ? options.serializedBody : null;
|
|
16931
|
-
}
|
|
16932
|
-
return options.body !== "" ? options.body : null;
|
|
16933
|
-
}
|
|
16934
|
-
if (hasBody) {
|
|
16935
|
-
return options.body;
|
|
16936
|
-
}
|
|
16937
|
-
return void 0;
|
|
16938
|
-
}
|
|
16939
|
-
|
|
16940
|
-
// src/client/core/auth.gen.ts
|
|
16941
|
-
var getAuthToken = async (auth, callback) => {
|
|
16942
|
-
const token = typeof callback === "function" ? await callback(auth) : callback;
|
|
16943
|
-
if (!token) {
|
|
16944
|
-
return;
|
|
16945
|
-
}
|
|
16946
|
-
if (auth.scheme === "bearer") {
|
|
16947
|
-
return `Bearer ${token}`;
|
|
16948
|
-
}
|
|
16949
|
-
if (auth.scheme === "basic") {
|
|
16950
|
-
return `Basic ${btoa(token)}`;
|
|
16951
|
-
}
|
|
16952
|
-
return token;
|
|
16953
|
-
};
|
|
16954
|
-
|
|
16955
|
-
// src/client/client/utils.gen.ts
|
|
16956
|
-
var PATH_PARAM_RE = /\{[^{}]+\}/g;
|
|
16957
|
-
var defaultPathSerializer = ({ path, url: _url }) => {
|
|
16958
|
-
let url = _url;
|
|
16959
|
-
const matches = _url.match(PATH_PARAM_RE);
|
|
16960
|
-
if (matches) {
|
|
16961
|
-
for (const match of matches) {
|
|
16962
|
-
let explode = false;
|
|
16963
|
-
let name = match.substring(1, match.length - 1);
|
|
16964
|
-
let style = "simple";
|
|
16965
|
-
if (name.endsWith("*")) {
|
|
16966
|
-
explode = true;
|
|
16967
|
-
name = name.substring(0, name.length - 1);
|
|
16968
|
-
}
|
|
16969
|
-
if (name.startsWith(".")) {
|
|
16970
|
-
name = name.substring(1);
|
|
16971
|
-
style = "label";
|
|
16972
|
-
} else if (name.startsWith(";")) {
|
|
16973
|
-
name = name.substring(1);
|
|
16974
|
-
style = "matrix";
|
|
16975
|
-
}
|
|
16976
|
-
const value = path[name];
|
|
16977
|
-
if (value === void 0 || value === null) {
|
|
16978
|
-
continue;
|
|
16979
|
-
}
|
|
16980
|
-
if (Array.isArray(value)) {
|
|
16981
|
-
url = url.replace(
|
|
16982
|
-
match,
|
|
16983
|
-
serializeArrayParam({ explode, name, style, value })
|
|
16984
|
-
);
|
|
16985
|
-
continue;
|
|
16986
|
-
}
|
|
16987
|
-
if (typeof value === "object") {
|
|
16988
|
-
url = url.replace(
|
|
16989
|
-
match,
|
|
16990
|
-
serializeObjectParam({
|
|
16991
|
-
explode,
|
|
16992
|
-
name,
|
|
16993
|
-
style,
|
|
16994
|
-
value,
|
|
16995
|
-
valueOnly: true
|
|
16996
|
-
})
|
|
16997
|
-
);
|
|
16998
|
-
continue;
|
|
16999
|
-
}
|
|
17000
|
-
if (style === "matrix") {
|
|
17001
|
-
url = url.replace(
|
|
17002
|
-
match,
|
|
17003
|
-
`;${serializePrimitiveParam({
|
|
17004
|
-
name,
|
|
17005
|
-
value
|
|
17006
|
-
})}`
|
|
17007
|
-
);
|
|
17008
|
-
continue;
|
|
17009
|
-
}
|
|
17010
|
-
const replaceValue = encodeURIComponent(
|
|
17011
|
-
style === "label" ? `.${value}` : value
|
|
17012
|
-
);
|
|
17013
|
-
url = url.replace(match, replaceValue);
|
|
17014
|
-
}
|
|
17015
|
-
}
|
|
17016
|
-
return url;
|
|
17017
|
-
};
|
|
17018
|
-
var createQuerySerializer = ({
|
|
17019
|
-
parameters = {},
|
|
17020
|
-
...args
|
|
17021
|
-
} = {}) => {
|
|
17022
|
-
const querySerializer = (queryParams) => {
|
|
17023
|
-
const search = [];
|
|
17024
|
-
if (queryParams && typeof queryParams === "object") {
|
|
17025
|
-
for (const name in queryParams) {
|
|
17026
|
-
const value = queryParams[name];
|
|
17027
|
-
if (value === void 0 || value === null) {
|
|
17028
|
-
continue;
|
|
17029
|
-
}
|
|
17030
|
-
const options = parameters[name] || args;
|
|
17031
|
-
if (Array.isArray(value)) {
|
|
17032
|
-
const serializedArray = serializeArrayParam({
|
|
17033
|
-
allowReserved: options.allowReserved,
|
|
17034
|
-
explode: true,
|
|
17035
|
-
name,
|
|
17036
|
-
style: "form",
|
|
17037
|
-
value,
|
|
17038
|
-
...options.array
|
|
17039
|
-
});
|
|
17040
|
-
if (serializedArray) search.push(serializedArray);
|
|
17041
|
-
} else if (typeof value === "object") {
|
|
17042
|
-
const serializedObject = serializeObjectParam({
|
|
17043
|
-
allowReserved: options.allowReserved,
|
|
17044
|
-
explode: true,
|
|
17045
|
-
name,
|
|
17046
|
-
style: "deepObject",
|
|
17047
|
-
value,
|
|
17048
|
-
...options.object
|
|
17049
|
-
});
|
|
17050
|
-
if (serializedObject) search.push(serializedObject);
|
|
17051
|
-
} else {
|
|
17052
|
-
const serializedPrimitive = serializePrimitiveParam({
|
|
17053
|
-
allowReserved: options.allowReserved,
|
|
17054
|
-
name,
|
|
17055
|
-
value
|
|
17056
|
-
});
|
|
17057
|
-
if (serializedPrimitive) search.push(serializedPrimitive);
|
|
17058
|
-
}
|
|
17059
|
-
}
|
|
17060
|
-
}
|
|
17061
|
-
return search.join("&");
|
|
17062
|
-
};
|
|
17063
|
-
return querySerializer;
|
|
17064
|
-
};
|
|
17065
|
-
var getParseAs = (contentType) => {
|
|
17066
|
-
if (!contentType) {
|
|
17067
|
-
return "stream";
|
|
17068
|
-
}
|
|
17069
|
-
const cleanContent = contentType.split(";")[0]?.trim();
|
|
17070
|
-
if (!cleanContent) {
|
|
17071
|
-
return;
|
|
17072
|
-
}
|
|
17073
|
-
if (cleanContent.startsWith("application/json") || cleanContent.endsWith("+json")) {
|
|
17074
|
-
return "json";
|
|
17075
|
-
}
|
|
17076
|
-
if (cleanContent === "multipart/form-data") {
|
|
17077
|
-
return "formData";
|
|
17078
|
-
}
|
|
17079
|
-
if (["application/", "audio/", "image/", "video/"].some(
|
|
17080
|
-
(type) => cleanContent.startsWith(type)
|
|
17081
|
-
)) {
|
|
17082
|
-
return "blob";
|
|
17083
|
-
}
|
|
17084
|
-
if (cleanContent.startsWith("text/")) {
|
|
17085
|
-
return "text";
|
|
17086
|
-
}
|
|
17087
|
-
return;
|
|
17088
|
-
};
|
|
17089
|
-
var checkForExistence = (options, name) => {
|
|
17090
|
-
if (!name) {
|
|
17091
|
-
return false;
|
|
17092
|
-
}
|
|
17093
|
-
if (options.headers.has(name) || options.query?.[name] || options.headers.get("Cookie")?.includes(`${name}=`)) {
|
|
17094
|
-
return true;
|
|
17095
|
-
}
|
|
17096
|
-
return false;
|
|
17097
|
-
};
|
|
17098
|
-
var setAuthParams = async ({
|
|
17099
|
-
security,
|
|
17100
|
-
...options
|
|
17101
|
-
}) => {
|
|
17102
|
-
for (const auth of security) {
|
|
17103
|
-
if (checkForExistence(options, auth.name)) {
|
|
17104
|
-
continue;
|
|
17105
|
-
}
|
|
17106
|
-
const token = await getAuthToken(auth, options.auth);
|
|
17107
|
-
if (!token) {
|
|
17108
|
-
continue;
|
|
17109
|
-
}
|
|
17110
|
-
const name = auth.name ?? "Authorization";
|
|
17111
|
-
switch (auth.in) {
|
|
17112
|
-
case "query":
|
|
17113
|
-
if (!options.query) {
|
|
17114
|
-
options.query = {};
|
|
17115
|
-
}
|
|
17116
|
-
options.query[name] = token;
|
|
17117
|
-
break;
|
|
17118
|
-
case "cookie":
|
|
17119
|
-
options.headers.append("Cookie", `${name}=${token}`);
|
|
17120
|
-
break;
|
|
17121
|
-
case "header":
|
|
17122
|
-
default:
|
|
17123
|
-
options.headers.set(name, token);
|
|
17124
|
-
break;
|
|
17125
|
-
}
|
|
17126
|
-
}
|
|
17127
|
-
};
|
|
17128
|
-
var buildUrl = (options) => {
|
|
17129
|
-
const url = getUrl({
|
|
17130
|
-
baseUrl: options.baseUrl,
|
|
17131
|
-
path: options.path,
|
|
17132
|
-
query: options.query,
|
|
17133
|
-
querySerializer: typeof options.querySerializer === "function" ? options.querySerializer : createQuerySerializer(options.querySerializer),
|
|
17134
|
-
url: options.url
|
|
17135
|
-
});
|
|
17136
|
-
return url;
|
|
17137
|
-
};
|
|
17138
|
-
var getUrl = ({
|
|
17139
|
-
baseUrl,
|
|
17140
|
-
path,
|
|
17141
|
-
query,
|
|
17142
|
-
querySerializer,
|
|
17143
|
-
url: _url
|
|
17144
|
-
}) => {
|
|
17145
|
-
const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
|
|
17146
|
-
let url = (baseUrl ?? "") + pathUrl;
|
|
17147
|
-
if (path) {
|
|
17148
|
-
url = defaultPathSerializer({ path, url });
|
|
17149
|
-
}
|
|
17150
|
-
let search = query ? querySerializer(query) : "";
|
|
17151
|
-
if (search.startsWith("?")) {
|
|
17152
|
-
search = search.substring(1);
|
|
17153
|
-
}
|
|
17154
|
-
if (search) {
|
|
17155
|
-
url += `?${search}`;
|
|
17156
|
-
}
|
|
17157
|
-
return url;
|
|
17158
|
-
};
|
|
17159
|
-
var mergeConfigs = (a, b) => {
|
|
17160
|
-
const config = { ...a, ...b };
|
|
17161
|
-
if (config.baseUrl?.endsWith("/")) {
|
|
17162
|
-
config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
|
|
17163
|
-
}
|
|
17164
|
-
config.headers = mergeHeaders(a.headers, b.headers);
|
|
17165
|
-
return config;
|
|
17166
|
-
};
|
|
17167
|
-
var headersEntries = (headers) => {
|
|
17168
|
-
const entries = [];
|
|
17169
|
-
headers.forEach((value, key) => {
|
|
17170
|
-
entries.push([key, value]);
|
|
17171
|
-
});
|
|
17172
|
-
return entries;
|
|
17173
|
-
};
|
|
17174
|
-
var mergeHeaders = (...headers) => {
|
|
17175
|
-
const mergedHeaders = new Headers();
|
|
17176
|
-
for (const header of headers) {
|
|
17177
|
-
if (!header || typeof header !== "object") {
|
|
17178
|
-
continue;
|
|
17179
|
-
}
|
|
17180
|
-
const iterator = header instanceof Headers ? headersEntries(header) : Object.entries(header);
|
|
17181
|
-
for (const [key, value] of iterator) {
|
|
17182
|
-
if (value === null) {
|
|
17183
|
-
mergedHeaders.delete(key);
|
|
17184
|
-
} else if (Array.isArray(value)) {
|
|
17185
|
-
for (const v of value) {
|
|
17186
|
-
mergedHeaders.append(key, v);
|
|
17187
|
-
}
|
|
17188
|
-
} else if (value !== void 0) {
|
|
17189
|
-
mergedHeaders.set(
|
|
17190
|
-
key,
|
|
17191
|
-
typeof value === "object" ? JSON.stringify(value) : value
|
|
17192
|
-
);
|
|
17193
|
-
}
|
|
17194
|
-
}
|
|
17195
|
-
}
|
|
17196
|
-
return mergedHeaders;
|
|
17197
|
-
};
|
|
17198
|
-
var Interceptors = class {
|
|
17199
|
-
constructor() {
|
|
17200
|
-
this.fns = [];
|
|
17201
|
-
}
|
|
17202
|
-
clear() {
|
|
17203
|
-
this.fns = [];
|
|
17204
|
-
}
|
|
17205
|
-
eject(id) {
|
|
17206
|
-
const index = this.getInterceptorIndex(id);
|
|
17207
|
-
if (this.fns[index]) {
|
|
17208
|
-
this.fns[index] = null;
|
|
17209
|
-
}
|
|
17210
|
-
}
|
|
17211
|
-
exists(id) {
|
|
17212
|
-
const index = this.getInterceptorIndex(id);
|
|
17213
|
-
return Boolean(this.fns[index]);
|
|
17214
|
-
}
|
|
17215
|
-
getInterceptorIndex(id) {
|
|
17216
|
-
if (typeof id === "number") {
|
|
17217
|
-
return this.fns[id] ? id : -1;
|
|
17218
|
-
}
|
|
17219
|
-
return this.fns.indexOf(id);
|
|
17220
|
-
}
|
|
17221
|
-
update(id, fn) {
|
|
17222
|
-
const index = this.getInterceptorIndex(id);
|
|
17223
|
-
if (this.fns[index]) {
|
|
17224
|
-
this.fns[index] = fn;
|
|
17225
|
-
return id;
|
|
17226
|
-
}
|
|
17227
|
-
return false;
|
|
17228
|
-
}
|
|
17229
|
-
use(fn) {
|
|
17230
|
-
this.fns.push(fn);
|
|
17231
|
-
return this.fns.length - 1;
|
|
17232
|
-
}
|
|
17233
|
-
};
|
|
17234
|
-
var createInterceptors = () => ({
|
|
17235
|
-
error: new Interceptors(),
|
|
17236
|
-
request: new Interceptors(),
|
|
17237
|
-
response: new Interceptors()
|
|
17238
|
-
});
|
|
17239
|
-
var defaultQuerySerializer = createQuerySerializer({
|
|
17240
|
-
allowReserved: false,
|
|
17241
|
-
array: {
|
|
17242
|
-
explode: true,
|
|
17243
|
-
style: "form"
|
|
17244
|
-
},
|
|
17245
|
-
object: {
|
|
17246
|
-
explode: true,
|
|
17247
|
-
style: "deepObject"
|
|
17248
|
-
}
|
|
17249
|
-
});
|
|
17250
|
-
var defaultHeaders = {
|
|
17251
|
-
"Content-Type": "application/json"
|
|
17252
|
-
};
|
|
17253
|
-
var createConfig = (override = {}) => ({
|
|
17254
|
-
...jsonBodySerializer,
|
|
17255
|
-
headers: defaultHeaders,
|
|
17256
|
-
parseAs: "auto",
|
|
17257
|
-
querySerializer: defaultQuerySerializer,
|
|
17258
|
-
...override
|
|
17259
|
-
});
|
|
17260
|
-
|
|
17261
|
-
// src/client/client/client.gen.ts
|
|
17262
|
-
var createClient = (config = {}) => {
|
|
17263
|
-
let _config = mergeConfigs(createConfig(), config);
|
|
17264
|
-
const getConfig = () => ({ ..._config });
|
|
17265
|
-
const setConfig = (config2) => {
|
|
17266
|
-
_config = mergeConfigs(_config, config2);
|
|
17267
|
-
return getConfig();
|
|
17268
|
-
};
|
|
17269
|
-
const interceptors = createInterceptors();
|
|
17270
|
-
const beforeRequest = async (options) => {
|
|
17271
|
-
const opts = {
|
|
17272
|
-
..._config,
|
|
17273
|
-
...options,
|
|
17274
|
-
fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
|
|
17275
|
-
headers: mergeHeaders(_config.headers, options.headers),
|
|
17276
|
-
serializedBody: void 0
|
|
17277
|
-
};
|
|
17278
|
-
if (opts.security) {
|
|
17279
|
-
await setAuthParams({
|
|
17280
|
-
...opts,
|
|
17281
|
-
security: opts.security
|
|
17282
|
-
});
|
|
17283
|
-
}
|
|
17284
|
-
if (opts.requestValidator) {
|
|
17285
|
-
await opts.requestValidator(opts);
|
|
17286
|
-
}
|
|
17287
|
-
if (opts.body !== void 0 && opts.bodySerializer) {
|
|
17288
|
-
opts.serializedBody = opts.bodySerializer(opts.body);
|
|
17289
|
-
}
|
|
17290
|
-
if (opts.body === void 0 || opts.serializedBody === "") {
|
|
17291
|
-
opts.headers.delete("Content-Type");
|
|
17292
|
-
}
|
|
17293
|
-
const url = buildUrl(opts);
|
|
17294
|
-
return { opts, url };
|
|
17295
|
-
};
|
|
17296
|
-
const request = async (options) => {
|
|
17297
|
-
const { opts, url } = await beforeRequest(options);
|
|
17298
|
-
for (const fn of interceptors.request.fns) {
|
|
17299
|
-
if (fn) {
|
|
17300
|
-
await fn(opts);
|
|
17301
|
-
}
|
|
17302
|
-
}
|
|
17303
|
-
const _fetch = opts.fetch;
|
|
17304
|
-
const requestInit = {
|
|
17305
|
-
...opts,
|
|
17306
|
-
body: getValidRequestBody(opts)
|
|
17307
|
-
};
|
|
17308
|
-
let response = await _fetch(url, requestInit);
|
|
17309
|
-
for (const fn of interceptors.response.fns) {
|
|
17310
|
-
if (fn) {
|
|
17311
|
-
response = await fn(response, opts);
|
|
17312
|
-
}
|
|
17313
|
-
}
|
|
17314
|
-
const result = {
|
|
17315
|
-
response
|
|
17316
|
-
};
|
|
17317
|
-
if (response.ok) {
|
|
17318
|
-
const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
|
|
17319
|
-
if (response.status === 204 || response.headers.get("Content-Length") === "0") {
|
|
17320
|
-
let emptyData;
|
|
17321
|
-
switch (parseAs) {
|
|
17322
|
-
case "arrayBuffer":
|
|
17323
|
-
case "blob":
|
|
17324
|
-
case "text":
|
|
17325
|
-
emptyData = await response[parseAs]();
|
|
17326
|
-
break;
|
|
17327
|
-
case "formData":
|
|
17328
|
-
emptyData = new FormData();
|
|
17329
|
-
break;
|
|
17330
|
-
case "stream":
|
|
17331
|
-
emptyData = response.body;
|
|
17332
|
-
break;
|
|
17333
|
-
case "json":
|
|
17334
|
-
default:
|
|
17335
|
-
emptyData = {};
|
|
17336
|
-
break;
|
|
17337
|
-
}
|
|
17338
|
-
return {
|
|
17339
|
-
data: emptyData,
|
|
17340
|
-
...result
|
|
17341
|
-
};
|
|
17342
|
-
}
|
|
17343
|
-
let data;
|
|
17344
|
-
switch (parseAs) {
|
|
17345
|
-
case "arrayBuffer":
|
|
17346
|
-
case "blob":
|
|
17347
|
-
case "formData":
|
|
17348
|
-
case "json":
|
|
17349
|
-
case "text":
|
|
17350
|
-
data = await response[parseAs]();
|
|
17351
|
-
break;
|
|
17352
|
-
case "stream":
|
|
17353
|
-
return {
|
|
17354
|
-
data: response.body,
|
|
17355
|
-
...result
|
|
17356
|
-
};
|
|
17357
|
-
}
|
|
17358
|
-
if (parseAs === "json") {
|
|
17359
|
-
if (opts.responseValidator) {
|
|
17360
|
-
await opts.responseValidator(data);
|
|
17361
|
-
}
|
|
17362
|
-
if (opts.responseTransformer) {
|
|
17363
|
-
data = await opts.responseTransformer(data);
|
|
17364
|
-
}
|
|
17365
|
-
}
|
|
17366
|
-
return {
|
|
17367
|
-
data,
|
|
17368
|
-
...result
|
|
17369
|
-
};
|
|
17370
|
-
}
|
|
17371
|
-
const textError = await response.text();
|
|
17372
|
-
let jsonError;
|
|
17373
|
-
try {
|
|
17374
|
-
jsonError = JSON.parse(textError);
|
|
17375
|
-
} catch {
|
|
17376
|
-
}
|
|
17377
|
-
const error = jsonError ?? textError;
|
|
17378
|
-
let finalError = error;
|
|
17379
|
-
for (const fn of interceptors.error.fns) {
|
|
17380
|
-
if (fn) {
|
|
17381
|
-
finalError = await fn(error, response, opts);
|
|
17382
|
-
}
|
|
17383
|
-
}
|
|
17384
|
-
finalError = finalError || {};
|
|
17385
|
-
if (opts.throwOnError) {
|
|
17386
|
-
throw finalError;
|
|
17387
|
-
}
|
|
17388
|
-
return {
|
|
17389
|
-
error: finalError,
|
|
17390
|
-
...result
|
|
17391
|
-
};
|
|
17392
|
-
};
|
|
17393
|
-
const makeMethodFn = (method) => (options) => request({ ...options, method });
|
|
17394
|
-
const makeSseFn = (method) => async (options) => {
|
|
17395
|
-
const { opts, url } = await beforeRequest(options);
|
|
17396
|
-
return createSseClient({
|
|
17397
|
-
...opts,
|
|
17398
|
-
body: opts.body,
|
|
17399
|
-
headers: opts.headers,
|
|
17400
|
-
method,
|
|
17401
|
-
onRequest: async (url2, init) => {
|
|
17402
|
-
let request2 = new Request(url2, init);
|
|
17403
|
-
const requestInit = {
|
|
17404
|
-
...init,
|
|
17405
|
-
method: init.method,
|
|
17406
|
-
url: url2
|
|
17407
|
-
};
|
|
17408
|
-
for (const fn of interceptors.request.fns) {
|
|
17409
|
-
if (fn) {
|
|
17410
|
-
await fn(requestInit);
|
|
17411
|
-
request2 = new Request(requestInit.url, requestInit);
|
|
17412
|
-
}
|
|
17413
|
-
}
|
|
17414
|
-
return request2;
|
|
17415
|
-
},
|
|
17416
|
-
url
|
|
17417
|
-
});
|
|
17418
|
-
};
|
|
17419
|
-
return {
|
|
17420
|
-
buildUrl,
|
|
17421
|
-
connect: makeMethodFn("CONNECT"),
|
|
17422
|
-
delete: makeMethodFn("DELETE"),
|
|
17423
|
-
get: makeMethodFn("GET"),
|
|
17424
|
-
getConfig,
|
|
17425
|
-
head: makeMethodFn("HEAD"),
|
|
17426
|
-
interceptors,
|
|
17427
|
-
options: makeMethodFn("OPTIONS"),
|
|
17428
|
-
patch: makeMethodFn("PATCH"),
|
|
17429
|
-
post: makeMethodFn("POST"),
|
|
17430
|
-
put: makeMethodFn("PUT"),
|
|
17431
|
-
request,
|
|
17432
|
-
setConfig,
|
|
17433
|
-
sse: {
|
|
17434
|
-
connect: makeSseFn("CONNECT"),
|
|
17435
|
-
delete: makeSseFn("DELETE"),
|
|
17436
|
-
get: makeSseFn("GET"),
|
|
17437
|
-
head: makeSseFn("HEAD"),
|
|
17438
|
-
options: makeSseFn("OPTIONS"),
|
|
17439
|
-
patch: makeSseFn("PATCH"),
|
|
17440
|
-
post: makeSseFn("POST"),
|
|
17441
|
-
put: makeSseFn("PUT"),
|
|
17442
|
-
trace: makeSseFn("TRACE")
|
|
17443
|
-
},
|
|
17444
|
-
trace: makeMethodFn("TRACE")
|
|
17445
|
-
};
|
|
17446
|
-
};
|
|
17447
|
-
|
|
17448
|
-
// src/client/client.gen.ts
|
|
17449
|
-
var client = createClient(createClientConfig(createConfig()));
|
|
17450
|
-
|
|
17451
|
-
// src/client/sdk.gen.ts
|
|
17452
|
-
var postApiV1Embeddings = (options) => {
|
|
17453
|
-
return (options.client ?? client).post({
|
|
17454
|
-
url: "/api/v1/embeddings",
|
|
17455
|
-
...options,
|
|
17456
|
-
headers: {
|
|
17457
|
-
"Content-Type": "application/json",
|
|
17458
|
-
...options.headers
|
|
17459
|
-
}
|
|
17460
|
-
});
|
|
17461
|
-
};
|
|
17462
|
-
|
|
17463
16777
|
// src/lib/memoryEngine/chunking.ts
|
|
17464
16778
|
var DEFAULT_CHUNK_SIZE = 400;
|
|
17465
16779
|
var DEFAULT_CHUNK_OVERLAP = 50;
|
|
@@ -17595,8 +16909,8 @@ function shouldChunkMessage(content, chunkSize = DEFAULT_CHUNK_SIZE) {
|
|
|
17595
16909
|
return content.length > chunkSize;
|
|
17596
16910
|
}
|
|
17597
16911
|
|
|
17598
|
-
// src/lib/memoryEngine/
|
|
17599
|
-
|
|
16912
|
+
// src/lib/memoryEngine/generate.ts
|
|
16913
|
+
import { postApiV1Embeddings } from "@anuma/sdk";
|
|
17600
16914
|
var EMBED_MAX_ATTEMPTS = 4;
|
|
17601
16915
|
async function withEmbeddingRetry(call) {
|
|
17602
16916
|
let last;
|
|
@@ -17640,7 +16954,7 @@ async function generateEmbedding(text, options) {
|
|
|
17640
16954
|
const { baseUrl = BASE_URL, getToken, apiKey, model, cache } = options;
|
|
17641
16955
|
if (cache) {
|
|
17642
16956
|
const cached = cache.get(text);
|
|
17643
|
-
if (cached) return cached;
|
|
16957
|
+
if (cached) return Array.from(cached);
|
|
17644
16958
|
}
|
|
17645
16959
|
let headers;
|
|
17646
16960
|
if (apiKey) {
|
|
@@ -17679,10 +16993,11 @@ async function generateEmbedding(text, options) {
|
|
|
17679
16993
|
totalTokens: response.data.usage.total_tokens ?? 0
|
|
17680
16994
|
});
|
|
17681
16995
|
}
|
|
16996
|
+
const f32Embedding = Float32Array.from(embedding);
|
|
17682
16997
|
if (cache) {
|
|
17683
|
-
cache.set(text,
|
|
16998
|
+
cache.set(text, f32Embedding);
|
|
17684
16999
|
}
|
|
17685
|
-
return
|
|
17000
|
+
return Array.from(f32Embedding);
|
|
17686
17001
|
}
|
|
17687
17002
|
var DEFAULT_EMBEDDING_BATCH_SIZE = 100;
|
|
17688
17003
|
var DEFAULT_EMBEDDING_BATCH_CONCURRENCY = 3;
|
|
@@ -17720,7 +17035,7 @@ async function generateEmbeddings(texts, options) {
|
|
|
17720
17035
|
if (cache) {
|
|
17721
17036
|
const cached = cache.get(texts[i]);
|
|
17722
17037
|
if (cached) {
|
|
17723
|
-
results[i] = cached;
|
|
17038
|
+
results[i] = Array.from(cached);
|
|
17724
17039
|
continue;
|
|
17725
17040
|
}
|
|
17726
17041
|
}
|
|
@@ -17781,13 +17096,17 @@ async function generateEmbeddings(texts, options) {
|
|
|
17781
17096
|
newEmbeddings = allEmbeddings.flat();
|
|
17782
17097
|
}
|
|
17783
17098
|
for (let i = 0; i < uncachedIndices.length; i++) {
|
|
17784
|
-
|
|
17099
|
+
const f32Embedding = Float32Array.from(newEmbeddings[i]);
|
|
17100
|
+
results[uncachedIndices[i]] = Array.from(f32Embedding);
|
|
17785
17101
|
if (cache) {
|
|
17786
|
-
cache.set(uncachedTexts[i],
|
|
17102
|
+
cache.set(uncachedTexts[i], f32Embedding);
|
|
17787
17103
|
}
|
|
17788
17104
|
}
|
|
17789
17105
|
return results;
|
|
17790
17106
|
}
|
|
17107
|
+
|
|
17108
|
+
// src/lib/memoryEngine/embeddings.ts
|
|
17109
|
+
var DEFAULT_MIN_CONTENT_LENGTH = 10;
|
|
17791
17110
|
async function embedMessage(ctx, messageId, options) {
|
|
17792
17111
|
let message;
|
|
17793
17112
|
const conversations = await getConversationsOp(ctx);
|
|
@@ -19207,7 +18526,7 @@ function createMemoryVaultSearchTool(vaultCtx, embeddingOptions, cache, searchOp
|
|
|
19207
18526
|
legacy.map((r) => ({ id: r.uniqueId, content: r.content, score: r.similarity }))
|
|
19208
18527
|
);
|
|
19209
18528
|
}
|
|
19210
|
-
const { recall: recall2 } = await import("./recall-
|
|
18529
|
+
const { recall: recall2 } = await import("./recall-WT5HY2IA.mjs");
|
|
19211
18530
|
const result = await recall2(
|
|
19212
18531
|
query,
|
|
19213
18532
|
{ vaultCtx, embeddingOptions, vaultCache: cache },
|
|
@@ -19847,8 +19166,10 @@ export {
|
|
|
19847
19166
|
clearAllEncryptionKeys,
|
|
19848
19167
|
getEncryptionKey,
|
|
19849
19168
|
encryptData,
|
|
19169
|
+
encryptDataBytes,
|
|
19850
19170
|
decryptData,
|
|
19851
19171
|
decryptDataBytes,
|
|
19172
|
+
decryptDataBytesFromBytes,
|
|
19852
19173
|
hasEncryptionKey,
|
|
19853
19174
|
encryptDataWithKey,
|
|
19854
19175
|
decryptDataWithKey,
|
|
@@ -19873,6 +19194,7 @@ export {
|
|
|
19873
19194
|
getConversationOp,
|
|
19874
19195
|
getConversationsOp,
|
|
19875
19196
|
getConversationsLazyOp,
|
|
19197
|
+
getConversationsPageOp,
|
|
19876
19198
|
getConversationsByProjectLazyOp,
|
|
19877
19199
|
updateConversationTitleOp,
|
|
19878
19200
|
deleteConversationOp,
|
|
@@ -19915,7 +19237,6 @@ export {
|
|
|
19915
19237
|
DEFAULT_MIN_CHUNK_SIZE,
|
|
19916
19238
|
chunkText,
|
|
19917
19239
|
shouldChunkMessage,
|
|
19918
|
-
createSseClient,
|
|
19919
19240
|
DEFAULT_API_EMBEDDING_MODEL,
|
|
19920
19241
|
generateEmbedding,
|
|
19921
19242
|
generateEmbeddings,
|