@opencode-ai/ai 0.0.0-dev-18150 → 0.0.0-dev-18153
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.
|
@@ -384,6 +384,7 @@ export declare const decodeKnownErrorEvent: (event: Event) => Effect.Effect<{
|
|
|
384
384
|
export declare const Event: Schema.StructWithRest<Schema.Struct<{
|
|
385
385
|
readonly type: Schema.String;
|
|
386
386
|
readonly delta: Schema.optional<Schema.String>;
|
|
387
|
+
readonly arguments: Schema.optional<Schema.String>;
|
|
387
388
|
readonly text: Schema.optional<Schema.String>;
|
|
388
389
|
readonly item_id: Schema.optional<Schema.String>;
|
|
389
390
|
readonly summary_index: Schema.optional<Schema.Number>;
|
|
@@ -1009,6 +1010,7 @@ export declare const protocol: Protocol<{
|
|
|
1009
1010
|
readonly reason?: string | undefined;
|
|
1010
1011
|
} | null | undefined;
|
|
1011
1012
|
} | undefined;
|
|
1013
|
+
readonly arguments?: string | undefined;
|
|
1012
1014
|
readonly param?: string | null | undefined;
|
|
1013
1015
|
readonly status_code?: unknown;
|
|
1014
1016
|
readonly item_id?: string | undefined;
|
|
@@ -204,6 +204,7 @@ export const decodeKnownErrorEvent = (event) => decodeWebSocketErrorEvent({
|
|
|
204
204
|
export const Event = Schema.StructWithRest(Schema.Struct({
|
|
205
205
|
type: Schema.String,
|
|
206
206
|
delta: Schema.optional(Schema.String),
|
|
207
|
+
arguments: Schema.optional(Schema.String),
|
|
207
208
|
text: Schema.optional(Schema.String),
|
|
208
209
|
item_id: Schema.optional(Schema.String),
|
|
209
210
|
summary_index: Schema.optional(Schema.Number),
|
|
@@ -756,9 +757,23 @@ const onReasoningSummaryPartDone = (state, event) => {
|
|
|
756
757
|
];
|
|
757
758
|
};
|
|
758
759
|
const onFunctionCallArgumentsDelta = Effect.fn("OpenResponses.onFunctionCallArgumentsDelta")(function* (state, event) {
|
|
759
|
-
if (!event.item_id
|
|
760
|
+
if (!event.item_id)
|
|
761
|
+
return [state, NO_EVENTS];
|
|
762
|
+
const tool = state.tools[event.item_id];
|
|
763
|
+
if (!tool)
|
|
764
|
+
return [state, NO_EVENTS];
|
|
765
|
+
const final = event.type === "response.function_call_arguments.done" ? event.arguments : undefined;
|
|
766
|
+
if (event.type === "response.function_call_arguments.done" && final === undefined)
|
|
767
|
+
return [state, NO_EVENTS];
|
|
768
|
+
if (final !== undefined && !final.startsWith(tool.input))
|
|
769
|
+
return [
|
|
770
|
+
{ ...state, tools: ToolStream.start(state.tools, event.item_id, { ...tool, input: final }) },
|
|
771
|
+
NO_EVENTS,
|
|
772
|
+
];
|
|
773
|
+
const delta = final === undefined ? event.delta : final.slice(tool.input.length);
|
|
774
|
+
if (!delta)
|
|
760
775
|
return [state, NO_EVENTS];
|
|
761
|
-
const result = ToolStream.appendExisting(state.id, state.tools, event.item_id,
|
|
776
|
+
const result = ToolStream.appendExisting(state.id, state.tools, event.item_id, delta, `${state.name} tool argument delta is missing its tool call`);
|
|
762
777
|
if (ToolStream.isError(result))
|
|
763
778
|
return yield* result;
|
|
764
779
|
const events = [];
|
|
@@ -943,7 +958,7 @@ export const step = (state, event) => {
|
|
|
943
958
|
return ProviderShared.eventError(state.id, `${event.type} message is missing id`);
|
|
944
959
|
return Effect.succeed(onOutputItemAdded(state, event));
|
|
945
960
|
}
|
|
946
|
-
if (event.type === "response.function_call_arguments.delta")
|
|
961
|
+
if (event.type === "response.function_call_arguments.delta" || event.type === "response.function_call_arguments.done")
|
|
947
962
|
return event.item_id
|
|
948
963
|
? onFunctionCallArgumentsDelta(state, event)
|
|
949
964
|
: ProviderShared.eventError(state.id, `${event.type} is missing item_id`);
|
|
@@ -5,7 +5,7 @@ import { Auth } from "../route/auth.js";
|
|
|
5
5
|
import { Endpoint } from "../route/endpoint.js";
|
|
6
6
|
import { HttpTransport } from "../route/transport/index.js";
|
|
7
7
|
import { Protocol } from "../route/protocol.js";
|
|
8
|
-
import { AIError, LLMEvent, ProviderInternalReason, UnknownProviderReason, Usage, } from "../schema/index.js";
|
|
8
|
+
import { AIError, InvalidProviderOutputReason, LLMEvent, ProviderInternalReason, UnknownProviderReason, Usage, } from "../schema/index.js";
|
|
9
9
|
import { classifyProviderFailure } from "../provider-error.js";
|
|
10
10
|
import { isRecord, JsonObject, optionalArray, optionalNull, ProviderShared } from "./shared.js";
|
|
11
11
|
import { OpenAIOptions } from "./utils/openai-options.js";
|
|
@@ -827,7 +827,15 @@ const step = (state, event) => Effect.gen(function* () {
|
|
|
827
827
|
});
|
|
828
828
|
const finishEvents = Effect.fn("OpenAIChat.finishEvents")(function* (state) {
|
|
829
829
|
if (state.finishReason === undefined && state.requireFinishReason)
|
|
830
|
-
return yield*
|
|
830
|
+
return yield* new AIError({
|
|
831
|
+
module: ADAPTER,
|
|
832
|
+
method: "stream",
|
|
833
|
+
reason: new InvalidProviderOutputReason({
|
|
834
|
+
classification: "incomplete-stream",
|
|
835
|
+
message: "OpenAI Chat stream ended without finish_reason",
|
|
836
|
+
route: ADAPTER,
|
|
837
|
+
}),
|
|
838
|
+
});
|
|
831
839
|
const events = [];
|
|
832
840
|
const toolCallEvents = state.finishReason === undefined && Object.keys(state.tools).length > 0
|
|
833
841
|
? (yield* ToolStream.finishAll(ADAPTER, state.tools)).events
|
|
@@ -309,6 +309,7 @@ export declare const protocol: Protocol<{
|
|
|
309
309
|
readonly reason?: string | undefined;
|
|
310
310
|
} | null | undefined;
|
|
311
311
|
} | undefined;
|
|
312
|
+
readonly arguments?: string | undefined;
|
|
312
313
|
readonly param?: string | null | undefined;
|
|
313
314
|
readonly status_code?: unknown;
|
|
314
315
|
readonly item_id?: string | undefined;
|
|
@@ -166,6 +166,7 @@ export declare const protocol: Protocol<{
|
|
|
166
166
|
readonly reason?: string | undefined;
|
|
167
167
|
} | null | undefined;
|
|
168
168
|
} | undefined;
|
|
169
|
+
readonly arguments?: string | undefined;
|
|
169
170
|
readonly param?: string | null | undefined;
|
|
170
171
|
readonly status_code?: unknown;
|
|
171
172
|
readonly item_id?: string | undefined;
|
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-18153",
|
|
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-18153",
|
|
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-18153",
|
|
43
43
|
"aws4fetch": "1.0.20",
|
|
44
44
|
"effect": "4.0.0-rc.111",
|
|
45
45
|
"google-auth-library": "10.5.0"
|