@opencode-ai/ai 0.0.0-dev-17706 → 0.0.0-dev-17711

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.
@@ -773,11 +773,17 @@ const onOutputItemDone = Effect.fn("OpenResponses.onOutputItemDone")(function* (
773
773
  }
774
774
  return [state, NO_EVENTS];
775
775
  });
776
- const onResponseFinish = (state, event) => {
777
- const events = [];
776
+ const onResponseFinish = Effect.fn("OpenResponses.onResponseFinish")(function* (state, event) {
777
+ // Some compatible providers omit output_item.done even after completing the response.
778
+ const pending = event.type === "response.completed"
779
+ ? yield* ToolStream.finishAll(state.id, state.tools)
780
+ : { tools: state.tools, events: NO_EVENTS };
781
+ const events = [...pending.events];
782
+ const hasFunctionCall = pending.events.some((event) => LLMEvent.is.toolCall(event) || LLMEvent.is.toolInputError(event)) ||
783
+ state.hasFunctionCall;
778
784
  const lifecycle = Lifecycle.finish(state.lifecycle, events, {
779
785
  reason: {
780
- normalized: mapFinishReason(event, state.hasFunctionCall),
786
+ normalized: mapFinishReason(event, hasFunctionCall),
781
787
  raw: event.response?.incomplete_details?.reason,
782
788
  },
783
789
  usage: mapUsage(event.response?.usage, state.providerMetadataKey),
@@ -788,8 +794,8 @@ const onResponseFinish = (state, event) => {
788
794
  })
789
795
  : undefined,
790
796
  });
791
- return [{ ...state, lifecycle }, events];
792
- };
797
+ return [{ ...state, lifecycle, hasFunctionCall, tools: pending.tools }, events];
798
+ });
793
799
  // Build a single human-readable message from whatever the provider supplied.
794
800
  // When both code and message are present, prefix the code so consumers see
795
801
  // the failure mode (e.g. `rate_limit_exceeded: Slow down`) instead of just
@@ -857,7 +863,7 @@ export const step = (state, event) => {
857
863
  return onOutputItemDone(state, event);
858
864
  }
859
865
  if (event.type === "response.completed" || event.type === "response.incomplete")
860
- return Effect.succeed(onResponseFinish(state, event));
866
+ return onResponseFinish(state, event);
861
867
  if (event.type === "response.failed")
862
868
  return providerError(state, event, `${state.name} response failed`);
863
869
  if (event.type === "error")
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-17706",
3
+ "version": "0.0.0-dev-17711",
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.110",
33
- "@opencode-ai/http-recorder": "0.0.0-dev-17706",
33
+ "@opencode-ai/http-recorder": "0.0.0-dev-17711",
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-17706",
42
+ "@opencode-ai/schema": "0.0.0-dev-17711",
43
43
  "aws4fetch": "1.0.20",
44
44
  "effect": "4.0.0-rc.110",
45
45
  "google-auth-library": "10.5.0"