@codex-app-sdk/backend 0.19.8 → 0.20.0

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
@@ -1075,7 +1075,7 @@ function nn(e = []) {
1075
1075
  path: e.kind === "plugin" ? `plugin://${e.id}` : e.id
1076
1076
  }] : []);
1077
1077
  }
1078
- function O(e, t) {
1078
+ function rn(e, t) {
1079
1079
  return e.map((e) => {
1080
1080
  let n = t.find((t) => t.enabled && t.name === e.name && t.path === e.path);
1081
1081
  if (!n) throw Error(`Skill '${e.name}' is not an enabled skill in the Codex catalog`);
@@ -1085,58 +1085,58 @@ function O(e, t) {
1085
1085
  };
1086
1086
  });
1087
1087
  }
1088
- function rn(...e) {
1088
+ function an(...e) {
1089
1089
  let t = /* @__PURE__ */ new Set();
1090
1090
  return e.flatMap((e) => e.filter((e) => {
1091
1091
  let n = `${e.name}\u0000${e.path}`;
1092
1092
  return t.has(n) ? !1 : (t.add(n), !0);
1093
1093
  }));
1094
1094
  }
1095
- function an(e, t, n, r) {
1095
+ function on(e, t, n, r) {
1096
1096
  let i = e.filter((e) => e.metadata?.turnId === t).flatMap((e) => e.parts).filter((e) => e.type === "tool" && e.kind === "mcp" && e.status === "running");
1097
1097
  return i.find((e) => {
1098
- let t = cn(e.metadata?.server), i = cn(e.metadata?.tool);
1098
+ let t = ln(e.metadata?.server), i = ln(e.metadata?.tool);
1099
1099
  return t === n && i === r || e.title.endsWith(`.${r}`);
1100
1100
  }) ?? (i.length === 1 ? i[0] ?? null : null);
1101
1101
  }
1102
- function on(e) {
1102
+ function sn(e) {
1103
1103
  if (Array.isArray(e.tool_params_display)) {
1104
- let t = e.tool_params_display.map((e) => !ln(e) || typeof e.name != "string" ? "" : `${cn(e.display_name) ?? e.name}: ${typeof e.value == "string" ? e.value : JSON.stringify(e.value)}`).filter(Boolean);
1104
+ let t = e.tool_params_display.map((e) => !un(e) || typeof e.name != "string" ? "" : `${ln(e.display_name) ?? e.name}: ${typeof e.value == "string" ? e.value : JSON.stringify(e.value)}`).filter(Boolean);
1105
1105
  if (t.length > 0) return t.join("\n");
1106
1106
  }
1107
1107
  return e.tool_params === void 0 ? "" : JSON.stringify(e.tool_params, null, 2);
1108
1108
  }
1109
- function sn(e, t) {
1109
+ function cn(e, t) {
1110
1110
  return e === t || Array.isArray(e) && e.includes(t);
1111
1111
  }
1112
- function cn(e) {
1112
+ function ln(e) {
1113
1113
  return typeof e == "string" && e.trim() ? e.trim() : null;
1114
1114
  }
1115
- function k(e) {
1115
+ function O(e) {
1116
1116
  let t = e.trim();
1117
1117
  if (!t) throw Error("Conversation id cannot be empty");
1118
1118
  return t;
1119
1119
  }
1120
- function ln(e) {
1120
+ function un(e) {
1121
1121
  return !!(e && typeof e == "object" && !Array.isArray(e));
1122
1122
  }
1123
- function A(e) {
1123
+ function k(e) {
1124
1124
  return e instanceof Error ? e.message : String(e);
1125
1125
  }
1126
1126
  //#endregion
1127
1127
  //#region src/node/codex-surface-message-state.ts
1128
- function un(e) {
1128
+ function dn(e) {
1129
1129
  for (let t = e.length - 1; t >= 0; --t) {
1130
1130
  let n = e[t];
1131
1131
  if (n?.status === "inProgress") return n.id;
1132
1132
  }
1133
1133
  return null;
1134
1134
  }
1135
- function j(e, t, n, r = {}) {
1136
- let i = [...e], a = P(i, (e) => e.metadata?.turnId === n), o = a >= 0 ? i[a] : void 0;
1135
+ function A(e, t, n, r = {}) {
1136
+ let i = [...e], a = N(i, (e) => e.metadata?.turnId === n), o = a >= 0 ? i[a] : void 0;
1137
1137
  if (o?.role === "assistant" && o.kind === void 0 && o.status === "streaming") return i;
1138
1138
  if (r.forceSegment) {
1139
- let e = P(i, (e) => e.role === "assistant" && e.kind === void 0 && e.metadata?.turnId === n), t = e >= 0 ? i[e] : void 0;
1139
+ let e = N(i, (e) => e.role === "assistant" && e.kind === void 0 && e.metadata?.turnId === n), t = e >= 0 ? i[e] : void 0;
1140
1140
  t?.parts.length === 0 ? i.splice(e, 1) : t && i.splice(e, 1, {
1141
1141
  ...t,
1142
1142
  status: "complete"
@@ -1156,9 +1156,9 @@ function j(e, t, n, r = {}) {
1156
1156
  }
1157
1157
  }), i;
1158
1158
  }
1159
- function dn(e, t, n, r, i, a) {
1159
+ function fn(e, t, n, r, i, a) {
1160
1160
  if (!i) return [...e];
1161
- let o = j(e, t, n), s = P(o, (e) => e.role === "assistant" && e.kind === void 0 && e.metadata?.turnId === n), c = s >= 0 ? o[s] : void 0;
1161
+ let o = A(e, t, n), s = N(o, (e) => e.role === "assistant" && e.kind === void 0 && e.metadata?.turnId === n), c = s >= 0 ? o[s] : void 0;
1162
1162
  if (!c) return o;
1163
1163
  let l = [...c.parts], u = l.at(-1);
1164
1164
  return u?.type === "text" && u.itemId === r ? l.splice(l.length - 1, 1, {
@@ -1174,9 +1174,9 @@ function dn(e, t, n, r, i, a) {
1174
1174
  ...c,
1175
1175
  status: "streaming",
1176
1176
  parts: l
1177
- }), N(o, t);
1177
+ }), M(o, t);
1178
1178
  }
1179
- function fn(e, t, n, r, i) {
1179
+ function pn(e, t, n, r, i) {
1180
1180
  let a = i.map((e, t) => {
1181
1181
  let n = e.trim();
1182
1182
  return n ? {
@@ -1192,16 +1192,16 @@ function fn(e, t, n, r, i) {
1192
1192
  itemId: r,
1193
1193
  summaryIndex: 0
1194
1194
  });
1195
- let o = j(e, t, n), s = P(o, (e) => e.role === "assistant" && e.kind === void 0 && e.metadata?.turnId === n), c = s >= 0 ? o[s] : void 0;
1195
+ let o = A(e, t, n), s = N(o, (e) => e.role === "assistant" && e.kind === void 0 && e.metadata?.turnId === n), c = s >= 0 ? o[s] : void 0;
1196
1196
  if (!c) return o;
1197
1197
  let l = c.parts.findIndex((e) => e.type === "reasoning" && e.itemId === r), u = c.parts.filter((e) => e.type !== "reasoning" || e.itemId !== r);
1198
1198
  return u.splice(l >= 0 ? l : u.length, 0, ...a), o.splice(s, 1, {
1199
1199
  ...c,
1200
1200
  status: "streaming",
1201
1201
  parts: u
1202
- }), N(o, t);
1202
+ }), M(o, t);
1203
1203
  }
1204
- function pn(e, t, n, r, i, a) {
1204
+ function mn(e, t, n, r, i, a) {
1205
1205
  let o = [...e];
1206
1206
  for (let e = o.length - 1; e >= 0; --e) {
1207
1207
  let s = o[e];
@@ -1217,9 +1217,9 @@ function pn(e, t, n, r, i, a) {
1217
1217
  }), o.splice(e, 1, {
1218
1218
  ...s,
1219
1219
  parts: l
1220
- }), N(o, t);
1220
+ }), M(o, t);
1221
1221
  }
1222
- let s = j(o, t, n), c = P(s, (e) => e.role === "assistant" && e.kind === void 0 && e.metadata?.turnId === n), l = c >= 0 ? s[c] : void 0;
1222
+ let s = A(o, t, n), c = N(s, (e) => e.role === "assistant" && e.kind === void 0 && e.metadata?.turnId === n), l = c >= 0 ? s[c] : void 0;
1223
1223
  if (!l) return s;
1224
1224
  let u = {
1225
1225
  type: "text",
@@ -1230,10 +1230,10 @@ function pn(e, t, n, r, i, a) {
1230
1230
  return s.splice(c, 1, {
1231
1231
  ...l,
1232
1232
  parts: [...l.parts, u]
1233
- }), N(s, t);
1233
+ }), M(s, t);
1234
1234
  }
1235
- function mn(e, t, n, r) {
1236
- return N(e.map((e) => {
1235
+ function hn(e, t, n, r) {
1236
+ return M(e.map((e) => {
1237
1237
  if (e.role !== "assistant" || e.metadata?.turnId !== n) return e;
1238
1238
  let t = e.parts.filter((e) => e.type !== "text" || e.itemId !== r);
1239
1239
  return t.length === e.parts.length ? e : {
@@ -1242,16 +1242,16 @@ function mn(e, t, n, r) {
1242
1242
  };
1243
1243
  }), t);
1244
1244
  }
1245
- function hn(e) {
1245
+ function gn(e) {
1246
1246
  let t = /<proposed_plan>([\s\S]*?)<\/proposed_plan>/iu.exec(e), n = t?.[1]?.trim() ?? "";
1247
1247
  return !t || !n ? null : {
1248
1248
  markdown: n,
1249
1249
  visibleText: `${e.slice(0, t.index)}${e.slice(t.index + t[0].length)}`.trim()
1250
1250
  };
1251
1251
  }
1252
- function M(e, t, n, r) {
1252
+ function j(e, t, n, r) {
1253
1253
  let i = [...e], a = i.findIndex((e) => e.role === "assistant" && e.metadata?.turnId === n && e.parts.some((e) => e.type === "tool" && e.id === r.id));
1254
- a < 0 && (i = j(i, t, n), a = P(i, (e) => e.role === "assistant" && e.kind === void 0 && e.metadata?.turnId === n));
1254
+ a < 0 && (i = A(i, t, n), a = N(i, (e) => e.role === "assistant" && e.kind === void 0 && e.metadata?.turnId === n));
1255
1255
  let o = a >= 0 ? i[a] : void 0;
1256
1256
  if (!o) return i;
1257
1257
  let s = [...o.parts], c = s.findIndex((e) => e.type === "tool" && e.id === r.id);
@@ -1263,7 +1263,7 @@ function M(e, t, n, r) {
1263
1263
  body: r.body ?? e.body,
1264
1264
  input: r.input ?? e.input,
1265
1265
  output: r.output ?? e.output,
1266
- statusText: r.statusText ?? Sn(e.statusText, r.status),
1266
+ statusText: r.statusText ?? Cn(e.statusText, r.status),
1267
1267
  metadata: {
1268
1268
  ...e.metadata ?? {},
1269
1269
  ...r.metadata ?? {}
@@ -1273,11 +1273,11 @@ function M(e, t, n, r) {
1273
1273
  return i.splice(a, 1, {
1274
1274
  ...o,
1275
1275
  parts: s
1276
- }), N(i, t);
1276
+ }), M(i, t);
1277
1277
  }
1278
- function gn(e, t, n, r, i = r.itemId) {
1278
+ function _n(e, t, n, r, i = r.itemId) {
1279
1279
  let a = [...e], o = a.findIndex((e) => e.role === "assistant" && e.metadata?.turnId === n && e.parts.some((e) => e.type === "media" && e.itemId === r.itemId));
1280
- o < 0 && r.itemId && (o = a.findIndex((e) => e.role === "assistant" && e.metadata?.turnId === n && e.parts.some((e) => e.type === "tool" && e.id === i))), o < 0 && (a = j(a, t, n), o = P(a, (e) => e.role === "assistant" && e.kind === void 0 && e.metadata?.turnId === n));
1280
+ o < 0 && r.itemId && (o = a.findIndex((e) => e.role === "assistant" && e.metadata?.turnId === n && e.parts.some((e) => e.type === "tool" && e.id === i))), o < 0 && (a = A(a, t, n), o = N(a, (e) => e.role === "assistant" && e.kind === void 0 && e.metadata?.turnId === n));
1281
1281
  let s = o >= 0 ? a[o] : void 0;
1282
1282
  if (!s) return a;
1283
1283
  let c = [...s.parts], l = c.findIndex((e) => e.type === "media" && e.itemId === r.itemId);
@@ -1285,25 +1285,25 @@ function gn(e, t, n, r, i = r.itemId) {
1285
1285
  ...s,
1286
1286
  status: "streaming",
1287
1287
  parts: c
1288
- }), N(a, t);
1288
+ }), M(a, t);
1289
1289
  }
1290
- function _n(e, t, n, r) {
1290
+ function vn(e, t, n, r) {
1291
1291
  let i = [...e], a = i.findIndex((e) => e.role === "assistant" && e.metadata?.turnId === n && e.parts.some((e) => e.type === "question" && e.request.id === r.request.id));
1292
- a < 0 && (i = j(i, t, n), a = P(i, (e) => e.role === "assistant" && e.kind === void 0 && e.metadata?.turnId === n));
1292
+ a < 0 && (i = A(i, t, n), a = N(i, (e) => e.role === "assistant" && e.kind === void 0 && e.metadata?.turnId === n));
1293
1293
  let o = a >= 0 ? i[a] : void 0;
1294
1294
  if (!o) return i;
1295
1295
  let s = [...o.parts], c = s.findIndex((e) => e.type === "question" && e.request.id === r.request.id);
1296
1296
  return c >= 0 ? s.splice(c, 1, r) : s.push(r), i.splice(a, 1, {
1297
1297
  ...o,
1298
1298
  parts: s
1299
- }), N(i, t);
1299
+ }), M(i, t);
1300
1300
  }
1301
- function vn(e, t) {
1301
+ function yn(e, t) {
1302
1302
  return e.itemId === t.itemId && e.media.url === t.media.url && e.media.alt === t.media.alt && e.media.mimeType === t.media.mimeType && e.media.prompt === t.media.prompt && e.media.title === t.media.title;
1303
1303
  }
1304
- function yn(e, t, n, r) {
1304
+ function bn(e, t, n, r) {
1305
1305
  let i = [...e], a = i.findIndex((e) => e.role === "assistant" && e.metadata?.turnId === n && e.parts.some((e) => e.type === "tool" && e.id === r.itemId));
1306
- if (a < 0) return r.fallbackToolPart ? yn(M(i, t, n, r.fallbackToolPart), t, n, {
1306
+ if (a < 0) return r.fallbackToolPart ? bn(j(i, t, n, r.fallbackToolPart), t, n, {
1307
1307
  ...r,
1308
1308
  fallbackToolPart: void 0
1309
1309
  }) : i;
@@ -1329,12 +1329,12 @@ function yn(e, t, n, r) {
1329
1329
  parts: s
1330
1330
  }), i) : i;
1331
1331
  }
1332
- function bn(e, t, n, r = "streaming") {
1332
+ function xn(e, t, n, r = "streaming") {
1333
1333
  if (e.some((e) => e.kind === "compaction" && e.metadata?.turnId === n)) return e.map((e) => r === "complete" && e.kind === "compaction" && e.metadata?.turnId === n ? {
1334
1334
  ...e,
1335
1335
  status: r
1336
1336
  } : e);
1337
- let i = [...e], a = P(i, (e) => e.role === "assistant" && e.kind === void 0 && e.metadata?.turnId === n), o = a >= 0 ? i[a] : void 0;
1337
+ let i = [...e], a = N(i, (e) => e.role === "assistant" && e.kind === void 0 && e.metadata?.turnId === n), o = a >= 0 ? i[a] : void 0;
1338
1338
  return o?.parts.length === 0 ? i.splice(a, 1) : o && i.splice(a, 1, {
1339
1339
  ...o,
1340
1340
  status: "complete"
@@ -1350,16 +1350,16 @@ function bn(e, t, n, r = "streaming") {
1350
1350
  conversationId: t,
1351
1351
  turnId: n
1352
1352
  }
1353
- }), N(i, t);
1353
+ }), M(i, t);
1354
1354
  }
1355
- function xn(e, t, n) {
1355
+ function Sn(e, t, n) {
1356
1356
  let r = n === "completed" ? "completed" : "failed";
1357
1357
  return e.map((e) => {
1358
1358
  if (e.metadata?.turnId !== t) return e;
1359
1359
  let n = !1, i = e.parts.map((e) => e.type !== "tool" || e.status !== "running" ? e : (n = !0, {
1360
1360
  ...e,
1361
1361
  status: r,
1362
- statusText: Sn(e.statusText, r)
1362
+ statusText: Cn(e.statusText, r)
1363
1363
  }));
1364
1364
  return n ? {
1365
1365
  ...e,
@@ -1367,11 +1367,11 @@ function xn(e, t, n) {
1367
1367
  } : e;
1368
1368
  });
1369
1369
  }
1370
- function Sn(e, t) {
1370
+ function Cn(e, t) {
1371
1371
  if (t === "running" || !e) return e;
1372
1372
  try {
1373
1373
  let n = JSON.parse(e);
1374
- return ln(n) ? JSON.stringify({
1374
+ return un(n) ? JSON.stringify({
1375
1375
  ...n,
1376
1376
  phase: t
1377
1377
  }) : e;
@@ -1379,27 +1379,27 @@ function Sn(e, t) {
1379
1379
  return e;
1380
1380
  }
1381
1381
  }
1382
- function N(e, t) {
1382
+ function M(e, t) {
1383
1383
  let n = e.map((e, t) => ({
1384
1384
  message: e,
1385
1385
  index: t
1386
1386
  })).filter(({ message: e }) => e.metadata?.conversationId === t).at(-1)?.index ?? -1;
1387
1387
  return e.filter((e, r) => e.metadata?.conversationId !== t || r === n || e.role !== "assistant" || e.kind !== void 0 || e.parts.length > 0);
1388
1388
  }
1389
- function P(e, t) {
1389
+ function N(e, t) {
1390
1390
  for (let n = e.length - 1; n >= 0; --n) {
1391
1391
  let r = e[n];
1392
1392
  if (r !== void 0 && t(r)) return n;
1393
1393
  }
1394
1394
  return -1;
1395
1395
  }
1396
- function Cn(e, t) {
1396
+ function wn(e, t) {
1397
1397
  return e.includes(t) ? [...e] : [...e, t];
1398
1398
  }
1399
- function wn(e, t) {
1399
+ function Tn(e, t) {
1400
1400
  return [e?.trim() ?? "", ...t.map((e) => `${e.status === "completed" ? "- [x]" : "- [ ]"} ${e.step}`)].filter(Boolean).join("\n");
1401
1401
  }
1402
- function Tn(e, t, n) {
1402
+ function En(e, t, n) {
1403
1403
  return {
1404
1404
  type: "tool",
1405
1405
  id: `plan-progress-${e}`,
@@ -1422,19 +1422,19 @@ function Tn(e, t, n) {
1422
1422
  }
1423
1423
  //#endregion
1424
1424
  //#region src/node/codex-conversation-history.ts
1425
- var En = 16 * 1024 * 1024, Dn = /* @__PURE__ */ new Set([
1425
+ var Dn = 16 * 1024 * 1024, On = /* @__PURE__ */ new Set([
1426
1426
  "image/avif",
1427
1427
  "image/gif",
1428
1428
  "image/jpeg",
1429
1429
  "image/png",
1430
1430
  "image/webp"
1431
1431
  ]);
1432
- function On(e) {
1433
- return (Array.isArray(e.turns) ? e.turns : []).flatMap((t) => F(e.id, t));
1432
+ function kn(e) {
1433
+ return (Array.isArray(e.turns) ? e.turns : []).flatMap((t) => Mn(e.id, t));
1434
1434
  }
1435
- function kn(e, t) {
1435
+ function An(e, t) {
1436
1436
  let n = /* @__PURE__ */ new Map();
1437
- for (let t of e) for (let e of t.parts) e.type !== "attachment" || e.attachment.kind !== "image" || !e.attachment.path || Wn(e.attachment.url) && n.set(e.attachment.path, e.attachment.url);
1437
+ for (let t of e) for (let e of t.parts) e.type !== "attachment" || e.attachment.kind !== "image" || !e.attachment.path || Kn(e.attachment.url) && n.set(e.attachment.path, e.attachment.url);
1438
1438
  return n.size === 0 ? [...t] : t.map((e) => {
1439
1439
  let t = !1, r = e.parts.map((e) => {
1440
1440
  if (e.type !== "attachment" || e.attachment.kind !== "image" || !e.attachment.path) return e;
@@ -1453,9 +1453,9 @@ function kn(e, t) {
1453
1453
  } : e;
1454
1454
  });
1455
1455
  }
1456
- function An(e, t) {
1456
+ function jn(e, t) {
1457
1457
  let n = new Map(e.filter((e) => e.role === "user" && e.metadata?.promptContent).map((e) => [e.id, e.metadata.promptContent]));
1458
- return kn(e, t).map((e) => {
1458
+ return An(e, t).map((e) => {
1459
1459
  let t = n.get(e.id);
1460
1460
  if (!t || e.role !== "user") return e;
1461
1461
  let r = ce(t);
@@ -1472,14 +1472,14 @@ function An(e, t) {
1472
1472
  };
1473
1473
  });
1474
1474
  }
1475
- function F(e, t) {
1476
- let n = [], r = [], i = Jn(t.startedAt ?? t.completedAt), a = 0, o = !1, s = !1, c = /* @__PURE__ */ new Set(), l = () => {
1475
+ function Mn(e, t) {
1476
+ let n = [], r = [], i = Xn(t.startedAt ?? t.completedAt), a = 0, o = !1, s = !1, c = /* @__PURE__ */ new Set(), l = () => {
1477
1477
  if (r.length === 0) return;
1478
1478
  let o = a === 0 ? "" : `-segment-${a}`;
1479
1479
  n.push({
1480
1480
  id: `assistant-${t.id}${o}`,
1481
1481
  role: "assistant",
1482
- status: qn(t.status),
1482
+ status: Yn(t.status),
1483
1483
  turnId: t.id,
1484
1484
  parts: [...r],
1485
1485
  createdAt: i,
@@ -1491,7 +1491,7 @@ function F(e, t) {
1491
1491
  };
1492
1492
  for (let a of Array.isArray(t.items) ? t.items : []) {
1493
1493
  if (a.type === "userMessage") {
1494
- let r = Fn(a), s = Ln(a);
1494
+ let r = Ln(a), s = zn(a);
1495
1495
  if (r.length > 0) {
1496
1496
  let u = o, d = u ? null : JSON.stringify(r);
1497
1497
  if (d && c.has(d)) continue;
@@ -1508,7 +1508,7 @@ function F(e, t) {
1508
1508
  turnId: t.id,
1509
1509
  ...s.length > 0 ? {
1510
1510
  asyncQuestionRequestIds: s,
1511
- asyncQuestionAnswers: Rn(a)
1511
+ asyncQuestionAnswers: Bn(a)
1512
1512
  } : {}
1513
1513
  }
1514
1514
  });
@@ -1536,7 +1536,7 @@ function F(e, t) {
1536
1536
  if (a.type === "agentMessage") {
1537
1537
  let n = typeof a.text == "string" ? a.text : "";
1538
1538
  a.phase === "final_answer" && n.trim() && (s = !0);
1539
- let i = Mn(e, t.id, a, !0), c = a.phase === "final_answer" ? hn(n) : null;
1539
+ let i = Pn(e, t.id, a, !0), c = a.phase === "final_answer" ? gn(n) : null;
1540
1540
  c && !i ? c.visibleText && (o = !0, r.push({
1541
1541
  type: "text",
1542
1542
  text: c.visibleText,
@@ -1577,13 +1577,13 @@ function F(e, t) {
1577
1577
  }
1578
1578
  let u = w(a);
1579
1579
  u && (o = !0, r.push(u));
1580
- let d = Pn(a);
1580
+ let d = In(a);
1581
1581
  d.length && (o = !0, r.push(...d));
1582
1582
  }
1583
1583
  return l(), (t.itemsView === "summary" || t.itemsView === "notLoaded") && !n.some((e) => e.role === "assistant") && n.push({
1584
1584
  id: `assistant-${t.id}`,
1585
1585
  role: "assistant",
1586
- status: qn(t.status),
1586
+ status: Yn(t.status),
1587
1587
  turnId: t.id,
1588
1588
  parts: [],
1589
1589
  createdAt: i,
@@ -1591,12 +1591,12 @@ function F(e, t) {
1591
1591
  conversationId: e,
1592
1592
  turnId: t.id
1593
1593
  }
1594
- }), t.status === "inProgress" ? n : xn(n, t.id, t.status);
1594
+ }), t.status === "inProgress" ? n : Sn(n, t.id, t.status);
1595
1595
  }
1596
- function jn(e, t, n) {
1597
- let r = Jn(t.startedAt);
1596
+ function Nn(e, t, n) {
1597
+ let r = Xn(t.startedAt);
1598
1598
  if (n.type === "userMessage") {
1599
- let i = Fn(n), a = Ln(n);
1599
+ let i = Ln(n), a = zn(n);
1600
1600
  return i.length > 0 ? {
1601
1601
  id: n.clientId ?? `user-${e}-${t.id}-${n.id}`,
1602
1602
  role: "user",
@@ -1610,13 +1610,13 @@ function jn(e, t, n) {
1610
1610
  itemId: n.id,
1611
1611
  ...a.length > 0 ? {
1612
1612
  asyncQuestionRequestIds: a,
1613
- asyncQuestionAnswers: Rn(n)
1613
+ asyncQuestionAnswers: Bn(n)
1614
1614
  } : {}
1615
1615
  }
1616
1616
  } : null;
1617
1617
  }
1618
1618
  if (n.type === "agentMessage" || n.type === "exitedReviewMode") {
1619
- let i = n.type === "agentMessage" ? n.text : n.review, a = n.type === "agentMessage" && n.phase === "final_answer" ? hn(i) : null, o = n.type === "agentMessage" ? Mn(e, t.id, n, !0) : null, s = [...!o && (a?.visibleText || !a && i) ? [{
1619
+ let i = n.type === "agentMessage" ? n.text : n.review, a = n.type === "agentMessage" && n.phase === "final_answer" ? gn(i) : null, o = n.type === "agentMessage" ? Pn(e, t.id, n, !0) : null, s = [...!o && (a?.visibleText || !a && i) ? [{
1620
1620
  type: "text",
1621
1621
  text: a?.visibleText ?? i,
1622
1622
  itemId: n.id,
@@ -1625,7 +1625,7 @@ function jn(e, t, n) {
1625
1625
  return s.length > 0 ? {
1626
1626
  id: `assistant-${n.id}`,
1627
1627
  role: "assistant",
1628
- status: qn(t.status),
1628
+ status: Yn(t.status),
1629
1629
  turnId: t.id,
1630
1630
  parts: s,
1631
1631
  createdAt: r,
@@ -1649,7 +1649,7 @@ function jn(e, t, n) {
1649
1649
  return i.length > 0 ? {
1650
1650
  id: `assistant-${n.id}`,
1651
1651
  role: "assistant",
1652
- status: qn(t.status),
1652
+ status: Yn(t.status),
1653
1653
  turnId: t.id,
1654
1654
  parts: i,
1655
1655
  createdAt: r,
@@ -1661,11 +1661,11 @@ function jn(e, t, n) {
1661
1661
  } : null;
1662
1662
  }
1663
1663
  let i = [], a = w(n);
1664
- a && i.push(a), i.push(...Pn(n));
1664
+ a && i.push(a), i.push(...In(n));
1665
1665
  let o = i.length > 0 ? {
1666
1666
  id: `assistant-${n.id}`,
1667
1667
  role: "assistant",
1668
- status: qn(t.status),
1668
+ status: Yn(t.status),
1669
1669
  turnId: t.id,
1670
1670
  parts: i,
1671
1671
  createdAt: r,
@@ -1675,9 +1675,9 @@ function jn(e, t, n) {
1675
1675
  itemId: n.id
1676
1676
  }
1677
1677
  } : null;
1678
- return !o || t.status === "inProgress" ? o : xn([o], t.id, t.status)[0] ?? null;
1678
+ return !o || t.status === "inProgress" ? o : Sn([o], t.id, t.status)[0] ?? null;
1679
1679
  }
1680
- function Mn(e, t, n, r = !1) {
1680
+ function Pn(e, t, n, r = !1) {
1681
1681
  if (n.delivery !== "async") return null;
1682
1682
  let i = n.questions ?? [], a = i.length > 0 ? i.map((e, t) => ({
1683
1683
  id: JSON.stringify([
@@ -1719,9 +1719,9 @@ function Mn(e, t, n, r = !1) {
1719
1719
  ...r ? { historical: !0 } : {}
1720
1720
  };
1721
1721
  }
1722
- function Nn(e) {
1722
+ function Fn(e) {
1723
1723
  if (e.type !== "imageGeneration" || w(e)?.status !== "completed") return null;
1724
- let t = typeof e.savedPath == "string" && v(e.savedPath) ? e.savedPath : null, n = t ? Hn(t) : void 0, r = n && Dn.has(n) ? t : null, i = Un("result" in e && typeof e.result == "string" ? e.result.trim() : ""), a = i?.url ?? (r ? fe(r).href : void 0);
1724
+ let t = typeof e.savedPath == "string" && v(e.savedPath) ? e.savedPath : null, n = t ? Wn(t) : void 0, r = n && On.has(n) ? t : null, i = Gn("result" in e && typeof e.result == "string" ? e.result.trim() : ""), a = i?.url ?? (r ? fe(r).href : void 0);
1725
1725
  if (!a) return null;
1726
1726
  let o = typeof e.revisedPrompt == "string" ? e.revisedPrompt.trim() : "";
1727
1727
  return {
@@ -1736,11 +1736,11 @@ function Nn(e) {
1736
1736
  }
1737
1737
  };
1738
1738
  }
1739
- function Pn(e) {
1739
+ function In(e) {
1740
1740
  if (e.type === "imageView") {
1741
1741
  if (typeof e.path != "string") return [];
1742
- let t = Hn(e.path);
1743
- return v(e.path) && t && Dn.has(t) ? [{
1742
+ let t = Wn(e.path);
1743
+ return v(e.path) && t && On.has(t) ? [{
1744
1744
  type: "media",
1745
1745
  phase: "commentary",
1746
1746
  itemId: e.id,
@@ -1752,7 +1752,7 @@ function Pn(e) {
1752
1752
  }
1753
1753
  }] : [];
1754
1754
  }
1755
- let t = Nn(e);
1755
+ let t = Fn(e);
1756
1756
  if (t) return [t];
1757
1757
  let n = e.type === "mcpToolCall" && e.status === "completed" ? e.result?.content : e.type === "dynamicToolCall" && e.status === "completed" ? e.contentItems : void 0;
1758
1758
  if (!Array.isArray(n)) return [];
@@ -1768,13 +1768,13 @@ function Pn(e) {
1768
1768
  a -= e;
1769
1769
  try {
1770
1770
  let e = JSON.parse(t.text);
1771
- I(e) && Array.isArray(e.content) && s(e.content, n + 1);
1771
+ P(e) && Array.isArray(e.content) && s(e.content, n + 1);
1772
1772
  } catch {}
1773
1773
  continue;
1774
1774
  }
1775
1775
  let l = t.type === "image" && typeof t.data == "string" ? t.data : t.type === "inputImage" && typeof t.imageUrl == "string" ? t.imageUrl : "";
1776
1776
  if (l.length > i) continue;
1777
- let u = Un(l);
1777
+ let u = Gn(l);
1778
1778
  u && (i -= u.url.length, r.push({
1779
1779
  type: "media",
1780
1780
  phase: "commentary",
@@ -1790,21 +1790,21 @@ function Pn(e) {
1790
1790
  };
1791
1791
  return s(n, 0), r;
1792
1792
  }
1793
- function Fn(e) {
1794
- let t = Array.isArray(e.content) ? e.content : [], n = t.some((e) => I(e) && e.type === "text" && typeof e.text == "string" && e.text.length > 0), r = [], i = [], a = /* @__PURE__ */ new Set(), o = () => {
1793
+ function Ln(e) {
1794
+ let t = Array.isArray(e.content) ? e.content : [], n = t.some((e) => P(e) && e.type === "text" && typeof e.text == "string" && e.text.length > 0), r = [], i = [], a = /* @__PURE__ */ new Set(), o = () => {
1795
1795
  i.length > 0 && r.push({
1796
1796
  type: "text",
1797
1797
  text: i.join("\n")
1798
1798
  }), i = [];
1799
1799
  };
1800
1800
  for (let e of t) {
1801
- if (I(e) && e.type === "skill" && typeof e.name == "string") {
1801
+ if (P(e) && e.type === "skill" && typeof e.name == "string") {
1802
1802
  if (n) continue;
1803
1803
  let t = e.name.toLowerCase();
1804
1804
  if (a.has(t)) continue;
1805
1805
  a.add(t);
1806
1806
  }
1807
- let t = In(e), s = ct(t);
1807
+ let t = Rn(e), s = ct(t);
1808
1808
  if (s) {
1809
1809
  o(), r.push({
1810
1810
  type: "attachment",
@@ -1819,7 +1819,7 @@ function Fn(e) {
1819
1819
  i.push(t);
1820
1820
  continue;
1821
1821
  }
1822
- let c = Bn(e);
1822
+ let c = Hn(e);
1823
1823
  c && (o(), r.push({
1824
1824
  type: "attachment",
1825
1825
  attachment: c
@@ -1827,26 +1827,26 @@ function Fn(e) {
1827
1827
  }
1828
1828
  return o(), r;
1829
1829
  }
1830
- function In(e) {
1831
- return !I(e) || typeof e.type != "string" ? "" : e.type === "text" && typeof e.text == "string" ? zn(e.text)?.displayText ?? e.text : e.type === "skill" && typeof e.name == "string" ? `$${e.name}` : "";
1830
+ function Rn(e) {
1831
+ return !P(e) || typeof e.type != "string" ? "" : e.type === "text" && typeof e.text == "string" ? Vn(e.text)?.displayText ?? e.text : e.type === "skill" && typeof e.name == "string" ? `$${e.name}` : "";
1832
1832
  }
1833
- function Ln(e) {
1833
+ function zn(e) {
1834
1834
  let t = /* @__PURE__ */ new Set();
1835
- for (let n of Array.isArray(e.content) ? e.content : []) if (!(!I(n) || n.type !== "text" || typeof n.text != "string")) for (let e of zn(n.text)?.requestIds ?? []) t.add(e);
1835
+ for (let n of Array.isArray(e.content) ? e.content : []) if (!(!P(n) || n.type !== "text" || typeof n.text != "string")) for (let e of Vn(n.text)?.requestIds ?? []) t.add(e);
1836
1836
  return [...t];
1837
1837
  }
1838
- function Rn(e) {
1838
+ function Bn(e) {
1839
1839
  let t = {};
1840
- for (let n of Array.isArray(e.content) ? e.content : []) !I(n) || n.type !== "text" || typeof n.text != "string" || Object.assign(t, zn(n.text)?.answers);
1840
+ for (let n of Array.isArray(e.content) ? e.content : []) !P(n) || n.type !== "text" || typeof n.text != "string" || Object.assign(t, Vn(n.text)?.answers);
1841
1841
  return t;
1842
1842
  }
1843
- function zn(e) {
1843
+ function Vn(e) {
1844
1844
  let t = e.match(/^<send_user_message_question_reply>\s*([\s\S]*?)\s*<\/send_user_message_question_reply>$/);
1845
1845
  if (!t?.[1]) return null;
1846
1846
  try {
1847
1847
  let e = JSON.parse(t[1]);
1848
1848
  if (!Array.isArray(e)) return null;
1849
- let n = e.filter((e) => I(e) && typeof e.questionItemId == "string" && typeof e.question == "string" && typeof e.answer == "string");
1849
+ let n = e.filter((e) => P(e) && typeof e.questionItemId == "string" && typeof e.question == "string" && typeof e.answer == "string");
1850
1850
  if (n.length === 0) return null;
1851
1851
  let r = n.flatMap((e) => {
1852
1852
  try {
@@ -1864,10 +1864,10 @@ function zn(e) {
1864
1864
  return null;
1865
1865
  }
1866
1866
  }
1867
- function Bn(e) {
1868
- if (!I(e) || typeof e.type != "string") return null;
1867
+ function Hn(e) {
1868
+ if (!P(e) || typeof e.type != "string") return null;
1869
1869
  if (e.type === "mention" && typeof e.path == "string" && !e.path.startsWith("plugin://")) {
1870
- let t = typeof e.name == "string" && e.name.trim() ? e.name.trim() : Vn(e.path, "File"), n = Hn(e.path);
1870
+ let t = typeof e.name == "string" && e.name.trim() ? e.name.trim() : Un(e.path, "File"), n = Wn(e.path);
1871
1871
  return {
1872
1872
  kind: "file",
1873
1873
  name: t,
@@ -1876,26 +1876,26 @@ function Bn(e) {
1876
1876
  };
1877
1877
  }
1878
1878
  if (e.type === "image" && typeof e.url == "string") {
1879
- let t = Hn(e.url);
1879
+ let t = Wn(e.url);
1880
1880
  return {
1881
1881
  kind: "image",
1882
- name: Vn(e.url, "Image"),
1882
+ name: Un(e.url, "Image"),
1883
1883
  url: e.url,
1884
1884
  ...t ? { mimeType: t } : {}
1885
1885
  };
1886
1886
  }
1887
1887
  if (e.type === "localImage" && typeof e.path == "string") {
1888
- let t = Hn(e.path);
1888
+ let t = Wn(e.path);
1889
1889
  return {
1890
1890
  kind: "image",
1891
- name: Vn(e.path, "Image"),
1891
+ name: Un(e.path, "Image"),
1892
1892
  path: e.path,
1893
1893
  ...t ? { mimeType: t } : {}
1894
1894
  };
1895
1895
  }
1896
1896
  return null;
1897
1897
  }
1898
- function Vn(e, t) {
1898
+ function Un(e, t) {
1899
1899
  try {
1900
1900
  let n = /^[a-z][a-z\d+.-]*:/i.test(e) ? new URL(e).pathname : e;
1901
1901
  return g(decodeURIComponent(n)).trim() || t;
@@ -1903,7 +1903,7 @@ function Vn(e, t) {
1903
1903
  return g(e).trim() || t;
1904
1904
  }
1905
1905
  }
1906
- function Hn(e) {
1906
+ function Wn(e) {
1907
1907
  let t = /^data:([^;,]+)/i.exec(e)?.[1]?.toLowerCase();
1908
1908
  if (t) return t;
1909
1909
  let n = "";
@@ -1925,23 +1925,23 @@ function Hn(e) {
1925
1925
  webp: "image/webp"
1926
1926
  }[n];
1927
1927
  }
1928
- function Un(e) {
1928
+ function Gn(e) {
1929
1929
  if (!e) return null;
1930
- let t = (/^data:image\/[a-z0-9.+-]+;base64,([a-z0-9+/=\s]+)$/i.exec(e)?.[1] ?? e).replace(/\s+/g, ""), n = Math.ceil(En / 3) * 4 + 4;
1930
+ let t = (/^data:image\/[a-z0-9.+-]+;base64,([a-z0-9+/=\s]+)$/i.exec(e)?.[1] ?? e).replace(/\s+/g, ""), n = Math.ceil(Dn / 3) * 4 + 4;
1931
1931
  if (!t || t.length > n || t.length % 4 != 0 || !/^[a-z0-9+/]+={0,2}$/i.test(t)) return null;
1932
1932
  let r = Buffer.from(t, "base64");
1933
- if (r.byteLength === 0 || r.byteLength > En) return null;
1934
- let i = Gn(r);
1933
+ if (r.byteLength === 0 || r.byteLength > Dn) return null;
1934
+ let i = qn(r);
1935
1935
  return i ? {
1936
1936
  url: `data:${i};base64,${t}`,
1937
1937
  mimeType: i
1938
1938
  } : null;
1939
1939
  }
1940
- function Wn(e) {
1940
+ function Kn(e) {
1941
1941
  return !!(e && e.length <= 16 * 1024 * 1024 && /^data:image\/(?:avif|bmp|gif|heic|heif|jpe?g|png|webp);base64,[a-z\d+/]+={0,2}$/i.test(e));
1942
1942
  }
1943
- function Gn(e) {
1944
- if (Kn(e, [
1943
+ function qn(e) {
1944
+ if (Jn(e, [
1945
1945
  137,
1946
1946
  80,
1947
1947
  78,
@@ -1951,7 +1951,7 @@ function Gn(e) {
1951
1951
  26,
1952
1952
  10
1953
1953
  ])) return "image/png";
1954
- if (Kn(e, [
1954
+ if (Jn(e, [
1955
1955
  255,
1956
1956
  216,
1957
1957
  255
@@ -1959,50 +1959,50 @@ function Gn(e) {
1959
1959
  let t = Buffer.from(e.subarray(0, 12)).toString("ascii");
1960
1960
  return t.startsWith("GIF87a") || t.startsWith("GIF89a") ? "image/gif" : t.startsWith("RIFF") && t.slice(8, 12) === "WEBP" ? "image/webp" : e.byteLength >= 12 && t.slice(4, 12) === "ftypavif" ? "image/avif" : null;
1961
1961
  }
1962
- function Kn(e, t) {
1962
+ function Jn(e, t) {
1963
1963
  return t.every((t, n) => e[n] === t);
1964
1964
  }
1965
- function qn(e) {
1965
+ function Yn(e) {
1966
1966
  return e === "inProgress" ? "streaming" : e === "failed" ? "error" : "complete";
1967
1967
  }
1968
- function Jn(e) {
1968
+ function Xn(e) {
1969
1969
  return typeof e != "number" || !Number.isFinite(e) ? (/* @__PURE__ */ new Date(0)).toISOString() : (/* @__PURE__ */ new Date(e * 1e3)).toISOString();
1970
1970
  }
1971
- function I(e) {
1971
+ function P(e) {
1972
1972
  return !!(e && typeof e == "object" && !Array.isArray(e));
1973
1973
  }
1974
1974
  //#endregion
1975
1975
  //#region ../../node_modules/image-size/dist/esm/types/utils.js
1976
- var Yn = new TextDecoder(), L = (e, t = 0, n = e.length) => Yn.decode(e.slice(t, n)), R = (e, t = 0, n = e.length) => e.slice(t, n).reduce((e, t) => e + `0${t.toString(16)}`.slice(-2), ""), z = (e, t) => new DataView(e.buffer, e.byteOffset + t), Xn = (e, t = 0) => z(e, t).getInt16(0, !0), Zn = (e, t = 0) => z(e, t).getUint16(0, !1), B = (e, t = 0) => z(e, t).getUint16(0, !0), Qn = (e, t = 0) => {
1977
- let n = z(e, t);
1976
+ var Zn = new TextDecoder(), F = (e, t = 0, n = e.length) => Zn.decode(e.slice(t, n)), Qn = (e, t = 0, n = e.length) => e.slice(t, n).reduce((e, t) => e + `0${t.toString(16)}`.slice(-2), ""), I = (e, t) => new DataView(e.buffer, e.byteOffset + t), $n = (e, t = 0) => I(e, t).getInt16(0, !0), er = (e, t = 0) => I(e, t).getUint16(0, !1), L = (e, t = 0) => I(e, t).getUint16(0, !0), tr = (e, t = 0) => {
1977
+ let n = I(e, t);
1978
1978
  return n.getUint16(0, !0) + (n.getUint8(2) << 16);
1979
- }, $n = (e, t = 0) => z(e, t).getInt32(0, !0), V = (e, t = 0) => z(e, t).getUint32(0, !1), H = (e, t = 0) => z(e, t).getUint32(0, !0), er = (e, t, n) => z(e, t).getBigUint64(0, !n), tr = {
1980
- readUInt16BE: Zn,
1981
- readUInt16LE: B,
1982
- readUInt32BE: V,
1983
- readUInt32LE: H
1979
+ }, nr = (e, t = 0) => I(e, t).getInt32(0, !0), R = (e, t = 0) => I(e, t).getUint32(0, !1), z = (e, t = 0) => I(e, t).getUint32(0, !0), rr = (e, t, n) => I(e, t).getBigUint64(0, !n), ir = {
1980
+ readUInt16BE: er,
1981
+ readUInt16LE: L,
1982
+ readUInt32BE: R,
1983
+ readUInt32LE: z
1984
1984
  };
1985
- function U(e, t, n = 0, r = !1) {
1986
- return tr[`readUInt${t}${r ? "BE" : "LE"}`](e, n);
1985
+ function B(e, t, n = 0, r = !1) {
1986
+ return ir[`readUInt${t}${r ? "BE" : "LE"}`](e, n);
1987
1987
  }
1988
- var nr = 8;
1989
- function rr(e, t) {
1990
- if (e.length - t < nr) return;
1991
- let n = V(e, t);
1988
+ var ar = 8;
1989
+ function or(e, t) {
1990
+ if (e.length - t < ar) return;
1991
+ let n = R(e, t);
1992
1992
  if (!(e.length - t < n)) return {
1993
- name: L(e, 4 + t, 8 + t),
1993
+ name: F(e, 4 + t, 8 + t),
1994
1994
  offset: t,
1995
1995
  size: n
1996
1996
  };
1997
1997
  }
1998
- function W(e, t, n) {
1998
+ function V(e, t, n) {
1999
1999
  let r = n;
2000
2000
  for (; r < e.length && !(e.length - r < 4);) {
2001
- if (V(e, r) < nr) {
2002
- r += nr;
2001
+ if (R(e, r) < ar) {
2002
+ r += ar;
2003
2003
  continue;
2004
2004
  }
2005
- let n = rr(e, r);
2005
+ let n = or(e, r);
2006
2006
  if (!n) break;
2007
2007
  if (n.name === t) return n;
2008
2008
  r += n.size;
@@ -2010,61 +2010,61 @@ function W(e, t, n) {
2010
2010
  }
2011
2011
  //#endregion
2012
2012
  //#region ../../node_modules/image-size/dist/esm/types/bmp.js
2013
- var ir = {
2014
- validate: (e) => L(e, 0, 2) === "BM",
2013
+ var sr = {
2014
+ validate: (e) => F(e, 0, 2) === "BM",
2015
2015
  calculate: (e) => ({
2016
- height: Math.abs($n(e, 22)),
2017
- width: H(e, 18)
2016
+ height: Math.abs(nr(e, 22)),
2017
+ width: z(e, 18)
2018
2018
  })
2019
- }, ar = 1, or = 6, sr = 16;
2020
- function cr(e, t) {
2019
+ }, cr = 1, lr = 6, ur = 16;
2020
+ function dr(e, t) {
2021
2021
  let n = e[t];
2022
2022
  return n === 0 ? 256 : n;
2023
2023
  }
2024
- function lr(e, t) {
2025
- let n = or + t * sr;
2024
+ function fr(e, t) {
2025
+ let n = lr + t * ur;
2026
2026
  return {
2027
- height: cr(e, n + 1),
2028
- width: cr(e, n)
2027
+ height: dr(e, n + 1),
2028
+ width: dr(e, n)
2029
2029
  };
2030
2030
  }
2031
- var ur = {
2031
+ var pr = {
2032
2032
  validate(e) {
2033
- let t = B(e, 0), n = B(e, 4);
2034
- return t !== 0 || n === 0 ? !1 : B(e, 2) === ar;
2033
+ let t = L(e, 0), n = L(e, 4);
2034
+ return t !== 0 || n === 0 ? !1 : L(e, 2) === cr;
2035
2035
  },
2036
2036
  calculate(e) {
2037
- let t = B(e, 4);
2038
- if (or + t * sr > e.length) throw TypeError("Invalid ICO");
2039
- let n = lr(e, 0);
2037
+ let t = L(e, 4);
2038
+ if (lr + t * ur > e.length) throw TypeError("Invalid ICO");
2039
+ let n = fr(e, 0);
2040
2040
  if (t === 1) return n;
2041
2041
  let r = [];
2042
- for (let n = 0; n < t; n += 1) r.push(lr(e, n));
2042
+ for (let n = 0; n < t; n += 1) r.push(fr(e, n));
2043
2043
  return {
2044
2044
  width: n.width,
2045
2045
  height: n.height,
2046
2046
  images: r
2047
2047
  };
2048
2048
  }
2049
- }, dr = 2, fr = {
2049
+ }, mr = 2, hr = {
2050
2050
  validate(e) {
2051
- let t = B(e, 0), n = B(e, 4);
2052
- return t !== 0 || n === 0 ? !1 : B(e, 2) === dr;
2051
+ let t = L(e, 0), n = L(e, 4);
2052
+ return t !== 0 || n === 0 ? !1 : L(e, 2) === mr;
2053
2053
  },
2054
- calculate: (e) => ur.calculate(e)
2055
- }, pr = {
2056
- validate: (e) => H(e, 0) === 542327876,
2054
+ calculate: (e) => pr.calculate(e)
2055
+ }, gr = {
2056
+ validate: (e) => z(e, 0) === 542327876,
2057
2057
  calculate: (e) => ({
2058
- height: H(e, 12),
2059
- width: H(e, 16)
2058
+ height: z(e, 12),
2059
+ width: z(e, 16)
2060
2060
  })
2061
- }, mr = /^GIF8[79]a/, hr = {
2062
- validate: (e) => mr.test(L(e, 0, 6)),
2061
+ }, _r = /^GIF8[79]a/, vr = {
2062
+ validate: (e) => _r.test(F(e, 0, 6)),
2063
2063
  calculate: (e) => ({
2064
- height: B(e, 8),
2065
- width: B(e, 6)
2064
+ height: L(e, 8),
2065
+ width: L(e, 6)
2066
2066
  })
2067
- }, gr = {
2067
+ }, yr = {
2068
2068
  avif: "avif",
2069
2069
  mif1: "heif",
2070
2070
  msf1: "heif",
@@ -2072,22 +2072,22 @@ var ur = {
2072
2072
  heix: "heic",
2073
2073
  hevc: "heic",
2074
2074
  hevx: "heic"
2075
- }, _r = {
2075
+ }, br = {
2076
2076
  validate(e) {
2077
- if (L(e, 4, 8) !== "ftyp") return !1;
2078
- let t = W(e, "ftyp", 0);
2079
- return t ? L(e, t.offset + 8, t.offset + 12) in gr : !1;
2077
+ if (F(e, 4, 8) !== "ftyp") return !1;
2078
+ let t = V(e, "ftyp", 0);
2079
+ return t ? F(e, t.offset + 8, t.offset + 12) in yr : !1;
2080
2080
  },
2081
2081
  calculate(e) {
2082
- let t = W(e, "meta", 0), n = t && W(e, "iprp", t.offset + 12), r = n && W(e, "ipco", n.offset + 8);
2082
+ let t = V(e, "meta", 0), n = t && V(e, "iprp", t.offset + 12), r = n && V(e, "ipco", n.offset + 8);
2083
2083
  if (!r) throw TypeError("Invalid HEIF, no ipco box found");
2084
- let i = L(e, 8, 12), a = [], o = r.offset + 8;
2084
+ let i = F(e, 8, 12), a = [], o = r.offset + 8;
2085
2085
  for (; o < r.offset + r.size;) {
2086
- let t = W(e, "ispe", o);
2086
+ let t = V(e, "ispe", o);
2087
2087
  if (!t) break;
2088
2088
  if (t.size < 20) throw TypeError("Invalid HEIF");
2089
- let n = V(e, t.offset + 12), i = V(e, t.offset + 16), s = W(e, "clap", o), c = n, l = i;
2090
- s && s.size >= 16 && s.offset < r.offset + r.size && (c = n - V(e, s.offset + 12)), a.push({
2089
+ let n = R(e, t.offset + 12), i = R(e, t.offset + 16), s = V(e, "clap", o), c = n, l = i;
2090
+ s && s.size >= 16 && s.offset < r.offset + r.size && (c = n - R(e, s.offset + 12)), a.push({
2091
2091
  height: l,
2092
2092
  width: c
2093
2093
  });
@@ -2103,7 +2103,7 @@ var ur = {
2103
2103
  ...a.length > 1 ? { images: a } : {}
2104
2104
  };
2105
2105
  }
2106
- }, vr = 8, yr = 4, br = 4, xr = {
2106
+ }, xr = 8, Sr = 4, Cr = 4, wr = {
2107
2107
  ICON: 32,
2108
2108
  "ICN#": 32,
2109
2109
  "icm#": 16,
@@ -2136,27 +2136,27 @@ var ur = {
2136
2136
  ic14: 512,
2137
2137
  ic10: 1024
2138
2138
  };
2139
- function Sr(e, t) {
2140
- let n = t + br;
2139
+ function Tr(e, t) {
2140
+ let n = t + Cr;
2141
2141
  if (n + 4 > e.length) throw TypeError("Invalid ICNS");
2142
- return [L(e, t, n), V(e, n)];
2142
+ return [F(e, t, n), R(e, n)];
2143
2143
  }
2144
- function Cr(e) {
2145
- let t = xr[e];
2144
+ function Er(e) {
2145
+ let t = wr[e];
2146
2146
  return {
2147
2147
  width: t,
2148
2148
  height: t,
2149
2149
  type: e
2150
2150
  };
2151
2151
  }
2152
- var wr = {
2153
- validate: (e) => L(e, 0, 4) === "icns",
2152
+ var Dr = {
2153
+ validate: (e) => F(e, 0, 4) === "icns",
2154
2154
  calculate(e) {
2155
- let t = e.length, n = V(e, yr), r = vr, i = [];
2155
+ let t = e.length, n = R(e, Sr), r = xr, i = [];
2156
2156
  for (; r < n && r < t;) {
2157
- let t = Sr(e, r), n = t[1];
2157
+ let t = Tr(e, r), n = t[1];
2158
2158
  if (n < 8) throw TypeError("Invalid ICNS");
2159
- let a = Cr(t[0]);
2159
+ let a = Er(t[0]);
2160
2160
  i.push(a), r += n;
2161
2161
  }
2162
2162
  if (i.length === 0) throw TypeError("Invalid ICNS, no sizes found");
@@ -2166,64 +2166,64 @@ var wr = {
2166
2166
  ...i.length > 1 ? { images: i } : {}
2167
2167
  };
2168
2168
  }
2169
- }, Tr = {
2170
- validate: (e) => V(e, 0) === 4283432785,
2169
+ }, Or = {
2170
+ validate: (e) => R(e, 0) === 4283432785,
2171
2171
  calculate: (e) => ({
2172
- height: V(e, 12),
2173
- width: V(e, 8)
2172
+ height: R(e, 12),
2173
+ width: R(e, 8)
2174
2174
  })
2175
- }, Er = {
2175
+ }, kr = {
2176
2176
  validate(e) {
2177
- if (L(e, 4, 8) !== "jP ") return !1;
2178
- let t = W(e, "ftyp", 0);
2179
- return t ? L(e, t.offset + 8, t.offset + 12) === "jp2 " : !1;
2177
+ if (F(e, 4, 8) !== "jP ") return !1;
2178
+ let t = V(e, "ftyp", 0);
2179
+ return t ? F(e, t.offset + 8, t.offset + 12) === "jp2 " : !1;
2180
2180
  },
2181
2181
  calculate(e) {
2182
- let t = W(e, "jp2h", 0), n = t && W(e, "ihdr", t.offset + 8);
2182
+ let t = V(e, "jp2h", 0), n = t && V(e, "ihdr", t.offset + 8);
2183
2183
  if (n) return {
2184
- height: V(e, n.offset + 8),
2185
- width: V(e, n.offset + 12)
2184
+ height: R(e, n.offset + 8),
2185
+ width: R(e, n.offset + 12)
2186
2186
  };
2187
2187
  throw TypeError("Unsupported JPEG 2000 format");
2188
2188
  }
2189
- }, Dr = "45786966", Or = 2, kr = 6, Ar = "4d4d", jr = "4949", Mr = 12;
2190
- function Nr(e) {
2191
- return R(e, 2, 6) === Dr;
2189
+ }, Ar = "45786966", jr = 2, Mr = 6, Nr = "4d4d", Pr = "4949", Fr = 12;
2190
+ function Ir(e) {
2191
+ return Qn(e, 2, 6) === Ar;
2192
2192
  }
2193
- function Pr(e, t) {
2193
+ function Lr(e, t) {
2194
2194
  return {
2195
- height: Zn(e, t),
2196
- width: Zn(e, t + 2)
2195
+ height: er(e, t),
2196
+ width: er(e, t + 2)
2197
2197
  };
2198
2198
  }
2199
- function Fr(e, t) {
2200
- let n = U(e, 16, 14, t);
2199
+ function Rr(e, t) {
2200
+ let n = B(e, 16, 14, t);
2201
2201
  for (let r = 0; r < n; r++) {
2202
- let n = 16 + r * Mr, i = n + Mr;
2202
+ let n = 16 + r * Fr, i = n + Fr;
2203
2203
  if (n > e.length) return;
2204
2204
  let a = e.slice(n, i);
2205
- if (U(a, 16, 0, t) === 274) return U(a, 16, 2, t) !== 3 || U(a, 32, 4, t) !== 1 ? void 0 : U(a, 16, 8, t);
2205
+ if (B(a, 16, 0, t) === 274) return B(a, 16, 2, t) !== 3 || B(a, 32, 4, t) !== 1 ? void 0 : B(a, 16, 8, t);
2206
2206
  }
2207
2207
  }
2208
- function Ir(e, t) {
2209
- let n = e.slice(Or, t), r = R(n, kr, 8), i = r === Ar;
2210
- if (i || r === jr) return Fr(n, i);
2208
+ function zr(e, t) {
2209
+ let n = e.slice(jr, t), r = Qn(n, Mr, 8), i = r === Nr;
2210
+ if (i || r === Pr) return Rr(n, i);
2211
2211
  }
2212
- function Lr(e, t) {
2212
+ function Br(e, t) {
2213
2213
  if (t > e.length) throw TypeError("Corrupt JPG, exceeded buffer limits");
2214
2214
  }
2215
- var Rr = {
2216
- validate: (e) => R(e, 0, 2) === "ffd8",
2215
+ var Vr = {
2216
+ validate: (e) => Qn(e, 0, 2) === "ffd8",
2217
2217
  calculate(e) {
2218
2218
  let t = e.slice(4), n, r;
2219
2219
  for (; t.length;) {
2220
- let e = Zn(t, 0);
2221
- if (Lr(t, e), t[e] !== 255) {
2220
+ let e = er(t, 0);
2221
+ if (Br(t, e), t[e] !== 255) {
2222
2222
  t = t.slice(1);
2223
2223
  continue;
2224
2224
  }
2225
- if (Nr(t) && (n = Ir(t, e)), r = t[e + 1], r === 192 || r === 193 || r === 194) {
2226
- let r = Pr(t, e + 5);
2225
+ if (Ir(t) && (n = zr(t, e)), r = t[e + 1], r === 192 || r === 193 || r === 194) {
2226
+ let r = Lr(t, e + 5);
2227
2227
  return n ? {
2228
2228
  height: r.height,
2229
2229
  orientation: n,
@@ -2234,7 +2234,7 @@ var Rr = {
2234
2234
  }
2235
2235
  throw TypeError("Invalid JPG, no size found");
2236
2236
  }
2237
- }, zr = class {
2237
+ }, Hr = class {
2238
2238
  input;
2239
2239
  endianness;
2240
2240
  byteOffset = 2;
@@ -2261,7 +2261,7 @@ var Rr = {
2261
2261
  };
2262
2262
  //#endregion
2263
2263
  //#region ../../node_modules/image-size/dist/esm/types/jxl-stream.js
2264
- function Br(e, t) {
2264
+ function Ur(e, t) {
2265
2265
  if (t) return 8 * (1 + e.getBits(5));
2266
2266
  let n = [
2267
2267
  9,
@@ -2271,8 +2271,8 @@ function Br(e, t) {
2271
2271
  ][e.getBits(2)];
2272
2272
  return 1 + e.getBits(n);
2273
2273
  }
2274
- function Vr(e, t, n, r) {
2275
- return t && n === 0 ? 8 * (1 + e.getBits(5)) : n === 0 ? Br(e, !1) : Math.floor(r * [
2274
+ function Wr(e, t, n, r) {
2275
+ return t && n === 0 ? 8 * (1 + e.getBits(5)) : n === 0 ? Ur(e, !1) : Math.floor(r * [
2276
2276
  1,
2277
2277
  1.2,
2278
2278
  4 / 3,
@@ -2282,82 +2282,82 @@ function Vr(e, t, n, r) {
2282
2282
  2
2283
2283
  ][n - 1]);
2284
2284
  }
2285
- var Hr = {
2286
- validate: (e) => R(e, 0, 2) === "ff0a",
2285
+ var Gr = {
2286
+ validate: (e) => Qn(e, 0, 2) === "ff0a",
2287
2287
  calculate(e) {
2288
- let t = new zr(e, "little-endian"), n = t.getBits(1) === 1, r = Br(t, n);
2288
+ let t = new Hr(e, "little-endian"), n = t.getBits(1) === 1, r = Ur(t, n);
2289
2289
  return {
2290
- width: Vr(t, n, t.getBits(3), r),
2290
+ width: Wr(t, n, t.getBits(3), r),
2291
2291
  height: r
2292
2292
  };
2293
2293
  }
2294
2294
  };
2295
2295
  //#endregion
2296
2296
  //#region ../../node_modules/image-size/dist/esm/types/jxl.js
2297
- function Ur(e) {
2298
- let t = W(e, "jxlc", 0);
2297
+ function Kr(e) {
2298
+ let t = V(e, "jxlc", 0);
2299
2299
  if (t) return e.slice(t.offset + 8, t.offset + t.size);
2300
- let n = Wr(e);
2301
- if (n.length > 0) return Gr(n);
2300
+ let n = qr(e);
2301
+ if (n.length > 0) return Jr(n);
2302
2302
  }
2303
- function Wr(e) {
2303
+ function qr(e) {
2304
2304
  let t = [], n = 0;
2305
2305
  for (; n < e.length;) {
2306
- let r = W(e, "jxlp", n);
2306
+ let r = V(e, "jxlp", n);
2307
2307
  if (!r) break;
2308
2308
  if (r.size < 12) throw TypeError("Invalid JXL");
2309
2309
  t.push(e.slice(r.offset + 12, r.offset + r.size)), n = r.offset + r.size;
2310
2310
  }
2311
2311
  return t;
2312
2312
  }
2313
- function Gr(e) {
2313
+ function Jr(e) {
2314
2314
  let t = e.reduce((e, t) => e + t.length, 0), n = new Uint8Array(t), r = 0;
2315
2315
  for (let t of e) n.set(t, r), r += t.length;
2316
2316
  return n;
2317
2317
  }
2318
- var Kr = {
2318
+ var Yr = {
2319
2319
  validate: (e) => {
2320
- if (L(e, 4, 8) !== "JXL ") return !1;
2321
- let t = W(e, "ftyp", 0);
2322
- return t ? L(e, t.offset + 8, t.offset + 12) === "jxl " : !1;
2320
+ if (F(e, 4, 8) !== "JXL ") return !1;
2321
+ let t = V(e, "ftyp", 0);
2322
+ return t ? F(e, t.offset + 8, t.offset + 12) === "jxl " : !1;
2323
2323
  },
2324
2324
  calculate(e) {
2325
- let t = Ur(e);
2326
- if (t) return Hr.calculate(t);
2325
+ let t = Kr(e);
2326
+ if (t) return Gr.calculate(t);
2327
2327
  throw TypeError("Invalid JXL");
2328
2328
  }
2329
- }, qr = {
2329
+ }, Xr = {
2330
2330
  validate: (e) => {
2331
- let t = L(e, 1, 7);
2331
+ let t = F(e, 1, 7);
2332
2332
  return ["KTX 11", "KTX 20"].includes(t);
2333
2333
  },
2334
2334
  calculate: (e) => {
2335
2335
  let t = e[5] === 49 ? "ktx" : "ktx2", n = t === "ktx" ? 36 : 20;
2336
2336
  return {
2337
- height: H(e, n + 4),
2338
- width: H(e, n),
2337
+ height: z(e, n + 4),
2338
+ width: z(e, n),
2339
2339
  type: t
2340
2340
  };
2341
2341
  }
2342
- }, Jr = "PNG\r\n\n", Yr = "IHDR", Xr = "CgBI", Zr = {
2342
+ }, Zr = "PNG\r\n\n", Qr = "IHDR", $r = "CgBI", ei = {
2343
2343
  validate(e) {
2344
- if (Jr === L(e, 1, 8)) {
2345
- let t = L(e, 12, 16);
2346
- if (t === Xr && (t = L(e, 28, 32)), t !== Yr) throw TypeError("Invalid PNG");
2344
+ if (Zr === F(e, 1, 8)) {
2345
+ let t = F(e, 12, 16);
2346
+ if (t === $r && (t = F(e, 28, 32)), t !== Qr) throw TypeError("Invalid PNG");
2347
2347
  return !0;
2348
2348
  }
2349
2349
  return !1;
2350
2350
  },
2351
2351
  calculate(e) {
2352
- return L(e, 12, 16) === Xr ? {
2353
- height: V(e, 36),
2354
- width: V(e, 32)
2352
+ return F(e, 12, 16) === $r ? {
2353
+ height: R(e, 36),
2354
+ width: R(e, 32)
2355
2355
  } : {
2356
- height: V(e, 20),
2357
- width: V(e, 16)
2356
+ height: R(e, 20),
2357
+ width: R(e, 16)
2358
2358
  };
2359
2359
  }
2360
- }, Qr = {
2360
+ }, ti = {
2361
2361
  P1: "pbm/ascii",
2362
2362
  P2: "pgm/ascii",
2363
2363
  P3: "ppm/ascii",
@@ -2366,7 +2366,7 @@ var Kr = {
2366
2366
  P6: "ppm",
2367
2367
  P7: "pam",
2368
2368
  PF: "pfm"
2369
- }, $r = {
2369
+ }, ni = {
2370
2370
  default: (e) => {
2371
2371
  let t = [];
2372
2372
  for (; e.length > 0;) {
@@ -2396,60 +2396,60 @@ var Kr = {
2396
2396
  };
2397
2397
  throw TypeError("Invalid PAM");
2398
2398
  }
2399
- }, ei = {
2400
- validate: (e) => L(e, 0, 2) in Qr,
2399
+ }, ri = {
2400
+ validate: (e) => F(e, 0, 2) in ti,
2401
2401
  calculate(e) {
2402
- let t = Qr[L(e, 0, 2)], n = L(e, 3).split(/[\r\n]+/);
2403
- return ($r[t] || $r.default)(n);
2402
+ let t = ti[F(e, 0, 2)], n = F(e, 3).split(/[\r\n]+/);
2403
+ return (ni[t] || ni.default)(n);
2404
2404
  }
2405
- }, ti = {
2406
- validate: (e) => L(e, 0, 4) === "8BPS",
2405
+ }, ii = {
2406
+ validate: (e) => F(e, 0, 4) === "8BPS",
2407
2407
  calculate: (e) => ({
2408
- height: V(e, 14),
2409
- width: V(e, 18)
2408
+ height: R(e, 14),
2409
+ width: R(e, 18)
2410
2410
  })
2411
- }, ni = /<svg\s([^>"']|"[^"]*"|'[^']*')*>/, ri = {
2411
+ }, ai = /<svg\s([^>"']|"[^"]*"|'[^']*')*>/, oi = {
2412
2412
  height: /\sheight=(['"])([^%]+?)\1/,
2413
- root: ni,
2413
+ root: ai,
2414
2414
  viewbox: /\sviewBox=(['"])(.+?)\1/i,
2415
2415
  width: /\swidth=(['"])([^%]+?)\1/
2416
- }, ii = 2.54, ai = {
2416
+ }, si = 2.54, ci = {
2417
2417
  in: 96,
2418
- cm: 96 / ii,
2418
+ cm: 96 / si,
2419
2419
  em: 16,
2420
2420
  ex: 8,
2421
- m: 96 / ii * 100,
2422
- mm: 96 / ii / 10,
2421
+ m: 96 / si * 100,
2422
+ mm: 96 / si / 10,
2423
2423
  pc: 96 / 72 / 12,
2424
2424
  pt: 96 / 72,
2425
2425
  px: 1
2426
- }, oi = RegExp(`^([0-9.]+(?:e\\d+)?)(${Object.keys(ai).join("|")})?$`);
2427
- function si(e) {
2428
- let t = oi.exec(e);
2429
- if (t) return Math.round(Number(t[1]) * (ai[t[2]] || 1));
2426
+ }, li = RegExp(`^([0-9.]+(?:e\\d+)?)(${Object.keys(ci).join("|")})?$`);
2427
+ function ui(e) {
2428
+ let t = li.exec(e);
2429
+ if (t) return Math.round(Number(t[1]) * (ci[t[2]] || 1));
2430
2430
  }
2431
- function ci(e) {
2431
+ function di(e) {
2432
2432
  let t = e.split(" ");
2433
2433
  return {
2434
- height: si(t[3]),
2435
- width: si(t[2])
2434
+ height: ui(t[3]),
2435
+ width: ui(t[2])
2436
2436
  };
2437
2437
  }
2438
- function li(e) {
2439
- let t = e.match(ri.width), n = e.match(ri.height), r = e.match(ri.viewbox);
2438
+ function fi(e) {
2439
+ let t = e.match(oi.width), n = e.match(oi.height), r = e.match(oi.viewbox);
2440
2440
  return {
2441
- height: n && si(n[2]),
2442
- viewbox: r && ci(r[2]),
2443
- width: t && si(t[2])
2441
+ height: n && ui(n[2]),
2442
+ viewbox: r && di(r[2]),
2443
+ width: t && ui(t[2])
2444
2444
  };
2445
2445
  }
2446
- function ui(e) {
2446
+ function pi(e) {
2447
2447
  return {
2448
2448
  height: e.height,
2449
2449
  width: e.width
2450
2450
  };
2451
2451
  }
2452
- function di(e, t) {
2452
+ function mi(e, t) {
2453
2453
  let n = t.width / t.height;
2454
2454
  return e.width ? {
2455
2455
  height: Math.floor(e.width / n),
@@ -2462,28 +2462,28 @@ function di(e, t) {
2462
2462
  width: t.width
2463
2463
  };
2464
2464
  }
2465
- var fi = {
2466
- validate: (e) => ni.test(L(e, 0, 1e3)),
2465
+ var hi = {
2466
+ validate: (e) => ai.test(F(e, 0, 1e3)),
2467
2467
  calculate(e) {
2468
- let t = L(e).match(ri.root);
2468
+ let t = F(e).match(oi.root);
2469
2469
  if (t) {
2470
- let e = li(t[0]);
2471
- if (e.width && e.height) return ui(e);
2472
- if (e.viewbox) return di(e, e.viewbox);
2470
+ let e = fi(t[0]);
2471
+ if (e.width && e.height) return pi(e);
2472
+ if (e.viewbox) return mi(e, e.viewbox);
2473
2473
  }
2474
2474
  throw TypeError("Invalid SVG");
2475
2475
  }
2476
- }, pi = {
2476
+ }, gi = {
2477
2477
  validate(e) {
2478
- return B(e, 0) === 0 && B(e, 4) === 0;
2478
+ return L(e, 0) === 0 && L(e, 4) === 0;
2479
2479
  },
2480
2480
  calculate(e) {
2481
2481
  return {
2482
- height: B(e, 14),
2483
- width: B(e, 12)
2482
+ height: L(e, 14),
2483
+ width: L(e, 12)
2484
2484
  };
2485
2485
  }
2486
- }, G = {
2486
+ }, H = {
2487
2487
  TAG: {
2488
2488
  WIDTH: 256,
2489
2489
  HEIGHT: 257,
@@ -2503,129 +2503,129 @@ var fi = {
2503
2503
  BIG: 8
2504
2504
  }
2505
2505
  };
2506
- function mi(e, { isBigEndian: t, isBigTiff: n }) {
2507
- let r = n ? Number(er(e, 8, t)) : U(e, 32, 4, t), i = n ? G.COUNT_SIZE.BIG : G.COUNT_SIZE.STANDARD;
2506
+ function _i(e, { isBigEndian: t, isBigTiff: n }) {
2507
+ let r = n ? Number(rr(e, 8, t)) : B(e, 32, 4, t), i = n ? H.COUNT_SIZE.BIG : H.COUNT_SIZE.STANDARD;
2508
2508
  return e.slice(r + i);
2509
2509
  }
2510
- function hi(e, t, n, r) {
2510
+ function vi(e, t, n, r) {
2511
2511
  switch (t) {
2512
- case G.TYPE.SHORT: return U(e, 16, n, r);
2513
- case G.TYPE.LONG: return U(e, 32, n, r);
2514
- case G.TYPE.LONG8: {
2515
- let t = Number(er(e, n, r));
2512
+ case H.TYPE.SHORT: return B(e, 16, n, r);
2513
+ case H.TYPE.LONG: return B(e, 32, n, r);
2514
+ case H.TYPE.LONG8: {
2515
+ let t = Number(rr(e, n, r));
2516
2516
  if (t > 2 ** 53 - 1) throw TypeError("Value too large");
2517
2517
  return t;
2518
2518
  }
2519
2519
  default: return 0;
2520
2520
  }
2521
2521
  }
2522
- function gi(e, t) {
2523
- let n = t ? G.ENTRY_SIZE.BIG : G.ENTRY_SIZE.STANDARD;
2522
+ function yi(e, t) {
2523
+ let n = t ? H.ENTRY_SIZE.BIG : H.ENTRY_SIZE.STANDARD;
2524
2524
  if (e.length > n) return e.slice(n);
2525
2525
  }
2526
- function _i(e, { isBigEndian: t, isBigTiff: n }) {
2526
+ function bi(e, { isBigEndian: t, isBigTiff: n }) {
2527
2527
  let r = {}, i = e;
2528
2528
  for (; i?.length;) {
2529
- let e = U(i, 16, 0, t), a = U(i, 16, 2, t), o = n ? Number(er(i, 4, t)) : U(i, 32, 4, t);
2529
+ let e = B(i, 16, 0, t), a = B(i, 16, 2, t), o = n ? Number(rr(i, 4, t)) : B(i, 32, 4, t);
2530
2530
  if (e === 0) break;
2531
- o === 1 && (a === G.TYPE.SHORT || a === G.TYPE.LONG || n && a === G.TYPE.LONG8) && (r[e] = hi(i, a, n ? 12 : 8, t)), i = gi(i, n);
2531
+ o === 1 && (a === H.TYPE.SHORT || a === H.TYPE.LONG || n && a === H.TYPE.LONG8) && (r[e] = vi(i, a, n ? 12 : 8, t)), i = yi(i, n);
2532
2532
  }
2533
2533
  return r;
2534
2534
  }
2535
- function vi(e) {
2536
- let t = L(e, 0, 2), n = U(e, 16, 2, t === "MM");
2535
+ function xi(e) {
2536
+ let t = F(e, 0, 2), n = B(e, 16, 2, t === "MM");
2537
2537
  return {
2538
2538
  isBigEndian: t === "MM",
2539
2539
  isBigTiff: n === 43
2540
2540
  };
2541
2541
  }
2542
- function yi(e, t) {
2543
- let n = U(e, 16, 4, t), r = U(e, 16, 6, t);
2542
+ function Si(e, t) {
2543
+ let n = B(e, 16, 4, t), r = B(e, 16, 6, t);
2544
2544
  if (n !== 8 || r !== 0) throw TypeError("Invalid BigTIFF header");
2545
2545
  }
2546
- var bi = /* @__PURE__ */ new Set([
2546
+ var Ci = /* @__PURE__ */ new Set([
2547
2547
  "49492a00",
2548
2548
  "4d4d002a",
2549
2549
  "49492b00",
2550
2550
  "4d4d002b"
2551
- ]), xi = {
2551
+ ]), wi = {
2552
2552
  validate: (e) => {
2553
- let t = R(e, 0, 4);
2554
- return bi.has(t);
2553
+ let t = Qn(e, 0, 4);
2554
+ return Ci.has(t);
2555
2555
  },
2556
2556
  calculate(e) {
2557
- let t = vi(e);
2558
- t.isBigTiff && yi(e, t.isBigEndian);
2559
- let n = _i(mi(e, t), t), r = {
2560
- height: n[G.TAG.HEIGHT],
2561
- width: n[G.TAG.WIDTH],
2557
+ let t = xi(e);
2558
+ t.isBigTiff && Si(e, t.isBigEndian);
2559
+ let n = bi(_i(e, t), t), r = {
2560
+ height: n[H.TAG.HEIGHT],
2561
+ width: n[H.TAG.WIDTH],
2562
2562
  type: t.isBigTiff ? "bigtiff" : "tiff"
2563
2563
  };
2564
- if (n[G.TAG.COMPRESSION] && (r.compression = n[G.TAG.COMPRESSION]), !r.width || !r.height) throw TypeError("Invalid Tiff. Missing tags");
2564
+ if (n[H.TAG.COMPRESSION] && (r.compression = n[H.TAG.COMPRESSION]), !r.width || !r.height) throw TypeError("Invalid Tiff. Missing tags");
2565
2565
  return r;
2566
2566
  }
2567
2567
  };
2568
2568
  //#endregion
2569
2569
  //#region ../../node_modules/image-size/dist/esm/types/webp.js
2570
- function Si(e) {
2570
+ function Ti(e) {
2571
2571
  return {
2572
- height: 1 + Qn(e, 7),
2573
- width: 1 + Qn(e, 4)
2572
+ height: 1 + tr(e, 7),
2573
+ width: 1 + tr(e, 4)
2574
2574
  };
2575
2575
  }
2576
- function Ci(e) {
2576
+ function Ei(e) {
2577
2577
  return {
2578
2578
  height: 1 + ((e[4] & 15) << 10 | e[3] << 2 | (e[2] & 192) >> 6),
2579
2579
  width: 1 + ((e[2] & 63) << 8 | e[1])
2580
2580
  };
2581
2581
  }
2582
- function wi(e) {
2582
+ function Di(e) {
2583
2583
  return {
2584
- height: Xn(e, 8) & 16383,
2585
- width: Xn(e, 6) & 16383
2584
+ height: $n(e, 8) & 16383,
2585
+ width: $n(e, 6) & 16383
2586
2586
  };
2587
2587
  }
2588
2588
  //#endregion
2589
2589
  //#region ../../node_modules/image-size/dist/esm/types/index.js
2590
- var Ti = /* @__PURE__ */ new Map([
2591
- ["bmp", ir],
2592
- ["cur", fr],
2593
- ["dds", pr],
2594
- ["gif", hr],
2595
- ["heif", _r],
2596
- ["icns", wr],
2597
- ["ico", ur],
2598
- ["j2c", Tr],
2599
- ["jp2", Er],
2600
- ["jpg", Rr],
2601
- ["jxl", Kr],
2602
- ["jxl-stream", Hr],
2603
- ["ktx", qr],
2604
- ["png", Zr],
2605
- ["pnm", ei],
2606
- ["psd", ti],
2607
- ["svg", fi],
2608
- ["tga", pi],
2609
- ["tiff", xi],
2590
+ var Oi = /* @__PURE__ */ new Map([
2591
+ ["bmp", sr],
2592
+ ["cur", hr],
2593
+ ["dds", gr],
2594
+ ["gif", vr],
2595
+ ["heif", br],
2596
+ ["icns", Dr],
2597
+ ["ico", pr],
2598
+ ["j2c", Or],
2599
+ ["jp2", kr],
2600
+ ["jpg", Vr],
2601
+ ["jxl", Yr],
2602
+ ["jxl-stream", Gr],
2603
+ ["ktx", Xr],
2604
+ ["png", ei],
2605
+ ["pnm", ri],
2606
+ ["psd", ii],
2607
+ ["svg", hi],
2608
+ ["tga", gi],
2609
+ ["tiff", wi],
2610
2610
  ["webp", {
2611
2611
  validate(e) {
2612
- let t = L(e, 0, 4) === "RIFF", n = L(e, 8, 12) === "WEBP", r = L(e, 12, 15) === "VP8";
2612
+ let t = F(e, 0, 4) === "RIFF", n = F(e, 8, 12) === "WEBP", r = F(e, 12, 15) === "VP8";
2613
2613
  return t && n && r;
2614
2614
  },
2615
2615
  calculate(e) {
2616
- let t = L(e, 12, 16), n = e.slice(20, 30);
2616
+ let t = F(e, 12, 16), n = e.slice(20, 30);
2617
2617
  if (t === "VP8X") {
2618
2618
  let e = n[0], t = (e & 192) == 0, r = (e & 1) == 0;
2619
- if (t && r) return Si(n);
2619
+ if (t && r) return Ti(n);
2620
2620
  throw TypeError("Invalid WebP");
2621
2621
  }
2622
- if (t === "VP8 " && n[0] !== 47) return wi(n);
2623
- let r = R(n, 3, 6);
2624
- if (t === "VP8L" && r !== "9d012a") return Ci(n);
2622
+ if (t === "VP8 " && n[0] !== 47) return Di(n);
2623
+ let r = Qn(n, 3, 6);
2624
+ if (t === "VP8L" && r !== "9d012a") return Ei(n);
2625
2625
  throw TypeError("Invalid WebP");
2626
2626
  }
2627
2627
  }]
2628
- ]), Ei = Array.from(Ti.keys()), Di = /* @__PURE__ */ new Map([
2628
+ ]), ki = Array.from(Oi.keys()), Ai = /* @__PURE__ */ new Map([
2629
2629
  [0, "heif"],
2630
2630
  [56, "psd"],
2631
2631
  [66, "bmp"],
@@ -2638,18 +2638,18 @@ var Ti = /* @__PURE__ */ new Map([
2638
2638
  [137, "png"],
2639
2639
  [255, "jpg"]
2640
2640
  ]);
2641
- function Oi(e) {
2642
- let t = e[0], n = Di.get(t);
2643
- return n && Ti.get(n)?.validate(e) ? n : Ei.find((t) => Ti.get(t)?.validate(e));
2641
+ function ji(e) {
2642
+ let t = e[0], n = Ai.get(t);
2643
+ return n && Oi.get(n)?.validate(e) ? n : ki.find((t) => Oi.get(t)?.validate(e));
2644
2644
  }
2645
2645
  //#endregion
2646
2646
  //#region ../../node_modules/image-size/dist/esm/lookup.js
2647
- var ki = { disabledTypes: [] };
2648
- function Ai(e) {
2649
- let t = Oi(e);
2647
+ var Mi = { disabledTypes: [] };
2648
+ function Ni(e) {
2649
+ let t = ji(e);
2650
2650
  if (t !== void 0) {
2651
- if (ki.disabledTypes.indexOf(t) > -1) throw TypeError(`disabled file type: ${t}`);
2652
- let n = Ti.get(t)?.calculate(e);
2651
+ if (Mi.disabledTypes.indexOf(t) > -1) throw TypeError(`disabled file type: ${t}`);
2652
+ let n = Oi.get(t)?.calculate(e);
2653
2653
  if (n !== void 0) {
2654
2654
  if (n.type = n.type ?? t, n.images && n.images.length > 1) {
2655
2655
  let e = n.images.reduce((e, t) => t.width * t.height > e.width * e.height ? t : e, n.images[0]);
@@ -2662,7 +2662,7 @@ function Ai(e) {
2662
2662
  }
2663
2663
  //#endregion
2664
2664
  //#region src/node/conversation-content-transport.ts
2665
- var ji = class {
2665
+ var Pi = class {
2666
2666
  conversationId;
2667
2667
  cache = /* @__PURE__ */ new WeakMap();
2668
2668
  constructor(e) {
@@ -2677,7 +2677,7 @@ var ji = class {
2677
2677
  if (!Number.isSafeInteger(n) || n < 0 || n >= r.byteLength) throw Error("Invalid content offset.");
2678
2678
  let i = Math.min(r.byteLength, n + 64 * 1024);
2679
2679
  return {
2680
- data: Mi(r, n, i).toString("base64"),
2680
+ data: Fi(r, n, i).toString("base64"),
2681
2681
  totalBytes: r.byteLength,
2682
2682
  nextOffset: i < r.byteLength ? i : null
2683
2683
  };
@@ -2696,13 +2696,13 @@ var ji = class {
2696
2696
  ].includes(a ?? "") && /^data:image\/[a-z0-9.+-]+;base64,[a-z\d+/]+=*$/i.test(e)) {
2697
2697
  let i = n.get(e);
2698
2698
  if (!i) {
2699
- let a = Pi(e);
2699
+ let a = Li(e);
2700
2700
  t.set(a, {
2701
2701
  text: e,
2702
2702
  byteLength: e.length,
2703
2703
  charOffset: 0,
2704
2704
  byteOffset: 0
2705
- }), i = `conversation-image:${encodeURIComponent(this.conversationId)}:${a}`, n.set(e, i), r.set(i, Fi(e));
2705
+ }), i = `conversation-image:${encodeURIComponent(this.conversationId)}:${a}`, n.set(e, i), r.set(i, Ri(e));
2706
2706
  }
2707
2707
  return i;
2708
2708
  }
@@ -2713,7 +2713,7 @@ var ji = class {
2713
2713
  "update",
2714
2714
  "delete"
2715
2715
  ].includes(String(o.kind?.type)) && typeof o.diff == "string" && Buffer.byteLength(o.diff) > 64 * 1024) {
2716
- let n = Buffer.byteLength(o.diff), r = Pi(o.diff);
2716
+ let n = Buffer.byteLength(o.diff), r = Li(o.diff);
2717
2717
  return t.set(r, {
2718
2718
  text: o.diff,
2719
2719
  byteLength: n,
@@ -2745,32 +2745,32 @@ var ji = class {
2745
2745
  return e && typeof e == "object" && this.cache.set(e, a), a;
2746
2746
  }
2747
2747
  };
2748
- function Mi(e, t, n) {
2748
+ function Fi(e, t, n) {
2749
2749
  if (e.byteLength === e.text.length) return Buffer.from(e.text.slice(t, n));
2750
2750
  t < e.byteOffset && (e.charOffset = 0, e.byteOffset = 0);
2751
2751
  let r = [];
2752
2752
  for (; e.byteOffset < n;) {
2753
- let i = Ni(e.text, e.charOffset), a = e.text.slice(e.charOffset, i), o = e.byteOffset + Buffer.byteLength(a);
2753
+ let i = Ii(e.text, e.charOffset), a = e.text.slice(e.charOffset, i), o = e.byteOffset + Buffer.byteLength(a);
2754
2754
  if (o > t && r.push(Buffer.from(a).subarray(Math.max(0, t - e.byteOffset), Math.min(o, n) - e.byteOffset)), o >= n) break;
2755
2755
  e.charOffset = i, e.byteOffset = o;
2756
2756
  }
2757
2757
  return Buffer.concat(r, n - t);
2758
2758
  }
2759
- function Ni(e, t) {
2759
+ function Ii(e, t) {
2760
2760
  let n = Math.min(e.length, t + 16 * 1024), r = e.charCodeAt(n - 1);
2761
2761
  return n < e.length && r >= 55296 && r <= 56319 ? n - 1 : n;
2762
2762
  }
2763
- function Pi(e) {
2763
+ function Li(e) {
2764
2764
  let t = C("sha256");
2765
2765
  for (let n = 0; n < e.length;) {
2766
- let r = Ni(e, n);
2766
+ let r = Ii(e, n);
2767
2767
  t.update(e.slice(n, r)), n = r;
2768
2768
  }
2769
2769
  return t.digest("hex");
2770
2770
  }
2771
- function Fi(e) {
2771
+ function Ri(e) {
2772
2772
  try {
2773
- let t = e.indexOf(",") + 1, { width: n, height: r, orientation: i } = Ai(Buffer.from(e.slice(t, t + 64 * 1024), "base64"));
2773
+ let t = e.indexOf(",") + 1, { width: n, height: r, orientation: i } = Ni(Buffer.from(e.slice(t, t + 64 * 1024), "base64"));
2774
2774
  return !Number.isSafeInteger(n) || !Number.isSafeInteger(r) || n <= 0 || r <= 0 ? void 0 : i && i >= 5 && i <= 8 ? {
2775
2775
  width: r,
2776
2776
  height: n
@@ -2784,7 +2784,7 @@ function Fi(e) {
2784
2784
  }
2785
2785
  //#endregion
2786
2786
  //#region src/node/codex-original-history-images.ts
2787
- var Ii = 32 * 1024 * 1024, Li = 20 * 1024 * 1024, Ri = 2048, zi = class {
2787
+ var zi = 32 * 1024 * 1024, Bi = 20 * 1024 * 1024, Vi = 2048, Hi = class {
2788
2788
  client;
2789
2789
  paths = /* @__PURE__ */ new Map();
2790
2790
  indexes = /* @__PURE__ */ new Map();
@@ -2841,13 +2841,13 @@ var Ii = 32 * 1024 * 1024, Li = 20 * 1024 * 1024, Ri = 2048, zi = class {
2841
2841
  let r = await this.index(e), i = r.images.get(t);
2842
2842
  if (!i) throw Error("Original conversation image is no longer available.");
2843
2843
  if (!Number.isSafeInteger(n) || n < 0 || n >= i.byteLength) throw Error("Invalid content offset.");
2844
- let a = Ui(await se(r.path));
2844
+ let a = Ki(await se(r.path));
2845
2845
  if (this.disposed || this.paths.get(e) !== r.path) throw Error("Conversation image reader was released.");
2846
2846
  let o = this.images.get(t), s = o?.signature === a ? o.url : void 0;
2847
2847
  if (this.images.delete(t), !s) {
2848
2848
  let t = await ae(r.path, "r");
2849
2849
  try {
2850
- await Wi(t, e);
2850
+ await qi(t, e);
2851
2851
  let n = Buffer.alloc(i.length);
2852
2852
  for (let e = 0; e < n.length;) {
2853
2853
  let r = await t.read(n, e, Math.min(64 * 1024, n.length - e), i.offset + e);
@@ -2855,9 +2855,9 @@ var Ii = 32 * 1024 * 1024, Li = 20 * 1024 * 1024, Ri = 2048, zi = class {
2855
2855
  e += r.bytesRead;
2856
2856
  }
2857
2857
  let a = JSON.parse(n.toString("utf8")), o = a.payload;
2858
- 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.");
2859
- let c = o.output[i.imageIndex], l = Vi(c);
2860
- 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 || Ui(o) !== i.turnId || !Array.isArray(o.output)) throw Error("Original image identity changed.");
2859
+ let c = o.output[i.imageIndex], l = Wi(c);
2860
+ if (!l || Gi(l) !== i.hash) throw Error("Original image bytes changed.");
2861
2861
  if (s = l, this.disposed || this.paths.get(e) !== r.path) throw Error("Conversation image reader was released.");
2862
2862
  } finally {
2863
2863
  await t.close();
@@ -2866,7 +2866,7 @@ var Ii = 32 * 1024 * 1024, Li = 20 * 1024 * 1024, Ri = 2048, zi = class {
2866
2866
  for (this.images.set(t, {
2867
2867
  signature: a,
2868
2868
  url: s
2869
- }); 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) > Bi;) this.images.delete(this.images.keys().next().value);
2870
2870
  let c = Math.min(s.length, n + 64 * 1024);
2871
2871
  return {
2872
2872
  data: Buffer.from(s.slice(n, c)).toString("base64"),
@@ -2888,14 +2888,14 @@ var Ii = 32 * 1024 * 1024, Li = 20 * 1024 * 1024, Ri = 2048, zi = class {
2888
2888
  }
2889
2889
  let n = await se(t);
2890
2890
  if (!n.isFile()) throw Error("Original history is not a file.");
2891
- let r = Ui(n), i = this.indexes.get(e);
2891
+ let r = Ki(n), i = this.indexes.get(e);
2892
2892
  if (i?.signature === r) return i;
2893
2893
  let a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), s = await ae(t, "r");
2894
2894
  try {
2895
- await Wi(s, e);
2895
+ await qi(s, e);
2896
2896
  let t = 0;
2897
- for await (let r of Gi(s, n.size)) {
2898
- if (++t > 1e5 || a.size >= Ri) break;
2897
+ for await (let r of Ji(s, n.size)) {
2898
+ if (++t > 1e5 || a.size >= Vi) break;
2899
2899
  let n;
2900
2900
  try {
2901
2901
  n = JSON.parse(r.text);
@@ -2904,7 +2904,7 @@ var Ii = 32 * 1024 * 1024, Li = 20 * 1024 * 1024, Ri = 2048, zi = class {
2904
2904
  }
2905
2905
  let i = n?.payload;
2906
2906
  if (n?.type !== "response_item" || !i || typeof i.call_id != "string" || !i.call_id || i.call_id.length > 256) continue;
2907
- let s = Bi(i);
2907
+ let s = Ui(i);
2908
2908
  if (s) {
2909
2909
  if (i.type === "custom_tool_call") {
2910
2910
  o.size < 4096 && o.set(i.call_id, s);
@@ -2912,10 +2912,10 @@ var Ii = 32 * 1024 * 1024, Li = 20 * 1024 * 1024, Ri = 2048, zi = class {
2912
2912
  }
2913
2913
  if (!(i.type !== "custom_tool_call_output" || o.get(i.call_id) !== s || !Array.isArray(i.output))) {
2914
2914
  o.delete(i.call_id);
2915
- for (let t = 0; t < Math.min(i.output.length, 256) && a.size < Ri; t++) {
2916
- let n = Vi(i.output[t]);
2915
+ for (let t = 0; t < Math.min(i.output.length, 256) && a.size < Vi; t++) {
2916
+ let n = Wi(i.output[t]);
2917
2917
  if (!n) continue;
2918
- let o = Hi(n), c = Hi(JSON.stringify([
2918
+ let o = Gi(n), c = Gi(JSON.stringify([
2919
2919
  e,
2920
2920
  s,
2921
2921
  i.call_id,
@@ -2939,7 +2939,7 @@ var Ii = 32 * 1024 * 1024, Li = 20 * 1024 * 1024, Ri = 2048, zi = class {
2939
2939
  mimeType: n.slice(5, n.indexOf(";")),
2940
2940
  title: "Recorded tool image",
2941
2941
  alt: "Recorded tool image",
2942
- ...Fi(n)
2942
+ ...Ri(n)
2943
2943
  }
2944
2944
  }
2945
2945
  });
@@ -2960,24 +2960,24 @@ var Ii = 32 * 1024 * 1024, Li = 20 * 1024 * 1024, Ri = 2048, zi = class {
2960
2960
  return c;
2961
2961
  }
2962
2962
  };
2963
- function Bi(e) {
2963
+ function Ui(e) {
2964
2964
  let t = e.internal_chat_message_metadata_passthrough;
2965
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;
2966
2966
  }
2967
- function Vi(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 > Li)) return Un(e.image_url)?.url;
2967
+ function Wi(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 > Bi)) return Gn(e.image_url)?.url;
2969
2969
  }
2970
- function Hi(e) {
2970
+ function Gi(e) {
2971
2971
  return C("sha256").update(e).digest("hex");
2972
2972
  }
2973
- function Ui(e) {
2973
+ function Ki(e) {
2974
2974
  return `${e.dev}:${e.ino}:${e.size}:${e.mtimeMs}`;
2975
2975
  }
2976
- async function Wi(e, t) {
2976
+ async function qi(e, t) {
2977
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);
2978
2978
  if (a?.type !== "session_meta" || a.payload?.id !== t) throw Error("Original history belongs to a different conversation.");
2979
2979
  }
2980
- async function* Gi(e, t) {
2980
+ async function* Ji(e, t) {
2981
2981
  let n = 0, r = 0, i = 0, a = [];
2982
2982
  for (; n < t;) {
2983
2983
  let o = Buffer.alloc(Math.min(64 * 1024, t - n)), { bytesRead: s } = await e.read(o, 0, o.length, n);
@@ -2985,7 +2985,7 @@ async function* Gi(e, t) {
2985
2985
  let c = 0;
2986
2986
  for (; c < s;) {
2987
2987
  let e = o.indexOf(10, c), t = e < 0 || e >= s ? s : e, l = o.subarray(c, t);
2988
- i += l.length, i <= Ii ? a.push(l) : a = [], e >= 0 && e < s && (i <= Ii && (yield {
2988
+ i += l.length, i <= zi ? a.push(l) : a = [], e >= 0 && e < s && (i <= zi && (yield {
2989
2989
  offset: r,
2990
2990
  length: i,
2991
2991
  text: Buffer.concat(a, i).toString("utf8")
@@ -2994,7 +2994,7 @@ async function* Gi(e, t) {
2994
2994
  n += s;
2995
2995
  }
2996
2996
  }
2997
- function Ki(e) {
2997
+ function Yi(e) {
2998
2998
  return e.map((e) => {
2999
2999
  let t = new Set(e.parts.filter((e) => e.type === "tool" && e.title === "view_image").map((e) => e.type === "tool" ? e.id : ""));
3000
3000
  return t.size ? {
@@ -3005,7 +3005,7 @@ function Ki(e) {
3005
3005
  }
3006
3006
  //#endregion
3007
3007
  //#region src/node/codex-surface-usage-controller.ts
3008
- var qi = {
3008
+ var Xi = {
3009
3009
  status: "unavailable",
3010
3010
  reason: "public-runtime-request-evidence-unavailable",
3011
3011
  unavailableFields: [
@@ -3023,7 +3023,7 @@ var qi = {
3023
3023
  "finality"
3024
3024
  ],
3025
3025
  requests: null
3026
- }, Ji = class {
3026
+ }, Zi = class {
3027
3027
  threads = /* @__PURE__ */ new Map();
3028
3028
  clear() {
3029
3029
  this.threads.clear();
@@ -3031,7 +3031,7 @@ var qi = {
3031
3031
  recover(e, t, n) {
3032
3032
  let r = this.threads.get(e)?.executions.get(t);
3033
3033
  if (!r) return;
3034
- let i = r.latest ? Zi(n.total, r.latest.total) : null, a = i ? Qi(n.execution, i) ?? n.execution : n.execution, o = i ? r.latest.total : n.total, s = i ? r.latest.last : n.last;
3034
+ let i = r.latest ? ea(n.total, r.latest.total) : null, a = i ? ta(n.execution, i) ?? n.execution : n.execution, o = i ? r.latest.total : n.total, s = i ? r.latest.last : n.last;
3035
3035
  r.native = structuredClone({
3036
3036
  total: o,
3037
3037
  execution: a
@@ -3044,7 +3044,7 @@ var qi = {
3044
3044
  }),
3045
3045
  observedStart: !0,
3046
3046
  model: r.latest?.model ?? null,
3047
- requestUsage: structuredClone(qi)
3047
+ requestUsage: structuredClone(Xi)
3048
3048
  };
3049
3049
  return r.latest = structuredClone(c), c;
3050
3050
  }
@@ -3085,16 +3085,16 @@ var qi = {
3085
3085
  let e = r.executions.get(r.activeTurnId);
3086
3086
  e && (e.baseline = null, e.native = void 0), i && (i.baseline = null, i.native = void 0);
3087
3087
  }
3088
- i && (!K(a.total) || i.latest && !Xi(i.latest.total, a.total)) && (i.baseline = null, i.native = void 0);
3089
- let s = i?.native ? Zi(i.native.total, a.total) : null, c = i?.native && s ? Qi(i.native.execution, s) : i?.baseline ? Zi(i.baseline, a.total) : null;
3088
+ i && (!U(a.total) || i.latest && !$i(i.latest.total, a.total)) && (i.baseline = null, i.native = void 0);
3089
+ let s = i?.native ? ea(i.native.total, a.total) : null, c = i?.native && s ? ta(i.native.execution, s) : i?.baseline ? ea(i.baseline, a.total) : null;
3090
3090
  i && c === null && (i.baseline = null);
3091
3091
  let l = {
3092
3092
  ...a,
3093
3093
  execution: c,
3094
3094
  observedStart: !!i,
3095
- requestUsage: structuredClone(qi)
3095
+ requestUsage: structuredClone(Xi)
3096
3096
  };
3097
- return i && (i.latest = structuredClone(l)), r.total = !o && K(a.total) ? structuredClone(a.total) : null, r.lastUsageTurnId = t.turnId, {
3097
+ return i && (i.latest = structuredClone(l)), r.total = !o && U(a.total) ? structuredClone(a.total) : null, r.lastUsageTurnId = t.turnId, {
3098
3098
  ...t,
3099
3099
  payload: { usage: l }
3100
3100
  };
@@ -3108,21 +3108,21 @@ var qi = {
3108
3108
  executions: /* @__PURE__ */ new Map()
3109
3109
  }, this.threads.set(e, t)), t;
3110
3110
  }
3111
- }, Yi = [
3111
+ }, Qi = [
3112
3112
  "totalTokens",
3113
3113
  "inputTokens",
3114
3114
  "cachedInputTokens",
3115
3115
  "outputTokens",
3116
3116
  "reasoningOutputTokens"
3117
3117
  ];
3118
- function K(e) {
3119
- return Yi.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;
3118
+ function U(e) {
3119
+ return Qi.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;
3120
3120
  }
3121
- function Xi(e, t) {
3122
- return Yi.every((n) => t[n] >= e[n]) && (e.cacheWriteInputTokens === null || t.cacheWriteInputTokens === null || t.cacheWriteInputTokens >= e.cacheWriteInputTokens);
3121
+ function $i(e, t) {
3122
+ return Qi.every((n) => t[n] >= e[n]) && (e.cacheWriteInputTokens === null || t.cacheWriteInputTokens === null || t.cacheWriteInputTokens >= e.cacheWriteInputTokens);
3123
3123
  }
3124
- function Zi(e, t) {
3125
- if (!K(e) || !K(t) || !Xi(e, t)) return null;
3124
+ function ea(e, t) {
3125
+ if (!U(e) || !U(t) || !$i(e, t)) return null;
3126
3126
  let n = {
3127
3127
  totalTokens: t.totalTokens - e.totalTokens,
3128
3128
  inputTokens: t.inputTokens - e.inputTokens,
@@ -3131,15 +3131,15 @@ function Zi(e, t) {
3131
3131
  outputTokens: t.outputTokens - e.outputTokens,
3132
3132
  reasoningOutputTokens: t.reasoningOutputTokens - e.reasoningOutputTokens
3133
3133
  };
3134
- return K(n) ? n : null;
3134
+ return U(n) ? n : null;
3135
3135
  }
3136
- function Qi(e, t) {
3137
- let n = Object.fromEntries(Yi.map((n) => [n, e[n] + t[n]]));
3138
- return n.cacheWriteInputTokens = e.cacheWriteInputTokens === null || t.cacheWriteInputTokens === null ? null : e.cacheWriteInputTokens + t.cacheWriteInputTokens, K(n) ? n : null;
3136
+ function ta(e, t) {
3137
+ let n = Object.fromEntries(Qi.map((n) => [n, e[n] + t[n]]));
3138
+ return n.cacheWriteInputTokens = e.cacheWriteInputTokens === null || t.cacheWriteInputTokens === null ? null : e.cacheWriteInputTokens + t.cacheWriteInputTokens, U(n) ? n : null;
3139
3139
  }
3140
3140
  //#endregion
3141
3141
  //#region src/node/codex-original-history-usage.ts
3142
- var $i = 1024 * 1024, ea = class {
3142
+ var na = 1024 * 1024, ra = class {
3143
3143
  client;
3144
3144
  indexes = /* @__PURE__ */ new Map();
3145
3145
  work = Promise.resolve();
@@ -3195,10 +3195,10 @@ var $i = 1024 * 1024, ea = class {
3195
3195
  for (let n = 0; n < s; n++) {
3196
3196
  if (o[n] !== 10) continue;
3197
3197
  let r = o.subarray(c, n);
3198
- !a && i.length + r.length <= $i && this.record(l, e, Buffer.concat([i, r]).toString("utf8")), i = Buffer.alloc(0), a = !1, c = n + 1, l.offset = t + c;
3198
+ !a && i.length + r.length <= na && this.record(l, e, Buffer.concat([i, r]).toString("utf8")), i = Buffer.alloc(0), a = !1, c = n + 1, l.offset = t + c;
3199
3199
  }
3200
3200
  let u = o.subarray(c, s);
3201
- i.length + u.length > $i ? (a = !0, i = Buffer.alloc(0)) : a || (i = Buffer.concat([i, u])), t += s;
3201
+ i.length + u.length > na ? (a = !0, i = Buffer.alloc(0)) : a || (i = Buffer.concat([i, u])), t += s;
3202
3202
  }
3203
3203
  l.size = r.size, l.mtimeMs = r.mtimeMs;
3204
3204
  }
@@ -3225,7 +3225,7 @@ var $i = 1024 * 1024, ea = class {
3225
3225
  return;
3226
3226
  }
3227
3227
  if (r?.type !== "token_usage_record" || i?.thread_id !== t || typeof i.turn_id != "string" || !i.turn_id || i.turn_id.length > 256 || typeof r.timestamp != "string" || !Number.isFinite(Date.parse(r.timestamp))) return;
3228
- let a = ta(i.turn_token_usage), o = ta(i.thread_token_usage), s = ta(i.usage);
3228
+ let a = ia(i.turn_token_usage), o = ia(i.thread_token_usage), s = ia(i.usage);
3229
3229
  !a || !o || !s || (e.turns.set(i.turn_id, {
3230
3230
  turnId: i.turn_id,
3231
3231
  recordedAt: r.timestamp,
@@ -3235,7 +3235,7 @@ var $i = 1024 * 1024, ea = class {
3235
3235
  }), e.turns.size > 5e4 && e.turns.delete(e.turns.keys().next().value));
3236
3236
  }
3237
3237
  };
3238
- function ta(e) {
3238
+ function ia(e) {
3239
3239
  if (!e || typeof e != "object") return;
3240
3240
  let t = {
3241
3241
  totalTokens: e.total_tokens,
@@ -3245,26 +3245,26 @@ function ta(e) {
3245
3245
  outputTokens: e.output_tokens,
3246
3246
  reasoningOutputTokens: e.reasoning_output_tokens
3247
3247
  };
3248
- return K(t) ? t : void 0;
3248
+ return U(t) ? t : void 0;
3249
3249
  }
3250
3250
  //#endregion
3251
3251
  //#region src/node/codex-surface-realtime.ts
3252
- function na(e, t) {
3252
+ function aa(e, t) {
3253
3253
  if (e === void 0) return;
3254
3254
  if (typeof e != "string") throw TypeError(`Realtime ${t} must be a string`);
3255
3255
  let n = e.trim();
3256
3256
  if (!n) throw TypeError(`Realtime ${t} cannot be empty`);
3257
3257
  return n;
3258
3258
  }
3259
- function ra(e, t) {
3259
+ function oa(e, t) {
3260
3260
  if (typeof e != "string") throw TypeError(`Realtime ${t} must be a string`);
3261
3261
  let n = e.trim();
3262
3262
  if (!n) throw TypeError(`Realtime ${t} cannot be empty`);
3263
3263
  return n;
3264
3264
  }
3265
- function ia(e) {
3265
+ function sa(e) {
3266
3266
  if (!(e.data instanceof Uint8Array)) throw TypeError("Realtime audio data must be a Uint8Array");
3267
- let t = oa(e.sampleRate, "sampleRate"), n = oa(e.numChannels, "numChannels"), r = e.samplesPerChannel === void 0 ? Math.floor(e.data.byteLength / 2 / n) : sa(e.samplesPerChannel, "samplesPerChannel"), i = e.itemId === void 0 ? null : e.itemId;
3267
+ let t = la(e.sampleRate, "sampleRate"), n = la(e.numChannels, "numChannels"), r = e.samplesPerChannel === void 0 ? Math.floor(e.data.byteLength / 2 / n) : ua(e.samplesPerChannel, "samplesPerChannel"), i = e.itemId === void 0 ? null : e.itemId;
3268
3268
  if (i !== null && (typeof i != "string" || !i.trim())) throw TypeError("Realtime audio itemId must be a non-empty string or null");
3269
3269
  return {
3270
3270
  data: Buffer.from(e.data.buffer, e.data.byteOffset, e.data.byteLength).toString("base64"),
@@ -3274,7 +3274,7 @@ function ia(e) {
3274
3274
  itemId: i
3275
3275
  };
3276
3276
  }
3277
- function aa(e) {
3277
+ function ca(e) {
3278
3278
  return {
3279
3279
  data: new Uint8Array(Buffer.from(e.data, "base64")),
3280
3280
  sampleRate: e.sampleRate,
@@ -3283,28 +3283,28 @@ function aa(e) {
3283
3283
  itemId: e.itemId
3284
3284
  };
3285
3285
  }
3286
- function oa(e, t) {
3286
+ function la(e, t) {
3287
3287
  if (!Number.isSafeInteger(e) || e <= 0) throw TypeError(`Realtime audio ${t} must be a positive integer`);
3288
3288
  return e;
3289
3289
  }
3290
- function sa(e, t) {
3290
+ function ua(e, t) {
3291
3291
  if (e === null) return null;
3292
3292
  if (!Number.isSafeInteger(e) || e < 0) throw TypeError(`Realtime audio ${t} must be a non-negative integer or null`);
3293
3293
  return e;
3294
3294
  }
3295
3295
  //#endregion
3296
3296
  //#region src/node/codex-surface-realtime-session.ts
3297
- async function ca(e) {
3297
+ async function da(e) {
3298
3298
  let { client: t, ensureThreadReady: n, onConversationEvent: r, options: i, threadId: a } = e;
3299
3299
  await n();
3300
3300
  let o = i.outputModality;
3301
3301
  if (o !== "text" && o !== "audio") throw TypeError(`Invalid realtime output modality '${String(o)}'`);
3302
3302
  let s = i.version;
3303
3303
  if (s !== void 0 && s !== "v1" && s !== "v2" && s !== "v3") throw TypeError(`Invalid realtime version '${String(s)}'`);
3304
- let c = na(i.model, "model"), l = na(i.voice, "voice"), u = i.transport ?? { type: "websocket" };
3304
+ let c = aa(i.model, "model"), l = aa(i.voice, "voice"), u = i.transport ?? { type: "websocket" };
3305
3305
  if (u.type !== "websocket" && u.type !== "webrtc") throw TypeError(`Invalid realtime transport '${String(u.type)}'`);
3306
3306
  if (u.type === "webrtc" && !u.sdp.trim()) throw TypeError("WebRTC realtime transport requires a non-empty SDP offer");
3307
- let d = u.type === "webrtc" ? la(r) : null, f;
3307
+ let d = u.type === "webrtc" ? fa(r) : null, f;
3308
3308
  try {
3309
3309
  let [, e] = await Promise.all([t.request("thread/realtime/start", {
3310
3310
  threadId: a,
@@ -3335,12 +3335,12 @@ async function ca(e) {
3335
3335
  if (m(), u.type === "webrtc") throw Error("WebRTC realtime audio must be sent through its negotiated media track");
3336
3336
  await t.request("thread/realtime/appendAudio", {
3337
3337
  threadId: a,
3338
- audio: ia(e)
3338
+ audio: sa(e)
3339
3339
  });
3340
3340
  },
3341
3341
  appendText: async (e, n = "user") => {
3342
3342
  m();
3343
- let r = ra(e, "text");
3343
+ let r = oa(e, "text");
3344
3344
  if (n !== "user" && n !== "developer" && n !== "assistant") throw TypeError(`Invalid realtime text role '${String(n)}'`);
3345
3345
  await t.request("thread/realtime/appendText", {
3346
3346
  threadId: a,
@@ -3351,7 +3351,7 @@ async function ca(e) {
3351
3351
  appendSpeech: async (e) => {
3352
3352
  m(), await t.request("thread/realtime/appendSpeech", {
3353
3353
  threadId: a,
3354
- text: ra(e, "speech")
3354
+ text: oa(e, "speech")
3355
3355
  });
3356
3356
  },
3357
3357
  stop: async () => {
@@ -3362,7 +3362,7 @@ async function ca(e) {
3362
3362
  })
3363
3363
  };
3364
3364
  }
3365
- function la(e) {
3365
+ function fa(e) {
3366
3366
  let t = () => void 0, n, r = !1, i = () => {
3367
3367
  r || (r = !0, clearTimeout(n), t());
3368
3368
  };
@@ -3379,7 +3379,7 @@ function la(e) {
3379
3379
  }
3380
3380
  //#endregion
3381
3381
  //#region src/node/codex-surface-runtime.ts
3382
- function ua(e) {
3382
+ function pa(e) {
3383
3383
  return {
3384
3384
  status: "idle",
3385
3385
  authentication: e,
@@ -3422,7 +3422,7 @@ function ua(e) {
3422
3422
  error: null
3423
3423
  };
3424
3424
  }
3425
- function da(e, t, n = {}) {
3425
+ function ma(e, t, n = {}) {
3426
3426
  return {
3427
3427
  threadId: e,
3428
3428
  cwd: null,
@@ -3462,7 +3462,7 @@ function da(e, t, n = {}) {
3462
3462
  ...n
3463
3463
  };
3464
3464
  }
3465
- function fa(e, t, n) {
3465
+ function ha(e, t, n) {
3466
3466
  let r = [...n], i = new Set(r.map((e) => e.id)), a = new Set(e.answeredClientRequestIds);
3467
3467
  for (let t of e.messages) {
3468
3468
  let e = t.metadata?.asyncQuestionRequestIds;
@@ -3505,7 +3505,7 @@ function fa(e, t, n) {
3505
3505
  }
3506
3506
  //#endregion
3507
3507
  //#region src/node/codex-surface-authentication.ts
3508
- function pa() {
3508
+ function ga() {
3509
3509
  return {
3510
3510
  status: "notLoaded",
3511
3511
  account: null,
@@ -3519,7 +3519,7 @@ function pa() {
3519
3519
  }
3520
3520
  };
3521
3521
  }
3522
- function ma(e) {
3522
+ function _a(e) {
3523
3523
  return e.type === "chatgpt" ? {
3524
3524
  type: "chatgpt",
3525
3525
  email: e.email,
@@ -3529,13 +3529,13 @@ function ma(e) {
3529
3529
  credentialSource: e.usesCodexManagedCredentials ? "codexManaged" : "awsManaged"
3530
3530
  } : { type: "apiKey" };
3531
3531
  }
3532
- function ha(e) {
3532
+ function va(e) {
3533
3533
  return JSON.stringify({
3534
3534
  account: e.account,
3535
3535
  requiresOpenaiAuth: e.requiresOpenaiAuth
3536
3536
  });
3537
3537
  }
3538
- function ga(e) {
3538
+ function ya(e) {
3539
3539
  let t = e.account;
3540
3540
  return t ? t.type === "chatgpt" ? JSON.stringify({
3541
3541
  type: t.type,
@@ -3548,12 +3548,12 @@ function ga(e) {
3548
3548
  requiresOpenaiAuth: e.requiresOpenaiAuth
3549
3549
  });
3550
3550
  }
3551
- function _a(e) {
3551
+ function ba(e) {
3552
3552
  let t = e.trim();
3553
3553
  if (!t) throw Error("Codex login id cannot be empty");
3554
3554
  return t;
3555
3555
  }
3556
- function va(e) {
3556
+ function xa(e) {
3557
3557
  let t;
3558
3558
  try {
3559
3559
  t = new URL(e);
@@ -3565,41 +3565,41 @@ function va(e) {
3565
3565
  }
3566
3566
  //#endregion
3567
3567
  //#region src/node/codex-surface-settings.ts
3568
- function q(e, t) {
3568
+ function W(e, t) {
3569
3569
  return e.find((e) => e.id === t || e.model === t) ?? e.find((e) => e.isDefault) ?? e[0] ?? null;
3570
3570
  }
3571
- function ya(e, t) {
3571
+ function Sa(e, t) {
3572
3572
  let n = e.find((e) => e.id === t || e.model === t);
3573
3573
  if (!n) throw Error(`Unknown model '${t}'`);
3574
3574
  return n;
3575
3575
  }
3576
- function ba(e, t) {
3576
+ function Ca(e, t) {
3577
3577
  if (!t) return;
3578
3578
  if (!e) throw Error(`Cannot select reasoning effort '${t}' without a model`);
3579
3579
  let n = e.supportedReasoningEfforts?.map((e) => e.reasoningEffort) ?? [];
3580
3580
  if (n.length > 0 && !n.includes(t)) throw Error(`Reasoning effort '${t}' is not available for '${e.displayName}'`);
3581
3581
  }
3582
- function xa(e) {
3582
+ function G(e) {
3583
3583
  return e.defaultReasoningEffort ?? e.supportedReasoningEfforts?.[0]?.reasoningEffort ?? null;
3584
3584
  }
3585
- function Sa(e) {
3585
+ function wa(e) {
3586
3586
  return e.defaultServiceTier ?? null;
3587
3587
  }
3588
- function Ca(e, t) {
3588
+ function Ta(e, t) {
3589
3589
  if (!t) return;
3590
3590
  if (!e) throw Error(`Cannot select service tier '${t}' without a model`);
3591
3591
  if (t === "default" || t === e.defaultServiceTier) return;
3592
3592
  let n = e.serviceTiers?.map((e) => e.id) ?? [];
3593
3593
  if (n.length > 0 && !n.includes(t)) throw Error(`Service tier '${t}' is not available for '${e.displayName}'`);
3594
3594
  }
3595
- function wa(e, t) {
3595
+ function Ea(e, t) {
3596
3596
  let n = new Set(e.filter((e) => e.allowed).map((e) => e.id)), r = [];
3597
- return n.has(":workspace") && Ta(t?.allowedApprovalPolicies, "on-request") && Ta(t?.allowedApprovalsReviewers, "user") && r.push("ask-for-approval"), n.has(":workspace") && Ta(t?.allowedApprovalPolicies, "on-request") && Ta(t?.allowedApprovalsReviewers, "auto_review") && r.push("approve-for-me"), (n.has(":danger-full-access") || n.has(":danger-no-sandbox")) && Ta(t?.allowedApprovalPolicies, "never") && Ta(t?.allowedApprovalsReviewers, "user") && r.push("full-access"), r;
3597
+ return n.has(":workspace") && K(t?.allowedApprovalPolicies, "on-request") && K(t?.allowedApprovalsReviewers, "user") && r.push("ask-for-approval"), n.has(":workspace") && K(t?.allowedApprovalPolicies, "on-request") && K(t?.allowedApprovalsReviewers, "auto_review") && r.push("approve-for-me"), (n.has(":danger-full-access") || n.has(":danger-no-sandbox")) && K(t?.allowedApprovalPolicies, "never") && K(t?.allowedApprovalsReviewers, "user") && r.push("full-access"), r;
3598
3598
  }
3599
- function Ta(e, t) {
3599
+ function K(e, t) {
3600
3600
  return !Array.isArray(e) || e.length === 0 || e.includes(t);
3601
3601
  }
3602
- function Ea(e) {
3602
+ function Da(e) {
3603
3603
  return e === "full-access" ? {
3604
3604
  approvalPolicy: "never",
3605
3605
  approvalsReviewer: "user",
@@ -3610,39 +3610,39 @@ function Ea(e) {
3610
3610
  permissions: ":workspace"
3611
3611
  };
3612
3612
  }
3613
- function Da(e) {
3614
- return Ea(e);
3613
+ function Oa(e) {
3614
+ return Da(e);
3615
3615
  }
3616
- function Oa(e, t, n, r) {
3616
+ function ka(e, t, n, r) {
3617
3617
  let i = r?.id;
3618
3618
  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;
3619
3619
  }
3620
- function ka(e, t, n) {
3621
- let r = q(t, e.model);
3620
+ function Aa(e, t, n) {
3621
+ let r = W(t, e.model);
3622
3622
  return {
3623
- approvalPreset: Oa(e.approvalPolicy, e.approvalsReviewer, e.sandbox, e.activePermissionProfile) ?? n.approvalPreset,
3623
+ approvalPreset: ka(e.approvalPolicy, e.approvalsReviewer, e.sandbox, e.activePermissionProfile) ?? n.approvalPreset,
3624
3624
  planMode: n.planMode,
3625
3625
  selectedModelId: r?.id ?? n.selectedModelId,
3626
- selectedReasoningEffort: e.reasoningEffort ?? (r ? xa(r) : null),
3627
- selectedServiceTier: e.serviceTier === void 0 ? r ? Sa(r) : null : e.serviceTier
3626
+ selectedReasoningEffort: e.reasoningEffort ?? (r ? G(r) : null),
3627
+ selectedServiceTier: e.serviceTier === void 0 ? r ? wa(r) : null : e.serviceTier
3628
3628
  };
3629
3629
  }
3630
- function Aa(e, t, n) {
3631
- let r = q(t, e.model);
3630
+ function ja(e, t, n) {
3631
+ let r = W(t, e.model);
3632
3632
  return {
3633
- approvalPreset: Oa(e.approvalPolicy, e.approvalsReviewer, e.sandboxPolicy, e.activePermissionProfile) ?? n.approvalPreset,
3633
+ approvalPreset: ka(e.approvalPolicy, e.approvalsReviewer, e.sandboxPolicy, e.activePermissionProfile) ?? n.approvalPreset,
3634
3634
  planMode: e.collaborationMode.mode === "plan",
3635
3635
  selectedModelId: r?.id ?? n.selectedModelId,
3636
- selectedReasoningEffort: e.effort ?? (r ? xa(r) : null),
3637
- selectedServiceTier: e.serviceTier === void 0 ? r ? Sa(r) : null : e.serviceTier
3636
+ selectedReasoningEffort: e.effort ?? (r ? G(r) : null),
3637
+ selectedServiceTier: e.serviceTier === void 0 ? r ? wa(r) : null : e.serviceTier
3638
3638
  };
3639
3639
  }
3640
- function ja(e, t) {
3641
- let n = q(e.models, e.selectedModelId);
3640
+ function Ma(e, t) {
3641
+ let n = W(e.models, e.selectedModelId);
3642
3642
  if (t.modelId && (n = e.models.find((e) => e.id === t.modelId) ?? null, !n)) throw Error(`Unknown model '${t.modelId}'`);
3643
3643
  let r = t.reasoningEffort ?? e.selectedReasoningEffort, i = t.serviceTier === void 0 ? e.selectedServiceTier ?? null : t.serviceTier, a = n?.supportedReasoningEfforts?.map((e) => e.reasoningEffort) ?? [];
3644
3644
  if (t.reasoningEffort && a.length > 0 && !a.includes(t.reasoningEffort)) throw Error(`Reasoning effort '${t.reasoningEffort}' is not available for '${n.displayName}'`);
3645
- return t.modelId && a.length > 0 && (!r || !a.includes(r)) && (r = n ? xa(n) : null), t.serviceTier !== void 0 && Ca(n, i), t.serviceTier === void 0 && t.modelId && i && !n.serviceTiers?.some((e) => e.id === i) && (i = n ? Sa(n) : null), {
3645
+ return t.modelId && a.length > 0 && (!r || !a.includes(r)) && (r = n ? G(n) : null), t.serviceTier !== void 0 && Ta(n, i), t.serviceTier === void 0 && t.modelId && i && !n.serviceTiers?.some((e) => e.id === i) && (i = n ? wa(n) : null), {
3646
3646
  approvalPreset: t.approvalPreset ?? e.approvalPreset,
3647
3647
  planMode: t.planMode ?? e.planMode,
3648
3648
  selectedModelId: n?.id ?? null,
@@ -3650,7 +3650,7 @@ function ja(e, t) {
3650
3650
  selectedServiceTier: i
3651
3651
  };
3652
3652
  }
3653
- function Ma(e, t, n) {
3653
+ function Na(e, t, n) {
3654
3654
  return {
3655
3655
  mode: e ? "plan" : "default",
3656
3656
  settings: {
@@ -3660,18 +3660,18 @@ function Ma(e, t, n) {
3660
3660
  }
3661
3661
  };
3662
3662
  }
3663
- function Na(e, t) {
3664
- let n = q(e.models, e.selectedModelId), r = t.model ?? n?.model, i = t.reasoningEffort ?? e.selectedReasoningEffort, a = t.planMode ?? e.planMode;
3663
+ function Pa(e, t) {
3664
+ let n = W(e.models, e.selectedModelId), r = t.model ?? n?.model, i = t.reasoningEffort ?? e.selectedReasoningEffort, a = t.planMode ?? e.planMode;
3665
3665
  return {
3666
3666
  ...r ? { model: r } : {},
3667
3667
  ...i ? { effort: i } : {},
3668
- ...r ? { collaborationMode: Ma(a, r, i) } : {},
3668
+ ...r ? { collaborationMode: Na(a, r, i) } : {},
3669
3669
  ...t.serviceTier === void 0 ? e.selectedServiceTier ? { serviceTier: e.selectedServiceTier } : {} : { serviceTier: t.serviceTier }
3670
3670
  };
3671
3671
  }
3672
3672
  //#endregion
3673
3673
  //#region src/node/codex-surface-data.ts
3674
- function J(e) {
3674
+ function q(e) {
3675
3675
  let t = e.preview.trim(), n = t.split("\n")[0];
3676
3676
  return {
3677
3677
  id: e.id,
@@ -3688,25 +3688,25 @@ function J(e) {
3688
3688
  updatedAt: (/* @__PURE__ */ new Date((e.recencyAt ?? e.updatedAt) * 1e3)).toISOString()
3689
3689
  };
3690
3690
  }
3691
- function Pa(e, t) {
3691
+ function Fa(e, t) {
3692
3692
  let n = new Map(e.map((e) => [e.id, e])), r = t.map((e) => {
3693
3693
  let t = n.get(e.id);
3694
3694
  return t && me(t, e) ? t : e;
3695
3695
  });
3696
3696
  return r.length === e.length && r.every((t, n) => t === e[n]) ? e : r;
3697
3697
  }
3698
- function Y(e, t) {
3698
+ function J(e, t) {
3699
3699
  return [t, ...e.filter((e) => e.id !== t.id)].sort((e, t) => t.updatedAt.localeCompare(e.updatedAt));
3700
3700
  }
3701
- function Fa(e, t) {
3702
- let n = t.model ? ya(e.models, t.model) : q(e.models, e.selectedModelId);
3703
- return ba(n, t.reasoningEffort), Ca(n, t.serviceTier), {
3701
+ function Ia(e, t) {
3702
+ let n = t.model ? Sa(e.models, t.model) : W(e.models, e.selectedModelId);
3703
+ return Ca(n, t.reasoningEffort), Ta(n, t.serviceTier), {
3704
3704
  ...t,
3705
- ...t.attachments ? { attachments: Ia(t.attachments) } : {},
3705
+ ...t.attachments ? { attachments: La(t.attachments) } : {},
3706
3706
  ...t.model && n ? { model: n.model } : {}
3707
3707
  };
3708
3708
  }
3709
- function Ia(e) {
3709
+ function La(e) {
3710
3710
  return e.map((e) => {
3711
3711
  let t = e.path.trim();
3712
3712
  if (!t) throw Error("Attachment paths cannot be empty");
@@ -3723,14 +3723,14 @@ function Ia(e) {
3723
3723
  };
3724
3724
  });
3725
3725
  }
3726
- function La(e) {
3726
+ function Ra(e) {
3727
3727
  return e.type === "image" ? {
3728
3728
  type: "localImage",
3729
3729
  path: e.path,
3730
3730
  ...e.detail === void 0 ? {} : { detail: e.detail }
3731
3731
  } : st(e.name ?? g(e.path), e.path);
3732
3732
  }
3733
- function Ra(e) {
3733
+ function za(e) {
3734
3734
  let t = e.name?.trim() || g(e.path);
3735
3735
  return e.type === "image" ? {
3736
3736
  type: "attachment",
@@ -3751,14 +3751,14 @@ function Ra(e) {
3751
3751
  }
3752
3752
  };
3753
3753
  }
3754
- function za(e) {
3754
+ function Ba(e) {
3755
3755
  let t = e.metadata?.turnId;
3756
3756
  return e.turnId ?? (typeof t == "string" ? t : null);
3757
3757
  }
3758
- function Ba(e) {
3758
+ function Va(e) {
3759
3759
  return e.parts.filter((e) => e.type === "text").map((e) => e.text).join("\n").trim();
3760
3760
  }
3761
- function Va(e) {
3761
+ function Ha(e) {
3762
3762
  return e.parts.flatMap((e) => {
3763
3763
  if (e.type !== "attachment") return [];
3764
3764
  let t = e.attachment, n = t.path;
@@ -3776,7 +3776,7 @@ function Va(e) {
3776
3776
  }] : [];
3777
3777
  });
3778
3778
  }
3779
- function Ha(e) {
3779
+ function Ua(e) {
3780
3780
  return {
3781
3781
  totalTokens: e.totalTokens,
3782
3782
  inputTokens: e.inputTokens,
@@ -3786,7 +3786,7 @@ function Ha(e) {
3786
3786
  reasoningOutputTokens: e.reasoningOutputTokens
3787
3787
  };
3788
3788
  }
3789
- function Ua(e) {
3789
+ function Wa(e) {
3790
3790
  let t = e.modelContextWindow, n = e.last.totalTokens, r = typeof t == "number" && t > 0 ? Math.min(100, Math.max(0, n / t * 100)) : null;
3791
3791
  return {
3792
3792
  totalTokens: e.total.totalTokens,
@@ -3799,7 +3799,7 @@ function Ua(e) {
3799
3799
  usedPercent: r
3800
3800
  };
3801
3801
  }
3802
- function Wa(e) {
3802
+ function Y(e) {
3803
3803
  return e.type === "active" ? {
3804
3804
  type: "active",
3805
3805
  activeFlags: [...e.activeFlags]
@@ -3946,7 +3946,7 @@ var to = class {
3946
3946
  try {
3947
3947
  let e = await this.client.request("account/login/start", { type: "chatgpt" });
3948
3948
  if (e.type !== "chatgpt") throw Error(`Codex account/login/start returned unexpected login type '${e.type}'`);
3949
- let t = _a(e.loginId), n = va(e.authUrl);
3949
+ let t = ba(e.loginId), n = xa(e.authUrl);
3950
3950
  return this.host.patchAuthentication({ login: {
3951
3951
  status: "pending",
3952
3952
  loginId: t,
@@ -3961,7 +3961,7 @@ var to = class {
3961
3961
  status: "error",
3962
3962
  loginId: null,
3963
3963
  authUrl: null,
3964
- error: A(e)
3964
+ error: k(e)
3965
3965
  } }, "action"), e;
3966
3966
  }
3967
3967
  })();
@@ -3983,7 +3983,7 @@ var to = class {
3983
3983
  try {
3984
3984
  let e = await this.client.request("account/login/start", { type: "chatgptDeviceCode" });
3985
3985
  if (e.type !== "chatgptDeviceCode") throw Error(`Codex account/login/start returned unexpected login type '${e.type}'`);
3986
- let t = _a(e.loginId), n = va(e.verificationUrl), r = e.userCode.trim();
3986
+ let t = ba(e.loginId), n = xa(e.verificationUrl), r = e.userCode.trim();
3987
3987
  if (!r) throw Error("Codex account/login/start returned an empty device user code");
3988
3988
  this.host.patchAuthentication({ login: {
3989
3989
  status: "pending",
@@ -4002,7 +4002,7 @@ var to = class {
4002
4002
  status: "error",
4003
4003
  loginId: null,
4004
4004
  authUrl: null,
4005
- error: A(e)
4005
+ error: k(e)
4006
4006
  } }, "action"), e;
4007
4007
  }
4008
4008
  })();
@@ -4011,7 +4011,7 @@ var to = class {
4011
4011
  }).catch(() => void 0), t;
4012
4012
  }
4013
4013
  async cancelLogin(e) {
4014
- let t = _a(e), n = await this.client.request("account/login/cancel", { loginId: t });
4014
+ let t = ba(e), n = await this.client.request("account/login/cancel", { loginId: t });
4015
4015
  return this.host.patchAuthentication({ login: {
4016
4016
  status: n.status === "canceled" ? "cancelled" : "idle",
4017
4017
  loginId: null,
@@ -4053,7 +4053,7 @@ var to = class {
4053
4053
  error: null
4054
4054
  }, e);
4055
4055
  try {
4056
- let n = await this.client.request("account/read", { refreshToken: !1 }), r = n.account ? ma(n.account) : null, i = ga({
4056
+ let n = await this.client.request("account/read", { refreshToken: !1 }), r = n.account ? _a(n.account) : null, i = ya({
4057
4057
  ...this.host.getSnapshot().authentication,
4058
4058
  account: r,
4059
4059
  requiresOpenaiAuth: n.requiresOpenaiAuth
@@ -4067,7 +4067,7 @@ var to = class {
4067
4067
  } catch (t) {
4068
4068
  throw this.host.patchAuthentication({
4069
4069
  status: "error",
4070
- error: A(t)
4070
+ error: k(t)
4071
4071
  }, e), t;
4072
4072
  }
4073
4073
  }
@@ -4380,7 +4380,7 @@ var So = class {
4380
4380
  let t = this.host.requireRuntime(e.threadId);
4381
4381
  this.host.markRuntimeTurnActive(t, e.turnId);
4382
4382
  let n = t.messages.flatMap((e) => e.parts).find((t) => t.type === "text" && t.itemId === e.itemId)?.phase;
4383
- this.host.patchRuntime(e.threadId, { messages: dn(t.messages, e.threadId, e.turnId, e.itemId, e.delta, n) });
4383
+ this.host.patchRuntime(e.threadId, { messages: fn(t.messages, e.threadId, e.turnId, e.itemId, e.delta, n) });
4384
4384
  let r = this.host.assistantMessageForTurn(e.threadId, e.turnId);
4385
4385
  r && this.host.emitEvent("notification", {
4386
4386
  type: "message.delta",
@@ -4398,7 +4398,7 @@ var So = class {
4398
4398
  let t = this.host.requireRuntime(e.threadId);
4399
4399
  this.host.markRuntimeTurnActive(t, e.turnId);
4400
4400
  let n = `${t.planMarkdownByTurn.get(e.turnId) ?? ""}${e.delta}`;
4401
- t.planMarkdownByTurn.set(e.turnId, n), this.host.patchRuntime(e.threadId, { messages: M(t.messages, e.threadId, e.turnId, Tn(e.turnId, n, "running")) }), this.host.emitEvent("notification", {
4401
+ t.planMarkdownByTurn.set(e.turnId, n), this.host.patchRuntime(e.threadId, { messages: j(t.messages, e.threadId, e.turnId, En(e.turnId, n, "running")) }), this.host.emitEvent("notification", {
4402
4402
  type: "plan.delta",
4403
4403
  conversationId: e.threadId,
4404
4404
  turnId: e.turnId,
@@ -4412,7 +4412,7 @@ var So = class {
4412
4412
  applyPlanUpdated(e) {
4413
4413
  let t = this.host.requireRuntime(e.threadId);
4414
4414
  this.host.markRuntimeTurnActive(t, e.turnId);
4415
- let n = wn(e.explanation, e.plan), r = (/* @__PURE__ */ new Date()).toISOString();
4415
+ let n = Tn(e.explanation, e.plan), r = (/* @__PURE__ */ new Date()).toISOString();
4416
4416
  t.planMarkdownByTurn.set(e.turnId, n), this.host.patchRuntime(e.threadId, {
4417
4417
  executionPlan: {
4418
4418
  turnId: e.turnId,
@@ -4421,7 +4421,7 @@ var So = class {
4421
4421
  markdown: n,
4422
4422
  updatedAt: r
4423
4423
  },
4424
- messages: M(t.messages, e.threadId, e.turnId, Tn(e.turnId, n, "completed"))
4424
+ messages: j(t.messages, e.threadId, e.turnId, En(e.turnId, n, "completed"))
4425
4425
  }), this.host.emitEvent("notification", {
4426
4426
  type: "plan.updated",
4427
4427
  conversationId: e.threadId,
@@ -4443,7 +4443,7 @@ var So = class {
4443
4443
  this.applyToolUpdate(e.threadId, e.turnId, n.payload);
4444
4444
  return;
4445
4445
  }
4446
- this.host.patchRuntime(e.threadId, { messages: M(t.messages, e.threadId, e.turnId, n.payload.toolPart) });
4446
+ this.host.patchRuntime(e.threadId, { messages: j(t.messages, e.threadId, e.turnId, n.payload.toolPart) });
4447
4447
  let r = this.host.messageContainingTool(e.threadId, e.turnId, n.payload.toolPart.id);
4448
4448
  r && (this.host.emitEvent("notification", {
4449
4449
  type: n.type === "item.completed" ? "tool.completed" : "tool.started",
@@ -4464,7 +4464,7 @@ var So = class {
4464
4464
  startedAt: ("startedAtMs" in e ? e.startedAtMs : e.completedAtMs) / 1e3
4465
4465
  };
4466
4466
  if (e.item.type === "userMessage") {
4467
- let t = jn(e.threadId, i, e.item);
4467
+ let t = Nn(e.threadId, i, e.item);
4468
4468
  if (!t || n.messages.some((e) => e.id === t.id)) return;
4469
4469
  let a = n.messages.some((t) => t.role === "assistant" && t.metadata?.turnId === e.turnId && t.parts.length > 0), o = !a && r ? n.messages.map((e) => e.role === "user" && e.kind !== "steer" && !e.turnId && JSON.stringify(e.parts) === JSON.stringify(t.parts)).lastIndexOf(!0) : -1;
4470
4470
  if (o >= 0) {
@@ -4490,7 +4490,7 @@ var So = class {
4490
4490
  ...t,
4491
4491
  kind: "steer"
4492
4492
  } : t, c = [...n.messages, s];
4493
- this.host.patchRuntime(e.threadId, { messages: a ? j(c, e.threadId, e.turnId, { forceSegment: !0 }) : c }), this.host.emitEvent("notification", {
4493
+ this.host.patchRuntime(e.threadId, { messages: a ? A(c, e.threadId, e.turnId, { forceSegment: !0 }) : c }), this.host.emitEvent("notification", {
4494
4494
  type: "message.appended",
4495
4495
  conversationId: e.threadId,
4496
4496
  turnId: e.turnId,
@@ -4500,7 +4500,7 @@ var So = class {
4500
4500
  }
4501
4501
  if (e.item.type === "reasoning") {
4502
4502
  let t = this.host.assistantMessageForTurn(e.threadId, e.turnId), r = t ? JSON.stringify(t.parts) : null;
4503
- this.host.patchRuntime(e.threadId, { messages: fn(n.messages, e.threadId, e.turnId, e.item.id, e.item.summary) });
4503
+ this.host.patchRuntime(e.threadId, { messages: pn(n.messages, e.threadId, e.turnId, e.item.id, e.item.summary) });
4504
4504
  let i = this.host.assistantMessageForTurn(e.threadId, e.turnId);
4505
4505
  if (!i || JSON.stringify(i.parts) === r) return;
4506
4506
  this.host.emitEvent("notification", {
@@ -4512,10 +4512,10 @@ var So = class {
4512
4512
  return;
4513
4513
  }
4514
4514
  if (e.item.type === "agentMessage" && t && n.planMode && e.item.phase === "final_answer") {
4515
- let t = hn(e.item.text);
4515
+ let t = gn(e.item.text);
4516
4516
  if (t) {
4517
- let r = this.host.assistantMessageForTurn(e.threadId, e.turnId), i = mn(n.messages, e.threadId, e.turnId, e.item.id);
4518
- t.visibleText && (i = pn(i, e.threadId, e.turnId, e.item.id, t.visibleText, e.item.phase)), i = M(i, e.threadId, e.turnId, Tn(e.turnId, t.markdown, "completed")), n.planMarkdownByTurn.set(e.turnId, t.markdown), this.host.patchRuntime(e.threadId, { messages: i });
4517
+ let r = this.host.assistantMessageForTurn(e.threadId, e.turnId), i = hn(n.messages, e.threadId, e.turnId, e.item.id);
4518
+ t.visibleText && (i = mn(i, e.threadId, e.turnId, e.item.id, t.visibleText, e.item.phase)), i = j(i, e.threadId, e.turnId, En(e.turnId, t.markdown, "completed")), n.planMarkdownByTurn.set(e.turnId, t.markdown), this.host.patchRuntime(e.threadId, { messages: i });
4519
4519
  let a = this.host.assistantMessageForTurn(e.threadId, e.turnId);
4520
4520
  a && this.host.emitEvent("notification", {
4521
4521
  type: r ? "message.updated" : "message.appended",
@@ -4540,8 +4540,8 @@ var So = class {
4540
4540
  let i = mo(e.threadId, e.turnId);
4541
4541
  if (e.item.type === "agentMessage" && this.reviewOutputByTurn.get(i) === t) return;
4542
4542
  e.item.type === "exitedReviewMode" && this.reviewOutputByTurn.set(i, t);
4543
- 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" ? Mn(e.threadId, e.turnId, e.item) : null, d = u ? "" : t, f = u ? mn(n.messages, e.threadId, e.turnId, e.item.id) : pn(n.messages, e.threadId, e.turnId, e.item.id, t, r);
4544
- if (u && (f = _n(f, e.threadId, e.turnId, u)), this.host.patchRuntime(e.threadId, { messages: f }), !d && !u && !r) return;
4543
+ 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" ? Pn(e.threadId, e.turnId, e.item) : null, d = u ? "" : t, f = u ? hn(n.messages, e.threadId, e.turnId, e.item.id) : mn(n.messages, e.threadId, e.turnId, e.item.id, t, r);
4544
+ if (u && (f = vn(f, e.threadId, e.turnId, u)), this.host.patchRuntime(e.threadId, { messages: f }), !d && !u && !r) return;
4545
4545
  let p = this.host.assistantMessageForTurn(e.threadId, e.turnId);
4546
4546
  if (p && !a.has(p.id)) this.host.emitEvent("notification", {
4547
4547
  type: "message.appended",
@@ -4585,7 +4585,7 @@ var So = class {
4585
4585
  if (e.item.type === "plan") {
4586
4586
  if (!t) return;
4587
4587
  let r = e.item.text.trim() || n.planMarkdownByTurn.get(e.turnId) || "";
4588
- n.planMarkdownByTurn.set(e.turnId, r), this.host.patchRuntime(e.threadId, { messages: M(n.messages, e.threadId, e.turnId, Tn(e.turnId, r, "completed")) }), this.host.emitEvent("notification", {
4588
+ n.planMarkdownByTurn.set(e.turnId, r), this.host.patchRuntime(e.threadId, { messages: j(n.messages, e.threadId, e.turnId, En(e.turnId, r, "completed")) }), this.host.emitEvent("notification", {
4589
4589
  type: "plan.completed",
4590
4590
  conversationId: e.threadId,
4591
4591
  turnId: e.turnId,
@@ -4597,7 +4597,7 @@ var So = class {
4597
4597
  return;
4598
4598
  }
4599
4599
  if (e.item.type === "contextCompaction") {
4600
- if (this.host.patchRuntime(e.threadId, { messages: bn(n.messages, e.threadId, e.turnId, t ? "complete" : "streaming") }), t) {
4600
+ if (this.host.patchRuntime(e.threadId, { messages: xn(n.messages, e.threadId, e.turnId, t ? "complete" : "streaming") }), t) {
4601
4601
  let t = this.host.requireRuntime(e.threadId).messages.find((t) => t.kind === "compaction" && t.metadata?.turnId === e.turnId);
4602
4602
  t && this.host.emitEvent("notification", {
4603
4603
  type: "context.compactionCompleted",
@@ -4648,10 +4648,10 @@ var So = class {
4648
4648
  let a = this.shouldForwardCommandOutput(e.threadId, t, e.item), o = w(e.item, {
4649
4649
  includeCommandOutput: a,
4650
4650
  cwd: n.cwd
4651
- }), s = Pn(e.item);
4651
+ }), s = In(e.item);
4652
4652
  if (!o && !s.length) return;
4653
- let c = s.some((e) => !n.messages.some((t) => t.parts.some((t) => t.type === "media" && vn(t, e)))), l = o ? M(n.messages, e.threadId, e.turnId, o) : [...n.messages];
4654
- for (let t of s) l = gn(l, e.threadId, e.turnId, t, e.item.id);
4653
+ let c = s.some((e) => !n.messages.some((t) => t.parts.some((t) => t.type === "media" && yn(t, e)))), l = o ? j(n.messages, e.threadId, e.turnId, o) : [...n.messages];
4654
+ for (let t of s) l = _n(l, e.threadId, e.turnId, t, e.item.id);
4655
4655
  this.host.patchRuntime(e.threadId, { messages: l });
4656
4656
  let u = o ? this.host.messageContainingTool(e.threadId, e.turnId, o.id) : this.host.assistantMessageForTurn(e.threadId, e.turnId);
4657
4657
  u && o && this.host.emitEvent("notification", {
@@ -4690,7 +4690,7 @@ var So = class {
4690
4690
  cwd: r.cwd
4691
4691
  }
4692
4692
  } : n;
4693
- this.host.patchRuntime(e, { messages: yn(r.messages, e, t, i) });
4693
+ this.host.patchRuntime(e, { messages: bn(r.messages, e, t, i) });
4694
4694
  let a = this.host.messageContainingTool(e, t, n.itemId);
4695
4695
  a && this.host.emitEvent("notification", {
4696
4696
  type: "tool.updated",
@@ -4726,7 +4726,7 @@ var So = class {
4726
4726
  t.turnIds.includes(e.turn.id) || t.turnIds.push(e.turn.id);
4727
4727
  let n = t.activeTurnId !== e.turn.id && t.turnStartPending;
4728
4728
  t.activeTurnId === e.turn.id && (t.activeTurnId = null);
4729
- let r = n || t.activeTurnId !== null, i = e.turn.status === "failed" ? "error" : "complete", a = xn(t.messages, e.turn.id, e.turn.status).map((t) => t.metadata?.turnId === e.turn.id ? {
4729
+ let r = n || t.activeTurnId !== null, i = e.turn.status === "failed" ? "error" : "complete", a = Sn(t.messages, e.turn.id, e.turn.status).map((t) => t.metadata?.turnId === e.turn.id ? {
4730
4730
  ...t,
4731
4731
  status: i
4732
4732
  } : t).filter((t) => !(t.role === "assistant" && t.metadata?.turnId === e.turn.id && t.kind === void 0 && t.parts.length === 0));
@@ -4820,12 +4820,12 @@ var To = class {
4820
4820
  "deny"
4821
4821
  ].includes(r)) throw Error(`Invalid tool confirmation decision '${String(r)}'`);
4822
4822
  this.pending.delete(t.id);
4823
- let i = this.host.requireRuntime(n.threadId), a = Cn(i.answeredClientRequestIds, t.id);
4823
+ let i = this.host.requireRuntime(n.threadId), a = wn(i.answeredClientRequestIds, t.id);
4824
4824
  if (n.kind === "ask_user") {
4825
4825
  let e = t.payload?.answers ?? {};
4826
4826
  n.responder.resolve({ answers: e }), this.host.patchRuntime(n.threadId, {
4827
4827
  answeredClientRequestIds: a,
4828
- messages: yn(i.messages, n.threadId, n.turnId, {
4828
+ messages: bn(i.messages, n.threadId, n.turnId, {
4829
4829
  itemId: n.itemId,
4830
4830
  output: { answers: e }
4831
4831
  })
@@ -4834,7 +4834,7 @@ var To = class {
4834
4834
  let e = r;
4835
4835
  n.responder.resolve(Yt(e)), this.host.patchRuntime(n.threadId, {
4836
4836
  answeredClientRequestIds: a,
4837
- messages: yn(i.messages, n.threadId, n.displayTurnId, {
4837
+ messages: bn(i.messages, n.threadId, n.displayTurnId, {
4838
4838
  itemId: n.itemId,
4839
4839
  output: { decision: e }
4840
4840
  })
@@ -4852,7 +4852,7 @@ var To = class {
4852
4852
  }), this.host.emitConversationActivity(n.threadId, "action");
4853
4853
  }
4854
4854
  async respondToAsyncQuestion(e, t) {
4855
- let n = e ?? this.host.activeConversationId(), r = n === null ? null : this.host.requireRuntime(n), i = r && fa(r, [], []).clientRequests.find((e) => e.kind === "ask_user" && e.id === t.id), a = r && i ? {
4855
+ let n = e ?? this.host.activeConversationId(), r = n === null ? null : this.host.requireRuntime(n), i = r && ha(r, [], []).clientRequests.find((e) => e.kind === "ask_user" && e.id === t.id), a = r && i ? {
4856
4856
  request: i,
4857
4857
  runtime: r
4858
4858
  } : null;
@@ -4871,7 +4871,7 @@ var To = class {
4871
4871
  ${JSON.stringify(s)}\n</send_user_message_question_reply>`, t = s.length === 1 ? s[0].answer : s.map((e) => `${e.question}: ${e.answer}`).join("\n");
4872
4872
  await this.host.answerAsyncQuestion(a.runtime.threadId, e, t);
4873
4873
  }
4874
- this.host.patchRuntime(a.runtime.threadId, { answeredClientRequestIds: Cn(a.runtime.answeredClientRequestIds, t.id) }), this.host.emitEvent("action", {
4874
+ this.host.patchRuntime(a.runtime.threadId, { answeredClientRequestIds: wn(a.runtime.answeredClientRequestIds, t.id) }), this.host.emitEvent("action", {
4875
4875
  type: "clientRequest.resolved",
4876
4876
  conversationId: a.runtime.threadId,
4877
4877
  ...a.request.turnId ? { turnId: a.request.turnId } : {},
@@ -4886,7 +4886,7 @@ ${JSON.stringify(s)}\n</send_user_message_question_reply>`, t = s.length === 1 ?
4886
4886
  let n = this.pending.get(e);
4887
4887
  if (this.pending.delete(e), n) {
4888
4888
  let t = this.host.requireRuntime(n.threadId);
4889
- this.host.patchRuntime(n.threadId, { answeredClientRequestIds: Cn(t.answeredClientRequestIds, e) });
4889
+ this.host.patchRuntime(n.threadId, { answeredClientRequestIds: wn(t.answeredClientRequestIds, e) });
4890
4890
  }
4891
4891
  this.maybeClearWaitingBusy(t), n && this.host.emitEvent("notification", {
4892
4892
  type: "clientRequest.resolved",
@@ -4934,7 +4934,7 @@ ${JSON.stringify(s)}\n</send_user_message_question_reply>`, t = s.length === 1 ?
4934
4934
  responder: t
4935
4935
  }), this.host.patchRuntime(n, {
4936
4936
  busy: !0,
4937
- messages: M(o.messages, n, r, {
4937
+ messages: j(o.messages, n, r, {
4938
4938
  type: "tool",
4939
4939
  id: i,
4940
4940
  kind: "generic",
@@ -4976,23 +4976,23 @@ ${JSON.stringify(s)}\n</send_user_message_question_reply>`, t = s.length === 1 ?
4976
4976
  let n = e.params;
4977
4977
  if (n.mode !== "form") return !1;
4978
4978
  let r = n._meta;
4979
- if (!ln(r) || r.codex_approval_kind !== "mcp_tool_call") return !1;
4980
- let i = String(e.id), a = cn(r.tool_name) ?? cn(r.tool_title) ?? "tool", o = this.host.requireRuntime(n.threadId);
4979
+ if (!un(r) || r.codex_approval_kind !== "mcp_tool_call") return !1;
4980
+ let i = String(e.id), a = ln(r.tool_name) ?? ln(r.tool_title) ?? "tool", o = this.host.requireRuntime(n.threadId);
4981
4981
  n.turnId && this.host.markRuntimeTurnActive(o, n.turnId);
4982
- let s = n.turnId ?? o.activeTurnId ?? `client-request-${i}`, c = an(o.messages, s, n.serverName, a), l = c?.id ?? `approval-${i}`, u = n.message.trim() || `Allow ${n.serverName} to run ${a}?`, d = {
4982
+ let s = n.turnId ?? o.activeTurnId ?? `client-request-${i}`, c = on(o.messages, s, n.serverName, a), l = c?.id ?? `approval-${i}`, u = n.message.trim() || `Allow ${n.serverName} to run ${a}?`, d = {
4983
4983
  id: i,
4984
4984
  kind: "confirm_tool",
4985
4985
  conversationId: n.threadId,
4986
4986
  turnId: n.turnId,
4987
4987
  itemId: l,
4988
4988
  payload: { confirmation: {
4989
- argumentsPreview: on(r),
4989
+ argumentsPreview: sn(r),
4990
4990
  integrationId: n.serverName,
4991
- integrationName: cn(r.connector_name) ?? n.serverName,
4991
+ integrationName: ln(r.connector_name) ?? n.serverName,
4992
4992
  summary: u,
4993
4993
  toolName: a,
4994
- ...sn(r.persist, "session") ? { allowConversation: !0 } : {},
4995
- ...sn(r.persist, "always") ? { allowAlways: !0 } : {}
4994
+ ...cn(r.persist, "session") ? { allowConversation: !0 } : {},
4995
+ ...cn(r.persist, "always") ? { allowAlways: !0 } : {}
4996
4996
  } }
4997
4997
  };
4998
4998
  this.pending.set(i, {
@@ -5017,9 +5017,9 @@ ${JSON.stringify(s)}\n</send_user_message_question_reply>`, t = s.length === 1 ?
5017
5017
  params: {
5018
5018
  requestId: i,
5019
5019
  confirmationSummary: u,
5020
- argumentsPreview: on(r),
5021
- allowConversation: sn(r.persist, "session"),
5022
- allowAlways: sn(r.persist, "always")
5020
+ argumentsPreview: sn(r),
5021
+ allowConversation: cn(r.persist, "session"),
5022
+ allowAlways: cn(r.persist, "always")
5023
5023
  }
5024
5024
  }),
5025
5025
  input: r.tool_params,
@@ -5033,7 +5033,7 @@ ${JSON.stringify(s)}\n</send_user_message_question_reply>`, t = s.length === 1 ?
5033
5033
  };
5034
5034
  this.host.patchRuntime(n.threadId, {
5035
5035
  busy: !0,
5036
- messages: M(o.messages, n.threadId, s, f)
5036
+ messages: j(o.messages, n.threadId, s, f)
5037
5037
  });
5038
5038
  let p = this.host.messageContainingTool(n.threadId, s, l);
5039
5039
  return p && this.host.emitEvent("notification", {
@@ -5220,7 +5220,7 @@ var Lo = class {
5220
5220
  }
5221
5221
  async loadPermissionProfiles() {
5222
5222
  try {
5223
- let e = await this.requestPermissionProfiles(this.cwd), t = (await this.client.request("configRequirements/read", void 0)).requirements, n = wa(e, t), r = this.host.preferredApprovalPreset();
5223
+ let e = await this.requestPermissionProfiles(this.cwd), t = (await this.client.request("configRequirements/read", void 0)).requirements, n = Ea(e, t), r = this.host.preferredApprovalPreset();
5224
5224
  this.host.patch({
5225
5225
  permissionProfiles: e,
5226
5226
  approvalPresets: n,
@@ -5267,7 +5267,7 @@ var Lo = class {
5267
5267
  skills: a,
5268
5268
  skillCatalogStatus: r.status === "fulfilled" ? "loaded" : "error",
5269
5269
  permissionProfiles: o,
5270
- approvalPresets: i.status === "fulfilled" ? wa(o, i.value.requirements) : []
5270
+ approvalPresets: i.status === "fulfilled" ? Ea(o, i.value.requirements) : []
5271
5271
  };
5272
5272
  }
5273
5273
  schedulePluginRefresh(e = !1) {
@@ -5299,13 +5299,13 @@ var Lo = class {
5299
5299
  return t;
5300
5300
  }
5301
5301
  applyModels(e, t) {
5302
- let n = q(e, this.host.getState().selectedModelId);
5302
+ let n = W(e, this.host.getState().selectedModelId);
5303
5303
  this.host.patch({
5304
5304
  models: e,
5305
5305
  modelCatalogStatus: "loaded",
5306
5306
  selectedModelId: n?.id ?? null,
5307
- selectedReasoningEffort: n ? xa(n) : null,
5308
- selectedServiceTier: n ? Sa(n) : null
5307
+ selectedReasoningEffort: n ? G(n) : null,
5308
+ selectedServiceTier: n ? wa(n) : null
5309
5309
  }), this.emitModels(e, "loaded", t);
5310
5310
  }
5311
5311
  emitModels(e, t, n = "action") {
@@ -5364,7 +5364,7 @@ var Lo = class {
5364
5364
  try {
5365
5365
  let t = await this.client.request("plugin/installed", { ...e.length > 0 ? { cwds: [...e] } : {} }), n = /* @__PURE__ */ new Map();
5366
5366
  for (let e of t.marketplaces) for (let t of e.plugins) n.has(t.id) || n.set(t.id, t);
5367
- let r = Pa(this.host.getState().plugins, await Promise.all([...n.values()].map((e) => Ao(e, (e) => this.iconDataUrl(e)))));
5367
+ let r = Fa(this.host.getState().plugins, await Promise.all([...n.values()].map((e) => Ao(e, (e) => this.iconDataUrl(e)))));
5368
5368
  if (this.host.isClosed() || this.host.authenticationBlocksBootstrap()) return;
5369
5369
  this.host.patch({
5370
5370
  plugins: r,
@@ -5832,7 +5832,7 @@ var $o = class {
5832
5832
  success: !1,
5833
5833
  contentItems: [{
5834
5834
  type: "inputText",
5835
- text: A(e)
5835
+ text: k(e)
5836
5836
  }]
5837
5837
  });
5838
5838
  }
@@ -5891,8 +5891,8 @@ var $o = class {
5891
5891
  startedAt: i.startedAt ? Date.parse(i.startedAt) / 1e3 : null,
5892
5892
  completedAt: i.completedAt ? Date.parse(i.completedAt) / 1e3 : null,
5893
5893
  durationMs: i.durationMs
5894
- }, o = An(n.messages, F(e, a));
5895
- this.originalImages && (o = Ki(o));
5894
+ }, o = jn(n.messages, Mn(e, a));
5895
+ this.originalImages && (o = Yi(o));
5896
5896
  let s = n.messages.findIndex((e) => e.turnId === t), c = n.messages.filter((e) => e.turnId !== t);
5897
5897
  c.splice(s < 0 ? c.length : s, 0, ...o), this.host.patchRuntime(e, { messages: c });
5898
5898
  }
@@ -5904,7 +5904,7 @@ var $o = class {
5904
5904
  } catch (t) {
5905
5905
  throw this.host.runtime(e) === n && o({
5906
5906
  detailsLoading: !1,
5907
- detailsError: A(t)
5907
+ detailsError: k(t)
5908
5908
  }), t;
5909
5909
  } finally {
5910
5910
  this.turnLoads.get(e) === i && i.delete(t);
@@ -5935,7 +5935,7 @@ var $o = class {
5935
5935
  return await this.host.ensureConnected(), this.load();
5936
5936
  }
5937
5937
  async load() {
5938
- let e = Pa(this.host.getState().conversations, await this.requestConversations({ limit: this.conversationLimit }));
5938
+ let e = Fa(this.host.getState().conversations, await this.requestConversations({ limit: this.conversationLimit }));
5939
5939
  this.host.patch({ conversations: e }), this.host.schedulePluginRefresh(!0);
5940
5940
  for (let t of e) this.host.emitSummaryUpserted(t, "listed", "action");
5941
5941
  return this.host.getSnapshot();
@@ -5944,7 +5944,7 @@ var $o = class {
5944
5944
  return await this.host.ensureConnected(), structuredClone(await this.requestConversations(e));
5945
5945
  }
5946
5946
  async readSummary(e) {
5947
- let t = k(e);
5947
+ let t = O(e);
5948
5948
  await this.host.ensureConnected();
5949
5949
  let n = await this.client.request("thread/read", {
5950
5950
  threadId: t,
@@ -5955,20 +5955,20 @@ var $o = class {
5955
5955
  return structuredClone(r);
5956
5956
  }
5957
5957
  async archive(e) {
5958
- let t = k(e);
5958
+ let t = O(e);
5959
5959
  return await this.host.ensureConnected(), await this.client.request("thread/archive", { threadId: t }), this.host.removeThread(t, "archived", "action"), this.host.getSnapshot();
5960
5960
  }
5961
5961
  async delete(e) {
5962
- let t = k(e);
5962
+ let t = O(e);
5963
5963
  return await this.host.ensureConnected(), await this.client.request("thread/delete", { threadId: t }), this.host.removeThread(t, "deleted", "action"), this.host.getSnapshot();
5964
5964
  }
5965
5965
  async unarchive(e) {
5966
- let t = k(e);
5966
+ let t = O(e);
5967
5967
  await this.host.ensureConnected();
5968
5968
  let n = await this.client.request("thread/unarchive", { threadId: t });
5969
5969
  if (n.thread.id !== t) throw Error(`Codex thread/unarchive returned '${n.thread.id}' for requested thread '${t}'`);
5970
5970
  let r = this.summaryWithKnownTurnCount(n.thread);
5971
- return this.host.patch({ conversations: Y(this.host.getState().conversations, r) }), this.host.emitSummaryUpserted(r, "updated", "action"), this.host.getSnapshot();
5971
+ return this.host.patch({ conversations: J(this.host.getState().conversations, r) }), this.host.emitSummaryUpserted(r, "updated", "action"), this.host.getSnapshot();
5972
5972
  }
5973
5973
  hydrateCompleteHistory(e, t = {}) {
5974
5974
  if (this.host.requireRuntime(e).fullHistoryHydrated && !t.restart) return Promise.resolve();
@@ -6005,7 +6005,7 @@ var $o = class {
6005
6005
  historyHasOlder: !1
6006
6006
  });
6007
6007
  } catch (t) {
6008
- throw this.host.runtime(e) && this.host.patchRuntime(e, { error: `Could not load complete conversation history: ${A(t)}` }), t;
6008
+ throw this.host.runtime(e) && this.host.patchRuntime(e, { error: `Could not load complete conversation history: ${k(t)}` }), t;
6009
6009
  }
6010
6010
  })();
6011
6011
  return this.historyHydrations.set(e, r), r.finally(() => {
@@ -6057,7 +6057,7 @@ var $o = class {
6057
6057
  hasOlder: this.host.requireRuntime(e).historyHasOlder
6058
6058
  };
6059
6059
  } catch (t) {
6060
- throw this.host.runtime(e) && this.host.patchRuntime(e, { error: A(t) }), t;
6060
+ throw this.host.runtime(e) && this.host.patchRuntime(e, { error: k(t) }), t;
6061
6061
  } finally {
6062
6062
  this.host.runtime(e) && this.host.patchRuntime(e, { historyLoadingOlder: !1 });
6063
6063
  }
@@ -6112,8 +6112,8 @@ var $o = class {
6112
6112
  let a = /* @__PURE__ */ new Set();
6113
6113
  i.activeTurnId && a.add(i.activeTurnId);
6114
6114
  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);
6115
- 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 = An(i.messages, s.flatMap((t) => F(e, t)));
6116
- r ? d = r(d) : this.originalImages && (d = Ki(d)), this.host.patchRuntime(e, {
6115
+ 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 = jn(i.messages, s.flatMap((t) => Mn(e, t)));
6116
+ r ? d = r(d) : this.originalImages && (d = Yi(d)), this.host.patchRuntime(e, {
6117
6117
  turnIds: [...s.map((e) => e.id), ...c],
6118
6118
  turns: [...s.map((e) => Q(e)), ...l],
6119
6119
  messages: [...d, ...u]
@@ -6127,7 +6127,7 @@ var $o = class {
6127
6127
  return m && this.host.emitSummaryUpserted(m, "updated", "action"), d.filter((e) => e.turnId !== void 0 && n.has(e.turnId));
6128
6128
  }
6129
6129
  summaryWithKnownTurnCount(e) {
6130
- let t = J(e), n = this.host.runtime(e.id);
6130
+ let t = q(e), n = this.host.runtime(e.id);
6131
6131
  if (n?.hydrated) return {
6132
6132
  ...t,
6133
6133
  turnCount: n.turnIds.length
@@ -6173,7 +6173,7 @@ var os = class {
6173
6173
  }
6174
6174
  threadStartSettings(e, t) {
6175
6175
  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);
6176
- if (r) return Ea(r);
6176
+ if (r) return Da(r);
6177
6177
  let i = e.approvalMode ?? this.defaults.approvalMode, a = e.permissionMode ?? this.defaults.permissionMode ?? "read-only";
6178
6178
  return {
6179
6179
  approvalPolicy: i === "ask" ? "on-request" : "never",
@@ -6199,23 +6199,23 @@ var os = class {
6199
6199
  async update(e) {
6200
6200
  let t = this.host.getState(), n = t.activeConversationId;
6201
6201
  if (!n) {
6202
- let n = ja(t, e);
6202
+ let n = Ma(t, e);
6203
6203
  if (e.approvalPreset && !t.approvalPresets.includes(e.approvalPreset)) throw Error(`Approval preset '${e.approvalPreset}' is not available`);
6204
6204
  return this.host.patch(n), this.host.getSnapshot();
6205
6205
  }
6206
6206
  return await this.updateForThread(n, e), this.host.getSnapshot();
6207
6207
  }
6208
6208
  async updateForThread(e, t) {
6209
- let n = await this.host.ensureThreadReady(e), r = this.host.snapshotForRuntime(n), i = ja(r, t), a = n.approvalPreset !== i.approvalPreset || n.selectedModelId !== i.selectedModelId || n.selectedReasoningEffort !== i.selectedReasoningEffort || n.selectedServiceTier !== i.selectedServiceTier || n.planMode !== i.planMode;
6209
+ let n = await this.host.ensureThreadReady(e), r = this.host.snapshotForRuntime(n), i = Ma(r, t), a = n.approvalPreset !== i.approvalPreset || n.selectedModelId !== i.selectedModelId || n.selectedReasoningEffort !== i.selectedReasoningEffort || n.selectedServiceTier !== i.selectedServiceTier || n.planMode !== i.planMode;
6210
6210
  if (t.approvalPreset && !r.approvalPresets.includes(t.approvalPreset)) throw Error(`Approval preset '${t.approvalPreset}' is not available`);
6211
- let o = q(this.host.getState().models, i.selectedModelId);
6211
+ let o = W(this.host.getState().models, i.selectedModelId);
6212
6212
  await this.client.request("thread/settings/update", {
6213
6213
  threadId: e,
6214
- ...t.approvalPreset ? Da(t.approvalPreset) : {},
6214
+ ...t.approvalPreset ? Oa(t.approvalPreset) : {},
6215
6215
  ...t.modelId && o ? { model: o.model } : {},
6216
6216
  ...t.reasoningEffort || t.modelId ? { effort: i.selectedReasoningEffort } : {},
6217
6217
  ...t.serviceTier !== void 0 || t.modelId ? { serviceTier: i.selectedServiceTier } : {},
6218
- ...o && (typeof t.planMode == "boolean" || t.modelId || t.reasoningEffort) ? { collaborationMode: Ma(i.planMode, o.model, i.selectedReasoningEffort) } : {}
6218
+ ...o && (typeof t.planMode == "boolean" || t.modelId || t.reasoningEffort) ? { collaborationMode: Na(i.planMode, o.model, i.selectedReasoningEffort) } : {}
6219
6219
  }), this.host.patchRuntime(e, i), a && this.host.emitConversationSettings(e, "action");
6220
6220
  }
6221
6221
  async setGoal(e, t) {
@@ -6293,7 +6293,7 @@ var os = class {
6293
6293
  if (i.reviewThreadId !== e) throw Error(`Codex review/start returned unexpected review thread '${i.reviewThreadId}' for inline review on thread '${e}'`);
6294
6294
  let a = n.turnIds.includes(i.turn.id);
6295
6295
  n.activeTurnId = i.turn.status === "inProgress" ? i.turn.id : null, n.turnIds.includes(i.turn.id) || n.turnIds.push(i.turn.id), this.host.patchConversationTurnCount(e, n.turnIds.length, "action");
6296
- let o = F(e, i.turn).filter((e) => !n.messages.some((t) => t.id === e.id)).map((e) => e.role === "user" ? {
6296
+ let o = Mn(e, i.turn).filter((e) => !n.messages.some((t) => t.id === e.id)).map((e) => e.role === "user" ? {
6297
6297
  ...e,
6298
6298
  parts: r.type === "uncommittedChanges" ? e.parts.map((e) => e.type === "text" && e.text === "current changes" ? {
6299
6299
  ...e,
@@ -6308,7 +6308,7 @@ var os = class {
6308
6308
  busy: n.activeTurnId !== null,
6309
6309
  turnStartPending: !1,
6310
6310
  turns: $(n.turns, Q(i.turn)),
6311
- messages: n.activeTurnId ? j(s, e, i.turn.id) : s
6311
+ messages: n.activeTurnId ? A(s, e, i.turn.id) : s
6312
6312
  });
6313
6313
  for (let t of o) this.host.emitEvent("action", {
6314
6314
  type: "message.appended",
@@ -6326,7 +6326,7 @@ var os = class {
6326
6326
  throw this.host.patchRuntime(e, {
6327
6327
  busy: !1,
6328
6328
  turnStartPending: !1,
6329
- error: A(t)
6329
+ error: k(t)
6330
6330
  }), this.host.patchConversationStatus(e, "error", "action"), this.host.emitConversationActivity(e, "action"), t;
6331
6331
  }
6332
6332
  }
@@ -6355,11 +6355,11 @@ var os = class {
6355
6355
  async editTurnForThread(e, t, n, r) {
6356
6356
  let i = await this.host.ensureThreadReady(e);
6357
6357
  i.turns.find((e) => e.id === t)?.itemsView === "summary" && await this.host.loadTurnHistory?.(e, t);
6358
- let a = i.messages.find((e) => e.role === "user" && e.kind !== "steer" && za(e) === t);
6358
+ let a = i.messages.find((e) => e.role === "user" && e.kind !== "steer" && Ba(e) === t);
6359
6359
  if (!a) throw Error(`Could not find the user prompt for Codex turn '${t}'`);
6360
6360
  let o = n.trim();
6361
6361
  if (!o) throw Error("Cannot replace a turn prompt with empty content");
6362
- let s = Va(a);
6362
+ let s = Ha(a);
6363
6363
  await this.rollbackToTurn(e, t), await this.host.sendMessageToThread(e, o, {
6364
6364
  ...r,
6365
6365
  ...s.length > 0 ? { attachments: s } : {}
@@ -6372,11 +6372,11 @@ var os = class {
6372
6372
  async retryTurnForThread(e, t) {
6373
6373
  let n = await this.host.ensureThreadReady(e);
6374
6374
  n.turns.find((e) => e.id === t)?.itemsView === "summary" && await this.host.loadTurnHistory?.(e, t);
6375
- let r = n.messages.find((e) => e.role === "user" && e.kind !== "steer" && za(e) === t);
6375
+ let r = n.messages.find((e) => e.role === "user" && e.kind !== "steer" && Ba(e) === t);
6376
6376
  if (!r) throw Error("Could not find the user prompt for this turn");
6377
- let i = Ba(r);
6377
+ let i = Va(r);
6378
6378
  if (!i) throw Error("Could not find the user prompt for this turn");
6379
- let a = Va(r);
6379
+ let a = Ha(r);
6380
6380
  await this.rollbackToTurn(e, t), await this.host.sendMessageToThread(e, i, {
6381
6381
  ...r.metadata?.promptContent ? { content: ce(r.metadata.promptContent) } : {},
6382
6382
  ...a.length > 0 ? { attachments: a } : {}
@@ -6397,15 +6397,15 @@ var os = class {
6397
6397
  });
6398
6398
  if (i.thread.id !== e) throw Error(`Codex thread/revert returned '${i.thread.id}' for requested thread '${e}'`);
6399
6399
  let a = r.turnIds.slice(0, n), o = new Set(a), s = r.messages.filter((e) => {
6400
- let t = za(e);
6400
+ let t = Ba(e);
6401
6401
  return t === null || o.has(t);
6402
6402
  });
6403
6403
  r.turnIds = a, r.turns = r.turns.filter((e) => o.has(e.id)), r.activeTurnId = null;
6404
6404
  let c = {
6405
- ...J(i.thread),
6405
+ ...q(i.thread),
6406
6406
  turnCount: a.length
6407
6407
  };
6408
- this.host.patch({ conversations: Y(this.host.getState().conversations, c) }), this.host.patchRuntime(e, {
6408
+ this.host.patch({ conversations: J(this.host.getState().conversations, c) }), this.host.patchRuntime(e, {
6409
6409
  messages: s,
6410
6410
  answeredClientRequestIds: [],
6411
6411
  busy: !1,
@@ -6490,8 +6490,8 @@ var us = class {
6490
6490
  let s = Qt(i);
6491
6491
  if (s) return this.host.startReviewForThread(e, { target: s });
6492
6492
  n = {
6493
- ...Fa(this.host.snapshotForRuntime(r), n),
6494
- ...n.skills ? { skills: O(n.skills, r.skills) } : {}
6493
+ ...Ia(this.host.snapshotForRuntime(r), n),
6494
+ ...n.skills ? { skills: rn(n.skills, r.skills) } : {}
6495
6495
  }, await this.sendPromptToThread(e, i, n);
6496
6496
  }
6497
6497
  async continueInterruptedTurn() {
@@ -6514,7 +6514,7 @@ var us = class {
6514
6514
  let n = await this.client.request("turn/start", {
6515
6515
  threadId: e,
6516
6516
  input: [],
6517
- ...Na(this.host.snapshotForRuntime(t), {})
6517
+ ...Pa(this.host.snapshotForRuntime(t), {})
6518
6518
  }), r = t.turnIds.includes(n.turn.id);
6519
6519
  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");
6520
6520
  let i = n.turn.status === "inProgress";
@@ -6522,7 +6522,7 @@ var us = class {
6522
6522
  busy: i,
6523
6523
  turnStartPending: !1,
6524
6524
  turns: $(t.turns, Q(n.turn)),
6525
- messages: i ? j(t.messages, e, n.turn.id) : t.messages
6525
+ messages: i ? A(t.messages, e, n.turn.id) : t.messages
6526
6526
  }), this.host.patchConversationStatus(e, i ? "active" : "idle", "action"), i && !r && this.host.emitEvent("action", {
6527
6527
  type: "turn.started",
6528
6528
  conversationId: e,
@@ -6533,14 +6533,14 @@ var us = class {
6533
6533
  throw this.host.patchRuntime(e, {
6534
6534
  busy: !1,
6535
6535
  turnStartPending: !1,
6536
- error: A(t)
6536
+ error: k(t)
6537
6537
  }), this.host.patchConversationStatus(e, "error", "action"), this.host.emitConversationActivity(e, "action"), t;
6538
6538
  }
6539
6539
  }
6540
6540
  async sendPromptToThread(e, t, n = {}, r) {
6541
- let i = this.host.requireRuntime(e), a = Fa(this.host.snapshotForRuntime(i), n), o = en(a.content);
6541
+ let i = this.host.requireRuntime(e), a = Ia(this.host.snapshotForRuntime(i), n), o = en(a.content);
6542
6542
  o && (a.content = o);
6543
- let s = o ? ue(o) : r?.trim() || t, c = rn(O(tn(o), i.skills), O(a.skills ?? [], i.skills)), l = Ia(a.attachments ?? []);
6543
+ let s = o ? ue(o) : r?.trim() || t, c = an(rn(tn(o), i.skills), rn(a.skills ?? [], i.skills)), l = La(a.attachments ?? []);
6544
6544
  if (i.busy) {
6545
6545
  this.host.patchRuntime(e, { queuedPrompts: [...i.queuedPrompts, {
6546
6546
  id: bo(),
@@ -6556,7 +6556,7 @@ var us = class {
6556
6556
  parts: [{
6557
6557
  type: "text",
6558
6558
  text: s
6559
- }, ...l.map(Ra)],
6559
+ }, ...l.map(za)],
6560
6560
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
6561
6561
  metadata: {
6562
6562
  conversationId: e,
@@ -6584,7 +6584,7 @@ var us = class {
6584
6584
  text: le(o ?? [], t),
6585
6585
  text_elements: []
6586
6586
  },
6587
- ...l.map(La),
6587
+ ...l.map(Ra),
6588
6588
  ...nn(o),
6589
6589
  ...c.map((e) => ({
6590
6590
  type: "skill",
@@ -6592,7 +6592,7 @@ var us = class {
6592
6592
  path: e.path
6593
6593
  }))
6594
6594
  ],
6595
- ...Na(this.host.snapshotForRuntime(i), a),
6595
+ ...Pa(this.host.snapshotForRuntime(i), a),
6596
6596
  ...a.outputSchema === void 0 ? {} : { outputSchema: a.outputSchema }
6597
6597
  }), r = i.turnIds.includes(n.turn.id);
6598
6598
  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");
@@ -6608,7 +6608,7 @@ var us = class {
6608
6608
  busy: s,
6609
6609
  turnStartPending: !1,
6610
6610
  turns: $(i.turns, Q(n.turn)),
6611
- messages: s ? j(d, e, n.turn.id) : d
6611
+ messages: s ? A(d, e, n.turn.id) : d
6612
6612
  }), this.host.patchConversationStatus(e, s ? "active" : "idle", "action");
6613
6613
  let f = d.find((e) => e.id === u);
6614
6614
  f && this.host.emitEvent("action", {
@@ -6626,7 +6626,7 @@ var us = class {
6626
6626
  throw this.host.patchRuntime(e, {
6627
6627
  busy: !1,
6628
6628
  turnStartPending: !1,
6629
- error: A(t)
6629
+ error: k(t)
6630
6630
  }), this.host.patchConversationStatus(e, "error", "action"), this.host.emitConversationActivity(e, "action"), t;
6631
6631
  }
6632
6632
  }
@@ -6635,10 +6635,10 @@ var us = class {
6635
6635
  return await this.steerForThread(n, e, t), this.host.getSnapshot();
6636
6636
  }
6637
6637
  async steerForThread(e, t, n = {}, r) {
6638
- let i = await this.host.ensureThreadReady(e), a = t.trim(), o = en(n.content), s = rn(O(tn(o), i.skills), O(n.skills ?? [], i.skills)), c = o ? ue(o) : r?.trim() || a;
6638
+ let i = await this.host.ensureThreadReady(e), a = t.trim(), o = en(n.content), s = an(rn(tn(o), i.skills), rn(n.skills ?? [], i.skills)), c = o ? ue(o) : r?.trim() || a;
6639
6639
  if (!a) throw Error("Cannot steer with an empty message");
6640
6640
  if (!i.activeTurnId) throw Error("There is no active turn to steer");
6641
- let l = Ia(n.attachments ?? []), u = yo(), d = {
6641
+ let l = La(n.attachments ?? []), u = yo(), d = {
6642
6642
  id: u,
6643
6643
  kind: "steer",
6644
6644
  role: "user",
@@ -6646,7 +6646,7 @@ var us = class {
6646
6646
  parts: [{
6647
6647
  type: "text",
6648
6648
  text: c
6649
- }, ...l.map(Ra)],
6649
+ }, ...l.map(za)],
6650
6650
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
6651
6651
  turnId: i.activeTurnId,
6652
6652
  metadata: {
@@ -6658,7 +6658,7 @@ var us = class {
6658
6658
  };
6659
6659
  this.host.patchRuntime(e, {
6660
6660
  error: null,
6661
- messages: j([...i.messages, d], e, i.activeTurnId, { forceSegment: !0 })
6661
+ messages: A([...i.messages, d], e, i.activeTurnId, { forceSegment: !0 })
6662
6662
  }), this.host.emitEvent("action", {
6663
6663
  type: "message.appended",
6664
6664
  conversationId: e,
@@ -6676,7 +6676,7 @@ var us = class {
6676
6676
  text: le(o ?? [], a),
6677
6677
  text_elements: []
6678
6678
  },
6679
- ...l.map(La),
6679
+ ...l.map(Ra),
6680
6680
  ...nn(o),
6681
6681
  ...s.map((e) => ({
6682
6682
  type: "skill",
@@ -6702,14 +6702,14 @@ var us = class {
6702
6702
  turnId: t.turnId
6703
6703
  }
6704
6704
  } : e);
6705
- this.host.patchRuntime(e, { messages: N(j(r, e, t.turnId), e) }), n || this.host.emitEvent("action", {
6705
+ this.host.patchRuntime(e, { messages: M(A(r, e, t.turnId), e) }), n || this.host.emitEvent("action", {
6706
6706
  type: "turn.started",
6707
6707
  conversationId: e,
6708
6708
  turnId: t.turnId,
6709
6709
  payload: { startedAt: (/* @__PURE__ */ new Date()).toISOString() }
6710
6710
  });
6711
6711
  } catch (t) {
6712
- throw this.host.patchRuntime(e, { error: A(t) }), t;
6712
+ throw this.host.patchRuntime(e, { error: k(t) }), t;
6713
6713
  }
6714
6714
  }
6715
6715
  async answerAsyncQuestion(e, t, n) {
@@ -6739,7 +6739,7 @@ var us = class {
6739
6739
  if (e.id !== t) return e;
6740
6740
  o = !0;
6741
6741
  let n = en(r?.content);
6742
- O(tn(n), i.skills);
6742
+ rn(tn(n), i.skills);
6743
6743
  let s = {
6744
6744
  ...e.options,
6745
6745
  ...r
@@ -6777,7 +6777,7 @@ var us = class {
6777
6777
  await this.sendPromptToThread(e, n.text, n.options);
6778
6778
  } catch (r) {
6779
6779
  this.host.patchRuntime(e, {
6780
- error: A(r),
6780
+ error: k(r),
6781
6781
  queuedPrompts: [n, ...t.queuedPrompts]
6782
6782
  }), this.emitQueuedPrompts(e, "notification");
6783
6783
  }
@@ -6834,8 +6834,8 @@ var us = class {
6834
6834
  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({
6835
6835
  ...e,
6836
6836
  ...a ? { approvalPreset: a } : {}
6837
- }, r.approvalPresets), s = q(i.models, i.selectedModelId), c = e.model ? ya(i.models, e.model) : s, l = c?.model, u = e.reasoningEffort ?? (c?.id === s?.id ? i.selectedReasoningEffort : c ? xa(c) : null) ?? void 0, d = e.serviceTier === void 0 ? c?.id === s?.id ? i.selectedServiceTier ?? null : c?.defaultServiceTier ?? null : e.serviceTier;
6838
- ba(c, u), Ca(c, d);
6837
+ }, r.approvalPresets), s = W(i.models, i.selectedModelId), c = e.model ? Sa(i.models, e.model) : s, l = c?.model, u = e.reasoningEffort ?? (c?.id === s?.id ? i.selectedReasoningEffort : c ? G(c) : null) ?? void 0, d = e.serviceTier === void 0 ? c?.id === s?.id ? i.selectedServiceTier ?? null : c?.defaultServiceTier ?? null : e.serviceTier;
6838
+ Ca(c, u), Ta(c, d);
6839
6839
  let f = t.mcpServers === void 0 ? this.extensions.defaultMcpServers : Ko(t.mcpServers), p = await this.extensions.conversationExtension({
6840
6840
  operation: "start",
6841
6841
  conversationId: null,
@@ -6855,11 +6855,11 @@ var us = class {
6855
6855
  serviceName: "codex_app_sdk"
6856
6856
  });
6857
6857
  this.host.observeEmptyConversation(m.thread.id);
6858
- let h = ka(m, i.models, i);
6858
+ let h = Aa(m, i.models, i);
6859
6859
  u && (await this.client.request("thread/settings/update", {
6860
6860
  threadId: m.thread.id,
6861
6861
  effort: u,
6862
- ...c ? { collaborationMode: Ma(i.planMode, c.model, u) } : {}
6862
+ ...c ? { collaborationMode: Na(i.planMode, c.model, u) } : {}
6863
6863
  }), h.selectedReasoningEffort = u), d !== void 0 && (h.selectedServiceTier = d), c && (h.selectedModelId = c.id), a && (h.approvalPreset = a);
6864
6864
  let g = this.host.createRuntime(m.thread.id, {
6865
6865
  hydrated: !0,
@@ -6870,7 +6870,7 @@ var us = class {
6870
6870
  turnIds: [],
6871
6871
  messages: [],
6872
6872
  answeredClientRequestIds: [],
6873
- threadStatus: Wa(m.thread.status),
6873
+ threadStatus: Y(m.thread.status),
6874
6874
  ...r,
6875
6875
  ...h
6876
6876
  });
@@ -6879,10 +6879,10 @@ var us = class {
6879
6879
  ...t,
6880
6880
  mcpServers: f
6881
6881
  });
6882
- let _ = J(m.thread);
6882
+ let _ = q(m.thread);
6883
6883
  return this.host.patch({
6884
6884
  activeConversationId: m.thread.id,
6885
- conversations: Y(i.conversations, _),
6885
+ conversations: J(i.conversations, _),
6886
6886
  ...this.host.runtimeProjection(g)
6887
6887
  }), this.host.emitSummaryUpserted(_, "created", "action"), this.host.emitSelected(m.thread.id), this.emitConversationState(m.thread.id), this.host.getSnapshot();
6888
6888
  }
@@ -6938,19 +6938,19 @@ var us = class {
6938
6938
  historyLoadingOlder: !1,
6939
6939
  fullHistoryHydrated: !0,
6940
6940
  busy: !!n.activeTurnId,
6941
- threadStatus: Wa(t.thread.status)
6941
+ threadStatus: Y(t.thread.status)
6942
6942
  }), i = {
6943
- ...J(t.thread),
6943
+ ...q(t.thread),
6944
6944
  turnCount: r.turnIds.length
6945
6945
  }, a = this.host.getState();
6946
6946
  return this.host.patch({
6947
- conversations: Y(a.conversations, i),
6947
+ conversations: J(a.conversations, i),
6948
6948
  ...a.activeConversationId === e ? this.host.runtimeProjection(r) : {}
6949
6949
  }), this.host.emitSummaryUpserted(i, "updated", "action"), this.host.emitHistoryReplaced(e, "resync", "action"), this.host.emitConversationActivity(e, "action"), this.historySnapshot(e, r);
6950
6950
  } catch (t) {
6951
6951
  throw this.host.patchRuntime(e, {
6952
6952
  historyLoading: !1,
6953
- error: A(t)
6953
+ error: k(t)
6954
6954
  }), t;
6955
6955
  }
6956
6956
  }
@@ -6998,7 +6998,7 @@ var us = class {
6998
6998
  ...e,
6999
6999
  items: await as(this.client, t.thread.id, e.id),
7000
7000
  itemsView: "full"
7001
- } : 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 : Wa(t.thread.status), v = f.map((e) => _.type === "idle" && e.status === "inProgress" ? {
7001
+ } : 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 : Y(t.thread.status), v = f.map((e) => _.type === "idle" && e.status === "inProgress" ? {
7002
7002
  ...e,
7003
7003
  status: "interrupted"
7004
7004
  } : 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) ? {
@@ -7007,9 +7007,9 @@ var us = class {
7007
7007
  itemsView: "full"
7008
7008
  } : Q(e)]));
7009
7009
  for (let e of g) b.set(e.id, e);
7010
- let x = g.length > 0 ? c.activeTurnId : _.type === "active" ? un(f) : null, S = An(c.messages, v.flatMap((e) => e.itemsView === "summary" && y.has(e.id) ? c.messages.filter((t) => t.turnId === e.id) : F(t.thread.id, e))), C = new Map(S.map((e) => [e.id, e]));
7010
+ let x = g.length > 0 ? c.activeTurnId : _.type === "active" ? dn(f) : null, S = jn(c.messages, v.flatMap((e) => e.itemsView === "summary" && y.has(e.id) ? c.messages.filter((t) => t.turnId === e.id) : Mn(t.thread.id, e))), C = new Map(S.map((e) => [e.id, e]));
7011
7011
  for (let e of c.messages) u.get(e.id) !== e && C.set(e.id, e);
7012
- let ee = x ? j([...C.values()], t.thread.id, x) : [...C.values()];
7012
+ let ee = x ? A([...C.values()], t.thread.id, x) : [...C.values()];
7013
7013
  h && (ee = h(ee));
7014
7014
  let te = this.host.createRuntime(t.thread.id, {
7015
7015
  hydrated: !0,
@@ -7030,13 +7030,13 @@ var us = class {
7030
7030
  goal: n ? { ...n } : null,
7031
7031
  threadStatus: _,
7032
7032
  ...m,
7033
- ...ka(t, this.host.getState().models, this.host.snapshotForRuntime(c))
7033
+ ...Aa(t, this.host.getState().models, this.host.snapshotForRuntime(c))
7034
7034
  }), ne = {
7035
- ...J(t.thread),
7035
+ ...q(t.thread),
7036
7036
  turnCount: f.length
7037
7037
  }, re = this.host.getState();
7038
7038
  return this.host.patch({
7039
- conversations: Y(re.conversations, ne),
7039
+ conversations: J(re.conversations, ne),
7040
7040
  ...re.activeConversationId === t.thread.id ? this.host.runtimeProjection(te) : {}
7041
7041
  }), this.host.emitSummaryUpserted(ne, "resumed", "action"), this.host.emitHistoryReplaced(t.thread.id, r, "action"), this.emitConversationState(t.thread.id), s === "summary" && this.conversations.hydrateOriginalImages(t.thread.id, t.thread.path), te.loadingStrategy === "eager" && i.nextCursor !== null && this.conversations.hydrateCompleteHistory(t.thread.id, {
7042
7042
  cursor: i.nextCursor,
@@ -7045,7 +7045,7 @@ var us = class {
7045
7045
  } catch (t) {
7046
7046
  throw this.host.patchRuntime(e, {
7047
7047
  historyLoading: !1,
7048
- error: A(t)
7048
+ error: k(t)
7049
7049
  }), t;
7050
7050
  }
7051
7051
  }
@@ -7075,16 +7075,16 @@ var us = class {
7075
7075
  case "thread/started": {
7076
7076
  this.host.createRuntime(e.params.thread.id, {
7077
7077
  historyMode: e.params.thread.historyMode ?? "legacy",
7078
- threadStatus: Wa(e.params.thread.status)
7078
+ threadStatus: Y(e.params.thread.status)
7079
7079
  });
7080
- let t = J(e.params.thread);
7081
- this.host.patch({ conversations: Y(this.host.getState().conversations, t) }), this.host.emitSummaryUpserted(t, "started", "notification"), this.host.emitConversationActivity(e.params.thread.id, "notification");
7080
+ let t = q(e.params.thread);
7081
+ this.host.patch({ conversations: J(this.host.getState().conversations, t) }), this.host.emitSummaryUpserted(t, "started", "notification"), this.host.emitConversationActivity(e.params.thread.id, "notification");
7082
7082
  return;
7083
7083
  }
7084
7084
  case "thread/status/changed": {
7085
7085
  let { threadId: t, status: n } = e.params, r = this.host.requireRuntime(t), i = n.type === "systemError";
7086
7086
  (i || n.type === "idle" && !r.turnStartPending) && (r.activeTurnId = null), this.host.patchRuntime(t, {
7087
- threadStatus: Wa(n),
7087
+ threadStatus: Y(n),
7088
7088
  busy: i ? !1 : r.turnStartPending || n.type === "active" || r.activeTurnId !== null,
7089
7089
  ...i ? {
7090
7090
  turnStartPending: !1,
@@ -7106,7 +7106,7 @@ var us = class {
7106
7106
  return;
7107
7107
  case "thread/unarchived":
7108
7108
  this.conversations.load().catch((e) => {
7109
- this.host.patch({ error: A(e) });
7109
+ this.host.patch({ error: k(e) });
7110
7110
  });
7111
7111
  return;
7112
7112
  case "thread/closed": {
@@ -7136,7 +7136,7 @@ var us = class {
7136
7136
  return;
7137
7137
  }
7138
7138
  case "thread/settings/updated": {
7139
- let t = this.host.requireRuntime(e.params.threadId), n = this.host.getState(), r = Aa(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;
7139
+ let t = this.host.requireRuntime(e.params.threadId), n = this.host.getState(), r = ja(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;
7140
7140
  this.host.patchRuntime(e.params.threadId, r), i && this.host.emitConversationSettings(e.params.threadId, "notification");
7141
7141
  return;
7142
7142
  }
@@ -7158,7 +7158,7 @@ var us = class {
7158
7158
  });
7159
7159
  return;
7160
7160
  case "thread/tokenUsage/updated": {
7161
- let t = Ua(e.params.tokenUsage);
7161
+ let t = Wa(e.params.tokenUsage);
7162
7162
  this.host.patchRuntime(e.params.threadId, { contextUsage: t }), this.host.emitEvent("notification", {
7163
7163
  type: "conversation.contextUsageChanged",
7164
7164
  conversationId: e.params.threadId,
@@ -7169,8 +7169,8 @@ var us = class {
7169
7169
  conversationId: e.params.threadId,
7170
7170
  turnId: e.params.turnId,
7171
7171
  payload: { usage: {
7172
- last: Ha(e.params.tokenUsage.last),
7173
- total: Ha(e.params.tokenUsage.total),
7172
+ last: Ua(e.params.tokenUsage.last),
7173
+ total: Ua(e.params.tokenUsage.total),
7174
7174
  execution: null,
7175
7175
  model: null,
7176
7176
  observedStart: !1
@@ -7198,7 +7198,7 @@ var us = class {
7198
7198
  error: null,
7199
7199
  turnGitDiff: null,
7200
7200
  turns: $(t.turns, Q(e.params.turn)),
7201
- messages: j(t.messages, e.params.threadId, e.params.turn.id, { createdAt: ho(e.params.turn.startedAt) })
7201
+ messages: A(t.messages, e.params.threadId, e.params.turn.id, { createdAt: ho(e.params.turn.startedAt) })
7202
7202
  }), this.host.patchConversationStatus(e.params.threadId, "active"), n || this.host.emitEvent("notification", {
7203
7203
  type: "turn.started",
7204
7204
  conversationId: e.params.threadId,
@@ -7255,7 +7255,7 @@ var us = class {
7255
7255
  }
7256
7256
  case "thread/compacted": {
7257
7257
  let t = this.host.requireRuntime(e.params.threadId);
7258
- this.host.patchRuntime(e.params.threadId, { messages: bn(t.messages, e.params.threadId, e.params.turnId, "complete") });
7258
+ this.host.patchRuntime(e.params.threadId, { messages: xn(t.messages, e.params.threadId, e.params.turnId, "complete") });
7259
7259
  let n = this.host.requireRuntime(e.params.threadId).messages.find((t) => t.kind === "compaction" && t.metadata?.turnId === e.params.turnId);
7260
7260
  this.host.emitEvent("notification", {
7261
7261
  type: "context.compactionCompleted",
@@ -7311,7 +7311,7 @@ var us = class {
7311
7311
  return;
7312
7312
  }
7313
7313
  case "account/updated":
7314
- this.authentication.refresh("notification").catch((e) => this.host.patch({ error: A(e) }));
7314
+ this.authentication.refresh("notification").catch((e) => this.host.patch({ error: k(e) }));
7315
7315
  return;
7316
7316
  case "account/login/completed":
7317
7317
  this.authentication.handleLoginCompleted(e.params);
@@ -7375,7 +7375,7 @@ var us = class {
7375
7375
  this.host.emitEvent("notification", {
7376
7376
  type: "realtime.audioDelta",
7377
7377
  conversationId: e.params.threadId,
7378
- payload: { audio: aa(e.params.audio) }
7378
+ payload: { audio: ca(e.params.audio) }
7379
7379
  });
7380
7380
  return;
7381
7381
  case "thread/realtime/sdp":
@@ -7466,14 +7466,14 @@ var us = class {
7466
7466
  create(e, t = {}) {
7467
7467
  let n = this.runtimes.get(e);
7468
7468
  if (n) return Object.assign(n, t), n;
7469
- let r = da(e, this.host.getState(), t);
7469
+ let r = ma(e, this.host.getState(), t);
7470
7470
  return this.runtimes.set(e, r), r;
7471
7471
  }
7472
7472
  require(e) {
7473
7473
  return this.runtimes.get(e) ?? this.create(e);
7474
7474
  }
7475
7475
  projection(e) {
7476
- return fa(e, this.approvals.approvalsForThread(e.threadId), this.clientRequests.requestsForThread(e.threadId));
7476
+ return ha(e, this.approvals.approvalsForThread(e.threadId), this.clientRequests.requestsForThread(e.threadId));
7477
7477
  }
7478
7478
  snapshot(e) {
7479
7479
  return {
@@ -7746,7 +7746,7 @@ var vs = /* @__PURE__ */ new Set(["compaction_image_budget", "default_mode_reque
7746
7746
  } catch (e) {
7747
7747
  throw this.host.patch({
7748
7748
  status: "error",
7749
- error: A(e)
7749
+ error: k(e)
7750
7750
  }), this.host.emitSurfaceStatus("lifecycle"), e;
7751
7751
  } finally {
7752
7752
  this.connectPromise = null;
@@ -7779,7 +7779,7 @@ var vs = /* @__PURE__ */ new Set(["compaction_image_budget", "default_mode_reque
7779
7779
  }
7780
7780
  }
7781
7781
  bootstrapSurfaceData(e = !1) {
7782
- let t = ha(this.host.getState().authentication);
7782
+ let t = va(this.host.getState().authentication);
7783
7783
  if (!e && this.bootstrappedAuthenticationKey === t) return Promise.resolve();
7784
7784
  if (this.surfaceBootstrapPromise) return this.surfaceBootstrapPromise.then(() => this.bootstrapSurfaceData(e));
7785
7785
  let n = (async () => {
@@ -7909,8 +7909,8 @@ var vs = /* @__PURE__ */ new Set(["compaction_image_budget", "default_mode_reque
7909
7909
  async fork(e, t = {}, n = {}, r = {}) {
7910
7910
  let i = this.host.requireRuntime(e);
7911
7911
  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");
7912
- let a = t.cwd ?? i.cwd ?? n.cwd, o = await this.catalog.loadConversationCatalogs(a ?? void 0), s = this.host.getState(), c = t.model ? ya(s.models, t.model) : q(s.models, i.selectedModelId);
7913
- ba(c, t.reasoningEffort), Ca(c, t.serviceTier);
7912
+ let a = t.cwd ?? i.cwd ?? n.cwd, o = await this.catalog.loadConversationCatalogs(a ?? void 0), s = this.host.getState(), c = t.model ? Sa(s.models, t.model) : W(s.models, i.selectedModelId);
7913
+ Ca(c, t.reasoningEffort), Ta(c, t.serviceTier);
7914
7914
  let l = n.mcpServers === void 0 ? this.extensions.defaultMcpServers : Ko(n.mcpServers), u = await this.extensions.conversationExtension({
7915
7915
  operation: "start",
7916
7916
  conversationId: null,
@@ -7935,7 +7935,7 @@ var vs = /* @__PURE__ */ new Set(["compaction_image_budget", "default_mode_reque
7935
7935
  t.reasoningEffort && await this.client.request("thread/settings/update", {
7936
7936
  threadId: d.thread.id,
7937
7937
  effort: t.reasoningEffort,
7938
- ...c ? { collaborationMode: Ma(i.planMode, c.model, t.reasoningEffort) } : {}
7938
+ ...c ? { collaborationMode: Na(i.planMode, c.model, t.reasoningEffort) } : {}
7939
7939
  });
7940
7940
  let f = n.historyItemsView ?? i.historyItemsView ?? "full", [p, m] = await Promise.all([this.client.request("thread/turns/list", {
7941
7941
  threadId: d.thread.id,
@@ -7947,10 +7947,10 @@ var vs = /* @__PURE__ */ new Set(["compaction_image_budget", "default_mode_reque
7947
7947
  ...e,
7948
7948
  items: await as(this.client, d.thread.id, e.id),
7949
7949
  itemsView: "full"
7950
- } : e)), g = f === "full" ? await this.originalImages?.prepare(d.thread.id, d.thread.path) : void 0, _ = un(h), v = On({
7950
+ } : e)), g = f === "full" ? await this.originalImages?.prepare(d.thread.id, d.thread.path) : void 0, _ = dn(h), v = kn({
7951
7951
  ...d.thread,
7952
7952
  turns: h
7953
- }), y = _ ? j(v, d.thread.id, _) : v;
7953
+ }), y = _ ? A(v, d.thread.id, _) : v;
7954
7954
  g && (y = g(y));
7955
7955
  let b = n.loadingStrategy ?? this.loadingStrategy ?? "lazy", x = this.host.createRuntime(d.thread.id, {
7956
7956
  hydrated: !0,
@@ -7968,9 +7968,9 @@ var vs = /* @__PURE__ */ new Set(["compaction_image_budget", "default_mode_reque
7968
7968
  messages: y,
7969
7969
  busy: !!_,
7970
7970
  goal: m ? { ...m } : null,
7971
- threadStatus: Wa(d.thread.status),
7971
+ threadStatus: Y(d.thread.status),
7972
7972
  ...o,
7973
- ...ka(d, s.models, this.host.snapshotForRuntime(i))
7973
+ ...Aa(d, s.models, this.host.snapshotForRuntime(i))
7974
7974
  });
7975
7975
  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, {
7976
7976
  ...n,
@@ -7980,10 +7980,10 @@ var vs = /* @__PURE__ */ new Set(["compaction_image_budget", "default_mode_reque
7980
7980
  mcpServers: l
7981
7981
  });
7982
7982
  let S = {
7983
- ...J(d.thread),
7983
+ ...q(d.thread),
7984
7984
  turnCount: h.length
7985
7985
  };
7986
- return this.host.patch({ conversations: Y(this.host.getState().conversations, S) }), this.host.emitSummaryUpserted(S), this.host.emitHistoryReplaced(d.thread.id), this.host.emitConversationActivity(d.thread.id), this.host.emitConversationSettings(d.thread.id), this.host.emitConversationSkills(d.thread.id), this.host.emitConversationPermissions(d.thread.id), f === "summary" && this.host.hydrateOriginalImages?.(d.thread.id, d.thread.path), b === "eager" && p.nextCursor !== null && this.host.hydrateCompleteHistory(d.thread.id).catch(() => void 0), d.thread.id;
7986
+ return this.host.patch({ conversations: J(this.host.getState().conversations, S) }), this.host.emitSummaryUpserted(S), this.host.emitHistoryReplaced(d.thread.id), this.host.emitConversationActivity(d.thread.id), this.host.emitConversationSettings(d.thread.id), this.host.emitConversationSkills(d.thread.id), this.host.emitConversationPermissions(d.thread.id), f === "summary" && this.host.hydrateOriginalImages?.(d.thread.id, d.thread.path), b === "eager" && p.nextCursor !== null && this.host.hydrateCompleteHistory(d.thread.id).catch(() => void 0), d.thread.id;
7987
7987
  }
7988
7988
  async forkTurn(e, t, n = {}, r = {}) {
7989
7989
  if (!this.host.requireRuntime(e).turnIds.includes(t)) throw Error(`Cannot fork at unknown Codex turn '${t}'`);
@@ -7993,7 +7993,7 @@ var vs = /* @__PURE__ */ new Set(["compaction_image_budget", "default_mode_reque
7993
7993
  function Ss(e, t) {
7994
7994
  if (e.approvalPreset) {
7995
7995
  if (!t.includes(e.approvalPreset)) throw Error(`Approval preset '${e.approvalPreset}' is not available`);
7996
- return Ea(e.approvalPreset);
7996
+ return Da(e.approvalPreset);
7997
7997
  }
7998
7998
  return {
7999
7999
  ...e.approvalMode === void 0 ? {} : { approvalPolicy: e.approvalMode === "ask" ? "on-request" : "never" },
@@ -8022,7 +8022,7 @@ var Cs = /(?<!\[)!\[([^\]]*)\]\(([^)\s]+)(?:\s+["']([^"']*)["'])?\)/g, ws = /* @
8022
8022
  let i = e[2], a = Es(i, t);
8023
8023
  if (!a) return null;
8024
8024
  try {
8025
- let t = Un((await this.client.request("fs/readFile", { path: a })).dataBase64);
8025
+ let t = Gn((await this.client.request("fs/readFile", { path: a })).dataBase64);
8026
8026
  if (!t) return null;
8027
8027
  let n = e[0].indexOf("](") + 2;
8028
8028
  return {
@@ -8088,7 +8088,7 @@ function ks(e, t) {
8088
8088
  }
8089
8089
  var As = /<context>[\s\S]*?<\/context>\s*/g, js = /<in-app-browser-context(?:\s[^>]*)?>[\s\S]*?<\/in-app-browser-context>\s*/g, Ms = /^[ \t]*## My request for Codex:[ \t]*$/m;
8090
8090
  async function Ns(e, t) {
8091
- let n = k(t);
8091
+ let n = O(t);
8092
8092
  return {
8093
8093
  conversationId: n,
8094
8094
  prompts: Ps((await e.request("thread/turns/list", {
@@ -8133,60 +8133,63 @@ var Is = 12e4, Ls = class {
8133
8133
  let n = e.trim();
8134
8134
  if (!n) throw Error("Generation prompt cannot be empty");
8135
8135
  if (t.signal?.aborted) throw Hs();
8136
+ if (t.attachments?.some((e) => e.type !== "image")) throw Error("Utility generation accepts image attachments only");
8137
+ let r = La(t.attachments ?? []), i = Ko(t.mcpServers ?? []);
8136
8138
  await this.host.ensureConnected();
8137
- let r = this.host.getSnapshot(), i = q(r.models, r.selectedModelId), a = t.model ? ya(r.models, t.model) : i, o = a?.model, s = t.reasoningEffort ?? (a?.id === i?.id ? r.selectedReasoningEffort : a ? xa(a) : null) ?? void 0, c = t.serviceTier === void 0 ? a?.id === i?.id ? r.selectedServiceTier : a?.defaultServiceTier ?? null : t.serviceTier;
8138
- ba(a, s), Ca(a, c);
8139
- let l = await this.client.request("thread/start", {
8139
+ let a = this.host.getSnapshot(), o = W(a.models, a.selectedModelId), s = t.model ? Sa(a.models, t.model) : o, c = s?.model, l = t.reasoningEffort ?? (s?.id === o?.id ? a.selectedReasoningEffort : s ? G(s) : null) ?? void 0, u = t.serviceTier === void 0 ? s?.id === o?.id ? a.selectedServiceTier : s?.defaultServiceTier ?? null : t.serviceTier;
8140
+ Ca(s, l), Ta(s, u);
8141
+ let d = await this.client.request("thread/start", {
8140
8142
  approvalPolicy: "never",
8141
8143
  approvalsReviewer: "user",
8142
8144
  ...t.baseInstructions === void 0 ? {} : { baseInstructions: t.baseInstructions },
8143
8145
  ...t.developerInstructions === void 0 ? {} : { developerInstructions: t.developerInstructions },
8144
8146
  cwd: t.cwd ?? this.defaultCwd,
8145
8147
  dynamicTools: [],
8146
- environments: [],
8148
+ ...i.length ? { config: Zo(i) } : {},
8149
+ ...t.tools === "read-only" ? {} : { environments: [] },
8147
8150
  ephemeral: !0,
8148
- ...o ? { model: o } : {},
8151
+ ...c ? { model: c } : {},
8149
8152
  permissions: ":read-only",
8150
- serviceTier: c,
8153
+ serviceTier: u,
8151
8154
  serviceName: "codex_app_sdk",
8152
8155
  threadSource: "sdk_ephemeral_generation"
8153
- }), u = l.thread.id;
8154
- if (!l.thread.ephemeral) throw await Rs(() => this.client.request("thread/delete", { threadId: u })), Error("Codex app-server did not create an ephemeral generation thread");
8155
- if (this.hiddenThreadIds.add(u), t.signal?.aborted) throw await Rs(() => this.client.request("thread/unsubscribe", { threadId: u })), this.hiddenThreadIds.delete(u), Hs();
8156
- let d = zs();
8157
- this.pendingByThread.set(u, d);
8158
- let f = null, p = !1, m = () => d.reject(Hs());
8159
- t.signal?.addEventListener("abort", m);
8160
- let h = setTimeout(() => {
8161
- d.reject(/* @__PURE__ */ Error("Codex ephemeral generation timed out"));
8156
+ }), f = d.thread.id;
8157
+ if (!d.thread.ephemeral) throw await Rs(() => this.client.request("thread/delete", { threadId: f })), Error("Codex app-server did not create an ephemeral generation thread");
8158
+ if (this.hiddenThreadIds.add(f), t.signal?.aborted) throw await Rs(() => this.client.request("thread/unsubscribe", { threadId: f })), this.hiddenThreadIds.delete(f), Hs();
8159
+ let p = zs();
8160
+ this.pendingByThread.set(f, p);
8161
+ let m = null, h = !1, g = () => p.reject(Hs());
8162
+ t.signal?.addEventListener("abort", g);
8163
+ let _ = setTimeout(() => {
8164
+ p.reject(/* @__PURE__ */ Error("Codex ephemeral generation timed out"));
8162
8165
  }, t.timeoutMs ?? Is);
8163
8166
  try {
8164
8167
  let e = await this.client.request("turn/start", {
8165
- threadId: u,
8168
+ threadId: f,
8166
8169
  input: [{
8167
8170
  type: "text",
8168
8171
  text: n,
8169
8172
  text_elements: []
8170
- }],
8171
- environments: [],
8173
+ }, ...r.map(Ra)],
8174
+ ...t.tools === "read-only" ? {} : { environments: [] },
8172
8175
  permissions: ":read-only",
8173
- ...o ? { model: o } : {},
8174
- ...s ? { effort: s } : {},
8175
- serviceTier: c,
8176
+ ...c ? { model: c } : {},
8177
+ ...l ? { effort: l } : {},
8178
+ serviceTier: u,
8176
8179
  ...t.outputSchema === void 0 ? {} : { outputSchema: t.outputSchema }
8177
8180
  });
8178
- f = e.turn.id, d.turnId = f, Bs(d, e.turn);
8179
- let r = await d.promise;
8180
- return p = !0, r;
8181
+ m = e.turn.id, p.turnId = m, Bs(p, e.turn);
8182
+ let i = await p.promise;
8183
+ return h = !0, i;
8181
8184
  } finally {
8182
- if (clearTimeout(h), t.signal?.removeEventListener("abort", m), this.pendingByThread.delete(u), !p && f) {
8183
- let e = f;
8185
+ if (clearTimeout(_), t.signal?.removeEventListener("abort", g), this.pendingByThread.delete(f), !h && m) {
8186
+ let e = m;
8184
8187
  await Rs(() => this.client.request("turn/interrupt", {
8185
- threadId: u,
8188
+ threadId: f,
8186
8189
  turnId: e
8187
8190
  }));
8188
8191
  }
8189
- await Rs(() => this.client.request("thread/unsubscribe", { threadId: u })), this.hiddenThreadIds.delete(u);
8192
+ await Rs(() => this.client.request("thread/unsubscribe", { threadId: f })), this.hiddenThreadIds.delete(f);
8190
8193
  }
8191
8194
  }
8192
8195
  close(e = /* @__PURE__ */ Error("Codex surface closed")) {
@@ -8300,20 +8303,20 @@ var Us = class {
8300
8303
  unsubscribeToolInputRequests;
8301
8304
  unsubscribeMcpElicitationRequests;
8302
8305
  eventSequence = 0;
8303
- usage = new Ji();
8306
+ usage = new Zi();
8304
8307
  accountGeneration = 0;
8305
8308
  pendingMarkdownImageHydrations = /* @__PURE__ */ new Set();
8306
8309
  closed = !1;
8307
- state = ua(pa());
8310
+ state = pa(ga());
8308
8311
  constructor(e = {}) {
8309
8312
  this.options = e, this.extensions = new $o(e.extensions ?? [], e.mcpServers ?? [], (e) => this.lifecycle.hostOptions(e));
8310
8313
  let n = $a(e);
8311
- this.client = e.client ?? new t(Qa(n) ? new et(n) : new Ye(n), e.onListenerError ? { onListenerError: e.onListenerError } : {}), this.originalImages = e.originalHistoryImages ? new zi(this.client) : void 0, this.originalUsage = e.originalHistoryUsage ? new ea(this.client) : void 0, this.markdownImages = new Ts(this.client), this.authentication = new to(this.client, {
8314
+ this.client = e.client ?? new t(Qa(n) ? new et(n) : new Ye(n), e.onListenerError ? { onListenerError: e.onListenerError } : {}), this.originalImages = e.originalHistoryImages ? new Hi(this.client) : void 0, this.originalUsage = e.originalHistoryUsage ? new ra(this.client) : void 0, this.markdownImages = new Ts(this.client), this.authentication = new to(this.client, {
8312
8315
  bootstrapSurfaceData: (e) => this.connection.bootstrapSurfaceData(e),
8313
8316
  clearAuthenticatedSurfaceData: () => this.connection.clearAuthenticatedSurfaceData(),
8314
8317
  getSnapshot: () => this.getSnapshot(),
8315
8318
  patchAuthentication: (e, t) => this.connection.patchAuthentication(e, t),
8316
- reportError: (e) => this.patch({ error: A(e) })
8319
+ reportError: (e) => this.patch({ error: k(e) })
8317
8320
  }), this.items = new So({
8318
8321
  assistantMessageForTurn: (e, t) => this.assistantMessageForTurn(e, t),
8319
8322
  emitConversationActivity: (e, t) => this.emitConversationActivity(e, t),
@@ -8635,7 +8638,7 @@ var Us = class {
8635
8638
  return this.lifecycle.create(e, t);
8636
8639
  }
8637
8640
  async forkConversation(e, t = {}, n = {}) {
8638
- let r = k(e);
8641
+ let r = O(e);
8639
8642
  await this.ensureThreadReady(r);
8640
8643
  let i = this.lifecycle.hostOptions(r) ?? {}, a = await this.forks.fork(r, t, {
8641
8644
  ...i,
@@ -8644,7 +8647,7 @@ var Us = class {
8644
8647
  return this.conversationForkResult(a);
8645
8648
  }
8646
8649
  async forkConversationAtTurn(e, t, n = {}, r = {}) {
8647
- let i = k(e);
8650
+ let i = O(e);
8648
8651
  await this.ensureThreadReady(i);
8649
8652
  let a = this.lifecycle.hostOptions(i) ?? {}, o = await this.forks.forkTurn(i, t, n, {
8650
8653
  ...a,
@@ -8656,7 +8659,7 @@ var Us = class {
8656
8659
  return this.lifecycle.select(e);
8657
8660
  }
8658
8661
  forgetConversation(e) {
8659
- let t = k(e), n = this.state.activeConversationId === t;
8662
+ let t = O(e), n = this.state.activeConversationId === t;
8660
8663
  this.runtimeState.forget(t), this.lifecycle.forget(t), this.originalImages?.forget(t), this.conversations.forget(t), this.items.forget(t), this.conversationHandles.delete(t), this.conversationListeners.delete(t), n && this.patch({
8661
8664
  activeConversationId: null,
8662
8665
  activeTurnId: null,
@@ -8690,7 +8693,7 @@ var Us = class {
8690
8693
  if (!a()) throw Error("Conversation content is no longer available.");
8691
8694
  return r;
8692
8695
  }
8693
- return new ji(e).read({ messages: r.messages }, t, n);
8696
+ return new Pi(e).read({ messages: r.messages }, t, n);
8694
8697
  }
8695
8698
  async readConversationHistory(e = this.state.activeConversationId ?? "") {
8696
8699
  return this.lifecycle.readHistory(e);
@@ -8702,7 +8705,7 @@ var Us = class {
8702
8705
  return await this.ensureThreadReady(t), await this.conversations.loadTurnHistory(t, e), this.getConversationSnapshot(t);
8703
8706
  }
8704
8707
  async loadOlderConversationHistory(e = this.state.activeConversationId ?? "") {
8705
- return this.conversations.loadOlderHistory(k(e));
8708
+ return this.conversations.loadOlderHistory(O(e));
8706
8709
  }
8707
8710
  async renameConversation(e) {
8708
8711
  let t = this.state.activeConversationId;
@@ -8766,7 +8769,7 @@ var Us = class {
8766
8769
  return await this.approvals.resolve(void 0, e, t, n), this.getSnapshot();
8767
8770
  }
8768
8771
  conversation(e) {
8769
- let t = k(e), n = this.conversationHandles.get(t);
8772
+ let t = O(e), n = this.conversationHandles.get(t);
8770
8773
  if (n) return n;
8771
8774
  let r = no(t, {
8772
8775
  clearGoal: () => this.conversationSettings.clearGoalForThread(t),
@@ -8825,7 +8828,7 @@ var Us = class {
8825
8828
  await this.client.request("thread/realtime/stop", { threadId: e });
8826
8829
  }
8827
8830
  startRealtimeForThread(e, t) {
8828
- return ca({
8831
+ return da({
8829
8832
  client: this.client,
8830
8833
  ensureThreadReady: async () => {
8831
8834
  await this.ensureThreadReady(e);
@@ -9046,8 +9049,8 @@ var Us = class {
9046
9049
  }
9047
9050
  async requestForAccount(e, t) {
9048
9051
  await this.ensureConnected(), await this.authentication.pendingRefresh();
9049
- let n = this.accountGeneration, r = ga(this.state.authentication), i = await e();
9050
- if (this.closed || n !== this.accountGeneration || r !== ga(this.state.authentication)) throw Error("Account changed during account operation");
9052
+ let n = this.accountGeneration, r = ya(this.state.authentication), i = await e();
9053
+ if (this.closed || n !== this.accountGeneration || r !== ya(this.state.authentication)) throw Error("Account changed during account operation");
9051
9054
  return t(i);
9052
9055
  }
9053
9056
  emitEvent(e, t, n = !1) {
@@ -9488,6 +9491,6 @@ async function tc(e, t, n = {}) {
9488
9491
  };
9489
9492
  }
9490
9493
  //#endregion
9491
- export { qs as CodexAppBackend, Ks as CodexAppBackendTtlCache, Ye as CodexAppServerStdioTransport, et as CodexAppServerUnixSocketTransport, ea as CodexOriginalHistoryUsage, Us as CodexSurface, ji as ConversationContentTransport, Nn as codexItemToMediaPart, jn as codexItemToSurfaceMessage, w as codexItemToToolPart, be as codexRuntimePathEntries, On as codexThreadToSurfaceMessages, F as codexTurnToSurfaceMessages, Js as createCodexAppBackend, Ws as createCodexSurface, ye as discoverCodexExecutable, kn as preserveHistoricalAttachmentPreviews, Xs as resolveAppleSpeechAnalyzerPath, Se as resolveCodexRuntime, tc as startAppleSpeechSession, Ys as transcribeWithAppleSpeechAnalyzer, xe as withCodexRuntimePath };
9494
+ export { qs as CodexAppBackend, Ks as CodexAppBackendTtlCache, Ye as CodexAppServerStdioTransport, et as CodexAppServerUnixSocketTransport, ra as CodexOriginalHistoryUsage, Us as CodexSurface, Pi as ConversationContentTransport, Fn as codexItemToMediaPart, Nn as codexItemToSurfaceMessage, w as codexItemToToolPart, be as codexRuntimePathEntries, kn as codexThreadToSurfaceMessages, Mn as codexTurnToSurfaceMessages, Js as createCodexAppBackend, Ws as createCodexSurface, ye as discoverCodexExecutable, An as preserveHistoricalAttachmentPreviews, Xs as resolveAppleSpeechAnalyzerPath, Se as resolveCodexRuntime, tc as startAppleSpeechSession, Ys as transcribeWithAppleSpeechAnalyzer, xe as withCodexRuntimePath };
9492
9495
 
9493
9496
  //# sourceMappingURL=index.js.map