@opencode/ai 0.0.0-dev-20131 → 0.0.0-dev-20136

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.
@@ -126,6 +126,13 @@ declare const BedrockConverseBody: Schema.Struct<{
126
126
  additionalModelRequestFields: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
127
127
  }>;
128
128
  export type BedrockConverseBody = Schema.Schema.Type<typeof BedrockConverseBody>;
129
+ declare const Options: Schema.Struct<{
130
+ readonly thinking: Schema.optional<Schema.Struct<{
131
+ readonly type: Schema.Literal<"enabled">;
132
+ readonly budgetTokens: Schema.Number;
133
+ }>>;
134
+ }>;
135
+ export type OptionsInput = typeof Options.Type;
129
136
  interface ParserState {
130
137
  readonly providerMetadataKey: string;
131
138
  readonly tools: ToolStream.State<number>;
@@ -346,11 +346,24 @@ const isHighReasoningEffort = Schema.is(Schema.Struct({
346
346
  reasoningConfig: Schema.Struct({ maxReasoningEffort: Schema.Literal("high") }),
347
347
  }),
348
348
  }));
349
+ const Options = Schema.Struct({
350
+ thinking: Schema.optional(Schema.Struct({ type: Schema.Literal("enabled"), budgetTokens: Schema.Number })),
351
+ });
352
+ const decodeOptions = ProviderShared.validateWith(Schema.decodeUnknownEffect(Options));
353
+ // Claude on Bedrock requires the thinking budget below `maxTokens`, with a minimum of 1,024.
354
+ const MIN_THINKING_BUDGET = 1_024;
349
355
  const fromRequest = Effect.fn("BedrockConverse.fromRequest")(function* (request) {
350
356
  const toolChoice = request.toolChoice ? yield* lowerToolChoice(request.toolChoice) : undefined;
351
357
  const flattened = ProviderShared.flattenToolRequest(request);
352
358
  const generation = request.generation;
359
+ const options = yield* decodeOptions(request.providerOptions ?? {});
353
360
  const maxTokens = isNova2(request.model) && isHighReasoningEffort(request.http?.body) ? undefined : generation?.maxTokens;
361
+ const thinking = options.thinking === undefined
362
+ ? undefined
363
+ : {
364
+ type: "enabled",
365
+ budget_tokens: ProviderShared.fitThinkingBudget(options.thinking.budgetTokens, maxTokens, MIN_THINKING_BUDGET),
366
+ };
354
367
  // Bedrock-Claude shares Anthropic's 4-breakpoint cap. Spend the budget in
355
368
  // tools → system → messages order to favour the highest-impact prefixes.
356
369
  const breakpoints = BedrockCache.breakpoints(request.model.id);
@@ -388,9 +401,14 @@ const fromRequest = Effect.fn("BedrockConverse.fromRequest")(function* (request)
388
401
  system,
389
402
  inferenceConfig,
390
403
  toolConfig,
391
- // Converse's base inferenceConfig has no topK; Anthropic/Nova accept it
392
- // as a model-specific field, so it goes through additionalModelRequestFields.
393
- additionalModelRequestFields: generation?.topK === undefined ? undefined : { top_k: generation.topK },
404
+ // Converse's base inferenceConfig has no topK or thinking; Anthropic/Nova accept them
405
+ // as model-specific fields, so they go through additionalModelRequestFields.
406
+ additionalModelRequestFields: generation?.topK === undefined && thinking === undefined
407
+ ? undefined
408
+ : {
409
+ ...(generation?.topK === undefined ? {} : { top_k: generation.topK }),
410
+ ...(thinking === undefined ? {} : { thinking }),
411
+ },
394
412
  };
395
413
  });
396
414
  // =============================================================================
@@ -59,7 +59,13 @@ const SERVER_CODES = new Set([
59
59
  "slow_down",
60
60
  "serviceunavailableexception",
61
61
  ]);
62
- const INVALID_REQUEST_CODES = new Set(["invalid_prompt", "invalid_request_error", "validationexception"]);
62
+ // `invalid_request` is the Vercel AI Gateway's code for an upstream request rejection.
63
+ const INVALID_REQUEST_CODES = new Set([
64
+ "invalid_prompt",
65
+ "invalid_request",
66
+ "invalid_request_error",
67
+ "validationexception",
68
+ ]);
63
69
  // Azure OpenAI reports `content_filter` with `innererror.code` ResponsibleAIPolicyViolation.
64
70
  // OpenRouter tags provider failures with a typed `error_type`; its Responses skin also
65
71
  // emits `image_content_policy_violation` as the native code.
@@ -1,6 +1,7 @@
1
1
  import type { RouteDefaultsInput } from "../route/client.js";
2
2
  import type { ProviderPackage } from "../provider-package.js";
3
3
  import { type ModelID } from "../schema/index.js";
4
+ import * as BedrockConverse from "../protocols/bedrock-converse.js";
4
5
  import type { BedrockCredentials } from "../protocols/bedrock-converse.js";
5
6
  export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
6
7
  export type Config = RouteDefaultsInput & {
@@ -26,6 +27,7 @@ export interface Settings extends ProviderPackage.Settings {
26
27
  readonly profile?: string;
27
28
  readonly region?: string;
28
29
  readonly topP?: number;
30
+ readonly thinking?: BedrockConverse.OptionsInput["thinking"];
29
31
  }
30
32
  export declare const routes: import("../route/client.js").Route<{
31
33
  readonly messages: readonly ({
@@ -36,6 +36,7 @@ export const model = (modelID, settings) => configure({
36
36
  generation: settings.topP === undefined ? undefined : { topP: settings.topP },
37
37
  headers: settings.headers === undefined ? undefined : { ...settings.headers },
38
38
  http: settings.body === undefined ? undefined : { body: { ...settings.body } },
39
+ providerOptions: settings.thinking === undefined ? undefined : { thinking: settings.thinking },
39
40
  profile: settings.profile,
40
41
  region: settings.region,
41
42
  }).model(modelID);
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-20131",
3
+ "version": "0.0.0-dev-20136",
4
4
  "name": "@opencode/ai",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -34,7 +34,7 @@
34
34
  "devDependencies": {
35
35
  "@clack/prompts": "1.0.0-alpha.1",
36
36
  "@effect/platform-node": "4.0.0-rc.112",
37
- "@opencode/http-recorder": "0.0.0-dev-20131",
37
+ "@opencode/http-recorder": "0.0.0-dev-20136",
38
38
  "@tsconfig/bun": "1.0.9",
39
39
  "@types/bun": "1.4.0",
40
40
  "@typescript/native-preview": "7.0.0-dev.20251207.1",
@@ -44,7 +44,7 @@
44
44
  "@aws-sdk/credential-providers": "3.1057.0",
45
45
  "@smithy/eventstream-codec": "4.2.14",
46
46
  "@smithy/util-utf8": "4.2.2",
47
- "@opencode/schema": "0.0.0-dev-20131",
47
+ "@opencode/schema": "0.0.0-dev-20136",
48
48
  "aws4fetch": "1.0.20",
49
49
  "effect": "4.0.0-rc.112",
50
50
  "google-auth-library": "10.5.0"