@opencode/ai 0.0.0-reserved → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +879 -2
- package/dist/cache-policy.d.ts +2 -0
- package/dist/cache-policy.js +129 -0
- package/dist/image-client.d.ts +19 -0
- package/dist/image-client.js +28 -0
- package/dist/image.d.ts +110 -0
- package/dist/image.js +103 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +12 -0
- package/dist/llm.d.ts +252 -0
- package/dist/llm.js +74 -0
- package/dist/protocols/alibaba-chat.d.ts +225 -0
- package/dist/protocols/alibaba-chat.js +75 -0
- package/dist/protocols/alibaba-messages.d.ts +350 -0
- package/dist/protocols/alibaba-messages.js +40 -0
- package/dist/protocols/alibaba-responses.d.ts +255 -0
- package/dist/protocols/alibaba-responses.js +80 -0
- package/dist/protocols/anthropic-messages.d.ts +980 -0
- package/dist/protocols/anthropic-messages.js +1460 -0
- package/dist/protocols/bedrock-converse.d.ts +499 -0
- package/dist/protocols/bedrock-converse.js +643 -0
- package/dist/protocols/bedrock-event-stream.d.ts +9 -0
- package/dist/protocols/bedrock-event-stream.js +97 -0
- package/dist/protocols/gemini.d.ts +285 -0
- package/dist/protocols/gemini.js +671 -0
- package/dist/protocols/google-images.d.ts +30 -0
- package/dist/protocols/google-images.js +181 -0
- package/dist/protocols/index.d.ts +12 -0
- package/dist/protocols/index.js +12 -0
- package/dist/protocols/meta-images.d.ts +26 -0
- package/dist/protocols/meta-images.js +89 -0
- package/dist/protocols/meta-messages.d.ts +356 -0
- package/dist/protocols/meta-messages.js +41 -0
- package/dist/protocols/meta-responses.d.ts +473 -0
- package/dist/protocols/meta-responses.js +173 -0
- package/dist/protocols/mistral-chat.d.ts +540 -0
- package/dist/protocols/mistral-chat.js +624 -0
- package/dist/protocols/open-responses-channel.d.ts +25 -0
- package/dist/protocols/open-responses-channel.js +141 -0
- package/dist/protocols/open-responses-continuation.d.ts +16 -0
- package/dist/protocols/open-responses-continuation.js +170 -0
- package/dist/protocols/open-responses.d.ts +1715 -0
- package/dist/protocols/open-responses.js +1228 -0
- package/dist/protocols/openai-chat.d.ts +860 -0
- package/dist/protocols/openai-chat.js +966 -0
- package/dist/protocols/openai-compatible-chat.d.ts +109 -0
- package/dist/protocols/openai-compatible-chat.js +19 -0
- package/dist/protocols/openai-compatible-responses.d.ts +172 -0
- package/dist/protocols/openai-compatible-responses.js +18 -0
- package/dist/protocols/openai-images.d.ts +32 -0
- package/dist/protocols/openai-images.js +183 -0
- package/dist/protocols/openai-responses.d.ts +1389 -0
- package/dist/protocols/openai-responses.js +260 -0
- package/dist/protocols/shared.d.ts +193 -0
- package/dist/protocols/shared.js +290 -0
- package/dist/protocols/utils/bedrock-auth.d.ts +60 -0
- package/dist/protocols/utils/bedrock-auth.js +85 -0
- package/dist/protocols/utils/bedrock-cache.d.ts +19 -0
- package/dist/protocols/utils/bedrock-cache.js +49 -0
- package/dist/protocols/utils/bedrock-media.d.ts +55 -0
- package/dist/protocols/utils/bedrock-media.js +73 -0
- package/dist/protocols/utils/cache.d.ts +6 -0
- package/dist/protocols/utils/cache.js +5 -0
- package/dist/protocols/utils/gemini-tool-schema.d.ts +2 -0
- package/dist/protocols/utils/gemini-tool-schema.js +103 -0
- package/dist/protocols/utils/image-input.d.ts +21 -0
- package/dist/protocols/utils/image-input.js +20 -0
- package/dist/protocols/utils/lifecycle.d.ts +24 -0
- package/dist/protocols/utils/lifecycle.js +72 -0
- package/dist/protocols/utils/meta-image.d.ts +2 -0
- package/dist/protocols/utils/meta-image.js +13 -0
- package/dist/protocols/utils/open-responses-options.d.ts +56 -0
- package/dist/protocols/utils/open-responses-options.js +61 -0
- package/dist/protocols/utils/openai-image.d.ts +5 -0
- package/dist/protocols/utils/openai-image.js +18 -0
- package/dist/protocols/utils/openai-options.d.ts +16 -0
- package/dist/protocols/utils/openai-options.js +14 -0
- package/dist/protocols/utils/partial-json-options.d.ts +62 -0
- package/dist/protocols/utils/partial-json-options.js +52 -0
- package/dist/protocols/utils/partial-json.d.ts +8 -0
- package/dist/protocols/utils/partial-json.js +279 -0
- package/dist/protocols/utils/responses-checkpoint.d.ts +4 -0
- package/dist/protocols/utils/responses-checkpoint.js +107 -0
- package/dist/protocols/utils/responses-compaction.d.ts +4 -0
- package/dist/protocols/utils/responses-compaction.js +129 -0
- package/dist/protocols/utils/responses-hosted-tools.d.ts +26 -0
- package/dist/protocols/utils/responses-hosted-tools.js +32 -0
- package/dist/protocols/utils/tool-schema.d.ts +8 -0
- package/dist/protocols/utils/tool-schema.js +54 -0
- package/dist/protocols/utils/tool-stream.d.ts +710 -0
- package/dist/protocols/utils/tool-stream.js +155 -0
- package/dist/protocols/xai-images.d.ts +26 -0
- package/dist/protocols/xai-images.js +106 -0
- package/dist/protocols/xai-responses.d.ts +250 -0
- package/dist/protocols/xai-responses.js +81 -0
- package/dist/protocols/zai-chat.d.ts +202 -0
- package/dist/protocols/zai-chat.js +49 -0
- package/dist/protocols/zai-images.d.ts +22 -0
- package/dist/protocols/zai-images.js +79 -0
- package/dist/protocols/zai-messages.d.ts +344 -0
- package/dist/protocols/zai-messages.js +27 -0
- package/dist/protocols.d.ts +1 -0
- package/dist/protocols.js +1 -0
- package/dist/provider-error.d.ts +15 -0
- package/dist/provider-error.js +125 -0
- package/dist/provider-package.d.ts +15 -0
- package/dist/provider-package.js +1 -0
- package/dist/provider.d.ts +23 -0
- package/dist/provider.js +2 -0
- package/dist/providers/alibaba/chat.d.ts +1 -0
- package/dist/providers/alibaba/chat.js +1 -0
- package/dist/providers/alibaba/messages.d.ts +3 -0
- package/dist/providers/alibaba/messages.js +1 -0
- package/dist/providers/alibaba/responses.d.ts +3 -0
- package/dist/providers/alibaba/responses.js +1 -0
- package/dist/providers/alibaba.d.ts +711 -0
- package/dist/providers/alibaba.js +94 -0
- package/dist/providers/amazon-bedrock/mantle/chat.d.ts +2 -0
- package/dist/providers/amazon-bedrock/mantle/chat.js +1 -0
- package/dist/providers/amazon-bedrock/mantle/responses.d.ts +2 -0
- package/dist/providers/amazon-bedrock/mantle/responses.js +1 -0
- package/dist/providers/amazon-bedrock/mantle.d.ts +2 -0
- package/dist/providers/amazon-bedrock/mantle.js +1 -0
- package/dist/providers/amazon-bedrock-mantle.d.ts +313 -0
- package/dist/providers/amazon-bedrock-mantle.js +79 -0
- package/dist/providers/amazon-bedrock.d.ts +173 -0
- package/dist/providers/amazon-bedrock.js +41 -0
- package/dist/providers/anthropic-compatible.d.ts +309 -0
- package/dist/providers/anthropic-compatible.js +50 -0
- package/dist/providers/anthropic.d.ts +307 -0
- package/dist/providers/anthropic.js +42 -0
- package/dist/providers/azure/chat.d.ts +2 -0
- package/dist/providers/azure/chat.js +1 -0
- package/dist/providers/azure/responses.d.ts +2 -0
- package/dist/providers/azure/responses.js +1 -0
- package/dist/providers/azure.d.ts +598 -0
- package/dist/providers/azure.js +115 -0
- package/dist/providers/baseten.d.ts +228 -0
- package/dist/providers/baseten.js +38 -0
- package/dist/providers/cerebras.d.ts +227 -0
- package/dist/providers/cerebras.js +40 -0
- package/dist/providers/cloudflare-ai-gateway.d.ts +237 -0
- package/dist/providers/cloudflare-ai-gateway.js +65 -0
- package/dist/providers/cloudflare-workers-ai.d.ts +231 -0
- package/dist/providers/cloudflare-workers-ai.js +51 -0
- package/dist/providers/deepinfra.d.ts +227 -0
- package/dist/providers/deepinfra.js +43 -0
- package/dist/providers/deepseek.d.ts +228 -0
- package/dist/providers/deepseek.js +41 -0
- package/dist/providers/fireworks.d.ts +228 -0
- package/dist/providers/fireworks.js +38 -0
- package/dist/providers/google-vertex/chat.d.ts +2 -0
- package/dist/providers/google-vertex/chat.js +1 -0
- package/dist/providers/google-vertex/gemini.d.ts +2 -0
- package/dist/providers/google-vertex/gemini.js +1 -0
- package/dist/providers/google-vertex/messages.d.ts +2 -0
- package/dist/providers/google-vertex/messages.js +1 -0
- package/dist/providers/google-vertex/responses.d.ts +2 -0
- package/dist/providers/google-vertex/responses.js +1 -0
- package/dist/providers/google-vertex-chat.d.ts +132 -0
- package/dist/providers/google-vertex-chat.js +55 -0
- package/dist/providers/google-vertex-messages.d.ts +306 -0
- package/dist/providers/google-vertex-messages.js +75 -0
- package/dist/providers/google-vertex-responses.d.ts +197 -0
- package/dist/providers/google-vertex-responses.js +56 -0
- package/dist/providers/google-vertex-shared.d.ts +22 -0
- package/dist/providers/google-vertex-shared.js +72 -0
- package/dist/providers/google-vertex.d.ts +119 -0
- package/dist/providers/google-vertex.js +98 -0
- package/dist/providers/google.d.ts +114 -0
- package/dist/providers/google.js +42 -0
- package/dist/providers/groq.d.ts +314 -0
- package/dist/providers/groq.js +81 -0
- package/dist/providers/index.d.ts +31 -0
- package/dist/providers/index.js +31 -0
- package/dist/providers/meta/chat.d.ts +2 -0
- package/dist/providers/meta/chat.js +1 -0
- package/dist/providers/meta/messages.d.ts +2 -0
- package/dist/providers/meta/messages.js +1 -0
- package/dist/providers/meta/responses.d.ts +2 -0
- package/dist/providers/meta/responses.js +1 -0
- package/dist/providers/meta.d.ts +636 -0
- package/dist/providers/meta.js +113 -0
- package/dist/providers/minimax/chat.d.ts +4 -0
- package/dist/providers/minimax/chat.js +8 -0
- package/dist/providers/minimax/messages.d.ts +1 -0
- package/dist/providers/minimax/messages.js +1 -0
- package/dist/providers/minimax/responses.d.ts +4 -0
- package/dist/providers/minimax/responses.js +8 -0
- package/dist/providers/minimax.d.ts +598 -0
- package/dist/providers/minimax.js +89 -0
- package/dist/providers/mistral.d.ts +207 -0
- package/dist/providers/mistral.js +28 -0
- package/dist/providers/moonshot/chat.d.ts +1 -0
- package/dist/providers/moonshot/chat.js +1 -0
- package/dist/providers/moonshot/messages.d.ts +4 -0
- package/dist/providers/moonshot/messages.js +8 -0
- package/dist/providers/moonshot/responses.d.ts +4 -0
- package/dist/providers/moonshot/responses.js +8 -0
- package/dist/providers/moonshot.d.ts +596 -0
- package/dist/providers/moonshot.js +90 -0
- package/dist/providers/open-responses-options.d.ts +6 -0
- package/dist/providers/open-responses-options.js +1 -0
- package/dist/providers/openai/chat.d.ts +2 -0
- package/dist/providers/openai/chat.js +1 -0
- package/dist/providers/openai/responses.d.ts +2 -0
- package/dist/providers/openai/responses.js +1 -0
- package/dist/providers/openai-compatible/responses.d.ts +1 -0
- package/dist/providers/openai-compatible/responses.js +1 -0
- package/dist/providers/openai-compatible-responses.d.ts +195 -0
- package/dist/providers/openai-compatible-responses.js +32 -0
- package/dist/providers/openai-compatible.d.ts +130 -0
- package/dist/providers/openai-compatible.js +33 -0
- package/dist/providers/openai-options.d.ts +26 -0
- package/dist/providers/openai-options.js +41 -0
- package/dist/providers/openai.d.ts +404 -0
- package/dist/providers/openai.js +82 -0
- package/dist/providers/openrouter.d.ts +563 -0
- package/dist/providers/openrouter.js +114 -0
- package/dist/providers/togetherai.d.ts +227 -0
- package/dist/providers/togetherai.js +40 -0
- package/dist/providers/xai.d.ts +163 -0
- package/dist/providers/xai.js +88 -0
- package/dist/providers/zai/chat.d.ts +1 -0
- package/dist/providers/zai/chat.js +1 -0
- package/dist/providers/zai-coding-plan/chat.d.ts +1 -0
- package/dist/providers/zai-coding-plan/chat.js +1 -0
- package/dist/providers/zai-coding-plan/messages.d.ts +4 -0
- package/dist/providers/zai-coding-plan/messages.js +8 -0
- package/dist/providers/zai-coding-plan/responses.d.ts +4 -0
- package/dist/providers/zai-coding-plan/responses.js +8 -0
- package/dist/providers/zai-coding-plan.d.ts +577 -0
- package/dist/providers/zai-coding-plan.js +63 -0
- package/dist/providers/zai.d.ts +149 -0
- package/dist/providers/zai.js +53 -0
- package/dist/providers.d.ts +1 -0
- package/dist/providers.js +1 -0
- package/dist/route/auth-options.d.ts +34 -0
- package/dist/route/auth-options.js +14 -0
- package/dist/route/auth.d.ts +51 -0
- package/dist/route/auth.js +87 -0
- package/dist/route/client.d.ts +430 -0
- package/dist/route/client.js +307 -0
- package/dist/route/endpoint.d.ts +28 -0
- package/dist/route/endpoint.js +21 -0
- package/dist/route/executor.d.ts +27 -0
- package/dist/route/executor.js +183 -0
- package/dist/route/framing.d.ts +29 -0
- package/dist/route/framing.js +14 -0
- package/dist/route/index.d.ts +16 -0
- package/dist/route/index.js +9 -0
- package/dist/route/protocol.d.ts +76 -0
- package/dist/route/protocol.js +16 -0
- package/dist/route/transport/http.d.ts +34 -0
- package/dist/route/transport/http.js +68 -0
- package/dist/route/transport/index.d.ts +41 -0
- package/dist/route/transport/index.js +4 -0
- package/dist/route/transport/websocket-channel.d.ts +57 -0
- package/dist/route/transport/websocket-channel.js +1 -0
- package/dist/route/transport/websocket.d.ts +56 -0
- package/dist/route/transport/websocket.js +370 -0
- package/dist/route.d.ts +1 -0
- package/dist/route.js +1 -0
- package/dist/schema/errors.d.ts +170 -0
- package/dist/schema/errors.js +131 -0
- package/dist/schema/events.d.ts +8123 -0
- package/dist/schema/events.js +550 -0
- package/dist/schema/ids.d.ts +17 -0
- package/dist/schema/ids.js +10 -0
- package/dist/schema/index.d.ts +5 -0
- package/dist/schema/index.js +5 -0
- package/dist/schema/messages.d.ts +646 -0
- package/dist/schema/messages.js +301 -0
- package/dist/schema/options.d.ts +159 -0
- package/dist/schema/options.js +189 -0
- package/dist/testing.d.ts +1693 -0
- package/dist/testing.js +129 -0
- package/dist/tool-history.d.ts +2 -0
- package/dist/tool-history.js +84 -0
- package/dist/tool-runtime.d.ts +15 -0
- package/dist/tool-runtime.js +62 -0
- package/dist/tool.d.ts +136 -0
- package/dist/tool.js +66 -0
- package/dist/utils/record.d.ts +2 -0
- package/dist/utils/record.js +2 -0
- package/dist/utils/sanitize.d.ts +1 -0
- package/dist/utils/sanitize.js +12 -0
- package/package.json +43 -10
|
@@ -0,0 +1,430 @@
|
|
|
1
|
+
import { Context, Effect, Layer, Schema, Stream } from "effect";
|
|
2
|
+
import { Auth } from "./auth.js";
|
|
3
|
+
import { Endpoint, type EndpointPatch } from "./endpoint.js";
|
|
4
|
+
import { RequestExecutor } from "./executor.js";
|
|
5
|
+
import { Framing } from "./framing.js";
|
|
6
|
+
import { HttpTransport } from "./transport/index.js";
|
|
7
|
+
import type { HttpMiddleware, Transport, TransportRuntime, WebSocketChannelExecutor } from "./transport/index.js";
|
|
8
|
+
import type { Protocol } from "./protocol.js";
|
|
9
|
+
import type { ProtocolID, ProviderOptions } from "../schema/index.js";
|
|
10
|
+
import { AIError, CompactionResponse, CompactionCheckpointResponse, GenerationOptions, HttpOptions, LLMRequest, LLMResponse, LanguageModel, LLMEvent, ProviderID } from "../schema/index.js";
|
|
11
|
+
export interface RouteBody<Body> {
|
|
12
|
+
/** Schema for the validated provider-native body sent as the JSON request. */
|
|
13
|
+
readonly schema: Schema.Codec<Body, unknown>;
|
|
14
|
+
/** Build the provider-native body from a common `LLMRequest`. */
|
|
15
|
+
readonly from: (request: LLMRequest) => Effect.Effect<Body, AIError>;
|
|
16
|
+
}
|
|
17
|
+
export interface Route<Body, Prepared = unknown, Compact extends CompactionOperations | undefined = CompactionOperations | undefined> {
|
|
18
|
+
readonly compact: Compact;
|
|
19
|
+
readonly id: string;
|
|
20
|
+
readonly provider?: ProviderID;
|
|
21
|
+
/** ProviderMetadata namespace emitted and consumed by this route. */
|
|
22
|
+
readonly providerMetadataKey?: string;
|
|
23
|
+
readonly protocol: ProtocolID;
|
|
24
|
+
readonly endpoint: Endpoint.Definition<Body>;
|
|
25
|
+
readonly auth: Auth.Definition;
|
|
26
|
+
/** Deployment headers resolved once for every operation, before transport authentication. */
|
|
27
|
+
readonly headers?: (input: {
|
|
28
|
+
readonly request: LLMRequest;
|
|
29
|
+
}) => Record<string, string>;
|
|
30
|
+
readonly transport: Transport<Body, Prepared, unknown>;
|
|
31
|
+
readonly defaults: RouteDefaults;
|
|
32
|
+
readonly body: RouteBody<Body>;
|
|
33
|
+
readonly with: {
|
|
34
|
+
<Next extends CompactionOperations | undefined>(patch: RoutePatch<Body, Prepared> & {
|
|
35
|
+
readonly compact: Next;
|
|
36
|
+
}): Route<Body, Prepared, Next>;
|
|
37
|
+
(patch: Omit<RoutePatch<Body, Prepared>, "compact"> & {
|
|
38
|
+
readonly compact?: undefined;
|
|
39
|
+
}): Route<Body, Prepared, Compact>;
|
|
40
|
+
(patch: RoutePatch<Body, Prepared>): Route<Body, Prepared>;
|
|
41
|
+
};
|
|
42
|
+
readonly model: <Options extends ProviderOptions = ProviderOptions>(input: RouteMappedLanguageModelInput) => LanguageModel<Options, Compact>;
|
|
43
|
+
readonly prepareTransport: (body: Body, request: LLMRequest, options?: StreamOptions) => Effect.Effect<Prepared, AIError>;
|
|
44
|
+
readonly streamPrepared: (prepared: Prepared, request: LLMRequest, runtime: TransportRuntime, options?: StreamOptions) => Stream.Stream<LLMEvent, AIError>;
|
|
45
|
+
}
|
|
46
|
+
export type AnyRoute<Compact extends CompactionOperations | undefined = CompactionOperations | undefined> = Route<any, any, Compact>;
|
|
47
|
+
export type HttpOptionsInput = HttpOptions.Input;
|
|
48
|
+
export type RouteLanguageModelInput = Omit<LanguageModel.Input, "provider" | "route">;
|
|
49
|
+
export type RouteRoutedLanguageModelInput = Omit<LanguageModel.Input, "route">;
|
|
50
|
+
export interface RouteDefaults {
|
|
51
|
+
readonly headers?: Record<string, string>;
|
|
52
|
+
readonly generation?: GenerationOptions;
|
|
53
|
+
readonly providerOptions?: ProviderOptions;
|
|
54
|
+
readonly http?: HttpOptions;
|
|
55
|
+
}
|
|
56
|
+
export interface RouteDefaultsInput {
|
|
57
|
+
readonly headers?: Record<string, string>;
|
|
58
|
+
readonly generation?: GenerationOptions.Input;
|
|
59
|
+
readonly providerOptions?: ProviderOptions;
|
|
60
|
+
readonly http?: HttpOptions.Input;
|
|
61
|
+
}
|
|
62
|
+
export interface RoutePatch<Body, Prepared> extends RouteDefaultsInput {
|
|
63
|
+
readonly compact?: CompactionOperations;
|
|
64
|
+
readonly id?: string;
|
|
65
|
+
readonly provider?: string | ProviderID;
|
|
66
|
+
readonly providerMetadataKey?: string;
|
|
67
|
+
readonly auth?: Auth.Definition;
|
|
68
|
+
readonly transport?: Transport<Body, Prepared, unknown>;
|
|
69
|
+
readonly endpoint?: EndpointPatch<Body>;
|
|
70
|
+
}
|
|
71
|
+
type RouteMappedLanguageModelInput = RouteLanguageModelInput | RouteRoutedLanguageModelInput;
|
|
72
|
+
export declare const generationOptions: (input: GenerationOptions.Input | undefined) => GenerationOptions | undefined;
|
|
73
|
+
export declare const httpOptions: (input: HttpOptionsInput | undefined) => HttpOptions | undefined;
|
|
74
|
+
export interface Interface {
|
|
75
|
+
readonly compact: CompactMethod;
|
|
76
|
+
readonly stream: StreamMethod;
|
|
77
|
+
readonly generate: GenerateMethod;
|
|
78
|
+
}
|
|
79
|
+
export interface StreamOptions {
|
|
80
|
+
readonly http?: HttpMiddleware;
|
|
81
|
+
readonly webSocket?: WebSocketChannelExecutor;
|
|
82
|
+
}
|
|
83
|
+
export interface StreamMethod {
|
|
84
|
+
(request: LLMRequest, options?: StreamOptions): Stream.Stream<LLMEvent, AIError>;
|
|
85
|
+
}
|
|
86
|
+
export interface GenerateMethod {
|
|
87
|
+
(request: LLMRequest, options?: StreamOptions): Effect.Effect<LLMResponse, AIError>;
|
|
88
|
+
}
|
|
89
|
+
export type CompactOperation = (request: LLMRequest, executor: RequestExecutor.Interface, options?: Pick<StreamOptions, "http">) => Effect.Effect<CompactionResponse, AIError>;
|
|
90
|
+
export type TriggerCompactOperation = (request: LLMRequest, executor: RequestExecutor.Interface, options: TriggerCompactOptions) => Effect.Effect<CompactionCheckpointResponse, AIError>;
|
|
91
|
+
/** Protocol capabilities, not deployment/model eligibility. */
|
|
92
|
+
export interface CompactionOperations {
|
|
93
|
+
readonly endpoint?: CompactOperation;
|
|
94
|
+
readonly trigger?: TriggerCompactOperation;
|
|
95
|
+
}
|
|
96
|
+
export interface EndpointCompactOptions extends Pick<StreamOptions, "http"> {
|
|
97
|
+
readonly mechanism?: "endpoint";
|
|
98
|
+
readonly webSocket?: never;
|
|
99
|
+
}
|
|
100
|
+
export interface TriggerCompactOptions extends StreamOptions {
|
|
101
|
+
readonly mechanism: "trigger";
|
|
102
|
+
}
|
|
103
|
+
export type CompactionRequest = LLMRequest & {
|
|
104
|
+
readonly model: LanguageModel<ProviderOptions, {
|
|
105
|
+
readonly endpoint: CompactOperation;
|
|
106
|
+
}>;
|
|
107
|
+
};
|
|
108
|
+
export type CheckpointRequest = LLMRequest & {
|
|
109
|
+
readonly model: LanguageModel<ProviderOptions, {
|
|
110
|
+
readonly trigger: TriggerCompactOperation;
|
|
111
|
+
}>;
|
|
112
|
+
};
|
|
113
|
+
export interface CompactMethod<R = never> {
|
|
114
|
+
(request: CheckpointRequest, options: TriggerCompactOptions): Effect.Effect<CompactionCheckpointResponse, AIError, R>;
|
|
115
|
+
(request: CompactionRequest, options?: EndpointCompactOptions): Effect.Effect<CompactionResponse, AIError, R>;
|
|
116
|
+
}
|
|
117
|
+
export declare function canCompact(request: LLMRequest, options?: {
|
|
118
|
+
readonly mechanism?: "endpoint";
|
|
119
|
+
}): request is CompactionRequest;
|
|
120
|
+
export declare function canCompact(request: LLMRequest, options: {
|
|
121
|
+
readonly mechanism: "trigger";
|
|
122
|
+
}): request is CheckpointRequest;
|
|
123
|
+
declare const Service_base: Context.ServiceClass<Service, "@opencode/LLMClient", Interface>;
|
|
124
|
+
export declare class Service extends Service_base {
|
|
125
|
+
}
|
|
126
|
+
export interface MakeInput<Body, Frame, Event, State> {
|
|
127
|
+
readonly compact?: CompactionOperations;
|
|
128
|
+
/** Route id used in diagnostics and prepared request metadata. */
|
|
129
|
+
readonly id: string;
|
|
130
|
+
/** Provider identity for route-owned model construction. */
|
|
131
|
+
readonly provider?: string | ProviderID;
|
|
132
|
+
/** ProviderMetadata namespace emitted and consumed by this route. */
|
|
133
|
+
readonly providerMetadataKey?: string;
|
|
134
|
+
/** Semantic API contract — owns body construction, body schema, and parsing. */
|
|
135
|
+
readonly protocol: Protocol<Body, Frame, Event, State>;
|
|
136
|
+
/** Where the request is sent. */
|
|
137
|
+
readonly endpoint: Endpoint.Definition<Body>;
|
|
138
|
+
/** Per-request transport auth. Provider facades override this via `route.with(...)`. */
|
|
139
|
+
readonly auth?: Auth.Definition;
|
|
140
|
+
/** Stream framing — bytes -> frames before `protocol.stream.event` decoding. */
|
|
141
|
+
readonly framing: Framing.Definition<Frame>;
|
|
142
|
+
/** Static / per-request headers added before `auth` runs. */
|
|
143
|
+
readonly headers?: (input: {
|
|
144
|
+
readonly request: LLMRequest;
|
|
145
|
+
}) => Record<string, string>;
|
|
146
|
+
/** Route/request defaults used when compiling requests for this route. */
|
|
147
|
+
readonly defaults?: RouteDefaultsInput;
|
|
148
|
+
}
|
|
149
|
+
export interface MakeTransportInput<Body, Prepared, Frame, Event, State> {
|
|
150
|
+
readonly compact?: CompactionOperations;
|
|
151
|
+
/** Route id used in diagnostics and prepared request metadata. */
|
|
152
|
+
readonly id: string;
|
|
153
|
+
/** Provider identity for route-owned model construction. */
|
|
154
|
+
readonly provider?: string | ProviderID;
|
|
155
|
+
/** ProviderMetadata namespace emitted and consumed by this route. */
|
|
156
|
+
readonly providerMetadataKey?: string;
|
|
157
|
+
/** Semantic API contract — owns body construction, body schema, and parsing. */
|
|
158
|
+
readonly protocol: Protocol<Body, Frame, Event, State>;
|
|
159
|
+
/** Where the request is sent. */
|
|
160
|
+
readonly endpoint: Endpoint.Definition<Body>;
|
|
161
|
+
/** Per-request transport auth. Provider facades override this via `route.with(...)`. */
|
|
162
|
+
readonly auth?: Auth.Definition;
|
|
163
|
+
/** Static / per-request headers added before `auth` runs. */
|
|
164
|
+
readonly headers?: (input: {
|
|
165
|
+
readonly request: LLMRequest;
|
|
166
|
+
}) => Record<string, string>;
|
|
167
|
+
/** Runnable transport route. */
|
|
168
|
+
readonly transport: Transport<Body, Prepared, Frame>;
|
|
169
|
+
/** Route/request defaults used when compiling requests for this route. */
|
|
170
|
+
readonly defaults?: RouteDefaultsInput;
|
|
171
|
+
}
|
|
172
|
+
export declare function make<Body, Prepared, Frame, Event, State, Compact extends CompactionOperations>(input: MakeTransportInput<Body, Prepared, Frame, Event, State> & {
|
|
173
|
+
readonly compact: Compact;
|
|
174
|
+
}): Route<Body, Prepared, Compact>;
|
|
175
|
+
export declare function make<Body, Frame, Event, State, Compact extends CompactionOperations>(input: MakeInput<Body, Frame, Event, State> & {
|
|
176
|
+
readonly compact: Compact;
|
|
177
|
+
}): Route<Body, HttpTransport.HttpPrepared<Frame>, Compact>;
|
|
178
|
+
export declare function make<Body, Prepared, Frame, Event, State>(input: MakeTransportInput<Body, Prepared, Frame, Event, State>): Route<Body, Prepared>;
|
|
179
|
+
/**
|
|
180
|
+
* Build a `Route` by composing the four orthogonal pieces of a deployment:
|
|
181
|
+
*
|
|
182
|
+
* - `Protocol` — what is the API I'm speaking?
|
|
183
|
+
* - `Endpoint` — where do I send the request?
|
|
184
|
+
* - `Auth` — how do I authenticate it?
|
|
185
|
+
* - `Framing` — how do I cut the response stream into protocol frames?
|
|
186
|
+
*
|
|
187
|
+
* Plus optional `headers` for cross-cutting deployment concerns (provider
|
|
188
|
+
* version pins, per-deployment quirks).
|
|
189
|
+
*
|
|
190
|
+
* This is the canonical route constructor. If a new route does not fit
|
|
191
|
+
* this four-axis model, add a purpose-built constructor rather than widening
|
|
192
|
+
* the public surface preemptively.
|
|
193
|
+
*/
|
|
194
|
+
export declare function make<Body, Frame, Event, State>(input: MakeInput<Body, Frame, Event, State>): Route<Body, HttpTransport.HttpPrepared<Frame>>;
|
|
195
|
+
/** @internal Test-only projection of the execution compiler; not exported from package barrels. */
|
|
196
|
+
export declare const compileRequest: (request: LLMRequest<LanguageModel<{
|
|
197
|
+
readonly [x: string]: unknown;
|
|
198
|
+
}, CompactionOperations | undefined>>) => Effect.Effect<{
|
|
199
|
+
id: string;
|
|
200
|
+
route: string;
|
|
201
|
+
protocol: string;
|
|
202
|
+
model: LanguageModel<{
|
|
203
|
+
readonly [x: string]: unknown;
|
|
204
|
+
}, CompactionOperations | undefined>;
|
|
205
|
+
body: any;
|
|
206
|
+
metadata: {
|
|
207
|
+
transport: string;
|
|
208
|
+
};
|
|
209
|
+
}, AIError, never>;
|
|
210
|
+
export declare function stream(request: LLMRequest, options?: StreamOptions): Stream.Stream<LLMEvent, AIError, Service>;
|
|
211
|
+
export declare function generate(request: LLMRequest, options?: StreamOptions): Effect.Effect<LLMResponse, AIError, Service>;
|
|
212
|
+
export declare function compact(request: CheckpointRequest, options: TriggerCompactOptions): Effect.Effect<CompactionCheckpointResponse, AIError, Service>;
|
|
213
|
+
export declare function compact(request: CompactionRequest, options?: EndpointCompactOptions): Effect.Effect<CompactionResponse, AIError, Service>;
|
|
214
|
+
export declare const streamRequest: (request: LLMRequest, options?: StreamOptions) => Stream.Stream<({
|
|
215
|
+
readonly type: "compaction";
|
|
216
|
+
readonly provider: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
217
|
+
readonly id?: string | undefined;
|
|
218
|
+
readonly text?: string | null | undefined;
|
|
219
|
+
readonly encrypted?: string | undefined;
|
|
220
|
+
} & ({
|
|
221
|
+
readonly encrypted: string;
|
|
222
|
+
readonly text?: never;
|
|
223
|
+
} | {
|
|
224
|
+
readonly text: string | null;
|
|
225
|
+
readonly encrypted?: never;
|
|
226
|
+
})) | {
|
|
227
|
+
readonly type: "step-start";
|
|
228
|
+
readonly index: number;
|
|
229
|
+
} | {
|
|
230
|
+
readonly id: string;
|
|
231
|
+
readonly type: "text-start";
|
|
232
|
+
readonly providerMetadata?: {
|
|
233
|
+
readonly [x: string]: {
|
|
234
|
+
readonly [x: string]: unknown;
|
|
235
|
+
};
|
|
236
|
+
} | undefined;
|
|
237
|
+
} | {
|
|
238
|
+
readonly id: string;
|
|
239
|
+
readonly type: "text-delta";
|
|
240
|
+
readonly text: string;
|
|
241
|
+
readonly providerMetadata?: {
|
|
242
|
+
readonly [x: string]: {
|
|
243
|
+
readonly [x: string]: unknown;
|
|
244
|
+
};
|
|
245
|
+
} | undefined;
|
|
246
|
+
} | {
|
|
247
|
+
readonly id: string;
|
|
248
|
+
readonly type: "text-end";
|
|
249
|
+
readonly text?: string | undefined;
|
|
250
|
+
readonly providerMetadata?: {
|
|
251
|
+
readonly [x: string]: {
|
|
252
|
+
readonly [x: string]: unknown;
|
|
253
|
+
};
|
|
254
|
+
} | undefined;
|
|
255
|
+
} | {
|
|
256
|
+
readonly id: string;
|
|
257
|
+
readonly type: "reasoning-start";
|
|
258
|
+
readonly providerMetadata?: {
|
|
259
|
+
readonly [x: string]: {
|
|
260
|
+
readonly [x: string]: unknown;
|
|
261
|
+
};
|
|
262
|
+
} | undefined;
|
|
263
|
+
} | {
|
|
264
|
+
readonly id: string;
|
|
265
|
+
readonly type: "reasoning-delta";
|
|
266
|
+
readonly text: string;
|
|
267
|
+
readonly providerMetadata?: {
|
|
268
|
+
readonly [x: string]: {
|
|
269
|
+
readonly [x: string]: unknown;
|
|
270
|
+
};
|
|
271
|
+
} | undefined;
|
|
272
|
+
} | {
|
|
273
|
+
readonly id: string;
|
|
274
|
+
readonly type: "reasoning-end";
|
|
275
|
+
readonly text?: string | undefined;
|
|
276
|
+
readonly providerMetadata?: {
|
|
277
|
+
readonly [x: string]: {
|
|
278
|
+
readonly [x: string]: unknown;
|
|
279
|
+
};
|
|
280
|
+
} | undefined;
|
|
281
|
+
} | {
|
|
282
|
+
readonly id: string;
|
|
283
|
+
readonly type: "tool-input-start";
|
|
284
|
+
readonly name: string;
|
|
285
|
+
readonly providerMetadata?: {
|
|
286
|
+
readonly [x: string]: {
|
|
287
|
+
readonly [x: string]: unknown;
|
|
288
|
+
};
|
|
289
|
+
} | undefined;
|
|
290
|
+
readonly namespace?: string | undefined;
|
|
291
|
+
readonly providerExecuted?: boolean | undefined;
|
|
292
|
+
} | {
|
|
293
|
+
readonly id: string;
|
|
294
|
+
readonly type: "tool-input-delta";
|
|
295
|
+
readonly name: string;
|
|
296
|
+
readonly text: string;
|
|
297
|
+
readonly input?: unknown;
|
|
298
|
+
readonly namespace?: string | undefined;
|
|
299
|
+
} | {
|
|
300
|
+
readonly id: string;
|
|
301
|
+
readonly type: "tool-input-end";
|
|
302
|
+
readonly name: string;
|
|
303
|
+
readonly providerMetadata?: {
|
|
304
|
+
readonly [x: string]: {
|
|
305
|
+
readonly [x: string]: unknown;
|
|
306
|
+
};
|
|
307
|
+
} | undefined;
|
|
308
|
+
readonly namespace?: string | undefined;
|
|
309
|
+
} | {
|
|
310
|
+
readonly id: string;
|
|
311
|
+
readonly type: "tool-input-error";
|
|
312
|
+
readonly name: string;
|
|
313
|
+
readonly raw: string;
|
|
314
|
+
readonly namespace?: string | undefined;
|
|
315
|
+
} | {
|
|
316
|
+
readonly id: string;
|
|
317
|
+
readonly type: "tool-call";
|
|
318
|
+
readonly name: string;
|
|
319
|
+
readonly input: unknown;
|
|
320
|
+
readonly providerMetadata?: {
|
|
321
|
+
readonly [x: string]: {
|
|
322
|
+
readonly [x: string]: unknown;
|
|
323
|
+
};
|
|
324
|
+
} | undefined;
|
|
325
|
+
readonly namespace?: string | undefined;
|
|
326
|
+
readonly providerExecuted?: boolean | undefined;
|
|
327
|
+
} | {
|
|
328
|
+
readonly id: string;
|
|
329
|
+
readonly type: "tool-result";
|
|
330
|
+
readonly name: string;
|
|
331
|
+
readonly result: {
|
|
332
|
+
readonly type: "json";
|
|
333
|
+
readonly value: unknown;
|
|
334
|
+
} | {
|
|
335
|
+
readonly type: "text";
|
|
336
|
+
readonly value: unknown;
|
|
337
|
+
} | {
|
|
338
|
+
readonly type: "error";
|
|
339
|
+
readonly value: unknown;
|
|
340
|
+
} | {
|
|
341
|
+
readonly type: "content";
|
|
342
|
+
readonly value: readonly ({
|
|
343
|
+
readonly type: "text";
|
|
344
|
+
readonly text: string;
|
|
345
|
+
} | {
|
|
346
|
+
readonly type: "file";
|
|
347
|
+
readonly uri: string;
|
|
348
|
+
readonly mime: string;
|
|
349
|
+
readonly name?: string | undefined;
|
|
350
|
+
})[];
|
|
351
|
+
};
|
|
352
|
+
readonly output?: {
|
|
353
|
+
readonly structured: unknown;
|
|
354
|
+
readonly content: readonly ({
|
|
355
|
+
readonly type: "text";
|
|
356
|
+
readonly text: string;
|
|
357
|
+
} | {
|
|
358
|
+
readonly type: "file";
|
|
359
|
+
readonly uri: string;
|
|
360
|
+
readonly mime: string;
|
|
361
|
+
readonly name?: string | undefined;
|
|
362
|
+
})[];
|
|
363
|
+
} | undefined;
|
|
364
|
+
readonly providerMetadata?: {
|
|
365
|
+
readonly [x: string]: {
|
|
366
|
+
readonly [x: string]: unknown;
|
|
367
|
+
};
|
|
368
|
+
} | undefined;
|
|
369
|
+
readonly namespace?: string | undefined;
|
|
370
|
+
readonly providerExecuted?: boolean | undefined;
|
|
371
|
+
} | {
|
|
372
|
+
readonly id: string;
|
|
373
|
+
readonly type: "tool-error";
|
|
374
|
+
readonly name: string;
|
|
375
|
+
readonly message: string;
|
|
376
|
+
readonly error?: unknown;
|
|
377
|
+
readonly providerMetadata?: {
|
|
378
|
+
readonly [x: string]: {
|
|
379
|
+
readonly [x: string]: unknown;
|
|
380
|
+
};
|
|
381
|
+
} | undefined;
|
|
382
|
+
readonly namespace?: string | undefined;
|
|
383
|
+
} | {
|
|
384
|
+
readonly type: "step-finish";
|
|
385
|
+
readonly reason: {
|
|
386
|
+
readonly normalized: "length" | "stop" | "tool-calls" | "content-filter" | "error" | "unknown";
|
|
387
|
+
readonly raw?: string | undefined;
|
|
388
|
+
};
|
|
389
|
+
readonly index: number;
|
|
390
|
+
readonly providerMetadata?: {
|
|
391
|
+
readonly [x: string]: {
|
|
392
|
+
readonly [x: string]: unknown;
|
|
393
|
+
};
|
|
394
|
+
} | undefined;
|
|
395
|
+
readonly usage?: import("../schema/events.js").Usage | undefined;
|
|
396
|
+
} | {
|
|
397
|
+
readonly type: "finish";
|
|
398
|
+
readonly reason: {
|
|
399
|
+
readonly normalized: "length" | "stop" | "tool-calls" | "content-filter" | "error" | "unknown";
|
|
400
|
+
readonly raw?: string | undefined;
|
|
401
|
+
};
|
|
402
|
+
readonly providerMetadata?: {
|
|
403
|
+
readonly [x: string]: {
|
|
404
|
+
readonly [x: string]: unknown;
|
|
405
|
+
};
|
|
406
|
+
} | undefined;
|
|
407
|
+
readonly usage?: import("../schema/events.js").Usage | undefined;
|
|
408
|
+
} | {
|
|
409
|
+
readonly type: "provider-error";
|
|
410
|
+
readonly message: string;
|
|
411
|
+
readonly providerMetadata?: {
|
|
412
|
+
readonly [x: string]: {
|
|
413
|
+
readonly [x: string]: unknown;
|
|
414
|
+
};
|
|
415
|
+
} | undefined;
|
|
416
|
+
readonly classification?: "context-overflow" | "payload-too-large" | undefined;
|
|
417
|
+
}, AIError, Service>;
|
|
418
|
+
export declare const layer: Layer.Layer<Service, never, RequestExecutor.Service>;
|
|
419
|
+
export declare const Route: {
|
|
420
|
+
readonly make: typeof make;
|
|
421
|
+
};
|
|
422
|
+
export declare const LLMClient: {
|
|
423
|
+
readonly canCompact: typeof canCompact;
|
|
424
|
+
readonly compact: typeof compact;
|
|
425
|
+
readonly Service: typeof Service;
|
|
426
|
+
readonly layer: Layer.Layer<Service, never, RequestExecutor.Service>;
|
|
427
|
+
readonly stream: typeof stream;
|
|
428
|
+
readonly generate: typeof generate;
|
|
429
|
+
};
|
|
430
|
+
export {};
|