Sign In

@opencode-ai/ai

Package Overview
Dependencies
Maintainers
2
Versions
795
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-beta-17963
to
0.0.0-beta-18027
+3
-2
dist/protocols/anthropic-messages.js

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

"content_block_stop",
"ping",
"error",

@@ -833,7 +834,7 @@ ]);

};
const onError = (event) => new AIError({
const onError = (event) => Effect.fail(new AIError({
module: ADAPTER,
method: "stream",
reason: classifyProviderFailure({ message: providerErrorMessage(event), code: event.error?.type }),
});
}));
const step = (state, event) => {

@@ -840,0 +841,0 @@ if (event.type === "message_start")

+40
-40

@@ -24,7 +24,7 @@ import { Schema } from "effect";

contents: Schema.$Array<Schema.Struct<{
readonly role: Schema.Literals<readonly ["user", "model"]>;
readonly parts: Schema.$Array<Schema.Union<readonly [Schema.Struct<{
readonly role: Schema.optional<Schema.NullOr<Schema.Literals<readonly ["user", "model"]>>>;
readonly parts: Schema.optional<Schema.NullOr<Schema.$Array<Schema.Union<readonly [Schema.Struct<{
readonly text: Schema.String;
readonly thought: Schema.optional<Schema.Boolean>;
readonly thoughtSignature: Schema.optional<Schema.String>;
readonly thought: Schema.optional<Schema.NullOr<Schema.Boolean>>;
readonly thoughtSignature: Schema.optional<Schema.NullOr<Schema.String>>;
}>, Schema.Struct<{

@@ -37,7 +37,7 @@ readonly inlineData: Schema.Struct<{

readonly functionCall: Schema.Struct<{
readonly id: Schema.optional<Schema.String>;
readonly id: Schema.optional<Schema.NullOr<Schema.String>>;
readonly name: Schema.String;
readonly args: Schema.optional<Schema.Unknown>;
}>;
readonly thoughtSignature: Schema.optional<Schema.String>;
readonly thoughtSignature: Schema.optional<Schema.NullOr<Schema.String>>;
}>, Schema.Struct<{

@@ -55,3 +55,3 @@ readonly functionResponse: Schema.Struct<{

}>;
}>]>>;
}>]>>>>;
}>>;

@@ -105,4 +105,3 @@ labels: Schema.optional<Schema.$Record<Schema.String, Schema.String>>;

readonly contents: readonly {
readonly role: "model" | "user";
readonly parts: readonly ({
readonly parts?: readonly ({
readonly inlineData: {

@@ -114,11 +113,11 @@ readonly mimeType: string;

readonly text: string;
readonly thought?: boolean | undefined;
readonly thoughtSignature?: string | undefined;
readonly thought?: boolean | null | undefined;
readonly thoughtSignature?: string | null | undefined;
} | {
readonly functionCall: {
readonly name: string;
readonly id?: string | undefined;
readonly id?: string | null | undefined;
readonly args?: unknown;
};
readonly thoughtSignature?: string | undefined;
readonly thoughtSignature?: string | null | undefined;
} | {

@@ -136,3 +135,4 @@ readonly functionResponse: {

};
})[];
})[] | null | undefined;
readonly role?: "model" | "user" | null | undefined;
}[];

@@ -186,4 +186,3 @@ readonly tools?: readonly {

readonly content?: {
readonly role: "model" | "user";
readonly parts: readonly ({
readonly parts?: readonly ({
readonly inlineData: {

@@ -195,11 +194,11 @@ readonly mimeType: string;

readonly text: string;
readonly thought?: boolean | undefined;
readonly thoughtSignature?: string | undefined;
readonly thought?: boolean | null | undefined;
readonly thoughtSignature?: string | null | undefined;
} | {
readonly functionCall: {
readonly name: string;
readonly id?: string | undefined;
readonly id?: string | null | undefined;
readonly args?: unknown;
};
readonly thoughtSignature?: string | undefined;
readonly thoughtSignature?: string | null | undefined;
} | {

@@ -217,19 +216,20 @@ readonly functionResponse: {

};
})[];
} | undefined;
readonly finishReason?: string | undefined;
}[] | undefined;
})[] | null | undefined;
readonly role?: "model" | "user" | null | undefined;
} | null | undefined;
readonly finishReason?: string | null | undefined;
}[] | null | undefined;
readonly promptFeedback?: {
readonly [x: string]: unknown;
readonly blockReason?: string | undefined;
readonly blockReasonMessage?: string | undefined;
readonly blockReason?: string | null | undefined;
readonly blockReasonMessage?: string | null | undefined;
readonly safetyRatings?: unknown;
} | undefined;
} | null | undefined;
readonly usageMetadata?: {
readonly cachedContentTokenCount?: number | undefined;
readonly thoughtsTokenCount?: number | undefined;
readonly promptTokenCount?: number | undefined;
readonly candidatesTokenCount?: number | undefined;
readonly totalTokenCount?: number | undefined;
} | undefined;
readonly cachedContentTokenCount?: number | null | undefined;
readonly thoughtsTokenCount?: number | null | undefined;
readonly promptTokenCount?: number | null | undefined;
readonly candidatesTokenCount?: number | null | undefined;
readonly totalTokenCount?: number | null | undefined;
} | null | undefined;
}, {

@@ -241,4 +241,3 @@ hasToolCalls: boolean;

readonly contents: readonly {
readonly role: "model" | "user";
readonly parts: readonly ({
readonly parts?: readonly ({
readonly inlineData: {

@@ -250,11 +249,11 @@ readonly mimeType: string;

readonly text: string;
readonly thought?: boolean | undefined;
readonly thoughtSignature?: string | undefined;
readonly thought?: boolean | null | undefined;
readonly thoughtSignature?: string | null | undefined;
} | {
readonly functionCall: {
readonly name: string;
readonly id?: string | undefined;
readonly id?: string | null | undefined;
readonly args?: unknown;
};
readonly thoughtSignature?: string | undefined;
readonly thoughtSignature?: string | null | undefined;
} | {

@@ -272,3 +271,4 @@ readonly functionResponse: {

};
})[];
})[] | null | undefined;
readonly role?: "model" | "user" | null | undefined;
}[];

@@ -275,0 +275,0 @@ readonly tools?: readonly {

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

import { LLMEvent, Usage, } from "../schema/index.js";
import { JsonObject, optionalArray, ProviderShared } from "./shared.js";
import { JsonObject, optionalArray, optionalNull, ProviderShared } from "./shared.js";
import { GeminiToolSchema } from "./utils/gemini-tool-schema.js";

@@ -33,9 +33,20 @@ import { Lifecycle } from "./utils/lifecycle.js";

const routesLegacyToolMedia = (modelID) => /gemini-2[.-]5(?:[.-]|$)/i.test(modelID);
// Blacklist: Gemini 1.x/2.x ignore or reject explicit function call ids.
// Every other model id (Gemini 3+, gemma, anything unrecognized) gets them.
const omitsFunctionCallIds = (modelID) => {
const match = /^gemini(?:-live)?-(\d+)/i.exec(modelID);
return match !== null && Number(match[1]) < 3;
};
// =============================================================================
// Request Body Schema
// =============================================================================
// Gemini is known to send explicit `null` for optional streaming fields
// (usage counts, flags, whole subtrees), so every response-side optional uses
// `optionalNull` instead of bare `Schema.optional`. The same part/content
// schemas lower the outbound request body; encoding drops `undefined` keys,
// so the shared schemas stay safe there.
const GeminiTextPart = Schema.Struct({
text: Schema.String,
thought: Schema.optional(Schema.Boolean),
thoughtSignature: Schema.optional(Schema.String),
thought: optionalNull(Schema.Boolean),
thoughtSignature: optionalNull(Schema.String),
});

@@ -50,7 +61,7 @@ const GeminiInlineDataPart = Schema.Struct({

functionCall: Schema.Struct({
id: Schema.optional(Schema.String),
id: optionalNull(Schema.String),
name: Schema.String,
args: Schema.optional(Schema.Unknown),
}),
thoughtSignature: Schema.optional(Schema.String),
thoughtSignature: optionalNull(Schema.String),
});

@@ -72,4 +83,4 @@ const GeminiFunctionResponsePart = Schema.Struct({

const GeminiContent = Schema.Struct({
role: Schema.Literals(["user", "model"]),
parts: Schema.Array(GeminiContentPart),
role: optionalNull(Schema.Literals(["user", "model"])),
parts: optionalNull(Schema.Array(GeminiContentPart)),
});

@@ -126,21 +137,21 @@ const GeminiSystemInstruction = Schema.Struct({

const GeminiUsage = Schema.Struct({
cachedContentTokenCount: Schema.optional(Schema.Number),
thoughtsTokenCount: Schema.optional(Schema.Number),
promptTokenCount: Schema.optional(Schema.Number),
candidatesTokenCount: Schema.optional(Schema.Number),
totalTokenCount: Schema.optional(Schema.Number),
cachedContentTokenCount: optionalNull(Schema.Number),
thoughtsTokenCount: optionalNull(Schema.Number),
promptTokenCount: optionalNull(Schema.Number),
candidatesTokenCount: optionalNull(Schema.Number),
totalTokenCount: optionalNull(Schema.Number),
});
const GeminiCandidate = Schema.Struct({
content: Schema.optional(GeminiContent),
finishReason: Schema.optional(Schema.String),
content: optionalNull(GeminiContent),
finishReason: optionalNull(Schema.String),
});
const GeminiPromptFeedback = Schema.StructWithRest(Schema.Struct({
blockReason: Schema.optional(Schema.String),
blockReasonMessage: Schema.optional(Schema.String),
safetyRatings: Schema.optional(Schema.Unknown),
blockReason: optionalNull(Schema.String),
blockReasonMessage: optionalNull(Schema.String),
safetyRatings: optionalNull(Schema.Unknown),
}), [Schema.Record(Schema.String, Schema.Unknown)]);
const GeminiEvent = Schema.Struct({
candidates: optionalArray(GeminiCandidate),
promptFeedback: Schema.optional(GeminiPromptFeedback),
usageMetadata: Schema.optional(GeminiUsage),
candidates: optionalNull(Schema.Array(GeminiCandidate)),
promptFeedback: optionalNull(GeminiPromptFeedback),
usageMetadata: optionalNull(GeminiUsage),
});

@@ -196,10 +207,4 @@ // =============================================================================

};
const functionCallId = (providerMetadata) => {
const google = providerMetadata?.google;
return ProviderShared.isRecord(google) && typeof google.functionCallId === "string"
? google.functionCallId
: undefined;
};
const lowerToolCall = (part) => ({
functionCall: { id: functionCallId(part.providerMetadata), name: part.name, args: part.input },
const lowerToolCall = (part, omitIds) => ({
functionCall: { ...(omitIds ? {} : { id: part.id }), name: part.name, args: part.input },
thoughtSignature: thoughtSignature(part.providerMetadata),

@@ -209,2 +214,3 @@ });

const contents = [];
const omitCallIds = omitsFunctionCallIds(request.model.id);
const legacyToolMedia = routesLegacyToolMedia(request.model.id);

@@ -226,4 +232,4 @@ let pendingMedia;

// parts, so an update after a tool result starts its own user turn.
if (previous?.role === "user" && !previous.parts.some((item) => "functionResponse" in item))
contents[contents.length - 1] = { role: "user", parts: [...previous.parts, { text: part.text }] };
if (previous?.role === "user" && !(previous.parts ?? []).some((item) => "functionResponse" in item))
contents[contents.length - 1] = { role: "user", parts: [...(previous.parts ?? []), { text: part.text }] };
else

@@ -259,3 +265,3 @@ contents.push({ role: "user", parts: [{ text: part.text }] });

if (part.type === "tool-call") {
const lowered = lowerToolCall(part);
const lowered = lowerToolCall(part, omitCallIds);
const signature = lowered.thoughtSignature;

@@ -284,3 +290,3 @@ parts.push({

functionResponse: {
id: functionCallId(part.providerMetadata),
...(omitCallIds ? {} : { id: part.id }),
name: part.name,

@@ -308,3 +314,3 @@ response: {

functionResponse: {
id: functionCallId(part.providerMetadata),
...(omitCallIds ? {} : { id: part.id }),
name: part.name,

@@ -322,4 +328,4 @@ response: {

const previous = contents.at(-1);
if (previous?.role === "user" && previous.parts.some((item) => "functionResponse" in item))
contents[contents.length - 1] = { role: "user", parts: [...previous.parts, ...parts] };
if (previous?.role === "user" && (previous.parts ?? []).some((item) => "functionResponse" in item))
contents[contents.length - 1] = { role: "user", parts: [...(previous.parts ?? []), ...parts] };
else

@@ -403,4 +409,9 @@ contents.push({ role: "user", parts });

return undefined;
const cached = usage.cachedContentTokenCount;
const nonCached = ProviderShared.subtractTokens(usage.promptTokenCount, cached);
// Explicit provider nulls decode as `null`; normalize to `undefined` so the
// token arithmetic below treats them like absent counts.
const promptTokens = usage.promptTokenCount ?? undefined;
const cached = usage.cachedContentTokenCount ?? undefined;
const thoughts = usage.thoughtsTokenCount ?? undefined;
const visible = usage.candidatesTokenCount ?? undefined;
const nonCached = ProviderShared.subtractTokens(promptTokens, cached);
// `candidatesTokenCount` is visible-only; sum with thoughts to produce the

@@ -410,10 +421,10 @@ // inclusive `outputTokens` the contract expects. Only compute the total

// inclusive number from a partial breakdown.
const outputTokens = usage.candidatesTokenCount !== undefined ? usage.candidatesTokenCount + (usage.thoughtsTokenCount ?? 0) : undefined;
const outputTokens = visible !== undefined ? visible + (thoughts ?? 0) : undefined;
return new Usage({
inputTokens: usage.promptTokenCount,
inputTokens: promptTokens,
outputTokens,
nonCachedInputTokens: nonCached,
cacheReadInputTokens: cached,
reasoningTokens: usage.thoughtsTokenCount,
totalTokens: ProviderShared.totalTokens(usage.promptTokenCount, outputTokens, usage.totalTokenCount),
reasoningTokens: thoughts,
totalTokens: ProviderShared.totalTokens(promptTokens, outputTokens, usage.totalTokenCount ?? undefined),
providerMetadata: { google: usage },

@@ -450,3 +461,5 @@ });

const finish = (state) => {
const promptBlockReason = state.finishReason === undefined ? state.promptFeedback?.blockReason : undefined;
// `?? undefined` normalizes an explicit `null` blockReason back to absent so
// the "nothing to finish" check below keeps its meaning.
const promptBlockReason = state.finishReason === undefined ? (state.promptFeedback?.blockReason ?? undefined) : undefined;
const finishReason = state.finishReason ?? promptBlockReason;

@@ -488,3 +501,5 @@ if (finishReason === undefined && state.usage === undefined)

let textSignature = nextState.textSignature;
for (const part of candidate.content.parts) {
// Supplier ids must be tracked across chunks of the same response, not just within one event's parts.
const seenCallIds = new Set(nextState.seenCallIds);
for (const part of candidate.content.parts ?? []) {
const signature = "thoughtSignature" in part && part.thoughtSignature ? part.thoughtSignature : undefined;

@@ -509,9 +524,11 @@ // Gemini attaches replay signatures to thought parts, visible text, or function calls;

const input = part.functionCall.args === undefined ? {} : part.functionCall.args;
// Gemini 2.0+ and Vertex supply a unique function call ID on the part; when omitted (e.g. Gemini 1.5),
// Gemini 2.0+ supplies a unique function call ID on the part; when omitted (e.g. Gemini 1.5),
// generate a globally unique ID rather than a per-request counter to prevent cross-request collisions in downstream registries.
const id = part.functionCall.id ?? `tool_${crypto.randomUUID().replaceAll("-", "")}`;
const metadata = {
...(part.functionCall.id === undefined ? {} : { functionCallId: part.functionCall.id }),
...(part.thoughtSignature === undefined ? {} : { thoughtSignature: part.thoughtSignature }),
};
// A repeated supplier id would replay as two identical calls, so only the first occurrence keeps it.
// A `null` supplier id normalizes to absent so the generated-id fallback applies.
const supplied = part.functionCall.id ?? undefined;
const duplicate = supplied !== undefined && seenCallIds.has(supplied);
if (supplied !== undefined)
seenCallIds.add(supplied);
const id = supplied !== undefined && !duplicate ? supplied : `tool_${crypto.randomUUID().replaceAll("-", "")}`;
lifecycle = Lifecycle.reasoningEnd(lifecycle, events, "reasoning-0", reasoningSignature ? googleMetadata({ thoughtSignature: reasoningSignature }) : undefined);

@@ -523,3 +540,3 @@ lifecycle = Lifecycle.stepStart(lifecycle, events);

input,
providerMetadata: Object.keys(metadata).length > 0 ? googleMetadata(metadata) : undefined,
providerMetadata: part.thoughtSignature ? googleMetadata({ thoughtSignature: part.thoughtSignature }) : undefined,
}));

@@ -536,2 +553,3 @@ hasToolCalls = true;

textSignature,
seenCallIds,
finishReason: candidate.finishReason ?? nextState.finishReason,

@@ -538,0 +556,0 @@ },

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

truncation: Schema.optional<Schema.Literals<readonly ["auto", "disabled"]>>;
service_tier: Schema.optional<Schema.Literals<readonly ["auto", "default", "flex", "priority"]>>;
service_tier: Schema.optional<Schema.declare<OpenResponsesOptions.ServiceTier, OpenResponsesOptions.ServiceTier>>;
prompt_cache_key: Schema.optional<Schema.String>;

@@ -324,3 +324,3 @@ include: Schema.optional<Schema.$Array<Schema.declare<OpenResponsesOptions.ResponseIncludable, OpenResponsesOptions.ResponseIncludable>>>;

readonly truncation: Schema.optional<Schema.Literals<readonly ["auto", "disabled"]>>;
readonly service_tier: Schema.optional<Schema.Literals<readonly ["auto", "default", "flex", "priority"]>>;
readonly service_tier: Schema.optional<Schema.declare<OpenResponsesOptions.ServiceTier, OpenResponsesOptions.ServiceTier>>;
readonly prompt_cache_key: Schema.optional<Schema.String>;

@@ -484,3 +484,3 @@ readonly include: Schema.optional<Schema.$Array<Schema.declare<OpenResponsesOptions.ResponseIncludable, OpenResponsesOptions.ResponseIncludable>>>;

max_tool_calls?: number | undefined;
service_tier?: "default" | "auto" | "flex" | "priority" | undefined;
service_tier?: OpenResponsesOptions.ServiceTier | undefined;
text?: {

@@ -646,3 +646,3 @@ verbosity: OpenResponsesOptions.TextVerbosity;

readonly top_logprobs?: number | undefined;
readonly service_tier?: "default" | "auto" | "flex" | "priority" | undefined;
readonly service_tier?: OpenResponsesOptions.ServiceTier | undefined;
readonly max_output_tokens?: number | undefined;

@@ -957,3 +957,3 @@ readonly max_tool_calls?: number | undefined;

readonly top_logprobs?: number | undefined;
readonly service_tier?: "default" | "auto" | "flex" | "priority" | undefined;
readonly service_tier?: OpenResponsesOptions.ServiceTier | undefined;
readonly max_output_tokens?: number | undefined;

@@ -1129,3 +1129,3 @@ readonly max_tool_calls?: number | undefined;

readonly top_logprobs?: number | undefined;
readonly service_tier?: "default" | "auto" | "flex" | "priority" | undefined;
readonly service_tier?: OpenResponsesOptions.ServiceTier | undefined;
readonly max_output_tokens?: number | undefined;

@@ -1132,0 +1132,0 @@ readonly max_tool_calls?: number | undefined;

import { Effect, Schema } from "effect";
import { HttpTransport } from "../route/transport/index.js";
import { Protocol } from "../route/protocol.js";
import { AIError, LLMEvent, Usage, } from "../schema/index.js";
import { AIError, LLMEvent, ProviderInternalReason, Usage, } from "../schema/index.js";
import { JsonObject, optionalArray, optionalNull, ProviderShared } from "./shared.js";

@@ -293,3 +293,3 @@ import { classifyProviderFailure } from "../provider-error.js";

filename: part.filename ?? (media.mime === "application/pdf" ? "document.pdf" : "file"),
...(url ? { file_url: url } : { file_data: media.base64 }),
...(url ? { file_url: url } : { file_data: media.dataUrl }),
};

@@ -860,2 +860,9 @@ }

: undefined;
const reason = event.type === "error" &&
event.error === undefined &&
event.response === undefined &&
summary === undefined &&
status === undefined
? new ProviderInternalReason({ message })
: classifyProviderFailure({ message, code, status, rawBody: body });
return new AIError({

@@ -865,3 +872,3 @@ module: id,

body,
reason: classifyProviderFailure({ message, code, status, rawBody: body }),
reason,
});

@@ -868,0 +875,0 @@ };

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

export declare const OpenAIChatEvent: Schema.Struct<{
readonly choices: Schema.optional<Schema.NullOr<Schema.$Array<Schema.Struct<{
readonly choices: Schema.optional<Schema.NullOr<Schema.$Array<Schema.StructWithRest<Schema.Struct<{
readonly delta: Schema.optional<Schema.NullOr<Schema.StructWithRest<Schema.Struct<{

@@ -224,3 +224,19 @@ readonly content: Schema.optional<Schema.NullOr<Schema.String>>;

readonly native_finish_reason: Schema.optional<Schema.NullOr<Schema.String>>;
}>>>>;
readonly usage: Schema.optional<Schema.NullOr<Schema.StructWithRest<Schema.Struct<{
readonly prompt_tokens: Schema.optional<Schema.NullOr<Schema.Number>>;
readonly completion_tokens: Schema.optional<Schema.NullOr<Schema.Number>>;
readonly total_tokens: Schema.optional<Schema.NullOr<Schema.Number>>;
readonly cached_tokens: Schema.optional<Schema.NullOr<Schema.Number>>;
readonly prompt_cache_hit_tokens: Schema.optional<Schema.NullOr<Schema.Number>>;
readonly prompt_tokens_details: Schema.optional<Schema.NullOr<Schema.StructWithRest<Schema.Struct<{
readonly cached_tokens: Schema.optional<Schema.NullOr<Schema.Number>>;
readonly cache_write_tokens: Schema.optional<Schema.NullOr<Schema.Number>>;
}>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>>>;
readonly completion_tokens_details: Schema.optional<Schema.NullOr<Schema.StructWithRest<Schema.Struct<{
readonly reasoning_tokens: Schema.optional<Schema.NullOr<Schema.Number>>;
readonly accepted_prediction_tokens: Schema.optional<Schema.NullOr<Schema.Number>>;
readonly rejected_prediction_tokens: Schema.optional<Schema.NullOr<Schema.Number>>;
}>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>>>;
}>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>>>;
}>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>>>>;
readonly usage: Schema.optional<Schema.NullOr<Schema.StructWithRest<Schema.Struct<{

@@ -230,2 +246,4 @@ readonly prompt_tokens: Schema.optional<Schema.NullOr<Schema.Number>>;

readonly total_tokens: Schema.optional<Schema.NullOr<Schema.Number>>;
readonly cached_tokens: Schema.optional<Schema.NullOr<Schema.Number>>;
readonly prompt_cache_hit_tokens: Schema.optional<Schema.NullOr<Schema.Number>>;
readonly prompt_tokens_details: Schema.optional<Schema.NullOr<Schema.StructWithRest<Schema.Struct<{

@@ -572,2 +590,4 @@ readonly cached_tokens: Schema.optional<Schema.NullOr<Schema.Number>>;

readonly total_tokens?: number | null | undefined;
readonly cached_tokens?: number | null | undefined;
readonly prompt_cache_hit_tokens?: number | null | undefined;
readonly prompt_tokens_details?: {

@@ -586,2 +606,3 @@ readonly [x: string]: unknown;

readonly choices?: readonly {
readonly [x: string]: unknown;
readonly delta?: {

@@ -604,2 +625,21 @@ readonly [x: string]: unknown;

} | null | undefined;
readonly usage?: {
readonly [x: string]: unknown;
readonly prompt_tokens?: number | null | undefined;
readonly completion_tokens?: number | null | undefined;
readonly total_tokens?: number | null | undefined;
readonly cached_tokens?: number | null | undefined;
readonly prompt_cache_hit_tokens?: number | null | undefined;
readonly prompt_tokens_details?: {
readonly [x: string]: unknown;
readonly cached_tokens?: number | null | undefined;
readonly cache_write_tokens?: number | null | undefined;
} | null | undefined;
readonly completion_tokens_details?: {
readonly [x: string]: unknown;
readonly reasoning_tokens?: number | null | undefined;
readonly accepted_prediction_tokens?: number | null | undefined;
readonly rejected_prediction_tokens?: number | null | undefined;
} | null | undefined;
} | null | undefined;
readonly finish_reason?: string | null | undefined;

@@ -606,0 +646,0 @@ readonly native_finish_reason?: string | null | undefined;

@@ -126,2 +126,5 @@ import { Effect, Schema } from "effect";

total_tokens: optionalNull(Schema.Number),
// Zai reports cache hits as top-level `cached_tokens`; DeepSeek uses `prompt_cache_hit_tokens`.
cached_tokens: optionalNull(Schema.Number),
prompt_cache_hit_tokens: optionalNull(Schema.Number),
prompt_tokens_details: optionalNull(Schema.StructWithRest(Schema.Struct({

@@ -155,7 +158,9 @@ cached_tokens: optionalNull(Schema.Number),

}), [Schema.Record(Schema.String, Schema.Unknown)]);
const OpenAIChatChoice = Schema.Struct({
const OpenAIChatChoice = Schema.StructWithRest(Schema.Struct({
delta: optionalNull(OpenAIChatDelta),
finish_reason: optionalNull(Schema.String),
native_finish_reason: optionalNull(Schema.String),
});
// Moonshot streams usage on `choice.usage` instead of top-level `usage`.
usage: optionalNull(OpenAIChatUsage),
}), [Schema.Record(Schema.String, Schema.Unknown)]);
const OpenAIChatError = Schema.Struct({

@@ -401,2 +406,14 @@ code: optionalNull(Schema.Union([Schema.String, Schema.Number])),

});
// Anthropic via LiteLLM and Amazon Bedrock require `tools` to be present
// whenever the conversation history contains tool calls/results. Send an
// explicit empty array when we have history but no active tools.
const hasToolHistory = (messages) => {
for (const message of messages) {
if (message.role === "tool")
return true;
if (message.role === "assistant" && message.content.some((part) => part.type === "tool-call"))
return true;
}
return false;
};
const lowerOptions = (request) => {

@@ -419,2 +436,3 @@ const options = OpenAIOptions.resolve(request);

const maxTokensField = request.model.compatibility?.maxTokensField ?? "max_tokens";
const hasHistory = hasToolHistory(request.messages);
return {

@@ -424,3 +442,5 @@ model: request.model.id,

tools: request.tools.length === 0
? undefined
? hasHistory
? []
: undefined
: request.tools.map((tool) => lowerTool(tool, ToolSchemaProjection.modelCompatibility(tool.inputSchema, toolSchemaCompatibility), options)),

@@ -466,2 +486,5 @@ tool_choice: request.toolChoice ? yield* lowerToolChoice(request.toolChoice) : undefined,

// satisfied on both sides.
// Providers differ on cache-hit location: OpenAI uses
// `prompt_tokens_details.cached_tokens`, DeepSeek uses
// `prompt_cache_hit_tokens`, and Zai uses top-level `cached_tokens`.
const mapUsage = (usage) => {

@@ -472,3 +495,6 @@ if (!usage)

const output = usage.completion_tokens ?? undefined;
const cached = usage.prompt_tokens_details?.cached_tokens ?? undefined;
const cached = (usage.prompt_tokens_details?.cached_tokens ??
usage.prompt_cache_hit_tokens ??
usage.cached_tokens ??
undefined);
const cacheWrite = usage.prompt_tokens_details?.cache_write_tokens ?? undefined;

@@ -564,4 +590,7 @@ const reasoning = usage.completion_tokens_details?.reasoning_tokens ?? undefined;

const events = [];
const usage = mapUsage(event.usage) ?? state.usage;
const choice = event.choices?.[0];
// Moonshot (and a few other OpenAI-compatible providers) attach usage to
// `choice.usage` instead of the top-level `usage` field.
const choiceUsage = choice?.usage;
const usage = mapUsage(event.usage) ?? (choiceUsage ? mapUsage(choiceUsage) : undefined) ?? state.usage;
const rawFinishReason = choice?.finish_reason;

@@ -568,0 +597,0 @@ const finishReason = rawFinishReason !== undefined && rawFinishReason !== null

@@ -120,3 +120,3 @@ import { Route, type RouteRoutedLanguageModelInput } from "../route/client.js";

readonly top_logprobs?: number | undefined;
readonly service_tier?: "default" | "auto" | "flex" | "priority" | undefined;
readonly service_tier?: import("./utils/open-responses-options.js").ServiceTier | undefined;
readonly max_output_tokens?: number | undefined;

@@ -123,0 +123,0 @@ readonly max_tool_calls?: number | undefined;

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

readonly truncation: Schema.optional<Schema.Literals<readonly ["auto", "disabled"]>>;
readonly service_tier: Schema.optional<Schema.Literals<readonly ["auto", "default", "flex", "priority"]>>;
readonly service_tier: Schema.optional<Schema.declare<import("./utils/open-responses-options.js").ServiceTier, import("./utils/open-responses-options.js").ServiceTier>>;
readonly prompt_cache_key: Schema.optional<Schema.String>;

@@ -259,3 +259,3 @@ readonly include: Schema.optional<Schema.$Array<Schema.declare<import("./utils/open-responses-options.js").ResponseIncludable, import("./utils/open-responses-options.js").ResponseIncludable>>>;

readonly top_logprobs?: number | undefined;
readonly service_tier?: "default" | "auto" | "flex" | "priority" | undefined;
readonly service_tier?: import("./utils/open-responses-options.js").ServiceTier | undefined;
readonly max_output_tokens?: number | undefined;

@@ -443,3 +443,3 @@ readonly max_tool_calls?: number | undefined;

readonly top_logprobs?: number | undefined;
readonly service_tier?: "default" | "auto" | "flex" | "priority" | undefined;
readonly service_tier?: import("./utils/open-responses-options.js").ServiceTier | undefined;
readonly max_output_tokens?: number | undefined;

@@ -573,3 +573,3 @@ readonly max_tool_calls?: number | undefined;

readonly top_logprobs?: number | undefined;
readonly service_tier?: "default" | "auto" | "flex" | "priority" | undefined;
readonly service_tier?: import("./utils/open-responses-options.js").ServiceTier | undefined;
readonly max_output_tokens?: number | undefined;

@@ -703,3 +703,3 @@ readonly max_tool_calls?: number | undefined;

readonly top_logprobs?: number | undefined;
readonly service_tier?: "default" | "auto" | "flex" | "priority" | undefined;
readonly service_tier?: import("./utils/open-responses-options.js").ServiceTier | undefined;
readonly max_output_tokens?: number | undefined;

@@ -833,3 +833,3 @@ readonly max_tool_calls?: number | undefined;

readonly top_logprobs?: number | undefined;
readonly service_tier?: "default" | "auto" | "flex" | "priority" | undefined;
readonly service_tier?: import("./utils/open-responses-options.js").ServiceTier | undefined;
readonly max_output_tokens?: number | undefined;

@@ -836,0 +836,0 @@ readonly max_tool_calls?: number | undefined;

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

},
computer_use_call: { name: "computer_use", input: (item) => item.action ?? {} },
computer_call: { name: "computer_use", input: (item) => item.action ?? {} },
image_generation_call: { name: "image_generation", input: () => ({}), result: hostedToolResult },

@@ -119,3 +119,2 @@ mcp_call: {

},
local_shell_call: { name: "local_shell", input: (item) => item.action ?? {} },
};

@@ -122,0 +121,0 @@ const step = (state, event) => {

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

export declare const ServiceTiers: readonly ["auto", "default", "flex", "priority"];
export type ServiceTier = (typeof ServiceTiers)[number];
export type ServiceTier = (typeof ServiceTiers)[number] | (string & {});
export declare const ServiceTier: Schema.declare<ServiceTier, ServiceTier>;
export declare const Truncations: readonly ["auto", "disabled"];

@@ -18,3 +19,3 @@ export type Truncation = (typeof Truncations)[number];

export declare const ResponseIncludableSchema: Schema.declare<ResponseIncludable, ResponseIncludable>;
export declare const ServiceTierSchema: Schema.Literals<readonly ["auto", "default", "flex", "priority"]>;
export declare const ServiceTierSchema: Schema.declare<ServiceTier, ServiceTier>;
export declare const TruncationSchema: Schema.Literals<readonly ["auto", "disabled"]>;

@@ -42,3 +43,3 @@ export declare const AllowedTools: Schema.Struct<{

readonly textVerbosity: Schema.optional<Schema.declare<TextVerbosity, TextVerbosity>>;
readonly serviceTier: Schema.optional<Schema.Literals<readonly ["auto", "default", "flex", "priority"]>>;
readonly serviceTier: Schema.optional<Schema.declare<ServiceTier, ServiceTier>>;
readonly truncation: Schema.optional<Schema.Literals<readonly ["auto", "disabled"]>>;

@@ -45,0 +46,0 @@ readonly allowedTools: Schema.optional<Schema.Struct<{

@@ -17,6 +17,7 @@ import { Option, Schema } from "effect";

export const ServiceTiers = ["auto", "default", "flex", "priority"];
export const ServiceTier = Schema.declare((value) => typeof value === "string", { title: "ServiceTier" });
export const Truncations = ["auto", "disabled"];
export const TextVerbositySchema = TextVerbosity;
export const ResponseIncludableSchema = Schema.declare((value) => typeof value === "string", { title: "ResponseIncludable" });
export const ServiceTierSchema = Schema.Literals(ServiceTiers);
export const ServiceTierSchema = ServiceTier;
export const TruncationSchema = Schema.Literals(Truncations);

@@ -23,0 +24,0 @@ export const AllowedTools = Schema.Struct({

@@ -8,10 +8,10 @@ import { OpenResponsesOptions } from "./open-responses-options.js";

export type OpenAIResponseIncludable = OpenResponsesOptions.ResponseIncludable;
export declare const OpenAIServiceTiers: readonly ["auto", "default", "flex", "priority"];
export type OpenAIServiceTier = OpenResponsesOptions.ServiceTier;
export declare const OpenAIServiceTiers: readonly ["auto", "default", "flex", "priority", "scale"];
export type OpenAIServiceTier = (typeof OpenAIServiceTiers)[number] | (string & {});
export declare const OpenAIReasoningEffort: import("effect/Schema").declare<OpenResponsesOptions.ReasoningEffort, OpenResponsesOptions.ReasoningEffort>;
export declare const OpenAITextVerbosity: import("effect/Schema").declare<OpenResponsesOptions.TextVerbosity, OpenResponsesOptions.TextVerbosity>;
export declare const OpenAIResponseIncludable: import("effect/Schema").declare<OpenResponsesOptions.ResponseIncludable, OpenResponsesOptions.ResponseIncludable>;
export declare const OpenAIServiceTier: import("effect/Schema").Literals<readonly ["auto", "default", "flex", "priority"]>;
export declare const OpenAIServiceTier: import("effect/Schema").declare<OpenResponsesOptions.ServiceTier, OpenResponsesOptions.ServiceTier>;
export declare const isReasoningEffort: (effort: unknown) => effort is OpenAIReasoningEffort;
export declare const resolve: (request: import("../../index.js").LLMRequest) => OpenResponsesOptions.Resolved;
export * as OpenAIOptions from "./openai-options.js";

@@ -7,3 +7,3 @@ import { OpenResponsesOptions } from "./open-responses-options.js";

export const OpenAIResponseIncludables = OpenResponsesOptions.ResponseIncludables;
export const OpenAIServiceTiers = OpenResponsesOptions.ServiceTiers;
export const OpenAIServiceTiers = [...OpenResponsesOptions.ServiceTiers, "scale"];
export const OpenAIReasoningEffort = OpenResponsesOptions.ReasoningEffort;

@@ -10,0 +10,0 @@ export const OpenAITextVerbosity = OpenResponsesOptions.TextVerbosity;

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

readonly top_logprobs?: number | undefined;
readonly service_tier?: "default" | "auto" | "flex" | "priority" | undefined;
readonly service_tier?: import("./utils/open-responses-options.js").ServiceTier | undefined;
readonly max_output_tokens?: number | undefined;

@@ -118,0 +118,0 @@ readonly max_tool_calls?: number | undefined;

@@ -242,3 +242,3 @@ import type { Route as RouteDef, RouteDefaultsInput } from "../route/client.js";

readonly top_logprobs?: number | undefined;
readonly service_tier?: "default" | "auto" | "flex" | "priority" | undefined;
readonly service_tier?: import("../protocols/utils/open-responses-options.js").ServiceTier | undefined;
readonly max_output_tokens?: number | undefined;

@@ -250,5 +250,5 @@ readonly max_tool_calls?: number | undefined;

id: string & import("effect/Brand").Brand<"AI.ProviderID">;
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput>;
chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput>;
responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput>;
configure: (input?: Config) => /*elided*/ any;

@@ -258,10 +258,10 @@ };

id: string & import("effect/Brand").Brand<"AI.ProviderID">;
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput>;
chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput>;
responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput>;
configure: (input?: Config) => {
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput>;
chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput>;
responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput>;
configure: /*elided*/ any;

@@ -272,2 +272,2 @@ };

export declare const responsesModel: ProviderPackage.Definition<Settings, OpenAIProviderOptionsInput>["model"];
export declare const model: (modelID: string, settings: Settings) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
export declare const model: (modelID: string, settings: Settings) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput>;

@@ -245,3 +245,3 @@ import { type AtLeastOne, type ProviderAuthOption } from "../route/auth-options.js";

readonly top_logprobs?: number | undefined;
readonly service_tier?: "default" | "auto" | "flex" | "priority" | undefined;
readonly service_tier?: import("../protocols/utils/open-responses-options.js").ServiceTier | undefined;
readonly max_output_tokens?: number | undefined;

@@ -253,5 +253,5 @@ readonly max_tool_calls?: number | undefined;

id: string & import("effect/Brand").Brand<"AI.ProviderID">;
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput>;
responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput>;
chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput>;
configure: (input: Config) => /*elided*/ any;

@@ -263,5 +263,5 @@ };

id: string & import("effect/Brand").Brand<"AI.ProviderID">;
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput>;
responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput>;
chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput>;
configure: /*elided*/ any;

@@ -272,3 +272,3 @@ };

export declare const chatModel: ProviderPackage.Definition<Settings, OpenAIProviderOptionsInput>["model"];
export declare const model: (modelID: string, settings: Settings) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
export declare const model: (modelID: string, settings: Settings) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput>;
export {};

@@ -326,3 +326,3 @@ import type { Config, Redacted } from "effect";

id: string & import("effect/Brand").Brand<"AI.ProviderID">;
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput>;
configure: /*elided*/ any;

@@ -335,3 +335,3 @@ };

id: string & import("effect/Brand").Brand<"AI.ProviderID">;
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput>;
configure: /*elided*/ any;

@@ -338,0 +338,0 @@ };

@@ -120,3 +120,3 @@ import type { ProviderPackage } from "../provider-package.js";

id: string & import("effect/Brand").Brand<"AI.ProviderID">;
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput>;
configure: (input?: Config) => /*elided*/ any;

@@ -128,3 +128,3 @@ };

id: string & import("effect/Brand").Brand<"AI.ProviderID">;
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput>;
configure: /*elided*/ any;

@@ -131,0 +131,0 @@ };

@@ -133,3 +133,3 @@ import type { ProviderPackage } from "../provider-package.js";

readonly top_logprobs?: number | undefined;
readonly service_tier?: "default" | "auto" | "flex" | "priority" | undefined;
readonly service_tier?: import("../protocols/utils/open-responses-options.js").ServiceTier | undefined;
readonly max_output_tokens?: number | undefined;

@@ -136,0 +136,0 @@ readonly max_tool_calls?: number | undefined;

@@ -31,4 +31,3 @@ import type { ProviderPackage } from "../provider-package.js";

readonly contents: readonly {
readonly role: "model" | "user";
readonly parts: readonly ({
readonly parts?: readonly ({
readonly inlineData: {

@@ -40,11 +39,11 @@ readonly mimeType: string;

readonly text: string;
readonly thought?: boolean | undefined;
readonly thoughtSignature?: string | undefined;
readonly thought?: boolean | null | undefined;
readonly thoughtSignature?: string | null | undefined;
} | {
readonly functionCall: {
readonly name: string;
readonly id?: string | undefined;
readonly id?: string | null | undefined;
readonly args?: unknown;
};
readonly thoughtSignature?: string | undefined;
readonly thoughtSignature?: string | null | undefined;
} | {

@@ -62,3 +61,4 @@ readonly functionResponse: {

};
})[];
})[] | null | undefined;
readonly role?: "model" | "user" | null | undefined;
}[];

@@ -65,0 +65,0 @@ readonly tools?: readonly {

@@ -13,2 +13,14 @@ import { Effect } from "effect";

const body = yield* Gemini.protocol.body.from(request);
// Vertex's native REST schema rejects `id` on FunctionCall/FunctionResponse parts with HTTP 400,
// unlike AI Studio, so history minted there cannot be lowered verbatim.
const contents = body.contents.map((content) => ({
...content,
parts: (content.parts ?? []).map((part) => {
if ("functionCall" in part)
return { ...part, functionCall: { ...part.functionCall, id: undefined } };
if ("functionResponse" in part)
return { ...part, functionResponse: { ...part.functionResponse, id: undefined } };
return part;
}),
}));
const value = request.providerOptions?.labels;

@@ -18,3 +30,3 @@ const labels = ProviderShared.isRecord(value)

: undefined;
return { ...body, labels };
return { ...body, contents, labels };
});

@@ -21,0 +33,0 @@ const protocol = {

@@ -12,4 +12,3 @@ import type { RouteDefaultsInput } from "../route/client.js";

readonly contents: readonly {
readonly role: "model" | "user";
readonly parts: readonly ({
readonly parts?: readonly ({
readonly inlineData: {

@@ -21,11 +20,11 @@ readonly mimeType: string;

readonly text: string;
readonly thought?: boolean | undefined;
readonly thoughtSignature?: string | undefined;
readonly thought?: boolean | null | undefined;
readonly thoughtSignature?: string | null | undefined;
} | {
readonly functionCall: {
readonly name: string;
readonly id?: string | undefined;
readonly id?: string | null | undefined;
readonly args?: unknown;
};
readonly thoughtSignature?: string | undefined;
readonly thoughtSignature?: string | null | undefined;
} | {

@@ -43,3 +42,4 @@ readonly functionResponse: {

};
})[];
})[] | null | undefined;
readonly role?: "model" | "user" | null | undefined;
}[];

@@ -46,0 +46,0 @@ readonly tools?: readonly {

@@ -131,3 +131,3 @@ import type { ProviderPackage } from "../provider-package.js";

readonly top_logprobs?: number | undefined;
readonly service_tier?: "default" | "auto" | "flex" | "priority" | undefined;
readonly service_tier?: import("../protocols/utils/open-responses-options.js").ServiceTier | undefined;
readonly max_output_tokens?: number | undefined;

@@ -134,0 +134,0 @@ readonly max_tool_calls?: number | undefined;

@@ -121,3 +121,3 @@ import { type ModelID } from "../schema/index.js";

id: string & import("effect/Brand").Brand<"AI.ProviderID">;
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput>;
configure: (input: GenericModelOptions) => /*elided*/ any;

@@ -129,3 +129,3 @@ };

id: string & import("effect/Brand").Brand<"AI.ProviderID">;
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput>;
configure: /*elided*/ any;

@@ -137,3 +137,3 @@ };

id: string & import("effect/Brand").Brand<"AI.ProviderID">;
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput>;
configure: (input?: FamilyModelOptions) => /*elided*/ any;

@@ -143,3 +143,3 @@ };

id: string & import("effect/Brand").Brand<"AI.ProviderID">;
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput>;
configure: (input?: FamilyModelOptions) => /*elided*/ any;

@@ -149,3 +149,3 @@ };

id: string & import("effect/Brand").Brand<"AI.ProviderID">;
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput>;
configure: (input?: FamilyModelOptions) => /*elided*/ any;

@@ -155,3 +155,3 @@ };

id: string & import("effect/Brand").Brand<"AI.ProviderID">;
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput>;
configure: (input?: FamilyModelOptions) => /*elided*/ any;

@@ -161,3 +161,3 @@ };

id: string & import("effect/Brand").Brand<"AI.ProviderID">;
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput>;
configure: (input?: FamilyModelOptions) => /*elided*/ any;

@@ -167,3 +167,3 @@ };

id: string & import("effect/Brand").Brand<"AI.ProviderID">;
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput>;
configure: (input?: FamilyModelOptions) => /*elided*/ any;

@@ -173,5 +173,5 @@ };

id: string & import("effect/Brand").Brand<"AI.ProviderID">;
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput>;
configure: (input?: FamilyModelOptions) => /*elided*/ any;
};
export {};
import { type ProviderOptions } from "../schema/index.js";
import type { OpenResponsesOptionsInput } from "./open-responses-options.js";
import type { OpenAIServiceTier } from "../protocols/utils/openai-options.js";
import type { Options } from "../protocols/utils/open-responses-options.js";
export type { OpenAIResponseIncludable, OpenAIServiceTier } from "../protocols/utils/openai-options.js";
export type OpenAIOptionsInput = OpenResponsesOptionsInput;
export type OpenAIOptionsInput = Omit<Options, "serviceTier"> & {
readonly serviceTier?: OpenAIServiceTier;
readonly [key: string]: unknown;
};
export type OpenAIProviderOptionsInput = OpenAIOptionsInput;

@@ -6,0 +10,0 @@ export declare const gpt5DefaultOptions: (modelID: string, options?: {

@@ -230,3 +230,3 @@ import { type ProviderAuthOption } from "../route/auth-options.js";

readonly top_logprobs?: number | undefined;
readonly service_tier?: "default" | "auto" | "flex" | "priority" | undefined;
readonly service_tier?: import("../protocols/utils/open-responses-options.js").ServiceTier | undefined;
readonly max_output_tokens?: number | undefined;

@@ -262,5 +262,5 @@ readonly max_tool_calls?: number | undefined;

id: string & import("effect/Brand").Brand<"AI.ProviderID">;
model: (id: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
responses: (id: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
chat: (id: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
model: (id: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput>;
responses: (id: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput>;
chat: (id: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput>;
image: (modelID: string | ModelID) => import("../image.js").ImageModel<import("../protocols/openai-images.js").OpenAIImageOptions>;

@@ -271,11 +271,11 @@ configure: (input?: Config) => /*elided*/ any;

id: string & import("effect/Brand").Brand<"AI.ProviderID">;
model: (id: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
responses: (id: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
chat: (id: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
model: (id: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput>;
responses: (id: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput>;
chat: (id: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput>;
image: (modelID: string | ModelID) => import("../image.js").ImageModel<import("../protocols/openai-images.js").OpenAIImageOptions>;
configure: (input?: Config) => {
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
model: (id: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
responses: (id: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
chat: (id: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
model: (id: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput>;
responses: (id: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput>;
chat: (id: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput>;
image: (modelID: string | ModelID) => import("../image.js").ImageModel<import("../protocols/openai-images.js").OpenAIImageOptions>;

@@ -287,4 +287,4 @@ configure: /*elided*/ any;

export declare const chatModel: ProviderPackage.Definition<Settings, OpenAIProviderOptionsInput>["model"];
export declare const responses: (id: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
export declare const chat: (id: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
export declare const responses: (id: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput>;
export declare const chat: (id: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput>;
export declare const image: (modelID: string | ModelID) => import("../image.js").ImageModel<import("../protocols/openai-images.js").OpenAIImageOptions>;

@@ -291,2 +291,4 @@ import { Schema } from "effect";

readonly total_tokens?: number | null | undefined;
readonly cached_tokens?: number | null | undefined;
readonly prompt_cache_hit_tokens?: number | null | undefined;
readonly prompt_tokens_details?: {

@@ -305,2 +307,3 @@ readonly [x: string]: unknown;

readonly choices?: readonly {
readonly [x: string]: unknown;
readonly delta?: {

@@ -323,2 +326,21 @@ readonly [x: string]: unknown;

} | null | undefined;
readonly usage?: {
readonly [x: string]: unknown;
readonly prompt_tokens?: number | null | undefined;
readonly completion_tokens?: number | null | undefined;
readonly total_tokens?: number | null | undefined;
readonly cached_tokens?: number | null | undefined;
readonly prompt_cache_hit_tokens?: number | null | undefined;
readonly prompt_tokens_details?: {
readonly [x: string]: unknown;
readonly cached_tokens?: number | null | undefined;
readonly cache_write_tokens?: number | null | undefined;
} | null | undefined;
readonly completion_tokens_details?: {
readonly [x: string]: unknown;
readonly reasoning_tokens?: number | null | undefined;
readonly accepted_prediction_tokens?: number | null | undefined;
readonly rejected_prediction_tokens?: number | null | undefined;
} | null | undefined;
} | null | undefined;
readonly finish_reason?: string | null | undefined;

@@ -325,0 +347,0 @@ readonly native_finish_reason?: string | null | undefined;

@@ -117,5 +117,5 @@ import { type ProviderAuthOption } from "../route/auth-options.js";

id: string & import("effect/Brand").Brand<"AI.ProviderID">;
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenAIOptionsInput>;
responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenAIOptionsInput>;
chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenAIOptionsInput>;
image: (modelID: string | ModelID) => import("../image.js").ImageModel<import("../protocols/xai-images.js").XAIImageOptions>;

@@ -126,11 +126,11 @@ configure: (input?: LanguageModelOptions) => /*elided*/ any;

id: string & import("effect/Brand").Brand<"AI.ProviderID">;
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenAIOptionsInput>;
responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenAIOptionsInput>;
chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenAIOptionsInput>;
image: (modelID: string | ModelID) => import("../image.js").ImageModel<import("../protocols/xai-images.js").XAIImageOptions>;
configure: (input?: LanguageModelOptions) => {
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenAIOptionsInput>;
responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenAIOptionsInput>;
chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenAIOptionsInput>;
image: (modelID: string | ModelID) => import("../image.js").ImageModel<import("../protocols/xai-images.js").XAIImageOptions>;

@@ -141,4 +141,4 @@ configure: /*elided*/ any;

export declare const model: ProviderPackage.Definition<Settings, XAIProviderOptionsInput>["model"];
export declare const responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
export declare const chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
export declare const responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenAIOptionsInput>;
export declare const chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenAIOptionsInput>;
export declare const image: (modelID: string | ModelID) => import("../image.js").ImageModel<import("../protocols/xai-images.js").XAIImageOptions>;
{
"$schema": "https://json.schemastore.org/package.json",
"version": "0.0.0-beta-17963",
"version": "0.0.0-beta-18027",
"name": "@opencode-ai/ai",

@@ -32,4 +32,4 @@ "type": "module",

"@clack/prompts": "1.0.0-alpha.1",
"@effect/platform-node": "4.0.0-rc.110",
"@opencode-ai/http-recorder": "0.0.0-beta-17963",
"@effect/platform-node": "4.0.0-rc.111",
"@opencode-ai/http-recorder": "0.0.0-beta-18027",
"@tsconfig/bun": "1.0.9",

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

"@smithy/util-utf8": "4.2.2",
"@opencode-ai/schema": "0.0.0-beta-17963",
"@opencode-ai/schema": "0.0.0-beta-18027",
"aws4fetch": "1.0.20",
"effect": "4.0.0-rc.110",
"effect": "4.0.0-rc.111",
"google-auth-library": "10.5.0"
}
}