@opencode-ai/ai
Advanced tools
@@ -30,2 +30,35 @@ import { Schema } from "effect"; | ||
| readonly effort?: string; | ||
| readonly service_tier?: "auto" | "standard_only"; | ||
| readonly serviceTier?: "auto" | "standard_only"; | ||
| readonly metadata?: { | ||
| readonly user_id?: string | null; | ||
| }; | ||
| readonly container?: string | { | ||
| readonly id?: string | null; | ||
| readonly skills?: ReadonlyArray<Record<string, unknown>> | null; | ||
| }; | ||
| readonly inference_geo?: string | null; | ||
| readonly inferenceGeo?: string | null; | ||
| readonly cache_control?: { | ||
| readonly type: "ephemeral"; | ||
| readonly ttl?: "5m" | "1h"; | ||
| }; | ||
| readonly cacheControl?: { | ||
| readonly type: "ephemeral"; | ||
| readonly ttl?: "5m" | "1h"; | ||
| }; | ||
| readonly output_config?: { | ||
| readonly effort?: string | null; | ||
| readonly format?: { | ||
| readonly type: "json_schema"; | ||
| readonly schema: Record<string, unknown>; | ||
| } | null; | ||
| }; | ||
| readonly outputConfig?: { | ||
| readonly effort?: string | null; | ||
| readonly format?: { | ||
| readonly type: "json_schema"; | ||
| readonly schema: Record<string, unknown>; | ||
| } | null; | ||
| }; | ||
| } | ||
@@ -54,7 +87,13 @@ export type ProviderOptionsInput = OptionsInput; | ||
| readonly type: Schema.tag<"image">; | ||
| readonly source: Schema.Struct<{ | ||
| readonly source: Schema.Union<readonly [Schema.Struct<{ | ||
| readonly type: Schema.tag<"base64">; | ||
| readonly media_type: Schema.String; | ||
| readonly data: Schema.String; | ||
| }>; | ||
| }>, Schema.Struct<{ | ||
| readonly type: Schema.tag<"url">; | ||
| readonly url: Schema.String; | ||
| }>, Schema.Struct<{ | ||
| readonly type: Schema.tag<"file">; | ||
| readonly file_id: Schema.String; | ||
| }>]>; | ||
| readonly cache_control: Schema.optional<Schema.Struct<{ | ||
@@ -64,9 +103,22 @@ readonly type: Schema.tag<"ephemeral">; | ||
| }>>; | ||
| readonly transformations: Schema.optional<Schema.Struct<{ | ||
| readonly oversized_image: Schema.optional<Schema.Literals<readonly ["downsize", "error"]>>; | ||
| }>>; | ||
| }>, Schema.Struct<{ | ||
| readonly type: Schema.tag<"document">; | ||
| readonly source: Schema.Struct<{ | ||
| readonly source: Schema.Union<readonly [Schema.Struct<{ | ||
| readonly type: Schema.tag<"base64">; | ||
| readonly media_type: Schema.Literal<"application/pdf">; | ||
| readonly data: Schema.String; | ||
| }>; | ||
| }>, Schema.Struct<{ | ||
| readonly type: Schema.tag<"text">; | ||
| readonly media_type: Schema.Literal<"text/plain">; | ||
| readonly data: Schema.String; | ||
| }>, Schema.Struct<{ | ||
| readonly type: Schema.tag<"url">; | ||
| readonly url: Schema.String; | ||
| }>, Schema.Struct<{ | ||
| readonly type: Schema.tag<"file">; | ||
| readonly file_id: Schema.String; | ||
| }>]>; | ||
| readonly cache_control: Schema.optional<Schema.Struct<{ | ||
@@ -76,2 +128,7 @@ readonly type: Schema.tag<"ephemeral">; | ||
| }>>; | ||
| readonly title: Schema.optional<Schema.String>; | ||
| readonly context: Schema.optional<Schema.String>; | ||
| readonly citations: Schema.optional<Schema.Struct<{ | ||
| readonly enabled: Schema.Boolean; | ||
| }>>; | ||
| }>, Schema.Struct<{ | ||
@@ -89,7 +146,13 @@ readonly type: Schema.tag<"tool_result">; | ||
| readonly type: Schema.tag<"image">; | ||
| readonly source: Schema.Struct<{ | ||
| readonly source: Schema.Union<readonly [Schema.Struct<{ | ||
| readonly type: Schema.tag<"base64">; | ||
| readonly media_type: Schema.String; | ||
| readonly data: Schema.String; | ||
| }>; | ||
| }>, Schema.Struct<{ | ||
| readonly type: Schema.tag<"url">; | ||
| readonly url: Schema.String; | ||
| }>, Schema.Struct<{ | ||
| readonly type: Schema.tag<"file">; | ||
| readonly file_id: Schema.String; | ||
| }>]>; | ||
| readonly cache_control: Schema.optional<Schema.Struct<{ | ||
@@ -99,9 +162,22 @@ readonly type: Schema.tag<"ephemeral">; | ||
| }>>; | ||
| readonly transformations: Schema.optional<Schema.Struct<{ | ||
| readonly oversized_image: Schema.optional<Schema.Literals<readonly ["downsize", "error"]>>; | ||
| }>>; | ||
| }>, Schema.Struct<{ | ||
| readonly type: Schema.tag<"document">; | ||
| readonly source: Schema.Struct<{ | ||
| readonly source: Schema.Union<readonly [Schema.Struct<{ | ||
| readonly type: Schema.tag<"base64">; | ||
| readonly media_type: Schema.Literal<"application/pdf">; | ||
| readonly data: Schema.String; | ||
| }>; | ||
| }>, Schema.Struct<{ | ||
| readonly type: Schema.tag<"text">; | ||
| readonly media_type: Schema.Literal<"text/plain">; | ||
| readonly data: Schema.String; | ||
| }>, Schema.Struct<{ | ||
| readonly type: Schema.tag<"url">; | ||
| readonly url: Schema.String; | ||
| }>, Schema.Struct<{ | ||
| readonly type: Schema.tag<"file">; | ||
| readonly file_id: Schema.String; | ||
| }>]>; | ||
| readonly cache_control: Schema.optional<Schema.Struct<{ | ||
@@ -111,2 +187,7 @@ readonly type: Schema.tag<"ephemeral">; | ||
| }>>; | ||
| readonly title: Schema.optional<Schema.String>; | ||
| readonly context: Schema.optional<Schema.String>; | ||
| readonly citations: Schema.optional<Schema.Struct<{ | ||
| readonly enabled: Schema.Boolean; | ||
| }>>; | ||
| }>]>>]>; | ||
@@ -131,3 +212,3 @@ readonly is_error: Schema.optional<Schema.Boolean>; | ||
| readonly thinking: Schema.String; | ||
| readonly signature: Schema.optional<Schema.String>; | ||
| readonly signature: Schema.String; | ||
| readonly cache_control: Schema.optional<Schema.Struct<{ | ||
@@ -193,5 +274,7 @@ readonly type: Schema.tag<"ephemeral">; | ||
| readonly type: Schema.Literals<readonly ["auto", "any", "none"]>; | ||
| readonly disable_parallel_tool_use: Schema.optional<Schema.Boolean>; | ||
| }>, Schema.Struct<{ | ||
| readonly type: Schema.tag<"tool">; | ||
| readonly name: Schema.String; | ||
| readonly disable_parallel_tool_use: Schema.optional<Schema.Boolean>; | ||
| }>]>>; | ||
@@ -216,3 +299,20 @@ stream: Schema.Literal<true>; | ||
| readonly effort: Schema.optional<Schema.String>; | ||
| readonly format: Schema.optional<Schema.NullOr<Schema.Struct<{ | ||
| readonly type: Schema.Literal<"json_schema">; | ||
| readonly schema: Schema.$Record<Schema.String, Schema.Unknown>; | ||
| }>>>; | ||
| }>>; | ||
| cache_control: Schema.optional<Schema.Struct<{ | ||
| readonly type: Schema.tag<"ephemeral">; | ||
| readonly ttl: Schema.optional<Schema.Literals<readonly ["5m", "1h"]>>; | ||
| }>>; | ||
| container: Schema.optional<Schema.NullOr<Schema.Union<readonly [Schema.String, Schema.Struct<{ | ||
| readonly id: Schema.optional<Schema.NullOr<Schema.String>>; | ||
| readonly skills: Schema.optional<Schema.NullOr<Schema.$Array<Schema.$Record<Schema.String, Schema.Unknown>>>>; | ||
| }>]>>>; | ||
| inference_geo: Schema.optional<Schema.NullOr<Schema.String>>; | ||
| metadata: Schema.optional<Schema.Struct<{ | ||
| readonly user_id: Schema.optional<Schema.NullOr<Schema.String>>; | ||
| }>>; | ||
| service_tier: Schema.optional<Schema.Literals<readonly ["auto", "standard_only"]>>; | ||
| }>; | ||
@@ -243,2 +343,8 @@ export type AnthropicMessagesBody = Schema.Schema.Type<typeof AnthropicMessagesBody>; | ||
| readonly data: string; | ||
| } | { | ||
| readonly type: "url"; | ||
| readonly url: string; | ||
| } | { | ||
| readonly type: "file"; | ||
| readonly file_id: string; | ||
| }; | ||
@@ -249,2 +355,5 @@ readonly cache_control?: { | ||
| } | undefined; | ||
| readonly transformations?: { | ||
| readonly oversized_image?: "error" | "downsize" | undefined; | ||
| } | undefined; | ||
| } | { | ||
@@ -256,3 +365,15 @@ readonly type: "document"; | ||
| readonly data: string; | ||
| } | { | ||
| readonly type: "text"; | ||
| readonly media_type: "text/plain"; | ||
| readonly data: string; | ||
| } | { | ||
| readonly type: "url"; | ||
| readonly url: string; | ||
| } | { | ||
| readonly type: "file"; | ||
| readonly file_id: string; | ||
| }; | ||
| readonly title?: string | undefined; | ||
| readonly context?: string | undefined; | ||
| readonly cache_control?: { | ||
@@ -262,2 +383,5 @@ readonly type: "ephemeral"; | ||
| } | undefined; | ||
| readonly citations?: { | ||
| readonly enabled: boolean; | ||
| } | undefined; | ||
| } | { | ||
@@ -278,2 +402,8 @@ readonly type: "tool_result"; | ||
| readonly data: string; | ||
| } | { | ||
| readonly type: "url"; | ||
| readonly url: string; | ||
| } | { | ||
| readonly type: "file"; | ||
| readonly file_id: string; | ||
| }; | ||
@@ -284,2 +414,5 @@ readonly cache_control?: { | ||
| } | undefined; | ||
| readonly transformations?: { | ||
| readonly oversized_image?: "error" | "downsize" | undefined; | ||
| } | undefined; | ||
| } | { | ||
@@ -291,3 +424,15 @@ readonly type: "document"; | ||
| readonly data: string; | ||
| } | { | ||
| readonly type: "text"; | ||
| readonly media_type: "text/plain"; | ||
| readonly data: string; | ||
| } | { | ||
| readonly type: "url"; | ||
| readonly url: string; | ||
| } | { | ||
| readonly type: "file"; | ||
| readonly file_id: string; | ||
| }; | ||
| readonly title?: string | undefined; | ||
| readonly context?: string | undefined; | ||
| readonly cache_control?: { | ||
@@ -297,2 +442,5 @@ readonly type: "ephemeral"; | ||
| } | undefined; | ||
| readonly citations?: { | ||
| readonly enabled: boolean; | ||
| } | undefined; | ||
| })[]; | ||
@@ -344,2 +492,3 @@ readonly tool_use_id: string; | ||
| readonly thinking: string; | ||
| readonly signature: string; | ||
| readonly cache_control?: { | ||
@@ -349,3 +498,2 @@ readonly type: "ephemeral"; | ||
| } | undefined; | ||
| readonly signature?: string | undefined; | ||
| } | { | ||
@@ -371,2 +519,5 @@ readonly data: string; | ||
| readonly stream: true; | ||
| readonly metadata?: { | ||
| readonly user_id?: string | null | undefined; | ||
| } | undefined; | ||
| readonly tools?: readonly { | ||
@@ -402,7 +553,30 @@ readonly description: string; | ||
| } | undefined; | ||
| readonly service_tier?: "auto" | "standard_only" | undefined; | ||
| readonly container?: string | { | ||
| readonly id?: string | null | undefined; | ||
| readonly skills?: readonly { | ||
| readonly [x: string]: unknown; | ||
| }[] | null | undefined; | ||
| } | null | undefined; | ||
| readonly inference_geo?: string | null | undefined; | ||
| readonly cache_control?: { | ||
| readonly type: "ephemeral"; | ||
| readonly ttl?: "1h" | "5m" | undefined; | ||
| } | undefined; | ||
| readonly output_config?: { | ||
| readonly format?: { | ||
| readonly type: "json_schema"; | ||
| readonly schema: { | ||
| readonly [x: string]: unknown; | ||
| }; | ||
| } | null | undefined; | ||
| readonly effort?: string | undefined; | ||
| } | undefined; | ||
| readonly tool_choice?: { | ||
| readonly type: "auto" | "none" | "any"; | ||
| readonly disable_parallel_tool_use?: boolean | undefined; | ||
| } | { | ||
| readonly type: "tool"; | ||
| readonly name: string; | ||
| readonly disable_parallel_tool_use?: boolean | undefined; | ||
| } | undefined; | ||
@@ -412,5 +586,2 @@ readonly top_p?: number | undefined; | ||
| readonly stop_sequences?: readonly string[] | undefined; | ||
| readonly output_config?: { | ||
| readonly effort?: string | undefined; | ||
| } | undefined; | ||
| }, string, { | ||
@@ -499,2 +670,8 @@ readonly type: string; | ||
| readonly data: string; | ||
| } | { | ||
| readonly type: "url"; | ||
| readonly url: string; | ||
| } | { | ||
| readonly type: "file"; | ||
| readonly file_id: string; | ||
| }; | ||
@@ -505,2 +682,5 @@ readonly cache_control?: { | ||
| } | undefined; | ||
| readonly transformations?: { | ||
| readonly oversized_image?: "error" | "downsize" | undefined; | ||
| } | undefined; | ||
| } | { | ||
@@ -512,3 +692,15 @@ readonly type: "document"; | ||
| readonly data: string; | ||
| } | { | ||
| readonly type: "text"; | ||
| readonly media_type: "text/plain"; | ||
| readonly data: string; | ||
| } | { | ||
| readonly type: "url"; | ||
| readonly url: string; | ||
| } | { | ||
| readonly type: "file"; | ||
| readonly file_id: string; | ||
| }; | ||
| readonly title?: string | undefined; | ||
| readonly context?: string | undefined; | ||
| readonly cache_control?: { | ||
@@ -518,2 +710,5 @@ readonly type: "ephemeral"; | ||
| } | undefined; | ||
| readonly citations?: { | ||
| readonly enabled: boolean; | ||
| } | undefined; | ||
| } | { | ||
@@ -534,2 +729,8 @@ readonly type: "tool_result"; | ||
| readonly data: string; | ||
| } | { | ||
| readonly type: "url"; | ||
| readonly url: string; | ||
| } | { | ||
| readonly type: "file"; | ||
| readonly file_id: string; | ||
| }; | ||
@@ -540,2 +741,5 @@ readonly cache_control?: { | ||
| } | undefined; | ||
| readonly transformations?: { | ||
| readonly oversized_image?: "error" | "downsize" | undefined; | ||
| } | undefined; | ||
| } | { | ||
@@ -547,3 +751,15 @@ readonly type: "document"; | ||
| readonly data: string; | ||
| } | { | ||
| readonly type: "text"; | ||
| readonly media_type: "text/plain"; | ||
| readonly data: string; | ||
| } | { | ||
| readonly type: "url"; | ||
| readonly url: string; | ||
| } | { | ||
| readonly type: "file"; | ||
| readonly file_id: string; | ||
| }; | ||
| readonly title?: string | undefined; | ||
| readonly context?: string | undefined; | ||
| readonly cache_control?: { | ||
@@ -553,2 +769,5 @@ readonly type: "ephemeral"; | ||
| } | undefined; | ||
| readonly citations?: { | ||
| readonly enabled: boolean; | ||
| } | undefined; | ||
| })[]; | ||
@@ -600,2 +819,3 @@ readonly tool_use_id: string; | ||
| readonly thinking: string; | ||
| readonly signature: string; | ||
| readonly cache_control?: { | ||
@@ -605,3 +825,2 @@ readonly type: "ephemeral"; | ||
| } | undefined; | ||
| readonly signature?: string | undefined; | ||
| } | { | ||
@@ -627,2 +846,5 @@ readonly data: string; | ||
| readonly stream: true; | ||
| readonly metadata?: { | ||
| readonly user_id?: string | null | undefined; | ||
| } | undefined; | ||
| readonly tools?: readonly { | ||
@@ -658,7 +880,30 @@ readonly description: string; | ||
| } | undefined; | ||
| readonly service_tier?: "auto" | "standard_only" | undefined; | ||
| readonly container?: string | { | ||
| readonly id?: string | null | undefined; | ||
| readonly skills?: readonly { | ||
| readonly [x: string]: unknown; | ||
| }[] | null | undefined; | ||
| } | null | undefined; | ||
| readonly inference_geo?: string | null | undefined; | ||
| readonly cache_control?: { | ||
| readonly type: "ephemeral"; | ||
| readonly ttl?: "1h" | "5m" | undefined; | ||
| } | undefined; | ||
| readonly output_config?: { | ||
| readonly format?: { | ||
| readonly type: "json_schema"; | ||
| readonly schema: { | ||
| readonly [x: string]: unknown; | ||
| }; | ||
| } | null | undefined; | ||
| readonly effort?: string | undefined; | ||
| } | undefined; | ||
| readonly tool_choice?: { | ||
| readonly type: "auto" | "none" | "any"; | ||
| readonly disable_parallel_tool_use?: boolean | undefined; | ||
| } | { | ||
| readonly type: "tool"; | ||
| readonly name: string; | ||
| readonly disable_parallel_tool_use?: boolean | undefined; | ||
| } | undefined; | ||
@@ -668,6 +913,3 @@ readonly top_p?: number | undefined; | ||
| readonly stop_sequences?: readonly string[] | undefined; | ||
| readonly output_config?: { | ||
| readonly effort?: string | undefined; | ||
| } | undefined; | ||
| }, import("../route/transport/http.js").HttpPrepared<string>>; | ||
| export * as AnthropicMessages from "./anthropic-messages.js"; |
@@ -0,1 +1,2 @@ | ||
| import { Buffer } from "node:buffer"; | ||
| import { Effect, Schema } from "effect"; | ||
@@ -43,19 +44,53 @@ import { Tool } from "@opencode-ai/schema/tool"; | ||
| }); | ||
| // SDK: Base64ImageSource:201 {type:"base64", media_type:"image/jpeg"|... , data}, URLImageSource:3817 {type:"url", url}, FileImageSource:2350 {type:"file", file_id} | ||
| // SDK: ImageBlockParam:2356 {source: Base64|URL|File, cache_control, transformations:2381 {oversized_image?}} | ||
| const AnthropicBase64ImageSource = Schema.Struct({ | ||
| type: Schema.tag("base64"), | ||
| media_type: Schema.String, | ||
| data: Schema.String, | ||
| }); | ||
| const AnthropicURLImageSource = Schema.Struct({ type: Schema.tag("url"), url: Schema.String }); | ||
| const AnthropicFileImageSource = Schema.Struct({ type: Schema.tag("file"), file_id: Schema.String }); | ||
| const AnthropicImageSource = Schema.Union([ | ||
| AnthropicBase64ImageSource, | ||
| AnthropicURLImageSource, | ||
| AnthropicFileImageSource, | ||
| ]); | ||
| const AnthropicImageTransformations = Schema.Struct({ | ||
| oversized_image: Schema.optional(Schema.Literals(["downsize", "error"])), | ||
| }); | ||
| const AnthropicImageBlock = Schema.Struct({ | ||
| type: Schema.tag("image"), | ||
| source: Schema.Struct({ | ||
| type: Schema.tag("base64"), | ||
| media_type: Schema.String, | ||
| data: Schema.String, | ||
| }), | ||
| source: AnthropicImageSource, | ||
| cache_control: Schema.optional(AnthropicCacheControl), | ||
| transformations: Schema.optional(AnthropicImageTransformations), | ||
| }); | ||
| // SDK: Base64PDFSource:209 {type:"base64", media_type:"application/pdf", data}, PlainTextSource:2716 {type:"text", media_type:"text/plain", data}, | ||
| // SDK: URLPDFSource:3823 {type:"url", url}, FileDocumentSource:2344 {type:"file", file_id}, ContentBlockSource:2266 {type:"content", content} | ||
| // SDK: DocumentBlockParam:2297 {source: 5-way union, cache_control, citations, context, title} | ||
| const AnthropicBase64PDFSource = Schema.Struct({ | ||
| type: Schema.tag("base64"), | ||
| media_type: Schema.Literal("application/pdf"), | ||
| data: Schema.String, | ||
| }); | ||
| const AnthropicPlainTextSource = Schema.Struct({ | ||
| type: Schema.tag("text"), | ||
| media_type: Schema.Literal("text/plain"), | ||
| data: Schema.String, | ||
| }); | ||
| const AnthropicURLPDFSource = Schema.Struct({ type: Schema.tag("url"), url: Schema.String }); | ||
| const AnthropicFileDocumentSource = Schema.Struct({ type: Schema.tag("file"), file_id: Schema.String }); | ||
| const AnthropicDocumentSource = Schema.Union([ | ||
| AnthropicBase64PDFSource, | ||
| AnthropicPlainTextSource, | ||
| AnthropicURLPDFSource, | ||
| AnthropicFileDocumentSource, | ||
| ]); | ||
| const AnthropicDocumentBlock = Schema.Struct({ | ||
| type: Schema.tag("document"), | ||
| source: Schema.Struct({ | ||
| type: Schema.tag("base64"), | ||
| media_type: Schema.Literal("application/pdf"), | ||
| data: Schema.String, | ||
| }), | ||
| source: AnthropicDocumentSource, | ||
| cache_control: Schema.optional(AnthropicCacheControl), | ||
| title: Schema.optional(Schema.String), | ||
| context: Schema.optional(Schema.String), | ||
| citations: Schema.optional(Schema.Struct({ enabled: Schema.Boolean })), | ||
| }); | ||
@@ -65,3 +100,3 @@ const AnthropicThinkingBlock = Schema.Struct({ | ||
| thinking: Schema.String, | ||
| signature: Schema.optional(Schema.String), | ||
| signature: Schema.String, | ||
| cache_control: Schema.optional(AnthropicCacheControl), | ||
@@ -144,4 +179,7 @@ }); | ||
| const AnthropicToolChoice = Schema.Union([ | ||
| Schema.Struct({ type: Schema.Literals(["auto", "any", "none"]) }), | ||
| Schema.Struct({ type: Schema.tag("tool"), name: Schema.String }), | ||
| Schema.Struct({ | ||
| type: Schema.Literals(["auto", "any", "none"]), | ||
| disable_parallel_tool_use: Schema.optional(Schema.Boolean), | ||
| }), | ||
| Schema.Struct({ type: Schema.tag("tool"), name: Schema.String, disable_parallel_tool_use: Schema.optional(Schema.Boolean) }), | ||
| ]); | ||
@@ -162,5 +200,21 @@ const AnthropicThinking = Schema.Union([ | ||
| ]); | ||
| // SDK OutputConfig:2684 {effort?: "low"|"medium"|"high"|"xhigh"|"max"|null, format?: JSONOutputFormat:2399} | ||
| const AnthropicJsonOutputFormat = Schema.Struct({ | ||
| type: Schema.Literal("json_schema"), | ||
| schema: JsonObject, | ||
| }); | ||
| const AnthropicOutputConfig = Schema.Struct({ | ||
| effort: Schema.optional(Schema.String), | ||
| format: Schema.optional(Schema.NullOr(AnthropicJsonOutputFormat)), | ||
| }); | ||
| // SDK Metadata:2649 {user_id?: string|null} | ||
| const AnthropicMetadata = Schema.Struct({ user_id: optionalNull(Schema.String) }); | ||
| // SDK MessageCreateParamsContainer:2596 ContainerParams|string; ContainerParams:2172 {id?, skills?} | ||
| const AnthropicContainer = Schema.Union([ | ||
| Schema.String, | ||
| Schema.Struct({ | ||
| id: optionalNull(Schema.String), | ||
| skills: optionalNull(Schema.Array(JsonObject)), | ||
| }), | ||
| ]); | ||
| const AnthropicBodyFields = { | ||
@@ -180,2 +234,8 @@ model: Schema.String, | ||
| output_config: Schema.optional(AnthropicOutputConfig), | ||
| // SDK top-level passthrough: cache_control:4638, container:4643, inference_geo:4649, metadata:4654, service_tier:4670 | ||
| cache_control: Schema.optional(AnthropicCacheControl), | ||
| container: Schema.optional(Schema.NullOr(AnthropicContainer)), | ||
| inference_geo: Schema.optional(Schema.NullOr(Schema.String)), | ||
| metadata: Schema.optional(AnthropicMetadata), | ||
| service_tier: Schema.optional(Schema.Literals(["auto", "standard_only"])), | ||
| }; | ||
@@ -275,6 +335,22 @@ export const AnthropicMessagesBody = Schema.Struct(AnthropicBodyFields); | ||
| const lowerToolChoice = (toolChoice) => ProviderShared.matchToolChoice("Anthropic Messages", toolChoice, { | ||
| auto: () => ({ type: "auto" }), | ||
| auto: () => ({ | ||
| type: "auto", | ||
| ...(toolChoice.disableParallelToolUse === undefined | ||
| ? {} | ||
| : { disable_parallel_tool_use: toolChoice.disableParallelToolUse }), | ||
| }), | ||
| none: () => ({ type: "none" }), | ||
| required: () => ({ type: "any" }), | ||
| tool: (name) => ({ type: "tool", name }), | ||
| required: () => ({ | ||
| type: "any", | ||
| ...(toolChoice.disableParallelToolUse === undefined | ||
| ? {} | ||
| : { disable_parallel_tool_use: toolChoice.disableParallelToolUse }), | ||
| }), | ||
| tool: (name) => ({ | ||
| type: "tool", | ||
| name, | ||
| ...(toolChoice.disableParallelToolUse === undefined | ||
| ? {} | ||
| : { disable_parallel_tool_use: toolChoice.disableParallelToolUse }), | ||
| }), | ||
| }); | ||
@@ -315,3 +391,145 @@ const scrubToolCallID = (id) => id.replace(/[^a-zA-Z0-9_-]/g, "_"); | ||
| }); | ||
| const lowerMedia = Effect.fn("AnthropicMessages.lowerMedia")(function* (part) { | ||
| const fileIdFromMetadata = (metadata) => { | ||
| if (!ProviderShared.isRecord(metadata)) | ||
| return undefined; | ||
| const anthropic = metadata.anthropic; | ||
| if (ProviderShared.isRecord(anthropic)) { | ||
| if (typeof anthropic.file_id === "string") | ||
| return anthropic.file_id; | ||
| if (typeof anthropic.fileId === "string") | ||
| return anthropic.fileId; | ||
| } | ||
| if (typeof metadata.file_id === "string") | ||
| return metadata.file_id; | ||
| if (typeof metadata.fileId === "string") | ||
| return metadata.fileId; | ||
| return undefined; | ||
| }; | ||
| const transformationsFromMetadata = (metadata) => { | ||
| if (!ProviderShared.isRecord(metadata)) | ||
| return undefined; | ||
| const anthropic = ProviderShared.isRecord(metadata.anthropic) ? metadata.anthropic : undefined; | ||
| const raw = anthropic?.transformations ?? metadata.transformations; | ||
| if (ProviderShared.isRecord(raw)) { | ||
| const value = raw.oversized_image; | ||
| if (value === "downsize" || value === "error") | ||
| return { oversized_image: value }; | ||
| } | ||
| if (anthropic && (anthropic.oversized_image === "downsize" || anthropic.oversized_image === "error")) | ||
| return { oversized_image: anthropic.oversized_image }; | ||
| return undefined; | ||
| }; | ||
| const documentTitleFromPart = (part) => { | ||
| if (ProviderShared.isRecord(part.metadata)) { | ||
| const anthropic = part.metadata.anthropic; | ||
| if (ProviderShared.isRecord(anthropic) && typeof anthropic.title === "string") | ||
| return anthropic.title; | ||
| if (typeof part.metadata.title === "string") | ||
| return part.metadata.title; | ||
| } | ||
| if (typeof part.filename === "string" && part.filename.length > 0) | ||
| return part.filename; | ||
| return undefined; | ||
| }; | ||
| const documentContextFromMetadata = (metadata) => { | ||
| if (!ProviderShared.isRecord(metadata)) | ||
| return undefined; | ||
| const anthropic = ProviderShared.isRecord(metadata.anthropic) ? metadata.anthropic : undefined; | ||
| if (anthropic && typeof anthropic.context === "string") | ||
| return anthropic.context; | ||
| if (typeof metadata.context === "string") | ||
| return metadata.context; | ||
| return undefined; | ||
| }; | ||
| const citationsFromMetadata = (metadata) => { | ||
| if (!ProviderShared.isRecord(metadata)) | ||
| return undefined; | ||
| const raw = ProviderShared.isRecord(metadata.anthropic) | ||
| ? (metadata.anthropic.citations ?? metadata.citations) | ||
| : metadata.citations; | ||
| if (ProviderShared.isRecord(raw) && typeof raw.enabled === "boolean") | ||
| return { enabled: raw.enabled }; | ||
| return undefined; | ||
| }; | ||
| const isHttpUrl = (value) => /^https?:\/\//i.test(value.trim()); | ||
| const lowerMedia = Effect.fn("AnthropicMessages.lowerMedia")(function* (part, breakpoints) { | ||
| const mime = part.mediaType.toLowerCase(); | ||
| const cacheControlValue = breakpoints ? cacheControl(breakpoints, part.cache) : undefined; | ||
| const fileId = fileIdFromMetadata(part.metadata); | ||
| // SDK file sources: FileImageSource:2350 / FileDocumentSource:2344 {type:"file", file_id} | ||
| if (fileId) { | ||
| if (mime.startsWith("image/")) | ||
| return { | ||
| type: "image", | ||
| source: { type: "file", file_id: fileId }, | ||
| ...(cacheControlValue === undefined ? {} : { cache_control: cacheControlValue }), | ||
| ...(transformationsFromMetadata(part.metadata) === undefined | ||
| ? {} | ||
| : { transformations: transformationsFromMetadata(part.metadata) }), | ||
| }; | ||
| return { | ||
| type: "document", | ||
| source: { type: "file", file_id: fileId }, | ||
| ...(cacheControlValue === undefined ? {} : { cache_control: cacheControlValue }), | ||
| ...(documentTitleFromPart(part) === undefined ? {} : { title: documentTitleFromPart(part) }), | ||
| ...(documentContextFromMetadata(part.metadata) === undefined | ||
| ? {} | ||
| : { context: documentContextFromMetadata(part.metadata) }), | ||
| ...(citationsFromMetadata(part.metadata) === undefined | ||
| ? {} | ||
| : { citations: citationsFromMetadata(part.metadata) }), | ||
| }; | ||
| } | ||
| const rawString = typeof part.data === "string" ? part.data.trim() : undefined; | ||
| // SDK URL sources: URLImageSource:3817 / URLPDFSource:3823 {type:"url", url} | ||
| if (rawString && isHttpUrl(rawString) && !rawString.startsWith("data:")) { | ||
| if (mime.startsWith("image/")) | ||
| return { | ||
| type: "image", | ||
| source: { type: "url", url: rawString }, | ||
| ...(cacheControlValue === undefined ? {} : { cache_control: cacheControlValue }), | ||
| ...(transformationsFromMetadata(part.metadata) === undefined | ||
| ? {} | ||
| : { transformations: transformationsFromMetadata(part.metadata) }), | ||
| }; | ||
| if (mime === "application/pdf") | ||
| return { | ||
| type: "document", | ||
| source: { type: "url", url: rawString }, | ||
| ...(cacheControlValue === undefined ? {} : { cache_control: cacheControlValue }), | ||
| ...(documentTitleFromPart(part) === undefined ? {} : { title: documentTitleFromPart(part) }), | ||
| ...(documentContextFromMetadata(part.metadata) === undefined | ||
| ? {} | ||
| : { context: documentContextFromMetadata(part.metadata) }), | ||
| ...(citationsFromMetadata(part.metadata) === undefined | ||
| ? {} | ||
| : { citations: citationsFromMetadata(part.metadata) }), | ||
| }; | ||
| } | ||
| // SDK PlainTextSource:2716 {type:"text", media_type:"text/plain", data} | ||
| if (mime === "text/plain") { | ||
| const textData = typeof part.data !== "string" | ||
| ? Buffer.from(part.data).toString("utf8") | ||
| : part.data.startsWith("data:") | ||
| ? (() => { | ||
| const comma = part.data.indexOf(","); | ||
| const payload = comma >= 0 ? part.data.slice(comma + 1) : part.data; | ||
| return part.data.includes(";base64") | ||
| ? Buffer.from(payload, "base64").toString("utf8") | ||
| : decodeURIComponent(payload); | ||
| })() | ||
| : part.data; | ||
| return { | ||
| type: "document", | ||
| source: { type: "text", media_type: "text/plain", data: textData }, | ||
| ...(cacheControlValue === undefined ? {} : { cache_control: cacheControlValue }), | ||
| ...(documentTitleFromPart(part) === undefined ? {} : { title: documentTitleFromPart(part) }), | ||
| ...(documentContextFromMetadata(part.metadata) === undefined | ||
| ? {} | ||
| : { context: documentContextFromMetadata(part.metadata) }), | ||
| ...(citationsFromMetadata(part.metadata) === undefined | ||
| ? {} | ||
| : { citations: citationsFromMetadata(part.metadata) }), | ||
| }; | ||
| } | ||
| const media = ProviderShared.normalizeMedia(part); | ||
@@ -326,2 +544,10 @@ if (media.mime === "application/pdf") | ||
| }, | ||
| ...(cacheControlValue === undefined ? {} : { cache_control: cacheControlValue }), | ||
| ...(documentTitleFromPart(part) === undefined ? {} : { title: documentTitleFromPart(part) }), | ||
| ...(documentContextFromMetadata(part.metadata) === undefined | ||
| ? {} | ||
| : { context: documentContextFromMetadata(part.metadata) }), | ||
| ...(citationsFromMetadata(part.metadata) === undefined | ||
| ? {} | ||
| : { citations: citationsFromMetadata(part.metadata) }), | ||
| }; | ||
@@ -337,2 +563,6 @@ if (!media.mime.startsWith("image/")) | ||
| }, | ||
| ...(cacheControlValue === undefined ? {} : { cache_control: cacheControlValue }), | ||
| ...(transformationsFromMetadata(part.metadata) === undefined | ||
| ? {} | ||
| : { transformations: transformationsFromMetadata(part.metadata) }), | ||
| }; | ||
@@ -356,2 +586,20 @@ }); | ||
| }); | ||
| const requireThinkingSignature = (request) => { | ||
| if (request.model.compatibility?.requireSignature !== undefined) | ||
| return request.model.compatibility.requireSignature; | ||
| const provider = request.model.provider.toLowerCase(); | ||
| const model = request.model.id.toLowerCase(); | ||
| const baseURL = (request.model.route.endpoint.baseURL ?? "").toLowerCase(); | ||
| if (provider === "kimi-for-coding" || | ||
| provider === "moonshotai" || | ||
| provider === "moonshotai-cn" || | ||
| model.startsWith("kimi-") || | ||
| baseURL.includes("api.kimi.com/coding") || | ||
| baseURL.includes("api.moonshot.ai/anthropic") || | ||
| baseURL.includes("api.moonshot.cn/anthropic")) | ||
| return false; | ||
| if (provider.includes("xiaomi") || model.includes("mimo") || baseURL.includes("xiaomimimo.com")) | ||
| return false; | ||
| return true; | ||
| }; | ||
| // Mid-conversation system messages became available with Opus 4.8 and version | ||
@@ -434,3 +682,3 @@ // 5 of the other supported Claude families. Treat later family versions as | ||
| if (part.type === "media") { | ||
| content.push(yield* lowerMedia(part)); | ||
| content.push(yield* lowerMedia(part, breakpoints)); | ||
| continue; | ||
@@ -451,5 +699,4 @@ } | ||
| if (part.type === "reasoning") { | ||
| // Mirrors Vercel's @ai-sdk/anthropic: a signature marks visible | ||
| // thinking; only signature-less parts carrying redactedData | ||
| // round-trip as opaque redacted_thinking blocks. | ||
| // A signature marks visible thinking; only signature-less parts carrying | ||
| // redactedData round-trip as opaque redacted_thinking blocks. | ||
| const signature = part.encrypted ?? signatureFromMetadata(part.providerMetadata); | ||
@@ -461,2 +708,19 @@ const redactedData = redactedDataFromMetadata(part.providerMetadata); | ||
| } | ||
| if (typeof signature !== "string" || signature.trim().length === 0) { | ||
| if (part.text.trim().length === 0) | ||
| continue; | ||
| if (!requireThinkingSignature(request)) { | ||
| content.push({ type: "thinking", thinking: part.text, signature: "" }); | ||
| continue; | ||
| } | ||
| // Without a signature this cannot be a valid thinking block per | ||
| // the SDK ThinkingBlockParam:3217 — demote to text so the | ||
| // conversation remains sendable. | ||
| content.push({ | ||
| type: "text", | ||
| text: part.text, | ||
| cache_control: cacheControl(breakpoints, part.cache), | ||
| }); | ||
| continue; | ||
| } | ||
| content.push({ type: "thinking", thinking: part.text, signature }); | ||
@@ -500,5 +764,48 @@ continue; | ||
| const input = request.providerOptions; | ||
| const rawServiceTier = input?.service_tier ?? input?.serviceTier; | ||
| const service_tier = rawServiceTier === "auto" || rawServiceTier === "standard_only" | ||
| ? rawServiceTier | ||
| : undefined; | ||
| const rawMetadata = input?.metadata; | ||
| const metadata = ProviderShared.isRecord(rawMetadata) && | ||
| (typeof rawMetadata.user_id === "string" || rawMetadata.user_id === null) | ||
| ? { user_id: rawMetadata.user_id } | ||
| : undefined; | ||
| const container = typeof input?.container === "string" || | ||
| ProviderShared.isRecord(input?.container) | ||
| ? input.container | ||
| : undefined; | ||
| const rawInferenceGeo = input?.inference_geo ?? | ||
| input?.inferenceGeo; | ||
| const inference_geo = typeof rawInferenceGeo === "string" ? rawInferenceGeo : undefined; | ||
| const rawCacheControl = input?.cache_control ?? | ||
| input?.cacheControl; | ||
| const cache_control = ProviderShared.isRecord(rawCacheControl) && rawCacheControl.type === "ephemeral" | ||
| ? rawCacheControl | ||
| : undefined; | ||
| const rawOutputConfig = input?.output_config ?? | ||
| input?.outputConfig; | ||
| const outputConfigEffort = typeof input?.effort === "string" | ||
| ? input.effort | ||
| : ProviderShared.isRecord(rawOutputConfig) && typeof rawOutputConfig.effort === "string" | ||
| ? rawOutputConfig.effort | ||
| : undefined; | ||
| const outputConfigFormat = ProviderShared.isRecord(rawOutputConfig) && ProviderShared.isRecord(rawOutputConfig.format) | ||
| ? rawOutputConfig.format | ||
| : undefined; | ||
| const output_config = outputConfigEffort === undefined && outputConfigFormat === undefined | ||
| ? undefined | ||
| : { | ||
| ...(outputConfigEffort === undefined ? {} : { effort: outputConfigEffort }), | ||
| ...(outputConfigFormat === undefined ? {} : { format: outputConfigFormat }), | ||
| }; | ||
| return { | ||
| thinking: yield* resolveThinking(input?.thinking), | ||
| effort: typeof input?.effort === "string" ? input.effort : undefined, | ||
| effort: outputConfigEffort, | ||
| output_config, | ||
| service_tier, | ||
| metadata, | ||
| container, | ||
| inference_geo, | ||
| cache_control, | ||
| }; | ||
@@ -564,3 +871,9 @@ }); | ||
| thinking: options.thinking, | ||
| output_config: options.effort === undefined ? undefined : { effort: options.effort }, | ||
| output_config: options.output_config, | ||
| // top-level passthrough per SDK MessageCreateParamsBase:4638,4643,4649,4654,4670 | ||
| cache_control: options.cache_control, | ||
| container: options.container, | ||
| inference_geo: options.inference_geo, | ||
| metadata: options.metadata, | ||
| service_tier: options.service_tier, | ||
| }; | ||
@@ -907,3 +1220,3 @@ }); | ||
| protocol, | ||
| endpoint: Endpoint.path(PATH, { baseURL: DEFAULT_BASE_URL }), | ||
| endpoint: Endpoint.path((input) => (input.request.model.provider === "anthropic" ? `${PATH}?beta=true` : PATH), { baseURL: DEFAULT_BASE_URL }), | ||
| auth: Auth.none, | ||
@@ -910,0 +1223,0 @@ framing, |
@@ -142,2 +142,3 @@ import { Schema } from "effect"; | ||
| }[] | undefined; | ||
| readonly serviceTier?: string | undefined; | ||
| readonly toolConfig?: { | ||
@@ -154,3 +155,2 @@ readonly functionCallingConfig: { | ||
| }[] | undefined; | ||
| readonly serviceTier?: string | undefined; | ||
| readonly labels?: { | ||
@@ -182,31 +182,3 @@ readonly [x: string]: string; | ||
| readonly content?: { | ||
| readonly parts?: readonly ({ | ||
| readonly inlineData: { | ||
| readonly mimeType: string; | ||
| readonly data: string; | ||
| }; | ||
| } | { | ||
| readonly text: string; | ||
| readonly thought?: boolean | null | undefined; | ||
| readonly thoughtSignature?: string | null | undefined; | ||
| } | { | ||
| readonly functionCall: { | ||
| readonly name: string; | ||
| readonly id?: string | null | undefined; | ||
| readonly args?: unknown; | ||
| }; | ||
| readonly thoughtSignature?: string | null | undefined; | ||
| } | { | ||
| readonly functionResponse: { | ||
| readonly name: string; | ||
| readonly response: unknown; | ||
| readonly id?: string | undefined; | ||
| readonly parts?: readonly { | ||
| readonly inlineData: { | ||
| readonly mimeType: string; | ||
| readonly data: string; | ||
| }; | ||
| }[] | undefined; | ||
| }; | ||
| })[] | null | undefined; | ||
| readonly parts?: readonly unknown[] | null | undefined; | ||
| readonly role?: "model" | "user" | null | undefined; | ||
@@ -230,2 +202,3 @@ } | null | undefined; | ||
| }, { | ||
| route: string; | ||
| hasToolCalls: boolean; | ||
@@ -276,2 +249,3 @@ lifecycle: Lifecycle.State; | ||
| }[] | undefined; | ||
| readonly serviceTier?: string | undefined; | ||
| readonly toolConfig?: { | ||
@@ -288,3 +262,2 @@ readonly functionCallingConfig: { | ||
| }[] | undefined; | ||
| readonly serviceTier?: string | undefined; | ||
| readonly labels?: { | ||
@@ -291,0 +264,0 @@ readonly [x: string]: string; |
@@ -1,2 +0,2 @@ | ||
| import { Effect, Schema } from "effect"; | ||
| import { Effect, Option, Schema } from "effect"; | ||
| import { Tool } from "@opencode-ai/schema/tool"; | ||
@@ -79,2 +79,3 @@ import { Route } from "../route/client.js"; | ||
| ]); | ||
| const decodeGeminiContentPart = Schema.decodeUnknownOption(GeminiContentPart); | ||
| const GeminiContent = Schema.Struct({ | ||
@@ -84,2 +85,6 @@ role: optionalNull(Schema.Literals(["user", "model"])), | ||
| }); | ||
| const GeminiResponseContent = Schema.Struct({ | ||
| role: optionalNull(Schema.Literals(["user", "model"])), | ||
| parts: optionalNull(Schema.Array(Schema.Unknown)), | ||
| }); | ||
| const GeminiSystemInstruction = Schema.Struct({ | ||
@@ -142,3 +147,3 @@ parts: Schema.Array(Schema.Struct({ text: Schema.String })), | ||
| const GeminiCandidate = Schema.Struct({ | ||
| content: optionalNull(GeminiContent), | ||
| content: optionalNull(GeminiResponseContent), | ||
| finishReason: optionalNull(Schema.String), | ||
@@ -491,3 +496,13 @@ }); | ||
| const seenCallIds = new Set(nextState.seenCallIds); | ||
| for (const part of candidate.content.parts ?? []) { | ||
| for (const input of candidate.content.parts ?? []) { | ||
| if (ProviderShared.isRecord(input) && | ||
| !("text" in input) && | ||
| !("inlineData" in input) && | ||
| !("functionCall" in input) && | ||
| !("functionResponse" in input)) | ||
| continue; | ||
| const decoded = decodeGeminiContentPart(input); | ||
| if (Option.isNone(decoded)) | ||
| return Effect.fail(ProviderShared.eventError(ADAPTER, `Invalid ${state.route} stream event`, ProviderShared.encodeJson(event))); | ||
| const part = decoded.value; | ||
| const signature = "thoughtSignature" in part && part.thoughtSignature ? part.thoughtSignature : undefined; | ||
@@ -560,3 +575,7 @@ // Gemini attaches replay signatures to thought parts, visible text, or function calls; | ||
| event: Protocol.jsonEvent(GeminiEvent), | ||
| initial: () => ({ hasToolCalls: false, lifecycle: Lifecycle.initial() }), | ||
| initial: (request) => ({ | ||
| route: `${request.model.provider}/${request.model.route.id}`, | ||
| hasToolCalls: false, | ||
| lifecycle: Lifecycle.initial(), | ||
| }), | ||
| step, | ||
@@ -563,0 +582,0 @@ onHalt: finish, |
@@ -437,2 +437,3 @@ import { Effect, Schema } from "effect"; | ||
| export type Event = Schema.Schema.Type<typeof Event>; | ||
| export type ItemKind = "message" | "reasoning" | "function-call" | "reference"; | ||
| export interface Extension { | ||
@@ -446,2 +447,3 @@ readonly id: string; | ||
| }) => MediaInput | undefined; | ||
| readonly acceptsItemID?: (kind: ItemKind, id: string) => boolean; | ||
| } | ||
@@ -464,2 +466,3 @@ export interface ParserState { | ||
| readonly summaryParts: Readonly<Record<number, ReasoningSummaryStatus>>; | ||
| readonly deltaIndexes: ReadonlySet<number>; | ||
| } | ||
@@ -481,2 +484,3 @@ export declare const lowerTool: (protocolName: string, tool: ToolDefinition, inputSchema: { | ||
| }, AIError, never>; | ||
| export declare const resolveParallelToolCalls: (request: LLMRequest) => boolean | undefined; | ||
| export declare const fromRequestWithExtension: (request: LLMRequest, extension: Extension) => Effect.Effect<{ | ||
@@ -624,2 +628,3 @@ truncation?: "auto" | "disabled" | undefined; | ||
| readonly temperature?: number | undefined; | ||
| readonly service_tier?: OpenResponsesOptions.ServiceTier | undefined; | ||
| readonly tool_choice?: "required" | "auto" | "none" | { | ||
@@ -648,3 +653,2 @@ readonly type: "function"; | ||
| readonly top_logprobs?: number | undefined; | ||
| readonly service_tier?: OpenResponsesOptions.ServiceTier | undefined; | ||
| readonly max_output_tokens?: number | undefined; | ||
@@ -658,3 +662,3 @@ readonly max_tool_calls?: number | undefined; | ||
| export declare const onReasoningDelta: (state: ParserState, event: Event, itemID: string) => StepResult; | ||
| export declare const onReasoningDone: (state: ParserState, _event: Event) => StepResult; | ||
| export declare const onReasoningDone: (state: ParserState, event: Event, itemID: string) => StepResult; | ||
| export declare const providerFailure: (id: string, event: Event, fallback: string) => AIError; | ||
@@ -937,2 +941,3 @@ export declare const step: (state: ParserState, event: Event) => AIError | Effect.Effect<StepResult, never, never> | Effect.Effect<[ParserState, readonly ({ | ||
| readonly temperature?: number | undefined; | ||
| readonly service_tier?: OpenResponsesOptions.ServiceTier | undefined; | ||
| readonly tool_choice?: "required" | "auto" | "none" | { | ||
@@ -961,3 +966,2 @@ readonly type: "function"; | ||
| readonly top_logprobs?: number | undefined; | ||
| readonly service_tier?: OpenResponsesOptions.ServiceTier | undefined; | ||
| readonly max_output_tokens?: number | undefined; | ||
@@ -1110,2 +1114,3 @@ readonly max_tool_calls?: number | undefined; | ||
| readonly temperature?: number | undefined; | ||
| readonly service_tier?: OpenResponsesOptions.ServiceTier | undefined; | ||
| readonly tool_choice?: "required" | "auto" | "none" | { | ||
@@ -1134,3 +1139,2 @@ readonly type: "function"; | ||
| readonly top_logprobs?: number | undefined; | ||
| readonly service_tier?: OpenResponsesOptions.ServiceTier | undefined; | ||
| readonly max_output_tokens?: number | undefined; | ||
@@ -1137,0 +1141,0 @@ readonly max_tool_calls?: number | undefined; |
@@ -248,13 +248,21 @@ import { Effect, Schema } from "effect"; | ||
| }); | ||
| // Servers validate item ids on replayed history, and a malformed or oversized | ||
| // id can fail an otherwise valid request. Only server-issued tokens are worth | ||
| // resending; anything else is treated as absent so the item is resent without | ||
| // an id (or skipped, for items that cannot be expressed without one). | ||
| const ITEM_ID_PATTERN = /^[A-Za-z0-9_-]{1,64}$/; | ||
| const itemID = (providerMetadata, providerMetadataKey) => { | ||
| const metadata = providerMetadata?.[providerMetadataKey]; | ||
| return ProviderShared.isRecord(metadata) && typeof metadata.itemId === "string" && metadata.itemId.length > 0 | ||
| return ProviderShared.isRecord(metadata) && | ||
| typeof metadata.itemId === "string" && | ||
| ITEM_ID_PATTERN.test(metadata.itemId) | ||
| ? metadata.itemId | ||
| : undefined; | ||
| }; | ||
| const lowerToolCall = (part, providerMetadataKey) => { | ||
| const acceptsItemID = (extension, kind, id) => id !== undefined && (extension.acceptsItemID?.(kind, id) ?? true); | ||
| const lowerToolCall = (part, providerMetadataKey, extension) => { | ||
| const id = itemID(part.providerMetadata, providerMetadataKey); | ||
| return { | ||
| type: "function_call", | ||
| ...(id ? { id } : {}), | ||
| ...(acceptsItemID(extension, "function-call", id) ? { id } : {}), | ||
| call_id: part.id, | ||
@@ -265,6 +273,6 @@ name: part.name, | ||
| }; | ||
| const lowerReasoning = (part, providerMetadataKey) => { | ||
| const lowerReasoning = (part, providerMetadataKey, extension) => { | ||
| const metadata = part.providerMetadata?.[providerMetadataKey]; | ||
| const id = itemID(part.providerMetadata, providerMetadataKey); | ||
| if (!ProviderShared.isRecord(metadata) || !id) | ||
| if (!ProviderShared.isRecord(metadata) || !acceptsItemID(extension, "reasoning", id)) | ||
| return undefined; | ||
@@ -364,3 +372,4 @@ const encryptedContent = typeof metadata.reasoningEncryptedContent === "string" || metadata.reasoningEncryptedContent === null | ||
| const metadata = part.providerMetadata?.[providerMetadataKey]; | ||
| const id = itemID(part.providerMetadata, providerMetadataKey); | ||
| const rawID = itemID(part.providerMetadata, providerMetadataKey); | ||
| const id = acceptsItemID(extension, "message", rawID) ? rawID : undefined; | ||
| const phase = ProviderShared.isRecord(metadata) ? messagePhase(metadata.phase) : undefined; | ||
@@ -390,3 +399,3 @@ const group = groups.at(-1); | ||
| flushText(); | ||
| const reasoning = lowerReasoning(part, providerMetadataKey); | ||
| const reasoning = lowerReasoning(part, providerMetadataKey, extension); | ||
| if (!reasoning) | ||
@@ -415,3 +424,3 @@ continue; | ||
| continue; | ||
| input.push(lowerToolCall(part, providerMetadataKey)); | ||
| input.push(lowerToolCall(part, providerMetadataKey, extension)); | ||
| continue; | ||
@@ -422,4 +431,5 @@ } | ||
| const id = itemID(part.providerMetadata, providerMetadataKey); | ||
| if (store !== false && id && !hostedToolReferences.has(id)) | ||
| input.push({ type: "item_reference", id }); | ||
| const reference = acceptsItemID(extension, "reference", id) ? id : undefined; | ||
| if (store !== false && reference && !hostedToolReferences.has(reference)) | ||
| input.push({ type: "item_reference", id: reference }); | ||
| if (store === false) { | ||
@@ -436,4 +446,4 @@ // The server is not storing this exchange, so the tool outcome has to | ||
| } | ||
| if (id) | ||
| hostedToolReferences.add(id); | ||
| if (reference) | ||
| hostedToolReferences.add(reference); | ||
| continue; | ||
@@ -471,2 +481,3 @@ } | ||
| const cacheKey = ProviderShared.clampPromptCacheKey(request.promptCacheKey); | ||
| const parallelToolCalls = resolveParallelToolCalls(request); | ||
| return { | ||
@@ -489,6 +500,13 @@ ...(options.instructions ? { instructions: options.instructions } : {}), | ||
| ...(options.maxToolCalls !== undefined ? { max_tool_calls: options.maxToolCalls } : {}), | ||
| ...(options.parallelToolCalls !== undefined ? { parallel_tool_calls: options.parallelToolCalls } : {}), | ||
| ...(parallelToolCalls !== undefined ? { parallel_tool_calls: parallelToolCalls } : {}), | ||
| ...(options.truncation ? { truncation: options.truncation } : {}), | ||
| }; | ||
| }; | ||
| export const resolveParallelToolCalls = (request) => { | ||
| const configured = OpenResponsesOptions.resolve(request).parallelToolCalls; | ||
| if (configured !== undefined) | ||
| return configured; | ||
| const disabled = request.toolChoice?.disableParallelToolUse; | ||
| return disabled === undefined ? undefined : !disabled; | ||
| }; | ||
| const allowedToolChoice = (request) => { | ||
@@ -579,3 +597,3 @@ const allowed = OpenResponsesOptions.resolve(request).allowedTools; | ||
| const onOutputTextDelta = (state, event, id) => { | ||
| if (!event.delta) | ||
| if (!event.delta || !state.messageItems.has(id)) | ||
| return [state, NO_EVENTS]; | ||
@@ -598,10 +616,15 @@ const events = []; | ||
| export const onReasoningDelta = (state, event, itemID) => { | ||
| if (!event.delta) | ||
| const item = state.reasoningItems[itemID]; | ||
| if (!event.delta || !item) | ||
| return [state, NO_EVENTS]; | ||
| const index = event.summary_index ?? 0; | ||
| const events = []; | ||
| const id = event.summary_index !== undefined || state.reasoningItems[itemID] ? `${itemID}:${event.summary_index ?? 0}` : itemID; | ||
| return [ | ||
| { | ||
| ...state, | ||
| lifecycle: Lifecycle.reasoningDelta(state.lifecycle, events, id, event.delta), | ||
| lifecycle: Lifecycle.reasoningDelta(state.lifecycle, events, `${itemID}:${index}`, event.delta), | ||
| reasoningItems: { | ||
| ...state.reasoningItems, | ||
| [itemID]: { ...item, deltaIndexes: new Set([...item.deltaIndexes, index]) }, | ||
| }, | ||
| }, | ||
@@ -611,3 +634,14 @@ events, | ||
| }; | ||
| export const onReasoningDone = (state, _event) => [state, NO_EVENTS]; | ||
| // Some compatible gateways emit a reasoning final without streaming any | ||
| // deltas, mirroring `response.output_text.done`. Reconcile the complete text | ||
| // as a single delta unless that summary index already streamed one. | ||
| export const onReasoningDone = (state, event, itemID) => { | ||
| const item = state.reasoningItems[itemID]; | ||
| if (!item || typeof event.text !== "string") | ||
| return [state, NO_EVENTS]; | ||
| const index = event.summary_index ?? 0; | ||
| if (item.deltaIndexes.has(index)) | ||
| return [state, NO_EVENTS]; | ||
| return onReasoningDelta(state, { ...event, delta: event.text }, itemID); | ||
| }; | ||
| const reasoningMetadata = (state, item) => providerMetadata(state, { itemId: item.id, reasoningEncryptedContent: item.encrypted_content ?? null }); | ||
@@ -647,3 +681,7 @@ // Responses APIs stream reasoning items in a stable order: | ||
| ...state.reasoningItems, | ||
| [item.id]: { encryptedContent: item.encrypted_content, summaryParts: { 0: "active" } }, | ||
| [item.id]: { | ||
| encryptedContent: item.encrypted_content, | ||
| summaryParts: { 0: "active" }, | ||
| deltaIndexes: new Set(), | ||
| }, | ||
| }, | ||
@@ -679,19 +717,7 @@ }, | ||
| return [state, NO_EVENTS]; | ||
| const item = state.reasoningItems[event.item_id] ?? { encryptedContent: undefined, summaryParts: {} }; | ||
| if (event.summary_index === 0) { | ||
| if (state.reasoningItems[event.item_id]) | ||
| return [state, NO_EVENTS]; | ||
| const events = []; | ||
| return [ | ||
| { | ||
| ...state, | ||
| lifecycle: Lifecycle.reasoningStart(state.lifecycle, events, `${event.item_id}:0`, providerMetadata(state, { itemId: event.item_id, reasoningEncryptedContent: null })), | ||
| reasoningItems: { | ||
| ...state.reasoningItems, | ||
| [event.item_id]: { ...item, summaryParts: { 0: "active" } }, | ||
| }, | ||
| }, | ||
| events, | ||
| ]; | ||
| } | ||
| const item = state.reasoningItems[event.item_id]; | ||
| if (!item) | ||
| return [state, NO_EVENTS]; | ||
| if (event.summary_index === 0) | ||
| return [state, NO_EVENTS]; | ||
| const events = []; | ||
@@ -747,3 +773,3 @@ const closed = Object.entries(item.summaryParts) | ||
| const onFunctionCallArgumentsDelta = Effect.fn("OpenResponses.onFunctionCallArgumentsDelta")(function* (state, event) { | ||
| if (!event.item_id || !event.delta) | ||
| if (!event.item_id || !event.delta || !state.tools[event.item_id]) | ||
| return [state, NO_EVENTS]; | ||
@@ -915,2 +941,9 @@ const result = ToolStream.appendExisting(state.id, state.tools, event.item_id, event.delta, `${state.name} tool argument delta is missing its tool call`); | ||
| } | ||
| if (event.type === "response.reasoning.done" || | ||
| event.type === "response.reasoning_summary_text.done" || | ||
| event.type === "response.reasoning_text.done") { | ||
| if (!event.item_id) | ||
| return ProviderShared.eventError(state.id, `${event.type} is missing item_id`); | ||
| return Effect.succeed(onReasoningDone(state, event, event.item_id)); | ||
| } | ||
| if (event.type === "response.reasoning_summary_part.added") | ||
@@ -930,3 +963,5 @@ return event.item_id | ||
| if (event.type === "response.function_call_arguments.delta") | ||
| return onFunctionCallArgumentsDelta(state, event); | ||
| return event.item_id | ||
| ? onFunctionCallArgumentsDelta(state, event) | ||
| : ProviderShared.eventError(state.id, `${event.type} is missing item_id`); | ||
| if (event.type === "response.output_item.done") { | ||
@@ -933,0 +968,0 @@ if (event.item?.type === "message" && !event.item.id) |
@@ -80,2 +80,3 @@ import { Effect, Schema } from "effect"; | ||
| readonly parameters: Schema.$Record<Schema.String, Schema.Unknown>; | ||
| readonly strict: Schema.optional<Schema.Boolean>; | ||
| }>; | ||
@@ -100,2 +101,3 @@ readonly cache_control: Schema.optional<Schema.Struct<{ | ||
| reasoning_effort: Schema.optional<Schema.declare<import("./utils/open-responses-options.js").ReasoningEffort, import("./utils/open-responses-options.js").ReasoningEffort>>; | ||
| tool_stream: Schema.optional<Schema.Boolean>; | ||
| max_completion_tokens: Schema.optional<Schema.Number>; | ||
@@ -176,2 +178,3 @@ max_tokens: Schema.optional<Schema.Number>; | ||
| readonly parameters: Schema.$Record<Schema.String, Schema.Unknown>; | ||
| readonly strict: Schema.optional<Schema.Boolean>; | ||
| }>; | ||
@@ -196,2 +199,3 @@ readonly cache_control: Schema.optional<Schema.Struct<{ | ||
| reasoning_effort: Schema.optional<Schema.declare<import("./utils/open-responses-options.js").ReasoningEffort, import("./utils/open-responses-options.js").ReasoningEffort>>; | ||
| tool_stream: Schema.optional<Schema.Boolean>; | ||
| max_completion_tokens: Schema.optional<Schema.Number>; | ||
@@ -299,2 +303,6 @@ max_tokens: Schema.optional<Schema.Number>; | ||
| max_completion_tokens: number | undefined; | ||
| tool_stream?: boolean | undefined; | ||
| stream_options?: { | ||
| include_usage: boolean; | ||
| } | undefined; | ||
| model: string & import("effect/Brand").Brand<"AI.ModelID">; | ||
@@ -362,7 +370,8 @@ messages: ({ | ||
| readonly function: { | ||
| readonly description: string; | ||
| readonly name: string; | ||
| readonly description: string; | ||
| readonly parameters: { | ||
| readonly [x: string]: unknown; | ||
| }; | ||
| readonly strict?: boolean | undefined; | ||
| }; | ||
@@ -382,5 +391,2 @@ readonly type: "function"; | ||
| stream: true; | ||
| stream_options: { | ||
| include_usage: boolean; | ||
| }; | ||
| } | { | ||
@@ -397,2 +403,6 @@ reasoning_effort?: import("./utils/open-responses-options.js").ReasoningEffort | undefined; | ||
| max_tokens: number | undefined; | ||
| tool_stream?: boolean | undefined; | ||
| stream_options?: { | ||
| include_usage: boolean; | ||
| } | undefined; | ||
| model: string & import("effect/Brand").Brand<"AI.ModelID">; | ||
@@ -460,7 +470,8 @@ messages: ({ | ||
| readonly function: { | ||
| readonly description: string; | ||
| readonly name: string; | ||
| readonly description: string; | ||
| readonly parameters: { | ||
| readonly [x: string]: unknown; | ||
| }; | ||
| readonly strict?: boolean | undefined; | ||
| }; | ||
@@ -480,5 +491,2 @@ readonly type: "function"; | ||
| stream: true; | ||
| stream_options: { | ||
| include_usage: boolean; | ||
| }; | ||
| }, AIError, never>; | ||
@@ -557,7 +565,8 @@ /** | ||
| readonly function: { | ||
| readonly description: string; | ||
| readonly name: string; | ||
| readonly description: string; | ||
| readonly parameters: { | ||
| readonly [x: string]: unknown; | ||
| }; | ||
| readonly strict?: boolean | undefined; | ||
| }; | ||
@@ -586,2 +595,3 @@ readonly type: "function"; | ||
| readonly reasoning_effort?: import("./utils/open-responses-options.js").ReasoningEffort | undefined; | ||
| readonly tool_stream?: boolean | undefined; | ||
| readonly frequency_penalty?: number | undefined; | ||
@@ -721,7 +731,8 @@ readonly presence_penalty?: number | undefined; | ||
| readonly function: { | ||
| readonly description: string; | ||
| readonly name: string; | ||
| readonly description: string; | ||
| readonly parameters: { | ||
| readonly [x: string]: unknown; | ||
| }; | ||
| readonly strict?: boolean | undefined; | ||
| }; | ||
@@ -750,2 +761,3 @@ readonly type: "function"; | ||
| readonly reasoning_effort?: import("./utils/open-responses-options.js").ReasoningEffort | undefined; | ||
| readonly tool_stream?: boolean | undefined; | ||
| readonly frequency_penalty?: number | undefined; | ||
@@ -820,7 +832,8 @@ readonly presence_penalty?: number | undefined; | ||
| readonly function: { | ||
| readonly description: string; | ||
| readonly name: string; | ||
| readonly description: string; | ||
| readonly parameters: { | ||
| readonly [x: string]: unknown; | ||
| }; | ||
| readonly strict?: boolean | undefined; | ||
| }; | ||
@@ -849,2 +862,3 @@ readonly type: "function"; | ||
| readonly reasoning_effort?: import("./utils/open-responses-options.js").ReasoningEffort | undefined; | ||
| readonly tool_stream?: boolean | undefined; | ||
| readonly frequency_penalty?: number | undefined; | ||
@@ -851,0 +865,0 @@ readonly presence_penalty?: number | undefined; |
@@ -36,3 +36,8 @@ import { Effect, Schema } from "effect"; | ||
| type: Schema.tag("function"), | ||
| function: OpenAIChatFunction, | ||
| function: Schema.Struct({ | ||
| name: Schema.String, | ||
| description: Schema.String, | ||
| parameters: JsonObject, | ||
| strict: Schema.optional(Schema.Boolean), | ||
| }), | ||
| cache_control: Schema.optional(OpenAIChatCacheControl), | ||
@@ -107,2 +112,3 @@ }); | ||
| reasoning_effort: Schema.optional(OpenAIOptions.OpenAIReasoningEffort), | ||
| tool_stream: Schema.optional(Schema.Boolean), | ||
| max_completion_tokens: Schema.optional(Schema.Number), | ||
@@ -175,3 +181,3 @@ max_tokens: Schema.optional(Schema.Number), | ||
| }); | ||
| const lowerTool = (tool, inputSchema, options) => ({ | ||
| const lowerTool = (tool, inputSchema, options, supportsStrictMode) => ({ | ||
| type: "function", | ||
@@ -182,2 +188,3 @@ function: { | ||
| parameters: inputSchema, | ||
| ...(supportsStrictMode ? { strict: false } : {}), | ||
| }, | ||
@@ -420,7 +427,106 @@ cache_control: options.cacheControl?.(tool.cache), | ||
| }; | ||
| const lowerOptions = (request) => { | ||
| // Derive `max_tokens` vs `max_completion_tokens` from provider/baseURL when | ||
| // explicit `compatibility.maxTokensField` is not set. Aligned with | ||
| // models.dev provider naming: DeepSeek, Moonshot AI, Together AI, ZAI | ||
| // (Zhipu + Coding Plan variants), Nvidia, Cerebras, Chutes, etc. still | ||
| // require `max_tokens`. | ||
| const detectMaxTokensField = (provider, baseURL) => { | ||
| const p = provider.toLowerCase(); | ||
| const url = (baseURL ?? "").toLowerCase(); | ||
| if (p === "deepseek" || | ||
| url.includes("deepseek.com") || | ||
| p === "moonshotai" || | ||
| url.includes("api.moonshot.ai") || | ||
| p === "togetherai" || | ||
| url.includes("api.together.") || | ||
| p === "zai" || | ||
| p === "zai-coding-plan" || | ||
| p === "zhipuai" || | ||
| p === "zhipuai-coding-plan" || | ||
| url.includes("api.z.ai") || | ||
| url.includes("open.bigmodel.cn") || | ||
| p === "nvidia" || | ||
| url.includes("integrate.api.nvidia.com") || | ||
| p === "cerebras" || | ||
| url.includes("cerebras.ai") || | ||
| url.includes("llm.chutes.ai") || | ||
| p === "chutes" || | ||
| p === "cloudflare-ai-gateway" || | ||
| url.includes("gateway.ai.cloudflare.com") || | ||
| p === "cloudflare-workers-ai" || | ||
| url.includes("api.cloudflare.com")) | ||
| return "max_tokens"; | ||
| return "max_completion_tokens"; | ||
| }; | ||
| const detectSupportsStore = (provider, baseURL) => { | ||
| const p = provider.toLowerCase(); | ||
| const url = (baseURL ?? "").toLowerCase(); | ||
| const isNvidia = p === "nvidia" || url.includes("integrate.api.nvidia.com"); | ||
| const isMoonshot = p === "moonshotai" || p === "moonshotai-cn" || url.includes("api.moonshot."); | ||
| const isTogether = p === "togetherai" || p === "together" || url.includes("api.together."); | ||
| const isZai = p === "zai" || | ||
| p === "zai-coding-plan" || | ||
| p === "zhipuai" || | ||
| p === "zhipuai-coding-plan" || | ||
| url.includes("api.z.ai") || | ||
| url.includes("open.bigmodel.cn"); | ||
| const isDeepSeek = p === "deepseek" || url.includes("deepseek.com"); | ||
| const isCerebras = p === "cerebras" || url.includes("cerebras.ai"); | ||
| const isXai = p === "xai" || url.includes("api.x.ai"); | ||
| const isChutes = p === "chutes" || url.includes("chutes.ai"); | ||
| const isCloudflareWorkersAI = p === "cloudflare-workers-ai" || url.includes("api.cloudflare.com"); | ||
| const isCloudflareAiGateway = p === "cloudflare-ai-gateway" || url.includes("gateway.ai.cloudflare.com"); | ||
| const isVercelAiGateway = p === "vercel-ai-gateway" || url.includes("ai-gateway.vercel.sh") || url.includes("vercel.sh"); | ||
| const isAntLing = p === "ant-ling" || url.includes("api.ant-ling.com"); | ||
| const isOpencode = p === "opencode" || url.includes("opencode.ai"); | ||
| const isNonStandard = isNvidia || | ||
| isCerebras || | ||
| isXai || | ||
| isTogether || | ||
| isChutes || | ||
| isDeepSeek || | ||
| isZai || | ||
| isMoonshot || | ||
| isOpencode || | ||
| isCloudflareWorkersAI || | ||
| isCloudflareAiGateway || | ||
| isVercelAiGateway || | ||
| isAntLing; | ||
| return !isNonStandard; | ||
| }; | ||
| const detectSupportsUsageInStreaming = () => true; | ||
| const detectSupportsStrictMode = (provider, baseURL) => { | ||
| const p = provider.toLowerCase(); | ||
| const url = (baseURL ?? "").toLowerCase(); | ||
| const isMoonshot = p === "moonshotai" || p === "moonshotai-cn" || url.includes("api.moonshot."); | ||
| const isTogether = p === "togetherai" || p === "together" || url.includes("api.together."); | ||
| const isCloudflareAiGateway = p === "cloudflare-ai-gateway" || url.includes("gateway.ai.cloudflare.com"); | ||
| const isNvidia = p === "nvidia" || url.includes("integrate.api.nvidia.com"); | ||
| return !isMoonshot && !isTogether && !isCloudflareAiGateway && !isNvidia; | ||
| }; | ||
| const detectZaiToolStream = (provider, baseURL, modelID) => { | ||
| const p = provider.toLowerCase(); | ||
| const url = (baseURL ?? "").toLowerCase(); | ||
| const isZai = p === "zai" || | ||
| p === "zai-coding-plan" || | ||
| p === "zhipuai" || | ||
| p === "zhipuai-coding-plan" || | ||
| url.includes("api.z.ai") || | ||
| url.includes("open.bigmodel.cn"); | ||
| if (!isZai) | ||
| return false; | ||
| const id = modelID.toLowerCase(); | ||
| if (id === "glm-4.5" || id === "glm-4.5-air" || id === "glm-4.5-flash" || id === "glm-4.5v") | ||
| return false; | ||
| return true; | ||
| }; | ||
| const lowerOptions = (request, supportsStore) => { | ||
| const options = OpenAIOptions.resolve(request); | ||
| const cacheKey = ProviderShared.clampPromptCacheKey(request.promptCacheKey); | ||
| return { | ||
| ...(options.store !== undefined ? { store: options.store } : {}), | ||
| ...(supportsStore && options.store !== undefined ? { store: options.store } : {}), | ||
| // For providers that support `store`, ensure stateless `store:false` is sent | ||
| // even when no explicit `providerOptions.store` was supplied, mirroring the | ||
| // native OpenAI Chat default. Non-standard providers omit `store` entirely. | ||
| ...(supportsStore && options.store === undefined ? { store: false } : {}), | ||
| ...(cacheKey ? { prompt_cache_key: cacheKey } : {}), | ||
@@ -438,4 +544,13 @@ ...(options.reasoningEffort ? { reasoning_effort: options.reasoningEffort } : {}), | ||
| const toolSchemaCompatibility = request.model.compatibility?.toolSchema; | ||
| const maxTokensField = request.model.compatibility?.maxTokensField ?? "max_tokens"; | ||
| const provider = String(request.model.provider); | ||
| const baseURL = request.model.route.endpoint.baseURL; | ||
| const detectedMaxTokensField = detectMaxTokensField(provider, baseURL); | ||
| const maxTokensField = request.model.compatibility?.maxTokensField ?? detectedMaxTokensField; | ||
| const supportsStore = request.model.compatibility?.supportsStore ?? detectSupportsStore(provider, baseURL); | ||
| const supportsUsageInStreaming = request.model.compatibility?.supportsUsageInStreaming ?? detectSupportsUsageInStreaming(); | ||
| const supportsStrictMode = request.model.compatibility?.supportsStrictMode ?? detectSupportsStrictMode(provider, baseURL); | ||
| const zaiToolStream = request.model.compatibility?.zaiToolStream ?? | ||
| detectZaiToolStream(provider, baseURL, request.model.id); | ||
| const hasHistory = hasToolHistory(request.messages); | ||
| const hasActiveTools = request.tools.length > 0; | ||
| return { | ||
@@ -448,6 +563,7 @@ model: request.model.id, | ||
| : undefined | ||
| : request.tools.map((tool) => lowerTool(tool, ToolSchemaProjection.modelCompatibility(tool.inputSchema, toolSchemaCompatibility), options)), | ||
| : request.tools.map((tool) => lowerTool(tool, ToolSchemaProjection.modelCompatibility(tool.inputSchema, toolSchemaCompatibility), options, supportsStrictMode)), | ||
| tool_choice: request.toolChoice ? yield* lowerToolChoice(request.toolChoice) : undefined, | ||
| stream: true, | ||
| stream_options: { include_usage: true }, | ||
| ...(supportsUsageInStreaming ? { stream_options: { include_usage: true } } : {}), | ||
| ...(zaiToolStream && hasActiveTools ? { tool_stream: true } : {}), | ||
| ...(maxTokensField === "max_completion_tokens" | ||
@@ -462,3 +578,3 @@ ? { max_completion_tokens: generation?.maxTokens } | ||
| stop: generation?.stop, | ||
| ...lowerOptions(request), | ||
| ...lowerOptions(request, supportsStore), | ||
| }; | ||
@@ -465,0 +581,0 @@ }); |
@@ -76,7 +76,8 @@ import { Route, type RouteRoutedLanguageModelInput } from "../route/client.js"; | ||
| readonly function: { | ||
| readonly description: string; | ||
| readonly name: string; | ||
| readonly description: string; | ||
| readonly parameters: { | ||
| readonly [x: string]: unknown; | ||
| }; | ||
| readonly strict?: boolean | undefined; | ||
| }; | ||
@@ -105,2 +106,3 @@ readonly type: "function"; | ||
| readonly reasoning_effort?: import("./utils/open-responses-options.js").ReasoningEffort | undefined; | ||
| readonly tool_stream?: boolean | undefined; | ||
| readonly frequency_penalty?: number | undefined; | ||
@@ -107,0 +109,0 @@ readonly presence_penalty?: number | undefined; |
@@ -97,2 +97,3 @@ import { Route, type RouteRoutedLanguageModelInput } from "../route/client.js"; | ||
| readonly temperature?: number | undefined; | ||
| readonly service_tier?: import("./utils/open-responses-options.js").ServiceTier | undefined; | ||
| readonly tool_choice?: "required" | "auto" | "none" | { | ||
@@ -121,3 +122,2 @@ readonly type: "function"; | ||
| readonly top_logprobs?: number | undefined; | ||
| readonly service_tier?: import("./utils/open-responses-options.js").ServiceTier | undefined; | ||
| readonly max_output_tokens?: number | undefined; | ||
@@ -124,0 +124,0 @@ readonly max_tool_calls?: number | undefined; |
@@ -233,2 +233,3 @@ import { Schema } from "effect"; | ||
| readonly temperature?: number | undefined; | ||
| readonly service_tier?: import("./utils/open-responses-options.js").ServiceTier | undefined; | ||
| readonly tool_choice?: "required" | "auto" | "none" | { | ||
@@ -259,3 +260,2 @@ readonly type: "function"; | ||
| readonly top_logprobs?: number | undefined; | ||
| readonly service_tier?: import("./utils/open-responses-options.js").ServiceTier | undefined; | ||
| readonly max_output_tokens?: number | undefined; | ||
@@ -418,2 +418,3 @@ readonly max_tool_calls?: number | undefined; | ||
| readonly temperature?: number | undefined; | ||
| readonly service_tier?: import("./utils/open-responses-options.js").ServiceTier | undefined; | ||
| readonly tool_choice?: "required" | "auto" | "none" | { | ||
@@ -444,3 +445,2 @@ readonly type: "function"; | ||
| readonly top_logprobs?: number | undefined; | ||
| readonly service_tier?: import("./utils/open-responses-options.js").ServiceTier | undefined; | ||
| readonly max_output_tokens?: number | undefined; | ||
@@ -549,2 +549,3 @@ readonly max_tool_calls?: number | undefined; | ||
| readonly temperature?: number | undefined; | ||
| readonly service_tier?: import("./utils/open-responses-options.js").ServiceTier | undefined; | ||
| readonly tool_choice?: "required" | "auto" | "none" | { | ||
@@ -575,3 +576,2 @@ readonly type: "function"; | ||
| readonly top_logprobs?: number | undefined; | ||
| readonly service_tier?: import("./utils/open-responses-options.js").ServiceTier | undefined; | ||
| readonly max_output_tokens?: number | undefined; | ||
@@ -680,2 +680,3 @@ readonly max_tool_calls?: number | undefined; | ||
| readonly temperature?: number | undefined; | ||
| readonly service_tier?: import("./utils/open-responses-options.js").ServiceTier | undefined; | ||
| readonly tool_choice?: "required" | "auto" | "none" | { | ||
@@ -706,3 +707,2 @@ readonly type: "function"; | ||
| readonly top_logprobs?: number | undefined; | ||
| readonly service_tier?: import("./utils/open-responses-options.js").ServiceTier | undefined; | ||
| readonly max_output_tokens?: number | undefined; | ||
@@ -811,2 +811,3 @@ readonly max_tool_calls?: number | undefined; | ||
| readonly temperature?: number | undefined; | ||
| readonly service_tier?: import("./utils/open-responses-options.js").ServiceTier | undefined; | ||
| readonly tool_choice?: "required" | "auto" | "none" | { | ||
@@ -837,3 +838,2 @@ readonly type: "function"; | ||
| readonly top_logprobs?: number | undefined; | ||
| readonly service_tier?: import("./utils/open-responses-options.js").ServiceTier | undefined; | ||
| readonly max_output_tokens?: number | undefined; | ||
@@ -840,0 +840,0 @@ readonly max_tool_calls?: number | undefined; |
@@ -46,5 +46,23 @@ import { Effect, Encoding, Schema } from "effect"; | ||
| }); | ||
| // Replayed items are paired with stored server state by id, so a foreign or | ||
| // synthetic token can fail request validation even when `call_id` pairing is | ||
| // intact. Only resend ids in each item kind's own grammar; hosted tool | ||
| // references keep generic validation because every hosted tool mints its own | ||
| // prefix. The same allowlist approach codex uses before resending history | ||
| // (codex-rs core/src/client.rs, `prepare_response_items_for_request`). | ||
| const ITEM_ID_PREFIXES = { | ||
| message: ["msg_"], | ||
| reasoning: ["rs_"], | ||
| "function-call": ["fc_"], | ||
| // Every hosted tool mints its own id prefix, so references keep generic | ||
| // validation only. | ||
| reference: [], | ||
| }; | ||
| const extension = { | ||
| id: ADAPTER, | ||
| name: NAME, | ||
| acceptsItemID: (kind, id) => { | ||
| const prefixes = ITEM_ID_PREFIXES[kind]; | ||
| return prefixes.length === 0 || prefixes.some((prefix) => id.startsWith(prefix)); | ||
| }, | ||
| }; | ||
@@ -79,4 +97,6 @@ const nativeImageToolInput = (tool) => { | ||
| const toolSchemaCompatibility = request.model.compatibility?.toolSchema; | ||
| const parallelToolCalls = OpenResponses.resolveParallelToolCalls(request); | ||
| return { | ||
| ...body, | ||
| ...(parallelToolCalls === undefined ? {} : { parallel_tool_calls: parallelToolCalls }), | ||
| tools: request.tools.length === 0 | ||
@@ -122,10 +142,6 @@ ? undefined | ||
| const step = (state, event) => { | ||
| if (event.type === "response.reasoning_text.delta" || event.type === "response.reasoning_summary.delta") | ||
| if (event.type === "response.reasoning_text.delta") | ||
| return event.item_id | ||
| ? Effect.succeed(OpenResponses.onReasoningDelta(state, event, event.item_id)) | ||
| : ProviderShared.eventError(ADAPTER, `${event.type} is missing item_id`); | ||
| if (event.type === "response.reasoning_text.done" || event.type === "response.reasoning_summary.done") | ||
| return event.item_id | ||
| ? Effect.succeed(OpenResponses.onReasoningDone(state, event)) | ||
| : ProviderShared.eventError(ADAPTER, `${event.type} is missing item_id`); | ||
| if (event.type === "response.output_item.done" && event.item && ResponsesHostedTools.isItem(event.item, HOSTED_TOOLS)) | ||
@@ -132,0 +148,0 @@ return ResponsesHostedTools.onDone(state, event.item, HOSTED_TOOLS); |
@@ -32,2 +32,3 @@ import { Effect, Schema } from "effect"; | ||
| } | undefined; | ||
| readonly cache?: import("../../schema/options.js").CacheHint | undefined; | ||
| readonly filename?: string | undefined; | ||
@@ -34,0 +35,0 @@ }) => Effect.Effect<{ |
@@ -92,2 +92,3 @@ import { Protocol } from "../route/protocol.js"; | ||
| readonly temperature?: number | undefined; | ||
| readonly service_tier?: import("./utils/open-responses-options.js").ServiceTier | undefined; | ||
| readonly tool_choice?: "required" | "auto" | "none" | { | ||
@@ -116,3 +117,2 @@ readonly type: "function"; | ||
| readonly top_logprobs?: number | undefined; | ||
| readonly service_tier?: import("./utils/open-responses-options.js").ServiceTier | undefined; | ||
| readonly max_output_tokens?: number | undefined; | ||
@@ -119,0 +119,0 @@ readonly max_tool_calls?: number | undefined; |
@@ -1,5 +0,3 @@ | ||
| import { Effect } from "effect"; | ||
| import { Protocol } from "../route/protocol.js"; | ||
| import { OpenResponses } from "./open-responses.js"; | ||
| import { ProviderShared } from "./shared.js"; | ||
| import { ResponsesHostedTools } from "./utils/responses-hosted-tools.js"; | ||
@@ -26,11 +24,5 @@ const ADAPTER = "xai-responses"; | ||
| }; | ||
| // Grok speaks the standard Responses reasoning dialect (`reasoning_summary_text.*`, | ||
| // handled by the baseline); only its hosted tool vocabulary differs. | ||
| const step = (state, event) => { | ||
| if (event.type === "response.reasoning_text.delta" || event.type === "response.reasoning_summary.delta") | ||
| return event.item_id | ||
| ? Effect.succeed(OpenResponses.onReasoningDelta(state, event, event.item_id)) | ||
| : ProviderShared.eventError(ADAPTER, `${event.type} is missing item_id`); | ||
| if (event.type === "response.reasoning_text.done" || event.type === "response.reasoning_summary.done") | ||
| return event.item_id | ||
| ? Effect.succeed(OpenResponses.onReasoningDone(state, event)) | ||
| : ProviderShared.eventError(ADAPTER, `${event.type} is missing item_id`); | ||
| if (event.type === "response.output_item.done" && event.item && ResponsesHostedTools.isItem(event.item, HOSTED_TOOLS)) | ||
@@ -37,0 +29,0 @@ return ResponsesHostedTools.onDone(state, event.item, HOSTED_TOOLS); |
@@ -88,7 +88,8 @@ import type { Route as RouteDef, RouteDefaultsInput } from "../route/client.js"; | ||
| readonly function: { | ||
| readonly description: string; | ||
| readonly name: string; | ||
| readonly description: string; | ||
| readonly parameters: { | ||
| readonly [x: string]: unknown; | ||
| }; | ||
| readonly strict?: boolean | undefined; | ||
| }; | ||
@@ -117,2 +118,3 @@ readonly type: "function"; | ||
| readonly reasoning_effort?: import("../protocols/utils/open-responses-options.js").ReasoningEffort | undefined; | ||
| readonly tool_stream?: boolean | undefined; | ||
| readonly frequency_penalty?: number | undefined; | ||
@@ -219,2 +221,3 @@ readonly presence_penalty?: number | undefined; | ||
| readonly temperature?: number | undefined; | ||
| readonly service_tier?: import("../protocols/utils/open-responses-options.js").ServiceTier | undefined; | ||
| readonly tool_choice?: "required" | "auto" | "none" | { | ||
@@ -245,3 +248,2 @@ readonly type: "function"; | ||
| readonly top_logprobs?: number | undefined; | ||
| readonly service_tier?: import("../protocols/utils/open-responses-options.js").ServiceTier | undefined; | ||
| readonly max_output_tokens?: number | undefined; | ||
@@ -248,0 +250,0 @@ readonly max_tool_calls?: number | undefined; |
@@ -44,2 +44,8 @@ import type { ProviderPackage } from "../provider-package.js"; | ||
| readonly data: string; | ||
| } | { | ||
| readonly type: "url"; | ||
| readonly url: string; | ||
| } | { | ||
| readonly type: "file"; | ||
| readonly file_id: string; | ||
| }; | ||
@@ -50,2 +56,5 @@ readonly cache_control?: { | ||
| } | undefined; | ||
| readonly transformations?: { | ||
| readonly oversized_image?: "error" | "downsize" | undefined; | ||
| } | undefined; | ||
| } | { | ||
@@ -57,3 +66,15 @@ readonly type: "document"; | ||
| readonly data: string; | ||
| } | { | ||
| readonly type: "text"; | ||
| readonly media_type: "text/plain"; | ||
| readonly data: string; | ||
| } | { | ||
| readonly type: "url"; | ||
| readonly url: string; | ||
| } | { | ||
| readonly type: "file"; | ||
| readonly file_id: string; | ||
| }; | ||
| readonly title?: string | undefined; | ||
| readonly context?: string | undefined; | ||
| readonly cache_control?: { | ||
@@ -63,2 +84,5 @@ readonly type: "ephemeral"; | ||
| } | undefined; | ||
| readonly citations?: { | ||
| readonly enabled: boolean; | ||
| } | undefined; | ||
| } | { | ||
@@ -79,2 +103,8 @@ readonly type: "tool_result"; | ||
| readonly data: string; | ||
| } | { | ||
| readonly type: "url"; | ||
| readonly url: string; | ||
| } | { | ||
| readonly type: "file"; | ||
| readonly file_id: string; | ||
| }; | ||
@@ -85,2 +115,5 @@ readonly cache_control?: { | ||
| } | undefined; | ||
| readonly transformations?: { | ||
| readonly oversized_image?: "error" | "downsize" | undefined; | ||
| } | undefined; | ||
| } | { | ||
@@ -92,3 +125,15 @@ readonly type: "document"; | ||
| readonly data: string; | ||
| } | { | ||
| readonly type: "text"; | ||
| readonly media_type: "text/plain"; | ||
| readonly data: string; | ||
| } | { | ||
| readonly type: "url"; | ||
| readonly url: string; | ||
| } | { | ||
| readonly type: "file"; | ||
| readonly file_id: string; | ||
| }; | ||
| readonly title?: string | undefined; | ||
| readonly context?: string | undefined; | ||
| readonly cache_control?: { | ||
@@ -98,2 +143,5 @@ readonly type: "ephemeral"; | ||
| } | undefined; | ||
| readonly citations?: { | ||
| readonly enabled: boolean; | ||
| } | undefined; | ||
| })[]; | ||
@@ -145,2 +193,3 @@ readonly tool_use_id: string; | ||
| readonly thinking: string; | ||
| readonly signature: string; | ||
| readonly cache_control?: { | ||
@@ -150,3 +199,2 @@ readonly type: "ephemeral"; | ||
| } | undefined; | ||
| readonly signature?: string | undefined; | ||
| } | { | ||
@@ -172,2 +220,5 @@ readonly data: string; | ||
| readonly stream: true; | ||
| readonly metadata?: { | ||
| readonly user_id?: string | null | undefined; | ||
| } | undefined; | ||
| readonly tools?: readonly { | ||
@@ -203,7 +254,30 @@ readonly description: string; | ||
| } | undefined; | ||
| readonly service_tier?: "auto" | "standard_only" | undefined; | ||
| readonly container?: string | { | ||
| readonly id?: string | null | undefined; | ||
| readonly skills?: readonly { | ||
| readonly [x: string]: unknown; | ||
| }[] | null | undefined; | ||
| } | null | undefined; | ||
| readonly inference_geo?: string | null | undefined; | ||
| readonly cache_control?: { | ||
| readonly type: "ephemeral"; | ||
| readonly ttl?: "1h" | "5m" | undefined; | ||
| } | undefined; | ||
| readonly output_config?: { | ||
| readonly format?: { | ||
| readonly type: "json_schema"; | ||
| readonly schema: { | ||
| readonly [x: string]: unknown; | ||
| }; | ||
| } | null | undefined; | ||
| readonly effort?: string | undefined; | ||
| } | undefined; | ||
| readonly tool_choice?: { | ||
| readonly type: "auto" | "none" | "any"; | ||
| readonly disable_parallel_tool_use?: boolean | undefined; | ||
| } | { | ||
| readonly type: "tool"; | ||
| readonly name: string; | ||
| readonly disable_parallel_tool_use?: boolean | undefined; | ||
| } | undefined; | ||
@@ -213,5 +287,2 @@ readonly top_p?: number | undefined; | ||
| readonly stop_sequences?: readonly string[] | undefined; | ||
| readonly output_config?: { | ||
| readonly effort?: string | undefined; | ||
| } | undefined; | ||
| }, import("../route/transport/http.js").HttpPrepared<string>>[]; | ||
@@ -218,0 +289,0 @@ export declare const configure: (input: Config) => { |
@@ -28,2 +28,8 @@ import type { RouteDefaultsInput } from "../route/client.js"; | ||
| readonly data: string; | ||
| } | { | ||
| readonly type: "url"; | ||
| readonly url: string; | ||
| } | { | ||
| readonly type: "file"; | ||
| readonly file_id: string; | ||
| }; | ||
@@ -34,2 +40,5 @@ readonly cache_control?: { | ||
| } | undefined; | ||
| readonly transformations?: { | ||
| readonly oversized_image?: "error" | "downsize" | undefined; | ||
| } | undefined; | ||
| } | { | ||
@@ -41,3 +50,15 @@ readonly type: "document"; | ||
| readonly data: string; | ||
| } | { | ||
| readonly type: "text"; | ||
| readonly media_type: "text/plain"; | ||
| readonly data: string; | ||
| } | { | ||
| readonly type: "url"; | ||
| readonly url: string; | ||
| } | { | ||
| readonly type: "file"; | ||
| readonly file_id: string; | ||
| }; | ||
| readonly title?: string | undefined; | ||
| readonly context?: string | undefined; | ||
| readonly cache_control?: { | ||
@@ -47,2 +68,5 @@ readonly type: "ephemeral"; | ||
| } | undefined; | ||
| readonly citations?: { | ||
| readonly enabled: boolean; | ||
| } | undefined; | ||
| } | { | ||
@@ -63,2 +87,8 @@ readonly type: "tool_result"; | ||
| readonly data: string; | ||
| } | { | ||
| readonly type: "url"; | ||
| readonly url: string; | ||
| } | { | ||
| readonly type: "file"; | ||
| readonly file_id: string; | ||
| }; | ||
@@ -69,2 +99,5 @@ readonly cache_control?: { | ||
| } | undefined; | ||
| readonly transformations?: { | ||
| readonly oversized_image?: "error" | "downsize" | undefined; | ||
| } | undefined; | ||
| } | { | ||
@@ -76,3 +109,15 @@ readonly type: "document"; | ||
| readonly data: string; | ||
| } | { | ||
| readonly type: "text"; | ||
| readonly media_type: "text/plain"; | ||
| readonly data: string; | ||
| } | { | ||
| readonly type: "url"; | ||
| readonly url: string; | ||
| } | { | ||
| readonly type: "file"; | ||
| readonly file_id: string; | ||
| }; | ||
| readonly title?: string | undefined; | ||
| readonly context?: string | undefined; | ||
| readonly cache_control?: { | ||
@@ -82,2 +127,5 @@ readonly type: "ephemeral"; | ||
| } | undefined; | ||
| readonly citations?: { | ||
| readonly enabled: boolean; | ||
| } | undefined; | ||
| })[]; | ||
@@ -129,2 +177,3 @@ readonly tool_use_id: string; | ||
| readonly thinking: string; | ||
| readonly signature: string; | ||
| readonly cache_control?: { | ||
@@ -134,3 +183,2 @@ readonly type: "ephemeral"; | ||
| } | undefined; | ||
| readonly signature?: string | undefined; | ||
| } | { | ||
@@ -156,2 +204,5 @@ readonly data: string; | ||
| readonly stream: true; | ||
| readonly metadata?: { | ||
| readonly user_id?: string | null | undefined; | ||
| } | undefined; | ||
| readonly tools?: readonly { | ||
@@ -187,7 +238,30 @@ readonly description: string; | ||
| } | undefined; | ||
| readonly service_tier?: "auto" | "standard_only" | undefined; | ||
| readonly container?: string | { | ||
| readonly id?: string | null | undefined; | ||
| readonly skills?: readonly { | ||
| readonly [x: string]: unknown; | ||
| }[] | null | undefined; | ||
| } | null | undefined; | ||
| readonly inference_geo?: string | null | undefined; | ||
| readonly cache_control?: { | ||
| readonly type: "ephemeral"; | ||
| readonly ttl?: "1h" | "5m" | undefined; | ||
| } | undefined; | ||
| readonly output_config?: { | ||
| readonly format?: { | ||
| readonly type: "json_schema"; | ||
| readonly schema: { | ||
| readonly [x: string]: unknown; | ||
| }; | ||
| } | null | undefined; | ||
| readonly effort?: string | undefined; | ||
| } | undefined; | ||
| readonly tool_choice?: { | ||
| readonly type: "auto" | "none" | "any"; | ||
| readonly disable_parallel_tool_use?: boolean | undefined; | ||
| } | { | ||
| readonly type: "tool"; | ||
| readonly name: string; | ||
| readonly disable_parallel_tool_use?: boolean | undefined; | ||
| } | undefined; | ||
@@ -197,5 +271,2 @@ readonly top_p?: number | undefined; | ||
| readonly stop_sequences?: readonly string[] | undefined; | ||
| readonly output_config?: { | ||
| readonly effort?: string | undefined; | ||
| } | undefined; | ||
| }, import("../route/transport/http.js").HttpPrepared<string>>[]; | ||
@@ -202,0 +273,0 @@ export type Config = RouteDefaultsInput & ProviderAuthOption<"optional"> & { |
@@ -91,7 +91,8 @@ import { type AtLeastOne, type ProviderAuthOption } from "../route/auth-options.js"; | ||
| readonly function: { | ||
| readonly description: string; | ||
| readonly name: string; | ||
| readonly description: string; | ||
| readonly parameters: { | ||
| readonly [x: string]: unknown; | ||
| }; | ||
| readonly strict?: boolean | undefined; | ||
| }; | ||
@@ -120,2 +121,3 @@ readonly type: "function"; | ||
| readonly reasoning_effort?: import("../protocols/utils/open-responses-options.js").ReasoningEffort | undefined; | ||
| readonly tool_stream?: boolean | undefined; | ||
| readonly frequency_penalty?: number | undefined; | ||
@@ -222,2 +224,3 @@ readonly presence_penalty?: number | undefined; | ||
| readonly temperature?: number | undefined; | ||
| readonly service_tier?: import("../protocols/utils/open-responses-options.js").ServiceTier | undefined; | ||
| readonly tool_choice?: "required" | "auto" | "none" | { | ||
@@ -248,3 +251,2 @@ readonly type: "function"; | ||
| readonly top_logprobs?: number | undefined; | ||
| readonly service_tier?: import("../protocols/utils/open-responses-options.js").ServiceTier | undefined; | ||
| readonly max_output_tokens?: number | undefined; | ||
@@ -251,0 +253,0 @@ readonly max_tool_calls?: number | undefined; |
@@ -97,7 +97,8 @@ import type { Config, Redacted } from "effect"; | ||
| readonly function: { | ||
| readonly description: string; | ||
| readonly name: string; | ||
| readonly description: string; | ||
| readonly parameters: { | ||
| readonly [x: string]: unknown; | ||
| }; | ||
| readonly strict?: boolean | undefined; | ||
| }; | ||
@@ -126,2 +127,3 @@ readonly type: "function"; | ||
| readonly reasoning_effort?: import("../protocols/utils/open-responses-options.js").ReasoningEffort | undefined; | ||
| readonly tool_stream?: boolean | undefined; | ||
| readonly frequency_penalty?: number | undefined; | ||
@@ -196,7 +198,8 @@ readonly presence_penalty?: number | undefined; | ||
| readonly function: { | ||
| readonly description: string; | ||
| readonly name: string; | ||
| readonly description: string; | ||
| readonly parameters: { | ||
| readonly [x: string]: unknown; | ||
| }; | ||
| readonly strict?: boolean | undefined; | ||
| }; | ||
@@ -225,2 +228,3 @@ readonly type: "function"; | ||
| readonly reasoning_effort?: import("../protocols/utils/open-responses-options.js").ReasoningEffort | undefined; | ||
| readonly tool_stream?: boolean | undefined; | ||
| readonly frequency_penalty?: number | undefined; | ||
@@ -295,7 +299,8 @@ readonly presence_penalty?: number | undefined; | ||
| readonly function: { | ||
| readonly description: string; | ||
| readonly name: string; | ||
| readonly description: string; | ||
| readonly parameters: { | ||
| readonly [x: string]: unknown; | ||
| }; | ||
| readonly strict?: boolean | undefined; | ||
| }; | ||
@@ -324,2 +329,3 @@ readonly type: "function"; | ||
| readonly reasoning_effort?: import("../protocols/utils/open-responses-options.js").ReasoningEffort | undefined; | ||
| readonly tool_stream?: boolean | undefined; | ||
| readonly frequency_penalty?: number | undefined; | ||
@@ -326,0 +332,0 @@ readonly presence_penalty?: number | undefined; |
@@ -87,7 +87,8 @@ import type { ProviderPackage } from "../provider-package.js"; | ||
| readonly function: { | ||
| readonly description: string; | ||
| readonly name: string; | ||
| readonly description: string; | ||
| readonly parameters: { | ||
| readonly [x: string]: unknown; | ||
| }; | ||
| readonly strict?: boolean | undefined; | ||
| }; | ||
@@ -116,2 +117,3 @@ readonly type: "function"; | ||
| readonly reasoning_effort?: import("../protocols/utils/open-responses-options.js").ReasoningEffort | undefined; | ||
| readonly tool_stream?: boolean | undefined; | ||
| readonly frequency_penalty?: number | undefined; | ||
@@ -118,0 +120,0 @@ readonly presence_penalty?: number | undefined; |
@@ -26,2 +26,5 @@ import type { ProviderPackage } from "../provider-package.js"; | ||
| anthropic_version: "vertex-2023-10-16"; | ||
| metadata?: { | ||
| readonly user_id?: string | null | undefined; | ||
| } | undefined; | ||
| max_tokens: number; | ||
@@ -62,2 +65,8 @@ tools?: readonly { | ||
| readonly data: string; | ||
| } | { | ||
| readonly type: "url"; | ||
| readonly url: string; | ||
| } | { | ||
| readonly type: "file"; | ||
| readonly file_id: string; | ||
| }; | ||
@@ -68,2 +77,5 @@ readonly cache_control?: { | ||
| } | undefined; | ||
| readonly transformations?: { | ||
| readonly oversized_image?: "error" | "downsize" | undefined; | ||
| } | undefined; | ||
| } | { | ||
@@ -75,3 +87,15 @@ readonly type: "document"; | ||
| readonly data: string; | ||
| } | { | ||
| readonly type: "text"; | ||
| readonly media_type: "text/plain"; | ||
| readonly data: string; | ||
| } | { | ||
| readonly type: "url"; | ||
| readonly url: string; | ||
| } | { | ||
| readonly type: "file"; | ||
| readonly file_id: string; | ||
| }; | ||
| readonly title?: string | undefined; | ||
| readonly context?: string | undefined; | ||
| readonly cache_control?: { | ||
@@ -81,2 +105,5 @@ readonly type: "ephemeral"; | ||
| } | undefined; | ||
| readonly citations?: { | ||
| readonly enabled: boolean; | ||
| } | undefined; | ||
| } | { | ||
@@ -97,2 +124,8 @@ readonly type: "tool_result"; | ||
| readonly data: string; | ||
| } | { | ||
| readonly type: "url"; | ||
| readonly url: string; | ||
| } | { | ||
| readonly type: "file"; | ||
| readonly file_id: string; | ||
| }; | ||
@@ -103,2 +136,5 @@ readonly cache_control?: { | ||
| } | undefined; | ||
| readonly transformations?: { | ||
| readonly oversized_image?: "error" | "downsize" | undefined; | ||
| } | undefined; | ||
| } | { | ||
@@ -110,3 +146,15 @@ readonly type: "document"; | ||
| readonly data: string; | ||
| } | { | ||
| readonly type: "text"; | ||
| readonly media_type: "text/plain"; | ||
| readonly data: string; | ||
| } | { | ||
| readonly type: "url"; | ||
| readonly url: string; | ||
| } | { | ||
| readonly type: "file"; | ||
| readonly file_id: string; | ||
| }; | ||
| readonly title?: string | undefined; | ||
| readonly context?: string | undefined; | ||
| readonly cache_control?: { | ||
@@ -116,2 +164,5 @@ readonly type: "ephemeral"; | ||
| } | undefined; | ||
| readonly citations?: { | ||
| readonly enabled: boolean; | ||
| } | undefined; | ||
| })[]; | ||
@@ -163,2 +214,3 @@ readonly tool_use_id: string; | ||
| readonly thinking: string; | ||
| readonly signature: string; | ||
| readonly cache_control?: { | ||
@@ -168,3 +220,2 @@ readonly type: "ephemeral"; | ||
| } | undefined; | ||
| readonly signature?: string | undefined; | ||
| } | { | ||
@@ -201,7 +252,30 @@ readonly data: string; | ||
| } | undefined; | ||
| service_tier?: "auto" | "standard_only" | undefined; | ||
| container?: string | { | ||
| readonly id?: string | null | undefined; | ||
| readonly skills?: readonly { | ||
| readonly [x: string]: unknown; | ||
| }[] | null | undefined; | ||
| } | null | undefined; | ||
| inference_geo?: string | null | undefined; | ||
| cache_control?: { | ||
| readonly type: "ephemeral"; | ||
| readonly ttl?: "1h" | "5m" | undefined; | ||
| } | undefined; | ||
| output_config?: { | ||
| readonly format?: { | ||
| readonly type: "json_schema"; | ||
| readonly schema: { | ||
| readonly [x: string]: unknown; | ||
| }; | ||
| } | null | undefined; | ||
| readonly effort?: string | undefined; | ||
| } | undefined; | ||
| tool_choice?: { | ||
| readonly type: "auto" | "none" | "any"; | ||
| readonly disable_parallel_tool_use?: boolean | undefined; | ||
| } | { | ||
| readonly type: "tool"; | ||
| readonly name: string; | ||
| readonly disable_parallel_tool_use?: boolean | undefined; | ||
| } | undefined; | ||
@@ -211,5 +285,2 @@ top_p?: number | undefined; | ||
| stop_sequences?: readonly string[] | undefined; | ||
| output_config?: { | ||
| readonly effort?: string | undefined; | ||
| } | undefined; | ||
| }, import("../route/transport/http.js").HttpPrepared<string>>[]; | ||
@@ -216,0 +287,0 @@ export declare const configure: (input?: Config) => { |
@@ -110,2 +110,3 @@ import type { ProviderPackage } from "../provider-package.js"; | ||
| readonly temperature?: number | undefined; | ||
| readonly service_tier?: import("../protocols/utils/open-responses-options.js").ServiceTier | undefined; | ||
| readonly tool_choice?: "required" | "auto" | "none" | { | ||
@@ -134,3 +135,2 @@ readonly type: "function"; | ||
| readonly top_logprobs?: number | undefined; | ||
| readonly service_tier?: import("../protocols/utils/open-responses-options.js").ServiceTier | undefined; | ||
| readonly max_output_tokens?: number | undefined; | ||
@@ -137,0 +137,0 @@ readonly max_tool_calls?: number | undefined; |
@@ -71,2 +71,3 @@ import type { ProviderPackage } from "../provider-package.js"; | ||
| }[] | undefined; | ||
| readonly serviceTier?: string | undefined; | ||
| readonly toolConfig?: { | ||
@@ -83,3 +84,2 @@ readonly functionCallingConfig: { | ||
| }[] | undefined; | ||
| readonly serviceTier?: string | undefined; | ||
| readonly labels?: { | ||
@@ -86,0 +86,0 @@ readonly [x: string]: string; |
@@ -52,2 +52,3 @@ import type { RouteDefaultsInput } from "../route/client.js"; | ||
| }[] | undefined; | ||
| readonly serviceTier?: string | undefined; | ||
| readonly toolConfig?: { | ||
@@ -64,3 +65,2 @@ readonly functionCallingConfig: { | ||
| }[] | undefined; | ||
| readonly serviceTier?: string | undefined; | ||
| readonly labels?: { | ||
@@ -67,0 +67,0 @@ readonly [x: string]: string; |
@@ -108,2 +108,3 @@ import type { ProviderPackage } from "../provider-package.js"; | ||
| readonly temperature?: number | undefined; | ||
| readonly service_tier?: import("../protocols/utils/open-responses-options.js").ServiceTier | undefined; | ||
| readonly tool_choice?: "required" | "auto" | "none" | { | ||
@@ -132,3 +133,2 @@ readonly type: "function"; | ||
| readonly top_logprobs?: number | undefined; | ||
| readonly service_tier?: import("../protocols/utils/open-responses-options.js").ServiceTier | undefined; | ||
| readonly max_output_tokens?: number | undefined; | ||
@@ -135,0 +135,0 @@ readonly max_tool_calls?: number | undefined; |
@@ -88,7 +88,8 @@ import { type ModelID } from "../schema/index.js"; | ||
| readonly function: { | ||
| readonly description: string; | ||
| readonly name: string; | ||
| readonly description: string; | ||
| readonly parameters: { | ||
| readonly [x: string]: unknown; | ||
| }; | ||
| readonly strict?: boolean | undefined; | ||
| }; | ||
@@ -117,2 +118,3 @@ readonly type: "function"; | ||
| readonly reasoning_effort?: import("../protocols/utils/open-responses-options.js").ReasoningEffort | undefined; | ||
| readonly tool_stream?: boolean | undefined; | ||
| readonly frequency_penalty?: number | undefined; | ||
@@ -119,0 +121,0 @@ readonly presence_penalty?: number | undefined; |
@@ -76,7 +76,8 @@ import { type ProviderAuthOption } from "../route/auth-options.js"; | ||
| readonly function: { | ||
| readonly description: string; | ||
| readonly name: string; | ||
| readonly description: string; | ||
| readonly parameters: { | ||
| readonly [x: string]: unknown; | ||
| }; | ||
| readonly strict?: boolean | undefined; | ||
| }; | ||
@@ -105,2 +106,3 @@ readonly type: "function"; | ||
| readonly reasoning_effort?: import("../protocols/utils/open-responses-options.js").ReasoningEffort | undefined; | ||
| readonly tool_stream?: boolean | undefined; | ||
| readonly frequency_penalty?: number | undefined; | ||
@@ -207,2 +209,3 @@ readonly presence_penalty?: number | undefined; | ||
| readonly temperature?: number | undefined; | ||
| readonly service_tier?: import("../protocols/utils/open-responses-options.js").ServiceTier | undefined; | ||
| readonly tool_choice?: "required" | "auto" | "none" | { | ||
@@ -233,3 +236,2 @@ readonly type: "function"; | ||
| readonly top_logprobs?: number | undefined; | ||
| readonly service_tier?: import("../protocols/utils/open-responses-options.js").ServiceTier | undefined; | ||
| readonly max_output_tokens?: number | undefined; | ||
@@ -236,0 +238,0 @@ readonly max_tool_calls?: number | undefined; |
@@ -155,2 +155,3 @@ import { Schema } from "effect"; | ||
| readonly parameters: Schema.$Record<Schema.String, Schema.Unknown>; | ||
| readonly strict: Schema.optional<Schema.Boolean>; | ||
| }>; | ||
@@ -175,2 +176,3 @@ readonly cache_control: Schema.optional<Schema.Struct<{ | ||
| reasoning_effort: Schema.optional<Schema.declare<import("../protocols/utils/open-responses-options.js").ReasoningEffort, import("../protocols/utils/open-responses-options.js").ReasoningEffort>>; | ||
| tool_stream: Schema.optional<Schema.Boolean>; | ||
| max_completion_tokens: Schema.optional<Schema.Number>; | ||
@@ -253,7 +255,8 @@ max_tokens: Schema.optional<Schema.Number>; | ||
| readonly function: { | ||
| readonly description: string; | ||
| readonly name: string; | ||
| readonly description: string; | ||
| readonly parameters: { | ||
| readonly [x: string]: unknown; | ||
| }; | ||
| readonly strict?: boolean | undefined; | ||
| }; | ||
@@ -282,2 +285,3 @@ readonly type: "function"; | ||
| readonly reasoning_effort?: import("../protocols/utils/open-responses-options.js").ReasoningEffort | undefined; | ||
| readonly tool_stream?: boolean | undefined; | ||
| readonly frequency_penalty?: number | undefined; | ||
@@ -418,7 +422,8 @@ readonly presence_penalty?: number | undefined; | ||
| readonly function: { | ||
| readonly description: string; | ||
| readonly name: string; | ||
| readonly description: string; | ||
| readonly parameters: { | ||
| readonly [x: string]: unknown; | ||
| }; | ||
| readonly strict?: boolean | undefined; | ||
| }; | ||
@@ -447,2 +452,3 @@ readonly type: "function"; | ||
| readonly reasoning_effort?: import("../protocols/utils/open-responses-options.js").ReasoningEffort | undefined; | ||
| readonly tool_stream?: boolean | undefined; | ||
| readonly frequency_penalty?: number | undefined; | ||
@@ -518,7 +524,8 @@ readonly presence_penalty?: number | undefined; | ||
| readonly function: { | ||
| readonly description: string; | ||
| readonly name: string; | ||
| readonly description: string; | ||
| readonly parameters: { | ||
| readonly [x: string]: unknown; | ||
| }; | ||
| readonly strict?: boolean | undefined; | ||
| }; | ||
@@ -547,2 +554,3 @@ readonly type: "function"; | ||
| readonly reasoning_effort?: import("../protocols/utils/open-responses-options.js").ReasoningEffort | undefined; | ||
| readonly tool_stream?: boolean | undefined; | ||
| readonly frequency_penalty?: number | undefined; | ||
@@ -549,0 +557,0 @@ readonly presence_penalty?: number | undefined; |
@@ -84,7 +84,8 @@ import { type ProviderAuthOption } from "../route/auth-options.js"; | ||
| readonly function: { | ||
| readonly description: string; | ||
| readonly name: string; | ||
| readonly description: string; | ||
| readonly parameters: { | ||
| readonly [x: string]: unknown; | ||
| }; | ||
| readonly strict?: boolean | undefined; | ||
| }; | ||
@@ -113,2 +114,3 @@ readonly type: "function"; | ||
| readonly reasoning_effort?: import("../protocols/utils/open-responses-options.js").ReasoningEffort | undefined; | ||
| readonly tool_stream?: boolean | undefined; | ||
| readonly frequency_penalty?: number | undefined; | ||
@@ -115,0 +117,0 @@ readonly presence_penalty?: number | undefined; |
@@ -37,2 +37,3 @@ import { Schema } from "effect"; | ||
| readonly filename: Schema.optional<Schema.String>; | ||
| readonly cache: Schema.optional<typeof CacheHint>; | ||
| readonly metadata: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>; | ||
@@ -179,2 +180,3 @@ }>; | ||
| readonly filename: Schema.optional<Schema.String>; | ||
| readonly cache: Schema.optional<typeof CacheHint>; | ||
| readonly metadata: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>; | ||
@@ -252,2 +254,3 @@ }>, Schema.Struct<{ | ||
| readonly filename: Schema.optional<Schema.String>; | ||
| readonly cache: Schema.optional<typeof CacheHint>; | ||
| readonly metadata: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>; | ||
@@ -354,2 +357,3 @@ }>, Schema.Struct<{ | ||
| readonly name: Schema.optional<Schema.String>; | ||
| readonly disableParallelToolUse: Schema.optional<Schema.Boolean>; | ||
| }>, {}>; | ||
@@ -356,0 +360,0 @@ export declare class ToolChoice extends ToolChoice_base { |
@@ -36,2 +36,3 @@ import { Schema } from "effect"; | ||
| filename: Schema.optional(Schema.String), | ||
| cache: Schema.optional(CacheHint), | ||
| metadata: Schema.optional(Schema.Record(Schema.String, Schema.Unknown)), | ||
@@ -191,2 +192,3 @@ }).annotate({ identifier: "LLM.Content.Media" }); | ||
| name: Schema.optional(Schema.String), | ||
| disableParallelToolUse: Schema.optional(Schema.Boolean), | ||
| }) { | ||
@@ -193,0 +195,0 @@ } |
@@ -77,2 +77,7 @@ import { Schema } from "effect"; | ||
| readonly requireFinishReason: Schema.optional<Schema.Boolean>; | ||
| readonly supportsStore: Schema.optional<Schema.Boolean>; | ||
| readonly supportsUsageInStreaming: Schema.optional<Schema.Boolean>; | ||
| readonly supportsStrictMode: Schema.optional<Schema.Boolean>; | ||
| readonly zaiToolStream: Schema.optional<Schema.Boolean>; | ||
| readonly requireSignature: Schema.optional<Schema.Boolean>; | ||
| }>, {}>; | ||
@@ -79,0 +84,0 @@ export declare class LanguageModelCompatibility extends LanguageModelCompatibility_base { |
@@ -104,2 +104,7 @@ import { Schema } from "effect"; | ||
| requireFinishReason: Schema.optional(Schema.Boolean), | ||
| supportsStore: Schema.optional(Schema.Boolean), | ||
| supportsUsageInStreaming: Schema.optional(Schema.Boolean), | ||
| supportsStrictMode: Schema.optional(Schema.Boolean), | ||
| zaiToolStream: Schema.optional(Schema.Boolean), | ||
| requireSignature: Schema.optional(Schema.Boolean), | ||
| }) { | ||
@@ -106,0 +111,0 @@ } |
+3
-3
| { | ||
| "$schema": "https://json.schemastore.org/package.json", | ||
| "version": "0.0.0-beta-18050", | ||
| "version": "0.0.0-beta-18135", | ||
| "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-beta-18050", | ||
| "@opencode-ai/http-recorder": "0.0.0-beta-18135", | ||
| "@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-beta-18050", | ||
| "@opencode-ai/schema": "0.0.0-beta-18135", | ||
| "aws4fetch": "1.0.20", | ||
@@ -46,0 +46,0 @@ "effect": "4.0.0-rc.111", |
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
1246380
3.76%28569
3.56%+ Added
- Removed