@opencode/ai 0.0.0-dev-20279 → 0.0.0-dev-20282

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.
@@ -77,8 +77,8 @@ export declare const protocol: Protocol<{
77
77
  } | {
78
78
  readonly type: "input_file";
79
79
  readonly filename: string;
80
- readonly file_data?: string | undefined;
81
80
  readonly detail?: string | undefined;
81
+ readonly file_data?: string | undefined;
82
82
  readonly file_url?: string | undefined;
83
83
  } | {
84
84
  readonly type: "input_text";
@@ -114,8 +114,8 @@ export declare const protocol: Protocol<{
114
114
  } | {
115
115
  readonly type: "input_file";
116
116
  readonly filename: string;
117
- readonly file_data?: string | undefined;
118
117
  readonly detail?: string | undefined;
118
+ readonly file_data?: string | undefined;
119
119
  readonly file_url?: string | undefined;
120
120
  } | {
121
121
  readonly type: "input_text";
@@ -92,8 +92,8 @@ export declare const protocol: Protocol<{
92
92
  } | {
93
93
  readonly type: "input_file";
94
94
  readonly filename: string;
95
- readonly file_data?: string | undefined;
96
95
  readonly detail?: string | undefined;
96
+ readonly file_data?: string | undefined;
97
97
  readonly file_url?: string | undefined;
98
98
  } | {
99
99
  readonly type: "input_text";
@@ -129,8 +129,8 @@ export declare const protocol: Protocol<{
129
129
  } | {
130
130
  readonly type: "input_file";
131
131
  readonly filename: string;
132
- readonly file_data?: string | undefined;
133
132
  readonly detail?: string | undefined;
133
+ readonly file_data?: string | undefined;
134
134
  readonly file_url?: string | undefined;
135
135
  } | {
136
136
  readonly type: "input_text";
@@ -338,8 +338,8 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
338
338
  } | {
339
339
  readonly type: "input_file";
340
340
  readonly filename: string;
341
- readonly file_data?: string | undefined;
342
341
  readonly detail?: string | undefined;
342
+ readonly file_data?: string | undefined;
343
343
  readonly file_url?: string | undefined;
344
344
  } | {
345
345
  readonly type: "input_text";
@@ -375,8 +375,8 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
375
375
  } | {
376
376
  readonly type: "input_file";
377
377
  readonly filename: string;
378
- readonly file_data?: string | undefined;
379
378
  readonly detail?: string | undefined;
379
+ readonly file_data?: string | undefined;
380
380
  readonly file_url?: string | undefined;
381
381
  } | {
382
382
  readonly type: "input_text";
@@ -896,8 +896,8 @@ export declare const fromRequest: (request: LLMRequest<import("../schema/options
896
896
  } | {
897
897
  readonly type: "input_file";
898
898
  readonly filename: string;
899
- readonly file_data?: string | undefined;
900
899
  readonly detail?: string | undefined;
900
+ readonly file_data?: string | undefined;
901
901
  readonly file_url?: string | undefined;
902
902
  } | {
903
903
  readonly type: "input_text";
@@ -933,8 +933,8 @@ export declare const fromRequest: (request: LLMRequest<import("../schema/options
933
933
  } | {
934
934
  readonly type: "input_file";
935
935
  readonly filename: string;
936
- readonly file_data?: string | undefined;
937
936
  readonly detail?: string | undefined;
937
+ readonly file_data?: string | undefined;
938
938
  readonly file_url?: string | undefined;
939
939
  } | {
940
940
  readonly type: "input_text";
@@ -1293,8 +1293,8 @@ export declare const protocol: Protocol<{
1293
1293
  } | {
1294
1294
  readonly type: "input_file";
1295
1295
  readonly filename: string;
1296
- readonly file_data?: string | undefined;
1297
1296
  readonly detail?: string | undefined;
1297
+ readonly file_data?: string | undefined;
1298
1298
  readonly file_url?: string | undefined;
1299
1299
  } | {
1300
1300
  readonly type: "input_text";
@@ -1330,8 +1330,8 @@ export declare const protocol: Protocol<{
1330
1330
  } | {
1331
1331
  readonly type: "input_file";
1332
1332
  readonly filename: string;
1333
- readonly file_data?: string | undefined;
1334
1333
  readonly detail?: string | undefined;
1334
+ readonly file_data?: string | undefined;
1335
1335
  readonly file_url?: string | undefined;
1336
1336
  } | {
1337
1337
  readonly type: "input_text";
@@ -1514,8 +1514,8 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
1514
1514
  } | {
1515
1515
  readonly type: "input_file";
1516
1516
  readonly filename: string;
1517
- readonly file_data?: string | undefined;
1518
1517
  readonly detail?: string | undefined;
1518
+ readonly file_data?: string | undefined;
1519
1519
  readonly file_url?: string | undefined;
1520
1520
  } | {
1521
1521
  readonly type: "input_text";
@@ -1551,8 +1551,8 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
1551
1551
  } | {
1552
1552
  readonly type: "input_file";
1553
1553
  readonly filename: string;
1554
- readonly file_data?: string | undefined;
1555
1554
  readonly detail?: string | undefined;
1555
+ readonly file_data?: string | undefined;
1556
1556
  readonly file_url?: string | undefined;
1557
1557
  } | {
1558
1558
  readonly type: "input_text";
@@ -72,8 +72,8 @@ export declare const route: Route<{
72
72
  } | {
73
73
  readonly type: "input_file";
74
74
  readonly filename: string;
75
- readonly file_data?: string | undefined;
76
75
  readonly detail?: string | undefined;
76
+ readonly file_data?: string | undefined;
77
77
  readonly file_url?: string | undefined;
78
78
  } | {
79
79
  readonly type: "input_text";
@@ -109,8 +109,8 @@ export declare const route: Route<{
109
109
  } | {
110
110
  readonly type: "input_file";
111
111
  readonly filename: string;
112
- readonly file_data?: string | undefined;
113
112
  readonly detail?: string | undefined;
113
+ readonly file_data?: string | undefined;
114
114
  readonly file_url?: string | undefined;
115
115
  } | {
116
116
  readonly type: "input_text";
@@ -291,8 +291,8 @@ export declare const protocol: Protocol<{
291
291
  } | {
292
292
  readonly type: "input_file";
293
293
  readonly filename: string;
294
- readonly file_data?: string | undefined;
295
294
  readonly detail?: string | undefined;
295
+ readonly file_data?: string | undefined;
296
296
  readonly file_url?: string | undefined;
297
297
  } | {
298
298
  readonly type: "input_text";
@@ -328,8 +328,8 @@ export declare const protocol: Protocol<{
328
328
  } | {
329
329
  readonly type: "input_file";
330
330
  readonly filename: string;
331
- readonly file_data?: string | undefined;
332
331
  readonly detail?: string | undefined;
332
+ readonly file_data?: string | undefined;
333
333
  readonly file_url?: string | undefined;
334
334
  } | {
335
335
  readonly type: "input_text";
@@ -574,8 +574,8 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
574
574
  } | {
575
575
  readonly type: "input_file";
576
576
  readonly filename: string;
577
- readonly file_data?: string | undefined;
578
577
  readonly detail?: string | undefined;
578
+ readonly file_data?: string | undefined;
579
579
  readonly file_url?: string | undefined;
580
580
  } | {
581
581
  readonly type: "input_text";
@@ -611,8 +611,8 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
611
611
  } | {
612
612
  readonly type: "input_file";
613
613
  readonly filename: string;
614
- readonly file_data?: string | undefined;
615
614
  readonly detail?: string | undefined;
615
+ readonly file_data?: string | undefined;
616
616
  readonly file_url?: string | undefined;
617
617
  } | {
618
618
  readonly type: "input_text";
@@ -802,8 +802,8 @@ export declare const channelTransport: (options: import("./open-responses-channe
802
802
  } | {
803
803
  readonly type: "input_file";
804
804
  readonly filename: string;
805
- readonly file_data?: string | undefined;
806
805
  readonly detail?: string | undefined;
806
+ readonly file_data?: string | undefined;
807
807
  readonly file_url?: string | undefined;
808
808
  } | {
809
809
  readonly type: "input_text";
@@ -839,8 +839,8 @@ export declare const channelTransport: (options: import("./open-responses-channe
839
839
  } | {
840
840
  readonly type: "input_file";
841
841
  readonly filename: string;
842
- readonly file_data?: string | undefined;
843
842
  readonly detail?: string | undefined;
843
+ readonly file_data?: string | undefined;
844
844
  readonly file_url?: string | undefined;
845
845
  } | {
846
846
  readonly type: "input_text";
@@ -1030,8 +1030,8 @@ export declare const transport: import("../route/transport/index.js").Transport<
1030
1030
  } | {
1031
1031
  readonly type: "input_file";
1032
1032
  readonly filename: string;
1033
- readonly file_data?: string | undefined;
1034
1033
  readonly detail?: string | undefined;
1034
+ readonly file_data?: string | undefined;
1035
1035
  readonly file_url?: string | undefined;
1036
1036
  } | {
1037
1037
  readonly type: "input_text";
@@ -1067,8 +1067,8 @@ export declare const transport: import("../route/transport/index.js").Transport<
1067
1067
  } | {
1068
1068
  readonly type: "input_file";
1069
1069
  readonly filename: string;
1070
- readonly file_data?: string | undefined;
1071
1070
  readonly detail?: string | undefined;
1071
+ readonly file_data?: string | undefined;
1072
1072
  readonly file_url?: string | undefined;
1073
1073
  } | {
1074
1074
  readonly type: "input_text";
@@ -1258,8 +1258,8 @@ export declare const route: Route<{
1258
1258
  } | {
1259
1259
  readonly type: "input_file";
1260
1260
  readonly filename: string;
1261
- readonly file_data?: string | undefined;
1262
1261
  readonly detail?: string | undefined;
1262
+ readonly file_data?: string | undefined;
1263
1263
  readonly file_url?: string | undefined;
1264
1264
  } | {
1265
1265
  readonly type: "input_text";
@@ -1295,8 +1295,8 @@ export declare const route: Route<{
1295
1295
  } | {
1296
1296
  readonly type: "input_file";
1297
1297
  readonly filename: string;
1298
- readonly file_data?: string | undefined;
1299
1298
  readonly detail?: string | undefined;
1299
+ readonly file_data?: string | undefined;
1300
1300
  readonly file_url?: string | undefined;
1301
1301
  } | {
1302
1302
  readonly type: "input_text";
@@ -67,8 +67,8 @@ export declare const protocol: Protocol<{
67
67
  } | {
68
68
  readonly type: "input_file";
69
69
  readonly filename: string;
70
- readonly file_data?: string | undefined;
71
70
  readonly detail?: string | undefined;
71
+ readonly file_data?: string | undefined;
72
72
  readonly file_url?: string | undefined;
73
73
  } | {
74
74
  readonly type: "input_text";
@@ -104,8 +104,8 @@ export declare const protocol: Protocol<{
104
104
  } | {
105
105
  readonly type: "input_file";
106
106
  readonly filename: string;
107
- readonly file_data?: string | undefined;
108
107
  readonly detail?: string | undefined;
108
+ readonly file_data?: string | undefined;
109
109
  readonly file_url?: string | undefined;
110
110
  } | {
111
111
  readonly type: "input_text";
@@ -7,6 +7,7 @@ export declare const isContextOverflowFailure: (failure: unknown) => boolean;
7
7
  * not deliver an accepted write, and unrecognized failures. Callers decide which calls are safe to repeat.
8
8
  */
9
9
  export declare const isRetryable: (error: AIError) => boolean;
10
+ export declare const providerErrorMessage: (body: string) => string | undefined;
10
11
  export interface ProviderFailure {
11
12
  readonly message: string;
12
13
  readonly status?: number | undefined;
@@ -1,4 +1,4 @@
1
- import { Option, Schema } from "effect";
1
+ import { Option, Schema, SchemaGetter } from "effect";
2
2
  import { AuthenticationError, ContentPolicyError, InvalidRequestError, AIError, ProviderErrorEvent, ProviderInternalError, QuotaExceededError, RateLimitError, UnknownProviderError, } from "./schema/index.js";
3
3
  const patterns = [
4
4
  /prompt is too long/i,
@@ -130,6 +130,24 @@ const QUOTA_TEXT = /insufficient[-_\s]?quota|quota[-_\s]?exceeded|budget exceede
130
130
  // under `invalid_request_error`.
131
131
  const CONTENT_POLICY_TEXT = /violating our usage policy|blocked by content filtering policy|content[-_\s]?policy|rejected as a result of our safety system/i;
132
132
  const SERVER_ERROR_TEXT = /\b(?:try again|(?:please |you can )?retry (?:the |this |your )?request|try (?:the |this |your )?request again|(?:currently |temporarily )?at capacity|overloaded|temporarily unavailable|service[-_\s]?unavailable|(?:server|internal)[-_\s]?error|server (?:is )?busy|provider returned (?:an )?error|resource[-_\s]?exhausted|upstream (?:connect|connection|request)|request buffer limit while retrying upstream)\b/i;
133
+ const Message = Schema.String.check(Schema.isPattern(/\S/));
134
+ const messageAt = (fields, message) => Schema.Struct(fields).pipe(Schema.decodeTo(Schema.String, {
135
+ decode: SchemaGetter.transform(message),
136
+ encode: SchemaGetter.forbidden(() => "Provider error messages are decode-only"),
137
+ }));
138
+ // Common error body layouts that carry a human-readable message, in priority order.
139
+ // Provider-specific layouts belong in their protocol.
140
+ const decodeMessage = Schema.decodeUnknownOption(Schema.fromJsonString(Schema.Union([
141
+ messageAt({ error: Schema.Struct({ message: Message }) }, (body) => body.error.message),
142
+ messageAt({ error: Message }, (body) => body.error),
143
+ messageAt({ message: Message }, (body) => body.message),
144
+ // AWS services
145
+ messageAt({ Message: Message }, (body) => body.Message),
146
+ // RFC 9457 problem details
147
+ messageAt({ detail: Message }, (body) => body.detail),
148
+ messageAt({ errors: Schema.NonEmptyArray(Schema.Struct({ message: Message })) }, (body) => body.errors[0].message),
149
+ ])));
150
+ export const providerErrorMessage = (body) => Option.getOrUndefined(decodeMessage(body));
133
151
  // Classification records affirmative evidence about a failure. Deterministic
134
152
  // failures need positive identification (a 4xx status, quota/auth/policy
135
153
  // signals); anything unrecognized stays UnknownProvider, which the session
@@ -487,8 +487,8 @@ export declare const routes: (Route<{
487
487
  } | {
488
488
  readonly type: "input_file";
489
489
  readonly filename: string;
490
- readonly file_data?: string | undefined;
491
490
  readonly detail?: string | undefined;
491
+ readonly file_data?: string | undefined;
492
492
  readonly file_url?: string | undefined;
493
493
  } | {
494
494
  readonly type: "input_text";
@@ -524,8 +524,8 @@ export declare const routes: (Route<{
524
524
  } | {
525
525
  readonly type: "input_file";
526
526
  readonly filename: string;
527
- readonly file_data?: string | undefined;
528
527
  readonly detail?: string | undefined;
528
+ readonly file_data?: string | undefined;
529
529
  readonly file_url?: string | undefined;
530
530
  } | {
531
531
  readonly type: "input_text";
@@ -208,8 +208,8 @@ export declare const routes: (Route<{
208
208
  } | {
209
209
  readonly type: "input_file";
210
210
  readonly filename: string;
211
- readonly file_data?: string | undefined;
212
211
  readonly detail?: string | undefined;
212
+ readonly file_data?: string | undefined;
213
213
  readonly file_url?: string | undefined;
214
214
  } | {
215
215
  readonly type: "input_text";
@@ -245,8 +245,8 @@ export declare const routes: (Route<{
245
245
  } | {
246
246
  readonly type: "input_file";
247
247
  readonly filename: string;
248
- readonly file_data?: string | undefined;
249
248
  readonly detail?: string | undefined;
249
+ readonly file_data?: string | undefined;
250
250
  readonly file_url?: string | undefined;
251
251
  } | {
252
252
  readonly type: "input_text";
@@ -93,8 +93,8 @@ declare const responsesRoute: Route<{
93
93
  } | {
94
94
  readonly type: "input_file";
95
95
  readonly filename: string;
96
- readonly file_data?: string | undefined;
97
96
  readonly detail?: string | undefined;
97
+ readonly file_data?: string | undefined;
98
98
  readonly file_url?: string | undefined;
99
99
  } | {
100
100
  readonly type: "input_text";
@@ -130,8 +130,8 @@ declare const responsesRoute: Route<{
130
130
  } | {
131
131
  readonly type: "input_file";
132
132
  readonly filename: string;
133
- readonly file_data?: string | undefined;
134
133
  readonly detail?: string | undefined;
134
+ readonly file_data?: string | undefined;
135
135
  readonly file_url?: string | undefined;
136
136
  } | {
137
137
  readonly type: "input_text";
@@ -438,8 +438,8 @@ export declare const routes: (Route<{
438
438
  } | {
439
439
  readonly type: "input_file";
440
440
  readonly filename: string;
441
- readonly file_data?: string | undefined;
442
441
  readonly detail?: string | undefined;
442
+ readonly file_data?: string | undefined;
443
443
  readonly file_url?: string | undefined;
444
444
  } | {
445
445
  readonly type: "input_text";
@@ -475,8 +475,8 @@ export declare const routes: (Route<{
475
475
  } | {
476
476
  readonly type: "input_file";
477
477
  readonly filename: string;
478
- readonly file_data?: string | undefined;
479
478
  readonly detail?: string | undefined;
479
+ readonly file_data?: string | undefined;
480
480
  readonly file_url?: string | undefined;
481
481
  } | {
482
482
  readonly type: "input_text";
@@ -99,8 +99,8 @@ export declare const responsesRoute: import("../route/client.js").Route<{
99
99
  } | {
100
100
  readonly type: "input_file";
101
101
  readonly filename: string;
102
- readonly file_data?: string | undefined;
103
102
  readonly detail?: string | undefined;
103
+ readonly file_data?: string | undefined;
104
104
  readonly file_url?: string | undefined;
105
105
  } | {
106
106
  readonly type: "input_text";
@@ -136,8 +136,8 @@ export declare const responsesRoute: import("../route/client.js").Route<{
136
136
  } | {
137
137
  readonly type: "input_file";
138
138
  readonly filename: string;
139
- readonly file_data?: string | undefined;
140
139
  readonly detail?: string | undefined;
140
+ readonly file_data?: string | undefined;
141
141
  readonly file_url?: string | undefined;
142
142
  } | {
143
143
  readonly type: "input_text";
@@ -1106,8 +1106,8 @@ export declare const routes: (import("../route/client.js").Route<{
1106
1106
  } | {
1107
1107
  readonly type: "input_file";
1108
1108
  readonly filename: string;
1109
- readonly file_data?: string | undefined;
1110
1109
  readonly detail?: string | undefined;
1110
+ readonly file_data?: string | undefined;
1111
1111
  readonly file_url?: string | undefined;
1112
1112
  } | {
1113
1113
  readonly type: "input_text";
@@ -1143,8 +1143,8 @@ export declare const routes: (import("../route/client.js").Route<{
1143
1143
  } | {
1144
1144
  readonly type: "input_file";
1145
1145
  readonly filename: string;
1146
- readonly file_data?: string | undefined;
1147
1146
  readonly detail?: string | undefined;
1147
+ readonly file_data?: string | undefined;
1148
1148
  readonly file_url?: string | undefined;
1149
1149
  } | {
1150
1150
  readonly type: "input_text";
@@ -84,8 +84,8 @@ export declare const routes: Route<{
84
84
  } | {
85
85
  readonly type: "input_file";
86
86
  readonly filename: string;
87
- readonly file_data?: string | undefined;
88
87
  readonly detail?: string | undefined;
88
+ readonly file_data?: string | undefined;
89
89
  readonly file_url?: string | undefined;
90
90
  } | {
91
91
  readonly type: "input_text";
@@ -121,8 +121,8 @@ export declare const routes: Route<{
121
121
  } | {
122
122
  readonly type: "input_file";
123
123
  readonly filename: string;
124
- readonly file_data?: string | undefined;
125
124
  readonly detail?: string | undefined;
125
+ readonly file_data?: string | undefined;
126
126
  readonly file_url?: string | undefined;
127
127
  } | {
128
128
  readonly type: "input_text";
@@ -220,8 +220,8 @@ export declare const routes: (Route<{
220
220
  } | {
221
221
  readonly type: "input_file";
222
222
  readonly filename: string;
223
- readonly file_data?: string | undefined;
224
223
  readonly detail?: string | undefined;
224
+ readonly file_data?: string | undefined;
225
225
  readonly file_url?: string | undefined;
226
226
  } | {
227
227
  readonly type: "input_text";
@@ -257,8 +257,8 @@ export declare const routes: (Route<{
257
257
  } | {
258
258
  readonly type: "input_file";
259
259
  readonly filename: string;
260
- readonly file_data?: string | undefined;
261
260
  readonly detail?: string | undefined;
261
+ readonly file_data?: string | undefined;
262
262
  readonly file_url?: string | undefined;
263
263
  } | {
264
264
  readonly type: "input_text";
@@ -372,8 +372,8 @@ export declare const routes: (Route<{
372
372
  } | {
373
373
  readonly type: "input_file";
374
374
  readonly filename: string;
375
- readonly file_data?: string | undefined;
376
375
  readonly detail?: string | undefined;
376
+ readonly file_data?: string | undefined;
377
377
  readonly file_url?: string | undefined;
378
378
  } | {
379
379
  readonly type: "input_text";
@@ -409,8 +409,8 @@ export declare const routes: (Route<{
409
409
  } | {
410
410
  readonly type: "input_file";
411
411
  readonly filename: string;
412
- readonly file_data?: string | undefined;
413
412
  readonly detail?: string | undefined;
413
+ readonly file_data?: string | undefined;
414
414
  readonly file_url?: string | undefined;
415
415
  } | {
416
416
  readonly type: "input_text";
@@ -370,8 +370,8 @@ export declare const routes: (Route<{
370
370
  } | {
371
371
  readonly type: "input_file";
372
372
  readonly filename: string;
373
- readonly file_data?: string | undefined;
374
373
  readonly detail?: string | undefined;
374
+ readonly file_data?: string | undefined;
375
375
  readonly file_url?: string | undefined;
376
376
  } | {
377
377
  readonly type: "input_text";
@@ -407,8 +407,8 @@ export declare const routes: (Route<{
407
407
  } | {
408
408
  readonly type: "input_file";
409
409
  readonly filename: string;
410
- readonly file_data?: string | undefined;
411
410
  readonly detail?: string | undefined;
411
+ readonly file_data?: string | undefined;
412
412
  readonly file_url?: string | undefined;
413
413
  } | {
414
414
  readonly type: "input_text";
@@ -82,8 +82,8 @@ export declare const routes: import("../route/client.js").Route<{
82
82
  } | {
83
83
  readonly type: "input_file";
84
84
  readonly filename: string;
85
- readonly file_data?: string | undefined;
86
85
  readonly detail?: string | undefined;
86
+ readonly file_data?: string | undefined;
87
87
  readonly file_url?: string | undefined;
88
88
  } | {
89
89
  readonly type: "input_text";
@@ -119,8 +119,8 @@ export declare const routes: import("../route/client.js").Route<{
119
119
  } | {
120
120
  readonly type: "input_file";
121
121
  readonly filename: string;
122
- readonly file_data?: string | undefined;
123
122
  readonly detail?: string | undefined;
123
+ readonly file_data?: string | undefined;
124
124
  readonly file_url?: string | undefined;
125
125
  } | {
126
126
  readonly type: "input_text";
@@ -196,8 +196,8 @@ export declare const routes: (Route<{
196
196
  } | {
197
197
  readonly type: "input_file";
198
198
  readonly filename: string;
199
- readonly file_data?: string | undefined;
200
199
  readonly detail?: string | undefined;
200
+ readonly file_data?: string | undefined;
201
201
  readonly file_url?: string | undefined;
202
202
  } | {
203
203
  readonly type: "input_text";
@@ -233,8 +233,8 @@ export declare const routes: (Route<{
233
233
  } | {
234
234
  readonly type: "input_file";
235
235
  readonly filename: string;
236
- readonly file_data?: string | undefined;
237
236
  readonly detail?: string | undefined;
237
+ readonly file_data?: string | undefined;
238
238
  readonly file_url?: string | undefined;
239
239
  } | {
240
240
  readonly type: "input_text";
@@ -86,8 +86,8 @@ export declare const routes: (Route<{
86
86
  } | {
87
87
  readonly type: "input_file";
88
88
  readonly filename: string;
89
- readonly file_data?: string | undefined;
90
89
  readonly detail?: string | undefined;
90
+ readonly file_data?: string | undefined;
91
91
  readonly file_url?: string | undefined;
92
92
  } | {
93
93
  readonly type: "input_text";
@@ -123,8 +123,8 @@ export declare const routes: (Route<{
123
123
  } | {
124
124
  readonly type: "input_file";
125
125
  readonly filename: string;
126
- readonly file_data?: string | undefined;
127
126
  readonly detail?: string | undefined;
127
+ readonly file_data?: string | undefined;
128
128
  readonly file_url?: string | undefined;
129
129
  } | {
130
130
  readonly type: "input_text";
@@ -1,7 +1,7 @@
1
1
  import { Cause, Effect, Layer, Option, Schema, Stream } from "effect";
2
2
  import { FetchHttpClient, Headers, HttpClient, HttpClientError, HttpClientRequest, HttpClientResponse, } from "effect/unstable/http";
3
3
  import { HttpContext, HttpRateLimitDetails, AIError, TransportError } from "../schema/index.js";
4
- import { classifyProviderFailure } from "../provider-error.js";
4
+ import { classifyProviderFailure, providerErrorMessage } from "../provider-error.js";
5
5
  import { Service } from "./executor-service.js";
6
6
  export { Service } from "./executor-service.js";
7
7
  const headerDetails = (headers) => Object.fromEntries(Object.entries(headers).map(([name, value]) => [name, String(value)]));
@@ -65,14 +65,18 @@ export const responseHttp = (response) => new HttpContext({
65
65
  status: response.status,
66
66
  headers: headerDetails(response.headers),
67
67
  });
68
- const decodeProviderBody = Schema.decodeUnknownOption(Schema.fromJsonString(Schema.Struct({
69
- message: Schema.optionalKey(Schema.String),
70
- error: Schema.optionalKey(Schema.Struct({ message: Schema.optionalKey(Schema.String) })),
71
- })));
68
+ const MAX_BODY_CHARS = 2000;
69
+ // Without a recognized message, show the raw body so the provider's explanation is never dropped.
72
70
  const providerMessage = (status, body) => {
73
- const decoded = body === undefined ? undefined : Option.getOrUndefined(decodeProviderBody(body));
74
- return ([decoded?.error?.message, decoded?.message].find((message) => message?.trim()) ??
75
- `Provider request failed with HTTP ${status}`);
71
+ const fallback = `Provider request failed with HTTP ${status}`;
72
+ const text = body?.trim() ?? "";
73
+ const message = providerErrorMessage(text);
74
+ if (message)
75
+ return message;
76
+ // Gateway and proxy HTML error pages are markup, not an explanation.
77
+ if (!text || /^<(?:!doctype|html)/i.test(text))
78
+ return fallback;
79
+ return `${fallback}: ${text.length > MAX_BODY_CHARS ? `${text.slice(0, MAX_BODY_CHARS)}…` : text}`;
76
80
  };
77
81
  const statusError = (response) => Effect.gen(function* () {
78
82
  if (response.status < 400)
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-20279",
3
+ "version": "0.0.0-dev-20282",
4
4
  "name": "@opencode/ai",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -34,7 +34,7 @@
34
34
  "devDependencies": {
35
35
  "@clack/prompts": "1.0.0-alpha.1",
36
36
  "@effect/platform-node": "4.0.0-rc.112",
37
- "@opencode/http-recorder": "0.0.0-dev-20279",
37
+ "@opencode/http-recorder": "0.0.0-dev-20282",
38
38
  "@tsconfig/bun": "1.0.9",
39
39
  "@types/bun": "1.4.0",
40
40
  "@typescript/native-preview": "7.0.0-dev.20251207.1",
@@ -44,7 +44,7 @@
44
44
  "@aws-sdk/credential-providers": "3.1057.0",
45
45
  "@smithy/eventstream-codec": "4.2.14",
46
46
  "@smithy/util-utf8": "4.2.2",
47
- "@opencode/schema": "0.0.0-dev-20279",
47
+ "@opencode/schema": "0.0.0-dev-20282",
48
48
  "aws4fetch": "1.0.20",
49
49
  "effect": "4.0.0-rc.112",
50
50
  "google-auth-library": "10.5.0"