@opencode/ai 0.0.0-dev-20498 → 0.0.0-dev-20501

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 (53) hide show
  1. package/README.md +25 -0
  2. package/dist/protocols/alibaba-chat.d.ts +3 -3
  3. package/dist/protocols/alibaba-responses.d.ts +16 -12
  4. package/dist/protocols/alibaba-responses.js +3 -5
  5. package/dist/protocols/google-interactions.d.ts +236 -0
  6. package/dist/protocols/google-interactions.js +478 -0
  7. package/dist/protocols/index.d.ts +1 -0
  8. package/dist/protocols/index.js +1 -0
  9. package/dist/protocols/meta-responses.d.ts +31 -58
  10. package/dist/protocols/meta-responses.js +5 -24
  11. package/dist/protocols/mistral-chat.d.ts +1 -1
  12. package/dist/protocols/open-responses.d.ts +406 -91
  13. package/dist/protocols/open-responses.js +12 -6
  14. package/dist/protocols/openai-chat.d.ts +5 -5
  15. package/dist/protocols/openai-compatible-chat.d.ts +1 -1
  16. package/dist/protocols/openai-compatible-responses.d.ts +16 -4
  17. package/dist/protocols/openai-responses.d.ts +87 -223
  18. package/dist/protocols/openai-responses.js +3 -10
  19. package/dist/protocols/xai-responses.d.ts +18 -21
  20. package/dist/protocols/xai-responses.js +2 -8
  21. package/dist/protocols/zai-chat.d.ts +3 -3
  22. package/dist/providers/alibaba.d.ts +17 -13
  23. package/dist/providers/amazon-bedrock-mantle.d.ts +17 -5
  24. package/dist/providers/azure.d.ts +13 -61
  25. package/dist/providers/baseten.d.ts +2 -2
  26. package/dist/providers/cerebras.d.ts +2 -2
  27. package/dist/providers/cloudflare-ai-gateway.d.ts +14 -62
  28. package/dist/providers/cloudflare-workers-ai.d.ts +2 -2
  29. package/dist/providers/cohere.d.ts +2 -2
  30. package/dist/providers/deepinfra.d.ts +2 -2
  31. package/dist/providers/deepseek.d.ts +2 -2
  32. package/dist/providers/digitalocean.d.ts +5 -5
  33. package/dist/providers/fireworks.d.ts +2 -2
  34. package/dist/providers/google/interactions.d.ts +7 -0
  35. package/dist/providers/google/interactions.js +8 -0
  36. package/dist/providers/google-vertex-chat.d.ts +1 -1
  37. package/dist/providers/google-vertex-responses.d.ts +16 -4
  38. package/dist/providers/google.d.ts +94 -3
  39. package/dist/providers/google.js +8 -1
  40. package/dist/providers/groq.d.ts +4 -4
  41. package/dist/providers/meta.d.ts +15 -28
  42. package/dist/providers/minimax.d.ts +17 -5
  43. package/dist/providers/moonshot.d.ts +17 -5
  44. package/dist/providers/openai-compatible-responses.d.ts +16 -4
  45. package/dist/providers/openai-compatible.d.ts +1 -1
  46. package/dist/providers/openai.d.ts +7 -31
  47. package/dist/providers/openrouter.d.ts +5 -5
  48. package/dist/providers/togetherai.d.ts +2 -2
  49. package/dist/providers/xai.d.ts +1 -1
  50. package/dist/providers/zai-coding-plan.d.ts +17 -5
  51. package/dist/providers/zai.d.ts +1 -1
  52. package/dist/route/client.js +2 -5
  53. package/package.json +3 -3
package/README.md CHANGED
@@ -27,6 +27,31 @@ Run `LLM.stream(...)` instead of `generate` when you want incremental `LLMEvent`
27
27
  `LLM.request(...)`. The event stream is provider-neutral — same shape across OpenAI Chat, OpenAI Responses,
28
28
  Anthropic Messages, Gemini, Bedrock Converse, and any OpenAI-compatible deployment.
29
29
 
30
+ ### Google Interactions
31
+
32
+ `Google.configure({ apiKey }).interactions(modelID)` selects the Interactions API; `.model(modelID)` still selects
33
+ GenerateContent. The package entrypoint is `@opencode/ai/providers/google/interactions`.
34
+
35
+ ```ts
36
+ const model = Google.configure({ apiKey }).interactions("gemini-3.8-flash")
37
+ const response = yield* LLM.generate({
38
+ model,
39
+ prompt: "Say hello.",
40
+ providerOptions: { thinkingLevel: "low", thinkingSummaries: "auto", store: true },
41
+ })
42
+ ```
43
+
44
+ Interactions supports text output, streamed function calls, native tool results, thought signatures, and multimodal
45
+ input. Full-history replay is the default (`store: false`); implicit caching works without retained interactions.
46
+ For server-side continuation, set `store: true` on the predecessor, read `interactionId` from the final event's
47
+ `providerMetadata.google`, and pass `previousInteractionId` on the next request with **only new messages**. Repeat
48
+ the system instructions and tool declarations on each request. Set `store: true` on each response you intend to
49
+ continue from. The package does not automatically select or persist continuation IDs.
50
+
51
+ Raw usage is preserved in `usage.providerMetadata.google`. `inputTokens` follows Google's top-level accounting;
52
+ `contextTokens` uses its full `raw_prompt_token` count when supplied. These can differ substantially with server-side
53
+ continuation. Explicit caches, hosted tools, and generated media are not supported by this initial protocol.
54
+
30
55
  The same configured facade names image, video, speech, and transcription models. `Image.generate` resolves the
31
56
  provider's image route from the model and returns `Media.Asset`s with lazily decoded bytes:
32
57
 
@@ -152,10 +152,10 @@ export declare const protocol: Protocol<{
152
152
  readonly top_k?: number | undefined;
153
153
  readonly frequency_penalty?: number | undefined;
154
154
  readonly presence_penalty?: number | undefined;
155
+ readonly store?: boolean | undefined;
155
156
  readonly prompt_cache_key?: string | undefined;
156
157
  readonly parallel_tool_calls?: boolean | undefined;
157
158
  readonly reasoning_effort?: OpenResponsesOptions.ReasoningEffort | undefined;
158
- readonly store?: boolean | undefined;
159
159
  readonly stream_options?: {
160
160
  readonly include_usage: boolean;
161
161
  } | undefined;
@@ -188,9 +188,9 @@ export declare const protocol: Protocol<{
188
188
  readonly [x: string]: unknown;
189
189
  readonly cache_read_input_tokens?: number | null | undefined;
190
190
  readonly cached_tokens?: number | null | undefined;
191
+ readonly total_tokens?: number | null | undefined;
191
192
  readonly prompt_tokens?: number | null | undefined;
192
193
  readonly completion_tokens?: number | null | undefined;
193
- readonly total_tokens?: number | null | undefined;
194
194
  readonly prompt_tokens_details?: {
195
195
  readonly [x: string]: unknown;
196
196
  readonly cached_tokens?: number | null | undefined;
@@ -229,9 +229,9 @@ export declare const protocol: Protocol<{
229
229
  readonly [x: string]: unknown;
230
230
  readonly cache_read_input_tokens?: number | null | undefined;
231
231
  readonly cached_tokens?: number | null | undefined;
232
+ readonly total_tokens?: number | null | undefined;
232
233
  readonly prompt_tokens?: number | null | undefined;
233
234
  readonly completion_tokens?: number | null | undefined;
234
- readonly total_tokens?: number | null | undefined;
235
235
  readonly prompt_tokens_details?: {
236
236
  readonly [x: string]: unknown;
237
237
  readonly cached_tokens?: number | null | undefined;
@@ -48,6 +48,15 @@ export declare const protocol: Protocol<{
48
48
  readonly error?: unknown;
49
49
  readonly arguments?: string | undefined;
50
50
  readonly server_label?: string | undefined;
51
+ } | {
52
+ readonly type: "configuration_update";
53
+ readonly reasoning: {
54
+ readonly effort: OpenResponsesOptions.ReasoningEffort;
55
+ };
56
+ } | {
57
+ readonly [x: string]: unknown;
58
+ readonly type: string;
59
+ readonly id: string;
51
60
  } | {
52
61
  readonly type: "reasoning";
53
62
  readonly summary: readonly {
@@ -124,12 +133,6 @@ export declare const protocol: Protocol<{
124
133
  readonly type: "input_video";
125
134
  readonly video_url: string;
126
135
  })[];
127
- } | {
128
- readonly [x: string]: unknown;
129
- readonly id: string;
130
- readonly type: "web_extractor_call";
131
- readonly urls?: readonly string[] | undefined;
132
- readonly goal?: string | undefined;
133
136
  })[];
134
137
  readonly model: string;
135
138
  readonly stream: true;
@@ -142,6 +145,9 @@ export declare const protocol: Protocol<{
142
145
  readonly effort?: OpenResponsesOptions.ReasoningEffort | undefined;
143
146
  } | undefined;
144
147
  readonly tools?: readonly ({
148
+ readonly [x: string]: unknown;
149
+ readonly type: string;
150
+ } | {
145
151
  readonly type: "function";
146
152
  readonly description: string;
147
153
  readonly name: string;
@@ -149,8 +155,6 @@ export declare const protocol: Protocol<{
149
155
  readonly [x: string]: unknown;
150
156
  };
151
157
  readonly strict?: boolean | undefined;
152
- } | {
153
- readonly type: "web_search" | "code_interpreter" | "web_extractor";
154
158
  })[] | undefined;
155
159
  readonly text?: {
156
160
  readonly verbosity?: OpenResponsesOptions.TextVerbosity | undefined;
@@ -171,9 +175,10 @@ export declare const protocol: Protocol<{
171
175
  readonly top_p?: number | undefined;
172
176
  readonly frequency_penalty?: number | undefined;
173
177
  readonly presence_penalty?: number | undefined;
178
+ readonly store?: boolean | undefined;
179
+ readonly max_output_tokens?: number | undefined;
174
180
  readonly prompt_cache_key?: string | undefined;
175
181
  readonly parallel_tool_calls?: boolean | undefined;
176
- readonly store?: boolean | undefined;
177
182
  readonly include?: readonly OpenResponsesOptions.ResponseIncludable[] | undefined;
178
183
  readonly truncation?: "auto" | "disabled" | undefined;
179
184
  readonly stream_options?: {
@@ -181,7 +186,6 @@ export declare const protocol: Protocol<{
181
186
  } | undefined;
182
187
  readonly safety_identifier?: string | undefined;
183
188
  readonly top_logprobs?: number | undefined;
184
- readonly max_output_tokens?: number | undefined;
185
189
  readonly max_tool_calls?: number | undefined;
186
190
  readonly previous_response_id?: string | undefined;
187
191
  readonly conversation?: string | undefined;
@@ -204,8 +208,8 @@ export declare const protocol: Protocol<{
204
208
  readonly name?: string | undefined;
205
209
  readonly namespace?: string | undefined;
206
210
  readonly arguments?: string | undefined;
207
- readonly encrypted_content?: string | null | undefined;
208
211
  readonly call_id?: string | undefined;
212
+ readonly encrypted_content?: string | null | undefined;
209
213
  }[] | undefined;
210
214
  readonly error?: unknown;
211
215
  readonly usage?: {
@@ -232,8 +236,8 @@ export declare const protocol: Protocol<{
232
236
  readonly name?: string | undefined;
233
237
  readonly namespace?: string | undefined;
234
238
  readonly arguments?: string | undefined;
235
- readonly encrypted_content?: string | null | undefined;
236
239
  readonly call_id?: string | undefined;
240
+ readonly encrypted_content?: string | null | undefined;
237
241
  } | null | undefined;
238
242
  readonly delta?: string | undefined;
239
243
  readonly arguments?: string | undefined;
@@ -1,7 +1,7 @@
1
1
  import { Effect, Schema } from "effect";
2
2
  import { Protocol } from "../route/protocol.js";
3
3
  import { OpenResponses } from "./open-responses.js";
4
- import { JsonObject, optionalArray, ProviderShared } from "./shared.js";
4
+ import { JsonObject, ProviderShared } from "./shared.js";
5
5
  import { OpenResponsesOptions } from "./utils/open-responses-options.js";
6
6
  import { ResponsesHostedTools } from "./utils/responses-hosted-tools.js";
7
7
  const Options = Schema.Struct({
@@ -20,8 +20,6 @@ const WebExtractorItem = Schema.StructWithRest(Schema.Struct({
20
20
  }), [JsonObject]);
21
21
  const Body = Schema.Struct({
22
22
  ...OpenResponses.coreFields,
23
- input: Schema.Array(Schema.Union([OpenResponses.InputItem, WebExtractorItem])),
24
- tools: optionalArray(Schema.Union([OpenResponses.Tool, NativeTool])),
25
23
  enable_thinking: Options.fields.enableThinking,
26
24
  previous_response_id: Options.fields.previousResponseId,
27
25
  conversation: Options.fields.conversation,
@@ -45,7 +43,7 @@ export const protocol = Protocol.make({
45
43
  const opts = yield* ProviderShared.validateWith(Schema.decodeUnknownEffect(Options))(req.providerOptions ?? {});
46
44
  const body = yield* OpenResponses.fromRequestWithAdapter(req, adapter);
47
45
  const choice = body.tool_choice;
48
- return yield* ProviderShared.validateWith(Schema.decodeUnknownEffect(Body))({
46
+ return {
49
47
  ...body,
50
48
  enable_thinking: opts.enableThinking,
51
49
  previous_response_id: opts.previousResponseId,
@@ -54,7 +52,7 @@ export const protocol = Protocol.make({
54
52
  tool_choice: typeof choice === "object" && choice.type === "function"
55
53
  ? { type: "allowed_tools", mode: "required", tools: [choice] }
56
54
  : choice,
57
- });
55
+ };
58
56
  }),
59
57
  },
60
58
  stream: {
@@ -0,0 +1,236 @@
1
+ import { Schema } from "effect";
2
+ import { Route } from "../route/client.js";
3
+ import { Protocol } from "../route/protocol.js";
4
+ import { Lifecycle } from "./utils/lifecycle.js";
5
+ import { ToolStream } from "./utils/tool-stream.js";
6
+ export declare const DEFAULT_BASE_URL = "https://generativelanguage.googleapis.com/v1beta";
7
+ declare const Options: Schema.Struct<{
8
+ readonly previousInteractionId: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.String>, never>>;
9
+ readonly store: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.Boolean>, never>>;
10
+ readonly thinkingLevel: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.declare<import("../schema/options.js").OpenString<"minimal" | "low" | "medium" | "high">, import("../schema/options.js").OpenString<"minimal" | "low" | "medium" | "high">>>, never>>;
11
+ readonly thinkingSummaries: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.declare<import("../schema/options.js").OpenString<"auto" | "none">, import("../schema/options.js").OpenString<"auto" | "none">>>, never>>;
12
+ readonly serviceTier: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.declare<import("../schema/options.js").OpenString<"standard" | "flex" | "priority">, import("../schema/options.js").OpenString<"standard" | "flex" | "priority">>>, never>>;
13
+ }>;
14
+ export type OptionsInput = typeof Options.Encoded;
15
+ export type ProviderOptionsInput = OptionsInput;
16
+ declare const OutputStep: Schema.Struct<{
17
+ readonly type: Schema.String;
18
+ readonly id: Schema.optional<Schema.String>;
19
+ readonly name: Schema.optional<Schema.String>;
20
+ readonly arguments: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
21
+ readonly signature: Schema.optional<Schema.String>;
22
+ readonly summary: Schema.optional<Schema.$Array<Schema.Struct<{
23
+ readonly type: Schema.Literal<"text">;
24
+ readonly text: Schema.String;
25
+ }>>>;
26
+ readonly content: Schema.optional<Schema.$Array<Schema.Struct<{
27
+ readonly type: Schema.String;
28
+ readonly text: Schema.optional<Schema.String>;
29
+ }>>>;
30
+ }>;
31
+ type OutputStep = typeof OutputStep.Type;
32
+ interface ParserState {
33
+ readonly route: string;
34
+ readonly metadataKey: string;
35
+ readonly lifecycle: Lifecycle.State;
36
+ readonly steps: Partial<Record<number, OutputStep>>;
37
+ readonly tools: ToolStream.State<number>;
38
+ readonly completed: boolean;
39
+ }
40
+ export declare const protocol: Protocol<{
41
+ readonly input: readonly ({
42
+ readonly type: "user_input" | "model_output";
43
+ readonly content: readonly ({
44
+ readonly type: "text";
45
+ readonly text: string;
46
+ } | {
47
+ readonly type: "image" | "document" | "video" | "audio";
48
+ readonly mime_type: string;
49
+ readonly data?: string | undefined;
50
+ readonly uri?: string | undefined;
51
+ })[];
52
+ } | {
53
+ readonly type: "thought";
54
+ readonly summary?: readonly {
55
+ readonly type: "text";
56
+ readonly text: string;
57
+ }[] | undefined;
58
+ readonly signature?: string | undefined;
59
+ } | {
60
+ readonly id: string;
61
+ readonly type: "function_call";
62
+ readonly name: string;
63
+ readonly arguments: unknown;
64
+ readonly signature?: string | undefined;
65
+ } | {
66
+ readonly type: "function_result";
67
+ readonly name: string;
68
+ readonly result: unknown;
69
+ readonly call_id: string;
70
+ readonly is_error?: boolean | undefined;
71
+ })[];
72
+ readonly model: string;
73
+ readonly stream: true;
74
+ readonly store: boolean;
75
+ readonly generation_config: {
76
+ readonly temperature?: number | undefined;
77
+ readonly seed?: number | undefined;
78
+ readonly tool_choice?: "auto" | "none" | "any" | {
79
+ readonly allowed_tools: {
80
+ readonly mode: "any";
81
+ readonly tools: readonly string[];
82
+ };
83
+ } | undefined;
84
+ readonly top_p?: number | undefined;
85
+ readonly stop_sequences?: readonly string[] | undefined;
86
+ readonly max_output_tokens?: number | undefined;
87
+ readonly thinking_level?: import("../schema/options.js").OpenString<"minimal" | "low" | "medium" | "high"> | undefined;
88
+ readonly thinking_summaries?: string | undefined;
89
+ };
90
+ readonly tools?: readonly {
91
+ readonly type: "function";
92
+ readonly name: string;
93
+ readonly description: string;
94
+ readonly parameters: {
95
+ readonly [x: string]: unknown;
96
+ };
97
+ }[] | undefined;
98
+ readonly service_tier?: string | undefined;
99
+ readonly previous_interaction_id?: string | undefined;
100
+ readonly system_instruction?: string | undefined;
101
+ }, string, {
102
+ readonly event_type: "step.start";
103
+ readonly index: number;
104
+ readonly step: {
105
+ readonly type: string;
106
+ readonly id?: string | undefined;
107
+ readonly name?: string | undefined;
108
+ readonly summary?: readonly {
109
+ readonly type: "text";
110
+ readonly text: string;
111
+ }[] | undefined;
112
+ readonly content?: readonly {
113
+ readonly type: string;
114
+ readonly text?: string | undefined;
115
+ }[] | undefined;
116
+ readonly signature?: string | undefined;
117
+ readonly arguments?: {
118
+ readonly [x: string]: unknown;
119
+ } | undefined;
120
+ };
121
+ } | {
122
+ readonly event_type: "step.delta";
123
+ readonly index: number;
124
+ readonly delta: {
125
+ readonly type: "text";
126
+ readonly text: string;
127
+ } | {
128
+ readonly type: "arguments_delta";
129
+ readonly arguments: string;
130
+ } | {
131
+ readonly type: "thought_signature";
132
+ readonly signature: string;
133
+ } | {
134
+ readonly type: "thought_summary";
135
+ readonly content: {
136
+ readonly type: "text";
137
+ readonly text: string;
138
+ };
139
+ } | {
140
+ readonly type: string;
141
+ };
142
+ } | {
143
+ readonly event_type: "step.stop";
144
+ readonly index: number;
145
+ } | {
146
+ readonly event_type: "interaction.created";
147
+ readonly interaction: {
148
+ readonly id?: string | undefined;
149
+ };
150
+ } | {
151
+ readonly status: string;
152
+ readonly event_type: "interaction.status_update";
153
+ readonly interaction_id?: string | undefined;
154
+ } | {
155
+ readonly event_type: "interaction.completed";
156
+ readonly interaction: {
157
+ readonly [x: string]: unknown;
158
+ readonly status: string;
159
+ readonly id?: string | undefined;
160
+ readonly usage?: {
161
+ readonly [x: string]: unknown;
162
+ readonly total_input_tokens?: number | null | undefined;
163
+ readonly total_cached_tokens?: number | null | undefined;
164
+ readonly total_output_tokens?: number | null | undefined;
165
+ readonly total_thought_tokens?: number | null | undefined;
166
+ readonly total_tokens?: number | null | undefined;
167
+ readonly raw_prompt_token?: number | null | undefined;
168
+ } | undefined;
169
+ };
170
+ } | {
171
+ readonly event_type: "error";
172
+ readonly error: unknown;
173
+ }, ParserState>;
174
+ export declare const route: Route<{
175
+ readonly input: readonly ({
176
+ readonly type: "user_input" | "model_output";
177
+ readonly content: readonly ({
178
+ readonly type: "text";
179
+ readonly text: string;
180
+ } | {
181
+ readonly type: "image" | "document" | "video" | "audio";
182
+ readonly mime_type: string;
183
+ readonly data?: string | undefined;
184
+ readonly uri?: string | undefined;
185
+ })[];
186
+ } | {
187
+ readonly type: "thought";
188
+ readonly summary?: readonly {
189
+ readonly type: "text";
190
+ readonly text: string;
191
+ }[] | undefined;
192
+ readonly signature?: string | undefined;
193
+ } | {
194
+ readonly id: string;
195
+ readonly type: "function_call";
196
+ readonly name: string;
197
+ readonly arguments: unknown;
198
+ readonly signature?: string | undefined;
199
+ } | {
200
+ readonly type: "function_result";
201
+ readonly name: string;
202
+ readonly result: unknown;
203
+ readonly call_id: string;
204
+ readonly is_error?: boolean | undefined;
205
+ })[];
206
+ readonly model: string;
207
+ readonly stream: true;
208
+ readonly store: boolean;
209
+ readonly generation_config: {
210
+ readonly temperature?: number | undefined;
211
+ readonly seed?: number | undefined;
212
+ readonly tool_choice?: "auto" | "none" | "any" | {
213
+ readonly allowed_tools: {
214
+ readonly mode: "any";
215
+ readonly tools: readonly string[];
216
+ };
217
+ } | undefined;
218
+ readonly top_p?: number | undefined;
219
+ readonly stop_sequences?: readonly string[] | undefined;
220
+ readonly max_output_tokens?: number | undefined;
221
+ readonly thinking_level?: import("../schema/options.js").OpenString<"minimal" | "low" | "medium" | "high"> | undefined;
222
+ readonly thinking_summaries?: string | undefined;
223
+ };
224
+ readonly tools?: readonly {
225
+ readonly type: "function";
226
+ readonly name: string;
227
+ readonly description: string;
228
+ readonly parameters: {
229
+ readonly [x: string]: unknown;
230
+ };
231
+ }[] | undefined;
232
+ readonly service_tier?: string | undefined;
233
+ readonly previous_interaction_id?: string | undefined;
234
+ readonly system_instruction?: string | undefined;
235
+ }, import("../route/transport/http.js").HttpPrepared<string>, import("../route/client.js").CompactionOperations | undefined>;
236
+ export * as GoogleInteractions from "./google-interactions.js";