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",
|
inputKey: "openai_api_key",
|
||||||
install: async () => {
|
install: async () => {
|
||||||
return await installFromNpmTarball({
|
return await installFromNpmTarball({
|
||||||
packageName: "codex",
|
packageName: "@openai/codex",
|
||||||
version: "latest",
|
version: "latest",
|
||||||
executablePath: "bin/codex",
|
executablePath: "bin/codex.js",
|
||||||
installDependencies: true,
|
installDependencies: true,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -43,8 +43,8 @@ export const codex = agent({
|
|||||||
}
|
}
|
||||||
|
|
||||||
log.info(`Adding MCP server '${serverName}'...`);
|
log.info(`Adding MCP server '${serverName}'...`);
|
||||||
const addResult = spawnSync(cliPath, addArgs, {
|
const addResult = spawnSync("node", [cliPath, ...addArgs], {
|
||||||
stdio: "inherit",
|
stdio: "pipe",
|
||||||
encoding: "utf-8",
|
encoding: "utf-8",
|
||||||
env: {
|
env: {
|
||||||
...process.env,
|
...process.env,
|
||||||
@@ -70,7 +70,7 @@ export const codex = agent({
|
|||||||
log.info("Running Codex via CLI...");
|
log.info("Running Codex via CLI...");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const result = spawnSync(cliPath, ["exec", addInstructions(prompt)], {
|
const result = spawnSync("node", [cliPath, "exec", addInstructions(prompt)], {
|
||||||
encoding: "utf-8",
|
encoding: "utf-8",
|
||||||
env: {
|
env: {
|
||||||
...process.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 { createWriteStream, existsSync } from "node:fs";
|
||||||
import { mkdtemp } from "node:fs/promises";
|
import { mkdtemp } from "node:fs/promises";
|
||||||
import { tmpdir } from "node:os";
|
import { tmpdir } from "node:os";
|
||||||
@@ -105,7 +105,15 @@ export async function installFromNpmTarball({
|
|||||||
|
|
||||||
// Extract tarball
|
// Extract tarball
|
||||||
log.info(`Extracting 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
|
// Find executable in the extracted package
|
||||||
const extractedDir = join(tempDir, "package");
|
const extractedDir = join(tempDir, "package");
|
||||||
@@ -120,7 +128,16 @@ export async function installFromNpmTarball({
|
|||||||
const packageJsonPath = join(extractedDir, "package.json");
|
const packageJsonPath = join(extractedDir, "package.json");
|
||||||
if (existsSync(packageJsonPath)) {
|
if (existsSync(packageJsonPath)) {
|
||||||
log.info(`Installing dependencies for ${packageName}...`);
|
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 define2 = ark.define;
|
||||||
var declare = ark.declare;
|
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 { join as join3 } from "path";
|
||||||
import { fileURLToPath } from "url";
|
import { fileURLToPath } from "url";
|
||||||
import { setMaxListeners } from "events";
|
import { setMaxListeners } from "events";
|
||||||
@@ -40718,7 +40718,7 @@ var log = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// agents/shared.ts
|
// 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 { createWriteStream as createWriteStream2, existsSync as existsSync2 } from "node:fs";
|
||||||
import { mkdtemp } from "node:fs/promises";
|
import { mkdtemp } from "node:fs/promises";
|
||||||
import { tmpdir } from "node:os";
|
import { tmpdir } from "node:os";
|
||||||
@@ -41183,7 +41183,15 @@ async function installFromNpmTarball({
|
|||||||
await pipeline(response.body, fileStream);
|
await pipeline(response.body, fileStream);
|
||||||
log.info(`Downloaded tarball to ${tarballPath}`);
|
log.info(`Downloaded tarball to ${tarballPath}`);
|
||||||
log.info(`Extracting 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"}`
|
||||||
|
);
|
||||||
|
}
|
||||||
const extractedDir = join5(tempDir, "package");
|
const extractedDir = join5(tempDir, "package");
|
||||||
const cliPath = join5(extractedDir, executablePath);
|
const cliPath = join5(extractedDir, executablePath);
|
||||||
if (!existsSync2(cliPath)) {
|
if (!existsSync2(cliPath)) {
|
||||||
@@ -41193,7 +41201,16 @@ async function installFromNpmTarball({
|
|||||||
const packageJsonPath = join5(extractedDir, "package.json");
|
const packageJsonPath = join5(extractedDir, "package.json");
|
||||||
if (existsSync2(packageJsonPath)) {
|
if (existsSync2(packageJsonPath)) {
|
||||||
log.info(`Installing dependencies for ${packageName}...`);
|
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}`);
|
log.info(`\u2713 ${packageName} installed at ${cliPath}`);
|
||||||
@@ -41377,15 +41394,15 @@ var messageHandlers = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// agents/codex.ts
|
// agents/codex.ts
|
||||||
import { spawnSync } from "node:child_process";
|
import { spawnSync as spawnSync2 } from "node:child_process";
|
||||||
var codex = agent({
|
var codex = agent({
|
||||||
name: "codex",
|
name: "codex",
|
||||||
inputKey: "openai_api_key",
|
inputKey: "openai_api_key",
|
||||||
install: async () => {
|
install: async () => {
|
||||||
return await installFromNpmTarball({
|
return await installFromNpmTarball({
|
||||||
packageName: "codex",
|
packageName: "@openai/codex",
|
||||||
version: "latest",
|
version: "latest",
|
||||||
executablePath: "bin/codex",
|
executablePath: "bin/codex.js",
|
||||||
installDependencies: true
|
installDependencies: true
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -41407,8 +41424,8 @@ var codex = agent({
|
|||||||
addArgs.push("--env", `${key}=${value2}`);
|
addArgs.push("--env", `${key}=${value2}`);
|
||||||
}
|
}
|
||||||
log.info(`Adding MCP server '${serverName}'...`);
|
log.info(`Adding MCP server '${serverName}'...`);
|
||||||
const addResult = spawnSync(cliPath, addArgs, {
|
const addResult = spawnSync2("node", [cliPath, ...addArgs], {
|
||||||
stdio: "inherit",
|
stdio: "pipe",
|
||||||
encoding: "utf-8",
|
encoding: "utf-8",
|
||||||
env: {
|
env: {
|
||||||
...process.env,
|
...process.env,
|
||||||
@@ -41430,7 +41447,7 @@ var codex = agent({
|
|||||||
}
|
}
|
||||||
log.info("Running Codex via CLI...");
|
log.info("Running Codex via CLI...");
|
||||||
try {
|
try {
|
||||||
const result = spawnSync(cliPath, ["exec", addInstructions(prompt)], {
|
const result = spawnSync2("node", [cliPath, "exec", addInstructions(prompt)], {
|
||||||
encoding: "utf-8",
|
encoding: "utf-8",
|
||||||
env: {
|
env: {
|
||||||
...process.env,
|
...process.env,
|
||||||
@@ -41522,15 +41539,15 @@ async function getRepoSettings(token, repoContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// utils/setup.ts
|
// utils/setup.ts
|
||||||
import { execSync as execSync2 } from "node:child_process";
|
import { execSync } from "node:child_process";
|
||||||
function setupGitConfig() {
|
function setupGitConfig() {
|
||||||
if (!process.env.GITHUB_ACTIONS) {
|
if (!process.env.GITHUB_ACTIONS) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
log.info("\u{1F527} Setting up git configuration...");
|
log.info("\u{1F527} Setting up git configuration...");
|
||||||
try {
|
try {
|
||||||
execSync2('git config user.email "action@pullfrog.ai"', { stdio: "pipe" });
|
execSync('git config user.email "action@pullfrog.ai"', { stdio: "pipe" });
|
||||||
execSync2('git config user.name "Pullfrog Action"', { stdio: "pipe" });
|
execSync('git config user.name "Pullfrog Action"', { stdio: "pipe" });
|
||||||
log.debug("setupGitConfig: \u2713 Git configuration set successfully");
|
log.debug("setupGitConfig: \u2713 Git configuration set successfully");
|
||||||
} catch (error2) {
|
} catch (error2) {
|
||||||
log.warning(
|
log.warning(
|
||||||
@@ -41544,13 +41561,13 @@ function setupGitAuth(githubToken, repoContext) {
|
|||||||
}
|
}
|
||||||
log.info("\u{1F510} Setting up git authentication...");
|
log.info("\u{1F510} Setting up git authentication...");
|
||||||
try {
|
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");
|
log.info("\u2713 Removed existing authentication headers");
|
||||||
} catch {
|
} catch {
|
||||||
log.info("No existing authentication headers to remove");
|
log.info("No existing authentication headers to remove");
|
||||||
}
|
}
|
||||||
const remoteUrl = `https://x-access-token:${githubToken}@github.com/${repoContext.owner}/${repoContext.name}.git`;
|
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");
|
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"]) {
|
if (args["--raw"]) {
|
||||||
prompt = args["--raw"];
|
prompt = args["--raw"];
|
||||||
} else {
|
} else {
|
||||||
// Default to testing tool calls if no file specified
|
const filePath = args._[0] || "basic.txt";
|
||||||
const filePath = args._[0] || null;
|
|
||||||
if (!filePath) {
|
const ext = extname(filePath).toLowerCase();
|
||||||
prompt =
|
let resolvedPath: string;
|
||||||
"List all available MCP tools from the gh-pullfrog server and show what each tool does.";
|
|
||||||
|
const fixturesPath = fromHere("fixtures", filePath);
|
||||||
|
if (existsSync(fixturesPath)) {
|
||||||
|
resolvedPath = fixturesPath;
|
||||||
|
} else if (existsSync(filePath)) {
|
||||||
|
resolvedPath = resolve(filePath);
|
||||||
} else {
|
} else {
|
||||||
const ext = extname(filePath).toLowerCase();
|
throw new Error(`File not found: ${filePath}`);
|
||||||
let resolvedPath: string;
|
}
|
||||||
|
|
||||||
const fixturesPath = fromHere("fixtures", filePath);
|
switch (ext) {
|
||||||
if (existsSync(fixturesPath)) {
|
case ".txt": {
|
||||||
resolvedPath = fixturesPath;
|
prompt = readFileSync(resolvedPath, "utf8").trim();
|
||||||
} else if (existsSync(filePath)) {
|
break;
|
||||||
resolvedPath = resolve(filePath);
|
|
||||||
} else {
|
|
||||||
throw new Error(`File not found: ${filePath}`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (ext) {
|
case ".json": {
|
||||||
case ".txt": {
|
const content = readFileSync(resolvedPath, "utf8");
|
||||||
prompt = readFileSync(resolvedPath, "utf8").trim();
|
const parsed = JSON.parse(content);
|
||||||
break;
|
prompt = JSON.stringify(parsed, null, 2);
|
||||||
}
|
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 ".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