@genesislcap/ai-assistant 15.89.0 → 15.90.1-GENC-1829.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/ai-assistant.d.ts +8 -0
- package/dist/chat-driver.cjs +161 -149
- package/dist/chat-driver.cjs.map +3 -3
- package/dist/chat-driver.mjs +161 -149
- package/dist/chat-driver.mjs.map +3 -3
- package/dist/custom-elements.json +240 -234
- package/dist/dts/main/main.d.ts +8 -0
- package/dist/dts/main/main.d.ts.map +1 -1
- package/dist/esm/main/main.js +24 -2
- package/package.json +17 -17
package/dist/ai-assistant.d.ts
CHANGED
|
@@ -6086,6 +6086,14 @@ export declare class FoundationAiAssistant extends GenesisElement {
|
|
|
6086
6086
|
*/
|
|
6087
6087
|
isEngaged: boolean;
|
|
6088
6088
|
private _handleGlobalInteraction;
|
|
6089
|
+
/**
|
|
6090
|
+
* The window lost focus: the user moved into an iframe (e.g. an app preview hosting its own
|
|
6091
|
+
* assistant), another tab or another app. None of those reach `_handleGlobalInteraction` —
|
|
6092
|
+
* an iframe's pointer and focus events stay in its own document — so without this the
|
|
6093
|
+
* assistant stays "engaged" and a turn ending here pulls focus back out of the frame.
|
|
6094
|
+
* Returning re-engages through `focusin`, which fires when the window's focus comes back.
|
|
6095
|
+
*/
|
|
6096
|
+
private _handleWindowBlur;
|
|
6089
6097
|
/** True when the user has intentionally scrolled away from the bottom — suppresses auto-scroll. */
|
|
6090
6098
|
private _userScrolledAway;
|
|
6091
6099
|
private _scrollListener?;
|
package/dist/chat-driver.cjs
CHANGED
|
@@ -1250,155 +1250,6 @@ var GeminiProvider = class {
|
|
|
1250
1250
|
}
|
|
1251
1251
|
};
|
|
1252
1252
|
|
|
1253
|
-
// ../../foundation-ai/dist/esm/transports/budget-exhausted-error.js
|
|
1254
|
-
var BUDGET_EXCEEDED_CODE = "BUDGET_EXCEEDED";
|
|
1255
|
-
var VENDOR_LABELS = Object.freeze({
|
|
1256
|
-
anthropic: "Anthropic",
|
|
1257
|
-
gemini: "Gemini",
|
|
1258
|
-
openai: "OpenAI",
|
|
1259
|
-
chrome: "Chrome"
|
|
1260
|
-
});
|
|
1261
|
-
var BUDGETED_VENDORS = Object.freeze([
|
|
1262
|
-
"anthropic",
|
|
1263
|
-
"gemini"
|
|
1264
|
-
]);
|
|
1265
|
-
var VENDOR_TYPE_BY_LABEL = new Map(Object.entries(VENDOR_LABELS).map(([type, label]) => [
|
|
1266
|
-
label.toLowerCase(),
|
|
1267
|
-
type
|
|
1268
|
-
]));
|
|
1269
|
-
function vendorTypeOfLabel(label) {
|
|
1270
|
-
if (typeof label !== "string")
|
|
1271
|
-
return void 0;
|
|
1272
|
-
return VENDOR_TYPE_BY_LABEL.get(label.trim().toLowerCase());
|
|
1273
|
-
}
|
|
1274
|
-
var BUDGET_EXCEEDED_STATUS = 402;
|
|
1275
|
-
var DEFAULT_BUDGET_EXHAUSTED_MESSAGE = "You've reached your AI usage limit. Contact your administrator to raise it.";
|
|
1276
|
-
var BudgetExhaustedError = class extends Error {
|
|
1277
|
-
constructor(vendorLabel, budgetUsd, spentUsd, detail, extra) {
|
|
1278
|
-
super(`${vendorLabel} request refused: the AI usage budget is exhausted` + (budgetUsd != null ? ` (spent ${spentUsd != null ? `$${spentUsd}` : "an unknown amount"} of a $${budgetUsd} budget)` : "") + (detail ? `: ${detail}` : "") + ". Retrying will not clear this \u2014 the budget must be raised.");
|
|
1279
|
-
this.vendorLabel = vendorLabel;
|
|
1280
|
-
this.budgetUsd = budgetUsd;
|
|
1281
|
-
this.spentUsd = spentUsd;
|
|
1282
|
-
this.detail = detail;
|
|
1283
|
-
this.name = "BudgetExhaustedError";
|
|
1284
|
-
this.otherVendorAvailable = extra === null || extra === void 0 ? void 0 : extra.otherVendorAvailable;
|
|
1285
|
-
this.serverVendor = extra === null || extra === void 0 ? void 0 : extra.serverVendor;
|
|
1286
|
-
}
|
|
1287
|
-
};
|
|
1288
|
-
var isBudgetRejection = (status, code) => status === BUDGET_EXCEEDED_STATUS || code === BUDGET_EXCEEDED_CODE;
|
|
1289
|
-
var parseJsonOrUndefined = (text) => {
|
|
1290
|
-
try {
|
|
1291
|
-
return JSON.parse(text);
|
|
1292
|
-
} catch (_a) {
|
|
1293
|
-
return void 0;
|
|
1294
|
-
}
|
|
1295
|
-
};
|
|
1296
|
-
var codeOf = (payload) => {
|
|
1297
|
-
const code = payload === null || payload === void 0 ? void 0 : payload.code;
|
|
1298
|
-
return typeof code === "string" ? code : void 0;
|
|
1299
|
-
};
|
|
1300
|
-
var numberOrUndefined = (value) => typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
1301
|
-
var booleanOrUndefined = (value) => typeof value === "boolean" ? value : void 0;
|
|
1302
|
-
var stringOrUndefined = (value) => typeof value === "string" && value.trim() !== "" ? value : void 0;
|
|
1303
|
-
function budgetExhaustedFrom(vendorLabel, payload, fallbackDetail) {
|
|
1304
|
-
var _a, _b, _c, _d;
|
|
1305
|
-
const body = typeof payload === "object" && payload !== null ? payload : {};
|
|
1306
|
-
const details = typeof body.details === "object" && body.details !== null ? body.details : {};
|
|
1307
|
-
const detail = typeof body.error === "string" ? body.error : fallbackDetail;
|
|
1308
|
-
return new BudgetExhaustedError(vendorLabel, (_a = numberOrUndefined(body.budgetUsd)) !== null && _a !== void 0 ? _a : numberOrUndefined(details.budgetUsd), (_b = numberOrUndefined(body.spentUsd)) !== null && _b !== void 0 ? _b : numberOrUndefined(details.spentUsd), detail, {
|
|
1309
|
-
otherVendorAvailable: (_c = booleanOrUndefined(body.otherVendorAvailable)) !== null && _c !== void 0 ? _c : booleanOrUndefined(details.otherVendorAvailable),
|
|
1310
|
-
serverVendor: (_d = stringOrUndefined(body.vendor)) !== null && _d !== void 0 ? _d : stringOrUndefined(details.vendor)
|
|
1311
|
-
});
|
|
1312
|
-
}
|
|
1313
|
-
|
|
1314
|
-
// ../../foundation-ai/dist/esm/transports/provider-refused.js
|
|
1315
|
-
var PROVIDER_REFUSED_CODE = "PROVIDER_REFUSED";
|
|
1316
|
-
var DEFAULT_PROVIDER_REFUSED_MESSAGE = "AI requests are currently being refused by the provider. This isn't related to your account or your usage and needs no action from you \u2014 please contact your support team so it can be restored.";
|
|
1317
|
-
var ProviderRefusedError = class extends Error {
|
|
1318
|
-
constructor(vendorLabel, kind, upstreamStatus, upstreamType, detail) {
|
|
1319
|
-
super(`${vendorLabel} refused the request (${kind})` + (upstreamStatus != null ? ` \u2014 HTTP ${upstreamStatus}` : "") + (upstreamType ? ` ${upstreamType}` : "") + (detail ? `: ${detail}` : "") + ". Retrying will not clear this \u2014 the provider account must be fixed.");
|
|
1320
|
-
this.vendorLabel = vendorLabel;
|
|
1321
|
-
this.kind = kind;
|
|
1322
|
-
this.upstreamStatus = upstreamStatus;
|
|
1323
|
-
this.upstreamType = upstreamType;
|
|
1324
|
-
this.detail = detail;
|
|
1325
|
-
this.name = "ProviderRefusedError";
|
|
1326
|
-
}
|
|
1327
|
-
};
|
|
1328
|
-
var ANTHROPIC_SPEND_PHRASES = Object.freeze([
|
|
1329
|
-
/credit balance/i,
|
|
1330
|
-
/usage limit/i,
|
|
1331
|
-
/spend limit/i,
|
|
1332
|
-
/insufficient (credit|funds|balance)/i
|
|
1333
|
-
]);
|
|
1334
|
-
var ANTHROPIC_AUTH_TYPES = Object.freeze([
|
|
1335
|
-
"authentication_error",
|
|
1336
|
-
"permission_error"
|
|
1337
|
-
]);
|
|
1338
|
-
function anthropicErrorBody(payload) {
|
|
1339
|
-
var _a;
|
|
1340
|
-
const outer = typeof payload === "object" && payload !== null ? payload : {};
|
|
1341
|
-
for (const candidate of [
|
|
1342
|
-
outer.error,
|
|
1343
|
-
(_a = outer.details) === null || _a === void 0 ? void 0 : _a.error
|
|
1344
|
-
]) {
|
|
1345
|
-
if (typeof candidate === "object" && candidate !== null) {
|
|
1346
|
-
const { type, message } = candidate;
|
|
1347
|
-
return {
|
|
1348
|
-
type: typeof type === "string" ? type : void 0,
|
|
1349
|
-
message: typeof message === "string" ? message : void 0
|
|
1350
|
-
};
|
|
1351
|
-
}
|
|
1352
|
-
}
|
|
1353
|
-
return void 0;
|
|
1354
|
-
}
|
|
1355
|
-
function statedKind(payload) {
|
|
1356
|
-
const outer = typeof payload === "object" && payload !== null ? payload : {};
|
|
1357
|
-
const nested = typeof outer.details === "object" && outer.details !== null ? outer.details : {};
|
|
1358
|
-
for (const candidate of [outer.kind, nested.kind]) {
|
|
1359
|
-
if (candidate === "auth" || candidate === "spend")
|
|
1360
|
-
return candidate;
|
|
1361
|
-
}
|
|
1362
|
-
return void 0;
|
|
1363
|
-
}
|
|
1364
|
-
function kindFromEnvelopeType(payload) {
|
|
1365
|
-
const body = anthropicErrorBody(payload);
|
|
1366
|
-
if (!(body === null || body === void 0 ? void 0 : body.type))
|
|
1367
|
-
return void 0;
|
|
1368
|
-
if (ANTHROPIC_AUTH_TYPES.includes(body.type))
|
|
1369
|
-
return "auth";
|
|
1370
|
-
if (body.type === "billing_error")
|
|
1371
|
-
return "spend";
|
|
1372
|
-
return void 0;
|
|
1373
|
-
}
|
|
1374
|
-
function providerRefusalOf(vendor, code, payload) {
|
|
1375
|
-
var _a, _b;
|
|
1376
|
-
if (code === PROVIDER_REFUSED_CODE) {
|
|
1377
|
-
return (_b = (_a = statedKind(payload)) !== null && _a !== void 0 ? _a : kindFromEnvelopeType(payload)) !== null && _b !== void 0 ? _b : "spend";
|
|
1378
|
-
}
|
|
1379
|
-
if (vendor !== "anthropic")
|
|
1380
|
-
return void 0;
|
|
1381
|
-
const structural = kindFromEnvelopeType(payload);
|
|
1382
|
-
if (structural)
|
|
1383
|
-
return structural;
|
|
1384
|
-
const body = anthropicErrorBody(payload);
|
|
1385
|
-
if ((body === null || body === void 0 ? void 0 : body.type) === "invalid_request_error" && body.message) {
|
|
1386
|
-
const message = body.message;
|
|
1387
|
-
if (ANTHROPIC_SPEND_PHRASES.some((phrase) => phrase.test(message)))
|
|
1388
|
-
return "spend";
|
|
1389
|
-
}
|
|
1390
|
-
return void 0;
|
|
1391
|
-
}
|
|
1392
|
-
function providerRefusedFrom(vendorLabel, kind, upstreamStatus, payload, fallbackDetail) {
|
|
1393
|
-
var _a;
|
|
1394
|
-
const body = anthropicErrorBody(payload);
|
|
1395
|
-
return new ProviderRefusedError(vendorLabel, kind, upstreamStatus, body === null || body === void 0 ? void 0 : body.type, (_a = body === null || body === void 0 ? void 0 : body.message) !== null && _a !== void 0 ? _a : fallbackDetail);
|
|
1396
|
-
}
|
|
1397
|
-
function vendorOfTransportLabel(vendorLabel) {
|
|
1398
|
-
const entry = Object.entries(VENDOR_LABELS).find(([, label]) => label === vendorLabel);
|
|
1399
|
-
return entry === null || entry === void 0 ? void 0 : entry[0];
|
|
1400
|
-
}
|
|
1401
|
-
|
|
1402
1253
|
// ../../foundation-ai/dist/esm/types/config.types.js
|
|
1403
1254
|
var SUPPORTED_GEMINI_MODEL_IDS = [
|
|
1404
1255
|
"gemini-2.5-pro",
|
|
@@ -1418,11 +1269,20 @@ var SUPPORTED_ANTHROPIC_MODEL_IDS = [
|
|
|
1418
1269
|
"claude-sonnet-4-6",
|
|
1419
1270
|
"claude-haiku-4-5-20251001"
|
|
1420
1271
|
];
|
|
1272
|
+
var SUPPORTED_OPENAI_MODEL_IDS = [
|
|
1273
|
+
"gpt-6-astra",
|
|
1274
|
+
"gpt-6.1-sol",
|
|
1275
|
+
"gpt-6.1-terra",
|
|
1276
|
+
"gpt-6-sol",
|
|
1277
|
+
"gpt-6-luna"
|
|
1278
|
+
];
|
|
1421
1279
|
function vendorOfModel(modelId) {
|
|
1422
1280
|
if (SUPPORTED_ANTHROPIC_MODEL_IDS.includes(modelId))
|
|
1423
1281
|
return "anthropic";
|
|
1424
1282
|
if (SUPPORTED_GEMINI_MODEL_IDS.includes(modelId))
|
|
1425
1283
|
return "gemini";
|
|
1284
|
+
if (SUPPORTED_OPENAI_MODEL_IDS.includes(modelId))
|
|
1285
|
+
return "openai";
|
|
1426
1286
|
return void 0;
|
|
1427
1287
|
}
|
|
1428
1288
|
|
|
@@ -1754,6 +1614,68 @@ function toGeminiSchema(parameters) {
|
|
|
1754
1614
|
return translated;
|
|
1755
1615
|
}
|
|
1756
1616
|
|
|
1617
|
+
// ../../foundation-ai/dist/esm/transports/budget-exhausted-error.js
|
|
1618
|
+
var BUDGET_EXCEEDED_CODE = "BUDGET_EXCEEDED";
|
|
1619
|
+
var VENDOR_LABELS = Object.freeze({
|
|
1620
|
+
anthropic: "Anthropic",
|
|
1621
|
+
gemini: "Gemini",
|
|
1622
|
+
openai: "OpenAI",
|
|
1623
|
+
chrome: "Chrome"
|
|
1624
|
+
});
|
|
1625
|
+
var BUDGETED_VENDORS = Object.freeze([
|
|
1626
|
+
"anthropic",
|
|
1627
|
+
"gemini",
|
|
1628
|
+
"openai"
|
|
1629
|
+
]);
|
|
1630
|
+
var VENDOR_TYPE_BY_LABEL = new Map(Object.entries(VENDOR_LABELS).map(([type, label]) => [
|
|
1631
|
+
label.toLowerCase(),
|
|
1632
|
+
type
|
|
1633
|
+
]));
|
|
1634
|
+
function vendorTypeOfLabel(label) {
|
|
1635
|
+
if (typeof label !== "string")
|
|
1636
|
+
return void 0;
|
|
1637
|
+
return VENDOR_TYPE_BY_LABEL.get(label.trim().toLowerCase());
|
|
1638
|
+
}
|
|
1639
|
+
var BUDGET_EXCEEDED_STATUS = 402;
|
|
1640
|
+
var DEFAULT_BUDGET_EXHAUSTED_MESSAGE = "You've reached your AI usage limit. Contact your administrator to raise it.";
|
|
1641
|
+
var BudgetExhaustedError = class extends Error {
|
|
1642
|
+
constructor(vendorLabel, budgetUsd, spentUsd, detail, extra) {
|
|
1643
|
+
super(`${vendorLabel} request refused: the AI usage budget is exhausted` + (budgetUsd != null ? ` (spent ${spentUsd != null ? `$${spentUsd}` : "an unknown amount"} of a $${budgetUsd} budget)` : "") + (detail ? `: ${detail}` : "") + ". Retrying will not clear this \u2014 the budget must be raised.");
|
|
1644
|
+
this.vendorLabel = vendorLabel;
|
|
1645
|
+
this.budgetUsd = budgetUsd;
|
|
1646
|
+
this.spentUsd = spentUsd;
|
|
1647
|
+
this.detail = detail;
|
|
1648
|
+
this.name = "BudgetExhaustedError";
|
|
1649
|
+
this.otherVendorAvailable = extra === null || extra === void 0 ? void 0 : extra.otherVendorAvailable;
|
|
1650
|
+
this.serverVendor = extra === null || extra === void 0 ? void 0 : extra.serverVendor;
|
|
1651
|
+
}
|
|
1652
|
+
};
|
|
1653
|
+
var isBudgetRejection = (status, code) => status === BUDGET_EXCEEDED_STATUS || code === BUDGET_EXCEEDED_CODE;
|
|
1654
|
+
var parseJsonOrUndefined = (text) => {
|
|
1655
|
+
try {
|
|
1656
|
+
return JSON.parse(text);
|
|
1657
|
+
} catch (_a) {
|
|
1658
|
+
return void 0;
|
|
1659
|
+
}
|
|
1660
|
+
};
|
|
1661
|
+
var codeOf = (payload) => {
|
|
1662
|
+
const code = payload === null || payload === void 0 ? void 0 : payload.code;
|
|
1663
|
+
return typeof code === "string" ? code : void 0;
|
|
1664
|
+
};
|
|
1665
|
+
var numberOrUndefined = (value) => typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
1666
|
+
var booleanOrUndefined = (value) => typeof value === "boolean" ? value : void 0;
|
|
1667
|
+
var stringOrUndefined = (value) => typeof value === "string" && value.trim() !== "" ? value : void 0;
|
|
1668
|
+
function budgetExhaustedFrom(vendorLabel, payload, fallbackDetail) {
|
|
1669
|
+
var _a, _b, _c, _d;
|
|
1670
|
+
const body = typeof payload === "object" && payload !== null ? payload : {};
|
|
1671
|
+
const details = typeof body.details === "object" && body.details !== null ? body.details : {};
|
|
1672
|
+
const detail = typeof body.error === "string" ? body.error : fallbackDetail;
|
|
1673
|
+
return new BudgetExhaustedError(vendorLabel, (_a = numberOrUndefined(body.budgetUsd)) !== null && _a !== void 0 ? _a : numberOrUndefined(details.budgetUsd), (_b = numberOrUndefined(body.spentUsd)) !== null && _b !== void 0 ? _b : numberOrUndefined(details.spentUsd), detail, {
|
|
1674
|
+
otherVendorAvailable: (_c = booleanOrUndefined(body.otherVendorAvailable)) !== null && _c !== void 0 ? _c : booleanOrUndefined(details.otherVendorAvailable),
|
|
1675
|
+
serverVendor: (_d = stringOrUndefined(body.vendor)) !== null && _d !== void 0 ? _d : stringOrUndefined(details.vendor)
|
|
1676
|
+
});
|
|
1677
|
+
}
|
|
1678
|
+
|
|
1757
1679
|
// ../../foundation-ai/dist/esm/utils/abort-reason.js
|
|
1758
1680
|
function authoritativeAbortReason(error, timeoutSignal, callerSignal) {
|
|
1759
1681
|
const abortShaped = (error instanceof DOMException || error instanceof Error) && (error.name === "AbortError" || error.name === "TimeoutError");
|
|
@@ -1887,6 +1809,8 @@ var CONTEXT_OVERFLOW_PHRASES = Object.freeze([
|
|
|
1887
1809
|
/input token count .* exceeds/i,
|
|
1888
1810
|
/maximum context length/i,
|
|
1889
1811
|
/context[_ ]length[_ ]exceeded/i,
|
|
1812
|
+
// OpenAI Responses: `Your input exceeds the context window of this model.`
|
|
1813
|
+
/exceeds the context window/i,
|
|
1890
1814
|
/too many (input )?tokens/i
|
|
1891
1815
|
]);
|
|
1892
1816
|
var TOKEN_FIGURES = /(\d[\d,]{2,})\D{0,40}?(?:>|exceeds)\D{0,80}?(\d[\d,]{2,})/i;
|
|
@@ -2005,6 +1929,94 @@ function readFramedBody(stream, onChunk, vendorLabel, stallTimeout) {
|
|
|
2005
1929
|
});
|
|
2006
1930
|
}
|
|
2007
1931
|
|
|
1932
|
+
// ../../foundation-ai/dist/esm/transports/provider-refused.js
|
|
1933
|
+
var PROVIDER_REFUSED_CODE = "PROVIDER_REFUSED";
|
|
1934
|
+
var DEFAULT_PROVIDER_REFUSED_MESSAGE = "AI requests are currently being refused by the provider. This isn't related to your account or your usage and needs no action from you \u2014 please contact your support team so it can be restored.";
|
|
1935
|
+
var ProviderRefusedError = class extends Error {
|
|
1936
|
+
constructor(vendorLabel, kind, upstreamStatus, upstreamType, detail) {
|
|
1937
|
+
super(`${vendorLabel} refused the request (${kind})` + (upstreamStatus != null ? ` \u2014 HTTP ${upstreamStatus}` : "") + (upstreamType ? ` ${upstreamType}` : "") + (detail ? `: ${detail}` : "") + ". Retrying will not clear this \u2014 the provider account must be fixed.");
|
|
1938
|
+
this.vendorLabel = vendorLabel;
|
|
1939
|
+
this.kind = kind;
|
|
1940
|
+
this.upstreamStatus = upstreamStatus;
|
|
1941
|
+
this.upstreamType = upstreamType;
|
|
1942
|
+
this.detail = detail;
|
|
1943
|
+
this.name = "ProviderRefusedError";
|
|
1944
|
+
}
|
|
1945
|
+
};
|
|
1946
|
+
var ANTHROPIC_SPEND_PHRASES = Object.freeze([
|
|
1947
|
+
/credit balance/i,
|
|
1948
|
+
/usage limit/i,
|
|
1949
|
+
/spend limit/i,
|
|
1950
|
+
/insufficient (credit|funds|balance)/i
|
|
1951
|
+
]);
|
|
1952
|
+
var ANTHROPIC_AUTH_TYPES = Object.freeze([
|
|
1953
|
+
"authentication_error",
|
|
1954
|
+
"permission_error"
|
|
1955
|
+
]);
|
|
1956
|
+
function anthropicErrorBody(payload) {
|
|
1957
|
+
var _a;
|
|
1958
|
+
const outer = typeof payload === "object" && payload !== null ? payload : {};
|
|
1959
|
+
for (const candidate of [
|
|
1960
|
+
outer.error,
|
|
1961
|
+
(_a = outer.details) === null || _a === void 0 ? void 0 : _a.error
|
|
1962
|
+
]) {
|
|
1963
|
+
if (typeof candidate === "object" && candidate !== null) {
|
|
1964
|
+
const { type, message } = candidate;
|
|
1965
|
+
return {
|
|
1966
|
+
type: typeof type === "string" ? type : void 0,
|
|
1967
|
+
message: typeof message === "string" ? message : void 0
|
|
1968
|
+
};
|
|
1969
|
+
}
|
|
1970
|
+
}
|
|
1971
|
+
return void 0;
|
|
1972
|
+
}
|
|
1973
|
+
function statedKind(payload) {
|
|
1974
|
+
const outer = typeof payload === "object" && payload !== null ? payload : {};
|
|
1975
|
+
const nested = typeof outer.details === "object" && outer.details !== null ? outer.details : {};
|
|
1976
|
+
for (const candidate of [outer.kind, nested.kind]) {
|
|
1977
|
+
if (candidate === "auth" || candidate === "spend")
|
|
1978
|
+
return candidate;
|
|
1979
|
+
}
|
|
1980
|
+
return void 0;
|
|
1981
|
+
}
|
|
1982
|
+
function kindFromEnvelopeType(payload) {
|
|
1983
|
+
const body = anthropicErrorBody(payload);
|
|
1984
|
+
if (!(body === null || body === void 0 ? void 0 : body.type))
|
|
1985
|
+
return void 0;
|
|
1986
|
+
if (ANTHROPIC_AUTH_TYPES.includes(body.type))
|
|
1987
|
+
return "auth";
|
|
1988
|
+
if (body.type === "billing_error")
|
|
1989
|
+
return "spend";
|
|
1990
|
+
return void 0;
|
|
1991
|
+
}
|
|
1992
|
+
function providerRefusalOf(vendor, code, payload) {
|
|
1993
|
+
var _a, _b;
|
|
1994
|
+
if (code === PROVIDER_REFUSED_CODE) {
|
|
1995
|
+
return (_b = (_a = statedKind(payload)) !== null && _a !== void 0 ? _a : kindFromEnvelopeType(payload)) !== null && _b !== void 0 ? _b : "spend";
|
|
1996
|
+
}
|
|
1997
|
+
if (vendor !== "anthropic")
|
|
1998
|
+
return void 0;
|
|
1999
|
+
const structural = kindFromEnvelopeType(payload);
|
|
2000
|
+
if (structural)
|
|
2001
|
+
return structural;
|
|
2002
|
+
const body = anthropicErrorBody(payload);
|
|
2003
|
+
if ((body === null || body === void 0 ? void 0 : body.type) === "invalid_request_error" && body.message) {
|
|
2004
|
+
const message = body.message;
|
|
2005
|
+
if (ANTHROPIC_SPEND_PHRASES.some((phrase) => phrase.test(message)))
|
|
2006
|
+
return "spend";
|
|
2007
|
+
}
|
|
2008
|
+
return void 0;
|
|
2009
|
+
}
|
|
2010
|
+
function providerRefusedFrom(vendorLabel, kind, upstreamStatus, payload, fallbackDetail) {
|
|
2011
|
+
var _a;
|
|
2012
|
+
const body = anthropicErrorBody(payload);
|
|
2013
|
+
return new ProviderRefusedError(vendorLabel, kind, upstreamStatus, body === null || body === void 0 ? void 0 : body.type, (_a = body === null || body === void 0 ? void 0 : body.message) !== null && _a !== void 0 ? _a : fallbackDetail);
|
|
2014
|
+
}
|
|
2015
|
+
function vendorOfTransportLabel(vendorLabel) {
|
|
2016
|
+
const entry = Object.entries(VENDOR_LABELS).find(([, label]) => label === vendorLabel);
|
|
2017
|
+
return entry === null || entry === void 0 ? void 0 : entry[0];
|
|
2018
|
+
}
|
|
2019
|
+
|
|
2008
2020
|
// ../../foundation-ai/dist/esm/transports/retry-hints.js
|
|
2009
2021
|
var MAX_SERVER_REQUESTED_BACKOFF_MS = 6e4;
|
|
2010
2022
|
var MAX_TOTAL_SERVER_REQUESTED_BACKOFF_MS = 12e4;
|