@opencode-ai/ai 0.0.0-bootstrap.0 → 0.0.0-next-15618

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.
Files changed (151) hide show
  1. package/README.md +176 -1
  2. package/dist/cache-policy.d.ts +2 -0
  3. package/dist/cache-policy.js +108 -0
  4. package/dist/index.d.ts +14 -0
  5. package/dist/index.js +9 -0
  6. package/dist/llm.d.ts +223 -0
  7. package/dist/llm.js +81 -0
  8. package/dist/protocols/anthropic-messages.d.ts +503 -0
  9. package/dist/protocols/anthropic-messages.js +745 -0
  10. package/dist/protocols/bedrock-converse.d.ts +476 -0
  11. package/dist/protocols/bedrock-converse.js +526 -0
  12. package/dist/protocols/bedrock-event-stream.d.ts +9 -0
  13. package/dist/protocols/bedrock-event-stream.js +64 -0
  14. package/dist/protocols/gemini.d.ts +220 -0
  15. package/dist/protocols/gemini.js +420 -0
  16. package/dist/protocols/google-vertex-anthropic.d.ts +494 -0
  17. package/dist/protocols/google-vertex-anthropic.js +33 -0
  18. package/dist/protocols/google-vertex-gemini.d.ts +59 -0
  19. package/dist/protocols/google-vertex-gemini.js +18 -0
  20. package/dist/protocols/index.d.ts +9 -0
  21. package/dist/protocols/index.js +9 -0
  22. package/dist/protocols/openai-chat.d.ts +391 -0
  23. package/dist/protocols/openai-chat.js +423 -0
  24. package/dist/protocols/openai-compatible-chat.d.ts +73 -0
  25. package/dist/protocols/openai-compatible-chat.js +20 -0
  26. package/dist/protocols/openai-compatible-responses.d.ts +85 -0
  27. package/dist/protocols/openai-compatible-responses.js +18 -0
  28. package/dist/protocols/openai-responses.d.ts +613 -0
  29. package/dist/protocols/openai-responses.js +828 -0
  30. package/dist/protocols/shared.d.ts +192 -0
  31. package/dist/protocols/shared.js +236 -0
  32. package/dist/protocols/utils/bedrock-auth.d.ts +18 -0
  33. package/dist/protocols/utils/bedrock-auth.js +41 -0
  34. package/dist/protocols/utils/bedrock-cache.d.ts +15 -0
  35. package/dist/protocols/utils/bedrock-cache.js +29 -0
  36. package/dist/protocols/utils/bedrock-media.d.ts +49 -0
  37. package/dist/protocols/utils/bedrock-media.js +68 -0
  38. package/dist/protocols/utils/cache.d.ts +6 -0
  39. package/dist/protocols/utils/cache.js +8 -0
  40. package/dist/protocols/utils/gemini-tool-schema.d.ts +2 -0
  41. package/dist/protocols/utils/gemini-tool-schema.js +83 -0
  42. package/dist/protocols/utils/lifecycle.d.ts +19 -0
  43. package/dist/protocols/utils/lifecycle.js +65 -0
  44. package/dist/protocols/utils/openai-options.d.ts +22 -0
  45. package/dist/protocols/utils/openai-options.js +64 -0
  46. package/dist/protocols/utils/tool-schema.d.ts +7 -0
  47. package/dist/protocols/utils/tool-schema.js +79 -0
  48. package/dist/protocols/utils/tool-stream.d.ts +155 -0
  49. package/dist/protocols/utils/tool-stream.js +136 -0
  50. package/dist/protocols.d.ts +1 -0
  51. package/dist/protocols.js +1 -0
  52. package/dist/provider-error.d.ts +13 -0
  53. package/dist/provider-error.js +122 -0
  54. package/dist/provider-package.d.ts +13 -0
  55. package/dist/provider-package.js +1 -0
  56. package/dist/provider.d.ts +23 -0
  57. package/dist/provider.js +2 -0
  58. package/dist/providers/amazon-bedrock.d.ts +150 -0
  59. package/dist/providers/amazon-bedrock.js +41 -0
  60. package/dist/providers/anthropic-compatible.d.ts +183 -0
  61. package/dist/providers/anthropic-compatible.js +44 -0
  62. package/dist/providers/anthropic.d.ts +181 -0
  63. package/dist/providers/anthropic.js +39 -0
  64. package/dist/providers/azure/chat.d.ts +2 -0
  65. package/dist/providers/azure/chat.js +1 -0
  66. package/dist/providers/azure/responses.d.ts +2 -0
  67. package/dist/providers/azure/responses.js +1 -0
  68. package/dist/providers/azure.d.ts +183 -0
  69. package/dist/providers/azure.js +89 -0
  70. package/dist/providers/cloudflare.d.ts +232 -0
  71. package/dist/providers/cloudflare.js +87 -0
  72. package/dist/providers/github-copilot.d.ts +167 -0
  73. package/dist/providers/github-copilot.js +47 -0
  74. package/dist/providers/google-vertex/anthropic.d.ts +2 -0
  75. package/dist/providers/google-vertex/anthropic.js +1 -0
  76. package/dist/providers/google-vertex-anthropic.d.ts +181 -0
  77. package/dist/providers/google-vertex-anthropic.js +46 -0
  78. package/dist/providers/google-vertex-shared.d.ts +22 -0
  79. package/dist/providers/google-vertex-shared.js +61 -0
  80. package/dist/providers/google-vertex.d.ts +93 -0
  81. package/dist/providers/google-vertex.js +49 -0
  82. package/dist/providers/google.d.ts +85 -0
  83. package/dist/providers/google.js +33 -0
  84. package/dist/providers/index.d.ts +15 -0
  85. package/dist/providers/index.js +15 -0
  86. package/dist/providers/openai/chat.d.ts +2 -0
  87. package/dist/providers/openai/chat.js +1 -0
  88. package/dist/providers/openai/responses.d.ts +2 -0
  89. package/dist/providers/openai/responses.js +1 -0
  90. package/dist/providers/openai-compatible/responses.d.ts +1 -0
  91. package/dist/providers/openai-compatible/responses.js +1 -0
  92. package/dist/providers/openai-compatible-profile.d.ts +43 -0
  93. package/dist/providers/openai-compatible-profile.js +12 -0
  94. package/dist/providers/openai-compatible-responses.d.ts +107 -0
  95. package/dist/providers/openai-compatible-responses.js +33 -0
  96. package/dist/providers/openai-compatible.d.ts +130 -0
  97. package/dist/providers/openai-compatible.js +55 -0
  98. package/dist/providers/openai-options.d.ts +30 -0
  99. package/dist/providers/openai-options.js +42 -0
  100. package/dist/providers/openai.d.ts +264 -0
  101. package/dist/providers/openai.js +62 -0
  102. package/dist/providers/openrouter.d.ts +321 -0
  103. package/dist/providers/openrouter.js +65 -0
  104. package/dist/providers/xai.d.ts +169 -0
  105. package/dist/providers/xai.js +43 -0
  106. package/dist/providers.d.ts +1 -0
  107. package/dist/providers.js +1 -0
  108. package/dist/route/auth-options.d.ts +34 -0
  109. package/dist/route/auth-options.js +14 -0
  110. package/dist/route/auth.d.ts +49 -0
  111. package/dist/route/auth.js +89 -0
  112. package/dist/route/client.d.ts +330 -0
  113. package/dist/route/client.js +211 -0
  114. package/dist/route/endpoint.d.ts +28 -0
  115. package/dist/route/endpoint.js +21 -0
  116. package/dist/route/executor.d.ts +12 -0
  117. package/dist/route/executor.js +229 -0
  118. package/dist/route/framing.d.ts +23 -0
  119. package/dist/route/framing.js +4 -0
  120. package/dist/route/index.d.ts +16 -0
  121. package/dist/route/index.js +9 -0
  122. package/dist/route/protocol.d.ts +76 -0
  123. package/dist/route/protocol.js +17 -0
  124. package/dist/route/transport/http.d.ts +33 -0
  125. package/dist/route/transport/http.js +98 -0
  126. package/dist/route/transport/index.d.ts +27 -0
  127. package/dist/route/transport/index.js +4 -0
  128. package/dist/route/transport/websocket.d.ts +56 -0
  129. package/dist/route/transport/websocket.js +181 -0
  130. package/dist/route.d.ts +1 -0
  131. package/dist/route.js +1 -0
  132. package/dist/schema/errors.d.ts +153 -0
  133. package/dist/schema/errors.js +150 -0
  134. package/dist/schema/events.d.ts +4292 -0
  135. package/dist/schema/events.js +482 -0
  136. package/dist/schema/ids.d.ts +30 -0
  137. package/dist/schema/ids.js +18 -0
  138. package/dist/schema/index.d.ts +5 -0
  139. package/dist/schema/index.js +5 -0
  140. package/dist/schema/messages.d.ts +385 -0
  141. package/dist/schema/messages.js +246 -0
  142. package/dist/schema/options.d.ts +143 -0
  143. package/dist/schema/options.js +195 -0
  144. package/dist/tool-runtime.d.ts +15 -0
  145. package/dist/tool-runtime.js +35 -0
  146. package/dist/tool.d.ts +134 -0
  147. package/dist/tool.js +66 -0
  148. package/dist/utils/record.d.ts +2 -0
  149. package/dist/utils/record.js +2 -0
  150. package/package.json +36 -9
  151. package/index.js +0 -1
@@ -0,0 +1,34 @@
1
+ import type { Config, Redacted } from "effect";
2
+ import { Auth } from "./auth";
3
+ export type ApiKeyMode = "optional" | "required";
4
+ export type AuthOverride = {
5
+ readonly auth: Auth.Definition;
6
+ readonly apiKey?: never;
7
+ };
8
+ export type OptionalApiKeyAuth = {
9
+ readonly apiKey?: string | Redacted.Redacted<string> | Config.Config<string | Redacted.Redacted<string>>;
10
+ readonly auth?: never;
11
+ };
12
+ export type RequiredApiKeyAuth = {
13
+ readonly apiKey: string | Redacted.Redacted<string> | Config.Config<string | Redacted.Redacted<string>>;
14
+ readonly auth?: never;
15
+ };
16
+ export type ProviderAuthOption<Mode extends ApiKeyMode> = AuthOverride | (Mode extends "optional" ? OptionalApiKeyAuth : RequiredApiKeyAuth);
17
+ export type ModelOptions<Base, Mode extends ApiKeyMode> = Omit<Base, "apiKey" | "auth"> & ProviderAuthOption<Mode>;
18
+ export type ModelArgs<Base, Mode extends ApiKeyMode> = Mode extends "optional" ? readonly [options?: ModelOptions<Base, Mode>] : readonly [options: ModelOptions<Base, Mode>];
19
+ export type ModelFactory<Base, Mode extends ApiKeyMode, Model> = (id: string, ...args: ModelArgs<Base, Mode>) => Model;
20
+ /**
21
+ * Require at least one of the keys in `T`. Use for option shapes where any
22
+ * subset of fields is acceptable but at least one must be present (e.g. Azure
23
+ * accepts `resourceName` or `baseURL`).
24
+ */
25
+ export type AtLeastOne<T> = {
26
+ [K in keyof T]: Required<Pick<T, K>> & Partial<Omit<T, K>>;
27
+ }[keyof T];
28
+ /**
29
+ * Standard bearer-auth resolution for providers: honor an explicit `auth`
30
+ * override, otherwise resolve `apiKey` (option > config var) and apply it as
31
+ * a bearer token.
32
+ */
33
+ export declare const bearer: (options: ProviderAuthOption<"optional">, envVar: string | ReadonlyArray<string>) => Auth.Definition;
34
+ export * as AuthOptions from "./auth-options";
@@ -0,0 +1,14 @@
1
+ import { Auth } from "./auth";
2
+ /**
3
+ * Standard bearer-auth resolution for providers: honor an explicit `auth`
4
+ * override, otherwise resolve `apiKey` (option > config var) and apply it as
5
+ * a bearer token.
6
+ */
7
+ export const bearer = (options, envVar) => {
8
+ if ("auth" in options && options.auth)
9
+ return options.auth;
10
+ return (Array.isArray(envVar) ? envVar : [envVar])
11
+ .reduce((auth, name) => auth.orElse(Auth.config(name)), Auth.optional("apiKey" in options ? options.apiKey : undefined, "apiKey"))
12
+ .bearer();
13
+ };
14
+ export * as AuthOptions from "./auth-options";
@@ -0,0 +1,49 @@
1
+ import { Config, Effect, Redacted } from "effect";
2
+ import { Headers } from "effect/unstable/http";
3
+ import { LLMError, type LLMRequest } from "../schema";
4
+ export declare class MissingCredentialError extends Error {
5
+ readonly source: string;
6
+ readonly _tag = "MissingCredentialError";
7
+ constructor(source: string);
8
+ }
9
+ export type CredentialError = MissingCredentialError | Config.ConfigError;
10
+ export type AuthError = CredentialError | LLMError;
11
+ type Secret = string | Redacted.Redacted | Config.Config<string | Redacted.Redacted>;
12
+ export interface AuthInput {
13
+ readonly request: LLMRequest;
14
+ readonly method: "POST" | "GET";
15
+ readonly url: string;
16
+ readonly body: string;
17
+ readonly headers: Headers.Headers;
18
+ }
19
+ export interface Credential {
20
+ readonly load: Effect.Effect<Redacted.Redacted, CredentialError>;
21
+ readonly orElse: (that: Credential) => Credential;
22
+ readonly bearer: () => Definition;
23
+ readonly header: (name: string) => Definition;
24
+ readonly pipe: <A>(f: (self: Credential) => A) => A;
25
+ }
26
+ export interface Definition {
27
+ readonly apply: (input: AuthInput) => Effect.Effect<Headers.Headers, AuthError>;
28
+ readonly andThen: (that: Definition) => Definition;
29
+ readonly orElse: (that: Definition) => Definition;
30
+ readonly pipe: <A>(f: (self: Definition) => A) => A;
31
+ }
32
+ export declare const isAuth: (input: unknown) => input is Definition;
33
+ export declare const value: (secret: string, source?: string) => Credential;
34
+ export declare const optional: (secret: Secret | undefined, source?: string) => Credential;
35
+ export declare const config: (name: string) => Credential;
36
+ export declare const effect: (load: Effect.Effect<Redacted.Redacted, CredentialError>) => Credential;
37
+ export declare const none: Definition;
38
+ export declare const headers: (input: Headers.Input) => Definition;
39
+ export declare const remove: (name: string) => Definition;
40
+ export declare const custom: (apply: (input: AuthInput) => Effect.Effect<Headers.Headers, LLMError>) => Definition;
41
+ export declare const passthrough: Definition;
42
+ export declare function bearer(source: Secret | Credential): Definition;
43
+ export declare const apiKey: typeof bearer;
44
+ export declare function header(name: string): (source: Secret | Credential) => Definition;
45
+ export declare function header(name: string, source: Secret | Credential): Definition;
46
+ export declare function bearerHeader(name: string): (source: Secret | Credential) => Definition;
47
+ export declare function bearerHeader(name: string, source: Secret | Credential): Definition;
48
+ export declare const toEffect: (input: Definition) => (authInput: AuthInput) => Effect.Effect<Headers.Headers, LLMError>;
49
+ export * as Auth from "./auth";
@@ -0,0 +1,89 @@
1
+ import { Config, Effect, Redacted } from "effect";
2
+ import { Headers } from "effect/unstable/http";
3
+ import { AuthenticationReason, InvalidRequestReason, LLMError } from "../schema";
4
+ export class MissingCredentialError extends Error {
5
+ source;
6
+ _tag = "MissingCredentialError";
7
+ constructor(source) {
8
+ super(`Missing auth credential: ${source}`);
9
+ this.source = source;
10
+ }
11
+ }
12
+ export const isAuth = (input) => typeof input === "object" && input !== null && "apply" in input && typeof input.apply === "function";
13
+ const credential = (load) => {
14
+ const self = {
15
+ load,
16
+ orElse: (that) => credential(load.pipe(Effect.catch(() => that.load))),
17
+ bearer: () => fromCredential(self, (secret) => ({ authorization: `Bearer ${secret}` })),
18
+ header: (name) => fromCredential(self, (secret) => ({ [name]: secret })),
19
+ pipe: (f) => f(self),
20
+ };
21
+ return self;
22
+ };
23
+ const auth = (apply) => {
24
+ const self = {
25
+ apply,
26
+ andThen: (that) => auth((input) => apply(input).pipe(Effect.flatMap((headers) => that.apply({ ...input, headers })))),
27
+ orElse: (that) => auth((input) => apply(input).pipe(Effect.catch(() => that.apply(input)))),
28
+ pipe: (f) => f(self),
29
+ };
30
+ return self;
31
+ };
32
+ const fromCredential = (source, render) => auth((input) => source.load.pipe(Effect.map((secret) => Headers.setAll(input.headers, render(Redacted.value(secret))))));
33
+ const secretEffect = (secret, source) => {
34
+ const redacted = typeof secret === "string" ? Redacted.make(secret) : secret;
35
+ if (Redacted.value(redacted) === "")
36
+ return Effect.fail(new MissingCredentialError(source));
37
+ return Effect.succeed(redacted);
38
+ };
39
+ const credentialFromSecret = (secret, source) => {
40
+ if (typeof secret === "string" || Redacted.isRedacted(secret))
41
+ return credential(secretEffect(secret, source));
42
+ return credential(Effect.gen(function* () {
43
+ return yield* secretEffect(yield* secret, source);
44
+ }));
45
+ };
46
+ export const value = (secret, source = "value") => credentialFromSecret(secret, source);
47
+ export const optional = (secret, source = "optional value") => secret === undefined
48
+ ? credential(Effect.fail(new MissingCredentialError(source)))
49
+ : credentialFromSecret(secret, source);
50
+ export const config = (name) => credentialFromSecret(Config.redacted(name), name);
51
+ export const effect = (load) => credential(load);
52
+ export const none = auth((input) => Effect.succeed(input.headers));
53
+ export const headers = (input) => auth((inputAuth) => Effect.succeed(Headers.setAll(inputAuth.headers, input)));
54
+ export const remove = (name) => auth((input) => Effect.succeed(Headers.remove(input.headers, name)));
55
+ export const custom = (apply) => auth(apply);
56
+ export const passthrough = none;
57
+ const credentialInput = (source) => typeof source === "string" || Redacted.isRedacted(source) || Config.isConfig(source)
58
+ ? credentialFromSecret(source, "value")
59
+ : source;
60
+ export function bearer(source) {
61
+ return credentialInput(source).bearer();
62
+ }
63
+ export const apiKey = bearer;
64
+ export function header(name, source) {
65
+ if (source === undefined) {
66
+ return (next) => credentialInput(next).header(name);
67
+ }
68
+ return credentialInput(source).header(name);
69
+ }
70
+ export function bearerHeader(name, source) {
71
+ const render = (input) => fromCredential(credentialInput(input), (secret) => ({ [name]: `Bearer ${secret}` }));
72
+ if (source === undefined)
73
+ return render;
74
+ return render(source);
75
+ }
76
+ const toLLMError = (error) => {
77
+ if (error instanceof MissingCredentialError || error instanceof Config.ConfigError) {
78
+ return new LLMError({
79
+ module: "Auth",
80
+ method: "apply",
81
+ reason: error instanceof MissingCredentialError
82
+ ? new AuthenticationReason({ message: error.message, kind: "missing" })
83
+ : new InvalidRequestReason({ message: `Failed to resolve auth config: ${error.message}` }),
84
+ });
85
+ }
86
+ return error;
87
+ };
88
+ export const toEffect = (input) => (authInput) => input.apply(authInput).pipe(Effect.mapError(toLLMError));
89
+ export * as Auth from "./auth";
@@ -0,0 +1,330 @@
1
+ import { Context, Effect, Layer, Schema, Stream } from "effect";
2
+ import { Auth } from "./auth";
3
+ import { Endpoint, type EndpointPatch } from "./endpoint";
4
+ import { RequestExecutor } from "./executor";
5
+ import { Framing } from "./framing";
6
+ import { HttpTransport } from "./transport";
7
+ import type { Transport, TransportRuntime } from "./transport";
8
+ import type { Protocol } from "./protocol";
9
+ import type { LLMError, PreparedRequestOf, ProtocolID, ProviderOptions } from "../schema";
10
+ import { GenerationOptions, HttpOptions, LLMRequest, LLMResponse, Model, ModelLimits, LLMEvent, ProviderID } from "../schema";
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, LLMError>;
16
+ }
17
+ export interface Route<Body, Prepared = unknown> {
18
+ readonly id: string;
19
+ readonly provider?: ProviderID;
20
+ /** ProviderMetadata namespace emitted and consumed by this route. */
21
+ readonly providerMetadataKey?: string;
22
+ readonly protocol: ProtocolID;
23
+ readonly endpoint: Endpoint.Definition<Body>;
24
+ readonly auth: Auth.Definition;
25
+ readonly transport: Transport<Body, Prepared, unknown>;
26
+ readonly defaults: RouteDefaults;
27
+ readonly body: RouteBody<Body>;
28
+ readonly with: (patch: RoutePatch<Body, Prepared>) => Route<Body, Prepared>;
29
+ readonly model: (input: RouteMappedModelInput) => Model;
30
+ readonly prepareTransport: (body: Body, request: LLMRequest) => Effect.Effect<Prepared, LLMError>;
31
+ readonly streamPrepared: (prepared: Prepared, request: LLMRequest, runtime: TransportRuntime) => Stream.Stream<LLMEvent, LLMError>;
32
+ }
33
+ export type AnyRoute = Route<any, any>;
34
+ export type HttpOptionsInput = HttpOptions.Input;
35
+ export type RouteModelInput = Omit<Model.Input, "provider" | "route">;
36
+ export type RouteRoutedModelInput = Omit<Model.Input, "route">;
37
+ export interface RouteDefaults {
38
+ readonly headers?: Record<string, string>;
39
+ readonly limits?: ModelLimits;
40
+ readonly generation?: GenerationOptions;
41
+ readonly providerOptions?: ProviderOptions;
42
+ readonly http?: HttpOptions;
43
+ }
44
+ export interface RouteDefaultsInput {
45
+ readonly headers?: Record<string, string>;
46
+ readonly limits?: ModelLimits.Input;
47
+ readonly generation?: GenerationOptions.Input;
48
+ readonly providerOptions?: ProviderOptions;
49
+ readonly http?: HttpOptions.Input;
50
+ }
51
+ export interface RoutePatch<Body, Prepared> extends RouteDefaultsInput {
52
+ readonly id?: string;
53
+ readonly provider?: string | ProviderID;
54
+ readonly auth?: Auth.Definition;
55
+ readonly transport?: Transport<Body, Prepared, unknown>;
56
+ readonly endpoint?: EndpointPatch<Body>;
57
+ }
58
+ type RouteMappedModelInput = RouteModelInput | RouteRoutedModelInput;
59
+ export declare const generationOptions: (input: GenerationOptions.Input | undefined) => GenerationOptions | undefined;
60
+ export declare const httpOptions: (input: HttpOptionsInput | undefined) => HttpOptions | undefined;
61
+ export interface Interface {
62
+ /**
63
+ * Compile a request through protocol body construction, validation, and HTTP
64
+ * preparation without sending it. Returns the prepared request including the
65
+ * provider-native body.
66
+ *
67
+ * Pass a `Body` type argument to statically expose the route's body
68
+ * shape (e.g. `prepare<OpenAIChatBody>(...)`) — the runtime body is
69
+ * identical, so this is a type-level assertion the caller makes about which
70
+ * route the request will resolve to.
71
+ */
72
+ readonly prepare: <Body = unknown>(request: LLMRequest) => Effect.Effect<PreparedRequestOf<Body>, LLMError>;
73
+ readonly stream: StreamMethod;
74
+ readonly generate: GenerateMethod;
75
+ }
76
+ export interface StreamMethod {
77
+ (request: LLMRequest): Stream.Stream<LLMEvent, LLMError>;
78
+ }
79
+ export interface GenerateMethod {
80
+ (request: LLMRequest): Effect.Effect<LLMResponse, LLMError>;
81
+ }
82
+ declare const Service_base: Context.ServiceClass<Service, "@opencode/LLMClient", Interface>;
83
+ export declare class Service extends Service_base {
84
+ }
85
+ export interface MakeInput<Body, Frame, Event, State> {
86
+ /** Route id used in diagnostics and prepared request metadata. */
87
+ readonly id: string;
88
+ /** Provider identity for route-owned model construction. */
89
+ readonly provider?: string | ProviderID;
90
+ /** ProviderMetadata namespace emitted and consumed by this route. */
91
+ readonly providerMetadataKey?: string;
92
+ /** Semantic API contract — owns body construction, body schema, and parsing. */
93
+ readonly protocol: Protocol<Body, Frame, Event, State>;
94
+ /** Where the request is sent. */
95
+ readonly endpoint: Endpoint.Definition<Body>;
96
+ /** Per-request transport auth. Provider facades override this via `route.with(...)`. */
97
+ readonly auth?: Auth.Definition;
98
+ /** Stream framing — bytes -> frames before `protocol.stream.event` decoding. */
99
+ readonly framing: Framing.Definition<Frame>;
100
+ /** Static / per-request headers added before `auth` runs. */
101
+ readonly headers?: (input: {
102
+ readonly request: LLMRequest;
103
+ }) => Record<string, string>;
104
+ /** Route/request defaults used when compiling requests for this route. */
105
+ readonly defaults?: RouteDefaultsInput;
106
+ }
107
+ export interface MakeTransportInput<Body, Prepared, Frame, Event, State> {
108
+ /** Route id used in diagnostics and prepared request metadata. */
109
+ readonly id: string;
110
+ /** Provider identity for route-owned model construction. */
111
+ readonly provider?: string | ProviderID;
112
+ /** ProviderMetadata namespace emitted and consumed by this route. */
113
+ readonly providerMetadataKey?: string;
114
+ /** Semantic API contract — owns body construction, body schema, and parsing. */
115
+ readonly protocol: Protocol<Body, Frame, Event, State>;
116
+ /** Where the request is sent. */
117
+ readonly endpoint: Endpoint.Definition<Body>;
118
+ /** Per-request transport auth. Provider facades override this via `route.with(...)`. */
119
+ readonly auth?: Auth.Definition;
120
+ /** Static / per-request headers added before `auth` runs. */
121
+ readonly headers?: (input: {
122
+ readonly request: LLMRequest;
123
+ }) => Record<string, string>;
124
+ /** Runnable transport route. */
125
+ readonly transport: Transport<Body, Prepared, Frame>;
126
+ /** Route/request defaults used when compiling requests for this route. */
127
+ readonly defaults?: RouteDefaultsInput;
128
+ }
129
+ export declare function make<Body, Prepared, Frame, Event, State>(input: MakeTransportInput<Body, Prepared, Frame, Event, State>): Route<Body, Prepared>;
130
+ /**
131
+ * Build a `Route` by composing the four orthogonal pieces of a deployment:
132
+ *
133
+ * - `Protocol` — what is the API I'm speaking?
134
+ * - `Endpoint` — where do I send the request?
135
+ * - `Auth` — how do I authenticate it?
136
+ * - `Framing` — how do I cut the response stream into protocol frames?
137
+ *
138
+ * Plus optional `headers` for cross-cutting deployment concerns (provider
139
+ * version pins, per-deployment quirks).
140
+ *
141
+ * This is the canonical route constructor. If a new route does not fit
142
+ * this four-axis model, add a purpose-built constructor rather than widening
143
+ * the public surface preemptively.
144
+ */
145
+ export declare function make<Body, Frame, Event, State>(input: MakeInput<Body, Frame, Event, State>): Route<Body, HttpTransport.HttpPrepared<Frame>>;
146
+ export declare const prepare: <Body = unknown>(request: LLMRequest) => Effect.Effect<PreparedRequestOf<Body>, LLMError>;
147
+ export declare function stream(request: LLMRequest): Stream.Stream<LLMEvent, LLMError>;
148
+ export declare function generate(request: LLMRequest): Effect.Effect<LLMResponse, LLMError>;
149
+ export declare const streamRequest: (request: LLMRequest) => Stream.Stream<{
150
+ readonly type: "step-start";
151
+ readonly index: number;
152
+ } | {
153
+ readonly type: "text-start";
154
+ readonly id: string;
155
+ readonly providerMetadata?: {
156
+ readonly [x: string]: {
157
+ readonly [x: string]: unknown;
158
+ };
159
+ } | undefined;
160
+ } | {
161
+ readonly type: "text-delta";
162
+ readonly id: string;
163
+ readonly text: string;
164
+ readonly providerMetadata?: {
165
+ readonly [x: string]: {
166
+ readonly [x: string]: unknown;
167
+ };
168
+ } | undefined;
169
+ } | {
170
+ readonly type: "text-end";
171
+ readonly id: string;
172
+ readonly providerMetadata?: {
173
+ readonly [x: string]: {
174
+ readonly [x: string]: unknown;
175
+ };
176
+ } | undefined;
177
+ } | {
178
+ readonly type: "reasoning-start";
179
+ readonly id: string;
180
+ readonly providerMetadata?: {
181
+ readonly [x: string]: {
182
+ readonly [x: string]: unknown;
183
+ };
184
+ } | undefined;
185
+ } | {
186
+ readonly type: "reasoning-delta";
187
+ readonly id: string;
188
+ readonly text: string;
189
+ readonly providerMetadata?: {
190
+ readonly [x: string]: {
191
+ readonly [x: string]: unknown;
192
+ };
193
+ } | undefined;
194
+ } | {
195
+ readonly type: "reasoning-end";
196
+ readonly id: string;
197
+ readonly providerMetadata?: {
198
+ readonly [x: string]: {
199
+ readonly [x: string]: unknown;
200
+ };
201
+ } | undefined;
202
+ } | {
203
+ readonly type: "tool-input-start";
204
+ readonly id: string;
205
+ readonly name: string;
206
+ readonly providerMetadata?: {
207
+ readonly [x: string]: {
208
+ readonly [x: string]: unknown;
209
+ };
210
+ } | undefined;
211
+ } | {
212
+ readonly type: "tool-input-delta";
213
+ readonly id: string;
214
+ readonly name: string;
215
+ readonly text: string;
216
+ } | {
217
+ readonly type: "tool-input-end";
218
+ readonly id: string;
219
+ readonly name: string;
220
+ readonly providerMetadata?: {
221
+ readonly [x: string]: {
222
+ readonly [x: string]: unknown;
223
+ };
224
+ } | undefined;
225
+ } | {
226
+ readonly type: "tool-call";
227
+ readonly id: string;
228
+ readonly name: string;
229
+ readonly input: unknown;
230
+ readonly providerExecuted?: boolean | undefined;
231
+ readonly providerMetadata?: {
232
+ readonly [x: string]: {
233
+ readonly [x: string]: unknown;
234
+ };
235
+ } | undefined;
236
+ } | {
237
+ readonly type: "tool-result";
238
+ readonly id: string;
239
+ readonly name: string;
240
+ readonly result: {
241
+ readonly type: "json";
242
+ readonly value: unknown;
243
+ } | {
244
+ readonly type: "text";
245
+ readonly value: unknown;
246
+ } | {
247
+ readonly type: "error";
248
+ readonly value: unknown;
249
+ } | {
250
+ readonly type: "content";
251
+ readonly value: readonly ({
252
+ readonly type: "text";
253
+ readonly text: string;
254
+ } | {
255
+ readonly type: "file";
256
+ readonly uri: string;
257
+ readonly mime: string;
258
+ readonly name?: string | undefined;
259
+ })[];
260
+ };
261
+ readonly output?: {
262
+ readonly structured: unknown;
263
+ readonly content: readonly ({
264
+ readonly type: "text";
265
+ readonly text: string;
266
+ } | {
267
+ readonly type: "file";
268
+ readonly uri: string;
269
+ readonly mime: string;
270
+ readonly name?: string | undefined;
271
+ })[];
272
+ } | undefined;
273
+ readonly providerExecuted?: boolean | undefined;
274
+ readonly providerMetadata?: {
275
+ readonly [x: string]: {
276
+ readonly [x: string]: unknown;
277
+ };
278
+ } | undefined;
279
+ } | {
280
+ readonly type: "tool-error";
281
+ readonly id: string;
282
+ readonly name: string;
283
+ readonly message: string;
284
+ readonly error?: unknown;
285
+ readonly providerMetadata?: {
286
+ readonly [x: string]: {
287
+ readonly [x: string]: unknown;
288
+ };
289
+ } | undefined;
290
+ } | {
291
+ readonly type: "step-finish";
292
+ readonly index: number;
293
+ readonly reason: "length" | "stop" | "tool-calls" | "content-filter" | "error" | "unknown";
294
+ readonly usage?: import("..").Usage | undefined;
295
+ readonly providerMetadata?: {
296
+ readonly [x: string]: {
297
+ readonly [x: string]: unknown;
298
+ };
299
+ } | undefined;
300
+ } | {
301
+ readonly type: "finish";
302
+ readonly reason: "length" | "stop" | "tool-calls" | "content-filter" | "error" | "unknown";
303
+ readonly usage?: import("..").Usage | undefined;
304
+ readonly providerMetadata?: {
305
+ readonly [x: string]: {
306
+ readonly [x: string]: unknown;
307
+ };
308
+ } | undefined;
309
+ } | {
310
+ readonly type: "provider-error";
311
+ readonly message: string;
312
+ readonly classification?: "context-overflow" | undefined;
313
+ readonly providerMetadata?: {
314
+ readonly [x: string]: {
315
+ readonly [x: string]: unknown;
316
+ };
317
+ } | undefined;
318
+ }, LLMError, Service>;
319
+ export declare const layer: Layer.Layer<Service, never, RequestExecutor.Service>;
320
+ export declare const Route: {
321
+ readonly make: typeof make;
322
+ };
323
+ export declare const LLMClient: {
324
+ readonly Service: typeof Service;
325
+ readonly layer: Layer.Layer<Service, never, RequestExecutor.Service>;
326
+ readonly prepare: <Body = unknown>(request: LLMRequest) => Effect.Effect<PreparedRequestOf<Body>, LLMError>;
327
+ readonly stream: typeof stream;
328
+ readonly generate: typeof generate;
329
+ };
330
+ export {};