@opencode-ai/ai 0.0.0-dev-18203 → 0.0.0-dev-18209
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.
|
@@ -387,6 +387,7 @@ export declare const Event: Schema.StructWithRest<Schema.Struct<{
|
|
|
387
387
|
readonly arguments: Schema.optional<Schema.String>;
|
|
388
388
|
readonly text: Schema.optional<Schema.String>;
|
|
389
389
|
readonly item_id: Schema.optional<Schema.String>;
|
|
390
|
+
readonly output_index: Schema.optional<Schema.Number>;
|
|
390
391
|
readonly summary_index: Schema.optional<Schema.Number>;
|
|
391
392
|
readonly item: Schema.optional<Schema.StructWithRest<Schema.Struct<{
|
|
392
393
|
readonly type: Schema.String;
|
|
@@ -461,6 +462,7 @@ export interface ParserState {
|
|
|
461
462
|
readonly tools: ToolStream.State<string>;
|
|
462
463
|
readonly hasFunctionCall: boolean;
|
|
463
464
|
readonly lifecycle: Lifecycle.State;
|
|
465
|
+
readonly outputItems: Readonly<Record<number, string>>;
|
|
464
466
|
readonly messageItems: ReadonlySet<string>;
|
|
465
467
|
readonly messagePhases: Readonly<Record<string, MessagePhase | null>>;
|
|
466
468
|
readonly reasoningItems: Readonly<Record<string, ReasoningStreamItem>>;
|
|
@@ -661,10 +663,11 @@ export declare const fromRequest: (request: LLMRequest) => Effect.Effect<{
|
|
|
661
663
|
export declare const providerMetadata: (state: ParserState, metadata: Record<string, unknown>) => ProviderMetadata;
|
|
662
664
|
export type StepResult = readonly [ParserState, ReadonlyArray<LLMEvent>];
|
|
663
665
|
export declare const terminal: (event: Event) => boolean;
|
|
666
|
+
export declare const outputItemID: (state: ParserState, event: Event) => string | undefined;
|
|
664
667
|
export declare const onReasoningDelta: (state: ParserState, event: Event, itemID: string) => StepResult;
|
|
665
668
|
export declare const onReasoningDone: (state: ParserState, event: Event, itemID: string) => StepResult;
|
|
666
669
|
export declare const providerFailure: (id: string, event: Event, fallback: string) => AIError;
|
|
667
|
-
export declare const step: (state: ParserState,
|
|
670
|
+
export declare const step: (state: ParserState, input: Event) => AIError | Effect.Effect<[ParserState, readonly ({
|
|
668
671
|
readonly type: "step-start";
|
|
669
672
|
readonly index: number;
|
|
670
673
|
} | {
|
|
@@ -1031,6 +1034,7 @@ export declare const protocol: Protocol<{
|
|
|
1031
1034
|
readonly param?: string | null | undefined;
|
|
1032
1035
|
readonly status_code?: unknown;
|
|
1033
1036
|
readonly item_id?: string | undefined;
|
|
1037
|
+
readonly output_index?: number | undefined;
|
|
1034
1038
|
readonly summary_index?: number | undefined;
|
|
1035
1039
|
}, ParserState>;
|
|
1036
1040
|
export declare const httpTransport: HttpTransport.HttpJsonTransport<{
|
|
@@ -207,6 +207,7 @@ export const Event = Schema.StructWithRest(Schema.Struct({
|
|
|
207
207
|
arguments: Schema.optional(Schema.String),
|
|
208
208
|
text: Schema.optional(Schema.String),
|
|
209
209
|
item_id: Schema.optional(Schema.String),
|
|
210
|
+
output_index: Schema.optional(Schema.Number),
|
|
210
211
|
summary_index: Schema.optional(Schema.Number),
|
|
211
212
|
item: Schema.optional(StreamItem),
|
|
212
213
|
response: Schema.optional(Schema.StructWithRest(Schema.Struct({
|
|
@@ -604,6 +605,7 @@ const onOutputTextDone = (state, event, id) => {
|
|
|
604
605
|
const events = [];
|
|
605
606
|
return [{ ...state, lifecycle: Lifecycle.textEnd(state.lifecycle, events, id) }, events];
|
|
606
607
|
};
|
|
608
|
+
export const outputItemID = (state, event) => event.output_index === undefined ? event.item_id : (state.outputItems[event.output_index] ?? event.item_id);
|
|
607
609
|
export const onReasoningDelta = (state, event, itemID) => {
|
|
608
610
|
const item = state.reasoningItems[itemID];
|
|
609
611
|
if (!event.delta || !item)
|
|
@@ -928,7 +930,10 @@ export const providerFailure = (id, event, fallback) => {
|
|
|
928
930
|
});
|
|
929
931
|
};
|
|
930
932
|
const providerError = (state, event, fallback) => providerFailure(state.id, event, fallback);
|
|
931
|
-
export const step = (state,
|
|
933
|
+
export const step = (state, input) => {
|
|
934
|
+
const event = input.item_id && outputItemID(state, input) !== input.item_id
|
|
935
|
+
? { ...input, item_id: outputItemID(state, input) }
|
|
936
|
+
: input;
|
|
932
937
|
if (event.type === "response.output_text.delta" || event.type === "response.output_text.done") {
|
|
933
938
|
if (!event.item_id)
|
|
934
939
|
return ProviderShared.eventError(state.id, `${event.type} is missing item_id`);
|
|
@@ -967,7 +972,9 @@ export const step = (state, event) => {
|
|
|
967
972
|
if (event.type === "response.output_item.added") {
|
|
968
973
|
if (event.item?.type === "message" && !event.item.id)
|
|
969
974
|
return ProviderShared.eventError(state.id, `${event.type} message is missing id`);
|
|
970
|
-
return Effect.succeed(onOutputItemAdded(
|
|
975
|
+
return Effect.succeed(onOutputItemAdded(event.output_index !== undefined && event.item?.id
|
|
976
|
+
? { ...state, outputItems: { ...state.outputItems, [event.output_index]: event.item.id } }
|
|
977
|
+
: state, event));
|
|
971
978
|
}
|
|
972
979
|
if (event.type === "response.function_call_arguments.delta" || event.type === "response.function_call_arguments.done")
|
|
973
980
|
return event.item_id
|
|
@@ -1000,6 +1007,7 @@ export const initial = (request, extension = BASE) => ({
|
|
|
1000
1007
|
hasFunctionCall: false,
|
|
1001
1008
|
tools: ToolStream.empty(),
|
|
1002
1009
|
lifecycle: Lifecycle.initial(),
|
|
1010
|
+
outputItems: {},
|
|
1003
1011
|
messageItems: new Set(),
|
|
1004
1012
|
messagePhases: {},
|
|
1005
1013
|
reasoningItems: {},
|
|
@@ -322,6 +322,7 @@ export declare const protocol: Protocol<{
|
|
|
322
322
|
readonly param?: string | null | undefined;
|
|
323
323
|
readonly status_code?: unknown;
|
|
324
324
|
readonly item_id?: string | undefined;
|
|
325
|
+
readonly output_index?: number | undefined;
|
|
325
326
|
readonly summary_index?: number | undefined;
|
|
326
327
|
}, OpenResponses.ParserState>;
|
|
327
328
|
export declare const httpTransport: HttpTransport.HttpJsonTransport<{
|
|
@@ -139,7 +139,7 @@ const HOSTED_TOOLS = {
|
|
|
139
139
|
const step = (state, event) => {
|
|
140
140
|
if (event.type === "response.reasoning_text.delta")
|
|
141
141
|
return event.item_id
|
|
142
|
-
? Effect.succeed(OpenResponses.onReasoningDelta(state, event, event.item_id))
|
|
142
|
+
? Effect.succeed(OpenResponses.onReasoningDelta(state, event, OpenResponses.outputItemID(state, event) ?? event.item_id))
|
|
143
143
|
: ProviderShared.eventError(ADAPTER, `${event.type} is missing item_id`);
|
|
144
144
|
if (event.type === "response.output_item.done" && event.item && ResponsesHostedTools.isItem(event.item, HOSTED_TOOLS))
|
|
145
145
|
return ResponsesHostedTools.onDone(state, event.item, HOSTED_TOOLS);
|
|
@@ -179,6 +179,7 @@ export declare const protocol: Protocol<{
|
|
|
179
179
|
readonly param?: string | null | undefined;
|
|
180
180
|
readonly status_code?: unknown;
|
|
181
181
|
readonly item_id?: string | undefined;
|
|
182
|
+
readonly output_index?: number | undefined;
|
|
182
183
|
readonly summary_index?: number | undefined;
|
|
183
184
|
}, OpenResponses.ParserState>;
|
|
184
185
|
export * as XAIResponses from "./xai-responses.js";
|
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-18209",
|
|
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-18209",
|
|
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-18209",
|
|
43
43
|
"aws4fetch": "1.0.20",
|
|
44
44
|
"effect": "4.0.0-rc.111",
|
|
45
45
|
"google-auth-library": "10.5.0"
|