Compare commits

...

1 Commits

Author SHA1 Message Date
David Blass c8ba7940e3 fix installation token propagation 2025-10-13 17:21:14 -04:00
5 changed files with 13 additions and 16 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);
+8 -2
View File
@@ -1,11 +1,11 @@
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 ActionInputs = typeof Inputs.infer;
@@ -20,7 +20,13 @@ export async function main(inputs: ActionInputs): 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.46",
"type": "module", "type": "module",
"files": [ "files": [
"index.js", "index.js",
-8
View File
@@ -7,7 +7,6 @@ import { config } from "dotenv";
import { type ActionInputs, main } from "./main.ts"; import { type ActionInputs, 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 installationToken = await setupGitHubInstallationToken();
process.env.GITHUB_INSTALLATION_TOKEN = installationToken;
console.log("✅ GitHub installation token setup successfully");
const inputs: ActionInputs = { 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);