@opencode-ai/ai 0.0.0-dev-18204 → 0.0.0-dev-18211
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({
|
|
@@ -463,12 +464,7 @@ const lowerMessages = Effect.fn("OpenResponses.lowerMessages")(function* (reques
|
|
|
463
464
|
});
|
|
464
465
|
}
|
|
465
466
|
}
|
|
466
|
-
|
|
467
|
-
// complete item has encrypted state. Summary blocks for one item may carry
|
|
468
|
-
// that state only on the last block, so filter after they have been joined.
|
|
469
|
-
return store === false
|
|
470
|
-
? input.filter((item) => !("type" in item) || item.type !== "reasoning" || typeof item.encrypted_content === "string")
|
|
471
|
-
: input;
|
|
467
|
+
return input;
|
|
472
468
|
});
|
|
473
469
|
const lowerOptions = (request) => {
|
|
474
470
|
const options = OpenResponsesOptions.resolve(request);
|
|
@@ -604,6 +600,7 @@ const onOutputTextDone = (state, event, id) => {
|
|
|
604
600
|
const events = [];
|
|
605
601
|
return [{ ...state, lifecycle: Lifecycle.textEnd(state.lifecycle, events, id) }, events];
|
|
606
602
|
};
|
|
603
|
+
export const outputItemID = (state, event) => event.output_index === undefined ? event.item_id : (state.outputItems[event.output_index] ?? event.item_id);
|
|
607
604
|
export const onReasoningDelta = (state, event, itemID) => {
|
|
608
605
|
const item = state.reasoningItems[itemID];
|
|
609
606
|
if (!event.delta || !item)
|
|
@@ -928,7 +925,10 @@ export const providerFailure = (id, event, fallback) => {
|
|
|
928
925
|
});
|
|
929
926
|
};
|
|
930
927
|
const providerError = (state, event, fallback) => providerFailure(state.id, event, fallback);
|
|
931
|
-
export const step = (state,
|
|
928
|
+
export const step = (state, input) => {
|
|
929
|
+
const event = input.item_id && outputItemID(state, input) !== input.item_id
|
|
930
|
+
? { ...input, item_id: outputItemID(state, input) }
|
|
931
|
+
: input;
|
|
932
932
|
if (event.type === "response.output_text.delta" || event.type === "response.output_text.done") {
|
|
933
933
|
if (!event.item_id)
|
|
934
934
|
return ProviderShared.eventError(state.id, `${event.type} is missing item_id`);
|
|
@@ -967,7 +967,9 @@ export const step = (state, event) => {
|
|
|
967
967
|
if (event.type === "response.output_item.added") {
|
|
968
968
|
if (event.item?.type === "message" && !event.item.id)
|
|
969
969
|
return ProviderShared.eventError(state.id, `${event.type} message is missing id`);
|
|
970
|
-
return Effect.succeed(onOutputItemAdded(
|
|
970
|
+
return Effect.succeed(onOutputItemAdded(event.output_index !== undefined && event.item?.id
|
|
971
|
+
? { ...state, outputItems: { ...state.outputItems, [event.output_index]: event.item.id } }
|
|
972
|
+
: state, event));
|
|
971
973
|
}
|
|
972
974
|
if (event.type === "response.function_call_arguments.delta" || event.type === "response.function_call_arguments.done")
|
|
973
975
|
return event.item_id
|
|
@@ -1000,6 +1002,7 @@ export const initial = (request, extension = BASE) => ({
|
|
|
1000
1002
|
hasFunctionCall: false,
|
|
1001
1003
|
tools: ToolStream.empty(),
|
|
1002
1004
|
lifecycle: Lifecycle.initial(),
|
|
1005
|
+
outputItems: {},
|
|
1003
1006
|
messageItems: new Set(),
|
|
1004
1007
|
messagePhases: {},
|
|
1005
1008
|
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-18211",
|
|
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-18211",
|
|
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-18211",
|
|
43
43
|
"aws4fetch": "1.0.20",
|
|
44
44
|
"effect": "4.0.0-rc.111",
|
|
45
45
|
"google-auth-library": "10.5.0"
|