mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-20 22:40:58 +00:00
Plugin SDK: split provider auth login seam
This commit is contained in:
@@ -2,11 +2,11 @@ import { definePluginEntry } from "openclaw/plugin-sdk/core";
|
||||
import {
|
||||
buildOauthProviderAuthResult,
|
||||
createProviderApiKeyAuthMethod,
|
||||
loginChutes,
|
||||
resolveOAuthApiKeyMarker,
|
||||
type ProviderAuthContext,
|
||||
type ProviderAuthResult,
|
||||
} from "openclaw/plugin-sdk/provider-auth";
|
||||
import { loginChutes } from "openclaw/plugin-sdk/provider-auth-login";
|
||||
import {
|
||||
CHUTES_DEFAULT_MODEL_REF,
|
||||
applyChutesApiKeyConfig,
|
||||
|
||||
@@ -5,7 +5,8 @@ import {
|
||||
type ProviderResolveDynamicModelContext,
|
||||
type ProviderRuntimeModel,
|
||||
} from "openclaw/plugin-sdk/core";
|
||||
import { coerceSecretRef, githubCopilotLoginCommand } from "openclaw/plugin-sdk/provider-auth";
|
||||
import { coerceSecretRef } from "openclaw/plugin-sdk/provider-auth";
|
||||
import { githubCopilotLoginCommand } from "openclaw/plugin-sdk/provider-auth-login";
|
||||
import { normalizeModelCompat } from "openclaw/plugin-sdk/provider-models";
|
||||
import { DEFAULT_COPILOT_API_BASE_URL, resolveCopilotApiToken } from "./token.js";
|
||||
import { fetchCopilotUsage } from "./usage.js";
|
||||
|
||||
@@ -9,9 +9,9 @@ import {
|
||||
CODEX_CLI_PROFILE_ID,
|
||||
ensureAuthProfileStore,
|
||||
listProfilesForProvider,
|
||||
loginOpenAICodexOAuth,
|
||||
type OAuthCredential,
|
||||
} from "openclaw/plugin-sdk/provider-auth";
|
||||
import { loginOpenAICodexOAuth } from "openclaw/plugin-sdk/provider-auth-login";
|
||||
import {
|
||||
DEFAULT_CONTEXT_TOKENS,
|
||||
normalizeModelCompat,
|
||||
|
||||
@@ -414,6 +414,10 @@
|
||||
"types": "./dist/plugin-sdk/provider-auth.d.ts",
|
||||
"default": "./dist/plugin-sdk/provider-auth.js"
|
||||
},
|
||||
"./plugin-sdk/provider-auth-login": {
|
||||
"types": "./dist/plugin-sdk/provider-auth-login.d.ts",
|
||||
"default": "./dist/plugin-sdk/provider-auth-login.js"
|
||||
},
|
||||
"./plugin-sdk/provider-catalog": {
|
||||
"types": "./dist/plugin-sdk/provider-catalog.d.ts",
|
||||
"default": "./dist/plugin-sdk/provider-catalog.js"
|
||||
|
||||
5
src/plugin-sdk/provider-auth-login.ts
Normal file
5
src/plugin-sdk/provider-auth-login.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
// Public interactive auth/login helpers for provider plugins.
|
||||
|
||||
export { githubCopilotLoginCommand } from "../providers/github-copilot-auth.js";
|
||||
export { loginChutes } from "../commands/chutes-oauth.js";
|
||||
export { loginOpenAICodexOAuth } from "../plugins/provider-openai-codex-oauth.js";
|
||||
@@ -36,9 +36,6 @@ export {
|
||||
validateAnthropicSetupToken,
|
||||
} from "../plugins/provider-auth-token.js";
|
||||
export { applyAuthProfileConfig, buildApiKeyCredential } from "../plugins/provider-auth-helpers.js";
|
||||
export { githubCopilotLoginCommand } from "../providers/github-copilot-auth.js";
|
||||
export { loginChutes } from "../commands/chutes-oauth.js";
|
||||
export { loginOpenAICodexOAuth } from "../plugins/provider-openai-codex-oauth.js";
|
||||
export { createProviderApiKeyAuthMethod } from "../plugins/provider-api-key-auth.js";
|
||||
export { coerceSecretRef } from "../config/types.secrets.js";
|
||||
export { resolveDefaultSecretProviderAlias } from "../secrets/ref-contract.js";
|
||||
|
||||
@@ -14,11 +14,11 @@ import type {
|
||||
import type { OpenClawPluginApi, ProviderPlugin } from "../types.js";
|
||||
|
||||
type LoginOpenAICodexOAuth =
|
||||
(typeof import("openclaw/plugin-sdk/provider-auth"))["loginOpenAICodexOAuth"];
|
||||
(typeof import("openclaw/plugin-sdk/provider-auth-login"))["loginOpenAICodexOAuth"];
|
||||
type LoginQwenPortalOAuth =
|
||||
(typeof import("../../../extensions/qwen-portal-auth/oauth.js"))["loginQwenPortalOAuth"];
|
||||
type GithubCopilotLoginCommand =
|
||||
(typeof import("openclaw/plugin-sdk/provider-auth"))["githubCopilotLoginCommand"];
|
||||
(typeof import("openclaw/plugin-sdk/provider-auth-login"))["githubCopilotLoginCommand"];
|
||||
type CreateVpsAwareHandlers =
|
||||
(typeof import("../provider-oauth-flow.js"))["createVpsAwareOAuthHandlers"];
|
||||
|
||||
@@ -26,8 +26,8 @@ const loginOpenAICodexOAuthMock = vi.hoisted(() => vi.fn<LoginOpenAICodexOAuth>(
|
||||
const loginQwenPortalOAuthMock = vi.hoisted(() => vi.fn<LoginQwenPortalOAuth>());
|
||||
const githubCopilotLoginCommandMock = vi.hoisted(() => vi.fn<GithubCopilotLoginCommand>());
|
||||
|
||||
vi.mock("openclaw/plugin-sdk/provider-auth", async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import("openclaw/plugin-sdk/provider-auth")>();
|
||||
vi.mock("openclaw/plugin-sdk/provider-auth-login", async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import("openclaw/plugin-sdk/provider-auth-login")>();
|
||||
return {
|
||||
...actual,
|
||||
loginOpenAICodexOAuth: loginOpenAICodexOAuthMock,
|
||||
|
||||
Reference in New Issue
Block a user