feat: 添加 Bedrock API 客户端及 API 层增强

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
unraid
2026-04-22 22:38:09 +08:00
parent 59f8675fa3
commit be97a0b010
15 changed files with 1362 additions and 197 deletions

View File

@@ -68,7 +68,6 @@ export function filterAllowedSdkBetas(
}
if (isClaudeAISubscriber()) {
// biome-ignore lint/suspicious/noConsole: intentional warning
console.warn(
'Warning: Custom betas are only available for API key users. Ignoring provided betas.',
)
@@ -77,7 +76,6 @@ export function filterAllowedSdkBetas(
const { allowed, disallowed } = partitionBetasByAllowlist(sdkBetas)
for (const beta of disallowed) {
// biome-ignore lint/suspicious/noConsole: intentional warning
console.warn(
`Warning: Beta header '${beta}' is not allowed. Only the following betas are supported: ${ALLOWED_SDK_BETAS.join(', ')}`,
)
@@ -151,6 +149,7 @@ export function modelSupportsStructuredOutputs(model: string): boolean {
canonical.includes('claude-opus-4-1') ||
canonical.includes('claude-opus-4-5') ||
canonical.includes('claude-opus-4-6') ||
canonical.includes('claude-opus-4-7') ||
canonical.includes('claude-haiku-4-5')
)
}
@@ -188,7 +187,7 @@ export function modelSupportsAutoMode(model: string): boolean {
return true
}
// External allowlist (firstParty already checked above).
return /^claude-(opus|sonnet)-4-6/.test(m)
return /^claude-(opus|sonnet)-4-[67]/.test(m)
}
return false
}
@@ -275,16 +274,18 @@ export const getAllModelBetas = memoize((model: string): string[] => {
betaHeaders.push(REDACT_THINKING_BETA_HEADER)
}
// Add context management beta for tool clearing (ant opt-in) or thinking preservation
const antOptedIntoToolClearing =
isEnvTruthy(process.env.USE_API_CONTEXT_MANAGEMENT) &&
process.env.USER_TYPE === 'ant'
// Add context management beta for tool clearing or thinking preservation.
// Tool clearing is enabled by default for all users (upstream gates on ant);
// thinking preservation activates when the model supports context management.
const toolClearingOptIn =
isEnvTruthy(process.env.USE_API_CONTEXT_MANAGEMENT) ||
modelSupportsContextManagement(model)
const thinkingPreservationEnabled = modelSupportsContextManagement(model)
if (
shouldIncludeFirstPartyOnlyBetas() &&
(antOptedIntoToolClearing || thinkingPreservationEnabled)
(toolClearingOptIn || thinkingPreservationEnabled)
) {
betaHeaders.push(CONTEXT_MANAGEMENT_BETA_HEADER)
}