@anuma/sdk 3.0.0 → 3.1.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/expo/{chunk-IY7NNIYM.mjs → chunk-IP2B74KE.mjs} +30 -866
- package/dist/expo/index.cjs +1658 -1070
- package/dist/expo/index.d.mts +179 -10
- package/dist/expo/index.d.ts +179 -10
- package/dist/expo/index.mjs +1563 -77
- package/dist/expo/{recall-DJ5LD5WJ.mjs → recall-NSSIYFNY.mjs} +1 -1
- package/dist/index.cjs +415 -394
- package/dist/index.mjs +412 -391
- package/dist/react/{chunk-OSDVRDLI.mjs → chunk-XVC7DWDN.mjs} +22 -1003
- package/dist/react/index.cjs +1702 -1731
- package/dist/react/index.d.mts +103 -12
- package/dist/react/index.d.ts +103 -12
- package/dist/react/index.mjs +1216 -228
- package/dist/react/{recall-3BDCIEQF.mjs → recall-VDP3H3QT.mjs} +1 -1
- package/dist/server/{chunk-QQOIC37O.mjs → chunk-4GKKHVF7.mjs} +21 -833
- package/dist/server/index.cjs +244 -966
- package/dist/server/index.d.mts +95 -12
- package/dist/server/index.d.ts +95 -12
- package/dist/server/index.mjs +189 -32
- package/dist/server/{recall-6QLUEYB7.mjs → recall-KYSR3XZJ.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
|
|
@@ -16703,27 +16702,25 @@ async function stampTopicsExtractedAtOp(ctx, memoryIds, extractedAt, version = T
|
|
|
16703
16702
|
for (let i = 0; i < uniqueIds.length; i += CHUNK) {
|
|
16704
16703
|
const chunkIds = uniqueIds.slice(i, i + CHUNK);
|
|
16705
16704
|
await ctx.database.write(async () => {
|
|
16706
|
-
const
|
|
16705
|
+
const records = [];
|
|
16707
16706
|
for (const id of chunkIds) {
|
|
16708
|
-
let record;
|
|
16709
16707
|
try {
|
|
16710
|
-
|
|
16708
|
+
records.push(await ctx.vaultMemoryCollection.find(id));
|
|
16711
16709
|
} catch {
|
|
16712
|
-
continue;
|
|
16713
|
-
}
|
|
16714
|
-
if (record.isDeleted || !isOwnedByCtxUser(ctx, record) || record.topicsUserManaged) {
|
|
16715
|
-
continue;
|
|
16716
16710
|
}
|
|
16717
|
-
const originalUpdatedAt = record.updatedAt.getTime();
|
|
16718
|
-
prepared.push(
|
|
16719
|
-
record.prepareUpdate((r) => {
|
|
16720
|
-
r._setRaw("topics_extracted_at", extractedAt);
|
|
16721
|
-
r._setRaw("topics_extracted_version", version);
|
|
16722
|
-
r._setRaw("updated_at", originalUpdatedAt);
|
|
16723
|
-
})
|
|
16724
|
-
);
|
|
16725
|
-
stamped.push(id);
|
|
16726
16711
|
}
|
|
16712
|
+
const eligible = records.filter(
|
|
16713
|
+
(record) => !record.isDeleted && isOwnedByCtxUser(ctx, record) && !record.topicsUserManaged
|
|
16714
|
+
);
|
|
16715
|
+
const prepared = eligible.map((record) => {
|
|
16716
|
+
const originalUpdatedAt = record.updatedAt.getTime();
|
|
16717
|
+
return record.prepareUpdate((r) => {
|
|
16718
|
+
r._setRaw("topics_extracted_at", extractedAt);
|
|
16719
|
+
r._setRaw("topics_extracted_version", version);
|
|
16720
|
+
r._setRaw("updated_at", originalUpdatedAt);
|
|
16721
|
+
});
|
|
16722
|
+
});
|
|
16723
|
+
for (const record of eligible) stamped.push(record.id);
|
|
16727
16724
|
if (prepared.length > 0) await ctx.database.batch(...prepared);
|
|
16728
16725
|
});
|
|
16729
16726
|
}
|
|
@@ -16775,817 +16772,6 @@ async function updateVaultMemoryEmbeddingOp(ctx, id, embedding, embeddingModel)
|
|
|
16775
16772
|
// src/lib/memoryEngine/constants.ts
|
|
16776
16773
|
var DEFAULT_API_EMBEDDING_MODEL = "qwen/qwen3-embedding-8b";
|
|
16777
16774
|
|
|
16778
|
-
// src/client/core/bodySerializer.gen.ts
|
|
16779
|
-
var jsonBodySerializer = {
|
|
16780
|
-
bodySerializer: (body) => JSON.stringify(
|
|
16781
|
-
body,
|
|
16782
|
-
(_key, value) => typeof value === "bigint" ? value.toString() : value
|
|
16783
|
-
)
|
|
16784
|
-
};
|
|
16785
|
-
|
|
16786
|
-
// src/client/core/serverSentEvents.gen.ts
|
|
16787
|
-
var createSseClient = ({
|
|
16788
|
-
onRequest,
|
|
16789
|
-
onSseError,
|
|
16790
|
-
onSseEvent,
|
|
16791
|
-
responseTransformer,
|
|
16792
|
-
responseValidator,
|
|
16793
|
-
sseDefaultRetryDelay,
|
|
16794
|
-
sseMaxRetryAttempts,
|
|
16795
|
-
sseMaxRetryDelay,
|
|
16796
|
-
sseSleepFn,
|
|
16797
|
-
url,
|
|
16798
|
-
...options
|
|
16799
|
-
}) => {
|
|
16800
|
-
let lastEventId;
|
|
16801
|
-
const sleep = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
16802
|
-
const createStream = async function* () {
|
|
16803
|
-
let retryDelay = sseDefaultRetryDelay ?? 3e3;
|
|
16804
|
-
let attempt = 0;
|
|
16805
|
-
const signal = options.signal ?? new AbortController().signal;
|
|
16806
|
-
while (true) {
|
|
16807
|
-
if (signal.aborted) break;
|
|
16808
|
-
attempt++;
|
|
16809
|
-
const headers = options.headers instanceof Headers ? options.headers : new Headers(options.headers);
|
|
16810
|
-
if (lastEventId !== void 0) {
|
|
16811
|
-
headers.set("Last-Event-ID", lastEventId);
|
|
16812
|
-
}
|
|
16813
|
-
try {
|
|
16814
|
-
const requestInit = {
|
|
16815
|
-
redirect: "follow",
|
|
16816
|
-
...options,
|
|
16817
|
-
body: options.serializedBody,
|
|
16818
|
-
headers,
|
|
16819
|
-
signal
|
|
16820
|
-
};
|
|
16821
|
-
let request = new Request(url, requestInit);
|
|
16822
|
-
if (onRequest) {
|
|
16823
|
-
request = await onRequest(url, requestInit);
|
|
16824
|
-
}
|
|
16825
|
-
const _fetch = options.fetch ?? globalThis.fetch;
|
|
16826
|
-
const response = await _fetch(request);
|
|
16827
|
-
if (!response.ok)
|
|
16828
|
-
throw new Error(
|
|
16829
|
-
`SSE failed: ${response.status} ${response.statusText}`
|
|
16830
|
-
);
|
|
16831
|
-
if (!response.body) throw new Error("No body in SSE response");
|
|
16832
|
-
const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
|
|
16833
|
-
let buffer = "";
|
|
16834
|
-
const abortHandler = () => {
|
|
16835
|
-
try {
|
|
16836
|
-
reader.cancel();
|
|
16837
|
-
} catch {
|
|
16838
|
-
}
|
|
16839
|
-
};
|
|
16840
|
-
signal.addEventListener("abort", abortHandler);
|
|
16841
|
-
try {
|
|
16842
|
-
while (true) {
|
|
16843
|
-
const { done, value } = await reader.read();
|
|
16844
|
-
if (done) break;
|
|
16845
|
-
buffer += value;
|
|
16846
|
-
const chunks = buffer.split("\n\n");
|
|
16847
|
-
buffer = chunks.pop() ?? "";
|
|
16848
|
-
for (const chunk of chunks) {
|
|
16849
|
-
const lines = chunk.split("\n");
|
|
16850
|
-
const dataLines = [];
|
|
16851
|
-
let eventName;
|
|
16852
|
-
for (const line of lines) {
|
|
16853
|
-
if (line.startsWith("data:")) {
|
|
16854
|
-
dataLines.push(line.replace(/^data:\s*/, ""));
|
|
16855
|
-
} else if (line.startsWith("event:")) {
|
|
16856
|
-
eventName = line.replace(/^event:\s*/, "");
|
|
16857
|
-
} else if (line.startsWith("id:")) {
|
|
16858
|
-
lastEventId = line.replace(/^id:\s*/, "");
|
|
16859
|
-
} else if (line.startsWith("retry:")) {
|
|
16860
|
-
const parsed = Number.parseInt(
|
|
16861
|
-
line.replace(/^retry:\s*/, ""),
|
|
16862
|
-
10
|
|
16863
|
-
);
|
|
16864
|
-
if (!Number.isNaN(parsed)) {
|
|
16865
|
-
retryDelay = parsed;
|
|
16866
|
-
}
|
|
16867
|
-
}
|
|
16868
|
-
}
|
|
16869
|
-
let data;
|
|
16870
|
-
let parsedJson = false;
|
|
16871
|
-
if (dataLines.length) {
|
|
16872
|
-
const rawData = dataLines.join("\n");
|
|
16873
|
-
try {
|
|
16874
|
-
data = JSON.parse(rawData);
|
|
16875
|
-
parsedJson = true;
|
|
16876
|
-
} catch {
|
|
16877
|
-
data = rawData;
|
|
16878
|
-
}
|
|
16879
|
-
}
|
|
16880
|
-
if (parsedJson) {
|
|
16881
|
-
if (responseValidator) {
|
|
16882
|
-
await responseValidator(data);
|
|
16883
|
-
}
|
|
16884
|
-
if (responseTransformer) {
|
|
16885
|
-
data = await responseTransformer(data);
|
|
16886
|
-
}
|
|
16887
|
-
}
|
|
16888
|
-
onSseEvent?.({
|
|
16889
|
-
data,
|
|
16890
|
-
event: eventName,
|
|
16891
|
-
id: lastEventId,
|
|
16892
|
-
retry: retryDelay
|
|
16893
|
-
});
|
|
16894
|
-
if (dataLines.length) {
|
|
16895
|
-
yield data;
|
|
16896
|
-
}
|
|
16897
|
-
}
|
|
16898
|
-
}
|
|
16899
|
-
} finally {
|
|
16900
|
-
signal.removeEventListener("abort", abortHandler);
|
|
16901
|
-
reader.releaseLock();
|
|
16902
|
-
}
|
|
16903
|
-
break;
|
|
16904
|
-
} catch (error) {
|
|
16905
|
-
onSseError?.(error);
|
|
16906
|
-
if (sseMaxRetryAttempts !== void 0 && attempt >= sseMaxRetryAttempts) {
|
|
16907
|
-
break;
|
|
16908
|
-
}
|
|
16909
|
-
const backoff = Math.min(
|
|
16910
|
-
retryDelay * 2 ** (attempt - 1),
|
|
16911
|
-
sseMaxRetryDelay ?? 3e4
|
|
16912
|
-
);
|
|
16913
|
-
await sleep(backoff);
|
|
16914
|
-
}
|
|
16915
|
-
}
|
|
16916
|
-
};
|
|
16917
|
-
const stream = createStream();
|
|
16918
|
-
return { stream };
|
|
16919
|
-
};
|
|
16920
|
-
|
|
16921
|
-
// src/client/core/pathSerializer.gen.ts
|
|
16922
|
-
var separatorArrayExplode = (style) => {
|
|
16923
|
-
switch (style) {
|
|
16924
|
-
case "label":
|
|
16925
|
-
return ".";
|
|
16926
|
-
case "matrix":
|
|
16927
|
-
return ";";
|
|
16928
|
-
case "simple":
|
|
16929
|
-
return ",";
|
|
16930
|
-
default:
|
|
16931
|
-
return "&";
|
|
16932
|
-
}
|
|
16933
|
-
};
|
|
16934
|
-
var separatorArrayNoExplode = (style) => {
|
|
16935
|
-
switch (style) {
|
|
16936
|
-
case "form":
|
|
16937
|
-
return ",";
|
|
16938
|
-
case "pipeDelimited":
|
|
16939
|
-
return "|";
|
|
16940
|
-
case "spaceDelimited":
|
|
16941
|
-
return "%20";
|
|
16942
|
-
default:
|
|
16943
|
-
return ",";
|
|
16944
|
-
}
|
|
16945
|
-
};
|
|
16946
|
-
var separatorObjectExplode = (style) => {
|
|
16947
|
-
switch (style) {
|
|
16948
|
-
case "label":
|
|
16949
|
-
return ".";
|
|
16950
|
-
case "matrix":
|
|
16951
|
-
return ";";
|
|
16952
|
-
case "simple":
|
|
16953
|
-
return ",";
|
|
16954
|
-
default:
|
|
16955
|
-
return "&";
|
|
16956
|
-
}
|
|
16957
|
-
};
|
|
16958
|
-
var serializeArrayParam = ({
|
|
16959
|
-
allowReserved,
|
|
16960
|
-
explode,
|
|
16961
|
-
name,
|
|
16962
|
-
style,
|
|
16963
|
-
value
|
|
16964
|
-
}) => {
|
|
16965
|
-
if (!explode) {
|
|
16966
|
-
const joinedValues2 = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join(separatorArrayNoExplode(style));
|
|
16967
|
-
switch (style) {
|
|
16968
|
-
case "label":
|
|
16969
|
-
return `.${joinedValues2}`;
|
|
16970
|
-
case "matrix":
|
|
16971
|
-
return `;${name}=${joinedValues2}`;
|
|
16972
|
-
case "simple":
|
|
16973
|
-
return joinedValues2;
|
|
16974
|
-
default:
|
|
16975
|
-
return `${name}=${joinedValues2}`;
|
|
16976
|
-
}
|
|
16977
|
-
}
|
|
16978
|
-
const separator = separatorArrayExplode(style);
|
|
16979
|
-
const joinedValues = value.map((v) => {
|
|
16980
|
-
if (style === "label" || style === "simple") {
|
|
16981
|
-
return allowReserved ? v : encodeURIComponent(v);
|
|
16982
|
-
}
|
|
16983
|
-
return serializePrimitiveParam({
|
|
16984
|
-
allowReserved,
|
|
16985
|
-
name,
|
|
16986
|
-
value: v
|
|
16987
|
-
});
|
|
16988
|
-
}).join(separator);
|
|
16989
|
-
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
|
|
16990
|
-
};
|
|
16991
|
-
var serializePrimitiveParam = ({
|
|
16992
|
-
allowReserved,
|
|
16993
|
-
name,
|
|
16994
|
-
value
|
|
16995
|
-
}) => {
|
|
16996
|
-
if (value === void 0 || value === null) {
|
|
16997
|
-
return "";
|
|
16998
|
-
}
|
|
16999
|
-
if (typeof value === "object") {
|
|
17000
|
-
throw new Error(
|
|
17001
|
-
"Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these."
|
|
17002
|
-
);
|
|
17003
|
-
}
|
|
17004
|
-
return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
|
|
17005
|
-
};
|
|
17006
|
-
var serializeObjectParam = ({
|
|
17007
|
-
allowReserved,
|
|
17008
|
-
explode,
|
|
17009
|
-
name,
|
|
17010
|
-
style,
|
|
17011
|
-
value,
|
|
17012
|
-
valueOnly
|
|
17013
|
-
}) => {
|
|
17014
|
-
if (value instanceof Date) {
|
|
17015
|
-
return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
|
|
17016
|
-
}
|
|
17017
|
-
if (style !== "deepObject" && !explode) {
|
|
17018
|
-
let values = [];
|
|
17019
|
-
Object.entries(value).forEach(([key, v]) => {
|
|
17020
|
-
values = [
|
|
17021
|
-
...values,
|
|
17022
|
-
key,
|
|
17023
|
-
allowReserved ? v : encodeURIComponent(v)
|
|
17024
|
-
];
|
|
17025
|
-
});
|
|
17026
|
-
const joinedValues2 = values.join(",");
|
|
17027
|
-
switch (style) {
|
|
17028
|
-
case "form":
|
|
17029
|
-
return `${name}=${joinedValues2}`;
|
|
17030
|
-
case "label":
|
|
17031
|
-
return `.${joinedValues2}`;
|
|
17032
|
-
case "matrix":
|
|
17033
|
-
return `;${name}=${joinedValues2}`;
|
|
17034
|
-
default:
|
|
17035
|
-
return joinedValues2;
|
|
17036
|
-
}
|
|
17037
|
-
}
|
|
17038
|
-
const separator = separatorObjectExplode(style);
|
|
17039
|
-
const joinedValues = Object.entries(value).map(
|
|
17040
|
-
([key, v]) => serializePrimitiveParam({
|
|
17041
|
-
allowReserved,
|
|
17042
|
-
name: style === "deepObject" ? `${name}[${key}]` : key,
|
|
17043
|
-
value: v
|
|
17044
|
-
})
|
|
17045
|
-
).join(separator);
|
|
17046
|
-
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
|
|
17047
|
-
};
|
|
17048
|
-
|
|
17049
|
-
// src/client/core/utils.gen.ts
|
|
17050
|
-
function getValidRequestBody(options) {
|
|
17051
|
-
const hasBody = options.body !== void 0;
|
|
17052
|
-
const isSerializedBody = hasBody && options.bodySerializer;
|
|
17053
|
-
if (isSerializedBody) {
|
|
17054
|
-
if ("serializedBody" in options) {
|
|
17055
|
-
const hasSerializedBody = options.serializedBody !== void 0 && options.serializedBody !== "";
|
|
17056
|
-
return hasSerializedBody ? options.serializedBody : null;
|
|
17057
|
-
}
|
|
17058
|
-
return options.body !== "" ? options.body : null;
|
|
17059
|
-
}
|
|
17060
|
-
if (hasBody) {
|
|
17061
|
-
return options.body;
|
|
17062
|
-
}
|
|
17063
|
-
return void 0;
|
|
17064
|
-
}
|
|
17065
|
-
|
|
17066
|
-
// src/client/core/auth.gen.ts
|
|
17067
|
-
var getAuthToken = async (auth, callback) => {
|
|
17068
|
-
const token = typeof callback === "function" ? await callback(auth) : callback;
|
|
17069
|
-
if (!token) {
|
|
17070
|
-
return;
|
|
17071
|
-
}
|
|
17072
|
-
if (auth.scheme === "bearer") {
|
|
17073
|
-
return `Bearer ${token}`;
|
|
17074
|
-
}
|
|
17075
|
-
if (auth.scheme === "basic") {
|
|
17076
|
-
return `Basic ${btoa(token)}`;
|
|
17077
|
-
}
|
|
17078
|
-
return token;
|
|
17079
|
-
};
|
|
17080
|
-
|
|
17081
|
-
// src/client/client/utils.gen.ts
|
|
17082
|
-
var PATH_PARAM_RE = /\{[^{}]+\}/g;
|
|
17083
|
-
var defaultPathSerializer = ({ path, url: _url }) => {
|
|
17084
|
-
let url = _url;
|
|
17085
|
-
const matches = _url.match(PATH_PARAM_RE);
|
|
17086
|
-
if (matches) {
|
|
17087
|
-
for (const match of matches) {
|
|
17088
|
-
let explode = false;
|
|
17089
|
-
let name = match.substring(1, match.length - 1);
|
|
17090
|
-
let style = "simple";
|
|
17091
|
-
if (name.endsWith("*")) {
|
|
17092
|
-
explode = true;
|
|
17093
|
-
name = name.substring(0, name.length - 1);
|
|
17094
|
-
}
|
|
17095
|
-
if (name.startsWith(".")) {
|
|
17096
|
-
name = name.substring(1);
|
|
17097
|
-
style = "label";
|
|
17098
|
-
} else if (name.startsWith(";")) {
|
|
17099
|
-
name = name.substring(1);
|
|
17100
|
-
style = "matrix";
|
|
17101
|
-
}
|
|
17102
|
-
const value = path[name];
|
|
17103
|
-
if (value === void 0 || value === null) {
|
|
17104
|
-
continue;
|
|
17105
|
-
}
|
|
17106
|
-
if (Array.isArray(value)) {
|
|
17107
|
-
url = url.replace(
|
|
17108
|
-
match,
|
|
17109
|
-
serializeArrayParam({ explode, name, style, value })
|
|
17110
|
-
);
|
|
17111
|
-
continue;
|
|
17112
|
-
}
|
|
17113
|
-
if (typeof value === "object") {
|
|
17114
|
-
url = url.replace(
|
|
17115
|
-
match,
|
|
17116
|
-
serializeObjectParam({
|
|
17117
|
-
explode,
|
|
17118
|
-
name,
|
|
17119
|
-
style,
|
|
17120
|
-
value,
|
|
17121
|
-
valueOnly: true
|
|
17122
|
-
})
|
|
17123
|
-
);
|
|
17124
|
-
continue;
|
|
17125
|
-
}
|
|
17126
|
-
if (style === "matrix") {
|
|
17127
|
-
url = url.replace(
|
|
17128
|
-
match,
|
|
17129
|
-
`;${serializePrimitiveParam({
|
|
17130
|
-
name,
|
|
17131
|
-
value
|
|
17132
|
-
})}`
|
|
17133
|
-
);
|
|
17134
|
-
continue;
|
|
17135
|
-
}
|
|
17136
|
-
const replaceValue = encodeURIComponent(
|
|
17137
|
-
style === "label" ? `.${value}` : value
|
|
17138
|
-
);
|
|
17139
|
-
url = url.replace(match, replaceValue);
|
|
17140
|
-
}
|
|
17141
|
-
}
|
|
17142
|
-
return url;
|
|
17143
|
-
};
|
|
17144
|
-
var createQuerySerializer = ({
|
|
17145
|
-
parameters = {},
|
|
17146
|
-
...args
|
|
17147
|
-
} = {}) => {
|
|
17148
|
-
const querySerializer = (queryParams) => {
|
|
17149
|
-
const search = [];
|
|
17150
|
-
if (queryParams && typeof queryParams === "object") {
|
|
17151
|
-
for (const name in queryParams) {
|
|
17152
|
-
const value = queryParams[name];
|
|
17153
|
-
if (value === void 0 || value === null) {
|
|
17154
|
-
continue;
|
|
17155
|
-
}
|
|
17156
|
-
const options = parameters[name] || args;
|
|
17157
|
-
if (Array.isArray(value)) {
|
|
17158
|
-
const serializedArray = serializeArrayParam({
|
|
17159
|
-
allowReserved: options.allowReserved,
|
|
17160
|
-
explode: true,
|
|
17161
|
-
name,
|
|
17162
|
-
style: "form",
|
|
17163
|
-
value,
|
|
17164
|
-
...options.array
|
|
17165
|
-
});
|
|
17166
|
-
if (serializedArray) search.push(serializedArray);
|
|
17167
|
-
} else if (typeof value === "object") {
|
|
17168
|
-
const serializedObject = serializeObjectParam({
|
|
17169
|
-
allowReserved: options.allowReserved,
|
|
17170
|
-
explode: true,
|
|
17171
|
-
name,
|
|
17172
|
-
style: "deepObject",
|
|
17173
|
-
value,
|
|
17174
|
-
...options.object
|
|
17175
|
-
});
|
|
17176
|
-
if (serializedObject) search.push(serializedObject);
|
|
17177
|
-
} else {
|
|
17178
|
-
const serializedPrimitive = serializePrimitiveParam({
|
|
17179
|
-
allowReserved: options.allowReserved,
|
|
17180
|
-
name,
|
|
17181
|
-
value
|
|
17182
|
-
});
|
|
17183
|
-
if (serializedPrimitive) search.push(serializedPrimitive);
|
|
17184
|
-
}
|
|
17185
|
-
}
|
|
17186
|
-
}
|
|
17187
|
-
return search.join("&");
|
|
17188
|
-
};
|
|
17189
|
-
return querySerializer;
|
|
17190
|
-
};
|
|
17191
|
-
var getParseAs = (contentType) => {
|
|
17192
|
-
if (!contentType) {
|
|
17193
|
-
return "stream";
|
|
17194
|
-
}
|
|
17195
|
-
const cleanContent = contentType.split(";")[0]?.trim();
|
|
17196
|
-
if (!cleanContent) {
|
|
17197
|
-
return;
|
|
17198
|
-
}
|
|
17199
|
-
if (cleanContent.startsWith("application/json") || cleanContent.endsWith("+json")) {
|
|
17200
|
-
return "json";
|
|
17201
|
-
}
|
|
17202
|
-
if (cleanContent === "multipart/form-data") {
|
|
17203
|
-
return "formData";
|
|
17204
|
-
}
|
|
17205
|
-
if (["application/", "audio/", "image/", "video/"].some(
|
|
17206
|
-
(type) => cleanContent.startsWith(type)
|
|
17207
|
-
)) {
|
|
17208
|
-
return "blob";
|
|
17209
|
-
}
|
|
17210
|
-
if (cleanContent.startsWith("text/")) {
|
|
17211
|
-
return "text";
|
|
17212
|
-
}
|
|
17213
|
-
return;
|
|
17214
|
-
};
|
|
17215
|
-
var checkForExistence = (options, name) => {
|
|
17216
|
-
if (!name) {
|
|
17217
|
-
return false;
|
|
17218
|
-
}
|
|
17219
|
-
if (options.headers.has(name) || options.query?.[name] || options.headers.get("Cookie")?.includes(`${name}=`)) {
|
|
17220
|
-
return true;
|
|
17221
|
-
}
|
|
17222
|
-
return false;
|
|
17223
|
-
};
|
|
17224
|
-
var setAuthParams = async ({
|
|
17225
|
-
security,
|
|
17226
|
-
...options
|
|
17227
|
-
}) => {
|
|
17228
|
-
for (const auth of security) {
|
|
17229
|
-
if (checkForExistence(options, auth.name)) {
|
|
17230
|
-
continue;
|
|
17231
|
-
}
|
|
17232
|
-
const token = await getAuthToken(auth, options.auth);
|
|
17233
|
-
if (!token) {
|
|
17234
|
-
continue;
|
|
17235
|
-
}
|
|
17236
|
-
const name = auth.name ?? "Authorization";
|
|
17237
|
-
switch (auth.in) {
|
|
17238
|
-
case "query":
|
|
17239
|
-
if (!options.query) {
|
|
17240
|
-
options.query = {};
|
|
17241
|
-
}
|
|
17242
|
-
options.query[name] = token;
|
|
17243
|
-
break;
|
|
17244
|
-
case "cookie":
|
|
17245
|
-
options.headers.append("Cookie", `${name}=${token}`);
|
|
17246
|
-
break;
|
|
17247
|
-
case "header":
|
|
17248
|
-
default:
|
|
17249
|
-
options.headers.set(name, token);
|
|
17250
|
-
break;
|
|
17251
|
-
}
|
|
17252
|
-
}
|
|
17253
|
-
};
|
|
17254
|
-
var buildUrl = (options) => {
|
|
17255
|
-
const url = getUrl({
|
|
17256
|
-
baseUrl: options.baseUrl,
|
|
17257
|
-
path: options.path,
|
|
17258
|
-
query: options.query,
|
|
17259
|
-
querySerializer: typeof options.querySerializer === "function" ? options.querySerializer : createQuerySerializer(options.querySerializer),
|
|
17260
|
-
url: options.url
|
|
17261
|
-
});
|
|
17262
|
-
return url;
|
|
17263
|
-
};
|
|
17264
|
-
var getUrl = ({
|
|
17265
|
-
baseUrl,
|
|
17266
|
-
path,
|
|
17267
|
-
query,
|
|
17268
|
-
querySerializer,
|
|
17269
|
-
url: _url
|
|
17270
|
-
}) => {
|
|
17271
|
-
const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
|
|
17272
|
-
let url = (baseUrl ?? "") + pathUrl;
|
|
17273
|
-
if (path) {
|
|
17274
|
-
url = defaultPathSerializer({ path, url });
|
|
17275
|
-
}
|
|
17276
|
-
let search = query ? querySerializer(query) : "";
|
|
17277
|
-
if (search.startsWith("?")) {
|
|
17278
|
-
search = search.substring(1);
|
|
17279
|
-
}
|
|
17280
|
-
if (search) {
|
|
17281
|
-
url += `?${search}`;
|
|
17282
|
-
}
|
|
17283
|
-
return url;
|
|
17284
|
-
};
|
|
17285
|
-
var mergeConfigs = (a, b) => {
|
|
17286
|
-
const config = { ...a, ...b };
|
|
17287
|
-
if (config.baseUrl?.endsWith("/")) {
|
|
17288
|
-
config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
|
|
17289
|
-
}
|
|
17290
|
-
config.headers = mergeHeaders(a.headers, b.headers);
|
|
17291
|
-
return config;
|
|
17292
|
-
};
|
|
17293
|
-
var headersEntries = (headers) => {
|
|
17294
|
-
const entries = [];
|
|
17295
|
-
headers.forEach((value, key) => {
|
|
17296
|
-
entries.push([key, value]);
|
|
17297
|
-
});
|
|
17298
|
-
return entries;
|
|
17299
|
-
};
|
|
17300
|
-
var mergeHeaders = (...headers) => {
|
|
17301
|
-
const mergedHeaders = new Headers();
|
|
17302
|
-
for (const header of headers) {
|
|
17303
|
-
if (!header || typeof header !== "object") {
|
|
17304
|
-
continue;
|
|
17305
|
-
}
|
|
17306
|
-
const iterator = header instanceof Headers ? headersEntries(header) : Object.entries(header);
|
|
17307
|
-
for (const [key, value] of iterator) {
|
|
17308
|
-
if (value === null) {
|
|
17309
|
-
mergedHeaders.delete(key);
|
|
17310
|
-
} else if (Array.isArray(value)) {
|
|
17311
|
-
for (const v of value) {
|
|
17312
|
-
mergedHeaders.append(key, v);
|
|
17313
|
-
}
|
|
17314
|
-
} else if (value !== void 0) {
|
|
17315
|
-
mergedHeaders.set(
|
|
17316
|
-
key,
|
|
17317
|
-
typeof value === "object" ? JSON.stringify(value) : value
|
|
17318
|
-
);
|
|
17319
|
-
}
|
|
17320
|
-
}
|
|
17321
|
-
}
|
|
17322
|
-
return mergedHeaders;
|
|
17323
|
-
};
|
|
17324
|
-
var Interceptors = class {
|
|
17325
|
-
constructor() {
|
|
17326
|
-
this.fns = [];
|
|
17327
|
-
}
|
|
17328
|
-
clear() {
|
|
17329
|
-
this.fns = [];
|
|
17330
|
-
}
|
|
17331
|
-
eject(id) {
|
|
17332
|
-
const index = this.getInterceptorIndex(id);
|
|
17333
|
-
if (this.fns[index]) {
|
|
17334
|
-
this.fns[index] = null;
|
|
17335
|
-
}
|
|
17336
|
-
}
|
|
17337
|
-
exists(id) {
|
|
17338
|
-
const index = this.getInterceptorIndex(id);
|
|
17339
|
-
return Boolean(this.fns[index]);
|
|
17340
|
-
}
|
|
17341
|
-
getInterceptorIndex(id) {
|
|
17342
|
-
if (typeof id === "number") {
|
|
17343
|
-
return this.fns[id] ? id : -1;
|
|
17344
|
-
}
|
|
17345
|
-
return this.fns.indexOf(id);
|
|
17346
|
-
}
|
|
17347
|
-
update(id, fn) {
|
|
17348
|
-
const index = this.getInterceptorIndex(id);
|
|
17349
|
-
if (this.fns[index]) {
|
|
17350
|
-
this.fns[index] = fn;
|
|
17351
|
-
return id;
|
|
17352
|
-
}
|
|
17353
|
-
return false;
|
|
17354
|
-
}
|
|
17355
|
-
use(fn) {
|
|
17356
|
-
this.fns.push(fn);
|
|
17357
|
-
return this.fns.length - 1;
|
|
17358
|
-
}
|
|
17359
|
-
};
|
|
17360
|
-
var createInterceptors = () => ({
|
|
17361
|
-
error: new Interceptors(),
|
|
17362
|
-
request: new Interceptors(),
|
|
17363
|
-
response: new Interceptors()
|
|
17364
|
-
});
|
|
17365
|
-
var defaultQuerySerializer = createQuerySerializer({
|
|
17366
|
-
allowReserved: false,
|
|
17367
|
-
array: {
|
|
17368
|
-
explode: true,
|
|
17369
|
-
style: "form"
|
|
17370
|
-
},
|
|
17371
|
-
object: {
|
|
17372
|
-
explode: true,
|
|
17373
|
-
style: "deepObject"
|
|
17374
|
-
}
|
|
17375
|
-
});
|
|
17376
|
-
var defaultHeaders = {
|
|
17377
|
-
"Content-Type": "application/json"
|
|
17378
|
-
};
|
|
17379
|
-
var createConfig = (override = {}) => ({
|
|
17380
|
-
...jsonBodySerializer,
|
|
17381
|
-
headers: defaultHeaders,
|
|
17382
|
-
parseAs: "auto",
|
|
17383
|
-
querySerializer: defaultQuerySerializer,
|
|
17384
|
-
...override
|
|
17385
|
-
});
|
|
17386
|
-
|
|
17387
|
-
// src/client/client/client.gen.ts
|
|
17388
|
-
var createClient = (config = {}) => {
|
|
17389
|
-
let _config = mergeConfigs(createConfig(), config);
|
|
17390
|
-
const getConfig = () => ({ ..._config });
|
|
17391
|
-
const setConfig = (config2) => {
|
|
17392
|
-
_config = mergeConfigs(_config, config2);
|
|
17393
|
-
return getConfig();
|
|
17394
|
-
};
|
|
17395
|
-
const interceptors = createInterceptors();
|
|
17396
|
-
const beforeRequest = async (options) => {
|
|
17397
|
-
const opts = {
|
|
17398
|
-
..._config,
|
|
17399
|
-
...options,
|
|
17400
|
-
fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
|
|
17401
|
-
headers: mergeHeaders(_config.headers, options.headers),
|
|
17402
|
-
serializedBody: void 0
|
|
17403
|
-
};
|
|
17404
|
-
if (opts.security) {
|
|
17405
|
-
await setAuthParams({
|
|
17406
|
-
...opts,
|
|
17407
|
-
security: opts.security
|
|
17408
|
-
});
|
|
17409
|
-
}
|
|
17410
|
-
if (opts.requestValidator) {
|
|
17411
|
-
await opts.requestValidator(opts);
|
|
17412
|
-
}
|
|
17413
|
-
if (opts.body !== void 0 && opts.bodySerializer) {
|
|
17414
|
-
opts.serializedBody = opts.bodySerializer(opts.body);
|
|
17415
|
-
}
|
|
17416
|
-
if (opts.body === void 0 || opts.serializedBody === "") {
|
|
17417
|
-
opts.headers.delete("Content-Type");
|
|
17418
|
-
}
|
|
17419
|
-
const url = buildUrl(opts);
|
|
17420
|
-
return { opts, url };
|
|
17421
|
-
};
|
|
17422
|
-
const request = async (options) => {
|
|
17423
|
-
const { opts, url } = await beforeRequest(options);
|
|
17424
|
-
for (const fn of interceptors.request.fns) {
|
|
17425
|
-
if (fn) {
|
|
17426
|
-
await fn(opts);
|
|
17427
|
-
}
|
|
17428
|
-
}
|
|
17429
|
-
const _fetch = opts.fetch;
|
|
17430
|
-
const requestInit = {
|
|
17431
|
-
...opts,
|
|
17432
|
-
body: getValidRequestBody(opts)
|
|
17433
|
-
};
|
|
17434
|
-
let response = await _fetch(url, requestInit);
|
|
17435
|
-
for (const fn of interceptors.response.fns) {
|
|
17436
|
-
if (fn) {
|
|
17437
|
-
response = await fn(response, opts);
|
|
17438
|
-
}
|
|
17439
|
-
}
|
|
17440
|
-
const result = {
|
|
17441
|
-
response
|
|
17442
|
-
};
|
|
17443
|
-
if (response.ok) {
|
|
17444
|
-
const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
|
|
17445
|
-
if (response.status === 204 || response.headers.get("Content-Length") === "0") {
|
|
17446
|
-
let emptyData;
|
|
17447
|
-
switch (parseAs) {
|
|
17448
|
-
case "arrayBuffer":
|
|
17449
|
-
case "blob":
|
|
17450
|
-
case "text":
|
|
17451
|
-
emptyData = await response[parseAs]();
|
|
17452
|
-
break;
|
|
17453
|
-
case "formData":
|
|
17454
|
-
emptyData = new FormData();
|
|
17455
|
-
break;
|
|
17456
|
-
case "stream":
|
|
17457
|
-
emptyData = response.body;
|
|
17458
|
-
break;
|
|
17459
|
-
case "json":
|
|
17460
|
-
default:
|
|
17461
|
-
emptyData = {};
|
|
17462
|
-
break;
|
|
17463
|
-
}
|
|
17464
|
-
return {
|
|
17465
|
-
data: emptyData,
|
|
17466
|
-
...result
|
|
17467
|
-
};
|
|
17468
|
-
}
|
|
17469
|
-
let data;
|
|
17470
|
-
switch (parseAs) {
|
|
17471
|
-
case "arrayBuffer":
|
|
17472
|
-
case "blob":
|
|
17473
|
-
case "formData":
|
|
17474
|
-
case "json":
|
|
17475
|
-
case "text":
|
|
17476
|
-
data = await response[parseAs]();
|
|
17477
|
-
break;
|
|
17478
|
-
case "stream":
|
|
17479
|
-
return {
|
|
17480
|
-
data: response.body,
|
|
17481
|
-
...result
|
|
17482
|
-
};
|
|
17483
|
-
}
|
|
17484
|
-
if (parseAs === "json") {
|
|
17485
|
-
if (opts.responseValidator) {
|
|
17486
|
-
await opts.responseValidator(data);
|
|
17487
|
-
}
|
|
17488
|
-
if (opts.responseTransformer) {
|
|
17489
|
-
data = await opts.responseTransformer(data);
|
|
17490
|
-
}
|
|
17491
|
-
}
|
|
17492
|
-
return {
|
|
17493
|
-
data,
|
|
17494
|
-
...result
|
|
17495
|
-
};
|
|
17496
|
-
}
|
|
17497
|
-
const textError = await response.text();
|
|
17498
|
-
let jsonError;
|
|
17499
|
-
try {
|
|
17500
|
-
jsonError = JSON.parse(textError);
|
|
17501
|
-
} catch {
|
|
17502
|
-
}
|
|
17503
|
-
const error = jsonError ?? textError;
|
|
17504
|
-
let finalError = error;
|
|
17505
|
-
for (const fn of interceptors.error.fns) {
|
|
17506
|
-
if (fn) {
|
|
17507
|
-
finalError = await fn(error, response, opts);
|
|
17508
|
-
}
|
|
17509
|
-
}
|
|
17510
|
-
finalError = finalError || {};
|
|
17511
|
-
if (opts.throwOnError) {
|
|
17512
|
-
throw finalError;
|
|
17513
|
-
}
|
|
17514
|
-
return {
|
|
17515
|
-
error: finalError,
|
|
17516
|
-
...result
|
|
17517
|
-
};
|
|
17518
|
-
};
|
|
17519
|
-
const makeMethodFn = (method) => (options) => request({ ...options, method });
|
|
17520
|
-
const makeSseFn = (method) => async (options) => {
|
|
17521
|
-
const { opts, url } = await beforeRequest(options);
|
|
17522
|
-
return createSseClient({
|
|
17523
|
-
...opts,
|
|
17524
|
-
body: opts.body,
|
|
17525
|
-
headers: opts.headers,
|
|
17526
|
-
method,
|
|
17527
|
-
onRequest: async (url2, init) => {
|
|
17528
|
-
let request2 = new Request(url2, init);
|
|
17529
|
-
const requestInit = {
|
|
17530
|
-
...init,
|
|
17531
|
-
method: init.method,
|
|
17532
|
-
url: url2
|
|
17533
|
-
};
|
|
17534
|
-
for (const fn of interceptors.request.fns) {
|
|
17535
|
-
if (fn) {
|
|
17536
|
-
await fn(requestInit);
|
|
17537
|
-
request2 = new Request(requestInit.url, requestInit);
|
|
17538
|
-
}
|
|
17539
|
-
}
|
|
17540
|
-
return request2;
|
|
17541
|
-
},
|
|
17542
|
-
url
|
|
17543
|
-
});
|
|
17544
|
-
};
|
|
17545
|
-
return {
|
|
17546
|
-
buildUrl,
|
|
17547
|
-
connect: makeMethodFn("CONNECT"),
|
|
17548
|
-
delete: makeMethodFn("DELETE"),
|
|
17549
|
-
get: makeMethodFn("GET"),
|
|
17550
|
-
getConfig,
|
|
17551
|
-
head: makeMethodFn("HEAD"),
|
|
17552
|
-
interceptors,
|
|
17553
|
-
options: makeMethodFn("OPTIONS"),
|
|
17554
|
-
patch: makeMethodFn("PATCH"),
|
|
17555
|
-
post: makeMethodFn("POST"),
|
|
17556
|
-
put: makeMethodFn("PUT"),
|
|
17557
|
-
request,
|
|
17558
|
-
setConfig,
|
|
17559
|
-
sse: {
|
|
17560
|
-
connect: makeSseFn("CONNECT"),
|
|
17561
|
-
delete: makeSseFn("DELETE"),
|
|
17562
|
-
get: makeSseFn("GET"),
|
|
17563
|
-
head: makeSseFn("HEAD"),
|
|
17564
|
-
options: makeSseFn("OPTIONS"),
|
|
17565
|
-
patch: makeSseFn("PATCH"),
|
|
17566
|
-
post: makeSseFn("POST"),
|
|
17567
|
-
put: makeSseFn("PUT"),
|
|
17568
|
-
trace: makeSseFn("TRACE")
|
|
17569
|
-
},
|
|
17570
|
-
trace: makeMethodFn("TRACE")
|
|
17571
|
-
};
|
|
17572
|
-
};
|
|
17573
|
-
|
|
17574
|
-
// src/client/client.gen.ts
|
|
17575
|
-
var client = createClient(createClientConfig(createConfig()));
|
|
17576
|
-
|
|
17577
|
-
// src/client/sdk.gen.ts
|
|
17578
|
-
var postApiV1Embeddings = (options) => {
|
|
17579
|
-
return (options.client ?? client).post({
|
|
17580
|
-
url: "/api/v1/embeddings",
|
|
17581
|
-
...options,
|
|
17582
|
-
headers: {
|
|
17583
|
-
"Content-Type": "application/json",
|
|
17584
|
-
...options.headers
|
|
17585
|
-
}
|
|
17586
|
-
});
|
|
17587
|
-
};
|
|
17588
|
-
|
|
17589
16775
|
// src/lib/memoryEngine/chunking.ts
|
|
17590
16776
|
var DEFAULT_CHUNK_SIZE = 400;
|
|
17591
16777
|
var DEFAULT_CHUNK_OVERLAP = 50;
|
|
@@ -17721,8 +16907,8 @@ function shouldChunkMessage(content, chunkSize = DEFAULT_CHUNK_SIZE) {
|
|
|
17721
16907
|
return content.length > chunkSize;
|
|
17722
16908
|
}
|
|
17723
16909
|
|
|
17724
|
-
// src/lib/memoryEngine/
|
|
17725
|
-
|
|
16910
|
+
// src/lib/memoryEngine/generate.ts
|
|
16911
|
+
import { postApiV1Embeddings } from "@anuma/sdk";
|
|
17726
16912
|
var EMBED_MAX_ATTEMPTS = 4;
|
|
17727
16913
|
async function withEmbeddingRetry(call) {
|
|
17728
16914
|
let last;
|
|
@@ -17916,6 +17102,9 @@ async function generateEmbeddings(texts, options) {
|
|
|
17916
17102
|
}
|
|
17917
17103
|
return results;
|
|
17918
17104
|
}
|
|
17105
|
+
|
|
17106
|
+
// src/lib/memoryEngine/embeddings.ts
|
|
17107
|
+
var DEFAULT_MIN_CONTENT_LENGTH = 10;
|
|
17919
17108
|
async function embedMessage(ctx, messageId, options) {
|
|
17920
17109
|
let message;
|
|
17921
17110
|
const conversations = await getConversationsOp(ctx);
|
|
@@ -19335,7 +18524,7 @@ function createMemoryVaultSearchTool(vaultCtx, embeddingOptions, cache, searchOp
|
|
|
19335
18524
|
legacy.map((r) => ({ id: r.uniqueId, content: r.content, score: r.similarity }))
|
|
19336
18525
|
);
|
|
19337
18526
|
}
|
|
19338
|
-
const { recall: recall2 } = await import("./recall-
|
|
18527
|
+
const { recall: recall2 } = await import("./recall-KYSR3XZJ.mjs");
|
|
19339
18528
|
const result = await recall2(
|
|
19340
18529
|
query,
|
|
19341
18530
|
{ vaultCtx, embeddingOptions, vaultCache: cache },
|
|
@@ -20046,7 +19235,6 @@ export {
|
|
|
20046
19235
|
DEFAULT_MIN_CHUNK_SIZE,
|
|
20047
19236
|
chunkText,
|
|
20048
19237
|
shouldChunkMessage,
|
|
20049
|
-
createSseClient,
|
|
20050
19238
|
DEFAULT_API_EMBEDDING_MODEL,
|
|
20051
19239
|
generateEmbedding,
|
|
20052
19240
|
generateEmbeddings,
|