@demicodes/provider 0.6.1 → 0.7.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/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as ProviderQuota, B as ProviderQuotaUnsupportedError, C as ProviderRuntimeFactory, D as ToolDefinition, E as ProviderServiceTier, F as ProviderQuotaProbeOptions, G as ensureQuota, H as ProviderQuotaWindowUnit, I as ProviderQuotaProbeResult, J as usedPercentFromRatio, K as severityFromUsedPercent, L as ProviderQuotaSeverity, M as ProviderQuotaObserveInput, N as ProviderQuotaPlan, O as CreateProviderQuotaOptions, P as ProviderQuotaProbeCost, R as ProviderQuotaSnapshot, S as ProviderRun, T as ProviderSelection, U as clampUsedPercent, V as ProviderQuotaWindow, W as createProviderQuota, _ as ProviderEvent, a as ModelPolicy, b as ProviderModelCost, c as ProviderAuthState, d as ProviderCredentialInfo, f as ProviderCredentialLoginOptions, g as ProviderCredentialsCapability, h as ProviderCredentials, i as InferenceSteer, j as ProviderQuotaCapability, k as EnsureQuotaOptions, l as ProviderCredentialActive, m as ProviderCredentialLoginResult, n as InferenceItem, o as Provider, p as ProviderCredentialLoginPending, q as unixSecondsToIso, r as InferenceRequest, s as ProviderAuth, t as AgentProvider, u as ProviderCredentialAddInput, v as ProviderFactoryDefinition, w as ProviderRuntimeState, x as ProviderModelList, y as ProviderModel, z as ProviderQuotaSource } from "./types-
|
|
1
|
+
import { A as ProviderQuota, B as ProviderQuotaUnsupportedError, C as ProviderRuntimeFactory, D as ToolDefinition, E as ProviderServiceTier, F as ProviderQuotaProbeOptions, G as ensureQuota, H as ProviderQuotaWindowUnit, I as ProviderQuotaProbeResult, J as usedPercentFromRatio, K as severityFromUsedPercent, L as ProviderQuotaSeverity, M as ProviderQuotaObserveInput, N as ProviderQuotaPlan, O as CreateProviderQuotaOptions, P as ProviderQuotaProbeCost, R as ProviderQuotaSnapshot, S as ProviderRun, T as ProviderSelection, U as clampUsedPercent, V as ProviderQuotaWindow, W as createProviderQuota, _ as ProviderEvent, a as ModelPolicy, b as ProviderModelCost, c as ProviderAuthState, d as ProviderCredentialInfo, f as ProviderCredentialLoginOptions, g as ProviderCredentialsCapability, h as ProviderCredentials, i as InferenceSteer, j as ProviderQuotaCapability, k as EnsureQuotaOptions, l as ProviderCredentialActive, m as ProviderCredentialLoginResult, n as InferenceItem, o as Provider, p as ProviderCredentialLoginPending, q as unixSecondsToIso, r as InferenceRequest, s as ProviderAuth, t as AgentProvider, u as ProviderCredentialAddInput, v as ProviderFactoryDefinition, w as ProviderRuntimeState, x as ProviderModelList, y as ProviderModel, z as ProviderQuotaSource } from "./types-CYSnFAuT.mjs";
|
|
2
2
|
import { FileExtension, ModelSelection, ThinkingCapability, ThinkingConfig, ToolResultContentBlock } from "@demicodes/core";
|
|
3
3
|
//#region src/content.d.ts
|
|
4
4
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -131,7 +131,8 @@ function redactCredentialText(text, extraFieldPatterns = []) {
|
|
|
131
131
|
/** Maps an HTTP status (and response text) to a coarse provider error code. */
|
|
132
132
|
function httpErrorCode(status, message) {
|
|
133
133
|
if (status === 401 || status === 403) return "auth_expired";
|
|
134
|
-
if (status ===
|
|
134
|
+
if (status === 429) return "rate_limit";
|
|
135
|
+
if (status === 408 || status === 409 || status === 425 || status >= 500) return "overloaded";
|
|
135
136
|
if (status === 400 && /context|too long|token/i.test(message)) return "context_length_exceeded";
|
|
136
137
|
return null;
|
|
137
138
|
}
|
|
@@ -140,8 +141,8 @@ function normalizeErrorCode(code, message) {
|
|
|
140
141
|
const value = `${code ?? ""} ${message}`.toLowerCase();
|
|
141
142
|
if (/context|too long|max.*token/.test(value)) return "context_length_exceeded";
|
|
142
143
|
if (/rate|quota|usage|billing|balance|limit/.test(value)) return "rate_limit";
|
|
143
|
-
if (/
|
|
144
|
-
if (/overload|unavailable|timed?\s?out|fetch failed|network|socket|econn/.test(value)) return "overloaded";
|
|
144
|
+
if (/\bauth(?:entication|orization)?\b/.test(value) || /(?:invalid|expired).*(?:api|access|auth)[_\s-]*(?:key|token)/.test(value) || /(?:api|access|auth)[_\s-]*(?:key|token).*(?:invalid|expired)/.test(value)) return "auth_expired";
|
|
145
|
+
if (/overload|unavailable|(?:server|internal|api)[_\s-]*error|timed?\s?out|fetch failed|network|socket|econn/.test(value)) return "overloaded";
|
|
145
146
|
return code;
|
|
146
147
|
}
|
|
147
148
|
/** Builds a provider `error` event from an unknown thrown value, redacting `secret`. */
|
package/dist/testing.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as ProviderRun, _ as ProviderEvent, i as InferenceSteer, r as InferenceRequest, t as AgentProvider } from "./types-
|
|
1
|
+
import { S as ProviderRun, _ as ProviderEvent, i as InferenceSteer, r as InferenceRequest, t as AgentProvider } from "./types-CYSnFAuT.mjs";
|
|
2
2
|
//#region src/testing.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* Scripted provider for testing. Each "turn" is a list of events to yield.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ModelSelection, ThinkingConfig, ThinkingEffort, TokenUsage, ToolResultContentBlock, UserContentBlock } from "@demicodes/core";
|
|
1
|
+
import { ModelSelection, ProviderErrorDiagnostics, ThinkingConfig, ThinkingEffort, TokenUsage, ToolResultContentBlock, UserContentBlock } from "@demicodes/core";
|
|
2
2
|
//#region src/quota.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* Unified subscription / rate-limit quota surface for concrete providers.
|
|
@@ -222,6 +222,7 @@ type ProviderEvent = {
|
|
|
222
222
|
type: 'error';
|
|
223
223
|
message: string;
|
|
224
224
|
code: string | null;
|
|
225
|
+
diagnostics?: ProviderErrorDiagnostics;
|
|
225
226
|
/** Server-suggested retry delay (e.g. from a Retry-After header), if any. */
|
|
226
227
|
retryAfterMs?: number;
|
|
227
228
|
} | {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@demicodes/provider",
|
|
3
3
|
"description": "Provider contract and shared building blocks for Demi inference adapters.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.7.1",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
7
7
|
"exports": {
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@demicodes/core": "^0.
|
|
23
|
-
"@demicodes/utils": "^0.
|
|
22
|
+
"@demicodes/core": "^0.7.1",
|
|
23
|
+
"@demicodes/utils": "^0.7.1"
|
|
24
24
|
},
|
|
25
25
|
"license": "Apache-2.0",
|
|
26
26
|
"main": "./dist/index.mjs",
|