diff --git a/index.mjs b/index.mjs index 3fd75af..3a1c4a9 100644 --- a/index.mjs +++ b/index.mjs @@ -66,12 +66,16 @@ async function exchange(code, verifier) { } /** - * @type {import('@opencode-ai/plugin').Plugin} + * build an anthropic provider plugin with the given name. + * + * @param {string} name the provider's key (eg. 'anthropic', 'anthropic-personal', etc) + * @param {import('@opencode-ai/plugin').PluginInput['client']} client + * @returns {Promise} */ -export async function AnthropicAuthPlugin({ client }) { +export async function makeAnthropicProviderPlugin(name, client) { return { auth: { - provider: "anthropic", + provider: name, async loader(getAuth, provider) { const auth = await getAuth(); if (auth.type === "oauth") { @@ -116,7 +120,7 @@ export async function AnthropicAuthPlugin({ client }) { const json = await response.json(); await client.auth.set({ path: { - id: "anthropic", + id: name, }, body: { type: "oauth", @@ -206,7 +210,7 @@ export async function AnthropicAuthPlugin({ client }) { }, }, { - provider: "anthropic", + provider: name, label: "Manually enter API Key", type: "api", }, @@ -214,3 +218,10 @@ export async function AnthropicAuthPlugin({ client }) { }, }; } + +/** + * @type {import('@opencode-ai/plugin').Plugin} + */ +export async function AnthropicAuthPlugin({ client }) { + return makeAnthropicProviderPlugin("anthropic", client); +} \ No newline at end of file