@ycodium-ai/agent-codex 0.2.4486 → 0.2.4505
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +47 -16
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -2434,10 +2434,12 @@ function buildCodexSpawnEnv(input) {
|
|
|
2434
2434
|
handOverrides: input.crushApiKeys ? CRUSHED_API_KEYS : {}
|
|
2435
2435
|
});
|
|
2436
2436
|
}
|
|
2437
|
-
function nativeLoginSpawnEnv(
|
|
2437
|
+
function nativeLoginSpawnEnv(input) {
|
|
2438
|
+
const { HOME: _instanceHome, ...instanceTable } = input.recipe.environment;
|
|
2438
2439
|
return mergeLaunchEnv({
|
|
2439
|
-
inherited: processEnv,
|
|
2440
|
-
|
|
2440
|
+
inherited: input.processEnv,
|
|
2441
|
+
instanceTable,
|
|
2442
|
+
handOverrides: { ...CRUSHED_API_KEYS, CODEX_HOME: input.isolatedHome }
|
|
2441
2443
|
});
|
|
2442
2444
|
}
|
|
2443
2445
|
function shouldCrushApiKeys(authMode) {
|
|
@@ -2538,8 +2540,9 @@ var DEFAULT_REQUEST_TIMEOUT_MS = 3e4;
|
|
|
2538
2540
|
var ANSI_ESCAPE_CHAR = String.fromCharCode(27);
|
|
2539
2541
|
var ANSI_RE = new RegExp(`${ANSI_ESCAPE_CHAR}\\[[0-9;]*m`, "g");
|
|
2540
2542
|
var CODEX_STDERR_LOG_REGEX = /\b(TRACE|DEBUG|INFO|WARN|ERROR)\b/;
|
|
2543
|
+
var stripCodexColors = (text) => text.replace(ANSI_RE, "");
|
|
2541
2544
|
function classifyStderrLine(line) {
|
|
2542
|
-
const stripped = line
|
|
2545
|
+
const stripped = stripCodexColors(line).trim();
|
|
2543
2546
|
if (stripped.length === 0) return "drop";
|
|
2544
2547
|
const match = CODEX_STDERR_LOG_REGEX.exec(stripped);
|
|
2545
2548
|
if (match === null) return "error";
|
|
@@ -6253,10 +6256,15 @@ async function startCodexSignIn(input) {
|
|
|
6253
6256
|
throw new Error("Codex program path is not configured");
|
|
6254
6257
|
}
|
|
6255
6258
|
const isolatedHome = accountHomeFromLayout(input.layout);
|
|
6256
|
-
const env = nativeLoginSpawnEnv(
|
|
6259
|
+
const env = nativeLoginSpawnEnv({
|
|
6260
|
+
processEnv: input.processEnv,
|
|
6261
|
+
recipe: input.recipe,
|
|
6262
|
+
isolatedHome
|
|
6263
|
+
});
|
|
6257
6264
|
const loginRecipe = { ...input.recipe, authMode: "chatgpt" };
|
|
6258
6265
|
const owner = { bindingId: input.host.bindingId };
|
|
6259
6266
|
const lifetime = signInLifetime(input.signal);
|
|
6267
|
+
let appServerFailure;
|
|
6260
6268
|
try {
|
|
6261
6269
|
const tryAppServer = async () => {
|
|
6262
6270
|
const { handle: handle2 } = await spawnCodexAppServer({
|
|
@@ -6342,6 +6350,7 @@ async function startCodexSignIn(input) {
|
|
|
6342
6350
|
} catch (error) {
|
|
6343
6351
|
await closeSignInRpc(rpc, input.host, handle2).catch(() => void 0);
|
|
6344
6352
|
if (lifetime.signal.aborted) throw error;
|
|
6353
|
+
appServerFailure = error instanceof Error ? error.message : String(error);
|
|
6345
6354
|
return void 0;
|
|
6346
6355
|
}
|
|
6347
6356
|
};
|
|
@@ -6359,24 +6368,42 @@ async function startCodexSignIn(input) {
|
|
|
6359
6368
|
});
|
|
6360
6369
|
const stdout = { text: "" };
|
|
6361
6370
|
const stderr = { text: "" };
|
|
6362
|
-
|
|
6363
|
-
|
|
6371
|
+
const reading = Promise.all([
|
|
6372
|
+
collectText(handle.stdout, stdout),
|
|
6373
|
+
collectText(handle.stderr, stderr)
|
|
6374
|
+
]).catch(() => void 0);
|
|
6375
|
+
const cli = { exited: false };
|
|
6376
|
+
void handle.exited.then(
|
|
6377
|
+
() => cli.exited = true,
|
|
6378
|
+
() => cli.exited = true
|
|
6379
|
+
);
|
|
6380
|
+
const output = () => stripCodexColors(`${stdout.text}
|
|
6381
|
+
${stderr.text}`);
|
|
6364
6382
|
const deadline = Date.now() + 3e3;
|
|
6365
|
-
while (Date.now() < deadline) {
|
|
6366
|
-
const combined2 =
|
|
6367
|
-
${stderr.text}`;
|
|
6383
|
+
while (Date.now() < deadline && !cli.exited) {
|
|
6384
|
+
const combined2 = output();
|
|
6368
6385
|
if (deviceCodeUrl(combined2) && deviceCodeValue(combined2)) break;
|
|
6369
6386
|
await new Promise((resolve4) => setTimeout(resolve4, 50));
|
|
6370
6387
|
}
|
|
6371
|
-
|
|
6372
|
-
|
|
6388
|
+
if (cli.exited) await reading;
|
|
6389
|
+
const combined = output();
|
|
6373
6390
|
const operationId = `codex-login-${Date.now()}`;
|
|
6374
6391
|
const userCode = deviceCodeValue(combined);
|
|
6375
6392
|
const verificationUrl = deviceCodeUrl(combined);
|
|
6393
|
+
if (userCode === void 0 || verificationUrl === void 0) {
|
|
6394
|
+
await handle.kill("SIGTERM").catch(() => void 0);
|
|
6395
|
+
await handle.exited.catch(() => void 0);
|
|
6396
|
+
const said = combined.trim().slice(-600) || appServerFailure;
|
|
6397
|
+
throw new Error(
|
|
6398
|
+
said === void 0 ? "Codex did not show a device code." : `Codex did not show a device code: ${said}`
|
|
6399
|
+
);
|
|
6400
|
+
}
|
|
6376
6401
|
const completed = raceAbort(
|
|
6377
6402
|
handle.exited.then((code) => {
|
|
6378
6403
|
if (code !== 0)
|
|
6379
|
-
throw new Error(
|
|
6404
|
+
throw new Error(
|
|
6405
|
+
stripCodexColors(stderr.text).trim() || `Codex sign-in exited with code ${String(code)}`
|
|
6406
|
+
);
|
|
6380
6407
|
}),
|
|
6381
6408
|
lifetime.signal
|
|
6382
6409
|
);
|
|
@@ -6399,8 +6426,8 @@ ${stderr.text}`;
|
|
|
6399
6426
|
}
|
|
6400
6427
|
}
|
|
6401
6428
|
},
|
|
6402
|
-
|
|
6403
|
-
|
|
6429
|
+
userCode,
|
|
6430
|
+
verificationUrl
|
|
6404
6431
|
};
|
|
6405
6432
|
} catch (error) {
|
|
6406
6433
|
lifetime.close();
|
|
@@ -6419,7 +6446,11 @@ async function verifyCodexSignIn(input) {
|
|
|
6419
6446
|
detail: "Codex program path is not configured"
|
|
6420
6447
|
};
|
|
6421
6448
|
}
|
|
6422
|
-
const env = nativeLoginSpawnEnv(
|
|
6449
|
+
const env = nativeLoginSpawnEnv({
|
|
6450
|
+
processEnv: input.processEnv,
|
|
6451
|
+
recipe: input.recipe,
|
|
6452
|
+
isolatedHome: home
|
|
6453
|
+
});
|
|
6423
6454
|
const { handle } = await spawnCodexAppServer({
|
|
6424
6455
|
host: input.host,
|
|
6425
6456
|
recipe: { ...input.recipe, authMode: "chatgpt" },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ycodium-ai/agent-codex",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4505",
|
|
4
4
|
"description": "Codex executor: Codex CLI over the app-server JSON-RPC protocol.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ycodium",
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
"tailwindcss": "^4.0.0",
|
|
30
30
|
"typescript": "~6.0.3",
|
|
31
31
|
"vite-plus": "0.2.2",
|
|
32
|
-
"@ycodium-ai/plugin-api": "0.2.4486",
|
|
33
32
|
"ycodium-executor-testing": "0.0.0",
|
|
34
|
-
"ycodium-jsonl-stream": "0.0.0"
|
|
33
|
+
"ycodium-jsonl-stream": "0.0.0",
|
|
34
|
+
"@ycodium-ai/plugin-api": "0.2.0"
|
|
35
35
|
},
|
|
36
36
|
"ycodium": {
|
|
37
37
|
"plugin": "./dist/index.js",
|