@ycodium-ai/agent-codex 0.2.4343 → 0.2.4368
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 +57 -7
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { definePlugin } from "@ycodium-ai/plugin-api";
|
|
3
3
|
|
|
4
4
|
// ../../packages/plugin-api/src/version.ts
|
|
5
|
-
var PLUGIN_API_VERSION =
|
|
5
|
+
var PLUGIN_API_VERSION = 112;
|
|
6
6
|
|
|
7
7
|
// src/index.ts
|
|
8
8
|
import {
|
|
@@ -2499,9 +2499,10 @@ async function readCodexCliVersion(input) {
|
|
|
2499
2499
|
}
|
|
2500
2500
|
|
|
2501
2501
|
// src/failureCategory.ts
|
|
2502
|
-
var codexProcessExitCategory = (session) => session !== void 0 && !session.stopRequested && typeof session.nativeThreadId === "string" && session.nativeThreadId.length > 0 ? "
|
|
2502
|
+
var codexProcessExitCategory = (session) => session !== void 0 && !session.stopRequested && typeof session.nativeThreadId === "string" && session.nativeThreadId.length > 0 ? "process-exit" : void 0;
|
|
2503
2503
|
|
|
2504
2504
|
// src/rpc.ts
|
|
2505
|
+
import { lastStderrLines, redactStderrExcerpt } from "@ycodium-ai/plugin-api/process-stdin";
|
|
2505
2506
|
function createLineAssembler() {
|
|
2506
2507
|
const fragments = [];
|
|
2507
2508
|
return {
|
|
@@ -2525,6 +2526,14 @@ function createLineAssembler() {
|
|
|
2525
2526
|
};
|
|
2526
2527
|
}
|
|
2527
2528
|
var STDERR_TAIL_LIMIT = 4e3;
|
|
2529
|
+
var EXIT_MESSAGE_STDERR_MAX_CHARS = 800;
|
|
2530
|
+
function codexProcessExitMessage(code, redactedStderr) {
|
|
2531
|
+
const head = `Codex app-server exited with code ${String(code)}.`;
|
|
2532
|
+
const excerpt = lastStderrLines(redactedStderr, EXIT_MESSAGE_STDERR_MAX_CHARS);
|
|
2533
|
+
return excerpt.length === 0 ? head : `${head}
|
|
2534
|
+
Codex stderr (last lines):
|
|
2535
|
+
${excerpt}`;
|
|
2536
|
+
}
|
|
2528
2537
|
var DEFAULT_REQUEST_TIMEOUT_MS = 3e4;
|
|
2529
2538
|
var ANSI_ESCAPE_CHAR = String.fromCharCode(27);
|
|
2530
2539
|
var ANSI_RE = new RegExp(`${ANSI_ESCAPE_CHAR}\\[[0-9;]*m`, "g");
|
|
@@ -2548,6 +2557,7 @@ async function createCodexRpcClient(handle, handlers) {
|
|
|
2548
2557
|
let stderrTail = "";
|
|
2549
2558
|
let exitReason = null;
|
|
2550
2559
|
let exitFailureCategory;
|
|
2560
|
+
let exitedBeforeClose;
|
|
2551
2561
|
let closeTask;
|
|
2552
2562
|
const attach = (error) => exitFailureCategory === void 0 ? error : Object.assign(error, { failureCategory: exitFailureCategory });
|
|
2553
2563
|
const failAll = (reason, failureCategory) => {
|
|
@@ -2609,8 +2619,9 @@ async function createCodexRpcClient(handle, handlers) {
|
|
|
2609
2619
|
const errorDecoder = new TextDecoder();
|
|
2610
2620
|
let buffer = "";
|
|
2611
2621
|
for await (const chunk of handle.stderr) {
|
|
2612
|
-
|
|
2613
|
-
|
|
2622
|
+
const text = errorDecoder.decode(chunk, { stream: true });
|
|
2623
|
+
buffer += text;
|
|
2624
|
+
stderrTail = `${stderrTail}${text}`.slice(-STDERR_TAIL_LIMIT);
|
|
2614
2625
|
let index = buffer.indexOf("\n");
|
|
2615
2626
|
while (index >= 0) {
|
|
2616
2627
|
handlers.onStderrLine(buffer.slice(0, index));
|
|
@@ -2621,9 +2632,17 @@ async function createCodexRpcClient(handle, handlers) {
|
|
|
2621
2632
|
if (buffer.length > 0) handlers.onStderrLine(buffer);
|
|
2622
2633
|
})().catch(() => void 0);
|
|
2623
2634
|
void handle.exited.then((code) => {
|
|
2635
|
+
const said = redactStderrExcerpt(stderrTail);
|
|
2636
|
+
const failureCategory = handlers.failureCategoryForProcessExit?.();
|
|
2637
|
+
if (exitReason === null) {
|
|
2638
|
+
exitedBeforeClose = {
|
|
2639
|
+
code,
|
|
2640
|
+
...failureCategory === void 0 ? {} : { failureCategory }
|
|
2641
|
+
};
|
|
2642
|
+
}
|
|
2624
2643
|
failAll(
|
|
2625
|
-
`the process exited with code ${String(code)}${
|
|
2626
|
-
|
|
2644
|
+
`the process exited with code ${String(code)}${said.length > 0 ? `: ${said}` : ""}`,
|
|
2645
|
+
failureCategory
|
|
2627
2646
|
);
|
|
2628
2647
|
handlers.onExit?.(code);
|
|
2629
2648
|
}).catch(() => {
|
|
@@ -2722,7 +2741,15 @@ async function createCodexRpcClient(handle, handlers) {
|
|
|
2722
2741
|
respondError,
|
|
2723
2742
|
close,
|
|
2724
2743
|
pid: handle.pid,
|
|
2725
|
-
pendingCountForTests: () => pending2.size
|
|
2744
|
+
pendingCountForTests: () => pending2.size,
|
|
2745
|
+
// 退出事件不等输出泵:stderr 的最后几行可能晚到,所以每次读都用当下的尾巴现拼。
|
|
2746
|
+
processExit: () => exitedBeforeClose === void 0 ? void 0 : {
|
|
2747
|
+
message: codexProcessExitMessage(
|
|
2748
|
+
exitedBeforeClose.code,
|
|
2749
|
+
redactStderrExcerpt(stderrTail)
|
|
2750
|
+
),
|
|
2751
|
+
...exitedBeforeClose.failureCategory === void 0 ? {} : { failureCategory: exitedBeforeClose.failureCategory }
|
|
2752
|
+
}
|
|
2726
2753
|
};
|
|
2727
2754
|
}
|
|
2728
2755
|
|
|
@@ -4776,6 +4803,28 @@ var CodexBackgroundCommands = class {
|
|
|
4776
4803
|
}
|
|
4777
4804
|
};
|
|
4778
4805
|
|
|
4806
|
+
// src/processExitTurn.ts
|
|
4807
|
+
function failTurnOnProcessExit(session, lifecycle) {
|
|
4808
|
+
const turnId = session.activeTurnId;
|
|
4809
|
+
const exit = session.rpc.processExit?.();
|
|
4810
|
+
if (turnId === void 0 || exit === void 0 || !lifecycle.acceptsLifecycle) return;
|
|
4811
|
+
session.activeTurnId = void 0;
|
|
4812
|
+
session.emit(
|
|
4813
|
+
baseEvent({
|
|
4814
|
+
type: "turn.completed",
|
|
4815
|
+
threadId: session.threadId,
|
|
4816
|
+
turnId,
|
|
4817
|
+
providerInstanceId: session.host.instanceId,
|
|
4818
|
+
payload: {
|
|
4819
|
+
state: "failed",
|
|
4820
|
+
stopReason: "error",
|
|
4821
|
+
errorMessage: exit.message,
|
|
4822
|
+
...exit.failureCategory === void 0 ? {} : { failureCategory: exit.failureCategory }
|
|
4823
|
+
}
|
|
4824
|
+
})
|
|
4825
|
+
);
|
|
4826
|
+
}
|
|
4827
|
+
|
|
4779
4828
|
// src/openCommands.ts
|
|
4780
4829
|
import {
|
|
4781
4830
|
isPosixShellCommandFlag,
|
|
@@ -5897,6 +5946,7 @@ var CodexSessionRuntime = class {
|
|
|
5897
5946
|
this.host.log.warn("codex output drain timed out", { threadId: this.threadId });
|
|
5898
5947
|
}
|
|
5899
5948
|
});
|
|
5949
|
+
if (reason === "process") failTurnOnProcessExit(this, this.#lifecycle);
|
|
5900
5950
|
for (const event of this.#background.settleSessionEnded(reason === "process"))
|
|
5901
5951
|
this.emit(event);
|
|
5902
5952
|
this.#collab.settleSessionEnded();
|
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.4368",
|
|
4
4
|
"description": "Codex executor: Codex CLI over the app-server JSON-RPC protocol.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ycodium",
|
|
@@ -29,7 +29,7 @@
|
|
|
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.
|
|
32
|
+
"@ycodium-ai/plugin-api": "0.2.4368",
|
|
33
33
|
"ycodium-executor-testing": "0.0.0",
|
|
34
34
|
"ycodium-jsonl-stream": "0.0.0"
|
|
35
35
|
},
|