@ycodium-ai/agent-codex 0.2.2526 → 0.2.2544

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 +38 -14
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -811,10 +811,15 @@ function decodeThreadOpen(result) {
811
811
  }
812
812
  function decodeTurnStart(result) {
813
813
  const turn = isRecord3(result) ? isRecord3(result["turn"]) ? result["turn"] : result : null;
814
- const id = turn ? asString(turn["id"]) : asString(isRecord3(result) ? result["turnId"] : null);
814
+ const id = turn ? asString(turn["id"]) : null;
815
815
  if (!id) throw new Error("codex turn/start returned no turn id");
816
816
  return { turnId: id };
817
817
  }
818
+ function decodeTurnSteer(result) {
819
+ const id = isRecord3(result) ? asString(result["turnId"]) : null;
820
+ if (!id) throw new Error("codex turn/steer returned no turn id");
821
+ return { turnId: id };
822
+ }
818
823
  function inProgressTurnIdFromThreadRead(result) {
819
824
  if (!isRecord3(result)) return void 0;
820
825
  const thread = isRecord3(result["thread"]) ? result["thread"] : result;
@@ -953,6 +958,8 @@ function classifyStderrLine(line) {
953
958
  if (level === "WARN") return "warn";
954
959
  return "drop";
955
960
  }
961
+ var CodexRpcResponseError = class extends Error {
962
+ };
956
963
  async function createCodexRpcClient(handle, handlers) {
957
964
  const pending = /* @__PURE__ */ new Map();
958
965
  const decoder = new TextDecoder();
@@ -993,7 +1000,9 @@ async function createCodexRpcClient(handle, handlers) {
993
1000
  pending.delete(typed.id);
994
1001
  if (typed.error !== void 0 && typed.error !== null) {
995
1002
  entry.reject(
996
- new Error(`codex app-server ${entry.method} failed: ${jsonRpcErrorMessage(typed.error)}`)
1003
+ new CodexRpcResponseError(
1004
+ `codex app-server ${entry.method} failed: ${jsonRpcErrorMessage(typed.error)}`
1005
+ )
997
1006
  );
998
1007
  return;
999
1008
  }
@@ -3125,19 +3134,23 @@ var CodexSessionRuntime = class {
3125
3134
  });
3126
3135
  }
3127
3136
  const isSteer = input.expectedTurnId !== void 0;
3128
- const result = isSteer ? await this.rpc.request(
3129
- "turn/steer",
3130
- {
3131
- ...params,
3132
- // 这一位的名字是 `expectedTurnId`,不是 `turnId`:0.155.1 少了它整条拒收
3133
- // (`Invalid request: missing field \`expectedTurnId\``),插队的那句话发不出去。
3134
- expectedTurnId: input.expectedTurnId
3135
- },
3136
- 0
3137
- ) : await this.withActiveWriterRecovery(() => this.rpc.request("turn/start", params, 0), false);
3138
- const started = decodeTurnStart(result);
3137
+ const result = await markProviderRejection(
3138
+ () => isSteer ? this.rpc.request(
3139
+ "turn/steer",
3140
+ {
3141
+ ...params,
3142
+ // 这一位的名字是 `expectedTurnId`,不是 `turnId`:0.155.1 少了它整条拒收
3143
+ // (`Invalid request: missing field \`expectedTurnId\``),插队的那句话发不出去。
3144
+ expectedTurnId: input.expectedTurnId
3145
+ },
3146
+ 0
3147
+ ) : this.withActiveWriterRecovery(() => this.rpc.request("turn/start", params, 0), false)
3148
+ );
3149
+ const started = isSteer ? decodeTurnSteer(result) : decodeTurnStart(result);
3139
3150
  this.activeTurnId = started.turnId;
3140
- this.turns.push({ id: started.turnId, items: [] });
3151
+ if (!this.turns.some((turn) => turn.id === started.turnId)) {
3152
+ this.turns.push({ id: started.turnId, items: [] });
3153
+ }
3141
3154
  this.session = {
3142
3155
  ...this.session,
3143
3156
  status: "running",
@@ -3254,6 +3267,17 @@ var CodexSessionRuntime = class {
3254
3267
  });
3255
3268
  }
3256
3269
  };
3270
+ async function markProviderRejection(run) {
3271
+ try {
3272
+ return await run();
3273
+ } catch (error) {
3274
+ if (!(error instanceof CodexRpcResponseError)) throw error;
3275
+ const rejected = Object.assign(new Error(error.message), {
3276
+ code: "provider-rejected"
3277
+ });
3278
+ throw rejected;
3279
+ }
3280
+ }
3257
3281
 
3258
3282
  // src/sessions.ts
3259
3283
  import * as NodeFS2 from "node:fs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ycodium-ai/agent-codex",
3
- "version": "0.2.2526",
3
+ "version": "0.2.2544",
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.2526",
32
+ "@ycodium-ai/plugin-api": "0.2.2544",
33
33
  "ycodium-executor-testing": "0.0.0"
34
34
  },
35
35
  "ycodium": {