mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-12 01:31:08 +00:00
Anthropic: fix claude-cli runtime auth
This commit is contained in:
@@ -300,6 +300,25 @@ describe("provider-runtime", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("returns no runtime plugin when the provider has no owning plugin", () => {
|
||||
it("matches providers by hook alias for runtime hook lookup", () => {
|
||||
resolveOwningPluginIdsForProviderMock.mockReturnValue(["anthropic"]);
|
||||
resolvePluginProvidersMock.mockReturnValue([
|
||||
{
|
||||
id: "anthropic",
|
||||
label: "Anthropic",
|
||||
hookAliases: ["claude-cli"],
|
||||
auth: [],
|
||||
},
|
||||
]);
|
||||
|
||||
expectProviderRuntimePluginLoad({
|
||||
provider: "claude-cli",
|
||||
expectedPluginId: "anthropic",
|
||||
expectedOnlyPluginIds: ["anthropic"],
|
||||
});
|
||||
});
|
||||
|
||||
it("returns no runtime plugin when the provider has no owning plugin", () => {
|
||||
expectProviderRuntimePluginLoad({
|
||||
provider: "anthropic",
|
||||
|
||||
@@ -26,6 +26,7 @@ let setActivePluginRegistry: SetActivePluginRegistry;
|
||||
function createManifestProviderPlugin(params: {
|
||||
id: string;
|
||||
providerIds: string[];
|
||||
cliBackends?: string[];
|
||||
origin?: "bundled" | "workspace";
|
||||
enabledByDefault?: boolean;
|
||||
modelSupport?: { modelPrefixes?: string[]; modelPatterns?: string[] };
|
||||
@@ -34,7 +35,7 @@ function createManifestProviderPlugin(params: {
|
||||
id: params.id,
|
||||
enabledByDefault: params.enabledByDefault,
|
||||
channels: [],
|
||||
cliBackends: [],
|
||||
cliBackends: params.cliBackends ?? [],
|
||||
providers: params.providerIds,
|
||||
modelSupport: params.modelSupport,
|
||||
skills: [],
|
||||
@@ -62,6 +63,7 @@ function setOwningProviderManifestPlugins() {
|
||||
createManifestProviderPlugin({
|
||||
id: "openai",
|
||||
providerIds: ["openai", "openai-codex"],
|
||||
cliBackends: ["codex-cli"],
|
||||
modelSupport: {
|
||||
modelPrefixes: ["gpt-", "o1", "o3", "o4"],
|
||||
},
|
||||
@@ -69,6 +71,7 @@ function setOwningProviderManifestPlugins() {
|
||||
createManifestProviderPlugin({
|
||||
id: "anthropic",
|
||||
providerIds: ["anthropic"],
|
||||
cliBackends: ["claude-cli"],
|
||||
modelSupport: {
|
||||
modelPrefixes: ["claude-"],
|
||||
},
|
||||
@@ -85,6 +88,7 @@ function setOwningProviderManifestPluginsWithWorkspace() {
|
||||
createManifestProviderPlugin({
|
||||
id: "openai",
|
||||
providerIds: ["openai", "openai-codex"],
|
||||
cliBackends: ["codex-cli"],
|
||||
modelSupport: {
|
||||
modelPrefixes: ["gpt-", "o1", "o3", "o4"],
|
||||
},
|
||||
@@ -92,6 +96,7 @@ function setOwningProviderManifestPluginsWithWorkspace() {
|
||||
createManifestProviderPlugin({
|
||||
id: "anthropic",
|
||||
providerIds: ["anthropic"],
|
||||
cliBackends: ["claude-cli"],
|
||||
modelSupport: {
|
||||
modelPrefixes: ["claude-"],
|
||||
},
|
||||
@@ -275,6 +280,13 @@ describe("resolvePluginProviders", () => {
|
||||
({ setActivePluginRegistry } = await import("./runtime.js"));
|
||||
});
|
||||
|
||||
it("maps cli backend ids to owning plugin ids via manifests", () => {
|
||||
setOwningProviderManifestPlugins();
|
||||
|
||||
expectOwningPluginIds("claude-cli", ["anthropic"]);
|
||||
expectOwningPluginIds("codex-cli", ["openai"]);
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
setActivePluginRegistry(createEmptyPluginRegistry());
|
||||
resolveRuntimePluginRegistryMock.mockReset();
|
||||
|
||||
@@ -203,8 +203,14 @@ export function resolveOwningPluginIdsForProvider(params: {
|
||||
|
||||
const registry = resolveManifestRegistry(params);
|
||||
const pluginIds = registry.plugins
|
||||
.filter((plugin) =>
|
||||
plugin.providers.some((providerId) => normalizeProviderId(providerId) === normalizedProvider),
|
||||
.filter(
|
||||
(plugin) =>
|
||||
plugin.providers.some(
|
||||
(providerId) => normalizeProviderId(providerId) === normalizedProvider,
|
||||
) ||
|
||||
plugin.cliBackends.some(
|
||||
(backendId) => normalizeProviderId(backendId) === normalizedProvider,
|
||||
),
|
||||
)
|
||||
.map((plugin) => plugin.id);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user