diff --git a/docs/plugins/architecture.md b/docs/plugins/architecture.md index 8d6a6505d72..36efd4f699f 100644 --- a/docs/plugins/architecture.md +++ b/docs/plugins/architecture.md @@ -711,10 +711,18 @@ api.registerProvider({ - Anthropic uses `resolveDynamicModel`, `capabilities`, `buildAuthDoctorHint`, `resolveUsageAuth`, `fetchUsageSnapshot`, `isCacheTtlEligible`, - `resolveDefaultThinkingLevel`, `applyConfigDefaults`, and `isModernModelRef` - because it owns Claude 4.6 forward-compat, provider-family hints, auth - repair guidance, usage endpoint integration, prompt-cache eligibility, - auth-aware config defaults, and Claude default/adaptive thinking policy. + `resolveDefaultThinkingLevel`, `applyConfigDefaults`, `isModernModelRef`, + and `wrapStreamFn` because it owns Claude 4.6 forward-compat, + provider-family hints, auth repair guidance, usage endpoint integration, + prompt-cache eligibility, auth-aware config defaults, Claude + default/adaptive thinking policy, and Anthropic-specific stream shaping for + beta headers, `/fast` / `serviceTier`, and `context1m`. +- Anthropic's Claude-specific stream helpers stay in the bundled plugin's own + public `api.ts` / `contract-api.ts` seam for now. That package surface + exports `wrapAnthropicProviderStream`, `resolveAnthropicBetas`, + `resolveAnthropicFastMode`, `resolveAnthropicServiceTier`, and the lower-level + Anthropic wrapper builders instead of widening the generic SDK around one + provider's beta-header rules. - OpenAI uses `resolveDynamicModel`, `normalizeResolvedModel`, and `capabilities` plus `buildMissingAuthMessage`, `suppressBuiltInModel`, `augmentModelCatalog`, `supportsXHighThinking`, and `isModernModelRef` diff --git a/docs/plugins/sdk-overview.md b/docs/plugins/sdk-overview.md index dc6f3be7f45..bf5e9136139 100644 --- a/docs/plugins/sdk-overview.md +++ b/docs/plugins/sdk-overview.md @@ -294,6 +294,13 @@ Facade-loaded bundled plugin public surfaces (`api.ts`, `runtime-api.ts`, active runtime config snapshot when OpenClaw is already running. If no runtime snapshot exists yet, they fall back to the resolved config file on disk. +Provider plugins can also expose a narrow plugin-local contract barrel when a +helper is intentionally provider-specific and does not belong in a generic SDK +subpath yet. Current bundled example: the Anthropic provider keeps its Claude +stream helpers in its own public `api.ts` / `contract-api.ts` seam instead of +promoting Anthropic beta-header and `service_tier` logic into a generic +`plugin-sdk/*` contract. + Extension production code should also avoid `openclaw/plugin-sdk/` imports. If a helper is truly shared, promote it to a neutral SDK subpath diff --git a/docs/plugins/sdk-provider-plugins.md b/docs/plugins/sdk-provider-plugins.md index b4e7fe10b0a..6cdb69c0edd 100644 --- a/docs/plugins/sdk-provider-plugins.md +++ b/docs/plugins/sdk-provider-plugins.md @@ -309,6 +309,14 @@ API key auth, and dynamic model resolution. - `openrouter`: `openrouter-thinking` - `zai`: `tool-stream-default-on` + Some stream helpers stay provider-local on purpose. Current bundled + example: `@openclaw/anthropic-provider` exports + `wrapAnthropicProviderStream`, `resolveAnthropicBetas`, + `resolveAnthropicFastMode`, `resolveAnthropicServiceTier`, and the + lower-level Anthropic wrapper builders from its public `api.ts` / + `contract-api.ts` seam. Those helpers remain Anthropic-specific because + they also encode Claude OAuth beta handling and `context1m` gating. + For providers that need a token exchange before each inference call: