@ycodium-ai/agent-codex 0.2.3024 → 0.2.3034

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.
Files changed (2) hide show
  1. package/dist/index.js +24 -19
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -706,6 +706,9 @@ async function spawnCodexAppServer(input) {
706
706
  return { handle, args };
707
707
  }
708
708
 
709
+ // src/failureCategory.ts
710
+ var codexProcessExitCategory = (session) => session !== void 0 && !session.closed && typeof session.nativeThreadId === "string" && session.nativeThreadId.length > 0 ? "transport" : void 0;
711
+
709
712
  // src/protocol.ts
710
713
  var CODEX_INITIALIZE_PARAMS = {
711
714
  clientInfo: { name: "ycodium", title: "Ycodium", version: "0" },
@@ -1021,11 +1024,14 @@ async function createCodexRpcClient(handle, handlers) {
1021
1024
  let nextId = 1;
1022
1025
  let stderrTail = "";
1023
1026
  let exitReason = null;
1027
+ let exitFailureCategory;
1024
1028
  let closed = false;
1025
- const failAll = (reason) => {
1029
+ const attach = (error) => exitFailureCategory === void 0 ? error : Object.assign(error, { failureCategory: exitFailureCategory });
1030
+ const failAll = (reason, failureCategory) => {
1031
+ if (exitReason === null) exitFailureCategory = failureCategory;
1026
1032
  exitReason = reason;
1027
1033
  for (const [, entry] of pending) {
1028
- entry.reject(new Error(`codex app-server ${entry.method} failed: ${reason}`));
1034
+ entry.reject(attach(new Error(`codex app-server ${entry.method} failed: ${reason}`)));
1029
1035
  }
1030
1036
  pending.clear();
1031
1037
  };
@@ -1093,11 +1099,12 @@ async function createCodexRpcClient(handle, handlers) {
1093
1099
  })().catch(() => void 0);
1094
1100
  void handle.exited.then((code) => {
1095
1101
  failAll(
1096
- `the process exited with code ${String(code)}${stderrTail.length > 0 ? `: ${stderrTail.trim()}` : ""}`
1102
+ `the process exited with code ${String(code)}${stderrTail.length > 0 ? `: ${stderrTail.trim()}` : ""}`,
1103
+ handlers.failureCategoryForProcessExit?.()
1097
1104
  );
1098
1105
  handlers.onExit?.(code);
1099
1106
  }).catch(() => {
1100
- failAll("the process ended unexpectedly");
1107
+ failAll("the process ended unexpectedly", handlers.failureCategoryForProcessExit?.());
1101
1108
  handlers.onExit?.(null);
1102
1109
  });
1103
1110
  const writeLine = async (payload, jsonRpcId) => {
@@ -1111,7 +1118,9 @@ async function createCodexRpcClient(handle, handlers) {
1111
1118
  }
1112
1119
  };
1113
1120
  const request = async (method, params, timeoutMs) => {
1114
- if (exitReason !== null) throw new Error(`codex app-server ${method} failed: ${exitReason}`);
1121
+ if (exitReason !== null) {
1122
+ throw attach(new Error(`codex app-server ${method} failed: ${exitReason}`));
1123
+ }
1115
1124
  const id = nextId;
1116
1125
  nextId += 1;
1117
1126
  const settled = new Promise((resolve2, reject) => {
@@ -2494,26 +2503,23 @@ function mapNotificationToEvents(input) {
2494
2503
  nowIso2(),
2495
2504
  trimText(turnError?.["message"])
2496
2505
  );
2506
+ const failureCategory = { failureCategory: "quota" };
2507
+ const at = { threadId, turnId, method, providerInstanceId };
2497
2508
  return [
2498
2509
  baseEvent({
2499
2510
  type: "runtime.error",
2500
- threadId,
2501
- turnId,
2511
+ ...at,
2502
2512
  payload: {
2503
2513
  message,
2504
2514
  class: "provider_error",
2515
+ ...failureCategory,
2505
2516
  ...params !== void 0 ? { detail: params } : {}
2506
- },
2507
- method,
2508
- providerInstanceId
2517
+ }
2509
2518
  }),
2510
2519
  baseEvent({
2511
2520
  type: "turn.completed",
2512
- threadId,
2513
- turnId,
2514
- payload: { ...controlFlow, errorMessage: message },
2515
- method,
2516
- providerInstanceId
2521
+ ...at,
2522
+ payload: { ...controlFlow, errorMessage: message, ...failureCategory }
2517
2523
  })
2518
2524
  ];
2519
2525
  }
@@ -5932,10 +5938,9 @@ var createCodexInstance = (config, host, attachments, cache) => {
5932
5938
  runtime?.settleNativeWrite(id, status);
5933
5939
  },
5934
5940
  onExit: () => {
5935
- if (runtime && !runtime.closed) {
5936
- void runtime.close().catch(() => void 0);
5937
- }
5938
- }
5941
+ if (runtime && !runtime.closed) void runtime.close().catch(() => void 0);
5942
+ },
5943
+ failureCategoryForProcessExit: () => codexProcessExitCategory(runtime)
5939
5944
  });
5940
5945
  runtime = new CodexSessionRuntime(
5941
5946
  host,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ycodium-ai/agent-codex",
3
- "version": "0.2.3024",
3
+ "version": "0.2.3034",
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.3024",
32
+ "@ycodium-ai/plugin-api": "0.2.3034",
33
33
  "ycodium-executor-testing": "0.0.0"
34
34
  },
35
35
  "ycodium": {