New:Socket for Asana Is Now Available.Learn more
Sign In

@opencode-ai/ai

Package Overview
Dependencies
Maintainers
2
Versions
984
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@opencode-ai/ai - npm Package Compare versions

Comparing version
0.0.0-dev-18317
to
0.0.0-dev-18318
+3
-3
dist/protocols/open-responses.d.ts

@@ -498,3 +498,3 @@ import { Effect, Schema } from "effect";

readonly summary_index: Schema.optional<Schema.Number>;
readonly item: Schema.optional<Schema.StructWithRest<Schema.Struct<{
readonly item: Schema.optional<Schema.NullOr<Schema.StructWithRest<Schema.Struct<{
readonly type: Schema.String;

@@ -506,3 +506,3 @@ readonly id: Schema.optional<Schema.String>;

readonly encrypted_content: Schema.optional<Schema.NullOr<Schema.String>>;
}>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>>;
}>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>>>;
readonly response: Schema.optional<Schema.StructWithRest<Schema.Struct<{

@@ -1170,3 +1170,3 @@ readonly id: Schema.optional<Schema.String>;

readonly call_id?: string | undefined;
} | undefined;
} | null | undefined;
readonly delta?: string | undefined;

@@ -1173,0 +1173,0 @@ readonly response?: {

@@ -245,3 +245,4 @@ import { Effect, Schema } from "effect";

summary_index: Schema.optional(Schema.Number),
item: Schema.optional(StreamItem),
// OutputItemAdded/Done permit a null item in the Open Responses OpenAPI schema.
item: optionalNull(StreamItem),
response: Schema.optional(Schema.StructWithRest(Schema.Struct({

@@ -602,3 +603,3 @@ id: Schema.optional(Schema.String),

});
const isReasoningItem = (item) => item.type === "reasoning" && typeof item.id === "string" && item.id.length > 0;
const isReasoningItem = (item) => item.type === "reasoning" && typeof item.id === "string";
const NO_EVENTS = [];

@@ -674,3 +675,3 @@ // `response.completed` / `response.incomplete` are clean finishes that emit a

const item = event.item;
if (item?.type === "message" && item.id) {
if (item?.type === "message" && item.id !== undefined) {
const phase = messagePhase(item.phase);

@@ -707,3 +708,3 @@ return [

const id = item.id ?? item.call_id;
const metadata = item.id ? providerMetadata(state, { itemId: item.id }) : undefined;
const metadata = item.id !== undefined ? providerMetadata(state, { itemId: item.id }) : undefined;
const events = [];

@@ -726,3 +727,3 @@ const lifecycle = Lifecycle.stepStart(state.lifecycle, events);

const onReasoningSummaryPartAdded = (state, event) => {
if (!event.item_id || event.summary_index === undefined)
if (event.item_id === undefined || event.summary_index === undefined)
return [state, NO_EVENTS];

@@ -757,3 +758,3 @@ const item = state.reasoningItems[event.item_id];

const onReasoningSummaryPartDone = (state, event) => {
if (!event.item_id || event.summary_index === undefined)
if (event.item_id === undefined || event.summary_index === undefined)
return [state, NO_EVENTS];

@@ -781,3 +782,3 @@ const item = state.reasoningItems[event.item_id];

const onFunctionCallArgumentsDelta = Effect.fn("OpenResponses.onFunctionCallArgumentsDelta")(function* (state, event) {
if (!event.item_id)
if (event.item_id === undefined)
return [state, NO_EVENTS];

@@ -810,3 +811,3 @@ const tool = state.tools[event.item_id];

return [state, NO_EVENTS];
if (item.type === "message" && item.id) {
if (item.type === "message" && item.id !== undefined) {
const itemPhase = messagePhase(item.phase);

@@ -837,3 +838,3 @@ const phase = itemPhase === undefined ? state.messagePhases[item.id] : itemPhase;

name: item.name,
providerMetadata: item.id ? providerMetadata(state, { itemId: item.id }) : undefined,
providerMetadata: item.id !== undefined ? providerMetadata(state, { itemId: item.id }) : undefined,
});

@@ -886,3 +887,3 @@ const result = item.arguments === undefined

const id = item.id ?? (item.type === "function_call" ? item.call_id : undefined);
if (!id ||
if (id === undefined ||
((item.type !== "function_call" || !current.tools[id]) &&

@@ -958,7 +959,8 @@ (item.type !== "reasoning" || !current.reasoningItems[id])))

export const step = (state, input) => {
const event = input.item_id && outputItemID(state, input) !== input.item_id
// The OpenAPI requires string IDs but imposes no minLength; empty is not missing.
const event = input.item_id !== undefined && outputItemID(state, input) !== input.item_id
? { ...input, item_id: outputItemID(state, input) }
: input;
if (event.type === "response.output_text.delta" || event.type === "response.output_text.done") {
if (!event.item_id)
if (event.item_id === undefined)
return ProviderShared.eventError(state.id, `${event.type} is missing item_id`);

@@ -971,3 +973,3 @@ return Effect.succeed(event.type === "response.output_text.delta"

const value = event.type === "response.refusal.delta" ? event.delta : event.refusal;
if (!event.item_id || typeof value !== "string")
if (event.item_id === undefined || typeof value !== "string")
return ProviderShared.eventError(state.id, `${event.type} is malformed`);

@@ -979,3 +981,3 @@ return Effect.succeed(event.type === "response.refusal.delta"

if (event.type === "response.reasoning.delta" || event.type === "response.reasoning_summary_text.delta") {
if (!event.item_id)
if (event.item_id === undefined)
return ProviderShared.eventError(state.id, `${event.type} is missing item_id`);

@@ -987,3 +989,3 @@ return Effect.succeed(onReasoningDelta(state, event, event.item_id));

event.type === "response.reasoning_text.done") {
if (!event.item_id)
if (event.item_id === undefined)
return ProviderShared.eventError(state.id, `${event.type} is missing item_id`);

@@ -993,14 +995,14 @@ return Effect.succeed(onReasoningDone(state, event, event.item_id));

if (event.type === "response.reasoning_summary_part.added")
return event.item_id
return event.item_id !== undefined
? Effect.succeed(onReasoningSummaryPartAdded(state, event))
: ProviderShared.eventError(state.id, `${event.type} is missing item_id`);
if (event.type === "response.reasoning_summary_part.done")
return event.item_id
return event.item_id !== undefined
? Effect.succeed(onReasoningSummaryPartDone(state, event))
: ProviderShared.eventError(state.id, `${event.type} is missing item_id`);
if (event.type === "response.output_item.added") {
if (event.item?.type === "message" && !event.item.id)
if (event.item?.type === "message" && event.item.id === undefined)
return ProviderShared.eventError(state.id, `${event.type} message is missing id`);
const id = event.item?.id ?? (event.item?.type === "function_call" ? event.item.call_id : undefined);
return Effect.succeed(onOutputItemAdded(event.output_index !== undefined && id
return Effect.succeed(onOutputItemAdded(event.output_index !== undefined && id !== undefined
? { ...state, outputItems: { ...state.outputItems, [event.output_index]: id } }

@@ -1010,7 +1012,7 @@ : state, event));

if (event.type === "response.function_call_arguments.delta" || event.type === "response.function_call_arguments.done")
return event.item_id
return event.item_id !== undefined
? onFunctionCallArgumentsDelta(state, event)
: ProviderShared.eventError(state.id, `${event.type} is missing item_id`);
if (event.type === "response.output_item.done") {
if (event.item?.type === "message" && !event.item.id)
if (event.item?.type === "message" && event.item.id === undefined)
return ProviderShared.eventError(state.id, `${event.type} message is missing id`);

@@ -1017,0 +1019,0 @@ return onOutputItemDone(state, event);

@@ -389,3 +389,3 @@ import { Schema } from "effect";

readonly call_id?: string | undefined;
} | undefined;
} | null | undefined;
readonly delta?: string | undefined;

@@ -392,0 +392,0 @@ readonly response?: {

@@ -150,3 +150,3 @@ import { Effect, Encoding, Schema } from "effect";

if (event.type === "response.reasoning_text.delta")
return event.item_id
return event.item_id !== undefined
? Effect.succeed(OpenResponses.onReasoningDelta(state, event, OpenResponses.outputItemID(state, event) ?? event.item_id))

@@ -153,0 +153,0 @@ : ProviderShared.eventError(ADAPTER, `${event.type} is missing item_id`);

@@ -190,3 +190,3 @@ import { Protocol } from "../route/protocol.js";

readonly call_id?: string | undefined;
} | undefined;
} | null | undefined;
readonly delta?: string | undefined;

@@ -193,0 +193,0 @@ readonly response?: {

{
"$schema": "https://json.schemastore.org/package.json",
"version": "0.0.0-dev-18317",
"version": "0.0.0-dev-18318",
"name": "@opencode-ai/ai",

@@ -33,3 +33,3 @@ "type": "module",

"@effect/platform-node": "4.0.0-rc.111",
"@opencode-ai/http-recorder": "0.0.0-dev-18317",
"@opencode-ai/http-recorder": "0.0.0-dev-18318",
"@tsconfig/bun": "1.0.9",

@@ -43,3 +43,3 @@ "@types/bun": "1.3.13",

"@smithy/util-utf8": "4.2.2",
"@opencode-ai/schema": "0.0.0-dev-18317",
"@opencode-ai/schema": "0.0.0-dev-18318",
"aws4fetch": "1.0.20",

@@ -46,0 +46,0 @@ "effect": "4.0.0-rc.111",