77import { SeverityThresholdSchema } from '../types/index.js' ;
88import type { SeverityThreshold } from '../types/index.js' ;
99import { DEFAULT_CONCURRENCY } from '../utils/index.js' ;
10+ import type { Provider } from '../config/schema.js' ;
1011
1112// -----------------------------------------------------------------------------
1213// Types
1314// -----------------------------------------------------------------------------
1415
1516export interface ActionInputs {
17+ /** Optional provider override (defaults to config/env) */
18+ provider ?: Provider ;
1619 /** API key for Anthropic API (empty if using OAuth) */
1720 anthropicApiKey : string ;
21+ /** API key for Pi provider */
22+ piApiKey ?: string ;
1823 /** OAuth token for Claude Code (empty if using API key) */
1924 oauthToken : string ;
2025 githubToken : string ;
@@ -58,31 +63,32 @@ function parseBooleanInput(value: string): boolean | undefined {
5863 return undefined ;
5964}
6065
66+ function parseProviderInput ( value : string ) : Provider | undefined {
67+ return value === 'claude' || value === 'pi' ? value : undefined ;
68+ }
69+
6170/**
6271 * Parse action inputs from the GitHub Actions environment.
6372 * Throws if required inputs are missing.
6473 */
6574export function parseActionInputs ( ) : ActionInputs {
66- // Check for auth token: supports both API keys and OAuth tokens
75+ const providerInput = getInput ( 'provider' ) || process . env [ 'WARDEN_PROVIDER' ] || '' ;
76+ const provider = parseProviderInput ( providerInput ) ;
77+
78+ // Claude auth token: supports both API keys and OAuth tokens
6779 // Priority: input > WARDEN_ANTHROPIC_API_KEY > ANTHROPIC_API_KEY > CLAUDE_CODE_OAUTH_TOKEN
68- const authToken =
80+ const claudeAuthToken =
6981 getInput ( 'anthropic-api-key' ) ||
7082 process . env [ 'WARDEN_ANTHROPIC_API_KEY' ] ||
7183 process . env [ 'ANTHROPIC_API_KEY' ] ||
7284 process . env [ 'CLAUDE_CODE_OAUTH_TOKEN' ] ||
7385 '' ;
7486
75- if ( ! authToken ) {
76- throw new Error (
77- 'Authentication not found. Provide an API key via anthropic-api-key input, ' +
78- 'ANTHROPIC_API_KEY env var, or OAuth token via CLAUDE_CODE_OAUTH_TOKEN env var.'
79- ) ;
80- }
81-
8287 // Detect token type: OAuth tokens start with 'sk-ant-oat', API keys are other 'sk-ant-' prefixes
83- const isOAuthToken = authToken . startsWith ( 'sk-ant-oat' ) ;
84- const anthropicApiKey = isOAuthToken ? '' : authToken ;
85- const oauthToken = isOAuthToken ? authToken : '' ;
88+ const isOAuthToken = claudeAuthToken . startsWith ( 'sk-ant-oat' ) ;
89+ const anthropicApiKey = isOAuthToken ? '' : claudeAuthToken ;
90+ const oauthToken = isOAuthToken ? claudeAuthToken : '' ;
91+ const piApiKey = process . env [ 'WARDEN_PI_API_KEY' ] || '' ;
8692
8793 const failOnInput = getInput ( 'fail-on' ) ;
8894 const failOn = SeverityThresholdSchema . safeParse ( failOnInput ) . success
@@ -101,7 +107,9 @@ export function parseActionInputs(): ActionInputs {
101107 const failCheck = parseBooleanInput ( getInput ( 'fail-check' ) ) ;
102108
103109 return {
110+ provider,
104111 anthropicApiKey,
112+ piApiKey,
105113 oauthToken,
106114 githubToken : getInput ( 'github-token' ) || process . env [ 'GITHUB_TOKEN' ] || '' ,
107115 configPath : getInput ( 'config-path' ) || 'warden.toml' ,
@@ -129,10 +137,18 @@ export function validateInputs(inputs: ActionInputs): void {
129137 * Sets appropriate env vars based on token type (API key vs OAuth).
130138 */
131139export function setupAuthEnv ( inputs : ActionInputs ) : void {
140+ if ( inputs . provider ) {
141+ process . env [ 'WARDEN_PROVIDER' ] = inputs . provider ;
142+ }
143+ if ( inputs . piApiKey ) {
144+ process . env [ 'WARDEN_PI_API_KEY' ] = inputs . piApiKey ;
145+ }
132146 if ( inputs . oauthToken ) {
133147 process . env [ 'CLAUDE_CODE_OAUTH_TOKEN' ] = inputs . oauthToken ;
134148 } else {
135- process . env [ 'WARDEN_ANTHROPIC_API_KEY' ] = inputs . anthropicApiKey ;
136- process . env [ 'ANTHROPIC_API_KEY' ] = inputs . anthropicApiKey ;
149+ if ( inputs . anthropicApiKey ) {
150+ process . env [ 'WARDEN_ANTHROPIC_API_KEY' ] = inputs . anthropicApiKey ;
151+ process . env [ 'ANTHROPIC_API_KEY' ] = inputs . anthropicApiKey ;
152+ }
137153 }
138154}
0 commit comments