@anuma/sdk 3.0.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-IY7NNIYM.mjs → chunk-22CSPJLL.mjs} +16 -850
- package/dist/expo/index.cjs +1663 -1071
- package/dist/expo/index.d.mts +179 -10
- package/dist/expo/index.d.ts +179 -10
- package/dist/expo/index.mjs +1556 -68
- package/dist/expo/{recall-DJ5LD5WJ.mjs → recall-LICO3TJ7.mjs} +1 -1
- package/dist/index.cjs +415 -394
- package/dist/index.mjs +412 -391
- package/dist/react/{chunk-OSDVRDLI.mjs → chunk-FD5MB73N.mjs} +8 -987
- package/dist/react/index.cjs +1687 -1712
- package/dist/react/index.d.mts +103 -12
- package/dist/react/index.d.ts +103 -12
- package/dist/react/index.mjs +1209 -219
- package/dist/react/{recall-3BDCIEQF.mjs → recall-FPACUZGD.mjs} +1 -1
- package/dist/server/{chunk-QQOIC37O.mjs → chunk-RKUNGNBF.mjs} +7 -817
- package/dist/server/index.cjs +223 -941
- package/dist/server/index.d.mts +95 -12
- package/dist/server/index.d.ts +95 -12
- package/dist/server/index.mjs +182 -23
- package/dist/server/{recall-6QLUEYB7.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
|
@@ -3,8 +3,7 @@ import {
|
|
|
3
3
|
getLogger
|
|
4
4
|
} from "./chunk-DFVCS3QQ.mjs";
|
|
5
5
|
import {
|
|
6
|
-
BASE_URL
|
|
7
|
-
createClientConfig
|
|
6
|
+
BASE_URL
|
|
8
7
|
} from "./chunk-GYKJOWEO.mjs";
|
|
9
8
|
|
|
10
9
|
// src/lib/db/chat/operations.ts
|
|
@@ -847,6 +846,12 @@ function getToolCallEvents(r) {
|
|
|
847
846
|
}
|
|
848
847
|
return r.tool_call_events;
|
|
849
848
|
}
|
|
849
|
+
function getToolsChecksum(r) {
|
|
850
|
+
if (isChatCompletionResponse(r)) {
|
|
851
|
+
return r.portal?.tools_checksum ?? r.tools_checksum;
|
|
852
|
+
}
|
|
853
|
+
return r.tools_checksum;
|
|
854
|
+
}
|
|
850
855
|
function getCostMicroUsd(r) {
|
|
851
856
|
if (isChatCompletionResponse(r)) {
|
|
852
857
|
return r.portal?.cost_micro_usd ?? r.usage?.cost_micro_usd;
|
|
@@ -2567,845 +2572,6 @@ async function updateVaultMemoryEmbeddingOp(ctx, id, embedding, embeddingModel)
|
|
|
2567
2572
|
// src/lib/memoryEngine/constants.ts
|
|
2568
2573
|
var DEFAULT_API_EMBEDDING_MODEL = "qwen/qwen3-embedding-8b";
|
|
2569
2574
|
|
|
2570
|
-
// src/client/core/bodySerializer.gen.ts
|
|
2571
|
-
var jsonBodySerializer = {
|
|
2572
|
-
bodySerializer: (body) => JSON.stringify(
|
|
2573
|
-
body,
|
|
2574
|
-
(_key, value) => typeof value === "bigint" ? value.toString() : value
|
|
2575
|
-
)
|
|
2576
|
-
};
|
|
2577
|
-
|
|
2578
|
-
// src/client/core/serverSentEvents.gen.ts
|
|
2579
|
-
var createSseClient = ({
|
|
2580
|
-
onRequest,
|
|
2581
|
-
onSseError,
|
|
2582
|
-
onSseEvent,
|
|
2583
|
-
responseTransformer,
|
|
2584
|
-
responseValidator,
|
|
2585
|
-
sseDefaultRetryDelay,
|
|
2586
|
-
sseMaxRetryAttempts,
|
|
2587
|
-
sseMaxRetryDelay,
|
|
2588
|
-
sseSleepFn,
|
|
2589
|
-
url,
|
|
2590
|
-
...options
|
|
2591
|
-
}) => {
|
|
2592
|
-
let lastEventId;
|
|
2593
|
-
const sleep = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
2594
|
-
const createStream = async function* () {
|
|
2595
|
-
let retryDelay = sseDefaultRetryDelay ?? 3e3;
|
|
2596
|
-
let attempt = 0;
|
|
2597
|
-
const signal = options.signal ?? new AbortController().signal;
|
|
2598
|
-
while (true) {
|
|
2599
|
-
if (signal.aborted) break;
|
|
2600
|
-
attempt++;
|
|
2601
|
-
const headers = options.headers instanceof Headers ? options.headers : new Headers(options.headers);
|
|
2602
|
-
if (lastEventId !== void 0) {
|
|
2603
|
-
headers.set("Last-Event-ID", lastEventId);
|
|
2604
|
-
}
|
|
2605
|
-
try {
|
|
2606
|
-
const requestInit = {
|
|
2607
|
-
redirect: "follow",
|
|
2608
|
-
...options,
|
|
2609
|
-
body: options.serializedBody,
|
|
2610
|
-
headers,
|
|
2611
|
-
signal
|
|
2612
|
-
};
|
|
2613
|
-
let request = new Request(url, requestInit);
|
|
2614
|
-
if (onRequest) {
|
|
2615
|
-
request = await onRequest(url, requestInit);
|
|
2616
|
-
}
|
|
2617
|
-
const _fetch = options.fetch ?? globalThis.fetch;
|
|
2618
|
-
const response = await _fetch(request);
|
|
2619
|
-
if (!response.ok)
|
|
2620
|
-
throw new Error(
|
|
2621
|
-
`SSE failed: ${response.status} ${response.statusText}`
|
|
2622
|
-
);
|
|
2623
|
-
if (!response.body) throw new Error("No body in SSE response");
|
|
2624
|
-
const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
|
|
2625
|
-
let buffer = "";
|
|
2626
|
-
const abortHandler = () => {
|
|
2627
|
-
try {
|
|
2628
|
-
reader.cancel();
|
|
2629
|
-
} catch {
|
|
2630
|
-
}
|
|
2631
|
-
};
|
|
2632
|
-
signal.addEventListener("abort", abortHandler);
|
|
2633
|
-
try {
|
|
2634
|
-
while (true) {
|
|
2635
|
-
const { done, value } = await reader.read();
|
|
2636
|
-
if (done) break;
|
|
2637
|
-
buffer += value;
|
|
2638
|
-
const chunks = buffer.split("\n\n");
|
|
2639
|
-
buffer = chunks.pop() ?? "";
|
|
2640
|
-
for (const chunk of chunks) {
|
|
2641
|
-
const lines = chunk.split("\n");
|
|
2642
|
-
const dataLines = [];
|
|
2643
|
-
let eventName;
|
|
2644
|
-
for (const line of lines) {
|
|
2645
|
-
if (line.startsWith("data:")) {
|
|
2646
|
-
dataLines.push(line.replace(/^data:\s*/, ""));
|
|
2647
|
-
} else if (line.startsWith("event:")) {
|
|
2648
|
-
eventName = line.replace(/^event:\s*/, "");
|
|
2649
|
-
} else if (line.startsWith("id:")) {
|
|
2650
|
-
lastEventId = line.replace(/^id:\s*/, "");
|
|
2651
|
-
} else if (line.startsWith("retry:")) {
|
|
2652
|
-
const parsed = Number.parseInt(
|
|
2653
|
-
line.replace(/^retry:\s*/, ""),
|
|
2654
|
-
10
|
|
2655
|
-
);
|
|
2656
|
-
if (!Number.isNaN(parsed)) {
|
|
2657
|
-
retryDelay = parsed;
|
|
2658
|
-
}
|
|
2659
|
-
}
|
|
2660
|
-
}
|
|
2661
|
-
let data;
|
|
2662
|
-
let parsedJson = false;
|
|
2663
|
-
if (dataLines.length) {
|
|
2664
|
-
const rawData = dataLines.join("\n");
|
|
2665
|
-
try {
|
|
2666
|
-
data = JSON.parse(rawData);
|
|
2667
|
-
parsedJson = true;
|
|
2668
|
-
} catch {
|
|
2669
|
-
data = rawData;
|
|
2670
|
-
}
|
|
2671
|
-
}
|
|
2672
|
-
if (parsedJson) {
|
|
2673
|
-
if (responseValidator) {
|
|
2674
|
-
await responseValidator(data);
|
|
2675
|
-
}
|
|
2676
|
-
if (responseTransformer) {
|
|
2677
|
-
data = await responseTransformer(data);
|
|
2678
|
-
}
|
|
2679
|
-
}
|
|
2680
|
-
onSseEvent?.({
|
|
2681
|
-
data,
|
|
2682
|
-
event: eventName,
|
|
2683
|
-
id: lastEventId,
|
|
2684
|
-
retry: retryDelay
|
|
2685
|
-
});
|
|
2686
|
-
if (dataLines.length) {
|
|
2687
|
-
yield data;
|
|
2688
|
-
}
|
|
2689
|
-
}
|
|
2690
|
-
}
|
|
2691
|
-
} finally {
|
|
2692
|
-
signal.removeEventListener("abort", abortHandler);
|
|
2693
|
-
reader.releaseLock();
|
|
2694
|
-
}
|
|
2695
|
-
break;
|
|
2696
|
-
} catch (error) {
|
|
2697
|
-
onSseError?.(error);
|
|
2698
|
-
if (sseMaxRetryAttempts !== void 0 && attempt >= sseMaxRetryAttempts) {
|
|
2699
|
-
break;
|
|
2700
|
-
}
|
|
2701
|
-
const backoff = Math.min(
|
|
2702
|
-
retryDelay * 2 ** (attempt - 1),
|
|
2703
|
-
sseMaxRetryDelay ?? 3e4
|
|
2704
|
-
);
|
|
2705
|
-
await sleep(backoff);
|
|
2706
|
-
}
|
|
2707
|
-
}
|
|
2708
|
-
};
|
|
2709
|
-
const stream = createStream();
|
|
2710
|
-
return { stream };
|
|
2711
|
-
};
|
|
2712
|
-
|
|
2713
|
-
// src/client/core/pathSerializer.gen.ts
|
|
2714
|
-
var separatorArrayExplode = (style) => {
|
|
2715
|
-
switch (style) {
|
|
2716
|
-
case "label":
|
|
2717
|
-
return ".";
|
|
2718
|
-
case "matrix":
|
|
2719
|
-
return ";";
|
|
2720
|
-
case "simple":
|
|
2721
|
-
return ",";
|
|
2722
|
-
default:
|
|
2723
|
-
return "&";
|
|
2724
|
-
}
|
|
2725
|
-
};
|
|
2726
|
-
var separatorArrayNoExplode = (style) => {
|
|
2727
|
-
switch (style) {
|
|
2728
|
-
case "form":
|
|
2729
|
-
return ",";
|
|
2730
|
-
case "pipeDelimited":
|
|
2731
|
-
return "|";
|
|
2732
|
-
case "spaceDelimited":
|
|
2733
|
-
return "%20";
|
|
2734
|
-
default:
|
|
2735
|
-
return ",";
|
|
2736
|
-
}
|
|
2737
|
-
};
|
|
2738
|
-
var separatorObjectExplode = (style) => {
|
|
2739
|
-
switch (style) {
|
|
2740
|
-
case "label":
|
|
2741
|
-
return ".";
|
|
2742
|
-
case "matrix":
|
|
2743
|
-
return ";";
|
|
2744
|
-
case "simple":
|
|
2745
|
-
return ",";
|
|
2746
|
-
default:
|
|
2747
|
-
return "&";
|
|
2748
|
-
}
|
|
2749
|
-
};
|
|
2750
|
-
var serializeArrayParam = ({
|
|
2751
|
-
allowReserved,
|
|
2752
|
-
explode,
|
|
2753
|
-
name,
|
|
2754
|
-
style,
|
|
2755
|
-
value
|
|
2756
|
-
}) => {
|
|
2757
|
-
if (!explode) {
|
|
2758
|
-
const joinedValues2 = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join(separatorArrayNoExplode(style));
|
|
2759
|
-
switch (style) {
|
|
2760
|
-
case "label":
|
|
2761
|
-
return `.${joinedValues2}`;
|
|
2762
|
-
case "matrix":
|
|
2763
|
-
return `;${name}=${joinedValues2}`;
|
|
2764
|
-
case "simple":
|
|
2765
|
-
return joinedValues2;
|
|
2766
|
-
default:
|
|
2767
|
-
return `${name}=${joinedValues2}`;
|
|
2768
|
-
}
|
|
2769
|
-
}
|
|
2770
|
-
const separator = separatorArrayExplode(style);
|
|
2771
|
-
const joinedValues = value.map((v) => {
|
|
2772
|
-
if (style === "label" || style === "simple") {
|
|
2773
|
-
return allowReserved ? v : encodeURIComponent(v);
|
|
2774
|
-
}
|
|
2775
|
-
return serializePrimitiveParam({
|
|
2776
|
-
allowReserved,
|
|
2777
|
-
name,
|
|
2778
|
-
value: v
|
|
2779
|
-
});
|
|
2780
|
-
}).join(separator);
|
|
2781
|
-
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
|
|
2782
|
-
};
|
|
2783
|
-
var serializePrimitiveParam = ({
|
|
2784
|
-
allowReserved,
|
|
2785
|
-
name,
|
|
2786
|
-
value
|
|
2787
|
-
}) => {
|
|
2788
|
-
if (value === void 0 || value === null) {
|
|
2789
|
-
return "";
|
|
2790
|
-
}
|
|
2791
|
-
if (typeof value === "object") {
|
|
2792
|
-
throw new Error(
|
|
2793
|
-
"Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these."
|
|
2794
|
-
);
|
|
2795
|
-
}
|
|
2796
|
-
return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
|
|
2797
|
-
};
|
|
2798
|
-
var serializeObjectParam = ({
|
|
2799
|
-
allowReserved,
|
|
2800
|
-
explode,
|
|
2801
|
-
name,
|
|
2802
|
-
style,
|
|
2803
|
-
value,
|
|
2804
|
-
valueOnly
|
|
2805
|
-
}) => {
|
|
2806
|
-
if (value instanceof Date) {
|
|
2807
|
-
return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
|
|
2808
|
-
}
|
|
2809
|
-
if (style !== "deepObject" && !explode) {
|
|
2810
|
-
let values = [];
|
|
2811
|
-
Object.entries(value).forEach(([key, v]) => {
|
|
2812
|
-
values = [
|
|
2813
|
-
...values,
|
|
2814
|
-
key,
|
|
2815
|
-
allowReserved ? v : encodeURIComponent(v)
|
|
2816
|
-
];
|
|
2817
|
-
});
|
|
2818
|
-
const joinedValues2 = values.join(",");
|
|
2819
|
-
switch (style) {
|
|
2820
|
-
case "form":
|
|
2821
|
-
return `${name}=${joinedValues2}`;
|
|
2822
|
-
case "label":
|
|
2823
|
-
return `.${joinedValues2}`;
|
|
2824
|
-
case "matrix":
|
|
2825
|
-
return `;${name}=${joinedValues2}`;
|
|
2826
|
-
default:
|
|
2827
|
-
return joinedValues2;
|
|
2828
|
-
}
|
|
2829
|
-
}
|
|
2830
|
-
const separator = separatorObjectExplode(style);
|
|
2831
|
-
const joinedValues = Object.entries(value).map(
|
|
2832
|
-
([key, v]) => serializePrimitiveParam({
|
|
2833
|
-
allowReserved,
|
|
2834
|
-
name: style === "deepObject" ? `${name}[${key}]` : key,
|
|
2835
|
-
value: v
|
|
2836
|
-
})
|
|
2837
|
-
).join(separator);
|
|
2838
|
-
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
|
|
2839
|
-
};
|
|
2840
|
-
|
|
2841
|
-
// src/client/core/utils.gen.ts
|
|
2842
|
-
function getValidRequestBody(options) {
|
|
2843
|
-
const hasBody = options.body !== void 0;
|
|
2844
|
-
const isSerializedBody = hasBody && options.bodySerializer;
|
|
2845
|
-
if (isSerializedBody) {
|
|
2846
|
-
if ("serializedBody" in options) {
|
|
2847
|
-
const hasSerializedBody = options.serializedBody !== void 0 && options.serializedBody !== "";
|
|
2848
|
-
return hasSerializedBody ? options.serializedBody : null;
|
|
2849
|
-
}
|
|
2850
|
-
return options.body !== "" ? options.body : null;
|
|
2851
|
-
}
|
|
2852
|
-
if (hasBody) {
|
|
2853
|
-
return options.body;
|
|
2854
|
-
}
|
|
2855
|
-
return void 0;
|
|
2856
|
-
}
|
|
2857
|
-
|
|
2858
|
-
// src/client/core/auth.gen.ts
|
|
2859
|
-
var getAuthToken = async (auth, callback) => {
|
|
2860
|
-
const token = typeof callback === "function" ? await callback(auth) : callback;
|
|
2861
|
-
if (!token) {
|
|
2862
|
-
return;
|
|
2863
|
-
}
|
|
2864
|
-
if (auth.scheme === "bearer") {
|
|
2865
|
-
return `Bearer ${token}`;
|
|
2866
|
-
}
|
|
2867
|
-
if (auth.scheme === "basic") {
|
|
2868
|
-
return `Basic ${btoa(token)}`;
|
|
2869
|
-
}
|
|
2870
|
-
return token;
|
|
2871
|
-
};
|
|
2872
|
-
|
|
2873
|
-
// src/client/client/utils.gen.ts
|
|
2874
|
-
var PATH_PARAM_RE = /\{[^{}]+\}/g;
|
|
2875
|
-
var defaultPathSerializer = ({ path, url: _url }) => {
|
|
2876
|
-
let url = _url;
|
|
2877
|
-
const matches = _url.match(PATH_PARAM_RE);
|
|
2878
|
-
if (matches) {
|
|
2879
|
-
for (const match of matches) {
|
|
2880
|
-
let explode = false;
|
|
2881
|
-
let name = match.substring(1, match.length - 1);
|
|
2882
|
-
let style = "simple";
|
|
2883
|
-
if (name.endsWith("*")) {
|
|
2884
|
-
explode = true;
|
|
2885
|
-
name = name.substring(0, name.length - 1);
|
|
2886
|
-
}
|
|
2887
|
-
if (name.startsWith(".")) {
|
|
2888
|
-
name = name.substring(1);
|
|
2889
|
-
style = "label";
|
|
2890
|
-
} else if (name.startsWith(";")) {
|
|
2891
|
-
name = name.substring(1);
|
|
2892
|
-
style = "matrix";
|
|
2893
|
-
}
|
|
2894
|
-
const value = path[name];
|
|
2895
|
-
if (value === void 0 || value === null) {
|
|
2896
|
-
continue;
|
|
2897
|
-
}
|
|
2898
|
-
if (Array.isArray(value)) {
|
|
2899
|
-
url = url.replace(
|
|
2900
|
-
match,
|
|
2901
|
-
serializeArrayParam({ explode, name, style, value })
|
|
2902
|
-
);
|
|
2903
|
-
continue;
|
|
2904
|
-
}
|
|
2905
|
-
if (typeof value === "object") {
|
|
2906
|
-
url = url.replace(
|
|
2907
|
-
match,
|
|
2908
|
-
serializeObjectParam({
|
|
2909
|
-
explode,
|
|
2910
|
-
name,
|
|
2911
|
-
style,
|
|
2912
|
-
value,
|
|
2913
|
-
valueOnly: true
|
|
2914
|
-
})
|
|
2915
|
-
);
|
|
2916
|
-
continue;
|
|
2917
|
-
}
|
|
2918
|
-
if (style === "matrix") {
|
|
2919
|
-
url = url.replace(
|
|
2920
|
-
match,
|
|
2921
|
-
`;${serializePrimitiveParam({
|
|
2922
|
-
name,
|
|
2923
|
-
value
|
|
2924
|
-
})}`
|
|
2925
|
-
);
|
|
2926
|
-
continue;
|
|
2927
|
-
}
|
|
2928
|
-
const replaceValue = encodeURIComponent(
|
|
2929
|
-
style === "label" ? `.${value}` : value
|
|
2930
|
-
);
|
|
2931
|
-
url = url.replace(match, replaceValue);
|
|
2932
|
-
}
|
|
2933
|
-
}
|
|
2934
|
-
return url;
|
|
2935
|
-
};
|
|
2936
|
-
var createQuerySerializer = ({
|
|
2937
|
-
parameters = {},
|
|
2938
|
-
...args
|
|
2939
|
-
} = {}) => {
|
|
2940
|
-
const querySerializer = (queryParams) => {
|
|
2941
|
-
const search = [];
|
|
2942
|
-
if (queryParams && typeof queryParams === "object") {
|
|
2943
|
-
for (const name in queryParams) {
|
|
2944
|
-
const value = queryParams[name];
|
|
2945
|
-
if (value === void 0 || value === null) {
|
|
2946
|
-
continue;
|
|
2947
|
-
}
|
|
2948
|
-
const options = parameters[name] || args;
|
|
2949
|
-
if (Array.isArray(value)) {
|
|
2950
|
-
const serializedArray = serializeArrayParam({
|
|
2951
|
-
allowReserved: options.allowReserved,
|
|
2952
|
-
explode: true,
|
|
2953
|
-
name,
|
|
2954
|
-
style: "form",
|
|
2955
|
-
value,
|
|
2956
|
-
...options.array
|
|
2957
|
-
});
|
|
2958
|
-
if (serializedArray) search.push(serializedArray);
|
|
2959
|
-
} else if (typeof value === "object") {
|
|
2960
|
-
const serializedObject = serializeObjectParam({
|
|
2961
|
-
allowReserved: options.allowReserved,
|
|
2962
|
-
explode: true,
|
|
2963
|
-
name,
|
|
2964
|
-
style: "deepObject",
|
|
2965
|
-
value,
|
|
2966
|
-
...options.object
|
|
2967
|
-
});
|
|
2968
|
-
if (serializedObject) search.push(serializedObject);
|
|
2969
|
-
} else {
|
|
2970
|
-
const serializedPrimitive = serializePrimitiveParam({
|
|
2971
|
-
allowReserved: options.allowReserved,
|
|
2972
|
-
name,
|
|
2973
|
-
value
|
|
2974
|
-
});
|
|
2975
|
-
if (serializedPrimitive) search.push(serializedPrimitive);
|
|
2976
|
-
}
|
|
2977
|
-
}
|
|
2978
|
-
}
|
|
2979
|
-
return search.join("&");
|
|
2980
|
-
};
|
|
2981
|
-
return querySerializer;
|
|
2982
|
-
};
|
|
2983
|
-
var getParseAs = (contentType) => {
|
|
2984
|
-
if (!contentType) {
|
|
2985
|
-
return "stream";
|
|
2986
|
-
}
|
|
2987
|
-
const cleanContent = contentType.split(";")[0]?.trim();
|
|
2988
|
-
if (!cleanContent) {
|
|
2989
|
-
return;
|
|
2990
|
-
}
|
|
2991
|
-
if (cleanContent.startsWith("application/json") || cleanContent.endsWith("+json")) {
|
|
2992
|
-
return "json";
|
|
2993
|
-
}
|
|
2994
|
-
if (cleanContent === "multipart/form-data") {
|
|
2995
|
-
return "formData";
|
|
2996
|
-
}
|
|
2997
|
-
if (["application/", "audio/", "image/", "video/"].some(
|
|
2998
|
-
(type) => cleanContent.startsWith(type)
|
|
2999
|
-
)) {
|
|
3000
|
-
return "blob";
|
|
3001
|
-
}
|
|
3002
|
-
if (cleanContent.startsWith("text/")) {
|
|
3003
|
-
return "text";
|
|
3004
|
-
}
|
|
3005
|
-
return;
|
|
3006
|
-
};
|
|
3007
|
-
var checkForExistence = (options, name) => {
|
|
3008
|
-
if (!name) {
|
|
3009
|
-
return false;
|
|
3010
|
-
}
|
|
3011
|
-
if (options.headers.has(name) || options.query?.[name] || options.headers.get("Cookie")?.includes(`${name}=`)) {
|
|
3012
|
-
return true;
|
|
3013
|
-
}
|
|
3014
|
-
return false;
|
|
3015
|
-
};
|
|
3016
|
-
var setAuthParams = async ({
|
|
3017
|
-
security,
|
|
3018
|
-
...options
|
|
3019
|
-
}) => {
|
|
3020
|
-
for (const auth of security) {
|
|
3021
|
-
if (checkForExistence(options, auth.name)) {
|
|
3022
|
-
continue;
|
|
3023
|
-
}
|
|
3024
|
-
const token = await getAuthToken(auth, options.auth);
|
|
3025
|
-
if (!token) {
|
|
3026
|
-
continue;
|
|
3027
|
-
}
|
|
3028
|
-
const name = auth.name ?? "Authorization";
|
|
3029
|
-
switch (auth.in) {
|
|
3030
|
-
case "query":
|
|
3031
|
-
if (!options.query) {
|
|
3032
|
-
options.query = {};
|
|
3033
|
-
}
|
|
3034
|
-
options.query[name] = token;
|
|
3035
|
-
break;
|
|
3036
|
-
case "cookie":
|
|
3037
|
-
options.headers.append("Cookie", `${name}=${token}`);
|
|
3038
|
-
break;
|
|
3039
|
-
case "header":
|
|
3040
|
-
default:
|
|
3041
|
-
options.headers.set(name, token);
|
|
3042
|
-
break;
|
|
3043
|
-
}
|
|
3044
|
-
}
|
|
3045
|
-
};
|
|
3046
|
-
var buildUrl = (options) => {
|
|
3047
|
-
const url = getUrl({
|
|
3048
|
-
baseUrl: options.baseUrl,
|
|
3049
|
-
path: options.path,
|
|
3050
|
-
query: options.query,
|
|
3051
|
-
querySerializer: typeof options.querySerializer === "function" ? options.querySerializer : createQuerySerializer(options.querySerializer),
|
|
3052
|
-
url: options.url
|
|
3053
|
-
});
|
|
3054
|
-
return url;
|
|
3055
|
-
};
|
|
3056
|
-
var getUrl = ({
|
|
3057
|
-
baseUrl,
|
|
3058
|
-
path,
|
|
3059
|
-
query,
|
|
3060
|
-
querySerializer,
|
|
3061
|
-
url: _url
|
|
3062
|
-
}) => {
|
|
3063
|
-
const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
|
|
3064
|
-
let url = (baseUrl ?? "") + pathUrl;
|
|
3065
|
-
if (path) {
|
|
3066
|
-
url = defaultPathSerializer({ path, url });
|
|
3067
|
-
}
|
|
3068
|
-
let search = query ? querySerializer(query) : "";
|
|
3069
|
-
if (search.startsWith("?")) {
|
|
3070
|
-
search = search.substring(1);
|
|
3071
|
-
}
|
|
3072
|
-
if (search) {
|
|
3073
|
-
url += `?${search}`;
|
|
3074
|
-
}
|
|
3075
|
-
return url;
|
|
3076
|
-
};
|
|
3077
|
-
var mergeConfigs = (a, b) => {
|
|
3078
|
-
const config = { ...a, ...b };
|
|
3079
|
-
if (config.baseUrl?.endsWith("/")) {
|
|
3080
|
-
config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
|
|
3081
|
-
}
|
|
3082
|
-
config.headers = mergeHeaders(a.headers, b.headers);
|
|
3083
|
-
return config;
|
|
3084
|
-
};
|
|
3085
|
-
var headersEntries = (headers) => {
|
|
3086
|
-
const entries = [];
|
|
3087
|
-
headers.forEach((value, key) => {
|
|
3088
|
-
entries.push([key, value]);
|
|
3089
|
-
});
|
|
3090
|
-
return entries;
|
|
3091
|
-
};
|
|
3092
|
-
var mergeHeaders = (...headers) => {
|
|
3093
|
-
const mergedHeaders = new Headers();
|
|
3094
|
-
for (const header of headers) {
|
|
3095
|
-
if (!header || typeof header !== "object") {
|
|
3096
|
-
continue;
|
|
3097
|
-
}
|
|
3098
|
-
const iterator = header instanceof Headers ? headersEntries(header) : Object.entries(header);
|
|
3099
|
-
for (const [key, value] of iterator) {
|
|
3100
|
-
if (value === null) {
|
|
3101
|
-
mergedHeaders.delete(key);
|
|
3102
|
-
} else if (Array.isArray(value)) {
|
|
3103
|
-
for (const v of value) {
|
|
3104
|
-
mergedHeaders.append(key, v);
|
|
3105
|
-
}
|
|
3106
|
-
} else if (value !== void 0) {
|
|
3107
|
-
mergedHeaders.set(
|
|
3108
|
-
key,
|
|
3109
|
-
typeof value === "object" ? JSON.stringify(value) : value
|
|
3110
|
-
);
|
|
3111
|
-
}
|
|
3112
|
-
}
|
|
3113
|
-
}
|
|
3114
|
-
return mergedHeaders;
|
|
3115
|
-
};
|
|
3116
|
-
var Interceptors = class {
|
|
3117
|
-
constructor() {
|
|
3118
|
-
this.fns = [];
|
|
3119
|
-
}
|
|
3120
|
-
clear() {
|
|
3121
|
-
this.fns = [];
|
|
3122
|
-
}
|
|
3123
|
-
eject(id) {
|
|
3124
|
-
const index = this.getInterceptorIndex(id);
|
|
3125
|
-
if (this.fns[index]) {
|
|
3126
|
-
this.fns[index] = null;
|
|
3127
|
-
}
|
|
3128
|
-
}
|
|
3129
|
-
exists(id) {
|
|
3130
|
-
const index = this.getInterceptorIndex(id);
|
|
3131
|
-
return Boolean(this.fns[index]);
|
|
3132
|
-
}
|
|
3133
|
-
getInterceptorIndex(id) {
|
|
3134
|
-
if (typeof id === "number") {
|
|
3135
|
-
return this.fns[id] ? id : -1;
|
|
3136
|
-
}
|
|
3137
|
-
return this.fns.indexOf(id);
|
|
3138
|
-
}
|
|
3139
|
-
update(id, fn) {
|
|
3140
|
-
const index = this.getInterceptorIndex(id);
|
|
3141
|
-
if (this.fns[index]) {
|
|
3142
|
-
this.fns[index] = fn;
|
|
3143
|
-
return id;
|
|
3144
|
-
}
|
|
3145
|
-
return false;
|
|
3146
|
-
}
|
|
3147
|
-
use(fn) {
|
|
3148
|
-
this.fns.push(fn);
|
|
3149
|
-
return this.fns.length - 1;
|
|
3150
|
-
}
|
|
3151
|
-
};
|
|
3152
|
-
var createInterceptors = () => ({
|
|
3153
|
-
error: new Interceptors(),
|
|
3154
|
-
request: new Interceptors(),
|
|
3155
|
-
response: new Interceptors()
|
|
3156
|
-
});
|
|
3157
|
-
var defaultQuerySerializer = createQuerySerializer({
|
|
3158
|
-
allowReserved: false,
|
|
3159
|
-
array: {
|
|
3160
|
-
explode: true,
|
|
3161
|
-
style: "form"
|
|
3162
|
-
},
|
|
3163
|
-
object: {
|
|
3164
|
-
explode: true,
|
|
3165
|
-
style: "deepObject"
|
|
3166
|
-
}
|
|
3167
|
-
});
|
|
3168
|
-
var defaultHeaders = {
|
|
3169
|
-
"Content-Type": "application/json"
|
|
3170
|
-
};
|
|
3171
|
-
var createConfig = (override = {}) => ({
|
|
3172
|
-
...jsonBodySerializer,
|
|
3173
|
-
headers: defaultHeaders,
|
|
3174
|
-
parseAs: "auto",
|
|
3175
|
-
querySerializer: defaultQuerySerializer,
|
|
3176
|
-
...override
|
|
3177
|
-
});
|
|
3178
|
-
|
|
3179
|
-
// src/client/client/client.gen.ts
|
|
3180
|
-
var createClient = (config = {}) => {
|
|
3181
|
-
let _config = mergeConfigs(createConfig(), config);
|
|
3182
|
-
const getConfig = () => ({ ..._config });
|
|
3183
|
-
const setConfig = (config2) => {
|
|
3184
|
-
_config = mergeConfigs(_config, config2);
|
|
3185
|
-
return getConfig();
|
|
3186
|
-
};
|
|
3187
|
-
const interceptors = createInterceptors();
|
|
3188
|
-
const beforeRequest = async (options) => {
|
|
3189
|
-
const opts = {
|
|
3190
|
-
..._config,
|
|
3191
|
-
...options,
|
|
3192
|
-
fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
|
|
3193
|
-
headers: mergeHeaders(_config.headers, options.headers),
|
|
3194
|
-
serializedBody: void 0
|
|
3195
|
-
};
|
|
3196
|
-
if (opts.security) {
|
|
3197
|
-
await setAuthParams({
|
|
3198
|
-
...opts,
|
|
3199
|
-
security: opts.security
|
|
3200
|
-
});
|
|
3201
|
-
}
|
|
3202
|
-
if (opts.requestValidator) {
|
|
3203
|
-
await opts.requestValidator(opts);
|
|
3204
|
-
}
|
|
3205
|
-
if (opts.body !== void 0 && opts.bodySerializer) {
|
|
3206
|
-
opts.serializedBody = opts.bodySerializer(opts.body);
|
|
3207
|
-
}
|
|
3208
|
-
if (opts.body === void 0 || opts.serializedBody === "") {
|
|
3209
|
-
opts.headers.delete("Content-Type");
|
|
3210
|
-
}
|
|
3211
|
-
const url = buildUrl(opts);
|
|
3212
|
-
return { opts, url };
|
|
3213
|
-
};
|
|
3214
|
-
const request = async (options) => {
|
|
3215
|
-
const { opts, url } = await beforeRequest(options);
|
|
3216
|
-
for (const fn of interceptors.request.fns) {
|
|
3217
|
-
if (fn) {
|
|
3218
|
-
await fn(opts);
|
|
3219
|
-
}
|
|
3220
|
-
}
|
|
3221
|
-
const _fetch = opts.fetch;
|
|
3222
|
-
const requestInit = {
|
|
3223
|
-
...opts,
|
|
3224
|
-
body: getValidRequestBody(opts)
|
|
3225
|
-
};
|
|
3226
|
-
let response = await _fetch(url, requestInit);
|
|
3227
|
-
for (const fn of interceptors.response.fns) {
|
|
3228
|
-
if (fn) {
|
|
3229
|
-
response = await fn(response, opts);
|
|
3230
|
-
}
|
|
3231
|
-
}
|
|
3232
|
-
const result = {
|
|
3233
|
-
response
|
|
3234
|
-
};
|
|
3235
|
-
if (response.ok) {
|
|
3236
|
-
const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
|
|
3237
|
-
if (response.status === 204 || response.headers.get("Content-Length") === "0") {
|
|
3238
|
-
let emptyData;
|
|
3239
|
-
switch (parseAs) {
|
|
3240
|
-
case "arrayBuffer":
|
|
3241
|
-
case "blob":
|
|
3242
|
-
case "text":
|
|
3243
|
-
emptyData = await response[parseAs]();
|
|
3244
|
-
break;
|
|
3245
|
-
case "formData":
|
|
3246
|
-
emptyData = new FormData();
|
|
3247
|
-
break;
|
|
3248
|
-
case "stream":
|
|
3249
|
-
emptyData = response.body;
|
|
3250
|
-
break;
|
|
3251
|
-
case "json":
|
|
3252
|
-
default:
|
|
3253
|
-
emptyData = {};
|
|
3254
|
-
break;
|
|
3255
|
-
}
|
|
3256
|
-
return {
|
|
3257
|
-
data: emptyData,
|
|
3258
|
-
...result
|
|
3259
|
-
};
|
|
3260
|
-
}
|
|
3261
|
-
let data;
|
|
3262
|
-
switch (parseAs) {
|
|
3263
|
-
case "arrayBuffer":
|
|
3264
|
-
case "blob":
|
|
3265
|
-
case "formData":
|
|
3266
|
-
case "json":
|
|
3267
|
-
case "text":
|
|
3268
|
-
data = await response[parseAs]();
|
|
3269
|
-
break;
|
|
3270
|
-
case "stream":
|
|
3271
|
-
return {
|
|
3272
|
-
data: response.body,
|
|
3273
|
-
...result
|
|
3274
|
-
};
|
|
3275
|
-
}
|
|
3276
|
-
if (parseAs === "json") {
|
|
3277
|
-
if (opts.responseValidator) {
|
|
3278
|
-
await opts.responseValidator(data);
|
|
3279
|
-
}
|
|
3280
|
-
if (opts.responseTransformer) {
|
|
3281
|
-
data = await opts.responseTransformer(data);
|
|
3282
|
-
}
|
|
3283
|
-
}
|
|
3284
|
-
return {
|
|
3285
|
-
data,
|
|
3286
|
-
...result
|
|
3287
|
-
};
|
|
3288
|
-
}
|
|
3289
|
-
const textError = await response.text();
|
|
3290
|
-
let jsonError;
|
|
3291
|
-
try {
|
|
3292
|
-
jsonError = JSON.parse(textError);
|
|
3293
|
-
} catch {
|
|
3294
|
-
}
|
|
3295
|
-
const error = jsonError ?? textError;
|
|
3296
|
-
let finalError = error;
|
|
3297
|
-
for (const fn of interceptors.error.fns) {
|
|
3298
|
-
if (fn) {
|
|
3299
|
-
finalError = await fn(error, response, opts);
|
|
3300
|
-
}
|
|
3301
|
-
}
|
|
3302
|
-
finalError = finalError || {};
|
|
3303
|
-
if (opts.throwOnError) {
|
|
3304
|
-
throw finalError;
|
|
3305
|
-
}
|
|
3306
|
-
return {
|
|
3307
|
-
error: finalError,
|
|
3308
|
-
...result
|
|
3309
|
-
};
|
|
3310
|
-
};
|
|
3311
|
-
const makeMethodFn = (method) => (options) => request({ ...options, method });
|
|
3312
|
-
const makeSseFn = (method) => async (options) => {
|
|
3313
|
-
const { opts, url } = await beforeRequest(options);
|
|
3314
|
-
return createSseClient({
|
|
3315
|
-
...opts,
|
|
3316
|
-
body: opts.body,
|
|
3317
|
-
headers: opts.headers,
|
|
3318
|
-
method,
|
|
3319
|
-
onRequest: async (url2, init) => {
|
|
3320
|
-
let request2 = new Request(url2, init);
|
|
3321
|
-
const requestInit = {
|
|
3322
|
-
...init,
|
|
3323
|
-
method: init.method,
|
|
3324
|
-
url: url2
|
|
3325
|
-
};
|
|
3326
|
-
for (const fn of interceptors.request.fns) {
|
|
3327
|
-
if (fn) {
|
|
3328
|
-
await fn(requestInit);
|
|
3329
|
-
request2 = new Request(requestInit.url, requestInit);
|
|
3330
|
-
}
|
|
3331
|
-
}
|
|
3332
|
-
return request2;
|
|
3333
|
-
},
|
|
3334
|
-
url
|
|
3335
|
-
});
|
|
3336
|
-
};
|
|
3337
|
-
return {
|
|
3338
|
-
buildUrl,
|
|
3339
|
-
connect: makeMethodFn("CONNECT"),
|
|
3340
|
-
delete: makeMethodFn("DELETE"),
|
|
3341
|
-
get: makeMethodFn("GET"),
|
|
3342
|
-
getConfig,
|
|
3343
|
-
head: makeMethodFn("HEAD"),
|
|
3344
|
-
interceptors,
|
|
3345
|
-
options: makeMethodFn("OPTIONS"),
|
|
3346
|
-
patch: makeMethodFn("PATCH"),
|
|
3347
|
-
post: makeMethodFn("POST"),
|
|
3348
|
-
put: makeMethodFn("PUT"),
|
|
3349
|
-
request,
|
|
3350
|
-
setConfig,
|
|
3351
|
-
sse: {
|
|
3352
|
-
connect: makeSseFn("CONNECT"),
|
|
3353
|
-
delete: makeSseFn("DELETE"),
|
|
3354
|
-
get: makeSseFn("GET"),
|
|
3355
|
-
head: makeSseFn("HEAD"),
|
|
3356
|
-
options: makeSseFn("OPTIONS"),
|
|
3357
|
-
patch: makeSseFn("PATCH"),
|
|
3358
|
-
post: makeSseFn("POST"),
|
|
3359
|
-
put: makeSseFn("PUT"),
|
|
3360
|
-
trace: makeSseFn("TRACE")
|
|
3361
|
-
},
|
|
3362
|
-
trace: makeMethodFn("TRACE")
|
|
3363
|
-
};
|
|
3364
|
-
};
|
|
3365
|
-
|
|
3366
|
-
// src/client/client.gen.ts
|
|
3367
|
-
var client = createClient(createClientConfig(createConfig()));
|
|
3368
|
-
|
|
3369
|
-
// src/client/sdk.gen.ts
|
|
3370
|
-
var getApiV1CreditsBalance = (options) => {
|
|
3371
|
-
return (options?.client ?? client).get({
|
|
3372
|
-
url: "/api/v1/credits/balance",
|
|
3373
|
-
...options
|
|
3374
|
-
});
|
|
3375
|
-
};
|
|
3376
|
-
var getApiV1CreditsPacks = (options) => {
|
|
3377
|
-
return (options?.client ?? client).get({
|
|
3378
|
-
url: "/api/v1/credits/packs",
|
|
3379
|
-
...options
|
|
3380
|
-
});
|
|
3381
|
-
};
|
|
3382
|
-
var postApiV1CreditsPurchase = (options) => {
|
|
3383
|
-
return (options.client ?? client).post({
|
|
3384
|
-
url: "/api/v1/credits/purchase",
|
|
3385
|
-
...options,
|
|
3386
|
-
headers: {
|
|
3387
|
-
"Content-Type": "application/json",
|
|
3388
|
-
...options.headers
|
|
3389
|
-
}
|
|
3390
|
-
});
|
|
3391
|
-
};
|
|
3392
|
-
var postApiV1Embeddings = (options) => {
|
|
3393
|
-
return (options.client ?? client).post({
|
|
3394
|
-
url: "/api/v1/embeddings",
|
|
3395
|
-
...options,
|
|
3396
|
-
headers: {
|
|
3397
|
-
"Content-Type": "application/json",
|
|
3398
|
-
...options.headers
|
|
3399
|
-
}
|
|
3400
|
-
});
|
|
3401
|
-
};
|
|
3402
|
-
var getApiV1Models = (options) => {
|
|
3403
|
-
return (options?.client ?? client).get({
|
|
3404
|
-
url: "/api/v1/models",
|
|
3405
|
-
...options
|
|
3406
|
-
});
|
|
3407
|
-
};
|
|
3408
|
-
|
|
3409
2575
|
// src/lib/memoryEngine/chunking.ts
|
|
3410
2576
|
var DEFAULT_CHUNK_SIZE = 400;
|
|
3411
2577
|
var DEFAULT_CHUNK_OVERLAP = 50;
|
|
@@ -3541,8 +2707,8 @@ function shouldChunkMessage(content, chunkSize = DEFAULT_CHUNK_SIZE) {
|
|
|
3541
2707
|
return content.length > chunkSize;
|
|
3542
2708
|
}
|
|
3543
2709
|
|
|
3544
|
-
// src/lib/memoryEngine/
|
|
3545
|
-
|
|
2710
|
+
// src/lib/memoryEngine/generate.ts
|
|
2711
|
+
import { postApiV1Embeddings } from "@anuma/sdk";
|
|
3546
2712
|
var EMBED_MAX_ATTEMPTS = 4;
|
|
3547
2713
|
async function withEmbeddingRetry(call) {
|
|
3548
2714
|
let last;
|
|
@@ -3736,6 +2902,9 @@ async function generateEmbeddings(texts, options) {
|
|
|
3736
2902
|
}
|
|
3737
2903
|
return results;
|
|
3738
2904
|
}
|
|
2905
|
+
|
|
2906
|
+
// src/lib/memoryEngine/embeddings.ts
|
|
2907
|
+
var DEFAULT_MIN_CONTENT_LENGTH = 10;
|
|
3739
2908
|
async function embedMessage(ctx, messageId, options) {
|
|
3740
2909
|
let message;
|
|
3741
2910
|
const conversations = await getConversationsOp(ctx);
|
|
@@ -5155,7 +4324,7 @@ function createMemoryVaultSearchTool(vaultCtx, embeddingOptions, cache, searchOp
|
|
|
5155
4324
|
legacy.map((r) => ({ id: r.uniqueId, content: r.content, score: r.similarity }))
|
|
5156
4325
|
);
|
|
5157
4326
|
}
|
|
5158
|
-
const { recall: recall2 } = await import("./recall-
|
|
4327
|
+
const { recall: recall2 } = await import("./recall-LICO3TJ7.mjs");
|
|
5159
4328
|
const result = await recall2(
|
|
5160
4329
|
query,
|
|
5161
4330
|
{ vaultCtx, embeddingOptions, vaultCache: cache },
|
|
@@ -5775,11 +4944,6 @@ function toChunkMemory(r) {
|
|
|
5775
4944
|
}
|
|
5776
4945
|
|
|
5777
4946
|
export {
|
|
5778
|
-
createSseClient,
|
|
5779
|
-
getApiV1CreditsBalance,
|
|
5780
|
-
getApiV1CreditsPacks,
|
|
5781
|
-
postApiV1CreditsPurchase,
|
|
5782
|
-
getApiV1Models,
|
|
5783
4947
|
onClearAllEncryptionState,
|
|
5784
4948
|
onKeyAvailable,
|
|
5785
4949
|
clearEncryptionKey,
|
|
@@ -5795,6 +4959,7 @@ export {
|
|
|
5795
4959
|
encryptJsonField,
|
|
5796
4960
|
decryptJsonField,
|
|
5797
4961
|
getToolCallEvents,
|
|
4962
|
+
getToolsChecksum,
|
|
5798
4963
|
getImageModel,
|
|
5799
4964
|
extractAssistantText,
|
|
5800
4965
|
stripToolCalls,
|
|
@@ -5820,6 +4985,7 @@ export {
|
|
|
5820
4985
|
createMessageOp,
|
|
5821
4986
|
upsertMessageOp,
|
|
5822
4987
|
updateMessageEmbeddingOp,
|
|
4988
|
+
updateMessageChunksOp,
|
|
5823
4989
|
updateMessageErrorOp,
|
|
5824
4990
|
searchChunksOp,
|
|
5825
4991
|
makeSyntheticStoredMessage,
|
|
@@ -5830,9 +4996,9 @@ export {
|
|
|
5830
4996
|
chunkText,
|
|
5831
4997
|
shouldChunkMessage,
|
|
5832
4998
|
DEFAULT_API_EMBEDDING_MODEL,
|
|
5833
|
-
DEFAULT_MIN_CONTENT_LENGTH,
|
|
5834
4999
|
generateEmbedding,
|
|
5835
5000
|
generateEmbeddings,
|
|
5001
|
+
DEFAULT_MIN_CONTENT_LENGTH,
|
|
5836
5002
|
embedMessage,
|
|
5837
5003
|
embedAllMessages,
|
|
5838
5004
|
chunkAndEmbedMessage,
|