@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.
- package/dist/expo/{chunk-7TATXBC5.mjs → chunk-AAB7OG7Q.mjs} +810 -4
- package/dist/{react/chunk-DFVCS3QQ.mjs → expo/chunk-BOY27A2C.mjs} +30 -3
- package/dist/expo/{consolidate-3QQPUWD6.mjs → consolidate-J5PHQKKY.mjs} +1 -1
- package/dist/expo/index.cjs +931 -825
- package/dist/expo/index.d.mts +9 -0
- package/dist/expo/index.d.ts +9 -0
- package/dist/expo/index.mjs +14 -817
- package/dist/{react/recall-OPKHWKZX.mjs → expo/recall-YVU7OSSJ.mjs} +2 -2
- package/dist/react/{chunk-DDHTJGZN.mjs → chunk-3VPEZDYL.mjs} +896 -4
- package/dist/{expo/chunk-DFVCS3QQ.mjs → react/chunk-BOY27A2C.mjs} +30 -3
- package/dist/react/{consolidate-3MXZV3G7.mjs → consolidate-PWJCAPZA.mjs} +1 -1
- package/dist/react/index.cjs +2021 -1907
- package/dist/react/index.d.mts +9 -0
- package/dist/react/index.d.ts +9 -0
- package/dist/react/index.mjs +29 -888
- package/dist/{expo/recall-IO4KJ5W7.mjs → react/recall-Z7BWJ67X.mjs} +2 -2
- package/dist/server/{chunk-V7SVKIXQ.mjs → chunk-LSKFJNLF.mjs} +795 -4
- package/dist/server/{chunk-AHJT66EO.mjs → chunk-MIXEASUP.mjs} +30 -3
- package/dist/server/{consolidate-CN2GQV4D.mjs → consolidate-PCHO3D3G.mjs} +1 -1
- package/dist/server/index.cjs +925 -163
- package/dist/server/index.d.mts +36 -0
- package/dist/server/index.d.ts +36 -0
- package/dist/server/index.mjs +9 -147
- package/dist/server/{recall-IWY2MYHR.mjs → recall-XEOLXA6P.mjs} +2 -2
- package/dist/tools/selection/index.cjs +793 -3
- package/dist/tools/selection/index.mjs +791 -3
- package/package.json +2 -2
|
@@ -14,6 +14,24 @@ function getLogger() {
|
|
|
14
14
|
return currentLogger;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
// src/lib/chat/endpointOverride.ts
|
|
18
|
+
function validateEndpointOverride(override) {
|
|
19
|
+
const trimmed = override.trim();
|
|
20
|
+
if (trimmed === "") {
|
|
21
|
+
return {
|
|
22
|
+
valid: false,
|
|
23
|
+
message: 'endpointOverride must be a non-empty, root-relative path (e.g. "/api/v1/utility/responses"); received an empty or whitespace-only string'
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
if (trimmed.startsWith("//") || trimmed.includes("://")) {
|
|
27
|
+
return {
|
|
28
|
+
valid: false,
|
|
29
|
+
message: `endpointOverride must be a root-relative path (e.g. "/api/v1/utility/responses"), not a protocol-relative or absolute URL; received "${trimmed}"`
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
return { valid: true, endpoint: trimmed.startsWith("/") ? trimmed : `/${trimmed}` };
|
|
33
|
+
}
|
|
34
|
+
|
|
17
35
|
// src/lib/memory/portalLlm.ts
|
|
18
36
|
function defaultBaseUrl() {
|
|
19
37
|
return typeof process !== "undefined" && process.env?.ANUMA_PORTAL_BASE_URL || BASE_URL;
|
|
@@ -65,6 +83,14 @@ async function resolvePortalAuthHeaders(auth, tag) {
|
|
|
65
83
|
}
|
|
66
84
|
async function callPortalJsonCompletion(req) {
|
|
67
85
|
const log = getLogger();
|
|
86
|
+
let endpoint = "/api/v1/chat/completions";
|
|
87
|
+
if (req.endpointOverride !== void 0) {
|
|
88
|
+
const overrideValidation = validateEndpointOverride(req.endpointOverride);
|
|
89
|
+
if (!overrideValidation.valid) {
|
|
90
|
+
throw new Error(overrideValidation.message);
|
|
91
|
+
}
|
|
92
|
+
endpoint = overrideValidation.endpoint;
|
|
93
|
+
}
|
|
68
94
|
const maxAttempts = Math.max(1, req.maxAttempts ?? 3);
|
|
69
95
|
const startedAt = Date.now();
|
|
70
96
|
const overBudget = () => req.totalTimeoutMs !== void 0 && Date.now() - startedAt >= req.totalTimeoutMs;
|
|
@@ -80,7 +106,7 @@ async function callPortalJsonCompletion(req) {
|
|
|
80
106
|
Math.min(req.timeoutMs ?? 6e4, req.totalTimeoutMs - (Date.now() - startedAt))
|
|
81
107
|
)
|
|
82
108
|
} : req;
|
|
83
|
-
const outcome = await attemptPortalJson(attemptReq);
|
|
109
|
+
const outcome = await attemptPortalJson(attemptReq, endpoint);
|
|
84
110
|
if (outcome.kind === "ok") return outcome.value;
|
|
85
111
|
if (outcome.kind === "terminal") {
|
|
86
112
|
log.warn(`[${req.tag}] ${outcome.reason}`);
|
|
@@ -103,7 +129,7 @@ async function callPortalJsonCompletion(req) {
|
|
|
103
129
|
}
|
|
104
130
|
return null;
|
|
105
131
|
}
|
|
106
|
-
async function attemptPortalJson(req) {
|
|
132
|
+
async function attemptPortalJson(req, endpoint) {
|
|
107
133
|
const baseUrl = req.baseUrl ?? defaultBaseUrl();
|
|
108
134
|
const fetchImpl = req.fetchFn ?? fetch;
|
|
109
135
|
const timeoutMs = req.timeoutMs ?? 6e4;
|
|
@@ -128,7 +154,7 @@ async function attemptPortalJson(req) {
|
|
|
128
154
|
if (!supportsJsonObjectFormat) delete requestBody.response_format;
|
|
129
155
|
let response;
|
|
130
156
|
try {
|
|
131
|
-
response = await fetchImpl(`${baseUrl}
|
|
157
|
+
response = await fetchImpl(`${baseUrl}${endpoint}`, {
|
|
132
158
|
method: "POST",
|
|
133
159
|
headers: { ...authHeaders, "Content-Type": "application/json" },
|
|
134
160
|
body: JSON.stringify(requestBody),
|
|
@@ -223,6 +249,7 @@ function extractCompletionContent(body) {
|
|
|
223
249
|
|
|
224
250
|
export {
|
|
225
251
|
getLogger,
|
|
252
|
+
validateEndpointOverride,
|
|
226
253
|
supportsResponseFormat,
|
|
227
254
|
resolvePortalAuthHeaders,
|
|
228
255
|
callPortalJsonCompletion,
|