@opencode-ai/ai
Advanced tools
| import { Context, Effect, Layer } from "effect"; | ||
| import { RequestExecutor } from "./route/executor"; | ||
| import type { ImageOptions, ImageRequestFor, ImageResponse } from "./image"; | ||
| import type { LLMError } from "./schema"; | ||
| import type { AIError } from "./schema"; | ||
| export type Execute = RequestExecutor.Interface["execute"]; | ||
| export interface Interface { | ||
| readonly generate: <Options extends ImageOptions>(request: ImageRequestFor<Options>) => Effect.Effect<ImageResponse, LLMError>; | ||
| readonly generate: <Options extends ImageOptions>(request: ImageRequestFor<Options>) => Effect.Effect<ImageResponse, AIError>; | ||
| } | ||
@@ -12,3 +12,3 @@ declare const Service_base: Context.ServiceClass<Service, "@opencode/ImageClient", Interface>; | ||
| } | ||
| export declare const generate: <Options extends ImageOptions>(request: ImageRequestFor<Options>) => Effect.Effect<ImageResponse, LLMError>; | ||
| export declare const generate: <Options extends ImageOptions>(request: ImageRequestFor<Options>) => Effect.Effect<ImageResponse, AIError>; | ||
| export declare const layer: Layer.Layer<Service, never, RequestExecutor.Service>; | ||
@@ -18,4 +18,4 @@ export declare const ImageClient: { | ||
| readonly layer: Layer.Layer<Service, never, RequestExecutor.Service>; | ||
| readonly generate: <Options extends ImageOptions>(request: ImageRequestFor<Options>) => Effect.Effect<ImageResponse, LLMError>; | ||
| readonly generate: <Options extends ImageOptions>(request: ImageRequestFor<Options>) => Effect.Effect<ImageResponse, AIError>; | ||
| }; | ||
| export {}; |
+4
-4
| import { Effect, Schema } from "effect"; | ||
| import { HttpOptions, LLMError, ModelID, ProviderID, Usage } from "./schema"; | ||
| import { HttpOptions, AIError, ModelID, ProviderID, Usage } from "./schema"; | ||
| import { Service, type Execute as ImageExecute } from "./image-client"; | ||
| export interface ImageRoute<Options extends ImageOptions = ImageOptions> { | ||
| readonly id: string; | ||
| readonly generate: (request: ImageRequestFor<Options>, execute: ImageExecute) => Effect.Effect<ImageResponse, LLMError>; | ||
| readonly generate: (request: ImageRequestFor<Options>, execute: ImageExecute) => Effect.Effect<ImageResponse, AIError>; | ||
| } | ||
@@ -104,4 +104,4 @@ export type ImageOptions = Record<string, unknown>; | ||
| export declare function request(input: ImageRequest): ImageRequest; | ||
| export declare function generate<const Model extends object>(input: ImageRequestInput<Model>): Effect.Effect<ImageResponse, LLMError, Service>; | ||
| export declare function generate(input: ImageRequest): Effect.Effect<ImageResponse, LLMError, Service>; | ||
| export declare function generate<const Model extends object>(input: ImageRequestInput<Model>): Effect.Effect<ImageResponse, AIError, Service>; | ||
| export declare function generate(input: ImageRequest): Effect.Effect<ImageResponse, AIError, Service>; | ||
| export declare const Image: { | ||
@@ -108,0 +108,0 @@ readonly request: typeof request; |
+2
-2
| import { Effect, Schema } from "effect"; | ||
| import { HttpOptions, InvalidRequestReason, LLMError, ModelID, ProviderID, ProviderMetadata, Usage } from "./schema"; | ||
| import { HttpOptions, InvalidRequestReason, AIError, ModelID, ProviderID, ProviderMetadata, Usage } from "./schema"; | ||
| import { ImageClient, Service } from "./image-client"; | ||
@@ -92,3 +92,3 @@ export class ImageModel { | ||
| try: () => (input instanceof ImageRequest ? input : request(input)), | ||
| catch: (error) => new LLMError({ | ||
| catch: (error) => new AIError({ | ||
| module: "Image", | ||
@@ -95,0 +95,0 @@ method: "generate", |
+2
-2
@@ -7,3 +7,3 @@ export { LLMClient } from "./route/client"; | ||
| export { isContextOverflow, isContextOverflowFailure } from "./provider-error"; | ||
| export type { RouteModelInput, RouteRoutedModelInput, Interface as LLMClientShape, Service as LLMClientService, } from "./route/client"; | ||
| export type { RouteLanguageModelInput, RouteRoutedLanguageModelInput, Interface as LLMClientShape, Service as LLMClientService, } from "./route/client"; | ||
| export * from "./schema"; | ||
@@ -18,3 +18,3 @@ export { GeneratedImage, ImageInput, ImageInputSchema, ImageModel, ImageRequest, ImageResponse } from "./image"; | ||
| export * as LLM from "./llm"; | ||
| export type { Definition as ProviderDefinition, ModelFactory as ProviderModelFactory, ModelOptions as ProviderModelOptions, } from "./provider"; | ||
| export type { Definition as ProviderDefinition, LanguageModelFactory as ProviderLanguageModelFactory, LanguageModelOptions as ProviderLanguageModelOptions, } from "./provider"; | ||
| export type { Definition as ProviderPackageDefinition, Settings as ProviderPackageSettings } from "./provider-package"; |
+11
-11
| import { Effect, JsonSchema, Schema } from "effect"; | ||
| import { GenerationOptions, HttpOptions, LLMError, LLMRequest, LLMResponse, Message, Model, SystemPart, ToolChoice, ToolDefinition, type ContentPart, type ModelProviderOptions } from "./schema"; | ||
| import { GenerationOptions, HttpOptions, AIError, LLMRequest, LLMResponse, Message, LanguageModel, SystemPart, ToolChoice, ToolDefinition, type ContentPart, type LanguageModelProviderOptions } from "./schema"; | ||
| import { type ToolSchema } from "./tool"; | ||
| /** Input accepted by `LLM.request`, normalized into the canonical `LLMRequest` class. */ | ||
| export type RequestInput<SelectedModel extends Model = Model> = Omit<ConstructorParameters<typeof LLMRequest>[0], "model" | "system" | "messages" | "tools" | "toolChoice" | "generation" | "http" | "providerOptions"> & { | ||
| readonly model: SelectedModel; | ||
| export type RequestInput<SelectedLanguageModel extends LanguageModel = LanguageModel> = Omit<ConstructorParameters<typeof LLMRequest>[0], "model" | "system" | "messages" | "tools" | "toolChoice" | "generation" | "http" | "providerOptions"> & { | ||
| readonly model: SelectedLanguageModel; | ||
| readonly system?: string | SystemPart | ReadonlyArray<SystemPart>; | ||
@@ -13,3 +13,3 @@ readonly prompt?: string | ContentPart | ReadonlyArray<ContentPart>; | ||
| readonly generation?: GenerationOptions.Input; | ||
| readonly providerOptions?: NoInfer<ModelProviderOptions<SelectedModel>>; | ||
| readonly providerOptions?: NoInfer<LanguageModelProviderOptions<SelectedLanguageModel>>; | ||
| readonly http?: HttpOptions.Input; | ||
@@ -19,4 +19,4 @@ }; | ||
| export declare const stream: typeof import("./route/client").stream; | ||
| export declare const request: <const SelectedModel extends Model>(input: RequestInput<SelectedModel>) => LLMRequest; | ||
| type GenerateObjectBase<SelectedModel extends Model = Model> = Omit<RequestInput<SelectedModel>, "tools" | "toolChoice">; | ||
| export declare const request: <const SelectedLanguageModel extends LanguageModel>(input: RequestInput<SelectedLanguageModel>) => LLMRequest; | ||
| type GenerateObjectBase<SelectedLanguageModel extends LanguageModel = LanguageModel> = Omit<RequestInput<SelectedLanguageModel>, "tools" | "toolChoice">; | ||
| export declare class GenerateObjectResponse<T> { | ||
@@ -210,6 +210,6 @@ readonly object: T; | ||
| } | ||
| export interface GenerateObjectOptions<S extends ToolSchema<any>, SelectedModel extends Model = Model> extends GenerateObjectBase<SelectedModel> { | ||
| export interface GenerateObjectOptions<S extends ToolSchema<any>, SelectedLanguageModel extends LanguageModel = LanguageModel> extends GenerateObjectBase<SelectedLanguageModel> { | ||
| readonly schema: S; | ||
| } | ||
| export interface GenerateObjectDynamicOptions<SelectedModel extends Model = Model> extends GenerateObjectBase<SelectedModel> { | ||
| export interface GenerateObjectDynamicOptions<SelectedLanguageModel extends LanguageModel = LanguageModel> extends GenerateObjectBase<SelectedLanguageModel> { | ||
| /** Raw JSON Schema object describing the expected output shape. */ | ||
@@ -226,8 +226,8 @@ readonly jsonSchema: JsonSchema.JsonSchema; | ||
| * 1. `schema: EffectSchema<T>` — `.object` is decoded and typed as `T`. | ||
| * Decode failures surface as `LLMError`. | ||
| * Decode failures surface as `AIError`. | ||
| * 2. `jsonSchema: JsonSchema.JsonSchema` — `.object` is `unknown`. Use when | ||
| * the schema is only available at runtime (MCP, plugin manifests). Caller validates. | ||
| */ | ||
| export declare function generateObject<const SelectedModel extends Model, S extends ToolSchema<any>>(options: GenerateObjectOptions<S, SelectedModel>): Effect.Effect<GenerateObjectResponse<Schema.Schema.Type<S>>, LLMError>; | ||
| export declare function generateObject<const SelectedModel extends Model>(options: GenerateObjectDynamicOptions<SelectedModel>): Effect.Effect<GenerateObjectResponse<unknown>, LLMError>; | ||
| export declare function generateObject<const SelectedLanguageModel extends LanguageModel, S extends ToolSchema<any>>(options: GenerateObjectOptions<S, SelectedLanguageModel>): Effect.Effect<GenerateObjectResponse<Schema.Schema.Type<S>>, AIError>; | ||
| export declare function generateObject<const SelectedLanguageModel extends LanguageModel>(options: GenerateObjectDynamicOptions<SelectedLanguageModel>): Effect.Effect<GenerateObjectResponse<unknown>, AIError>; | ||
| export {}; |
+3
-3
| import { Effect, JsonSchema, Schema } from "effect"; | ||
| import { LLMClient } from "./route/client"; | ||
| import { GenerationOptions, HttpOptions, InvalidProviderOutputReason, LLMError, LLMEvent, LLMRequest, LLMResponse, Message, Model, SystemPart, ToolChoice, ToolDefinition, } from "./schema"; | ||
| import { GenerationOptions, HttpOptions, InvalidProviderOutputReason, AIError, LLMEvent, LLMRequest, LLMResponse, Message, LanguageModel, SystemPart, ToolChoice, ToolDefinition, } from "./schema"; | ||
| import { make as makeTool, toDefinitions } from "./tool"; | ||
@@ -45,3 +45,3 @@ export const generate = LLMClient.generate; | ||
| if (!call || !LLMEvent.is.toolCall(call)) | ||
| return yield* new LLMError({ | ||
| return yield* new AIError({ | ||
| module: "LLM", | ||
@@ -53,3 +53,3 @@ method: "generateObject", | ||
| }); | ||
| const object = yield* tool._decode(call.input).pipe(Effect.mapError((error) => new LLMError({ | ||
| const object = yield* tool._decode(call.input).pipe(Effect.mapError((error) => new AIError({ | ||
| module: "LLM", | ||
@@ -56,0 +56,0 @@ method: "generateObject", |
@@ -8,3 +8,3 @@ import { Effect, Schema } from "effect"; | ||
| import { Protocol } from "../route/protocol"; | ||
| import { LLMError, LLMEvent, mergeJsonRecords, Usage, } from "../schema"; | ||
| import { AIError, LLMEvent, mergeJsonRecords, Usage, } from "../schema"; | ||
| import { JsonObject, optionalArray, optionalNull, ProviderShared } from "./shared"; | ||
@@ -171,4 +171,8 @@ import { classifyProviderFailure } from "../provider-error"; | ||
| cache_read_input_tokens: optionalNull(Schema.Number), | ||
| server_tool_use: optionalNull(Schema.StructWithRest(Schema.Struct({ web_search_requests: Schema.optional(Schema.Number) }), [Schema.Record(Schema.String, Schema.Unknown)])), | ||
| output_tokens_details: optionalNull(Schema.StructWithRest(Schema.Struct({ thinking_tokens: Schema.optional(Schema.Number) }), [Schema.Record(Schema.String, Schema.Unknown)])), | ||
| server_tool_use: optionalNull(Schema.StructWithRest(Schema.Struct({ web_search_requests: Schema.optional(Schema.Number) }), [ | ||
| Schema.Record(Schema.String, Schema.Unknown), | ||
| ])), | ||
| output_tokens_details: optionalNull(Schema.StructWithRest(Schema.Struct({ thinking_tokens: Schema.optional(Schema.Number) }), [ | ||
| Schema.Record(Schema.String, Schema.Unknown), | ||
| ])), | ||
| }), [Schema.Record(Schema.String, Schema.Unknown)]); | ||
@@ -798,3 +802,3 @@ const AnthropicStreamBlock = Schema.Struct({ | ||
| }; | ||
| const onError = (event) => new LLMError({ | ||
| const onError = (event) => new AIError({ | ||
| module: ADAPTER, | ||
@@ -801,0 +805,0 @@ method: "stream", |
@@ -5,3 +5,3 @@ import { Effect, Schema } from "effect"; | ||
| import { Protocol } from "../route/protocol"; | ||
| import { LLMError, LLMEvent, Usage, } from "../schema"; | ||
| import { AIError, LLMEvent, Usage, } from "../schema"; | ||
| import { BedrockEventStream } from "./bedrock-event-stream"; | ||
@@ -197,5 +197,3 @@ import { classifyProviderFailure } from "../provider-error"; | ||
| const bedrock = part.providerMetadata?.bedrock; | ||
| return ProviderShared.isRecord(bedrock) && typeof bedrock.redactedData === "string" | ||
| ? bedrock.redactedData | ||
| : undefined; | ||
| return ProviderShared.isRecord(bedrock) && typeof bedrock.redactedData === "string" ? bedrock.redactedData : undefined; | ||
| }; | ||
@@ -514,3 +512,3 @@ const lowerToolCall = (part) => ({ | ||
| if (exception) { | ||
| return yield* new LLMError({ | ||
| return yield* new AIError({ | ||
| module: ADAPTER, | ||
@@ -517,0 +515,0 @@ method: "stream", |
@@ -5,3 +5,3 @@ import { Effect, Encoding, Schema } from "effect"; | ||
| import { Auth } from "../route/auth"; | ||
| import { InvalidProviderOutputReason, LLMError, Usage, mergeHttpOptions, mergeJsonRecords, } from "../schema"; | ||
| import { InvalidProviderOutputReason, AIError, Usage, mergeHttpOptions, mergeJsonRecords, } from "../schema"; | ||
| import { ProviderShared } from "./shared"; | ||
@@ -62,3 +62,3 @@ import { ImageInputs } from "./utils/image-input"; | ||
| }; | ||
| const invalidOutput = (message, providerMetadata) => new LLMError({ | ||
| const invalidOutput = (message, providerMetadata) => new AIError({ | ||
| module: ADAPTER, | ||
@@ -65,0 +65,0 @@ method: "generate", |
| import { Effect, Schema } from "effect"; | ||
| import { HttpTransport } from "../route/transport"; | ||
| import { Protocol } from "../route/protocol"; | ||
| import { LLMError, LLMEvent, Usage, type LLMRequest, type MediaPart, type ProviderMetadata, type ToolDefinition } from "../schema"; | ||
| import { AIError, LLMEvent, Usage, type LLMRequest, type MediaPart, type ProviderMetadata, type ToolDefinition } from "../schema"; | ||
| import { ProviderShared } from "./shared"; | ||
@@ -364,7 +364,7 @@ import { Lifecycle } from "./utils/lifecycle"; | ||
| strict: boolean; | ||
| }, LLMError, never>; | ||
| }, AIError, never>; | ||
| export declare const lowerToolChoice: (protocolName: string, toolChoice: NonNullable<LLMRequest["toolChoice"]>) => Effect.Effect<"required" | "none" | "auto" | { | ||
| type: "function"; | ||
| name: string; | ||
| }, LLMError, never>; | ||
| }, AIError, never>; | ||
| export declare const fromRequestWithExtension: (request: LLMRequest, extension: Extension) => Effect.Effect<{ | ||
@@ -383,3 +383,3 @@ service_tier?: "auto" | "default" | "flex" | "priority" | undefined; | ||
| instructions?: string | undefined; | ||
| model: string & import("effect/Brand").Brand<"LLM.ModelID">; | ||
| model: string & import("effect/Brand").Brand<"AI.ModelID">; | ||
| input: LoweredInputItem[]; | ||
@@ -403,3 +403,3 @@ tools: { | ||
| top_p: number | undefined; | ||
| }, LLMError, never>; | ||
| }, AIError, never>; | ||
| export declare const fromRequest: (request: LLMRequest) => Effect.Effect<{ | ||
@@ -492,3 +492,3 @@ readonly input: readonly ({ | ||
| readonly max_output_tokens?: number | undefined; | ||
| }, LLMError, never>; | ||
| }, AIError, never>; | ||
| export declare const providerMetadata: (state: ParserState, metadata: Record<string, unknown>) => ProviderMetadata; | ||
@@ -499,3 +499,3 @@ export type StepResult = readonly [ParserState, ReadonlyArray<LLMEvent>]; | ||
| export declare const onReasoningDone: (state: ParserState, _event: Event) => StepResult; | ||
| export declare const step: (state: ParserState, event: Event) => LLMError | Effect.Effect<StepResult, never, never> | Effect.Effect<[ParserState, readonly ({ | ||
| export declare const step: (state: ParserState, event: Event) => AIError | Effect.Effect<StepResult, never, never> | Effect.Effect<[ParserState, readonly ({ | ||
| readonly type: "step-start"; | ||
@@ -681,3 +681,3 @@ readonly index: number; | ||
| readonly classification?: "context-overflow" | "payload-too-large" | undefined; | ||
| })[]], LLMError, never>; | ||
| })[]], AIError, never>; | ||
| /** | ||
@@ -684,0 +684,0 @@ * The provider-neutral Open Responses protocol. Provider-specific Responses |
| import { Effect, Schema } from "effect"; | ||
| import { HttpTransport } from "../route/transport"; | ||
| import { Protocol } from "../route/protocol"; | ||
| import { LLMError, LLMEvent, Usage, } from "../schema"; | ||
| import { AIError, LLMEvent, Usage, } from "../schema"; | ||
| import { JsonObject, optionalArray, optionalNull, ProviderShared } from "./shared"; | ||
@@ -293,5 +293,3 @@ import { classifyProviderFailure } from "../provider-error"; | ||
| const metadata = part.providerMetadata?.[providerMetadataKey]; | ||
| const phase = ProviderShared.isRecord(metadata) | ||
| ? messagePhase(metadata.phase, extension) | ||
| : undefined; | ||
| const phase = ProviderShared.isRecord(metadata) ? messagePhase(metadata.phase, extension) : undefined; | ||
| const group = groups.at(-1); | ||
@@ -485,6 +483,3 @@ if (group && group.phase === phase) | ||
| const lifecycle = Lifecycle.textStart(state.lifecycle, events, id, metadata); | ||
| return [ | ||
| { ...state, lifecycle: Lifecycle.textDelta(lifecycle, events, id, event.delta) }, | ||
| events, | ||
| ]; | ||
| return [{ ...state, lifecycle: Lifecycle.textDelta(lifecycle, events, id, event.delta) }, events]; | ||
| }; | ||
@@ -759,3 +754,3 @@ const onOutputTextDone = (state, event, id) => { | ||
| const message = providerErrorMessage(event, fallback); | ||
| return new LLMError({ | ||
| return new AIError({ | ||
| module: state.id, | ||
@@ -762,0 +757,0 @@ method: "stream", |
@@ -5,3 +5,3 @@ import { Effect, Schema } from "effect"; | ||
| import { Protocol } from "../route/protocol"; | ||
| import { LLMError, LLMEvent, Usage, type FinishReasonDetails, type CacheHint, type LLMRequest } from "../schema"; | ||
| import { AIError, LLMEvent, Usage, type FinishReasonDetails, type CacheHint, type LLMRequest } from "../schema"; | ||
| import { Lifecycle } from "./utils/lifecycle"; | ||
@@ -270,3 +270,3 @@ import { ToolStream } from "./utils/tool-stream"; | ||
| max_completion_tokens: number | undefined; | ||
| model: string & import("effect/Brand").Brand<"LLM.ModelID">; | ||
| model: string & import("effect/Brand").Brand<"AI.ModelID">; | ||
| messages: ({ | ||
@@ -365,3 +365,3 @@ readonly role: "system"; | ||
| max_tokens: number | undefined; | ||
| model: string & import("effect/Brand").Brand<"LLM.ModelID">; | ||
| model: string & import("effect/Brand").Brand<"AI.ModelID">; | ||
| messages: ({ | ||
@@ -450,3 +450,3 @@ readonly role: "system"; | ||
| }; | ||
| }, LLMError, never>; | ||
| }, AIError, never>; | ||
| /** | ||
@@ -453,0 +453,0 @@ * The OpenAI Chat protocol — request body construction, body schema, and the |
@@ -8,3 +8,3 @@ import { Effect, Schema } from "effect"; | ||
| import { Protocol } from "../route/protocol"; | ||
| import { LLMError, LLMEvent, Usage, } from "../schema"; | ||
| import { AIError, LLMEvent, Usage, } from "../schema"; | ||
| import { classifyProviderFailure } from "../provider-error"; | ||
@@ -448,3 +448,3 @@ import { isRecord, JsonObject, optionalArray, optionalNull, ProviderShared } from "./shared"; | ||
| // total) with a `reasoning_tokens` subset. We pass the inclusive totals | ||
| // through and derive the non-cached breakdown so the `LLM.Usage` contract is | ||
| // through and derive the non-cached breakdown so the `AI.Usage` contract is | ||
| // satisfied on both sides. | ||
@@ -529,3 +529,3 @@ const mapUsage = (usage) => { | ||
| if (event.error) | ||
| return yield* new LLMError({ | ||
| return yield* new AIError({ | ||
| module: ADAPTER, | ||
@@ -532,0 +532,0 @@ method: "stream", |
@@ -1,3 +0,3 @@ | ||
| import { Route, type RouteRoutedModelInput } from "../route/client"; | ||
| export type OpenAICompatibleChatModelInput = RouteRoutedModelInput; | ||
| import { Route, type RouteRoutedLanguageModelInput } from "../route/client"; | ||
| export type OpenAICompatibleChatLanguageModelInput = RouteRoutedLanguageModelInput; | ||
| /** | ||
@@ -4,0 +4,0 @@ * Route for non-OpenAI providers that expose an OpenAI Chat-compatible |
@@ -1,3 +0,3 @@ | ||
| import { Route, type RouteRoutedModelInput } from "../route/client"; | ||
| export type OpenAICompatibleResponsesModelInput = RouteRoutedModelInput; | ||
| import { Route, type RouteRoutedLanguageModelInput } from "../route/client"; | ||
| export type OpenAICompatibleResponsesLanguageModelInput = RouteRoutedLanguageModelInput; | ||
| /** | ||
@@ -4,0 +4,0 @@ * Deployment adapter for providers that expose an Open Responses-compatible |
@@ -5,3 +5,3 @@ import { Effect, Encoding, Schema } from "effect"; | ||
| import { Auth } from "../route/auth"; | ||
| import { InvalidProviderOutputReason, LLMError, Usage, mergeHttpOptions, mergeJsonRecords, } from "../schema"; | ||
| import { InvalidProviderOutputReason, AIError, Usage, mergeHttpOptions, mergeJsonRecords, } from "../schema"; | ||
| import { ProviderShared } from "./shared"; | ||
@@ -39,3 +39,3 @@ import { ImageInputs } from "./utils/image-input"; | ||
| }; | ||
| const invalidOutput = (message) => new LLMError({ | ||
| const invalidOutput = (message) => new AIError({ | ||
| module: ADAPTER, | ||
@@ -42,0 +42,0 @@ method: "generate", |
@@ -5,3 +5,3 @@ import { Buffer } from "node:buffer"; | ||
| import { Headers, HttpClientRequest } from "effect/unstable/http"; | ||
| import { LLMError, type ContentPart, type LLMRequest, type ToolResultPart } from "../schema"; | ||
| import { AIError, type ContentPart, type LLMRequest, type ToolResultPart } from "../schema"; | ||
| import { isRecord } from "../utils/record"; | ||
@@ -31,3 +31,3 @@ export { isRecord }; | ||
| * | ||
| * Under the additive `LLM.Usage` contract, `inputTokens` and `outputTokens` | ||
| * Under the additive `AI.Usage` contract, `inputTokens` and `outputTokens` | ||
| * are the non-cached input and visible output only. The provider-supplied | ||
@@ -60,4 +60,4 @@ * `total` is the source of truth when present; the computed fallback | ||
| export declare const sumTokens: (...values: ReadonlyArray<number | undefined>) => number | undefined; | ||
| export declare const eventError: (route: string, message: string, raw?: string) => LLMError; | ||
| export declare const parseJson: (route: string, input: string, message: string) => Effect.Effect<unknown, LLMError, never>; | ||
| export declare const eventError: (route: string, message: string, raw?: string) => AIError; | ||
| export declare const parseJson: (route: string, input: string, message: string) => Effect.Effect<unknown, AIError, never>; | ||
| /** | ||
@@ -98,3 +98,3 @@ * Join the `text` field of a list of parts with newlines. Used by routes | ||
| } | undefined; | ||
| }[], LLMError, never>; | ||
| }[], AIError, never>; | ||
| /** Lower an unsupported privileged update into visible, in-order user text. */ | ||
@@ -105,3 +105,3 @@ export declare const wrappedSystemUpdate: (route: string, message: import("..").Message) => Effect.Effect<{ | ||
| cache: import("..").CacheHint | undefined; | ||
| }, LLMError, never>; | ||
| }, AIError, never>; | ||
| /** | ||
@@ -113,3 +113,3 @@ * Parse the streamed JSON input of a tool call. Treats an empty string as | ||
| */ | ||
| export declare const parseToolInput: (route: string, name: string, raw: string) => Effect.Effect<unknown, LLMError, never>; | ||
| export declare const parseToolInput: (route: string, name: string, raw: string) => Effect.Effect<unknown, AIError, never>; | ||
| export declare const IMAGE_MIMES: readonly ["image/png", "image/jpeg", "image/gif", "image/webp"]; | ||
@@ -141,3 +141,3 @@ export declare const VIDEO_MIMES: readonly ["video/mp4", "video/webm", "video/quicktime"]; | ||
| bytes: Buffer<ArrayBuffer>; | ||
| }, LLMError, never>; | ||
| }, AIError, never>; | ||
| export declare const validateToolFile: (route: string, part: Tool.FileContent, supportedMimes: ReadonlySet<string>) => Effect.Effect<{ | ||
@@ -148,3 +148,3 @@ mime: string; | ||
| bytes: Buffer<ArrayBuffer>; | ||
| }, LLMError, never>; | ||
| }, AIError, never>; | ||
| export declare const trimBaseUrl: (value: string) => string; | ||
@@ -159,5 +159,5 @@ export declare const toolResultText: (part: ToolResultPart) => string; | ||
| * implement client-driven retries) so the public error channel stays | ||
| * `LLMError`. | ||
| * `AIError`. | ||
| */ | ||
| export declare const sseFraming: (bytes: Stream.Stream<Uint8Array, LLMError>) => Stream.Stream<string, LLMError>; | ||
| export declare const sseFraming: (bytes: Stream.Stream<Uint8Array, AIError>) => Stream.Stream<string, AIError>; | ||
| /** | ||
@@ -170,3 +170,3 @@ * Canonical invalid-request constructor. Lift one-line `const invalid = | ||
| */ | ||
| export declare const invalidRequest: (message: string) => LLMError; | ||
| export declare const invalidRequest: (message: string) => AIError; | ||
| export declare const matchToolChoice: <Auto, None, Required, Tool>(route: string, toolChoice: NonNullable<LLMRequest["toolChoice"]>, cases: { | ||
@@ -177,3 +177,3 @@ readonly auto: () => Auto; | ||
| readonly tool: (name: string) => Tool; | ||
| }) => Effect.Effect<Auto | None | Required | Tool, LLMError, never>; | ||
| }) => Effect.Effect<Auto | None | Required | Tool, AIError, never>; | ||
| type ContentType = ContentPart["type"]; | ||
@@ -183,3 +183,3 @@ export declare const supportsContent: <const Type extends ContentType>(part: ContentPart, types: ReadonlyArray<Type>) => part is Extract<ContentPart, { | ||
| }>; | ||
| export declare const unsupportedContent: (route: string, role: LLMRequest["messages"][number]["role"], types: ReadonlyArray<ContentType>) => LLMError; | ||
| export declare const unsupportedContent: (route: string, role: LLMRequest["messages"][number]["role"], types: ReadonlyArray<ContentType>) => AIError; | ||
| /** | ||
@@ -189,7 +189,7 @@ * Build a `validate` step from a Schema decoder. Replaces the per-route | ||
| * invalid(e.message)))`. Any decode error is translated into | ||
| * `LLMError` carrying the original parse-error message. | ||
| * `AIError` carrying the original parse-error message. | ||
| */ | ||
| export declare const validateWith: <A, I, E extends { | ||
| readonly message: string; | ||
| }>(decode: (input: I) => Effect.Effect<A, E>) => (payload: I) => Effect.Effect<A, LLMError, never>; | ||
| }>(decode: (input: I) => Effect.Effect<A, E>) => (payload: I) => Effect.Effect<A, AIError, never>; | ||
| /** | ||
@@ -196,0 +196,0 @@ * Build an HTTP POST with a JSON body. Sets `content-type: application/json` |
@@ -6,3 +6,3 @@ import { Buffer } from "node:buffer"; | ||
| import { Headers, HttpClientRequest } from "effect/unstable/http"; | ||
| import { InvalidProviderOutputReason, InvalidRequestReason, LLMError, } from "../schema"; | ||
| import { InvalidProviderOutputReason, InvalidRequestReason, AIError, } from "../schema"; | ||
| import { isRecord } from "../utils/record"; | ||
@@ -23,3 +23,3 @@ export { isRecord }; | ||
| * | ||
| * Under the additive `LLM.Usage` contract, `inputTokens` and `outputTokens` | ||
| * Under the additive `AI.Usage` contract, `inputTokens` and `outputTokens` | ||
| * are the non-cached input and visible output only. The provider-supplied | ||
@@ -68,3 +68,3 @@ * `total` is the source of truth when present; the computed fallback | ||
| }; | ||
| export const eventError = (route, message, raw) => new LLMError({ | ||
| export const eventError = (route, message, raw) => new AIError({ | ||
| module: "ProviderShared", | ||
@@ -191,3 +191,3 @@ method: "stream", | ||
| * implement client-driven retries) so the public error channel stays | ||
| * `LLMError`. | ||
| * `AIError`. | ||
| */ | ||
@@ -202,3 +202,3 @@ export const sseFraming = (bytes) => bytes.pipe(Stream.decodeText(), Stream.pipeThroughChannel(Sse.decode()), Stream.catchTag("Retry", () => Stream.empty), Stream.filter((event) => event.data.length > 0 && event.data !== "[DONE]"), Stream.map((event) => event.data)); | ||
| */ | ||
| export const invalidRequest = (message) => new LLMError({ | ||
| export const invalidRequest = (message) => new AIError({ | ||
| module: "ProviderShared", | ||
@@ -232,3 +232,3 @@ method: "request", | ||
| * invalid(e.message)))`. Any decode error is translated into | ||
| * `LLMError` carrying the original parse-error message. | ||
| * `AIError` carrying the original parse-error message. | ||
| */ | ||
@@ -235,0 +235,0 @@ export const validateWith = (decode) => (payload) => decode(payload).pipe(Effect.mapError((error) => invalidRequest(error.message))); |
@@ -48,3 +48,3 @@ import { Effect, Schema } from "effect"; | ||
| }; | ||
| }, import("../..").LLMError, never>; | ||
| }, import("../..").AIError, never>; | ||
| export * as BedrockMedia from "./bedrock-media"; |
| import { Effect } from "effect"; | ||
| import type { ImageInput } from "../../image"; | ||
| import { LLMError } from "../../schema"; | ||
| import { AIError } from "../../schema"; | ||
| export declare const dataUrl: (input: Extract<ImageInput, { | ||
@@ -10,4 +10,4 @@ readonly type: "bytes"; | ||
| readonly data: Uint8Array; | ||
| } | undefined, LLMError>; | ||
| export declare const invalidImageInput: (module: string, message: string) => LLMError; | ||
| } | undefined, AIError>; | ||
| export declare const invalidImageInput: (module: string, message: string) => AIError; | ||
| export declare const ImageInputs: { | ||
@@ -20,4 +20,4 @@ readonly dataUrl: (input: Extract<ImageInput, { | ||
| readonly data: Uint8Array; | ||
| } | undefined, LLMError>; | ||
| readonly invalid: (module: string, message: string) => LLMError; | ||
| } | undefined, AIError>; | ||
| readonly invalid: (module: string, message: string) => AIError; | ||
| }; |
| import { Effect, Encoding } from "effect"; | ||
| import { InvalidRequestReason, LLMError } from "../../schema"; | ||
| const invalid = (module, message) => new LLMError({ | ||
| import { InvalidRequestReason, AIError } from "../../schema"; | ||
| const invalid = (module, message) => new AIError({ | ||
| module, | ||
@@ -5,0 +5,0 @@ method: "generate", |
@@ -1,5 +0,5 @@ | ||
| import type { JsonSchema, ModelToolSchemaCompatibility } from "../../schema"; | ||
| import type { JsonSchema, LanguageModelToolSchemaCompatibility } from "../../schema"; | ||
| export declare const ToolSchemaProjection: { | ||
| readonly gemini: (schema: JsonSchema) => JsonSchema; | ||
| readonly modelCompatibility: (schema: JsonSchema, compatibility: ModelToolSchemaCompatibility | undefined) => JsonSchema; | ||
| readonly modelCompatibility: (schema: JsonSchema, compatibility: LanguageModelToolSchemaCompatibility | undefined) => JsonSchema; | ||
| readonly moonshot: (schema: JsonSchema) => JsonSchema; | ||
@@ -6,0 +6,0 @@ readonly openAI: (schema: JsonSchema) => JsonSchema; |
| import { Effect } from "effect"; | ||
| import { LLMError, LLMEvent, type ProviderMetadata } from "../../schema"; | ||
| import { AIError, LLMEvent, type ProviderMetadata } from "../../schema"; | ||
| import { type ToolAccumulator } from "../shared"; | ||
@@ -36,3 +36,3 @@ type StreamKey = string | number; | ||
| export declare const empty: <K extends StreamKey>() => State<K>; | ||
| export declare const isError: <K extends StreamKey>(result: AppendOutcome<K> | LLMError) => result is LLMError; | ||
| export declare const isError: <K extends StreamKey>(result: AppendOutcome<K> | AIError) => result is AIError; | ||
| /** | ||
@@ -56,3 +56,3 @@ * Register a tool call whose start event arrived before any argument deltas. | ||
| readonly text: string; | ||
| }, missingToolMessage: string) => AppendOutcome<K> | LLMError; | ||
| }, missingToolMessage: string) => AppendOutcome<K> | AIError; | ||
| /** | ||
@@ -63,3 +63,3 @@ * Append argument text to a tool that must already have been started. This keeps | ||
| */ | ||
| export declare const appendExisting: <K extends StreamKey>(route: string, tools: State<K>, key: K, text: string, missingToolMessage: string) => AppendOutcome<K> | LLMError; | ||
| export declare const appendExisting: <K extends StreamKey>(route: string, tools: State<K>, key: K, text: string, missingToolMessage: string) => AppendOutcome<K> | AIError; | ||
| /** | ||
@@ -258,3 +258,3 @@ * Finalize one pending tool call: parse the accumulated raw JSON, remove it | ||
| })[]; | ||
| }, LLMError, never>; | ||
| }, AIError, never>; | ||
| /** | ||
@@ -452,3 +452,3 @@ * Finalize one pending tool call with an authoritative final input string. | ||
| })[]; | ||
| }, LLMError, never>; | ||
| }, AIError, never>; | ||
| /** | ||
@@ -643,3 +643,3 @@ * Finalize every pending tool call at once. OpenAI Chat has this shape: it does | ||
| })[]; | ||
| }, LLMError, never>; | ||
| }, AIError, never>; | ||
| export * as ToolStream from "./tool-stream"; |
| import { Effect } from "effect"; | ||
| import { LLMError, LLMEvent } from "../../schema"; | ||
| import { AIError, LLMEvent } from "../../schema"; | ||
| import { eventError, parseToolInput } from "../shared"; | ||
@@ -57,3 +57,3 @@ /** Create empty accumulator state for one provider stream. */ | ||
| }; | ||
| export const isError = (result) => result instanceof LLMError; | ||
| export const isError = (result) => result instanceof AIError; | ||
| /** | ||
@@ -60,0 +60,0 @@ * Register a tool call whose start event arrived before any argument deltas. |
@@ -5,3 +5,3 @@ import { Effect, Encoding, Schema } from "effect"; | ||
| import { Auth } from "../route/auth"; | ||
| import { InvalidProviderOutputReason, LLMError, Usage, mergeHttpOptions, mergeJsonRecords, } from "../schema"; | ||
| import { InvalidProviderOutputReason, AIError, Usage, mergeHttpOptions, mergeJsonRecords, } from "../schema"; | ||
| import { ProviderShared, optionalNull } from "./shared"; | ||
@@ -32,3 +32,3 @@ import { ImageInputs } from "./utils/image-input"; | ||
| }; | ||
| const invalidOutput = (message) => new LLMError({ | ||
| const invalidOutput = (message) => new AIError({ | ||
| module: ADAPTER, | ||
@@ -35,0 +35,0 @@ method: "generate", |
@@ -5,3 +5,3 @@ import { Effect, Schema } from "effect"; | ||
| import { Auth } from "../route/auth"; | ||
| import { InvalidProviderOutputReason, LLMError, mergeHttpOptions, mergeJsonRecords } from "../schema"; | ||
| import { InvalidProviderOutputReason, AIError, mergeHttpOptions, mergeJsonRecords } from "../schema"; | ||
| import { ProviderShared } from "./shared"; | ||
@@ -31,3 +31,3 @@ import { ImageInputs } from "./utils/image-input"; | ||
| }; | ||
| const invalidOutput = (message) => new LLMError({ | ||
| const invalidOutput = (message) => new AIError({ | ||
| module: ADAPTER, | ||
@@ -34,0 +34,0 @@ method: "generate", |
@@ -1,2 +0,2 @@ | ||
| import { LLMError, type HttpContext, type HttpRateLimitDetails, type ProviderMetadata } from "./schema"; | ||
| import { AIError, type HttpContext, type HttpRateLimitDetails, type ProviderMetadata } from "./schema"; | ||
| export declare const isContextOverflow: (message: string) => boolean; | ||
@@ -14,2 +14,2 @@ export declare const isPayloadTooLarge: (message: string) => boolean; | ||
| } | ||
| export declare function classifyProviderFailure(input: ProviderFailure): LLMError["reason"]; | ||
| export declare function classifyProviderFailure(input: ProviderFailure): AIError["reason"]; |
| import { Option, Schema } from "effect"; | ||
| import { AuthenticationReason, ContentPolicyReason, InvalidRequestReason, LLMError, ProviderErrorEvent, ProviderInternalReason, QuotaExceededReason, RateLimitReason, UnknownProviderReason, } from "./schema"; | ||
| import { AuthenticationReason, ContentPolicyReason, InvalidRequestReason, AIError, ProviderErrorEvent, ProviderInternalReason, QuotaExceededReason, RateLimitReason, UnknownProviderReason, } from "./schema"; | ||
| const patterns = [ | ||
@@ -35,3 +35,3 @@ /prompt is too long/i, | ||
| export const isPayloadTooLarge = (message) => payloadPatterns.some((pattern) => pattern.test(message)); | ||
| export const isContextOverflowFailure = (failure) => failure instanceof LLMError | ||
| export const isContextOverflowFailure = (failure) => failure instanceof AIError | ||
| ? failure.reason._tag === "InvalidRequest" && failure.reason.classification === "context-overflow" | ||
@@ -38,0 +38,0 @@ : Schema.is(ProviderErrorEvent)(failure) && failure.classification === "context-overflow"; |
@@ -1,2 +0,2 @@ | ||
| import type { Model, ProviderOptions } from "./schema"; | ||
| import type { LanguageModel, ProviderOptions } from "./schema"; | ||
| export interface Settings extends Readonly<Record<string, unknown>> { | ||
@@ -13,4 +13,4 @@ readonly baseURL?: string; | ||
| export interface Definition<ProviderSettings extends Settings = Settings, Options extends ProviderOptions = ProviderOptions> { | ||
| readonly model: (modelID: string, settings: ProviderSettings) => Model<Options>; | ||
| readonly model: (modelID: string, settings: ProviderSettings) => LanguageModel<Options>; | ||
| } | ||
| export * as ProviderPackage from "./provider-package"; |
@@ -1,3 +0,3 @@ | ||
| import type { Model, ModelID, ProviderID } from "./schema"; | ||
| export type ModelOptions = Pick<Model.Input, "defaults" | "compatibility">; | ||
| import type { LanguageModel, ModelID, ProviderID } from "./schema"; | ||
| export type LanguageModelOptions = Pick<LanguageModel.Input, "defaults" | "compatibility">; | ||
| /** | ||
@@ -9,13 +9,13 @@ * Advanced structural provider definition helper. Built-in providers should | ||
| */ | ||
| export type ModelFactory<Options extends ModelOptions = ModelOptions> = (id: string | ModelID, options?: Options) => Model; | ||
| type AnyModelFactory = (...args: never[]) => Model; | ||
| export interface Definition<Factory extends AnyModelFactory = ModelFactory> { | ||
| export type LanguageModelFactory<Options extends LanguageModelOptions = LanguageModelOptions> = (id: string | ModelID, options?: Options) => LanguageModel; | ||
| type AnyLanguageModelFactory = (...args: never[]) => LanguageModel; | ||
| export interface Definition<Factory extends AnyLanguageModelFactory = LanguageModelFactory> { | ||
| readonly id: ProviderID; | ||
| readonly model: Factory; | ||
| readonly apis?: Record<string, AnyModelFactory>; | ||
| readonly apis?: Record<string, AnyLanguageModelFactory>; | ||
| } | ||
| type DefinitionShape = { | ||
| readonly id: ProviderID; | ||
| readonly model: (...args: never[]) => Model; | ||
| readonly apis?: Record<string, (...args: never[]) => Model>; | ||
| readonly model: (...args: never[]) => LanguageModel; | ||
| readonly apis?: Record<string, (...args: never[]) => LanguageModel>; | ||
| }; | ||
@@ -22,0 +22,0 @@ type NoExtraFields<Input, Shape> = Input & Record<Exclude<keyof Input, keyof Shape>, never>; |
@@ -5,3 +5,3 @@ import type { RouteDefaultsInput } from "../route/client"; | ||
| import type { BedrockCredentials } from "../protocols/bedrock-converse"; | ||
| export declare const id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| export type Config = RouteDefaultsInput & { | ||
@@ -148,4 +148,4 @@ readonly apiKey?: string; | ||
| export declare const configure: (input?: Config) => { | ||
| id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").Model<{ | ||
| id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").LanguageModel<{ | ||
| readonly [x: string]: { | ||
@@ -158,4 +158,4 @@ readonly [x: string]: unknown; | ||
| export declare const provider: { | ||
| id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").Model<{ | ||
| id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").LanguageModel<{ | ||
| readonly [x: string]: { | ||
@@ -166,4 +166,4 @@ readonly [x: string]: unknown; | ||
| configure: (input?: Config) => { | ||
| id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").Model<{ | ||
| id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").LanguageModel<{ | ||
| readonly [x: string]: { | ||
@@ -170,0 +170,0 @@ readonly [x: string]: unknown; |
@@ -9,3 +9,3 @@ import type { ProviderPackage } from "../provider-package"; | ||
| export type AnthropicThinkingInput = AnthropicMessages.ThinkingInput; | ||
| export declare const id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| export type Config = RouteDefaultsInput & ProviderAuthOption<"optional"> & { | ||
@@ -206,11 +206,11 @@ readonly provider?: string; | ||
| export declare const configure: (input: Config) => { | ||
| id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").Model<AnthropicMessages.ProviderOptionsInput>; | ||
| id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").LanguageModel<AnthropicMessages.ProviderOptionsInput>; | ||
| configure: (input: Config) => /*elided*/ any; | ||
| }; | ||
| export declare const provider: { | ||
| id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| configure: (input: Config) => { | ||
| id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").Model<AnthropicMessages.ProviderOptionsInput>; | ||
| id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").LanguageModel<AnthropicMessages.ProviderOptionsInput>; | ||
| configure: /*elided*/ any; | ||
@@ -217,0 +217,0 @@ }; |
@@ -9,3 +9,3 @@ import type { RouteDefaultsInput } from "../route/client"; | ||
| export type AnthropicThinkingInput = AnthropicMessages.ThinkingInput; | ||
| export declare const id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| export declare const routes: import("../route").Route<{ | ||
@@ -204,12 +204,12 @@ readonly model: string; | ||
| export declare const configure: (input?: Config) => { | ||
| id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").Model<AnthropicMessages.ProviderOptionsInput>; | ||
| id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").LanguageModel<AnthropicMessages.ProviderOptionsInput>; | ||
| configure: (input?: Config) => /*elided*/ any; | ||
| }; | ||
| export declare const provider: { | ||
| id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").Model<AnthropicMessages.ProviderOptionsInput>; | ||
| id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").LanguageModel<AnthropicMessages.ProviderOptionsInput>; | ||
| configure: (input?: Config) => { | ||
| id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").Model<AnthropicMessages.ProviderOptionsInput>; | ||
| id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").LanguageModel<AnthropicMessages.ProviderOptionsInput>; | ||
| configure: /*elided*/ any; | ||
@@ -216,0 +216,0 @@ }; |
@@ -6,3 +6,3 @@ import { type AtLeastOne, type ProviderAuthOption } from "../route/auth-options"; | ||
| import { type OpenAIProviderOptionsInput } from "./openai-options"; | ||
| export declare const id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| type AzureURL = AtLeastOne<{ | ||
@@ -12,3 +12,3 @@ readonly resourceName: string; | ||
| }>; | ||
| export type ModelOptions = AzureURL & RouteDefaultsInput & ProviderAuthOption<"optional"> & { | ||
| export type LanguageModelOptions = AzureURL & RouteDefaultsInput & ProviderAuthOption<"optional"> & { | ||
| readonly apiVersion?: string; | ||
@@ -19,3 +19,3 @@ readonly queryParams?: Record<string, string>; | ||
| }; | ||
| export type Config = ModelOptions; | ||
| export type Config = LanguageModelOptions; | ||
| export type Settings = ProviderPackage.Settings & AzureURL & { | ||
@@ -230,15 +230,15 @@ readonly apiKey?: string; | ||
| export declare const configure: (input: Config) => { | ||
| id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").Model<OpenAIProviderOptionsInput>; | ||
| responses: (modelID: string | ModelID) => import("..").Model<OpenAIProviderOptionsInput>; | ||
| chat: (modelID: string | ModelID) => import("..").Model<OpenAIProviderOptionsInput>; | ||
| id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").LanguageModel<OpenAIProviderOptionsInput>; | ||
| responses: (modelID: string | ModelID) => import("..").LanguageModel<OpenAIProviderOptionsInput>; | ||
| chat: (modelID: string | ModelID) => import("..").LanguageModel<OpenAIProviderOptionsInput>; | ||
| configure: (input: Config) => /*elided*/ any; | ||
| }; | ||
| export declare const provider: { | ||
| id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| configure: (input: Config) => { | ||
| id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").Model<OpenAIProviderOptionsInput>; | ||
| responses: (modelID: string | ModelID) => import("..").Model<OpenAIProviderOptionsInput>; | ||
| chat: (modelID: string | ModelID) => import("..").Model<OpenAIProviderOptionsInput>; | ||
| id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").LanguageModel<OpenAIProviderOptionsInput>; | ||
| responses: (modelID: string | ModelID) => import("..").LanguageModel<OpenAIProviderOptionsInput>; | ||
| chat: (modelID: string | ModelID) => import("..").LanguageModel<OpenAIProviderOptionsInput>; | ||
| configure: /*elided*/ any; | ||
@@ -249,3 +249,3 @@ }; | ||
| export declare const chatModel: ProviderPackage.Definition<Settings, OpenAIProviderOptionsInput>["model"]; | ||
| export declare const model: (modelID: string, settings: Settings) => import("..").Model<OpenAIProviderOptionsInput>; | ||
| export declare const model: (modelID: string, settings: Settings) => import("..").LanguageModel<OpenAIProviderOptionsInput>; | ||
| export {}; |
@@ -6,4 +6,4 @@ import type { Config, Redacted } from "effect"; | ||
| import type { OpenAIProviderOptionsInput } from "./openai-options"; | ||
| export declare const aiGatewayID: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| export declare const workersAIID: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| export declare const aiGatewayID: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| export declare const workersAIID: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| export declare const aiGatewayAuthEnvVars: readonly ["CLOUDFLARE_API_TOKEN", "CF_AIG_TOKEN"]; | ||
@@ -321,6 +321,6 @@ export declare const workersAIAuthEnvVars: readonly ["CLOUDFLARE_API_KEY", "CLOUDFLARE_WORKERS_AI_TOKEN"]; | ||
| export declare const CloudflareAIGateway: { | ||
| id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| configure: (options: AIGatewayOptions) => { | ||
| id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").Model<OpenAIProviderOptionsInput>; | ||
| id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").LanguageModel<OpenAIProviderOptionsInput>; | ||
| configure: /*elided*/ any; | ||
@@ -330,6 +330,6 @@ }; | ||
| export declare const CloudflareWorkersAI: { | ||
| id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| configure: (options: WorkersAIOptions) => { | ||
| id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").Model<OpenAIProviderOptionsInput>; | ||
| id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").LanguageModel<OpenAIProviderOptionsInput>; | ||
| configure: /*elided*/ any; | ||
@@ -336,0 +336,0 @@ }; |
@@ -5,4 +5,4 @@ import { type ProviderAuthOption } from "../route/auth-options"; | ||
| import { type OpenAIProviderOptionsInput } from "./openai-options"; | ||
| export declare const id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| export type ModelOptions = Omit<RouteDefaultsInput, "providerOptions"> & ProviderAuthOption<"optional"> & { | ||
| export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| export type LanguageModelOptions = Omit<RouteDefaultsInput, "providerOptions"> & ProviderAuthOption<"optional"> & { | ||
| readonly baseURL: string; | ||
@@ -12,3 +12,3 @@ readonly endpoint?: "chat" | "responses"; | ||
| }; | ||
| export declare const shouldUseResponsesApi: (modelID: string | ModelID, endpoint?: ModelOptions["endpoint"]) => boolean; | ||
| export declare const shouldUseResponsesApi: (modelID: string | ModelID, endpoint?: LanguageModelOptions["endpoint"]) => boolean; | ||
| export declare const routes: (import("../route").Route<{ | ||
@@ -216,18 +216,18 @@ readonly model: string; | ||
| }, import("../route/transport/http").HttpPrepared<string>>)[]; | ||
| export declare const configure: (options: ModelOptions) => { | ||
| id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").Model<OpenAIProviderOptionsInput>; | ||
| responses: (modelID: string | ModelID) => import("..").Model<OpenAIProviderOptionsInput>; | ||
| chat: (modelID: string | ModelID) => import("..").Model<OpenAIProviderOptionsInput>; | ||
| configure: (options: ModelOptions) => /*elided*/ any; | ||
| export declare const configure: (options: LanguageModelOptions) => { | ||
| id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").LanguageModel<OpenAIProviderOptionsInput>; | ||
| responses: (modelID: string | ModelID) => import("..").LanguageModel<OpenAIProviderOptionsInput>; | ||
| chat: (modelID: string | ModelID) => import("..").LanguageModel<OpenAIProviderOptionsInput>; | ||
| configure: (options: LanguageModelOptions) => /*elided*/ any; | ||
| }; | ||
| export declare const provider: { | ||
| id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| configure: (options: ModelOptions) => { | ||
| id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").Model<OpenAIProviderOptionsInput>; | ||
| responses: (modelID: string | ModelID) => import("..").Model<OpenAIProviderOptionsInput>; | ||
| chat: (modelID: string | ModelID) => import("..").Model<OpenAIProviderOptionsInput>; | ||
| id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| configure: (options: LanguageModelOptions) => { | ||
| id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").LanguageModel<OpenAIProviderOptionsInput>; | ||
| responses: (modelID: string | ModelID) => import("..").LanguageModel<OpenAIProviderOptionsInput>; | ||
| chat: (modelID: string | ModelID) => import("..").LanguageModel<OpenAIProviderOptionsInput>; | ||
| configure: /*elided*/ any; | ||
| }; | ||
| }; |
@@ -6,3 +6,3 @@ import type { ProviderPackage } from "../provider-package"; | ||
| import type { OpenAIProviderOptionsInput } from "./openai-options"; | ||
| export declare const id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| export type Config = RouteDefaultsInput & GoogleVertexShared.OAuthOptions & { | ||
@@ -119,11 +119,11 @@ readonly baseURL?: string; | ||
| export declare const configure: (input?: Config) => { | ||
| id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").Model<OpenAIProviderOptionsInput>; | ||
| id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").LanguageModel<OpenAIProviderOptionsInput>; | ||
| configure: (input?: Config) => /*elided*/ any; | ||
| }; | ||
| export declare const provider: { | ||
| id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| configure: (input?: Config) => { | ||
| id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").Model<OpenAIProviderOptionsInput>; | ||
| id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").LanguageModel<OpenAIProviderOptionsInput>; | ||
| configure: /*elided*/ any; | ||
@@ -130,0 +130,0 @@ }; |
@@ -9,3 +9,3 @@ import type { ProviderPackage } from "../provider-package"; | ||
| export type AnthropicThinkingInput = AnthropicMessages.ThinkingInput; | ||
| export declare const id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| export type Config = RouteDefaultsInput & GoogleVertexShared.OAuthOptions & { | ||
@@ -204,11 +204,11 @@ readonly baseURL?: string; | ||
| export declare const configure: (input?: Config) => { | ||
| id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").Model<AnthropicMessages.ProviderOptionsInput>; | ||
| id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").LanguageModel<AnthropicMessages.ProviderOptionsInput>; | ||
| configure: (input?: Config) => /*elided*/ any; | ||
| }; | ||
| export declare const provider: { | ||
| id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| configure: (input?: Config) => { | ||
| id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").Model<AnthropicMessages.ProviderOptionsInput>; | ||
| id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").LanguageModel<AnthropicMessages.ProviderOptionsInput>; | ||
| configure: /*elided*/ any; | ||
@@ -215,0 +215,0 @@ }; |
@@ -6,3 +6,3 @@ import type { ProviderPackage } from "../provider-package"; | ||
| import type { OpenResponsesProviderOptionsInput } from "./open-responses-options"; | ||
| export declare const id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| export type Config = RouteDefaultsInput & GoogleVertexShared.OAuthOptions & { | ||
@@ -111,11 +111,11 @@ readonly baseURL?: string; | ||
| export declare const configure: (input?: Config) => { | ||
| id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").Model<OpenResponsesProviderOptionsInput>; | ||
| id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").LanguageModel<OpenResponsesProviderOptionsInput>; | ||
| configure: (input?: Config) => /*elided*/ any; | ||
| }; | ||
| export declare const provider: { | ||
| id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| configure: (input?: Config) => { | ||
| id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").Model<OpenResponsesProviderOptionsInput>; | ||
| id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").LanguageModel<OpenResponsesProviderOptionsInput>; | ||
| configure: /*elided*/ any; | ||
@@ -122,0 +122,0 @@ }; |
@@ -8,3 +8,3 @@ import type { ProviderPackage } from "../provider-package"; | ||
| export type GeminiProviderOptionsInput = Gemini.ProviderOptionsInput; | ||
| export declare const id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| export type Config = RouteDefaultsInput & GoogleVertexShared.ApiKeyOptions & { | ||
@@ -101,11 +101,11 @@ readonly baseURL?: string; | ||
| export declare const configure: (input?: Config) => { | ||
| id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").Model<Gemini.ProviderOptionsInput>; | ||
| id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").LanguageModel<Gemini.ProviderOptionsInput>; | ||
| configure: (input?: Config) => /*elided*/ any; | ||
| }; | ||
| export declare const provider: { | ||
| id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| configure: (input?: Config) => { | ||
| id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").Model<Gemini.ProviderOptionsInput>; | ||
| id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").LanguageModel<Gemini.ProviderOptionsInput>; | ||
| configure: /*elided*/ any; | ||
@@ -112,0 +112,0 @@ }; |
@@ -9,3 +9,3 @@ import type { RouteDefaultsInput } from "../route/client"; | ||
| export type GeminiProviderOptionsInput = Gemini.ProviderOptionsInput; | ||
| export declare const id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| export declare const routes: import("../route").Route<{ | ||
@@ -93,4 +93,4 @@ readonly contents: readonly { | ||
| export declare const configure: (input?: Config) => { | ||
| id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").Model<Gemini.ProviderOptionsInput>; | ||
| id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").LanguageModel<Gemini.ProviderOptionsInput>; | ||
| image: (modelID: string | ModelID) => import("..").ImageModel<import("./google").GoogleImageOptions>; | ||
@@ -100,8 +100,8 @@ configure: (input?: Config) => /*elided*/ any; | ||
| export declare const provider: { | ||
| id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").Model<Gemini.ProviderOptionsInput>; | ||
| id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").LanguageModel<Gemini.ProviderOptionsInput>; | ||
| image: (modelID: string | ModelID) => import("..").ImageModel<import("./google").GoogleImageOptions>; | ||
| configure: (input?: Config) => { | ||
| id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").Model<Gemini.ProviderOptionsInput>; | ||
| id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").LanguageModel<Gemini.ProviderOptionsInput>; | ||
| image: (modelID: string | ModelID) => import("..").ImageModel<import("./google").GoogleImageOptions>; | ||
@@ -108,0 +108,0 @@ configure: /*elided*/ any; |
@@ -7,3 +7,3 @@ import type { ProviderPackage } from "../provider-package"; | ||
| export type { OpenResponsesOptionsInput, OpenResponsesProviderOptionsInput } from "./open-responses-options"; | ||
| export declare const id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| export type Config = RouteDefaultsInput & ProviderAuthOption<"optional"> & { | ||
@@ -109,11 +109,11 @@ readonly provider?: string; | ||
| export declare const configure: (input: Config) => { | ||
| id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").Model<OpenResponsesProviderOptionsInput>; | ||
| id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").LanguageModel<OpenResponsesProviderOptionsInput>; | ||
| configure: (input: Config) => /*elided*/ any; | ||
| }; | ||
| export declare const provider: { | ||
| id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| configure: (input: Config) => { | ||
| id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").Model<OpenResponsesProviderOptionsInput>; | ||
| id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").LanguageModel<OpenResponsesProviderOptionsInput>; | ||
| configure: /*elided*/ any; | ||
@@ -120,0 +120,0 @@ }; |
@@ -6,3 +6,3 @@ import { type ModelID } from "../schema"; | ||
| import type { OpenAIProviderOptionsInput } from "./openai-options"; | ||
| export declare const id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| type GenericModelOptions = Omit<RouteDefaultsInput, "providerOptions"> & ProviderAuthOption<"optional"> & { | ||
@@ -119,11 +119,11 @@ readonly provider?: string; | ||
| export declare const configure: (input: GenericModelOptions) => { | ||
| id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").Model<OpenAIProviderOptionsInput>; | ||
| id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").LanguageModel<OpenAIProviderOptionsInput>; | ||
| configure: (input: GenericModelOptions) => /*elided*/ any; | ||
| }; | ||
| export declare const provider: { | ||
| id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| configure: (input: GenericModelOptions) => { | ||
| id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").Model<OpenAIProviderOptionsInput>; | ||
| id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").LanguageModel<OpenAIProviderOptionsInput>; | ||
| configure: /*elided*/ any; | ||
@@ -134,36 +134,36 @@ }; | ||
| export declare const baseten: { | ||
| id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").Model<OpenAIProviderOptionsInput>; | ||
| id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").LanguageModel<OpenAIProviderOptionsInput>; | ||
| configure: (input?: FamilyModelOptions) => /*elided*/ any; | ||
| }; | ||
| export declare const cerebras: { | ||
| id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").Model<OpenAIProviderOptionsInput>; | ||
| id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").LanguageModel<OpenAIProviderOptionsInput>; | ||
| configure: (input?: FamilyModelOptions) => /*elided*/ any; | ||
| }; | ||
| export declare const deepinfra: { | ||
| id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").Model<OpenAIProviderOptionsInput>; | ||
| id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").LanguageModel<OpenAIProviderOptionsInput>; | ||
| configure: (input?: FamilyModelOptions) => /*elided*/ any; | ||
| }; | ||
| export declare const deepseek: { | ||
| id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").Model<OpenAIProviderOptionsInput>; | ||
| id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").LanguageModel<OpenAIProviderOptionsInput>; | ||
| configure: (input?: FamilyModelOptions) => /*elided*/ any; | ||
| }; | ||
| export declare const fireworks: { | ||
| id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").Model<OpenAIProviderOptionsInput>; | ||
| id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").LanguageModel<OpenAIProviderOptionsInput>; | ||
| configure: (input?: FamilyModelOptions) => /*elided*/ any; | ||
| }; | ||
| export declare const groq: { | ||
| id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").Model<OpenAIProviderOptionsInput>; | ||
| id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").LanguageModel<OpenAIProviderOptionsInput>; | ||
| configure: (input?: FamilyModelOptions) => /*elided*/ any; | ||
| }; | ||
| export declare const togetherai: { | ||
| id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").Model<OpenAIProviderOptionsInput>; | ||
| id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").LanguageModel<OpenAIProviderOptionsInput>; | ||
| configure: (input?: FamilyModelOptions) => /*elided*/ any; | ||
| }; | ||
| export {}; |
@@ -9,3 +9,3 @@ import { type ProviderAuthOption } from "../route/auth-options"; | ||
| export type { OpenAIImageOptions } from "../protocols/openai-images"; | ||
| export declare const id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| export declare const routes: (Route<{ | ||
@@ -345,7 +345,7 @@ readonly model: string; | ||
| export declare const configure: (input?: Config) => { | ||
| id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| model: (id: string | ModelID) => import("..").Model<OpenAIProviderOptionsInput>; | ||
| responses: (id: string | ModelID) => import("..").Model<OpenAIProviderOptionsInput>; | ||
| responsesWebSocket: (id: string | ModelID) => import("..").Model<OpenAIProviderOptionsInput>; | ||
| chat: (id: string | ModelID) => import("..").Model<OpenAIProviderOptionsInput>; | ||
| id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| model: (id: string | ModelID) => import("..").LanguageModel<OpenAIProviderOptionsInput>; | ||
| responses: (id: string | ModelID) => import("..").LanguageModel<OpenAIProviderOptionsInput>; | ||
| responsesWebSocket: (id: string | ModelID) => import("..").LanguageModel<OpenAIProviderOptionsInput>; | ||
| chat: (id: string | ModelID) => import("..").LanguageModel<OpenAIProviderOptionsInput>; | ||
| image: (modelID: string | ModelID) => import("..").ImageModel<import("./openai").OpenAIImageOptions>; | ||
@@ -355,14 +355,14 @@ configure: (input?: Config) => /*elided*/ any; | ||
| export declare const provider: { | ||
| id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| model: (id: string | ModelID) => import("..").Model<OpenAIProviderOptionsInput>; | ||
| responses: (id: string | ModelID) => import("..").Model<OpenAIProviderOptionsInput>; | ||
| responsesWebSocket: (id: string | ModelID) => import("..").Model<OpenAIProviderOptionsInput>; | ||
| chat: (id: string | ModelID) => import("..").Model<OpenAIProviderOptionsInput>; | ||
| id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| model: (id: string | ModelID) => import("..").LanguageModel<OpenAIProviderOptionsInput>; | ||
| responses: (id: string | ModelID) => import("..").LanguageModel<OpenAIProviderOptionsInput>; | ||
| responsesWebSocket: (id: string | ModelID) => import("..").LanguageModel<OpenAIProviderOptionsInput>; | ||
| chat: (id: string | ModelID) => import("..").LanguageModel<OpenAIProviderOptionsInput>; | ||
| image: (modelID: string | ModelID) => import("..").ImageModel<import("./openai").OpenAIImageOptions>; | ||
| configure: (input?: Config) => { | ||
| id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| model: (id: string | ModelID) => import("..").Model<OpenAIProviderOptionsInput>; | ||
| responses: (id: string | ModelID) => import("..").Model<OpenAIProviderOptionsInput>; | ||
| responsesWebSocket: (id: string | ModelID) => import("..").Model<OpenAIProviderOptionsInput>; | ||
| chat: (id: string | ModelID) => import("..").Model<OpenAIProviderOptionsInput>; | ||
| id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| model: (id: string | ModelID) => import("..").LanguageModel<OpenAIProviderOptionsInput>; | ||
| responses: (id: string | ModelID) => import("..").LanguageModel<OpenAIProviderOptionsInput>; | ||
| responsesWebSocket: (id: string | ModelID) => import("..").LanguageModel<OpenAIProviderOptionsInput>; | ||
| chat: (id: string | ModelID) => import("..").LanguageModel<OpenAIProviderOptionsInput>; | ||
| image: (modelID: string | ModelID) => import("..").ImageModel<import("./openai").OpenAIImageOptions>; | ||
@@ -374,5 +374,5 @@ configure: /*elided*/ any; | ||
| export declare const chatModel: ProviderPackage.Definition<Settings, OpenAIProviderOptionsInput>["model"]; | ||
| export declare const responses: (id: string | ModelID) => import("..").Model<OpenAIProviderOptionsInput>; | ||
| export declare const responsesWebSocket: (id: string | ModelID) => import("..").Model<OpenAIProviderOptionsInput>; | ||
| export declare const chat: (id: string | ModelID) => import("..").Model<OpenAIProviderOptionsInput>; | ||
| export declare const responses: (id: string | ModelID) => import("..").LanguageModel<OpenAIProviderOptionsInput>; | ||
| export declare const responsesWebSocket: (id: string | ModelID) => import("..").LanguageModel<OpenAIProviderOptionsInput>; | ||
| export declare const chat: (id: string | ModelID) => import("..").LanguageModel<OpenAIProviderOptionsInput>; | ||
| export declare const image: (modelID: string | ModelID) => import("..").ImageModel<import("./openai").OpenAIImageOptions>; |
@@ -12,3 +12,3 @@ import { Schema } from "effect"; | ||
| }; | ||
| export declare const id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| type OpenRouterString<Known extends string> = Known | (string & {}); | ||
@@ -84,3 +84,3 @@ export interface OpenRouterProviderRouting { | ||
| }; | ||
| export type ModelOptions = Omit<RouteDefaultsInput, "providerOptions"> & ProviderAuthOption<"optional"> & { | ||
| export type LanguageModelOptions = Omit<RouteDefaultsInput, "providerOptions"> & ProviderAuthOption<"optional"> & { | ||
| readonly baseURL?: string; | ||
@@ -516,13 +516,13 @@ readonly providerOptions?: OpenRouterProviderOptionsInput; | ||
| }, import("../route/transport/http").HttpPrepared<string>>[]; | ||
| export declare const configure: (input?: ModelOptions) => { | ||
| id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").Model<OpenRouterProviderOptionsInput>; | ||
| configure: (input?: ModelOptions) => /*elided*/ any; | ||
| export declare const configure: (input?: LanguageModelOptions) => { | ||
| id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").LanguageModel<OpenRouterProviderOptionsInput>; | ||
| configure: (input?: LanguageModelOptions) => /*elided*/ any; | ||
| }; | ||
| export declare const provider: { | ||
| id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").Model<OpenRouterProviderOptionsInput>; | ||
| configure: (input?: ModelOptions) => { | ||
| id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").Model<OpenRouterProviderOptionsInput>; | ||
| id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").LanguageModel<OpenRouterProviderOptionsInput>; | ||
| configure: (input?: LanguageModelOptions) => { | ||
| id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").LanguageModel<OpenRouterProviderOptionsInput>; | ||
| configure: /*elided*/ any; | ||
@@ -529,0 +529,0 @@ }; |
+19
-19
@@ -6,7 +6,7 @@ import { type ProviderAuthOption } from "../route/auth-options"; | ||
| import type { ProviderPackage } from "../provider-package"; | ||
| export declare const id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| export type XAIProviderOptionsInput = ProviderOptions & { | ||
| readonly xai?: OpenAIOptionsInput; | ||
| }; | ||
| export type ModelOptions = Omit<RouteDefaultsInput, "providerOptions"> & ProviderAuthOption<"optional"> & { | ||
| export type LanguageModelOptions = Omit<RouteDefaultsInput, "providerOptions"> & ProviderAuthOption<"optional"> & { | ||
| readonly baseURL?: string; | ||
@@ -223,21 +223,21 @@ readonly providerOptions?: XAIProviderOptionsInput; | ||
| }, import("../route/transport/http").HttpPrepared<string>>)[]; | ||
| export declare const configure: (input?: ModelOptions) => { | ||
| id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").Model<XAIProviderOptionsInput>; | ||
| responses: (modelID: string | ModelID) => import("..").Model<XAIProviderOptionsInput>; | ||
| chat: (modelID: string | ModelID) => import("..").Model<XAIProviderOptionsInput>; | ||
| export declare const configure: (input?: LanguageModelOptions) => { | ||
| id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").LanguageModel<XAIProviderOptionsInput>; | ||
| responses: (modelID: string | ModelID) => import("..").LanguageModel<XAIProviderOptionsInput>; | ||
| chat: (modelID: string | ModelID) => import("..").LanguageModel<XAIProviderOptionsInput>; | ||
| image: (modelID: string | ModelID) => import("..").ImageModel<import("./xai").XAIImageOptions>; | ||
| configure: (input?: ModelOptions) => /*elided*/ any; | ||
| configure: (input?: LanguageModelOptions) => /*elided*/ any; | ||
| }; | ||
| export declare const provider: { | ||
| id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").Model<XAIProviderOptionsInput>; | ||
| responses: (modelID: string | ModelID) => import("..").Model<XAIProviderOptionsInput>; | ||
| chat: (modelID: string | ModelID) => import("..").Model<XAIProviderOptionsInput>; | ||
| id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").LanguageModel<XAIProviderOptionsInput>; | ||
| responses: (modelID: string | ModelID) => import("..").LanguageModel<XAIProviderOptionsInput>; | ||
| chat: (modelID: string | ModelID) => import("..").LanguageModel<XAIProviderOptionsInput>; | ||
| image: (modelID: string | ModelID) => import("..").ImageModel<import("./xai").XAIImageOptions>; | ||
| configure: (input?: ModelOptions) => { | ||
| id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").Model<XAIProviderOptionsInput>; | ||
| responses: (modelID: string | ModelID) => import("..").Model<XAIProviderOptionsInput>; | ||
| chat: (modelID: string | ModelID) => import("..").Model<XAIProviderOptionsInput>; | ||
| configure: (input?: LanguageModelOptions) => { | ||
| id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| model: (modelID: string | ModelID) => import("..").LanguageModel<XAIProviderOptionsInput>; | ||
| responses: (modelID: string | ModelID) => import("..").LanguageModel<XAIProviderOptionsInput>; | ||
| chat: (modelID: string | ModelID) => import("..").LanguageModel<XAIProviderOptionsInput>; | ||
| image: (modelID: string | ModelID) => import("..").ImageModel<import("./xai").XAIImageOptions>; | ||
@@ -248,4 +248,4 @@ configure: /*elided*/ any; | ||
| export declare const model: ProviderPackage.Definition<Settings, XAIProviderOptionsInput>["model"]; | ||
| export declare const responses: (modelID: string | ModelID) => import("..").Model<XAIProviderOptionsInput>; | ||
| export declare const chat: (modelID: string | ModelID) => import("..").Model<XAIProviderOptionsInput>; | ||
| export declare const responses: (modelID: string | ModelID) => import("..").LanguageModel<XAIProviderOptionsInput>; | ||
| export declare const chat: (modelID: string | ModelID) => import("..").LanguageModel<XAIProviderOptionsInput>; | ||
| export declare const image: (modelID: string | ModelID) => import("..").ImageModel<import("./xai").XAIImageOptions>; |
| import { type ProviderAuthOption } from "../route/auth-options"; | ||
| import { HttpOptions, type ModelID } from "../schema"; | ||
| export declare const id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| export type Config = ProviderAuthOption<"optional"> & { | ||
@@ -11,3 +11,3 @@ readonly baseURL?: string; | ||
| export declare const configure: (input?: Config) => { | ||
| id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| image: (modelID: string | ModelID) => import("..").ImageModel<import("./zai").ZAIImageOptions>; | ||
@@ -17,6 +17,6 @@ configure: (input?: Config) => /*elided*/ any; | ||
| export declare const provider: { | ||
| id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| image: (modelID: string | ModelID) => import("..").ImageModel<import("./zai").ZAIImageOptions>; | ||
| configure: (input?: Config) => { | ||
| id: string & import("effect/Brand").Brand<"LLM.ProviderID">; | ||
| id: string & import("effect/Brand").Brand<"AI.ProviderID">; | ||
| image: (modelID: string | ModelID) => import("..").ImageModel<import("./zai").ZAIImageOptions>; | ||
@@ -23,0 +23,0 @@ configure: /*elided*/ any; |
@@ -17,5 +17,5 @@ import type { Config, Redacted } from "effect"; | ||
| export type ProviderAuthOption<Mode extends ApiKeyMode> = AuthOverride | (Mode extends "optional" ? OptionalApiKeyAuth : RequiredApiKeyAuth); | ||
| export type ModelOptions<Base, Mode extends ApiKeyMode> = Omit<Base, "apiKey" | "auth"> & ProviderAuthOption<Mode>; | ||
| export type ModelArgs<Base, Mode extends ApiKeyMode> = Mode extends "optional" ? readonly [options?: ModelOptions<Base, Mode>] : readonly [options: ModelOptions<Base, Mode>]; | ||
| export type ModelFactory<Base, Mode extends ApiKeyMode, Model> = (id: string, ...args: ModelArgs<Base, Mode>) => Model; | ||
| export type LanguageModelOptions<Base, Mode extends ApiKeyMode> = Omit<Base, "apiKey" | "auth"> & ProviderAuthOption<Mode>; | ||
| export type LanguageModelArgs<Base, Mode extends ApiKeyMode> = Mode extends "optional" ? readonly [options?: LanguageModelOptions<Base, Mode>] : readonly [options: LanguageModelOptions<Base, Mode>]; | ||
| export type LanguageModelFactory<Base, Mode extends ApiKeyMode, LanguageModel> = (id: string, ...args: LanguageModelArgs<Base, Mode>) => LanguageModel; | ||
| /** | ||
@@ -22,0 +22,0 @@ * Require at least one of the keys in `T`. Use for option shapes where any |
| import { Config, Effect, Redacted } from "effect"; | ||
| import { Headers } from "effect/unstable/http"; | ||
| import { LLMError, type HttpOptions } from "../schema"; | ||
| import { AIError, type HttpOptions } from "../schema"; | ||
| export declare class MissingCredentialError extends Error { | ||
@@ -10,3 +10,3 @@ readonly source: string; | ||
| export type CredentialError = MissingCredentialError | Config.ConfigError; | ||
| export type AuthError = CredentialError | LLMError; | ||
| export type AuthError = CredentialError | AIError; | ||
| type Secret = string | Redacted.Redacted | Config.Config<string | Redacted.Redacted>; | ||
@@ -43,3 +43,3 @@ export interface AuthInput { | ||
| export declare const remove: (name: string) => Definition; | ||
| export declare const custom: (apply: (input: AuthInput) => Effect.Effect<Headers.Headers, LLMError>) => Definition; | ||
| export declare const custom: (apply: (input: AuthInput) => Effect.Effect<Headers.Headers, AIError>) => Definition; | ||
| export declare const passthrough: Definition; | ||
@@ -52,3 +52,3 @@ export declare function bearer(source: Secret | Credential): Definition; | ||
| export declare function bearerHeader(name: string, source: Secret | Credential): Definition; | ||
| export declare const toEffect: (input: Definition) => (authInput: AuthInput) => Effect.Effect<Headers.Headers, LLMError>; | ||
| export declare const toEffect: (input: Definition) => (authInput: AuthInput) => Effect.Effect<Headers.Headers, AIError>; | ||
| export * as Auth from "./auth"; |
| import { Config, Effect, Redacted } from "effect"; | ||
| import { Headers } from "effect/unstable/http"; | ||
| import { AuthenticationReason, InvalidRequestReason, LLMError } from "../schema"; | ||
| import { AuthenticationReason, InvalidRequestReason, AIError } from "../schema"; | ||
| export class MissingCredentialError extends Error { | ||
@@ -76,5 +76,5 @@ source; | ||
| } | ||
| const toLLMError = (error) => { | ||
| const toAIError = (error) => { | ||
| if (error instanceof MissingCredentialError || error instanceof Config.ConfigError) { | ||
| return new LLMError({ | ||
| return new AIError({ | ||
| module: "Auth", | ||
@@ -89,3 +89,3 @@ method: "apply", | ||
| }; | ||
| export const toEffect = (input) => (authInput) => input.apply(authInput).pipe(Effect.mapError(toLLMError)); | ||
| export const toEffect = (input) => (authInput) => input.apply(authInput).pipe(Effect.mapError(toAIError)); | ||
| export * as Auth from "./auth"; |
+18
-18
@@ -9,4 +9,4 @@ import { Context, Effect, Layer, Schema, Stream } from "effect"; | ||
| import type { Protocol } from "./protocol"; | ||
| import type { LLMError, ProtocolID, ProviderOptions } from "../schema"; | ||
| import { GenerationOptions, HttpOptions, LLMRequest, LLMResponse, Model, ModelLimits, LLMEvent, ProviderID } from "../schema"; | ||
| import type { ProtocolID, ProviderOptions } from "../schema"; | ||
| import { AIError, GenerationOptions, HttpOptions, LLMRequest, LLMResponse, LanguageModel, LanguageModelLimits, LLMEvent, ProviderID } from "../schema"; | ||
| export interface RouteBody<Body> { | ||
@@ -16,3 +16,3 @@ /** Schema for the validated provider-native body sent as the JSON request. */ | ||
| /** Build the provider-native body from a common `LLMRequest`. */ | ||
| readonly from: (request: LLMRequest) => Effect.Effect<Body, LLMError>; | ||
| readonly from: (request: LLMRequest) => Effect.Effect<Body, AIError>; | ||
| } | ||
@@ -31,13 +31,13 @@ export interface Route<Body, Prepared = unknown> { | ||
| readonly with: (patch: RoutePatch<Body, Prepared>) => Route<Body, Prepared>; | ||
| readonly model: <Options extends ProviderOptions = ProviderOptions>(input: RouteMappedModelInput) => Model<Options>; | ||
| readonly prepareTransport: (body: Body, request: LLMRequest, options?: StreamOptions) => Effect.Effect<Prepared, LLMError>; | ||
| readonly streamPrepared: (prepared: Prepared, request: LLMRequest, runtime: TransportRuntime) => Stream.Stream<LLMEvent, LLMError>; | ||
| readonly model: <Options extends ProviderOptions = ProviderOptions>(input: RouteMappedLanguageModelInput) => LanguageModel<Options>; | ||
| readonly prepareTransport: (body: Body, request: LLMRequest, options?: StreamOptions) => Effect.Effect<Prepared, AIError>; | ||
| readonly streamPrepared: (prepared: Prepared, request: LLMRequest, runtime: TransportRuntime) => Stream.Stream<LLMEvent, AIError>; | ||
| } | ||
| export type AnyRoute = Route<any, any>; | ||
| export type HttpOptionsInput = HttpOptions.Input; | ||
| export type RouteModelInput = Omit<Model.Input, "provider" | "route">; | ||
| export type RouteRoutedModelInput = Omit<Model.Input, "route">; | ||
| export type RouteLanguageModelInput = Omit<LanguageModel.Input, "provider" | "route">; | ||
| export type RouteRoutedLanguageModelInput = Omit<LanguageModel.Input, "route">; | ||
| export interface RouteDefaults { | ||
| readonly headers?: Record<string, string>; | ||
| readonly limits?: ModelLimits; | ||
| readonly limits?: LanguageModelLimits; | ||
| readonly generation?: GenerationOptions; | ||
@@ -49,3 +49,3 @@ readonly providerOptions?: ProviderOptions; | ||
| readonly headers?: Record<string, string>; | ||
| readonly limits?: ModelLimits.Input; | ||
| readonly limits?: LanguageModelLimits.Input; | ||
| readonly generation?: GenerationOptions.Input; | ||
@@ -62,3 +62,3 @@ readonly providerOptions?: ProviderOptions; | ||
| } | ||
| type RouteMappedModelInput = RouteModelInput | RouteRoutedModelInput; | ||
| type RouteMappedLanguageModelInput = RouteLanguageModelInput | RouteRoutedLanguageModelInput; | ||
| export declare const generationOptions: (input: GenerationOptions.Input | undefined) => GenerationOptions | undefined; | ||
@@ -74,6 +74,6 @@ export declare const httpOptions: (input: HttpOptionsInput | undefined) => HttpOptions | undefined; | ||
| export interface StreamMethod { | ||
| (request: LLMRequest, options?: StreamOptions): Stream.Stream<LLMEvent, LLMError>; | ||
| (request: LLMRequest, options?: StreamOptions): Stream.Stream<LLMEvent, AIError>; | ||
| } | ||
| export interface GenerateMethod { | ||
| (request: LLMRequest, options?: StreamOptions): Effect.Effect<LLMResponse, LLMError>; | ||
| (request: LLMRequest, options?: StreamOptions): Effect.Effect<LLMResponse, AIError>; | ||
| } | ||
@@ -149,3 +149,3 @@ declare const Service_base: Context.ServiceClass<Service, "@opencode/LLMClient", Interface>; | ||
| protocol: string; | ||
| model: Model<{ | ||
| model: LanguageModel<{ | ||
| readonly [x: string]: { | ||
@@ -159,5 +159,5 @@ readonly [x: string]: unknown; | ||
| }; | ||
| }, LLMError, never>; | ||
| export declare function stream(request: LLMRequest, options?: StreamOptions): Stream.Stream<LLMEvent, LLMError>; | ||
| export declare function generate(request: LLMRequest, options?: StreamOptions): Effect.Effect<LLMResponse, LLMError>; | ||
| }, AIError, never>; | ||
| export declare function stream(request: LLMRequest, options?: StreamOptions): Stream.Stream<LLMEvent, AIError>; | ||
| export declare function generate(request: LLMRequest, options?: StreamOptions): Effect.Effect<LLMResponse, AIError>; | ||
| export declare const streamRequest: (request: LLMRequest, options?: StreamOptions) => Stream.Stream<{ | ||
@@ -344,3 +344,3 @@ readonly type: "step-start"; | ||
| readonly classification?: "context-overflow" | "payload-too-large" | undefined; | ||
| }, LLMError, Service>; | ||
| }, AIError, Service>; | ||
| export declare const layer: Layer.Layer<Service, never, RequestExecutor.Service>; | ||
@@ -347,0 +347,0 @@ export declare const Route: { |
@@ -11,4 +11,4 @@ import { Cause, Context, Effect, Layer, Schema, Stream } from "effect"; | ||
| import * as ProviderShared from "../protocols/shared"; | ||
| import { GenerationOptions, HttpOptions, LLMRequest, LLMResponse, Model, ModelLimits, LLMError as LLMErrorClass, LLMEvent, ProviderID, mergeGenerationOptions, mergeHttpOptions, mergeProviderOptions, } from "../schema"; | ||
| const makeRouteModel = (route, mapped) => { | ||
| import { AIError, GenerationOptions, HttpOptions, LLMRequest, LLMResponse, LanguageModel, LanguageModelLimits, LLMEvent, ProviderID, mergeGenerationOptions, mergeHttpOptions, mergeProviderOptions, } from "../schema"; | ||
| const makeRouteLanguageModel = (route, mapped) => { | ||
| const provider = route.provider ?? ("provider" in mapped ? mapped.provider : undefined); | ||
@@ -19,3 +19,3 @@ if (!provider) | ||
| throw new Error(`Route.model(${route.id}) requires an endpoint baseURL — configure it on the route first`); | ||
| return Model.make({ | ||
| return LanguageModel.make({ | ||
| ...mapped, | ||
@@ -32,3 +32,3 @@ provider, | ||
| headers, | ||
| limits: patch.limits === undefined ? base?.limits : ModelLimits.make(patch.limits), | ||
| limits: patch.limits === undefined ? base?.limits : LanguageModelLimits.make(patch.limits), | ||
| generation: mergeGenerationOptions(generationOptions(base?.generation), generationOptions(patch.generation)), | ||
@@ -66,3 +66,3 @@ providerOptions: mergeProviderOptions(base?.providerOptions, patch.providerOptions), | ||
| const failed = cause.reasons.find(Cause.isFailReason)?.error; | ||
| if (failed instanceof LLMErrorClass) | ||
| if (failed instanceof AIError) | ||
| return failed; | ||
@@ -111,3 +111,3 @@ return ProviderShared.eventError(route, message, Cause.pretty(cause)); | ||
| }, | ||
| model: (input) => makeRouteModel(route, input), | ||
| model: (input) => makeRouteLanguageModel(route, input), | ||
| prepareTransport: (body, request, options) => routeInput.transport.prepare({ | ||
@@ -114,0 +114,0 @@ body, |
| import { Context, Effect, Layer } from "effect"; | ||
| import { HttpClient, HttpClientRequest, HttpClientResponse } from "effect/unstable/http"; | ||
| import { LLMError } from "../schema"; | ||
| import { AIError } from "../schema"; | ||
| export interface Interface { | ||
| readonly execute: (request: HttpClientRequest.HttpClientRequest) => Effect.Effect<HttpClientResponse.HttpClientResponse, LLMError>; | ||
| readonly execute: (request: HttpClientRequest.HttpClientRequest) => Effect.Effect<HttpClientResponse.HttpClientResponse, AIError>; | ||
| } | ||
| declare const Service_base: Context.ServiceClass<Service, "@opencode/LLM/RequestExecutor", Interface>; | ||
| declare const Service_base: Context.ServiceClass<Service, "@opencode/AI/RequestExecutor", Interface>; | ||
| export declare class Service extends Service_base { | ||
@@ -9,0 +9,0 @@ } |
| import { Cause, Context, Effect, Layer } from "effect"; | ||
| import { FetchHttpClient, Headers, HttpClient, HttpClientError, HttpClientRequest, HttpClientResponse, } from "effect/unstable/http"; | ||
| import { HttpContext, HttpRateLimitDetails, HttpRequestDetails, HttpResponseDetails, LLMError, TransportReason, } from "../schema"; | ||
| import { HttpContext, HttpRateLimitDetails, HttpRequestDetails, HttpResponseDetails, AIError, TransportReason, } from "../schema"; | ||
| import { classifyProviderFailure } from "../provider-error"; | ||
| export class Service extends Context.Service()("@opencode/LLM/RequestExecutor") { | ||
| export class Service extends Context.Service()("@opencode/AI/RequestExecutor") { | ||
| } | ||
@@ -166,3 +166,3 @@ const BODY_LIMIT = 16_384; | ||
| const details = responseBody(body, request); | ||
| return yield* new LLMError({ | ||
| return yield* new AIError({ | ||
| module: "RequestExecutor", | ||
@@ -187,3 +187,3 @@ method: "execute", | ||
| const toHttpError = (redactedNames) => (error) => { | ||
| const transportError = (input) => new LLMError({ | ||
| const transportError = (input) => new AIError({ | ||
| module: "RequestExecutor", | ||
@@ -190,0 +190,0 @@ method: "execute", |
| import type { Stream } from "effect"; | ||
| import type { LLMError } from "../schema"; | ||
| import type { AIError } from "../schema"; | ||
| /** | ||
@@ -19,3 +19,3 @@ * Decode a streaming HTTP response body into provider-protocol frames. | ||
| readonly id: string; | ||
| readonly frame: (bytes: Stream.Stream<Uint8Array, LLMError>) => Stream.Stream<Frame, LLMError>; | ||
| readonly frame: (bytes: Stream.Stream<Uint8Array, AIError>) => Stream.Stream<Frame, AIError>; | ||
| } | ||
@@ -22,0 +22,0 @@ /** Server-Sent Events framing. Used by every JSON-streaming HTTP provider. */ |
| export { Route, LLMClient } from "./client"; | ||
| export type { Route as RouteShape, RouteModelInput, RouteRoutedModelInput, RouteDefaults, RouteDefaultsInput, AnyRoute, Interface as LLMClientShape, Service as LLMClientService, StreamOptions, } from "./client"; | ||
| export type { Route as RouteShape, RouteLanguageModelInput, RouteRoutedLanguageModelInput, RouteDefaults, RouteDefaultsInput, AnyRoute, Interface as LLMClientShape, Service as LLMClientService, StreamOptions, } from "./client"; | ||
| export * from "./executor"; | ||
@@ -4,0 +4,0 @@ export { Auth } from "./auth"; |
| import { Schema, type Effect } from "effect"; | ||
| import type { LLMError, LLMEvent, LLMRequest, ProtocolID } from "../schema"; | ||
| import type { AIError, LLMEvent, LLMRequest, ProtocolID } from "../schema"; | ||
| /** | ||
@@ -48,3 +48,3 @@ * The semantic API contract of one model server family. | ||
| /** Build the provider-native body from a common `LLMRequest`. */ | ||
| readonly from: (request: LLMRequest) => Effect.Effect<Body, LLMError>; | ||
| readonly from: (request: LLMRequest) => Effect.Effect<Body, AIError>; | ||
| } | ||
@@ -57,3 +57,3 @@ export interface ProtocolStream<Frame, Event, State> { | ||
| /** Translate one event into emitted `LLMEvent`s plus the next state. */ | ||
| readonly step: (state: State, event: Event) => Effect.Effect<readonly [State, ReadonlyArray<LLMEvent>], LLMError>; | ||
| readonly step: (state: State, event: Event) => Effect.Effect<readonly [State, ReadonlyArray<LLMEvent>], AIError>; | ||
| /** Optional request-completion signal for transports that do not end naturally. */ | ||
@@ -60,0 +60,0 @@ readonly terminal?: (event: Event) => boolean; |
@@ -21,3 +21,3 @@ import { Effect } from "effect"; | ||
| headers: Headers.Headers; | ||
| }, import("../..").LLMError, never>; | ||
| }, import("../..").AIError, never>; | ||
| export interface HttpJsonInput<_Body, Frame> { | ||
@@ -24,0 +24,0 @@ readonly framing: Framing.Definition<Frame>; |
@@ -6,3 +6,3 @@ import type { Effect, Stream } from "effect"; | ||
| import type { Interface as WebSocketExecutorInterface } from "./websocket"; | ||
| import type { LLMError, LLMRequest } from "../../schema"; | ||
| import type { AIError, LLMRequest } from "../../schema"; | ||
| export interface TransportRuntime { | ||
@@ -21,4 +21,4 @@ readonly http: RequestExecutorInterface; | ||
| readonly id: string; | ||
| readonly prepare: (input: TransportPrepareInput<Body>) => Effect.Effect<Prepared, LLMError>; | ||
| readonly frames: (prepared: Prepared, request: LLMRequest, runtime: TransportRuntime) => Stream.Stream<Frame, LLMError>; | ||
| readonly prepare: (input: TransportPrepareInput<Body>) => Effect.Effect<Prepared, AIError>; | ||
| readonly frames: (prepared: Prepared, request: LLMRequest, runtime: TransportRuntime) => Stream.Stream<Frame, AIError>; | ||
| } | ||
@@ -25,0 +25,0 @@ export interface TransportPrepareInput<Body> { |
| import { Context, Effect, Layer, Stream } from "effect"; | ||
| import { Headers } from "effect/unstable/http"; | ||
| import { LLMError } from "../../schema"; | ||
| import { AIError } from "../../schema"; | ||
| import type { Transport } from "./index"; | ||
@@ -10,15 +10,15 @@ export interface WebSocketRequest { | ||
| export interface WebSocketConnection { | ||
| readonly sendText: (message: string) => Effect.Effect<void, LLMError>; | ||
| readonly messages: Stream.Stream<string | Uint8Array, LLMError>; | ||
| readonly sendText: (message: string) => Effect.Effect<void, AIError>; | ||
| readonly messages: Stream.Stream<string | Uint8Array, AIError>; | ||
| readonly close: Effect.Effect<void, never>; | ||
| } | ||
| export interface Interface { | ||
| readonly open: (input: WebSocketRequest) => Effect.Effect<WebSocketConnection, LLMError>; | ||
| readonly open: (input: WebSocketRequest) => Effect.Effect<WebSocketConnection, AIError>; | ||
| } | ||
| declare const Service_base: Context.ServiceClass<Service, "@opencode/LLM/WebSocketExecutor", Interface>; | ||
| declare const Service_base: Context.ServiceClass<Service, "@opencode/AI/WebSocketExecutor", Interface>; | ||
| export declare class Service extends Service_base { | ||
| } | ||
| export declare const open: (input: WebSocketRequest) => Effect.Effect<WebSocketConnection, LLMError, never>; | ||
| export declare const open: (input: WebSocketRequest) => Effect.Effect<WebSocketConnection, AIError, never>; | ||
| export declare const layer: Layer.Layer<Service>; | ||
| export declare const fromWebSocket: (ws: globalThis.WebSocket, input: WebSocketRequest) => Effect.Effect<WebSocketConnection, LLMError>; | ||
| export declare const fromWebSocket: (ws: globalThis.WebSocket, input: WebSocketRequest) => Effect.Effect<WebSocketConnection, AIError>; | ||
| export declare const messageText: (message: string | Uint8Array, decoder: TextDecoder) => string; | ||
@@ -31,3 +31,3 @@ export interface JsonPrepared { | ||
| export interface JsonInput<Body, Message> { | ||
| readonly toMessage: (body: Body | Record<string, unknown>) => Effect.Effect<Message, LLMError>; | ||
| readonly toMessage: (body: Body | Record<string, unknown>) => Effect.Effect<Message, AIError>; | ||
| readonly encodeMessage: (message: Message) => string; | ||
@@ -47,4 +47,4 @@ } | ||
| readonly layer: Layer.Layer<Service, never, never>; | ||
| readonly open: (input: WebSocketRequest) => Effect.Effect<WebSocketConnection, LLMError, never>; | ||
| readonly fromWebSocket: (ws: globalThis.WebSocket, input: WebSocketRequest) => Effect.Effect<WebSocketConnection, LLMError>; | ||
| readonly open: (input: WebSocketRequest) => Effect.Effect<WebSocketConnection, AIError, never>; | ||
| readonly fromWebSocket: (ws: globalThis.WebSocket, input: WebSocketRequest) => Effect.Effect<WebSocketConnection, AIError>; | ||
| readonly messageText: (message: string | Uint8Array, decoder: TextDecoder) => string; | ||
@@ -51,0 +51,0 @@ }; |
| import { Cause, Context, Effect, Layer, Queue, Stream } from "effect"; | ||
| import { Headers } from "effect/unstable/http"; | ||
| import { LLMError, TransportReason } from "../../schema"; | ||
| import { AIError, TransportReason } from "../../schema"; | ||
| import * as HttpTransport from "./http"; | ||
| export class Service extends Context.Service()("@opencode/LLM/WebSocketExecutor") { | ||
| export class Service extends Context.Service()("@opencode/AI/WebSocketExecutor") { | ||
| } | ||
| const transportError = (method, message, input = {}) => new LLMError({ | ||
| const transportError = (method, message, input = {}) => new AIError({ | ||
| module: "WebSocketExecutor", | ||
@@ -9,0 +9,0 @@ method, |
@@ -49,4 +49,4 @@ import { Schema } from "effect"; | ||
| readonly route: Schema.String; | ||
| readonly provider: Schema.brand<Schema.String, "LLM.ProviderID">; | ||
| readonly model: Schema.brand<Schema.String, "LLM.ModelID">; | ||
| readonly provider: Schema.brand<Schema.String, "AI.ProviderID">; | ||
| readonly model: Schema.brand<Schema.String, "AI.ModelID">; | ||
| }>, {}>; | ||
@@ -128,5 +128,5 @@ export declare class NoRouteReason extends NoRouteReason_base { | ||
| } | ||
| export declare const LLMErrorReason: Schema.toTaggedUnion<"_tag", readonly [typeof InvalidRequestReason, typeof NoRouteReason, typeof AuthenticationReason, typeof RateLimitReason, typeof QuotaExceededReason, typeof ContentPolicyReason, typeof ProviderInternalReason, typeof TransportReason, typeof InvalidProviderOutputReason, typeof UnknownProviderReason]>; | ||
| export type LLMErrorReason = Schema.Schema.Type<typeof LLMErrorReason>; | ||
| declare const LLMError_base: Schema.Class<LLMError, Schema.TaggedStruct<"LLM.Error", { | ||
| export declare const AIErrorReason: Schema.toTaggedUnion<"_tag", readonly [typeof InvalidRequestReason, typeof NoRouteReason, typeof AuthenticationReason, typeof RateLimitReason, typeof QuotaExceededReason, typeof ContentPolicyReason, typeof ProviderInternalReason, typeof TransportReason, typeof InvalidProviderOutputReason, typeof UnknownProviderReason]>; | ||
| export type AIErrorReason = Schema.Schema.Type<typeof AIErrorReason>; | ||
| declare const AIError_base: Schema.Class<AIError, Schema.TaggedStruct<"AI.Error", { | ||
| readonly module: Schema.String; | ||
@@ -136,3 +136,3 @@ readonly method: Schema.String; | ||
| }>, import("effect/Cause").YieldableError>; | ||
| export declare class LLMError extends LLMError_base { | ||
| export declare class AIError extends AIError_base { | ||
| readonly cause: InvalidRequestReason | NoRouteReason | AuthenticationReason | RateLimitReason | QuotaExceededReason | ContentPolicyReason | ProviderInternalReason | TransportReason | InvalidProviderOutputReason | UnknownProviderReason; | ||
@@ -139,0 +139,0 @@ get message(): string; |
+18
-18
@@ -5,3 +5,3 @@ import { Schema } from "effect"; | ||
| export const ProviderFailureClassification = Schema.Literals(["context-overflow", "payload-too-large"]); | ||
| export class HttpRequestDetails extends Schema.Class("LLM.HttpRequestDetails")({ | ||
| export class HttpRequestDetails extends Schema.Class("AI.HttpRequestDetails")({ | ||
| method: Schema.String, | ||
@@ -12,3 +12,3 @@ url: Schema.String, | ||
| } | ||
| export class HttpResponseDetails extends Schema.Class("LLM.HttpResponseDetails")({ | ||
| export class HttpResponseDetails extends Schema.Class("AI.HttpResponseDetails")({ | ||
| status: Schema.Number, | ||
@@ -18,3 +18,3 @@ headers: Schema.Record(Schema.String, Schema.String), | ||
| } | ||
| export class HttpRateLimitDetails extends Schema.Class("LLM.HttpRateLimitDetails")({ | ||
| export class HttpRateLimitDetails extends Schema.Class("AI.HttpRateLimitDetails")({ | ||
| retryAfterMs: Schema.optional(Schema.Number), | ||
@@ -26,3 +26,3 @@ limit: Schema.optional(Schema.Record(Schema.String, Schema.String)), | ||
| } | ||
| export class HttpContext extends Schema.Class("LLM.HttpContext")({ | ||
| export class HttpContext extends Schema.Class("AI.HttpContext")({ | ||
| request: HttpRequestDetails, | ||
@@ -36,3 +36,3 @@ response: Schema.optional(HttpResponseDetails), | ||
| } | ||
| export class InvalidRequestReason extends Schema.Class("LLM.Error.InvalidRequest")({ | ||
| export class InvalidRequestReason extends Schema.Class("AI.Error.InvalidRequest")({ | ||
| _tag: Schema.tag("InvalidRequest"), | ||
@@ -46,3 +46,3 @@ message: Schema.String, | ||
| } | ||
| export class NoRouteReason extends Schema.Class("LLM.Error.NoRoute")({ | ||
| export class NoRouteReason extends Schema.Class("AI.Error.NoRoute")({ | ||
| _tag: Schema.tag("NoRoute"), | ||
@@ -54,6 +54,6 @@ route: RouteID, | ||
| get message() { | ||
| return `No LLM route for ${this.provider}/${this.model} using ${this.route}`; | ||
| return `No AI route for ${this.provider}/${this.model} using ${this.route}`; | ||
| } | ||
| } | ||
| export class AuthenticationReason extends Schema.Class("LLM.Error.Authentication")({ | ||
| export class AuthenticationReason extends Schema.Class("AI.Error.Authentication")({ | ||
| _tag: Schema.tag("Authentication"), | ||
@@ -66,3 +66,3 @@ message: Schema.String, | ||
| } | ||
| export class RateLimitReason extends Schema.Class("LLM.Error.RateLimit")({ | ||
| export class RateLimitReason extends Schema.Class("AI.Error.RateLimit")({ | ||
| _tag: Schema.tag("RateLimit"), | ||
@@ -76,3 +76,3 @@ message: Schema.String, | ||
| } | ||
| export class QuotaExceededReason extends Schema.Class("LLM.Error.QuotaExceeded")({ | ||
| export class QuotaExceededReason extends Schema.Class("AI.Error.QuotaExceeded")({ | ||
| _tag: Schema.tag("QuotaExceeded"), | ||
@@ -84,3 +84,3 @@ message: Schema.String, | ||
| } | ||
| export class ContentPolicyReason extends Schema.Class("LLM.Error.ContentPolicy")({ | ||
| export class ContentPolicyReason extends Schema.Class("AI.Error.ContentPolicy")({ | ||
| _tag: Schema.tag("ContentPolicy"), | ||
@@ -92,3 +92,3 @@ message: Schema.String, | ||
| } | ||
| export class ProviderInternalReason extends Schema.Class("LLM.Error.ProviderInternal")({ | ||
| export class ProviderInternalReason extends Schema.Class("AI.Error.ProviderInternal")({ | ||
| _tag: Schema.tag("ProviderInternal"), | ||
@@ -102,3 +102,3 @@ message: Schema.String, | ||
| } | ||
| export class TransportReason extends Schema.Class("LLM.Error.Transport")({ | ||
| export class TransportReason extends Schema.Class("AI.Error.Transport")({ | ||
| _tag: Schema.tag("Transport"), | ||
@@ -111,3 +111,3 @@ message: Schema.String, | ||
| } | ||
| export class InvalidProviderOutputReason extends Schema.Class("LLM.Error.InvalidProviderOutput")({ | ||
| export class InvalidProviderOutputReason extends Schema.Class("AI.Error.InvalidProviderOutput")({ | ||
| _tag: Schema.tag("InvalidProviderOutput"), | ||
@@ -120,3 +120,3 @@ message: Schema.String, | ||
| } | ||
| export class UnknownProviderReason extends Schema.Class("LLM.Error.UnknownProvider")({ | ||
| export class UnknownProviderReason extends Schema.Class("AI.Error.UnknownProvider")({ | ||
| _tag: Schema.tag("UnknownProvider"), | ||
@@ -129,3 +129,3 @@ message: Schema.String, | ||
| } | ||
| export const LLMErrorReason = Schema.Union([ | ||
| export const AIErrorReason = Schema.Union([ | ||
| InvalidRequestReason, | ||
@@ -142,6 +142,6 @@ NoRouteReason, | ||
| ]).pipe(Schema.toTaggedUnion("_tag")); | ||
| export class LLMError extends Schema.TaggedErrorClass()("LLM.Error", { | ||
| export class AIError extends Schema.TaggedErrorClass()("AI.Error", { | ||
| module: Schema.String, | ||
| method: Schema.String, | ||
| reason: LLMErrorReason, | ||
| reason: AIErrorReason, | ||
| }) { | ||
@@ -148,0 +148,0 @@ cause = this.reason; |
@@ -50,3 +50,3 @@ import { Schema } from "effect"; | ||
| */ | ||
| export class Usage extends Schema.Class("LLM.Usage")({ | ||
| export class Usage extends Schema.Class("AI.Usage")({ | ||
| inputTokens: Schema.optional(Schema.Number), | ||
@@ -53,0 +53,0 @@ outputTokens: Schema.optional(Schema.Number), |
| import { Schema } from "effect"; | ||
| import { ProviderMetadata } from "@opencode-ai/schema/llm"; | ||
| import { ProviderMetadata } from "@opencode-ai/schema/ai"; | ||
| export { ProviderMetadata }; | ||
@@ -10,5 +10,5 @@ /** Stable string identifier for a protocol implementation. */ | ||
| export type RouteID = Schema.Schema.Type<typeof RouteID>; | ||
| export declare const ModelID: Schema.brand<Schema.String, "LLM.ModelID">; | ||
| export declare const ModelID: Schema.brand<Schema.String, "AI.ModelID">; | ||
| export type ModelID = typeof ModelID.Type; | ||
| export declare const ProviderID: Schema.brand<Schema.String, "LLM.ProviderID">; | ||
| export declare const ProviderID: Schema.brand<Schema.String, "AI.ProviderID">; | ||
| export type ProviderID = typeof ProviderID.Type; | ||
@@ -15,0 +15,0 @@ export declare const ResponseID: Schema.String; |
| import { Schema } from "effect"; | ||
| import { LLM, ProviderMetadata } from "@opencode-ai/schema/llm"; | ||
| import { ProviderMetadata } from "@opencode-ai/schema/ai"; | ||
| import { LLM } from "@opencode-ai/schema/llm"; | ||
| export { ProviderMetadata }; | ||
@@ -8,4 +9,4 @@ /** Stable string identifier for a protocol implementation. */ | ||
| export const RouteID = Schema.String; | ||
| export const ModelID = Schema.String.pipe(Schema.brand("LLM.ModelID")); | ||
| export const ProviderID = Schema.String.pipe(Schema.brand("LLM.ProviderID")); | ||
| export const ModelID = Schema.String.pipe(Schema.brand("AI.ModelID")); | ||
| export const ProviderID = Schema.String.pipe(Schema.brand("AI.ProviderID")); | ||
| export const ResponseID = Schema.String; | ||
@@ -12,0 +13,0 @@ export const ContentBlockID = Schema.String; |
@@ -339,7 +339,7 @@ import { Schema } from "effect"; | ||
| readonly id: Schema.optional<Schema.String>; | ||
| readonly model: Schema.declare<import("./options").Model<{ | ||
| readonly model: Schema.declare<import("./options").LanguageModel<{ | ||
| readonly [x: string]: { | ||
| readonly [x: string]: unknown; | ||
| }; | ||
| }>, import("./options").Model<{ | ||
| }>, import("./options").LanguageModel<{ | ||
| readonly [x: string]: { | ||
@@ -346,0 +346,0 @@ readonly [x: string]: unknown; |
| import { Schema } from "effect"; | ||
| import { Tool } from "@opencode-ai/schema/tool"; | ||
| import { JsonSchema, MessageRole, ProviderMetadata } from "./ids"; | ||
| import { CacheHint, CachePolicy, GenerationOptions, HttpOptions, ModelSchema, ProviderOptions } from "./options"; | ||
| import { CacheHint, CachePolicy, GenerationOptions, HttpOptions, LanguageModelSchema, ProviderOptions } from "./options"; | ||
| import { isRecord } from "../utils/record"; | ||
@@ -205,3 +205,3 @@ const systemPartSchema = Schema.Struct({ | ||
| id: Schema.optional(Schema.String), | ||
| model: ModelSchema, | ||
| model: LanguageModelSchema, | ||
| system: Schema.Array(SystemPart), | ||
@@ -208,0 +208,0 @@ messages: Schema.Array(Message), |
+38
-38
@@ -50,3 +50,3 @@ import { Schema } from "effect"; | ||
| export declare const mergeGenerationOptions: (...items: ReadonlyArray<GenerationOptionsInput | undefined>) => GenerationOptions | undefined; | ||
| declare const ModelLimits_base: Schema.Class<ModelLimits, Schema.Struct<{ | ||
| declare const LanguageModelLimits_base: Schema.Class<LanguageModelLimits, Schema.Struct<{ | ||
| readonly context: Schema.optional<Schema.Number>; | ||
@@ -56,11 +56,11 @@ readonly input: Schema.optional<Schema.Number>; | ||
| }>, {}>; | ||
| export declare class ModelLimits extends ModelLimits_base { | ||
| export declare class LanguageModelLimits extends LanguageModelLimits_base { | ||
| } | ||
| export declare namespace ModelLimits { | ||
| type Input = ModelLimits | ConstructorParameters<typeof ModelLimits>[0]; | ||
| /** Normalize model limit input into the canonical `ModelLimits` class. */ | ||
| const make: (input: Input | undefined) => ModelLimits; | ||
| export declare namespace LanguageModelLimits { | ||
| type Input = LanguageModelLimits | ConstructorParameters<typeof LanguageModelLimits>[0]; | ||
| /** Normalize model limit input into the canonical `LanguageModelLimits` class. */ | ||
| const make: (input: Input | undefined) => LanguageModelLimits; | ||
| } | ||
| declare const ModelDefaults_base: Schema.Class<ModelDefaults, Schema.Struct<{ | ||
| readonly limits: Schema.optional<typeof ModelLimits>; | ||
| declare const LanguageModelDefaults_base: Schema.Class<LanguageModelDefaults, Schema.Struct<{ | ||
| readonly limits: Schema.optional<typeof LanguageModelLimits>; | ||
| readonly generation: Schema.optional<typeof GenerationOptions>; | ||
@@ -70,7 +70,7 @@ readonly providerOptions: Schema.optional<Schema.$Record<Schema.String, Schema.$Record<Schema.String, Schema.Unknown>>>; | ||
| }>, {}>; | ||
| export declare class ModelDefaults extends ModelDefaults_base { | ||
| export declare class LanguageModelDefaults extends LanguageModelDefaults_base { | ||
| } | ||
| export declare namespace ModelDefaults { | ||
| type Input = ModelDefaults | { | ||
| readonly limits?: ModelLimits.Input; | ||
| export declare namespace LanguageModelDefaults { | ||
| type Input = LanguageModelDefaults | { | ||
| readonly limits?: LanguageModelLimits.Input; | ||
| readonly generation?: GenerationOptions.Input; | ||
@@ -81,9 +81,9 @@ readonly providerOptions?: ProviderOptions; | ||
| /** Normalize selected-model request defaults without applying precedence. */ | ||
| const make: (input: Input) => ModelDefaults; | ||
| const make: (input: Input) => LanguageModelDefaults; | ||
| } | ||
| export declare const ModelToolSchemaCompatibility: Schema.Literals<readonly ["gemini", "moonshot"]>; | ||
| export type ModelToolSchemaCompatibility = Schema.Schema.Type<typeof ModelToolSchemaCompatibility>; | ||
| export declare const ModelMaxTokensFieldCompatibility: Schema.Literals<readonly ["max_completion_tokens", "max_tokens"]>; | ||
| export type ModelMaxTokensFieldCompatibility = Schema.Schema.Type<typeof ModelMaxTokensFieldCompatibility>; | ||
| declare const ModelCompatibility_base: Schema.Class<ModelCompatibility, Schema.Struct<{ | ||
| export declare const LanguageModelToolSchemaCompatibility: Schema.Literals<readonly ["gemini", "moonshot"]>; | ||
| export type LanguageModelToolSchemaCompatibility = Schema.Schema.Type<typeof LanguageModelToolSchemaCompatibility>; | ||
| export declare const LanguageModelMaxTokensFieldCompatibility: Schema.Literals<readonly ["max_completion_tokens", "max_tokens"]>; | ||
| export type LanguageModelMaxTokensFieldCompatibility = Schema.Schema.Type<typeof LanguageModelMaxTokensFieldCompatibility>; | ||
| declare const LanguageModelCompatibility_base: Schema.Class<LanguageModelCompatibility, Schema.Struct<{ | ||
| readonly toolSchema: Schema.optional<Schema.Literals<readonly ["gemini", "moonshot"]>>; | ||
@@ -93,10 +93,10 @@ readonly reasoningField: Schema.optional<Schema.String>; | ||
| }>, {}>; | ||
| export declare class ModelCompatibility extends ModelCompatibility_base { | ||
| export declare class LanguageModelCompatibility extends LanguageModelCompatibility_base { | ||
| } | ||
| export declare namespace ModelCompatibility { | ||
| type Input = ModelCompatibility | ConstructorParameters<typeof ModelCompatibility>[0]; | ||
| export declare namespace LanguageModelCompatibility { | ||
| type Input = LanguageModelCompatibility | ConstructorParameters<typeof LanguageModelCompatibility>[0]; | ||
| /** Normalize model/upstream compatibility metadata without projecting requests. */ | ||
| const make: (input: Input) => ModelCompatibility; | ||
| const make: (input: Input) => LanguageModelCompatibility; | ||
| } | ||
| export declare class Model<Options extends ProviderOptions = ProviderOptions> { | ||
| export declare class LanguageModel<Options extends ProviderOptions = ProviderOptions> { | ||
| protected readonly _ProviderOptions: Options; | ||
@@ -106,10 +106,10 @@ readonly id: ModelID; | ||
| readonly route: AnyRoute; | ||
| readonly defaults?: ModelDefaults; | ||
| readonly compatibility?: ModelCompatibility; | ||
| constructor(input: Model.ConstructorInput); | ||
| static make<Options extends ProviderOptions = ProviderOptions>(input: Model.Input): Model<Options>; | ||
| static input<Options extends ProviderOptions>(model: Model<Options>): Model.ConstructorInput; | ||
| static update<Options extends ProviderOptions>(model: Model<Options>, patch: Partial<Model.Input>): Model<Options>; | ||
| readonly defaults?: LanguageModelDefaults; | ||
| readonly compatibility?: LanguageModelCompatibility; | ||
| constructor(input: LanguageModel.ConstructorInput); | ||
| static make<Options extends ProviderOptions = ProviderOptions>(input: LanguageModel.Input): LanguageModel<Options>; | ||
| static input<Options extends ProviderOptions>(model: LanguageModel<Options>): LanguageModel.ConstructorInput; | ||
| static update<Options extends ProviderOptions>(model: LanguageModel<Options>, patch: Partial<LanguageModel.Input>): LanguageModel<Options>; | ||
| } | ||
| export declare namespace Model { | ||
| export declare namespace LanguageModel { | ||
| type ConstructorInput = { | ||
@@ -119,4 +119,4 @@ readonly id: ModelID; | ||
| readonly route: AnyRoute; | ||
| readonly defaults?: ModelDefaults; | ||
| readonly compatibility?: ModelCompatibility; | ||
| readonly defaults?: LanguageModelDefaults; | ||
| readonly compatibility?: LanguageModelCompatibility; | ||
| }; | ||
@@ -126,13 +126,13 @@ type Input = Omit<ConstructorInput, "id" | "provider" | "defaults" | "compatibility"> & { | ||
| readonly provider: string | ProviderID; | ||
| readonly defaults?: ModelDefaults.Input; | ||
| readonly compatibility?: ModelCompatibility.Input; | ||
| readonly defaults?: LanguageModelDefaults.Input; | ||
| readonly compatibility?: LanguageModelCompatibility.Input; | ||
| }; | ||
| } | ||
| export type ModelInput = Model.Input; | ||
| export type ModelProviderOptions<SelectedModel> = SelectedModel extends Model<infer Options> ? Options : never; | ||
| export declare const ModelSchema: Schema.declare<Model<{ | ||
| export type LanguageModelInput = LanguageModel.Input; | ||
| export type LanguageModelProviderOptions<SelectedModel> = SelectedModel extends LanguageModel<infer Options> ? Options : never; | ||
| export declare const LanguageModelSchema: Schema.declare<LanguageModel<{ | ||
| readonly [x: string]: { | ||
| readonly [x: string]: unknown; | ||
| }; | ||
| }>, Model<{ | ||
| }>, LanguageModel<{ | ||
| readonly [x: string]: { | ||
@@ -139,0 +139,0 @@ readonly [x: string]: unknown; |
+31
-29
@@ -43,3 +43,3 @@ import { Schema } from "effect"; | ||
| }; | ||
| export class HttpOptions extends Schema.Class("LLM.HttpOptions")({ | ||
| export class HttpOptions extends Schema.Class("AI.HttpOptions")({ | ||
| body: Schema.optional(JsonSchema), | ||
@@ -91,3 +91,3 @@ headers: Schema.optional(Schema.Record(Schema.String, Schema.String)), | ||
| }; | ||
| export class ModelLimits extends Schema.Class("LLM.ModelLimits")({ | ||
| export class LanguageModelLimits extends Schema.Class("LLM.LanguageModelLimits")({ | ||
| context: Schema.optional(Schema.Number), | ||
@@ -98,8 +98,8 @@ input: Schema.optional(Schema.Number), | ||
| } | ||
| (function (ModelLimits) { | ||
| /** Normalize model limit input into the canonical `ModelLimits` class. */ | ||
| ModelLimits.make = (input) => input instanceof ModelLimits ? input : new ModelLimits(input ?? {}); | ||
| })(ModelLimits || (ModelLimits = {})); | ||
| export class ModelDefaults extends Schema.Class("LLM.ModelDefaults")({ | ||
| limits: Schema.optional(ModelLimits), | ||
| (function (LanguageModelLimits) { | ||
| /** Normalize model limit input into the canonical `LanguageModelLimits` class. */ | ||
| LanguageModelLimits.make = (input) => input instanceof LanguageModelLimits ? input : new LanguageModelLimits(input ?? {}); | ||
| })(LanguageModelLimits || (LanguageModelLimits = {})); | ||
| export class LanguageModelDefaults extends Schema.Class("LLM.LanguageModelDefaults")({ | ||
| limits: Schema.optional(LanguageModelLimits), | ||
| generation: Schema.optional(GenerationOptions), | ||
@@ -110,9 +110,9 @@ providerOptions: Schema.optional(ProviderOptions), | ||
| } | ||
| (function (ModelDefaults) { | ||
| (function (LanguageModelDefaults) { | ||
| /** Normalize selected-model request defaults without applying precedence. */ | ||
| ModelDefaults.make = (input) => { | ||
| if (input instanceof ModelDefaults) | ||
| LanguageModelDefaults.make = (input) => { | ||
| if (input instanceof LanguageModelDefaults) | ||
| return input; | ||
| return new ModelDefaults({ | ||
| limits: input.limits === undefined ? undefined : ModelLimits.make(input.limits), | ||
| return new LanguageModelDefaults({ | ||
| limits: input.limits === undefined ? undefined : LanguageModelLimits.make(input.limits), | ||
| generation: input.generation === undefined ? undefined : GenerationOptions.make(input.generation), | ||
@@ -123,16 +123,16 @@ providerOptions: input.providerOptions, | ||
| }; | ||
| })(ModelDefaults || (ModelDefaults = {})); | ||
| export const ModelToolSchemaCompatibility = Schema.Literals(["gemini", "moonshot"]); | ||
| export const ModelMaxTokensFieldCompatibility = Schema.Literals(["max_completion_tokens", "max_tokens"]); | ||
| export class ModelCompatibility extends Schema.Class("LLM.ModelCompatibility")({ | ||
| toolSchema: Schema.optional(ModelToolSchemaCompatibility), | ||
| })(LanguageModelDefaults || (LanguageModelDefaults = {})); | ||
| export const LanguageModelToolSchemaCompatibility = Schema.Literals(["gemini", "moonshot"]); | ||
| export const LanguageModelMaxTokensFieldCompatibility = Schema.Literals(["max_completion_tokens", "max_tokens"]); | ||
| export class LanguageModelCompatibility extends Schema.Class("LLM.LanguageModelCompatibility")({ | ||
| toolSchema: Schema.optional(LanguageModelToolSchemaCompatibility), | ||
| reasoningField: Schema.optional(Schema.String), | ||
| maxTokensField: Schema.optional(ModelMaxTokensFieldCompatibility), | ||
| maxTokensField: Schema.optional(LanguageModelMaxTokensFieldCompatibility), | ||
| }) { | ||
| } | ||
| (function (ModelCompatibility) { | ||
| (function (LanguageModelCompatibility) { | ||
| /** Normalize model/upstream compatibility metadata without projecting requests. */ | ||
| ModelCompatibility.make = (input) => (input instanceof ModelCompatibility ? input : new ModelCompatibility(input)); | ||
| })(ModelCompatibility || (ModelCompatibility = {})); | ||
| export class Model { | ||
| LanguageModelCompatibility.make = (input) => input instanceof LanguageModelCompatibility ? input : new LanguageModelCompatibility(input); | ||
| })(LanguageModelCompatibility || (LanguageModelCompatibility = {})); | ||
| export class LanguageModel { | ||
| id; | ||
@@ -151,8 +151,8 @@ provider; | ||
| static make(input) { | ||
| return new Model({ | ||
| return new LanguageModel({ | ||
| id: ModelID.make(input.id), | ||
| provider: ProviderID.make(input.provider), | ||
| route: input.route, | ||
| defaults: input.defaults === undefined ? undefined : ModelDefaults.make(input.defaults), | ||
| compatibility: input.compatibility === undefined ? undefined : ModelCompatibility.make(input.compatibility), | ||
| defaults: input.defaults === undefined ? undefined : LanguageModelDefaults.make(input.defaults), | ||
| compatibility: input.compatibility === undefined ? undefined : LanguageModelCompatibility.make(input.compatibility), | ||
| }); | ||
@@ -172,4 +172,4 @@ } | ||
| return model; | ||
| return Model.make({ | ||
| ...Model.input(model), | ||
| return LanguageModel.make({ | ||
| ...LanguageModel.input(model), | ||
| ...patch, | ||
@@ -179,3 +179,5 @@ }); | ||
| } | ||
| export const ModelSchema = Schema.declare((value) => value instanceof Model, { expected: "LLM.Model" }); | ||
| export const LanguageModelSchema = Schema.declare((value) => value instanceof LanguageModel, { | ||
| expected: "LLM.LanguageModel", | ||
| }); | ||
| export class CacheHint extends Schema.Class("LLM.CacheHint")({ | ||
@@ -182,0 +184,0 @@ type: Schema.Literals(["ephemeral", "persistent"]), |
| export * as TestLLM from "./testing"; | ||
| import { type Interface as LLMClientShape } from "./route/client"; | ||
| import { LLMEvent, type FinishReasonDetails, type LLMError, type LLMRequest, type UsageInput } from "./schema"; | ||
| import { LLMEvent, type FinishReasonDetails, type AIError, type LLMRequest, type UsageInput } from "./schema"; | ||
| import { Context, Effect, Layer, Scope, Stream } from "effect"; | ||
| export type Response = readonly LLMEvent[] | Stream.Stream<LLMEvent, LLMError>; | ||
| export type Response = readonly LLMEvent[] | Stream.Stream<LLMEvent, AIError>; | ||
| export type Gate = Readonly<{ | ||
@@ -1121,3 +1121,3 @@ started: Effect.Effect<void>; | ||
| })[]; | ||
| export declare const failAfter: (error: LLMError, ...events: readonly LLMEvent[]) => Stream.Stream<{ | ||
| export declare const failAfter: (error: AIError, ...events: readonly LLMEvent[]) => Stream.Stream<{ | ||
| readonly type: "step-start"; | ||
@@ -1303,3 +1303,3 @@ readonly index: number; | ||
| readonly classification?: "context-overflow" | "payload-too-large" | undefined; | ||
| }, LLMError, never>; | ||
| }, AIError, never>; | ||
| export declare const hangAfter: (...events: readonly LLMEvent[]) => Stream.Stream<{ | ||
@@ -1306,0 +1306,0 @@ readonly type: "step-start"; |
+3
-3
| { | ||
| "$schema": "https://json.schemastore.org/package.json", | ||
| "version": "0.0.0-next-16671", | ||
| "version": "0.0.0-next-16676", | ||
| "name": "@opencode-ai/ai", | ||
@@ -33,3 +33,3 @@ "type": "module", | ||
| "@effect/platform-node": "4.0.0-beta.101", | ||
| "@opencode-ai/http-recorder": "0.0.0-next-16671", | ||
| "@opencode-ai/http-recorder": "0.0.0-next-16676", | ||
| "@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-next-16671", | ||
| "@opencode-ai/schema": "0.0.0-next-16676", | ||
| "aws4fetch": "1.0.20", | ||
@@ -46,0 +46,0 @@ "effect": "4.0.0-beta.101", |
+1
-1
@@ -198,3 +198,3 @@ # @opencode-ai/ai | ||
| - **`Message.user(...)` / `Message.assistant(...)` / `Message.tool(...)`** — message constructors from the canonical schema model. | ||
| - **`Model.make(...)` / `ToolCallPart.make(...)` / `ToolResultPart.make(...)` / `ToolDefinition.make(...)`** — model and tool-related constructors from the canonical schema model. | ||
| - **`LanguageModel.make(...)` / `ToolCallPart.make(...)` / `ToolResultPart.make(...)` / `ToolDefinition.make(...)`** — model and tool-related constructors from the canonical schema model. | ||
| - **`LLMEvent.is.*`** — typed guards (`is.textDelta`, `is.toolCall`, `is.finish`, …) for filtering streams. | ||
@@ -201,0 +201,0 @@ - **`Image.generate({...})`** — generate images through a provider-neutral image request and response model. |
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.
1118110
0.17%+ Added
- Removed