@codex-app-sdk/backend 0.19.1 → 0.19.3

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 CHANGED
@@ -1742,6 +1742,7 @@ function Nn(e) {
1742
1742
  let t = Vn(e.path);
1743
1743
  return v(e.path) && t && En.has(t) ? [{
1744
1744
  type: "media",
1745
+ phase: "commentary",
1745
1746
  itemId: e.id,
1746
1747
  media: {
1747
1748
  url: fe(e.path).href,
@@ -1776,6 +1777,7 @@ function Nn(e) {
1776
1777
  let u = Hn(l);
1777
1778
  u && (i -= u.url.length, r.push({
1778
1779
  type: "media",
1780
+ phase: "commentary",
1779
1781
  itemId: r.length ? `${e.id}:image:${r.length}` : e.id,
1780
1782
  media: {
1781
1783
  url: u.url,
@@ -2782,7 +2784,7 @@ function Pi(e) {
2782
2784
  }
2783
2785
  //#endregion
2784
2786
  //#region src/node/codex-original-history-images.ts
2785
- var Fi = 256 * 1024 * 1024, Ii = 32 * 1024 * 1024, Li = 20 * 1024 * 1024, Ri = 2048, zi = class {
2787
+ var Fi = 32 * 1024 * 1024, Ii = 20 * 1024 * 1024, Li = 2048, Ri = class {
2786
2788
  client;
2787
2789
  paths = /* @__PURE__ */ new Map();
2788
2790
  indexes = /* @__PURE__ */ new Map();
@@ -2839,13 +2841,13 @@ var Fi = 256 * 1024 * 1024, Ii = 32 * 1024 * 1024, Li = 20 * 1024 * 1024, Ri = 2
2839
2841
  let r = await this.index(e), i = r.images.get(t);
2840
2842
  if (!i) throw Error("Original conversation image is no longer available.");
2841
2843
  if (!Number.isSafeInteger(n) || n < 0 || n >= i.byteLength) throw Error("Invalid content offset.");
2842
- let a = Ui(await se(r.path));
2844
+ let a = Hi(await se(r.path));
2843
2845
  if (this.disposed || this.paths.get(e) !== r.path) throw Error("Conversation image reader was released.");
2844
2846
  let o = this.images.get(t), s = o?.signature === a ? o.url : void 0;
2845
2847
  if (this.images.delete(t), !s) {
2846
2848
  let t = await ae(r.path, "r");
2847
2849
  try {
2848
- await Wi(t, e);
2850
+ await Ui(t, e);
2849
2851
  let n = Buffer.alloc(i.length);
2850
2852
  for (let e = 0; e < n.length;) {
2851
2853
  let r = await t.read(n, e, Math.min(64 * 1024, n.length - e), i.offset + e);
@@ -2853,9 +2855,9 @@ var Fi = 256 * 1024 * 1024, Ii = 32 * 1024 * 1024, Li = 20 * 1024 * 1024, Ri = 2
2853
2855
  e += r.bytesRead;
2854
2856
  }
2855
2857
  let a = JSON.parse(n.toString("utf8")), o = a.payload;
2856
- if (a.type !== "response_item" || o?.type !== "custom_tool_call_output" || o.call_id !== i.callId || Bi(o) !== i.turnId || !Array.isArray(o.output)) throw Error("Original image identity changed.");
2857
- let c = o.output[i.imageIndex], l = Vi(c);
2858
- if (!l || Hi(l) !== i.hash) throw Error("Original image bytes changed.");
2858
+ if (a.type !== "response_item" || o?.type !== "custom_tool_call_output" || o.call_id !== i.callId || zi(o) !== i.turnId || !Array.isArray(o.output)) throw Error("Original image identity changed.");
2859
+ let c = o.output[i.imageIndex], l = Bi(c);
2860
+ if (!l || Vi(l) !== i.hash) throw Error("Original image bytes changed.");
2859
2861
  if (s = l, this.disposed || this.paths.get(e) !== r.path) throw Error("Conversation image reader was released.");
2860
2862
  } finally {
2861
2863
  await t.close();
@@ -2864,7 +2866,7 @@ var Fi = 256 * 1024 * 1024, Ii = 32 * 1024 * 1024, Li = 20 * 1024 * 1024, Ri = 2
2864
2866
  for (this.images.set(t, {
2865
2867
  signature: a,
2866
2868
  url: s
2867
- }); this.images.size > 2 || [...this.images.values()].reduce((e, t) => e + t.url.length, 0) > Li;) this.images.delete(this.images.keys().next().value);
2869
+ }); this.images.size > 2 || [...this.images.values()].reduce((e, t) => e + t.url.length, 0) > Ii;) this.images.delete(this.images.keys().next().value);
2868
2870
  let c = Math.min(s.length, n + 64 * 1024);
2869
2871
  return {
2870
2872
  data: Buffer.from(s.slice(n, c)).toString("base64"),
@@ -2885,15 +2887,15 @@ var Fi = 256 * 1024 * 1024, Ii = 32 * 1024 * 1024, Li = 20 * 1024 * 1024, Ri = 2
2885
2887
  t = n.path, this.paths.set(e, t);
2886
2888
  }
2887
2889
  let n = await se(t);
2888
- if (!n.isFile() || n.size > Fi) throw Error("Original history exceeds the read limit.");
2889
- let r = Ui(n), i = this.indexes.get(e);
2890
+ if (!n.isFile()) throw Error("Original history is not a file.");
2891
+ let r = Hi(n), i = this.indexes.get(e);
2890
2892
  if (i?.signature === r) return i;
2891
2893
  let a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), s = await ae(t, "r");
2892
2894
  try {
2893
- await Wi(s, e);
2895
+ await Ui(s, e);
2894
2896
  let t = 0;
2895
- for await (let r of Gi(s, n.size)) {
2896
- if (++t > 1e5 || a.size >= Ri) break;
2897
+ for await (let r of Wi(s, n.size)) {
2898
+ if (++t > 1e5 || a.size >= Li) break;
2897
2899
  let n;
2898
2900
  try {
2899
2901
  n = JSON.parse(r.text);
@@ -2902,7 +2904,7 @@ var Fi = 256 * 1024 * 1024, Ii = 32 * 1024 * 1024, Li = 20 * 1024 * 1024, Ri = 2
2902
2904
  }
2903
2905
  let i = n?.payload;
2904
2906
  if (n?.type !== "response_item" || !i || typeof i.call_id != "string" || !i.call_id || i.call_id.length > 256) continue;
2905
- let s = Bi(i);
2907
+ let s = zi(i);
2906
2908
  if (s) {
2907
2909
  if (i.type === "custom_tool_call") {
2908
2910
  o.size < 4096 && o.set(i.call_id, s);
@@ -2910,10 +2912,10 @@ var Fi = 256 * 1024 * 1024, Ii = 32 * 1024 * 1024, Li = 20 * 1024 * 1024, Ri = 2
2910
2912
  }
2911
2913
  if (!(i.type !== "custom_tool_call_output" || o.get(i.call_id) !== s || !Array.isArray(i.output))) {
2912
2914
  o.delete(i.call_id);
2913
- for (let t = 0; t < Math.min(i.output.length, 256) && a.size < Ri; t++) {
2914
- let n = Vi(i.output[t]);
2915
+ for (let t = 0; t < Math.min(i.output.length, 256) && a.size < Li; t++) {
2916
+ let n = Bi(i.output[t]);
2915
2917
  if (!n) continue;
2916
- let o = Hi(n), c = Hi(JSON.stringify([
2918
+ let o = Vi(n), c = Vi(JSON.stringify([
2917
2919
  e,
2918
2920
  s,
2919
2921
  i.call_id,
@@ -2930,6 +2932,7 @@ var Fi = 256 * 1024 * 1024, Ii = 32 * 1024 * 1024, Li = 20 * 1024 * 1024, Ri = 2
2930
2932
  hash: o,
2931
2933
  part: {
2932
2934
  type: "media",
2935
+ phase: "commentary",
2933
2936
  itemId: `original-image:${i.call_id}:${t}`,
2934
2937
  media: {
2935
2938
  url: `conversation-image:${encodeURIComponent(e)}:${c}`,
@@ -2957,24 +2960,24 @@ var Fi = 256 * 1024 * 1024, Ii = 32 * 1024 * 1024, Li = 20 * 1024 * 1024, Ri = 2
2957
2960
  return c;
2958
2961
  }
2959
2962
  };
2960
- function Bi(e) {
2963
+ function zi(e) {
2961
2964
  let t = e.internal_chat_message_metadata_passthrough;
2962
2965
  return t && typeof t == "object" && "turn_id" in t && typeof t.turn_id == "string" && t.turn_id.length <= 256 ? t.turn_id : void 0;
2963
2966
  }
2964
- function Vi(e) {
2965
- if (!(!e || typeof e != "object" || !("type" in e) || e.type !== "input_image" || !("image_url" in e) || typeof e.image_url != "string" || e.image_url.length > Li)) return Hn(e.image_url)?.url;
2967
+ function Bi(e) {
2968
+ if (!(!e || typeof e != "object" || !("type" in e) || e.type !== "input_image" || !("image_url" in e) || typeof e.image_url != "string" || e.image_url.length > Ii)) return Hn(e.image_url)?.url;
2966
2969
  }
2967
- function Hi(e) {
2970
+ function Vi(e) {
2968
2971
  return C("sha256").update(e).digest("hex");
2969
2972
  }
2970
- function Ui(e) {
2973
+ function Hi(e) {
2971
2974
  return `${e.dev}:${e.ino}:${e.size}:${e.mtimeMs}`;
2972
2975
  }
2973
- async function Wi(e, t) {
2976
+ async function Ui(e, t) {
2974
2977
  let n = Buffer.alloc(64 * 1024), { bytesRead: r } = await e.read(n, 0, n.length, 0), i = n.subarray(0, r).toString("utf8").split("\n", 1)[0], a = JSON.parse(i);
2975
2978
  if (a?.type !== "session_meta" || a.payload?.id !== t) throw Error("Original history belongs to a different conversation.");
2976
2979
  }
2977
- async function* Gi(e, t) {
2980
+ async function* Wi(e, t) {
2978
2981
  let n = 0, r = 0, i = 0, a = [];
2979
2982
  for (; n < t;) {
2980
2983
  let o = Buffer.alloc(Math.min(64 * 1024, t - n)), { bytesRead: s } = await e.read(o, 0, o.length, n);
@@ -2982,7 +2985,7 @@ async function* Gi(e, t) {
2982
2985
  let c = 0;
2983
2986
  for (; c < s;) {
2984
2987
  let e = o.indexOf(10, c), t = e < 0 || e >= s ? s : e, l = o.subarray(c, t);
2985
- i += l.length, i <= Ii ? a.push(l) : a = [], e >= 0 && e < s && (i <= Ii && (yield {
2988
+ i += l.length, i <= Fi ? a.push(l) : a = [], e >= 0 && e < s && (i <= Fi && (yield {
2986
2989
  offset: r,
2987
2990
  length: i,
2988
2991
  text: Buffer.concat(a, i).toString("utf8")
@@ -2991,7 +2994,7 @@ async function* Gi(e, t) {
2991
2994
  n += s;
2992
2995
  }
2993
2996
  }
2994
- function Ki(e) {
2997
+ function Gi(e) {
2995
2998
  return e.map((e) => {
2996
2999
  let t = new Set(e.parts.filter((e) => e.type === "tool" && e.title === "view_image").map((e) => e.type === "tool" ? e.id : ""));
2997
3000
  return t.size ? {
@@ -3002,22 +3005,22 @@ function Ki(e) {
3002
3005
  }
3003
3006
  //#endregion
3004
3007
  //#region src/node/codex-surface-realtime.ts
3005
- function qi(e, t) {
3008
+ function Ki(e, t) {
3006
3009
  if (e === void 0) return;
3007
3010
  if (typeof e != "string") throw TypeError(`Realtime ${t} must be a string`);
3008
3011
  let n = e.trim();
3009
3012
  if (!n) throw TypeError(`Realtime ${t} cannot be empty`);
3010
3013
  return n;
3011
3014
  }
3012
- function Ji(e, t) {
3015
+ function qi(e, t) {
3013
3016
  if (typeof e != "string") throw TypeError(`Realtime ${t} must be a string`);
3014
3017
  let n = e.trim();
3015
3018
  if (!n) throw TypeError(`Realtime ${t} cannot be empty`);
3016
3019
  return n;
3017
3020
  }
3018
- function Yi(e) {
3021
+ function Ji(e) {
3019
3022
  if (!(e.data instanceof Uint8Array)) throw TypeError("Realtime audio data must be a Uint8Array");
3020
- let t = Zi(e.sampleRate, "sampleRate"), n = Zi(e.numChannels, "numChannels"), r = e.samplesPerChannel === void 0 ? Math.floor(e.data.byteLength / 2 / n) : Qi(e.samplesPerChannel, "samplesPerChannel"), i = e.itemId === void 0 ? null : e.itemId;
3023
+ let t = Xi(e.sampleRate, "sampleRate"), n = Xi(e.numChannels, "numChannels"), r = e.samplesPerChannel === void 0 ? Math.floor(e.data.byteLength / 2 / n) : Zi(e.samplesPerChannel, "samplesPerChannel"), i = e.itemId === void 0 ? null : e.itemId;
3021
3024
  if (i !== null && (typeof i != "string" || !i.trim())) throw TypeError("Realtime audio itemId must be a non-empty string or null");
3022
3025
  return {
3023
3026
  data: Buffer.from(e.data.buffer, e.data.byteOffset, e.data.byteLength).toString("base64"),
@@ -3027,7 +3030,7 @@ function Yi(e) {
3027
3030
  itemId: i
3028
3031
  };
3029
3032
  }
3030
- function Xi(e) {
3033
+ function Yi(e) {
3031
3034
  return {
3032
3035
  data: new Uint8Array(Buffer.from(e.data, "base64")),
3033
3036
  sampleRate: e.sampleRate,
@@ -3036,28 +3039,28 @@ function Xi(e) {
3036
3039
  itemId: e.itemId
3037
3040
  };
3038
3041
  }
3039
- function Zi(e, t) {
3042
+ function Xi(e, t) {
3040
3043
  if (!Number.isSafeInteger(e) || e <= 0) throw TypeError(`Realtime audio ${t} must be a positive integer`);
3041
3044
  return e;
3042
3045
  }
3043
- function Qi(e, t) {
3046
+ function Zi(e, t) {
3044
3047
  if (e === null) return null;
3045
3048
  if (!Number.isSafeInteger(e) || e < 0) throw TypeError(`Realtime audio ${t} must be a non-negative integer or null`);
3046
3049
  return e;
3047
3050
  }
3048
3051
  //#endregion
3049
3052
  //#region src/node/codex-surface-realtime-session.ts
3050
- async function $i(e) {
3053
+ async function Qi(e) {
3051
3054
  let { client: t, ensureThreadReady: n, onConversationEvent: r, options: i, threadId: a } = e;
3052
3055
  await n();
3053
3056
  let o = i.outputModality;
3054
3057
  if (o !== "text" && o !== "audio") throw TypeError(`Invalid realtime output modality '${String(o)}'`);
3055
3058
  let s = i.version;
3056
3059
  if (s !== void 0 && s !== "v1" && s !== "v2" && s !== "v3") throw TypeError(`Invalid realtime version '${String(s)}'`);
3057
- let c = qi(i.model, "model"), l = qi(i.voice, "voice"), u = i.transport ?? { type: "websocket" };
3060
+ let c = Ki(i.model, "model"), l = Ki(i.voice, "voice"), u = i.transport ?? { type: "websocket" };
3058
3061
  if (u.type !== "websocket" && u.type !== "webrtc") throw TypeError(`Invalid realtime transport '${String(u.type)}'`);
3059
3062
  if (u.type === "webrtc" && !u.sdp.trim()) throw TypeError("WebRTC realtime transport requires a non-empty SDP offer");
3060
- let d = u.type === "webrtc" ? ea(r) : null, f;
3063
+ let d = u.type === "webrtc" ? $i(r) : null, f;
3061
3064
  try {
3062
3065
  let [, e] = await Promise.all([t.request("thread/realtime/start", {
3063
3066
  threadId: a,
@@ -3088,12 +3091,12 @@ async function $i(e) {
3088
3091
  if (m(), u.type === "webrtc") throw Error("WebRTC realtime audio must be sent through its negotiated media track");
3089
3092
  await t.request("thread/realtime/appendAudio", {
3090
3093
  threadId: a,
3091
- audio: Yi(e)
3094
+ audio: Ji(e)
3092
3095
  });
3093
3096
  },
3094
3097
  appendText: async (e, n = "user") => {
3095
3098
  m();
3096
- let r = Ji(e, "text");
3099
+ let r = qi(e, "text");
3097
3100
  if (n !== "user" && n !== "developer" && n !== "assistant") throw TypeError(`Invalid realtime text role '${String(n)}'`);
3098
3101
  await t.request("thread/realtime/appendText", {
3099
3102
  threadId: a,
@@ -3104,7 +3107,7 @@ async function $i(e) {
3104
3107
  appendSpeech: async (e) => {
3105
3108
  m(), await t.request("thread/realtime/appendSpeech", {
3106
3109
  threadId: a,
3107
- text: Ji(e, "speech")
3110
+ text: qi(e, "speech")
3108
3111
  });
3109
3112
  },
3110
3113
  stop: async () => {
@@ -3115,7 +3118,7 @@ async function $i(e) {
3115
3118
  })
3116
3119
  };
3117
3120
  }
3118
- function ea(e) {
3121
+ function $i(e) {
3119
3122
  let t = () => void 0, n, r = !1, i = () => {
3120
3123
  r || (r = !0, clearTimeout(n), t());
3121
3124
  };
@@ -3132,7 +3135,7 @@ function ea(e) {
3132
3135
  }
3133
3136
  //#endregion
3134
3137
  //#region src/node/codex-surface-runtime.ts
3135
- function ta(e) {
3138
+ function ea(e) {
3136
3139
  return {
3137
3140
  status: "idle",
3138
3141
  authentication: e,
@@ -3175,7 +3178,7 @@ function ta(e) {
3175
3178
  error: null
3176
3179
  };
3177
3180
  }
3178
- function na(e, t, n = {}) {
3181
+ function ta(e, t, n = {}) {
3179
3182
  return {
3180
3183
  threadId: e,
3181
3184
  cwd: null,
@@ -3215,7 +3218,7 @@ function na(e, t, n = {}) {
3215
3218
  ...n
3216
3219
  };
3217
3220
  }
3218
- function ra(e, t, n) {
3221
+ function na(e, t, n) {
3219
3222
  let r = [...n], i = new Set(r.map((e) => e.id)), a = new Set(e.answeredClientRequestIds);
3220
3223
  for (let t of e.messages) {
3221
3224
  let e = t.metadata?.asyncQuestionRequestIds;
@@ -3258,7 +3261,7 @@ function ra(e, t, n) {
3258
3261
  }
3259
3262
  //#endregion
3260
3263
  //#region src/node/codex-surface-authentication.ts
3261
- function ia() {
3264
+ function ra() {
3262
3265
  return {
3263
3266
  status: "notLoaded",
3264
3267
  account: null,
@@ -3272,7 +3275,7 @@ function ia() {
3272
3275
  }
3273
3276
  };
3274
3277
  }
3275
- function aa(e) {
3278
+ function ia(e) {
3276
3279
  return e.type === "chatgpt" ? {
3277
3280
  type: "chatgpt",
3278
3281
  email: e.email,
@@ -3282,13 +3285,13 @@ function aa(e) {
3282
3285
  credentialSource: e.usesCodexManagedCredentials ? "codexManaged" : "awsManaged"
3283
3286
  } : { type: "apiKey" };
3284
3287
  }
3285
- function oa(e) {
3288
+ function aa(e) {
3286
3289
  return JSON.stringify({
3287
3290
  account: e.account,
3288
3291
  requiresOpenaiAuth: e.requiresOpenaiAuth
3289
3292
  });
3290
3293
  }
3291
- function sa(e) {
3294
+ function oa(e) {
3292
3295
  let t = e.account;
3293
3296
  return t ? t.type === "chatgpt" ? JSON.stringify({
3294
3297
  type: t.type,
@@ -3301,12 +3304,12 @@ function sa(e) {
3301
3304
  requiresOpenaiAuth: e.requiresOpenaiAuth
3302
3305
  });
3303
3306
  }
3304
- function ca(e) {
3307
+ function sa(e) {
3305
3308
  let t = e.trim();
3306
3309
  if (!t) throw Error("Codex login id cannot be empty");
3307
3310
  return t;
3308
3311
  }
3309
- function la(e) {
3312
+ function ca(e) {
3310
3313
  let t;
3311
3314
  try {
3312
3315
  t = new URL(e);
@@ -3321,38 +3324,38 @@ function la(e) {
3321
3324
  function q(e, t) {
3322
3325
  return e.find((e) => e.id === t || e.model === t) ?? e.find((e) => e.isDefault) ?? e[0] ?? null;
3323
3326
  }
3324
- function ua(e, t) {
3327
+ function la(e, t) {
3325
3328
  let n = e.find((e) => e.id === t || e.model === t);
3326
3329
  if (!n) throw Error(`Unknown model '${t}'`);
3327
3330
  return n;
3328
3331
  }
3329
- function da(e, t) {
3332
+ function ua(e, t) {
3330
3333
  if (!t) return;
3331
3334
  if (!e) throw Error(`Cannot select reasoning effort '${t}' without a model`);
3332
3335
  let n = e.supportedReasoningEfforts?.map((e) => e.reasoningEffort) ?? [];
3333
3336
  if (n.length > 0 && !n.includes(t)) throw Error(`Reasoning effort '${t}' is not available for '${e.displayName}'`);
3334
3337
  }
3335
- function fa(e) {
3338
+ function da(e) {
3336
3339
  return e.defaultReasoningEffort ?? e.supportedReasoningEfforts?.[0]?.reasoningEffort ?? null;
3337
3340
  }
3338
- function pa(e) {
3341
+ function fa(e) {
3339
3342
  return e.defaultServiceTier ?? null;
3340
3343
  }
3341
- function ma(e, t) {
3344
+ function pa(e, t) {
3342
3345
  if (!t) return;
3343
3346
  if (!e) throw Error(`Cannot select service tier '${t}' without a model`);
3344
3347
  if (t === "default" || t === e.defaultServiceTier) return;
3345
3348
  let n = e.serviceTiers?.map((e) => e.id) ?? [];
3346
3349
  if (n.length > 0 && !n.includes(t)) throw Error(`Service tier '${t}' is not available for '${e.displayName}'`);
3347
3350
  }
3348
- function ha(e, t) {
3351
+ function ma(e, t) {
3349
3352
  let n = new Set(e.filter((e) => e.allowed).map((e) => e.id)), r = [];
3350
- return n.has(":workspace") && ga(t?.allowedApprovalPolicies, "on-request") && ga(t?.allowedApprovalsReviewers, "user") && r.push("ask-for-approval"), n.has(":workspace") && ga(t?.allowedApprovalPolicies, "on-request") && ga(t?.allowedApprovalsReviewers, "auto_review") && r.push("approve-for-me"), (n.has(":danger-full-access") || n.has(":danger-no-sandbox")) && ga(t?.allowedApprovalPolicies, "never") && ga(t?.allowedApprovalsReviewers, "user") && r.push("full-access"), r;
3353
+ return n.has(":workspace") && ha(t?.allowedApprovalPolicies, "on-request") && ha(t?.allowedApprovalsReviewers, "user") && r.push("ask-for-approval"), n.has(":workspace") && ha(t?.allowedApprovalPolicies, "on-request") && ha(t?.allowedApprovalsReviewers, "auto_review") && r.push("approve-for-me"), (n.has(":danger-full-access") || n.has(":danger-no-sandbox")) && ha(t?.allowedApprovalPolicies, "never") && ha(t?.allowedApprovalsReviewers, "user") && r.push("full-access"), r;
3351
3354
  }
3352
- function ga(e, t) {
3355
+ function ha(e, t) {
3353
3356
  return !Array.isArray(e) || e.length === 0 || e.includes(t);
3354
3357
  }
3355
- function _a(e) {
3358
+ function ga(e) {
3356
3359
  return e === "full-access" ? {
3357
3360
  approvalPolicy: "never",
3358
3361
  approvalsReviewer: "user",
@@ -3363,39 +3366,39 @@ function _a(e) {
3363
3366
  permissions: ":workspace"
3364
3367
  };
3365
3368
  }
3366
- function va(e) {
3367
- return _a(e);
3369
+ function _a(e) {
3370
+ return ga(e);
3368
3371
  }
3369
- function ya(e, t, n, r) {
3372
+ function va(e, t, n, r) {
3370
3373
  let i = r?.id;
3371
3374
  return e === "never" && (n.type === "dangerFullAccess" || i === ":danger-full-access" || i === ":danger-no-sandbox") ? "full-access" : e === "on-request" && (t === "auto_review" || t === "guardian_subagent") ? "approve-for-me" : e === "on-request" ? "ask-for-approval" : null;
3372
3375
  }
3373
- function ba(e, t, n) {
3376
+ function ya(e, t, n) {
3374
3377
  let r = q(t, e.model);
3375
3378
  return {
3376
- approvalPreset: ya(e.approvalPolicy, e.approvalsReviewer, e.sandbox, e.activePermissionProfile) ?? n.approvalPreset,
3379
+ approvalPreset: va(e.approvalPolicy, e.approvalsReviewer, e.sandbox, e.activePermissionProfile) ?? n.approvalPreset,
3377
3380
  planMode: n.planMode,
3378
3381
  selectedModelId: r?.id ?? n.selectedModelId,
3379
- selectedReasoningEffort: e.reasoningEffort ?? (r ? fa(r) : null),
3380
- selectedServiceTier: e.serviceTier === void 0 ? r ? pa(r) : null : e.serviceTier
3382
+ selectedReasoningEffort: e.reasoningEffort ?? (r ? da(r) : null),
3383
+ selectedServiceTier: e.serviceTier === void 0 ? r ? fa(r) : null : e.serviceTier
3381
3384
  };
3382
3385
  }
3383
- function xa(e, t, n) {
3386
+ function ba(e, t, n) {
3384
3387
  let r = q(t, e.model);
3385
3388
  return {
3386
- approvalPreset: ya(e.approvalPolicy, e.approvalsReviewer, e.sandboxPolicy, e.activePermissionProfile) ?? n.approvalPreset,
3389
+ approvalPreset: va(e.approvalPolicy, e.approvalsReviewer, e.sandboxPolicy, e.activePermissionProfile) ?? n.approvalPreset,
3387
3390
  planMode: e.collaborationMode.mode === "plan",
3388
3391
  selectedModelId: r?.id ?? n.selectedModelId,
3389
- selectedReasoningEffort: e.effort ?? (r ? fa(r) : null),
3390
- selectedServiceTier: e.serviceTier === void 0 ? r ? pa(r) : null : e.serviceTier
3392
+ selectedReasoningEffort: e.effort ?? (r ? da(r) : null),
3393
+ selectedServiceTier: e.serviceTier === void 0 ? r ? fa(r) : null : e.serviceTier
3391
3394
  };
3392
3395
  }
3393
- function Sa(e, t) {
3396
+ function xa(e, t) {
3394
3397
  let n = q(e.models, e.selectedModelId);
3395
3398
  if (t.modelId && (n = e.models.find((e) => e.id === t.modelId) ?? null, !n)) throw Error(`Unknown model '${t.modelId}'`);
3396
3399
  let r = t.reasoningEffort ?? e.selectedReasoningEffort, i = t.serviceTier === void 0 ? e.selectedServiceTier ?? null : t.serviceTier, a = n?.supportedReasoningEfforts?.map((e) => e.reasoningEffort) ?? [];
3397
3400
  if (t.reasoningEffort && a.length > 0 && !a.includes(t.reasoningEffort)) throw Error(`Reasoning effort '${t.reasoningEffort}' is not available for '${n.displayName}'`);
3398
- return t.modelId && a.length > 0 && (!r || !a.includes(r)) && (r = n ? fa(n) : null), t.serviceTier !== void 0 && ma(n, i), t.serviceTier === void 0 && t.modelId && i && !n.serviceTiers?.some((e) => e.id === i) && (i = n ? pa(n) : null), {
3401
+ return t.modelId && a.length > 0 && (!r || !a.includes(r)) && (r = n ? da(n) : null), t.serviceTier !== void 0 && pa(n, i), t.serviceTier === void 0 && t.modelId && i && !n.serviceTiers?.some((e) => e.id === i) && (i = n ? fa(n) : null), {
3399
3402
  approvalPreset: t.approvalPreset ?? e.approvalPreset,
3400
3403
  planMode: t.planMode ?? e.planMode,
3401
3404
  selectedModelId: n?.id ?? null,
@@ -3403,7 +3406,7 @@ function Sa(e, t) {
3403
3406
  selectedServiceTier: i
3404
3407
  };
3405
3408
  }
3406
- function Ca(e, t, n) {
3409
+ function Sa(e, t, n) {
3407
3410
  return {
3408
3411
  mode: e ? "plan" : "default",
3409
3412
  settings: {
@@ -3413,12 +3416,12 @@ function Ca(e, t, n) {
3413
3416
  }
3414
3417
  };
3415
3418
  }
3416
- function wa(e, t) {
3419
+ function Ca(e, t) {
3417
3420
  let n = q(e.models, e.selectedModelId), r = t.model ?? n?.model, i = t.reasoningEffort ?? e.selectedReasoningEffort, a = t.planMode ?? e.planMode;
3418
3421
  return {
3419
3422
  ...r ? { model: r } : {},
3420
3423
  ...i ? { effort: i } : {},
3421
- ...r ? { collaborationMode: Ca(a, r, i) } : {},
3424
+ ...r ? { collaborationMode: Sa(a, r, i) } : {},
3422
3425
  ...t.serviceTier === void 0 ? e.selectedServiceTier ? { serviceTier: e.selectedServiceTier } : {} : { serviceTier: t.serviceTier }
3423
3426
  };
3424
3427
  }
@@ -3441,7 +3444,7 @@ function J(e) {
3441
3444
  updatedAt: (/* @__PURE__ */ new Date((e.recencyAt ?? e.updatedAt) * 1e3)).toISOString()
3442
3445
  };
3443
3446
  }
3444
- function Ta(e, t) {
3447
+ function wa(e, t) {
3445
3448
  let n = new Map(e.map((e) => [e.id, e])), r = t.map((e) => {
3446
3449
  let t = n.get(e.id);
3447
3450
  return t && me(t, e) ? t : e;
@@ -3451,15 +3454,15 @@ function Ta(e, t) {
3451
3454
  function Y(e, t) {
3452
3455
  return [t, ...e.filter((e) => e.id !== t.id)].sort((e, t) => t.updatedAt.localeCompare(e.updatedAt));
3453
3456
  }
3454
- function Ea(e, t) {
3455
- let n = t.model ? ua(e.models, t.model) : q(e.models, e.selectedModelId);
3456
- return da(n, t.reasoningEffort), ma(n, t.serviceTier), {
3457
+ function Ta(e, t) {
3458
+ let n = t.model ? la(e.models, t.model) : q(e.models, e.selectedModelId);
3459
+ return ua(n, t.reasoningEffort), pa(n, t.serviceTier), {
3457
3460
  ...t,
3458
- ...t.attachments ? { attachments: Da(t.attachments) } : {},
3461
+ ...t.attachments ? { attachments: Ea(t.attachments) } : {},
3459
3462
  ...t.model && n ? { model: n.model } : {}
3460
3463
  };
3461
3464
  }
3462
- function Da(e) {
3465
+ function Ea(e) {
3463
3466
  return e.map((e) => {
3464
3467
  let t = e.path.trim();
3465
3468
  if (!t) throw Error("Attachment paths cannot be empty");
@@ -3476,14 +3479,14 @@ function Da(e) {
3476
3479
  };
3477
3480
  });
3478
3481
  }
3479
- function Oa(e) {
3482
+ function Da(e) {
3480
3483
  return e.type === "image" ? {
3481
3484
  type: "localImage",
3482
3485
  path: e.path,
3483
3486
  ...e.detail === void 0 ? {} : { detail: e.detail }
3484
3487
  } : ot(e.name ?? g(e.path), e.path);
3485
3488
  }
3486
- function ka(e) {
3489
+ function Oa(e) {
3487
3490
  let t = e.name?.trim() || g(e.path);
3488
3491
  return e.type === "image" ? {
3489
3492
  type: "attachment",
@@ -3504,14 +3507,14 @@ function ka(e) {
3504
3507
  }
3505
3508
  };
3506
3509
  }
3507
- function Aa(e) {
3510
+ function ka(e) {
3508
3511
  let t = e.metadata?.turnId;
3509
3512
  return e.turnId ?? (typeof t == "string" ? t : null);
3510
3513
  }
3511
- function ja(e) {
3514
+ function Aa(e) {
3512
3515
  return e.parts.filter((e) => e.type === "text").map((e) => e.text).join("\n").trim();
3513
3516
  }
3514
- function Ma(e) {
3517
+ function ja(e) {
3515
3518
  return e.parts.flatMap((e) => {
3516
3519
  if (e.type !== "attachment") return [];
3517
3520
  let t = e.attachment, n = t.path;
@@ -3529,7 +3532,7 @@ function Ma(e) {
3529
3532
  }] : [];
3530
3533
  });
3531
3534
  }
3532
- function Na(e) {
3535
+ function Ma(e) {
3533
3536
  return {
3534
3537
  totalTokens: e.totalTokens,
3535
3538
  inputTokens: e.inputTokens,
@@ -3539,7 +3542,7 @@ function Na(e) {
3539
3542
  reasoningOutputTokens: e.reasoningOutputTokens
3540
3543
  };
3541
3544
  }
3542
- function Pa(e) {
3545
+ function Na(e) {
3543
3546
  let t = e.modelContextWindow, n = e.last.totalTokens, r = typeof t == "number" && t > 0 ? Math.min(100, Math.max(0, n / t * 100)) : null;
3544
3547
  return {
3545
3548
  totalTokens: e.total.totalTokens,
@@ -3552,34 +3555,34 @@ function Pa(e) {
3552
3555
  usedPercent: r
3553
3556
  };
3554
3557
  }
3555
- function Fa(e) {
3558
+ function Pa(e) {
3556
3559
  return e.type === "active" ? {
3557
3560
  type: "active",
3558
3561
  activeFlags: [...e.activeFlags]
3559
3562
  } : { type: e.type };
3560
3563
  }
3561
- function Ia(e) {
3564
+ function Fa(e) {
3562
3565
  return e.type === "active" ? "active" : e.type === "systemError" ? "error" : "idle";
3563
3566
  }
3564
- function La(e) {
3565
- let t = e.rateLimitsByLimitId ? Object.fromEntries(Object.entries(e.rateLimitsByLimitId).filter((e) => !!e[1]).map(([e, t]) => [e, Ba(t)])) : null;
3567
+ function Ia(e) {
3568
+ let t = e.rateLimitsByLimitId ? Object.fromEntries(Object.entries(e.rateLimitsByLimitId).filter((e) => !!e[1]).map(([e, t]) => [e, za(t)])) : null;
3566
3569
  return {
3567
- rateLimits: Ba(e.rateLimits),
3570
+ rateLimits: za(e.rateLimits),
3568
3571
  rateLimitsByLimitId: t,
3569
3572
  rateLimitResetCredits: e.rateLimitResetCredits ? {
3570
- availableCount: Ra(e.rateLimitResetCredits.availableCount),
3573
+ availableCount: La(e.rateLimitResetCredits.availableCount),
3571
3574
  credits: e.rateLimitResetCredits.credits?.map((e) => ({ ...e })) ?? null
3572
3575
  } : null
3573
3576
  };
3574
3577
  }
3575
- function Ra(e) {
3578
+ function La(e) {
3576
3579
  if (typeof e == "bigint" && e >= 0n) return e.toString();
3577
3580
  if (typeof e == "number" && Number.isSafeInteger(e) && e >= 0) return String(e);
3578
3581
  if (typeof e == "string" && /^(0|[1-9][0-9]*)$/.test(e)) return e;
3579
3582
  throw Error("Invalid account count: expected an exact nonnegative integer");
3580
3583
  }
3581
- function za(e) {
3582
- let t = (e) => e === null ? null : Ra(e);
3584
+ function Ra(e) {
3585
+ let t = (e) => e === null ? null : La(e);
3583
3586
  return {
3584
3587
  summary: {
3585
3588
  lifetimeTokens: t(e.summary.lifetimeTokens),
@@ -3590,11 +3593,11 @@ function za(e) {
3590
3593
  },
3591
3594
  dailyUsageBuckets: e.dailyUsageBuckets?.map((e) => ({
3592
3595
  startDate: e.startDate,
3593
- tokens: Ra(e.tokens)
3596
+ tokens: La(e.tokens)
3594
3597
  })) ?? null
3595
3598
  };
3596
3599
  }
3597
- function Ba(e) {
3600
+ function za(e) {
3598
3601
  return {
3599
3602
  limitId: e.limitId,
3600
3603
  limitName: e.limitName,
@@ -3606,21 +3609,21 @@ function Ba(e) {
3606
3609
  rateLimitReachedType: e.rateLimitReachedType
3607
3610
  };
3608
3611
  }
3609
- function Va(e, t) {
3610
- let n = Ba(t);
3612
+ function Ba(e, t) {
3613
+ let n = za(t);
3611
3614
  if (!e) return {
3612
3615
  rateLimits: n,
3613
3616
  rateLimitsByLimitId: n.limitId ? { [n.limitId]: n } : null,
3614
3617
  rateLimitResetCredits: null
3615
3618
  };
3616
- let r = Ha(e.rateLimits, n), i = e.rateLimitsByLimitId ? { ...e.rateLimitsByLimitId } : {};
3617
- return r.limitId && (i[r.limitId] = Ha(i[r.limitId] ?? r, n)), {
3619
+ let r = Va(e.rateLimits, n), i = e.rateLimitsByLimitId ? { ...e.rateLimitsByLimitId } : {};
3620
+ return r.limitId && (i[r.limitId] = Va(i[r.limitId] ?? r, n)), {
3618
3621
  ...e,
3619
3622
  rateLimits: r,
3620
3623
  rateLimitsByLimitId: Object.keys(i).length > 0 ? i : null
3621
3624
  };
3622
3625
  }
3623
- function Ha(e, t) {
3626
+ function Va(e, t) {
3624
3627
  return {
3625
3628
  limitId: t.limitId ?? e.limitId,
3626
3629
  limitName: t.limitName ?? e.limitName,
@@ -3646,18 +3649,18 @@ function Ha(e, t) {
3646
3649
  }
3647
3650
  //#endregion
3648
3651
  //#region src/node/codex-surface-transport-options.ts
3649
- function Ua(e) {
3652
+ function Ha(e) {
3650
3653
  return "type" in e && e.type === "unixSocket";
3651
3654
  }
3652
- function Wa(e) {
3653
- let t = e.codexHome === void 0 ? void 0 : Ga(e.codexHome), n = e.transport?.codexHome;
3655
+ function Ua(e) {
3656
+ let t = e.codexHome === void 0 ? void 0 : Wa(e.codexHome), n = e.transport?.codexHome;
3654
3657
  if (t !== void 0 && n !== void 0 && t !== n) throw Error("Codex surface codexHome conflicts with transport.codexHome");
3655
3658
  return {
3656
3659
  ...e.transport ?? {},
3657
3660
  ...t === void 0 ? {} : { codexHome: t }
3658
3661
  };
3659
3662
  }
3660
- function Ga(e) {
3663
+ function Wa(e) {
3661
3664
  let t = e.trim();
3662
3665
  if (!t) throw Error("Codex surface codexHome cannot be empty");
3663
3666
  if (!v(t)) throw Error("Codex surface codexHome must be an absolute path");
@@ -3665,7 +3668,7 @@ function Ga(e) {
3665
3668
  }
3666
3669
  //#endregion
3667
3670
  //#region src/node/codex-surface-authentication-controller.ts
3668
- var Ka = class {
3671
+ var Ga = class {
3669
3672
  client;
3670
3673
  host;
3671
3674
  accountRefreshPromise = null;
@@ -3699,7 +3702,7 @@ var Ka = class {
3699
3702
  try {
3700
3703
  let e = await this.client.request("account/login/start", { type: "chatgpt" });
3701
3704
  if (e.type !== "chatgpt") throw Error(`Codex account/login/start returned unexpected login type '${e.type}'`);
3702
- let t = ca(e.loginId), n = la(e.authUrl);
3705
+ let t = sa(e.loginId), n = ca(e.authUrl);
3703
3706
  return this.host.patchAuthentication({ login: {
3704
3707
  status: "pending",
3705
3708
  loginId: t,
@@ -3736,7 +3739,7 @@ var Ka = class {
3736
3739
  try {
3737
3740
  let e = await this.client.request("account/login/start", { type: "chatgptDeviceCode" });
3738
3741
  if (e.type !== "chatgptDeviceCode") throw Error(`Codex account/login/start returned unexpected login type '${e.type}'`);
3739
- let t = ca(e.loginId), n = la(e.verificationUrl), r = e.userCode.trim();
3742
+ let t = sa(e.loginId), n = ca(e.verificationUrl), r = e.userCode.trim();
3740
3743
  if (!r) throw Error("Codex account/login/start returned an empty device user code");
3741
3744
  this.host.patchAuthentication({ login: {
3742
3745
  status: "pending",
@@ -3764,7 +3767,7 @@ var Ka = class {
3764
3767
  }).catch(() => void 0), t;
3765
3768
  }
3766
3769
  async cancelLogin(e) {
3767
- let t = ca(e), n = await this.client.request("account/login/cancel", { loginId: t });
3770
+ let t = sa(e), n = await this.client.request("account/login/cancel", { loginId: t });
3768
3771
  return this.host.patchAuthentication({ login: {
3769
3772
  status: n.status === "canceled" ? "cancelled" : "idle",
3770
3773
  loginId: null,
@@ -3806,7 +3809,7 @@ var Ka = class {
3806
3809
  error: null
3807
3810
  }, e);
3808
3811
  try {
3809
- let n = await this.client.request("account/read", { refreshToken: !1 }), r = n.account ? aa(n.account) : null, i = sa({
3812
+ let n = await this.client.request("account/read", { refreshToken: !1 }), r = n.account ? ia(n.account) : null, i = oa({
3810
3813
  ...this.host.getSnapshot().authentication,
3811
3814
  account: r,
3812
3815
  requiresOpenaiAuth: n.requiresOpenaiAuth
@@ -3849,7 +3852,7 @@ var Ka = class {
3849
3852
  };
3850
3853
  //#endregion
3851
3854
  //#region src/node/codex-conversation-handle.ts
3852
- function qa(e, t) {
3855
+ function Ka(e, t) {
3853
3856
  let n = async (e) => (await e(), t.getSnapshot());
3854
3857
  return {
3855
3858
  id: e,
@@ -3894,19 +3897,19 @@ function qa(e, t) {
3894
3897
  }
3895
3898
  //#endregion
3896
3899
  //#region src/node/codex-raw-response-item-adapter.ts
3897
- function Ja(e) {
3898
- if (!ro(e) || typeof e.type != "string") return null;
3900
+ function qa(e) {
3901
+ if (!no(e) || typeof e.type != "string") return null;
3899
3902
  if (e.type === "local_shell_call") {
3900
- let t = T(Ya(e));
3903
+ let t = T(Ja(e));
3901
3904
  return {
3902
- type: $a(e.status) ? "item.completed" : "item.started",
3905
+ type: Qa(e.status) ? "item.completed" : "item.started",
3903
3906
  payload: { toolPart: t }
3904
3907
  };
3905
3908
  }
3906
3909
  return e.type === "function_call" ? {
3907
3910
  type: "item.started",
3908
- payload: { toolPart: T(Xa(e)) }
3909
- } : e.type === "function_call_output" ? Za(e.call_id, e.output) : e.type === "custom_tool_call" ? {
3911
+ payload: { toolPart: T(Ya(e)) }
3912
+ } : e.type === "function_call_output" ? Xa(e.call_id, e.output) : e.type === "custom_tool_call" ? {
3910
3913
  type: "item.started",
3911
3914
  payload: { toolPart: T({
3912
3915
  type: "dynamicToolCall",
@@ -3919,7 +3922,7 @@ function Ja(e) {
3919
3922
  success: null,
3920
3923
  durationMs: null
3921
3924
  }) }
3922
- } : e.type === "custom_tool_call_output" ? Za(e.call_id, e.output, Z(e.name) ?? void 0) : e.type === "tool_search_call" ? {
3925
+ } : e.type === "custom_tool_call_output" ? Xa(e.call_id, e.output, Z(e.name) ?? void 0) : e.type === "tool_search_call" ? {
3923
3926
  type: "item.started",
3924
3927
  payload: { toolPart: T({
3925
3928
  type: "dynamicToolCall",
@@ -3941,7 +3944,7 @@ function Ja(e) {
3941
3944
  payload: { toolPart: T({
3942
3945
  type: "webSearch",
3943
3946
  id: X(e),
3944
- query: to(e.action),
3947
+ query: eo(e.action),
3945
3948
  action: e.action
3946
3949
  }) }
3947
3950
  } : e.type === "image_generation_call" ? {
@@ -3959,8 +3962,8 @@ function Ja(e) {
3959
3962
  }) }
3960
3963
  } : null;
3961
3964
  }
3962
- function Ya(e) {
3963
- let t = ro(e.action) ? e.action : {}, n = Array.isArray(t.command) ? no(t.command) : Z(t.command) ?? "local shell";
3965
+ function Ja(e) {
3966
+ let t = no(e.action) ? e.action : {}, n = Array.isArray(t.command) ? to(t.command) : Z(t.command) ?? "local shell";
3964
3967
  return {
3965
3968
  type: "commandExecution",
3966
3969
  id: Z(e.call_id) ?? X(e),
@@ -3968,16 +3971,16 @@ function Ya(e) {
3968
3971
  cwd: Z(t.working_directory) ?? "",
3969
3972
  processId: null,
3970
3973
  source: "agent",
3971
- status: Qa(e.status),
3974
+ status: Za(e.status),
3972
3975
  commandActions: [],
3973
3976
  aggregatedOutput: null,
3974
3977
  exitCode: null,
3975
3978
  durationMs: null
3976
3979
  };
3977
3980
  }
3978
- function Xa(e) {
3979
- let t = Z(e.name) ?? "function_call", n = eo(e.arguments), r = Z(e.call_id) ?? X(e);
3980
- return t === "shell_command" && ro(n) ? {
3981
+ function Ya(e) {
3982
+ let t = Z(e.name) ?? "function_call", n = $a(e.arguments), r = Z(e.call_id) ?? X(e);
3983
+ return t === "shell_command" && no(n) ? {
3981
3984
  type: "commandExecution",
3982
3985
  id: r,
3983
3986
  command: Z(n.command) ?? t,
@@ -4001,19 +4004,19 @@ function Xa(e) {
4001
4004
  durationMs: null
4002
4005
  };
4003
4006
  }
4004
- function Za(e, t, n) {
4007
+ function Xa(e, t, n) {
4005
4008
  return {
4006
4009
  type: "item.updated",
4007
4010
  payload: yt(Z(e) ?? "raw-response-output", t, n)
4008
4011
  };
4009
4012
  }
4010
- function Qa(e) {
4013
+ function Za(e) {
4011
4014
  return e === "completed" ? "completed" : e === "incomplete" || e === "failed" || e === "error" ? "failed" : "inProgress";
4012
4015
  }
4013
- function $a(e) {
4016
+ function Qa(e) {
4014
4017
  return e === "completed" || e === "failed" || e === "error" || e === "incomplete";
4015
4018
  }
4016
- function eo(e) {
4019
+ function $a(e) {
4017
4020
  if (typeof e != "string") return e;
4018
4021
  try {
4019
4022
  return JSON.parse(e);
@@ -4021,10 +4024,10 @@ function eo(e) {
4021
4024
  return e;
4022
4025
  }
4023
4026
  }
4024
- function to(e) {
4025
- return ro(e) ? Z(e.query) ?? Z(e.searchTerm) ?? "web search" : "web search";
4027
+ function eo(e) {
4028
+ return no(e) ? Z(e.query) ?? Z(e.searchTerm) ?? "web search" : "web search";
4026
4029
  }
4027
- function no(e) {
4030
+ function to(e) {
4028
4031
  return e.map((e) => {
4029
4032
  let t = String(e);
4030
4033
  return /\s/.test(t) ? JSON.stringify(t) : t;
@@ -4036,21 +4039,21 @@ function X(e) {
4036
4039
  function Z(e) {
4037
4040
  return typeof e == "string" && e.length > 0 ? e : null;
4038
4041
  }
4039
- function ro(e) {
4042
+ function no(e) {
4040
4043
  return !!(e && typeof e == "object" && !Array.isArray(e));
4041
4044
  }
4042
4045
  //#endregion
4043
4046
  //#region src/node/codex-surface-events.ts
4044
- function io(e, t) {
4047
+ function ro(e, t) {
4045
4048
  return `${e}\u0000${t}`;
4046
4049
  }
4047
- function ao(e) {
4050
+ function io(e) {
4048
4051
  return typeof e == "number" && Number.isFinite(e) ? (/* @__PURE__ */ new Date(e * 1e3)).toISOString() : (/* @__PURE__ */ new Date()).toISOString();
4049
4052
  }
4050
- function oo(e) {
4053
+ function ao(e) {
4051
4054
  return typeof e == "number" && Number.isFinite(e) ? (/* @__PURE__ */ new Date(e * 1e3)).toISOString() : null;
4052
4055
  }
4053
- function so(e) {
4056
+ function oo(e) {
4054
4057
  return e ? {
4055
4058
  message: e.message,
4056
4059
  additionalDetails: e.additionalDetails,
@@ -4062,10 +4065,10 @@ function Q(e, t = !1) {
4062
4065
  id: e.id,
4063
4066
  ...e.itemsView === "summary" || e.itemsView === "notLoaded" ? { itemsView: "summary" } : {},
4064
4067
  status: e.status,
4065
- error: so(e.error),
4068
+ error: oo(e.error),
4066
4069
  willRetry: t,
4067
- startedAt: oo(e.startedAt),
4068
- completedAt: oo(e.completedAt),
4070
+ startedAt: ao(e.startedAt),
4071
+ completedAt: ao(e.completedAt),
4069
4072
  durationMs: e.durationMs ?? null
4070
4073
  };
4071
4074
  }
@@ -4078,18 +4081,18 @@ function $(e, t) {
4078
4081
  startedAt: t.startedAt ?? e[n].startedAt
4079
4082
  }), r;
4080
4083
  }
4081
- function co(e, t) {
4084
+ function so(e, t) {
4082
4085
  return JSON.stringify(e) === JSON.stringify(t);
4083
4086
  }
4084
- function lo() {
4087
+ function co() {
4085
4088
  return `user-${globalThis.crypto.randomUUID()}`;
4086
4089
  }
4087
- function uo() {
4090
+ function lo() {
4088
4091
  return `queued-prompt-${globalThis.crypto.randomUUID()}`;
4089
4092
  }
4090
4093
  //#endregion
4091
4094
  //#region src/node/codex-surface-subagents.ts
4092
- function fo(e) {
4095
+ function uo(e) {
4093
4096
  let t = {};
4094
4097
  for (let [n, r] of Object.entries(e.agentsStates)) r && (t[n] = {
4095
4098
  status: r.status,
@@ -4109,7 +4112,7 @@ function fo(e) {
4109
4112
  }
4110
4113
  //#endregion
4111
4114
  //#region src/node/codex-surface-items-controller.ts
4112
- var po = class {
4115
+ var fo = class {
4113
4116
  host;
4114
4117
  commandOutputForwardItemIds = /* @__PURE__ */ new Set();
4115
4118
  fileActivityKeys = /* @__PURE__ */ new Set();
@@ -4127,7 +4130,7 @@ var po = class {
4127
4130
  for (let e of this.reviewOutputByTurn.keys()) e.startsWith(t) && this.reviewOutputByTurn.delete(e);
4128
4131
  }
4129
4132
  isForwardingCommandOutput(e, t) {
4130
- return this.commandOutputForwardItemIds.has(io(e, t));
4133
+ return this.commandOutputForwardItemIds.has(ro(e, t));
4131
4134
  }
4132
4135
  applyAgentDelta(e) {
4133
4136
  let t = this.host.requireRuntime(e.threadId);
@@ -4190,7 +4193,7 @@ var po = class {
4190
4193
  applyRawResponseItem(e) {
4191
4194
  let t = this.host.requireRuntime(e.threadId);
4192
4195
  this.host.markRuntimeTurnActive(t, e.turnId);
4193
- let n = Ja(e.item);
4196
+ let n = qa(e.item);
4194
4197
  if (!n) return;
4195
4198
  if (n.type === "item.updated") {
4196
4199
  this.applyToolUpdate(e.threadId, e.turnId, n.payload);
@@ -4290,7 +4293,7 @@ var po = class {
4290
4293
  if (e.item.type === "agentMessage" || e.item.type === "exitedReviewMode") {
4291
4294
  let t = e.item.type === "agentMessage" ? e.item.text : e.item.review, r = e.item.type === "agentMessage" ? e.item.phase ?? void 0 : void 0;
4292
4295
  if (!t && e.item.type !== "agentMessage") return;
4293
- let i = io(e.threadId, e.turnId);
4296
+ let i = ro(e.threadId, e.turnId);
4294
4297
  if (e.item.type === "agentMessage" && this.reviewOutputByTurn.get(i) === t) return;
4295
4298
  e.item.type === "exitedReviewMode" && this.reviewOutputByTurn.set(i, t);
4296
4299
  let a = new Set(n.messages.map((e) => e.id)), o = this.host.assistantMessageForTurn(e.threadId, e.turnId), s = o ? JSON.stringify(o.parts) : null, c = new Set(o?.parts.flatMap((e) => e.type === "question" ? [e.request.id] : []) ?? []), l = n.messages.flatMap((e) => e.parts).find((t) => t.type === "text" && t.itemId === e.item.id)?.text ?? "", u = e.item.type === "agentMessage" ? jn(e.threadId, e.turnId, e.item) : null, d = u ? "" : t, f = u ? pn(n.messages, e.threadId, e.turnId, e.item.id) : fn(n.messages, e.threadId, e.turnId, e.item.id, t, r);
@@ -4376,7 +4379,7 @@ var po = class {
4376
4379
  turnId: e.turnId,
4377
4380
  payload: {
4378
4381
  lifecycle: t ? "completed" : "started",
4379
- toolCall: fo(e.item)
4382
+ toolCall: uo(e.item)
4380
4383
  }
4381
4384
  });
4382
4385
  return;
@@ -4425,7 +4428,7 @@ var po = class {
4425
4428
  shouldForwardCommandOutput(e, t, n) {
4426
4429
  let r = "id" in n && typeof n.id == "string" ? n.id : null;
4427
4430
  if (!r) return !1;
4428
- let i = io(e, r);
4431
+ let i = ro(e, r);
4429
4432
  if (!t) {
4430
4433
  let e = ht(n);
4431
4434
  return e ? this.commandOutputForwardItemIds.add(i) : this.commandOutputForwardItemIds.delete(i), e;
@@ -4436,7 +4439,7 @@ var po = class {
4436
4439
  applyToolUpdate(e, t, n) {
4437
4440
  let r = this.host.requireRuntime(e);
4438
4441
  this.host.markRuntimeTurnActive(r, t);
4439
- let i = r.cwd && mo(n) ? {
4442
+ let i = r.cwd && po(n) ? {
4440
4443
  ...n,
4441
4444
  metadata: {
4442
4445
  ...n.metadata,
@@ -4505,26 +4508,26 @@ var po = class {
4505
4508
  turnId: e.turn.id,
4506
4509
  payload: {
4507
4510
  status: e.turn.status,
4508
- error: so(e.turn.error),
4511
+ error: oo(e.turn.error),
4509
4512
  willRetry: !1,
4510
- startedAt: oo(e.turn.startedAt),
4511
- completedAt: oo(e.turn.completedAt),
4513
+ startedAt: ao(e.turn.startedAt),
4514
+ completedAt: ao(e.turn.completedAt),
4512
4515
  durationMs: e.turn.durationMs ?? null
4513
4516
  }
4514
4517
  }), this.host.emitConversationActivity(e.threadId, "notification"), t.planMarkdownByTurn.delete(e.turn.id), this.host.sendNextQueuedPrompt(e.threadId);
4515
4518
  }
4516
4519
  };
4517
- function mo(e) {
4520
+ function po(e) {
4518
4521
  if (e.fallbackToolPart?.kind === "fileChange") return !0;
4519
4522
  let t = e.input, n = e.metadata;
4520
- return ho(t) && Array.isArray(t.changes) || ho(n) && Array.isArray(n.changes);
4523
+ return mo(t) && Array.isArray(t.changes) || mo(n) && Array.isArray(n.changes);
4521
4524
  }
4522
- function ho(e) {
4525
+ function mo(e) {
4523
4526
  return typeof e == "object" && !!e;
4524
4527
  }
4525
4528
  //#endregion
4526
4529
  //#region src/node/codex-surface-client-requests-controller.ts
4527
- var go = class {
4530
+ var ho = class {
4528
4531
  host;
4529
4532
  pending = /* @__PURE__ */ new Map();
4530
4533
  constructor(e) {
@@ -4605,7 +4608,7 @@ var go = class {
4605
4608
  }), this.host.emitConversationActivity(n.threadId, "action");
4606
4609
  }
4607
4610
  async respondToAsyncQuestion(e, t) {
4608
- let n = e ?? this.host.activeConversationId(), r = n === null ? null : this.host.requireRuntime(n), i = r && ra(r, [], []).clientRequests.find((e) => e.kind === "ask_user" && e.id === t.id), a = r && i ? {
4611
+ let n = e ?? this.host.activeConversationId(), r = n === null ? null : this.host.requireRuntime(n), i = r && na(r, [], []).clientRequests.find((e) => e.kind === "ask_user" && e.id === t.id), a = r && i ? {
4609
4612
  request: i,
4610
4613
  runtime: r
4611
4614
  } : null;
@@ -4804,8 +4807,8 @@ ${JSON.stringify(s)}\n</send_user_message_question_reply>`, t = s.length === 1 ?
4804
4807
  payload: { request: structuredClone(d) }
4805
4808
  }), this.host.emitConversationActivity(n.threadId, "notification"), !0;
4806
4809
  }
4807
- }, _o = 256 * 1024;
4808
- function vo(e) {
4810
+ }, go = 256 * 1024;
4811
+ function _o(e) {
4809
4812
  return {
4810
4813
  id: e.id,
4811
4814
  model: e.model,
@@ -4830,11 +4833,11 @@ function vo(e) {
4830
4833
  }
4831
4834
  };
4832
4835
  }
4833
- async function yo(e, t) {
4834
- return Promise.all(e.filter((e) => e.enabled).map((e) => bo(e, t)));
4836
+ async function vo(e, t) {
4837
+ return Promise.all(e.filter((e) => e.enabled).map((e) => yo(e, t)));
4835
4838
  }
4836
- async function bo(e, t) {
4837
- let n = Eo(e.interface?.brandColor), r = Do(e.interface?.defaultPrompt), [i, a] = await Promise.all([e.interface?.iconSmall ? t(e.interface.iconSmall) : void 0, e.interface?.iconLarge ? t(e.interface.iconLarge) : void 0]);
4839
+ async function yo(e, t) {
4840
+ let n = To(e.interface?.brandColor), r = Eo(e.interface?.defaultPrompt), [i, a] = await Promise.all([e.interface?.iconSmall ? t(e.interface.iconSmall) : void 0, e.interface?.iconLarge ? t(e.interface.iconLarge) : void 0]);
4838
4841
  return {
4839
4842
  name: e.name,
4840
4843
  description: e.description,
@@ -4849,8 +4852,8 @@ async function bo(e, t) {
4849
4852
  enabled: e.enabled
4850
4853
  };
4851
4854
  }
4852
- async function xo(e, t) {
4853
- let n = e.interface, r = Co(n?.composerIconUrl), i = Co(n?.logoUrl), a = Co(n?.logoUrlDark), o = Eo(n?.displayName) ?? e.name, s = Eo(n?.shortDescription), c = Eo(n?.longDescription), l = Eo(n?.brandColor), u = r ?? i ?? await So([n?.composerIcon, n?.logo], t), d = r ?? a ?? i ?? await So([
4855
+ async function bo(e, t) {
4856
+ let n = e.interface, r = So(n?.composerIconUrl), i = So(n?.logoUrl), a = So(n?.logoUrlDark), o = To(n?.displayName) ?? e.name, s = To(n?.shortDescription), c = To(n?.longDescription), l = To(n?.brandColor), u = r ?? i ?? await xo([n?.composerIcon, n?.logo], t), d = r ?? a ?? i ?? await xo([
4854
4857
  n?.composerIcon,
4855
4858
  n?.logoDark,
4856
4859
  n?.logo
@@ -4867,20 +4870,20 @@ async function xo(e, t) {
4867
4870
  enabled: e.enabled
4868
4871
  };
4869
4872
  }
4870
- async function So(e, t) {
4873
+ async function xo(e, t) {
4871
4874
  for (let n of e) {
4872
4875
  if (!n) continue;
4873
4876
  let e = await t(n);
4874
4877
  if (e) return e;
4875
4878
  }
4876
4879
  }
4877
- function Co(e) {
4878
- let t = Eo(e);
4880
+ function So(e) {
4881
+ let t = To(e);
4879
4882
  try {
4880
4883
  return new URL(t).protocol === "https:" ? t : void 0;
4881
4884
  } catch {}
4882
4885
  }
4883
- function wo(e) {
4886
+ function Co(e) {
4884
4887
  switch (_(e).toLowerCase()) {
4885
4888
  case ".avif": return "image/avif";
4886
4889
  case ".bmp": return "image/bmp";
@@ -4893,23 +4896,23 @@ function wo(e) {
4893
4896
  case ".webp": return "image/webp";
4894
4897
  }
4895
4898
  }
4896
- function To(e, t) {
4899
+ function wo(e, t) {
4897
4900
  let n = t.trim();
4898
4901
  if (!/^[a-z\d+/]+={0,2}$/i.test(n)) return;
4899
4902
  let r = n.replace(/=+$/, "");
4900
4903
  if (r.length % 4 == 1) return;
4901
4904
  let i = n.length - r.length, a = (4 - r.length % 4) % 4;
4902
- if (!(i !== 0 && i !== a) && !(Math.floor(r.length * 3 / 4) > _o)) return `data:${e};base64,${`${r}${"=".repeat((4 - r.length % 4) % 4)}`}`;
4905
+ if (!(i !== 0 && i !== a) && !(Math.floor(r.length * 3 / 4) > go)) return `data:${e};base64,${`${r}${"=".repeat((4 - r.length % 4) % 4)}`}`;
4903
4906
  }
4904
- function Eo(e) {
4907
+ function To(e) {
4905
4908
  return (typeof e == "string" ? e.trim() : void 0) || void 0;
4906
4909
  }
4907
- function Do(e) {
4910
+ function Eo(e) {
4908
4911
  return typeof e == "string" ? e : void 0;
4909
4912
  }
4910
4913
  //#endregion
4911
4914
  //#region src/node/codex-surface-catalog-controller.ts
4912
- var Oo = class {
4915
+ var Do = class {
4913
4916
  client;
4914
4917
  cwd;
4915
4918
  host;
@@ -4944,7 +4947,7 @@ var Oo = class {
4944
4947
  async loadSkills(e = !1, t = "action") {
4945
4948
  e && this.iconDataUrls.clear(), this.host.patch({ skillCatalogStatus: "loading" }), this.emitSkills(this.cwd ?? null, [], "loading", t);
4946
4949
  try {
4947
- let n = await yo((await this.client.request("skills/list", {
4950
+ let n = await vo((await this.client.request("skills/list", {
4948
4951
  ...this.cwd ? { cwds: [this.cwd] } : {},
4949
4952
  forceReload: e
4950
4953
  })).data.flatMap((e) => e.skills), (e) => this.iconDataUrl(e));
@@ -4961,7 +4964,7 @@ var Oo = class {
4961
4964
  }
4962
4965
  async listSkills(e = {}) {
4963
4966
  await this.host.ensureConnected(), e.forceReload && this.iconDataUrls.clear();
4964
- let t = await yo((await this.client.request("skills/list", {
4967
+ let t = await vo((await this.client.request("skills/list", {
4965
4968
  ...e.cwd ? { cwds: [e.cwd] } : {},
4966
4969
  forceReload: e.forceReload ?? !1
4967
4970
  })).data.flatMap((e) => e.skills), (e) => this.iconDataUrl(e));
@@ -4973,7 +4976,7 @@ var Oo = class {
4973
4976
  }
4974
4977
  async loadPermissionProfiles() {
4975
4978
  try {
4976
- let e = await this.requestPermissionProfiles(this.cwd), t = (await this.client.request("configRequirements/read", void 0)).requirements, n = ha(e, t), r = this.host.preferredApprovalPreset();
4979
+ let e = await this.requestPermissionProfiles(this.cwd), t = (await this.client.request("configRequirements/read", void 0)).requirements, n = ma(e, t), r = this.host.preferredApprovalPreset();
4977
4980
  this.host.patch({
4978
4981
  permissionProfiles: e,
4979
4982
  approvalPresets: n,
@@ -4989,7 +4992,7 @@ var Oo = class {
4989
4992
  }
4990
4993
  async loadRateLimits() {
4991
4994
  try {
4992
- let e = La(await this.client.request("account/rateLimits/read", void 0));
4995
+ let e = Ia(await this.client.request("account/rateLimits/read", void 0));
4993
4996
  this.host.patch({ rateLimits: e }), this.host.emitEvent("action", {
4994
4997
  type: "rateLimits.changed",
4995
4998
  payload: { rateLimits: structuredClone(e) }
@@ -5015,12 +5018,12 @@ var Oo = class {
5015
5018
  }), (async () => ({
5016
5019
  profiles: await this.requestPermissionProfiles(e),
5017
5020
  requirements: (await this.client.request("configRequirements/read", void 0)).requirements
5018
- }))()]), a = r.status === "fulfilled" ? await yo(r.value.data.flatMap((e) => e.skills), (e) => this.iconDataUrl(e)) : [], o = i.status === "fulfilled" ? i.value.profiles : [];
5021
+ }))()]), a = r.status === "fulfilled" ? await vo(r.value.data.flatMap((e) => e.skills), (e) => this.iconDataUrl(e)) : [], o = i.status === "fulfilled" ? i.value.profiles : [];
5019
5022
  return {
5020
5023
  skills: a,
5021
5024
  skillCatalogStatus: r.status === "fulfilled" ? "loaded" : "error",
5022
5025
  permissionProfiles: o,
5023
- approvalPresets: i.status === "fulfilled" ? ha(o, i.value.requirements) : []
5026
+ approvalPresets: i.status === "fulfilled" ? ma(o, i.value.requirements) : []
5024
5027
  };
5025
5028
  }
5026
5029
  schedulePluginRefresh(e = !1) {
@@ -5047,7 +5050,7 @@ var Oo = class {
5047
5050
  cursor: n,
5048
5051
  includeHidden: e
5049
5052
  });
5050
- t.push(...r.data.map(vo)), n = r.nextCursor;
5053
+ t.push(...r.data.map(_o)), n = r.nextCursor;
5051
5054
  } while (n);
5052
5055
  return t;
5053
5056
  }
@@ -5057,8 +5060,8 @@ var Oo = class {
5057
5060
  models: e,
5058
5061
  modelCatalogStatus: "loaded",
5059
5062
  selectedModelId: n?.id ?? null,
5060
- selectedReasoningEffort: n ? fa(n) : null,
5061
- selectedServiceTier: n ? pa(n) : null
5063
+ selectedReasoningEffort: n ? da(n) : null,
5064
+ selectedServiceTier: n ? fa(n) : null
5062
5065
  }), this.emitModels(e, "loaded", t);
5063
5066
  }
5064
5067
  emitModels(e, t, n = "action") {
@@ -5117,7 +5120,7 @@ var Oo = class {
5117
5120
  try {
5118
5121
  let t = await this.client.request("plugin/installed", { ...e.length > 0 ? { cwds: [...e] } : {} }), n = /* @__PURE__ */ new Map();
5119
5122
  for (let e of t.marketplaces) for (let t of e.plugins) n.has(t.id) || n.set(t.id, t);
5120
- let r = Ta(this.host.getState().plugins, await Promise.all([...n.values()].map((e) => xo(e, (e) => this.iconDataUrl(e)))));
5123
+ let r = wa(this.host.getState().plugins, await Promise.all([...n.values()].map((e) => bo(e, (e) => this.iconDataUrl(e)))));
5121
5124
  if (this.host.isClosed() || this.host.authenticationBlocksBootstrap()) return;
5122
5125
  this.host.patch({
5123
5126
  plugins: r,
@@ -5148,9 +5151,9 @@ var Oo = class {
5148
5151
  }
5149
5152
  async readIconDataUrl(e) {
5150
5153
  if (!v(e)) return;
5151
- let t = wo(e);
5154
+ let t = Co(e);
5152
5155
  if (t) try {
5153
- return To(t, (await this.client.request("fs/readFile", { path: e })).dataBase64);
5156
+ return wo(t, (await this.client.request("fs/readFile", { path: e })).dataBase64);
5154
5157
  } catch {
5155
5158
  return;
5156
5159
  }
@@ -5158,18 +5161,18 @@ var Oo = class {
5158
5161
  };
5159
5162
  //#endregion
5160
5163
  //#region src/node/codex-approvals.ts
5161
- function ko(e, t) {
5164
+ function Oo(e, t) {
5162
5165
  let n = [
5163
5166
  e.onServerRequest("item/commandExecution/requestApproval", (e, n) => (t({
5164
- approval: Ao(e.id, e.params),
5165
- resolve: (t, r) => n.resolve({ decision: No(e.params, t, r) })
5167
+ approval: ko(e.id, e.params),
5168
+ resolve: (t, r) => n.resolve({ decision: Mo(e.params, t, r) })
5166
5169
  }), !0)),
5167
5170
  e.onServerRequest("item/fileChange/requestApproval", (e, n) => (t({
5168
- approval: jo(e.id, e.params),
5171
+ approval: Ao(e.id, e.params),
5169
5172
  resolve: (e, t) => n.resolve({ decision: e === "deny" ? "decline" : t === "session" ? "acceptForSession" : "accept" })
5170
5173
  }), !0)),
5171
5174
  e.onServerRequest("item/permissions/requestApproval", (e, n) => (t({
5172
- approval: Mo(e.id, e.params),
5175
+ approval: jo(e.id, e.params),
5173
5176
  resolve: (t, r) => n.resolve({
5174
5177
  permissions: t === "deny" ? {} : {
5175
5178
  ...e.params.permissions.fileSystem ? { fileSystem: e.params.permissions.fileSystem } : {},
@@ -5207,8 +5210,8 @@ function ko(e, t) {
5207
5210
  for (let e of n) e();
5208
5211
  };
5209
5212
  }
5210
- function Ao(e, t) {
5211
- let n = t.availableDecisions, r = Po(t.additionalPermissions), i = [...t.networkApprovalContext ? [{
5213
+ function ko(e, t) {
5214
+ let n = t.availableDecisions, r = No(t.additionalPermissions), i = [...t.networkApprovalContext ? [{
5212
5215
  kind: "network",
5213
5216
  enabled: !0,
5214
5217
  host: t.networkApprovalContext.host,
@@ -5231,7 +5234,7 @@ function Ao(e, t) {
5231
5234
  } : {}
5232
5235
  };
5233
5236
  }
5234
- function jo(e, t) {
5237
+ function Ao(e, t) {
5235
5238
  return {
5236
5239
  id: String(e),
5237
5240
  kind: "file-change",
@@ -5242,8 +5245,8 @@ function jo(e, t) {
5242
5245
  ...t.reason || t.grantRoot ? { description: t.reason ?? `Write under ${t.grantRoot}` } : {}
5243
5246
  };
5244
5247
  }
5245
- function Mo(e, t) {
5246
- let n = Po(t.permissions);
5248
+ function jo(e, t) {
5249
+ let n = No(t.permissions);
5247
5250
  return {
5248
5251
  id: String(e),
5249
5252
  kind: "permissions",
@@ -5256,13 +5259,13 @@ function Mo(e, t) {
5256
5259
  ...n.length ? { requestedPermissions: n } : {}
5257
5260
  };
5258
5261
  }
5259
- function No(e, t, n) {
5262
+ function Mo(e, t, n) {
5260
5263
  let r = e.availableDecisions, i = t === "deny" ? "decline" : n === "session" ? "acceptForSession" : "accept";
5261
5264
  if (!r || r.includes(i)) return i;
5262
5265
  if (t === "deny" && r.includes("cancel")) return "cancel";
5263
5266
  throw Error(`Approval decision '${t}:${n}' is not available for this command`);
5264
5267
  }
5265
- function Po(e) {
5268
+ function No(e) {
5266
5269
  if (!e) return [];
5267
5270
  let t = [];
5268
5271
  if (e.network && t.push({
@@ -5282,12 +5285,12 @@ function Po(e) {
5282
5285
  for (let n of e.fileSystem.entries ?? []) t.push({
5283
5286
  kind: "filesystem",
5284
5287
  access: n.access,
5285
- path: Fo(n.path)
5288
+ path: Po(n.path)
5286
5289
  });
5287
5290
  }
5288
5291
  return t;
5289
5292
  }
5290
- function Fo(e) {
5293
+ function Po(e) {
5291
5294
  if (e.type === "path") return e.path;
5292
5295
  if (e.type === "glob_pattern") return e.pattern;
5293
5296
  let t = e.value;
@@ -5302,12 +5305,12 @@ function Fo(e) {
5302
5305
  }
5303
5306
  //#endregion
5304
5307
  //#region src/node/codex-surface-approvals-controller.ts
5305
- var Io = class {
5308
+ var Fo = class {
5306
5309
  host;
5307
5310
  pending = /* @__PURE__ */ new Map();
5308
5311
  unsubscribeHandler;
5309
5312
  constructor(e, t) {
5310
- this.host = t, this.unsubscribeHandler = ko(e, (e) => this.add(e));
5313
+ this.host = t, this.unsubscribeHandler = Oo(e, (e) => this.add(e));
5311
5314
  }
5312
5315
  close() {
5313
5316
  this.unsubscribeHandler(), this.pending.clear();
@@ -5388,7 +5391,7 @@ var Io = class {
5388
5391
  };
5389
5392
  //#endregion
5390
5393
  //#region src/node/codex-surface-mcp.ts
5391
- function Lo(e) {
5394
+ function Io(e) {
5392
5395
  if (!Array.isArray(e)) throw TypeError("Codex MCP servers must be an array");
5393
5396
  let t = /* @__PURE__ */ new Set();
5394
5397
  return e.map((e, n) => {
@@ -5397,10 +5400,10 @@ function Lo(e) {
5397
5400
  if (!r || !/^[A-Za-z0-9][A-Za-z0-9_-]*$/.test(r)) throw TypeError(`Codex MCP server ${n + 1} name must match ^[A-Za-z0-9][A-Za-z0-9_-]*$`);
5398
5401
  if (t.has(r)) throw Error(`Duplicate Codex MCP server '${r}'`);
5399
5402
  t.add(r);
5400
- let i = Ro(e.transport, r), a = e.toolApprovalMode;
5403
+ let i = Lo(e.transport, r), a = e.toolApprovalMode;
5401
5404
  if (a !== void 0 && a !== "auto" && a !== "prompt" && a !== "writes" && a !== "approve") throw TypeError(`Codex MCP server '${r}' tool approval mode is invalid`);
5402
5405
  if (e.required !== void 0 && typeof e.required != "boolean") throw TypeError(`Codex MCP server '${r}' required flag must be a boolean`);
5403
- let o = e.enabledTools === void 0 ? void 0 : zo(e.enabledTools, `Codex MCP server '${r}' enabled tool`), s = Vo(e.startupTimeoutMs, `Codex MCP server '${r}' startup timeout`), c = Vo(e.toolTimeoutMs, `Codex MCP server '${r}' tool timeout`);
5406
+ let o = e.enabledTools === void 0 ? void 0 : Ro(e.enabledTools, `Codex MCP server '${r}' enabled tool`), s = Bo(e.startupTimeoutMs, `Codex MCP server '${r}' startup timeout`), c = Bo(e.toolTimeoutMs, `Codex MCP server '${r}' tool timeout`);
5404
5407
  return {
5405
5408
  name: r,
5406
5409
  transport: i,
@@ -5412,7 +5415,7 @@ function Lo(e) {
5412
5415
  };
5413
5416
  });
5414
5417
  }
5415
- function Ro(e, t) {
5418
+ function Lo(e, t) {
5416
5419
  if (!e || typeof e != "object" || Array.isArray(e)) throw TypeError(`Codex MCP server '${t}' transport must be an object`);
5417
5420
  if (e.type === "http") {
5418
5421
  let n = e.url?.trim(), r;
@@ -5430,7 +5433,7 @@ function Ro(e, t) {
5430
5433
  if (e.type !== "stdio") throw TypeError(`Codex MCP server '${t}' transport type is invalid`);
5431
5434
  let n = e.command?.trim();
5432
5435
  if (!n) throw TypeError(`Codex MCP server '${t}' command cannot be empty`);
5433
- let r = e.args === void 0 ? void 0 : zo(e.args, `Codex MCP server '${t}' argument`), i = e.cwd?.trim();
5436
+ let r = e.args === void 0 ? void 0 : Ro(e.args, `Codex MCP server '${t}' argument`), i = e.cwd?.trim();
5434
5437
  if (i !== void 0 && (!i || !v(i))) throw TypeError(`Codex MCP server '${t}' cwd must be an absolute path`);
5435
5438
  let a;
5436
5439
  if (e.env !== void 0) {
@@ -5441,7 +5444,7 @@ function Ro(e, t) {
5441
5444
  a[n] = r;
5442
5445
  }
5443
5446
  }
5444
- let o = e.envVars === void 0 ? void 0 : Bo(e.envVars, t);
5447
+ let o = e.envVars === void 0 ? void 0 : zo(e.envVars, t);
5445
5448
  return {
5446
5449
  type: "stdio",
5447
5450
  command: n,
@@ -5451,7 +5454,7 @@ function Ro(e, t) {
5451
5454
  ...o === void 0 ? {} : { envVars: o }
5452
5455
  };
5453
5456
  }
5454
- function zo(e, t) {
5457
+ function Ro(e, t) {
5455
5458
  if (!Array.isArray(e)) throw TypeError(`${t}s must be an array`);
5456
5459
  let n = e.map((e) => {
5457
5460
  if (typeof e != "string" || !e.trim()) throw TypeError(`${t} cannot be empty`);
@@ -5459,18 +5462,18 @@ function zo(e, t) {
5459
5462
  });
5460
5463
  return [...new Set(n)];
5461
5464
  }
5462
- function Bo(e, t) {
5463
- let n = zo(e, `Codex MCP server '${t}' environment variable`);
5465
+ function zo(e, t) {
5466
+ let n = Ro(e, `Codex MCP server '${t}' environment variable`);
5464
5467
  for (let e of n) if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(e)) throw TypeError(`Codex MCP server '${t}' environment variable '${e}' is invalid`);
5465
5468
  return n;
5466
5469
  }
5467
- function Vo(e, t) {
5470
+ function Bo(e, t) {
5468
5471
  if (e !== void 0) {
5469
5472
  if (!Number.isFinite(e) || e <= 0) throw TypeError(`${t} must be a positive finite number`);
5470
5473
  return e;
5471
5474
  }
5472
5475
  }
5473
- function Ho(e) {
5476
+ function Vo(e) {
5474
5477
  let t = {};
5475
5478
  for (let n of e) {
5476
5479
  let e = n.transport.type === "http" ? { url: n.transport.url } : {
@@ -5484,7 +5487,7 @@ function Ho(e) {
5484
5487
  }
5485
5488
  return t;
5486
5489
  }
5487
- function Uo(e, t) {
5490
+ function Ho(e, t) {
5488
5491
  if (t.length !== 0) for (let n of Object.keys(e)) {
5489
5492
  if (n === "mcp_servers") throw Error("Raw mcp_servers config cannot be combined with typed Codex MCP servers");
5490
5493
  for (let e of t) {
@@ -5495,13 +5498,13 @@ function Uo(e, t) {
5495
5498
  }
5496
5499
  //#endregion
5497
5500
  //#region src/node/codex-surface-extensions-controller.ts
5498
- var Wo = class {
5501
+ var Uo = class {
5499
5502
  extensions;
5500
5503
  hostOptionsForThread;
5501
5504
  dynamicTools = /* @__PURE__ */ new Map();
5502
5505
  defaultMcpServers;
5503
5506
  constructor(e, t, n) {
5504
- this.extensions = e, this.hostOptionsForThread = n, this.defaultMcpServers = Lo(t);
5507
+ this.extensions = e, this.hostOptionsForThread = n, this.defaultMcpServers = Io(t);
5505
5508
  for (let t of e) for (let e of t.dynamicTools ?? []) {
5506
5509
  let t = e.name.trim();
5507
5510
  if (!t) throw Error("Dynamic tool names cannot be empty");
@@ -5525,13 +5528,13 @@ var Wo = class {
5525
5528
  }));
5526
5529
  }
5527
5530
  async conversationExtension(e, t = {}, n = this.defaultMcpServers) {
5528
- let r = Ho(n), i = [], a;
5531
+ let r = Vo(n), i = [], a;
5529
5532
  for (let t of this.extensions) {
5530
5533
  if (!t.configureConversation) continue;
5531
5534
  let o = await t.configureConversation(e);
5532
- o.config && (Uo(o.config, n), Object.assign(r, o.config)), o.baseInstructions !== void 0 && (a = o.baseInstructions), o.developerInstructions?.trim() && i.push(o.developerInstructions.trim());
5535
+ o.config && (Ho(o.config, n), Object.assign(r, o.config)), o.baseInstructions !== void 0 && (a = o.baseInstructions), o.developerInstructions?.trim() && i.push(o.developerInstructions.trim());
5533
5536
  }
5534
- return t.config && (Uo(t.config, n), Object.assign(r, t.config)), t.baseInstructions !== void 0 && (a = t.baseInstructions), t.developerInstructions?.trim() && i.push(t.developerInstructions.trim()), {
5537
+ return t.config && (Ho(t.config, n), Object.assign(r, t.config)), t.baseInstructions !== void 0 && (a = t.baseInstructions), t.developerInstructions?.trim() && i.push(t.developerInstructions.trim()), {
5535
5538
  ...a === void 0 ? {} : { baseInstructions: a },
5536
5539
  ...Object.keys(r).length === 0 ? {} : { config: r },
5537
5540
  ...i.length === 0 ? {} : { developerInstructions: i.join("\n\n") }
@@ -5590,7 +5593,7 @@ var Wo = class {
5590
5593
  });
5591
5594
  }
5592
5595
  }
5593
- }, Go = 50, Ko = 25, qo = 25, Jo = class {
5596
+ }, Wo = 50, Go = 25, Ko = 25, qo = class {
5594
5597
  client;
5595
5598
  conversationLimit;
5596
5599
  host;
@@ -5629,7 +5632,7 @@ var Wo = class {
5629
5632
  detailsLoading: !0,
5630
5633
  detailsError: null
5631
5634
  });
5632
- let r = await Xo(this.client, e, t);
5635
+ let r = await Yo(this.client, e, t);
5633
5636
  if (this.host.runtime(e) !== n) throw Error("Conversation changed while loading turn details.");
5634
5637
  let i = n.turns.find((e) => e.id === t);
5635
5638
  if (!i) throw Error("Turn is no longer available.");
@@ -5645,7 +5648,7 @@ var Wo = class {
5645
5648
  completedAt: i.completedAt ? Date.parse(i.completedAt) / 1e3 : null,
5646
5649
  durationMs: i.durationMs
5647
5650
  }, o = kn(n.messages, I(e, a));
5648
- this.originalImages && (o = Ki(o));
5651
+ this.originalImages && (o = Gi(o));
5649
5652
  let s = n.messages.findIndex((e) => e.turnId === t), c = n.messages.filter((e) => e.turnId !== t);
5650
5653
  c.splice(s < 0 ? c.length : s, 0, ...o), this.host.patchRuntime(e, { messages: c });
5651
5654
  }
@@ -5688,7 +5691,7 @@ var Wo = class {
5688
5691
  return await this.host.ensureConnected(), this.load();
5689
5692
  }
5690
5693
  async load() {
5691
- let e = Ta(this.host.getState().conversations, await this.requestConversations({ limit: this.conversationLimit }));
5694
+ let e = wa(this.host.getState().conversations, await this.requestConversations({ limit: this.conversationLimit }));
5692
5695
  this.host.patch({ conversations: e }), this.host.schedulePluginRefresh(!0);
5693
5696
  for (let t of e) this.host.emitSummaryUpserted(t, "listed", "action");
5694
5697
  return this.host.getSnapshot();
@@ -5738,7 +5741,7 @@ var Wo = class {
5738
5741
  let t = await this.client.request("thread/turns/list", {
5739
5742
  threadId: e,
5740
5743
  cursor: null,
5741
- limit: Go,
5744
+ limit: Wo,
5742
5745
  sortDirection: "desc",
5743
5746
  itemsView: "full"
5744
5747
  });
@@ -5786,14 +5789,14 @@ var Wo = class {
5786
5789
  let a = new Set(this.host.requireRuntime(e).turnIds), o = t ?? this.host.requireRuntime(e).historyItemsView, s = await this.client.request("thread/turns/list", {
5787
5790
  threadId: e,
5788
5791
  cursor: n,
5789
- limit: Ko,
5792
+ limit: Go,
5790
5793
  sortDirection: "desc",
5791
5794
  itemsView: o
5792
5795
  });
5793
5796
  o === "summary" && (t ?? this.host.requireRuntime(e).historyItemsView) === "full" && (s = await this.client.request("thread/turns/list", {
5794
5797
  threadId: e,
5795
5798
  cursor: n,
5796
- limit: Ko,
5799
+ limit: Go,
5797
5800
  sortDirection: "desc",
5798
5801
  itemsView: "full"
5799
5802
  }));
@@ -5825,8 +5828,8 @@ var Wo = class {
5825
5828
  }
5826
5829
  async emitHistoryChunks(e, t) {
5827
5830
  for (let n = t.length; n > 0;) {
5828
- let r = Math.max(0, n - qo);
5829
- this.host.emitHistoryPrepended(e, t.slice(r, n), "lifecycle"), await Yo(), n = r;
5831
+ let r = Math.max(0, n - Ko);
5832
+ this.host.emitHistoryPrepended(e, t.slice(r, n), "lifecycle"), await Jo(), n = r;
5830
5833
  }
5831
5834
  }
5832
5835
  async refreshCompleteHistory(e) {
@@ -5866,7 +5869,7 @@ var Wo = class {
5866
5869
  i.activeTurnId && a.add(i.activeTurnId);
5867
5870
  for (let e of t) (e.status === "inProgress" || e.itemsView === "summary" && i.turns.find((t) => t.id === e.id)?.itemsView !== "summary") && i.turnIds.includes(e.id) && a.add(e.id);
5868
5871
  let o = new Set(t.filter((e) => !a.has(e.id)).map((e) => e.id)), s = t.filter((e) => o.has(e.id)), c = i.turnIds.filter((e) => !o.has(e)), l = i.turns.filter((e) => !o.has(e.id)), u = i.messages.filter((e) => e.turnId === void 0 || !o.has(e.turnId)), d = kn(i.messages, s.flatMap((t) => I(e, t)));
5869
- r ? d = r(d) : this.originalImages && (d = Ki(d)), this.host.patchRuntime(e, {
5872
+ r ? d = r(d) : this.originalImages && (d = Gi(d)), this.host.patchRuntime(e, {
5870
5873
  turnIds: [...s.map((e) => e.id), ...c],
5871
5874
  turns: [...s.map((e) => Q(e)), ...l],
5872
5875
  messages: [...d, ...u]
@@ -5892,10 +5895,10 @@ var Wo = class {
5892
5895
  } : t;
5893
5896
  }
5894
5897
  };
5895
- function Yo() {
5898
+ function Jo() {
5896
5899
  return new Promise((e) => setTimeout(e, 0));
5897
5900
  }
5898
- async function Xo(e, t, n) {
5901
+ async function Yo(e, t, n) {
5899
5902
  let r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set(), a = null;
5900
5903
  do {
5901
5904
  let o = await e.request("thread/items/list", {
@@ -5914,7 +5917,7 @@ async function Xo(e, t, n) {
5914
5917
  }
5915
5918
  //#endregion
5916
5919
  //#region src/node/codex-surface-conversation-settings-controller.ts
5917
- var Zo = class {
5920
+ var Xo = class {
5918
5921
  client;
5919
5922
  defaults;
5920
5923
  host;
@@ -5926,7 +5929,7 @@ var Zo = class {
5926
5929
  }
5927
5930
  threadStartSettings(e, t) {
5928
5931
  let n = this.preferredApprovalPreset(), r = e.approvalPreset ?? (e.approvalMode === void 0 && e.permissionMode === void 0 ? t.includes(n ?? "ask-for-approval") ? n : t[0] ?? null : null);
5929
- if (r) return _a(r);
5932
+ if (r) return ga(r);
5930
5933
  let i = e.approvalMode ?? this.defaults.approvalMode, a = e.permissionMode ?? this.defaults.permissionMode ?? "read-only";
5931
5934
  return {
5932
5935
  approvalPolicy: i === "ask" ? "on-request" : "never",
@@ -5952,23 +5955,23 @@ var Zo = class {
5952
5955
  async update(e) {
5953
5956
  let t = this.host.getState(), n = t.activeConversationId;
5954
5957
  if (!n) {
5955
- let n = Sa(t, e);
5958
+ let n = xa(t, e);
5956
5959
  if (e.approvalPreset && !t.approvalPresets.includes(e.approvalPreset)) throw Error(`Approval preset '${e.approvalPreset}' is not available`);
5957
5960
  return this.host.patch(n), this.host.getSnapshot();
5958
5961
  }
5959
5962
  return await this.updateForThread(n, e), this.host.getSnapshot();
5960
5963
  }
5961
5964
  async updateForThread(e, t) {
5962
- let n = await this.host.ensureThreadReady(e), r = this.host.snapshotForRuntime(n), i = Sa(r, t), a = n.approvalPreset !== i.approvalPreset || n.selectedModelId !== i.selectedModelId || n.selectedReasoningEffort !== i.selectedReasoningEffort || n.selectedServiceTier !== i.selectedServiceTier || n.planMode !== i.planMode;
5965
+ let n = await this.host.ensureThreadReady(e), r = this.host.snapshotForRuntime(n), i = xa(r, t), a = n.approvalPreset !== i.approvalPreset || n.selectedModelId !== i.selectedModelId || n.selectedReasoningEffort !== i.selectedReasoningEffort || n.selectedServiceTier !== i.selectedServiceTier || n.planMode !== i.planMode;
5963
5966
  if (t.approvalPreset && !r.approvalPresets.includes(t.approvalPreset)) throw Error(`Approval preset '${t.approvalPreset}' is not available`);
5964
5967
  let o = q(this.host.getState().models, i.selectedModelId);
5965
5968
  await this.client.request("thread/settings/update", {
5966
5969
  threadId: e,
5967
- ...t.approvalPreset ? va(t.approvalPreset) : {},
5970
+ ...t.approvalPreset ? _a(t.approvalPreset) : {},
5968
5971
  ...t.modelId && o ? { model: o.model } : {},
5969
5972
  ...t.reasoningEffort || t.modelId ? { effort: i.selectedReasoningEffort } : {},
5970
5973
  ...t.serviceTier !== void 0 || t.modelId ? { serviceTier: i.selectedServiceTier } : {},
5971
- ...o && (typeof t.planMode == "boolean" || t.modelId || t.reasoningEffort) ? { collaborationMode: Ca(i.planMode, o.model, i.selectedReasoningEffort) } : {}
5974
+ ...o && (typeof t.planMode == "boolean" || t.modelId || t.reasoningEffort) ? { collaborationMode: Sa(i.planMode, o.model, i.selectedReasoningEffort) } : {}
5972
5975
  }), this.host.patchRuntime(e, i), a && this.host.emitConversationSettings(e, "action");
5973
5976
  }
5974
5977
  async setGoal(e, t) {
@@ -5987,7 +5990,7 @@ var Zo = class {
5987
5990
  ...n === void 0 ? {} : { tokenBudget: n }
5988
5991
  });
5989
5992
  if (a.goal.threadId !== e) throw Error(`Codex thread/goal/set returned a goal for '${a.goal.threadId}' instead of '${e}'`);
5990
- let o = !co(r.goal, a.goal);
5993
+ let o = !so(r.goal, a.goal);
5991
5994
  this.host.patchRuntime(e, { goal: { ...a.goal } }), o && this.host.emitEvent("action", {
5992
5995
  type: "conversation.goalChanged",
5993
5996
  conversationId: e,
@@ -6009,7 +6012,7 @@ var Zo = class {
6009
6012
  payload: { goal: null }
6010
6013
  });
6011
6014
  }
6012
- }, Qo = "Review the current code changes (staged, unstaged, and untracked files) and provide prioritized findings.", $o = class {
6015
+ }, Zo = "Review the current code changes (staged, unstaged, and untracked files) and provide prioritized findings.", Qo = class {
6013
6016
  client;
6014
6017
  host;
6015
6018
  constructor(e, t) {
@@ -6050,13 +6053,13 @@ var Zo = class {
6050
6053
  ...e,
6051
6054
  parts: r.type === "uncommittedChanges" ? e.parts.map((e) => e.type === "text" && e.text === "current changes" ? {
6052
6055
  ...e,
6053
- text: Qo
6056
+ text: Zo
6054
6057
  } : e) : e.parts,
6055
6058
  metadata: {
6056
6059
  ...e.metadata,
6057
6060
  reviewPrompt: !0
6058
6061
  }
6059
- } : e), s = es(n.messages, i.turn.id, o);
6062
+ } : e), s = $o(n.messages, i.turn.id, o);
6060
6063
  this.host.patchRuntime(e, {
6061
6064
  busy: n.activeTurnId !== null,
6062
6065
  turnStartPending: !1,
@@ -6073,7 +6076,7 @@ var Zo = class {
6073
6076
  type: "turn.started",
6074
6077
  conversationId: e,
6075
6078
  turnId: i.turn.id,
6076
- payload: { startedAt: ao(i.turn.startedAt) }
6079
+ payload: { startedAt: io(i.turn.startedAt) }
6077
6080
  }), this.host.emitConversationActivity(e, "action");
6078
6081
  } catch (t) {
6079
6082
  throw this.host.patchRuntime(e, {
@@ -6108,11 +6111,11 @@ var Zo = class {
6108
6111
  async editTurnForThread(e, t, n, r) {
6109
6112
  let i = await this.host.ensureThreadReady(e);
6110
6113
  i.turns.find((e) => e.id === t)?.itemsView === "summary" && await this.host.loadTurnHistory?.(e, t);
6111
- let a = i.messages.find((e) => e.role === "user" && e.kind !== "steer" && Aa(e) === t);
6114
+ let a = i.messages.find((e) => e.role === "user" && e.kind !== "steer" && ka(e) === t);
6112
6115
  if (!a) throw Error(`Could not find the user prompt for Codex turn '${t}'`);
6113
6116
  let o = n.trim();
6114
6117
  if (!o) throw Error("Cannot replace a turn prompt with empty content");
6115
- let s = Ma(a);
6118
+ let s = ja(a);
6116
6119
  await this.rollbackToTurn(e, t), await this.host.sendMessageToThread(e, o, {
6117
6120
  ...r,
6118
6121
  ...s.length > 0 ? { attachments: s } : {}
@@ -6125,11 +6128,11 @@ var Zo = class {
6125
6128
  async retryTurnForThread(e, t) {
6126
6129
  let n = await this.host.ensureThreadReady(e);
6127
6130
  n.turns.find((e) => e.id === t)?.itemsView === "summary" && await this.host.loadTurnHistory?.(e, t);
6128
- let r = n.messages.find((e) => e.role === "user" && e.kind !== "steer" && Aa(e) === t);
6131
+ let r = n.messages.find((e) => e.role === "user" && e.kind !== "steer" && ka(e) === t);
6129
6132
  if (!r) throw Error("Could not find the user prompt for this turn");
6130
- let i = ja(r);
6133
+ let i = Aa(r);
6131
6134
  if (!i) throw Error("Could not find the user prompt for this turn");
6132
- let a = Ma(r);
6135
+ let a = ja(r);
6133
6136
  await this.rollbackToTurn(e, t), await this.host.sendMessageToThread(e, i, {
6134
6137
  ...r.metadata?.promptContent ? { content: ce(r.metadata.promptContent) } : {},
6135
6138
  ...a.length > 0 ? { attachments: a } : {}
@@ -6150,7 +6153,7 @@ var Zo = class {
6150
6153
  });
6151
6154
  if (i.thread.id !== e) throw Error(`Codex thread/revert returned '${i.thread.id}' for requested thread '${e}'`);
6152
6155
  let a = r.turnIds.slice(0, n), o = new Set(a), s = r.messages.filter((e) => {
6153
- let t = Aa(e);
6156
+ let t = ka(e);
6154
6157
  return t === null || o.has(t);
6155
6158
  });
6156
6159
  r.turnIds = a, r.turns = r.turns.filter((e) => o.has(e.id)), r.activeTurnId = null;
@@ -6177,7 +6180,7 @@ var Zo = class {
6177
6180
  return e;
6178
6181
  }
6179
6182
  };
6180
- function es(e, t, n) {
6183
+ function $o(e, t, n) {
6181
6184
  let r = e.findIndex((e) => e.turnId === t);
6182
6185
  return r < 0 ? [...e, ...n] : [
6183
6186
  ...e.slice(0, r),
@@ -6187,7 +6190,7 @@ function es(e, t, n) {
6187
6190
  }
6188
6191
  //#endregion
6189
6192
  //#region src/node/codex-surface-messages-controller.ts
6190
- var ts = class {
6193
+ var es = class {
6191
6194
  client;
6192
6195
  host;
6193
6196
  constructor(e, t) {
@@ -6243,7 +6246,7 @@ var ts = class {
6243
6246
  let s = Zt(i);
6244
6247
  if (s) return this.host.startReviewForThread(e, { target: s });
6245
6248
  n = {
6246
- ...Ea(this.host.snapshotForRuntime(r), n),
6249
+ ...Ta(this.host.snapshotForRuntime(r), n),
6247
6250
  ...n.skills ? { skills: k(n.skills, r.skills) } : {}
6248
6251
  }, await this.sendPromptToThread(e, i, n);
6249
6252
  }
@@ -6267,7 +6270,7 @@ var ts = class {
6267
6270
  let n = await this.client.request("turn/start", {
6268
6271
  threadId: e,
6269
6272
  input: [],
6270
- ...wa(this.host.snapshotForRuntime(t), {})
6273
+ ...Ca(this.host.snapshotForRuntime(t), {})
6271
6274
  }), r = t.turnIds.includes(n.turn.id);
6272
6275
  t.activeTurnId = n.turn.status === "inProgress" ? n.turn.id : null, r || t.turnIds.push(n.turn.id), this.host.patchConversationTurnCount(e, t.turnIds.length, "action");
6273
6276
  let i = n.turn.status === "inProgress";
@@ -6280,7 +6283,7 @@ var ts = class {
6280
6283
  type: "turn.started",
6281
6284
  conversationId: e,
6282
6285
  turnId: n.turn.id,
6283
- payload: { startedAt: ao(n.turn.startedAt) }
6286
+ payload: { startedAt: io(n.turn.startedAt) }
6284
6287
  }), this.host.emitConversationActivity(e, "action");
6285
6288
  } catch (t) {
6286
6289
  throw this.host.patchRuntime(e, {
@@ -6291,25 +6294,25 @@ var ts = class {
6291
6294
  }
6292
6295
  }
6293
6296
  async sendPromptToThread(e, t, n = {}, r) {
6294
- let i = this.host.requireRuntime(e), a = Ea(this.host.snapshotForRuntime(i), n), o = $t(a.content);
6297
+ let i = this.host.requireRuntime(e), a = Ta(this.host.snapshotForRuntime(i), n), o = $t(a.content);
6295
6298
  o && (a.content = o);
6296
- let s = o ? ue(o) : r?.trim() || t, c = nn(k(en(o), i.skills), k(a.skills ?? [], i.skills)), l = Da(a.attachments ?? []);
6299
+ let s = o ? ue(o) : r?.trim() || t, c = nn(k(en(o), i.skills), k(a.skills ?? [], i.skills)), l = Ea(a.attachments ?? []);
6297
6300
  if (i.busy) {
6298
6301
  this.host.patchRuntime(e, { queuedPrompts: [...i.queuedPrompts, {
6299
- id: uo(),
6302
+ id: lo(),
6300
6303
  text: s,
6301
6304
  ...Object.keys(a).length > 0 ? { options: a } : {}
6302
6305
  }] }), this.emitQueuedPrompts(e);
6303
6306
  return;
6304
6307
  }
6305
- let u = lo(), d = {
6308
+ let u = co(), d = {
6306
6309
  id: u,
6307
6310
  role: "user",
6308
6311
  status: "complete",
6309
6312
  parts: [{
6310
6313
  type: "text",
6311
6314
  text: s
6312
- }, ...l.map(ka)],
6315
+ }, ...l.map(Oa)],
6313
6316
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
6314
6317
  metadata: {
6315
6318
  conversationId: e,
@@ -6337,7 +6340,7 @@ var ts = class {
6337
6340
  text: le(o ?? [], t),
6338
6341
  text_elements: []
6339
6342
  },
6340
- ...l.map(Oa),
6343
+ ...l.map(Da),
6341
6344
  ...tn(o),
6342
6345
  ...c.map((e) => ({
6343
6346
  type: "skill",
@@ -6345,7 +6348,7 @@ var ts = class {
6345
6348
  path: e.path
6346
6349
  }))
6347
6350
  ],
6348
- ...wa(this.host.snapshotForRuntime(i), a),
6351
+ ...Ca(this.host.snapshotForRuntime(i), a),
6349
6352
  ...a.outputSchema === void 0 ? {} : { outputSchema: a.outputSchema }
6350
6353
  }), r = i.turnIds.includes(n.turn.id);
6351
6354
  i.activeTurnId = n.turn.status === "inProgress" ? n.turn.id : null, i.turnIds.includes(n.turn.id) || i.turnIds.push(n.turn.id), this.host.patchConversationTurnCount(e, i.turnIds.length, "action");
@@ -6373,7 +6376,7 @@ var ts = class {
6373
6376
  type: "turn.started",
6374
6377
  conversationId: e,
6375
6378
  turnId: n.turn.id,
6376
- payload: { startedAt: ao(n.turn.startedAt) }
6379
+ payload: { startedAt: io(n.turn.startedAt) }
6377
6380
  }), this.host.emitConversationActivity(e, "action");
6378
6381
  } catch (t) {
6379
6382
  throw this.host.patchRuntime(e, {
@@ -6391,7 +6394,7 @@ var ts = class {
6391
6394
  let i = await this.host.ensureThreadReady(e), a = t.trim(), o = $t(n.content), s = nn(k(en(o), i.skills), k(n.skills ?? [], i.skills)), c = o ? ue(o) : r?.trim() || a;
6392
6395
  if (!a) throw Error("Cannot steer with an empty message");
6393
6396
  if (!i.activeTurnId) throw Error("There is no active turn to steer");
6394
- let l = Da(n.attachments ?? []), u = lo(), d = {
6397
+ let l = Ea(n.attachments ?? []), u = co(), d = {
6395
6398
  id: u,
6396
6399
  kind: "steer",
6397
6400
  role: "user",
@@ -6399,7 +6402,7 @@ var ts = class {
6399
6402
  parts: [{
6400
6403
  type: "text",
6401
6404
  text: c
6402
- }, ...l.map(ka)],
6405
+ }, ...l.map(Oa)],
6403
6406
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
6404
6407
  turnId: i.activeTurnId,
6405
6408
  metadata: {
@@ -6429,7 +6432,7 @@ var ts = class {
6429
6432
  text: le(o ?? [], a),
6430
6433
  text_elements: []
6431
6434
  },
6432
- ...l.map(Oa),
6435
+ ...l.map(Da),
6433
6436
  ...tn(o),
6434
6437
  ...s.map((e) => ({
6435
6438
  type: "skill",
@@ -6548,7 +6551,7 @@ var ts = class {
6548
6551
  if (!e) throw Error("There is no active conversation");
6549
6552
  return e;
6550
6553
  }
6551
- }, ns = 5, rs = class {
6554
+ }, ts = 5, ns = class {
6552
6555
  client;
6553
6556
  options;
6554
6557
  catalog;
@@ -6587,9 +6590,9 @@ var ts = class {
6587
6590
  let i = this.host.getState(), a = e.approvalPreset ?? (e.approvalMode === void 0 && e.permissionMode === void 0 && i.approvalPreset && r.approvalPresets.includes(i.approvalPreset) ? i.approvalPreset : void 0), o = this.settings.threadStartSettings({
6588
6591
  ...e,
6589
6592
  ...a ? { approvalPreset: a } : {}
6590
- }, r.approvalPresets), s = q(i.models, i.selectedModelId), c = e.model ? ua(i.models, e.model) : s, l = c?.model, u = e.reasoningEffort ?? (c?.id === s?.id ? i.selectedReasoningEffort : c ? fa(c) : null) ?? void 0, d = e.serviceTier === void 0 ? c?.id === s?.id ? i.selectedServiceTier ?? null : c?.defaultServiceTier ?? null : e.serviceTier;
6591
- da(c, u), ma(c, d);
6592
- let f = t.mcpServers === void 0 ? this.extensions.defaultMcpServers : Lo(t.mcpServers), p = await this.extensions.conversationExtension({
6593
+ }, r.approvalPresets), s = q(i.models, i.selectedModelId), c = e.model ? la(i.models, e.model) : s, l = c?.model, u = e.reasoningEffort ?? (c?.id === s?.id ? i.selectedReasoningEffort : c ? da(c) : null) ?? void 0, d = e.serviceTier === void 0 ? c?.id === s?.id ? i.selectedServiceTier ?? null : c?.defaultServiceTier ?? null : e.serviceTier;
6594
+ ua(c, u), pa(c, d);
6595
+ let f = t.mcpServers === void 0 ? this.extensions.defaultMcpServers : Io(t.mcpServers), p = await this.extensions.conversationExtension({
6593
6596
  operation: "start",
6594
6597
  conversationId: null,
6595
6598
  cwd: n,
@@ -6608,11 +6611,11 @@ var ts = class {
6608
6611
  serviceName: "codex_app_sdk"
6609
6612
  });
6610
6613
  this.host.observeEmptyConversation(m.thread.id);
6611
- let h = ba(m, i.models, i);
6614
+ let h = ya(m, i.models, i);
6612
6615
  u && (await this.client.request("thread/settings/update", {
6613
6616
  threadId: m.thread.id,
6614
6617
  effort: u,
6615
- ...c ? { collaborationMode: Ca(i.planMode, c.model, u) } : {}
6618
+ ...c ? { collaborationMode: Sa(i.planMode, c.model, u) } : {}
6616
6619
  }), h.selectedReasoningEffort = u), d !== void 0 && (h.selectedServiceTier = d), c && (h.selectedModelId = c.id), a && (h.approvalPreset = a);
6617
6620
  let g = this.host.createRuntime(m.thread.id, {
6618
6621
  hydrated: !0,
@@ -6623,7 +6626,7 @@ var ts = class {
6623
6626
  turnIds: [],
6624
6627
  messages: [],
6625
6628
  answeredClientRequestIds: [],
6626
- threadStatus: Fa(m.thread.status),
6629
+ threadStatus: Pa(m.thread.status),
6627
6630
  ...r,
6628
6631
  ...h
6629
6632
  });
@@ -6691,7 +6694,7 @@ var ts = class {
6691
6694
  historyLoadingOlder: !1,
6692
6695
  fullHistoryHydrated: !0,
6693
6696
  busy: !!n.activeTurnId,
6694
- threadStatus: Fa(t.thread.status)
6697
+ threadStatus: Pa(t.thread.status)
6695
6698
  }), i = {
6696
6699
  ...J(t.thread),
6697
6700
  turnCount: r.turnIds.length
@@ -6713,7 +6716,7 @@ var ts = class {
6713
6716
  ...n
6714
6717
  }, a = {
6715
6718
  ...i,
6716
- mcpServers: i.mcpServers === void 0 ? this.extensions.defaultMcpServers : Lo(i.mcpServers)
6719
+ mcpServers: i.mcpServers === void 0 ? this.extensions.defaultMcpServers : Io(i.mcpServers)
6717
6720
  };
6718
6721
  this.hostOptionsByThread.set(e, a);
6719
6722
  let o = await this.extensions.conversationExtension({
@@ -6731,7 +6734,7 @@ var ts = class {
6731
6734
  threadId: e,
6732
6735
  excludeTurns: !0,
6733
6736
  initialTurnsPage: {
6734
- limit: ns,
6737
+ limit: ts,
6735
6738
  sortDirection: "desc",
6736
6739
  itemsView: s
6737
6740
  },
@@ -6744,14 +6747,14 @@ var ts = class {
6744
6747
  let i = t.initialTurnsPage ?? await this.client.request("thread/turns/list", {
6745
6748
  threadId: t.thread.id,
6746
6749
  cursor: null,
6747
- limit: ns,
6750
+ limit: ts,
6748
6751
  sortDirection: "desc",
6749
6752
  itemsView: s
6750
6753
  }), f = await Promise.all([...i.data].reverse().map(async (e) => e.status === "inProgress" && (e.itemsView === "summary" || e.itemsView === "notLoaded") ? {
6751
6754
  ...e,
6752
- items: await Xo(this.client, t.thread.id, e.id),
6755
+ items: await Yo(this.client, t.thread.id, e.id),
6753
6756
  itemsView: "full"
6754
- } : e)), p = t.cwd ?? t.thread.cwd ?? a.cwd, m = await this.catalog.loadConversationCatalogs(p), h = s === "full" ? await this.originalImages?.prepare(t.thread.id, t.thread.path) : void 0, g = c.turns.filter((e) => l.get(e.id) !== e), _ = c.threadStatus !== d && c.threadStatus ? c.threadStatus : Fa(t.thread.status), v = f.map((e) => _.type === "idle" && e.status === "inProgress" ? {
6757
+ } : e)), p = t.cwd ?? t.thread.cwd ?? a.cwd, m = await this.catalog.loadConversationCatalogs(p), h = s === "full" ? await this.originalImages?.prepare(t.thread.id, t.thread.path) : void 0, g = c.turns.filter((e) => l.get(e.id) !== e), _ = c.threadStatus !== d && c.threadStatus ? c.threadStatus : Pa(t.thread.status), v = f.map((e) => _.type === "idle" && e.status === "inProgress" ? {
6755
6758
  ...e,
6756
6759
  status: "interrupted"
6757
6760
  } : e), y = new Set(c.turns.filter((e) => e.itemsView !== "summary").map((e) => e.id)), b = new Map(v.map((e) => [e.id, e.itemsView === "summary" && y.has(e.id) ? {
@@ -6783,7 +6786,7 @@ var ts = class {
6783
6786
  goal: n ? { ...n } : null,
6784
6787
  threadStatus: _,
6785
6788
  ...m,
6786
- ...ba(t, this.host.getState().models, this.host.snapshotForRuntime(c))
6789
+ ...ya(t, this.host.getState().models, this.host.snapshotForRuntime(c))
6787
6790
  }), ne = {
6788
6791
  ...J(t.thread),
6789
6792
  turnCount: f.length
@@ -6812,7 +6815,7 @@ var ts = class {
6812
6815
  threadStatus: structuredClone(t.threadStatus)
6813
6816
  };
6814
6817
  }
6815
- }, is = class {
6818
+ }, rs = class {
6816
6819
  authentication;
6817
6820
  approvals;
6818
6821
  catalog;
@@ -6828,7 +6831,7 @@ var ts = class {
6828
6831
  case "thread/started": {
6829
6832
  this.host.createRuntime(e.params.thread.id, {
6830
6833
  historyMode: e.params.thread.historyMode ?? "legacy",
6831
- threadStatus: Fa(e.params.thread.status)
6834
+ threadStatus: Pa(e.params.thread.status)
6832
6835
  });
6833
6836
  let t = J(e.params.thread);
6834
6837
  this.host.patch({ conversations: Y(this.host.getState().conversations, t) }), this.host.emitSummaryUpserted(t, "started", "notification"), this.host.emitConversationActivity(e.params.thread.id, "notification");
@@ -6837,7 +6840,7 @@ var ts = class {
6837
6840
  case "thread/status/changed": {
6838
6841
  let { threadId: t, status: n } = e.params, r = this.host.requireRuntime(t), i = n.type === "systemError";
6839
6842
  (i || n.type === "idle" && !r.turnStartPending) && (r.activeTurnId = null), this.host.patchRuntime(t, {
6840
- threadStatus: Fa(n),
6843
+ threadStatus: Pa(n),
6841
6844
  busy: i ? !1 : r.turnStartPending || n.type === "active" || r.activeTurnId !== null,
6842
6845
  ...i ? {
6843
6846
  turnStartPending: !1,
@@ -6847,7 +6850,7 @@ var ts = class {
6847
6850
  let a = this.host.getState();
6848
6851
  this.host.patch({ conversations: a.conversations.map((e) => e.id === t ? {
6849
6852
  ...e,
6850
- status: Ia(n)
6853
+ status: Fa(n)
6851
6854
  } : e) });
6852
6855
  let o = this.host.getState().conversations.find((e) => e.id === t);
6853
6856
  o && this.host.emitSummaryUpserted(o, "updated", "notification"), this.host.emitConversationActivity(t, "notification"), n.type === "idle" && this.host.sendNextQueuedPrompt(t);
@@ -6889,12 +6892,12 @@ var ts = class {
6889
6892
  return;
6890
6893
  }
6891
6894
  case "thread/settings/updated": {
6892
- let t = this.host.requireRuntime(e.params.threadId), n = this.host.getState(), r = xa(e.params.threadSettings, n.models, this.host.snapshotForRuntime(t)), i = t.approvalPreset !== r.approvalPreset || t.selectedModelId !== r.selectedModelId || t.selectedReasoningEffort !== r.selectedReasoningEffort || t.selectedServiceTier !== r.selectedServiceTier || t.planMode !== r.planMode;
6895
+ let t = this.host.requireRuntime(e.params.threadId), n = this.host.getState(), r = ba(e.params.threadSettings, n.models, this.host.snapshotForRuntime(t)), i = t.approvalPreset !== r.approvalPreset || t.selectedModelId !== r.selectedModelId || t.selectedReasoningEffort !== r.selectedReasoningEffort || t.selectedServiceTier !== r.selectedServiceTier || t.planMode !== r.planMode;
6893
6896
  this.host.patchRuntime(e.params.threadId, r), i && this.host.emitConversationSettings(e.params.threadId, "notification");
6894
6897
  return;
6895
6898
  }
6896
6899
  case "thread/goal/updated":
6897
- if (co(this.host.requireRuntime(e.params.threadId).goal, e.params.goal)) return;
6900
+ if (so(this.host.requireRuntime(e.params.threadId).goal, e.params.goal)) return;
6898
6901
  this.host.patchRuntime(e.params.threadId, { goal: { ...e.params.goal } }), this.host.emitEvent("notification", {
6899
6902
  type: "conversation.goalChanged",
6900
6903
  conversationId: e.params.threadId,
@@ -6911,7 +6914,7 @@ var ts = class {
6911
6914
  });
6912
6915
  return;
6913
6916
  case "thread/tokenUsage/updated": {
6914
- let t = Pa(e.params.tokenUsage);
6917
+ let t = Na(e.params.tokenUsage);
6915
6918
  this.host.patchRuntime(e.params.threadId, { contextUsage: t }), this.host.emitEvent("notification", {
6916
6919
  type: "conversation.contextUsageChanged",
6917
6920
  conversationId: e.params.threadId,
@@ -6922,8 +6925,8 @@ var ts = class {
6922
6925
  conversationId: e.params.threadId,
6923
6926
  turnId: e.params.turnId,
6924
6927
  payload: { usage: {
6925
- last: Na(e.params.tokenUsage.last),
6926
- total: Na(e.params.tokenUsage.total),
6928
+ last: Ma(e.params.tokenUsage.last),
6929
+ total: Ma(e.params.tokenUsage.total),
6927
6930
  execution: null,
6928
6931
  model: null,
6929
6932
  observedStart: !1
@@ -6951,12 +6954,12 @@ var ts = class {
6951
6954
  error: null,
6952
6955
  turnGitDiff: null,
6953
6956
  turns: $(t.turns, Q(e.params.turn)),
6954
- messages: M(t.messages, e.params.threadId, e.params.turn.id, { createdAt: ao(e.params.turn.startedAt) })
6957
+ messages: M(t.messages, e.params.threadId, e.params.turn.id, { createdAt: io(e.params.turn.startedAt) })
6955
6958
  }), this.host.patchConversationStatus(e.params.threadId, "active"), n || this.host.emitEvent("notification", {
6956
6959
  type: "turn.started",
6957
6960
  conversationId: e.params.threadId,
6958
6961
  turnId: e.params.turn.id,
6959
- payload: { startedAt: ao(e.params.turn.startedAt) }
6962
+ payload: { startedAt: io(e.params.turn.startedAt) }
6960
6963
  }), this.host.emitConversationActivity(e.params.threadId, "notification");
6961
6964
  return;
6962
6965
  }
@@ -7037,7 +7040,7 @@ var ts = class {
7037
7040
  durationMs: null
7038
7041
  },
7039
7042
  status: e.params.willRetry ? "inProgress" : "failed",
7040
- error: so(e.params.error),
7043
+ error: oo(e.params.error),
7041
7044
  willRetry: e.params.willRetry
7042
7045
  }),
7043
7046
  ...n ? {
@@ -7049,7 +7052,7 @@ var ts = class {
7049
7052
  conversationId: e.params.threadId,
7050
7053
  turnId: e.params.turnId,
7051
7054
  payload: {
7052
- error: so(e.params.error),
7055
+ error: oo(e.params.error),
7053
7056
  willRetry: e.params.willRetry
7054
7057
  }
7055
7058
  }), this.host.emitConversationActivity(e.params.threadId, "notification");
@@ -7057,7 +7060,7 @@ var ts = class {
7057
7060
  }
7058
7061
  case "account/rateLimits/updated": {
7059
7062
  let t = this.host.getState();
7060
- this.host.patch({ rateLimits: Va(t.rateLimits, e.params.rateLimits) }), this.host.emitEvent("notification", {
7063
+ this.host.patch({ rateLimits: Ba(t.rateLimits, e.params.rateLimits) }), this.host.emitEvent("notification", {
7061
7064
  type: "rateLimits.changed",
7062
7065
  payload: { rateLimits: structuredClone(this.host.getState().rateLimits) }
7063
7066
  });
@@ -7128,7 +7131,7 @@ var ts = class {
7128
7131
  this.host.emitEvent("notification", {
7129
7132
  type: "realtime.audioDelta",
7130
7133
  conversationId: e.params.threadId,
7131
- payload: { audio: Xi(e.params.audio) }
7134
+ payload: { audio: Yi(e.params.audio) }
7132
7135
  });
7133
7136
  return;
7134
7137
  case "thread/realtime/sdp":
@@ -7195,7 +7198,7 @@ var ts = class {
7195
7198
  default: return this.host.unknownNotification(e);
7196
7199
  }
7197
7200
  }
7198
- }, as = class {
7201
+ }, is = class {
7199
7202
  approvals;
7200
7203
  clientRequests;
7201
7204
  host;
@@ -7219,14 +7222,14 @@ var ts = class {
7219
7222
  create(e, t = {}) {
7220
7223
  let n = this.runtimes.get(e);
7221
7224
  if (n) return Object.assign(n, t), n;
7222
- let r = na(e, this.host.getState(), t);
7225
+ let r = ta(e, this.host.getState(), t);
7223
7226
  return this.runtimes.set(e, r), r;
7224
7227
  }
7225
7228
  require(e) {
7226
7229
  return this.runtimes.get(e) ?? this.create(e);
7227
7230
  }
7228
7231
  projection(e) {
7229
- return ra(e, this.approvals.approvalsForThread(e.threadId), this.clientRequests.requestsForThread(e.threadId));
7232
+ return na(e, this.approvals.approvalsForThread(e.threadId), this.clientRequests.requestsForThread(e.threadId));
7230
7233
  }
7231
7234
  snapshot(e) {
7232
7235
  return {
@@ -7257,7 +7260,7 @@ var ts = class {
7257
7260
  conversationId: e,
7258
7261
  payload: {
7259
7262
  historyLoading: n.historyLoading,
7260
- historyState: cs(n),
7263
+ historyState: ss(n),
7261
7264
  error: n.error
7262
7265
  }
7263
7266
  });
@@ -7351,7 +7354,7 @@ var ts = class {
7351
7354
  reason: t,
7352
7355
  messages: structuredClone(r.messages),
7353
7356
  threadStatus: structuredClone(r.threadStatus),
7354
- state: os(r)
7357
+ state: as(r)
7355
7358
  }
7356
7359
  });
7357
7360
  }
@@ -7363,7 +7366,7 @@ var ts = class {
7363
7366
  conversationId: e,
7364
7367
  payload: {
7365
7368
  messages: structuredClone(t.map((e) => r.get(e.id) ?? e)),
7366
- state: ss(this.require(e))
7369
+ state: os(this.require(e))
7367
7370
  }
7368
7371
  });
7369
7372
  }
@@ -7418,7 +7421,7 @@ var ts = class {
7418
7421
  i && this.emitSummaryUpserted(i, "updated", n);
7419
7422
  }
7420
7423
  };
7421
- function os(e) {
7424
+ function as(e) {
7422
7425
  return structuredClone({
7423
7426
  activeTurnId: e.activeTurnId,
7424
7427
  answeredClientRequestIds: e.answeredClientRequestIds,
@@ -7427,21 +7430,21 @@ function os(e) {
7427
7430
  error: e.error,
7428
7431
  executionPlan: e.executionPlan,
7429
7432
  historyLoading: e.historyLoading,
7430
- historyState: cs(e),
7433
+ historyState: ss(e),
7431
7434
  turnGitDiff: e.turnGitDiff,
7432
7435
  turnIds: e.turnIds,
7433
7436
  turns: e.turns
7434
7437
  });
7435
7438
  }
7436
- function ss(e) {
7439
+ function os(e) {
7437
7440
  return structuredClone({
7438
7441
  historyLoading: e.historyLoading,
7439
- historyState: cs(e),
7442
+ historyState: ss(e),
7440
7443
  turnIds: e.turnIds,
7441
7444
  turns: e.turns
7442
7445
  });
7443
7446
  }
7444
- function cs(e) {
7447
+ function ss(e) {
7445
7448
  return {
7446
7449
  loadingStrategy: e.loadingStrategy,
7447
7450
  ...e.historyItemsView === "summary" ? { itemsView: "summary" } : {},
@@ -7452,7 +7455,7 @@ function cs(e) {
7452
7455
  }
7453
7456
  //#endregion
7454
7457
  //#region src/node/codex-surface-connection-controller.ts
7455
- var ls = /* @__PURE__ */ new Set(["compaction_image_budget", "default_mode_request_user_input"]), us = class {
7458
+ var cs = /* @__PURE__ */ new Set(["compaction_image_budget", "default_mode_request_user_input"]), ls = class {
7456
7459
  client;
7457
7460
  options;
7458
7461
  authentication;
@@ -7515,7 +7518,7 @@ var ls = /* @__PURE__ */ new Set(["compaction_image_budget", "default_mode_reque
7515
7518
  limit: 100,
7516
7519
  threadId: null
7517
7520
  });
7518
- for (let e of n.data) ls.has(e.name) && !e.enabled && (t[e.name] = !0);
7521
+ for (let e of n.data) cs.has(e.name) && !e.enabled && (t[e.name] = !0);
7519
7522
  e = n.nextCursor;
7520
7523
  } while (e);
7521
7524
  Object.keys(t).length > 0 && await this.client.request("experimentalFeature/enablement/set", { enablement: t });
@@ -7532,7 +7535,7 @@ var ls = /* @__PURE__ */ new Set(["compaction_image_budget", "default_mode_reque
7532
7535
  }
7533
7536
  }
7534
7537
  bootstrapSurfaceData(e = !1) {
7535
- let t = oa(this.host.getState().authentication);
7538
+ let t = aa(this.host.getState().authentication);
7536
7539
  if (!e && this.bootstrappedAuthenticationKey === t) return Promise.resolve();
7537
7540
  if (this.surfaceBootstrapPromise) return this.surfaceBootstrapPromise.then(() => this.bootstrapSurfaceData(e));
7538
7541
  let n = (async () => {
@@ -7649,7 +7652,7 @@ var ls = /* @__PURE__ */ new Set(["compaction_image_budget", "default_mode_reque
7649
7652
  error: null
7650
7653
  });
7651
7654
  }
7652
- }, ds = 5, fs = class {
7655
+ }, us = 5, ds = class {
7653
7656
  client;
7654
7657
  loadingStrategy;
7655
7658
  catalog;
@@ -7662,9 +7665,9 @@ var ls = /* @__PURE__ */ new Set(["compaction_image_budget", "default_mode_reque
7662
7665
  async fork(e, t = {}, n = {}, r = {}) {
7663
7666
  let i = this.host.requireRuntime(e);
7664
7667
  if ((i.busy || i.activeTurnId) && !r.beforeTurnId && (!r.lastTurnId || r.lastTurnId === i.activeTurnId)) throw Error("Cannot fork a conversation while its current turn is still active");
7665
- let a = t.cwd ?? i.cwd ?? n.cwd, o = await this.catalog.loadConversationCatalogs(a ?? void 0), s = this.host.getState(), c = t.model ? ua(s.models, t.model) : q(s.models, i.selectedModelId);
7666
- da(c, t.reasoningEffort), ma(c, t.serviceTier);
7667
- let l = n.mcpServers === void 0 ? this.extensions.defaultMcpServers : Lo(n.mcpServers), u = await this.extensions.conversationExtension({
7668
+ let a = t.cwd ?? i.cwd ?? n.cwd, o = await this.catalog.loadConversationCatalogs(a ?? void 0), s = this.host.getState(), c = t.model ? la(s.models, t.model) : q(s.models, i.selectedModelId);
7669
+ ua(c, t.reasoningEffort), pa(c, t.serviceTier);
7670
+ let l = n.mcpServers === void 0 ? this.extensions.defaultMcpServers : Io(n.mcpServers), u = await this.extensions.conversationExtension({
7668
7671
  operation: "start",
7669
7672
  conversationId: null,
7670
7673
  cwd: a ?? void 0,
@@ -7682,23 +7685,23 @@ var ls = /* @__PURE__ */ new Set(["compaction_image_budget", "default_mode_reque
7682
7685
  ...u.baseInstructions === void 0 ? {} : { baseInstructions: u.baseInstructions },
7683
7686
  ...u.developerInstructions === void 0 ? {} : { developerInstructions: u.developerInstructions },
7684
7687
  ...u.config === void 0 ? {} : { config: u.config },
7685
- ...ps(t, o.approvalPresets)
7688
+ ...fs(t, o.approvalPresets)
7686
7689
  });
7687
7690
  if (!d.thread.id || d.thread.id === e) throw Error(`Codex thread/fork returned an invalid new thread id '${d.thread.id}'`);
7688
7691
  t.reasoningEffort && await this.client.request("thread/settings/update", {
7689
7692
  threadId: d.thread.id,
7690
7693
  effort: t.reasoningEffort,
7691
- ...c ? { collaborationMode: Ca(i.planMode, c.model, t.reasoningEffort) } : {}
7694
+ ...c ? { collaborationMode: Sa(i.planMode, c.model, t.reasoningEffort) } : {}
7692
7695
  });
7693
7696
  let f = n.historyItemsView ?? i.historyItemsView ?? "full", [p, m] = await Promise.all([this.client.request("thread/turns/list", {
7694
7697
  threadId: d.thread.id,
7695
7698
  cursor: null,
7696
- limit: ds,
7699
+ limit: us,
7697
7700
  sortDirection: "desc",
7698
7701
  itemsView: f
7699
7702
  }), this.client.request("thread/goal/get", { threadId: d.thread.id }).then((e) => e.goal).catch(() => null)]), h = await Promise.all([...p.data].reverse().map(async (e) => e.status === "inProgress" && (e.itemsView === "summary" || e.itemsView === "notLoaded") ? {
7700
7703
  ...e,
7701
- items: await Xo(this.client, d.thread.id, e.id),
7704
+ items: await Yo(this.client, d.thread.id, e.id),
7702
7705
  itemsView: "full"
7703
7706
  } : e)), g = f === "full" ? await this.originalImages?.prepare(d.thread.id, d.thread.path) : void 0, _ = ln(h), v = Dn({
7704
7707
  ...d.thread,
@@ -7721,9 +7724,9 @@ var ls = /* @__PURE__ */ new Set(["compaction_image_budget", "default_mode_reque
7721
7724
  messages: y,
7722
7725
  busy: !!_,
7723
7726
  goal: m ? { ...m } : null,
7724
- threadStatus: Fa(d.thread.status),
7727
+ threadStatus: Pa(d.thread.status),
7725
7728
  ...o,
7726
- ...ba(d, s.models, this.host.snapshotForRuntime(i))
7729
+ ...ya(d, s.models, this.host.snapshotForRuntime(i))
7727
7730
  });
7728
7731
  t.reasoningEffort && (x.selectedReasoningEffort = t.reasoningEffort), t.serviceTier !== void 0 && (x.selectedServiceTier = t.serviceTier), t.model && c && (x.selectedModelId = c.id), this.host.rememberHostOptions(d.thread.id, {
7729
7732
  ...n,
@@ -7743,10 +7746,10 @@ var ls = /* @__PURE__ */ new Set(["compaction_image_budget", "default_mode_reque
7743
7746
  return this.fork(e, n, r, { lastTurnId: t });
7744
7747
  }
7745
7748
  };
7746
- function ps(e, t) {
7749
+ function fs(e, t) {
7747
7750
  if (e.approvalPreset) {
7748
7751
  if (!t.includes(e.approvalPreset)) throw Error(`Approval preset '${e.approvalPreset}' is not available`);
7749
- return _a(e.approvalPreset);
7752
+ return ga(e.approvalPreset);
7750
7753
  }
7751
7754
  return {
7752
7755
  ...e.approvalMode === void 0 ? {} : { approvalPolicy: e.approvalMode === "ask" ? "on-request" : "never" },
@@ -7755,24 +7758,24 @@ function ps(e, t) {
7755
7758
  }
7756
7759
  //#endregion
7757
7760
  //#region src/node/codex-markdown-images.ts
7758
- var ms = /(?<!\[)!\[([^\]]*)\]\(([^)\s]+)(?:\s+["']([^"']*)["'])?\)/g, hs = /* @__PURE__ */ new Set([
7761
+ var ps = /(?<!\[)!\[([^\]]*)\]\(([^)\s]+)(?:\s+["']([^"']*)["'])?\)/g, ms = /* @__PURE__ */ new Set([
7759
7762
  ".avif",
7760
7763
  ".gif",
7761
7764
  ".jpeg",
7762
7765
  ".jpg",
7763
7766
  ".png",
7764
7767
  ".webp"
7765
- ]), gs = class {
7768
+ ]), hs = class {
7766
7769
  client;
7767
7770
  constructor(e) {
7768
7771
  this.client = e;
7769
7772
  }
7770
7773
  async hydrate(e, t) {
7771
- let n = ys(e);
7772
- return vs(e, (await Promise.all(Array.from(e.matchAll(ms), async (e) => {
7774
+ let n = vs(e);
7775
+ return _s(e, (await Promise.all(Array.from(e.matchAll(ps), async (e) => {
7773
7776
  let r = e.index ?? 0;
7774
- if (bs(r, n)) return null;
7775
- let i = e[2], a = _s(i, t);
7777
+ if (ys(r, n)) return null;
7778
+ let i = e[2], a = gs(i, t);
7776
7779
  if (!a) return null;
7777
7780
  try {
7778
7781
  let t = Hn((await this.client.request("fs/readFile", { path: a })).dataBase64);
@@ -7789,7 +7792,7 @@ var ms = /(?<!\[)!\[([^\]]*)\]\(([^)\s]+)(?:\s+["']([^"']*)["'])?\)/g, hs = /* @
7789
7792
  }))).filter((e) => e !== null));
7790
7793
  }
7791
7794
  };
7792
- function _s(e, t) {
7795
+ function gs(e, t) {
7793
7796
  let n = e.trim();
7794
7797
  if (!n || /[\u0000-\u001f\u007f]/.test(n)) return null;
7795
7798
  let r;
@@ -7804,18 +7807,18 @@ function _s(e, t) {
7804
7807
  } catch {
7805
7808
  return null;
7806
7809
  }
7807
- if (!hs.has(_(r).toLowerCase())) return null;
7810
+ if (!ms.has(_(r).toLowerCase())) return null;
7808
7811
  if (v(r)) return r;
7809
7812
  if (!t || !v(t)) return null;
7810
7813
  let i = x(t, r), a = b(t, i);
7811
7814
  return a === ".." || a.startsWith(`..${S}`) || v(a) ? null : i;
7812
7815
  }
7813
- function vs(e, t) {
7816
+ function _s(e, t) {
7814
7817
  let n = e;
7815
7818
  for (let e of t.sort((e, t) => t.start - e.start)) n = `${n.slice(0, e.start)}${e.value}${n.slice(e.end)}`;
7816
7819
  return n;
7817
7820
  }
7818
- function ys(e) {
7821
+ function vs(e) {
7819
7822
  let t = [], n = /(^|\n)(```|~~~)/g, r;
7820
7823
  for (; (r = n.exec(e)) !== null;) {
7821
7824
  let i = r[2], a = r[1], o = r.index + a.length, s = RegExp(`(^|\\n)${i}`, "g");
@@ -7836,15 +7839,15 @@ function ys(e) {
7836
7839
  }
7837
7840
  return t;
7838
7841
  }
7839
- function bs(e, t) {
7842
+ function ys(e, t) {
7840
7843
  return t.some((t) => e >= t.start && e <= t.end);
7841
7844
  }
7842
- var xs = /<context>[\s\S]*?<\/context>\s*/g, Ss = /<in-app-browser-context(?:\s[^>]*)?>[\s\S]*?<\/in-app-browser-context>\s*/g, Cs = /^[ \t]*## My request for Codex:[ \t]*$/m;
7843
- async function ws(e, t) {
7845
+ var bs = /<context>[\s\S]*?<\/context>\s*/g, xs = /<in-app-browser-context(?:\s[^>]*)?>[\s\S]*?<\/in-app-browser-context>\s*/g, Ss = /^[ \t]*## My request for Codex:[ \t]*$/m;
7846
+ async function Cs(e, t) {
7844
7847
  let n = A(t);
7845
7848
  return {
7846
7849
  conversationId: n,
7847
- prompts: Ts((await e.request("thread/turns/list", {
7850
+ prompts: ws((await e.request("thread/turns/list", {
7848
7851
  threadId: n,
7849
7852
  cursor: null,
7850
7853
  limit: 100,
@@ -7853,20 +7856,20 @@ async function ws(e, t) {
7853
7856
  })).data)
7854
7857
  };
7855
7858
  }
7856
- function Ts(e) {
7859
+ function ws(e) {
7857
7860
  return [...e].reverse().flatMap((e) => e.items.flatMap((e) => {
7858
7861
  if (e.type !== "userMessage") return [];
7859
- let t = Es(e.content.flatMap((e) => e.type === "text" ? [e.text] : []).join(""));
7862
+ let t = Ts(e.content.flatMap((e) => e.type === "text" ? [e.text] : []).join(""));
7860
7863
  return t && t !== "(no user instructions)" ? [t] : [];
7861
7864
  }));
7862
7865
  }
7863
- function Es(e) {
7864
- let t = e.replace(xs, ""), n = t.replace(Ss, "");
7865
- return (n === t ? n : n.replace(Cs, "")).trim();
7866
+ function Ts(e) {
7867
+ let t = e.replace(bs, ""), n = t.replace(xs, "");
7868
+ return (n === t ? n : n.replace(Ss, "")).trim();
7866
7869
  }
7867
7870
  //#endregion
7868
7871
  //#region src/node/codex-surface-text-generation-controller.ts
7869
- var Ds = 12e4, Os = class {
7872
+ var Es = 12e4, Ds = class {
7870
7873
  client;
7871
7874
  defaultCwd;
7872
7875
  host;
@@ -7877,7 +7880,7 @@ var Ds = 12e4, Os = class {
7877
7880
  }
7878
7881
  handleNotification(e) {
7879
7882
  e.method === "thread/started" && e.params.thread.ephemeral && this.hiddenThreadIds.add(e.params.thread.id);
7880
- let t = Ms(e);
7883
+ let t = js(e);
7881
7884
  if (!t || !this.hiddenThreadIds.has(t)) return !1;
7882
7885
  let n = this.pendingByThread.get(t);
7883
7886
  return n && this.consumeNotification(n, e), (e.method === "thread/closed" || e.method === "thread/deleted") && this.hiddenThreadIds.delete(t), !0;
@@ -7885,10 +7888,10 @@ var Ds = 12e4, Os = class {
7885
7888
  async generate(e, t = {}) {
7886
7889
  let n = e.trim();
7887
7890
  if (!n) throw Error("Generation prompt cannot be empty");
7888
- if (t.signal?.aborted) throw Ns();
7891
+ if (t.signal?.aborted) throw Ms();
7889
7892
  await this.host.ensureConnected();
7890
- let r = this.host.getSnapshot(), i = q(r.models, r.selectedModelId), a = t.model ? ua(r.models, t.model) : i, o = a?.model, s = t.reasoningEffort ?? (a?.id === i?.id ? r.selectedReasoningEffort : a ? fa(a) : null) ?? void 0, c = t.serviceTier === void 0 ? a?.id === i?.id ? r.selectedServiceTier : a?.defaultServiceTier ?? null : t.serviceTier;
7891
- da(a, s), ma(a, c);
7893
+ let r = this.host.getSnapshot(), i = q(r.models, r.selectedModelId), a = t.model ? la(r.models, t.model) : i, o = a?.model, s = t.reasoningEffort ?? (a?.id === i?.id ? r.selectedReasoningEffort : a ? da(a) : null) ?? void 0, c = t.serviceTier === void 0 ? a?.id === i?.id ? r.selectedServiceTier : a?.defaultServiceTier ?? null : t.serviceTier;
7894
+ ua(a, s), pa(a, c);
7892
7895
  let l = await this.client.request("thread/start", {
7893
7896
  approvalPolicy: "never",
7894
7897
  approvalsReviewer: "user",
@@ -7904,15 +7907,15 @@ var Ds = 12e4, Os = class {
7904
7907
  serviceName: "codex_app_sdk",
7905
7908
  threadSource: "sdk_ephemeral_generation"
7906
7909
  }), u = l.thread.id;
7907
- if (!l.thread.ephemeral) throw await ks(() => this.client.request("thread/delete", { threadId: u })), Error("Codex app-server did not create an ephemeral generation thread");
7908
- if (this.hiddenThreadIds.add(u), t.signal?.aborted) throw await ks(() => this.client.request("thread/unsubscribe", { threadId: u })), this.hiddenThreadIds.delete(u), Ns();
7909
- let d = As();
7910
+ if (!l.thread.ephemeral) throw await Os(() => this.client.request("thread/delete", { threadId: u })), Error("Codex app-server did not create an ephemeral generation thread");
7911
+ if (this.hiddenThreadIds.add(u), t.signal?.aborted) throw await Os(() => this.client.request("thread/unsubscribe", { threadId: u })), this.hiddenThreadIds.delete(u), Ms();
7912
+ let d = ks();
7910
7913
  this.pendingByThread.set(u, d);
7911
- let f = null, p = !1, m = () => d.reject(Ns());
7914
+ let f = null, p = !1, m = () => d.reject(Ms());
7912
7915
  t.signal?.addEventListener("abort", m);
7913
7916
  let h = setTimeout(() => {
7914
7917
  d.reject(/* @__PURE__ */ Error("Codex ephemeral generation timed out"));
7915
- }, t.timeoutMs ?? Ds);
7918
+ }, t.timeoutMs ?? Es);
7916
7919
  try {
7917
7920
  let e = await this.client.request("turn/start", {
7918
7921
  threadId: u,
@@ -7928,18 +7931,18 @@ var Ds = 12e4, Os = class {
7928
7931
  serviceTier: c,
7929
7932
  ...t.outputSchema === void 0 ? {} : { outputSchema: t.outputSchema }
7930
7933
  });
7931
- f = e.turn.id, d.turnId = f, js(d, e.turn);
7934
+ f = e.turn.id, d.turnId = f, As(d, e.turn);
7932
7935
  let r = await d.promise;
7933
7936
  return p = !0, r;
7934
7937
  } finally {
7935
7938
  if (clearTimeout(h), t.signal?.removeEventListener("abort", m), this.pendingByThread.delete(u), !p && f) {
7936
7939
  let e = f;
7937
- await ks(() => this.client.request("turn/interrupt", {
7940
+ await Os(() => this.client.request("turn/interrupt", {
7938
7941
  threadId: u,
7939
7942
  turnId: e
7940
7943
  }));
7941
7944
  }
7942
- await ks(() => this.client.request("thread/unsubscribe", { threadId: u })), this.hiddenThreadIds.delete(u);
7945
+ await Os(() => this.client.request("thread/unsubscribe", { threadId: u })), this.hiddenThreadIds.delete(u);
7943
7946
  }
7944
7947
  }
7945
7948
  close(e = /* @__PURE__ */ Error("Codex surface closed")) {
@@ -7962,16 +7965,16 @@ var Ds = 12e4, Os = class {
7962
7965
  }
7963
7966
  if (t.method === "turn/completed") {
7964
7967
  if (e.turnId && t.params.turn.id !== e.turnId) return;
7965
- js(e, t.params.turn);
7968
+ As(e, t.params.turn);
7966
7969
  }
7967
7970
  }
7968
7971
  };
7969
- async function ks(e) {
7972
+ async function Os(e) {
7970
7973
  try {
7971
7974
  await e();
7972
7975
  } catch {}
7973
7976
  }
7974
- function As() {
7977
+ function ks() {
7975
7978
  let e, t, n = {
7976
7979
  promise: new Promise((n, r) => {
7977
7980
  e = n, t = r;
@@ -7987,7 +7990,7 @@ function As() {
7987
7990
  };
7988
7991
  return n.promise.catch(() => void 0), n;
7989
7992
  }
7990
- function js(e, t) {
7993
+ function As(e, t) {
7991
7994
  for (let n of t.items) {
7992
7995
  if (n.type !== "agentMessage") continue;
7993
7996
  let t = n.text.trim();
@@ -8009,17 +8012,17 @@ function js(e, t) {
8009
8012
  }
8010
8013
  e.resolve({ text: n });
8011
8014
  }
8012
- function Ms(e) {
8015
+ function js(e) {
8013
8016
  if (e.method === "thread/started") return e.params.thread.id;
8014
8017
  let t = e.params;
8015
8018
  return typeof t.threadId == "string" ? t.threadId : null;
8016
8019
  }
8017
- function Ns() {
8020
+ function Ms() {
8018
8021
  return /* @__PURE__ */ Error("Codex ephemeral generation was aborted");
8019
8022
  }
8020
8023
  //#endregion
8021
8024
  //#region src/node/codex-surface-usage-controller.ts
8022
- var Ps = {
8025
+ var Ns = {
8023
8026
  status: "unavailable",
8024
8027
  reason: "public-runtime-request-evidence-unavailable",
8025
8028
  unavailableFields: [
@@ -8037,7 +8040,7 @@ var Ps = {
8037
8040
  "finality"
8038
8041
  ],
8039
8042
  requests: null
8040
- }, Fs = class {
8043
+ }, Ps = class {
8041
8044
  threads = /* @__PURE__ */ new Map();
8042
8045
  clear() {
8043
8046
  this.threads.clear();
@@ -8079,16 +8082,16 @@ var Ps = {
8079
8082
  let e = r.executions.get(r.activeTurnId);
8080
8083
  e && (e.baseline = null), i && (i.baseline = null);
8081
8084
  }
8082
- i && (!Ls(a.total) || i.latest && !Rs(i.latest.total, a.total)) && (i.baseline = null);
8083
- let s = i?.baseline ? zs(i.baseline, a.total) : null;
8085
+ i && (!Is(a.total) || i.latest && !Ls(i.latest.total, a.total)) && (i.baseline = null);
8086
+ let s = i?.baseline ? Rs(i.baseline, a.total) : null;
8084
8087
  i && s === null && (i.baseline = null);
8085
8088
  let c = {
8086
8089
  ...a,
8087
8090
  execution: s,
8088
8091
  observedStart: !!i,
8089
- requestUsage: structuredClone(Ps)
8092
+ requestUsage: structuredClone(Ns)
8090
8093
  };
8091
- return i && (i.latest = structuredClone(c)), r.total = !o && Ls(a.total) ? structuredClone(a.total) : null, r.lastUsageTurnId = t.turnId, {
8094
+ return i && (i.latest = structuredClone(c)), r.total = !o && Is(a.total) ? structuredClone(a.total) : null, r.lastUsageTurnId = t.turnId, {
8092
8095
  ...t,
8093
8096
  payload: { usage: c }
8094
8097
  };
@@ -8102,21 +8105,21 @@ var Ps = {
8102
8105
  executions: /* @__PURE__ */ new Map()
8103
8106
  }, this.threads.set(e, t)), t;
8104
8107
  }
8105
- }, Is = [
8108
+ }, Fs = [
8106
8109
  "totalTokens",
8107
8110
  "inputTokens",
8108
8111
  "cachedInputTokens",
8109
8112
  "outputTokens",
8110
8113
  "reasoningOutputTokens"
8111
8114
  ];
8112
- function Ls(e) {
8113
- return Is.every((t) => Number.isSafeInteger(e[t]) && e[t] >= 0) && (e.cacheWriteInputTokens === null || Number.isSafeInteger(e.cacheWriteInputTokens) && e.cacheWriteInputTokens >= 0) && e.totalTokens === e.inputTokens + e.outputTokens && e.cachedInputTokens <= e.inputTokens && e.reasoningOutputTokens <= e.outputTokens;
8115
+ function Is(e) {
8116
+ return Fs.every((t) => Number.isSafeInteger(e[t]) && e[t] >= 0) && (e.cacheWriteInputTokens === null || Number.isSafeInteger(e.cacheWriteInputTokens) && e.cacheWriteInputTokens >= 0) && e.totalTokens === e.inputTokens + e.outputTokens && e.cachedInputTokens <= e.inputTokens && e.reasoningOutputTokens <= e.outputTokens;
8114
8117
  }
8115
- function Rs(e, t) {
8116
- return Is.every((n) => t[n] >= e[n]) && (e.cacheWriteInputTokens === null || t.cacheWriteInputTokens === null || t.cacheWriteInputTokens >= e.cacheWriteInputTokens);
8118
+ function Ls(e, t) {
8119
+ return Fs.every((n) => t[n] >= e[n]) && (e.cacheWriteInputTokens === null || t.cacheWriteInputTokens === null || t.cacheWriteInputTokens >= e.cacheWriteInputTokens);
8117
8120
  }
8118
- function zs(e, t) {
8119
- if (!Ls(e) || !Ls(t) || !Rs(e, t)) return null;
8121
+ function Rs(e, t) {
8122
+ if (!Is(e) || !Is(t) || !Ls(e, t)) return null;
8120
8123
  let n = {
8121
8124
  totalTokens: t.totalTokens - e.totalTokens,
8122
8125
  inputTokens: t.inputTokens - e.inputTokens,
@@ -8125,11 +8128,11 @@ function zs(e, t) {
8125
8128
  outputTokens: t.outputTokens - e.outputTokens,
8126
8129
  reasoningOutputTokens: t.reasoningOutputTokens - e.reasoningOutputTokens
8127
8130
  };
8128
- return Ls(n) ? n : null;
8131
+ return Is(n) ? n : null;
8129
8132
  }
8130
8133
  //#endregion
8131
8134
  //#region src/node/codex-surface.ts
8132
- var Bs = class {
8135
+ var zs = class {
8133
8136
  options;
8134
8137
  client;
8135
8138
  listeners = /* @__PURE__ */ new Set();
@@ -8161,21 +8164,21 @@ var Bs = class {
8161
8164
  unsubscribeToolInputRequests;
8162
8165
  unsubscribeMcpElicitationRequests;
8163
8166
  eventSequence = 0;
8164
- usage = new Fs();
8167
+ usage = new Ps();
8165
8168
  accountGeneration = 0;
8166
8169
  pendingMarkdownImageHydrations = /* @__PURE__ */ new Set();
8167
8170
  closed = !1;
8168
- state = ta(ia());
8171
+ state = ea(ra());
8169
8172
  constructor(e = {}) {
8170
- this.options = e, this.extensions = new Wo(e.extensions ?? [], e.mcpServers ?? [], (e) => this.lifecycle.hostOptions(e));
8171
- let n = Wa(e);
8172
- this.client = e.client ?? new t(Ua(n) ? new $e(n) : new Je(n), e.onListenerError ? { onListenerError: e.onListenerError } : {}), this.originalImages = e.originalHistoryImages ? new zi(this.client) : void 0, this.markdownImages = new gs(this.client), this.authentication = new Ka(this.client, {
8173
+ this.options = e, this.extensions = new Uo(e.extensions ?? [], e.mcpServers ?? [], (e) => this.lifecycle.hostOptions(e));
8174
+ let n = Ua(e);
8175
+ this.client = e.client ?? new t(Ha(n) ? new $e(n) : new Je(n), e.onListenerError ? { onListenerError: e.onListenerError } : {}), this.originalImages = e.originalHistoryImages ? new Ri(this.client) : void 0, this.markdownImages = new hs(this.client), this.authentication = new Ga(this.client, {
8173
8176
  bootstrapSurfaceData: (e) => this.connection.bootstrapSurfaceData(e),
8174
8177
  clearAuthenticatedSurfaceData: () => this.connection.clearAuthenticatedSurfaceData(),
8175
8178
  getSnapshot: () => this.getSnapshot(),
8176
8179
  patchAuthentication: (e, t) => this.connection.patchAuthentication(e, t),
8177
8180
  reportError: (e) => this.patch({ error: j(e) })
8178
- }), this.items = new po({
8181
+ }), this.items = new fo({
8179
8182
  assistantMessageForTurn: (e, t) => this.assistantMessageForTurn(e, t),
8180
8183
  emitConversationActivity: (e, t) => this.emitConversationActivity(e, t),
8181
8184
  emitEvent: (e, t) => this.emitEvent(e, t),
@@ -8189,7 +8192,7 @@ var Bs = class {
8189
8192
  sendNextQueuedPrompt: (e) => {
8190
8193
  this.messagesController.sendNextQueuedPrompt(e);
8191
8194
  }
8192
- }), this.approvals = new Io(this.client, {
8195
+ }), this.approvals = new Fo(this.client, {
8193
8196
  activeConversationId: () => this.state.activeConversationId,
8194
8197
  createRuntime: (e, t) => this.createRuntime(e, t),
8195
8198
  emitConversationActivity: (e, t) => this.emitConversationActivity(e, t),
@@ -8199,7 +8202,7 @@ var Bs = class {
8199
8202
  patch: (e) => this.patch(e),
8200
8203
  patchConversationStatus: (e, t) => this.patchConversationStatus(e, t),
8201
8204
  patchRuntime: (e, t) => this.patchRuntime(e, t)
8202
- }), this.clientRequests = new go({
8205
+ }), this.clientRequests = new ho({
8203
8206
  activeConversationId: () => this.state.activeConversationId,
8204
8207
  answerAsyncQuestion: (e, t, n) => this.messagesController.answerAsyncQuestion(e, t, n),
8205
8208
  emitConversationActivity: (e, t) => this.emitConversationActivity(e, t),
@@ -8209,13 +8212,13 @@ var Bs = class {
8209
8212
  messageContainingTool: (e, t, n) => this.messageContainingTool(e, t, n),
8210
8213
  patchRuntime: (e, t) => this.patchRuntime(e, t),
8211
8214
  requireRuntime: (e) => this.requireRuntime(e)
8212
- }), this.runtimeState = new as(this.approvals, this.clientRequests, {
8215
+ }), this.runtimeState = new is(this.approvals, this.clientRequests, {
8213
8216
  emitEvent: (e, t) => this.emitEvent(e, t),
8214
8217
  getState: () => this.state,
8215
8218
  notifyConversationListeners: (e) => this.notifyConversationListeners(e),
8216
8219
  patch: (e, t) => this.patch(e, t),
8217
8220
  schedulePluginRefresh: () => this.catalog.schedulePluginRefresh()
8218
- }), this.conversationSettings = new Zo(this.client, {
8221
+ }), this.conversationSettings = new Xo(this.client, {
8219
8222
  approvalMode: e.approvalMode,
8220
8223
  approvalPreset: e.approvalPreset,
8221
8224
  permissionMode: e.permissionMode
@@ -8233,7 +8236,7 @@ var Bs = class {
8233
8236
  patch: (e) => this.patch(e),
8234
8237
  patchRuntime: (e, t) => this.patchRuntime(e, t),
8235
8238
  snapshotForRuntime: (e) => this.snapshotForRuntime(e)
8236
- }), this.turnActions = new $o(this.client, {
8239
+ }), this.turnActions = new Qo(this.client, {
8237
8240
  createConversation: async () => {
8238
8241
  await this.createConversation();
8239
8242
  },
@@ -8251,7 +8254,7 @@ var Bs = class {
8251
8254
  patchConversationTurnCount: (e, t, n) => this.patchConversationTurnCount(e, t, n),
8252
8255
  patchRuntime: (e, t) => this.patchRuntime(e, t),
8253
8256
  sendMessageToThread: (e, t, n) => this.messagesController.sendToThread(e, t, n)
8254
- }), this.messagesController = new ts(this.client, {
8257
+ }), this.messagesController = new es(this.client, {
8255
8258
  clearGoalForThread: (e) => this.conversationSettings.clearGoalForThread(e),
8256
8259
  compactForThread: (e) => this.turnActions.compactForThread(e),
8257
8260
  createConversation: async () => {
@@ -8274,7 +8277,7 @@ var Bs = class {
8274
8277
  startReviewForThread: (e, t) => this.turnActions.startReviewForThread(e, t),
8275
8278
  updateSettings: (e) => this.conversationSettings.update(e),
8276
8279
  updateSettingsForThread: (e, t) => this.conversationSettings.updateForThread(e, t)
8277
- }), this.catalog = new Oo(this.client, e.cwd, {
8280
+ }), this.catalog = new Do(this.client, e.cwd, {
8278
8281
  authenticationBlocksBootstrap: () => this.authentication.blocksBootstrap(),
8279
8282
  emitConversationSkills: (e, t) => this.emitConversationSkills(e, t),
8280
8283
  emitEvent: (e, t) => this.emitEvent(e, t),
@@ -8285,7 +8288,7 @@ var Bs = class {
8285
8288
  patchRuntime: (e, t) => this.patchRuntime(e, t),
8286
8289
  preferredApprovalPreset: () => this.conversationSettings.preferredApprovalPreset(),
8287
8290
  runtimes: () => this.runtimeState.values()
8288
- }), this.conversations = new Jo(this.client, e.conversationLimit, {
8291
+ }), this.conversations = new qo(this.client, e.conversationLimit, {
8289
8292
  emitHistoryReplaced: (e, t, n) => this.emitHistoryReplaced(e, t, n),
8290
8293
  emitHistoryPrepended: (e, t, n) => this.emitHistoryPrepended(e, t, n),
8291
8294
  emitSummaryUpserted: (e, t, n) => this.emitSummaryUpserted(e, t, n),
@@ -8298,7 +8301,7 @@ var Bs = class {
8298
8301
  requireRuntime: (e) => this.requireRuntime(e),
8299
8302
  runtime: (e) => this.runtimeState.get(e),
8300
8303
  schedulePluginRefresh: (e) => this.catalog.schedulePluginRefresh(e)
8301
- }, this.originalImages), this.lifecycle = new rs(this.client, e, this.catalog, this.extensions, this.conversationSettings, this.conversations, {
8304
+ }, this.originalImages), this.lifecycle = new ns(this.client, e, this.catalog, this.extensions, this.conversationSettings, this.conversations, {
8302
8305
  activateRuntime: (e) => this.activateRuntime(e),
8303
8306
  createRuntime: (e, t) => this.createRuntime(e, t),
8304
8307
  emitConversationActivity: (e, t) => this.emitConversationActivity(e, t),
@@ -8321,7 +8324,7 @@ var Bs = class {
8321
8324
  runtime: (e) => this.runtimeState.get(e),
8322
8325
  runtimeProjection: (e) => this.runtimeProjection(e),
8323
8326
  snapshotForRuntime: (e) => this.snapshotForRuntime(e)
8324
- }, this.originalImages), this.forks = new fs(this.client, e.loadingStrategy, this.catalog, this.extensions, {
8327
+ }, this.originalImages), this.forks = new ds(this.client, e.loadingStrategy, this.catalog, this.extensions, {
8325
8328
  createRuntime: (e, t) => this.createRuntime(e, t),
8326
8329
  emitConversationActivity: (e) => this.emitConversationActivity(e, "action"),
8327
8330
  emitConversationPermissions: (e) => this.emitConversationPermissions(e, "action"),
@@ -8336,7 +8339,7 @@ var Bs = class {
8336
8339
  rememberHostOptions: (e, t) => this.lifecycle.rememberHostOptions(e, t),
8337
8340
  requireRuntime: (e) => this.requireRuntime(e),
8338
8341
  snapshotForRuntime: (e) => this.snapshotForRuntime(e)
8339
- }, this.originalImages), this.connection = new us(this.client, e, this.authentication, this.approvals, this.catalog, this.clientRequests, this.conversations, this.items, this.lifecycle, this.runtimeState, {
8342
+ }, this.originalImages), this.connection = new ls(this.client, e, this.authentication, this.approvals, this.catalog, this.clientRequests, this.conversations, this.items, this.lifecycle, this.runtimeState, {
8340
8343
  clearConversationHandles: () => this.conversationHandles.clear(),
8341
8344
  clearPendingForThread: (e, t, n) => this.clearPendingForThread(e, t, n),
8342
8345
  closed: () => this.closed,
@@ -8348,7 +8351,7 @@ var Bs = class {
8348
8351
  getSnapshot: () => this.getSnapshot(),
8349
8352
  getState: () => this.state,
8350
8353
  patch: (e) => this.patch(e)
8351
- }), this.notifications = new is(this.authentication, this.approvals, this.catalog, this.clientRequests, this.conversations, this.items, {
8354
+ }), this.notifications = new rs(this.authentication, this.approvals, this.catalog, this.clientRequests, this.conversations, this.items, {
8352
8355
  clearPendingForThread: (e, t, n) => this.clearPendingForThread(e, t, n),
8353
8356
  createRuntime: (e, t) => this.createRuntime(e, t),
8354
8357
  emitConversationActivity: (e, t) => this.emitConversationActivity(e, t),
@@ -8372,7 +8375,7 @@ var Bs = class {
8372
8375
  },
8373
8376
  snapshotForRuntime: (e) => this.snapshotForRuntime(e),
8374
8377
  unknownNotification: (e) => this.handleUnknownNotification(e)
8375
- }), this.textGeneration = new Os(this.client, e.cwd, {
8378
+ }), this.textGeneration = new Ds(this.client, e.cwd, {
8376
8379
  ensureConnected: () => this.ensureConnected(),
8377
8380
  getSnapshot: () => this.getSnapshot()
8378
8381
  }), this.unsubscribeNotification = this.client.onNotification((e) => {
@@ -8406,7 +8409,7 @@ var Bs = class {
8406
8409
  }
8407
8410
  async readRateLimits(e) {
8408
8411
  return this.requestForAccount(() => this.client.request("account/rateLimits/read", e), (e) => {
8409
- let t = La(e);
8412
+ let t = Ia(e);
8410
8413
  return this.patch({ rateLimits: t }), this.emitEvent("action", {
8411
8414
  type: "rateLimits.changed",
8412
8415
  payload: { rateLimits: structuredClone(t) }
@@ -8414,7 +8417,7 @@ var Bs = class {
8414
8417
  });
8415
8418
  }
8416
8419
  async readAccountUsage() {
8417
- return this.requestForAccount(() => this.client.request("account/usage/read", {}), za);
8420
+ return this.requestForAccount(() => this.client.request("account/usage/read", {}), Ra);
8418
8421
  }
8419
8422
  async consumeRateLimitResetCredit(e) {
8420
8423
  if (!e || typeof e.idempotencyKey != "string" || !e.idempotencyKey.trim() || e.creditId !== void 0 && (typeof e.creditId != "string" || !e.creditId.trim())) throw TypeError("Reset-credit options require non-empty identifiers");
@@ -8557,7 +8560,7 @@ var Bs = class {
8557
8560
  return this.lifecycle.readHistory(e);
8558
8561
  }
8559
8562
  async readConversationPromptHistory(e = this.state.activeConversationId ?? "") {
8560
- return await this.ensureConnected(), ws(this.client, e);
8563
+ return await this.ensureConnected(), Cs(this.client, e);
8561
8564
  }
8562
8565
  async loadTurnHistory(e, t = this.state.activeConversationId ?? "") {
8563
8566
  return await this.ensureThreadReady(t), await this.conversations.loadTurnHistory(t, e), this.getConversationSnapshot(t);
@@ -8629,7 +8632,7 @@ var Bs = class {
8629
8632
  conversation(e) {
8630
8633
  let t = A(e), n = this.conversationHandles.get(t);
8631
8634
  if (n) return n;
8632
- let r = qa(t, {
8635
+ let r = Ka(t, {
8633
8636
  clearGoal: () => this.conversationSettings.clearGoalForThread(t),
8634
8637
  compact: () => this.turnActions.compactForThread(t),
8635
8638
  continueInterruptedTurn: () => this.messagesController.continueInterruptedTurnForThread(t),
@@ -8686,7 +8689,7 @@ var Bs = class {
8686
8689
  await this.client.request("thread/realtime/stop", { threadId: e });
8687
8690
  }
8688
8691
  startRealtimeForThread(e, t) {
8689
- return $i({
8692
+ return Qi({
8690
8693
  client: this.client,
8691
8694
  ensureThreadReady: async () => {
8692
8695
  await this.ensureThreadReady(e);
@@ -8907,8 +8910,8 @@ var Bs = class {
8907
8910
  }
8908
8911
  async requestForAccount(e, t) {
8909
8912
  await this.ensureConnected(), await this.authentication.pendingRefresh();
8910
- let n = this.accountGeneration, r = sa(this.state.authentication), i = await e();
8911
- if (this.closed || n !== this.accountGeneration || r !== sa(this.state.authentication)) throw Error("Account changed during account operation");
8913
+ let n = this.accountGeneration, r = oa(this.state.authentication), i = await e();
8914
+ if (this.closed || n !== this.accountGeneration || r !== oa(this.state.authentication)) throw Error("Account changed during account operation");
8912
8915
  return t(i);
8913
8916
  }
8914
8917
  emitEvent(e, t) {
@@ -8959,19 +8962,19 @@ var Bs = class {
8959
8962
  for (let e of this.conversationListeners.keys()) this.notifyConversationListeners(e);
8960
8963
  }
8961
8964
  };
8962
- function Vs(e = {}) {
8963
- return new Bs(e);
8965
+ function Bs(e = {}) {
8966
+ return new zs(e);
8964
8967
  }
8965
8968
  //#endregion
8966
8969
  //#region src/node/codex-app-backend-cache.ts
8967
- var Hs = {
8970
+ var Vs = {
8968
8971
  set(e, t) {
8969
8972
  return setTimeout(e, t);
8970
8973
  },
8971
8974
  clear(e) {
8972
8975
  clearTimeout(e);
8973
8976
  }
8974
- }, Us = class {
8977
+ }, Hs = class {
8975
8978
  options;
8976
8979
  records = /* @__PURE__ */ new Map();
8977
8980
  now;
@@ -8984,7 +8987,7 @@ var Hs = {
8984
8987
  constructor(e) {
8985
8988
  if (this.options = e, !Number.isFinite(e.ttlMs) || e.ttlMs <= 0) throw Error("Codex backend cache ttlMs must be greater than zero");
8986
8989
  if (e.sweepIntervalMs !== void 0 && e.sweepIntervalMs !== null && (!Number.isFinite(e.sweepIntervalMs) || e.sweepIntervalMs <= 0)) throw Error("Codex backend cache sweepIntervalMs must be greater than zero");
8987
- this.now = e.now ?? Date.now, this.scheduler = e.scheduler ?? Hs, this.sweepIntervalMs = e.sweepIntervalMs ?? null;
8990
+ this.now = e.now ?? Date.now, this.scheduler = e.scheduler ?? Vs, this.sweepIntervalMs = e.sweepIntervalMs ?? null;
8988
8991
  }
8989
8992
  get size() {
8990
8993
  return this.records.size;
@@ -9082,7 +9085,7 @@ var Hs = {
9082
9085
  assertOpen() {
9083
9086
  if (this.closed) throw Error("Codex backend cache is closed");
9084
9087
  }
9085
- }, Ws = class {
9088
+ }, Us = class {
9086
9089
  surface;
9087
9090
  moduleServices = /* @__PURE__ */ new Map();
9088
9091
  ttlCaches = /* @__PURE__ */ new Set();
@@ -9098,7 +9101,7 @@ var Hs = {
9098
9101
  if (n.has(e)) throw Error(`Duplicate Codex backend module '${e}'`);
9099
9102
  n.add(e);
9100
9103
  }
9101
- this.surface = e.surface ?? new Bs(e.surfaceOptions);
9104
+ this.surface = e.surface ?? new zs(e.surfaceOptions);
9102
9105
  for (let { id: e, module: n } of t) this.moduleServices.set(e, n.create({
9103
9106
  surface: this.surface,
9104
9107
  closeBackend: () => this.close(),
@@ -9112,7 +9115,7 @@ var Hs = {
9112
9115
  }
9113
9116
  createTtlCache(e) {
9114
9117
  if (this.closePromise) throw Error("Cannot create a cache after the Codex backend is closed");
9115
- let t = new Us(e);
9118
+ let t = new Hs(e);
9116
9119
  return this.ttlCaches.add(t), t;
9117
9120
  }
9118
9121
  close() {
@@ -9122,16 +9125,16 @@ var Hs = {
9122
9125
  await Promise.all([...this.ttlCaches].map((e) => e.close())), await this.surface.close();
9123
9126
  }
9124
9127
  };
9125
- function Gs(e = {}) {
9126
- return new Ws(e);
9128
+ function Ws(e = {}) {
9129
+ return new Us(e);
9127
9130
  }
9128
9131
  //#endregion
9129
9132
  //#region src/node/apple-speech-transcription.ts
9130
- async function Ks(e, t = {}, n = {}) {
9133
+ async function Gs(e, t = {}, n = {}) {
9131
9134
  let r = n.fs ?? l, i = n.spawn ?? o, a = n.tmpdir ?? f.tmpdir, s = await r.mkdtemp(h.join(a(), "codex-app-sdk-apple-stt-")), c = h.join(s, "input.wav"), u = h.join(s, "output.txt");
9132
9135
  try {
9133
- let a = await Zs(qs(n.assetsPath), s, r);
9134
- return await r.writeFile(c, e), await Ys(i, a, Js(c, u, t)), { text: (await r.readFile(u, "utf8")).trim() };
9136
+ let a = await Xs(Ks(n.assetsPath), s, r);
9137
+ return await r.writeFile(c, e), await Js(i, a, qs(c, u, t)), { text: (await r.readFile(u, "utf8")).trim() };
9135
9138
  } catch (e) {
9136
9139
  return {
9137
9140
  text: "",
@@ -9144,10 +9147,10 @@ async function Ks(e, t = {}, n = {}) {
9144
9147
  });
9145
9148
  }
9146
9149
  }
9147
- function qs(e, t = {}) {
9148
- return h.join(e ?? Xs(t), "apple-speechanalyzer-cli");
9150
+ function Ks(e, t = {}) {
9151
+ return h.join(e ?? Ys(t), "apple-speechanalyzer-cli");
9149
9152
  }
9150
- function Js(e, t, n) {
9153
+ function qs(e, t, n) {
9151
9154
  let r = [
9152
9155
  "--input-audio-path",
9153
9156
  e,
@@ -9156,7 +9159,7 @@ function Js(e, t, n) {
9156
9159
  ], i = n.locale?.trim();
9157
9160
  return i && r.push("--locale", i), n.live && r.push("--live"), r;
9158
9161
  }
9159
- function Ys(e, t, n) {
9162
+ function Js(e, t, n) {
9160
9163
  return new Promise((r, i) => {
9161
9164
  let a = e(t, n), o = "";
9162
9165
  a.stderr?.on("data", (e) => {
@@ -9172,7 +9175,7 @@ function Ys(e, t, n) {
9172
9175
  });
9173
9176
  });
9174
9177
  }
9175
- function Xs(e) {
9178
+ function Ys(e) {
9176
9179
  let t = (e.env ?? process.env).CODEX_APP_SDK_ASSETS_PATH?.trim();
9177
9180
  if (t) return t;
9178
9181
  let n = process.resourcesPath, r = e.resourcesPath === void 0 ? n : e.resourcesPath ?? void 0, i = e.existsSync ?? c;
@@ -9203,18 +9206,18 @@ function Xs(e) {
9203
9206
  let u = import.meta.url, d = e.moduleUrl === void 0 ? u : e.moduleUrl ?? void 0, f = d ? h.dirname(de(d)) : s, p = [h.resolve(f, "../assets"), h.resolve(f, "../../assets")];
9204
9207
  return p.find((e) => i(h.join(e, "apple-speechanalyzer-cli"))) ?? p[0];
9205
9208
  }
9206
- async function Zs(e, t, n) {
9209
+ async function Xs(e, t, n) {
9207
9210
  let r = h.join(t, "apple-speechanalyzer-cli");
9208
9211
  return await n.copyFile(e, r), await n.chmod(r, 448), r;
9209
9212
  }
9210
9213
  //#endregion
9211
9214
  //#region src/node/apple-speech-session.ts
9212
- async function Qs(e, t, n = {}) {
9215
+ async function Zs(e, t, n = {}) {
9213
9216
  if (n.signal?.throwIfAborted(), !Number.isInteger(e.sampleRate) || e.sampleRate < 8e3 || e.sampleRate > 96e3) throw Error("Unsupported speech sample rate.");
9214
9217
  let r = await ie(h.join(m(), "codex-sdk-live-speech-")), i;
9215
9218
  try {
9216
9219
  let t = h.join(r, "apple-speechanalyzer-cli");
9217
- await re(qs(n.assetsPath), t), await ne(t, 448), n.signal?.throwIfAborted(), i = (n.spawn ?? o)(t, [
9220
+ await re(Ks(n.assetsPath), t), await ne(t, 448), n.signal?.throwIfAborted(), i = (n.spawn ?? o)(t, [
9218
9221
  "--stream",
9219
9222
  "--sample-rate",
9220
9223
  String(e.sampleRate),
@@ -9316,6 +9319,6 @@ async function Qs(e, t, n = {}) {
9316
9319
  };
9317
9320
  }
9318
9321
  //#endregion
9319
- export { Ws as CodexAppBackend, Us as CodexAppBackendTtlCache, Je as CodexAppServerStdioTransport, $e as CodexAppServerUnixSocketTransport, Bs as CodexSurface, Ai as ConversationContentTransport, Mn as codexItemToMediaPart, An as codexItemToSurfaceMessage, T as codexItemToToolPart, be as codexRuntimePathEntries, Dn as codexThreadToSurfaceMessages, I as codexTurnToSurfaceMessages, Gs as createCodexAppBackend, Vs as createCodexSurface, ye as discoverCodexExecutable, On as preserveHistoricalAttachmentPreviews, qs as resolveAppleSpeechAnalyzerPath, Se as resolveCodexRuntime, Qs as startAppleSpeechSession, Ks as transcribeWithAppleSpeechAnalyzer, xe as withCodexRuntimePath };
9322
+ export { Us as CodexAppBackend, Hs as CodexAppBackendTtlCache, Je as CodexAppServerStdioTransport, $e as CodexAppServerUnixSocketTransport, zs as CodexSurface, Ai as ConversationContentTransport, Mn as codexItemToMediaPart, An as codexItemToSurfaceMessage, T as codexItemToToolPart, be as codexRuntimePathEntries, Dn as codexThreadToSurfaceMessages, I as codexTurnToSurfaceMessages, Ws as createCodexAppBackend, Bs as createCodexSurface, ye as discoverCodexExecutable, On as preserveHistoricalAttachmentPreviews, Ks as resolveAppleSpeechAnalyzerPath, Se as resolveCodexRuntime, Zs as startAppleSpeechSession, Gs as transcribeWithAppleSpeechAnalyzer, xe as withCodexRuntimePath };
9320
9323
 
9321
9324
  //# sourceMappingURL=index.js.map