@anuma/sdk 3.3.0 → 3.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/index.cjs +793 -1420
- package/dist/client/index.d.mts +406 -402
- package/dist/client/index.d.ts +406 -402
- package/dist/client/index.mjs +793 -1420
- package/dist/expo/{chunk-NMZMXIUM.mjs → chunk-EIHIZ5L4.mjs} +4 -1
- package/dist/expo/index.cjs +120 -153
- package/dist/expo/index.mjs +118 -154
- package/dist/expo/{recall-7FUJRHOI.mjs → recall-C3LJ5R2E.mjs} +1 -1
- package/dist/index.cjs +453 -783
- package/dist/index.d.mts +491 -487
- package/dist/index.d.ts +491 -487
- package/dist/index.mjs +453 -783
- package/dist/react/{chunk-GZRK43CA.mjs → chunk-PWTWECXY.mjs} +4 -1
- package/dist/react/index.cjs +191 -275
- package/dist/react/index.d.mts +380 -376
- package/dist/react/index.d.ts +380 -376
- package/dist/react/index.mjs +189 -276
- package/dist/react/{recall-YZGWZC5W.mjs → recall-FZVV5XUU.mjs} +1 -1
- package/dist/server/{chunk-NVTMJWFA.mjs → chunk-J5QZOPUI.mjs} +4 -1
- package/dist/server/index.cjs +10 -15
- package/dist/server/index.mjs +8 -16
- package/dist/server/{recall-76WPPKLR.mjs → recall-NNBMWRLB.mjs} +1 -1
- package/dist/tools/selection/index.cjs +3 -0
- package/dist/tools/selection/index.mjs +3 -0
- package/package.json +2 -2
|
@@ -2912,6 +2912,9 @@ async function withEmbeddingRetry(call) {
|
|
|
2912
2912
|
}
|
|
2913
2913
|
}
|
|
2914
2914
|
if (threw) throw lastThrown;
|
|
2915
|
+
if (last?.error instanceof Error && last.response?.status === void 0) {
|
|
2916
|
+
throw last.error;
|
|
2917
|
+
}
|
|
2915
2918
|
return last;
|
|
2916
2919
|
}
|
|
2917
2920
|
var EmbeddingHttpError = class extends Error {
|
|
@@ -4507,7 +4510,7 @@ function createMemoryVaultSearchTool(vaultCtx, embeddingOptions, cache, searchOp
|
|
|
4507
4510
|
legacy.map((r) => ({ id: r.uniqueId, content: r.content, score: r.similarity }))
|
|
4508
4511
|
);
|
|
4509
4512
|
}
|
|
4510
|
-
const { recall: recall2 } = await import("./recall-
|
|
4513
|
+
const { recall: recall2 } = await import("./recall-C3LJ5R2E.mjs");
|
|
4511
4514
|
const result = await recall2(
|
|
4512
4515
|
query,
|
|
4513
4516
|
{ vaultCtx, embeddingOptions, vaultCache: cache },
|
package/dist/expo/index.cjs
CHANGED
|
@@ -2103,6 +2103,9 @@ async function withEmbeddingRetry(call) {
|
|
|
2103
2103
|
}
|
|
2104
2104
|
}
|
|
2105
2105
|
if (threw) throw lastThrown;
|
|
2106
|
+
if (last?.error instanceof Error && last.response?.status === void 0) {
|
|
2107
|
+
throw last.error;
|
|
2108
|
+
}
|
|
2106
2109
|
return last;
|
|
2107
2110
|
}
|
|
2108
2111
|
function isFatalEmbeddingError(err) {
|
|
@@ -7022,7 +7025,7 @@ function createWebSearchPreProcessor(options = {}) {
|
|
|
7022
7025
|
init_clientConfig();
|
|
7023
7026
|
|
|
7024
7027
|
// src/client/core/serverSentEvents.gen.ts
|
|
7025
|
-
|
|
7028
|
+
function createSseClient({
|
|
7026
7029
|
onRequest,
|
|
7027
7030
|
onSseError,
|
|
7028
7031
|
onSseEvent,
|
|
@@ -7034,7 +7037,7 @@ var createSseClient = ({
|
|
|
7034
7037
|
sseSleepFn,
|
|
7035
7038
|
url,
|
|
7036
7039
|
...options
|
|
7037
|
-
})
|
|
7040
|
+
}) {
|
|
7038
7041
|
let lastEventId;
|
|
7039
7042
|
const sleep4 = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
7040
7043
|
const createStream = async function* () {
|
|
@@ -7062,10 +7065,7 @@ var createSseClient = ({
|
|
|
7062
7065
|
}
|
|
7063
7066
|
const _fetch = options.fetch ?? globalThis.fetch;
|
|
7064
7067
|
const response = await _fetch(request);
|
|
7065
|
-
if (!response.ok)
|
|
7066
|
-
throw new Error(
|
|
7067
|
-
`SSE failed: ${response.status} ${response.statusText}`
|
|
7068
|
-
);
|
|
7068
|
+
if (!response.ok) throw new Error(`SSE failed: ${response.status} ${response.statusText}`);
|
|
7069
7069
|
if (!response.body) throw new Error("No body in SSE response");
|
|
7070
7070
|
const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
|
|
7071
7071
|
let buffer = "";
|
|
@@ -7081,6 +7081,7 @@ var createSseClient = ({
|
|
|
7081
7081
|
const { done, value } = await reader.read();
|
|
7082
7082
|
if (done) break;
|
|
7083
7083
|
buffer += value;
|
|
7084
|
+
buffer = buffer.replace(/\r\n?/g, "\n");
|
|
7084
7085
|
const chunks = buffer.split("\n\n");
|
|
7085
7086
|
buffer = chunks.pop() ?? "";
|
|
7086
7087
|
for (const chunk of chunks) {
|
|
@@ -7095,10 +7096,7 @@ var createSseClient = ({
|
|
|
7095
7096
|
} else if (line.startsWith("id:")) {
|
|
7096
7097
|
lastEventId = line.replace(/^id:\s*/, "");
|
|
7097
7098
|
} else if (line.startsWith("retry:")) {
|
|
7098
|
-
const parsed = Number.parseInt(
|
|
7099
|
-
line.replace(/^retry:\s*/, ""),
|
|
7100
|
-
10
|
|
7101
|
-
);
|
|
7099
|
+
const parsed = Number.parseInt(line.replace(/^retry:\s*/, ""), 10);
|
|
7102
7100
|
if (!Number.isNaN(parsed)) {
|
|
7103
7101
|
retryDelay = parsed;
|
|
7104
7102
|
}
|
|
@@ -7144,17 +7142,14 @@ var createSseClient = ({
|
|
|
7144
7142
|
if (sseMaxRetryAttempts !== void 0 && attempt >= sseMaxRetryAttempts) {
|
|
7145
7143
|
break;
|
|
7146
7144
|
}
|
|
7147
|
-
const backoff = Math.min(
|
|
7148
|
-
retryDelay * 2 ** (attempt - 1),
|
|
7149
|
-
sseMaxRetryDelay ?? 3e4
|
|
7150
|
-
);
|
|
7145
|
+
const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 3e4);
|
|
7151
7146
|
await sleep4(backoff);
|
|
7152
7147
|
}
|
|
7153
7148
|
}
|
|
7154
7149
|
};
|
|
7155
7150
|
const stream = createStream();
|
|
7156
7151
|
return { stream };
|
|
7157
|
-
}
|
|
7152
|
+
}
|
|
7158
7153
|
|
|
7159
7154
|
// src/lib/chat/toolLoop.ts
|
|
7160
7155
|
init_clientConfig();
|
|
@@ -10613,10 +10608,7 @@ var import_react = require("react");
|
|
|
10613
10608
|
|
|
10614
10609
|
// src/client/core/bodySerializer.gen.ts
|
|
10615
10610
|
var jsonBodySerializer = {
|
|
10616
|
-
bodySerializer: (body) => JSON.stringify(
|
|
10617
|
-
body,
|
|
10618
|
-
(_key, value) => typeof value === "bigint" ? value.toString() : value
|
|
10619
|
-
)
|
|
10611
|
+
bodySerializer: (body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value)
|
|
10620
10612
|
};
|
|
10621
10613
|
|
|
10622
10614
|
// src/client/core/pathSerializer.gen.ts
|
|
@@ -10718,11 +10710,7 @@ var serializeObjectParam = ({
|
|
|
10718
10710
|
if (style !== "deepObject" && !explode) {
|
|
10719
10711
|
let values = [];
|
|
10720
10712
|
Object.entries(value).forEach(([key, v]) => {
|
|
10721
|
-
values = [
|
|
10722
|
-
...values,
|
|
10723
|
-
key,
|
|
10724
|
-
allowReserved ? v : encodeURIComponent(v)
|
|
10725
|
-
];
|
|
10713
|
+
values = [...values, key, allowReserved ? v : encodeURIComponent(v)];
|
|
10726
10714
|
});
|
|
10727
10715
|
const joinedValues2 = values.join(",");
|
|
10728
10716
|
switch (style) {
|
|
@@ -10805,10 +10793,7 @@ var defaultPathSerializer = ({ path, url: _url }) => {
|
|
|
10805
10793
|
continue;
|
|
10806
10794
|
}
|
|
10807
10795
|
if (Array.isArray(value)) {
|
|
10808
|
-
url = url.replace(
|
|
10809
|
-
match,
|
|
10810
|
-
serializeArrayParam({ explode, name, style, value })
|
|
10811
|
-
);
|
|
10796
|
+
url = url.replace(match, serializeArrayParam({ explode, name, style, value }));
|
|
10812
10797
|
continue;
|
|
10813
10798
|
}
|
|
10814
10799
|
if (typeof value === "object") {
|
|
@@ -10903,9 +10888,7 @@ var getParseAs = (contentType) => {
|
|
|
10903
10888
|
if (cleanContent === "multipart/form-data") {
|
|
10904
10889
|
return "formData";
|
|
10905
10890
|
}
|
|
10906
|
-
if (["application/", "audio/", "image/", "video/"].some(
|
|
10907
|
-
(type) => cleanContent.startsWith(type)
|
|
10908
|
-
)) {
|
|
10891
|
+
if (["application/", "audio/", "image/", "video/"].some((type) => cleanContent.startsWith(type))) {
|
|
10909
10892
|
return "blob";
|
|
10910
10893
|
}
|
|
10911
10894
|
if (cleanContent.startsWith("text/")) {
|
|
@@ -10922,11 +10905,8 @@ var checkForExistence = (options, name) => {
|
|
|
10922
10905
|
}
|
|
10923
10906
|
return false;
|
|
10924
10907
|
};
|
|
10925
|
-
|
|
10926
|
-
security
|
|
10927
|
-
...options
|
|
10928
|
-
}) => {
|
|
10929
|
-
for (const auth of security) {
|
|
10908
|
+
async function setAuthParams(options) {
|
|
10909
|
+
for (const auth of options.security ?? []) {
|
|
10930
10910
|
if (checkForExistence(options, auth.name)) {
|
|
10931
10911
|
continue;
|
|
10932
10912
|
}
|
|
@@ -10951,7 +10931,7 @@ var setAuthParams = async ({
|
|
|
10951
10931
|
break;
|
|
10952
10932
|
}
|
|
10953
10933
|
}
|
|
10954
|
-
}
|
|
10934
|
+
}
|
|
10955
10935
|
var buildUrl = (options) => {
|
|
10956
10936
|
const url = getUrl({
|
|
10957
10937
|
baseUrl: options.baseUrl,
|
|
@@ -11103,10 +11083,7 @@ var createClient = (config = {}) => {
|
|
|
11103
11083
|
serializedBody: void 0
|
|
11104
11084
|
};
|
|
11105
11085
|
if (opts.security) {
|
|
11106
|
-
await setAuthParams(
|
|
11107
|
-
...opts,
|
|
11108
|
-
security: opts.security
|
|
11109
|
-
});
|
|
11086
|
+
await setAuthParams(opts);
|
|
11110
11087
|
}
|
|
11111
11088
|
if (opts.requestValidator) {
|
|
11112
11089
|
await opts.requestValidator(opts);
|
|
@@ -11117,105 +11094,115 @@ var createClient = (config = {}) => {
|
|
|
11117
11094
|
if (opts.body === void 0 || opts.serializedBody === "") {
|
|
11118
11095
|
opts.headers.delete("Content-Type");
|
|
11119
11096
|
}
|
|
11120
|
-
const
|
|
11121
|
-
|
|
11097
|
+
const resolvedOpts = opts;
|
|
11098
|
+
const url = buildUrl(resolvedOpts);
|
|
11099
|
+
return { opts: resolvedOpts, url };
|
|
11122
11100
|
};
|
|
11123
11101
|
const request = async (options) => {
|
|
11124
|
-
const
|
|
11125
|
-
|
|
11126
|
-
|
|
11127
|
-
|
|
11102
|
+
const throwOnError = options.throwOnError ?? _config.throwOnError;
|
|
11103
|
+
let response;
|
|
11104
|
+
try {
|
|
11105
|
+
const { opts, url } = await beforeRequest(options);
|
|
11106
|
+
for (const fn of interceptors.request.fns) {
|
|
11107
|
+
if (fn) {
|
|
11108
|
+
await fn(opts);
|
|
11109
|
+
}
|
|
11128
11110
|
}
|
|
11129
|
-
|
|
11130
|
-
|
|
11131
|
-
|
|
11132
|
-
|
|
11133
|
-
|
|
11134
|
-
|
|
11135
|
-
|
|
11136
|
-
|
|
11137
|
-
|
|
11138
|
-
|
|
11111
|
+
const _fetch = opts.fetch;
|
|
11112
|
+
const requestInit = {
|
|
11113
|
+
...opts,
|
|
11114
|
+
body: getValidRequestBody(opts)
|
|
11115
|
+
};
|
|
11116
|
+
response = await _fetch(url, requestInit);
|
|
11117
|
+
for (const fn of interceptors.response.fns) {
|
|
11118
|
+
if (fn) {
|
|
11119
|
+
response = await fn(response, opts);
|
|
11120
|
+
}
|
|
11139
11121
|
}
|
|
11140
|
-
|
|
11141
|
-
|
|
11142
|
-
|
|
11143
|
-
|
|
11144
|
-
|
|
11145
|
-
|
|
11146
|
-
|
|
11147
|
-
|
|
11122
|
+
const result = {
|
|
11123
|
+
response
|
|
11124
|
+
};
|
|
11125
|
+
if (response.ok) {
|
|
11126
|
+
const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
|
|
11127
|
+
if (response.status === 204 || response.headers.get("Content-Length") === "0") {
|
|
11128
|
+
let emptyData;
|
|
11129
|
+
switch (parseAs) {
|
|
11130
|
+
case "arrayBuffer":
|
|
11131
|
+
case "blob":
|
|
11132
|
+
case "text":
|
|
11133
|
+
emptyData = await response[parseAs]();
|
|
11134
|
+
break;
|
|
11135
|
+
case "formData":
|
|
11136
|
+
emptyData = new FormData();
|
|
11137
|
+
break;
|
|
11138
|
+
case "stream":
|
|
11139
|
+
emptyData = response.body;
|
|
11140
|
+
break;
|
|
11141
|
+
case "json":
|
|
11142
|
+
default:
|
|
11143
|
+
emptyData = {};
|
|
11144
|
+
break;
|
|
11145
|
+
}
|
|
11146
|
+
return {
|
|
11147
|
+
data: emptyData,
|
|
11148
|
+
...result
|
|
11149
|
+
};
|
|
11150
|
+
}
|
|
11151
|
+
let data;
|
|
11148
11152
|
switch (parseAs) {
|
|
11149
11153
|
case "arrayBuffer":
|
|
11150
11154
|
case "blob":
|
|
11155
|
+
case "formData":
|
|
11151
11156
|
case "text":
|
|
11152
|
-
|
|
11157
|
+
data = await response[parseAs]();
|
|
11153
11158
|
break;
|
|
11154
|
-
case "
|
|
11155
|
-
|
|
11159
|
+
case "json": {
|
|
11160
|
+
const text12 = await response.text();
|
|
11161
|
+
data = text12 ? JSON.parse(text12) : {};
|
|
11156
11162
|
break;
|
|
11163
|
+
}
|
|
11157
11164
|
case "stream":
|
|
11158
|
-
|
|
11159
|
-
|
|
11160
|
-
|
|
11161
|
-
|
|
11162
|
-
|
|
11163
|
-
|
|
11165
|
+
return {
|
|
11166
|
+
data: response.body,
|
|
11167
|
+
...result
|
|
11168
|
+
};
|
|
11169
|
+
}
|
|
11170
|
+
if (parseAs === "json") {
|
|
11171
|
+
if (opts.responseValidator) {
|
|
11172
|
+
await opts.responseValidator(data);
|
|
11173
|
+
}
|
|
11174
|
+
if (opts.responseTransformer) {
|
|
11175
|
+
data = await opts.responseTransformer(data);
|
|
11176
|
+
}
|
|
11164
11177
|
}
|
|
11165
11178
|
return {
|
|
11166
|
-
data
|
|
11179
|
+
data,
|
|
11167
11180
|
...result
|
|
11168
11181
|
};
|
|
11169
11182
|
}
|
|
11170
|
-
|
|
11171
|
-
|
|
11172
|
-
|
|
11173
|
-
|
|
11174
|
-
|
|
11175
|
-
case "json":
|
|
11176
|
-
case "text":
|
|
11177
|
-
data = await response[parseAs]();
|
|
11178
|
-
break;
|
|
11179
|
-
case "stream":
|
|
11180
|
-
return {
|
|
11181
|
-
data: response.body,
|
|
11182
|
-
...result
|
|
11183
|
-
};
|
|
11183
|
+
const textError = await response.text();
|
|
11184
|
+
let jsonError;
|
|
11185
|
+
try {
|
|
11186
|
+
jsonError = JSON.parse(textError);
|
|
11187
|
+
} catch {
|
|
11184
11188
|
}
|
|
11185
|
-
|
|
11186
|
-
|
|
11187
|
-
|
|
11188
|
-
|
|
11189
|
-
if (
|
|
11190
|
-
|
|
11189
|
+
throw jsonError ?? textError;
|
|
11190
|
+
} catch (error) {
|
|
11191
|
+
let finalError = error;
|
|
11192
|
+
for (const fn of interceptors.error.fns) {
|
|
11193
|
+
if (fn) {
|
|
11194
|
+
finalError = await fn(finalError, response, options);
|
|
11191
11195
|
}
|
|
11192
11196
|
}
|
|
11197
|
+
finalError = finalError || {};
|
|
11198
|
+
if (throwOnError) {
|
|
11199
|
+
throw finalError;
|
|
11200
|
+
}
|
|
11193
11201
|
return {
|
|
11194
|
-
|
|
11195
|
-
|
|
11202
|
+
error: finalError,
|
|
11203
|
+
response
|
|
11196
11204
|
};
|
|
11197
11205
|
}
|
|
11198
|
-
const textError = await response.text();
|
|
11199
|
-
let jsonError;
|
|
11200
|
-
try {
|
|
11201
|
-
jsonError = JSON.parse(textError);
|
|
11202
|
-
} catch {
|
|
11203
|
-
}
|
|
11204
|
-
const error = jsonError ?? textError;
|
|
11205
|
-
let finalError = error;
|
|
11206
|
-
for (const fn of interceptors.error.fns) {
|
|
11207
|
-
if (fn) {
|
|
11208
|
-
finalError = await fn(error, response, opts);
|
|
11209
|
-
}
|
|
11210
|
-
}
|
|
11211
|
-
finalError = finalError || {};
|
|
11212
|
-
if (opts.throwOnError) {
|
|
11213
|
-
throw finalError;
|
|
11214
|
-
}
|
|
11215
|
-
return {
|
|
11216
|
-
error: finalError,
|
|
11217
|
-
...result
|
|
11218
|
-
};
|
|
11219
11206
|
};
|
|
11220
11207
|
const makeMethodFn = (method) => (options) => request({ ...options, method });
|
|
11221
11208
|
const makeSseFn = (method) => async (options) => {
|
|
@@ -11223,15 +11210,10 @@ var createClient = (config = {}) => {
|
|
|
11223
11210
|
return createSseClient({
|
|
11224
11211
|
...opts,
|
|
11225
11212
|
body: opts.body,
|
|
11226
|
-
headers: opts.headers,
|
|
11227
11213
|
method,
|
|
11228
11214
|
onRequest: async (url2, init) => {
|
|
11229
11215
|
let request2 = new Request(url2, init);
|
|
11230
|
-
const requestInit = {
|
|
11231
|
-
...init,
|
|
11232
|
-
method: init.method,
|
|
11233
|
-
url: url2
|
|
11234
|
-
};
|
|
11216
|
+
const requestInit = { ...init, url: url2 };
|
|
11235
11217
|
for (const fn of interceptors.request.fns) {
|
|
11236
11218
|
if (fn) {
|
|
11237
11219
|
await fn(requestInit);
|
|
@@ -11240,11 +11222,13 @@ var createClient = (config = {}) => {
|
|
|
11240
11222
|
}
|
|
11241
11223
|
return request2;
|
|
11242
11224
|
},
|
|
11225
|
+
serializedBody: getValidRequestBody(opts),
|
|
11243
11226
|
url
|
|
11244
11227
|
});
|
|
11245
11228
|
};
|
|
11229
|
+
const _buildUrl = (options) => buildUrl({ ..._config, ...options });
|
|
11246
11230
|
return {
|
|
11247
|
-
buildUrl,
|
|
11231
|
+
buildUrl: _buildUrl,
|
|
11248
11232
|
connect: makeMethodFn("CONNECT"),
|
|
11249
11233
|
delete: makeMethodFn("DELETE"),
|
|
11250
11234
|
get: makeMethodFn("GET"),
|
|
@@ -11277,34 +11261,17 @@ init_clientConfig();
|
|
|
11277
11261
|
var client = createClient(createClientConfig(createConfig()));
|
|
11278
11262
|
|
|
11279
11263
|
// src/client/sdk.gen.ts
|
|
11280
|
-
var getApiV1CreditsBalance = (options) => {
|
|
11281
|
-
|
|
11282
|
-
|
|
11283
|
-
|
|
11284
|
-
|
|
11285
|
-
|
|
11286
|
-
|
|
11287
|
-
|
|
11288
|
-
|
|
11289
|
-
|
|
11290
|
-
|
|
11291
|
-
};
|
|
11292
|
-
var postApiV1CreditsPurchase = (options) => {
|
|
11293
|
-
return (options.client ?? client).post({
|
|
11294
|
-
url: "/api/v1/credits/purchase",
|
|
11295
|
-
...options,
|
|
11296
|
-
headers: {
|
|
11297
|
-
"Content-Type": "application/json",
|
|
11298
|
-
...options.headers
|
|
11299
|
-
}
|
|
11300
|
-
});
|
|
11301
|
-
};
|
|
11302
|
-
var getApiV1Models = (options) => {
|
|
11303
|
-
return (options?.client ?? client).get({
|
|
11304
|
-
url: "/api/v1/models",
|
|
11305
|
-
...options
|
|
11306
|
-
});
|
|
11307
|
-
};
|
|
11264
|
+
var getApiV1CreditsBalance = (options) => (options?.client ?? client).get({ url: "/api/v1/credits/balance", ...options });
|
|
11265
|
+
var getApiV1CreditsPacks = (options) => (options?.client ?? client).get({ url: "/api/v1/credits/packs", ...options });
|
|
11266
|
+
var postApiV1CreditsPurchase = (options) => (options.client ?? client).post({
|
|
11267
|
+
url: "/api/v1/credits/purchase",
|
|
11268
|
+
...options,
|
|
11269
|
+
headers: {
|
|
11270
|
+
"Content-Type": "application/json",
|
|
11271
|
+
...options.headers
|
|
11272
|
+
}
|
|
11273
|
+
});
|
|
11274
|
+
var getApiV1Models = (options) => (options?.client ?? client).get({ url: "/api/v1/models", ...options });
|
|
11308
11275
|
|
|
11309
11276
|
// src/react/useCredits.ts
|
|
11310
11277
|
init_clientConfig();
|