diff --git a/action.yml b/action.yml index 5b33ef3..128f5db 100644 --- a/action.yml +++ b/action.yml @@ -7,15 +7,6 @@ inputs: description: "Prompt to send to Claude Code" required: true default: "Hello from Claude Code!" - defaultAgent: - description: "Default agent to use. Overridden by payload.agent if present." - required: false - type: choice - options: - - claude - - codex - - cursor - - gemini anthropic_api_key: description: "Anthropic API key for Claude Code authentication" required: false diff --git a/entry.ts b/entry.ts index 6f9d77c..74d3667 100644 --- a/entry.ts +++ b/entry.ts @@ -7,7 +7,7 @@ import * as core from "@actions/core"; import { flatMorph } from "@ark/util"; import { agents } from "./agents/index.ts"; -import { AgentName, type Inputs, main } from "./main.ts"; +import { type Inputs, main } from "./main.ts"; import { log } from "./utils/cli.ts"; async function run(): Promise { @@ -22,7 +22,6 @@ async function run(): Promise { try { const inputs: Required = { prompt: core.getInput("prompt", { required: true }), - defaultAgent: core.getInput("defaultAgent") ? AgentName.assert(core.getInput("defaultAgent")) : undefined, ...flatMorph(agents, (_, agent) => agent.apiKeyNames.map((inputKey) => [inputKey, core.getInput(inputKey)]) ), diff --git a/main.ts b/main.ts index 365047b..2cbae6f 100644 --- a/main.ts +++ b/main.ts @@ -5,6 +5,7 @@ import { join } from "node:path"; import { flatMorph } from "@ark/util"; import { type } from "arktype"; import { agents } from "./agents/index.ts"; +import type { AgentResult } from "./agents/shared.ts"; import type { AgentName, AgentName as AgentNameType, Payload } from "./external.ts"; import { createMcpConfigs } from "./mcp/config.ts"; import { modes } from "./modes.ts"; @@ -35,9 +36,6 @@ const keyInputDefs = flatMorph(agents, (_, agent) => export const Inputs = type({ prompt: "string", ...keyInputDefs, - "defaultAgent?": type - .enumerated(...Object.values(agents).map((agent) => agent.name)) - .or("undefined"), }); export type Inputs = typeof Inputs.infer; @@ -177,11 +175,9 @@ async function determineAgent( repoContext: ctx.repoContext, }); - // precedence: override agent > payload.agent > inputs.defaultAgent > repoSettings.defaultAgent > "claude" ctx.agentName = (process.env.NODE_ENV === "development" && AGENT_OVERRIDE) || ctx.payload.agent || - ctx.inputs.defaultAgent || repoSettings.defaultAgent || "claude"; // TODO: look at env vars ctx.agent = agents[ctx.agentName]; @@ -242,9 +238,7 @@ async function installAgentCli(ctx: MainContext): Promise { } function validateApiKey(ctx: MainContext): void { - const matchingInputKey = ctx.agent.apiKeyNames.find( - (inputKey: string) => ctx.inputs[inputKey as AgentInputKey] - ); + const matchingInputKey = ctx.agent.apiKeyNames.find((inputKey) => ctx.inputs[inputKey]); if (!matchingInputKey) { throwMissingApiKeyError({ agentName: ctx.agentName, @@ -253,10 +247,10 @@ function validateApiKey(ctx: MainContext): void { inputs: ctx.inputs, }); } - ctx.apiKey = ctx.inputs[matchingInputKey as AgentInputKey]!; + ctx.apiKey = ctx.inputs[matchingInputKey]!; } -async function runAgent(ctx: MainContext): Promise { +async function runAgent(ctx: MainContext): Promise { log.info(`Running ${ctx.agentName}...`); log.box(ctx.payload.prompt, { title: "Prompt" }); @@ -269,9 +263,7 @@ async function runAgent(ctx: MainContext): Promise { +async function handleAgentResult(result: AgentResult): Promise { if (!result.success) { return { success: false, diff --git a/play.ts b/play.ts index da8dbad..5dd600f 100644 --- a/play.ts +++ b/play.ts @@ -27,7 +27,6 @@ export async function run(prompt: string): Promise { // we don't need to extract it here since main() will parse the payload const inputs: Required = { prompt, - defaultAgent: "gemini", ...flatMorph(agents, (_, agent) => agent.apiKeyNames.map((inputKey) => [inputKey, process.env[inputKey.toUpperCase()]]) ), diff --git a/utils/api.ts b/utils/api.ts index cd6c7ff..7cfc4c7 100644 --- a/utils/api.ts +++ b/utils/api.ts @@ -1,5 +1,4 @@ import type { AgentName } from "../external.ts"; -import { log } from "./cli.ts"; import type { RepoContext } from "./github.ts"; export interface Mode {