diff --git a/extensions/anthropic/index.test.ts b/extensions/anthropic/index.test.ts index ec9791b52da..5aa2a73be27 100644 --- a/extensions/anthropic/index.test.ts +++ b/extensions/anthropic/index.test.ts @@ -1,4 +1,5 @@ import { describe, expect, it, vi } from "vitest"; +import { createCapturedPluginRegistration } from "../../src/test-utils/plugin-registration.js"; import { registerSingleProviderPlugin } from "../../test/helpers/plugins/plugin-registration.js"; const { readClaudeCliCredentialsForSetupMock, readClaudeCliCredentialsForRuntimeMock } = vi.hoisted( @@ -18,6 +19,23 @@ vi.mock("./cli-auth-seam.js", () => { import anthropicPlugin from "./index.js"; describe("anthropic provider replay hooks", () => { + it("registers the claude-cli backend", async () => { + const captured = createCapturedPluginRegistration(); + await anthropicPlugin.register(captured.api); + + expect(captured.cliBackends).toContainEqual( + expect.objectContaining({ + id: "claude-cli", + bundleMcp: true, + config: expect.objectContaining({ + command: "claude", + modelArg: "--model", + sessionArg: "--session-id", + }), + }), + ); + }); + it("owns native reasoning output mode for Claude transports", async () => { const provider = await registerSingleProviderPlugin(anthropicPlugin); diff --git a/src/agents/model-selection.test.ts b/src/agents/model-selection.test.ts index a4570bfa67d..2eb17fd6863 100644 --- a/src/agents/model-selection.test.ts +++ b/src/agents/model-selection.test.ts @@ -2,7 +2,7 @@ import { describe, it, expect, vi } from "vitest"; import type { OpenClawConfig } from "../config/config.js"; import { resetLogger, setLoggerOverride } from "../logging/logger.js"; import { createEmptyPluginRegistry } from "../plugins/registry-empty.js"; -import { setActivePluginRegistry } from "../plugins/runtime.js"; +import { getActivePluginRegistry, setActivePluginRegistry } from "../plugins/runtime.js"; import { buildAllowedModelSet, inferUniqueProviderFromConfiguredModels, @@ -135,17 +135,26 @@ describe("model-selection", () => { describe("isCliProvider", () => { it("treats runtime-registered CLI backends as CLI providers", () => { + const previousRegistry = getActivePluginRegistry(); const registry = createEmptyPluginRegistry(); - registry.cliBackends.push({ - pluginId: "anthropic", - backend: { - id: "claude-cli", - label: "Claude CLI", - command: ["claude"], - }, - }); - setActivePluginRegistry(registry); - expect(isCliProvider("claude-cli", {} as OpenClawConfig)).toBe(true); + try { + registry.cliBackends = [ + { + pluginId: "example-plugin", + source: "test", + backend: { + id: "example-cli", + config: { + command: "example", + }, + }, + }, + ]; + setActivePluginRegistry(registry); + expect(isCliProvider("example-cli", {} as OpenClawConfig)).toBe(true); + } finally { + setActivePluginRegistry(previousRegistry ?? createEmptyPluginRegistry()); + } }); });