@anuma/sdk 3.6.2 → 3.7.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.
Files changed (27) hide show
  1. package/dist/expo/{chunk-7TATXBC5.mjs → chunk-AAB7OG7Q.mjs} +810 -4
  2. package/dist/{react/chunk-DFVCS3QQ.mjs → expo/chunk-BOY27A2C.mjs} +30 -3
  3. package/dist/expo/{consolidate-3QQPUWD6.mjs → consolidate-J5PHQKKY.mjs} +1 -1
  4. package/dist/expo/index.cjs +931 -825
  5. package/dist/expo/index.d.mts +9 -0
  6. package/dist/expo/index.d.ts +9 -0
  7. package/dist/expo/index.mjs +14 -817
  8. package/dist/{react/recall-OPKHWKZX.mjs → expo/recall-YVU7OSSJ.mjs} +2 -2
  9. package/dist/react/{chunk-DDHTJGZN.mjs → chunk-3VPEZDYL.mjs} +896 -4
  10. package/dist/{expo/chunk-DFVCS3QQ.mjs → react/chunk-BOY27A2C.mjs} +30 -3
  11. package/dist/react/{consolidate-3MXZV3G7.mjs → consolidate-PWJCAPZA.mjs} +1 -1
  12. package/dist/react/index.cjs +2021 -1907
  13. package/dist/react/index.d.mts +9 -0
  14. package/dist/react/index.d.ts +9 -0
  15. package/dist/react/index.mjs +29 -888
  16. package/dist/{expo/recall-IO4KJ5W7.mjs → react/recall-Z7BWJ67X.mjs} +2 -2
  17. package/dist/server/{chunk-V7SVKIXQ.mjs → chunk-LSKFJNLF.mjs} +795 -4
  18. package/dist/server/{chunk-AHJT66EO.mjs → chunk-MIXEASUP.mjs} +30 -3
  19. package/dist/server/{consolidate-CN2GQV4D.mjs → consolidate-PCHO3D3G.mjs} +1 -1
  20. package/dist/server/index.cjs +925 -163
  21. package/dist/server/index.d.mts +36 -0
  22. package/dist/server/index.d.ts +36 -0
  23. package/dist/server/index.mjs +9 -147
  24. package/dist/server/{recall-IWY2MYHR.mjs → recall-XEOLXA6P.mjs} +2 -2
  25. package/dist/tools/selection/index.cjs +793 -3
  26. package/dist/tools/selection/index.mjs +791 -3
  27. package/package.json +2 -2
@@ -1,11 +1,12 @@
1
1
  import {
2
2
  callPortalJsonCompletion,
3
3
  getLogger
4
- } from "./chunk-AHJT66EO.mjs";
4
+ } from "./chunk-MIXEASUP.mjs";
5
5
  import {
6
6
  BASE_URL,
7
7
  __commonJS,
8
- __toESM
8
+ __toESM,
9
+ createClientConfig
9
10
  } from "./chunk-3RPGXXPZ.mjs";
10
11
 
11
12
  // node_modules/.pnpm/@babel+runtime@7.26.0/node_modules/@babel/runtime/helpers/interopRequireDefault.js
@@ -17089,8 +17090,797 @@ function shouldChunkMessage(content, chunkSize = DEFAULT_CHUNK_SIZE) {
17089
17090
  return content.length > chunkSize;
17090
17091
  }
17091
17092
 
17093
+ // src/client/core/bodySerializer.gen.ts
17094
+ var jsonBodySerializer = {
17095
+ bodySerializer: (body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value)
17096
+ };
17097
+
17098
+ // src/client/core/serverSentEvents.gen.ts
17099
+ function createSseClient({
17100
+ onRequest,
17101
+ onSseError,
17102
+ onSseEvent,
17103
+ responseTransformer,
17104
+ responseValidator,
17105
+ sseDefaultRetryDelay,
17106
+ sseMaxRetryAttempts,
17107
+ sseMaxRetryDelay,
17108
+ sseSleepFn,
17109
+ url,
17110
+ ...options
17111
+ }) {
17112
+ let lastEventId;
17113
+ const sleep = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
17114
+ const createStream = async function* () {
17115
+ let retryDelay = sseDefaultRetryDelay ?? 3e3;
17116
+ let attempt = 0;
17117
+ const signal = options.signal ?? new AbortController().signal;
17118
+ while (true) {
17119
+ if (signal.aborted) break;
17120
+ attempt++;
17121
+ const headers = options.headers instanceof Headers ? options.headers : new Headers(options.headers);
17122
+ if (lastEventId !== void 0) {
17123
+ headers.set("Last-Event-ID", lastEventId);
17124
+ }
17125
+ try {
17126
+ const requestInit = {
17127
+ redirect: "follow",
17128
+ ...options,
17129
+ body: options.serializedBody,
17130
+ headers,
17131
+ signal
17132
+ };
17133
+ let request = new Request(url, requestInit);
17134
+ if (onRequest) {
17135
+ request = await onRequest(url, requestInit);
17136
+ }
17137
+ const _fetch = options.fetch ?? globalThis.fetch;
17138
+ const response = await _fetch(request);
17139
+ if (!response.ok) throw new Error(`SSE failed: ${response.status} ${response.statusText}`);
17140
+ if (!response.body) throw new Error("No body in SSE response");
17141
+ const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
17142
+ let buffer = "";
17143
+ const abortHandler = () => {
17144
+ try {
17145
+ reader.cancel();
17146
+ } catch {
17147
+ }
17148
+ };
17149
+ signal.addEventListener("abort", abortHandler);
17150
+ try {
17151
+ while (true) {
17152
+ const { done, value } = await reader.read();
17153
+ if (done) break;
17154
+ buffer += value;
17155
+ buffer = buffer.replace(/\r\n?/g, "\n");
17156
+ const chunks = buffer.split("\n\n");
17157
+ buffer = chunks.pop() ?? "";
17158
+ for (const chunk of chunks) {
17159
+ const lines = chunk.split("\n");
17160
+ const dataLines = [];
17161
+ let eventName;
17162
+ for (const line of lines) {
17163
+ if (line.startsWith("data:")) {
17164
+ dataLines.push(line.replace(/^data:\s*/, ""));
17165
+ } else if (line.startsWith("event:")) {
17166
+ eventName = line.replace(/^event:\s*/, "");
17167
+ } else if (line.startsWith("id:")) {
17168
+ lastEventId = line.replace(/^id:\s*/, "");
17169
+ } else if (line.startsWith("retry:")) {
17170
+ const parsed = Number.parseInt(line.replace(/^retry:\s*/, ""), 10);
17171
+ if (!Number.isNaN(parsed)) {
17172
+ retryDelay = parsed;
17173
+ }
17174
+ }
17175
+ }
17176
+ let data;
17177
+ let parsedJson = false;
17178
+ if (dataLines.length) {
17179
+ const rawData = dataLines.join("\n");
17180
+ try {
17181
+ data = JSON.parse(rawData);
17182
+ parsedJson = true;
17183
+ } catch {
17184
+ data = rawData;
17185
+ }
17186
+ }
17187
+ if (parsedJson) {
17188
+ if (responseValidator) {
17189
+ await responseValidator(data);
17190
+ }
17191
+ if (responseTransformer) {
17192
+ data = await responseTransformer(data);
17193
+ }
17194
+ }
17195
+ onSseEvent?.({
17196
+ data,
17197
+ event: eventName,
17198
+ id: lastEventId,
17199
+ retry: retryDelay
17200
+ });
17201
+ if (dataLines.length) {
17202
+ yield data;
17203
+ }
17204
+ }
17205
+ }
17206
+ } finally {
17207
+ signal.removeEventListener("abort", abortHandler);
17208
+ reader.releaseLock();
17209
+ }
17210
+ break;
17211
+ } catch (error) {
17212
+ onSseError?.(error);
17213
+ if (sseMaxRetryAttempts !== void 0 && attempt >= sseMaxRetryAttempts) {
17214
+ break;
17215
+ }
17216
+ const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 3e4);
17217
+ await sleep(backoff);
17218
+ }
17219
+ }
17220
+ };
17221
+ const stream = createStream();
17222
+ return { stream };
17223
+ }
17224
+
17225
+ // src/client/core/pathSerializer.gen.ts
17226
+ var separatorArrayExplode = (style) => {
17227
+ switch (style) {
17228
+ case "label":
17229
+ return ".";
17230
+ case "matrix":
17231
+ return ";";
17232
+ case "simple":
17233
+ return ",";
17234
+ default:
17235
+ return "&";
17236
+ }
17237
+ };
17238
+ var separatorArrayNoExplode = (style) => {
17239
+ switch (style) {
17240
+ case "form":
17241
+ return ",";
17242
+ case "pipeDelimited":
17243
+ return "|";
17244
+ case "spaceDelimited":
17245
+ return "%20";
17246
+ default:
17247
+ return ",";
17248
+ }
17249
+ };
17250
+ var separatorObjectExplode = (style) => {
17251
+ switch (style) {
17252
+ case "label":
17253
+ return ".";
17254
+ case "matrix":
17255
+ return ";";
17256
+ case "simple":
17257
+ return ",";
17258
+ default:
17259
+ return "&";
17260
+ }
17261
+ };
17262
+ var serializeArrayParam = ({
17263
+ allowReserved,
17264
+ explode,
17265
+ name,
17266
+ style,
17267
+ value
17268
+ }) => {
17269
+ if (!explode) {
17270
+ const joinedValues2 = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join(separatorArrayNoExplode(style));
17271
+ switch (style) {
17272
+ case "label":
17273
+ return `.${joinedValues2}`;
17274
+ case "matrix":
17275
+ return `;${name}=${joinedValues2}`;
17276
+ case "simple":
17277
+ return joinedValues2;
17278
+ default:
17279
+ return `${name}=${joinedValues2}`;
17280
+ }
17281
+ }
17282
+ const separator = separatorArrayExplode(style);
17283
+ const joinedValues = value.map((v) => {
17284
+ if (style === "label" || style === "simple") {
17285
+ return allowReserved ? v : encodeURIComponent(v);
17286
+ }
17287
+ return serializePrimitiveParam({
17288
+ allowReserved,
17289
+ name,
17290
+ value: v
17291
+ });
17292
+ }).join(separator);
17293
+ return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
17294
+ };
17295
+ var serializePrimitiveParam = ({
17296
+ allowReserved,
17297
+ name,
17298
+ value
17299
+ }) => {
17300
+ if (value === void 0 || value === null) {
17301
+ return "";
17302
+ }
17303
+ if (typeof value === "object") {
17304
+ throw new Error(
17305
+ "Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these."
17306
+ );
17307
+ }
17308
+ return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
17309
+ };
17310
+ var serializeObjectParam = ({
17311
+ allowReserved,
17312
+ explode,
17313
+ name,
17314
+ style,
17315
+ value,
17316
+ valueOnly
17317
+ }) => {
17318
+ if (value instanceof Date) {
17319
+ return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
17320
+ }
17321
+ if (style !== "deepObject" && !explode) {
17322
+ let values = [];
17323
+ Object.entries(value).forEach(([key, v]) => {
17324
+ values = [...values, key, allowReserved ? v : encodeURIComponent(v)];
17325
+ });
17326
+ const joinedValues2 = values.join(",");
17327
+ switch (style) {
17328
+ case "form":
17329
+ return `${name}=${joinedValues2}`;
17330
+ case "label":
17331
+ return `.${joinedValues2}`;
17332
+ case "matrix":
17333
+ return `;${name}=${joinedValues2}`;
17334
+ default:
17335
+ return joinedValues2;
17336
+ }
17337
+ }
17338
+ const separator = separatorObjectExplode(style);
17339
+ const joinedValues = Object.entries(value).map(
17340
+ ([key, v]) => serializePrimitiveParam({
17341
+ allowReserved,
17342
+ name: style === "deepObject" ? `${name}[${key}]` : key,
17343
+ value: v
17344
+ })
17345
+ ).join(separator);
17346
+ return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
17347
+ };
17348
+
17349
+ // src/client/core/utils.gen.ts
17350
+ function getValidRequestBody(options) {
17351
+ const hasBody = options.body !== void 0;
17352
+ const isSerializedBody = hasBody && options.bodySerializer;
17353
+ if (isSerializedBody) {
17354
+ if ("serializedBody" in options) {
17355
+ const hasSerializedBody = options.serializedBody !== void 0 && options.serializedBody !== "";
17356
+ return hasSerializedBody ? options.serializedBody : null;
17357
+ }
17358
+ return options.body !== "" ? options.body : null;
17359
+ }
17360
+ if (hasBody) {
17361
+ return options.body;
17362
+ }
17363
+ return void 0;
17364
+ }
17365
+
17366
+ // src/client/core/auth.gen.ts
17367
+ var getAuthToken = async (auth, callback) => {
17368
+ const token = typeof callback === "function" ? await callback(auth) : callback;
17369
+ if (!token) {
17370
+ return;
17371
+ }
17372
+ if (auth.scheme === "bearer") {
17373
+ return `Bearer ${token}`;
17374
+ }
17375
+ if (auth.scheme === "basic") {
17376
+ return `Basic ${btoa(token)}`;
17377
+ }
17378
+ return token;
17379
+ };
17380
+
17381
+ // src/client/client/utils.gen.ts
17382
+ var PATH_PARAM_RE = /\{[^{}]+\}/g;
17383
+ var defaultPathSerializer = ({ path, url: _url }) => {
17384
+ let url = _url;
17385
+ const matches = _url.match(PATH_PARAM_RE);
17386
+ if (matches) {
17387
+ for (const match of matches) {
17388
+ let explode = false;
17389
+ let name = match.substring(1, match.length - 1);
17390
+ let style = "simple";
17391
+ if (name.endsWith("*")) {
17392
+ explode = true;
17393
+ name = name.substring(0, name.length - 1);
17394
+ }
17395
+ if (name.startsWith(".")) {
17396
+ name = name.substring(1);
17397
+ style = "label";
17398
+ } else if (name.startsWith(";")) {
17399
+ name = name.substring(1);
17400
+ style = "matrix";
17401
+ }
17402
+ const value = path[name];
17403
+ if (value === void 0 || value === null) {
17404
+ continue;
17405
+ }
17406
+ if (Array.isArray(value)) {
17407
+ url = url.replace(match, serializeArrayParam({ explode, name, style, value }));
17408
+ continue;
17409
+ }
17410
+ if (typeof value === "object") {
17411
+ url = url.replace(
17412
+ match,
17413
+ serializeObjectParam({
17414
+ explode,
17415
+ name,
17416
+ style,
17417
+ value,
17418
+ valueOnly: true
17419
+ })
17420
+ );
17421
+ continue;
17422
+ }
17423
+ if (style === "matrix") {
17424
+ url = url.replace(
17425
+ match,
17426
+ `;${serializePrimitiveParam({
17427
+ name,
17428
+ value
17429
+ })}`
17430
+ );
17431
+ continue;
17432
+ }
17433
+ const replaceValue = encodeURIComponent(
17434
+ style === "label" ? `.${value}` : value
17435
+ );
17436
+ url = url.replace(match, replaceValue);
17437
+ }
17438
+ }
17439
+ return url;
17440
+ };
17441
+ var createQuerySerializer = ({
17442
+ parameters = {},
17443
+ ...args
17444
+ } = {}) => {
17445
+ const querySerializer = (queryParams) => {
17446
+ const search = [];
17447
+ if (queryParams && typeof queryParams === "object") {
17448
+ for (const name in queryParams) {
17449
+ const value = queryParams[name];
17450
+ if (value === void 0 || value === null) {
17451
+ continue;
17452
+ }
17453
+ const options = parameters[name] || args;
17454
+ if (Array.isArray(value)) {
17455
+ const serializedArray = serializeArrayParam({
17456
+ allowReserved: options.allowReserved,
17457
+ explode: true,
17458
+ name,
17459
+ style: "form",
17460
+ value,
17461
+ ...options.array
17462
+ });
17463
+ if (serializedArray) search.push(serializedArray);
17464
+ } else if (typeof value === "object") {
17465
+ const serializedObject = serializeObjectParam({
17466
+ allowReserved: options.allowReserved,
17467
+ explode: true,
17468
+ name,
17469
+ style: "deepObject",
17470
+ value,
17471
+ ...options.object
17472
+ });
17473
+ if (serializedObject) search.push(serializedObject);
17474
+ } else {
17475
+ const serializedPrimitive = serializePrimitiveParam({
17476
+ allowReserved: options.allowReserved,
17477
+ name,
17478
+ value
17479
+ });
17480
+ if (serializedPrimitive) search.push(serializedPrimitive);
17481
+ }
17482
+ }
17483
+ }
17484
+ return search.join("&");
17485
+ };
17486
+ return querySerializer;
17487
+ };
17488
+ var getParseAs = (contentType) => {
17489
+ if (!contentType) {
17490
+ return "stream";
17491
+ }
17492
+ const cleanContent = contentType.split(";")[0]?.trim();
17493
+ if (!cleanContent) {
17494
+ return;
17495
+ }
17496
+ if (cleanContent.startsWith("application/json") || cleanContent.endsWith("+json")) {
17497
+ return "json";
17498
+ }
17499
+ if (cleanContent === "multipart/form-data") {
17500
+ return "formData";
17501
+ }
17502
+ if (["application/", "audio/", "image/", "video/"].some((type) => cleanContent.startsWith(type))) {
17503
+ return "blob";
17504
+ }
17505
+ if (cleanContent.startsWith("text/")) {
17506
+ return "text";
17507
+ }
17508
+ return;
17509
+ };
17510
+ var checkForExistence = (options, name) => {
17511
+ if (!name) {
17512
+ return false;
17513
+ }
17514
+ if (options.headers.has(name) || options.query?.[name] || options.headers.get("Cookie")?.includes(`${name}=`)) {
17515
+ return true;
17516
+ }
17517
+ return false;
17518
+ };
17519
+ async function setAuthParams(options) {
17520
+ for (const auth of options.security ?? []) {
17521
+ if (checkForExistence(options, auth.name)) {
17522
+ continue;
17523
+ }
17524
+ const token = await getAuthToken(auth, options.auth);
17525
+ if (!token) {
17526
+ continue;
17527
+ }
17528
+ const name = auth.name ?? "Authorization";
17529
+ switch (auth.in) {
17530
+ case "query":
17531
+ if (!options.query) {
17532
+ options.query = {};
17533
+ }
17534
+ options.query[name] = token;
17535
+ break;
17536
+ case "cookie":
17537
+ options.headers.append("Cookie", `${name}=${token}`);
17538
+ break;
17539
+ case "header":
17540
+ default:
17541
+ options.headers.set(name, token);
17542
+ break;
17543
+ }
17544
+ }
17545
+ }
17546
+ var buildUrl = (options) => {
17547
+ const url = getUrl({
17548
+ baseUrl: options.baseUrl,
17549
+ path: options.path,
17550
+ query: options.query,
17551
+ querySerializer: typeof options.querySerializer === "function" ? options.querySerializer : createQuerySerializer(options.querySerializer),
17552
+ url: options.url
17553
+ });
17554
+ return url;
17555
+ };
17556
+ var getUrl = ({
17557
+ baseUrl,
17558
+ path,
17559
+ query,
17560
+ querySerializer,
17561
+ url: _url
17562
+ }) => {
17563
+ const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
17564
+ let url = (baseUrl ?? "") + pathUrl;
17565
+ if (path) {
17566
+ url = defaultPathSerializer({ path, url });
17567
+ }
17568
+ let search = query ? querySerializer(query) : "";
17569
+ if (search.startsWith("?")) {
17570
+ search = search.substring(1);
17571
+ }
17572
+ if (search) {
17573
+ url += `?${search}`;
17574
+ }
17575
+ return url;
17576
+ };
17577
+ var mergeConfigs = (a, b) => {
17578
+ const config = { ...a, ...b };
17579
+ if (config.baseUrl?.endsWith("/")) {
17580
+ config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
17581
+ }
17582
+ config.headers = mergeHeaders(a.headers, b.headers);
17583
+ return config;
17584
+ };
17585
+ var headersEntries = (headers) => {
17586
+ const entries = [];
17587
+ headers.forEach((value, key) => {
17588
+ entries.push([key, value]);
17589
+ });
17590
+ return entries;
17591
+ };
17592
+ var mergeHeaders = (...headers) => {
17593
+ const mergedHeaders = new Headers();
17594
+ for (const header of headers) {
17595
+ if (!header || typeof header !== "object") {
17596
+ continue;
17597
+ }
17598
+ const iterator = header instanceof Headers ? headersEntries(header) : Object.entries(header);
17599
+ for (const [key, value] of iterator) {
17600
+ if (value === null) {
17601
+ mergedHeaders.delete(key);
17602
+ } else if (Array.isArray(value)) {
17603
+ for (const v of value) {
17604
+ mergedHeaders.append(key, v);
17605
+ }
17606
+ } else if (value !== void 0) {
17607
+ mergedHeaders.set(
17608
+ key,
17609
+ typeof value === "object" ? JSON.stringify(value) : value
17610
+ );
17611
+ }
17612
+ }
17613
+ }
17614
+ return mergedHeaders;
17615
+ };
17616
+ var Interceptors = class {
17617
+ constructor() {
17618
+ this.fns = [];
17619
+ }
17620
+ clear() {
17621
+ this.fns = [];
17622
+ }
17623
+ eject(id) {
17624
+ const index = this.getInterceptorIndex(id);
17625
+ if (this.fns[index]) {
17626
+ this.fns[index] = null;
17627
+ }
17628
+ }
17629
+ exists(id) {
17630
+ const index = this.getInterceptorIndex(id);
17631
+ return Boolean(this.fns[index]);
17632
+ }
17633
+ getInterceptorIndex(id) {
17634
+ if (typeof id === "number") {
17635
+ return this.fns[id] ? id : -1;
17636
+ }
17637
+ return this.fns.indexOf(id);
17638
+ }
17639
+ update(id, fn) {
17640
+ const index = this.getInterceptorIndex(id);
17641
+ if (this.fns[index]) {
17642
+ this.fns[index] = fn;
17643
+ return id;
17644
+ }
17645
+ return false;
17646
+ }
17647
+ use(fn) {
17648
+ this.fns.push(fn);
17649
+ return this.fns.length - 1;
17650
+ }
17651
+ };
17652
+ var createInterceptors = () => ({
17653
+ error: new Interceptors(),
17654
+ request: new Interceptors(),
17655
+ response: new Interceptors()
17656
+ });
17657
+ var defaultQuerySerializer = createQuerySerializer({
17658
+ allowReserved: false,
17659
+ array: {
17660
+ explode: true,
17661
+ style: "form"
17662
+ },
17663
+ object: {
17664
+ explode: true,
17665
+ style: "deepObject"
17666
+ }
17667
+ });
17668
+ var defaultHeaders = {
17669
+ "Content-Type": "application/json"
17670
+ };
17671
+ var createConfig = (override = {}) => ({
17672
+ ...jsonBodySerializer,
17673
+ headers: defaultHeaders,
17674
+ parseAs: "auto",
17675
+ querySerializer: defaultQuerySerializer,
17676
+ ...override
17677
+ });
17678
+
17679
+ // src/client/client/client.gen.ts
17680
+ var createClient = (config = {}) => {
17681
+ let _config = mergeConfigs(createConfig(), config);
17682
+ const getConfig = () => ({ ..._config });
17683
+ const setConfig = (config2) => {
17684
+ _config = mergeConfigs(_config, config2);
17685
+ return getConfig();
17686
+ };
17687
+ const interceptors = createInterceptors();
17688
+ const beforeRequest = async (options) => {
17689
+ const opts = {
17690
+ ..._config,
17691
+ ...options,
17692
+ fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
17693
+ headers: mergeHeaders(_config.headers, options.headers),
17694
+ serializedBody: void 0
17695
+ };
17696
+ if (opts.security) {
17697
+ await setAuthParams(opts);
17698
+ }
17699
+ if (opts.requestValidator) {
17700
+ await opts.requestValidator(opts);
17701
+ }
17702
+ if (opts.body !== void 0 && opts.bodySerializer) {
17703
+ opts.serializedBody = opts.bodySerializer(opts.body);
17704
+ }
17705
+ if (opts.body === void 0 || opts.serializedBody === "") {
17706
+ opts.headers.delete("Content-Type");
17707
+ }
17708
+ const resolvedOpts = opts;
17709
+ const url = buildUrl(resolvedOpts);
17710
+ return { opts: resolvedOpts, url };
17711
+ };
17712
+ const request = async (options) => {
17713
+ const throwOnError = options.throwOnError ?? _config.throwOnError;
17714
+ let response;
17715
+ try {
17716
+ const { opts, url } = await beforeRequest(options);
17717
+ for (const fn of interceptors.request.fns) {
17718
+ if (fn) {
17719
+ await fn(opts);
17720
+ }
17721
+ }
17722
+ const _fetch = opts.fetch;
17723
+ const requestInit = {
17724
+ ...opts,
17725
+ body: getValidRequestBody(opts)
17726
+ };
17727
+ response = await _fetch(url, requestInit);
17728
+ for (const fn of interceptors.response.fns) {
17729
+ if (fn) {
17730
+ response = await fn(response, opts);
17731
+ }
17732
+ }
17733
+ const result = {
17734
+ response
17735
+ };
17736
+ if (response.ok) {
17737
+ const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
17738
+ if (response.status === 204 || response.headers.get("Content-Length") === "0") {
17739
+ let emptyData;
17740
+ switch (parseAs) {
17741
+ case "arrayBuffer":
17742
+ case "blob":
17743
+ case "text":
17744
+ emptyData = await response[parseAs]();
17745
+ break;
17746
+ case "formData":
17747
+ emptyData = new FormData();
17748
+ break;
17749
+ case "stream":
17750
+ emptyData = response.body;
17751
+ break;
17752
+ case "json":
17753
+ default:
17754
+ emptyData = {};
17755
+ break;
17756
+ }
17757
+ return {
17758
+ data: emptyData,
17759
+ ...result
17760
+ };
17761
+ }
17762
+ let data;
17763
+ switch (parseAs) {
17764
+ case "arrayBuffer":
17765
+ case "blob":
17766
+ case "formData":
17767
+ case "text":
17768
+ data = await response[parseAs]();
17769
+ break;
17770
+ case "json": {
17771
+ const text = await response.text();
17772
+ data = text ? JSON.parse(text) : {};
17773
+ break;
17774
+ }
17775
+ case "stream":
17776
+ return {
17777
+ data: response.body,
17778
+ ...result
17779
+ };
17780
+ }
17781
+ if (parseAs === "json") {
17782
+ if (opts.responseValidator) {
17783
+ await opts.responseValidator(data);
17784
+ }
17785
+ if (opts.responseTransformer) {
17786
+ data = await opts.responseTransformer(data);
17787
+ }
17788
+ }
17789
+ return {
17790
+ data,
17791
+ ...result
17792
+ };
17793
+ }
17794
+ const textError = await response.text();
17795
+ let jsonError;
17796
+ try {
17797
+ jsonError = JSON.parse(textError);
17798
+ } catch {
17799
+ }
17800
+ throw jsonError ?? textError;
17801
+ } catch (error) {
17802
+ let finalError = error;
17803
+ for (const fn of interceptors.error.fns) {
17804
+ if (fn) {
17805
+ finalError = await fn(finalError, response, options);
17806
+ }
17807
+ }
17808
+ finalError = finalError || {};
17809
+ if (throwOnError) {
17810
+ throw finalError;
17811
+ }
17812
+ return {
17813
+ error: finalError,
17814
+ response
17815
+ };
17816
+ }
17817
+ };
17818
+ const makeMethodFn = (method) => (options) => request({ ...options, method });
17819
+ const makeSseFn = (method) => async (options) => {
17820
+ const { opts, url } = await beforeRequest(options);
17821
+ return createSseClient({
17822
+ ...opts,
17823
+ body: opts.body,
17824
+ method,
17825
+ onRequest: async (url2, init) => {
17826
+ let request2 = new Request(url2, init);
17827
+ const requestInit = { ...init, url: url2 };
17828
+ for (const fn of interceptors.request.fns) {
17829
+ if (fn) {
17830
+ await fn(requestInit);
17831
+ request2 = new Request(requestInit.url, requestInit);
17832
+ }
17833
+ }
17834
+ return request2;
17835
+ },
17836
+ serializedBody: getValidRequestBody(opts),
17837
+ url
17838
+ });
17839
+ };
17840
+ const _buildUrl = (options) => buildUrl({ ..._config, ...options });
17841
+ return {
17842
+ buildUrl: _buildUrl,
17843
+ connect: makeMethodFn("CONNECT"),
17844
+ delete: makeMethodFn("DELETE"),
17845
+ get: makeMethodFn("GET"),
17846
+ getConfig,
17847
+ head: makeMethodFn("HEAD"),
17848
+ interceptors,
17849
+ options: makeMethodFn("OPTIONS"),
17850
+ patch: makeMethodFn("PATCH"),
17851
+ post: makeMethodFn("POST"),
17852
+ put: makeMethodFn("PUT"),
17853
+ request,
17854
+ setConfig,
17855
+ sse: {
17856
+ connect: makeSseFn("CONNECT"),
17857
+ delete: makeSseFn("DELETE"),
17858
+ get: makeSseFn("GET"),
17859
+ head: makeSseFn("HEAD"),
17860
+ options: makeSseFn("OPTIONS"),
17861
+ patch: makeSseFn("PATCH"),
17862
+ post: makeSseFn("POST"),
17863
+ put: makeSseFn("PUT"),
17864
+ trace: makeSseFn("TRACE")
17865
+ },
17866
+ trace: makeMethodFn("TRACE")
17867
+ };
17868
+ };
17869
+
17870
+ // src/client/client.gen.ts
17871
+ var client = createClient(createClientConfig(createConfig()));
17872
+
17873
+ // src/client/sdk.gen.ts
17874
+ var postApiV1Embeddings = (options) => (options.client ?? client).post({
17875
+ url: "/api/v1/embeddings",
17876
+ ...options,
17877
+ headers: {
17878
+ "Content-Type": "application/json",
17879
+ ...options.headers
17880
+ }
17881
+ });
17882
+
17092
17883
  // src/lib/memoryEngine/generate.ts
17093
- import { postApiV1Embeddings } from "@anuma/sdk";
17094
17884
  var EMBED_MAX_ATTEMPTS = 4;
17095
17885
  async function withEmbeddingRetry(call) {
17096
17886
  let last;
@@ -18764,7 +19554,7 @@ function createMemoryVaultSearchTool(vaultCtx, embeddingOptions, cache, searchOp
18764
19554
  legacy.map((r) => ({ id: r.uniqueId, content: r.content, score: r.similarity }))
18765
19555
  );
18766
19556
  }
18767
- const { recall: recall2 } = await import("./recall-IWY2MYHR.mjs");
19557
+ const { recall: recall2 } = await import("./recall-XEOLXA6P.mjs");
18768
19558
  const result = await recall2(
18769
19559
  query,
18770
19560
  { vaultCtx, embeddingOptions, vaultCache: cache },
@@ -19738,6 +20528,7 @@ export {
19738
20528
  chunkText,
19739
20529
  shouldChunkMessage,
19740
20530
  DEFAULT_API_EMBEDDING_MODEL,
20531
+ createSseClient,
19741
20532
  generateEmbedding,
19742
20533
  generateEmbeddings,
19743
20534
  embedMessage,