@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
|
@@ -27,6 +27,24 @@ function getLogger() {
|
|
|
27
27
|
return currentLogger;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
// src/lib/chat/endpointOverride.ts
|
|
31
|
+
function validateEndpointOverride(override) {
|
|
32
|
+
const trimmed = override.trim();
|
|
33
|
+
if (trimmed === "") {
|
|
34
|
+
return {
|
|
35
|
+
valid: false,
|
|
36
|
+
message: 'endpointOverride must be a non-empty, root-relative path (e.g. "/api/v1/utility/responses"); received an empty or whitespace-only string'
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
if (trimmed.startsWith("//") || trimmed.includes("://")) {
|
|
40
|
+
return {
|
|
41
|
+
valid: false,
|
|
42
|
+
message: `endpointOverride must be a root-relative path (e.g. "/api/v1/utility/responses"), not a protocol-relative or absolute URL; received "${trimmed}"`
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
return { valid: true, endpoint: trimmed.startsWith("/") ? trimmed : `/${trimmed}` };
|
|
46
|
+
}
|
|
47
|
+
|
|
30
48
|
// src/lib/memory/portalLlm.ts
|
|
31
49
|
function defaultBaseUrl() {
|
|
32
50
|
return typeof process !== "undefined" && process.env?.ANUMA_PORTAL_BASE_URL || BASE_URL;
|
|
@@ -78,6 +96,14 @@ async function resolvePortalAuthHeaders(auth, tag) {
|
|
|
78
96
|
}
|
|
79
97
|
async function callPortalJsonCompletion(req) {
|
|
80
98
|
const log = getLogger();
|
|
99
|
+
let endpoint = "/api/v1/chat/completions";
|
|
100
|
+
if (req.endpointOverride !== void 0) {
|
|
101
|
+
const overrideValidation = validateEndpointOverride(req.endpointOverride);
|
|
102
|
+
if (!overrideValidation.valid) {
|
|
103
|
+
throw new Error(overrideValidation.message);
|
|
104
|
+
}
|
|
105
|
+
endpoint = overrideValidation.endpoint;
|
|
106
|
+
}
|
|
81
107
|
const maxAttempts = Math.max(1, req.maxAttempts ?? 3);
|
|
82
108
|
const startedAt = Date.now();
|
|
83
109
|
const overBudget = () => req.totalTimeoutMs !== void 0 && Date.now() - startedAt >= req.totalTimeoutMs;
|
|
@@ -93,7 +119,7 @@ async function callPortalJsonCompletion(req) {
|
|
|
93
119
|
Math.min(req.timeoutMs ?? 6e4, req.totalTimeoutMs - (Date.now() - startedAt))
|
|
94
120
|
)
|
|
95
121
|
} : req;
|
|
96
|
-
const outcome = await attemptPortalJson(attemptReq);
|
|
122
|
+
const outcome = await attemptPortalJson(attemptReq, endpoint);
|
|
97
123
|
if (outcome.kind === "ok") return outcome.value;
|
|
98
124
|
if (outcome.kind === "terminal") {
|
|
99
125
|
log.warn(`[${req.tag}] ${outcome.reason}`);
|
|
@@ -116,7 +142,7 @@ async function callPortalJsonCompletion(req) {
|
|
|
116
142
|
}
|
|
117
143
|
return null;
|
|
118
144
|
}
|
|
119
|
-
async function attemptPortalJson(req) {
|
|
145
|
+
async function attemptPortalJson(req, endpoint) {
|
|
120
146
|
const baseUrl = req.baseUrl ?? defaultBaseUrl();
|
|
121
147
|
const fetchImpl = req.fetchFn ?? fetch;
|
|
122
148
|
const timeoutMs = req.timeoutMs ?? 6e4;
|
|
@@ -141,7 +167,7 @@ async function attemptPortalJson(req) {
|
|
|
141
167
|
if (!supportsJsonObjectFormat) delete requestBody.response_format;
|
|
142
168
|
let response;
|
|
143
169
|
try {
|
|
144
|
-
response = await fetchImpl(`${baseUrl}
|
|
170
|
+
response = await fetchImpl(`${baseUrl}${endpoint}`, {
|
|
145
171
|
method: "POST",
|
|
146
172
|
headers: { ...authHeaders, "Content-Type": "application/json" },
|
|
147
173
|
body: JSON.stringify(requestBody),
|
|
@@ -239,6 +265,7 @@ export {
|
|
|
239
265
|
noopLogger,
|
|
240
266
|
setLogger,
|
|
241
267
|
getLogger,
|
|
268
|
+
validateEndpointOverride,
|
|
242
269
|
supportsResponseFormat,
|
|
243
270
|
resolvePortalAuthHeaders,
|
|
244
271
|
callPortalJsonCompletion,
|