diff --git a/extensions/anthropic/index.ts b/extensions/anthropic/index.ts index 251777b8292..e19838baca7 100644 --- a/extensions/anthropic/index.ts +++ b/extensions/anthropic/index.ts @@ -1,6 +1,11 @@ +/** + * Anthropic provider plugin entry. It registers Claude API auth, Claude CLI + * backend support, media understanding, stream wrappers, and usage reporting. + */ import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry"; import { registerAnthropicPlugin } from "./register.runtime.js"; +/** Provider entry for Anthropic API and Claude CLI runtime surfaces. */ export default definePluginEntry({ id: "anthropic", name: "Anthropic Provider", diff --git a/extensions/anthropic/media-understanding-provider.ts b/extensions/anthropic/media-understanding-provider.ts index 758e382eea7..ff7d5e3d18e 100644 --- a/extensions/anthropic/media-understanding-provider.ts +++ b/extensions/anthropic/media-understanding-provider.ts @@ -1,9 +1,14 @@ +/** + * Anthropic media-understanding provider descriptor. It routes image and native + * document description through the shared model-backed media helpers. + */ import { describeImageWithModel, describeImagesWithModel, type MediaUnderstandingProvider, } from "openclaw/plugin-sdk/media-understanding"; +/** Media-understanding provider for Anthropic Claude models. */ export const anthropicMediaUnderstandingProvider: MediaUnderstandingProvider = { id: "anthropic", capabilities: ["image"], diff --git a/extensions/anthropic/provider-contract-api.ts b/extensions/anthropic/provider-contract-api.ts index 34acbcc9d7f..de7c4a1622e 100644 --- a/extensions/anthropic/provider-contract-api.ts +++ b/extensions/anthropic/provider-contract-api.ts @@ -1,7 +1,12 @@ +/** + * Contract API for Anthropic provider metadata. It builds a provider descriptor + * without runtime registration side effects. + */ import type { ProviderPlugin } from "openclaw/plugin-sdk/provider-model-shared"; const noopAuth = async () => ({ profiles: [] }); +/** Create the static Anthropic provider contract descriptor. */ export function createAnthropicProvider(): ProviderPlugin { return { id: "anthropic", diff --git a/extensions/anthropic/provider-discovery.ts b/extensions/anthropic/provider-discovery.ts index 49fd584865c..74aa996a34e 100644 --- a/extensions/anthropic/provider-discovery.ts +++ b/extensions/anthropic/provider-discovery.ts @@ -1,3 +1,7 @@ +/** + * Claude CLI provider discovery descriptor. It exposes subscription-backed + * synthetic auth for catalog/runtime discovery without full Anthropic registration. + */ import type { ProviderPlugin } from "openclaw/plugin-sdk/provider-model-shared"; import { readClaudeCliCredentialsForRuntime } from "./cli-auth-seam.js"; diff --git a/extensions/anthropic/provider-policy-api.ts b/extensions/anthropic/provider-policy-api.ts index 1655bcf20af..891dc7a9dc6 100644 --- a/extensions/anthropic/provider-policy-api.ts +++ b/extensions/anthropic/provider-policy-api.ts @@ -1,3 +1,7 @@ +/** + * Provider-policy API for Anthropic and Claude CLI. Core calls this lightweight + * path for config defaults and thinking profiles. + */ import { resolveClaudeThinkingProfile } from "openclaw/plugin-sdk/provider-model-shared"; import type { ModelProviderConfig } from "openclaw/plugin-sdk/provider-model-types"; import { @@ -5,14 +9,17 @@ import { normalizeAnthropicProviderConfigForProvider, } from "./config-defaults.js"; +/** Normalize Anthropic provider config without importing runtime registration. */ export function normalizeConfig(params: { provider: string; providerConfig: ModelProviderConfig }) { return normalizeAnthropicProviderConfigForProvider(params); } +/** Apply Anthropic config defaults through the provider-policy seam. */ export function applyConfigDefaults(params: Parameters[0]) { return applyAnthropicConfigDefaults(params); } +/** Resolve Claude thinking profile for Anthropic or Claude CLI providers. */ export function resolveThinkingProfile(params: { provider: string; modelId: string }) { switch (params.provider.trim().toLowerCase()) { case "anthropic": diff --git a/extensions/anthropic/register.runtime.ts b/extensions/anthropic/register.runtime.ts index 18cbe280249..0e1047f95a1 100644 --- a/extensions/anthropic/register.runtime.ts +++ b/extensions/anthropic/register.runtime.ts @@ -1,3 +1,7 @@ +/** + * Anthropic provider runtime registration. It owns API-key/setup-token/Claude + * CLI auth, dynamic model normalization, usage auth, media, and stream wrappers. + */ import { formatCliCommand, parseDurationMs } from "openclaw/plugin-sdk/cli-runtime"; import { resolveExpiresAtMsFromDurationMs } from "openclaw/plugin-sdk/number-runtime"; import type { @@ -695,6 +699,7 @@ async function resolveAnthropicUsageAuth( return { handled: true }; } +/** Build the full Anthropic provider descriptor used by runtime registration. */ export function buildAnthropicProvider(): ProviderPlugin { const providerId = "anthropic"; const defaultAnthropicModel = DEFAULT_ANTHROPIC_MODEL; @@ -833,6 +838,7 @@ export function buildAnthropicProvider(): ProviderPlugin { }; } +/** Register Anthropic provider, Claude CLI backend, and media understanding provider. */ export function registerAnthropicPlugin(api: OpenClawPluginApi): void { api.registerCliBackend(buildAnthropicCliBackend()); api.registerProvider(buildAnthropicProvider()); diff --git a/extensions/anthropic/replay-policy.ts b/extensions/anthropic/replay-policy.ts index 251ec8c3bbc..63382a3419c 100644 --- a/extensions/anthropic/replay-policy.ts +++ b/extensions/anthropic/replay-policy.ts @@ -1,3 +1,7 @@ +/** + * Anthropic replay-policy bridge. It re-exports the native Anthropic replay + * policy from the shared provider-model hooks and fails fast if it disappears. + */ import { NATIVE_ANTHROPIC_REPLAY_HOOKS } from "openclaw/plugin-sdk/provider-model-shared"; const { buildReplayPolicy } = NATIVE_ANTHROPIC_REPLAY_HOOKS; diff --git a/extensions/anthropic/setup-api.ts b/extensions/anthropic/setup-api.ts index 0f5ea4d3d21..fc5a0deed80 100644 --- a/extensions/anthropic/setup-api.ts +++ b/extensions/anthropic/setup-api.ts @@ -1,6 +1,11 @@ +/** + * Lightweight Anthropic setup entry. It registers Claude CLI backend metadata + * without loading full provider runtime code. + */ import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry"; import { buildAnthropicCliBackend } from "./cli-backend.js"; +/** Setup entry for Claude CLI backend registration. */ export default definePluginEntry({ id: "anthropic", name: "Anthropic Setup", diff --git a/extensions/anthropic/stream-wrappers.ts b/extensions/anthropic/stream-wrappers.ts index 1ab3acd465a..26a65d422a1 100644 --- a/extensions/anthropic/stream-wrappers.ts +++ b/extensions/anthropic/stream-wrappers.ts @@ -1,3 +1,7 @@ +/** + * Anthropic stream wrappers. They add beta headers, service tier/fast-mode + * payload fields, and thinking-prefill cleanup around provider stream functions. + */ import type { StreamFn } from "openclaw/plugin-sdk/agent-core"; import { streamSimple } from "openclaw/plugin-sdk/llm"; import type { ProviderWrapStreamFnContext } from "openclaw/plugin-sdk/plugin-entry"; @@ -101,6 +105,7 @@ function hasConfiguredAnthropicBeta(extraParams: Record | undef return configured.some((beta) => typeof beta === "string" && beta.trim().length > 0); } +/** Resolve configured Anthropic beta headers from extra model params. */ export function resolveAnthropicBetas( extraParams: Record | undefined, _modelId: string, @@ -128,6 +133,7 @@ export function resolveAnthropicBetas( return betas.size > 0 ? [...betas] : undefined; } +/** Wrap a stream function to merge OpenClaw and configured Anthropic beta headers. */ export function createAnthropicBetaHeadersWrapper( baseStreamFn: StreamFn | undefined, betas: string[], @@ -148,6 +154,7 @@ export function createAnthropicBetaHeadersWrapper( }; } +/** Wrap a stream function with the Anthropic fast-mode service tier. */ export function createAnthropicFastModeWrapper( baseStreamFn: StreamFn | undefined, enabled: boolean, @@ -155,6 +162,7 @@ export function createAnthropicFastModeWrapper( return createAnthropicServiceTierWrapper(baseStreamFn, resolveAnthropicFastServiceTier(enabled)); } +/** Wrap a stream function with an explicit Anthropic service tier when allowed. */ export function createAnthropicServiceTierWrapper( baseStreamFn: StreamFn | undefined, serviceTier: AnthropicServiceTier, @@ -181,6 +189,7 @@ export function createAnthropicServiceTierWrapper( }; } +/** Wrap a stream function to strip trailing assistant prefill before thinking requests. */ export function createAnthropicThinkingPrefillWrapper( baseStreamFn: StreamFn | undefined, ): StreamFn { @@ -191,6 +200,7 @@ export function createAnthropicThinkingPrefillWrapper( }); } +/** Resolve Anthropic fast-mode setting from model extra params. */ export function resolveAnthropicFastMode( extraParams: Record | undefined, ): boolean | undefined { @@ -199,6 +209,7 @@ export function resolveAnthropicFastMode( ); } +/** Resolve Anthropic service tier from model extra params. */ export function resolveAnthropicServiceTier( extraParams: Record | undefined, ): AnthropicServiceTier | undefined { @@ -211,6 +222,7 @@ export function resolveAnthropicServiceTier( return normalized; } +/** Compose all Anthropic stream wrappers for one provider/model context. */ export function wrapAnthropicProviderStream( ctx: ProviderWrapStreamFnContext, ): StreamFn | undefined { @@ -236,6 +248,7 @@ export function wrapAnthropicProviderStream( ); } +/** Test-only hooks for Anthropic stream wrapper behavior. */ export const testing = { log, stripTrailingAssistantPrefillWhenThinking: stripTrailingAnthropicAssistantPrefillWhenThinking, diff --git a/extensions/anthropic/test-api.ts b/extensions/anthropic/test-api.ts index 62175f950df..714f3e18d2b 100644 --- a/extensions/anthropic/test-api.ts +++ b/extensions/anthropic/test-api.ts @@ -1,3 +1,7 @@ +/** + * Test API barrel for Anthropic plugin internals. Tests import this path to + * avoid reaching into unrelated runtime modules. + */ export { buildAnthropicCliBackend } from "./cli-backend.js"; export { normalizeClaudeBackendConfig } from "./cli-shared.js"; export { anthropicMediaUnderstandingProvider } from "./media-understanding-provider.js";