@opencode-ai/ai 0.0.0-next-17018 → 0.0.0-next-17025

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.
@@ -598,8 +598,7 @@ const step = (state, event) => Effect.gen(function* () {
598
598
  const matched = toolIndexByID(tools, pendingTools, tool.id || undefined);
599
599
  const fallback = toolDeltas.length > 1 ? position : (latestToolIndex ?? position);
600
600
  const fallbackTool = tools[fallback] ?? pendingTools[fallback];
601
- const index = tool.index ?? matched ??
602
- (tool.id && fallbackTool?.id && fallbackTool.id !== tool.id ? nextToolIndex : fallback);
601
+ const index = tool.index ?? matched ?? (tool.id && fallbackTool?.id && fallbackTool.id !== tool.id ? nextToolIndex : fallback);
603
602
  const current = tools[index];
604
603
  const pending = pendingTools[index];
605
604
  const id = current?.id ?? pending?.id ?? (tool.id || undefined);
@@ -81,9 +81,7 @@ const requireTerminalEvent = (route) => (events) => Stream.suspend(() => {
81
81
  if (LLMEvent.is.finish(event) || LLMEvent.is.providerError(event))
82
82
  terminal = true;
83
83
  return Effect.succeed(event);
84
- }), Stream.onEnd(Effect.suspend(() => terminal
85
- ? Effect.void
86
- : Effect.fail(incompleteStreamError(route)))));
84
+ }), Stream.onEnd(Effect.suspend(() => (terminal ? Effect.void : Effect.fail(incompleteStreamError(route))))));
87
85
  });
88
86
  function makeFromTransport(input) {
89
87
  const protocol = input.protocol;
@@ -1,4 +1,4 @@
1
- import { Cause, Context, Effect, Layer } from "effect";
1
+ import { Cause, Context, Effect, Layer, Option, Schema } from "effect";
2
2
  import { FetchHttpClient, Headers, HttpClient, HttpClientError, HttpClientRequest, HttpClientResponse, } from "effect/unstable/http";
3
3
  import { HttpContext, HttpRateLimitDetails, HttpRequestDetails, HttpResponseDetails, AIError, TransportReason, } from "../schema";
4
4
  import { classifyProviderFailure } from "../provider-error";
@@ -143,9 +143,15 @@ const responseBody = (body, request) => {
143
143
  return { body: redacted };
144
144
  return { body: redacted.slice(0, BODY_LIMIT), bodyTruncated: true };
145
145
  };
146
+ const decodeProviderBody = Schema.decodeUnknownOption(Schema.fromJsonString(Schema.Struct({
147
+ message: Schema.optionalKey(Schema.String),
148
+ error: Schema.optionalKey(Schema.Struct({ message: Schema.optionalKey(Schema.String) })),
149
+ })));
146
150
  const providerMessage = (status, body) => {
147
- if (body.body && body.body.length <= 500)
148
- return `Provider request failed with HTTP ${status}: ${body.body}`;
151
+ if (body.body && body.body.length <= 500) {
152
+ const decoded = Option.getOrUndefined(decodeProviderBody(body.body));
153
+ return `Provider request failed with HTTP ${status}: ${decoded?.error?.message ?? decoded?.message ?? body.body}`;
154
+ }
149
155
  return `Provider request failed with HTTP ${status}`;
150
156
  };
151
157
  const responseHttp = (input) => new HttpContext({
package/dist/tool.js CHANGED
@@ -61,7 +61,6 @@ const toJsonSchema = (schema) => {
61
61
  return document.schema;
62
62
  return { ...document.schema, $defs: document.definitions };
63
63
  };
64
- const project = (toModelOutput, toStructuredOutput, parameters, id, output) => ToolOutput.make(toStructuredOutput?.(output) ?? output, toModelOutput?.({ id, parameters, output }) ??
65
- (typeof output === "string" ? [{ type: "text", text: output }] : []));
64
+ const project = (toModelOutput, toStructuredOutput, parameters, id, output) => ToolOutput.make(toStructuredOutput?.(output) ?? output, toModelOutput?.({ id, parameters, output }) ?? (typeof output === "string" ? [{ type: "text", text: output }] : []));
66
65
  export { ToolFailure };
67
66
  export * as Tool from "./tool";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
- "version": "0.0.0-next-17018",
3
+ "version": "0.0.0-next-17025",
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-beta.101",
33
- "@opencode-ai/http-recorder": "0.0.0-next-17018",
33
+ "@opencode-ai/http-recorder": "0.0.0-next-17025",
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-next-17018",
42
+ "@opencode-ai/schema": "0.0.0-next-17025",
43
43
  "aws4fetch": "1.0.20",
44
44
  "effect": "4.0.0-beta.101",
45
45
  "google-auth-library": "10.5.0"