@opencode/ai 0.0.0-dev-1321 → 0.0.0-dev-1323

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.
@@ -108,10 +108,6 @@ const GeminiThinkingConfig = Schema.Struct({
108
108
  includeThoughts: Schema.optional(Schema.Boolean),
109
109
  thinkingLevel: Schema.optional(GeminiThinkingLevel),
110
110
  });
111
- const GeminiSafetySetting = Schema.Struct({
112
- category: knownString(),
113
- threshold: knownString(),
114
- });
115
111
  // =============================================================================
116
112
  // Provider Options
117
113
  // =============================================================================
@@ -124,7 +120,7 @@ const GeminiThinkingConfigInput = Schema.Struct({
124
120
  });
125
121
  const Options = Schema.Struct({
126
122
  cachedContent: lenient(Schema.String),
127
- safetySettings: lenient(Schema.Array(GeminiSafetySetting)),
123
+ safetySettings: lenient(Schema.Array(GeminiGenerateContent.SafetySetting)),
128
124
  serviceTier: lenient(knownString()),
129
125
  thinkingConfig: lenient(GeminiThinkingConfigInput),
130
126
  });
@@ -144,7 +140,7 @@ const GeminiBodyFields = {
144
140
  cachedContent: Schema.optional(Schema.String),
145
141
  contents: Schema.Array(GeminiContent),
146
142
  labels: Schema.optional(Schema.Record(Schema.String, Schema.String)),
147
- safetySettings: optionalArray(GeminiSafetySetting),
143
+ safetySettings: optionalArray(GeminiGenerateContent.SafetySetting),
148
144
  serviceTier: Schema.optional(Schema.String),
149
145
  systemInstruction: Schema.optional(GeminiSystemInstruction),
150
146
  tools: optionalArray(GeminiTool),
@@ -13,6 +13,10 @@ declare const Options: Schema.Struct<{
13
13
  readonly thinkingLevel: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.declare<import("../schema/options.js").OpenString<"high" | "low" | "medium" | "minimal">, import("../schema/options.js").OpenString<"high" | "low" | "medium" | "minimal">>>, never>>;
14
14
  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>>;
15
15
  readonly serviceTier: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.declare<import("../schema/options.js").OpenString<"deferred" | "flex" | "priority" | "standard">, import("../schema/options.js").OpenString<"deferred" | "flex" | "priority" | "standard">>>, never>>;
16
+ readonly safetySettings: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.$Array<Schema.Struct<{
17
+ readonly category: Schema.declare<import("../schema/options.js").OpenString<"HARM_CATEGORY_CIVIC_INTEGRITY" | "HARM_CATEGORY_DANGEROUS_CONTENT" | "HARM_CATEGORY_HARASSMENT" | "HARM_CATEGORY_HATE_SPEECH" | "HARM_CATEGORY_SEXUALLY_EXPLICIT" | "HARM_CATEGORY_UNSPECIFIED">, import("../schema/options.js").OpenString<"HARM_CATEGORY_CIVIC_INTEGRITY" | "HARM_CATEGORY_DANGEROUS_CONTENT" | "HARM_CATEGORY_HARASSMENT" | "HARM_CATEGORY_HATE_SPEECH" | "HARM_CATEGORY_SEXUALLY_EXPLICIT" | "HARM_CATEGORY_UNSPECIFIED">>;
18
+ readonly threshold: Schema.declare<import("../schema/options.js").OpenString<"BLOCK_LOW_AND_ABOVE" | "BLOCK_MEDIUM_AND_ABOVE" | "BLOCK_NONE" | "BLOCK_ONLY_HIGH" | "HARM_BLOCK_THRESHOLD_UNSPECIFIED" | "OFF">, import("../schema/options.js").OpenString<"BLOCK_LOW_AND_ABOVE" | "BLOCK_MEDIUM_AND_ABOVE" | "BLOCK_NONE" | "BLOCK_ONLY_HIGH" | "HARM_BLOCK_THRESHOLD_UNSPECIFIED" | "OFF">>;
19
+ }>>>, never>>;
16
20
  }>;
17
21
  export type OptionsInput = typeof Options.Encoded;
18
22
  export type ProviderOptionsInput = OptionsInput;
@@ -55,6 +59,10 @@ declare const Body: Schema.Struct<{
55
59
  readonly continuation_token: Schema.optional<Schema.String>;
56
60
  readonly system_instruction: Schema.optional<Schema.String>;
57
61
  readonly service_tier: Schema.optional<Schema.String>;
62
+ readonly safety_settings: Schema.optional<Schema.$Array<Schema.Struct<{
63
+ readonly type: Schema.String;
64
+ readonly threshold: Schema.String;
65
+ }>>>;
58
66
  readonly tools: Schema.optional<Schema.$Array<Schema.Struct<{
59
67
  readonly type: Schema.Literal<"function">;
60
68
  readonly name: Schema.String;
@@ -262,6 +270,10 @@ export declare const protocol: Protocol<{
262
270
  readonly continuation_token?: string | undefined;
263
271
  readonly system_instruction?: string | undefined;
264
272
  readonly service_tier?: string | undefined;
273
+ readonly safety_settings?: readonly {
274
+ readonly type: string;
275
+ readonly threshold: string;
276
+ }[] | undefined;
265
277
  readonly tools?: readonly {
266
278
  readonly type: "function";
267
279
  readonly name: string;
@@ -505,6 +517,10 @@ export declare const route: Route<{
505
517
  readonly continuation_token?: string | undefined;
506
518
  readonly system_instruction?: string | undefined;
507
519
  readonly service_tier?: string | undefined;
520
+ readonly safety_settings?: readonly {
521
+ readonly type: string;
522
+ readonly threshold: string;
523
+ }[] | undefined;
508
524
  readonly tools?: readonly {
509
525
  readonly type: "function";
510
526
  readonly name: string;
@@ -29,6 +29,7 @@ const Options = Schema.Struct({
29
29
  thinkingLevel: lenient(ThinkingLevel),
30
30
  thinkingSummaries: lenient(knownString()),
31
31
  serviceTier: lenient(knownString()),
32
+ safetySettings: lenient(Schema.Array(GeminiGenerateContent.SafetySetting)),
32
33
  });
33
34
  const decodeOptions = ProviderShared.validateWith(Schema.decodeUnknownEffect(Options));
34
35
  // =============================================================================
@@ -77,6 +78,7 @@ const Body = Schema.Struct({
77
78
  continuation_token: Schema.optional(Schema.String),
78
79
  system_instruction: Schema.optional(Schema.String),
79
80
  service_tier: Schema.optional(Schema.String),
81
+ safety_settings: Schema.optional(Schema.Array(Schema.Struct({ type: Schema.String, threshold: Schema.String }))),
80
82
  tools: Schema.optional(Schema.Array(Schema.Struct({
81
83
  type: Schema.Literal("function"),
82
84
  name: Schema.String,
@@ -179,12 +181,26 @@ const Event = Schema.Union([
179
181
  // =============================================================================
180
182
  // Request Body Construction
181
183
  // =============================================================================
184
+ // https://aistudio.google.com/docs/document-processing#office-documents
185
+ const OFFICE_DOCUMENT_MIME_TYPES = new Set([
186
+ "application/msword",
187
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
188
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.template",
189
+ "application/vnd.oasis.opendocument.text",
190
+ "application/vnd.ms-powerpoint",
191
+ "application/vnd.openxmlformats-officedocument.presentationml.presentation",
192
+ "application/vnd.oasis.opendocument.presentation",
193
+ "application/vnd.ms-excel",
194
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
195
+ "application/vnd.oasis.opendocument.spreadsheet",
196
+ ]);
182
197
  export const mediaContent = Effect.fnUntraced(function* (asset) {
183
198
  if (asset.kind !== "image" &&
184
199
  asset.kind !== "audio" &&
185
200
  asset.kind !== "video" &&
186
201
  asset.mediaType !== "application/pdf" &&
187
- asset.mediaType !== "text/csv")
202
+ asset.mediaType !== "text/csv" &&
203
+ !OFFICE_DOCUMENT_MIME_TYPES.has(asset.mediaType))
188
204
  return yield* ProviderShared.invalidRequest(`Google Interactions does not support ${asset.mediaType} document input`);
189
205
  const type = asset.kind === "image" || asset.kind === "audio" || asset.kind === "video" ? asset.kind : "document";
190
206
  const uri = asset.kind === "video" && asset.source.type === "url" && /^https?:\/\//i.test(asset.source.url)
@@ -304,6 +320,10 @@ const fromRequest = Effect.fn("GoogleInteractions.fromRequest")(function* (reque
304
320
  previous_interaction_id: options.previousInteractionId,
305
321
  system_instruction: request.system.length ? ProviderShared.joinText(request.system) : undefined,
306
322
  service_tier: options.serviceTier,
323
+ safety_settings: options.safetySettings?.map((setting) => ({
324
+ type: setting.category.replace(/^HARM_CATEGORY_/, "").toLowerCase(),
325
+ threshold: setting.threshold.toLowerCase(),
326
+ })),
307
327
  tools: flattened.tools.length
308
328
  ? flattened.tools.map((tool) => ({
309
329
  type: "function",
@@ -3,6 +3,10 @@ import type { Tool } from "@opencode/schema/tool";
3
3
  import { Media } from "../../media.js";
4
4
  import type { MediaProtocol } from "../../route/media-protocol.js";
5
5
  import { AIError, type MediaUsage, type ProviderMetadata } from "../../schema/index.js";
6
+ export declare const SafetySetting: Schema.Struct<{
7
+ readonly category: Schema.declare<import("../../schema/options.js").OpenString<"HARM_CATEGORY_CIVIC_INTEGRITY" | "HARM_CATEGORY_DANGEROUS_CONTENT" | "HARM_CATEGORY_HARASSMENT" | "HARM_CATEGORY_HATE_SPEECH" | "HARM_CATEGORY_SEXUALLY_EXPLICIT" | "HARM_CATEGORY_UNSPECIFIED">, import("../../schema/options.js").OpenString<"HARM_CATEGORY_CIVIC_INTEGRITY" | "HARM_CATEGORY_DANGEROUS_CONTENT" | "HARM_CATEGORY_HARASSMENT" | "HARM_CATEGORY_HATE_SPEECH" | "HARM_CATEGORY_SEXUALLY_EXPLICIT" | "HARM_CATEGORY_UNSPECIFIED">>;
8
+ readonly threshold: Schema.declare<import("../../schema/options.js").OpenString<"BLOCK_LOW_AND_ABOVE" | "BLOCK_MEDIUM_AND_ABOVE" | "BLOCK_NONE" | "BLOCK_ONLY_HIGH" | "HARM_BLOCK_THRESHOLD_UNSPECIFIED" | "OFF">, import("../../schema/options.js").OpenString<"BLOCK_LOW_AND_ABOVE" | "BLOCK_MEDIUM_AND_ABOVE" | "BLOCK_NONE" | "BLOCK_ONLY_HIGH" | "HARM_BLOCK_THRESHOLD_UNSPECIFIED" | "OFF">>;
9
+ }>;
6
10
  declare const UsageMetadata: Schema.Struct<{
7
11
  readonly promptTokenCount: Schema.optional<Schema.Number>;
8
12
  readonly candidatesTokenCount: Schema.optional<Schema.Number>;
@@ -2,9 +2,13 @@ import { Effect, Schema } from "effect";
2
2
  import { Media } from "../../media.js";
3
3
  import { Framing } from "../../route/framing.js";
4
4
  import { AIError, ContentPolicyError, ProviderID, tokenUsage, } from "../../schema/index.js";
5
- import { ProviderShared } from "../shared.js";
5
+ import { knownString, ProviderShared } from "../shared.js";
6
6
  import { MediaInput } from "./media-input.js";
7
7
  const PROVIDER = ProviderID.make("google");
8
+ export const SafetySetting = Schema.Struct({
9
+ category: knownString(),
10
+ threshold: knownString(),
11
+ });
8
12
  const UsageMetadata = Schema.Struct({
9
13
  promptTokenCount: Schema.optional(Schema.Number),
10
14
  candidatesTokenCount: Schema.optional(Schema.Number),
@@ -61,6 +61,10 @@ export declare const routes: Route<{
61
61
  readonly continuation_token?: string | undefined;
62
62
  readonly system_instruction?: string | undefined;
63
63
  readonly service_tier?: string | undefined;
64
+ readonly safety_settings?: readonly {
65
+ readonly type: string;
66
+ readonly threshold: string;
67
+ }[] | undefined;
64
68
  readonly tools?: readonly {
65
69
  readonly type: "function";
66
70
  readonly name: string;
@@ -93,6 +97,10 @@ export declare const configure: (input?: Config) => {
93
97
  readonly thinkingLevel?: import("../schema/options.js").OpenString<"high" | "low" | "medium" | "minimal"> | undefined;
94
98
  readonly thinkingSummaries?: import("../schema/options.js").OpenString<"auto" | "none"> | undefined;
95
99
  readonly serviceTier?: import("../schema/options.js").OpenString<"deferred" | "flex" | "priority" | "standard"> | undefined;
100
+ readonly safetySettings?: readonly {
101
+ readonly category: import("../schema/options.js").OpenString<"HARM_CATEGORY_CIVIC_INTEGRITY" | "HARM_CATEGORY_DANGEROUS_CONTENT" | "HARM_CATEGORY_HARASSMENT" | "HARM_CATEGORY_HATE_SPEECH" | "HARM_CATEGORY_SEXUALLY_EXPLICIT" | "HARM_CATEGORY_UNSPECIFIED">;
102
+ readonly threshold: import("../schema/options.js").OpenString<"BLOCK_LOW_AND_ABOVE" | "BLOCK_MEDIUM_AND_ABOVE" | "BLOCK_NONE" | "BLOCK_ONLY_HIGH" | "HARM_BLOCK_THRESHOLD_UNSPECIFIED" | "OFF">;
103
+ }[] | undefined;
96
104
  }, import("../route/client.js").CompactionOperations | undefined>;
97
105
  configure: typeof configure;
98
106
  };
@@ -139,6 +139,10 @@ export declare const routes: (import("../route.js").Route<{
139
139
  readonly continuation_token?: string | undefined;
140
140
  readonly system_instruction?: string | undefined;
141
141
  readonly service_tier?: string | undefined;
142
+ readonly safety_settings?: readonly {
143
+ readonly type: string;
144
+ readonly threshold: string;
145
+ }[] | undefined;
142
146
  readonly tools?: readonly {
143
147
  readonly type: "function";
144
148
  readonly name: string;
@@ -181,6 +185,10 @@ export declare const configure: (input?: Config) => {
181
185
  readonly thinkingLevel?: import("../schema/options.js").OpenString<"high" | "low" | "medium" | "minimal"> | undefined;
182
186
  readonly thinkingSummaries?: import("../schema/options.js").OpenString<"auto" | "none"> | undefined;
183
187
  readonly serviceTier?: import("../schema/options.js").OpenString<"deferred" | "flex" | "priority" | "standard"> | undefined;
188
+ readonly safetySettings?: readonly {
189
+ readonly category: import("../schema/options.js").OpenString<"HARM_CATEGORY_CIVIC_INTEGRITY" | "HARM_CATEGORY_DANGEROUS_CONTENT" | "HARM_CATEGORY_HARASSMENT" | "HARM_CATEGORY_HATE_SPEECH" | "HARM_CATEGORY_SEXUALLY_EXPLICIT" | "HARM_CATEGORY_UNSPECIFIED">;
190
+ readonly threshold: import("../schema/options.js").OpenString<"BLOCK_LOW_AND_ABOVE" | "BLOCK_MEDIUM_AND_ABOVE" | "BLOCK_NONE" | "BLOCK_ONLY_HIGH" | "HARM_BLOCK_THRESHOLD_UNSPECIFIED" | "OFF">;
191
+ }[] | undefined;
184
192
  }, import("../route.js").CompactionOperations | undefined>;
185
193
  image: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../image.js").ImageModel<import("../protocols/google-images.js").GoogleImageOptions>;
186
194
  video: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../video.js").VideoModel<import("../protocols/google-interactions-video.js").GoogleVideoOptions>;
@@ -200,6 +208,10 @@ export declare const provider: {
200
208
  readonly thinkingLevel?: import("../schema/options.js").OpenString<"high" | "low" | "medium" | "minimal"> | undefined;
201
209
  readonly thinkingSummaries?: import("../schema/options.js").OpenString<"auto" | "none"> | undefined;
202
210
  readonly serviceTier?: import("../schema/options.js").OpenString<"deferred" | "flex" | "priority" | "standard"> | undefined;
211
+ readonly safetySettings?: readonly {
212
+ readonly category: import("../schema/options.js").OpenString<"HARM_CATEGORY_CIVIC_INTEGRITY" | "HARM_CATEGORY_DANGEROUS_CONTENT" | "HARM_CATEGORY_HARASSMENT" | "HARM_CATEGORY_HATE_SPEECH" | "HARM_CATEGORY_SEXUALLY_EXPLICIT" | "HARM_CATEGORY_UNSPECIFIED">;
213
+ readonly threshold: import("../schema/options.js").OpenString<"BLOCK_LOW_AND_ABOVE" | "BLOCK_MEDIUM_AND_ABOVE" | "BLOCK_NONE" | "BLOCK_ONLY_HIGH" | "HARM_BLOCK_THRESHOLD_UNSPECIFIED" | "OFF">;
214
+ }[] | undefined;
203
215
  }, import("../route.js").CompactionOperations | undefined>;
204
216
  image: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../image.js").ImageModel<import("../protocols/google-images.js").GoogleImageOptions>;
205
217
  video: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../video.js").VideoModel<import("../protocols/google-interactions-video.js").GoogleVideoOptions>;
@@ -224,6 +236,10 @@ export declare const interactions: (modelID: string | ModelID) => import("../sch
224
236
  readonly thinkingLevel?: import("../schema/options.js").OpenString<"high" | "low" | "medium" | "minimal"> | undefined;
225
237
  readonly thinkingSummaries?: import("../schema/options.js").OpenString<"auto" | "none"> | undefined;
226
238
  readonly serviceTier?: import("../schema/options.js").OpenString<"deferred" | "flex" | "priority" | "standard"> | undefined;
239
+ readonly safetySettings?: readonly {
240
+ readonly category: import("../schema/options.js").OpenString<"HARM_CATEGORY_CIVIC_INTEGRITY" | "HARM_CATEGORY_DANGEROUS_CONTENT" | "HARM_CATEGORY_HARASSMENT" | "HARM_CATEGORY_HATE_SPEECH" | "HARM_CATEGORY_SEXUALLY_EXPLICIT" | "HARM_CATEGORY_UNSPECIFIED">;
241
+ readonly threshold: import("../schema/options.js").OpenString<"BLOCK_LOW_AND_ABOVE" | "BLOCK_MEDIUM_AND_ABOVE" | "BLOCK_NONE" | "BLOCK_ONLY_HIGH" | "HARM_BLOCK_THRESHOLD_UNSPECIFIED" | "OFF">;
242
+ }[] | undefined;
227
243
  }, import("../route.js").CompactionOperations | undefined>;
228
244
  export declare const speech: (modelID: string | ModelID) => import("../speech.js").SpeechModel<import("../protocols/google-speech.js").GoogleSpeechOptions>;
229
245
  export declare const transcription: (modelID: string | ModelID) => import("../transcription.js").TranscriptionModel<import("../protocols/google-transcription.js").GoogleTranscriptionOptions>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
- "version": "0.0.0-dev-1321",
3
+ "version": "0.0.0-dev-1323",
4
4
  "name": "@opencode/ai",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -624,7 +624,7 @@
624
624
  "devDependencies": {
625
625
  "@clack/prompts": "1.0.0-alpha.1",
626
626
  "@effect/platform-node": "4.1.0",
627
- "@opencode/http-recorder": "0.0.0-dev-1321",
627
+ "@opencode/http-recorder": "0.0.0-dev-1323",
628
628
  "@tsconfig/bun": "1.0.9",
629
629
  "@types/bun": "1.4.3",
630
630
  "@typescript/native": "npm:typescript@7.1.0-beta",
@@ -634,7 +634,7 @@
634
634
  "@aws-sdk/credential-providers": "3.1057.0",
635
635
  "@smithy/eventstream-codec": "4.2.14",
636
636
  "@smithy/util-utf8": "4.2.2",
637
- "@opencode/schema": "0.0.0-dev-1321",
637
+ "@opencode/schema": "0.0.0-dev-1323",
638
638
  "aws4fetch": "1.0.20",
639
639
  "effect": "4.1.0",
640
640
  "google-auth-library": "10.5.0"