@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,232 @@
1
+ import type { Config, Redacted } from "effect";
2
+ import { type AtLeastOne, type ProviderAuthOption } from "../route/auth-options";
3
+ import type { RouteDefaultsInput } from "../route/client";
4
+ import { type ModelID } from "../schema";
5
+ export declare const aiGatewayID: string & import("effect/Brand").Brand<"LLM.ProviderID">;
6
+ export declare const workersAIID: string & import("effect/Brand").Brand<"LLM.ProviderID">;
7
+ export declare const aiGatewayAuthEnvVars: readonly ["CLOUDFLARE_API_TOKEN", "CF_AIG_TOKEN"];
8
+ export declare const workersAIAuthEnvVars: readonly ["CLOUDFLARE_API_KEY", "CLOUDFLARE_WORKERS_AI_TOKEN"];
9
+ type CloudflareSecret = string | Redacted.Redacted | Config.Config<string | Redacted.Redacted>;
10
+ type GatewayURL = AtLeastOne<{
11
+ readonly accountId: string;
12
+ readonly baseURL: string;
13
+ }> & {
14
+ readonly gatewayId?: string;
15
+ };
16
+ export type AIGatewayOptions = GatewayURL & RouteDefaultsInput & ProviderAuthOption<"optional"> & {
17
+ /** Cloudflare AI Gateway authentication token. Sent as `cf-aig-authorization`. */
18
+ readonly gatewayApiKey?: CloudflareSecret;
19
+ };
20
+ type WorkersAIURL = AtLeastOne<{
21
+ readonly accountId: string;
22
+ readonly baseURL: string;
23
+ }>;
24
+ export type WorkersAIOptions = WorkersAIURL & RouteDefaultsInput & ProviderAuthOption<"optional">;
25
+ export declare const aiGatewayBaseURL: (input: GatewayURL) => string;
26
+ export declare const workersAIBaseURL: (input: WorkersAIURL) => string;
27
+ export declare const aiGatewayRoute: import("../route").Route<{
28
+ readonly model: string;
29
+ readonly messages: readonly ({
30
+ readonly role: "system";
31
+ readonly content: string;
32
+ } | {
33
+ readonly role: "user";
34
+ readonly content: string | readonly ({
35
+ readonly type: "text";
36
+ readonly text: string;
37
+ } | {
38
+ readonly type: "image_url";
39
+ readonly image_url: {
40
+ readonly url: string;
41
+ };
42
+ })[];
43
+ } | {
44
+ readonly role: "assistant";
45
+ readonly content: string | null;
46
+ readonly tool_calls?: readonly {
47
+ readonly id: string;
48
+ readonly type: "function";
49
+ readonly function: {
50
+ readonly name: string;
51
+ readonly arguments: string;
52
+ };
53
+ }[] | undefined;
54
+ readonly reasoning_content?: string | undefined;
55
+ } | {
56
+ readonly role: "tool";
57
+ readonly tool_call_id: string;
58
+ readonly content: string;
59
+ })[];
60
+ readonly stream: true;
61
+ readonly tools?: readonly {
62
+ readonly type: "function";
63
+ readonly function: {
64
+ readonly name: string;
65
+ readonly description: string;
66
+ readonly parameters: {
67
+ readonly [x: string]: unknown;
68
+ };
69
+ };
70
+ }[] | undefined;
71
+ readonly tool_choice?: "required" | "none" | "auto" | {
72
+ readonly type: "function";
73
+ readonly function: {
74
+ readonly name: string;
75
+ };
76
+ } | undefined;
77
+ readonly stream_options?: {
78
+ readonly include_usage: boolean;
79
+ } | undefined;
80
+ readonly store?: boolean | undefined;
81
+ readonly reasoning_effort?: string | undefined;
82
+ readonly max_tokens?: number | undefined;
83
+ readonly temperature?: number | undefined;
84
+ readonly top_p?: number | undefined;
85
+ readonly frequency_penalty?: number | undefined;
86
+ readonly presence_penalty?: number | undefined;
87
+ readonly seed?: number | undefined;
88
+ readonly stop?: readonly string[] | undefined;
89
+ }, import("../route/transport/http").HttpPrepared<string>>;
90
+ export declare const workersAIRoute: import("../route").Route<{
91
+ readonly model: string;
92
+ readonly messages: readonly ({
93
+ readonly role: "system";
94
+ readonly content: string;
95
+ } | {
96
+ readonly role: "user";
97
+ readonly content: string | readonly ({
98
+ readonly type: "text";
99
+ readonly text: string;
100
+ } | {
101
+ readonly type: "image_url";
102
+ readonly image_url: {
103
+ readonly url: string;
104
+ };
105
+ })[];
106
+ } | {
107
+ readonly role: "assistant";
108
+ readonly content: string | null;
109
+ readonly tool_calls?: readonly {
110
+ readonly id: string;
111
+ readonly type: "function";
112
+ readonly function: {
113
+ readonly name: string;
114
+ readonly arguments: string;
115
+ };
116
+ }[] | undefined;
117
+ readonly reasoning_content?: string | undefined;
118
+ } | {
119
+ readonly role: "tool";
120
+ readonly tool_call_id: string;
121
+ readonly content: string;
122
+ })[];
123
+ readonly stream: true;
124
+ readonly tools?: readonly {
125
+ readonly type: "function";
126
+ readonly function: {
127
+ readonly name: string;
128
+ readonly description: string;
129
+ readonly parameters: {
130
+ readonly [x: string]: unknown;
131
+ };
132
+ };
133
+ }[] | undefined;
134
+ readonly tool_choice?: "required" | "none" | "auto" | {
135
+ readonly type: "function";
136
+ readonly function: {
137
+ readonly name: string;
138
+ };
139
+ } | undefined;
140
+ readonly stream_options?: {
141
+ readonly include_usage: boolean;
142
+ } | undefined;
143
+ readonly store?: boolean | undefined;
144
+ readonly reasoning_effort?: string | undefined;
145
+ readonly max_tokens?: number | undefined;
146
+ readonly temperature?: number | undefined;
147
+ readonly top_p?: number | undefined;
148
+ readonly frequency_penalty?: number | undefined;
149
+ readonly presence_penalty?: number | undefined;
150
+ readonly seed?: number | undefined;
151
+ readonly stop?: readonly string[] | undefined;
152
+ }, import("../route/transport/http").HttpPrepared<string>>;
153
+ export declare const routes: import("../route").Route<{
154
+ readonly model: string;
155
+ readonly messages: readonly ({
156
+ readonly role: "system";
157
+ readonly content: string;
158
+ } | {
159
+ readonly role: "user";
160
+ readonly content: string | readonly ({
161
+ readonly type: "text";
162
+ readonly text: string;
163
+ } | {
164
+ readonly type: "image_url";
165
+ readonly image_url: {
166
+ readonly url: string;
167
+ };
168
+ })[];
169
+ } | {
170
+ readonly role: "assistant";
171
+ readonly content: string | null;
172
+ readonly tool_calls?: readonly {
173
+ readonly id: string;
174
+ readonly type: "function";
175
+ readonly function: {
176
+ readonly name: string;
177
+ readonly arguments: string;
178
+ };
179
+ }[] | undefined;
180
+ readonly reasoning_content?: string | undefined;
181
+ } | {
182
+ readonly role: "tool";
183
+ readonly tool_call_id: string;
184
+ readonly content: string;
185
+ })[];
186
+ readonly stream: true;
187
+ readonly tools?: readonly {
188
+ readonly type: "function";
189
+ readonly function: {
190
+ readonly name: string;
191
+ readonly description: string;
192
+ readonly parameters: {
193
+ readonly [x: string]: unknown;
194
+ };
195
+ };
196
+ }[] | undefined;
197
+ readonly tool_choice?: "required" | "none" | "auto" | {
198
+ readonly type: "function";
199
+ readonly function: {
200
+ readonly name: string;
201
+ };
202
+ } | undefined;
203
+ readonly stream_options?: {
204
+ readonly include_usage: boolean;
205
+ } | undefined;
206
+ readonly store?: boolean | undefined;
207
+ readonly reasoning_effort?: string | undefined;
208
+ readonly max_tokens?: number | undefined;
209
+ readonly temperature?: number | undefined;
210
+ readonly top_p?: number | undefined;
211
+ readonly frequency_penalty?: number | undefined;
212
+ readonly presence_penalty?: number | undefined;
213
+ readonly seed?: number | undefined;
214
+ readonly stop?: readonly string[] | undefined;
215
+ }, import("../route/transport/http").HttpPrepared<string>>[];
216
+ export declare const CloudflareAIGateway: {
217
+ id: string & import("effect/Brand").Brand<"LLM.ProviderID">;
218
+ configure: (options: AIGatewayOptions) => {
219
+ id: string & import("effect/Brand").Brand<"LLM.ProviderID">;
220
+ model: (modelID: string | ModelID) => import("..").Model;
221
+ configure: /*elided*/ any;
222
+ };
223
+ };
224
+ export declare const CloudflareWorkersAI: {
225
+ id: string & import("effect/Brand").Brand<"LLM.ProviderID">;
226
+ configure: (options: WorkersAIOptions) => {
227
+ id: string & import("effect/Brand").Brand<"LLM.ProviderID">;
228
+ model: (modelID: string | ModelID) => import("..").Model;
229
+ configure: /*elided*/ any;
230
+ };
231
+ };
232
+ export {};
@@ -0,0 +1,87 @@
1
+ import * as OpenAICompatibleChat from "../protocols/openai-compatible-chat";
2
+ import { Auth } from "../route/auth";
3
+ import { AuthOptions } from "../route/auth-options";
4
+ import { ProviderID } from "../schema";
5
+ export const aiGatewayID = ProviderID.make("cloudflare-ai-gateway");
6
+ export const workersAIID = ProviderID.make("cloudflare-workers-ai");
7
+ export const aiGatewayAuthEnvVars = ["CLOUDFLARE_API_TOKEN", "CF_AIG_TOKEN"];
8
+ export const workersAIAuthEnvVars = ["CLOUDFLARE_API_KEY", "CLOUDFLARE_WORKERS_AI_TOKEN"];
9
+ export const aiGatewayBaseURL = (input) => {
10
+ if (input.baseURL)
11
+ return input.baseURL;
12
+ if (!input.accountId)
13
+ throw new Error("CloudflareAIGateway.configure requires accountId unless baseURL is supplied");
14
+ return `https://gateway.ai.cloudflare.com/v1/${encodeURIComponent(input.accountId)}/${encodeURIComponent(input.gatewayId?.trim() || "default")}/compat`;
15
+ };
16
+ const aiGatewayAuth = (input) => {
17
+ if ("auth" in input && input.auth)
18
+ return input.auth;
19
+ const gateway = Auth.optional(input.gatewayApiKey, "gatewayApiKey")
20
+ .orElse(Auth.config("CLOUDFLARE_API_TOKEN"))
21
+ .orElse(Auth.config("CF_AIG_TOKEN"))
22
+ .pipe(Auth.bearerHeader("cf-aig-authorization"));
23
+ if (!("apiKey" in input) || input.apiKey === undefined)
24
+ return gateway;
25
+ if (input.gatewayApiKey === undefined)
26
+ return Auth.bearer(input.apiKey);
27
+ return Auth.bearerHeader("cf-aig-authorization", input.gatewayApiKey).andThen(Auth.bearer(input.apiKey));
28
+ };
29
+ export const workersAIBaseURL = (input) => {
30
+ if (input.baseURL)
31
+ return input.baseURL;
32
+ if (!input.accountId)
33
+ throw new Error("CloudflareWorkersAI.configure requires accountId unless baseURL is supplied");
34
+ return `https://api.cloudflare.com/client/v4/accounts/${encodeURIComponent(input.accountId)}/ai/v1`;
35
+ };
36
+ const workersAIAuth = (input) => {
37
+ return AuthOptions.bearer(input, workersAIAuthEnvVars);
38
+ };
39
+ export const aiGatewayRoute = OpenAICompatibleChat.route.with({
40
+ id: "cloudflare-ai-gateway",
41
+ provider: aiGatewayID,
42
+ });
43
+ export const workersAIRoute = OpenAICompatibleChat.route.with({
44
+ id: "cloudflare-workers-ai",
45
+ provider: workersAIID,
46
+ });
47
+ export const routes = [aiGatewayRoute, workersAIRoute];
48
+ const aiGatewayDefaults = (options) => {
49
+ const { accountId: _accountId, gatewayId: _gatewayId, apiKey: _apiKey, gatewayApiKey: _gatewayApiKey, baseURL: _baseURL, auth: _auth, ...rest } = options;
50
+ return rest;
51
+ };
52
+ const workersAIDefaults = (options) => {
53
+ const { accountId: _accountId, apiKey: _apiKey, auth: _auth, baseURL: _baseURL, ...rest } = options;
54
+ return rest;
55
+ };
56
+ const configureAIGateway = (options) => {
57
+ const route = aiGatewayRoute.with({
58
+ ...aiGatewayDefaults(options),
59
+ endpoint: { baseURL: aiGatewayBaseURL(options) },
60
+ auth: aiGatewayAuth(options),
61
+ });
62
+ return {
63
+ id: aiGatewayID,
64
+ model: (modelID) => route.model({ id: modelID }),
65
+ configure: configureAIGateway,
66
+ };
67
+ };
68
+ const configureWorkersAI = (options) => {
69
+ const route = workersAIRoute.with({
70
+ ...workersAIDefaults(options),
71
+ endpoint: { baseURL: workersAIBaseURL(options) },
72
+ auth: workersAIAuth(options),
73
+ });
74
+ return {
75
+ id: workersAIID,
76
+ model: (modelID) => route.model({ id: modelID }),
77
+ configure: configureWorkersAI,
78
+ };
79
+ };
80
+ export const CloudflareAIGateway = {
81
+ id: aiGatewayID,
82
+ configure: configureAIGateway,
83
+ };
84
+ export const CloudflareWorkersAI = {
85
+ id: workersAIID,
86
+ configure: configureWorkersAI,
87
+ };
@@ -0,0 +1,167 @@
1
+ import { type ProviderAuthOption } from "../route/auth-options";
2
+ import type { RouteDefaultsInput } from "../route/client";
3
+ import { type ModelID } from "../schema";
4
+ import { type OpenAIProviderOptionsInput } from "./openai-options";
5
+ export declare const id: string & import("effect/Brand").Brand<"LLM.ProviderID">;
6
+ export type ModelOptions = Omit<RouteDefaultsInput, "providerOptions"> & ProviderAuthOption<"optional"> & {
7
+ readonly baseURL: string;
8
+ readonly endpoint?: "chat" | "responses";
9
+ readonly providerOptions?: OpenAIProviderOptionsInput;
10
+ };
11
+ export declare const shouldUseResponsesApi: (modelID: string | ModelID, endpoint?: ModelOptions["endpoint"]) => boolean;
12
+ export declare const routes: (import("../route").Route<{
13
+ readonly model: string;
14
+ readonly messages: readonly ({
15
+ readonly role: "system";
16
+ readonly content: string;
17
+ } | {
18
+ readonly role: "user";
19
+ readonly content: string | readonly ({
20
+ readonly type: "text";
21
+ readonly text: string;
22
+ } | {
23
+ readonly type: "image_url";
24
+ readonly image_url: {
25
+ readonly url: string;
26
+ };
27
+ })[];
28
+ } | {
29
+ readonly role: "assistant";
30
+ readonly content: string | null;
31
+ readonly tool_calls?: readonly {
32
+ readonly id: string;
33
+ readonly type: "function";
34
+ readonly function: {
35
+ readonly name: string;
36
+ readonly arguments: string;
37
+ };
38
+ }[] | undefined;
39
+ readonly reasoning_content?: string | undefined;
40
+ } | {
41
+ readonly role: "tool";
42
+ readonly tool_call_id: string;
43
+ readonly content: string;
44
+ })[];
45
+ readonly stream: true;
46
+ readonly tools?: readonly {
47
+ readonly type: "function";
48
+ readonly function: {
49
+ readonly name: string;
50
+ readonly description: string;
51
+ readonly parameters: {
52
+ readonly [x: string]: unknown;
53
+ };
54
+ };
55
+ }[] | undefined;
56
+ readonly tool_choice?: "required" | "none" | "auto" | {
57
+ readonly type: "function";
58
+ readonly function: {
59
+ readonly name: string;
60
+ };
61
+ } | undefined;
62
+ readonly stream_options?: {
63
+ readonly include_usage: boolean;
64
+ } | undefined;
65
+ readonly store?: boolean | undefined;
66
+ readonly reasoning_effort?: string | undefined;
67
+ readonly max_tokens?: number | undefined;
68
+ readonly temperature?: number | undefined;
69
+ readonly top_p?: number | undefined;
70
+ readonly frequency_penalty?: number | undefined;
71
+ readonly presence_penalty?: number | undefined;
72
+ readonly seed?: number | undefined;
73
+ readonly stop?: readonly string[] | undefined;
74
+ }, import("../route/transport/http").HttpPrepared<string>> | import("../route").Route<{
75
+ readonly stream: true;
76
+ readonly model: string;
77
+ readonly input: readonly ({
78
+ readonly role: "system";
79
+ readonly content: string;
80
+ } | {
81
+ readonly role: "user";
82
+ readonly content: readonly ({
83
+ readonly type: "input_text";
84
+ readonly text: string;
85
+ } | {
86
+ readonly type: "input_image";
87
+ readonly image_url: string;
88
+ })[];
89
+ } | {
90
+ readonly role: "assistant";
91
+ readonly content: readonly {
92
+ readonly type: "output_text";
93
+ readonly text: string;
94
+ }[];
95
+ } | {
96
+ readonly type: "reasoning";
97
+ readonly summary: readonly {
98
+ readonly type: "summary_text";
99
+ readonly text: string;
100
+ }[];
101
+ readonly id?: string | undefined;
102
+ readonly encrypted_content?: string | null | undefined;
103
+ } | {
104
+ readonly type: "item_reference";
105
+ readonly id: string;
106
+ } | {
107
+ readonly type: "function_call";
108
+ readonly call_id: string;
109
+ readonly name: string;
110
+ readonly arguments: string;
111
+ } | {
112
+ readonly type: "function_call_output";
113
+ readonly call_id: string;
114
+ readonly output: string | readonly ({
115
+ readonly type: "input_text";
116
+ readonly text: string;
117
+ } | {
118
+ readonly type: "input_image";
119
+ readonly image_url: string;
120
+ })[];
121
+ })[];
122
+ readonly instructions?: string | undefined;
123
+ readonly tools?: readonly {
124
+ readonly type: "function";
125
+ readonly name: string;
126
+ readonly description: string;
127
+ readonly parameters: {
128
+ readonly [x: string]: unknown;
129
+ };
130
+ readonly strict?: boolean | undefined;
131
+ }[] | undefined;
132
+ readonly tool_choice?: "required" | "none" | "auto" | {
133
+ readonly type: "function";
134
+ readonly name: string;
135
+ } | undefined;
136
+ readonly store?: boolean | undefined;
137
+ readonly service_tier?: "auto" | "default" | "flex" | "priority" | undefined;
138
+ readonly prompt_cache_key?: string | undefined;
139
+ readonly include?: readonly ("file_search_call.results" | "web_search_call.results" | "web_search_call.action.sources" | "message.input_image.image_url" | "computer_call_output.output.image_url" | "code_interpreter_call.outputs" | "reasoning.encrypted_content" | "message.output_text.logprobs")[] | undefined;
140
+ readonly reasoning?: {
141
+ readonly effort?: string | undefined;
142
+ readonly summary?: "auto" | undefined;
143
+ } | undefined;
144
+ readonly text?: {
145
+ readonly verbosity?: "low" | "medium" | "high" | undefined;
146
+ } | undefined;
147
+ readonly max_output_tokens?: number | undefined;
148
+ readonly temperature?: number | undefined;
149
+ readonly top_p?: number | undefined;
150
+ }, import("../route/transport/http").HttpPrepared<string>>)[];
151
+ export declare const configure: (options: ModelOptions) => {
152
+ id: string & import("effect/Brand").Brand<"LLM.ProviderID">;
153
+ model: (modelID: string | ModelID) => import("..").Model;
154
+ responses: (modelID: string | ModelID) => import("..").Model;
155
+ chat: (modelID: string | ModelID) => import("..").Model;
156
+ configure: (options: ModelOptions) => /*elided*/ any;
157
+ };
158
+ export declare const provider: {
159
+ id: string & import("effect/Brand").Brand<"LLM.ProviderID">;
160
+ configure: (options: ModelOptions) => {
161
+ id: string & import("effect/Brand").Brand<"LLM.ProviderID">;
162
+ model: (modelID: string | ModelID) => import("..").Model;
163
+ responses: (modelID: string | ModelID) => import("..").Model;
164
+ chat: (modelID: string | ModelID) => import("..").Model;
165
+ configure: /*elided*/ any;
166
+ };
167
+ };
@@ -0,0 +1,47 @@
1
+ import { AuthOptions } from "../route/auth-options";
2
+ import { ProviderID } from "../schema";
3
+ import * as OpenAIChat from "../protocols/openai-chat";
4
+ import * as OpenAIResponses from "../protocols/openai-responses";
5
+ import { withOpenAIOptions } from "./openai-options";
6
+ export const id = ProviderID.make("github-copilot");
7
+ export const shouldUseResponsesApi = (modelID, endpoint) => {
8
+ if (endpoint)
9
+ return endpoint === "responses";
10
+ const model = String(modelID);
11
+ const match = /^gpt-(\d+)/.exec(model);
12
+ if (!match)
13
+ return false;
14
+ return Number(match[1]) >= 5 && !model.startsWith("gpt-5-mini");
15
+ };
16
+ export const routes = [OpenAIResponses.route, OpenAIChat.route];
17
+ const chatRoute = OpenAIChat.route.with({ provider: id });
18
+ const responsesRoute = OpenAIResponses.route.with({ provider: id });
19
+ const defaults = (options) => {
20
+ const { apiKey: _, auth: _auth, baseURL: _baseURL, endpoint: _endpoint, ...rest } = options;
21
+ return rest;
22
+ };
23
+ const configuredResponsesRoute = (options) => responsesRoute.with({
24
+ endpoint: { baseURL: options.baseURL },
25
+ auth: AuthOptions.bearer(options, []),
26
+ });
27
+ const configuredChatRoute = (options) => chatRoute.with({
28
+ endpoint: { baseURL: options.baseURL },
29
+ auth: AuthOptions.bearer(options, []),
30
+ });
31
+ export const configure = (options) => {
32
+ const responsesRoute = configuredResponsesRoute(options);
33
+ const chatRoute = configuredChatRoute(options);
34
+ const responses = (modelID) => responsesRoute.with(withOpenAIOptions(modelID, defaults(options))).model({ id: modelID });
35
+ const chat = (modelID) => chatRoute.with(withOpenAIOptions(modelID, defaults(options))).model({ id: modelID });
36
+ return {
37
+ id,
38
+ model: (modelID) => shouldUseResponsesApi(modelID, options.endpoint) ? responses(modelID) : chat(modelID),
39
+ responses,
40
+ chat,
41
+ configure,
42
+ };
43
+ };
44
+ export const provider = {
45
+ id,
46
+ configure,
47
+ };
@@ -0,0 +1,2 @@
1
+ export { model } from "../google-vertex-anthropic";
2
+ export type { Settings } from "../google-vertex-anthropic";
@@ -0,0 +1 @@
1
+ export { model } from "../google-vertex-anthropic";