Compare commits

...

3 Commits

Author SHA1 Message Date
David Blass d03debab4b bump version 2025-10-14 15:56:27 -04:00
David Blass a05829f781 fix type errors 2025-10-14 14:58:46 -04:00
David Blass c8ba7940e3 fix installation token propagation 2025-10-13 17:21:14 -04:00
7 changed files with 23 additions and 30 deletions
-3
View File
@@ -10,9 +10,6 @@ inputs:
anthropic_api_key: anthropic_api_key:
description: "Anthropic API key for Claude Code authentication" description: "Anthropic API key for Claude Code authentication"
required: false required: false
github_installation_token:
description: "GitHub App installation token"
required: false
runs: runs:
using: "composite" using: "composite"
+4 -2
View File
@@ -10,6 +10,7 @@ import type { Agent, AgentConfig, AgentResult } from "./types.ts";
*/ */
export class ClaudeAgent implements Agent { export class ClaudeAgent implements Agent {
private apiKey: string; private apiKey: string;
private githubInstallationToken?: string;
public runStats = { public runStats = {
toolsUsed: 0, toolsUsed: 0,
turns: 0, turns: 0,
@@ -21,6 +22,7 @@ export class ClaudeAgent implements Agent {
throw new Error("Claude agent requires an API key"); throw new Error("Claude agent requires an API key");
} }
this.apiKey = config.apiKey; this.apiKey = config.apiKey;
this.githubInstallationToken = config.githubInstallationToken;
} }
/** /**
@@ -90,13 +92,13 @@ export class ClaudeAgent implements Agent {
"bypassPermissions", "bypassPermissions",
]; ];
if (!process.env.GITHUB_INSTALLATION_TOKEN) { if (!this.githubInstallationToken) {
throw new Error( throw new Error(
"GITHUB_INSTALLATION_TOKEN is required for GitHub integration" "GITHUB_INSTALLATION_TOKEN is required for GitHub integration"
); );
} }
const mcpConfig = createMcpConfig(process.env.GITHUB_INSTALLATION_TOKEN); const mcpConfig = createMcpConfig(this.githubInstallationToken);
console.log("📋 MCP Config:", mcpConfig); console.log("📋 MCP Config:", mcpConfig);
args.push("--mcp-config", mcpConfig); args.push("--mcp-config", mcpConfig);
+5 -9
View File
@@ -1,13 +1,9 @@
import type { MainParams } from "../main.ts"; import type { Inputs } from "../main.ts";
const testParams = { const testParams = {
inputs: { prompt:
prompt: "List all files in the current directory, then create a file called dynamic-test.txt with the content 'This was loaded from a TypeScript file!', then delete it.",
"List all files in the current directory, then create a file called dynamic-test.txt with the content 'This was loaded from a TypeScript file!', then delete it.", anthropic_api_key: "sk-test-key",
anthropic_api_key: "sk-test-key", } satisfies Inputs;
},
env: {},
cwd: process.cwd(),
} satisfies MainParams;
export default testParams; export default testParams;
+1 -1
View File
@@ -6,7 +6,7 @@
export { ClaudeAgent } from "./agents/claude.ts"; export { ClaudeAgent } from "./agents/claude.ts";
export type { Agent, AgentConfig, AgentResult } from "./agents/types.ts"; export type { Agent, AgentConfig, AgentResult } from "./agents/types.ts";
export { export {
type ActionInputs as ExecutionInputs, type Inputs as ExecutionInputs,
type MainResult, type MainResult,
main, main,
} from "./main.ts"; } from "./main.ts";
+10 -4
View File
@@ -1,14 +1,14 @@
import * as core from "@actions/core"; import * as core from "@actions/core";
import { type } from "arktype"; import { type } from "arktype";
import { ClaudeAgent } from "./agents/claude.ts"; import { ClaudeAgent } from "./agents/claude.ts";
import { setupGitHubInstallationToken } from "./utils/github.ts";
export const Inputs = type({ export const Inputs = type({
prompt: "string", prompt: "string",
"anthropic_api_key?": "string | undefined", "anthropic_api_key?": "string | undefined",
"github_installation_token?": "string | undefined",
}); });
export type ActionInputs = typeof Inputs.infer; export type Inputs = typeof Inputs.infer;
export interface MainResult { export interface MainResult {
success: boolean; success: boolean;
@@ -16,11 +16,17 @@ export interface MainResult {
error?: string | undefined; error?: string | undefined;
} }
export async function main(inputs: ActionInputs): Promise<MainResult> { export async function main(inputs: Inputs): Promise<MainResult> {
try { try {
core.info(`→ Starting agent run with Claude Code`); core.info(`→ Starting agent run with Claude Code`);
const agent = new ClaudeAgent({ apiKey: inputs.anthropic_api_key! }); // Setup GitHub installation token
const githubInstallationToken = await setupGitHubInstallationToken();
const agent = new ClaudeAgent({
apiKey: inputs.anthropic_api_key!,
githubInstallationToken,
});
await agent.install(); await agent.install();
const result = await agent.execute(inputs.prompt); const result = await agent.execute(inputs.prompt);
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@pullfrog/action", "name": "@pullfrog/action",
"version": "0.0.45", "version": "0.0.47",
"type": "module", "type": "module",
"files": [ "files": [
"index.js", "index.js",
+2 -10
View File
@@ -4,10 +4,9 @@ import { pathToFileURL } from "node:url";
import { fromHere } from "@ark/fs"; import { fromHere } from "@ark/fs";
import arg from "arg"; import arg from "arg";
import { config } from "dotenv"; import { config } from "dotenv";
import { type ActionInputs, main } from "./main.ts"; import { type Inputs, main } from "./main.ts";
import packageJson from "./package.json" with { type: "json" }; import packageJson from "./package.json" with { type: "json" };
import { runAct } from "./utils/act.ts"; import { runAct } from "./utils/act.ts";
import { setupGitHubInstallationToken } from "./utils/github.ts";
import { setupTestRepo } from "./utils/setup.ts"; import { setupTestRepo } from "./utils/setup.ts";
config(); config();
@@ -36,16 +35,9 @@ export async function run(
console.log(prompt); console.log(prompt);
console.log("─".repeat(50)); console.log("─".repeat(50));
console.log("🔑 Setting up GitHub installation token..."); const inputs: Inputs = {
const installationToken = await setupGitHubInstallationToken();
process.env.GITHUB_INSTALLATION_TOKEN = installationToken;
console.log("✅ GitHub installation token setup successfully");
const inputs: ActionInputs = {
prompt, prompt,
anthropic_api_key: process.env.ANTHROPIC_API_KEY, anthropic_api_key: process.env.ANTHROPIC_API_KEY,
github_installation_token: installationToken,
}; };
const result = await main(inputs); const result = await main(inputs);