@oh-my-pi/pi-ai 16.2.1 → 16.2.2
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/CHANGELOG.md +27 -0
- package/dist/types/auth-gateway/server.d.ts +0 -19
- package/dist/types/auth-retry.d.ts +2 -10
- package/dist/types/auth-storage.d.ts +1 -2
- package/dist/types/dialect/demotion.d.ts +22 -0
- package/dist/types/dialect/index.d.ts +2 -0
- package/dist/types/error/abort.d.ts +14 -0
- package/dist/types/error/auth-classify.d.ts +16 -0
- package/dist/types/error/auth.d.ts +27 -0
- package/dist/types/error/aws.d.ts +23 -0
- package/dist/types/error/classes.d.ts +102 -0
- package/dist/types/error/finalize.d.ts +39 -0
- package/dist/types/error/flags.d.ts +70 -0
- package/dist/types/error/format.d.ts +20 -0
- package/dist/types/error/gateway.d.ts +20 -0
- package/dist/types/error/index.d.ts +13 -0
- package/dist/types/error/oauth.d.ts +43 -0
- package/dist/types/error/provider.d.ts +42 -0
- package/dist/types/{rate-limit-utils.d.ts → error/rate-limit.d.ts} +14 -1
- package/dist/types/error/retryable.d.ts +27 -0
- package/dist/types/error/validation.d.ts +32 -0
- package/dist/types/index.d.ts +1 -3
- package/dist/types/providers/amazon-bedrock.d.ts +0 -5
- package/dist/types/providers/anthropic-client.d.ts +2 -16
- package/dist/types/providers/anthropic.d.ts +6 -1
- package/dist/types/providers/aws-eventstream.d.ts +2 -1
- package/dist/types/providers/cursor.d.ts +8 -7
- package/dist/types/providers/google-gemini-cli.d.ts +0 -5
- package/dist/types/providers/google-shared.d.ts +0 -5
- package/dist/types/providers/ollama.d.ts +0 -5
- package/dist/types/providers/openai-codex/request-transformer.d.ts +2 -2
- package/dist/types/providers/openai-codex/response-handler.d.ts +1 -1
- package/dist/types/providers/openai-codex-responses.d.ts +2 -2
- package/dist/types/providers/openai-responses-server-schema.d.ts +6 -0
- package/dist/types/providers/openai-responses-wire.d.ts +1 -1
- package/dist/types/providers/openai-responses.d.ts +1 -0
- package/dist/types/providers/openai-shared.d.ts +8 -6
- package/dist/types/providers/pi-native-client.d.ts +0 -9
- package/dist/types/registry/oauth/xai-oauth.d.ts +0 -9
- package/dist/types/types.d.ts +6 -0
- package/dist/types/utils/block-symbols.d.ts +20 -0
- package/dist/types/utils/openai-http.d.ts +4 -8
- package/dist/types/utils/retry.d.ts +2 -14
- package/dist/types/utils/thinking-loop.d.ts +3 -1
- package/package.json +8 -4
- package/src/api-registry.ts +3 -1
- package/src/auth-broker/discover.ts +7 -2
- package/src/auth-broker/remote-store.ts +8 -7
- package/src/auth-gateway/server.ts +27 -115
- package/src/auth-retry.ts +9 -21
- package/src/auth-storage.ts +34 -49
- package/src/dialect/demotion.ts +31 -0
- package/src/dialect/factory.ts +0 -2
- package/src/dialect/index.ts +2 -0
- package/src/dialect/owned-stream.ts +0 -1
- package/src/dialect/thinking.ts +22 -10
- package/src/error/abort.ts +18 -0
- package/src/error/auth-classify.ts +30 -0
- package/src/error/auth.ts +48 -0
- package/src/error/aws.ts +31 -0
- package/src/error/classes.ts +186 -0
- package/src/error/finalize.ts +69 -0
- package/src/error/flags.ts +486 -0
- package/src/error/format.ts +36 -0
- package/src/error/gateway.ts +96 -0
- package/src/error/index.ts +13 -0
- package/src/error/oauth.ts +58 -0
- package/src/error/provider.ts +56 -0
- package/src/{rate-limit-utils.ts → error/rate-limit.ts} +9 -3
- package/src/error/retryable.ts +70 -0
- package/src/error/validation.ts +44 -0
- package/src/index.ts +1 -3
- package/src/providers/amazon-bedrock.ts +61 -57
- package/src/providers/anthropic-client.ts +13 -41
- package/src/providers/anthropic-messages-server.ts +9 -2
- package/src/providers/anthropic.ts +84 -147
- package/src/providers/aws-credentials.ts +41 -11
- package/src/providers/aws-eventstream.ts +12 -21
- package/src/providers/azure-openai-responses.ts +27 -17
- package/src/providers/cursor.ts +59 -53
- package/src/providers/devin.ts +28 -20
- package/src/providers/gitlab-duo-workflow.ts +30 -10
- package/src/providers/gitlab-duo.ts +22 -6
- package/src/providers/google-auth.ts +15 -5
- package/src/providers/google-gemini-cli.ts +46 -60
- package/src/providers/google-shared.ts +40 -38
- package/src/providers/google-vertex.ts +3 -2
- package/src/providers/google.ts +5 -1
- package/src/providers/mock.ts +10 -7
- package/src/providers/ollama.ts +34 -29
- package/src/providers/openai-chat-server.ts +2 -1
- package/src/providers/openai-codex/request-transformer.ts +13 -12
- package/src/providers/openai-codex/response-handler.ts +1 -1
- package/src/providers/openai-codex-responses.ts +931 -1012
- package/src/providers/openai-completions.ts +46 -36
- package/src/providers/openai-responses-server-schema.ts +3 -0
- package/src/providers/openai-responses-server.ts +82 -30
- package/src/providers/openai-responses-wire.ts +1 -1
- package/src/providers/openai-responses.ts +46 -22
- package/src/providers/openai-shared.ts +118 -51
- package/src/providers/pi-native-client.ts +12 -18
- package/src/providers/pi-native-server.ts +9 -6
- package/src/providers/register-builtins.ts +5 -2
- package/src/providers/transform-messages.ts +31 -63
- package/src/registry/alibaba-coding-plan.ts +6 -5
- package/src/registry/api-key-login.ts +4 -3
- package/src/registry/api-key-validation.ts +4 -3
- package/src/registry/cloudflare-ai-gateway.ts +4 -3
- package/src/registry/coreweave.ts +2 -1
- package/src/registry/deepseek.ts +2 -1
- package/src/registry/google-antigravity.ts +2 -1
- package/src/registry/google-gemini-cli.ts +2 -1
- package/src/registry/kagi.ts +4 -3
- package/src/registry/kilo.ts +32 -10
- package/src/registry/litellm.ts +4 -3
- package/src/registry/llama-cpp.ts +3 -2
- package/src/registry/lm-studio.ts +3 -2
- package/src/registry/nvidia.ts +7 -7
- package/src/registry/oauth/anthropic.ts +23 -6
- package/src/registry/oauth/callback-server.ts +5 -3
- package/src/registry/oauth/cursor.ts +18 -4
- package/src/registry/oauth/devin.ts +14 -3
- package/src/registry/oauth/github-copilot.ts +21 -10
- package/src/registry/oauth/gitlab-duo-workflow.ts +15 -3
- package/src/registry/oauth/gitlab-duo.ts +30 -6
- package/src/registry/oauth/google-antigravity.ts +14 -5
- package/src/registry/oauth/google-gemini-cli.ts +24 -7
- package/src/registry/oauth/google-oauth-shared.ts +6 -3
- package/src/registry/oauth/index.ts +19 -8
- package/src/registry/oauth/kimi.ts +40 -10
- package/src/registry/oauth/openai-codex.ts +26 -11
- package/src/registry/oauth/opencode.ts +4 -3
- package/src/registry/oauth/perplexity.ts +33 -11
- package/src/registry/oauth/xai-oauth.ts +62 -18
- package/src/registry/oauth/xiaomi.ts +21 -9
- package/src/registry/ollama-cloud.ts +5 -4
- package/src/registry/ollama.ts +3 -2
- package/src/registry/parallel.ts +4 -3
- package/src/registry/qwen-portal.ts +4 -3
- package/src/registry/tavily.ts +4 -3
- package/src/registry/vercel-ai-gateway.ts +4 -3
- package/src/registry/vllm.ts +3 -2
- package/src/stream.ts +79 -24
- package/src/types.ts +6 -0
- package/src/usage/claude.ts +2 -1
- package/src/usage/github-copilot.ts +4 -3
- package/src/usage/google-antigravity.ts +2 -1
- package/src/utils/abort.ts +4 -2
- package/src/utils/block-symbols.ts +32 -0
- package/src/utils/event-stream.ts +15 -3
- package/src/utils/http-inspector.ts +4 -4
- package/src/utils/idle-iterator.ts +6 -5
- package/src/utils/openai-http.ts +11 -46
- package/src/utils/parse-bind.ts +7 -5
- package/src/utils/proxy.ts +2 -1
- package/src/utils/retry.ts +7 -23
- package/src/utils/schema/normalize.ts +3 -2
- package/src/utils/thinking-loop.ts +15 -11
- package/src/utils/validation.ts +4 -3
- package/dist/types/dialect/pi.d.ts +0 -9
- package/dist/types/errors.d.ts +0 -24
- package/dist/types/utils/overflow.d.ts +0 -55
- package/src/dialect/pi.md +0 -55
- package/src/dialect/pi.ts +0 -600
- package/src/errors.ts +0 -32
- package/src/utils/overflow.ts +0 -140
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,33 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
### Changed
|
|
6
|
+
|
|
7
|
+
- Default reasoning context to `all_turns` for all Codex requests
|
|
8
|
+
|
|
9
|
+
## [16.2.2] - 2026-06-27
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- Added a comprehensive, public-facing error module exported via the "./error" path, featuring structured error classification, provider-specific HTTP error classes (e.g., Anthropic, OpenAI, Gemini), OAuth/Auth-specific errors, rate-limit utilities, and retryability predicates.
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
|
|
17
|
+
- Updated OpenAI Codex defaults to increase default text verbosity to medium, enable detailed reasoning summaries by default, and include all turns in the reasoning context by default.
|
|
18
|
+
- Updated the OpenAI Codex WebSocket transport to resolve its configuration (via PI_CODEX_WEBSOCKET_* environment variables) once at startup rather than re-parsing on every request.
|
|
19
|
+
- Enhanced cross-model reasoning recovery and preservation to render demoted reasoning in the target model's canonical inline thinking dialect (such as Gemini's thinking fence or standard think tags) to prevent leaking inert context or control tokens into history.
|
|
20
|
+
- Broadened the leaked-thinking stream healer to recover reasoning emitted in any dialect's canonical idiom (including Gemini, Gemma, Harmony, and scratchpads) and route them to thinking events instead of raw markup.
|
|
21
|
+
- Implemented automatic retry logic for detected thinking-loop stalls to improve response reliability.
|
|
22
|
+
- Hardened stateful delta chaining to ignore transient streaming bookkeeping symbols during structural equality checks, preventing unnecessary full-transcript replays.
|
|
23
|
+
|
|
24
|
+
### Fixed
|
|
25
|
+
|
|
26
|
+
- Fixed preservation of OpenAI Responses assistant message phase values across auth-gateway parsing, streaming, and history replay, ensuring GPT-5.4/GPT-5.5 intermediate updates and final answers retain their original phase labels.
|
|
27
|
+
|
|
28
|
+
### Removed
|
|
29
|
+
|
|
30
|
+
- Removed Pi dialect support and related serialization/parsing logic.
|
|
31
|
+
|
|
5
32
|
## [16.2.0] - 2026-06-27
|
|
6
33
|
|
|
7
34
|
### Breaking Changes
|
|
@@ -33,23 +33,4 @@ export interface AuthGatewayBootOptions extends AuthGatewayServerOptions {
|
|
|
33
33
|
/** Optional supplier for `/v1/models` listing. Returns the full model array. */
|
|
34
34
|
listModels?: () => Iterable<Model<Api>>;
|
|
35
35
|
}
|
|
36
|
-
/**
|
|
37
|
-
* Classify an upstream / gateway-internal error into a status code and a
|
|
38
|
-
* format-neutral type. The order is intentional:
|
|
39
|
-
*
|
|
40
|
-
* 1. Honour an explicit numeric `status` property on the thrown error.
|
|
41
|
-
* 2. Parse a status code embedded in the message string. Provider errors
|
|
42
|
-
* virtually always carry one (`Google API error (400): …`, `HTTP 429`,
|
|
43
|
-
* `status=503`) and the embedded value is authoritative.
|
|
44
|
-
* 3. Fall through to **word-boundaried** substring heuristics. The old
|
|
45
|
-
* `lower.includes("rate")` test famously matched
|
|
46
|
-
* `GenerateContentRequest`, surfacing every Google 400 as a 429
|
|
47
|
-
* `rate_limit_error`. The patterns here all require boundaries so they
|
|
48
|
-
* don't collide with provider field names.
|
|
49
|
-
*/
|
|
50
|
-
export declare function classifyGatewayError(err: unknown): {
|
|
51
|
-
status: number;
|
|
52
|
-
type: string;
|
|
53
|
-
message: string;
|
|
54
|
-
};
|
|
55
36
|
export declare function startAuthGateway(opts: AuthGatewayBootOptions): AuthGatewayServerHandle;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { OAuthAccess } from "./auth-storage";
|
|
2
|
+
import { isAuthRetryableError } from "./error/auth-classify";
|
|
2
3
|
/**
|
|
3
4
|
* Context passed to an {@link ApiKeyResolver} on each resolution attempt.
|
|
4
5
|
*
|
|
@@ -46,16 +47,7 @@ export declare function resolveApiKeyOnce(key: ApiKey | undefined, signal?: Abor
|
|
|
46
47
|
* `resolver`.
|
|
47
48
|
*/
|
|
48
49
|
export declare function seedApiKeyResolver(seed: string | undefined, resolver: ApiKeyResolver): ApiKeyResolver;
|
|
49
|
-
|
|
50
|
-
* Classifies whether an error should trigger a credential refresh/rotation
|
|
51
|
-
* retry: a hard `401`, body-classified usage limit (Codex
|
|
52
|
-
* `usage_limit_reached`, Anthropic account rate-limit, Google
|
|
53
|
-
* `resource_exhausted`, OpenAI `insufficient_quota`, …), or a bare `429`
|
|
54
|
-
* whose payload did not preserve a richer quota code. Transient 429s
|
|
55
|
-
* (`Too many requests`, per-minute caps) classify as `RATE_LIMIT_EXCEEDED`
|
|
56
|
-
* via {@link parseRateLimitReason} and stay in the upstream-backoff lane.
|
|
57
|
-
*/
|
|
58
|
-
export declare function isAuthRetryableError(error: unknown): boolean;
|
|
50
|
+
export { isAuthRetryableError };
|
|
59
51
|
/**
|
|
60
52
|
* The ordered `lastChance` values for the retry steps after the initial
|
|
61
53
|
* attempt fails: `false` → step (b) refresh-same, `true` → step (c) switch.
|
|
@@ -391,7 +391,7 @@ export type AuthStorageOptions = {
|
|
|
391
391
|
*/
|
|
392
392
|
fetchUsageReports?: (signal?: AbortSignal) => Promise<UsageReport[] | null>;
|
|
393
393
|
};
|
|
394
|
-
export
|
|
394
|
+
export { isDefinitiveOAuthFailure } from "./error/auth-classify";
|
|
395
395
|
/**
|
|
396
396
|
* Outcome of {@link AuthStorage.markUsageLimitReached}.
|
|
397
397
|
*
|
|
@@ -1023,4 +1023,3 @@ export declare class SqliteAuthCredentialStore implements AuthCredentialStore {
|
|
|
1023
1023
|
deleteProvider(provider: string): void;
|
|
1024
1024
|
close(): void;
|
|
1025
1025
|
}
|
|
1026
|
-
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wrap a prior-turn reasoning string for demotion into native conversation
|
|
3
|
+
* history — the cross-provider / cross-model case where the target cannot replay
|
|
4
|
+
* it as a structured thinking block (verified end-to-end against Gemini 3: a
|
|
5
|
+
* replayed unsigned `thought` part is schema-accepted but silently discarded —
|
|
6
|
+
* neither recalled nor influencing generation).
|
|
7
|
+
*
|
|
8
|
+
* The reasoning is rendered in the TARGET model's canonical inline thinking
|
|
9
|
+
* delimiters so it reads as reasoning in that model's own idiom instead of bare
|
|
10
|
+
* prose the model might continue. Harmony and Gemma are the exception: their
|
|
11
|
+
* `renderThinking` emits chat-template control tokens (`<|channel|>analysis`,
|
|
12
|
+
* `<|channel>thought`) that must not appear inside a structured native message,
|
|
13
|
+
* so they fall back to a plain `<think>` block. Every other dialect's thinking
|
|
14
|
+
* form is inline-safe XML tags or a markdown fence.
|
|
15
|
+
*
|
|
16
|
+
* The result ends with a trailing newline so the block stays separated from the
|
|
17
|
+
* turn's reply text when the wire encoder concatenates parts.
|
|
18
|
+
*
|
|
19
|
+
* Distinct from {@link DialectDefinition.renderThinking}, which targets the
|
|
20
|
+
* owned-dialect *text transport* where those control tokens are legal.
|
|
21
|
+
*/
|
|
22
|
+
export declare function renderDemotedThinking(modelId: string, text: string): string;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
export * from "./catalog";
|
|
2
2
|
export * from "./coercion";
|
|
3
|
+
export * from "./demotion";
|
|
3
4
|
export * from "./examples";
|
|
4
5
|
export * from "./factory";
|
|
5
6
|
export * from "./history";
|
|
6
7
|
export * from "./inventory";
|
|
7
8
|
export * from "./owned-stream";
|
|
8
9
|
export { renderDelimitedThinking } from "./rendering";
|
|
10
|
+
export * from "./thinking";
|
|
9
11
|
export * from "./types";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A request was cancelled — by the caller's `AbortSignal` or a provider-local
|
|
3
|
+
* watchdog. Carries the {@link Flag.Abort} classification structurally so retry
|
|
4
|
+
* logic does not have to regex the message text.
|
|
5
|
+
*
|
|
6
|
+
* The default message is kept byte-identical to the historical
|
|
7
|
+
* `"Request was aborted"` string so any remaining text-based matchers keep
|
|
8
|
+
* working through the migration.
|
|
9
|
+
*/
|
|
10
|
+
export declare class AbortError extends Error {
|
|
11
|
+
constructor(message?: string, options?: {
|
|
12
|
+
cause?: unknown;
|
|
13
|
+
});
|
|
14
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether an OAuth refresh failure is definitive (the credential must be
|
|
3
|
+
* disabled) versus transient. Thin alias over the {@link Flag.OAuthExpiry}
|
|
4
|
+
* text classifier {@link isOAuthExpiry}; retained as the public
|
|
5
|
+
* `@oh-my-pi/pi-ai` entrypoint name used by the coding agent and auth-broker.
|
|
6
|
+
*/
|
|
7
|
+
export declare function isDefinitiveOAuthFailure(errorMsg: string): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Whether an upstream failure should rotate to a sibling credential: a hard
|
|
10
|
+
* `401`, a body-classified usage limit (Codex `usage_limit_reached`, Anthropic
|
|
11
|
+
* account rate-limit, Google `resource_exhausted`, OpenAI `insufficient_quota`,
|
|
12
|
+
* …), or a bare `429` whose payload did not preserve a richer quota code.
|
|
13
|
+
* Transient 429s (`Too many requests`, per-minute caps) stay in the
|
|
14
|
+
* upstream-backoff lane.
|
|
15
|
+
*/
|
|
16
|
+
export declare function isAuthRetryableError(error: unknown): boolean;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* No API key / credential was available to dispatch a request.
|
|
3
|
+
*
|
|
4
|
+
* The default message preserves the historical `"No API key for provider: X"`
|
|
5
|
+
* wording, which {@link Flag.AuthFailed}'s regex (`no api key`) keys off — but
|
|
6
|
+
* the flag is also attached structurally so classification never depends on the
|
|
7
|
+
* exact phrasing.
|
|
8
|
+
*/
|
|
9
|
+
export declare class MissingApiKeyError extends Error {
|
|
10
|
+
readonly provider: string | undefined;
|
|
11
|
+
constructor(provider?: string, message?: string);
|
|
12
|
+
}
|
|
13
|
+
/** A user-facing login flow required an `onPrompt` callback that was not supplied. */
|
|
14
|
+
export declare class OnPromptRequiredError extends Error {
|
|
15
|
+
constructor(providerLabel: string);
|
|
16
|
+
}
|
|
17
|
+
/** An interactive login asked for an API key but the user supplied an empty value. */
|
|
18
|
+
export declare class ApiKeyRequiredError extends Error {
|
|
19
|
+
constructor(message?: string);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* A user cancelled an interactive login / device flow. Classified as an abort
|
|
23
|
+
* so it is never surfaced as a retryable transient failure.
|
|
24
|
+
*/
|
|
25
|
+
export declare class LoginCancelledError extends Error {
|
|
26
|
+
constructor(message?: string);
|
|
27
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** Which AWS credential-resolution path failed. */
|
|
2
|
+
export type AwsCredentialsErrorKind =
|
|
3
|
+
/** No usable credential source resolved (chain exhausted). */
|
|
4
|
+
"resolution"
|
|
5
|
+
/** SSO cache token missing (`aws sso login` not run). */
|
|
6
|
+
| "sso-token-missing"
|
|
7
|
+
/** SSO cache token present but expired. */
|
|
8
|
+
| "sso-token-expired"
|
|
9
|
+
/** SSO `GetRoleCredentials` call failed or returned no role. */
|
|
10
|
+
| "sso-role"
|
|
11
|
+
/** External `credential_process` failed, timed out, or emitted bad output. */
|
|
12
|
+
| "credential-process";
|
|
13
|
+
/** A failure resolving AWS credentials for the Bedrock provider. */
|
|
14
|
+
export declare class AwsCredentialsError extends Error {
|
|
15
|
+
readonly kind: AwsCredentialsErrorKind;
|
|
16
|
+
constructor(message: string, kind: AwsCredentialsErrorKind, options?: {
|
|
17
|
+
cause?: unknown;
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
/** A malformed AWS event-stream frame (bad length, CRC mismatch, unknown header type). */
|
|
21
|
+
export declare class EventStreamFrameError extends Error {
|
|
22
|
+
constructor(detail: string);
|
|
23
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import type { CapturedHttpErrorResponse } from "../utils/http-inspector";
|
|
2
|
+
/** Prefix on errors raised when an Anthropic SSE stream envelope is malformed. */
|
|
3
|
+
export declare const STREAM_ENVELOPE_ERROR_PREFIX = "Anthropic stream envelope error:";
|
|
4
|
+
/** Structured HTTP errors thrown by provider clients. */
|
|
5
|
+
export interface ProviderHttpErrorOptions {
|
|
6
|
+
/** Response headers; enables `retry-after`/rate-limit extraction downstream. */
|
|
7
|
+
headers?: Headers;
|
|
8
|
+
/** Machine-readable error code from the response body (`error.code` / `error.type`). */
|
|
9
|
+
code?: string;
|
|
10
|
+
cause?: unknown;
|
|
11
|
+
}
|
|
12
|
+
/** Non-2xx HTTP response from a provider. */
|
|
13
|
+
export declare class ProviderHttpError extends Error {
|
|
14
|
+
readonly status: number;
|
|
15
|
+
readonly headers: Headers | undefined;
|
|
16
|
+
readonly code: string | undefined;
|
|
17
|
+
constructor(message: string, status: number, options?: ProviderHttpErrorOptions);
|
|
18
|
+
}
|
|
19
|
+
/** Non-2xx response from an OpenAI-wire endpoint, with the decoded body attached. */
|
|
20
|
+
export declare class OpenAIHttpError extends ProviderHttpError {
|
|
21
|
+
readonly captured: CapturedHttpErrorResponse;
|
|
22
|
+
constructor(message: string, captured: CapturedHttpErrorResponse, code?: string, cause?: unknown);
|
|
23
|
+
/**
|
|
24
|
+
* Pull a human-readable message and machine code out of an OpenAI-style error
|
|
25
|
+
* envelope (`{ error: { message, code, type } }`), tolerating the flat shapes
|
|
26
|
+
* compat hosts return (`{ error: "..." }`, `{ message: "..." }`) and falling
|
|
27
|
+
* back to the raw body text.
|
|
28
|
+
*/
|
|
29
|
+
static parseEnvelope(bodyJson: unknown, bodyText: string | undefined): {
|
|
30
|
+
detail: string | undefined;
|
|
31
|
+
code: string | undefined;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/** Non-2xx response from the Anthropic API. */
|
|
35
|
+
export declare class AnthropicApiError extends ProviderHttpError {
|
|
36
|
+
readonly headers: Headers;
|
|
37
|
+
readonly requestId: string | null;
|
|
38
|
+
constructor(status: number, message: string, headers: Headers);
|
|
39
|
+
static fromResponse(response: Response): Promise<AnthropicApiError>;
|
|
40
|
+
}
|
|
41
|
+
/** Network-level failure (DNS, TLS, socket reset) after retries were exhausted. */
|
|
42
|
+
export declare class AnthropicConnectionError extends Error {
|
|
43
|
+
constructor(cause: unknown);
|
|
44
|
+
}
|
|
45
|
+
/** No response headers arrived within the configured request timeout. */
|
|
46
|
+
export declare class AnthropicConnectionTimeoutError extends Error {
|
|
47
|
+
constructor();
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* A malformed Anthropic SSE stream envelope — events arriving out of order
|
|
51
|
+
* (before `message_start`) or otherwise violating the message-event grammar.
|
|
52
|
+
* The message is prefixed with {@link STREAM_ENVELOPE_ERROR_PREFIX} so the
|
|
53
|
+
* shared envelope predicates classify it.
|
|
54
|
+
*/
|
|
55
|
+
export declare class AnthropicStreamEnvelopeError extends Error {
|
|
56
|
+
constructor(detail: string);
|
|
57
|
+
}
|
|
58
|
+
/** Non-2xx response (or in-stream exception event) from the Bedrock runtime API. */
|
|
59
|
+
export declare class BedrockApiError extends ProviderHttpError {
|
|
60
|
+
readonly name = "BedrockApiError";
|
|
61
|
+
}
|
|
62
|
+
/** Non-2xx response (or in-stream error chunk) from the Cloud Code Assist API. */
|
|
63
|
+
export declare class GeminiCliApiError extends ProviderHttpError {
|
|
64
|
+
readonly name = "GeminiCliApiError";
|
|
65
|
+
}
|
|
66
|
+
/** Non-2xx response (or in-stream error chunk) from the Google Generative Language / Vertex API. */
|
|
67
|
+
export declare class GoogleApiError extends ProviderHttpError {
|
|
68
|
+
readonly name = "GoogleApiError";
|
|
69
|
+
}
|
|
70
|
+
/** Non-2xx response from the Ollama `/api/chat` endpoint. */
|
|
71
|
+
export declare class OllamaApiError extends ProviderHttpError {
|
|
72
|
+
readonly name = "OllamaApiError";
|
|
73
|
+
}
|
|
74
|
+
/** Auth gateway HTTP failure. */
|
|
75
|
+
export declare class AuthGatewayError extends ProviderHttpError {
|
|
76
|
+
constructor(message: string, status: number, headers?: Headers, code?: string);
|
|
77
|
+
}
|
|
78
|
+
export declare class CodexWebSocketTransportError extends Error {
|
|
79
|
+
constructor(detail: string);
|
|
80
|
+
}
|
|
81
|
+
export declare class CodexWhitespaceToolCallLoopError extends Error {
|
|
82
|
+
constructor(message: string);
|
|
83
|
+
}
|
|
84
|
+
export declare class CodexProviderStreamError extends Error {
|
|
85
|
+
readonly retryable: boolean;
|
|
86
|
+
constructor(message: string, options?: {
|
|
87
|
+
retryable?: boolean;
|
|
88
|
+
cause?: unknown;
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
export declare class AuthBrokerError extends Error {
|
|
92
|
+
readonly status: number | undefined;
|
|
93
|
+
readonly body: string | undefined;
|
|
94
|
+
constructor(message: string, opts?: {
|
|
95
|
+
status?: number;
|
|
96
|
+
body?: string;
|
|
97
|
+
cause?: unknown;
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
export declare class AuthBrokerStreamUnsupportedError extends AuthBrokerError {
|
|
101
|
+
constructor(message?: string);
|
|
102
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Api } from "../types";
|
|
2
|
+
import type { AbortSourceTracker } from "../utils/abort";
|
|
3
|
+
import type { CapturedHttpErrorResponse, RawHttpRequestDump } from "../utils/http-inspector";
|
|
4
|
+
/** Context a provider catch block hands to {@link finalize}. */
|
|
5
|
+
export interface FinalizeOptions {
|
|
6
|
+
/** Wire API, for api-specific text classification (e.g. stale-responses items). */
|
|
7
|
+
api?: Api;
|
|
8
|
+
/** Provider id; forwarded to the message formatter for copilot rewrites. */
|
|
9
|
+
provider?: string;
|
|
10
|
+
/** Caller signal, for providers that don't run an abort tracker. */
|
|
11
|
+
signal?: AbortSignal;
|
|
12
|
+
/** Abort tracker, preferred over `signal`: distinguishes caller vs. local aborts. */
|
|
13
|
+
abortTracker?: AbortSourceTracker;
|
|
14
|
+
/** Raw request, dumped into the message for 400-class failures. */
|
|
15
|
+
rawRequestDump?: RawHttpRequestDump;
|
|
16
|
+
/** Captured non-2xx response body, used for status fallback and message detail. */
|
|
17
|
+
capturedErrorResponse?: CapturedHttpErrorResponse;
|
|
18
|
+
}
|
|
19
|
+
/** The full bundle a provider assigns onto its `AssistantMessage` error fields. */
|
|
20
|
+
export interface FinalizeResult {
|
|
21
|
+
/** Structured flag id from {@link classify}. */
|
|
22
|
+
id: number;
|
|
23
|
+
/** HTTP status, from the error or the captured response. */
|
|
24
|
+
status: number | undefined;
|
|
25
|
+
/** `"aborted"` when the caller cancelled, otherwise `"error"`. */
|
|
26
|
+
stopReason: "aborted" | "error";
|
|
27
|
+
/** User-facing message from {@link formatMessage}, or a local abort reason. */
|
|
28
|
+
message: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Build the complete error bundle for a provider catch block, replacing the
|
|
32
|
+
* `stopReason` / `errorStatus` / `errorId` / `errorMessage` boilerplate.
|
|
33
|
+
*
|
|
34
|
+
* `stopReason` comes from the abort tracker (caller intent dominates) or, when
|
|
35
|
+
* no tracker is supplied, the raw `signal.aborted`. A local abort reason (e.g. a
|
|
36
|
+
* first-event timeout) supersedes the formatted message. Message formatting is
|
|
37
|
+
* wrapped so a formatter throw can never skip the caller's `stream.end()`.
|
|
38
|
+
*/
|
|
39
|
+
export declare function finalize(error: unknown, opts?: FinalizeOptions): Promise<FinalizeResult>;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { Api, AssistantMessage } from "../types";
|
|
2
|
+
export declare const Flag: {
|
|
3
|
+
readonly Class: 4096;
|
|
4
|
+
readonly ThinkingLoop: 65536;
|
|
5
|
+
readonly Transient: 131072;
|
|
6
|
+
readonly Timeout: 262144;
|
|
7
|
+
readonly UsageLimit: 524288;
|
|
8
|
+
readonly StaleResponsesItem: 1048576;
|
|
9
|
+
readonly MalformedFunctionCall: 2097152;
|
|
10
|
+
readonly ProviderFinishError: 4194304;
|
|
11
|
+
readonly ContextOverflow: 8388608;
|
|
12
|
+
readonly AuthFailed: 16777216;
|
|
13
|
+
readonly SilentAbort: 33554432;
|
|
14
|
+
readonly UserInterrupt: 67108864;
|
|
15
|
+
readonly Abort: 134217728;
|
|
16
|
+
/** Anthropic strict-tool grammar too large / schema too complex to compile (400). */
|
|
17
|
+
readonly Grammar: 268435456;
|
|
18
|
+
/** Anthropic model/account does not support fast mode / the `speed` parameter. */
|
|
19
|
+
readonly FastModeUnsupported: 536870912;
|
|
20
|
+
/** OAuth refresh failed definitively — the stored grant is dead, re-login required. */
|
|
21
|
+
readonly OAuthExpiry: 1073741824;
|
|
22
|
+
};
|
|
23
|
+
export type Flag = (typeof Flag)[keyof typeof Flag];
|
|
24
|
+
export declare const TRANSIENT_TRANSPORT_PATTERN: RegExp;
|
|
25
|
+
/** Whether an OAuth refresh error message means the grant is definitively dead. */
|
|
26
|
+
export declare function isOAuthExpiry(errorMessage: string): boolean;
|
|
27
|
+
export declare function create(...flags: number[]): number;
|
|
28
|
+
export declare function is(id: number | undefined, flag: Flag): boolean;
|
|
29
|
+
export declare function retriable(id: number | undefined, opts?: {
|
|
30
|
+
replayUnsafe?: boolean;
|
|
31
|
+
}): boolean;
|
|
32
|
+
export declare function status(error: unknown): number | undefined;
|
|
33
|
+
export declare function classify(error: unknown, api?: Api): number;
|
|
34
|
+
/**
|
|
35
|
+
* Whether an error (or message string) classifies as an account usage/quota
|
|
36
|
+
* limit — the persistent, credential-rotation-worthy kind. This is the public
|
|
37
|
+
* accessor for {@link Flag.UsageLimit}; prefer it over re-running message
|
|
38
|
+
* regexes at call sites.
|
|
39
|
+
*/
|
|
40
|
+
export declare function isUsageLimit(error: unknown, api?: Api): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Anthropic strict-tool grammar too large / schema too complex to compile.
|
|
43
|
+
* Accessor for {@link Flag.Grammar}.
|
|
44
|
+
*/
|
|
45
|
+
export declare function isGrammarError(error: unknown): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Anthropic model/account does not support fast mode / the `speed` parameter.
|
|
48
|
+
* Accessor for {@link Flag.FastModeUnsupported}.
|
|
49
|
+
*/
|
|
50
|
+
export declare function isFastModeUnsupported(error: unknown): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* GitHub Copilot 400 `model_not_supported` routing flap — transient. Reads the
|
|
53
|
+
* structural `code` (and falls back to {@link Flag.Transient} text classification).
|
|
54
|
+
*/
|
|
55
|
+
export declare function isCopilotTransientModelError(error: unknown): boolean;
|
|
56
|
+
export declare function classifyMessage(message: {
|
|
57
|
+
api?: Api;
|
|
58
|
+
errorId?: number;
|
|
59
|
+
errorMessage?: string;
|
|
60
|
+
errorStatus?: number;
|
|
61
|
+
}): number;
|
|
62
|
+
export declare function attach<E extends object>(error: E, id: number): E;
|
|
63
|
+
export declare function isContextOverflow(message: AssistantMessage, contextWindow?: number): boolean;
|
|
64
|
+
export declare function stringify(id: number | undefined): string;
|
|
65
|
+
/** Transient stream corruption where the response was truncated mid-JSON. */
|
|
66
|
+
export declare function isTransientStreamParseError(error: unknown): boolean;
|
|
67
|
+
/** Any malformed stream-envelope error (prefix-tagged or out-of-order events). */
|
|
68
|
+
export declare function isStreamEnvelopeError(error: unknown): boolean;
|
|
69
|
+
/** Stream-envelope errors safe to retry against the provider (event ordering only). */
|
|
70
|
+
export declare function isRetryableStreamEnvelopeError(error: unknown): boolean;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type CapturedHttpErrorResponse, type RawHttpRequestDump } from "../utils/http-inspector";
|
|
2
|
+
/** Inputs that steer {@link formatMessage}'s formatter selection. */
|
|
3
|
+
export interface FormatMessageOptions {
|
|
4
|
+
/** When present, the raw request is dumped into the message for 400-class failures. */
|
|
5
|
+
rawRequestDump?: RawHttpRequestDump;
|
|
6
|
+
/** Captured non-2xx response body, appended to the message when available. */
|
|
7
|
+
capturedErrorResponse?: CapturedHttpErrorResponse;
|
|
8
|
+
/** Provider id; `"github-copilot"` triggers the copilot message rewrite. */
|
|
9
|
+
provider?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Format a provider error into a user-facing message, unifying the three
|
|
13
|
+
* formatters: lightweight retry-after extraction, the raw-dump finalizer, and
|
|
14
|
+
* the copilot rewrite.
|
|
15
|
+
*
|
|
16
|
+
* Selection is driven by inputs, not a mode flag: a `rawRequestDump` routes
|
|
17
|
+
* through {@link finalizeErrorMessage} (retry-after + raw dump + captured body),
|
|
18
|
+
* otherwise the lightweight {@link formatErrorMessageWithRetryAfter} is used.
|
|
19
|
+
*/
|
|
20
|
+
export declare function formatMessage(error: unknown, opts?: FormatMessageOptions): Promise<string>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** A gateway-facing classification of an arbitrary upstream/internal error. */
|
|
2
|
+
export interface GatewayErrorClassification {
|
|
3
|
+
status: number;
|
|
4
|
+
type: string;
|
|
5
|
+
message: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Classify an upstream / gateway-internal error into a status code and a
|
|
9
|
+
* format-neutral type. The order is intentional:
|
|
10
|
+
*
|
|
11
|
+
* 1. Honour an explicit numeric `status` property on the thrown error.
|
|
12
|
+
* 2. Parse a status code embedded in the message string. Provider errors
|
|
13
|
+
* virtually always carry one (`Google API error (400): …`, `HTTP 429`,
|
|
14
|
+
* `status=503`) and the embedded value is authoritative.
|
|
15
|
+
* 3. Fall through to **word-boundaried** substring heuristics. The old
|
|
16
|
+
* `lower.includes("rate")` test famously matched `GenerateContentRequest`,
|
|
17
|
+
* surfacing every Google 400 as a 429 `rate_limit_error`. The patterns here
|
|
18
|
+
* all require boundaries so they don't collide with provider field names.
|
|
19
|
+
*/
|
|
20
|
+
export declare function classifyGatewayError(err: unknown): GatewayErrorClassification;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from "./abort";
|
|
2
|
+
export * from "./auth";
|
|
3
|
+
export * from "./auth-classify";
|
|
4
|
+
export * from "./aws";
|
|
5
|
+
export * from "./classes";
|
|
6
|
+
export * from "./finalize";
|
|
7
|
+
export * from "./flags";
|
|
8
|
+
export * from "./format";
|
|
9
|
+
export * from "./gateway";
|
|
10
|
+
export * from "./oauth";
|
|
11
|
+
export * from "./provider";
|
|
12
|
+
export * from "./retryable";
|
|
13
|
+
export * from "./validation";
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What stage of an OAuth / device-code login flow failed. Discriminates the
|
|
3
|
+
* single {@link OAuthError} class so login flows don't each mint a bespoke
|
|
4
|
+
* error type.
|
|
5
|
+
*/
|
|
6
|
+
export type OAuthErrorKind =
|
|
7
|
+
/** Token-exchange / refresh / discovery HTTP response was non-2xx or unparseable. */
|
|
8
|
+
"http"
|
|
9
|
+
/** Response body was missing required fields (token, account id, endpoints, …). */
|
|
10
|
+
| "validation"
|
|
11
|
+
/** Authorization-code → token exchange failed. */
|
|
12
|
+
| "token-exchange"
|
|
13
|
+
/** Refresh-token grant failed. */
|
|
14
|
+
| "token-refresh"
|
|
15
|
+
/** Device-code / authorization polling failed (server error, too many retries). */
|
|
16
|
+
| "polling"
|
|
17
|
+
/** The flow exceeded its deadline (device-code expiry, polling timeout). */
|
|
18
|
+
| "timeout"
|
|
19
|
+
/** Device authorization was denied or cancelled by the user/provider. */
|
|
20
|
+
| "device-auth"
|
|
21
|
+
/** Misconfiguration (bad redirect URI, missing projectId, callback bind, …). */
|
|
22
|
+
| "configuration"
|
|
23
|
+
/** Cloud project provisioning / onboarding (loadCodeAssist, onboardUser). */
|
|
24
|
+
| "provisioning"
|
|
25
|
+
/** OIDC / endpoint discovery failed. */
|
|
26
|
+
| "discovery";
|
|
27
|
+
export interface OAuthErrorOptions {
|
|
28
|
+
kind?: OAuthErrorKind;
|
|
29
|
+
provider?: string;
|
|
30
|
+
status?: number;
|
|
31
|
+
cause?: unknown;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* A failure inside an interactive OAuth / device-code login flow. The `kind`
|
|
35
|
+
* pinpoints the stage. Timeout/polling are classified transient; everything
|
|
36
|
+
* else is a hard auth failure so the credential layer does not silently retry.
|
|
37
|
+
*/
|
|
38
|
+
export declare class OAuthError extends Error {
|
|
39
|
+
readonly kind: OAuthErrorKind;
|
|
40
|
+
readonly provider: string | undefined;
|
|
41
|
+
readonly status: number | undefined;
|
|
42
|
+
constructor(message: string, options?: OAuthErrorOptions);
|
|
43
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { ProviderHttpError } from "./classes";
|
|
2
|
+
/** Which part of a provider exchange produced a non-HTTP error. */
|
|
3
|
+
export type ProviderResponseErrorKind =
|
|
4
|
+
/** Stream closed before a terminal completion/response event. */
|
|
5
|
+
"incomplete-stream"
|
|
6
|
+
/** Terminal event carried an error / unexpected stop reason. */
|
|
7
|
+
| "output"
|
|
8
|
+
/** Response body was empty/missing when content was required. */
|
|
9
|
+
| "empty-body"
|
|
10
|
+
/** Malformed wire envelope (unexpected message ordering / shape). */
|
|
11
|
+
| "envelope"
|
|
12
|
+
/** Content was blocked by a provider safety filter. */
|
|
13
|
+
| "content-blocked"
|
|
14
|
+
/** Runtime/namespace resolution or other provider-internal failure. */
|
|
15
|
+
| "runtime";
|
|
16
|
+
export interface ProviderResponseErrorOptions {
|
|
17
|
+
provider?: string;
|
|
18
|
+
kind?: ProviderResponseErrorKind;
|
|
19
|
+
cause?: unknown;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* A non-HTTP provider failure: a truncated stream, an error stop reason, an
|
|
23
|
+
* empty body, a malformed envelope, or a runtime fault. For non-2xx HTTP
|
|
24
|
+
* responses use {@link ProviderHttpError} (or a provider subclass) instead.
|
|
25
|
+
*/
|
|
26
|
+
export declare class ProviderResponseError extends Error {
|
|
27
|
+
readonly provider: string | undefined;
|
|
28
|
+
readonly kind: ProviderResponseErrorKind;
|
|
29
|
+
constructor(message: string, options?: ProviderResponseErrorOptions);
|
|
30
|
+
}
|
|
31
|
+
/** Non-2xx response from the Devin API. */
|
|
32
|
+
export declare class DevinApiError extends ProviderHttpError {
|
|
33
|
+
readonly name = "DevinApiError";
|
|
34
|
+
}
|
|
35
|
+
/** Non-2xx response from the GitLab Duo direct-access API. */
|
|
36
|
+
export declare class GitLabDuoApiError extends ProviderHttpError {
|
|
37
|
+
readonly name = "GitLabDuoApiError";
|
|
38
|
+
}
|
|
39
|
+
/** Non-2xx response from the GitLab Duo Workflow API. */
|
|
40
|
+
export declare class GitLabDuoWorkflowApiError extends ProviderHttpError {
|
|
41
|
+
readonly name = "GitLabDuoWorkflowApiError";
|
|
42
|
+
}
|
|
@@ -43,4 +43,17 @@ export declare function isUsageLimitStatus(status: number | undefined): boolean;
|
|
|
43
43
|
* credentials.
|
|
44
44
|
*/
|
|
45
45
|
export declare function isUsageLimitOutcome(status: number | undefined, message: string | undefined): boolean;
|
|
46
|
-
|
|
46
|
+
/**
|
|
47
|
+
* A 429 body is opaque when it carries no signal beyond the status itself —
|
|
48
|
+
* empty, whitespace-only, the status digits with HTTP/JSON framing, or
|
|
49
|
+
* generic punctuation. Anything else (retry hints, capacity wording, error
|
|
50
|
+
* descriptions) is informative enough to defer to the classifier.
|
|
51
|
+
*/
|
|
52
|
+
export declare function isOpaqueStatusBody(message: string): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Internal text matcher for usage/quota-limit phrasing. NOT part of the public
|
|
55
|
+
* API — callers classify through {@link import("./flags").isUsageLimit} (the
|
|
56
|
+
* flag accessor). `flags.ts` consumes this to populate `Flag.UsageLimit`, and
|
|
57
|
+
* {@link isUsageLimitOutcome} uses it for the account-rotation decision.
|
|
58
|
+
*/
|
|
59
|
+
export declare function matchesUsageLimitText(errorMessage: string): boolean;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether a numeric HTTP status is in the canonical transient/retryable set:
|
|
3
|
+
* 408 (Request Timeout), 429 (Too Many Requests), and any 5xx.
|
|
4
|
+
*
|
|
5
|
+
* This is a pure predicate over a status code already in hand — distinct from
|
|
6
|
+
* {@link classify}, which inspects a whole error (including message text) and
|
|
7
|
+
* may match more. Use this when you only have a `status: number`.
|
|
8
|
+
*/
|
|
9
|
+
export declare function isTransientStatus(status: number | undefined): boolean;
|
|
10
|
+
/** Hook for provider-specific transient detection that the error module must not import directly. */
|
|
11
|
+
export interface ProviderRetryableHooks {
|
|
12
|
+
/** Provider id of the failing request, used to gate provider-specific checks. */
|
|
13
|
+
provider?: string;
|
|
14
|
+
/** Provider-specific transient predicate (e.g. Copilot `model_not_supported`). */
|
|
15
|
+
isProviderTransient?: (error: Error) => boolean;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Whether a provider stream error should be retried against the same credential.
|
|
19
|
+
*
|
|
20
|
+
* Account-level usage/quota limits are deliberately treated as **non**-retryable
|
|
21
|
+
* here — they are owned by the credential-rotation layer (auth-gateway /
|
|
22
|
+
* `streamSimple` a/b/c policy), not this seconds-scale provider backoff.
|
|
23
|
+
*
|
|
24
|
+
* Provider-specific transient cases are injected via {@link ProviderRetryableHooks}
|
|
25
|
+
* so this stays free of provider imports.
|
|
26
|
+
*/
|
|
27
|
+
export declare function isProviderRetryableError(error: unknown, hooks?: ProviderRetryableHooks): boolean;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Caller-supplied input failed validation before/while building a provider
|
|
3
|
+
* request: bad request body, malformed tool arguments, unsupported content
|
|
4
|
+
* type, a schema that cannot be normalized, an unknown tool, etc.
|
|
5
|
+
*
|
|
6
|
+
* This is a programmer/config/contract error, not a transient provider fault —
|
|
7
|
+
* it is never retried.
|
|
8
|
+
*/
|
|
9
|
+
export declare class ValidationError extends Error {
|
|
10
|
+
constructor(message: string, options?: {
|
|
11
|
+
cause?: unknown;
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
/** A referenced tool was not found in the active tool set. */
|
|
15
|
+
export declare class ToolNotFoundError extends ValidationError {
|
|
16
|
+
constructor(toolName: string);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Provider/auth configuration was missing or malformed (env var pointing at a
|
|
20
|
+
* missing file, missing projectId, bad bind string, mTLS half-configured, …).
|
|
21
|
+
*/
|
|
22
|
+
export declare class ConfigurationError extends Error {
|
|
23
|
+
constructor(message: string, options?: {
|
|
24
|
+
cause?: unknown;
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
/** A request was abandoned because it exceeded a stream/idle/first-event deadline. */
|
|
28
|
+
export declare class StreamTimeoutError extends Error {
|
|
29
|
+
constructor(message?: string, options?: {
|
|
30
|
+
cause?: unknown;
|
|
31
|
+
});
|
|
32
|
+
}
|