Switch to payload

This commit is contained in:
Colin McDonnell
2025-11-18 23:15:44 -08:00
parent 3ef1635bb6
commit 06a19567c0
13 changed files with 614 additions and 410 deletions
+2 -2
View File
@@ -15,11 +15,11 @@ export const claude = agent({
executablePath: "cli.js",
});
},
run: async ({ prompt, mcpServers, apiKey, cliPath }) => {
run: async ({ payload, mcpServers, apiKey, cliPath }) => {
process.env.ANTHROPIC_API_KEY = apiKey;
const queryInstance = query({
prompt: addInstructions(prompt),
prompt: addInstructions(payload),
options: {
permissionMode: "bypassPermissions",
mcpServers,
+2 -2
View File
@@ -14,7 +14,7 @@ export const codex = agent({
executablePath: "bin/codex.js",
});
},
run: async ({ prompt, mcpServers, apiKey, cliPath, githubInstallationToken }) => {
run: async ({ payload, mcpServers, apiKey, cliPath, githubInstallationToken }) => {
process.env.OPENAI_API_KEY = apiKey;
process.env.GITHUB_INSTALLATION_TOKEN = githubInstallationToken;
@@ -39,7 +39,7 @@ export const codex = agent({
try {
// Use runStreamed to get streaming events similar to claude.ts
const streamedTurn = await thread.runStreamed(addInstructions(prompt));
const streamedTurn = await thread.runStreamed(addInstructions(payload));
// Stream events and handle them
let finalOutput = "";
+2 -2
View File
@@ -14,7 +14,7 @@ export const cursor = agent({
executableName: "cursor-agent",
});
},
run: async ({ prompt, apiKey, cliPath, githubInstallationToken, mcpServers }) => {
run: async ({ payload, apiKey, cliPath, githubInstallationToken, mcpServers }) => {
process.env.CURSOR_API_KEY = apiKey;
process.env.GITHUB_INSTALLATION_TOKEN = githubInstallationToken;
@@ -24,7 +24,7 @@ export const cursor = agent({
// Run cursor-agent in non-interactive mode with the prompt
// Using -p flag for prompt, --output-format text for plain text output
// and --approve-mcps to automatically approve all MCP servers
const fullPrompt = addInstructions(prompt);
const fullPrompt = addInstructions(payload);
// Find temp directory from cliPath to set HOME for MCP config lookup
const tempDir = cliPath.split("/.local/bin/")[0];
+3 -3
View File
@@ -15,7 +15,7 @@ export const gemini = agent({
installDependencies: true,
});
},
run: async ({ prompt, apiKey, mcpServers, githubInstallationToken, cliPath }) => {
run: async ({ payload, apiKey, mcpServers, githubInstallationToken, cliPath }) => {
configureGeminiMcpServers({ mcpServers, cliPath });
if (!apiKey) {
throw new Error("google_api_key or gemini_api_key is required for gemini agent");
@@ -25,8 +25,8 @@ export const gemini = agent({
process.env.GEMINI_API_KEY = apiKey;
process.env.GITHUB_INSTALLATION_TOKEN = githubInstallationToken;
const sessionPrompt = addInstructions(prompt);
log.info(`Starting Gemini CLI with prompt: ${prompt.substring(0, 100)}...`);
const sessionPrompt = addInstructions(payload);
log.info(`Starting Gemini CLI with prompt: ${payload.prompt.substring(0, 100)}...`);
let finalOutput = "";
try {
+12 -8
View File
@@ -1,13 +1,15 @@
import { ghPullfrogMcpName } from "../mcp/index.ts";
import { modes } from "../modes.ts";
import type { Payload } from "../payload.ts";
const userPromptHeader = `****** USER PROMPT ******\n`;
// const userPromptHeader = `************* USER PROMPT *************\n`;
export const instructions = `
export const addInstructions = (payload: Payload) =>
`************* GENERAL INSTRUCTIONS *************
# General instructions
You are a diligent, detail-oriented, no-nonsense software engineering agent.
You will perform the task that is asked of you below ${userPromptHeader}.
You will perform the task described in the *USER PROMPT* below.
You are careful, to-the-point, and kind. You only say things you know to be true.
You have an extreme bias toward minimalism in your code and responses.
Your code is focused, elegant, and production-ready.
@@ -48,12 +50,14 @@ Ensure after your edits are done, your final comments do not contain intermediat
choose the appropriate mode based on the prompt payload:
${modes.map((w) => ` - "${w.name}": ${w.description}`).join("\n")}
${[...modes, ...payload.modes].map((w) => ` - "${w.name}": ${w.description}`).join("\n")}
## Modes
${modes.map((w) => `### ${w.name}\n\n${w.prompt}`).join("\n\n")}
`;
${[...modes, ...payload.modes].map((w) => `### ${w.name}\n\n${w.prompt}`).join("\n\n")}
export const addInstructions = (prompt: string) =>
`****** GENERAL INSTRUCTIONS ******\n${instructions}\n\n${userPromptHeader}${prompt}`;
************* USER PROMPT *************
${payload.prompt}
${payload.event}`;
+2 -1
View File
@@ -5,6 +5,7 @@ import { tmpdir } from "node:os";
import { join } from "node:path";
import { pipeline } from "node:stream/promises";
import type { McpStdioServerConfig } from "@anthropic-ai/claude-agent-sdk";
import type { Payload } from "../payload.ts";
import { log } from "../utils/cli.ts";
/**
@@ -23,7 +24,7 @@ export interface AgentResult {
export interface AgentConfig {
apiKey: string;
githubInstallationToken: string;
prompt: string;
payload: Payload;
mcpServers: Record<string, McpStdioServerConfig>;
cliPath: string;
}