drop inputs.defaultAgent

This commit is contained in:
David Blass
2025-11-21 15:40:47 -05:00
parent bef3f7794c
commit fda0de8dfe
5 changed files with 6 additions and 26 deletions
-9
View File
@@ -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
+1 -2
View File
@@ -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<void> {
@@ -22,7 +22,6 @@ async function run(): Promise<void> {
try {
const inputs: Required<Inputs> = {
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)])
),
+5 -13
View File
@@ -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<void> {
}
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<import("./agents/shared.ts").AgentResult> {
async function runAgent(ctx: MainContext): Promise<AgentResult> {
log.info(`Running ${ctx.agentName}...`);
log.box(ctx.payload.prompt, { title: "Prompt" });
@@ -269,9 +263,7 @@ async function runAgent(ctx: MainContext): Promise<import("./agents/shared.ts").
});
}
async function handleAgentResult(
result: import("./agents/shared.ts").AgentResult
): Promise<MainResult> {
async function handleAgentResult(result: AgentResult): Promise<MainResult> {
if (!result.success) {
return {
success: false,
-1
View File
@@ -27,7 +27,6 @@ export async function run(prompt: string): Promise<AgentResult> {
// we don't need to extract it here since main() will parse the payload
const inputs: Required<Inputs> = {
prompt,
defaultAgent: "gemini",
...flatMorph(agents, (_, agent) =>
agent.apiKeyNames.map((inputKey) => [inputKey, process.env[inputKey.toUpperCase()]])
),
-1
View File
@@ -1,5 +1,4 @@
import type { AgentName } from "../external.ts";
import { log } from "./cli.ts";
import type { RepoContext } from "./github.ts";
export interface Mode {