@opencode/ai 0.0.0-dev-21795 → 0.0.0-dev-21798
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.
|
@@ -165,6 +165,10 @@ export declare const protocol: Protocol<{
|
|
|
165
165
|
readonly total_tokens?: number | null | undefined;
|
|
166
166
|
readonly raw_prompt_token?: number | null | undefined;
|
|
167
167
|
} | undefined;
|
|
168
|
+
readonly errors?: readonly {
|
|
169
|
+
readonly code?: string | undefined;
|
|
170
|
+
readonly message?: string | undefined;
|
|
171
|
+
}[] | undefined;
|
|
168
172
|
};
|
|
169
173
|
} | {
|
|
170
174
|
readonly event_type: "error";
|
|
@@ -128,6 +128,7 @@ const Interaction = Schema.StructWithRest(Schema.Struct({
|
|
|
128
128
|
id: Schema.optional(Schema.String),
|
|
129
129
|
status: Schema.String,
|
|
130
130
|
usage: Schema.optional(RawUsage),
|
|
131
|
+
errors: Schema.optional(Schema.Array(Schema.Struct({ code: Schema.optional(Schema.String), message: Schema.optional(Schema.String) }))),
|
|
131
132
|
}), [Schema.Record(Schema.String, Schema.Unknown)]);
|
|
132
133
|
const KNOWN_EVENT_TYPES = new Set([
|
|
133
134
|
"step.start",
|
|
@@ -440,14 +441,17 @@ const step = Effect.fnUntraced(function* (state, event) {
|
|
|
440
441
|
});
|
|
441
442
|
case "interaction.completed": {
|
|
442
443
|
const interaction = event.interaction;
|
|
443
|
-
if (interaction.status === "failed" || interaction.status === "cancelled")
|
|
444
|
+
if (interaction.status === "failed" || interaction.status === "cancelled") {
|
|
445
|
+
const messages = (interaction.errors ?? []).flatMap((error) => (error.message?.trim() ? [error.message] : []));
|
|
444
446
|
return yield* new AIError({
|
|
445
447
|
reason: classifyProviderFailure({
|
|
446
|
-
message: `Google Interactions ${interaction.status}`,
|
|
447
|
-
|
|
448
|
+
message: messages.length > 0 ? messages.join("\n") : `Google Interactions ${interaction.status}`,
|
|
449
|
+
// The first coded error decides the classification; every message stays visible.
|
|
450
|
+
data: interaction.errors?.find((error) => error.code) ?? interaction,
|
|
448
451
|
rawBody: encodeJson(event),
|
|
449
452
|
}),
|
|
450
453
|
});
|
|
454
|
+
}
|
|
451
455
|
if (!["completed", "requires_action", "incomplete"].includes(interaction.status))
|
|
452
456
|
return yield* ProviderShared.eventError(ADAPTER, `Unexpected terminal Interactions status: ${interaction.status}`, encodeJson(event));
|
|
453
457
|
const pending = yield* ToolStream.finishAll(ADAPTER, state.tools);
|
package/dist/provider-error.js
CHANGED
|
@@ -193,6 +193,7 @@ export function classifyProviderFailure(input) {
|
|
|
193
193
|
...providerCodes(body),
|
|
194
194
|
...providerCodes(input.message),
|
|
195
195
|
...(GATEWAY_CODE_LABEL.exec(input.message)?.slice(1) ?? []),
|
|
196
|
+
...awsErrorType(input.http?.headers["x-amzn-errortype"]),
|
|
196
197
|
].map((code) => code.toLowerCase());
|
|
197
198
|
// Scan the raw payload too so signals missing from the summary message
|
|
198
199
|
// (e.g. overflow phrases nested in a JSON error body) still classify.
|
|
@@ -257,6 +258,8 @@ function providerCodes(value) {
|
|
|
257
258
|
const exception = isRecord(decoded.exception) ? decoded.exception : undefined;
|
|
258
259
|
return [
|
|
259
260
|
decoded.code,
|
|
261
|
+
...awsErrorType(decoded.__type),
|
|
262
|
+
...awsErrorType(decoded.code),
|
|
260
263
|
// Stability's `{ id, name, errors }` bodies carry the code in `name`.
|
|
261
264
|
Array.isArray(decoded.errors) ? decoded.name : undefined,
|
|
262
265
|
decoded.error_type,
|
|
@@ -275,3 +278,9 @@ function providerCodes(value) {
|
|
|
275
278
|
exception?.type,
|
|
276
279
|
].filter((value) => typeof value === "string");
|
|
277
280
|
}
|
|
281
|
+
// AWS restJson1 reports the modeled error in `X-Amzn-Errortype`, `__type` or `code`, possibly
|
|
282
|
+
// namespaced (`ns#Name`) or suffixed (`Name:uri`). Keep the shape name only.
|
|
283
|
+
// https://smithy.io/2.0/aws/protocols/aws-restjson1-protocol.html#operation-error-serialization
|
|
284
|
+
function awsErrorType(value) {
|
|
285
|
+
return typeof value === "string" ? [value.replace(/:.*/s, "").replace(/^[^#]*#/, "")] : [];
|
|
286
|
+
}
|
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-21798",
|
|
4
4
|
"name": "@opencode/ai",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@clack/prompts": "1.0.0-alpha.1",
|
|
37
37
|
"@effect/platform-node": "4.0.1",
|
|
38
|
-
"@opencode/http-recorder": "0.0.0-dev-
|
|
38
|
+
"@opencode/http-recorder": "0.0.0-dev-21798",
|
|
39
39
|
"@tsconfig/bun": "1.0.9",
|
|
40
40
|
"@types/bun": "1.4.3",
|
|
41
41
|
"@typescript/native": "npm:typescript@7.1.0-beta",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@aws-sdk/credential-providers": "3.1057.0",
|
|
46
46
|
"@smithy/eventstream-codec": "4.2.14",
|
|
47
47
|
"@smithy/util-utf8": "4.2.2",
|
|
48
|
-
"@opencode/schema": "0.0.0-dev-
|
|
48
|
+
"@opencode/schema": "0.0.0-dev-21798",
|
|
49
49
|
"aws4fetch": "1.0.20",
|
|
50
50
|
"effect": "4.0.1",
|
|
51
51
|
"google-auth-library": "10.5.0"
|