Files
shockbot/main.ts
T
Colin McDonnell 7d633da1be refactor: complete action testing system overhaul
- Removed /scratch directory, now cloning pullfrogai/scratch as needed
- Implemented new play.ts testing system with local and Docker/act modes
- Added environment variable propagation to cloned test repositories
- Created minimal .act-dist approach to avoid pnpm symlink issues with Docker
- Migrated from dist/index.js to entry.cjs bundled output
- Added TypeScript fixture support with MainParams type safety
- Organized all test fixtures in fixtures/ directory
- Updated publish workflow to trigger on package.json changes
- Removed unnecessary INPUT_ANTHROPIC_API_KEY references
- Added comprehensive documentation for new testing system
- Fixed pre-commit hook to use entry.cjs instead of dist/
2025-09-09 16:20:00 -07:00

55 lines
1.3 KiB
TypeScript

import * as core from "@actions/core";
import { ClaudeAgent } from "./agents";
export interface MainParams {
prompt: string;
anthropicApiKey?: string;
}
export interface MainResult {
success: boolean;
output?: string;
error?: string;
}
export async function main(params: MainParams): Promise<MainResult> {
try {
// Use provided API key or fall back to environment variable
const anthropicApiKey =
params.anthropicApiKey || process.env.ANTHROPIC_API_KEY;
if (!anthropicApiKey) {
throw new Error("anthropic_api_key is required");
}
core.info(`→ Starting agent run with Claude Code`);
// Create and install the Claude agent
const agent = new ClaudeAgent({ apiKey: anthropicApiKey });
await agent.install();
// Execute the agent with the prompt
const result = await agent.execute(params.prompt);
if (!result.success) {
return {
success: false,
error: result.error || "Agent execution failed",
output: result.output,
};
}
return {
success: true,
output: result.output || "",
};
} catch (error) {
const errorMessage =
error instanceof Error ? error.message : "Unknown error occurred";
return {
success: false,
error: errorMessage,
};
}
}