@opencode-ai/ai 0.0.0-dev-18409 → 0.0.0-dev-18412
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/image.js +5 -4
- package/dist/llm.js +4 -7
- package/dist/protocols/anthropic-messages.js +7 -5
- package/dist/protocols/bedrock-converse.js +4 -6
- package/dist/protocols/bedrock-event-stream.js +16 -6
- package/dist/protocols/gemini.d.ts +1 -0
- package/dist/protocols/gemini.js +13 -1
- package/dist/protocols/google-images.js +8 -18
- package/dist/protocols/open-responses-channel.js +20 -9
- package/dist/protocols/open-responses-continuation.js +9 -8
- package/dist/protocols/open-responses.d.ts +1 -1
- package/dist/protocols/open-responses.js +7 -16
- package/dist/protocols/openai-chat.js +23 -18
- package/dist/protocols/openai-images.js +11 -16
- package/dist/protocols/openai-responses.js +1 -1
- package/dist/protocols/shared.d.ts +7 -3
- package/dist/protocols/shared.js +26 -13
- package/dist/protocols/utils/image-input.d.ts +4 -4
- package/dist/protocols/utils/image-input.js +6 -8
- package/dist/protocols/xai-images.js +7 -12
- package/dist/protocols/zai-images.js +5 -10
- package/dist/provider-error.d.ts +4 -4
- package/dist/provider-error.js +31 -32
- package/dist/route/auth.js +3 -5
- package/dist/route/client.js +29 -11
- package/dist/route/executor.d.ts +9 -5
- package/dist/route/executor.js +33 -66
- package/dist/route/framing.d.ts +2 -0
- package/dist/route/transport/http.js +7 -2
- package/dist/route/transport/index.d.ts +3 -1
- package/dist/route/transport/websocket-channel.d.ts +2 -1
- package/dist/route/transport/websocket.d.ts +2 -1
- package/dist/route/transport/websocket.js +70 -30
- package/dist/schema/errors.d.ts +71 -88
- package/dist/schema/errors.js +36 -85
- package/package.json +3 -3
package/dist/schema/errors.d.ts
CHANGED
|
@@ -2,18 +2,12 @@ import { Schema } from "effect";
|
|
|
2
2
|
import { Tool } from "@opencode-ai/schema/tool";
|
|
3
3
|
export declare const ProviderFailureClassification: Schema.Literals<readonly ["context-overflow", "payload-too-large"]>;
|
|
4
4
|
export type ProviderFailureClassification = typeof ProviderFailureClassification.Type;
|
|
5
|
-
declare const
|
|
6
|
-
readonly method: Schema.String;
|
|
5
|
+
declare const HttpContext_base: Schema.Class<HttpContext, Schema.Struct<{
|
|
7
6
|
readonly url: Schema.String;
|
|
7
|
+
readonly status: Schema.Int;
|
|
8
8
|
readonly headers: Schema.$Record<Schema.String, Schema.String>;
|
|
9
9
|
}>, {}>;
|
|
10
|
-
export declare class
|
|
11
|
-
}
|
|
12
|
-
declare const HttpResponseDetails_base: Schema.Class<HttpResponseDetails, Schema.Struct<{
|
|
13
|
-
readonly status: Schema.Number;
|
|
14
|
-
readonly headers: Schema.$Record<Schema.String, Schema.String>;
|
|
15
|
-
}>, {}>;
|
|
16
|
-
export declare class HttpResponseDetails extends HttpResponseDetails_base {
|
|
10
|
+
export declare class HttpContext extends HttpContext_base {
|
|
17
11
|
}
|
|
18
12
|
declare const HttpRateLimitDetails_base: Schema.Class<HttpRateLimitDetails, Schema.Struct<{
|
|
19
13
|
readonly retryAfterMs: Schema.optional<Schema.Number>;
|
|
@@ -23,126 +17,115 @@ declare const HttpRateLimitDetails_base: Schema.Class<HttpRateLimitDetails, Sche
|
|
|
23
17
|
}>, {}>;
|
|
24
18
|
export declare class HttpRateLimitDetails extends HttpRateLimitDetails_base {
|
|
25
19
|
}
|
|
26
|
-
declare const
|
|
27
|
-
readonly request: typeof HttpRequestDetails;
|
|
28
|
-
readonly response: Schema.optional<typeof HttpResponseDetails>;
|
|
29
|
-
readonly body: Schema.optional<Schema.String>;
|
|
30
|
-
readonly bodyTruncated: Schema.optional<Schema.Boolean>;
|
|
31
|
-
readonly rateLimit: Schema.optional<typeof HttpRateLimitDetails>;
|
|
32
|
-
}>, {}>;
|
|
33
|
-
export declare class HttpContext extends HttpContext_base {
|
|
34
|
-
}
|
|
35
|
-
declare const InvalidRequestReason_base: Schema.Class<InvalidRequestReason, Schema.Struct<{
|
|
36
|
-
readonly _tag: Schema.tag<"InvalidRequest">;
|
|
37
|
-
readonly message: Schema.String;
|
|
20
|
+
declare const InvalidRequestError_base: Schema.Class<InvalidRequestError, Schema.TaggedStruct<"InvalidRequest", {
|
|
38
21
|
readonly parameter: Schema.optional<Schema.String>;
|
|
39
22
|
readonly classification: Schema.optional<Schema.Literals<readonly ["context-overflow", "payload-too-large"]>>;
|
|
40
|
-
readonly
|
|
23
|
+
readonly message: Schema.String;
|
|
24
|
+
readonly body: Schema.optional<Schema.String>;
|
|
41
25
|
readonly http: Schema.optional<typeof HttpContext>;
|
|
42
|
-
|
|
43
|
-
|
|
26
|
+
readonly cause: Schema.optional<Schema.Defect>;
|
|
27
|
+
}>, import("effect/Cause").YieldableError>;
|
|
28
|
+
export declare class InvalidRequestError extends InvalidRequestError_base {
|
|
44
29
|
}
|
|
45
|
-
declare const
|
|
46
|
-
readonly _tag: Schema.tag<"NoRoute">;
|
|
30
|
+
declare const NoRouteError_base: Schema.Class<NoRouteError, Schema.TaggedStruct<"NoRoute", {
|
|
47
31
|
readonly route: Schema.String;
|
|
48
32
|
readonly provider: Schema.brand<Schema.String, "AI.ProviderID">;
|
|
49
33
|
readonly model: Schema.brand<Schema.String, "AI.ModelID">;
|
|
50
|
-
}>, {}>;
|
|
51
|
-
export declare class NoRouteReason extends NoRouteReason_base {
|
|
52
|
-
get message(): string;
|
|
53
|
-
}
|
|
54
|
-
declare const AuthenticationReason_base: Schema.Class<AuthenticationReason, Schema.Struct<{
|
|
55
|
-
readonly _tag: Schema.tag<"Authentication">;
|
|
56
34
|
readonly message: Schema.String;
|
|
57
|
-
readonly
|
|
58
|
-
readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
|
|
35
|
+
readonly body: Schema.optional<Schema.String>;
|
|
59
36
|
readonly http: Schema.optional<typeof HttpContext>;
|
|
60
|
-
|
|
61
|
-
|
|
37
|
+
readonly cause: Schema.optional<Schema.Defect>;
|
|
38
|
+
}>, import("effect/Cause").YieldableError>;
|
|
39
|
+
export declare class NoRouteError extends NoRouteError_base {
|
|
62
40
|
}
|
|
63
|
-
declare const
|
|
64
|
-
readonly
|
|
41
|
+
declare const AuthenticationError_base: Schema.Class<AuthenticationError, Schema.TaggedStruct<"Authentication", {
|
|
42
|
+
readonly kind: Schema.Literals<readonly ["missing", "invalid", "expired", "insufficient-permissions", "unknown"]>;
|
|
65
43
|
readonly message: Schema.String;
|
|
66
|
-
readonly
|
|
67
|
-
readonly rateLimit: Schema.optional<typeof HttpRateLimitDetails>;
|
|
68
|
-
readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
|
|
44
|
+
readonly body: Schema.optional<Schema.String>;
|
|
69
45
|
readonly http: Schema.optional<typeof HttpContext>;
|
|
70
|
-
|
|
71
|
-
|
|
46
|
+
readonly cause: Schema.optional<Schema.Defect>;
|
|
47
|
+
}>, import("effect/Cause").YieldableError>;
|
|
48
|
+
export declare class AuthenticationError extends AuthenticationError_base {
|
|
72
49
|
}
|
|
73
|
-
declare const
|
|
74
|
-
readonly
|
|
50
|
+
declare const RateLimitError_base: Schema.Class<RateLimitError, Schema.TaggedStruct<"RateLimit", {
|
|
51
|
+
readonly retryAfterMs: Schema.optional<Schema.Number>;
|
|
52
|
+
readonly rateLimit: Schema.optional<typeof HttpRateLimitDetails>;
|
|
75
53
|
readonly message: Schema.String;
|
|
76
|
-
readonly
|
|
54
|
+
readonly body: Schema.optional<Schema.String>;
|
|
77
55
|
readonly http: Schema.optional<typeof HttpContext>;
|
|
78
|
-
|
|
79
|
-
|
|
56
|
+
readonly cause: Schema.optional<Schema.Defect>;
|
|
57
|
+
}>, import("effect/Cause").YieldableError>;
|
|
58
|
+
export declare class RateLimitError extends RateLimitError_base {
|
|
80
59
|
}
|
|
81
|
-
declare const
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}>,
|
|
87
|
-
export declare class
|
|
60
|
+
declare const QuotaExceededError_base: Schema.Class<QuotaExceededError, Schema.TaggedStruct<"QuotaExceeded", {
|
|
61
|
+
message: Schema.String;
|
|
62
|
+
body: Schema.optional<Schema.String>;
|
|
63
|
+
http: Schema.optional<typeof HttpContext>;
|
|
64
|
+
cause: Schema.optional<Schema.Defect>;
|
|
65
|
+
}>, import("effect/Cause").YieldableError>;
|
|
66
|
+
export declare class QuotaExceededError extends QuotaExceededError_base {
|
|
88
67
|
}
|
|
89
|
-
declare const
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
68
|
+
declare const ContentPolicyError_base: Schema.Class<ContentPolicyError, Schema.TaggedStruct<"ContentPolicy", {
|
|
69
|
+
message: Schema.String;
|
|
70
|
+
body: Schema.optional<Schema.String>;
|
|
71
|
+
http: Schema.optional<typeof HttpContext>;
|
|
72
|
+
cause: Schema.optional<Schema.Defect>;
|
|
73
|
+
}>, import("effect/Cause").YieldableError>;
|
|
74
|
+
export declare class ContentPolicyError extends ContentPolicyError_base {
|
|
75
|
+
}
|
|
76
|
+
declare const ProviderInternalError_base: Schema.Class<ProviderInternalError, Schema.TaggedStruct<"ProviderInternal", {
|
|
93
77
|
readonly retryAfterMs: Schema.optional<Schema.Number>;
|
|
94
|
-
readonly
|
|
78
|
+
readonly message: Schema.String;
|
|
79
|
+
readonly body: Schema.optional<Schema.String>;
|
|
95
80
|
readonly http: Schema.optional<typeof HttpContext>;
|
|
96
|
-
|
|
97
|
-
|
|
81
|
+
readonly cause: Schema.optional<Schema.Defect>;
|
|
82
|
+
}>, import("effect/Cause").YieldableError>;
|
|
83
|
+
export declare class ProviderInternalError extends ProviderInternalError_base {
|
|
98
84
|
}
|
|
99
85
|
export declare const TransportType: Schema.Literals<readonly ["http", "websocket"]>;
|
|
100
86
|
export type TransportType = typeof TransportType.Type;
|
|
101
87
|
export declare const TransportOperation: Schema.Literals<readonly ["request", "read", "write"]>;
|
|
102
88
|
export type TransportOperation = typeof TransportOperation.Type;
|
|
103
|
-
declare const
|
|
104
|
-
readonly _tag: Schema.tag<"Transport">;
|
|
105
|
-
readonly message: Schema.String;
|
|
89
|
+
declare const TransportError_base: Schema.Class<TransportError, Schema.TaggedStruct<"Transport", {
|
|
106
90
|
readonly transport: Schema.Literals<readonly ["http", "websocket"]>;
|
|
107
91
|
readonly operation: Schema.Literals<readonly ["request", "read", "write"]>;
|
|
108
92
|
readonly code: Schema.optional<Schema.String>;
|
|
109
93
|
readonly url: Schema.optional<Schema.String>;
|
|
110
|
-
readonly http: Schema.optional<typeof HttpContext>;
|
|
111
94
|
readonly phase: Schema.optional<Schema.Literals<readonly ["prepare", "queue", "connect", "send", "receive", "decode", "complete", "fallback", "close"]>>;
|
|
112
95
|
readonly delivery: Schema.optional<Schema.Literals<readonly ["not-sent", "rejected", "ambiguous", "accepted"]>>;
|
|
113
96
|
readonly recovery: Schema.optional<Schema.Literals<readonly ["retry-connect", "retry-full", "rotate-and-retry-full", "fallback-http", "fail"]>>;
|
|
114
|
-
}>, {}>;
|
|
115
|
-
export declare class TransportReason extends TransportReason_base {
|
|
116
|
-
}
|
|
117
|
-
declare const InvalidProviderOutputReason_base: Schema.Class<InvalidProviderOutputReason, Schema.Struct<{
|
|
118
|
-
readonly _tag: Schema.tag<"InvalidProviderOutput">;
|
|
119
97
|
readonly message: Schema.String;
|
|
98
|
+
readonly body: Schema.optional<Schema.String>;
|
|
99
|
+
readonly http: Schema.optional<typeof HttpContext>;
|
|
100
|
+
readonly cause: Schema.optional<Schema.Defect>;
|
|
101
|
+
}>, import("effect/Cause").YieldableError>;
|
|
102
|
+
export declare class TransportError extends TransportError_base {
|
|
103
|
+
}
|
|
104
|
+
declare const InvalidProviderOutputError_base: Schema.Class<InvalidProviderOutputError, Schema.TaggedStruct<"InvalidProviderOutput", {
|
|
120
105
|
readonly classification: Schema.optional<Schema.Literals<readonly ["incomplete-stream"]>>;
|
|
121
106
|
readonly route: Schema.optional<Schema.String>;
|
|
122
|
-
readonly raw: Schema.optional<Schema.String>;
|
|
123
|
-
readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
|
|
124
|
-
}>, {}>;
|
|
125
|
-
export declare class InvalidProviderOutputReason extends InvalidProviderOutputReason_base {
|
|
126
|
-
}
|
|
127
|
-
declare const UnknownProviderReason_base: Schema.Class<UnknownProviderReason, Schema.Struct<{
|
|
128
|
-
readonly _tag: Schema.tag<"UnknownProvider">;
|
|
129
107
|
readonly message: Schema.String;
|
|
130
|
-
readonly
|
|
131
|
-
readonly providerMetadata: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>;
|
|
108
|
+
readonly body: Schema.optional<Schema.String>;
|
|
132
109
|
readonly http: Schema.optional<typeof HttpContext>;
|
|
133
|
-
|
|
134
|
-
|
|
110
|
+
readonly cause: Schema.optional<Schema.Defect>;
|
|
111
|
+
}>, import("effect/Cause").YieldableError>;
|
|
112
|
+
export declare class InvalidProviderOutputError extends InvalidProviderOutputError_base {
|
|
135
113
|
}
|
|
136
|
-
|
|
114
|
+
declare const UnknownProviderError_base: Schema.Class<UnknownProviderError, Schema.TaggedStruct<"UnknownProvider", {
|
|
115
|
+
message: Schema.String;
|
|
116
|
+
body: Schema.optional<Schema.String>;
|
|
117
|
+
http: Schema.optional<typeof HttpContext>;
|
|
118
|
+
cause: Schema.optional<Schema.Defect>;
|
|
119
|
+
}>, import("effect/Cause").YieldableError>;
|
|
120
|
+
export declare class UnknownProviderError extends UnknownProviderError_base {
|
|
121
|
+
}
|
|
122
|
+
export declare const AIErrorReason: Schema.toTaggedUnion<"_tag", readonly [typeof InvalidRequestError, typeof NoRouteError, typeof AuthenticationError, typeof RateLimitError, typeof QuotaExceededError, typeof ContentPolicyError, typeof ProviderInternalError, typeof TransportError, typeof InvalidProviderOutputError, typeof UnknownProviderError]>;
|
|
137
123
|
export type AIErrorReason = Schema.Schema.Type<typeof AIErrorReason>;
|
|
138
124
|
declare const AIError_base: Schema.Class<AIError, Schema.TaggedStruct<"AI.Error", {
|
|
139
|
-
readonly
|
|
140
|
-
readonly method: Schema.String;
|
|
141
|
-
readonly reason: Schema.toTaggedUnion<"_tag", readonly [typeof InvalidRequestReason, typeof NoRouteReason, typeof AuthenticationReason, typeof RateLimitReason, typeof QuotaExceededReason, typeof ContentPolicyReason, typeof ProviderInternalReason, typeof TransportReason, typeof InvalidProviderOutputReason, typeof UnknownProviderReason]>;
|
|
142
|
-
readonly body: Schema.optional<Schema.String>;
|
|
125
|
+
readonly reason: Schema.toTaggedUnion<"_tag", readonly [typeof InvalidRequestError, typeof NoRouteError, typeof AuthenticationError, typeof RateLimitError, typeof QuotaExceededError, typeof ContentPolicyError, typeof ProviderInternalError, typeof TransportError, typeof InvalidProviderOutputError, typeof UnknownProviderError]>;
|
|
143
126
|
}>, import("effect/Cause").YieldableError>;
|
|
144
127
|
export declare class AIError extends AIError_base {
|
|
145
|
-
readonly cause:
|
|
128
|
+
readonly cause: InvalidRequestError | NoRouteError | AuthenticationError | RateLimitError | QuotaExceededError | ContentPolicyError | ProviderInternalError | TransportError | InvalidProviderOutputError | UnknownProviderError;
|
|
146
129
|
get message(): string;
|
|
147
130
|
}
|
|
148
131
|
/**
|
package/dist/schema/errors.js
CHANGED
|
@@ -1,16 +1,10 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
2
|
import { Tool } from "@opencode-ai/schema/tool";
|
|
3
3
|
import { ModelID, ProviderID, RouteID } from "./ids.js";
|
|
4
|
-
import { ProviderMetadata } from "./messages.js";
|
|
5
4
|
export const ProviderFailureClassification = Schema.Literals(["context-overflow", "payload-too-large"]);
|
|
6
|
-
export class
|
|
7
|
-
method: Schema.String,
|
|
5
|
+
export class HttpContext extends Schema.Class("AI.HttpContext")({
|
|
8
6
|
url: Schema.String,
|
|
9
|
-
|
|
10
|
-
}) {
|
|
11
|
-
}
|
|
12
|
-
export class HttpResponseDetails extends Schema.Class("AI.HttpResponseDetails")({
|
|
13
|
-
status: Schema.Number,
|
|
7
|
+
status: Schema.Int.check(Schema.isBetween({ minimum: 100, maximum: 599 })),
|
|
14
8
|
headers: Schema.Record(Schema.String, Schema.String),
|
|
15
9
|
}) {
|
|
16
10
|
}
|
|
@@ -21,128 +15,85 @@ export class HttpRateLimitDetails extends Schema.Class("AI.HttpRateLimitDetails"
|
|
|
21
15
|
reset: Schema.optional(Schema.Record(Schema.String, Schema.String)),
|
|
22
16
|
}) {
|
|
23
17
|
}
|
|
24
|
-
|
|
25
|
-
request: HttpRequestDetails,
|
|
26
|
-
response: Schema.optional(HttpResponseDetails),
|
|
27
|
-
body: Schema.optional(Schema.String),
|
|
28
|
-
bodyTruncated: Schema.optional(Schema.Boolean),
|
|
29
|
-
rateLimit: Schema.optional(HttpRateLimitDetails),
|
|
30
|
-
}) {
|
|
31
|
-
}
|
|
32
|
-
export class InvalidRequestReason extends Schema.Class("AI.Error.InvalidRequest")({
|
|
33
|
-
_tag: Schema.tag("InvalidRequest"),
|
|
18
|
+
const ReasonFields = {
|
|
34
19
|
message: Schema.String,
|
|
20
|
+
// Preserve the complete original response or triggering event before decoding narrows it.
|
|
21
|
+
body: Schema.optional(Schema.String),
|
|
22
|
+
http: Schema.optional(HttpContext),
|
|
23
|
+
cause: Schema.optional(Schema.Defect({ includeStack: true })),
|
|
24
|
+
};
|
|
25
|
+
export class InvalidRequestError extends Schema.TaggedError("AI.Error.InvalidRequest")("InvalidRequest", {
|
|
26
|
+
...ReasonFields,
|
|
35
27
|
parameter: Schema.optional(Schema.String),
|
|
36
28
|
classification: Schema.optional(ProviderFailureClassification),
|
|
37
|
-
providerMetadata: Schema.optional(ProviderMetadata),
|
|
38
|
-
http: Schema.optional(HttpContext),
|
|
39
29
|
}) {
|
|
40
30
|
}
|
|
41
|
-
export class
|
|
42
|
-
|
|
31
|
+
export class NoRouteError extends Schema.TaggedError("AI.Error.NoRoute")("NoRoute", {
|
|
32
|
+
...ReasonFields,
|
|
43
33
|
route: RouteID,
|
|
44
34
|
provider: ProviderID,
|
|
45
35
|
model: ModelID,
|
|
46
36
|
}) {
|
|
47
|
-
get message() {
|
|
48
|
-
return `No AI route for ${this.provider}/${this.model} using ${this.route}`;
|
|
49
|
-
}
|
|
50
37
|
}
|
|
51
|
-
export class
|
|
52
|
-
|
|
53
|
-
message: Schema.String,
|
|
38
|
+
export class AuthenticationError extends Schema.TaggedError("AI.Error.Authentication")("Authentication", {
|
|
39
|
+
...ReasonFields,
|
|
54
40
|
kind: Schema.Literals(["missing", "invalid", "expired", "insufficient-permissions", "unknown"]),
|
|
55
|
-
providerMetadata: Schema.optional(ProviderMetadata),
|
|
56
|
-
http: Schema.optional(HttpContext),
|
|
57
41
|
}) {
|
|
58
42
|
}
|
|
59
|
-
export class
|
|
60
|
-
|
|
61
|
-
message: Schema.String,
|
|
43
|
+
export class RateLimitError extends Schema.TaggedError("AI.Error.RateLimit")("RateLimit", {
|
|
44
|
+
...ReasonFields,
|
|
62
45
|
retryAfterMs: Schema.optional(Schema.Number),
|
|
63
46
|
rateLimit: Schema.optional(HttpRateLimitDetails),
|
|
64
|
-
providerMetadata: Schema.optional(ProviderMetadata),
|
|
65
|
-
http: Schema.optional(HttpContext),
|
|
66
47
|
}) {
|
|
67
48
|
}
|
|
68
|
-
export class
|
|
69
|
-
_tag: Schema.tag("QuotaExceeded"),
|
|
70
|
-
message: Schema.String,
|
|
71
|
-
providerMetadata: Schema.optional(ProviderMetadata),
|
|
72
|
-
http: Schema.optional(HttpContext),
|
|
73
|
-
}) {
|
|
49
|
+
export class QuotaExceededError extends Schema.TaggedError("AI.Error.QuotaExceeded")("QuotaExceeded", ReasonFields) {
|
|
74
50
|
}
|
|
75
|
-
export class
|
|
76
|
-
_tag: Schema.tag("ContentPolicy"),
|
|
77
|
-
message: Schema.String,
|
|
78
|
-
providerMetadata: Schema.optional(ProviderMetadata),
|
|
79
|
-
http: Schema.optional(HttpContext),
|
|
80
|
-
}) {
|
|
51
|
+
export class ContentPolicyError extends Schema.TaggedError("AI.Error.ContentPolicy")("ContentPolicy", ReasonFields) {
|
|
81
52
|
}
|
|
82
|
-
export class
|
|
83
|
-
|
|
84
|
-
message: Schema.String,
|
|
85
|
-
status: Schema.optional(Schema.Number),
|
|
53
|
+
export class ProviderInternalError extends Schema.TaggedError("AI.Error.ProviderInternal")("ProviderInternal", {
|
|
54
|
+
...ReasonFields,
|
|
86
55
|
retryAfterMs: Schema.optional(Schema.Number),
|
|
87
|
-
providerMetadata: Schema.optional(ProviderMetadata),
|
|
88
|
-
http: Schema.optional(HttpContext),
|
|
89
56
|
}) {
|
|
90
57
|
}
|
|
91
58
|
export const TransportType = Schema.Literals(["http", "websocket"]);
|
|
92
59
|
export const TransportOperation = Schema.Literals(["request", "read", "write"]);
|
|
93
|
-
export class
|
|
94
|
-
|
|
95
|
-
message: Schema.String,
|
|
60
|
+
export class TransportError extends Schema.TaggedError("AI.Error.Transport")("Transport", {
|
|
61
|
+
...ReasonFields,
|
|
96
62
|
transport: TransportType,
|
|
97
63
|
operation: TransportOperation,
|
|
98
64
|
code: Schema.optional(Schema.String),
|
|
99
65
|
url: Schema.optional(Schema.String),
|
|
100
|
-
http: Schema.optional(HttpContext),
|
|
101
66
|
phase: Schema.optional(Schema.Literals(["prepare", "queue", "connect", "send", "receive", "decode", "complete", "fallback", "close"])),
|
|
102
67
|
delivery: Schema.optional(Schema.Literals(["not-sent", "rejected", "ambiguous", "accepted"])),
|
|
103
68
|
recovery: Schema.optional(Schema.Literals(["retry-connect", "retry-full", "rotate-and-retry-full", "fallback-http", "fail"])),
|
|
104
69
|
}) {
|
|
105
70
|
}
|
|
106
|
-
export class
|
|
107
|
-
|
|
108
|
-
message: Schema.String,
|
|
71
|
+
export class InvalidProviderOutputError extends Schema.TaggedError("AI.Error.InvalidProviderOutput")("InvalidProviderOutput", {
|
|
72
|
+
...ReasonFields,
|
|
109
73
|
classification: Schema.optional(Schema.Literals(["incomplete-stream"])),
|
|
110
74
|
route: Schema.optional(Schema.String),
|
|
111
|
-
raw: Schema.optional(Schema.String),
|
|
112
|
-
providerMetadata: Schema.optional(ProviderMetadata),
|
|
113
75
|
}) {
|
|
114
76
|
}
|
|
115
|
-
export class
|
|
116
|
-
_tag: Schema.tag("UnknownProvider"),
|
|
117
|
-
message: Schema.String,
|
|
118
|
-
status: Schema.optional(Schema.Number),
|
|
119
|
-
providerMetadata: Schema.optional(ProviderMetadata),
|
|
120
|
-
http: Schema.optional(HttpContext),
|
|
121
|
-
}) {
|
|
77
|
+
export class UnknownProviderError extends Schema.TaggedError("AI.Error.UnknownProvider")("UnknownProvider", ReasonFields) {
|
|
122
78
|
}
|
|
123
79
|
export const AIErrorReason = Schema.Union([
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
80
|
+
InvalidRequestError,
|
|
81
|
+
NoRouteError,
|
|
82
|
+
AuthenticationError,
|
|
83
|
+
RateLimitError,
|
|
84
|
+
QuotaExceededError,
|
|
85
|
+
ContentPolicyError,
|
|
86
|
+
ProviderInternalError,
|
|
87
|
+
TransportError,
|
|
88
|
+
InvalidProviderOutputError,
|
|
89
|
+
UnknownProviderError,
|
|
134
90
|
]).pipe(Schema.toTaggedUnion("_tag"));
|
|
135
91
|
export class AIError extends Schema.TaggedError()("AI.Error", {
|
|
136
|
-
module: Schema.String,
|
|
137
|
-
method: Schema.String,
|
|
138
92
|
reason: AIErrorReason,
|
|
139
|
-
// Raw provider payload as a string, so classified failures never lose the
|
|
140
|
-
// original error detail even when the pretty message is a summary.
|
|
141
|
-
body: Schema.optional(Schema.String),
|
|
142
93
|
}) {
|
|
143
94
|
cause = this.reason;
|
|
144
95
|
get message() {
|
|
145
|
-
return
|
|
96
|
+
return this.reason.message;
|
|
146
97
|
}
|
|
147
98
|
}
|
|
148
99
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
|
-
"version": "0.0.0-dev-
|
|
3
|
+
"version": "0.0.0-dev-18412",
|
|
4
4
|
"name": "@opencode-ai/ai",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@clack/prompts": "1.0.0-alpha.1",
|
|
32
32
|
"@effect/platform-node": "4.0.0-rc.111",
|
|
33
|
-
"@opencode-ai/http-recorder": "0.0.0-dev-
|
|
33
|
+
"@opencode-ai/http-recorder": "0.0.0-dev-18412",
|
|
34
34
|
"@tsconfig/bun": "1.0.9",
|
|
35
35
|
"@types/bun": "1.3.13",
|
|
36
36
|
"@typescript/native-preview": "7.0.0-dev.20251207.1",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@smithy/eventstream-codec": "4.2.14",
|
|
41
41
|
"@smithy/util-utf8": "4.2.2",
|
|
42
|
-
"@opencode-ai/schema": "0.0.0-dev-
|
|
42
|
+
"@opencode-ai/schema": "0.0.0-dev-18412",
|
|
43
43
|
"aws4fetch": "1.0.20",
|
|
44
44
|
"effect": "4.0.0-rc.111",
|
|
45
45
|
"google-auth-library": "10.5.0"
|