@opencode/ai 0.0.0-beta-19507 → 0.0.0-dev-19276

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 (114) hide show
  1. package/README.md +0 -200
  2. package/dist/protocols/anthropic-messages.d.ts +1 -24
  3. package/dist/protocols/anthropic-messages.js +12 -58
  4. package/dist/protocols/meta-messages.d.ts +0 -6
  5. package/dist/protocols/open-responses-channel.d.ts +0 -2
  6. package/dist/protocols/open-responses-channel.js +2 -2
  7. package/dist/protocols/open-responses-continuation.d.ts +3 -7
  8. package/dist/protocols/open-responses-continuation.js +7 -16
  9. package/dist/protocols/open-responses.d.ts +9 -141
  10. package/dist/protocols/open-responses.js +7 -29
  11. package/dist/provider-package.d.ts +0 -4
  12. package/dist/providers/amazon-bedrock-mantle.d.ts +62 -4
  13. package/dist/providers/amazon-bedrock-mantle.js +20 -23
  14. package/dist/providers/amazon-bedrock.js +3 -3
  15. package/dist/providers/anthropic-compatible.d.ts +2 -7
  16. package/dist/providers/anthropic-compatible.js +12 -18
  17. package/dist/providers/anthropic.d.ts +2 -7
  18. package/dist/providers/anthropic.js +9 -12
  19. package/dist/providers/azure.d.ts +2 -1
  20. package/dist/providers/azure.js +14 -14
  21. package/dist/providers/baseten.d.ts +3 -2
  22. package/dist/providers/baseten.js +6 -6
  23. package/dist/providers/cerebras.d.ts +3 -2
  24. package/dist/providers/cerebras.js +6 -6
  25. package/dist/providers/cloudflare-ai-gateway.d.ts +2 -1
  26. package/dist/providers/cloudflare-ai-gateway.js +10 -16
  27. package/dist/providers/cloudflare-workers-ai.d.ts +2 -1
  28. package/dist/providers/cloudflare-workers-ai.js +9 -15
  29. package/dist/providers/deepinfra.d.ts +3 -2
  30. package/dist/providers/deepinfra.js +6 -6
  31. package/dist/providers/deepseek.d.ts +3 -2
  32. package/dist/providers/deepseek.js +6 -6
  33. package/dist/providers/fireworks.d.ts +3 -2
  34. package/dist/providers/fireworks.js +6 -6
  35. package/dist/providers/google-vertex-chat.d.ts +3 -2
  36. package/dist/providers/google-vertex-chat.js +12 -12
  37. package/dist/providers/google-vertex-messages.d.ts +3 -8
  38. package/dist/providers/google-vertex-messages.js +12 -12
  39. package/dist/providers/google-vertex-responses.d.ts +3 -2
  40. package/dist/providers/google-vertex-responses.js +12 -12
  41. package/dist/providers/google-vertex-shared.js +3 -14
  42. package/dist/providers/google-vertex.d.ts +2 -1
  43. package/dist/providers/google-vertex.js +12 -18
  44. package/dist/providers/google.d.ts +3 -2
  45. package/dist/providers/google.js +6 -6
  46. package/dist/providers/groq.d.ts +3 -2
  47. package/dist/providers/groq.js +6 -6
  48. package/dist/providers/index.d.ts +0 -3
  49. package/dist/providers/index.js +0 -3
  50. package/dist/providers/meta.d.ts +3 -8
  51. package/dist/providers/meta.js +6 -6
  52. package/dist/providers/minimax/chat.js +6 -6
  53. package/dist/providers/minimax/responses.js +6 -6
  54. package/dist/providers/minimax.d.ts +3 -8
  55. package/dist/providers/minimax.js +6 -6
  56. package/dist/providers/mistral.d.ts +3 -2
  57. package/dist/providers/mistral.js +6 -6
  58. package/dist/providers/openai-compatible-responses.d.ts +3 -2
  59. package/dist/providers/openai-compatible-responses.js +7 -7
  60. package/dist/providers/openai-compatible.d.ts +3 -2
  61. package/dist/providers/openai-compatible.js +7 -7
  62. package/dist/providers/openai.d.ts +3 -2
  63. package/dist/providers/openai.js +9 -9
  64. package/dist/providers/openrouter.d.ts +3 -2
  65. package/dist/providers/openrouter.js +6 -6
  66. package/dist/providers/togetherai.d.ts +3 -2
  67. package/dist/providers/togetherai.js +6 -6
  68. package/dist/providers/xai.d.ts +3 -2
  69. package/dist/providers/xai.js +6 -10
  70. package/dist/providers/zai.d.ts +8 -133
  71. package/dist/providers/zai.js +0 -32
  72. package/dist/route/client.js +2 -5
  73. package/dist/route/transport/websocket.js +2 -6
  74. package/dist/schema/errors.d.ts +0 -12
  75. package/dist/schema/errors.js +0 -11
  76. package/dist/schema/options.d.ts +0 -2
  77. package/dist/schema/options.js +0 -2
  78. package/package.json +3 -3
  79. package/dist/protocols/alibaba-chat.d.ts +0 -225
  80. package/dist/protocols/alibaba-chat.js +0 -75
  81. package/dist/protocols/alibaba-messages.d.ts +0 -350
  82. package/dist/protocols/alibaba-messages.js +0 -40
  83. package/dist/protocols/alibaba-responses.d.ts +0 -255
  84. package/dist/protocols/alibaba-responses.js +0 -80
  85. package/dist/protocols/zai-chat.d.ts +0 -202
  86. package/dist/protocols/zai-chat.js +0 -49
  87. package/dist/protocols/zai-messages.d.ts +0 -344
  88. package/dist/protocols/zai-messages.js +0 -27
  89. package/dist/providers/alibaba/chat.d.ts +0 -1
  90. package/dist/providers/alibaba/chat.js +0 -1
  91. package/dist/providers/alibaba/messages.d.ts +0 -3
  92. package/dist/providers/alibaba/messages.js +0 -1
  93. package/dist/providers/alibaba/responses.d.ts +0 -3
  94. package/dist/providers/alibaba/responses.js +0 -1
  95. package/dist/providers/alibaba.d.ts +0 -711
  96. package/dist/providers/alibaba.js +0 -94
  97. package/dist/providers/moonshot/chat.d.ts +0 -1
  98. package/dist/providers/moonshot/chat.js +0 -1
  99. package/dist/providers/moonshot/messages.d.ts +0 -4
  100. package/dist/providers/moonshot/messages.js +0 -8
  101. package/dist/providers/moonshot/responses.d.ts +0 -4
  102. package/dist/providers/moonshot/responses.js +0 -8
  103. package/dist/providers/moonshot.d.ts +0 -596
  104. package/dist/providers/moonshot.js +0 -90
  105. package/dist/providers/zai/chat.d.ts +0 -1
  106. package/dist/providers/zai/chat.js +0 -1
  107. package/dist/providers/zai-coding-plan/chat.d.ts +0 -1
  108. package/dist/providers/zai-coding-plan/chat.js +0 -1
  109. package/dist/providers/zai-coding-plan/messages.d.ts +0 -4
  110. package/dist/providers/zai-coding-plan/messages.js +0 -8
  111. package/dist/providers/zai-coding-plan/responses.d.ts +0 -4
  112. package/dist/providers/zai-coding-plan/responses.js +0 -8
  113. package/dist/providers/zai-coding-plan.d.ts +0 -577
  114. package/dist/providers/zai-coding-plan.js +0 -63
@@ -1,7 +1,7 @@
1
1
  import { Headers } from "effect/unstable/http";
2
2
  import { Auth } from "../route/auth.js";
3
3
  import {} from "../route/auth-options.js";
4
- import { ProviderConfigurationError, ProviderID } from "../schema/index.js";
4
+ import { ProviderID } from "../schema/index.js";
5
5
  import * as OpenAIChat from "../protocols/openai-chat.js";
6
6
  import * as OpenAIResponses from "../protocols/openai-responses.js";
7
7
  import { ProviderShared } from "../protocols/shared.js";
@@ -94,21 +94,21 @@ export const provider = {
94
94
  id,
95
95
  configure,
96
96
  };
97
- const config = ({ apiKey, apiVersion, baseURL, body, headers, queryParams, resourceName, useDeploymentBasedUrls, ...providerOptions }) => {
97
+ const config = (settings) => {
98
98
  const common = {
99
- apiKey,
100
- apiVersion,
101
- headers: headers === undefined ? undefined : { ...headers },
102
- http: body === undefined ? undefined : { body: { ...body } },
103
- providerOptions,
104
- queryParams: queryParams === undefined ? undefined : { ...queryParams },
105
- useDeploymentBasedUrls,
99
+ apiKey: settings.apiKey,
100
+ apiVersion: settings.apiVersion,
101
+ headers: settings.headers === undefined ? undefined : { ...settings.headers },
102
+ http: settings.body === undefined ? undefined : { body: { ...settings.body } },
103
+ providerOptions: settings.providerOptions,
104
+ queryParams: settings.queryParams === undefined ? undefined : { ...settings.queryParams },
105
+ useDeploymentBasedUrls: settings.useDeploymentBasedUrls,
106
106
  };
107
- if (baseURL !== undefined)
108
- return { ...common, baseURL };
109
- if (resourceName !== undefined)
110
- return { ...common, resourceName };
111
- throw new ProviderConfigurationError({ provider: id, message: "Azure requires resourceName or baseURL" });
107
+ if (settings.baseURL !== undefined)
108
+ return { ...common, baseURL: settings.baseURL };
109
+ if (settings.resourceName !== undefined)
110
+ return { ...common, resourceName: settings.resourceName };
111
+ throw new Error("Azure requires resourceName or baseURL");
112
112
  };
113
113
  export const responsesModel = (modelID, settings) => configure(config(settings)).responses(modelID);
114
114
  export const chatModel = (modelID, settings) => configure(config(settings)).chat(modelID);
@@ -8,10 +8,11 @@ export type LanguageModelOptions = Omit<RouteDefaultsInput, "providerOptions"> &
8
8
  readonly baseURL?: string;
9
9
  readonly providerOptions?: OpenAIProviderOptionsInput;
10
10
  };
11
- export type Settings = ProviderPackage.Settings & OpenAIProviderOptionsInput & {
11
+ export interface Settings extends ProviderPackage.Settings {
12
12
  readonly apiKey?: string;
13
13
  readonly baseURL?: string;
14
- };
14
+ readonly providerOptions?: OpenAIProviderOptionsInput;
15
+ }
15
16
  export declare const route: Route<{
16
17
  readonly model: string;
17
18
  readonly messages: readonly ({
@@ -28,11 +28,11 @@ export const configure = (input = {}) => {
28
28
  };
29
29
  };
30
30
  export const provider = configure();
31
- export const model = (modelID, { apiKey, baseURL, body, headers, ...providerOptions }) => configure({
32
- apiKey,
33
- baseURL,
34
- headers: headers === undefined ? undefined : { ...headers },
35
- http: body === undefined ? undefined : { body: { ...body } },
36
- providerOptions,
31
+ export const model = (modelID, settings) => configure({
32
+ apiKey: settings.apiKey,
33
+ baseURL: settings.baseURL,
34
+ headers: settings.headers === undefined ? undefined : { ...settings.headers },
35
+ http: settings.body === undefined ? undefined : { body: { ...settings.body } },
36
+ providerOptions: settings.providerOptions,
37
37
  }).model(modelID);
38
38
  export * as Baseten from "./baseten.js";
@@ -8,10 +8,11 @@ export type LanguageModelOptions = Omit<RouteDefaultsInput, "providerOptions"> &
8
8
  readonly baseURL?: string;
9
9
  readonly providerOptions?: OpenAIProviderOptionsInput;
10
10
  };
11
- export type Settings = ProviderPackage.Settings & OpenAIProviderOptionsInput & {
11
+ export interface Settings extends ProviderPackage.Settings {
12
12
  readonly apiKey?: string;
13
13
  readonly baseURL?: string;
14
- };
14
+ readonly providerOptions?: OpenAIProviderOptionsInput;
15
+ }
15
16
  export declare const route: Route<{
16
17
  readonly model: string;
17
18
  readonly messages: readonly ({
@@ -31,10 +31,10 @@ export const configure = (input = {}) => {
31
31
  };
32
32
  };
33
33
  export const provider = configure();
34
- export const model = (modelID, { apiKey, baseURL, body, headers, ...providerOptions }) => configure({
35
- apiKey,
36
- baseURL,
37
- headers: headers === undefined ? undefined : { ...headers },
38
- http: body === undefined ? undefined : { body: { ...body } },
39
- providerOptions,
34
+ export const model = (modelID, settings) => configure({
35
+ apiKey: settings.apiKey,
36
+ baseURL: settings.baseURL,
37
+ headers: settings.headers === undefined ? undefined : { ...settings.headers },
38
+ http: settings.body === undefined ? undefined : { body: { ...settings.body } },
39
+ providerOptions: settings.providerOptions,
40
40
  }).model(modelID);
@@ -17,9 +17,10 @@ export type LanguageModelOptions = GatewayURL & Omit<RouteDefaultsInput, "provid
17
17
  readonly gatewayApiKey?: string | Redacted.Redacted | Config.Config<string | Redacted.Redacted>;
18
18
  readonly providerOptions?: OpenAIProviderOptionsInput;
19
19
  };
20
- export type Settings = ProviderPackage.Settings & OpenAIProviderOptionsInput & GatewayURL & {
20
+ export type Settings = ProviderPackage.Settings & GatewayURL & {
21
21
  readonly apiKey?: string;
22
22
  readonly gatewayApiKey?: string;
23
+ readonly providerOptions?: OpenAIProviderOptionsInput;
23
24
  };
24
25
  export declare const baseURL: (input: GatewayURL) => string;
25
26
  export declare const route: Route<{
@@ -2,17 +2,14 @@ import { OpenAIChat } from "../protocols/openai-chat.js";
2
2
  import { Auth } from "../route/auth.js";
3
3
  import { Route } from "../route/client.js";
4
4
  import { Endpoint } from "../route/endpoint.js";
5
- import { ProviderConfigurationError, ProviderID } from "../schema/index.js";
5
+ import { ProviderID } from "../schema/index.js";
6
6
  export const id = ProviderID.make("cloudflare-ai-gateway");
7
7
  export const authEnvVars = ["CLOUDFLARE_API_TOKEN", "CF_AIG_TOKEN"];
8
8
  export const baseURL = (input) => {
9
9
  if (input.baseURL)
10
10
  return input.baseURL;
11
11
  if (!input.accountId)
12
- throw new ProviderConfigurationError({
13
- provider: id,
14
- message: "CloudflareAIGateway.configure requires accountId unless baseURL is supplied",
15
- });
12
+ throw new Error("CloudflareAIGateway.configure requires accountId unless baseURL is supplied");
16
13
  return `https://gateway.ai.cloudflare.com/v1/${encodeURIComponent(input.accountId)}/${encodeURIComponent(input.gatewayId?.trim() || "default")}/compat`;
17
14
  };
18
15
  const auth = (input) => {
@@ -51,15 +48,12 @@ export const configure = (input) => {
51
48
  };
52
49
  };
53
50
  export const provider = { id, configure };
54
- export const model = (modelID, settings) => {
55
- const { accountId: _, apiKey, baseURL: _url, body, gatewayApiKey, gatewayId: _id, headers, ...providerOptions } = settings;
56
- return configure({
57
- apiKey,
58
- gatewayApiKey,
59
- baseURL: baseURL(settings),
60
- headers: headers === undefined ? undefined : { ...headers },
61
- http: body === undefined ? undefined : { body: { ...body } },
62
- providerOptions,
63
- }).model(modelID);
64
- };
51
+ export const model = (modelID, settings) => configure({
52
+ apiKey: settings.apiKey,
53
+ gatewayApiKey: settings.gatewayApiKey,
54
+ baseURL: baseURL(settings),
55
+ headers: settings.headers === undefined ? undefined : { ...settings.headers },
56
+ http: settings.body === undefined ? undefined : { body: { ...settings.body } },
57
+ providerOptions: settings.providerOptions,
58
+ }).model(modelID);
65
59
  export * as CloudflareAIGateway from "./cloudflare-ai-gateway.js";
@@ -12,8 +12,9 @@ type WorkersAIURL = AtLeastOne<{
12
12
  export type LanguageModelOptions = WorkersAIURL & Omit<RouteDefaultsInput, "providerOptions"> & ProviderAuthOption<"optional"> & {
13
13
  readonly providerOptions?: OpenAIProviderOptionsInput;
14
14
  };
15
- export type Settings = ProviderPackage.Settings & OpenAIProviderOptionsInput & WorkersAIURL & {
15
+ export type Settings = ProviderPackage.Settings & WorkersAIURL & {
16
16
  readonly apiKey?: string;
17
+ readonly providerOptions?: OpenAIProviderOptionsInput;
17
18
  };
18
19
  export declare const baseURL: (input: WorkersAIURL) => string;
19
20
  export declare const route: Route<{
@@ -2,17 +2,14 @@ import { OpenAIChat } from "../protocols/openai-chat.js";
2
2
  import { AuthOptions } from "../route/auth-options.js";
3
3
  import { Route } from "../route/client.js";
4
4
  import { Endpoint } from "../route/endpoint.js";
5
- import { ProviderConfigurationError, ProviderID } from "../schema/index.js";
5
+ import { ProviderID } from "../schema/index.js";
6
6
  export const id = ProviderID.make("cloudflare-workers-ai");
7
7
  export const authEnvVars = ["CLOUDFLARE_API_KEY", "CLOUDFLARE_WORKERS_AI_TOKEN"];
8
8
  export const baseURL = (input) => {
9
9
  if (input.baseURL)
10
10
  return input.baseURL;
11
11
  if (!input.accountId)
12
- throw new ProviderConfigurationError({
13
- provider: id,
14
- message: "CloudflareWorkersAI.configure requires accountId unless baseURL is supplied",
15
- });
12
+ throw new Error("CloudflareWorkersAI.configure requires accountId unless baseURL is supplied");
16
13
  return `https://api.cloudflare.com/client/v4/accounts/${encodeURIComponent(input.accountId)}/ai/v1`;
17
14
  };
18
15
  export const route = Route.make({
@@ -38,14 +35,11 @@ export const configure = (input) => {
38
35
  };
39
36
  };
40
37
  export const provider = { id, configure };
41
- export const model = (modelID, settings) => {
42
- const { accountId: _, apiKey, baseURL: _url, body, headers, ...providerOptions } = settings;
43
- return configure({
44
- apiKey,
45
- baseURL: baseURL(settings),
46
- headers: headers === undefined ? undefined : { ...headers },
47
- http: body === undefined ? undefined : { body: { ...body } },
48
- providerOptions,
49
- }).model(modelID);
50
- };
38
+ export const model = (modelID, settings) => configure({
39
+ apiKey: settings.apiKey,
40
+ baseURL: baseURL(settings),
41
+ headers: settings.headers === undefined ? undefined : { ...settings.headers },
42
+ http: settings.body === undefined ? undefined : { body: { ...settings.body } },
43
+ providerOptions: settings.providerOptions,
44
+ }).model(modelID);
51
45
  export * as CloudflareWorkersAI from "./cloudflare-workers-ai.js";
@@ -8,10 +8,11 @@ export type LanguageModelOptions = Omit<RouteDefaultsInput, "providerOptions"> &
8
8
  readonly baseURL?: string;
9
9
  readonly providerOptions?: OpenAIProviderOptionsInput;
10
10
  };
11
- export type Settings = ProviderPackage.Settings & OpenAIProviderOptionsInput & {
11
+ export interface Settings extends ProviderPackage.Settings {
12
12
  readonly apiKey?: string;
13
13
  readonly baseURL?: string;
14
- };
14
+ readonly providerOptions?: OpenAIProviderOptionsInput;
15
+ }
15
16
  export declare const route: Route<{
16
17
  readonly model: string;
17
18
  readonly messages: readonly ({
@@ -34,10 +34,10 @@ export const configure = (input = {}) => {
34
34
  };
35
35
  };
36
36
  export const provider = configure();
37
- export const model = (modelID, { apiKey, baseURL, body, headers, ...providerOptions }) => configure({
38
- apiKey,
39
- baseURL,
40
- headers: headers === undefined ? undefined : { ...headers },
41
- http: body === undefined ? undefined : { body: { ...body } },
42
- providerOptions,
37
+ export const model = (modelID, settings) => configure({
38
+ apiKey: settings.apiKey,
39
+ baseURL: settings.baseURL,
40
+ headers: settings.headers === undefined ? undefined : { ...settings.headers },
41
+ http: settings.body === undefined ? undefined : { body: { ...settings.body } },
42
+ providerOptions: settings.providerOptions,
43
43
  }).model(modelID);
@@ -8,10 +8,11 @@ export type LanguageModelOptions = Omit<RouteDefaultsInput, "providerOptions"> &
8
8
  readonly baseURL?: string;
9
9
  readonly providerOptions?: OpenAIProviderOptionsInput;
10
10
  };
11
- export type Settings = ProviderPackage.Settings & OpenAIProviderOptionsInput & {
11
+ export interface Settings extends ProviderPackage.Settings {
12
12
  readonly apiKey?: string;
13
13
  readonly baseURL?: string;
14
- };
14
+ readonly providerOptions?: OpenAIProviderOptionsInput;
15
+ }
15
16
  export declare const route: Route<{
16
17
  readonly model: string;
17
18
  readonly messages: readonly ({
@@ -31,11 +31,11 @@ export const configure = (input = {}) => {
31
31
  };
32
32
  };
33
33
  export const provider = configure();
34
- export const model = (modelID, { apiKey, baseURL, body, headers, ...providerOptions }) => configure({
35
- apiKey,
36
- baseURL,
37
- headers: headers === undefined ? undefined : { ...headers },
38
- http: body === undefined ? undefined : { body: { ...body } },
39
- providerOptions,
34
+ export const model = (modelID, settings) => configure({
35
+ apiKey: settings.apiKey,
36
+ baseURL: settings.baseURL,
37
+ headers: settings.headers === undefined ? undefined : { ...settings.headers },
38
+ http: settings.body === undefined ? undefined : { body: { ...settings.body } },
39
+ providerOptions: settings.providerOptions,
40
40
  }).model(modelID);
41
41
  export * as DeepSeek from "./deepseek.js";
@@ -8,10 +8,11 @@ export type LanguageModelOptions = Omit<RouteDefaultsInput, "providerOptions"> &
8
8
  readonly baseURL?: string;
9
9
  readonly providerOptions?: OpenAIProviderOptionsInput;
10
10
  };
11
- export type Settings = ProviderPackage.Settings & OpenAIProviderOptionsInput & {
11
+ export interface Settings extends ProviderPackage.Settings {
12
12
  readonly apiKey?: string;
13
13
  readonly baseURL?: string;
14
- };
14
+ readonly providerOptions?: OpenAIProviderOptionsInput;
15
+ }
15
16
  export declare const route: Route<{
16
17
  readonly model: string;
17
18
  readonly messages: readonly ({
@@ -28,11 +28,11 @@ export const configure = (input = {}) => {
28
28
  };
29
29
  };
30
30
  export const provider = configure();
31
- export const model = (modelID, { apiKey, baseURL, body, headers, ...providerOptions }) => configure({
32
- apiKey,
33
- baseURL,
34
- headers: headers === undefined ? undefined : { ...headers },
35
- http: body === undefined ? undefined : { body: { ...body } },
36
- providerOptions,
31
+ export const model = (modelID, settings) => configure({
32
+ apiKey: settings.apiKey,
33
+ baseURL: settings.baseURL,
34
+ headers: settings.headers === undefined ? undefined : { ...settings.headers },
35
+ http: settings.body === undefined ? undefined : { body: { ...settings.body } },
36
+ providerOptions: settings.providerOptions,
37
37
  }).model(modelID);
38
38
  export * as Fireworks from "./fireworks.js";
@@ -10,13 +10,14 @@ export type Config = RouteDefaultsInput & GoogleVertexShared.OAuthOptions & {
10
10
  readonly project?: string;
11
11
  readonly providerOptions?: OpenAIProviderOptionsInput;
12
12
  };
13
- export type Settings = ProviderPackage.Settings & OpenAIProviderOptionsInput & {
13
+ export interface Settings extends ProviderPackage.Settings {
14
14
  readonly accessToken?: string;
15
15
  readonly apiKey?: never;
16
16
  readonly baseURL?: string;
17
17
  readonly location?: string;
18
18
  readonly project?: string;
19
- };
19
+ readonly providerOptions?: OpenAIProviderOptionsInput;
20
+ }
20
21
  export declare const routes: Route<{
21
22
  readonly model: string;
22
23
  readonly messages: readonly ({
@@ -1,7 +1,7 @@
1
1
  import { OpenAIChat } from "../protocols/openai-chat.js";
2
2
  import { Route } from "../route/client.js";
3
3
  import { Endpoint } from "../route/endpoint.js";
4
- import { ProviderConfigurationError, ProviderID } from "../schema/index.js";
4
+ import { ProviderID } from "../schema/index.js";
5
5
  import { GoogleVertexShared } from "./google-vertex-shared.js";
6
6
  export const id = ProviderID.make("google-vertex");
7
7
  const route = Route.make({
@@ -15,7 +15,7 @@ const route = Route.make({
15
15
  export const routes = [route];
16
16
  const configuredRoute = (input) => {
17
17
  if ("apiKey" in input && input.apiKey !== undefined)
18
- throw new ProviderConfigurationError({ provider: id, message: "Google Vertex Chat does not support API keys" });
18
+ throw new Error("Google Vertex Chat does not support API keys");
19
19
  const { accessToken: _accessToken, auth: _auth, baseURL, location: inputLocation, project: inputProject, ...rest } = input;
20
20
  const location = GoogleVertexShared.location(inputLocation, "global");
21
21
  const project = GoogleVertexShared.project(inputProject);
@@ -40,16 +40,16 @@ export const provider = {
40
40
  id,
41
41
  configure,
42
42
  };
43
- export const model = (modelID, { accessToken, apiKey, baseURL, body, headers, location, project, ...providerOptions }) => {
44
- if (apiKey !== undefined)
45
- throw new ProviderConfigurationError({ provider: id, message: "Google Vertex Chat does not support API keys" });
43
+ export const model = (modelID, settings) => {
44
+ if (settings.apiKey !== undefined)
45
+ throw new Error("Google Vertex Chat does not support API keys");
46
46
  return configure({
47
- accessToken,
48
- baseURL,
49
- headers: headers === undefined ? undefined : { ...headers },
50
- http: body === undefined ? undefined : { body: { ...body } },
51
- location,
52
- project,
53
- providerOptions,
47
+ accessToken: settings.accessToken,
48
+ baseURL: settings.baseURL,
49
+ headers: settings.headers === undefined ? undefined : { ...settings.headers },
50
+ http: settings.body === undefined ? undefined : { body: { ...settings.body } },
51
+ location: settings.location,
52
+ project: settings.project,
53
+ providerOptions: settings.providerOptions,
54
54
  }).model(modelID);
55
55
  };
@@ -13,13 +13,14 @@ export type Config = RouteDefaultsInput & GoogleVertexShared.OAuthOptions & {
13
13
  readonly project?: string;
14
14
  readonly providerOptions?: AnthropicMessages.ProviderOptionsInput;
15
15
  };
16
- export type Settings = ProviderPackage.Settings & AnthropicMessages.ProviderOptionsInput & {
16
+ export interface Settings extends ProviderPackage.Settings {
17
17
  readonly accessToken?: string;
18
18
  readonly apiKey?: never;
19
19
  readonly baseURL?: string;
20
20
  readonly location?: string;
21
21
  readonly project?: string;
22
- };
22
+ readonly providerOptions?: AnthropicMessages.ProviderOptionsInput;
23
+ }
23
24
  export declare const routes: Route<{
24
25
  anthropic_version: "vertex-2023-10-16";
25
26
  metadata?: {
@@ -234,15 +235,9 @@ export declare const routes: Route<{
234
235
  readonly type: "enabled";
235
236
  readonly budget_tokens: number;
236
237
  readonly display?: "summarized" | "omitted" | undefined;
237
- readonly block_binding?: {
238
- readonly prefix_mismatch_behavior?: string | undefined;
239
- } | undefined;
240
238
  } | {
241
239
  readonly type: "adaptive";
242
240
  readonly display?: "summarized" | "omitted" | undefined;
243
- readonly block_binding?: {
244
- readonly prefix_mismatch_behavior?: string | undefined;
245
- } | undefined;
246
241
  } | {
247
242
  readonly type: "disabled";
248
243
  } | undefined;
@@ -4,7 +4,7 @@ import { Auth } from "../route/auth.js";
4
4
  import { Route } from "../route/client.js";
5
5
  import { Endpoint } from "../route/endpoint.js";
6
6
  import { Protocol } from "../route/protocol.js";
7
- import { ProviderConfigurationError, ProviderID } from "../schema/index.js";
7
+ import { ProviderID } from "../schema/index.js";
8
8
  import { GoogleVertexShared } from "./google-vertex-shared.js";
9
9
  const VERSION = "vertex-2023-10-16";
10
10
  const HEADER_VERSION = "2023-06-01";
@@ -35,7 +35,7 @@ const route = Route.make({
35
35
  export const routes = [route];
36
36
  const configuredRoute = (input) => {
37
37
  if ("apiKey" in input && input.apiKey !== undefined)
38
- throw new ProviderConfigurationError({ provider: id, message: "Google Vertex Messages does not support API keys" });
38
+ throw new Error("Google Vertex Messages does not support API keys");
39
39
  const { accessToken: _accessToken, auth: _auth, baseURL, location: inputLocation, project: inputProject, ...rest } = input;
40
40
  const location = GoogleVertexShared.location(inputLocation, "global");
41
41
  const project = GoogleVertexShared.project(inputProject);
@@ -60,16 +60,16 @@ export const provider = {
60
60
  id,
61
61
  configure,
62
62
  };
63
- export const model = (modelID, { accessToken, apiKey, baseURL, body, headers, location, project, ...providerOptions }) => {
64
- if (apiKey !== undefined)
65
- throw new ProviderConfigurationError({ provider: id, message: "Google Vertex Messages does not support API keys" });
63
+ export const model = (modelID, settings) => {
64
+ if (settings.apiKey !== undefined)
65
+ throw new Error("Google Vertex Messages does not support API keys");
66
66
  return configure({
67
- accessToken,
68
- baseURL,
69
- headers: headers === undefined ? undefined : { ...headers },
70
- http: body === undefined ? undefined : { body: { ...body } },
71
- location,
72
- project,
73
- providerOptions,
67
+ accessToken: settings.accessToken,
68
+ baseURL: settings.baseURL,
69
+ headers: settings.headers === undefined ? undefined : { ...settings.headers },
70
+ http: settings.body === undefined ? undefined : { body: { ...settings.body } },
71
+ location: settings.location,
72
+ project: settings.project,
73
+ providerOptions: settings.providerOptions,
74
74
  }).model(modelID);
75
75
  };
@@ -10,13 +10,14 @@ export type Config = RouteDefaultsInput & GoogleVertexShared.OAuthOptions & {
10
10
  readonly project?: string;
11
11
  readonly providerOptions?: OpenResponsesProviderOptionsInput;
12
12
  };
13
- export type Settings = ProviderPackage.Settings & OpenResponsesProviderOptionsInput & {
13
+ export interface Settings extends ProviderPackage.Settings {
14
14
  readonly accessToken?: string;
15
15
  readonly apiKey?: never;
16
16
  readonly baseURL?: string;
17
17
  readonly location?: string;
18
18
  readonly project?: string;
19
- };
19
+ readonly providerOptions?: OpenResponsesProviderOptionsInput;
20
+ }
20
21
  export declare const routes: Route<{
21
22
  readonly input: readonly ({
22
23
  readonly [x: string]: unknown;
@@ -1,7 +1,7 @@
1
1
  import { OpenResponses } from "../protocols/open-responses.js";
2
2
  import { Route } from "../route/client.js";
3
3
  import { Endpoint } from "../route/endpoint.js";
4
- import { ProviderConfigurationError, ProviderID } from "../schema/index.js";
4
+ import { ProviderID } from "../schema/index.js";
5
5
  import { GoogleVertexShared } from "./google-vertex-shared.js";
6
6
  export const id = ProviderID.make("google-vertex");
7
7
  const route = Route.make({
@@ -16,7 +16,7 @@ const route = Route.make({
16
16
  export const routes = [route];
17
17
  const configuredRoute = (input) => {
18
18
  if ("apiKey" in input && input.apiKey !== undefined)
19
- throw new ProviderConfigurationError({ provider: id, message: "Google Vertex Responses does not support API keys" });
19
+ throw new Error("Google Vertex Responses does not support API keys");
20
20
  const { accessToken: _accessToken, auth: _auth, baseURL, location: inputLocation, project: inputProject, ...rest } = input;
21
21
  const location = GoogleVertexShared.location(inputLocation, "global");
22
22
  const project = GoogleVertexShared.project(inputProject);
@@ -41,16 +41,16 @@ export const provider = {
41
41
  id,
42
42
  configure,
43
43
  };
44
- export const model = (modelID, { accessToken, apiKey, baseURL, body, headers, location, project, ...providerOptions }) => {
45
- if (apiKey !== undefined)
46
- throw new ProviderConfigurationError({ provider: id, message: "Google Vertex Responses does not support API keys" });
44
+ export const model = (modelID, settings) => {
45
+ if (settings.apiKey !== undefined)
46
+ throw new Error("Google Vertex Responses does not support API keys");
47
47
  return configure({
48
- accessToken,
49
- baseURL,
50
- headers: headers === undefined ? undefined : { ...headers },
51
- http: body === undefined ? undefined : { body: { ...body } },
52
- location,
53
- project,
54
- providerOptions,
48
+ accessToken: settings.accessToken,
49
+ baseURL: settings.baseURL,
50
+ headers: settings.headers === undefined ? undefined : { ...settings.headers },
51
+ http: settings.body === undefined ? undefined : { body: { ...settings.body } },
52
+ location: settings.location,
53
+ project: settings.project,
54
+ providerOptions: settings.providerOptions,
55
55
  }).model(modelID);
56
56
  };
@@ -1,8 +1,6 @@
1
1
  import { Effect, Redacted } from "effect";
2
2
  import { Auth, MissingCredentialError } from "../route/auth.js";
3
- import { ProviderConfigurationError, ProviderID } from "../schema/index.js";
4
3
  const SCOPE = "https://www.googleapis.com/auth/cloud-platform";
5
- const id = ProviderID.make("google-vertex");
6
4
  export const project = (value) => value ??
7
5
  process.env.GOOGLE_VERTEX_PROJECT ??
8
6
  process.env.GOOGLE_CLOUD_PROJECT ??
@@ -24,17 +22,11 @@ export const host = (location) => {
24
22
  export const requireProject = (value) => {
25
23
  if (value)
26
24
  return value;
27
- throw new ProviderConfigurationError({
28
- provider: id,
29
- message: "Google Vertex requires a project when baseURL is not configured",
30
- });
25
+ throw new Error("Google Vertex requires a project when baseURL is not configured");
31
26
  };
32
27
  export const apiKey = (input) => {
33
28
  if (input.apiKey !== undefined && (input.accessToken !== undefined || input.auth !== undefined))
34
- throw new ProviderConfigurationError({
35
- provider: id,
36
- message: "Google Vertex apiKey cannot be combined with accessToken or auth",
37
- });
29
+ throw new Error("Google Vertex apiKey cannot be combined with accessToken or auth");
38
30
  if (input.accessToken !== undefined || input.auth !== undefined)
39
31
  return undefined;
40
32
  return input.apiKey ?? process.env.GOOGLE_VERTEX_API_KEY;
@@ -59,10 +51,7 @@ const adc = (project) => {
59
51
  };
60
52
  export const oauth = (input, project) => {
61
53
  if (input.accessToken !== undefined && input.auth !== undefined)
62
- throw new ProviderConfigurationError({
63
- provider: id,
64
- message: "Google Vertex accessToken cannot be combined with auth",
65
- });
54
+ throw new Error("Google Vertex accessToken cannot be combined with auth");
66
55
  if (input.auth)
67
56
  return input.auth;
68
57
  if (input.accessToken !== undefined)
@@ -14,7 +14,7 @@ export type Config = RouteDefaultsInput & GoogleVertexShared.ApiKeyOptions & {
14
14
  readonly project?: string;
15
15
  readonly providerOptions?: GeminiProviderOptionsInput;
16
16
  };
17
- export type Settings = ProviderPackage.Settings & GeminiProviderOptionsInput & ({
17
+ export type Settings = ProviderPackage.Settings & ({
18
18
  readonly accessToken?: string;
19
19
  readonly apiKey?: never;
20
20
  } | {
@@ -24,6 +24,7 @@ export type Settings = ProviderPackage.Settings & GeminiProviderOptionsInput & (
24
24
  readonly baseURL?: string;
25
25
  readonly location?: string;
26
26
  readonly project?: string;
27
+ readonly providerOptions?: GeminiProviderOptionsInput;
27
28
  };
28
29
  export declare const routes: Route<{
29
30
  readonly contents: readonly {