/** * Amazon Bedrock Converse Stream provider. * * Talks directly to `bedrock-runtime.{region}.amazonaws.com` over HTTPS with * SigV4 signing and decodes the `application/vnd.amazon.eventstream` response. * No `@aws-sdk/*`, no `@smithy/*`, no `proxy-agent`. Proxies are honored via * Bun's native `HTTPS_PROXY` support. */ import { parseBedrockClaudeGeneration } from "../bedrock-claude-cache-policy"; import type { Effort } from "../model-thinking"; import type { Model, StreamFunction, StreamOptions, ThinkingBudgets, Tool, ToolChoice } from "../types"; export type BedrockThinkingDisplay = "summarized" | "omitted"; export interface BedrockOptions extends StreamOptions { region?: string; profile?: string; toolChoice?: ToolChoice; reasoning?: Effort; thinkingBudgets?: ThinkingBudgets; interleavedThinking?: boolean; /** * Controls how Anthropic model returns thinking content in Bedrock responses. * - `"summarized"`: thinking blocks include human-readable summaries (default here). * - `"omitted"`: thinking content is suppressed; the encrypted signature still * travels back for multi-turn continuity. * * Starting with Anthropic model Opus 4.7 the Anthropic API default is `"omitted"`, which * leaves callers waiting on a silent stream during long reasoning runs (issue * #1373). We default to `"summarized"` so adaptive-thinking models that accept * the field keep producing visible thinking deltas. Older adaptive-thinking * models (Opus 4.6, Sonnet 4.6+) reject the field, so we omit it for them. */ thinkingDisplay?: BedrockThinkingDisplay; } interface WireToolSpec { toolSpec: { name: string; description: string; inputSchema: { json: unknown; }; }; } interface WireToolChoice { auto?: Record; any?: Record; tool?: { name: string; }; } interface WireToolConfig { tools: WireToolSpec[]; toolChoice?: WireToolChoice; } export declare const streamBedrock: StreamFunction<"bedrock-converse-stream">; /** * Check if the model supports prompt caching. * Supported: Claude 3.5 Haiku, Claude 3.7 Sonnet, and every later Claude * generation: * https://docs.aws.amazon.com/bedrock/latest/userguide/prompt-caching.html * * For base models and system-defined inference profiles the model ID / ARN * contains the model name, so we can decide locally. * * For application inference profiles (whose ARNs don't contain the model name), * set AWS_BEDROCK_FORCE_CACHE=1 to enable cache points. Amazon Nova models * have automatic caching and don't need explicit cache points. */ export declare function supportsPromptCaching(model: Model<"bedrock-converse-stream">): boolean; export { parseBedrockClaudeGeneration }; export declare function stripBedrockForcedToolChoiceForRetry(body: T): T; export declare function convertToolConfig(tools: Tool[] | undefined, toolChoice: BedrockOptions["toolChoice"]): WireToolConfig | undefined;