@opencode/ai 2.0.26 → 2.0.28

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 (108) hide show
  1. package/README.md +8 -2
  2. package/dist/cache-policy.js +20 -11
  3. package/dist/experimental/system-one.js +1 -1
  4. package/dist/media.d.ts +1 -1
  5. package/dist/media.js +7 -6
  6. package/dist/protocols/alibaba-chat.d.ts +2 -2
  7. package/dist/protocols/alibaba-messages.d.ts +1 -1
  8. package/dist/protocols/anthropic-messages.js +1 -1
  9. package/dist/protocols/bedrock-converse.js +4 -3
  10. package/dist/protocols/bedrock-event-stream.js +4 -3
  11. package/dist/protocols/gemini.d.ts +73 -9
  12. package/dist/protocols/gemini.js +111 -17
  13. package/dist/protocols/meta-responses.js +3 -2
  14. package/dist/protocols/mistral-chat.d.ts +1 -1
  15. package/dist/protocols/mistral-chat.js +4 -2
  16. package/dist/protocols/open-responses-channel.d.ts +1 -1
  17. package/dist/protocols/open-responses-channel.js +7 -2
  18. package/dist/protocols/openai-chat.js +6 -2
  19. package/dist/protocols/openai-responses.d.ts +5 -5
  20. package/dist/protocols/openai-responses.js +4 -3
  21. package/dist/protocols/shared.d.ts +6 -2
  22. package/dist/protocols/shared.js +29 -3
  23. package/dist/protocols/utils/bedrock-auth.js +1 -1
  24. package/dist/protocols/utils/bedrock-media.js +4 -3
  25. package/dist/protocols/utils/fal-queue.d.ts +1 -1
  26. package/dist/protocols/utils/media-input.js +4 -3
  27. package/dist/protocols/utils/responses-compaction.js +6 -1
  28. package/dist/protocols/utils/tool-schema.js +8 -2
  29. package/dist/providers/alibaba.d.ts +5 -5
  30. package/dist/providers/amazon-bedrock-mantle.js +2 -2
  31. package/dist/providers/anthropic-compatible.js +2 -2
  32. package/dist/providers/anthropic.js +2 -2
  33. package/dist/providers/azure.d.ts +2 -2
  34. package/dist/providers/azure.js +3 -3
  35. package/dist/providers/baseten.js +2 -2
  36. package/dist/providers/cerebras.js +2 -2
  37. package/dist/providers/cloudflare-ai-gateway.d.ts +2 -2
  38. package/dist/providers/cloudflare-ai-gateway.js +2 -2
  39. package/dist/providers/cloudflare-workers-ai.js +2 -2
  40. package/dist/providers/cohere/chat.js +1 -1
  41. package/dist/providers/cohere.js +1 -1
  42. package/dist/providers/deepinfra.js +2 -2
  43. package/dist/providers/deepseek.js +2 -2
  44. package/dist/providers/fireworks.js +2 -2
  45. package/dist/providers/google/interactions.js +2 -2
  46. package/dist/providers/google-vertex/interactions.d.ts +2 -0
  47. package/dist/providers/google-vertex/interactions.js +1 -0
  48. package/dist/providers/google-vertex/mistral.d.ts +2 -0
  49. package/dist/providers/google-vertex/mistral.js +1 -0
  50. package/dist/providers/google-vertex-chat.js +3 -3
  51. package/dist/providers/google-vertex-interactions.d.ts +112 -0
  52. package/dist/providers/google-vertex-interactions.js +64 -0
  53. package/dist/providers/google-vertex-messages.js +3 -3
  54. package/dist/providers/google-vertex-mistral.d.ts +124 -0
  55. package/dist/providers/google-vertex-mistral.js +69 -0
  56. package/dist/providers/google-vertex-responses.js +3 -3
  57. package/dist/providers/google-vertex-shared.d.ts +3 -1
  58. package/dist/providers/google-vertex-shared.js +29 -3
  59. package/dist/providers/google-vertex.d.ts +2 -1
  60. package/dist/providers/google-vertex.js +4 -5
  61. package/dist/providers/google.d.ts +2 -1
  62. package/dist/providers/google.js +2 -2
  63. package/dist/providers/groq.js +2 -2
  64. package/dist/providers/index.d.ts +3 -1
  65. package/dist/providers/index.js +3 -1
  66. package/dist/providers/meta.js +1 -1
  67. package/dist/providers/minimax/chat.js +1 -1
  68. package/dist/providers/minimax/responses.js +1 -1
  69. package/dist/providers/minimax.js +1 -1
  70. package/dist/providers/mistral.js +2 -2
  71. package/dist/providers/moonshot/messages.js +1 -1
  72. package/dist/providers/moonshot/responses.js +1 -1
  73. package/dist/providers/moonshot.js +1 -1
  74. package/dist/providers/openai-compatible-responses.js +2 -2
  75. package/dist/providers/openai-compatible.js +2 -2
  76. package/dist/providers/openai.d.ts +1 -1
  77. package/dist/providers/openai.js +2 -2
  78. package/dist/providers/{opencode-zen.d.ts → opencode.d.ts} +1 -1
  79. package/dist/providers/{opencode-zen.js → opencode.js} +2 -2
  80. package/dist/providers/openrouter.js +1 -1
  81. package/dist/providers/togetherai.js +2 -2
  82. package/dist/providers/venice.js +1 -1
  83. package/dist/providers/vercel-ai-gateway.js +2 -2
  84. package/dist/providers/xai.js +1 -1
  85. package/dist/providers/zai-coding-plan/messages.js +1 -1
  86. package/dist/providers/zai-coding-plan/responses.js +1 -1
  87. package/dist/providers/zai-coding-plan.js +1 -1
  88. package/dist/providers/zai.js +1 -1
  89. package/dist/route/auth.d.ts +1 -1
  90. package/dist/route/auth.js +2 -2
  91. package/dist/route/executor-service.d.ts +1 -1
  92. package/dist/route/executor.d.ts +1 -1
  93. package/dist/route/executor.js +1 -1
  94. package/dist/route/framing.js +1 -1
  95. package/dist/route/media-protocol.d.ts +1 -1
  96. package/dist/route/media-protocol.js +1 -1
  97. package/dist/route/media.js +1 -1
  98. package/dist/route/transport/http.d.ts +1 -1
  99. package/dist/route/transport/http.js +5 -4
  100. package/dist/route/transport/websocket-channel.d.ts +1 -1
  101. package/dist/route/transport/websocket.d.ts +4 -4
  102. package/dist/route/transport/websocket.js +4 -9
  103. package/dist/schema/messages.js +9 -8
  104. package/dist/schema/options.d.ts +15 -1
  105. package/dist/schema/options.js +25 -5
  106. package/dist/tool.d.ts +10 -0
  107. package/dist/tool.js +21 -2
  108. package/package.json +5 -5
@@ -0,0 +1,112 @@
1
+ import type { ProviderPackage } from "../provider-package.js";
2
+ import { GoogleInteractions } from "../protocols/google-interactions.js";
3
+ import { Route, type RouteDefaultsInput } from "../route/client.js";
4
+ import { type ModelID } from "../schema/index.js";
5
+ import { GoogleVertexShared } from "./google-vertex-shared.js";
6
+ export type GoogleInteractionsOptionsInput = GoogleInteractions.OptionsInput;
7
+ export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
8
+ export type Config = RouteDefaultsInput & GoogleVertexShared.ApiKeyOptions & {
9
+ readonly baseURL?: string;
10
+ readonly location?: string;
11
+ readonly project?: string;
12
+ readonly providerOptions?: GoogleInteractions.ProviderOptionsInput;
13
+ };
14
+ export type Settings = ProviderPackage.Settings & GoogleInteractions.ProviderOptionsInput & ({
15
+ readonly accessToken?: string;
16
+ readonly apiKey?: never;
17
+ } | {
18
+ readonly accessToken?: never;
19
+ readonly apiKey?: string;
20
+ }) & {
21
+ readonly baseURL?: string;
22
+ readonly location?: string;
23
+ readonly project?: string;
24
+ };
25
+ export declare const routes: Route<{
26
+ readonly input: readonly ({
27
+ readonly type: "user_input" | "model_output";
28
+ readonly content: readonly ({
29
+ readonly type: "text";
30
+ readonly text: string;
31
+ } | {
32
+ readonly type: "image" | "document" | "video" | "audio";
33
+ readonly mime_type: string;
34
+ readonly data?: string | undefined;
35
+ readonly uri?: string | undefined;
36
+ })[];
37
+ } | {
38
+ readonly type: "thought";
39
+ readonly summary?: readonly {
40
+ readonly type: "text";
41
+ readonly text: string;
42
+ }[] | undefined;
43
+ readonly signature?: string | undefined;
44
+ } | {
45
+ readonly id: string;
46
+ readonly type: "function_call";
47
+ readonly name: string;
48
+ readonly arguments: unknown;
49
+ readonly signature?: string | undefined;
50
+ } | {
51
+ readonly type: "function_result";
52
+ readonly name: string;
53
+ readonly result: unknown;
54
+ readonly call_id: string;
55
+ readonly is_error?: boolean | undefined;
56
+ })[];
57
+ readonly model: string;
58
+ readonly stream: true;
59
+ readonly store: boolean;
60
+ readonly generation_config: {
61
+ readonly temperature?: number | undefined;
62
+ readonly seed?: number | undefined;
63
+ readonly tool_choice?: "auto" | "none" | "any" | {
64
+ readonly allowed_tools: {
65
+ readonly mode: "any";
66
+ readonly tools: readonly string[];
67
+ };
68
+ } | undefined;
69
+ readonly top_p?: number | undefined;
70
+ readonly stop_sequences?: readonly string[] | undefined;
71
+ readonly max_output_tokens?: number | undefined;
72
+ readonly thinking_level?: import("../schema/options.js").OpenString<"minimal" | "low" | "medium" | "high"> | undefined;
73
+ readonly thinking_summaries?: string | undefined;
74
+ };
75
+ readonly tools?: readonly {
76
+ readonly type: "function";
77
+ readonly name: string;
78
+ readonly description: string;
79
+ readonly parameters: {
80
+ readonly [x: string]: unknown;
81
+ };
82
+ }[] | undefined;
83
+ readonly service_tier?: string | undefined;
84
+ readonly previous_interaction_id?: string | undefined;
85
+ readonly system_instruction?: string | undefined;
86
+ }, import("../route/transport/http.js").HttpPrepared<string>, import("../route/client.js").CompactionOperations | undefined>[];
87
+ export declare const configure: (input?: Config) => {
88
+ id: string & import("effect/Brand").Brand<"AI.ProviderID">;
89
+ model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<{
90
+ readonly serviceTier?: import("../schema/options.js").OpenString<"standard" | "flex" | "priority" | "deferred"> | undefined;
91
+ readonly thinkingLevel?: import("../schema/options.js").OpenString<"minimal" | "low" | "medium" | "high"> | undefined;
92
+ readonly previousInteractionId?: string | undefined;
93
+ readonly store?: boolean | undefined;
94
+ readonly thinkingSummaries?: import("../schema/options.js").OpenString<"auto" | "none"> | undefined;
95
+ }, import("../route/client.js").CompactionOperations | undefined>;
96
+ configure: (input?: Config) => /*elided*/ any;
97
+ };
98
+ export declare const provider: {
99
+ id: string & import("effect/Brand").Brand<"AI.ProviderID">;
100
+ configure: (input?: Config) => {
101
+ id: string & import("effect/Brand").Brand<"AI.ProviderID">;
102
+ model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<{
103
+ readonly serviceTier?: import("../schema/options.js").OpenString<"standard" | "flex" | "priority" | "deferred"> | undefined;
104
+ readonly thinkingLevel?: import("../schema/options.js").OpenString<"minimal" | "low" | "medium" | "high"> | undefined;
105
+ readonly previousInteractionId?: string | undefined;
106
+ readonly store?: boolean | undefined;
107
+ readonly thinkingSummaries?: import("../schema/options.js").OpenString<"auto" | "none"> | undefined;
108
+ }, import("../route/client.js").CompactionOperations | undefined>;
109
+ configure: /*elided*/ any;
110
+ };
111
+ };
112
+ export declare const model: ProviderPackage.Definition<Settings, GoogleInteractions.ProviderOptionsInput>["model"];
@@ -0,0 +1,64 @@
1
+ import { GoogleInteractions } from "../protocols/google-interactions.js";
2
+ import { Auth } from "../route/auth.js";
3
+ import { Route } from "../route/client.js";
4
+ import { Endpoint } from "../route/endpoint.js";
5
+ import { Framing } from "../route/framing.js";
6
+ import { ProviderConfigurationError, ProviderID } from "../schema/index.js";
7
+ import { GoogleVertexShared } from "./google-vertex-shared.js";
8
+ export const id = ProviderID.make("google-vertex");
9
+ const route = Route.make({
10
+ id: "google-vertex-interactions",
11
+ provider: id,
12
+ providerMetadataKey: "vertex",
13
+ protocol: GoogleInteractions.protocol,
14
+ endpoint: Endpoint.path("/interactions", { query: { alt: "sse" } }),
15
+ auth: Auth.none,
16
+ headers: ({ request }) => {
17
+ const serviceTier = request.providerOptions?.serviceTier;
18
+ return typeof serviceTier === "string" ? { "x-vertex-ai-llm-shared-request-type": serviceTier } : {};
19
+ },
20
+ framing: Framing.sse,
21
+ });
22
+ export const routes = [route];
23
+ const configuredRoute = (input) => {
24
+ const { accessToken: _accessToken, apiKey: _apiKey, auth: _auth, baseURL, location: inputLocation, project: inputProject, ...rest } = input;
25
+ const apiKey = GoogleVertexShared.apiKey(input);
26
+ const location = GoogleVertexShared.location(inputLocation);
27
+ const project = GoogleVertexShared.project(inputProject);
28
+ return route.with({
29
+ ...rest,
30
+ endpoint: {
31
+ baseURL: baseURL ??
32
+ `https://${GoogleVertexShared.host(location)}/v1beta1/${apiKey === undefined ? `projects/${GoogleVertexShared.requireProject(project)}/` : ""}locations/${location}`,
33
+ },
34
+ auth: apiKey === undefined ? GoogleVertexShared.oauth(input, project) : Auth.header("x-goog-api-key", apiKey),
35
+ });
36
+ };
37
+ export const configure = (input = {}) => {
38
+ const route = configuredRoute(input);
39
+ return {
40
+ id,
41
+ model: (modelID) => route.model({ id: modelID }),
42
+ configure,
43
+ };
44
+ };
45
+ export const provider = {
46
+ id,
47
+ configure,
48
+ };
49
+ export const model = (modelID, { accessToken, apiKey, baseURL, body, headers, location, project, ...providerOptions }) => {
50
+ if (apiKey !== undefined && accessToken !== undefined)
51
+ throw new ProviderConfigurationError({
52
+ provider: id,
53
+ message: "Google Vertex apiKey cannot be combined with accessToken or auth",
54
+ });
55
+ return configure({
56
+ ...(apiKey === undefined ? { accessToken } : { apiKey }),
57
+ baseURL,
58
+ headers,
59
+ http: body === undefined ? undefined : { body },
60
+ location,
61
+ project,
62
+ providerOptions,
63
+ }).model(modelID);
64
+ };
@@ -38,7 +38,7 @@ const configuredRoute = (input) => {
38
38
  if ("apiKey" in input && input.apiKey !== undefined)
39
39
  throw new ProviderConfigurationError({ provider: id, message: "Google Vertex Messages does not support API keys" });
40
40
  const { accessToken: _accessToken, auth: _auth, baseURL, location: inputLocation, project: inputProject, ...rest } = input;
41
- const location = GoogleVertexShared.location(inputLocation, "global");
41
+ const location = GoogleVertexShared.location(inputLocation);
42
42
  const project = GoogleVertexShared.project(inputProject);
43
43
  return route.with({
44
44
  ...rest,
@@ -67,8 +67,8 @@ export const model = (modelID, { accessToken, apiKey, baseURL, body, headers, lo
67
67
  return configure({
68
68
  accessToken,
69
69
  baseURL,
70
- headers: headers === undefined ? undefined : { ...headers },
71
- http: body === undefined ? undefined : { body: { ...body } },
70
+ headers,
71
+ http: body === undefined ? undefined : { body },
72
72
  location,
73
73
  project,
74
74
  providerOptions,
@@ -0,0 +1,124 @@
1
+ import type { ProviderPackage } from "../provider-package.js";
2
+ import { MistralChat } from "../protocols/mistral-chat.js";
3
+ import { Route, type RouteDefaultsInput } from "../route/client.js";
4
+ import { HttpTransport } from "../route/transport/index.js";
5
+ import { type ModelID } from "../schema/index.js";
6
+ import { GoogleVertexShared } from "./google-vertex-shared.js";
7
+ export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
8
+ export type Config = RouteDefaultsInput & GoogleVertexShared.OAuthOptions & {
9
+ readonly baseURL?: string;
10
+ readonly location?: string;
11
+ readonly project?: string;
12
+ readonly providerOptions?: MistralChat.ProviderOptionsInput;
13
+ };
14
+ export type Settings = ProviderPackage.Settings & MistralChat.ProviderOptionsInput & {
15
+ readonly accessToken?: string;
16
+ readonly apiKey?: never;
17
+ readonly baseURL?: string;
18
+ readonly location?: string;
19
+ readonly project?: string;
20
+ };
21
+ export declare const routes: Route<{
22
+ readonly max_tokens?: number | undefined;
23
+ readonly tools?: readonly {
24
+ readonly type: "function";
25
+ readonly function: {
26
+ readonly name: string;
27
+ readonly description: string;
28
+ readonly parameters: {
29
+ readonly [x: string]: unknown;
30
+ };
31
+ readonly strict: false;
32
+ };
33
+ }[] | undefined;
34
+ readonly model: string;
35
+ readonly stop?: readonly string[] | undefined;
36
+ readonly messages: readonly ({
37
+ readonly role: "system";
38
+ readonly content: string | readonly {
39
+ readonly type: "text";
40
+ readonly text: string;
41
+ }[];
42
+ } | {
43
+ readonly role: "user";
44
+ readonly content: string | readonly ({
45
+ readonly type: "text";
46
+ readonly text: string;
47
+ } | {
48
+ readonly type: "image_url";
49
+ readonly image_url: string;
50
+ } | {
51
+ readonly type: "document_url";
52
+ readonly document_url: string;
53
+ })[];
54
+ } | {
55
+ readonly content: string | readonly ({
56
+ readonly [x: string]: unknown;
57
+ readonly type: "thinking";
58
+ readonly thinking: readonly {
59
+ readonly [x: string]: unknown;
60
+ readonly type?: string | undefined;
61
+ readonly text?: string | undefined;
62
+ }[];
63
+ } | {
64
+ readonly type: "text";
65
+ readonly text: string;
66
+ })[];
67
+ readonly role: "assistant";
68
+ readonly tool_calls?: readonly {
69
+ readonly id: string;
70
+ readonly type: "function";
71
+ readonly function: {
72
+ readonly name: string;
73
+ readonly arguments: string;
74
+ };
75
+ }[] | undefined;
76
+ readonly prefix?: true | undefined;
77
+ } | {
78
+ readonly role: "tool";
79
+ readonly tool_call_id: string;
80
+ readonly name: string;
81
+ readonly content: string | readonly ({
82
+ readonly type: "text";
83
+ readonly text: string;
84
+ } | {
85
+ readonly type: "image_url";
86
+ readonly image_url: string;
87
+ } | {
88
+ readonly type: "document_url";
89
+ readonly document_url: string;
90
+ })[];
91
+ })[];
92
+ readonly temperature?: number | undefined;
93
+ readonly stream: true;
94
+ readonly tool_choice?: "auto" | "none" | "any" | {
95
+ readonly type: "function";
96
+ readonly function: {
97
+ readonly name: string;
98
+ };
99
+ } | undefined;
100
+ readonly top_p?: number | undefined;
101
+ readonly frequency_penalty?: number | undefined;
102
+ readonly presence_penalty?: number | undefined;
103
+ readonly random_seed?: number | undefined;
104
+ readonly safe_prompt?: boolean | undefined;
105
+ readonly document_image_limit?: number | undefined;
106
+ readonly document_page_limit?: number | undefined;
107
+ readonly parallel_tool_calls?: boolean | undefined;
108
+ readonly reasoning_effort?: string | undefined;
109
+ readonly prompt_mode?: "reasoning" | undefined;
110
+ }, HttpTransport.HttpPrepared<string>, import("../route/client.js").CompactionOperations | undefined>[];
111
+ export declare const configure: (input?: Config) => {
112
+ id: string & import("effect/Brand").Brand<"AI.ProviderID">;
113
+ model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<MistralChat.ProviderOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
114
+ configure: (input?: Config) => /*elided*/ any;
115
+ };
116
+ export declare const provider: {
117
+ id: string & import("effect/Brand").Brand<"AI.ProviderID">;
118
+ configure: (input?: Config) => {
119
+ id: string & import("effect/Brand").Brand<"AI.ProviderID">;
120
+ model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<MistralChat.ProviderOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
121
+ configure: /*elided*/ any;
122
+ };
123
+ };
124
+ export declare const model: ProviderPackage.Definition<Settings, MistralChat.ProviderOptionsInput>["model"];
@@ -0,0 +1,69 @@
1
+ import { Effect, Schema, Struct } from "effect";
2
+ import { MistralChat } from "../protocols/mistral-chat.js";
3
+ import { Auth } from "../route/auth.js";
4
+ import { Route } from "../route/client.js";
5
+ import { Endpoint } from "../route/endpoint.js";
6
+ import { Protocol } from "../route/protocol.js";
7
+ import { HttpTransport } from "../route/transport/index.js";
8
+ import { ProviderConfigurationError, ProviderID } from "../schema/index.js";
9
+ import { GoogleVertexShared } from "./google-vertex-shared.js";
10
+ export const id = ProviderID.make("google-vertex");
11
+ // Mistral on Vertex takes the Mistral chat body, model included, through the publisher's streamRawPredict method.
12
+ // Vertex validates the body strictly and rejects prompt_cache_key, which Mistral's own API accepts.
13
+ const route = Route.make({
14
+ id: "google-vertex-mistral",
15
+ provider: id,
16
+ providerMetadataKey: "vertex",
17
+ protocol: Protocol.make({
18
+ id: MistralChat.protocol.id,
19
+ body: {
20
+ schema: Schema.Struct(Struct.omit(MistralChat.MistralBody.fields, ["prompt_cache_key"])),
21
+ from: (request) => MistralChat.protocol.body.from(request).pipe(Effect.map((body) => Struct.omit(body, ["prompt_cache_key"]))),
22
+ },
23
+ stream: MistralChat.protocol.stream,
24
+ }),
25
+ endpoint: Endpoint.path(({ request }) => `/${request.model.id}:streamRawPredict`),
26
+ auth: Auth.none,
27
+ transport: HttpTransport.sseJson.with().with({ framing: MistralChat.framing }),
28
+ });
29
+ export const routes = [route];
30
+ const configuredRoute = (input) => {
31
+ if ("apiKey" in input && input.apiKey !== undefined)
32
+ throw new ProviderConfigurationError({ provider: id, message: "Google Vertex Mistral does not support API keys" });
33
+ const { accessToken: _accessToken, auth: _auth, baseURL, location: inputLocation, project: inputProject, ...rest } = input;
34
+ const location = GoogleVertexShared.location(inputLocation);
35
+ const project = GoogleVertexShared.project(inputProject);
36
+ return route.with({
37
+ ...rest,
38
+ endpoint: {
39
+ baseURL: baseURL ??
40
+ `https://${GoogleVertexShared.host(location)}/v1/projects/${GoogleVertexShared.requireProject(project)}/locations/${location}/publishers/mistralai/models`,
41
+ },
42
+ auth: GoogleVertexShared.oauth(input, project),
43
+ });
44
+ };
45
+ export const configure = (input = {}) => {
46
+ const route = configuredRoute(input);
47
+ return {
48
+ id,
49
+ model: (modelID) => route.model({ id: modelID }),
50
+ configure,
51
+ };
52
+ };
53
+ export const provider = {
54
+ id,
55
+ configure,
56
+ };
57
+ export const model = (modelID, { accessToken, apiKey, baseURL, body, headers, location, project, ...providerOptions }) => {
58
+ if (apiKey !== undefined)
59
+ throw new ProviderConfigurationError({ provider: id, message: "Google Vertex Mistral does not support API keys" });
60
+ return configure({
61
+ accessToken,
62
+ baseURL,
63
+ headers,
64
+ http: body === undefined ? undefined : { body },
65
+ location,
66
+ project,
67
+ providerOptions,
68
+ }).model(modelID);
69
+ };
@@ -18,7 +18,7 @@ const configuredRoute = (input) => {
18
18
  if ("apiKey" in input && input.apiKey !== undefined)
19
19
  throw new ProviderConfigurationError({ provider: id, message: "Google Vertex Responses does not support API keys" });
20
20
  const { accessToken: _accessToken, auth: _auth, baseURL, location: inputLocation, project: inputProject, ...rest } = input;
21
- const location = GoogleVertexShared.location(inputLocation, "global");
21
+ const location = GoogleVertexShared.location(inputLocation);
22
22
  const project = GoogleVertexShared.project(inputProject);
23
23
  return route.with({
24
24
  ...rest,
@@ -47,8 +47,8 @@ export const model = (modelID, { accessToken, apiKey, baseURL, body, headers, lo
47
47
  return configure({
48
48
  accessToken,
49
49
  baseURL,
50
- headers: headers === undefined ? undefined : { ...headers },
51
- http: body === undefined ? undefined : { body: { ...body } },
50
+ headers,
51
+ http: body === undefined ? undefined : { body },
52
52
  location,
53
53
  project,
54
54
  providerOptions,
@@ -1,4 +1,6 @@
1
+ import type { AnyAuthClient } from "google-auth-library";
1
2
  import { Auth } from "../route/auth.js";
3
+ export declare const loadADCClient: (project?: string) => Promise<AnyAuthClient>;
2
4
  export type OAuthOptions = {
3
5
  readonly accessToken?: string;
4
6
  readonly auth?: never;
@@ -14,7 +16,7 @@ export type ApiKeyOptions = (OAuthOptions & {
14
16
  readonly auth?: never;
15
17
  };
16
18
  export declare const project: (value?: string) => string | undefined;
17
- export declare const location: (value: string | undefined, fallback: string) => string;
19
+ export declare const location: (value: string | undefined) => string;
18
20
  export declare const host: (location: string) => string;
19
21
  export declare const requireProject: (value: string | undefined) => string;
20
22
  export declare const apiKey: (input: ApiKeyOptions & {
@@ -3,16 +3,42 @@ import { Auth, MissingCredentialError } from "../route/auth.js";
3
3
  import { ProviderConfigurationError, ProviderID } from "../schema/index.js";
4
4
  const SCOPE = "https://www.googleapis.com/auth/cloud-platform";
5
5
  const id = ProviderID.make("google-vertex");
6
+ export const loadADCClient = async (project) => {
7
+ const { GoogleAuth } = await import("google-auth-library");
8
+ // google-auth-library 10.5.0 ignores CLOUDSDK_CONFIG during ADC file discovery.
9
+ // Fix this in shipped AI code: a repository-level Bun dependency patch would not
10
+ // reach npm or Bun consumers of the published @opencode/ai package.
11
+ // Override only the well-known-file lookup: keyFilename bypasses ADC's quota-project
12
+ // preparation. Keep explicit credentials and metadata fallback in Google's ADC chain.
13
+ class CloudSDKAuth extends GoogleAuth {
14
+ async _tryGetApplicationCredentialsFromWellKnownFile(options) {
15
+ const config = process.env.CLOUDSDK_CONFIG;
16
+ if (!config)
17
+ return super._tryGetApplicationCredentialsFromWellKnownFile(options);
18
+ // Keep local filesystem helpers lazy for explicitly authenticated Worker callers;
19
+ // this ADC-file lookup itself requires a Node-compatible filesystem.
20
+ const { existsSync } = await import("node:fs");
21
+ const { homedir } = await import("node:os");
22
+ const { join } = await import("node:path");
23
+ const directory = config === "~" ? homedir() : config.startsWith("~/") ? join(homedir(), config.slice(2)) : config;
24
+ const file = join(directory, "application_default_credentials.json");
25
+ if (!existsSync(file))
26
+ return null;
27
+ return this._getApplicationCredentialsFromFilePath(file, options);
28
+ }
29
+ }
30
+ return new CloudSDKAuth({ projectId: project, scopes: [SCOPE] }).getClient();
31
+ };
6
32
  export const project = (value) => value ??
7
33
  process.env.GOOGLE_VERTEX_PROJECT ??
8
34
  process.env.GOOGLE_CLOUD_PROJECT ??
9
35
  process.env.GCP_PROJECT ??
10
36
  process.env.GCLOUD_PROJECT;
11
- export const location = (value, fallback) => value ??
37
+ export const location = (value) => value ??
12
38
  process.env.GOOGLE_VERTEX_LOCATION ??
13
39
  process.env.GOOGLE_CLOUD_LOCATION ??
14
40
  process.env.VERTEX_LOCATION ??
15
- fallback;
41
+ "global";
16
42
  export const host = (location) => {
17
43
  if (location === "global")
18
44
  return "aiplatform.googleapis.com";
@@ -50,7 +76,7 @@ const adc = (project) => {
50
76
  const loadClient = () => {
51
77
  if (client)
52
78
  return client;
53
- client = import("google-auth-library").then(({ GoogleAuth }) => new GoogleAuth({ projectId: project, scopes: [SCOPE] }).getClient());
79
+ client = loadADCClient(project);
54
80
  return client;
55
81
  };
56
82
  return Auth.effect(Effect.tryPromise({
@@ -109,7 +109,8 @@ export declare const routes: Route<{
109
109
  } | undefined;
110
110
  readonly maxOutputTokens?: number | undefined;
111
111
  } | undefined;
112
- }, import("../route/transport/http.js").HttpPrepared<string>, import("../route/client.js").CompactionOperations | undefined>[];
112
+ readonly continuationToken?: string | undefined;
113
+ }, Gemini.Prepared, import("../route/client.js").CompactionOperations | undefined>[];
113
114
  export declare const configure: (input?: Config) => {
114
115
  id: string & import("effect/Brand").Brand<"AI.ProviderID">;
115
116
  model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<GeminiOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
@@ -4,7 +4,6 @@ import { ProviderShared } from "../protocols/shared.js";
4
4
  import { Auth } from "../route/auth.js";
5
5
  import { Route } from "../route/client.js";
6
6
  import { Endpoint } from "../route/endpoint.js";
7
- import { Framing } from "../route/framing.js";
8
7
  import { ProviderConfigurationError, ProviderID } from "../schema/index.js";
9
8
  import { GoogleVertexShared } from "./google-vertex-shared.js";
10
9
  export const id = ProviderID.make("google-vertex");
@@ -37,7 +36,7 @@ const route = Route.make({
37
36
  const serviceTier = request.providerOptions?.serviceTier;
38
37
  return typeof serviceTier === "string" ? { "x-vertex-ai-llm-shared-request-type": serviceTier } : {};
39
38
  },
40
- framing: Framing.sse,
39
+ transport: Gemini.transport,
41
40
  });
42
41
  export const routes = [route];
43
42
  const configuredRoute = (input, modelID) => {
@@ -49,7 +48,7 @@ const configuredRoute = (input, modelID) => {
49
48
  provider: id,
50
49
  message: "Google Vertex tuned models do not support Express Mode API keys",
51
50
  });
52
- const location = GoogleVertexShared.location(inputLocation, "global");
51
+ const location = GoogleVertexShared.location(inputLocation);
53
52
  const project = GoogleVertexShared.project(inputProject);
54
53
  const endpoint = baseURL ??
55
54
  (apiKey
@@ -81,8 +80,8 @@ export const model = (modelID, { accessToken, apiKey, baseURL, body, headers, lo
81
80
  return configure({
82
81
  ...(apiKey === undefined ? { accessToken: accessToken } : { apiKey: apiKey }),
83
82
  baseURL,
84
- headers: headers === undefined ? undefined : { ...headers },
85
- http: body === undefined ? undefined : { body: { ...body } },
83
+ headers,
84
+ http: body === undefined ? undefined : { body },
86
85
  location,
87
86
  project,
88
87
  providerOptions,
@@ -96,7 +96,8 @@ export declare const routes: (import("../route/client.js").Route<{
96
96
  } | undefined;
97
97
  readonly maxOutputTokens?: number | undefined;
98
98
  } | undefined;
99
- }, import("../route/transport/http.js").HttpPrepared<string>, import("../route/client.js").CompactionOperations | undefined> | import("../route/client.js").Route<{
99
+ readonly continuationToken?: string | undefined;
100
+ }, Gemini.Prepared, import("../route/client.js").CompactionOperations | undefined> | import("../route/client.js").Route<{
100
101
  readonly input: readonly ({
101
102
  readonly type: "user_input" | "model_output";
102
103
  readonly content: readonly ({
@@ -42,8 +42,8 @@ export const provider = configure();
42
42
  export const model = (modelID, { apiKey, baseURL, body, headers, ...providerOptions }) => configure({
43
43
  apiKey,
44
44
  baseURL,
45
- headers: headers === undefined ? undefined : { ...headers },
46
- http: body === undefined ? undefined : { body: { ...body } },
45
+ headers,
46
+ http: body === undefined ? undefined : { body },
47
47
  providerOptions,
48
48
  }).model(modelID);
49
49
  export const image = provider.image;
@@ -74,8 +74,8 @@ export const provider = configure();
74
74
  export const model = (modelID, { apiKey, baseURL, body, headers, ...providerOptions }) => configure({
75
75
  apiKey,
76
76
  baseURL,
77
- headers: headers === undefined ? undefined : { ...headers },
78
- http: body === undefined ? undefined : { body: { ...body } },
77
+ headers,
78
+ http: body === undefined ? undefined : { body },
79
79
  providerOptions,
80
80
  }).model(modelID);
81
81
  export * as Groq from "./groq.js";
@@ -22,7 +22,9 @@ export * as Fireworks from "./fireworks.js";
22
22
  export * as Google from "./google.js";
23
23
  export * as GoogleVertex from "./google-vertex.js";
24
24
  export * as GoogleVertexChat from "./google-vertex-chat.js";
25
+ export * as GoogleVertexInteractions from "./google-vertex-interactions.js";
25
26
  export * as GoogleVertexMessages from "./google-vertex-messages.js";
27
+ export * as GoogleVertexMistral from "./google-vertex-mistral.js";
26
28
  export * as GoogleVertexResponses from "./google-vertex-responses.js";
27
29
  export * as Groq from "./groq.js";
28
30
  export * as Meta from "./meta.js";
@@ -32,7 +34,7 @@ export * as Moonshot from "./moonshot.js";
32
34
  export * as OpenAI from "./openai.js";
33
35
  export * as OpenAICompatible from "./openai-compatible.js";
34
36
  export * as OpenAICompatibleResponses from "./openai-compatible-responses.js";
35
- export * as OpenCodeZen from "./opencode-zen.js";
37
+ export * as OpenCode from "./opencode.js";
36
38
  export * as OpenRouter from "./openrouter.js";
37
39
  export * as Replicate from "./replicate.js";
38
40
  export * as Runway from "./runway.js";
@@ -22,7 +22,9 @@ export * as Fireworks from "./fireworks.js";
22
22
  export * as Google from "./google.js";
23
23
  export * as GoogleVertex from "./google-vertex.js";
24
24
  export * as GoogleVertexChat from "./google-vertex-chat.js";
25
+ export * as GoogleVertexInteractions from "./google-vertex-interactions.js";
25
26
  export * as GoogleVertexMessages from "./google-vertex-messages.js";
27
+ export * as GoogleVertexMistral from "./google-vertex-mistral.js";
26
28
  export * as GoogleVertexResponses from "./google-vertex-responses.js";
27
29
  export * as Groq from "./groq.js";
28
30
  export * as Meta from "./meta.js";
@@ -32,7 +34,7 @@ export * as Moonshot from "./moonshot.js";
32
34
  export * as OpenAI from "./openai.js";
33
35
  export * as OpenAICompatible from "./openai-compatible.js";
34
36
  export * as OpenAICompatibleResponses from "./openai-compatible-responses.js";
35
- export * as OpenCodeZen from "./opencode-zen.js";
37
+ export * as OpenCode from "./opencode.js";
36
38
  export * as OpenRouter from "./openrouter.js";
37
39
  export * as Replicate from "./replicate.js";
38
40
  export * as Runway from "./runway.js";
@@ -102,7 +102,7 @@ function fromSettings({ apiKey, baseURL, body, headers, ...providerOptions }) {
102
102
  apiKey,
103
103
  baseURL,
104
104
  headers,
105
- http: body === undefined ? undefined : { body: { ...body } },
105
+ http: body === undefined ? undefined : { body },
106
106
  providerOptions,
107
107
  });
108
108
  }
@@ -3,6 +3,6 @@ export const model = (modelID, { apiKey, baseURL, body, headers, ...providerOpti
3
3
  apiKey,
4
4
  baseURL,
5
5
  headers,
6
- http: body === undefined ? undefined : { body: { ...body } },
6
+ http: body === undefined ? undefined : { body },
7
7
  providerOptions,
8
8
  }).chat(modelID);
@@ -3,6 +3,6 @@ export const model = (modelID, { apiKey, baseURL, body, headers, ...providerOpti
3
3
  apiKey,
4
4
  baseURL,
5
5
  headers,
6
- http: body === undefined ? undefined : { body: { ...body } },
6
+ http: body === undefined ? undefined : { body },
7
7
  providerOptions,
8
8
  }).responses(modelID);
@@ -80,7 +80,7 @@ export const model = (modelID, { apiKey, baseURL, body, headers, ...providerOpti
80
80
  apiKey,
81
81
  baseURL,
82
82
  headers,
83
- http: body === undefined ? undefined : { body: { ...body } },
83
+ http: body === undefined ? undefined : { body },
84
84
  providerOptions,
85
85
  }).model(modelID);
86
86
  export const messages = provider.messages;
@@ -21,8 +21,8 @@ export const provider = configure();
21
21
  export const model = (modelID, { apiKey, baseURL, body, headers, ...providerOptions }) => configure({
22
22
  apiKey,
23
23
  baseURL,
24
- headers: headers === undefined ? undefined : { ...headers },
25
- http: body === undefined ? undefined : { body: { ...body } },
24
+ headers,
25
+ http: body === undefined ? undefined : { body },
26
26
  providerOptions,
27
27
  }).model(modelID);
28
28
  export * as Mistral from "./mistral.js";