File size: 2,440 Bytes
eb3f11e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | /**
* Shared contract fixtures for agent auth profile runtime behavior.
*/
import {
resolveProviderIdForAuth,
type ProviderAuthAliasLookupParams,
} from "../../../agents/provider-auth-aliases.js";
import type { PluginManifestRegistry } from "../../../plugins/manifest-registry.js";
export const AUTH_PROFILE_RUNTIME_CONTRACT = {
sessionId: "session-auth-contract",
sessionKey: "agent:main:auth-contract",
runId: "run-auth-contract",
workspacePrompt: "continue with the bound Codex profile",
openAiProvider: "openai",
openAiCodexProvider: "openai",
codexCliProvider: "codex-cli",
codexHarnessProvider: "codex",
claudeCliProvider: "claude-cli",
openAiProfileId: "openai:work",
openAiCodexProfileId: "openai:work",
anthropicProfileId: "anthropic:work",
} as const;
export function createAuthAliasManifestRegistry(): PluginManifestRegistry {
return {
plugins: [
{
id: "openai",
origin: "bundled",
channels: [],
providers: [],
cliBackends: [],
skills: [],
hooks: [],
rootDir: "/tmp/openclaw-auth-contract-plugin",
source: "test",
manifestPath: "/tmp/openclaw-auth-contract-plugin/plugin.json",
providerAuthAliases: {
[AUTH_PROFILE_RUNTIME_CONTRACT.openAiCodexProvider]:
AUTH_PROFILE_RUNTIME_CONTRACT.openAiProvider,
[AUTH_PROFILE_RUNTIME_CONTRACT.codexCliProvider]:
AUTH_PROFILE_RUNTIME_CONTRACT.openAiProvider,
},
providerAuthChoices: [
{
provider: AUTH_PROFILE_RUNTIME_CONTRACT.openAiProvider,
method: "oauth",
choiceId: AUTH_PROFILE_RUNTIME_CONTRACT.openAiProvider,
deprecatedChoiceIds: [
AUTH_PROFILE_RUNTIME_CONTRACT.openAiCodexProvider,
AUTH_PROFILE_RUNTIME_CONTRACT.codexCliProvider,
],
},
],
},
],
diagnostics: [],
};
}
export function expectedForwardedAuthProfile(params: {
provider: string;
authProfileProvider: string;
aliasLookupParams: ProviderAuthAliasLookupParams;
sessionAuthProfileId: string | undefined;
}): string | undefined {
return resolveProviderIdForAuth(params.provider, params.aliasLookupParams) ===
resolveProviderIdForAuth(params.authProfileProvider, {
...params.aliasLookupParams,
storedCredential: true,
})
? params.sessionAuthProfileId
: undefined;
}
|