fix(providers): narrow staged anthropic client type · openclaw/openclaw@741d5d3
steipete
·
2026-04-25
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -5,6 +5,8 @@ import { streamAnthropic } from "@mariozechner/pi-ai/anthropic";
|
5 | 5 | |
6 | 6 | const MANTLE_ANTHROPIC_BETA = "fine-grained-tool-streaming-2025-05-14"; |
7 | 7 | type AnthropicOptions = ConstructorParameters<typeof Anthropic>[0]; |
| 8 | +type AnthropicStreamOptions = NonNullable<Parameters<typeof streamAnthropic>[2]>; |
| 9 | +type AnthropicStreamClient = NonNullable<AnthropicStreamOptions["client"]>; |
8 | 10 | |
9 | 11 | export function resolveMantleAnthropicBaseUrl(baseUrl: string): string { |
10 | 12 | const trimmed = baseUrl.replace(/\/+$/, ""); |
@@ -98,10 +100,13 @@ export function createMantleAnthropicStreamFn(deps?: {
|
98 | 100 | ), |
99 | 101 | }); |
100 | 102 | const base = buildMantleAnthropicBaseOptions(model, options, apiKey); |
| 103 | +// Staged plugin runtime deps can give this plugin a distinct physical SDK copy. |
| 104 | +// The client API is the same, but the SDK class private field makes types nominal. |
| 105 | +const streamClient = client as unknown as AnthropicStreamClient; |
101 | 106 | if (!options?.reasoning || requiresDefaultSampling(model.id)) { |
102 | 107 | return stream(model as Model<"anthropic-messages">, context, { |
103 | 108 | ...base, |
104 | | - client, |
| 109 | +client: streamClient, |
105 | 110 | thinkingEnabled: false, |
106 | 111 | }); |
107 | 112 | } |
@@ -114,7 +119,7 @@ export function createMantleAnthropicStreamFn(deps?: {
|
114 | 119 | ); |
115 | 120 | return stream(model as Model<"anthropic-messages">, context, { |
116 | 121 | ...base, |
117 | | - client, |
| 122 | +client: streamClient, |
118 | 123 | maxTokens: adjusted.maxTokens, |
119 | 124 | thinkingEnabled: true, |
120 | 125 | thinkingBudgetTokens: adjusted.thinkingBudget, |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。