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

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,181 @@
1
+ import type { ProviderPackage } from "../provider-package";
2
+ import type { RouteDefaultsInput } from "../route/client";
3
+ import { type ModelID, type ProviderOptions } from "../schema";
4
+ import { GoogleVertexShared } from "./google-vertex-shared";
5
+ export declare const id: string & import("effect/Brand").Brand<"LLM.ProviderID">;
6
+ export type Config = RouteDefaultsInput & GoogleVertexShared.OAuthOptions & {
7
+ readonly baseURL?: string;
8
+ readonly location?: string;
9
+ readonly project?: string;
10
+ };
11
+ export interface Settings extends ProviderPackage.Settings {
12
+ readonly accessToken?: string;
13
+ readonly apiKey?: never;
14
+ readonly baseURL?: string;
15
+ readonly location?: string;
16
+ readonly project?: string;
17
+ readonly providerOptions?: ProviderOptions;
18
+ }
19
+ export declare const routes: import("../route").Route<{
20
+ anthropic_version: "vertex-2023-10-16";
21
+ system?: readonly {
22
+ readonly type: "text";
23
+ readonly text: string;
24
+ readonly cache_control?: {
25
+ readonly type: "ephemeral";
26
+ readonly ttl?: "1h" | "5m" | undefined;
27
+ } | undefined;
28
+ }[] | undefined;
29
+ messages: readonly ({
30
+ readonly role: "user";
31
+ readonly content: readonly ({
32
+ readonly type: "text";
33
+ readonly text: string;
34
+ readonly cache_control?: {
35
+ readonly type: "ephemeral";
36
+ readonly ttl?: "1h" | "5m" | undefined;
37
+ } | undefined;
38
+ } | {
39
+ readonly type: "image";
40
+ readonly source: {
41
+ readonly type: "base64";
42
+ readonly media_type: string;
43
+ readonly data: string;
44
+ };
45
+ readonly cache_control?: {
46
+ readonly type: "ephemeral";
47
+ readonly ttl?: "1h" | "5m" | undefined;
48
+ } | undefined;
49
+ } | {
50
+ readonly type: "tool_result";
51
+ readonly tool_use_id: string;
52
+ readonly content: string | readonly ({
53
+ readonly type: "text";
54
+ readonly text: string;
55
+ readonly cache_control?: {
56
+ readonly type: "ephemeral";
57
+ readonly ttl?: "1h" | "5m" | undefined;
58
+ } | undefined;
59
+ } | {
60
+ readonly type: "image";
61
+ readonly source: {
62
+ readonly type: "base64";
63
+ readonly media_type: string;
64
+ readonly data: string;
65
+ };
66
+ readonly cache_control?: {
67
+ readonly type: "ephemeral";
68
+ readonly ttl?: "1h" | "5m" | undefined;
69
+ } | undefined;
70
+ })[];
71
+ readonly is_error?: boolean | undefined;
72
+ readonly cache_control?: {
73
+ readonly type: "ephemeral";
74
+ readonly ttl?: "1h" | "5m" | undefined;
75
+ } | undefined;
76
+ })[];
77
+ } | {
78
+ readonly role: "assistant";
79
+ readonly content: readonly ({
80
+ readonly type: "text";
81
+ readonly text: string;
82
+ readonly cache_control?: {
83
+ readonly type: "ephemeral";
84
+ readonly ttl?: "1h" | "5m" | undefined;
85
+ } | undefined;
86
+ } | {
87
+ readonly type: "tool_use";
88
+ readonly id: string;
89
+ readonly name: string;
90
+ readonly input: unknown;
91
+ readonly cache_control?: {
92
+ readonly type: "ephemeral";
93
+ readonly ttl?: "1h" | "5m" | undefined;
94
+ } | undefined;
95
+ } | {
96
+ readonly type: "server_tool_use";
97
+ readonly id: string;
98
+ readonly name: string;
99
+ readonly input: unknown;
100
+ readonly cache_control?: {
101
+ readonly type: "ephemeral";
102
+ readonly ttl?: "1h" | "5m" | undefined;
103
+ } | undefined;
104
+ } | {
105
+ readonly type: "web_search_tool_result" | "code_execution_tool_result" | "web_fetch_tool_result";
106
+ readonly tool_use_id: string;
107
+ readonly content: unknown;
108
+ readonly cache_control?: {
109
+ readonly type: "ephemeral";
110
+ readonly ttl?: "1h" | "5m" | undefined;
111
+ } | undefined;
112
+ } | {
113
+ readonly type: "thinking";
114
+ readonly thinking: string;
115
+ readonly signature?: string | undefined;
116
+ readonly cache_control?: {
117
+ readonly type: "ephemeral";
118
+ readonly ttl?: "1h" | "5m" | undefined;
119
+ } | undefined;
120
+ })[];
121
+ } | {
122
+ readonly role: "system";
123
+ readonly content: readonly {
124
+ readonly type: "text";
125
+ readonly text: string;
126
+ readonly cache_control?: {
127
+ readonly type: "ephemeral";
128
+ readonly ttl?: "1h" | "5m" | undefined;
129
+ } | undefined;
130
+ }[];
131
+ })[];
132
+ tools?: readonly {
133
+ readonly name: string;
134
+ readonly description: string;
135
+ readonly input_schema: {
136
+ readonly [x: string]: unknown;
137
+ };
138
+ readonly cache_control?: {
139
+ readonly type: "ephemeral";
140
+ readonly ttl?: "1h" | "5m" | undefined;
141
+ } | undefined;
142
+ }[] | undefined;
143
+ temperature?: number | undefined;
144
+ stream: true;
145
+ max_tokens: number;
146
+ stop_sequences?: readonly string[] | undefined;
147
+ thinking?: {
148
+ readonly type: "enabled";
149
+ readonly budget_tokens: number;
150
+ } | {
151
+ readonly type: "adaptive";
152
+ readonly display?: "summarized" | "omitted" | undefined;
153
+ } | {
154
+ readonly type: "disabled";
155
+ } | undefined;
156
+ tool_choice?: {
157
+ readonly type: "auto" | "any";
158
+ } | {
159
+ readonly type: "tool";
160
+ readonly name: string;
161
+ } | undefined;
162
+ top_k?: number | undefined;
163
+ top_p?: number | undefined;
164
+ output_config?: {
165
+ readonly effort?: string | undefined;
166
+ } | undefined;
167
+ }, import("../route/transport/http").HttpPrepared<string>>[];
168
+ export declare const configure: (input?: Config) => {
169
+ id: string & import("effect/Brand").Brand<"LLM.ProviderID">;
170
+ model: (modelID: string | ModelID) => import("..").Model;
171
+ configure: (input?: Config) => /*elided*/ any;
172
+ };
173
+ export declare const provider: {
174
+ id: string & import("effect/Brand").Brand<"LLM.ProviderID">;
175
+ configure: (input?: Config) => {
176
+ id: string & import("effect/Brand").Brand<"LLM.ProviderID">;
177
+ model: (modelID: string | ModelID) => import("..").Model;
178
+ configure: /*elided*/ any;
179
+ };
180
+ };
181
+ export declare const model: ProviderPackage.Definition<Settings>["model"];
@@ -0,0 +1,46 @@
1
+ import { GoogleVertexAnthropic } from "../protocols/google-vertex-anthropic";
2
+ import { ProviderID } from "../schema";
3
+ import { GoogleVertexShared } from "./google-vertex-shared";
4
+ export const id = ProviderID.make("google-vertex-anthropic");
5
+ export const routes = [GoogleVertexAnthropic.route];
6
+ const configuredRoute = (input) => {
7
+ if ("apiKey" in input && input.apiKey !== undefined)
8
+ throw new Error("Google Vertex Anthropic does not support API keys");
9
+ const { accessToken: _accessToken, auth: _auth, baseURL, location: inputLocation, project: inputProject, ...rest } = input;
10
+ const location = GoogleVertexShared.location(inputLocation, "global");
11
+ const project = GoogleVertexShared.project(inputProject);
12
+ return GoogleVertexAnthropic.route.with({
13
+ ...rest,
14
+ endpoint: {
15
+ baseURL: baseURL ??
16
+ `https://${GoogleVertexShared.host(location)}/v1/projects/${GoogleVertexShared.requireProject(project)}/locations/${location}/publishers/anthropic/models`,
17
+ },
18
+ auth: GoogleVertexShared.oauth(input, project),
19
+ });
20
+ };
21
+ export const configure = (input = {}) => {
22
+ const route = configuredRoute(input);
23
+ return {
24
+ id,
25
+ model: (modelID) => route.model({ id: modelID }),
26
+ configure,
27
+ };
28
+ };
29
+ export const provider = {
30
+ id,
31
+ configure,
32
+ };
33
+ export const model = (modelID, settings) => {
34
+ if (settings.apiKey !== undefined)
35
+ throw new Error("Google Vertex Anthropic does not support API keys");
36
+ return configure({
37
+ accessToken: settings.accessToken,
38
+ baseURL: settings.baseURL,
39
+ headers: settings.headers === undefined ? undefined : { ...settings.headers },
40
+ http: settings.body === undefined ? undefined : { body: { ...settings.body } },
41
+ limits: settings.limits,
42
+ location: settings.location,
43
+ project: settings.project,
44
+ providerOptions: settings.providerOptions,
45
+ }).model(modelID);
46
+ };
@@ -0,0 +1,22 @@
1
+ import { Auth } from "../route/auth";
2
+ export type OAuthOptions = {
3
+ readonly accessToken?: string;
4
+ readonly auth?: never;
5
+ } | {
6
+ readonly accessToken?: never;
7
+ readonly auth?: Auth.Definition;
8
+ };
9
+ export type ApiKeyOptions = (OAuthOptions & {
10
+ readonly apiKey?: never;
11
+ }) | {
12
+ readonly accessToken?: never;
13
+ readonly apiKey?: string;
14
+ readonly auth?: never;
15
+ };
16
+ export declare const project: (value?: string) => string | undefined;
17
+ export declare const location: (value: string | undefined, fallback: string) => string;
18
+ export declare const host: (location: string) => string;
19
+ export declare const requireProject: (value: string | undefined) => string;
20
+ export declare const apiKey: (input: ApiKeyOptions) => string | undefined;
21
+ export declare const oauth: (input: OAuthOptions, project?: string) => Auth.Definition;
22
+ export * as GoogleVertexShared from "./google-vertex-shared";
@@ -0,0 +1,61 @@
1
+ import { Effect, Redacted } from "effect";
2
+ import { Auth, MissingCredentialError } from "../route/auth";
3
+ const SCOPE = "https://www.googleapis.com/auth/cloud-platform";
4
+ export const project = (value) => value ??
5
+ process.env.GOOGLE_VERTEX_PROJECT ??
6
+ process.env.GOOGLE_CLOUD_PROJECT ??
7
+ process.env.GCP_PROJECT ??
8
+ process.env.GCLOUD_PROJECT;
9
+ export const location = (value, fallback) => value ??
10
+ process.env.GOOGLE_VERTEX_LOCATION ??
11
+ process.env.GOOGLE_CLOUD_LOCATION ??
12
+ process.env.VERTEX_LOCATION ??
13
+ fallback;
14
+ export const host = (location) => {
15
+ if (location === "global")
16
+ return "aiplatform.googleapis.com";
17
+ // Jurisdictional multi-regions use Regional Endpoint Platform domains.
18
+ if (location === "eu" || location === "us")
19
+ return `aiplatform.${location}.rep.googleapis.com`;
20
+ return `${location}-aiplatform.googleapis.com`;
21
+ };
22
+ export const requireProject = (value) => {
23
+ if (value)
24
+ return value;
25
+ throw new Error("Google Vertex requires a project when baseURL is not configured");
26
+ };
27
+ export const apiKey = (input) => {
28
+ if (input.apiKey !== undefined && (input.accessToken !== undefined || input.auth !== undefined))
29
+ throw new Error("Google Vertex apiKey cannot be combined with accessToken or auth");
30
+ if (input.accessToken !== undefined || input.auth !== undefined)
31
+ return undefined;
32
+ return input.apiKey ?? process.env.GOOGLE_VERTEX_API_KEY;
33
+ };
34
+ const adc = (project) => {
35
+ let client;
36
+ const loadClient = () => {
37
+ if (client)
38
+ return client;
39
+ client = import("google-auth-library").then(({ GoogleAuth }) => new GoogleAuth({ projectId: project, scopes: [SCOPE] }).getClient());
40
+ return client;
41
+ };
42
+ return Auth.effect(Effect.tryPromise({
43
+ try: async () => {
44
+ const token = await (await loadClient()).getAccessToken();
45
+ if (!token.token)
46
+ throw new Error("Google ADC returned an empty access token");
47
+ return Redacted.make(token.token);
48
+ },
49
+ catch: () => new MissingCredentialError("Google Application Default Credentials"),
50
+ })).bearer();
51
+ };
52
+ export const oauth = (input, project) => {
53
+ if (input.accessToken !== undefined && input.auth !== undefined)
54
+ throw new Error("Google Vertex accessToken cannot be combined with auth");
55
+ if (input.auth)
56
+ return input.auth;
57
+ if (input.accessToken !== undefined)
58
+ return Auth.bearer(input.accessToken);
59
+ return adc(project);
60
+ };
61
+ export * as GoogleVertexShared from "./google-vertex-shared";
@@ -0,0 +1,93 @@
1
+ import type { ProviderPackage } from "../provider-package";
2
+ import type { RouteDefaultsInput } from "../route/client";
3
+ import { type ModelID, type ProviderOptions } from "../schema";
4
+ import { GoogleVertexShared } from "./google-vertex-shared";
5
+ export declare const id: string & import("effect/Brand").Brand<"LLM.ProviderID">;
6
+ export type Config = RouteDefaultsInput & GoogleVertexShared.ApiKeyOptions & {
7
+ readonly baseURL?: string;
8
+ readonly location?: string;
9
+ readonly project?: string;
10
+ };
11
+ export type Settings = ProviderPackage.Settings & ({
12
+ readonly accessToken?: string;
13
+ readonly apiKey?: never;
14
+ } | {
15
+ readonly accessToken?: never;
16
+ readonly apiKey?: string;
17
+ }) & {
18
+ readonly baseURL?: string;
19
+ readonly location?: string;
20
+ readonly project?: string;
21
+ readonly providerOptions?: ProviderOptions;
22
+ };
23
+ export declare const routes: import("../route").Route<{
24
+ readonly contents: readonly {
25
+ readonly role: "user" | "model";
26
+ readonly parts: readonly ({
27
+ readonly text: string;
28
+ readonly thought?: boolean | undefined;
29
+ readonly thoughtSignature?: string | undefined;
30
+ } | {
31
+ readonly inlineData: {
32
+ readonly mimeType: string;
33
+ readonly data: string;
34
+ };
35
+ } | {
36
+ readonly functionCall: {
37
+ readonly name: string;
38
+ readonly args: unknown;
39
+ };
40
+ readonly thoughtSignature?: string | undefined;
41
+ } | {
42
+ readonly functionResponse: {
43
+ readonly name: string;
44
+ readonly response: unknown;
45
+ };
46
+ })[];
47
+ }[];
48
+ readonly systemInstruction?: {
49
+ readonly parts: readonly {
50
+ readonly text: string;
51
+ }[];
52
+ } | undefined;
53
+ readonly tools?: readonly {
54
+ readonly functionDeclarations: readonly {
55
+ readonly name: string;
56
+ readonly description: string;
57
+ readonly parameters?: {
58
+ readonly [x: string]: unknown;
59
+ } | undefined;
60
+ }[];
61
+ }[] | undefined;
62
+ readonly toolConfig?: {
63
+ readonly functionCallingConfig: {
64
+ readonly mode: "AUTO" | "NONE" | "ANY";
65
+ readonly allowedFunctionNames?: readonly string[] | undefined;
66
+ };
67
+ } | undefined;
68
+ readonly generationConfig?: {
69
+ readonly maxOutputTokens?: number | undefined;
70
+ readonly temperature?: number | undefined;
71
+ readonly topP?: number | undefined;
72
+ readonly topK?: number | undefined;
73
+ readonly stopSequences?: readonly string[] | undefined;
74
+ readonly thinkingConfig?: {
75
+ readonly thinkingBudget?: number | undefined;
76
+ readonly includeThoughts?: boolean | undefined;
77
+ } | undefined;
78
+ } | undefined;
79
+ }, import("../route/transport/http").HttpPrepared<string>>[];
80
+ export declare const configure: (input?: Config) => {
81
+ id: string & import("effect/Brand").Brand<"LLM.ProviderID">;
82
+ model: (modelID: string | ModelID) => import("..").Model;
83
+ configure: (input?: Config) => /*elided*/ any;
84
+ };
85
+ export declare const provider: {
86
+ id: string & import("effect/Brand").Brand<"LLM.ProviderID">;
87
+ configure: (input?: Config) => {
88
+ id: string & import("effect/Brand").Brand<"LLM.ProviderID">;
89
+ model: (modelID: string | ModelID) => import("..").Model;
90
+ configure: /*elided*/ any;
91
+ };
92
+ };
93
+ export declare const model: ProviderPackage.Definition<Settings>["model"];
@@ -0,0 +1,49 @@
1
+ import { GoogleVertexGemini } from "../protocols/google-vertex-gemini";
2
+ import { Auth } from "../route/auth";
3
+ import { ProviderID } from "../schema";
4
+ import { GoogleVertexShared } from "./google-vertex-shared";
5
+ export const id = ProviderID.make("google-vertex");
6
+ export const routes = [GoogleVertexGemini.route];
7
+ const configuredRoute = (input, modelID) => {
8
+ const { accessToken: _accessToken, apiKey: _apiKey, auth: _auth, baseURL, location: inputLocation, project: inputProject, ...rest } = input;
9
+ const apiKey = GoogleVertexShared.apiKey(input);
10
+ const endpointModel = String(modelID).startsWith("endpoints/");
11
+ if (apiKey !== undefined && endpointModel)
12
+ throw new Error("Google Vertex tuned models do not support Express Mode API keys");
13
+ const location = GoogleVertexShared.location(inputLocation, "us-central1");
14
+ const project = GoogleVertexShared.project(inputProject);
15
+ const endpoint = baseURL ??
16
+ (apiKey
17
+ ? "https://aiplatform.googleapis.com/v1/publishers/google"
18
+ : `https://${GoogleVertexShared.host(location)}/v1beta1/projects/${GoogleVertexShared.requireProject(project)}/locations/${location}${endpointModel ? "" : "/publishers/google"}`);
19
+ return GoogleVertexGemini.route.with({
20
+ ...rest,
21
+ endpoint: { baseURL: endpoint },
22
+ auth: apiKey === undefined ? GoogleVertexShared.oauth(input, project) : Auth.header("x-goog-api-key", apiKey),
23
+ });
24
+ };
25
+ export const configure = (input = {}) => {
26
+ return {
27
+ id,
28
+ model: (modelID) => configuredRoute(input, modelID).model({ id: modelID }),
29
+ configure,
30
+ };
31
+ };
32
+ export const provider = {
33
+ id,
34
+ configure,
35
+ };
36
+ export const model = (modelID, settings) => {
37
+ if (settings.apiKey !== undefined && settings.accessToken !== undefined)
38
+ throw new Error("Google Vertex apiKey cannot be combined with accessToken or auth");
39
+ return configure({
40
+ ...(settings.apiKey === undefined ? { accessToken: settings.accessToken } : { apiKey: settings.apiKey }),
41
+ baseURL: settings.baseURL,
42
+ headers: settings.headers === undefined ? undefined : { ...settings.headers },
43
+ http: settings.body === undefined ? undefined : { body: { ...settings.body } },
44
+ limits: settings.limits,
45
+ location: settings.location,
46
+ project: settings.project,
47
+ providerOptions: settings.providerOptions,
48
+ }).model(modelID);
49
+ };
@@ -0,0 +1,85 @@
1
+ import type { RouteDefaultsInput } from "../route/client";
2
+ import type { ProviderAuthOption } from "../route/auth-options";
3
+ import type { ProviderPackage } from "../provider-package";
4
+ import { type ModelID, type ProviderOptions } from "../schema";
5
+ export declare const id: string & import("effect/Brand").Brand<"LLM.ProviderID">;
6
+ export declare const routes: import("../route").Route<{
7
+ readonly contents: readonly {
8
+ readonly role: "user" | "model";
9
+ readonly parts: readonly ({
10
+ readonly text: string;
11
+ readonly thought?: boolean | undefined;
12
+ readonly thoughtSignature?: string | undefined;
13
+ } | {
14
+ readonly inlineData: {
15
+ readonly mimeType: string;
16
+ readonly data: string;
17
+ };
18
+ } | {
19
+ readonly functionCall: {
20
+ readonly name: string;
21
+ readonly args: unknown;
22
+ };
23
+ readonly thoughtSignature?: string | undefined;
24
+ } | {
25
+ readonly functionResponse: {
26
+ readonly name: string;
27
+ readonly response: unknown;
28
+ };
29
+ })[];
30
+ }[];
31
+ readonly systemInstruction?: {
32
+ readonly parts: readonly {
33
+ readonly text: string;
34
+ }[];
35
+ } | undefined;
36
+ readonly tools?: readonly {
37
+ readonly functionDeclarations: readonly {
38
+ readonly name: string;
39
+ readonly description: string;
40
+ readonly parameters?: {
41
+ readonly [x: string]: unknown;
42
+ } | undefined;
43
+ }[];
44
+ }[] | undefined;
45
+ readonly toolConfig?: {
46
+ readonly functionCallingConfig: {
47
+ readonly mode: "AUTO" | "NONE" | "ANY";
48
+ readonly allowedFunctionNames?: readonly string[] | undefined;
49
+ };
50
+ } | undefined;
51
+ readonly generationConfig?: {
52
+ readonly maxOutputTokens?: number | undefined;
53
+ readonly temperature?: number | undefined;
54
+ readonly topP?: number | undefined;
55
+ readonly topK?: number | undefined;
56
+ readonly stopSequences?: readonly string[] | undefined;
57
+ readonly thinkingConfig?: {
58
+ readonly thinkingBudget?: number | undefined;
59
+ readonly includeThoughts?: boolean | undefined;
60
+ } | undefined;
61
+ } | undefined;
62
+ }, import("../route/transport/http").HttpPrepared<string>>[];
63
+ export type Config = RouteDefaultsInput & ProviderAuthOption<"optional"> & {
64
+ readonly baseURL?: string;
65
+ };
66
+ export interface Settings extends ProviderPackage.Settings {
67
+ readonly apiKey?: string;
68
+ readonly baseURL?: string;
69
+ readonly providerOptions?: ProviderOptions;
70
+ }
71
+ export declare const configure: (input?: Config) => {
72
+ id: string & import("effect/Brand").Brand<"LLM.ProviderID">;
73
+ model: (modelID: string | ModelID) => import("..").Model;
74
+ configure: (input?: Config) => /*elided*/ any;
75
+ };
76
+ export declare const provider: {
77
+ id: string & import("effect/Brand").Brand<"LLM.ProviderID">;
78
+ model: (modelID: string | ModelID) => import("..").Model;
79
+ configure: (input?: Config) => {
80
+ id: string & import("effect/Brand").Brand<"LLM.ProviderID">;
81
+ model: (modelID: string | ModelID) => import("..").Model;
82
+ configure: /*elided*/ any;
83
+ };
84
+ };
85
+ export declare const model: ProviderPackage.Definition<Settings>["model"];
@@ -0,0 +1,33 @@
1
+ import { Auth } from "../route/auth";
2
+ import { ProviderID } from "../schema";
3
+ import * as Gemini from "../protocols/gemini";
4
+ export const id = ProviderID.make("google");
5
+ export const routes = [Gemini.route];
6
+ const auth = (options) => {
7
+ if ("auth" in options && options.auth)
8
+ return options.auth;
9
+ return Auth.optional("apiKey" in options ? options.apiKey : undefined, "apiKey")
10
+ .orElse(Auth.config("GOOGLE_GENERATIVE_AI_API_KEY"))
11
+ .pipe(Auth.header("x-goog-api-key"));
12
+ };
13
+ const configuredRoute = (input) => {
14
+ const { apiKey: _, auth: _auth, baseURL, ...rest } = input;
15
+ return Gemini.route.with({ ...rest, endpoint: { baseURL }, auth: auth(input) });
16
+ };
17
+ export const configure = (input = {}) => {
18
+ const route = configuredRoute(input);
19
+ return {
20
+ id,
21
+ model: (modelID) => route.model({ id: modelID }),
22
+ configure,
23
+ };
24
+ };
25
+ export const provider = configure();
26
+ export const model = (modelID, settings) => configure({
27
+ apiKey: settings.apiKey,
28
+ baseURL: settings.baseURL,
29
+ headers: settings.headers === undefined ? undefined : { ...settings.headers },
30
+ http: settings.body === undefined ? undefined : { body: { ...settings.body } },
31
+ limits: settings.limits,
32
+ providerOptions: settings.providerOptions,
33
+ }).model(modelID);
@@ -0,0 +1,15 @@
1
+ export * as Anthropic from "./anthropic";
2
+ export * as AnthropicCompatible from "./anthropic-compatible";
3
+ export * as AmazonBedrock from "./amazon-bedrock";
4
+ export * as Azure from "./azure";
5
+ export * as Cloudflare from "./cloudflare";
6
+ export { CloudflareAIGateway, CloudflareWorkersAI } from "./cloudflare";
7
+ export * as GitHubCopilot from "./github-copilot";
8
+ export * as Google from "./google";
9
+ export * as GoogleVertex from "./google-vertex";
10
+ export * as GoogleVertexAnthropic from "./google-vertex-anthropic";
11
+ export * as OpenAI from "./openai";
12
+ export * as OpenAICompatible from "./openai-compatible";
13
+ export * as OpenAICompatibleResponses from "./openai-compatible-responses";
14
+ export * as OpenRouter from "./openrouter";
15
+ export * as XAI from "./xai";
@@ -0,0 +1,15 @@
1
+ export * as Anthropic from "./anthropic";
2
+ export * as AnthropicCompatible from "./anthropic-compatible";
3
+ export * as AmazonBedrock from "./amazon-bedrock";
4
+ export * as Azure from "./azure";
5
+ export * as Cloudflare from "./cloudflare";
6
+ export { CloudflareAIGateway, CloudflareWorkersAI } from "./cloudflare";
7
+ export * as GitHubCopilot from "./github-copilot";
8
+ export * as Google from "./google";
9
+ export * as GoogleVertex from "./google-vertex";
10
+ export * as GoogleVertexAnthropic from "./google-vertex-anthropic";
11
+ export * as OpenAI from "./openai";
12
+ export * as OpenAICompatible from "./openai-compatible";
13
+ export * as OpenAICompatibleResponses from "./openai-compatible-responses";
14
+ export * as OpenRouter from "./openrouter";
15
+ export * as XAI from "./xai";
@@ -0,0 +1,2 @@
1
+ export { chatModel as model } from "../openai";
2
+ export type { Settings } from "../openai";
@@ -0,0 +1 @@
1
+ export { chatModel as model } from "../openai";
@@ -0,0 +1,2 @@
1
+ export { model } from "../openai";
2
+ export type { Settings } from "../openai";
@@ -0,0 +1 @@
1
+ export { model } from "../openai";
@@ -0,0 +1 @@
1
+ export * from "../openai-compatible-responses";
@@ -0,0 +1 @@
1
+ export * from "../openai-compatible-responses";
@@ -0,0 +1,43 @@
1
+ export interface OpenAICompatibleProfile {
2
+ readonly provider: string;
3
+ readonly baseURL: string;
4
+ }
5
+ export declare const profiles: {
6
+ readonly baseten: {
7
+ readonly provider: "baseten";
8
+ readonly baseURL: "https://inference.baseten.co/v1";
9
+ };
10
+ readonly cerebras: {
11
+ readonly provider: "cerebras";
12
+ readonly baseURL: "https://api.cerebras.ai/v1";
13
+ };
14
+ readonly deepinfra: {
15
+ readonly provider: "deepinfra";
16
+ readonly baseURL: "https://api.deepinfra.com/v1/openai";
17
+ };
18
+ readonly deepseek: {
19
+ readonly provider: "deepseek";
20
+ readonly baseURL: "https://api.deepseek.com/v1";
21
+ };
22
+ readonly fireworks: {
23
+ readonly provider: "fireworks";
24
+ readonly baseURL: "https://api.fireworks.ai/inference/v1";
25
+ };
26
+ readonly groq: {
27
+ readonly provider: "groq";
28
+ readonly baseURL: "https://api.groq.com/openai/v1";
29
+ };
30
+ readonly openrouter: {
31
+ readonly provider: "openrouter";
32
+ readonly baseURL: "https://openrouter.ai/api/v1";
33
+ };
34
+ readonly togetherai: {
35
+ readonly provider: "togetherai";
36
+ readonly baseURL: "https://api.together.xyz/v1";
37
+ };
38
+ readonly xai: {
39
+ readonly provider: "xai";
40
+ readonly baseURL: "https://api.x.ai/v1";
41
+ };
42
+ };
43
+ export declare const byProvider: Record<string, OpenAICompatibleProfile>;