replace execSync cases with spawnSync, use correct package @openai/codex
This commit is contained in:
+5
-5
@@ -8,9 +8,9 @@ export const codex = agent({
|
||||
inputKey: "openai_api_key",
|
||||
install: async () => {
|
||||
return await installFromNpmTarball({
|
||||
packageName: "codex",
|
||||
packageName: "@openai/codex",
|
||||
version: "latest",
|
||||
executablePath: "bin/codex",
|
||||
executablePath: "bin/codex.js",
|
||||
installDependencies: true,
|
||||
});
|
||||
},
|
||||
@@ -43,8 +43,8 @@ export const codex = agent({
|
||||
}
|
||||
|
||||
log.info(`Adding MCP server '${serverName}'...`);
|
||||
const addResult = spawnSync(cliPath, addArgs, {
|
||||
stdio: "inherit",
|
||||
const addResult = spawnSync("node", [cliPath, ...addArgs], {
|
||||
stdio: "pipe",
|
||||
encoding: "utf-8",
|
||||
env: {
|
||||
...process.env,
|
||||
@@ -70,7 +70,7 @@ export const codex = agent({
|
||||
log.info("Running Codex via CLI...");
|
||||
|
||||
try {
|
||||
const result = spawnSync(cliPath, ["exec", addInstructions(prompt)], {
|
||||
const result = spawnSync("node", [cliPath, "exec", addInstructions(prompt)], {
|
||||
encoding: "utf-8",
|
||||
env: {
|
||||
...process.env,
|
||||
|
||||
+20
-3
@@ -1,4 +1,4 @@
|
||||
import { execSync } from "node:child_process";
|
||||
import { spawnSync } from "node:child_process";
|
||||
import { createWriteStream, existsSync } from "node:fs";
|
||||
import { mkdtemp } from "node:fs/promises";
|
||||
import { tmpdir } from "node:os";
|
||||
@@ -105,7 +105,15 @@ export async function installFromNpmTarball({
|
||||
|
||||
// Extract tarball
|
||||
log.info(`Extracting tarball...`);
|
||||
execSync(`tar -xzf "${tarballPath}" -C "${tempDir}"`, { stdio: "pipe" });
|
||||
const extractResult = spawnSync("tar", ["-xzf", tarballPath, "-C", tempDir], {
|
||||
stdio: "pipe",
|
||||
encoding: "utf-8",
|
||||
});
|
||||
if (extractResult.status !== 0) {
|
||||
throw new Error(
|
||||
`Failed to extract tarball: ${extractResult.stderr || extractResult.stdout || "Unknown error"}`
|
||||
);
|
||||
}
|
||||
|
||||
// Find executable in the extracted package
|
||||
const extractedDir = join(tempDir, "package");
|
||||
@@ -120,7 +128,16 @@ export async function installFromNpmTarball({
|
||||
const packageJsonPath = join(extractedDir, "package.json");
|
||||
if (existsSync(packageJsonPath)) {
|
||||
log.info(`Installing dependencies for ${packageName}...`);
|
||||
execSync(`npm install --production`, { cwd: extractedDir, stdio: "pipe" });
|
||||
const installResult = spawnSync("npm", ["install", "--production"], {
|
||||
cwd: extractedDir,
|
||||
stdio: "pipe",
|
||||
encoding: "utf-8",
|
||||
});
|
||||
if (installResult.status !== 0) {
|
||||
throw new Error(
|
||||
`Failed to install dependencies: ${installResult.stderr || installResult.stdout || "Unknown error"}`
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28177,7 +28177,7 @@ var schema = ark.schema;
|
||||
var define2 = ark.define;
|
||||
var declare = ark.declare;
|
||||
|
||||
// ../node_modules/.pnpm/@anthropic-ai+claude-agent-sdk@0.1.26_zod@4.1.12/node_modules/@anthropic-ai/claude-agent-sdk/sdk.mjs
|
||||
// ../node_modules/.pnpm/@anthropic-ai+claude-agent-sdk@0.1.26_zod@3.25.76/node_modules/@anthropic-ai/claude-agent-sdk/sdk.mjs
|
||||
import { join as join3 } from "path";
|
||||
import { fileURLToPath } from "url";
|
||||
import { setMaxListeners } from "events";
|
||||
@@ -40718,7 +40718,7 @@ var log = {
|
||||
};
|
||||
|
||||
// agents/shared.ts
|
||||
import { execSync } from "node:child_process";
|
||||
import { spawnSync } from "node:child_process";
|
||||
import { createWriteStream as createWriteStream2, existsSync as existsSync2 } from "node:fs";
|
||||
import { mkdtemp } from "node:fs/promises";
|
||||
import { tmpdir } from "node:os";
|
||||
@@ -41183,7 +41183,15 @@ async function installFromNpmTarball({
|
||||
await pipeline(response.body, fileStream);
|
||||
log.info(`Downloaded tarball to ${tarballPath}`);
|
||||
log.info(`Extracting tarball...`);
|
||||
execSync(`tar -xzf "${tarballPath}" -C "${tempDir}"`, { stdio: "pipe" });
|
||||
const extractResult = spawnSync("tar", ["-xzf", tarballPath, "-C", tempDir], {
|
||||
stdio: "pipe",
|
||||
encoding: "utf-8"
|
||||
});
|
||||
if (extractResult.status !== 0) {
|
||||
throw new Error(
|
||||
`Failed to extract tarball: ${extractResult.stderr || extractResult.stdout || "Unknown error"}`
|
||||
);
|
||||
}
|
||||
const extractedDir = join5(tempDir, "package");
|
||||
const cliPath = join5(extractedDir, executablePath);
|
||||
if (!existsSync2(cliPath)) {
|
||||
@@ -41193,7 +41201,16 @@ async function installFromNpmTarball({
|
||||
const packageJsonPath = join5(extractedDir, "package.json");
|
||||
if (existsSync2(packageJsonPath)) {
|
||||
log.info(`Installing dependencies for ${packageName}...`);
|
||||
execSync(`npm install --production`, { cwd: extractedDir, stdio: "pipe" });
|
||||
const installResult = spawnSync("npm", ["install", "--production"], {
|
||||
cwd: extractedDir,
|
||||
stdio: "pipe",
|
||||
encoding: "utf-8"
|
||||
});
|
||||
if (installResult.status !== 0) {
|
||||
throw new Error(
|
||||
`Failed to install dependencies: ${installResult.stderr || installResult.stdout || "Unknown error"}`
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
log.info(`\u2713 ${packageName} installed at ${cliPath}`);
|
||||
@@ -41377,15 +41394,15 @@ var messageHandlers = {
|
||||
};
|
||||
|
||||
// agents/codex.ts
|
||||
import { spawnSync } from "node:child_process";
|
||||
import { spawnSync as spawnSync2 } from "node:child_process";
|
||||
var codex = agent({
|
||||
name: "codex",
|
||||
inputKey: "openai_api_key",
|
||||
install: async () => {
|
||||
return await installFromNpmTarball({
|
||||
packageName: "codex",
|
||||
packageName: "@openai/codex",
|
||||
version: "latest",
|
||||
executablePath: "bin/codex",
|
||||
executablePath: "bin/codex.js",
|
||||
installDependencies: true
|
||||
});
|
||||
},
|
||||
@@ -41407,8 +41424,8 @@ var codex = agent({
|
||||
addArgs.push("--env", `${key}=${value2}`);
|
||||
}
|
||||
log.info(`Adding MCP server '${serverName}'...`);
|
||||
const addResult = spawnSync(cliPath, addArgs, {
|
||||
stdio: "inherit",
|
||||
const addResult = spawnSync2("node", [cliPath, ...addArgs], {
|
||||
stdio: "pipe",
|
||||
encoding: "utf-8",
|
||||
env: {
|
||||
...process.env,
|
||||
@@ -41430,7 +41447,7 @@ var codex = agent({
|
||||
}
|
||||
log.info("Running Codex via CLI...");
|
||||
try {
|
||||
const result = spawnSync(cliPath, ["exec", addInstructions(prompt)], {
|
||||
const result = spawnSync2("node", [cliPath, "exec", addInstructions(prompt)], {
|
||||
encoding: "utf-8",
|
||||
env: {
|
||||
...process.env,
|
||||
@@ -41522,15 +41539,15 @@ async function getRepoSettings(token, repoContext) {
|
||||
}
|
||||
|
||||
// utils/setup.ts
|
||||
import { execSync as execSync2 } from "node:child_process";
|
||||
import { execSync } from "node:child_process";
|
||||
function setupGitConfig() {
|
||||
if (!process.env.GITHUB_ACTIONS) {
|
||||
return;
|
||||
}
|
||||
log.info("\u{1F527} Setting up git configuration...");
|
||||
try {
|
||||
execSync2('git config user.email "action@pullfrog.ai"', { stdio: "pipe" });
|
||||
execSync2('git config user.name "Pullfrog Action"', { stdio: "pipe" });
|
||||
execSync('git config user.email "action@pullfrog.ai"', { stdio: "pipe" });
|
||||
execSync('git config user.name "Pullfrog Action"', { stdio: "pipe" });
|
||||
log.debug("setupGitConfig: \u2713 Git configuration set successfully");
|
||||
} catch (error2) {
|
||||
log.warning(
|
||||
@@ -41544,13 +41561,13 @@ function setupGitAuth(githubToken, repoContext) {
|
||||
}
|
||||
log.info("\u{1F510} Setting up git authentication...");
|
||||
try {
|
||||
execSync2("git config --unset-all http.https://github.com/.extraheader", { stdio: "inherit" });
|
||||
execSync("git config --unset-all http.https://github.com/.extraheader", { stdio: "inherit" });
|
||||
log.info("\u2713 Removed existing authentication headers");
|
||||
} catch {
|
||||
log.info("No existing authentication headers to remove");
|
||||
}
|
||||
const remoteUrl = `https://x-access-token:${githubToken}@github.com/${repoContext.owner}/${repoContext.name}.git`;
|
||||
execSync2(`git remote set-url origin "${remoteUrl}"`, { stdio: "inherit" });
|
||||
execSync(`git remote set-url origin "${remoteUrl}"`, { stdio: "inherit" });
|
||||
log.info("\u2713 Updated remote URL with authentication token");
|
||||
}
|
||||
|
||||
|
||||
+5909
-6765
File diff suppressed because it is too large
Load Diff
@@ -85,58 +85,53 @@ Examples:
|
||||
if (args["--raw"]) {
|
||||
prompt = args["--raw"];
|
||||
} else {
|
||||
// Default to testing tool calls if no file specified
|
||||
const filePath = args._[0] || null;
|
||||
if (!filePath) {
|
||||
prompt =
|
||||
"List all available MCP tools from the gh-pullfrog server and show what each tool does.";
|
||||
const filePath = args._[0] || "basic.txt";
|
||||
|
||||
const ext = extname(filePath).toLowerCase();
|
||||
let resolvedPath: string;
|
||||
|
||||
const fixturesPath = fromHere("fixtures", filePath);
|
||||
if (existsSync(fixturesPath)) {
|
||||
resolvedPath = fixturesPath;
|
||||
} else if (existsSync(filePath)) {
|
||||
resolvedPath = resolve(filePath);
|
||||
} else {
|
||||
const ext = extname(filePath).toLowerCase();
|
||||
let resolvedPath: string;
|
||||
throw new Error(`File not found: ${filePath}`);
|
||||
}
|
||||
|
||||
const fixturesPath = fromHere("fixtures", filePath);
|
||||
if (existsSync(fixturesPath)) {
|
||||
resolvedPath = fixturesPath;
|
||||
} else if (existsSync(filePath)) {
|
||||
resolvedPath = resolve(filePath);
|
||||
} else {
|
||||
throw new Error(`File not found: ${filePath}`);
|
||||
switch (ext) {
|
||||
case ".txt": {
|
||||
prompt = readFileSync(resolvedPath, "utf8").trim();
|
||||
break;
|
||||
}
|
||||
|
||||
switch (ext) {
|
||||
case ".txt": {
|
||||
prompt = readFileSync(resolvedPath, "utf8").trim();
|
||||
break;
|
||||
}
|
||||
|
||||
case ".json": {
|
||||
const content = readFileSync(resolvedPath, "utf8");
|
||||
const parsed = JSON.parse(content);
|
||||
prompt = JSON.stringify(parsed, null, 2);
|
||||
break;
|
||||
}
|
||||
|
||||
case ".ts": {
|
||||
const fileUrl = pathToFileURL(resolvedPath).href;
|
||||
const module = await import(fileUrl);
|
||||
|
||||
if (!module.default) {
|
||||
throw new Error(`TypeScript file ${filePath} must have a default export`);
|
||||
}
|
||||
|
||||
if (typeof module.default === "string") {
|
||||
prompt = module.default;
|
||||
} else if (typeof module.default === "object" && module.default.prompt) {
|
||||
prompt = module.default.prompt;
|
||||
} else {
|
||||
prompt = JSON.stringify(module.default, null, 2);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
throw new Error(`Unsupported file type: ${ext}. Supported types: .txt, .json, .ts`);
|
||||
case ".json": {
|
||||
const content = readFileSync(resolvedPath, "utf8");
|
||||
const parsed = JSON.parse(content);
|
||||
prompt = JSON.stringify(parsed, null, 2);
|
||||
break;
|
||||
}
|
||||
|
||||
case ".ts": {
|
||||
const fileUrl = pathToFileURL(resolvedPath).href;
|
||||
const module = await import(fileUrl);
|
||||
|
||||
if (!module.default) {
|
||||
throw new Error(`TypeScript file ${filePath} must have a default export`);
|
||||
}
|
||||
|
||||
if (typeof module.default === "string") {
|
||||
prompt = module.default;
|
||||
} else if (typeof module.default === "object" && module.default.prompt) {
|
||||
prompt = module.default.prompt;
|
||||
} else {
|
||||
prompt = JSON.stringify(module.default, null, 2);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
throw new Error(`Unsupported file type: ${ext}. Supported types: .txt, .json, .ts`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user