@codexhost/cli-linux-arm64 0.23.0 → 0.25.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.
Files changed (60) hide show
  1. package/README.md +1 -1
  2. package/app/codexhost-distribution.json +1 -1
  3. package/app/console-server.mjs +3968 -4082
  4. package/app/console-web.js +6822 -2065
  5. package/app/desktop-controller.mjs +13620 -2977
  6. package/app/host-runtime.mjs +12025 -12636
  7. package/app/plugins/antigravity/plugin.mjs +2382 -1452
  8. package/app/plugins/claude-code/plugin.mjs +2248 -1645
  9. package/app/plugins/codebuddy/plugin.mjs +1753 -1215
  10. package/app/plugins/codex-usage/plugin.mjs +1214 -915
  11. package/app/plugins/copilot/plugin.mjs +1239 -919
  12. package/app/plugins/cursor-cli/plugin.mjs +1549 -1099
  13. package/app/plugins/deepseek-harness/plugin.mjs +1955 -1484
  14. package/app/plugins/devin/plugin.mjs +1295 -978
  15. package/app/plugins/grok/plugin.mjs +1772 -1482
  16. package/app/plugins/hermes/plugin.mjs +1485 -1184
  17. package/app/plugins/kimi-code/plugin.mjs +1388 -1093
  18. package/app/plugins/kiro-cli/plugin.mjs +1349 -1036
  19. package/app/plugins/omp/plugin.mjs +2027 -1420
  20. package/app/plugins/opencode/plugin.mjs +2219 -1844
  21. package/app/plugins/pi/plugin.mjs +1956 -1606
  22. package/app/plugins/qoder/plugin.mjs +1536 -1229
  23. package/app/plugins/qoder-cn/plugin.mjs +1536 -1229
  24. package/app/plugins/qwen-code/plugin.mjs +1490 -1198
  25. package/app/plugins/workbuddy/plugin.mjs +1757 -1221
  26. package/app/plugins/zcode/plugin.mjs +1841 -1072
  27. package/app/renderer-extension.js +12894 -8392
  28. package/app/web/assets/index-CTCFIQbU.css +1 -0
  29. package/app/web/assets/index-DUOvhHbV.js +203 -0
  30. package/app/web/codexhost-settings.js +4811 -36168
  31. package/app/web/index.html +2 -2
  32. package/app/web/plugins/deepseek-ai__dsh-api-remotes/client.js +64 -64
  33. package/app/web/plugins/deepseek-ai__dsh-api-session-controller/client.js +69 -69
  34. package/app/web/plugins/deepseek-ai__dsh-api-workspace-controller/client.js +1 -1
  35. package/app/web/plugins/deepseek-ai__dsh-client-shortcuts/client.js +1 -1
  36. package/app/web/plugins/deepseek-ai__dsh-client-ui-approval/client.js +1 -1
  37. package/app/web/plugins/deepseek-ai__dsh-client-ui-brand-official/client.js +1 -1
  38. package/app/web/plugins/deepseek-ai__dsh-client-ui-chat/client.js +74 -74
  39. package/app/web/plugins/deepseek-ai__dsh-client-ui-codexhost/client.js +75 -64
  40. package/app/web/plugins/deepseek-ai__dsh-client-ui-conversation/client.js +98 -95
  41. package/app/web/plugins/deepseek-ai__dsh-client-ui-input-trigger/client.js +1 -1
  42. package/app/web/plugins/deepseek-ai__dsh-client-ui-layout/client.js +2 -2
  43. package/app/web/plugins/deepseek-ai__dsh-client-ui-model-selection/client.js +2 -2
  44. package/app/web/plugins/deepseek-ai__dsh-client-ui-settings-general/client.js +1 -1
  45. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar/client.js +2 -2
  46. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-documentpreview/client.js +9 -9
  47. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-files/client.js +1 -1
  48. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-right/client.js +1 -1
  49. package/app/web/plugins/deepseek-ai__dsh-client-ui-theme/client.js +1 -1
  50. package/app/web/plugins/deepseek-ai__dsh-client-ui-tool/client.js +18 -18
  51. package/app/web/plugins/deepseek-ai__dsh-client-ui-user-questions/client.js +3 -3
  52. package/app/web/plugins/deepseek-ai__dsh-client-ui-workspace/client.js +9 -9
  53. package/app/web/sw.js +8 -1
  54. package/app/web-modules/server.mjs +4752 -6790
  55. package/bin/codexhost +0 -0
  56. package/libexec/codexhost-shim +0 -0
  57. package/libexec/codexhost-updater +0 -0
  58. package/package.json +1 -1
  59. package/app/web/assets/index-DJW4bmyx.css +0 -1
  60. package/app/web/assets/index-Dyh1KzAB.js +0 -201
@@ -32,10 +32,10 @@ function executableExtensions(command, platform, environment) {
32
32
  return [""];
33
33
  return (environmentValue(environment, "PATHEXT") ?? ".COM;.EXE;.BAT;.CMD").split(";").map((extension) => extension.trim()).filter(Boolean);
34
34
  }
35
- function isExecutableFile(filePath, platform) {
35
+ function isExecutableFile(filePath2, platform) {
36
36
  try {
37
- fs.accessSync(filePath, platform === "win32" ? fs.constants.F_OK : fs.constants.X_OK);
38
- return fs.statSync(filePath).isFile();
37
+ fs.accessSync(filePath2, platform === "win32" ? fs.constants.F_OK : fs.constants.X_OK);
38
+ return fs.statSync(filePath2).isFile();
39
39
  } catch {
40
40
  return false;
41
41
  }
@@ -147,8 +147,8 @@ var VERSION_MANAGER_ROOTS = "<version-managers>";
147
147
  function installRootExtensions(platform) {
148
148
  return platform === "win32" ? [".exe", ".cmd"] : [""];
149
149
  }
150
- function resolveHomeDirectory(input) {
151
- return input.homeDirectory ?? environmentValue(input.environment, "HOME") ?? environmentValue(input.environment, "USERPROFILE") ?? os.homedir();
150
+ function resolveHomeDirectory(input2) {
151
+ return input2.homeDirectory ?? environmentValue(input2.environment, "HOME") ?? environmentValue(input2.environment, "USERPROFILE") ?? os.homedir();
152
152
  }
153
153
  function templateVariables(environment, platform, home) {
154
154
  const pathFlavor = targetPath(platform);
@@ -181,36 +181,36 @@ function expandInstallRoot(template, environment, platform, home) {
181
181
  });
182
182
  return unresolved ? void 0 : joinTemplate(platform, substituted);
183
183
  }
184
- function installRootDirectories(spec, input, dependencies, platform, home) {
184
+ function installRootDirectories(spec, input2, dependencies, platform, home) {
185
185
  const templates = (platform === "win32" ? spec.installRoots?.windows : spec.installRoots?.posix) ?? [];
186
186
  const directories = [];
187
187
  for (const template of templates) {
188
188
  if (template === VERSION_MANAGER_ROOTS) {
189
189
  directories.push(...versionManagerBinaryDirectories({
190
190
  platform,
191
- environment: input.environment,
191
+ environment: input2.environment,
192
192
  home,
193
193
  ...dependencies.subdirectories ? { subdirectories: dependencies.subdirectories } : {}
194
194
  }));
195
195
  continue;
196
196
  }
197
- const directory = expandInstallRoot(template, input.environment, platform, home);
197
+ const directory = expandInstallRoot(template, input2.environment, platform, home);
198
198
  if (directory !== void 0)
199
199
  directories.push(directory);
200
200
  }
201
201
  return directories;
202
202
  }
203
- function harnessCandidates(spec, input, dependencies = {}) {
204
- const platform = input.platform ?? process.platform;
203
+ function harnessCandidates(spec, input2, dependencies = {}) {
204
+ const platform = input2.platform ?? process.platform;
205
205
  const pathFlavor = targetPath(platform);
206
- const configured = input.command ?? (spec.commandEnvironmentVariable ? environmentValue(input.environment, spec.commandEnvironmentVariable) : void 0);
206
+ const configured = input2.command ?? (spec.commandEnvironmentVariable ? environmentValue(input2.environment, spec.commandEnvironmentVariable) : void 0);
207
207
  const command = configured ?? spec.command;
208
208
  if (pathFlavor.isAbsolute(command) || command.includes("/") || command.includes("\\")) {
209
209
  return [{ candidate: command, source: "configured" }];
210
210
  }
211
211
  const candidates = [];
212
- const extensions = executableExtensions(command, platform, input.environment);
213
- for (const directory of pathDirectories(input.environment, platform)) {
212
+ const extensions = executableExtensions(command, platform, input2.environment);
213
+ for (const directory of pathDirectories(input2.environment, platform)) {
214
214
  for (const extension of extensions) {
215
215
  candidates.push({
216
216
  candidate: pathFlavor.join(directory, command + extension),
@@ -220,8 +220,8 @@ function harnessCandidates(spec, input, dependencies = {}) {
220
220
  }
221
221
  if (configured !== void 0)
222
222
  return candidates;
223
- const home = resolveHomeDirectory(input);
224
- for (const directory of installRootDirectories(spec, input, dependencies, platform, home)) {
223
+ const home = resolveHomeDirectory(input2);
224
+ for (const directory of installRootDirectories(spec, input2, dependencies, platform, home)) {
225
225
  for (const extension of installRootExtensions(platform)) {
226
226
  candidates.push({
227
227
  candidate: pathFlavor.join(directory, spec.command + extension),
@@ -231,12 +231,12 @@ function harnessCandidates(spec, input, dependencies = {}) {
231
231
  }
232
232
  return candidates;
233
233
  }
234
- function resolveHarnessExecutable(spec, input, dependencies = {}) {
235
- const platform = input.platform ?? process.platform;
234
+ function resolveHarnessExecutable(spec, input2, dependencies = {}) {
235
+ const platform = input2.platform ?? process.platform;
236
236
  const isExecutable = dependencies.isExecutable ?? ((candidate) => isExecutableFile(candidate, platform));
237
237
  const runnable = spec.runnableCandidate ?? ((candidate) => candidate);
238
238
  const context = { platform, isExecutable };
239
- for (const { candidate, source } of harnessCandidates(spec, input, dependencies)) {
239
+ for (const { candidate, source } of harnessCandidates(spec, input2, dependencies)) {
240
240
  const executable = runnable(candidate, context);
241
241
  if (executable !== void 0 && isExecutable(executable))
242
242
  return { executable, source };
@@ -247,13 +247,13 @@ function resolveHarnessExecutable(spec, input, dependencies = {}) {
247
247
  // ../../harness-discovery/dist/installation.js
248
248
  import { execFile } from "node:child_process";
249
249
  import { homedir } from "node:os";
250
- function runInstallationCommand(command, args, environment, timeout = 3e4) {
250
+ function runInstallationCommand(command, args, environment, timeout = 3e4, cwd) {
251
251
  const env = withNodeRuntimeOnPath(environment);
252
252
  const invocation = /\.[cm]?js$/i.test(command) ? commandInvocation(process.execPath, [command, ...args], env) : commandInvocation(command, args, env);
253
253
  return new Promise((resolve, reject) => {
254
254
  const child = execFile(invocation.command, invocation.arguments, {
255
255
  env,
256
- cwd: env.HOME ?? env.USERPROFILE ?? homedir(),
256
+ cwd: cwd ?? env.HOME ?? env.USERPROFILE ?? homedir(),
257
257
  encoding: "utf8",
258
258
  timeout,
259
259
  killSignal: "SIGKILL",
@@ -275,7 +275,7 @@ function createInstallationManager(options) {
275
275
  const check2 = () => checking ??= options.check().finally(() => {
276
276
  checking = void 0;
277
277
  });
278
- return (action) => {
278
+ return (action, confirmedVersion) => {
279
279
  if (updating)
280
280
  return updating;
281
281
  if (action === "check")
@@ -286,6 +286,8 @@ function createInstallationManager(options) {
286
286
  return before;
287
287
  if (!before.canUpdate)
288
288
  throw new Error(before.message ?? "This installation cannot be updated automatically");
289
+ if ((before.latestVerifiedVersion !== void 0 || confirmedVersion !== void 0) && before.latestVersion !== confirmedVersion)
290
+ return { ...before, confirmationRequired: true };
289
291
  await options.update(before);
290
292
  const after = await check2();
291
293
  if (after.currentVersion === before.currentVersion)
@@ -1077,8 +1079,8 @@ function cached(getter) {
1077
1079
  }
1078
1080
  };
1079
1081
  }
1080
- function nullish(input) {
1081
- return input === null || input === void 0;
1082
+ function nullish(input2) {
1083
+ return input2 === null || input2 === void 0;
1082
1084
  }
1083
1085
  function cleanRegex(source) {
1084
1086
  const start = source.startsWith("^") ? 1 : 0;
@@ -1165,8 +1167,8 @@ function randomString(length = 10) {
1165
1167
  function esc(str) {
1166
1168
  return JSON.stringify(str);
1167
1169
  }
1168
- function slugify(input) {
1169
- return input.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
1170
+ function slugify(input2) {
1171
+ return input2.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
1170
1172
  }
1171
1173
  var captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {
1172
1174
  };
@@ -1571,19 +1573,19 @@ function finalizeIssue(iss, ctx, config2) {
1571
1573
  }
1572
1574
  return rest;
1573
1575
  }
1574
- function getSizableOrigin(input) {
1575
- if (input instanceof Set)
1576
+ function getSizableOrigin(input2) {
1577
+ if (input2 instanceof Set)
1576
1578
  return "set";
1577
- if (input instanceof Map)
1579
+ if (input2 instanceof Map)
1578
1580
  return "map";
1579
- if (input instanceof File)
1581
+ if (input2 instanceof File)
1580
1582
  return "file";
1581
1583
  return "unknown";
1582
1584
  }
1583
- function getLengthableOrigin(input) {
1584
- if (Array.isArray(input))
1585
+ function getLengthableOrigin(input2) {
1586
+ if (Array.isArray(input2))
1585
1587
  return "array";
1586
- if (typeof input === "string")
1588
+ if (typeof input2 === "string")
1587
1589
  return "string";
1588
1590
  return "unknown";
1589
1591
  }
@@ -1609,12 +1611,12 @@ function parsedType(data) {
1609
1611
  return t;
1610
1612
  }
1611
1613
  function issue(...args) {
1612
- const [iss, input, inst] = args;
1614
+ const [iss, input2, inst] = args;
1613
1615
  if (typeof iss === "string") {
1614
1616
  return {
1615
1617
  message: iss,
1616
1618
  code: "custom",
1617
- input,
1619
+ input: input2,
1618
1620
  inst
1619
1621
  };
1620
1622
  }
@@ -1625,8 +1627,8 @@ function cleanEnum(obj) {
1625
1627
  return Number.isNaN(Number.parseInt(k, 10));
1626
1628
  }).map((el) => el[1]);
1627
1629
  }
1628
- function base64ToUint8Array(base643) {
1629
- const binaryString = atob(base643);
1630
+ function base64ToUint8Array(base644) {
1631
+ const binaryString = atob(base644);
1630
1632
  const bytes = new Uint8Array(binaryString.length);
1631
1633
  for (let i = 0; i < binaryString.length; i++) {
1632
1634
  bytes[i] = binaryString.charCodeAt(i);
@@ -1641,9 +1643,9 @@ function uint8ArrayToBase64(bytes) {
1641
1643
  return btoa(binaryString);
1642
1644
  }
1643
1645
  function base64urlToUint8Array(base64url3) {
1644
- const base643 = base64url3.replace(/-/g, "+").replace(/_/g, "/");
1645
- const padding = "=".repeat((4 - base643.length % 4) % 4);
1646
- return base64ToUint8Array(base643 + padding);
1646
+ const base644 = base64url3.replace(/-/g, "+").replace(/_/g, "/");
1647
+ const padding = "=".repeat((4 - base644.length % 4) % 4);
1648
+ return base64ToUint8Array(base644 + padding);
1647
1649
  }
1648
1650
  function uint8ArrayToBase64url(bytes) {
1649
1651
  return uint8ArrayToBase64(bytes).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
@@ -2158,23 +2160,23 @@ var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat"
2158
2160
  bag.pattern = integer;
2159
2161
  });
2160
2162
  inst._zod.check = (payload) => {
2161
- const input = payload.value;
2163
+ const input2 = payload.value;
2162
2164
  if (isInt) {
2163
- if (!Number.isInteger(input)) {
2165
+ if (!Number.isInteger(input2)) {
2164
2166
  payload.issues.push({
2165
2167
  expected: origin,
2166
2168
  format: def.format,
2167
2169
  code: "invalid_type",
2168
2170
  continue: false,
2169
- input,
2171
+ input: input2,
2170
2172
  inst
2171
2173
  });
2172
2174
  return;
2173
2175
  }
2174
- if (!Number.isSafeInteger(input)) {
2175
- if (input > 0) {
2176
+ if (!Number.isSafeInteger(input2)) {
2177
+ if (input2 > 0) {
2176
2178
  payload.issues.push({
2177
- input,
2179
+ input: input2,
2178
2180
  code: "too_big",
2179
2181
  maximum: Number.MAX_SAFE_INTEGER,
2180
2182
  note: "Integers must be within the safe integer range.",
@@ -2185,7 +2187,7 @@ var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat"
2185
2187
  });
2186
2188
  } else {
2187
2189
  payload.issues.push({
2188
- input,
2190
+ input: input2,
2189
2191
  code: "too_small",
2190
2192
  minimum: Number.MIN_SAFE_INTEGER,
2191
2193
  note: "Integers must be within the safe integer range.",
@@ -2198,10 +2200,10 @@ var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat"
2198
2200
  return;
2199
2201
  }
2200
2202
  }
2201
- if (input < minimum) {
2203
+ if (input2 < minimum) {
2202
2204
  payload.issues.push({
2203
2205
  origin: "number",
2204
- input,
2206
+ input: input2,
2205
2207
  code: "too_small",
2206
2208
  minimum,
2207
2209
  inclusive: true,
@@ -2209,10 +2211,10 @@ var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat"
2209
2211
  continue: !def.abort
2210
2212
  });
2211
2213
  }
2212
- if (input > maximum) {
2214
+ if (input2 > maximum) {
2213
2215
  payload.issues.push({
2214
2216
  origin: "number",
2215
- input,
2217
+ input: input2,
2216
2218
  code: "too_big",
2217
2219
  maximum,
2218
2220
  inclusive: true,
@@ -2232,11 +2234,11 @@ var $ZodCheckBigIntFormat = /* @__PURE__ */ $constructor("$ZodCheckBigIntFormat"
2232
2234
  bag.maximum = maximum;
2233
2235
  });
2234
2236
  inst._zod.check = (payload) => {
2235
- const input = payload.value;
2236
- if (input < minimum) {
2237
+ const input2 = payload.value;
2238
+ if (input2 < minimum) {
2237
2239
  payload.issues.push({
2238
2240
  origin: "bigint",
2239
- input,
2241
+ input: input2,
2240
2242
  code: "too_small",
2241
2243
  minimum,
2242
2244
  inclusive: true,
@@ -2244,10 +2246,10 @@ var $ZodCheckBigIntFormat = /* @__PURE__ */ $constructor("$ZodCheckBigIntFormat"
2244
2246
  continue: !def.abort
2245
2247
  });
2246
2248
  }
2247
- if (input > maximum) {
2249
+ if (input2 > maximum) {
2248
2250
  payload.issues.push({
2249
2251
  origin: "bigint",
2250
- input,
2252
+ input: input2,
2251
2253
  code: "too_big",
2252
2254
  maximum,
2253
2255
  inclusive: true,
@@ -2270,16 +2272,16 @@ var $ZodCheckMaxSize = /* @__PURE__ */ $constructor("$ZodCheckMaxSize", (inst, d
2270
2272
  inst2._zod.bag.maximum = def.maximum;
2271
2273
  });
2272
2274
  inst._zod.check = (payload) => {
2273
- const input = payload.value;
2274
- const size = input.size;
2275
+ const input2 = payload.value;
2276
+ const size = input2.size;
2275
2277
  if (size <= def.maximum)
2276
2278
  return;
2277
2279
  payload.issues.push({
2278
- origin: getSizableOrigin(input),
2280
+ origin: getSizableOrigin(input2),
2279
2281
  code: "too_big",
2280
2282
  maximum: def.maximum,
2281
2283
  inclusive: true,
2282
- input,
2284
+ input: input2,
2283
2285
  inst,
2284
2286
  continue: !def.abort
2285
2287
  });
@@ -2298,16 +2300,16 @@ var $ZodCheckMinSize = /* @__PURE__ */ $constructor("$ZodCheckMinSize", (inst, d
2298
2300
  inst2._zod.bag.minimum = def.minimum;
2299
2301
  });
2300
2302
  inst._zod.check = (payload) => {
2301
- const input = payload.value;
2302
- const size = input.size;
2303
+ const input2 = payload.value;
2304
+ const size = input2.size;
2303
2305
  if (size >= def.minimum)
2304
2306
  return;
2305
2307
  payload.issues.push({
2306
- origin: getSizableOrigin(input),
2308
+ origin: getSizableOrigin(input2),
2307
2309
  code: "too_small",
2308
2310
  minimum: def.minimum,
2309
2311
  inclusive: true,
2310
- input,
2312
+ input: input2,
2311
2313
  inst,
2312
2314
  continue: !def.abort
2313
2315
  });
@@ -2327,13 +2329,13 @@ var $ZodCheckSizeEquals = /* @__PURE__ */ $constructor("$ZodCheckSizeEquals", (i
2327
2329
  bag.size = def.size;
2328
2330
  });
2329
2331
  inst._zod.check = (payload) => {
2330
- const input = payload.value;
2331
- const size = input.size;
2332
+ const input2 = payload.value;
2333
+ const size = input2.size;
2332
2334
  if (size === def.size)
2333
2335
  return;
2334
2336
  const tooBig = size > def.size;
2335
2337
  payload.issues.push({
2336
- origin: getSizableOrigin(input),
2338
+ origin: getSizableOrigin(input2),
2337
2339
  ...tooBig ? { code: "too_big", maximum: def.size } : { code: "too_small", minimum: def.size },
2338
2340
  inclusive: true,
2339
2341
  exact: true,
@@ -2356,17 +2358,17 @@ var $ZodCheckMaxLength = /* @__PURE__ */ $constructor("$ZodCheckMaxLength", (ins
2356
2358
  inst2._zod.bag.maximum = def.maximum;
2357
2359
  });
2358
2360
  inst._zod.check = (payload) => {
2359
- const input = payload.value;
2360
- const length = input.length;
2361
+ const input2 = payload.value;
2362
+ const length = input2.length;
2361
2363
  if (length <= def.maximum)
2362
2364
  return;
2363
- const origin = getLengthableOrigin(input);
2365
+ const origin = getLengthableOrigin(input2);
2364
2366
  payload.issues.push({
2365
2367
  origin,
2366
2368
  code: "too_big",
2367
2369
  maximum: def.maximum,
2368
2370
  inclusive: true,
2369
- input,
2371
+ input: input2,
2370
2372
  inst,
2371
2373
  continue: !def.abort
2372
2374
  });
@@ -2385,17 +2387,17 @@ var $ZodCheckMinLength = /* @__PURE__ */ $constructor("$ZodCheckMinLength", (ins
2385
2387
  inst2._zod.bag.minimum = def.minimum;
2386
2388
  });
2387
2389
  inst._zod.check = (payload) => {
2388
- const input = payload.value;
2389
- const length = input.length;
2390
+ const input2 = payload.value;
2391
+ const length = input2.length;
2390
2392
  if (length >= def.minimum)
2391
2393
  return;
2392
- const origin = getLengthableOrigin(input);
2394
+ const origin = getLengthableOrigin(input2);
2393
2395
  payload.issues.push({
2394
2396
  origin,
2395
2397
  code: "too_small",
2396
2398
  minimum: def.minimum,
2397
2399
  inclusive: true,
2398
- input,
2400
+ input: input2,
2399
2401
  inst,
2400
2402
  continue: !def.abort
2401
2403
  });
@@ -2415,11 +2417,11 @@ var $ZodCheckLengthEquals = /* @__PURE__ */ $constructor("$ZodCheckLengthEquals"
2415
2417
  bag.length = def.length;
2416
2418
  });
2417
2419
  inst._zod.check = (payload) => {
2418
- const input = payload.value;
2419
- const length = input.length;
2420
+ const input2 = payload.value;
2421
+ const length = input2.length;
2420
2422
  if (length === def.length)
2421
2423
  return;
2422
- const origin = getLengthableOrigin(input);
2424
+ const origin = getLengthableOrigin(input2);
2423
2425
  const tooBig = length > def.length;
2424
2426
  payload.issues.push({
2425
2427
  origin,
@@ -3009,8 +3011,8 @@ var $ZodBase64 = /* @__PURE__ */ $constructor("$ZodBase64", (inst, def) => {
3009
3011
  function isValidBase64URL(data) {
3010
3012
  if (!base64url.test(data))
3011
3013
  return false;
3012
- const base643 = data.replace(/[-_]/g, (c) => c === "-" ? "+" : "/");
3013
- const padded = base643.padEnd(Math.ceil(base643.length / 4) * 4, "=");
3014
+ const base644 = data.replace(/[-_]/g, (c) => c === "-" ? "+" : "/");
3015
+ const padded = base644.padEnd(Math.ceil(base644.length / 4) * 4, "=");
3014
3016
  return isValidBase64(padded);
3015
3017
  }
3016
3018
  var $ZodBase64URL = /* @__PURE__ */ $constructor("$ZodBase64URL", (inst, def) => {
@@ -3090,15 +3092,15 @@ var $ZodNumber = /* @__PURE__ */ $constructor("$ZodNumber", (inst, def) => {
3090
3092
  payload.value = Number(payload.value);
3091
3093
  } catch (_) {
3092
3094
  }
3093
- const input = payload.value;
3094
- if (typeof input === "number" && !Number.isNaN(input) && Number.isFinite(input)) {
3095
+ const input2 = payload.value;
3096
+ if (typeof input2 === "number" && !Number.isNaN(input2) && Number.isFinite(input2)) {
3095
3097
  return payload;
3096
3098
  }
3097
- const received = typeof input === "number" ? Number.isNaN(input) ? "NaN" : !Number.isFinite(input) ? "Infinity" : void 0 : void 0;
3099
+ const received = typeof input2 === "number" ? Number.isNaN(input2) ? "NaN" : !Number.isFinite(input2) ? "Infinity" : void 0 : void 0;
3098
3100
  payload.issues.push({
3099
3101
  expected: "number",
3100
3102
  code: "invalid_type",
3101
- input,
3103
+ input: input2,
3102
3104
  inst,
3103
3105
  ...received ? { received } : {}
3104
3106
  });
@@ -3118,13 +3120,13 @@ var $ZodBoolean = /* @__PURE__ */ $constructor("$ZodBoolean", (inst, def) => {
3118
3120
  payload.value = Boolean(payload.value);
3119
3121
  } catch (_) {
3120
3122
  }
3121
- const input = payload.value;
3122
- if (typeof input === "boolean")
3123
+ const input2 = payload.value;
3124
+ if (typeof input2 === "boolean")
3123
3125
  return payload;
3124
3126
  payload.issues.push({
3125
3127
  expected: "boolean",
3126
3128
  code: "invalid_type",
3127
- input,
3129
+ input: input2,
3128
3130
  inst
3129
3131
  });
3130
3132
  return payload;
@@ -3157,13 +3159,13 @@ var $ZodBigIntFormat = /* @__PURE__ */ $constructor("$ZodBigIntFormat", (inst, d
3157
3159
  var $ZodSymbol = /* @__PURE__ */ $constructor("$ZodSymbol", (inst, def) => {
3158
3160
  $ZodType.init(inst, def);
3159
3161
  inst._zod.parse = (payload, _ctx) => {
3160
- const input = payload.value;
3161
- if (typeof input === "symbol")
3162
+ const input2 = payload.value;
3163
+ if (typeof input2 === "symbol")
3162
3164
  return payload;
3163
3165
  payload.issues.push({
3164
3166
  expected: "symbol",
3165
3167
  code: "invalid_type",
3166
- input,
3168
+ input: input2,
3167
3169
  inst
3168
3170
  });
3169
3171
  return payload;
@@ -3174,13 +3176,13 @@ var $ZodUndefined = /* @__PURE__ */ $constructor("$ZodUndefined", (inst, def) =>
3174
3176
  inst._zod.pattern = _undefined;
3175
3177
  inst._zod.values = /* @__PURE__ */ new Set([void 0]);
3176
3178
  inst._zod.parse = (payload, _ctx) => {
3177
- const input = payload.value;
3178
- if (typeof input === "undefined")
3179
+ const input2 = payload.value;
3180
+ if (typeof input2 === "undefined")
3179
3181
  return payload;
3180
3182
  payload.issues.push({
3181
3183
  expected: "undefined",
3182
3184
  code: "invalid_type",
3183
- input,
3185
+ input: input2,
3184
3186
  inst
3185
3187
  });
3186
3188
  return payload;
@@ -3191,13 +3193,13 @@ var $ZodNull = /* @__PURE__ */ $constructor("$ZodNull", (inst, def) => {
3191
3193
  inst._zod.pattern = _null;
3192
3194
  inst._zod.values = /* @__PURE__ */ new Set([null]);
3193
3195
  inst._zod.parse = (payload, _ctx) => {
3194
- const input = payload.value;
3195
- if (input === null)
3196
+ const input2 = payload.value;
3197
+ if (input2 === null)
3196
3198
  return payload;
3197
3199
  payload.issues.push({
3198
3200
  expected: "null",
3199
3201
  code: "invalid_type",
3200
- input,
3202
+ input: input2,
3201
3203
  inst
3202
3204
  });
3203
3205
  return payload;
@@ -3226,13 +3228,13 @@ var $ZodNever = /* @__PURE__ */ $constructor("$ZodNever", (inst, def) => {
3226
3228
  var $ZodVoid = /* @__PURE__ */ $constructor("$ZodVoid", (inst, def) => {
3227
3229
  $ZodType.init(inst, def);
3228
3230
  inst._zod.parse = (payload, _ctx) => {
3229
- const input = payload.value;
3230
- if (typeof input === "undefined")
3231
+ const input2 = payload.value;
3232
+ if (typeof input2 === "undefined")
3231
3233
  return payload;
3232
3234
  payload.issues.push({
3233
3235
  expected: "void",
3234
3236
  code: "invalid_type",
3235
- input,
3237
+ input: input2,
3236
3238
  inst
3237
3239
  });
3238
3240
  return payload;
@@ -3247,15 +3249,15 @@ var $ZodDate = /* @__PURE__ */ $constructor("$ZodDate", (inst, def) => {
3247
3249
  } catch (_err) {
3248
3250
  }
3249
3251
  }
3250
- const input = payload.value;
3251
- const isDate = input instanceof Date;
3252
- const isValidDate = isDate && !Number.isNaN(input.getTime());
3252
+ const input2 = payload.value;
3253
+ const isDate = input2 instanceof Date;
3254
+ const isValidDate = isDate && !Number.isNaN(input2.getTime());
3253
3255
  if (isValidDate)
3254
3256
  return payload;
3255
3257
  payload.issues.push({
3256
3258
  expected: "date",
3257
3259
  code: "invalid_type",
3258
- input,
3260
+ input: input2,
3259
3261
  ...isDate ? { received: "Invalid Date" } : {},
3260
3262
  inst
3261
3263
  });
@@ -3271,20 +3273,20 @@ function handleArrayResult(result, final, index) {
3271
3273
  var $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
3272
3274
  $ZodType.init(inst, def);
3273
3275
  inst._zod.parse = (payload, ctx) => {
3274
- const input = payload.value;
3275
- if (!Array.isArray(input)) {
3276
+ const input2 = payload.value;
3277
+ if (!Array.isArray(input2)) {
3276
3278
  payload.issues.push({
3277
3279
  expected: "array",
3278
3280
  code: "invalid_type",
3279
- input,
3281
+ input: input2,
3280
3282
  inst
3281
3283
  });
3282
3284
  return payload;
3283
3285
  }
3284
- payload.value = Array(input.length);
3286
+ payload.value = Array(input2.length);
3285
3287
  const proms = [];
3286
- for (let i = 0; i < input.length; i++) {
3287
- const item = input[i];
3288
+ for (let i = 0; i < input2.length; i++) {
3289
+ const item = input2[i];
3288
3290
  const result = def.element._zod.run({
3289
3291
  value: item,
3290
3292
  issues: []
@@ -3301,8 +3303,8 @@ var $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
3301
3303
  return payload;
3302
3304
  };
3303
3305
  });
3304
- function handlePropertyResult(result, final, key, input, isOptionalIn, isOptionalOut) {
3305
- const isPresent = key in input;
3306
+ function handlePropertyResult(result, final, key, input2, isOptionalIn, isOptionalOut) {
3307
+ const isPresent = key in input2;
3306
3308
  if (result.issues.length) {
3307
3309
  if (isOptionalIn && isOptionalOut && !isPresent) {
3308
3310
  return;
@@ -3344,14 +3346,14 @@ function normalizeDef(def) {
3344
3346
  optionalKeys: new Set(okeys)
3345
3347
  };
3346
3348
  }
3347
- function handleCatchall(proms, input, payload, ctx, def, inst) {
3349
+ function handleCatchall(proms, input2, payload, ctx, def, inst) {
3348
3350
  const unrecognized = [];
3349
3351
  const keySet = def.keySet;
3350
3352
  const _catchall = def.catchall._zod;
3351
3353
  const t = _catchall.def.type;
3352
3354
  const isOptionalIn = _catchall.optin === "optional";
3353
3355
  const isOptionalOut = _catchall.optout === "optional";
3354
- for (const key in input) {
3356
+ for (const key in input2) {
3355
3357
  if (key === "__proto__")
3356
3358
  continue;
3357
3359
  if (keySet.has(key))
@@ -3360,18 +3362,18 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
3360
3362
  unrecognized.push(key);
3361
3363
  continue;
3362
3364
  }
3363
- const r = _catchall.run({ value: input[key], issues: [] }, ctx);
3365
+ const r = _catchall.run({ value: input2[key], issues: [] }, ctx);
3364
3366
  if (r instanceof Promise) {
3365
- proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input, isOptionalIn, isOptionalOut)));
3367
+ proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input2, isOptionalIn, isOptionalOut)));
3366
3368
  } else {
3367
- handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut);
3369
+ handlePropertyResult(r, payload, key, input2, isOptionalIn, isOptionalOut);
3368
3370
  }
3369
3371
  }
3370
3372
  if (unrecognized.length) {
3371
3373
  payload.issues.push({
3372
3374
  code: "unrecognized_keys",
3373
3375
  keys: unrecognized,
3374
- input,
3376
+ input: input2,
3375
3377
  inst
3376
3378
  });
3377
3379
  }
@@ -3415,12 +3417,12 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
3415
3417
  let value;
3416
3418
  inst._zod.parse = (payload, ctx) => {
3417
3419
  value ?? (value = _normalized.value);
3418
- const input = payload.value;
3419
- if (!isObject2(input)) {
3420
+ const input2 = payload.value;
3421
+ if (!isObject2(input2)) {
3420
3422
  payload.issues.push({
3421
3423
  expected: "object",
3422
3424
  code: "invalid_type",
3423
- input,
3425
+ input: input2,
3424
3426
  inst
3425
3427
  });
3426
3428
  return payload;
@@ -3432,17 +3434,17 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
3432
3434
  const el = shape[key];
3433
3435
  const isOptionalIn = el._zod.optin === "optional";
3434
3436
  const isOptionalOut = el._zod.optout === "optional";
3435
- const r = el._zod.run({ value: input[key], issues: [] }, ctx);
3437
+ const r = el._zod.run({ value: input2[key], issues: [] }, ctx);
3436
3438
  if (r instanceof Promise) {
3437
- proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input, isOptionalIn, isOptionalOut)));
3439
+ proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input2, isOptionalIn, isOptionalOut)));
3438
3440
  } else {
3439
- handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut);
3441
+ handlePropertyResult(r, payload, key, input2, isOptionalIn, isOptionalOut);
3440
3442
  }
3441
3443
  }
3442
3444
  if (!catchall) {
3443
3445
  return proms.length ? Promise.all(proms).then(() => payload) : payload;
3444
3446
  }
3445
- return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
3447
+ return handleCatchall(proms, input2, payload, ctx, _normalized.value, inst);
3446
3448
  };
3447
3449
  });
3448
3450
  var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) => {
@@ -3464,42 +3466,42 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
3464
3466
  }
3465
3467
  doc.write(`const newResult = {};`);
3466
3468
  for (const key of normalized.keys) {
3467
- const id = ids[key];
3469
+ const id2 = ids[key];
3468
3470
  const k = esc(key);
3469
3471
  const schema = shape[key];
3470
3472
  const isOptionalIn = schema?._zod?.optin === "optional";
3471
3473
  const isOptionalOut = schema?._zod?.optout === "optional";
3472
- doc.write(`const ${id} = ${parseStr(key)};`);
3474
+ doc.write(`const ${id2} = ${parseStr(key)};`);
3473
3475
  if (isOptionalIn && isOptionalOut) {
3474
3476
  doc.write(`
3475
- if (${id}.issues.length) {
3477
+ if (${id2}.issues.length) {
3476
3478
  if (${k} in input) {
3477
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
3479
+ payload.issues = payload.issues.concat(${id2}.issues.map(iss => ({
3478
3480
  ...iss,
3479
3481
  path: iss.path ? [${k}, ...iss.path] : [${k}]
3480
3482
  })));
3481
3483
  }
3482
3484
  }
3483
3485
 
3484
- if (${id}.value === undefined) {
3486
+ if (${id2}.value === undefined) {
3485
3487
  if (${k} in input) {
3486
3488
  newResult[${k}] = undefined;
3487
3489
  }
3488
3490
  } else {
3489
- newResult[${k}] = ${id}.value;
3491
+ newResult[${k}] = ${id2}.value;
3490
3492
  }
3491
3493
 
3492
3494
  `);
3493
3495
  } else if (!isOptionalIn) {
3494
3496
  doc.write(`
3495
- const ${id}_present = ${k} in input;
3496
- if (${id}.issues.length) {
3497
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
3497
+ const ${id2}_present = ${k} in input;
3498
+ if (${id2}.issues.length) {
3499
+ payload.issues = payload.issues.concat(${id2}.issues.map(iss => ({
3498
3500
  ...iss,
3499
3501
  path: iss.path ? [${k}, ...iss.path] : [${k}]
3500
3502
  })));
3501
3503
  }
3502
- if (!${id}_present && !${id}.issues.length) {
3504
+ if (!${id2}_present && !${id2}.issues.length) {
3503
3505
  payload.issues.push({
3504
3506
  code: "invalid_type",
3505
3507
  expected: "nonoptional",
@@ -3508,30 +3510,30 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
3508
3510
  });
3509
3511
  }
3510
3512
 
3511
- if (${id}_present) {
3512
- if (${id}.value === undefined) {
3513
+ if (${id2}_present) {
3514
+ if (${id2}.value === undefined) {
3513
3515
  newResult[${k}] = undefined;
3514
3516
  } else {
3515
- newResult[${k}] = ${id}.value;
3517
+ newResult[${k}] = ${id2}.value;
3516
3518
  }
3517
3519
  }
3518
3520
 
3519
3521
  `);
3520
3522
  } else {
3521
3523
  doc.write(`
3522
- if (${id}.issues.length) {
3523
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
3524
+ if (${id2}.issues.length) {
3525
+ payload.issues = payload.issues.concat(${id2}.issues.map(iss => ({
3524
3526
  ...iss,
3525
3527
  path: iss.path ? [${k}, ...iss.path] : [${k}]
3526
3528
  })));
3527
3529
  }
3528
3530
 
3529
- if (${id}.value === undefined) {
3531
+ if (${id2}.value === undefined) {
3530
3532
  if (${k} in input) {
3531
3533
  newResult[${k}] = undefined;
3532
3534
  }
3533
3535
  } else {
3534
- newResult[${k}] = ${id}.value;
3536
+ newResult[${k}] = ${id2}.value;
3535
3537
  }
3536
3538
 
3537
3539
  `);
@@ -3551,12 +3553,12 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
3551
3553
  let value;
3552
3554
  inst._zod.parse = (payload, ctx) => {
3553
3555
  value ?? (value = _normalized.value);
3554
- const input = payload.value;
3555
- if (!isObject2(input)) {
3556
+ const input2 = payload.value;
3557
+ if (!isObject2(input2)) {
3556
3558
  payload.issues.push({
3557
3559
  expected: "object",
3558
3560
  code: "invalid_type",
3559
- input,
3561
+ input: input2,
3560
3562
  inst
3561
3563
  });
3562
3564
  return payload;
@@ -3567,7 +3569,7 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
3567
3569
  payload = fastpass(payload, ctx);
3568
3570
  if (!catchall)
3569
3571
  return payload;
3570
- return handleCatchall([], input, payload, ctx, value, inst);
3572
+ return handleCatchall([], input2, payload, ctx, value, inst);
3571
3573
  }
3572
3574
  return superParse(payload, ctx);
3573
3575
  };
@@ -3727,17 +3729,17 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
3727
3729
  return map2;
3728
3730
  });
3729
3731
  inst._zod.parse = (payload, ctx) => {
3730
- const input = payload.value;
3731
- if (!isObject(input)) {
3732
+ const input2 = payload.value;
3733
+ if (!isObject(input2)) {
3732
3734
  payload.issues.push({
3733
3735
  code: "invalid_type",
3734
3736
  expected: "object",
3735
- input,
3737
+ input: input2,
3736
3738
  inst
3737
3739
  });
3738
3740
  return payload;
3739
3741
  }
3740
- const opt = disc.value.get(input?.[def.discriminator]);
3742
+ const opt = disc.value.get(input2?.[def.discriminator]);
3741
3743
  if (opt) {
3742
3744
  return opt._zod.run(payload, ctx);
3743
3745
  }
@@ -3750,7 +3752,7 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
3750
3752
  note: "No matching discriminator",
3751
3753
  discriminator: def.discriminator,
3752
3754
  options: Array.from(disc.value.keys()),
3753
- input,
3755
+ input: input2,
3754
3756
  path: [def.discriminator],
3755
3757
  inst
3756
3758
  });
@@ -3760,9 +3762,9 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
3760
3762
  var $ZodIntersection = /* @__PURE__ */ $constructor("$ZodIntersection", (inst, def) => {
3761
3763
  $ZodType.init(inst, def);
3762
3764
  inst._zod.parse = (payload, ctx) => {
3763
- const input = payload.value;
3764
- const left = def.left._zod.run({ value: input, issues: [] }, ctx);
3765
- const right = def.right._zod.run({ value: input, issues: [] }, ctx);
3765
+ const input2 = payload.value;
3766
+ const left = def.left._zod.run({ value: input2, issues: [] }, ctx);
3767
+ const right = def.right._zod.run({ value: input2, issues: [] }, ctx);
3766
3768
  const async = left instanceof Promise || right instanceof Promise;
3767
3769
  if (async) {
3768
3770
  return Promise.all([left, right]).then(([left2, right2]) => {
@@ -3859,10 +3861,10 @@ var $ZodTuple = /* @__PURE__ */ $constructor("$ZodTuple", (inst, def) => {
3859
3861
  $ZodType.init(inst, def);
3860
3862
  const items = def.items;
3861
3863
  inst._zod.parse = (payload, ctx) => {
3862
- const input = payload.value;
3863
- if (!Array.isArray(input)) {
3864
+ const input2 = payload.value;
3865
+ if (!Array.isArray(input2)) {
3864
3866
  payload.issues.push({
3865
- input,
3867
+ input: input2,
3866
3868
  inst,
3867
3869
  expected: "tuple",
3868
3870
  code: "invalid_type"
@@ -3874,23 +3876,23 @@ var $ZodTuple = /* @__PURE__ */ $constructor("$ZodTuple", (inst, def) => {
3874
3876
  const optinStart = getTupleOptStart(items, "optin");
3875
3877
  const optoutStart = getTupleOptStart(items, "optout");
3876
3878
  if (!def.rest) {
3877
- if (input.length < optinStart) {
3879
+ if (input2.length < optinStart) {
3878
3880
  payload.issues.push({
3879
3881
  code: "too_small",
3880
3882
  minimum: optinStart,
3881
3883
  inclusive: true,
3882
- input,
3884
+ input: input2,
3883
3885
  inst,
3884
3886
  origin: "array"
3885
3887
  });
3886
3888
  return payload;
3887
3889
  }
3888
- if (input.length > items.length) {
3890
+ if (input2.length > items.length) {
3889
3891
  payload.issues.push({
3890
3892
  code: "too_big",
3891
3893
  maximum: items.length,
3892
3894
  inclusive: true,
3893
- input,
3895
+ input: input2,
3894
3896
  inst,
3895
3897
  origin: "array"
3896
3898
  });
@@ -3898,7 +3900,7 @@ var $ZodTuple = /* @__PURE__ */ $constructor("$ZodTuple", (inst, def) => {
3898
3900
  }
3899
3901
  const itemResults = new Array(items.length);
3900
3902
  for (let i = 0; i < items.length; i++) {
3901
- const r = items[i]._zod.run({ value: input[i], issues: [] }, ctx);
3903
+ const r = items[i]._zod.run({ value: input2[i], issues: [] }, ctx);
3902
3904
  if (r instanceof Promise) {
3903
3905
  proms.push(r.then((rr) => {
3904
3906
  itemResults[i] = rr;
@@ -3909,7 +3911,7 @@ var $ZodTuple = /* @__PURE__ */ $constructor("$ZodTuple", (inst, def) => {
3909
3911
  }
3910
3912
  if (def.rest) {
3911
3913
  let i = items.length - 1;
3912
- const rest = input.slice(items.length);
3914
+ const rest = input2.slice(items.length);
3913
3915
  for (const el of rest) {
3914
3916
  i++;
3915
3917
  const result = def.rest._zod.run({ value: el, issues: [] }, ctx);
@@ -3921,9 +3923,9 @@ var $ZodTuple = /* @__PURE__ */ $constructor("$ZodTuple", (inst, def) => {
3921
3923
  }
3922
3924
  }
3923
3925
  if (proms.length) {
3924
- return Promise.all(proms).then(() => handleTupleResults(itemResults, payload, items, input, optoutStart));
3926
+ return Promise.all(proms).then(() => handleTupleResults(itemResults, payload, items, input2, optoutStart));
3925
3927
  }
3926
- return handleTupleResults(itemResults, payload, items, input, optoutStart);
3928
+ return handleTupleResults(itemResults, payload, items, input2, optoutStart);
3927
3929
  };
3928
3930
  });
3929
3931
  function getTupleOptStart(items, key) {
@@ -3939,10 +3941,10 @@ function handleTupleResult(result, final, index) {
3939
3941
  }
3940
3942
  final.value[index] = result.value;
3941
3943
  }
3942
- function handleTupleResults(itemResults, final, items, input, optoutStart) {
3944
+ function handleTupleResults(itemResults, final, items, input2, optoutStart) {
3943
3945
  for (let i = 0; i < items.length; i++) {
3944
3946
  const r = itemResults[i];
3945
- const isPresent = i < input.length;
3947
+ const isPresent = i < input2.length;
3946
3948
  if (r.issues.length) {
3947
3949
  if (!isPresent && i >= optoutStart) {
3948
3950
  final.value.length = i;
@@ -3952,7 +3954,7 @@ function handleTupleResults(itemResults, final, items, input, optoutStart) {
3952
3954
  }
3953
3955
  final.value[i] = r.value;
3954
3956
  }
3955
- for (let i = final.value.length - 1; i >= input.length; i--) {
3957
+ for (let i = final.value.length - 1; i >= input2.length; i--) {
3956
3958
  if (items[i]._zod.optout === "optional" && final.value[i] === void 0) {
3957
3959
  final.value.length = i;
3958
3960
  } else {
@@ -3964,12 +3966,12 @@ function handleTupleResults(itemResults, final, items, input, optoutStart) {
3964
3966
  var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
3965
3967
  $ZodType.init(inst, def);
3966
3968
  inst._zod.parse = (payload, ctx) => {
3967
- const input = payload.value;
3968
- if (!isPlainObject(input)) {
3969
+ const input2 = payload.value;
3970
+ if (!isPlainObject(input2)) {
3969
3971
  payload.issues.push({
3970
3972
  expected: "record",
3971
3973
  code: "invalid_type",
3972
- input,
3974
+ input: input2,
3973
3975
  inst
3974
3976
  });
3975
3977
  return payload;
@@ -3998,7 +4000,7 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
3998
4000
  continue;
3999
4001
  }
4000
4002
  const outKey = keyResult.value;
4001
- const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
4003
+ const result = def.valueType._zod.run({ value: input2[key], issues: [] }, ctx);
4002
4004
  if (result instanceof Promise) {
4003
4005
  proms.push(result.then((result2) => {
4004
4006
  if (result2.issues.length) {
@@ -4015,7 +4017,7 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
4015
4017
  }
4016
4018
  }
4017
4019
  let unrecognized;
4018
- for (const key in input) {
4020
+ for (const key in input2) {
4019
4021
  if (!recordKeys.has(key)) {
4020
4022
  unrecognized = unrecognized ?? [];
4021
4023
  unrecognized.push(key);
@@ -4024,17 +4026,17 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
4024
4026
  if (unrecognized && unrecognized.length > 0) {
4025
4027
  payload.issues.push({
4026
4028
  code: "unrecognized_keys",
4027
- input,
4029
+ input: input2,
4028
4030
  inst,
4029
4031
  keys: unrecognized
4030
4032
  });
4031
4033
  }
4032
4034
  } else {
4033
4035
  payload.value = {};
4034
- for (const key of Reflect.ownKeys(input)) {
4036
+ for (const key of Reflect.ownKeys(input2)) {
4035
4037
  if (key === "__proto__")
4036
4038
  continue;
4037
- if (!Object.prototype.propertyIsEnumerable.call(input, key))
4039
+ if (!Object.prototype.propertyIsEnumerable.call(input2, key))
4038
4040
  continue;
4039
4041
  let keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
4040
4042
  if (keyResult instanceof Promise) {
@@ -4052,7 +4054,7 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
4052
4054
  }
4053
4055
  if (keyResult.issues.length) {
4054
4056
  if (def.mode === "loose") {
4055
- payload.value[key] = input[key];
4057
+ payload.value[key] = input2[key];
4056
4058
  } else {
4057
4059
  payload.issues.push({
4058
4060
  code: "invalid_key",
@@ -4065,7 +4067,7 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
4065
4067
  }
4066
4068
  continue;
4067
4069
  }
4068
- const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
4070
+ const result = def.valueType._zod.run({ value: input2[key], issues: [] }, ctx);
4069
4071
  if (result instanceof Promise) {
4070
4072
  proms.push(result.then((result2) => {
4071
4073
  if (result2.issues.length) {
@@ -4090,27 +4092,27 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
4090
4092
  var $ZodMap = /* @__PURE__ */ $constructor("$ZodMap", (inst, def) => {
4091
4093
  $ZodType.init(inst, def);
4092
4094
  inst._zod.parse = (payload, ctx) => {
4093
- const input = payload.value;
4094
- if (!(input instanceof Map)) {
4095
+ const input2 = payload.value;
4096
+ if (!(input2 instanceof Map)) {
4095
4097
  payload.issues.push({
4096
4098
  expected: "map",
4097
4099
  code: "invalid_type",
4098
- input,
4100
+ input: input2,
4099
4101
  inst
4100
4102
  });
4101
4103
  return payload;
4102
4104
  }
4103
4105
  const proms = [];
4104
4106
  payload.value = /* @__PURE__ */ new Map();
4105
- for (const [key, value] of input) {
4107
+ for (const [key, value] of input2) {
4106
4108
  const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
4107
4109
  const valueResult = def.valueType._zod.run({ value, issues: [] }, ctx);
4108
4110
  if (keyResult instanceof Promise || valueResult instanceof Promise) {
4109
4111
  proms.push(Promise.all([keyResult, valueResult]).then(([keyResult2, valueResult2]) => {
4110
- handleMapResult(keyResult2, valueResult2, payload, key, input, inst, ctx);
4112
+ handleMapResult(keyResult2, valueResult2, payload, key, input2, inst, ctx);
4111
4113
  }));
4112
4114
  } else {
4113
- handleMapResult(keyResult, valueResult, payload, key, input, inst, ctx);
4115
+ handleMapResult(keyResult, valueResult, payload, key, input2, inst, ctx);
4114
4116
  }
4115
4117
  }
4116
4118
  if (proms.length)
@@ -4118,7 +4120,7 @@ var $ZodMap = /* @__PURE__ */ $constructor("$ZodMap", (inst, def) => {
4118
4120
  return payload;
4119
4121
  };
4120
4122
  });
4121
- function handleMapResult(keyResult, valueResult, final, key, input, inst, ctx) {
4123
+ function handleMapResult(keyResult, valueResult, final, key, input2, inst, ctx) {
4122
4124
  if (keyResult.issues.length) {
4123
4125
  if (propertyKeyTypes.has(typeof key)) {
4124
4126
  final.issues.push(...prefixIssues(key, keyResult.issues));
@@ -4126,7 +4128,7 @@ function handleMapResult(keyResult, valueResult, final, key, input, inst, ctx) {
4126
4128
  final.issues.push({
4127
4129
  code: "invalid_key",
4128
4130
  origin: "map",
4129
- input,
4131
+ input: input2,
4130
4132
  inst,
4131
4133
  issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx, config()))
4132
4134
  });
@@ -4139,7 +4141,7 @@ function handleMapResult(keyResult, valueResult, final, key, input, inst, ctx) {
4139
4141
  final.issues.push({
4140
4142
  origin: "map",
4141
4143
  code: "invalid_element",
4142
- input,
4144
+ input: input2,
4143
4145
  inst,
4144
4146
  key,
4145
4147
  issues: valueResult.issues.map((iss) => finalizeIssue(iss, ctx, config()))
@@ -4151,10 +4153,10 @@ function handleMapResult(keyResult, valueResult, final, key, input, inst, ctx) {
4151
4153
  var $ZodSet = /* @__PURE__ */ $constructor("$ZodSet", (inst, def) => {
4152
4154
  $ZodType.init(inst, def);
4153
4155
  inst._zod.parse = (payload, ctx) => {
4154
- const input = payload.value;
4155
- if (!(input instanceof Set)) {
4156
+ const input2 = payload.value;
4157
+ if (!(input2 instanceof Set)) {
4156
4158
  payload.issues.push({
4157
- input,
4159
+ input: input2,
4158
4160
  inst,
4159
4161
  expected: "set",
4160
4162
  code: "invalid_type"
@@ -4163,7 +4165,7 @@ var $ZodSet = /* @__PURE__ */ $constructor("$ZodSet", (inst, def) => {
4163
4165
  }
4164
4166
  const proms = [];
4165
4167
  payload.value = /* @__PURE__ */ new Set();
4166
- for (const item of input) {
4168
+ for (const item of input2) {
4167
4169
  const result = def.valueType._zod.run({ value: item, issues: [] }, ctx);
4168
4170
  if (result instanceof Promise) {
4169
4171
  proms.push(result.then((result2) => handleSetResult(result2, payload)));
@@ -4188,14 +4190,14 @@ var $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
4188
4190
  inst._zod.values = valuesSet;
4189
4191
  inst._zod.pattern = new RegExp(`^(${values.filter((k) => propertyKeyTypes.has(typeof k)).map((o) => typeof o === "string" ? escapeRegex(o) : o.toString()).join("|")})$`);
4190
4192
  inst._zod.parse = (payload, _ctx) => {
4191
- const input = payload.value;
4192
- if (valuesSet.has(input)) {
4193
+ const input2 = payload.value;
4194
+ if (valuesSet.has(input2)) {
4193
4195
  return payload;
4194
4196
  }
4195
4197
  payload.issues.push({
4196
4198
  code: "invalid_value",
4197
4199
  values,
4198
- input,
4200
+ input: input2,
4199
4201
  inst
4200
4202
  });
4201
4203
  return payload;
@@ -4210,14 +4212,14 @@ var $ZodLiteral = /* @__PURE__ */ $constructor("$ZodLiteral", (inst, def) => {
4210
4212
  inst._zod.values = values;
4211
4213
  inst._zod.pattern = new RegExp(`^(${def.values.map((o) => typeof o === "string" ? escapeRegex(o) : o ? escapeRegex(o.toString()) : String(o)).join("|")})$`);
4212
4214
  inst._zod.parse = (payload, _ctx) => {
4213
- const input = payload.value;
4214
- if (values.has(input)) {
4215
+ const input2 = payload.value;
4216
+ if (values.has(input2)) {
4215
4217
  return payload;
4216
4218
  }
4217
4219
  payload.issues.push({
4218
4220
  code: "invalid_value",
4219
4221
  values: def.values,
4220
- input,
4222
+ input: input2,
4221
4223
  inst
4222
4224
  });
4223
4225
  return payload;
@@ -4226,13 +4228,13 @@ var $ZodLiteral = /* @__PURE__ */ $constructor("$ZodLiteral", (inst, def) => {
4226
4228
  var $ZodFile = /* @__PURE__ */ $constructor("$ZodFile", (inst, def) => {
4227
4229
  $ZodType.init(inst, def);
4228
4230
  inst._zod.parse = (payload, _ctx) => {
4229
- const input = payload.value;
4230
- if (input instanceof File)
4231
+ const input2 = payload.value;
4232
+ if (input2 instanceof File)
4231
4233
  return payload;
4232
4234
  payload.issues.push({
4233
4235
  expected: "file",
4234
4236
  code: "invalid_type",
4235
- input,
4237
+ input: input2,
4236
4238
  inst
4237
4239
  });
4238
4240
  return payload;
@@ -4262,8 +4264,8 @@ var $ZodTransform = /* @__PURE__ */ $constructor("$ZodTransform", (inst, def) =>
4262
4264
  return payload;
4263
4265
  };
4264
4266
  });
4265
- function handleOptionalResult(result, input) {
4266
- if (input === void 0 && (result.issues.length || result.fallback)) {
4267
+ function handleOptionalResult(result, input2) {
4268
+ if (input2 === void 0 && (result.issues.length || result.fallback)) {
4267
4269
  return { issues: [], value: void 0 };
4268
4270
  }
4269
4271
  return result;
@@ -4281,11 +4283,11 @@ var $ZodOptional = /* @__PURE__ */ $constructor("$ZodOptional", (inst, def) => {
4281
4283
  });
4282
4284
  inst._zod.parse = (payload, ctx) => {
4283
4285
  if (def.innerType._zod.optin === "optional") {
4284
- const input = payload.value;
4286
+ const input2 = payload.value;
4285
4287
  const result = def.innerType._zod.run(payload, ctx);
4286
4288
  if (result instanceof Promise)
4287
- return result.then((r) => handleOptionalResult(r, input));
4288
- return handleOptionalResult(result, input);
4289
+ return result.then((r) => handleOptionalResult(r, input2));
4290
+ return handleOptionalResult(result, input2);
4289
4291
  }
4290
4292
  if (payload.value === void 0) {
4291
4293
  return payload;
@@ -4710,20 +4712,20 @@ var $ZodCustom = /* @__PURE__ */ $constructor("$ZodCustom", (inst, def) => {
4710
4712
  return payload;
4711
4713
  };
4712
4714
  inst._zod.check = (payload) => {
4713
- const input = payload.value;
4714
- const r = def.fn(input);
4715
+ const input2 = payload.value;
4716
+ const r = def.fn(input2);
4715
4717
  if (r instanceof Promise) {
4716
- return r.then((r2) => handleRefineResult(r2, payload, input, inst));
4718
+ return r.then((r2) => handleRefineResult(r2, payload, input2, inst));
4717
4719
  }
4718
- handleRefineResult(r, payload, input, inst);
4720
+ handleRefineResult(r, payload, input2, inst);
4719
4721
  return;
4720
4722
  };
4721
4723
  });
4722
- function handleRefineResult(result, payload, input, inst) {
4724
+ function handleRefineResult(result, payload, input2, inst) {
4723
4725
  if (!result) {
4724
4726
  const _iss = {
4725
4727
  code: "custom",
4726
- input,
4728
+ input: input2,
4727
4729
  inst,
4728
4730
  // incorporates params.error into issue reporting
4729
4731
  path: [...inst._zod.def.path ?? []],
@@ -8010,8 +8012,8 @@ function ko_default() {
8010
8012
  }
8011
8013
 
8012
8014
  // ../../../node_modules/zod/v4/locales/lt.js
8013
- var capitalizeFirstCharacter = (text2) => {
8014
- return text2.charAt(0).toUpperCase() + text2.slice(1);
8015
+ var capitalizeFirstCharacter = (text3) => {
8016
+ return text3.charAt(0).toUpperCase() + text3.slice(1);
8015
8017
  };
8016
8018
  function getUnitTypeFromNumber(number4) {
8017
8019
  const abs = Math.abs(number4);
@@ -11411,23 +11413,23 @@ function _overwrite(tx) {
11411
11413
  }
11412
11414
  // @__NO_SIDE_EFFECTS__
11413
11415
  function _normalize(form) {
11414
- return /* @__PURE__ */ _overwrite((input) => input.normalize(form));
11416
+ return /* @__PURE__ */ _overwrite((input2) => input2.normalize(form));
11415
11417
  }
11416
11418
  // @__NO_SIDE_EFFECTS__
11417
11419
  function _trim() {
11418
- return /* @__PURE__ */ _overwrite((input) => input.trim());
11420
+ return /* @__PURE__ */ _overwrite((input2) => input2.trim());
11419
11421
  }
11420
11422
  // @__NO_SIDE_EFFECTS__
11421
11423
  function _toLowerCase() {
11422
- return /* @__PURE__ */ _overwrite((input) => input.toLowerCase());
11424
+ return /* @__PURE__ */ _overwrite((input2) => input2.toLowerCase());
11423
11425
  }
11424
11426
  // @__NO_SIDE_EFFECTS__
11425
11427
  function _toUpperCase() {
11426
- return /* @__PURE__ */ _overwrite((input) => input.toUpperCase());
11428
+ return /* @__PURE__ */ _overwrite((input2) => input2.toUpperCase());
11427
11429
  }
11428
11430
  // @__NO_SIDE_EFFECTS__
11429
11431
  function _slugify() {
11430
- return /* @__PURE__ */ _overwrite((input) => slugify(input));
11432
+ return /* @__PURE__ */ _overwrite((input2) => slugify(input2));
11431
11433
  }
11432
11434
  // @__NO_SIDE_EFFECTS__
11433
11435
  function _array(Class2, element, params) {
@@ -11732,8 +11734,8 @@ function _stringbool(Classes, _params) {
11732
11734
  type: "pipe",
11733
11735
  in: stringSchema,
11734
11736
  out: booleanSchema,
11735
- transform: ((input, payload) => {
11736
- let data = input;
11737
+ transform: ((input2, payload) => {
11738
+ let data = input2;
11737
11739
  if (params.case !== "sensitive")
11738
11740
  data = data.toLowerCase();
11739
11741
  if (truthySet.has(data)) {
@@ -11752,8 +11754,8 @@ function _stringbool(Classes, _params) {
11752
11754
  return {};
11753
11755
  }
11754
11756
  }),
11755
- reverseTransform: ((input, _payload) => {
11756
- if (input === true) {
11757
+ reverseTransform: ((input2, _payload) => {
11758
+ if (input2 === true) {
11757
11759
  return truthyArray[0] || "true";
11758
11760
  } else {
11759
11761
  return falsyArray[0] || "false";
@@ -11863,26 +11865,26 @@ function extractDefs(ctx, schema) {
11863
11865
  throw new Error("Unprocessed schema. This is a bug in Zod.");
11864
11866
  const idToSchema = /* @__PURE__ */ new Map();
11865
11867
  for (const entry of ctx.seen.entries()) {
11866
- const id = ctx.metadataRegistry.get(entry[0])?.id;
11867
- if (id) {
11868
- const existing = idToSchema.get(id);
11868
+ const id2 = ctx.metadataRegistry.get(entry[0])?.id;
11869
+ if (id2) {
11870
+ const existing = idToSchema.get(id2);
11869
11871
  if (existing && existing !== entry[0]) {
11870
- throw new Error(`Duplicate schema id "${id}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
11872
+ throw new Error(`Duplicate schema id "${id2}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
11871
11873
  }
11872
- idToSchema.set(id, entry[0]);
11874
+ idToSchema.set(id2, entry[0]);
11873
11875
  }
11874
11876
  }
11875
11877
  const makeURI = (entry) => {
11876
11878
  const defsSegment = ctx.target === "draft-2020-12" ? "$defs" : "definitions";
11877
11879
  if (ctx.external) {
11878
11880
  const externalId = ctx.external.registry.get(entry[0])?.id;
11879
- const uriGenerator = ctx.external.uri ?? ((id2) => id2);
11881
+ const uriGenerator = ctx.external.uri ?? ((id3) => id3);
11880
11882
  if (externalId) {
11881
11883
  return { ref: uriGenerator(externalId) };
11882
11884
  }
11883
- const id = entry[1].defId ?? entry[1].schema.id ?? `schema${ctx.counter++}`;
11884
- entry[1].defId = id;
11885
- return { defId: id, ref: `${uriGenerator("__shared")}#/${defsSegment}/${id}` };
11885
+ const id2 = entry[1].defId ?? entry[1].schema.id ?? `schema${ctx.counter++}`;
11886
+ entry[1].defId = id2;
11887
+ return { defId: id2, ref: `${uriGenerator("__shared")}#/${defsSegment}/${id2}` };
11886
11888
  }
11887
11889
  if (entry[1] === root) {
11888
11890
  return { ref: "#" };
@@ -11930,8 +11932,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
11930
11932
  continue;
11931
11933
  }
11932
11934
  }
11933
- const id = ctx.metadataRegistry.get(entry[0])?.id;
11934
- if (id) {
11935
+ const id2 = ctx.metadataRegistry.get(entry[0])?.id;
11936
+ if (id2) {
11935
11937
  extractToDef(entry);
11936
11938
  continue;
11937
11939
  }
@@ -12027,10 +12029,10 @@ function finalize(ctx, schema) {
12027
12029
  } else {
12028
12030
  }
12029
12031
  if (ctx.external?.uri) {
12030
- const id = ctx.external.registry.get(schema)?.id;
12031
- if (!id)
12032
+ const id2 = ctx.external.registry.get(schema)?.id;
12033
+ if (!id2)
12032
12034
  throw new Error("Schema is missing an `id` property");
12033
- result.$id = ctx.external.uri(id);
12035
+ result.$id = ctx.external.uri(id2);
12034
12036
  }
12035
12037
  Object.assign(result, root.def ?? root.schema);
12036
12038
  const rootMetaId = ctx.metadataRegistry.get(schema)?.id;
@@ -12190,9 +12192,9 @@ var numberProcessor = (schema, ctx, _json, _params) => {
12190
12192
  json2.type = "number";
12191
12193
  const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
12192
12194
  const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
12193
- const legacy = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
12195
+ const legacy2 = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
12194
12196
  if (exMin) {
12195
- if (legacy) {
12197
+ if (legacy2) {
12196
12198
  json2.minimum = exclusiveMinimum;
12197
12199
  json2.exclusiveMinimum = true;
12198
12200
  } else {
@@ -12202,7 +12204,7 @@ var numberProcessor = (schema, ctx, _json, _params) => {
12202
12204
  json2.minimum = minimum;
12203
12205
  }
12204
12206
  if (exMax) {
12205
- if (legacy) {
12207
+ if (legacy2) {
12206
12208
  json2.maximum = exclusiveMaximum;
12207
12209
  json2.exclusiveMaximum = true;
12208
12210
  } else {
@@ -12649,9 +12651,9 @@ var allProcessors = {
12649
12651
  optional: optionalProcessor,
12650
12652
  lazy: lazyProcessor
12651
12653
  };
12652
- function toJSONSchema(input, params) {
12653
- if ("_idmap" in input) {
12654
- const registry2 = input;
12654
+ function toJSONSchema(input2, params) {
12655
+ if ("_idmap" in input2) {
12656
+ const registry2 = input2;
12655
12657
  const ctx2 = initializeContext({ ...params, processors: allProcessors });
12656
12658
  const defs = {};
12657
12659
  for (const entry of registry2._idmap.entries()) {
@@ -12679,9 +12681,9 @@ function toJSONSchema(input, params) {
12679
12681
  return { schemas };
12680
12682
  }
12681
12683
  const ctx = initializeContext({ ...params, processors: allProcessors });
12682
- process2(input, ctx);
12683
- extractDefs(ctx, input);
12684
- return finalize(ctx, input);
12684
+ process2(input2, ctx);
12685
+ extractDefs(ctx, input2);
12686
+ return finalize(ctx, input2);
12685
12687
  }
12686
12688
 
12687
12689
  // ../../../node_modules/zod/v4/core/json-schema-generator.js
@@ -13064,7 +13066,7 @@ var safeDecodeAsync2 = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
13064
13066
 
13065
13067
  // ../../../node_modules/zod/v4/classic/schemas.js
13066
13068
  var _installedGroups = /* @__PURE__ */ new WeakMap();
13067
- function _installLazyMethods(inst, group, methods) {
13069
+ function _installLazyMethods(inst, group, methods2) {
13068
13070
  const proto = Object.getPrototypeOf(inst);
13069
13071
  let installed = _installedGroups.get(proto);
13070
13072
  if (!installed) {
@@ -13074,8 +13076,8 @@ function _installLazyMethods(inst, group, methods) {
13074
13076
  if (installed.has(group))
13075
13077
  return;
13076
13078
  installed.add(group);
13077
- for (const key in methods) {
13078
- const fn = methods[key];
13079
+ for (const key in methods2) {
13080
+ const fn = methods2[key];
13079
13081
  Object.defineProperty(proto, key, {
13080
13082
  configurable: true,
13081
13083
  enumerable: false,
@@ -14886,87 +14888,6 @@ function date4(params) {
14886
14888
  // ../../../node_modules/zod/v4/classic/external.js
14887
14889
  config(en_default());
14888
14890
 
14889
- // ../../shared-contracts/dist/ids.js
14890
- var opaqueIdSchema = external_exports.string().refine((value) => value.trim().length > 0, {
14891
- message: "Identifier must not be empty or whitespace"
14892
- });
14893
- var harnessIdSchema = opaqueIdSchema.brand();
14894
- var hostThreadIdSchema = opaqueIdSchema.brand();
14895
- var hostTurnIdSchema = opaqueIdSchema.brand();
14896
- var hostItemIdSchema = opaqueIdSchema.brand();
14897
- var hostInteractionIdSchema = opaqueIdSchema.brand();
14898
-
14899
- // ../../shared-contracts/dist/harness-plugins.js
14900
- var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
14901
- var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
14902
- var HARNESS_PLUGIN_LIMIT = 128;
14903
- var installedPluginIdSchema = external_exports.string().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u);
14904
- var installedHarnessPluginIdSchema = installedPluginIdSchema.pipe(harnessIdSchema);
14905
- var harnessPluginIdSchema = installedHarnessPluginIdSchema.refine((id) => id !== "codex", "The official Codex identity is reserved");
14906
- var pluginRelativeResourceSchema = external_exports.string().min(1).max(512).refine((value) => !/[\\\u0000:#?]/u.test(value) && !value.startsWith("/") && !value.split("/").some((part) => part === ".." || part === ""), "Plugin resources must be relative paths inside the plugin");
14907
- var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
14908
- var localizedTextSchema = external_exports.object({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).strict();
14909
- var harnessInstallationGuideSchema = external_exports.object({
14910
- commands: external_exports.array(external_exports.object({ terminal: external_exports.string().max(256), command: external_exports.string().max(4096) }).strict()).max(8),
14911
- before: localizedTextSchema.optional(),
14912
- after: localizedTextSchema.optional(),
14913
- downloads: external_exports.array(external_exports.object({ label: external_exports.string().max(128), url: documentationUrlSchema }).strict()).max(8).optional()
14914
- }).strict();
14915
- var pluginPresentationShape = {
14916
- id: installedHarnessPluginIdSchema,
14917
- name: external_exports.string().trim().min(1).max(128),
14918
- version: external_exports.string().min(1).max(128),
14919
- /** Capability-only plugin; omitted for existing session-capable plugins. */
14920
- kind: external_exports.literal("usage").optional(),
14921
- /** Original image styling or bounded vector paths; never arbitrary CSS/SVG markup. */
14922
- iconStyle: external_exports.object({
14923
- vector: external_exports.object({
14924
- viewBox: external_exports.string().max(128).regex(/^-?\d+(?:\.\d+)?(?: +-?\d+(?:\.\d+)?){3}$/u),
14925
- color: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu),
14926
- paths: external_exports.array(external_exports.object({
14927
- d: external_exports.string().min(1).max(32768).regex(/^[MmLlHhVvCcSsQqTtAaZz\d.,+eE\s-]+$/u),
14928
- fillRule: external_exports.enum(["evenodd", "nonzero"]).optional(),
14929
- fill: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu).optional()
14930
- }).strict()).min(1).max(32)
14931
- }).strict().optional(),
14932
- background: external_exports.string().regex(/^#[a-f0-9]{6}$/iu).optional(),
14933
- borderRadius: external_exports.number().min(0).max(50).optional(),
14934
- paddingRatio: external_exports.number().min(0).max(0.25).optional()
14935
- }).strict().optional(),
14936
- installation: harnessInstallationGuideSchema.optional(),
14937
- notice: localizedTextSchema.optional(),
14938
- /** The factory accepts a persisted local entrypoint through its construction context. */
14939
- launchCommand: external_exports.literal(true).optional(),
14940
- links: external_exports.object({
14941
- website: documentationUrlSchema.optional(),
14942
- documentation: documentationUrlSchema.optional(),
14943
- installation: documentationUrlSchema.optional()
14944
- }).strict().optional()
14945
- };
14946
- var harnessPluginManifestSchema = external_exports.object({
14947
- manifestVersion: external_exports.literal(1),
14948
- ...pluginPresentationShape,
14949
- adapterApiVersion: external_exports.number().int().positive(),
14950
- entry: pluginRelativeResourceSchema,
14951
- icon: pluginRelativeResourceSchema.optional()
14952
- }).strict();
14953
- var harnessPluginIconSchema = external_exports.string().max(Math.ceil(HARNESS_PLUGIN_ICON_MAX_BYTES / 3) * 4 + 64).regex(/^data:image\/(?:png|jpeg|webp|svg\+xml);base64,[A-Za-z0-9+/]+={0,2}$/u);
14954
- var harnessPluginDescriptorSchema = external_exports.object({
14955
- ...pluginPresentationShape,
14956
- icon: harnessPluginIconSchema.optional()
14957
- }).strict();
14958
- var harnessPluginListParamsSchema = external_exports.object({}).strict();
14959
- var harnessPluginListResultSchema = external_exports.object({
14960
- plugins: external_exports.array(harnessPluginDescriptorSchema.extend({ id: harnessPluginIdSchema })).max(HARNESS_PLUGIN_LIMIT)
14961
- }).strict();
14962
- var harnessPluginConfigurationSchema = external_exports.object({
14963
- version: external_exports.literal(1),
14964
- enabled: external_exports.array(installedHarnessPluginIdSchema).max(HARNESS_PLUGIN_LIMIT)
14965
- }).strict().refine((value) => new Set(value.enabled).size === value.enabled.length, {
14966
- message: "Enabled plugin IDs must be unique",
14967
- path: ["enabled"]
14968
- });
14969
-
14970
14891
  // ../../shared-contracts/dist/json-value.js
14971
14892
  function rejectExplicitUndefined(keys) {
14972
14893
  return (value, context) => {
@@ -15026,403 +14947,73 @@ var jsonValueSchema = nonCircularSchema.pipe(recursiveJsonValueSchema);
15026
14947
  var jsonArraySchema = nonCircularSchema.pipe(external_exports.array(recursiveJsonValueSchema));
15027
14948
  var jsonObjectSchema = nonCircularSchema.pipe(external_exports.record(external_exports.string(), recursiveJsonValueSchema));
15028
14949
 
15029
- // ../../shared-contracts/dist/desktop-extensions.js
15030
- var DESKTOP_EXTENSION_API_VERSION = 1;
15031
- var DESKTOP_EXTENSION_LIMIT = 64;
15032
- var DESKTOP_EXTENSION_ZIP_MAX_BYTES = 64 * 1024 * 1024;
15033
- var DESKTOP_EXTENSION_ZIP_MAX_BASE64_LENGTH = 4 * Math.ceil(DESKTOP_EXTENSION_ZIP_MAX_BYTES / 3);
15034
- var DESKTOP_EXTENSION_MANIFEST_MAX_BYTES = 128 * 1024;
15035
- var DESKTOP_EXTENSION_SCRIPT_MAX_BYTES = 2 * 1024 * 1024;
15036
- var DESKTOP_EXTENSION_STYLE_MAX_BYTES = 256 * 1024;
15037
- var DESKTOP_EXTENSION_ICON_MAX_BYTES = 128 * 1024;
15038
- var DESKTOP_EXTENSION_SCREENSHOT_LIMIT = 4;
15039
- var DESKTOP_EXTENSION_SCREENSHOT_MAX_BYTES = 512 * 1024;
15040
- var DESKTOP_EXTENSION_LIST_SCREENSHOTS_MAX_BYTES = 8 * 1024 * 1024;
15041
- var DESKTOP_EXTENSION_SNAPSHOT_MAX_BYTES = 8 * 1024 * 1024;
15042
- var DESKTOP_EXTENSION_ASSET_MAX_BYTES = 16 * 1024 * 1024;
15043
- var DESKTOP_EXTENSION_SETTINGS_MAX_BYTES = 1024 * 1024;
15044
- var desktopExtensionIdSchema = installedPluginIdSchema;
15045
- var desktopExtensionSlotSchema = external_exports.enum([
15046
- "sidebar.thread-layout",
15047
- "sidebar.thread-badge",
15048
- "appearance.theme"
15049
- ]);
15050
- var desktopExtensionCategorySchema = external_exports.enum([
15051
- "appearance",
15052
- "interface",
15053
- "workflow",
15054
- "analytics",
15055
- "integrations",
15056
- "tools"
15057
- ]);
15058
- var extensionName = external_exports.string().trim().min(1).max(128);
15059
- function desktopExtensionScreenshotMimeType(resource) {
15060
- switch (resource.match(/\.([^./]+)$/u)?.[1]?.toLowerCase()) {
15061
- case "png":
15062
- return "image/png";
15063
- case "jpg":
15064
- case "jpeg":
15065
- return "image/jpeg";
15066
- case "webp":
15067
- return "image/webp";
15068
- default:
15069
- return void 0;
14950
+ // ../../shared-contracts/dist/errors.js
14951
+ var codexhostErrorSchema = external_exports.strictObject({
14952
+ code: external_exports.string().min(1),
14953
+ message: external_exports.string().min(1),
14954
+ retryable: external_exports.boolean(),
14955
+ diagnostic: external_exports.string().min(1).optional(),
14956
+ stage: external_exports.string().min(1).optional(),
14957
+ durationMs: external_exports.number().int().nonnegative().optional(),
14958
+ stderrTail: external_exports.string().min(1).optional()
14959
+ }).superRefine(rejectExplicitUndefined(["diagnostic", "stage", "durationMs", "stderrTail"]));
14960
+
14961
+ // ../../shared-contracts/dist/harness-presentation.js
14962
+ var localeSchema = external_exports.string().max(64).regex(/^[a-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/u);
14963
+ var displayText = (maximum) => external_exports.string().min(1).max(maximum).refine((text3) => text3.trim().length > 0);
14964
+ var harnessLocalizationsSchema = external_exports.record(localeSchema, external_exports.object({
14965
+ label: displayText(256).optional(),
14966
+ description: displayText(1024).optional()
14967
+ }).strict()).refine((entries) => Object.keys(entries).length <= 16, "Too many locales");
14968
+ var harnessLocalizedTextSchema = external_exports.record(localeSchema, displayText(4096)).refine((entries) => typeof entries.en === "string", "English fallback is required").refine((entries) => Object.keys(entries).length <= 16, "Too many locales");
14969
+
14970
+ // ../../shared-contracts/dist/ids.js
14971
+ var opaqueIdSchema = external_exports.string().refine((value) => value.trim().length > 0, {
14972
+ message: "Identifier must not be empty or whitespace"
14973
+ });
14974
+ var harnessIdSchema = opaqueIdSchema.brand();
14975
+ var hostThreadIdSchema = opaqueIdSchema.brand();
14976
+ var hostTurnIdSchema = opaqueIdSchema.brand();
14977
+ var hostItemIdSchema = opaqueIdSchema.brand();
14978
+ var hostInteractionIdSchema = opaqueIdSchema.brand();
14979
+
14980
+ // ../../shared-contracts/dist/harness-permission-modes.js
14981
+ var HARNESS_PERMISSION_MODE_ID_MAX_LENGTH = 128;
14982
+ var HARNESS_PERMISSION_MODE_LABEL_MAX_LENGTH = 256;
14983
+ var HARNESS_PERMISSION_MODE_DESCRIPTION_MAX_LENGTH = 1024;
14984
+ var HARNESS_PERMISSION_MODE_CATALOG_MAX_LENGTH = 32;
14985
+ var nonBlankTextSchema = external_exports.string().refine((value) => value.trim().length > 0, {
14986
+ message: "Value must not be empty or whitespace"
14987
+ });
14988
+ var harnessPermissionModeIdSchema = nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_ID_MAX_LENGTH).regex(/^[A-Za-z0-9._~:-]+$/u, "Permission Mode ID must use transport-safe characters").brand();
14989
+ var harnessPermissionModeSchema = external_exports.object({
14990
+ id: harnessPermissionModeIdSchema,
14991
+ label: nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_LABEL_MAX_LENGTH),
14992
+ description: nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_DESCRIPTION_MAX_LENGTH).optional(),
14993
+ dangerous: external_exports.boolean().optional(),
14994
+ localizations: harnessLocalizationsSchema.optional()
14995
+ }).strict();
14996
+ var harnessPermissionModeCatalogSchema = external_exports.object({
14997
+ modes: external_exports.array(harnessPermissionModeSchema).min(1).max(HARNESS_PERMISSION_MODE_CATALOG_MAX_LENGTH),
14998
+ defaultModeId: harnessPermissionModeIdSchema
14999
+ }).strict().superRefine((catalog, context) => {
15000
+ const ids = /* @__PURE__ */ new Set();
15001
+ for (const [index, mode] of catalog.modes.entries()) {
15002
+ if (ids.has(mode.id)) {
15003
+ context.addIssue({
15004
+ code: "custom",
15005
+ message: "Permission Mode IDs must be unique",
15006
+ path: ["modes", index, "id"]
15007
+ });
15008
+ }
15009
+ ids.add(mode.id);
15070
15010
  }
15071
- }
15072
- function desktopExtensionAssetMimeType(resource) {
15073
- switch (resource.match(/\.([^./]+)$/u)?.[1]?.toLowerCase()) {
15074
- case "gif":
15075
- return "image/gif";
15076
- case "svg":
15077
- return "image/svg+xml";
15078
- case "woff2":
15079
- return "font/woff2";
15080
- case "json":
15081
- return "application/json";
15082
- case "css":
15083
- return "text/css";
15084
- default:
15085
- return desktopExtensionScreenshotMimeType(resource);
15086
- }
15087
- }
15088
- var hasPortableSegments = (resource) => resource.split("/").every((segment) => !/[. ]$/u.test(segment));
15089
- var desktopExtensionAssetPathSchema = pluginRelativeResourceSchema.refine((resource) => hasPortableSegments(resource) && desktopExtensionAssetMimeType(resource) !== void 0, "Expected a relative Desktop extension asset path with a supported suffix");
15090
- var imagePathSchema = pluginRelativeResourceSchema.refine((resource) => desktopExtensionScreenshotMimeType(resource) !== void 0 && hasPortableSegments(resource), "Images must be relative .png, .jpg, .jpeg, or .webp paths with no segments ending in a dot or space");
15091
- var desktopExtensionHttpUrlSchema = external_exports.string().trim().max(2048).regex(/^https?:\/\/[^/?#\\\s]+/iu, "Expected an HTTP(S) URL").pipe(external_exports.url({ protocol: /^https?$/u })).refine((value) => {
15092
- const { username, password } = new URL(value);
15093
- return !username && !password && !/[\\\s]/u.test(value);
15094
- }, "URL must not contain credentials, backslashes, or whitespace");
15095
- function localizedText(text2) {
15096
- return external_exports.strictObject({ en: text2, "zh-CN": text2 });
15097
- }
15098
- var desktopExtensionLocalizedTextSchema = localizedText(external_exports.string().trim().min(1));
15099
- var categoriesSchema = external_exports.array(desktopExtensionCategorySchema).max(desktopExtensionCategorySchema.options.length).refine((categories) => new Set(categories).size === categories.length, "Duplicate categories");
15100
- var slotsSchema = external_exports.array(desktopExtensionSlotSchema).max(desktopExtensionSlotSchema.options.length).refine((slots) => new Set(slots).size === slots.length, "Duplicate slots");
15101
- var settingField = {
15102
- key: external_exports.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/u),
15103
- label: desktopExtensionLocalizedTextSchema,
15104
- description: desktopExtensionLocalizedTextSchema.optional()
15105
- };
15106
- var numericSetting = {
15107
- ...settingField,
15108
- step: external_exports.number().positive().optional(),
15109
- default: external_exports.number().optional()
15110
- };
15111
- var settingOption = external_exports.strictObject({
15112
- value: external_exports.string(),
15113
- label: desktopExtensionLocalizedTextSchema
15114
- });
15115
- var desktopExtensionSettingFieldSchema = external_exports.discriminatedUnion("type", [
15116
- external_exports.strictObject({
15117
- ...settingField,
15118
- type: external_exports.literal("boolean"),
15119
- default: external_exports.boolean().optional()
15120
- }),
15121
- external_exports.strictObject({
15122
- ...settingField,
15123
- type: external_exports.literal("string"),
15124
- placeholder: desktopExtensionLocalizedTextSchema.optional(),
15125
- default: external_exports.string().optional()
15126
- }),
15127
- external_exports.strictObject({
15128
- ...numericSetting,
15129
- type: external_exports.literal("number"),
15130
- min: external_exports.number().optional(),
15131
- max: external_exports.number().optional()
15132
- }),
15133
- external_exports.strictObject({
15134
- ...numericSetting,
15135
- type: external_exports.literal("range"),
15136
- min: external_exports.number(),
15137
- max: external_exports.number()
15138
- }),
15139
- external_exports.strictObject({
15140
- ...settingField,
15141
- type: external_exports.literal("select"),
15142
- options: external_exports.array(settingOption).min(1),
15143
- default: external_exports.string().optional()
15144
- })
15145
- ]).superRefine((field2, ctx) => {
15146
- const issue2 = (path8, message) => ctx.addIssue({ code: "custom", path: [path8], message });
15147
- if (field2.type === "number" || field2.type === "range") {
15148
- const { min = -Infinity, max = Infinity, default: value } = field2;
15149
- if (min > max)
15150
- issue2("max", "Must be at least min");
15151
- if (value !== void 0 && (value < min || value > max))
15152
- issue2("default", "Must be within min and max");
15153
- } else if (field2.type === "select") {
15154
- const values = new Set(field2.options.map(({ value }) => value));
15155
- if (values.size !== field2.options.length)
15156
- issue2("options", "Duplicate option values");
15157
- if (field2.default !== void 0 && !values.has(field2.default))
15158
- issue2("default", "Must match an option value");
15159
- }
15160
- });
15161
- var manifestHeader = external_exports.object({
15162
- manifestVersion: external_exports.int().positive(),
15163
- id: desktopExtensionIdSchema,
15164
- name: external_exports.union([extensionName, localizedText(extensionName)]),
15165
- version: external_exports.string().min(1).max(128),
15166
- desktopApi: external_exports.int().positive()
15167
- }).passthrough();
15168
- var desktopExtensionManifestSchema = manifestHeader.extend({
15169
- manifestVersion: external_exports.literal(1),
15170
- desktopApi: external_exports.literal(DESKTOP_EXTENSION_API_VERSION),
15171
- description: external_exports.strictObject({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).optional(),
15172
- author: external_exports.string().trim().min(1).max(128).optional(),
15173
- repository: desktopExtensionHttpUrlSchema.optional(),
15174
- details: external_exports.strictObject({ en: external_exports.string().max(16384), "zh-CN": external_exports.string().max(16384).optional() }).optional(),
15175
- icon: imagePathSchema.optional(),
15176
- screenshots: external_exports.array(imagePathSchema).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).refine((screenshots) => new Set(screenshots).size === screenshots.length, "Duplicate screenshots").optional(),
15177
- desktop: external_exports.strictObject({
15178
- script: pluginRelativeResourceSchema,
15179
- style: pluginRelativeResourceSchema.optional()
15180
- }).optional(),
15181
- backend: external_exports.strictObject({ script: pluginRelativeResourceSchema.refine(hasPortableSegments) }).optional(),
15182
- slots: slotsSchema.default(() => []),
15183
- settingsSchema: external_exports.array(desktopExtensionSettingFieldSchema).max(32).refine((fields) => new Set(fields.map(({ key }) => key)).size === fields.length, "Duplicate setting keys").optional(),
15184
- categories: categoriesSchema.optional()
15185
- }).strict().refine((manifest) => manifest.desktop !== void 0 || manifest.backend !== void 0, "Expected at least one desktop or backend entry");
15186
- var desktopExtensionConfigurationSchema = external_exports.strictObject({
15187
- version: external_exports.literal(1),
15188
- revision: external_exports.int().nonnegative(),
15189
- enabled: external_exports.array(desktopExtensionIdSchema).max(DESKTOP_EXTENSION_LIMIT).refine((ids) => new Set(ids).size === ids.length, "Duplicate extension IDs"),
15190
- reloadToken: external_exports.uuid().optional()
15191
- });
15192
- var desktopExtensionHashSchema = external_exports.string().regex(/^[a-f0-9]{64}$/u);
15193
- var desktopExtensionStatusSchema = external_exports.strictObject({
15194
- state: external_exports.enum([
15195
- "running",
15196
- "disabled",
15197
- "invalid",
15198
- "incompatible",
15199
- "conflict",
15200
- "failed",
15201
- "waiting"
15202
- ]),
15203
- hash: desktopExtensionHashSchema.optional(),
15204
- error: external_exports.string().optional(),
15205
- conflictWith: desktopExtensionIdSchema.optional()
15206
- });
15207
- var desktopExtensionsDiagnosticSchema = external_exports.strictObject({
15208
- controllerPid: external_exports.int().positive(),
15209
- targetId: external_exports.string().nullable(),
15210
- updatedAt: external_exports.iso.datetime(),
15211
- handledReloadToken: external_exports.uuid().optional(),
15212
- extensions: external_exports.record(external_exports.string(), desktopExtensionStatusSchema)
15213
- });
15214
- var desktopExtensionTrustTierSchema = external_exports.enum(["official", "community"]);
15215
- function isGitHubDesktopExtensionZipballUrl(url2) {
15216
- return url2.origin === "https://api.github.com" && /^\/repos\/[\w-]+\/[\w.-]+\/zipball(?:\/[^/]+)?\/?$/u.test(url2.pathname);
15217
- }
15218
- var desktopExtensionZipUrlSchema = desktopExtensionHttpUrlSchema.refine((input) => {
15219
- const url2 = new URL(input);
15220
- return /\.zip$/iu.test(url2.pathname) || isGitHubDesktopExtensionZipballUrl(url2) || url2.origin === "https://github.com" && /^\/[\w-]+\/[\w.-]+\/zipball(?:\/.+)?\/?$/u.test(url2.pathname) || url2.origin === "https://codeload.github.com" && /^\/[\w-]+\/[\w.-]+\/(?:zip|zipball|legacy\.zip)\/.+$/u.test(url2.pathname);
15221
- }, "Expected a .zip download URL or a GitHub zipball URL");
15222
- var desktopExtensionCatalogEntrySchema = external_exports.strictObject({
15223
- id: desktopExtensionIdSchema,
15224
- version: external_exports.string().trim().min(1).max(128),
15225
- name: desktopExtensionLocalizedTextSchema.extend({ en: extensionName, "zh-CN": extensionName }),
15226
- description: localizedText(external_exports.string().trim().min(1).max(4096)),
15227
- details: localizedText(external_exports.string().trim().min(1).max(16384)).optional(),
15228
- author: external_exports.string().trim().min(1).max(128),
15229
- repository: desktopExtensionHttpUrlSchema,
15230
- stars: external_exports.number().int().min(0).optional(),
15231
- downloads: external_exports.number().int().min(0).optional(),
15232
- categories: categoriesSchema.optional(),
15233
- trustTier: desktopExtensionTrustTierSchema.default("community"),
15234
- icon: desktopExtensionHttpUrlSchema.optional(),
15235
- screenshots: external_exports.array(desktopExtensionHttpUrlSchema).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).optional(),
15236
- downloadUrl: desktopExtensionZipUrlSchema,
15237
- sha256: desktopExtensionHashSchema,
15238
- slots: slotsSchema.optional(),
15239
- publishedAt: external_exports.string().optional(),
15240
- updatedAt: external_exports.string().optional(),
15241
- minCodexHostVersion: external_exports.string().optional()
15242
- });
15243
- var desktopExtensionCatalogSchema = external_exports.strictObject({
15244
- schemaVersion: external_exports.literal(1),
15245
- generatedAt: external_exports.string(),
15246
- extensions: external_exports.array(desktopExtensionCatalogEntrySchema).refine((entries) => new Set(entries.map(({ id }) => id)).size === entries.length, "Duplicate extension IDs")
15247
- });
15248
- var DESKTOP_EXTENSIONS_ASSET_METHOD = "codexhost/desktop/extensions/asset";
15249
- var DESKTOP_EXTENSIONS_SETTINGS_GET_METHOD = "codexhost/desktop/extensions/settings/get";
15250
- var DESKTOP_EXTENSIONS_SETTINGS_SET_METHOD = "codexhost/desktop/extensions/settings/set";
15251
- var DESKTOP_EXTENSIONS_BACKEND_INVOKE_METHOD = "codexhost/desktop/extensions/backend/invoke";
15252
- var extensionIdParams = { id: desktopExtensionIdSchema };
15253
- var desktopExtensionsAssetParamsSchema = external_exports.strictObject({
15254
- ...extensionIdParams,
15255
- path: desktopExtensionAssetPathSchema
15256
- });
15257
- var desktopExtensionsAssetResultSchema = external_exports.strictObject({
15258
- mimeType: external_exports.string(),
15259
- dataUrl: external_exports.string()
15260
- });
15261
- var desktopExtensionsSettingsGetParamsSchema = external_exports.strictObject(extensionIdParams);
15262
- var desktopExtensionsSettingsSetParamsSchema = external_exports.strictObject({
15263
- ...extensionIdParams,
15264
- values: jsonObjectSchema
15265
- });
15266
- var desktopExtensionsSettingsResultSchema = external_exports.strictObject({ values: jsonObjectSchema });
15267
- var desktopExtensionBackendMethodSchema = external_exports.string().trim().min(1).max(128);
15268
- var desktopExtensionsBackendInvokeParamsSchema = external_exports.strictObject({
15269
- ...extensionIdParams,
15270
- method: desktopExtensionBackendMethodSchema,
15271
- params: jsonValueSchema.optional()
15272
- });
15273
- var desktopExtensionsBackendInvokeResultSchema = external_exports.strictObject({
15274
- result: jsonValueSchema
15275
- });
15276
-
15277
- // ../../shared-contracts/dist/desktop-extension-management.js
15278
- var DESKTOP_EXTENSIONS_LIST_METHOD = "codexhost/desktop/extensions/list";
15279
- var DESKTOP_EXTENSIONS_ENABLE_METHOD = "codexhost/desktop/extensions/enable";
15280
- var DESKTOP_EXTENSIONS_DISABLE_METHOD = "codexhost/desktop/extensions/disable";
15281
- var DESKTOP_EXTENSIONS_CATALOG_METHOD = "codexhost/desktop/extensions/catalog";
15282
- var DESKTOP_EXTENSIONS_INSTALL_METHOD = "codexhost/desktop/extensions/install";
15283
- var DESKTOP_EXTENSIONS_UNINSTALL_METHOD = "codexhost/desktop/extensions/uninstall";
15284
- var DESKTOP_EXTENSIONS_RECOVER_METHOD = "codexhost/desktop/extensions/disable-all-and-reload";
15285
- var DESKTOP_EXTENSION_MANAGEMENT_METHODS = [
15286
- DESKTOP_EXTENSIONS_LIST_METHOD,
15287
- DESKTOP_EXTENSIONS_ENABLE_METHOD,
15288
- DESKTOP_EXTENSIONS_DISABLE_METHOD,
15289
- DESKTOP_EXTENSIONS_RECOVER_METHOD,
15290
- DESKTOP_EXTENSIONS_CATALOG_METHOD,
15291
- DESKTOP_EXTENSIONS_INSTALL_METHOD,
15292
- DESKTOP_EXTENSIONS_UNINSTALL_METHOD,
15293
- DESKTOP_EXTENSIONS_ASSET_METHOD,
15294
- DESKTOP_EXTENSIONS_SETTINGS_GET_METHOD,
15295
- DESKTOP_EXTENSIONS_SETTINGS_SET_METHOD,
15296
- DESKTOP_EXTENSIONS_BACKEND_INVOKE_METHOD
15297
- ];
15298
- var revisionSchema = external_exports.int().nonnegative();
15299
- var desktopExtensionsListParamsSchema = external_exports.strictObject({});
15300
- var desktopExtensionSelectionParamsSchema = external_exports.strictObject({
15301
- id: desktopExtensionIdSchema,
15302
- expectedRevision: revisionSchema
15303
- });
15304
- var desktopExtensionsRecoveryParamsSchema = external_exports.strictObject({
15305
- expectedRevision: revisionSchema.optional()
15306
- });
15307
- var rasterDataUrlSchema = (maxBytes) => external_exports.string().max("data:image/jpeg;base64,".length + 4 * Math.ceil(maxBytes / 3)).regex(/^data:image\/(?:png|jpeg|webp);base64,[A-Za-z0-9+/]+={0,2}$/u);
15308
- var desktopExtensionListItemSchema = external_exports.strictObject({
15309
- // An invalid discovery can have a directory name that isn't a valid extension ID.
15310
- id: external_exports.string().min(1),
15311
- manifest: desktopExtensionManifestSchema.optional(),
15312
- iconDataUrl: rasterDataUrlSchema(DESKTOP_EXTENSION_ICON_MAX_BYTES).optional(),
15313
- screenshotDataUrls: external_exports.array(rasterDataUrlSchema(DESKTOP_EXTENSION_SCREENSHOT_MAX_BYTES)).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).optional(),
15314
- enabled: external_exports.boolean(),
15315
- status: desktopExtensionStatusSchema
15316
- });
15317
- var desktopExtensionsListResultSchema = external_exports.strictObject({
15318
- configuration: desktopExtensionConfigurationSchema,
15319
- desktopConnected: external_exports.boolean(),
15320
- diagnostics: external_exports.array(external_exports.string()),
15321
- extensions: external_exports.array(desktopExtensionListItemSchema)
15322
- });
15323
- var desktopExtensionsCatalogParamsSchema = external_exports.strictObject({
15324
- forceRefresh: external_exports.boolean().optional()
15325
- });
15326
- var desktopExtensionsCatalogResultSchema = external_exports.strictObject({
15327
- catalogUrl: external_exports.string(),
15328
- source: external_exports.enum(["remote", "fallback"]),
15329
- fetchedAt: external_exports.string(),
15330
- cached: external_exports.boolean(),
15331
- extensions: desktopExtensionCatalogSchema.shape.extensions,
15332
- error: external_exports.string().optional()
15333
- });
15334
- var desktopExtensionsInstallParamsSchema = external_exports.strictObject({
15335
- source: external_exports.discriminatedUnion("type", [
15336
- external_exports.strictObject({ type: external_exports.literal("catalog"), id: desktopExtensionIdSchema }),
15337
- external_exports.strictObject({
15338
- type: external_exports.literal("url"),
15339
- url: desktopExtensionHttpUrlSchema,
15340
- expectedSha256: desktopExtensionHashSchema.optional()
15341
- }),
15342
- external_exports.strictObject({
15343
- type: external_exports.literal("zip-base64"),
15344
- fileName: external_exports.string().trim().min(1).max(255),
15345
- contentBase64: external_exports.string().min(4).max(DESKTOP_EXTENSION_ZIP_MAX_BASE64_LENGTH).refine((value) => value.length % 4 === 0 && /^[A-Za-z0-9+/]+={0,2}$/u.test(value), "Expected standard padded base64")
15346
- })
15347
- ])
15348
- });
15349
- var desktopExtensionsInstallResultSchema = external_exports.strictObject({
15350
- extensionId: desktopExtensionIdSchema,
15351
- version: external_exports.string().min(1),
15352
- replaced: external_exports.boolean(),
15353
- installedPath: external_exports.string(),
15354
- list: desktopExtensionsListResultSchema
15355
- });
15356
- var desktopExtensionsUninstallParamsSchema = external_exports.strictObject({
15357
- id: desktopExtensionIdSchema
15358
- });
15359
- var desktopExtensionsUninstallResultSchema = external_exports.strictObject({
15360
- removedId: desktopExtensionIdSchema,
15361
- list: desktopExtensionsListResultSchema
15362
- });
15363
- var desktopExtensionMutationResultSchema = external_exports.discriminatedUnion("state", [
15364
- external_exports.strictObject({ state: external_exports.literal("saved"), configuration: desktopExtensionConfigurationSchema }),
15365
- external_exports.strictObject({ state: external_exports.literal("slot-conflict"), conflictWith: desktopExtensionIdSchema }),
15366
- external_exports.strictObject({ state: external_exports.literal("revision-conflict"), revision: revisionSchema })
15367
- ]);
15368
-
15369
- // ../../shared-contracts/dist/errors.js
15370
- var codexhostErrorSchema = external_exports.strictObject({
15371
- code: external_exports.string().min(1),
15372
- message: external_exports.string().min(1),
15373
- retryable: external_exports.boolean(),
15374
- diagnostic: external_exports.string().min(1).optional(),
15375
- stage: external_exports.string().min(1).optional(),
15376
- durationMs: external_exports.number().int().nonnegative().optional(),
15377
- stderrTail: external_exports.string().min(1).optional()
15378
- }).superRefine(rejectExplicitUndefined(["diagnostic", "stage", "durationMs", "stderrTail"]));
15379
-
15380
- // ../../shared-contracts/dist/harness-presentation.js
15381
- var localeSchema = external_exports.string().max(64).regex(/^[a-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/u);
15382
- var displayText = (maximum) => external_exports.string().min(1).max(maximum).refine((text2) => text2.trim().length > 0);
15383
- var harnessLocalizationsSchema = external_exports.record(localeSchema, external_exports.object({
15384
- label: displayText(256).optional(),
15385
- description: displayText(1024).optional()
15386
- }).strict()).refine((entries) => Object.keys(entries).length <= 16, "Too many locales");
15387
- var harnessLocalizedTextSchema = external_exports.record(localeSchema, displayText(4096)).refine((entries) => typeof entries.en === "string", "English fallback is required").refine((entries) => Object.keys(entries).length <= 16, "Too many locales");
15388
-
15389
- // ../../shared-contracts/dist/harness-permission-modes.js
15390
- var HARNESS_PERMISSION_MODE_ID_MAX_LENGTH = 128;
15391
- var HARNESS_PERMISSION_MODE_LABEL_MAX_LENGTH = 256;
15392
- var HARNESS_PERMISSION_MODE_DESCRIPTION_MAX_LENGTH = 1024;
15393
- var HARNESS_PERMISSION_MODE_CATALOG_MAX_LENGTH = 32;
15394
- var nonBlankTextSchema = external_exports.string().refine((value) => value.trim().length > 0, {
15395
- message: "Value must not be empty or whitespace"
15396
- });
15397
- var harnessPermissionModeIdSchema = nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_ID_MAX_LENGTH).regex(/^[A-Za-z0-9._~:-]+$/u, "Permission Mode ID must use transport-safe characters").brand();
15398
- var harnessPermissionModeSchema = external_exports.object({
15399
- id: harnessPermissionModeIdSchema,
15400
- label: nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_LABEL_MAX_LENGTH),
15401
- description: nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_DESCRIPTION_MAX_LENGTH).optional(),
15402
- dangerous: external_exports.boolean().optional(),
15403
- localizations: harnessLocalizationsSchema.optional()
15404
- }).strict();
15405
- var harnessPermissionModeCatalogSchema = external_exports.object({
15406
- modes: external_exports.array(harnessPermissionModeSchema).min(1).max(HARNESS_PERMISSION_MODE_CATALOG_MAX_LENGTH),
15407
- defaultModeId: harnessPermissionModeIdSchema
15408
- }).strict().superRefine((catalog, context) => {
15409
- const ids = /* @__PURE__ */ new Set();
15410
- for (const [index, mode] of catalog.modes.entries()) {
15411
- if (ids.has(mode.id)) {
15412
- context.addIssue({
15413
- code: "custom",
15414
- message: "Permission Mode IDs must be unique",
15415
- path: ["modes", index, "id"]
15416
- });
15417
- }
15418
- ids.add(mode.id);
15419
- }
15420
- if (!ids.has(catalog.defaultModeId)) {
15421
- context.addIssue({
15422
- code: "custom",
15423
- message: "Default Permission Mode must exist in the catalog",
15424
- path: ["defaultModeId"]
15425
- });
15011
+ if (!ids.has(catalog.defaultModeId)) {
15012
+ context.addIssue({
15013
+ code: "custom",
15014
+ message: "Default Permission Mode must exist in the catalog",
15015
+ path: ["defaultModeId"]
15016
+ });
15426
15017
  }
15427
15018
  });
15428
15019
  var threadPermissionModeSelectParamsSchema = external_exports.object({
@@ -15430,6 +15021,9 @@ var threadPermissionModeSelectParamsSchema = external_exports.object({
15430
15021
  permissionModeId: harnessPermissionModeIdSchema
15431
15022
  }).strict();
15432
15023
 
15024
+ // ../../shared-contracts/dist/harness-route-limit.js
15025
+ var HARNESS_TRANSPORT_MODEL_ID_MAX_LENGTH = 8192;
15026
+
15433
15027
  // ../../shared-contracts/dist/thread-usage.js
15434
15028
  var nonNegativeSafeIntegerSchema = external_exports.number().int().safe().nonnegative();
15435
15029
  var finiteNonNegativeNumberSchema = external_exports.number().finite().nonnegative();
@@ -15455,14 +15049,14 @@ var usageMeasurementsSchema = external_exports.object({
15455
15049
  outputTokensPerSecond: usageMeasurementSchema.refine((value) => value.version === 4).optional().catch(void 0),
15456
15050
  timeToFirstOutputMs: usageMeasurementSchema.extend({ value: nonNegativeSafeIntegerSchema }).optional()
15457
15051
  }).strict();
15458
- var indicatorTextSchema = (maximum) => harnessLocalizedTextSchema.refine((entries) => Object.values(entries).every((text2) => text2.length <= maximum));
15052
+ var indicatorTextSchema = (maximum) => harnessLocalizedTextSchema.refine((entries) => Object.values(entries).every((text3) => text3.length <= maximum));
15459
15053
  var composerIndicatorsSchema = external_exports.array(external_exports.object({
15460
15054
  kind: external_exports.literal("countdown"),
15461
15055
  id: external_exports.string().min(1).max(64),
15462
15056
  expiresAtUnix: nonNegativeSafeIntegerSchema,
15463
15057
  label: indicatorTextSchema(256).optional(),
15464
15058
  tooltip: indicatorTextSchema(1024).optional()
15465
- }).strict()).max(2).refine((entries) => new Set(entries.map(({ id }) => id)).size === entries.length, {
15059
+ }).strict()).max(2).refine((entries) => new Set(entries.map(({ id: id2 }) => id2)).size === entries.length, {
15466
15060
  message: "Composer indicator IDs must be unique"
15467
15061
  });
15468
15062
  var threadUsageSnapshotSchema = external_exports.object({
@@ -15488,6 +15082,7 @@ var threadUsageSnapshotSchema = external_exports.object({
15488
15082
  planSevenDayResetsAtUnix: nonNegativeSafeIntegerSchema.optional(),
15489
15083
  sessionCacheHitRatePercent: cacheHitRatePercentSchema.optional(),
15490
15084
  timeToFirstOutputMs: nonNegativeSafeIntegerSchema.optional(),
15085
+ latestRequestTimeToFirstOutputMs: nonNegativeSafeIntegerSchema.optional(),
15491
15086
  costSource: external_exports.enum(["publicPrice", "native"]).optional(),
15492
15087
  unpricedModels: external_exports.array(external_exports.string().min(1)).min(1).optional()
15493
15088
  }).strict().superRefine((usage, context) => {
@@ -15615,10 +15210,15 @@ var THREAD_OWNERSHIP_LIST_MAX_LENGTH = 100;
15615
15210
  var nonBlankTextSchema2 = external_exports.string().refine((value) => value.trim().length > 0, {
15616
15211
  message: "Value must not be empty or whitespace"
15617
15212
  });
15618
- var harnessModelRefIdSchema = nonBlankTextSchema2.max(HARNESS_MODEL_REF_MAX_LENGTH).regex(/^[A-Za-z0-9._~-]+$/u, "Model Ref must use transport-safe opaque characters").brand();
15213
+ var harnessModelRefIdSchema = external_exports.string().min(1).max(HARNESS_MODEL_REF_MAX_LENGTH).refine((id2) => !new RegExp("\\p{Cc}", "u").test(id2), "Model Ref must not contain control characters").brand();
15214
+ var harnessModelServiceTierSchema = external_exports.enum(["priority", "ultrafast"]);
15619
15215
  var harnessModelRefSchema = external_exports.object({
15620
- id: harnessModelRefIdSchema
15216
+ id: harnessModelRefIdSchema,
15217
+ serviceTier: harnessModelServiceTierSchema.optional()
15621
15218
  }).strict();
15219
+ function sameHarnessModelRef(left, right) {
15220
+ return left?.id === right?.id && left?.serviceTier === right?.serviceTier;
15221
+ }
15622
15222
  var harnessThinkingOptionIdSchema = nonBlankTextSchema2.max(HARNESS_THINKING_OPTION_ID_MAX_LENGTH).regex(/^[A-Za-z0-9._~-]+$/u, "Thinking option ID must use transport-safe characters").brand();
15623
15223
  var harnessResolvedModelLabelSchema = nonBlankTextSchema2.max(HARNESS_MODEL_LABEL_MAX_LENGTH);
15624
15224
  var harnessThinkingOptionSchema = external_exports.object({
@@ -15632,7 +15232,15 @@ var harnessModelSchema = external_exports.object({
15632
15232
  /** Optional opaque selection for this same Model with priority processing enabled. */
15633
15233
  fastModel: harnessModelRefSchema.optional(),
15634
15234
  supportedThinkingOptionIds: external_exports.array(harnessThinkingOptionIdSchema).optional()
15635
- }).strict();
15235
+ }).strict().refine((model2) => model2.fastModel?.serviceTier === void 0 || model2.fastModel.id === model2.ref.id, {
15236
+ path: ["fastModel", "id"],
15237
+ message: "A tiered Fast Model must share the base Model ID"
15238
+ });
15239
+ function catalogModelForRef(catalog, ref) {
15240
+ if (!ref)
15241
+ return void 0;
15242
+ return catalog?.models.find((model2) => sameHarnessModelRef(model2.ref, ref) || sameHarnessModelRef(model2.fastModel, ref));
15243
+ }
15636
15244
  var harnessThinkingOptionsSchema = external_exports.array(harnessThinkingOptionSchema).superRefine((options, context) => {
15637
15245
  const ids = /* @__PURE__ */ new Set();
15638
15246
  for (const [index, option] of options.entries()) {
@@ -15652,26 +15260,26 @@ var harnessModelCatalogSchema = external_exports.object({
15652
15260
  thinkingOptions: harnessThinkingOptionsSchema,
15653
15261
  defaultThinkingOptionId: harnessThinkingOptionIdSchema.optional()
15654
15262
  }).strict().superRefine((catalog, context) => {
15655
- const refs = /* @__PURE__ */ new Set();
15656
- const thinkingIds = new Set(catalog.thinkingOptions.map(({ id }) => id));
15263
+ const refs = [];
15264
+ const thinkingIds = new Set(catalog.thinkingOptions.map(({ id: id2 }) => id2));
15657
15265
  for (const [index, model2] of catalog.models.entries()) {
15658
- if (refs.has(model2.ref.id)) {
15266
+ if (refs.some((ref) => sameHarnessModelRef(ref, model2.ref))) {
15659
15267
  context.addIssue({
15660
15268
  code: "custom",
15661
15269
  message: "Model Catalog refs must be unique",
15662
15270
  path: ["models", index, "ref", "id"]
15663
15271
  });
15664
15272
  }
15665
- refs.add(model2.ref.id);
15273
+ refs.push(model2.ref);
15666
15274
  if (model2.fastModel) {
15667
- if (refs.has(model2.fastModel.id) || catalog.models.some((entry) => entry.ref.id === model2.fastModel?.id)) {
15275
+ if (refs.some((ref) => sameHarnessModelRef(ref, model2.fastModel))) {
15668
15276
  context.addIssue({
15669
15277
  code: "custom",
15670
15278
  message: "Fast Model refs must be distinct and unique",
15671
15279
  path: ["models", index, "fastModel"]
15672
15280
  });
15673
15281
  }
15674
- refs.add(model2.fastModel.id);
15282
+ refs.push(model2.fastModel);
15675
15283
  }
15676
15284
  const supportedThinkingIds = /* @__PURE__ */ new Set();
15677
15285
  for (const [optionIndex, optionId] of (model2.supportedThinkingOptionIds ?? []).entries()) {
@@ -15692,7 +15300,7 @@ var harnessModelCatalogSchema = external_exports.object({
15692
15300
  }
15693
15301
  }
15694
15302
  }
15695
- if (catalog.defaultModel && !refs.has(catalog.defaultModel.id)) {
15303
+ if (catalog.defaultModel && !catalogModelForRef(catalog, catalog.defaultModel)) {
15696
15304
  context.addIssue({
15697
15305
  code: "custom",
15698
15306
  message: "Default Model must exist in the Model Catalog",
@@ -15732,7 +15340,12 @@ var harnessSessionCapabilitiesSchema = external_exports.object({
15732
15340
  observe: external_exports.boolean()
15733
15341
  }).strict().optional(),
15734
15342
  /** True only when `turn.steer` delivers input into the active Turn through a native primitive. */
15735
- steer: external_exports.boolean().optional()
15343
+ steer: external_exports.boolean().optional(),
15344
+ /**
15345
+ * True when the native plan (task list) outlives the Turn that changed it, so a reopened
15346
+ * Thread gets its latest plan again. Otherwise a plan stays with the Turn that made it.
15347
+ */
15348
+ persistentPlan: external_exports.boolean().optional()
15736
15349
  }).strict();
15737
15350
  var harnessConfigurationStateSchema = external_exports.object({
15738
15351
  effectiveModel: harnessModelRefSchema.optional(),
@@ -15741,7 +15354,7 @@ var harnessConfigurationStateSchema = external_exports.object({
15741
15354
  availableThinkingOptions: harnessThinkingOptionsSchema.optional(),
15742
15355
  effectivePermissionModeId: harnessPermissionModeIdSchema.optional()
15743
15356
  }).strict().superRefine((state, context) => {
15744
- if (state.effectiveThinkingOptionId && state.availableThinkingOptions && !state.availableThinkingOptions.some(({ id }) => id === state.effectiveThinkingOptionId)) {
15357
+ if (state.effectiveThinkingOptionId && state.availableThinkingOptions && !state.availableThinkingOptions.some(({ id: id2 }) => id2 === state.effectiveThinkingOptionId)) {
15745
15358
  context.addIssue({
15746
15359
  code: "custom",
15747
15360
  message: "Effective Thinking option must be currently available",
@@ -15749,150 +15362,698 @@ var harnessConfigurationStateSchema = external_exports.object({
15749
15362
  });
15750
15363
  }
15751
15364
  });
15752
- var harnessWebUiCapabilitySchema = external_exports.object({
15753
- open: external_exports.literal(true)
15754
- }).strict();
15755
- var readyHarnessInspectionSchema = external_exports.object({
15756
- status: external_exports.literal("ready"),
15757
- catalog: harnessModelCatalogSchema,
15758
- permissionModes: harnessPermissionModeCatalogSchema.optional(),
15759
- capabilities: harnessSessionCapabilitiesSchema,
15760
- webUi: harnessWebUiCapabilitySchema.optional()
15761
- }).strict().superRefine((inspection, context) => {
15762
- const selectable = inspection.capabilities.configuration.selectPermissionMode;
15763
- if (selectable !== Boolean(inspection.permissionModes)) {
15764
- context.addIssue({
15765
- code: "custom",
15766
- message: "Permission Mode catalog and capability must agree",
15767
- path: selectable ? ["permissionModes"] : ["capabilities", "configuration", "selectPermissionMode"]
15768
- });
15769
- }
15365
+ var harnessWebUiCapabilitySchema = external_exports.object({
15366
+ open: external_exports.literal(true)
15367
+ }).strict();
15368
+ var readyHarnessInspectionSchema = external_exports.object({
15369
+ status: external_exports.literal("ready"),
15370
+ catalog: harnessModelCatalogSchema,
15371
+ permissionModes: harnessPermissionModeCatalogSchema.optional(),
15372
+ capabilities: harnessSessionCapabilitiesSchema,
15373
+ webUi: harnessWebUiCapabilitySchema.optional()
15374
+ }).strict().superRefine((inspection, context) => {
15375
+ const selectable = inspection.capabilities.configuration.selectPermissionMode;
15376
+ if (selectable !== Boolean(inspection.permissionModes)) {
15377
+ context.addIssue({
15378
+ code: "custom",
15379
+ message: "Permission Mode catalog and capability must agree",
15380
+ path: selectable ? ["permissionModes"] : ["capabilities", "configuration", "selectPermissionMode"]
15381
+ });
15382
+ }
15383
+ });
15384
+ var failedHarnessInspectionSchema = external_exports.object({
15385
+ status: external_exports.enum(["notInstalled", "unavailable", "error"]),
15386
+ error: codexhostErrorSchema
15387
+ }).strict();
15388
+ var harnessInspectionSchema = external_exports.union([
15389
+ readyHarnessInspectionSchema,
15390
+ failedHarnessInspectionSchema
15391
+ ]);
15392
+ var harnessInspectParamsSchema = external_exports.object({
15393
+ harnessId: harnessIdSchema,
15394
+ cwd: nonBlankTextSchema2.max(16384).optional(),
15395
+ refresh: external_exports.boolean().optional(),
15396
+ /** `availability` asks only whether the Harness can run; see `InspectHarnessInput.purpose`. */
15397
+ purpose: external_exports.literal("availability").optional(),
15398
+ credentialAccess: external_exports.enum(["allow", "retry"]).optional()
15399
+ }).strict();
15400
+ var harnessWebUiOpenParamsSchema = external_exports.object({
15401
+ harnessId: harnessIdSchema
15402
+ }).strict();
15403
+ var harnessWebUiOpenResultSchema = external_exports.object({}).strict();
15404
+ var threadModelSelectParamsSchema = external_exports.object({
15405
+ threadId: hostThreadIdSchema,
15406
+ model: harnessModelRefSchema
15407
+ }).strict();
15408
+ var threadThinkingSelectParamsSchema = external_exports.object({
15409
+ threadId: hostThreadIdSchema,
15410
+ thinkingOptionId: harnessThinkingOptionIdSchema
15411
+ }).strict();
15412
+ var threadInspectionParamsSchema = external_exports.object({
15413
+ threadId: hostThreadIdSchema,
15414
+ includeReferenceCapability: external_exports.boolean().optional()
15415
+ }).strict();
15416
+ var codexThreadInspectionSchema = external_exports.object({
15417
+ owner: external_exports.literal("codex"),
15418
+ locked: external_exports.boolean(),
15419
+ effectiveModel: harnessModelRefSchema.optional(),
15420
+ resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
15421
+ effectiveThinkingOptionId: harnessThinkingOptionIdSchema.optional(),
15422
+ effectivePermissionModeId: harnessPermissionModeIdSchema.optional(),
15423
+ history: harnessHistoryCapabilitiesSchema.optional(),
15424
+ supportsThreadReferences: external_exports.literal(true).optional()
15425
+ }).strict();
15426
+ var externalThreadInspectionSchema = external_exports.object({
15427
+ owner: external_exports.literal("external"),
15428
+ harnessId: nonBlankTextSchema2.max(256),
15429
+ transportModelId: nonBlankTextSchema2.max(HARNESS_TRANSPORT_MODEL_ID_MAX_LENGTH),
15430
+ effectiveModel: harnessModelRefSchema.optional(),
15431
+ resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
15432
+ effectiveThinkingOptionId: harnessThinkingOptionIdSchema.optional(),
15433
+ availableThinkingOptions: harnessThinkingOptionsSchema.optional(),
15434
+ effectivePermissionModeId: harnessPermissionModeIdSchema.optional(),
15435
+ /** Live Session catalog when it, not the Adapter inspection, contains `effectiveModel`. */
15436
+ catalog: harnessModelCatalogSchema.optional(),
15437
+ history: harnessHistoryCapabilitiesSchema,
15438
+ usage: threadUsageSnapshotSchema.optional(),
15439
+ locked: external_exports.literal(true)
15440
+ }).strict();
15441
+ var threadInspectionSchema = external_exports.discriminatedUnion("owner", [
15442
+ codexThreadInspectionSchema,
15443
+ externalThreadInspectionSchema
15444
+ ]);
15445
+ var threadOwnershipListParamsSchema = external_exports.object({
15446
+ threadIds: external_exports.array(hostThreadIdSchema).min(1).max(THREAD_OWNERSHIP_LIST_MAX_LENGTH)
15447
+ }).strict().superRefine(({ threadIds }, context) => {
15448
+ const seen = /* @__PURE__ */ new Set();
15449
+ for (const [index, threadId] of threadIds.entries()) {
15450
+ if (seen.has(threadId)) {
15451
+ context.addIssue({
15452
+ code: "custom",
15453
+ message: "Thread ownership-list IDs must be unique",
15454
+ path: ["threadIds", index]
15455
+ });
15456
+ }
15457
+ seen.add(threadId);
15458
+ }
15459
+ });
15460
+ var codexThreadOwnershipSchema = external_exports.object({
15461
+ threadId: hostThreadIdSchema,
15462
+ owner: external_exports.literal("codex")
15463
+ }).strict();
15464
+ var externalThreadOwnershipSchema = external_exports.object({
15465
+ threadId: hostThreadIdSchema,
15466
+ owner: external_exports.literal("external"),
15467
+ harnessId: external_exports.string().max(256).pipe(harnessIdSchema)
15468
+ }).strict();
15469
+ var threadOwnershipSchema = external_exports.discriminatedUnion("owner", [
15470
+ codexThreadOwnershipSchema,
15471
+ externalThreadOwnershipSchema
15472
+ ]);
15473
+ var threadOwnershipListResultSchema = external_exports.object({
15474
+ threads: external_exports.array(threadOwnershipSchema).min(1).max(THREAD_OWNERSHIP_LIST_MAX_LENGTH)
15475
+ }).strict().superRefine(({ threads }, context) => {
15476
+ const seen = /* @__PURE__ */ new Set();
15477
+ for (const [index, thread2] of threads.entries()) {
15478
+ if (seen.has(thread2.threadId)) {
15479
+ context.addIssue({
15480
+ code: "custom",
15481
+ message: "Thread ownership-list results must be unique",
15482
+ path: ["threads", index, "threadId"]
15483
+ });
15484
+ }
15485
+ seen.add(thread2.threadId);
15486
+ }
15487
+ });
15488
+ var threadSteeringInspectParamsSchema = external_exports.object({
15489
+ threadId: hostThreadIdSchema,
15490
+ /** The text about to be steered; a Harness command always stops and restarts. */
15491
+ text: external_exports.string().optional()
15492
+ }).strict();
15493
+ var threadSteeringContextSchema = external_exports.object({
15494
+ kind: external_exports.literal("application"),
15495
+ value: external_exports.string().transform((text3, context) => {
15496
+ try {
15497
+ return JSON.parse(text3);
15498
+ } catch {
15499
+ context.addIssue({ code: "custom", message: "Invalid steering context JSON" });
15500
+ return external_exports.NEVER;
15501
+ }
15502
+ }).pipe(external_exports.object({
15503
+ expectedTurnId: hostTurnIdSchema,
15504
+ clientUserMessageId: external_exports.string().min(1),
15505
+ delivery: external_exports.enum(["newTurn", "activeTurn"])
15506
+ }).strict())
15507
+ }).strict().transform((context) => context.value);
15508
+ var threadSteerDeliverySchema = external_exports.enum(["activeTurn", "newTurn"]);
15509
+ var threadSteeringInspectResultSchema = external_exports.object({
15510
+ delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
15511
+ }).strict();
15512
+
15513
+ // ../../shared-contracts/dist/harness-plugins.js
15514
+ var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
15515
+ var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
15516
+ var HARNESS_PLUGIN_LIMIT = 128;
15517
+ var installedPluginIdSchema = external_exports.string().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u);
15518
+ var installedHarnessPluginIdSchema = installedPluginIdSchema.pipe(harnessIdSchema);
15519
+ var harnessPluginIdSchema = installedHarnessPluginIdSchema.refine((id2) => id2 !== "codex", "The official Codex identity is reserved");
15520
+ var pluginRelativeResourceSchema = external_exports.string().min(1).max(512).refine((value) => !/[\\\u0000:#?]/u.test(value) && !value.startsWith("/") && !value.split("/").some((part) => part === ".." || part === ""), "Plugin resources must be relative paths inside the plugin");
15521
+ var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
15522
+ var localizedTextSchema = external_exports.object({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).strict();
15523
+ var harnessInstallationGuideSchema = external_exports.object({
15524
+ commands: external_exports.array(external_exports.object({ terminal: external_exports.string().max(256), command: external_exports.string().max(4096) }).strict()).max(8),
15525
+ before: localizedTextSchema.optional(),
15526
+ after: localizedTextSchema.optional(),
15527
+ downloads: external_exports.array(external_exports.object({ label: external_exports.string().max(128), url: documentationUrlSchema }).strict()).max(8).optional()
15528
+ }).strict();
15529
+ var pluginPresentationShape = {
15530
+ id: installedHarnessPluginIdSchema,
15531
+ name: external_exports.string().trim().min(1).max(128),
15532
+ version: external_exports.string().min(1).max(128),
15533
+ /** Capability-only plugin; omitted for existing session-capable plugins. */
15534
+ kind: external_exports.literal("usage").optional(),
15535
+ /** Original image styling or bounded vector paths; never arbitrary CSS/SVG markup. */
15536
+ iconStyle: external_exports.object({
15537
+ vector: external_exports.object({
15538
+ viewBox: external_exports.string().max(128).regex(/^-?\d+(?:\.\d+)?(?: +-?\d+(?:\.\d+)?){3}$/u),
15539
+ color: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu),
15540
+ paths: external_exports.array(external_exports.object({
15541
+ d: external_exports.string().min(1).max(32768).regex(/^[MmLlHhVvCcSsQqTtAaZz\d.,+eE\s-]+$/u),
15542
+ fillRule: external_exports.enum(["evenodd", "nonzero"]).optional(),
15543
+ fill: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu).optional()
15544
+ }).strict()).min(1).max(32)
15545
+ }).strict().optional(),
15546
+ background: external_exports.string().regex(/^#[a-f0-9]{6}$/iu).optional(),
15547
+ borderRadius: external_exports.number().min(0).max(50).optional(),
15548
+ paddingRatio: external_exports.number().min(0).max(0.25).optional()
15549
+ }).strict().optional(),
15550
+ installation: harnessInstallationGuideSchema.optional(),
15551
+ notice: localizedTextSchema.optional(),
15552
+ /** The factory accepts a persisted local entrypoint through its construction context. */
15553
+ launchCommand: external_exports.literal(true).optional(),
15554
+ links: external_exports.object({
15555
+ website: documentationUrlSchema.optional(),
15556
+ documentation: documentationUrlSchema.optional(),
15557
+ installation: documentationUrlSchema.optional()
15558
+ }).strict().optional()
15559
+ };
15560
+ var harnessPluginManifestSchema = external_exports.object({
15561
+ manifestVersion: external_exports.literal(1),
15562
+ ...pluginPresentationShape,
15563
+ adapterApiVersion: external_exports.number().int().positive(),
15564
+ entry: pluginRelativeResourceSchema,
15565
+ icon: pluginRelativeResourceSchema.optional()
15566
+ }).strict();
15567
+ var harnessPluginIconSchema = external_exports.string().max(Math.ceil(HARNESS_PLUGIN_ICON_MAX_BYTES / 3) * 4 + 64).regex(/^data:image\/(?:png|jpeg|webp|svg\+xml);base64,[A-Za-z0-9+/]+={0,2}$/u);
15568
+ var harnessPluginDescriptorSchema = external_exports.object({
15569
+ ...pluginPresentationShape,
15570
+ icon: harnessPluginIconSchema.optional()
15571
+ }).strict();
15572
+ var harnessPluginListParamsSchema = external_exports.object({}).strict();
15573
+ var harnessPluginListResultSchema = external_exports.object({
15574
+ plugins: external_exports.array(harnessPluginDescriptorSchema.extend({ id: harnessPluginIdSchema })).max(HARNESS_PLUGIN_LIMIT)
15575
+ }).strict();
15576
+ var harnessPluginConfigurationSchema = external_exports.object({
15577
+ version: external_exports.literal(1),
15578
+ enabled: external_exports.array(installedHarnessPluginIdSchema).max(HARNESS_PLUGIN_LIMIT)
15579
+ }).strict().refine((value) => new Set(value.enabled).size === value.enabled.length, {
15580
+ message: "Enabled plugin IDs must be unique",
15581
+ path: ["enabled"]
15582
+ });
15583
+
15584
+ // ../../shared-contracts/dist/desktop-extensions.js
15585
+ var DESKTOP_EXTENSION_API_VERSION = 1;
15586
+ var DESKTOP_EXTENSION_LIMIT = 64;
15587
+ var DESKTOP_EXTENSION_ZIP_MAX_BYTES = 64 * 1024 * 1024;
15588
+ var DESKTOP_EXTENSION_MANIFEST_MAX_BYTES = 128 * 1024;
15589
+ var DESKTOP_EXTENSION_SCRIPT_MAX_BYTES = 2 * 1024 * 1024;
15590
+ var DESKTOP_EXTENSION_STYLE_MAX_BYTES = 256 * 1024;
15591
+ var DESKTOP_EXTENSION_ICON_MAX_BYTES = 128 * 1024;
15592
+ var DESKTOP_EXTENSION_SCREENSHOT_LIMIT = 4;
15593
+ var DESKTOP_EXTENSION_SCREENSHOT_MAX_BYTES = 512 * 1024;
15594
+ var DESKTOP_EXTENSION_LIST_SCREENSHOTS_MAX_BYTES = 8 * 1024 * 1024;
15595
+ var DESKTOP_EXTENSION_SNAPSHOT_MAX_BYTES = 8 * 1024 * 1024;
15596
+ var DESKTOP_EXTENSION_ASSET_MAX_BYTES = 16 * 1024 * 1024;
15597
+ var DESKTOP_EXTENSION_SETTINGS_MAX_BYTES = 1024 * 1024;
15598
+ var desktopExtensionIdSchema = installedPluginIdSchema;
15599
+ var desktopExtensionSlotSchema = external_exports.enum([
15600
+ "sidebar.thread-layout",
15601
+ "sidebar.thread-badge",
15602
+ "appearance.theme"
15603
+ ]);
15604
+ var desktopExtensionCategorySchema = external_exports.enum([
15605
+ "appearance",
15606
+ "interface",
15607
+ "workflow",
15608
+ "analytics",
15609
+ "integrations",
15610
+ "tools"
15611
+ ]);
15612
+ var extensionName = external_exports.string().trim().min(1).max(128);
15613
+ function desktopExtensionScreenshotMimeType(resource) {
15614
+ switch (resource.match(/\.([^./]+)$/u)?.[1]?.toLowerCase()) {
15615
+ case "png":
15616
+ return "image/png";
15617
+ case "jpg":
15618
+ case "jpeg":
15619
+ return "image/jpeg";
15620
+ case "webp":
15621
+ return "image/webp";
15622
+ default:
15623
+ return void 0;
15624
+ }
15625
+ }
15626
+ var hasPortableSegments = (resource) => resource.split("/").every((segment) => !/[. ]$/u.test(segment));
15627
+ var imagePathSchema = pluginRelativeResourceSchema.refine((resource) => desktopExtensionScreenshotMimeType(resource) !== void 0 && hasPortableSegments(resource), "Images must be relative .png, .jpg, .jpeg, or .webp paths with no segments ending in a dot or space");
15628
+ var desktopExtensionHttpUrlSchema = external_exports.string().trim().max(2048).regex(/^https?:\/\/[^/?#\\\s]+/iu, "Expected an HTTP(S) URL").pipe(external_exports.url({ protocol: /^https?$/u })).refine((value) => {
15629
+ const { username, password } = new URL(value);
15630
+ return !username && !password && !/[\\\s]/u.test(value);
15631
+ }, "URL must not contain credentials, backslashes, or whitespace");
15632
+ function localizedText(text3) {
15633
+ return external_exports.strictObject({ en: text3, "zh-CN": text3 });
15634
+ }
15635
+ var desktopExtensionLocalizedTextSchema = localizedText(external_exports.string().trim().min(1));
15636
+ var categoriesSchema = external_exports.array(desktopExtensionCategorySchema).max(desktopExtensionCategorySchema.options.length).refine((categories) => new Set(categories).size === categories.length, "Duplicate categories");
15637
+ var slotsSchema = external_exports.array(desktopExtensionSlotSchema).max(desktopExtensionSlotSchema.options.length).refine((slots) => new Set(slots).size === slots.length, "Duplicate slots");
15638
+ var settingField = {
15639
+ key: external_exports.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/u),
15640
+ label: desktopExtensionLocalizedTextSchema,
15641
+ description: desktopExtensionLocalizedTextSchema.optional()
15642
+ };
15643
+ var numericSetting = {
15644
+ ...settingField,
15645
+ step: external_exports.number().positive().optional(),
15646
+ default: external_exports.number().optional()
15647
+ };
15648
+ var settingOption = external_exports.strictObject({
15649
+ value: external_exports.string(),
15650
+ label: desktopExtensionLocalizedTextSchema
15651
+ });
15652
+ var desktopExtensionSettingFieldSchema = external_exports.discriminatedUnion("type", [
15653
+ external_exports.strictObject({
15654
+ ...settingField,
15655
+ type: external_exports.literal("boolean"),
15656
+ default: external_exports.boolean().optional()
15657
+ }),
15658
+ external_exports.strictObject({
15659
+ ...settingField,
15660
+ type: external_exports.literal("string"),
15661
+ placeholder: desktopExtensionLocalizedTextSchema.optional(),
15662
+ default: external_exports.string().optional()
15663
+ }),
15664
+ external_exports.strictObject({
15665
+ ...numericSetting,
15666
+ type: external_exports.literal("number"),
15667
+ min: external_exports.number().optional(),
15668
+ max: external_exports.number().optional()
15669
+ }),
15670
+ external_exports.strictObject({
15671
+ ...numericSetting,
15672
+ type: external_exports.literal("range"),
15673
+ min: external_exports.number(),
15674
+ max: external_exports.number()
15675
+ }),
15676
+ external_exports.strictObject({
15677
+ ...settingField,
15678
+ type: external_exports.literal("select"),
15679
+ options: external_exports.array(settingOption).min(1),
15680
+ default: external_exports.string().optional()
15681
+ })
15682
+ ]).superRefine((field2, ctx) => {
15683
+ const issue2 = (path8, message) => ctx.addIssue({ code: "custom", path: [path8], message });
15684
+ if (field2.type === "number" || field2.type === "range") {
15685
+ const { min = -Infinity, max = Infinity, default: value } = field2;
15686
+ if (min > max)
15687
+ issue2("max", "Must be at least min");
15688
+ if (value !== void 0 && (value < min || value > max))
15689
+ issue2("default", "Must be within min and max");
15690
+ } else if (field2.type === "select") {
15691
+ const values = new Set(field2.options.map(({ value }) => value));
15692
+ if (values.size !== field2.options.length)
15693
+ issue2("options", "Duplicate option values");
15694
+ if (field2.default !== void 0 && !values.has(field2.default))
15695
+ issue2("default", "Must match an option value");
15696
+ }
15697
+ });
15698
+ var manifestHeader = external_exports.object({
15699
+ manifestVersion: external_exports.int().positive(),
15700
+ id: desktopExtensionIdSchema,
15701
+ name: external_exports.union([extensionName, localizedText(extensionName)]),
15702
+ version: external_exports.string().min(1).max(128),
15703
+ desktopApi: external_exports.int().positive()
15704
+ }).passthrough();
15705
+ var desktopExtensionManifestSchema = manifestHeader.extend({
15706
+ manifestVersion: external_exports.literal(1),
15707
+ desktopApi: external_exports.literal(DESKTOP_EXTENSION_API_VERSION),
15708
+ description: external_exports.strictObject({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).optional(),
15709
+ author: external_exports.string().trim().min(1).max(128).optional(),
15710
+ repository: desktopExtensionHttpUrlSchema.optional(),
15711
+ details: external_exports.strictObject({ en: external_exports.string().max(16384), "zh-CN": external_exports.string().max(16384).optional() }).optional(),
15712
+ icon: imagePathSchema.optional(),
15713
+ screenshots: external_exports.array(imagePathSchema).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).refine((screenshots) => new Set(screenshots).size === screenshots.length, "Duplicate screenshots").optional(),
15714
+ desktop: external_exports.strictObject({
15715
+ script: pluginRelativeResourceSchema,
15716
+ style: pluginRelativeResourceSchema.optional()
15717
+ }).optional(),
15718
+ backend: external_exports.strictObject({ script: pluginRelativeResourceSchema.refine(hasPortableSegments) }).optional(),
15719
+ slots: slotsSchema.default(() => []),
15720
+ settingsSchema: external_exports.array(desktopExtensionSettingFieldSchema).max(32).refine((fields) => new Set(fields.map(({ key }) => key)).size === fields.length, "Duplicate setting keys").optional(),
15721
+ categories: categoriesSchema.optional()
15722
+ }).strict().refine((manifest) => manifest.desktop !== void 0 || manifest.backend !== void 0, "Expected at least one desktop or backend entry");
15723
+ var desktopExtensionHashSchema = external_exports.string().regex(/^[a-f0-9]{64}$/u);
15724
+ var desktopExtensionStatusSchema = external_exports.strictObject({
15725
+ state: external_exports.enum([
15726
+ "running",
15727
+ "disabled",
15728
+ "invalid",
15729
+ "incompatible",
15730
+ "conflict",
15731
+ "failed",
15732
+ "waiting"
15733
+ ]),
15734
+ hash: desktopExtensionHashSchema.optional(),
15735
+ error: external_exports.string().optional(),
15736
+ conflictWith: desktopExtensionIdSchema.optional()
15737
+ });
15738
+ var desktopExtensionsDiagnosticSchema = external_exports.strictObject({
15739
+ controllerPid: external_exports.int().positive(),
15740
+ targetId: external_exports.string().nullable(),
15741
+ updatedAt: external_exports.iso.datetime(),
15742
+ handledReloadToken: external_exports.uuid().optional(),
15743
+ extensions: external_exports.record(external_exports.string(), desktopExtensionStatusSchema),
15744
+ surfaces: external_exports.record(external_exports.string(), desktopExtensionStatusSchema).optional()
15745
+ });
15746
+ var desktopExtensionTrustTierSchema = external_exports.enum(["official", "community"]);
15747
+ function isGitHubDesktopExtensionZipballUrl(url2) {
15748
+ return url2.origin === "https://api.github.com" && /^\/repos\/[\w-]+\/[\w.-]+\/zipball(?:\/[^/]+)?\/?$/u.test(url2.pathname);
15749
+ }
15750
+ var desktopExtensionZipUrlSchema = desktopExtensionHttpUrlSchema.refine((input2) => {
15751
+ const url2 = new URL(input2);
15752
+ return /\.zip$/iu.test(url2.pathname) || isGitHubDesktopExtensionZipballUrl(url2) || url2.origin === "https://github.com" && /^\/[\w-]+\/[\w.-]+\/zipball(?:\/.+)?\/?$/u.test(url2.pathname) || url2.origin === "https://codeload.github.com" && /^\/[\w-]+\/[\w.-]+\/(?:zip|zipball|legacy\.zip)\/.+$/u.test(url2.pathname);
15753
+ }, "Expected a .zip download URL or a GitHub zipball URL");
15754
+ var desktopExtensionCatalogEntrySchema = external_exports.strictObject({
15755
+ id: desktopExtensionIdSchema,
15756
+ version: external_exports.string().trim().min(1).max(128),
15757
+ name: desktopExtensionLocalizedTextSchema.extend({ en: extensionName, "zh-CN": extensionName }),
15758
+ description: localizedText(external_exports.string().trim().min(1).max(4096)),
15759
+ details: localizedText(external_exports.string().trim().min(1).max(16384)).optional(),
15760
+ author: external_exports.string().trim().min(1).max(128),
15761
+ repository: desktopExtensionHttpUrlSchema,
15762
+ stars: external_exports.number().int().min(0).optional(),
15763
+ downloads: external_exports.number().int().min(0).optional(),
15764
+ categories: categoriesSchema.optional(),
15765
+ trustTier: desktopExtensionTrustTierSchema.default("community"),
15766
+ icon: desktopExtensionHttpUrlSchema.optional(),
15767
+ screenshots: external_exports.array(desktopExtensionHttpUrlSchema).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).optional(),
15768
+ downloadUrl: desktopExtensionZipUrlSchema,
15769
+ sha256: desktopExtensionHashSchema,
15770
+ slots: slotsSchema.optional(),
15771
+ publishedAt: external_exports.string().optional(),
15772
+ updatedAt: external_exports.string().optional(),
15773
+ minCodexHostVersion: external_exports.string().optional()
15770
15774
  });
15771
- var failedHarnessInspectionSchema = external_exports.object({
15772
- status: external_exports.enum(["notInstalled", "unavailable", "error"]),
15773
- error: codexhostErrorSchema
15774
- }).strict();
15775
- var harnessInspectionSchema = external_exports.union([
15776
- readyHarnessInspectionSchema,
15777
- failedHarnessInspectionSchema
15775
+ var desktopExtensionCatalogSchema = external_exports.strictObject({
15776
+ schemaVersion: external_exports.literal(1),
15777
+ generatedAt: external_exports.string(),
15778
+ extensions: external_exports.array(desktopExtensionCatalogEntrySchema).refine((entries) => new Set(entries.map(({ id: id2 }) => id2)).size === entries.length, "Duplicate extension IDs")
15779
+ });
15780
+ var desktopExtensionBackendMethodSchema = external_exports.string().trim().min(1).max(128);
15781
+
15782
+ // ../../shared-contracts/dist/host-extensions.js
15783
+ var reservedName = /^(?:con|prn|aux|nul|com[1-9¹²³]|lpt[1-9¹²³]) *(?:\.|$)/iu;
15784
+ var HOST_EXTENSION_PAGE_API_VERSION = 1;
15785
+ var hostExtensionIdSchema = desktopExtensionIdSchema.refine((id2) => !reservedName.test(id2), "Reserved extension ID");
15786
+ var hostExtensionTargetSchema = external_exports.enum(["desktop", "web"]);
15787
+ var hostExtensionDigestSchema = desktopExtensionHashSchema;
15788
+ var hostExtensionActivationIdSchema = external_exports.uuid();
15789
+ var hostExtensionResourcePathSchema = pluginRelativeResourceSchema.refine((resource) => !/[\x00-\x1f\x7f<>"|*]/u.test(resource) && resource.split("/").every((part) => !/[. ]$/u.test(part) && !reservedName.test(part)), "Expected a portable relative resource path").refine((path8) => path8.split("/").length <= 32, "Extension resources may be at most 32 segments deep");
15790
+ var legacy = desktopExtensionManifestSchema.shape;
15791
+ var localized = (max, min = 0) => external_exports.strictObject({
15792
+ en: external_exports.string().trim().min(min).max(max),
15793
+ "zh-CN": external_exports.string().trim().min(min).max(max)
15794
+ });
15795
+ var resourceWithSuffix = (suffix) => hostExtensionResourcePathSchema.refine((path8) => path8.endsWith(suffix), `Expected a ${suffix} file`);
15796
+ var moduleEntry = resourceWithSuffix(".mjs");
15797
+ var style = resourceWithSuffix(".css").optional();
15798
+ var hostExtensionCanonicalPath = (path8) => path8.normalize("NFC").toLowerCase();
15799
+ var hostExtensionManifestV2Schema = external_exports.strictObject({
15800
+ manifestVersion: external_exports.literal(2),
15801
+ id: hostExtensionIdSchema,
15802
+ name: localized(128, 1),
15803
+ version: external_exports.string().trim().min(1).max(128),
15804
+ description: localized(4096),
15805
+ details: localized(16384).optional(),
15806
+ author: legacy.author,
15807
+ repository: legacy.repository,
15808
+ icon: legacy.icon.refine((path8) => path8 === void 0 || hostExtensionResourcePathSchema.safeParse(path8).success),
15809
+ screenshots: legacy.screenshots.refine((paths) => paths === void 0 || paths.every((path8) => hostExtensionResourcePathSchema.safeParse(path8).success)),
15810
+ categories: legacy.categories,
15811
+ settingsSchema: legacy.settingsSchema,
15812
+ slots: legacy.slots.removeDefault().optional(),
15813
+ page: external_exports.strictObject({
15814
+ apiVersion: external_exports.literal(HOST_EXTENSION_PAGE_API_VERSION),
15815
+ entry: moduleEntry,
15816
+ style,
15817
+ title: localized(128, 1).optional()
15818
+ }).optional(),
15819
+ widget: external_exports.strictObject({
15820
+ apiVersion: external_exports.literal(HOST_EXTENSION_PAGE_API_VERSION),
15821
+ entry: moduleEntry,
15822
+ style
15823
+ }).optional(),
15824
+ desktop: external_exports.strictObject({ apiVersion: external_exports.literal(1), script: resourceWithSuffix(".js"), style }).optional(),
15825
+ web: external_exports.strictObject({ apiVersion: external_exports.literal(1), entry: moduleEntry.optional(), style }).refine(({ entry, style: style2 }) => entry !== void 0 || style2 !== void 0, "Expected a Web entry or style").optional(),
15826
+ backend: external_exports.strictObject({ apiVersion: external_exports.literal(1), entry: moduleEntry }).optional()
15827
+ }).refine(({ page, widget, desktop, web, backend }) => Boolean(page || widget || desktop || web || backend), "Expected at least one page, widget, desktop, web, or backend entry").refine(({ page, widget, web, backend }) => !backend || [page?.entry, widget?.entry, web?.entry].every((entry) => entry === void 0 || hostExtensionCanonicalPath(entry) !== hostExtensionCanonicalPath(backend.entry)), { path: ["backend", "entry"], message: "A backend entry cannot also be a frontend entry" });
15828
+ function targetsForCapabilities({ hasPage, hasWidget, hasDesktop, hasWeb, hasBackend }) {
15829
+ if (hasPage || hasWidget || hasBackend && !hasDesktop && !hasWeb)
15830
+ return ["desktop", "web"];
15831
+ const targets = [];
15832
+ if (hasDesktop)
15833
+ targets.push("desktop");
15834
+ if (hasWeb)
15835
+ targets.push("web");
15836
+ return targets;
15837
+ }
15838
+ var hostExtensionBackendMethodSchema = desktopExtensionBackendMethodSchema;
15839
+
15840
+ // ../../shared-contracts/dist/host-extension-management.js
15841
+ var HOST_EXTENSION_ZIP_MAX_BYTES = DESKTOP_EXTENSION_ZIP_MAX_BYTES;
15842
+ var hostExtensionRevisionSchema = external_exports.int().nonnegative();
15843
+ var hostExtensionConfigurationSchema = external_exports.strictObject({
15844
+ revision: hostExtensionRevisionSchema,
15845
+ enabled: external_exports.array(hostExtensionIdSchema).max(DESKTOP_EXTENSION_LIMIT).refine((ids) => new Set(ids).size === ids.length, "Duplicate extension IDs")
15846
+ });
15847
+ var { downloadUrl, ...catalogMetadata } = desktopExtensionCatalogEntrySchema.shape;
15848
+ var hostExtensionCatalogEntrySchema = external_exports.object({
15849
+ ...catalogMetadata,
15850
+ id: hostExtensionIdSchema,
15851
+ format: external_exports.literal("codexhost"),
15852
+ targets: external_exports.array(hostExtensionTargetSchema).min(1).max(2).refine((targets) => new Set(targets).size === targets.length, "Duplicate targets"),
15853
+ apis: external_exports.strictObject({
15854
+ page: external_exports.int().positive().optional(),
15855
+ widget: external_exports.int().positive().optional(),
15856
+ desktop: external_exports.int().positive().optional(),
15857
+ web: external_exports.int().positive().optional(),
15858
+ backend: external_exports.int().positive().optional()
15859
+ }),
15860
+ downloadUrl: downloadUrl.refine((url2) => url2.startsWith("https://"), "Expected HTTPS")
15861
+ }).refine(({ targets, apis }) => {
15862
+ const derived = targetsForCapabilities({
15863
+ hasPage: Boolean(apis.page),
15864
+ hasWidget: Boolean(apis.widget),
15865
+ hasDesktop: Boolean(apis.desktop),
15866
+ hasWeb: Boolean(apis.web),
15867
+ hasBackend: Boolean(apis.backend)
15868
+ });
15869
+ return targets.length === derived.length && derived.every((target2) => targets.includes(target2));
15870
+ }, "Catalog targets must match the declared APIs");
15871
+ var hostExtensionCatalogSchema = external_exports.object({
15872
+ schemaVersion: external_exports.literal(2),
15873
+ generatedAt: external_exports.string().min(1),
15874
+ extensions: external_exports.array(hostExtensionCatalogEntrySchema).max(1e4).refine((entries) => new Set(entries.map(({ id: id2 }) => id2)).size === entries.length, "Duplicate extension IDs")
15875
+ });
15876
+ var hostExtensionsCatalogResultSchema = hostExtensionCatalogSchema.extend({
15877
+ catalogUrl: desktopExtensionHttpUrlSchema,
15878
+ fetchedAt: external_exports.iso.datetime(),
15879
+ cached: external_exports.boolean()
15880
+ });
15881
+ var id = { id: hostExtensionIdSchema };
15882
+ var active = {
15883
+ ...id,
15884
+ activationId: hostExtensionActivationIdSchema,
15885
+ digest: hostExtensionDigestSchema
15886
+ };
15887
+ var optionalActivation = { ...id, activationId: active.activationId.optional() };
15888
+ var filePath = external_exports.string().min(1).max(4096).refine((path8) => /^(?:\/|[a-z]:[/\\])/iu.test(path8) && !path8.includes("\0") && !path8.split(/[/\\]/u).some((part) => part === "." || part === ".."), "Expected an absolute local path without dot segments");
15889
+ var gitRef = external_exports.string().min(1).max(256).refine((ref) => ref.split("/").every((part) => part && /^[a-z0-9_.-]+$/iu.test(part) && part !== "." && part !== ".."), "Invalid GitHub ref");
15890
+ function base643(maxBytes) {
15891
+ return external_exports.string().max(4 * Math.ceil(maxBytes / 3)).refine((value) => {
15892
+ const padding = value.endsWith("==") ? 2 : value.endsWith("=") ? 1 : 0;
15893
+ return value.length % 4 === 0 && value.length * 3 / 4 - padding <= maxBytes && /^[A-Za-z0-9+/]*={0,2}$/u.test(value);
15894
+ }, "Expected bounded standard padded base64");
15895
+ }
15896
+ var hostExtensionGitHubSourceSchema = external_exports.strictObject({
15897
+ type: external_exports.literal("github"),
15898
+ repository: external_exports.string().max(150).regex(/^[a-z0-9-]+\/[a-z0-9_-][a-z0-9_.-]*$/iu),
15899
+ ref: gitRef.optional(),
15900
+ tag: gitRef.optional(),
15901
+ asset: external_exports.string().max(255).regex(/^[a-z0-9_.-]+\.zip$/iu).optional(),
15902
+ subpath: hostExtensionResourcePathSchema.optional()
15903
+ }).refine(({ ref, tag, asset }) => !ref || !tag && !asset, "Use either a zipball ref or a release tag/asset");
15904
+ var hostExtensionInstallSourceSchema = external_exports.union([
15905
+ external_exports.strictObject({ type: external_exports.literal("catalog"), ...id }),
15906
+ hostExtensionGitHubSourceSchema,
15907
+ external_exports.strictObject({ type: external_exports.literal("zip"), base64: base643(HOST_EXTENSION_ZIP_MAX_BYTES).min(4) }),
15908
+ external_exports.strictObject({ type: external_exports.literal("zip"), localZipPath: filePath }),
15909
+ external_exports.strictObject({ type: external_exports.literal("localDir"), localDir: filePath })
15778
15910
  ]);
15779
- var harnessInspectParamsSchema = external_exports.object({
15780
- harnessId: harnessIdSchema,
15781
- cwd: nonBlankTextSchema2.max(16384).optional(),
15782
- refresh: external_exports.boolean().optional(),
15783
- /** `availability` asks only whether the Harness can run; see `InspectHarnessInput.purpose`. */
15784
- purpose: external_exports.literal("availability").optional()
15785
- }).strict();
15786
- var harnessWebUiOpenParamsSchema = external_exports.object({
15787
- harnessId: harnessIdSchema
15788
- }).strict();
15789
- var harnessWebUiOpenResultSchema = external_exports.object({}).strict();
15790
- var threadModelSelectParamsSchema = external_exports.object({
15791
- threadId: hostThreadIdSchema,
15792
- model: harnessModelRefSchema
15793
- }).strict();
15794
- var threadThinkingSelectParamsSchema = external_exports.object({
15795
- threadId: hostThreadIdSchema,
15796
- thinkingOptionId: harnessThinkingOptionIdSchema
15797
- }).strict();
15798
- var threadInspectionParamsSchema = external_exports.object({
15799
- threadId: hostThreadIdSchema,
15800
- includeReferenceCapability: external_exports.boolean().optional()
15801
- }).strict();
15802
- var codexThreadInspectionSchema = external_exports.object({
15803
- owner: external_exports.literal("codex"),
15804
- locked: external_exports.boolean(),
15805
- effectiveModel: harnessModelRefSchema.optional(),
15806
- resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
15807
- effectiveThinkingOptionId: harnessThinkingOptionIdSchema.optional(),
15808
- effectivePermissionModeId: harnessPermissionModeIdSchema.optional(),
15809
- history: harnessHistoryCapabilitiesSchema.optional(),
15810
- supportsThreadReferences: external_exports.literal(true).optional()
15811
- }).strict();
15812
- var externalThreadInspectionSchema = external_exports.object({
15813
- owner: external_exports.literal("external"),
15814
- harnessId: nonBlankTextSchema2.max(256),
15815
- transportModelId: nonBlankTextSchema2.max(1024),
15816
- effectiveModel: harnessModelRefSchema.optional(),
15817
- resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
15818
- effectiveThinkingOptionId: harnessThinkingOptionIdSchema.optional(),
15819
- availableThinkingOptions: harnessThinkingOptionsSchema.optional(),
15820
- effectivePermissionModeId: harnessPermissionModeIdSchema.optional(),
15821
- history: harnessHistoryCapabilitiesSchema,
15822
- usage: threadUsageSnapshotSchema.optional(),
15823
- locked: external_exports.literal(true)
15824
- }).strict();
15825
- var threadInspectionSchema = external_exports.discriminatedUnion("owner", [
15826
- codexThreadInspectionSchema,
15827
- externalThreadInspectionSchema
15911
+ var hostExtensionProvenanceSchema = external_exports.discriminatedUnion("type", [
15912
+ external_exports.strictObject({ type: external_exports.literal("catalog"), ...id }),
15913
+ hostExtensionGitHubSourceSchema,
15914
+ external_exports.strictObject({ type: external_exports.literal("zip") }),
15915
+ external_exports.strictObject({ type: external_exports.literal("localDir") })
15828
15916
  ]);
15829
- var threadOwnershipListParamsSchema = external_exports.object({
15830
- threadIds: external_exports.array(hostThreadIdSchema).min(1).max(THREAD_OWNERSHIP_LIST_MAX_LENGTH)
15831
- }).strict().superRefine(({ threadIds }, context) => {
15832
- const seen = /* @__PURE__ */ new Set();
15833
- for (const [index, threadId] of threadIds.entries()) {
15834
- if (seen.has(threadId)) {
15835
- context.addIssue({
15836
- code: "custom",
15837
- message: "Thread ownership-list IDs must be unique",
15838
- path: ["threadIds", index]
15839
- });
15840
- }
15841
- seen.add(threadId);
15842
- }
15917
+ var hostExtensionInstallationSchema = external_exports.strictObject({
15918
+ ...active,
15919
+ manifest: hostExtensionManifestV2Schema,
15920
+ installedAt: external_exports.iso.datetime(),
15921
+ source: hostExtensionProvenanceSchema.optional()
15843
15922
  });
15844
- var codexThreadOwnershipSchema = external_exports.object({
15845
- threadId: hostThreadIdSchema,
15846
- owner: external_exports.literal("codex")
15847
- }).strict();
15848
- var externalThreadOwnershipSchema = external_exports.object({
15849
- threadId: hostThreadIdSchema,
15850
- owner: external_exports.literal("external"),
15851
- harnessId: external_exports.string().max(256).pipe(harnessIdSchema)
15852
- }).strict();
15853
- var threadOwnershipSchema = external_exports.discriminatedUnion("owner", [
15854
- codexThreadOwnershipSchema,
15855
- externalThreadOwnershipSchema
15923
+ var rasterDataUrlSchema = (maxBytes) => external_exports.string().max("data:image/jpeg;base64,".length + 4 * Math.ceil(maxBytes / 3)).regex(/^data:image\/(?:png|jpeg|webp);base64,[A-Za-z0-9+/]+={0,2}$/u);
15924
+ var desktopConflict = { desktopConflictWith: hostExtensionIdSchema.optional() };
15925
+ var backendState = external_exports.enum(["none", "inactive", "starting", "running", "failed"]);
15926
+ var hostExtensionListItemSchema = external_exports.discriminatedUnion("state", [
15927
+ hostExtensionInstallationSchema.extend({
15928
+ state: external_exports.literal("valid"),
15929
+ enabled: external_exports.boolean(),
15930
+ ...desktopConflict,
15931
+ iconDataUrl: rasterDataUrlSchema(DESKTOP_EXTENSION_ICON_MAX_BYTES).optional(),
15932
+ screenshotDataUrls: external_exports.array(rasterDataUrlSchema(DESKTOP_EXTENSION_SCREENSHOT_MAX_BYTES)).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).optional(),
15933
+ backendState: backendState.optional(),
15934
+ backendError: external_exports.string().optional()
15935
+ }),
15936
+ external_exports.strictObject({
15937
+ state: external_exports.enum(["invalid", "incompatible"]),
15938
+ id: external_exports.string().min(1),
15939
+ enabled: external_exports.boolean(),
15940
+ error: external_exports.string()
15941
+ })
15856
15942
  ]);
15857
- var threadOwnershipListResultSchema = external_exports.object({
15858
- threads: external_exports.array(threadOwnershipSchema).min(1).max(THREAD_OWNERSHIP_LIST_MAX_LENGTH)
15859
- }).strict().superRefine(({ threads }, context) => {
15860
- const seen = /* @__PURE__ */ new Set();
15861
- for (const [index, thread2] of threads.entries()) {
15862
- if (seen.has(thread2.threadId)) {
15863
- context.addIssue({
15864
- code: "custom",
15865
- message: "Thread ownership-list results must be unique",
15866
- path: ["threads", index, "threadId"]
15867
- });
15868
- }
15869
- seen.add(thread2.threadId);
15870
- }
15943
+ var hostExtensionsListResultSchema = external_exports.strictObject({
15944
+ revision: hostExtensionRevisionSchema,
15945
+ configuration: hostExtensionConfigurationSchema,
15946
+ diagnostics: external_exports.array(external_exports.string()),
15947
+ extensions: external_exports.array(hostExtensionListItemSchema)
15948
+ });
15949
+ var hostExtensionRuntimeEntrySchema = hostExtensionInstallationSchema.extend({
15950
+ ...desktopConflict,
15951
+ settingsRevision: hostExtensionRevisionSchema
15952
+ });
15953
+ var hostExtensionsSnapshotResultSchema = external_exports.strictObject({
15954
+ /** The Host publishes this revision in extensions-changed, independent of enabled.json's revision. */
15955
+ revision: hostExtensionRevisionSchema,
15956
+ // Enabled, valid activations only. A Desktop conflict does not hide other capabilities.
15957
+ extensions: external_exports.array(hostExtensionRuntimeEntrySchema).max(DESKTOP_EXTENSION_LIMIT)
15958
+ });
15959
+ var HOST_EXTENSIONS_RPC = {
15960
+ list: "codexhost/extensions/list",
15961
+ snapshot: "codexhost/extensions/snapshot",
15962
+ catalog: "codexhost/extensions/catalog",
15963
+ install: "codexhost/extensions/install",
15964
+ update: "codexhost/extensions/update",
15965
+ enable: "codexhost/extensions/enable",
15966
+ disable: "codexhost/extensions/disable",
15967
+ uninstall: "codexhost/extensions/uninstall",
15968
+ recover: "codexhost/extensions/recover",
15969
+ asset: "codexhost/extensions/asset",
15970
+ settingsGet: "codexhost/extensions/settings/get",
15971
+ settingsSet: "codexhost/extensions/settings/set",
15972
+ backendInvoke: "codexhost/extensions/backend/invoke"
15973
+ };
15974
+ var HOST_EXTENSION_MANAGEMENT_METHODS = Object.freeze(Object.values(HOST_EXTENSIONS_RPC));
15975
+ var methods = new Set(HOST_EXTENSION_MANAGEMENT_METHODS);
15976
+ var noParams = external_exports.strictObject({});
15977
+ var expectedRevision = { expectedRevision: hostExtensionRevisionSchema };
15978
+ var selection = external_exports.strictObject({ ...id, ...expectedRevision });
15979
+ var installationResult = hostExtensionInstallationSchema.extend({ replaced: external_exports.boolean() });
15980
+ var mutationResult = external_exports.discriminatedUnion("state", [
15981
+ external_exports.strictObject({ state: external_exports.literal("saved"), configuration: hostExtensionConfigurationSchema }),
15982
+ external_exports.strictObject({ state: external_exports.literal("revision-conflict"), revision: hostExtensionRevisionSchema })
15983
+ ]);
15984
+ var hostExtensionsAssetParamsSchema = external_exports.strictObject({
15985
+ ...optionalActivation,
15986
+ digest: active.digest.optional(),
15987
+ path: hostExtensionResourcePathSchema
15988
+ });
15989
+ var hostExtensionsAssetResultSchema = external_exports.strictObject({
15990
+ mimeType: external_exports.string().min(1),
15991
+ base64: base643(DESKTOP_EXTENSION_ASSET_MAX_BYTES),
15992
+ digest: active.digest
15993
+ });
15994
+ var hostExtensionSettingsSchema = external_exports.strictObject({
15995
+ settingsRevision: hostExtensionRevisionSchema,
15996
+ values: jsonObjectSchema
15871
15997
  });
15872
- var threadSteeringInspectParamsSchema = external_exports.object({
15873
- threadId: hostThreadIdSchema,
15874
- /** The text about to be steered; a Harness command always stops and restarts. */
15875
- text: external_exports.string().optional()
15876
- }).strict();
15877
- var threadSteeringContextSchema = external_exports.object({
15878
- kind: external_exports.literal("application"),
15879
- value: external_exports.string().transform((text2, context) => {
15880
- try {
15881
- return JSON.parse(text2);
15882
- } catch {
15883
- context.addIssue({ code: "custom", message: "Invalid steering context JSON" });
15884
- return external_exports.NEVER;
15885
- }
15886
- }).pipe(external_exports.object({
15887
- expectedTurnId: hostTurnIdSchema,
15888
- clientUserMessageId: external_exports.string().min(1),
15889
- delivery: external_exports.enum(["newTurn", "activeTurn"])
15890
- }).strict())
15891
- }).strict().transform((context) => context.value);
15892
- var threadSteerDeliverySchema = external_exports.enum(["activeTurn", "newTurn"]);
15893
- var threadSteeringInspectResultSchema = external_exports.object({
15894
- delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
15895
- }).strict();
15998
+ var hostExtensionsRpcSchemas = {
15999
+ [HOST_EXTENSIONS_RPC.list]: { params: noParams, result: hostExtensionsListResultSchema },
16000
+ [HOST_EXTENSIONS_RPC.snapshot]: { params: noParams, result: hostExtensionsSnapshotResultSchema },
16001
+ [HOST_EXTENSIONS_RPC.catalog]: {
16002
+ params: external_exports.strictObject({ forceRefresh: external_exports.boolean().optional() }),
16003
+ result: hostExtensionsCatalogResultSchema
16004
+ },
16005
+ [HOST_EXTENSIONS_RPC.install]: {
16006
+ params: external_exports.strictObject({ source: hostExtensionInstallSourceSchema }),
16007
+ result: installationResult
16008
+ },
16009
+ [HOST_EXTENSIONS_RPC.update]: {
16010
+ params: external_exports.strictObject({
16011
+ ...id,
16012
+ expectedDigest: active.digest,
16013
+ expectedActivationId: active.activationId.optional(),
16014
+ source: hostExtensionInstallSourceSchema.optional()
16015
+ }),
16016
+ result: installationResult
16017
+ },
16018
+ [HOST_EXTENSIONS_RPC.enable]: { params: selection, result: mutationResult },
16019
+ [HOST_EXTENSIONS_RPC.disable]: { params: selection, result: mutationResult },
16020
+ [HOST_EXTENSIONS_RPC.uninstall]: {
16021
+ params: external_exports.strictObject({
16022
+ ...id,
16023
+ removeData: external_exports.boolean().optional(),
16024
+ expectedDigest: active.digest.optional()
16025
+ }),
16026
+ result: external_exports.strictObject({ ...id, removed: external_exports.boolean() })
16027
+ },
16028
+ [HOST_EXTENSIONS_RPC.recover]: {
16029
+ params: external_exports.strictObject({ expectedRevision: expectedRevision.expectedRevision.optional() }),
16030
+ result: mutationResult
16031
+ },
16032
+ [HOST_EXTENSIONS_RPC.asset]: {
16033
+ params: hostExtensionsAssetParamsSchema,
16034
+ result: hostExtensionsAssetResultSchema
16035
+ },
16036
+ [HOST_EXTENSIONS_RPC.settingsGet]: {
16037
+ params: external_exports.strictObject(optionalActivation),
16038
+ result: hostExtensionSettingsSchema
16039
+ },
16040
+ [HOST_EXTENSIONS_RPC.settingsSet]: {
16041
+ params: external_exports.strictObject({
16042
+ ...optionalActivation,
16043
+ expectedSettingsRevision: hostExtensionRevisionSchema,
16044
+ values: jsonObjectSchema
16045
+ }),
16046
+ result: hostExtensionSettingsSchema
16047
+ },
16048
+ [HOST_EXTENSIONS_RPC.backendInvoke]: {
16049
+ params: external_exports.strictObject({
16050
+ ...optionalActivation,
16051
+ method: hostExtensionBackendMethodSchema,
16052
+ params: jsonValueSchema.optional()
16053
+ }),
16054
+ result: external_exports.strictObject({ result: jsonValueSchema })
16055
+ }
16056
+ };
15896
16057
 
15897
16058
  // ../../shared-contracts/dist/thread-archive-confirm.js
15898
16059
  var THREAD_ARCHIVE_CONFIRM_METHOD = "codexhost/thread/archive/confirm";
@@ -15938,6 +16099,8 @@ var CLIENT_CHANNEL_METHODS = [
15938
16099
  "codexhost/workspace/read",
15939
16100
  "codexhost/thread/tree/read",
15940
16101
  "codexhost/thread/pins/list",
16102
+ "codexhost/thread/sections/list",
16103
+ "codexhost/thread/sections/move",
15941
16104
  "codexhost/thread/pins/set",
15942
16105
  "codexhost/harness/plugins/list",
15943
16106
  "codexhost/harness/inspect",
@@ -15955,7 +16118,7 @@ var CLIENT_CHANNEL_METHODS = [
15955
16118
  "codexhost/harness/session-import/list",
15956
16119
  "codexhost/harness/session-import/import",
15957
16120
  // Host settings shared across Desktop and Web.
15958
- ...DESKTOP_EXTENSION_MANAGEMENT_METHODS,
16121
+ ...HOST_EXTENSION_MANAGEMENT_METHODS,
15959
16122
  "codexhost/harness/installation",
15960
16123
  "codexhost/harness/installation/start",
15961
16124
  "codexhost/harness/installation/status",
@@ -15976,8 +16139,21 @@ var CLIENT_CHANNEL_METHODS = [
15976
16139
  "codexhost/update/check",
15977
16140
  "codexhost/update/start",
15978
16141
  "codexhost/update/status",
16142
+ "codexhost/announcement/get",
16143
+ "codexhost/announcement/acknowledge",
15979
16144
  "codexhost/sessions/loaded/list"
15980
16145
  ];
16146
+ var clientThreadSectionsSchema = external_exports.object({
16147
+ sections: external_exports.array(external_exports.object({
16148
+ id: external_exports.string().min(1),
16149
+ name: external_exports.string().min(1),
16150
+ threads: external_exports.array(jsonObjectSchema)
16151
+ }).strict())
16152
+ }).strict();
16153
+ var clientThreadSectionMoveSchema = external_exports.object({
16154
+ threadId: external_exports.string().min(1).max(1024),
16155
+ sectionId: external_exports.string().min(1).max(1024).nullable()
16156
+ }).strict();
15981
16157
  var clientThreadPinsSchema = external_exports.object({ threadIds: external_exports.array(external_exports.string().min(1)) }).strict();
15982
16158
  var clientThreadPinParamsSchema = external_exports.object({ threadId: external_exports.string().min(1).max(1024), pinned: external_exports.boolean() }).strict();
15983
16159
  var clientThreadTreeReadParamsSchema = external_exports.object({}).strict();
@@ -16016,6 +16192,11 @@ var clientChannelEventSchema = external_exports.discriminatedUnion("type", [
16016
16192
  cursor: clientChannelCursorSchema,
16017
16193
  revision: external_exports.number().int().nonnegative()
16018
16194
  }),
16195
+ external_exports.object({
16196
+ type: external_exports.literal("extensions-changed"),
16197
+ cursor: clientChannelCursorSchema,
16198
+ revision: hostExtensionRevisionSchema
16199
+ }),
16019
16200
  external_exports.object({
16020
16201
  type: external_exports.literal("hello"),
16021
16202
  version: external_exports.literal(1),
@@ -16452,7 +16633,7 @@ var DEFAULT_IDLE_RELEASE_SETTINGS = Object.freeze({
16452
16633
 
16453
16634
  // ../../shared-contracts/dist/harness-preferences.js
16454
16635
  var harnessPreferenceScopeSchema = external_exports.string().regex(/^external$/u);
16455
- var preferenceHarnessKey = harnessIdSchema.transform((id) => String(id));
16636
+ var preferenceHarnessKey = harnessIdSchema.transform((id2) => String(id2));
16456
16637
  var harnessDefaultConfigurationSchema = external_exports.strictObject({
16457
16638
  model: harnessModelRefSchema.optional(),
16458
16639
  thinkingOptionId: harnessThinkingOptionIdSchema.optional(),
@@ -16462,11 +16643,19 @@ var newThreadDefaultsSchema = external_exports.strictObject({
16462
16643
  lastHarness: harnessIdSchema.optional(),
16463
16644
  byHarness: external_exports.record(preferenceHarnessKey, harnessDefaultConfigurationSchema)
16464
16645
  });
16646
+ var harnessDelegationDefaultSchema = external_exports.strictObject({
16647
+ model: harnessModelRefSchema.optional(),
16648
+ thinkingOptionId: harnessThinkingOptionIdSchema.optional()
16649
+ }).refine((value) => Boolean(value.model || value.thinkingOptionId), "A delegation default must contain a Model or Thinking option");
16650
+ var delegationDefaultsSchema = external_exports.strictObject({
16651
+ byHarness: external_exports.record(preferenceHarnessKey, harnessDelegationDefaultSchema)
16652
+ });
16465
16653
  var modelId = external_exports.string().min(1).max(1024);
16466
16654
  var harnessPreferenceValuesSchema = external_exports.strictObject({
16467
16655
  idleRelease: idleReleaseSettingsSchema.optional(),
16468
16656
  favorites: external_exports.record(preferenceHarnessKey, external_exports.array(modelId).max(2048)).default({}),
16469
- newThread: newThreadDefaultsSchema.optional()
16657
+ newThread: newThreadDefaultsSchema.optional(),
16658
+ delegation: delegationDefaultsSchema.optional()
16470
16659
  });
16471
16660
  var harnessPreferenceSnapshotSchema = external_exports.strictObject({
16472
16661
  scope: harnessPreferenceScopeSchema,
@@ -16494,6 +16683,11 @@ var harnessPreferenceOperationSchema = external_exports.discriminatedUnion("kind
16494
16683
  lastHarness: harnessIdSchema.optional(),
16495
16684
  harnessId: harnessIdSchema.optional(),
16496
16685
  configuration: harnessDefaultConfigurationSchema.optional()
16686
+ }),
16687
+ external_exports.strictObject({
16688
+ kind: external_exports.literal("delegation"),
16689
+ harnessId: harnessIdSchema,
16690
+ configuration: harnessDelegationDefaultSchema.nullable()
16497
16691
  })
16498
16692
  ]);
16499
16693
  var harnessPreferencePatchSchema = external_exports.strictObject({
@@ -16501,8 +16695,8 @@ var harnessPreferencePatchSchema = external_exports.strictObject({
16501
16695
  operations: external_exports.array(harnessPreferenceOperationSchema).min(1).max(256),
16502
16696
  initializeOnly: external_exports.boolean().optional(),
16503
16697
  expectedRevision: external_exports.number().int().nonnegative().optional()
16504
- }).superRefine((input, ctx) => {
16505
- for (const operation of input.operations) {
16698
+ }).superRefine((input2, ctx) => {
16699
+ for (const operation of input2.operations) {
16506
16700
  if (operation.kind === "newThread" && (!operation.lastHarness && !operation.configuration || Boolean(operation.harnessId) !== Boolean(operation.configuration)))
16507
16701
  ctx.addIssue({
16508
16702
  code: "custom",
@@ -16904,13 +17098,18 @@ var harnessLaunchSettingsSchema = external_exports.object({
16904
17098
  // ../../shared-contracts/dist/harness-installation.js
16905
17099
  var harnessInstallationParamsSchema = external_exports.object({
16906
17100
  harnessId: harnessIdSchema,
16907
- action: external_exports.enum(["check", "update", "install"])
16908
- }).strict();
17101
+ action: external_exports.enum(["check", "update", "install"]),
17102
+ confirmedVersion: external_exports.string().min(1).max(128).optional()
17103
+ }).strict().refine(({ action, confirmedVersion }) => action === "update" || confirmedVersion === void 0);
16909
17104
  var harnessInstallationStateSchema = external_exports.object({
16910
17105
  currentVersion: external_exports.string().min(1).max(128),
16911
17106
  latestVersion: external_exports.string().min(1).max(128),
16912
17107
  updateAvailable: external_exports.boolean(),
16913
17108
  canUpdate: external_exports.boolean(),
17109
+ /** Present when the Adapter has a verified list and the available target is outside it. */
17110
+ latestVerifiedVersion: external_exports.string().min(1).max(128).optional(),
17111
+ /** Update preflight stopped before running the installer; latestVersion needs confirmation. */
17112
+ confirmationRequired: external_exports.literal(true).optional(),
16914
17113
  /** Defaults to CLI; some Harnesses ship only inside a desktop application. */
16915
17114
  versionKind: external_exports.enum(["cli", "application"]).optional(),
16916
17115
  /** Official download opened by the user; does not imply an automatic installation. */
@@ -17240,6 +17439,38 @@ var updateStatusResultSchema = external_exports.strictObject({
17240
17439
  status: updateStatusSchema.nullable()
17241
17440
  });
17242
17441
 
17442
+ // ../../shared-contracts/dist/release-announcement.js
17443
+ var RELEASE_ANNOUNCEMENT_MAX_THEMES = 12;
17444
+ var releaseAnnouncementThemeSchema = external_exports.strictObject({
17445
+ icon: external_exports.string().min(1).max(16).optional(),
17446
+ title: external_exports.string().min(1).max(120),
17447
+ body: external_exports.string().min(1).max(1200),
17448
+ contributors: external_exports.array(external_exports.string().min(1).max(39)).max(30)
17449
+ });
17450
+ var releaseAnnouncementContentSchema = external_exports.strictObject({
17451
+ summary: external_exports.string().min(1).max(600).optional(),
17452
+ themes: external_exports.array(releaseAnnouncementThemeSchema).min(1).max(RELEASE_ANNOUNCEMENT_MAX_THEMES)
17453
+ });
17454
+ var releaseAnnouncementSchema = external_exports.strictObject({
17455
+ version: updateSemanticVersionSchema,
17456
+ publishedAt: external_exports.iso.datetime(),
17457
+ url: external_exports.string().max(300).regex(/^https:\/\/github\.com\/BytePioneer-AI\/codex-host\/releases\/tag\/v[0-9A-Za-z.+-]+$/u),
17458
+ zh: releaseAnnouncementContentSchema.nullable(),
17459
+ en: releaseAnnouncementContentSchema.nullable()
17460
+ }).refine((value) => value.zh !== null || value.en !== null, {
17461
+ message: "an announcement needs at least one language"
17462
+ });
17463
+ var releaseAnnouncementGetParamsSchema = external_exports.strictObject({
17464
+ manual: external_exports.boolean().optional()
17465
+ });
17466
+ var releaseAnnouncementGetResultSchema = external_exports.strictObject({
17467
+ announcement: releaseAnnouncementSchema.nullable(),
17468
+ unread: external_exports.boolean()
17469
+ });
17470
+ var releaseAnnouncementAcknowledgeParamsSchema = external_exports.strictObject({
17471
+ version: updateSemanticVersionSchema
17472
+ });
17473
+
17243
17474
  // ../../shared-contracts/dist/thread-watch-notice.js
17244
17475
  var THREAD_WATCH_NOTICE_OUTCOMES = [
17245
17476
  "completed",
@@ -17287,17 +17518,67 @@ var remoteSshSetupResultSchema = external_exports.object({ state: external_expor
17287
17518
 
17288
17519
  // ../../shared-contracts/dist/remote-sessions.js
17289
17520
  var REMOTE_CONTROLLER_REQUEST_MAX_BYTES = 16 * 1024;
17290
- var identity = external_exports.string().min(1).max(1024);
17521
+ var REMOTE_IDENTITY_MAX_LENGTH = 1024;
17522
+ var identity = external_exports.string().min(1).max(REMOTE_IDENTITY_MAX_LENGTH);
17291
17523
  var target = { hostId: identity.regex(/^remote-(?:ssh(?:-|:)|control:)/u) };
17292
17524
  var thread = { ...target, threadId: identity };
17525
+ var text = external_exports.string().min(1).max(8e3);
17526
+ var input = { text, requestId: identity };
17527
+ var remoteDeliveryReplySchema = external_exports.discriminatedUnion("accepted", [
17528
+ external_exports.object({ accepted: external_exports.literal(true), startQueuedItemId: identity.optional() }),
17529
+ external_exports.object({
17530
+ accepted: external_exports.literal(false),
17531
+ code: external_exports.enum([
17532
+ "remote/queue-unavailable",
17533
+ "remote/steer-unavailable",
17534
+ "remote/turn-changed",
17535
+ "remote/send-rejected",
17536
+ "session/queue-item-not-found",
17537
+ "session/queue-item-starting"
17538
+ ]),
17539
+ message: external_exports.string()
17540
+ })
17541
+ ]);
17542
+ var remoteQueueSnapshotSchema = external_exports.discriminatedUnion("available", [
17543
+ external_exports.object({ available: external_exports.literal(false) }),
17544
+ external_exports.object({
17545
+ available: external_exports.literal(true),
17546
+ items: external_exports.array(external_exports.object({ id: identity, clientUserMessageId: identity, preview: external_exports.string().max(801) })).max(100)
17547
+ })
17548
+ ]);
17293
17549
  var remoteSessionOperationSchema = external_exports.discriminatedUnion("kind", [
17294
17550
  external_exports.strictObject({ kind: external_exports.literal("hosts") }),
17551
+ external_exports.strictObject({
17552
+ kind: external_exports.literal("create"),
17553
+ ...target,
17554
+ cwd: external_exports.string().min(1).max(8192),
17555
+ epoch: identity
17556
+ }),
17557
+ external_exports.strictObject({ kind: external_exports.literal("projectHarnesses"), ...target, epoch: identity }),
17558
+ external_exports.strictObject({
17559
+ kind: external_exports.literal("inspectHarness"),
17560
+ ...target,
17561
+ epoch: identity,
17562
+ cwd: external_exports.string().min(1).max(8192),
17563
+ harnessId: identity
17564
+ }),
17565
+ external_exports.strictObject({
17566
+ kind: external_exports.literal("startSelected"),
17567
+ ...target,
17568
+ epoch: identity,
17569
+ cwd: external_exports.string().min(1).max(8192),
17570
+ harnessId: identity,
17571
+ model: external_exports.string().min(1).max(4096),
17572
+ serviceTier: external_exports.enum(["priority", "ultrafast"]).optional(),
17573
+ reasoningEffort: identity.optional()
17574
+ }),
17295
17575
  external_exports.strictObject({ kind: external_exports.literal("status"), ...thread }),
17296
17576
  external_exports.strictObject({
17297
17577
  kind: external_exports.literal("list"),
17298
17578
  ...target,
17299
17579
  cursor: external_exports.string().nullable(),
17300
- archived: external_exports.boolean()
17580
+ archived: external_exports.boolean(),
17581
+ includeLoaded: external_exports.literal(true).optional()
17301
17582
  }),
17302
17583
  external_exports.strictObject({
17303
17584
  kind: external_exports.literal("read"),
@@ -17317,16 +17598,35 @@ var remoteSessionOperationSchema = external_exports.discriminatedUnion("kind", [
17317
17598
  ...thread,
17318
17599
  epoch: identity,
17319
17600
  modelId: identity.optional(),
17601
+ serviceTier: harnessModelServiceTierSchema.optional(),
17320
17602
  thinkingOptionId: identity.optional(),
17321
17603
  permissionModeId: identity.optional()
17322
- }).refine((value) => [value.modelId, value.thinkingOptionId, value.permissionModeId].filter((v) => v !== void 0).length === 1, "Select exactly one remote setting"),
17604
+ }).refine((value) => [value.modelId, value.thinkingOptionId, value.permissionModeId].filter((v) => v !== void 0).length === 1, "Select exactly one remote setting").refine((value) => value.serviceTier === void 0 || value.modelId !== void 0, {
17605
+ message: "A service tier requires a Model ID"
17606
+ }),
17323
17607
  external_exports.strictObject({
17324
17608
  kind: external_exports.literal("prompt"),
17325
17609
  ...thread,
17326
17610
  epoch: identity,
17327
- text: external_exports.string().min(1).max(8e3),
17611
+ text,
17328
17612
  requestId: identity.optional()
17329
17613
  }),
17614
+ external_exports.strictObject({ kind: external_exports.literal("queue"), ...thread, epoch: identity }),
17615
+ external_exports.strictObject({
17616
+ kind: external_exports.literal("delivery"),
17617
+ ...thread,
17618
+ epoch: identity,
17619
+ action: external_exports.discriminatedUnion("kind", [
17620
+ external_exports.strictObject({ kind: external_exports.literal("enqueue"), ...input }),
17621
+ external_exports.strictObject({ kind: external_exports.literal("steer"), ...input, turnId: identity }),
17622
+ external_exports.strictObject({ kind: external_exports.literal("remove"), itemId: identity }),
17623
+ external_exports.strictObject({
17624
+ kind: external_exports.literal("start"),
17625
+ itemId: identity,
17626
+ onlyIfHead: external_exports.literal(true).optional()
17627
+ })
17628
+ ])
17629
+ }),
17330
17630
  external_exports.strictObject({ kind: external_exports.literal("interrupt"), ...thread, epoch: identity, turnId: identity }),
17331
17631
  external_exports.strictObject({
17332
17632
  kind: external_exports.literal("rename"),
@@ -17369,7 +17669,7 @@ var remoteConnectionsRequestSchema = external_exports.discriminatedUnion("action
17369
17669
  external_exports.strictObject({ action: external_exports.literal("catalog") }),
17370
17670
  external_exports.strictObject({
17371
17671
  action: external_exports.literal("read-thread"),
17372
- hostId: hostId.refine((id) => id !== "local"),
17672
+ hostId: hostId.refine((id2) => id2 !== "local"),
17373
17673
  input: delegationReadParamsSchema
17374
17674
  }),
17375
17675
  external_exports.strictObject({
@@ -17383,7 +17683,7 @@ var remoteConnectionsRequestSchema = external_exports.discriminatedUnion("action
17383
17683
  external_exports.strictObject({ action: external_exports.literal("runtime"), hostId }),
17384
17684
  external_exports.strictObject({
17385
17685
  action: external_exports.literal("update"),
17386
- hostId: hostId.refine((id) => id !== "local"),
17686
+ hostId: hostId.refine((id2) => id2 !== "local"),
17387
17687
  version: remoteUpdateParamsSchema.shape.version
17388
17688
  })
17389
17689
  ]);
@@ -17447,7 +17747,7 @@ function invalidRequest(message) {
17447
17747
  return { code: "invalidRequest", message, retryable: false };
17448
17748
  }
17449
17749
  function validateHostApprovalResponse(interaction, response) {
17450
- return interaction.actions.some(({ id }) => id === response.actionId) ? null : invalidRequest("Approval Response contains an undeclared action ID");
17750
+ return interaction.actions.some(({ id: id2 }) => id2 === response.actionId) ? null : invalidRequest("Approval Response contains an undeclared action ID");
17451
17751
  }
17452
17752
 
17453
17753
  // ../../harness-adapter/dist/question.js
@@ -17455,7 +17755,7 @@ function invalidRequest2(message) {
17455
17755
  return { code: "invalidRequest", message, retryable: false };
17456
17756
  }
17457
17757
  function validateHostQuestionResponse(interaction, response) {
17458
- const questionIds = new Set(interaction.questions.map(({ id }) => id));
17758
+ const questionIds = new Set(interaction.questions.map(({ id: id2 }) => id2));
17459
17759
  if (response.cancelled) {
17460
17760
  return Object.keys(response.answers).length === 0 ? null : invalidRequest2("Cancelled Question Response must not contain answers");
17461
17761
  }
@@ -17486,6 +17786,18 @@ function validateHostQuestionResponse(interaction, response) {
17486
17786
  return null;
17487
17787
  }
17488
17788
 
17789
+ // ../../harness-adapter/dist/legacy-model-ref.js
17790
+ import { Buffer as Buffer2 } from "node:buffer";
17791
+ function normalizeLegacyBase64ModelRef(ref, catalog, prefix) {
17792
+ if (ref.serviceTier || !ref.id.startsWith(prefix))
17793
+ return void 0;
17794
+ const encoded = ref.id.slice(prefix.length);
17795
+ const id2 = Buffer2.from(encoded, "base64url").toString("utf8");
17796
+ if (Buffer2.from(id2).toString("base64url") !== encoded)
17797
+ return void 0;
17798
+ return catalog.models.find(({ ref: ref2 }) => ref2.id === id2 && !ref2.serviceTier)?.ref;
17799
+ }
17800
+
17489
17801
  // ../../harness-adapter/dist/output-channel.js
17490
17802
  var HarnessOutputChannel = class {
17491
17803
  outputs;
@@ -17570,7 +17882,8 @@ var tokenFields = [
17570
17882
  var safeIntegerFields = [
17571
17883
  "planFiveHourResetsAtUnix",
17572
17884
  "planSevenDayResetsAtUnix",
17573
- "timeToFirstOutputMs"
17885
+ "timeToFirstOutputMs",
17886
+ "latestRequestTimeToFirstOutputMs"
17574
17887
  ];
17575
17888
  var percentFields = [
17576
17889
  "cacheHitRatePercent",
@@ -17780,21 +18093,11 @@ async function hermesPythonCommand(runtime, script, environment, timeoutMs = 2e4
17780
18093
  function isHermesModeId(value) {
17781
18094
  return value === "default" || value === "dont_ask";
17782
18095
  }
17783
- function encodeHermesModelRef(modelId2) {
17784
- const ref = harnessModelRefSchema.safeParse({
17785
- id: Buffer.from(modelId2, "utf8").toString("base64url")
17786
- });
17787
- return ref.success ? ref.data : null;
18096
+ function hermesModelRef(id2) {
18097
+ return harnessModelRefSchema.safeParse({ id: id2 }).data ?? null;
17788
18098
  }
17789
- function decodeHermesModelRefId(modelRefId) {
17790
- if (!/^[A-Za-z0-9_-]+$/.test(modelRefId))
17791
- return null;
17792
- try {
17793
- const decoded = Buffer.from(modelRefId, "base64url").toString("utf8");
17794
- return decoded.length > 0 ? decoded : null;
17795
- } catch {
17796
- return null;
17797
- }
18099
+ function normalizeStoredHermesModelRef(ref, catalog) {
18100
+ return normalizeLegacyBase64ModelRef(ref, catalog, "");
17798
18101
  }
17799
18102
  function catalogAlignedModelLabel(name) {
17800
18103
  return name.replace(/\s+·\s+/g, " / ");
@@ -17807,7 +18110,7 @@ function projectHermesModelState(models) {
17807
18110
  if (!current)
17808
18111
  return { effectiveModel: null, resolvedModelLabel: null };
17809
18112
  return {
17810
- effectiveModel: encodeHermesModelRef(current.modelId),
18113
+ effectiveModel: hermesModelRef(current.modelId),
17811
18114
  resolvedModelLabel: catalogAlignedModelLabel(current.name)
17812
18115
  };
17813
18116
  }
@@ -18052,7 +18355,7 @@ function catalogModelsFromInventory(inventory) {
18052
18355
  if (model2.available === false)
18053
18356
  continue;
18054
18357
  const nativeModelId = model2.modelId;
18055
- const ref = encodeHermesModelRef(nativeModelId);
18358
+ const ref = hermesModelRef(nativeModelId);
18056
18359
  if (!ref)
18057
18360
  continue;
18058
18361
  if (inventory.currentModelId && (model2.modelId === inventory.currentModelId || nativeModelId === inventory.currentModelId || model2.modelIdAliases?.includes(inventory.currentModelId))) {
@@ -18310,7 +18613,7 @@ var HermesGatewayTransport = class _HermesGatewayTransport {
18310
18613
  environment;
18311
18614
  timeoutMs;
18312
18615
  onEvent = () => void 0;
18313
- onRequest = (id) => this.rejectRequest(id);
18616
+ onRequest = (id2) => this.rejectRequest(id2);
18314
18617
  onFault = () => void 0;
18315
18618
  #child = null;
18316
18619
  #nextId = 0;
@@ -18457,10 +18760,10 @@ var HermesGatewayTransport = class _HermesGatewayTransport {
18457
18760
  async request(method, params, timeoutMs = this.timeoutMs, fatalOnTimeout = true) {
18458
18761
  if (this.#closed || !this.#child)
18459
18762
  throw new Error("Hermes gateway is closed");
18460
- const id = `codexhost-${++this.#nextId}`;
18763
+ const id2 = `codexhost-${++this.#nextId}`;
18461
18764
  const response = new Promise((resolve, reject) => {
18462
- this.#pending.set(id, { resolve, reject });
18463
- this.#send({ jsonrpc: "2.0", id, method, params });
18765
+ this.#pending.set(id2, { resolve, reject });
18766
+ this.#send({ jsonrpc: "2.0", id: id2, method, params });
18464
18767
  });
18465
18768
  try {
18466
18769
  return await withTimeout(response, timeoutMs, `Hermes ${method}`);
@@ -18469,16 +18772,16 @@ var HermesGatewayTransport = class _HermesGatewayTransport {
18469
18772
  this.#fault(error51);
18470
18773
  throw error51;
18471
18774
  } finally {
18472
- this.#pending.delete(id);
18775
+ this.#pending.delete(id2);
18473
18776
  }
18474
18777
  }
18475
- respond(id, result) {
18476
- this.#send({ jsonrpc: "2.0", id, result });
18778
+ respond(id2, result) {
18779
+ this.#send({ jsonrpc: "2.0", id: id2, result });
18477
18780
  }
18478
- rejectRequest(id) {
18781
+ rejectRequest(id2) {
18479
18782
  this.#send({
18480
18783
  jsonrpc: "2.0",
18481
- id,
18784
+ id: id2,
18482
18785
  error: { code: -32601, message: "Unsupported Host interaction" }
18483
18786
  });
18484
18787
  }
@@ -18507,11 +18810,11 @@ var HermesGatewayTransport = class _HermesGatewayTransport {
18507
18810
  this.onRequest(frame.id, frame.method, gatewayRecord(frame.params));
18508
18811
  return;
18509
18812
  }
18510
- const id = gatewayString(frame.id);
18511
- const pending = this.#pending.get(id);
18813
+ const id2 = gatewayString(frame.id);
18814
+ const pending = this.#pending.get(id2);
18512
18815
  if (!pending)
18513
18816
  return;
18514
- this.#pending.delete(id);
18817
+ this.#pending.delete(id2);
18515
18818
  if (frame.error)
18516
18819
  pending.reject(new Error(gatewayString(gatewayRecord(frame.error).message) || "Hermes gateway request failed"));
18517
18820
  else
@@ -18645,8 +18948,8 @@ var HERMES_GATEWAY_COMMANDS = [
18645
18948
  input: { hint: "Optional compression focus" }
18646
18949
  }
18647
18950
  ];
18648
- function hermesGatewayCommandName(text2, commands = HERMES_GATEWAY_COMMANDS) {
18649
- const match = /^\/([\w-]+)(?:\s+([\s\S]*))?$/u.exec(text2.trim());
18951
+ function hermesGatewayCommandName(text3, commands = HERMES_GATEWAY_COMMANDS) {
18952
+ const match = /^\/([\w-]+)(?:\s+([\s\S]*))?$/u.exec(text3.trim());
18650
18953
  const name = match?.[1]?.toLowerCase();
18651
18954
  const command = commands.find((entry) => entry.name === name && !isExcludedHermesCommand(entry.name));
18652
18955
  return command && (command.input || !match?.[2]?.trim()) ? command.name : null;
@@ -18829,18 +19132,18 @@ function projectCandidate(value) {
18829
19132
  });
18830
19133
  return parsed2.success ? parsed2.data : null;
18831
19134
  }
18832
- async function listHermesSessionCandidates(input) {
19135
+ async function listHermesSessionCandidates(input2) {
18833
19136
  const candidates = /* @__PURE__ */ new Map();
18834
- for (const row of await readHermesSessions(input)) {
19137
+ for (const row of await readHermesSessions(input2)) {
18835
19138
  const candidate = projectCandidate(row);
18836
19139
  if (candidate && !candidates.has(candidate.nativeSessionId))
18837
19140
  candidates.set(candidate.nativeSessionId, candidate);
18838
19141
  }
18839
19142
  return [...candidates.values()];
18840
19143
  }
18841
- async function resolveHermesSessionCandidate(input) {
18842
- const candidates = await listHermesSessionCandidates(input);
18843
- const candidate = candidates.find((row) => row.nativeSessionId === input.nativeSessionId);
19144
+ async function resolveHermesSessionCandidate(input2) {
19145
+ const candidates = await listHermesSessionCandidates(input2);
19146
+ const candidate = candidates.find((row) => row.nativeSessionId === input2.nativeSessionId);
18844
19147
  if (!candidate)
18845
19148
  return null;
18846
19149
  return {
@@ -18867,12 +19170,12 @@ var hermesDiscoverySpec = {
18867
19170
  windows: ["${APPDATA}/npm", "~/.local/bin", VERSION_MANAGER_ROOTS]
18868
19171
  }
18869
19172
  };
18870
- function resolveHermesExecutable(input = {}) {
18871
- const platform = input.platform ?? process.platform;
19173
+ function resolveHermesExecutable(input2 = {}) {
19174
+ const platform = input2.platform ?? process.platform;
18872
19175
  const resolution = resolveHarnessExecutable(hermesDiscoverySpec, {
18873
- ...input.command ? { command: input.command } : {},
18874
- environment: input.environment ?? process.env,
18875
- ...input.homeDirectory ? { homeDirectory: input.homeDirectory } : {},
19176
+ ...input2.command ? { command: input2.command } : {},
19177
+ environment: input2.environment ?? process.env,
19178
+ ...input2.homeDirectory ? { homeDirectory: input2.homeDirectory } : {},
18876
19179
  platform
18877
19180
  });
18878
19181
  if (!resolution)
@@ -19121,11 +19424,11 @@ print(json.dumps(result, ensure_ascii=True), file=output)
19121
19424
  function record3(value) {
19122
19425
  return value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
19123
19426
  }
19124
- function text(value) {
19427
+ function text2(value) {
19125
19428
  if (typeof value === "string")
19126
19429
  return value;
19127
19430
  if (Array.isArray(value))
19128
- return value.map((part) => text(record3(part).text)).join("\n");
19431
+ return value.map((part) => text2(record3(part).text)).join("\n");
19129
19432
  return "";
19130
19433
  }
19131
19434
  function parsed(value) {
@@ -19145,7 +19448,7 @@ function projectGatewayHistory(sessionId, data) {
19145
19448
  for (const row of data.rows) {
19146
19449
  if (!Number.isSafeInteger(row.id) || !Number.isSafeInteger(row.original_id))
19147
19450
  throw new Error("Hermes history has no durable message identity");
19148
- const id = String(row.original_id);
19451
+ const id2 = String(row.original_id);
19149
19452
  if (row.role === "user") {
19150
19453
  if (typeof row.user_text !== "string")
19151
19454
  continue;
@@ -19155,7 +19458,7 @@ function projectGatewayHistory(sessionId, data) {
19155
19458
  nativeTurnRef: nativeTurnRefSchema.parse({
19156
19459
  harnessId: "hermes",
19157
19460
  nativeSessionId: sessionId,
19158
- nativeTurnKey: id,
19461
+ nativeTurnKey: id2,
19159
19462
  formatVersion: 1
19160
19463
  }),
19161
19464
  ...boundary ? {
@@ -19180,15 +19483,15 @@ function projectGatewayHistory(sessionId, data) {
19180
19483
  }
19181
19484
  if (!turn)
19182
19485
  continue;
19183
- const itemId = (suffix) => hostItemIdSchema.parse(`hermes:${id}:${suffix}`);
19486
+ const itemId = (suffix) => hostItemIdSchema.parse(`hermes:${id2}:${suffix}`);
19184
19487
  if (row.role === "assistant") {
19185
- const reasoning = row.display_visible === false ? "" : text(row.reasoning_content) || text(row.reasoning);
19488
+ const reasoning = row.display_visible === false ? "" : text2(row.reasoning_content) || text2(row.reasoning);
19186
19489
  if (reasoning)
19187
19490
  turn.items.push({
19188
19491
  item: { type: "reasoning", itemId: itemId("reasoning"), text: reasoning },
19189
19492
  outcome: { status: "succeeded" }
19190
19493
  });
19191
- const content = typeof row.display_text === "string" ? row.display_text : text(row.content);
19494
+ const content = typeof row.display_text === "string" ? row.display_text : text2(row.content);
19192
19495
  if (content)
19193
19496
  turn.items.push({
19194
19497
  item: { type: "agentMessage", itemId: itemId("message"), text: content },
@@ -19257,15 +19560,15 @@ var HermesGatewayHistory = class {
19257
19560
  throw new Error("Missing Hermes storage identity");
19258
19561
  return data.physicalSessionId;
19259
19562
  }
19260
- async ensureCreated(input) {
19261
- await this.#run({ operation: "ensure", ...input });
19563
+ async ensureCreated(input2) {
19564
+ await this.#run({ operation: "ensure", ...input2 });
19262
19565
  }
19263
- async derive(input = {}) {
19264
- if (input.checkpoint && input.rollbackLastTurn)
19566
+ async derive(input2 = {}) {
19567
+ if (input2.checkpoint && input2.rollbackLastTurn)
19265
19568
  throw new Error("Conflicting Hermes derivation boundaries");
19266
- if (input.checkpoint && (input.checkpoint.harnessId !== "hermes" || input.checkpoint.nativeSessionId !== this.options.nativeSessionId))
19569
+ if (input2.checkpoint && (input2.checkpoint.harnessId !== "hermes" || input2.checkpoint.nativeSessionId !== this.options.nativeSessionId))
19267
19570
  throw new Error("Hermes checkpoint belongs to another session");
19268
- const data = await this.#run({ operation: "derive", ...input });
19571
+ const data = await this.#run({ operation: "derive", ...input2 });
19269
19572
  const ref = nativeSessionRefSchema.parse({
19270
19573
  harnessId: "hermes",
19271
19574
  nativeSessionId: data.sessionId,
@@ -19290,7 +19593,7 @@ var HermesGatewayHistory = class {
19290
19593
  this.#derived.delete(ref.nativeSessionId);
19291
19594
  return result.deleted === true;
19292
19595
  }
19293
- async #run(input) {
19596
+ async #run(input2) {
19294
19597
  const command = await hermesPythonCommand(this.options.python, GATEWAY_HISTORY_SCRIPT, {
19295
19598
  ...process.env,
19296
19599
  ...this.options.environment
@@ -19335,7 +19638,7 @@ var HermesGatewayHistory = class {
19335
19638
  reject(new Error("Malformed Hermes native history response"));
19336
19639
  }
19337
19640
  });
19338
- child.stdin.end(JSON.stringify({ ...input, sessionId: this.options.nativeSessionId }));
19641
+ child.stdin.end(JSON.stringify({ ...input2, sessionId: this.options.nativeSessionId }));
19339
19642
  });
19340
19643
  }
19341
19644
  };
@@ -19417,25 +19720,25 @@ var hermesGatewayThinkingOptions = [
19417
19720
  "xhigh",
19418
19721
  "max",
19419
19722
  "ultra"
19420
- ].map((id) => ({ id: harnessThinkingOptionIdSchema.parse(id), label: id }));
19723
+ ].map((id2) => ({ id: harnessThinkingOptionIdSchema.parse(id2), label: id2 }));
19421
19724
  function question(entry, fallbackId) {
19422
- const id = gatewayString(entry.qid) || fallbackId;
19725
+ const id2 = gatewayString(entry.qid) || fallbackId;
19423
19726
  const prompt = gatewayString(entry.question);
19424
19727
  if (!prompt)
19425
19728
  throw new Error("Hermes clarify request has no question");
19426
19729
  const choices = Array.isArray(entry.choices) ? entry.choices.filter((choice) => typeof choice === "string") : [];
19427
19730
  return choices.length ? {
19428
- id,
19731
+ id: id2,
19429
19732
  type: "choice",
19430
19733
  prompt,
19431
19734
  options: choices.map((value) => ({ value, label: value })),
19432
19735
  multiple: entry.multi_select === true,
19433
19736
  allowOther: true,
19434
19737
  optional: false
19435
- } : { id, type: "text", prompt, multiline: true, secret: false, optional: false };
19738
+ } : { id: id2, type: "text", prompt, multiline: true, secret: false, optional: false };
19436
19739
  }
19437
- function gatewayDiff(text2) {
19438
- if (!text2 || text2.length > 1024 * 1024)
19740
+ function gatewayDiff(text3) {
19741
+ if (!text3 || text3.length > 1024 * 1024)
19439
19742
  return [];
19440
19743
  const result = [];
19441
19744
  let path8 = "";
@@ -19452,7 +19755,7 @@ function gatewayDiff(text2) {
19452
19755
  oldLines = [];
19453
19756
  newLines = [];
19454
19757
  };
19455
- for (const raw of text2.split("\n")) {
19758
+ for (const raw of text3.split("\n")) {
19456
19759
  const line = raw.replace(/\u001b\[[0-9;]*m/gu, "");
19457
19760
  const header = /^(a\/.+|\/dev\/null) → (b\/.+|\/dev\/null)$/u.exec(line);
19458
19761
  if (header) {
@@ -19491,9 +19794,9 @@ var HermesGatewaySessionTransport = class {
19491
19794
  #commands = HERMES_GATEWAY_COMMANDS;
19492
19795
  onUsage;
19493
19796
  #knownCommands = /* @__PURE__ */ new Set();
19494
- rejectsCommand(text2) {
19495
- const name = /^\/([\w-]+)(?:\s|$)/u.exec(text2.trim())?.[1]?.toLowerCase();
19496
- return !!name && this.#knownCommands.has(name) && !this.nativeCommandName(text2);
19797
+ rejectsCommand(text3) {
19798
+ const name = /^\/([\w-]+)(?:\s|$)/u.exec(text3.trim())?.[1]?.toLowerCase();
19799
+ return !!name && this.#knownCommands.has(name) && !this.nativeCommandName(text3);
19497
19800
  }
19498
19801
  get availableCommands() {
19499
19802
  return this.#commands;
@@ -19554,8 +19857,8 @@ var HermesGatewaySessionTransport = class {
19554
19857
  nativeSessionId
19555
19858
  });
19556
19859
  transport.onEvent = (event) => this.#event(event);
19557
- transport.onRequest = (id, method, params) => {
19558
- void this.#request(id, method, params).catch((error51) => this.#fault(error51));
19860
+ transport.onRequest = (id2, method, params) => {
19861
+ void this.#request(id2, method, params).catch((error51) => this.#fault(error51));
19559
19862
  };
19560
19863
  transport.onFault = (error51) => this.#fault(error51);
19561
19864
  }
@@ -19586,7 +19889,7 @@ var HermesGatewaySessionTransport = class {
19586
19889
  ]
19587
19890
  },
19588
19891
  thinkingOptions: hermesGatewayThinkingOptions,
19589
- ...hermesGatewayThinkingOptions.some(({ id }) => id === currentThinkingOptionId) ? { currentThinkingOptionId } : {}
19892
+ ...hermesGatewayThinkingOptions.some(({ id: id2 }) => id2 === currentThinkingOptionId) ? { currentThinkingOptionId } : {}
19590
19893
  }
19591
19894
  };
19592
19895
  }
@@ -19594,7 +19897,7 @@ var HermesGatewaySessionTransport = class {
19594
19897
  return this.history.readSnapshot();
19595
19898
  }
19596
19899
  async setThinking(optionId) {
19597
- if (!hermesGatewayThinkingOptions.some(({ id }) => id === optionId))
19900
+ if (!hermesGatewayThinkingOptions.some(({ id: id2 }) => id2 === optionId))
19598
19901
  throw new Error("Unsupported Hermes reasoning effort");
19599
19902
  const result = await this.transport.request("config.set", {
19600
19903
  key: "reasoning",
@@ -19640,10 +19943,10 @@ var HermesGatewaySessionTransport = class {
19640
19943
  throw new Error("Hermes effective approval policy differs from the requested mode; check native global approvals policy");
19641
19944
  this.#info = { ...this.#info, yolo: modeId === "dont_ask" };
19642
19945
  }
19643
- nativeCommandName(text2) {
19644
- return hermesGatewayCommandName(text2, this.#commands);
19946
+ nativeCommandName(text3) {
19947
+ return hermesGatewayCommandName(text3, this.#commands);
19645
19948
  }
19646
- async runTurn(text2, emit, permission, question2) {
19949
+ async runTurn(text3, emit, permission, question2) {
19647
19950
  if (this.#active || this.#closed)
19648
19951
  throw new Error("Hermes gateway Session is unavailable");
19649
19952
  let resolveResult = () => void 0;
@@ -19653,7 +19956,7 @@ var HermesGatewaySessionTransport = class {
19653
19956
  rejectResult = reject;
19654
19957
  });
19655
19958
  void result.catch(() => void 0);
19656
- const active = {
19959
+ const active2 = {
19657
19960
  emit,
19658
19961
  permission,
19659
19962
  ...question2 ? { question: question2 } : {},
@@ -19664,10 +19967,10 @@ var HermesGatewaySessionTransport = class {
19664
19967
  toolIds: /* @__PURE__ */ new Set(),
19665
19968
  admissionId: null
19666
19969
  };
19667
- this.#active = active;
19668
- void this.#adoptedPrompts.splice(0).map((prompt) => void this.#respondAdoptedApproval(prompt, active).catch(() => void 0));
19669
- const commandText = text2.trim();
19670
- const nativeCommand = this.nativeCommandName(text2);
19970
+ this.#active = active2;
19971
+ void this.#adoptedPrompts.splice(0).map((prompt) => void this.#respondAdoptedApproval(prompt, active2).catch(() => void 0));
19972
+ const commandText = text3.trim();
19973
+ const nativeCommand = this.nativeCommandName(text3);
19671
19974
  try {
19672
19975
  if (nativeCommand === "compress") {
19673
19976
  const compact = await this.transport.request("session.compress", { session_id: this.sessionId, focus_topic: commandText.slice(9).trim() }, 3e5);
@@ -19683,7 +19986,7 @@ var HermesGatewaySessionTransport = class {
19683
19986
  throw new Error("Hermes returned an unrecognized compression outcome");
19684
19987
  this.#usage(gatewayRecord(compact.usage));
19685
19988
  const succeeded = compact.status === "compressed" && summary.noop !== true;
19686
- active.resolve({
19989
+ active2.resolve({
19687
19990
  stopReason: "end_turn",
19688
19991
  compactionOutcome: compact.status === "aborted" || summary.aborted === true ? {
19689
19992
  status: "failed",
@@ -19702,31 +20005,31 @@ var HermesGatewaySessionTransport = class {
19702
20005
  if (typeof response.output !== "string")
19703
20006
  throw new HermesTransportError("protocolError", "Hermes slash.exec did not return terminal command output");
19704
20007
  emit({ type: "agent.text", text: response.output });
19705
- active.resolve({ stopReason: "end_turn" });
20008
+ active2.resolve({ stopReason: "end_turn" });
19706
20009
  } else {
19707
20010
  const guidance = this.#delegationGuidance;
19708
20011
  this.#delegationGuidance = null;
19709
20012
  const submitted = await this.transport.request("prompt.submit", {
19710
20013
  session_id: this.sessionId,
19711
- text: text2,
20014
+ text: text3,
19712
20015
  submission_id: `codexhost-turn-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
19713
20016
  clarify_batch: true,
19714
20017
  ...guidance ? { api_text: `${guidance}
19715
20018
 
19716
- ${text2}` } : {}
20019
+ ${text3}` } : {}
19717
20020
  });
19718
20021
  if (submitted.status !== "queued" && submitted.status !== "started")
19719
20022
  this.#fault(new Error(`Hermes did not accept the turn (${String(submitted.status)})`));
19720
- else if (active.admissionId === null && typeof submitted.admission_id === "string")
19721
- active.admissionId = submitted.admission_id;
20023
+ else if (active2.admissionId === null && typeof submitted.admission_id === "string")
20024
+ active2.admissionId = submitted.admission_id;
19722
20025
  }
19723
20026
  } catch (error51) {
19724
- active.reject(error51 instanceof Error ? error51 : new Error(String(error51)));
20027
+ active2.reject(error51 instanceof Error ? error51 : new Error(String(error51)));
19725
20028
  }
19726
20029
  try {
19727
20030
  return await result;
19728
20031
  } finally {
19729
- if (this.#active === active)
20032
+ if (this.#active === active2)
19730
20033
  this.#active = null;
19731
20034
  for (const controller of this.#requests.values())
19732
20035
  controller.abort("cancelled");
@@ -19792,46 +20095,46 @@ ${text2}` } : {}
19792
20095
  return;
19793
20096
  }
19794
20097
  if (event.type === "approval.cancelled") {
19795
- const ids = Array.isArray(payload.request_ids) ? payload.request_ids.filter((id) => typeof id === "string") : [];
19796
- for (const id of ids) {
19797
- this.#approvalRequests.get(id)?.abort("cancelled");
19798
- this.#approvalRequests.delete(id);
20098
+ const ids = Array.isArray(payload.request_ids) ? payload.request_ids.filter((id2) => typeof id2 === "string") : [];
20099
+ for (const id2 of ids) {
20100
+ this.#approvalRequests.get(id2)?.abort("cancelled");
20101
+ this.#approvalRequests.delete(id2);
19799
20102
  }
19800
20103
  return;
19801
20104
  }
19802
- const active = this.#active;
19803
- if (!active) {
20105
+ const active2 = this.#active;
20106
+ if (!active2) {
19804
20107
  if (event.type === "error")
19805
20108
  this.#fault(new Error(gatewayString(payload.message)));
19806
20109
  return;
19807
20110
  }
19808
20111
  const eventAdmission = gatewayString(event.admission_id);
19809
20112
  const eventType = gatewayString(event.type);
19810
- if (eventAdmission && active.admissionId && eventAdmission !== active.admissionId) {
20113
+ if (eventAdmission && active2.admissionId && eventAdmission !== active2.admissionId) {
19811
20114
  if (eventType.startsWith("message.") || eventType.startsWith("reasoning."))
19812
20115
  return;
19813
20116
  }
19814
- const text2 = gatewayString(payload.text);
20117
+ const text3 = gatewayString(payload.text);
19815
20118
  if (event.type === "message.delta") {
19816
- active.streamed += text2;
19817
- active.emit({ type: "agent.text", text: text2 });
20119
+ active2.streamed += text3;
20120
+ active2.emit({ type: "agent.text", text: text3 });
19818
20121
  } else if (event.type === "reasoning.delta" || event.type === "reasoning.available") {
19819
- if (event.type === "reasoning.delta" || !active.reasoning) {
19820
- active.reasoning += text2;
19821
- active.emit({ type: "agent.thought", text: text2 });
20122
+ if (event.type === "reasoning.delta" || !active2.reasoning) {
20123
+ active2.reasoning += text3;
20124
+ active2.emit({ type: "agent.thought", text: text3 });
19822
20125
  }
19823
20126
  } else if (event.type === "message.interim") {
19824
20127
  if (payload.already_streamed !== true)
19825
- active.emit({ type: "agent.text", text: text2 });
19826
- active.streamed = "";
19827
- active.reasoning = "";
20128
+ active2.emit({ type: "agent.text", text: text3 });
20129
+ active2.streamed = "";
20130
+ active2.reasoning = "";
19828
20131
  } else if (event.type === "status.update") {
19829
20132
  if (payload.kind === "compacting")
19830
- active.emit({ type: "compaction.started", text: text2 });
20133
+ active2.emit({ type: "compaction.started", text: text3 });
19831
20134
  else if (payload.kind === "compacted")
19832
- active.emit({ type: "compaction.finished", text: text2 });
20135
+ active2.emit({ type: "compaction.finished", text: text3 });
19833
20136
  else if (payload.kind === "warning")
19834
- active.emit({ type: "status.warning", text: text2 });
20137
+ active2.emit({ type: "status.warning", text: text3 });
19835
20138
  } else if (event.type === "tool.start" || event.type === "tool.complete") {
19836
20139
  const toolCallId = gatewayString(payload.tool_id);
19837
20140
  if (!toolCallId)
@@ -19842,8 +20145,8 @@ ${text2}` } : {}
19842
20145
  ...output ? [{ type: "content", content: { type: "text", text: output } }] : [],
19843
20146
  ...gatewayDiff(gatewayString(payload.inline_diff))
19844
20147
  ];
19845
- if (event.type === "tool.complete" && !active.toolIds.has(toolCallId))
19846
- active.emit({
20148
+ if (event.type === "tool.complete" && !active2.toolIds.has(toolCallId))
20149
+ active2.emit({
19847
20150
  type: "tool.call",
19848
20151
  toolCallId,
19849
20152
  update: {
@@ -19853,8 +20156,8 @@ ${text2}` } : {}
19853
20156
  status: "in_progress"
19854
20157
  }
19855
20158
  });
19856
- active.toolIds.add(toolCallId);
19857
- active.emit(event.type === "tool.start" ? {
20159
+ active2.toolIds.add(toolCallId);
20160
+ active2.emit(event.type === "tool.start" ? {
19858
20161
  type: "tool.call",
19859
20162
  toolCallId,
19860
20163
  update: {
@@ -19873,28 +20176,28 @@ ${text2}` } : {}
19873
20176
  }
19874
20177
  });
19875
20178
  } else if (event.type === "message.complete") {
19876
- if (!active.streamed)
19877
- active.emit({ type: "agent.text", text: text2 });
19878
- else if (text2.startsWith(active.streamed) && text2.length > active.streamed.length)
19879
- active.emit({ type: "agent.text", text: text2.slice(active.streamed.length) });
20179
+ if (!active2.streamed)
20180
+ active2.emit({ type: "agent.text", text: text3 });
20181
+ else if (text3.startsWith(active2.streamed) && text3.length > active2.streamed.length)
20182
+ active2.emit({ type: "agent.text", text: text3.slice(active2.streamed.length) });
19880
20183
  const reasoning = gatewayString(payload.reasoning);
19881
- if (reasoning && !active.reasoning)
19882
- active.emit({ type: "agent.thought", text: reasoning });
19883
- else if (reasoning.startsWith(active.reasoning) && reasoning.length > active.reasoning.length)
19884
- active.emit({ type: "agent.thought", text: reasoning.slice(active.reasoning.length) });
20184
+ if (reasoning && !active2.reasoning)
20185
+ active2.emit({ type: "agent.thought", text: reasoning });
20186
+ else if (reasoning.startsWith(active2.reasoning) && reasoning.length > active2.reasoning.length)
20187
+ active2.emit({ type: "agent.thought", text: reasoning.slice(active2.reasoning.length) });
19885
20188
  const usage = gatewayRecord(payload.usage);
19886
20189
  const terminalUsage = projectGatewayUsage(usage);
19887
20190
  this.#usage(usage);
19888
20191
  if (payload.status === "error")
19889
- active.reject(new Error(gatewayString(payload.error) || gatewayString(payload.failure_reason) || "Hermes turn failed"));
20192
+ active2.reject(new Error(gatewayString(payload.error) || gatewayString(payload.failure_reason) || "Hermes turn failed"));
19890
20193
  else
19891
- active.resolve({
20194
+ active2.resolve({
19892
20195
  stopReason: payload.status === "interrupted" ? "cancelled" : "end_turn",
19893
- ...payload.status === "complete" && text2.trim() ? { finalAnswerText: text2 } : {},
20196
+ ...payload.status === "complete" && text3.trim() ? { finalAnswerText: text3 } : {},
19894
20197
  ...terminalUsage ? { usage: terminalUsage } : {}
19895
20198
  });
19896
20199
  } else if (event.type === "error")
19897
- active.reject(new Error(gatewayString(payload.message) || "Hermes gateway failed"));
20200
+ active2.reject(new Error(gatewayString(payload.message) || "Hermes gateway failed"));
19898
20201
  }
19899
20202
  #usage(usage) {
19900
20203
  const projected = projectGatewayUsage(usage);
@@ -19905,19 +20208,19 @@ ${text2}` } : {}
19905
20208
  else
19906
20209
  this.onUsage?.(projected);
19907
20210
  }
19908
- async #request(id, method, params) {
19909
- const active = this.#active;
19910
- if (!active || params.session_id !== this.sessionId || !["clarify", "approval"].includes(method)) {
19911
- this.transport.rejectRequest(id);
20211
+ async #request(id2, method, params) {
20212
+ const active2 = this.#active;
20213
+ if (!active2 || params.session_id !== this.sessionId || !["clarify", "approval"].includes(method)) {
20214
+ this.transport.rejectRequest(id2);
19912
20215
  return;
19913
20216
  }
19914
20217
  const controller = new AbortController();
19915
- this.#requests.set(id, controller);
20218
+ this.#requests.set(id2, controller);
19916
20219
  try {
19917
- if (method === "clarify" && active.question) {
20220
+ if (method === "clarify" && active2.question) {
19918
20221
  const batch = Array.isArray(params.questions);
19919
20222
  const questions = batch ? params.questions.map((value, index) => question(gatewayRecord(value), String(index))) : [question(params, "answer")];
19920
- const response = await active.question({
20223
+ const response = await active2.question({
19921
20224
  title: "Hermes",
19922
20225
  questions,
19923
20226
  signal: controller.signal
@@ -19930,7 +20233,7 @@ ${text2}` } : {}
19930
20233
  q?.type === "choice" && q.multiple ? JSON.stringify(values) : values[0] ?? ""
19931
20234
  ];
19932
20235
  }));
19933
- this.transport.respond(id, response.cancelled ? {} : batch ? { answers } : { answer: answers.answer ?? "" });
20236
+ this.transport.respond(id2, response.cancelled ? {} : batch ? { answers } : { answer: answers.answer ?? "" });
19934
20237
  }
19935
20238
  } else if (method === "approval") {
19936
20239
  const choices = Array.isArray(params.choices) ? params.choices : ["once", "deny"];
@@ -19945,14 +20248,14 @@ ${text2}` } : {}
19945
20248
  if (payloadRequestId)
19946
20249
  this.#approvalRequests.set(payloadRequestId, controller);
19947
20250
  try {
19948
- const response = await active.permission({
20251
+ const response = await active2.permission({
19949
20252
  signal: controller.signal,
19950
20253
  title: gatewayString(params.description) || gatewayString(params.command),
19951
20254
  description: gatewayString(params.command) || gatewayString(params.description),
19952
20255
  options
19953
20256
  });
19954
20257
  if (!controller.signal.aborted)
19955
- this.transport.respond(id, {
20258
+ this.transport.respond(id2, {
19956
20259
  choice: response ?? "deny"
19957
20260
  });
19958
20261
  } finally {
@@ -19960,9 +20263,9 @@ ${text2}` } : {}
19960
20263
  this.#approvalRequests.delete(payloadRequestId);
19961
20264
  }
19962
20265
  } else
19963
- this.transport.rejectRequest(id);
20266
+ this.transport.rejectRequest(id2);
19964
20267
  } finally {
19965
- this.#requests.delete(id);
20268
+ this.#requests.delete(id2);
19966
20269
  }
19967
20270
  }
19968
20271
  /** Keep approval prompts from the create/resume snapshot for the next turn. */
@@ -19981,7 +20284,7 @@ ${text2}` } : {}
19981
20284
  * question is served by the `clarify` server request (batch mode), and the
19982
20285
  * gateway re-issues still-open server requests to an attaching client.
19983
20286
  */
19984
- async #respondAdoptedApproval(prompt, active) {
20287
+ async #respondAdoptedApproval(prompt, active2) {
19985
20288
  if (this.#closed)
19986
20289
  return;
19987
20290
  const promptId = gatewayString(prompt.prompt_id);
@@ -19994,7 +20297,7 @@ ${text2}` } : {}
19994
20297
  label: choice === "session" ? "Allow for this session" : "Always allow"
19995
20298
  }
19996
20299
  ] : choice === "deny" ? [{ id: "deny", effect: "deny", label: "Deny" }] : []);
19997
- const response = await active.permission({
20300
+ const response = await active2.permission({
19998
20301
  signal: new AbortController().signal,
19999
20302
  title: gatewayString(prompt.description) || gatewayString(prompt.command) || "Hermes approval requested before this Session attached",
20000
20303
  description: gatewayString(prompt.command) || gatewayString(prompt.description),
@@ -20090,15 +20393,15 @@ function tokenCount(value) {
20090
20393
  }
20091
20394
  function hermesUsageEntry(row) {
20092
20395
  const apiCalls = tokenCount(row.api_call_count) ? row.api_call_count : 0;
20093
- const input = tokenCount(row.input_tokens) ? row.input_tokens : 0;
20396
+ const input2 = tokenCount(row.input_tokens) ? row.input_tokens : 0;
20094
20397
  const output = tokenCount(row.output_tokens) ? row.output_tokens : 0;
20095
20398
  const cacheRead = tokenCount(row.cache_read_tokens) ? row.cache_read_tokens : 0;
20096
20399
  const cacheWrite = tokenCount(row.cache_write_tokens) ? row.cache_write_tokens : 0;
20097
20400
  const reasoning = tokenCount(row.reasoning_tokens) ? row.reasoning_tokens : 0;
20098
- if (apiCalls === 0 && input === 0 && output === 0 && cacheRead === 0 && cacheWrite === 0) {
20401
+ if (apiCalls === 0 && input2 === 0 && output === 0 && cacheRead === 0 && cacheWrite === 0) {
20099
20402
  return null;
20100
20403
  }
20101
- const id = typeof row.id === "string" && row.id.length > 0 ? row.id : null;
20404
+ const id2 = typeof row.id === "string" && row.id.length > 0 ? row.id : null;
20102
20405
  const epochSeconds = (value) => {
20103
20406
  if (typeof value !== "number" || !Number.isFinite(value))
20104
20407
  return null;
@@ -20106,12 +20409,12 @@ function hermesUsageEntry(row) {
20106
20409
  return Number.isSafeInteger(ms) && !Number.isNaN(new Date(ms).getTime()) ? ms : null;
20107
20410
  };
20108
20411
  const at = epochSeconds(row.last_activity_at) ?? epochSeconds(row.started_at);
20109
- if (id === null || at === null)
20412
+ if (id2 === null || at === null)
20110
20413
  return null;
20111
20414
  const request = {
20112
- requestId: id,
20415
+ requestId: id2,
20113
20416
  ...typeof row.model === "string" && row.model.length > 0 ? { model: row.model } : {},
20114
- inputTokens: input + cacheRead + cacheWrite,
20417
+ inputTokens: input2 + cacheRead + cacheWrite,
20115
20418
  outputTokens: output,
20116
20419
  ...reasoning > 0 ? { reasoningOutputTokens: reasoning } : {},
20117
20420
  // Both buckets exist whenever either does: the writer records them as a pair.
@@ -20121,7 +20424,7 @@ function hermesUsageEntry(row) {
20121
20424
  if (!entry)
20122
20425
  return null;
20123
20426
  return withUsageSession(entry, {
20124
- sessionId: id,
20427
+ sessionId: id2,
20125
20428
  cwd: typeof row.cwd === "string" ? row.cwd : void 0,
20126
20429
  title: usageSessionTitle(row.title ?? row.display_name)
20127
20430
  });
@@ -20153,7 +20456,7 @@ function createHermesUsageStatistics(environment) {
20153
20456
  const stamp = await fingerprint(file2);
20154
20457
  return stamp ? [{ id: file2, fingerprint: stamp }] : [];
20155
20458
  },
20156
- readSource: (id) => readHermesUsage(id)
20459
+ readSource: (id2) => readHermesUsage(id2)
20157
20460
  });
20158
20461
  }
20159
20462
 
@@ -20213,15 +20516,15 @@ var HermesQuestions = class {
20213
20516
  return { ok: true, value: { accepted: true } };
20214
20517
  }
20215
20518
  cancel(turnId) {
20216
- for (const [id, waiter] of this.#waiters)
20519
+ for (const [id2, waiter] of this.#waiters)
20217
20520
  if (!turnId || waiter.interaction.turnId === turnId)
20218
- this.#cancel(id, "cancelled");
20521
+ this.#cancel(id2, "cancelled");
20219
20522
  }
20220
- #cancel(id, reason) {
20221
- const waiter = this.#waiters.get(id);
20523
+ #cancel(id2, reason) {
20524
+ const waiter = this.#waiters.get(id2);
20222
20525
  if (!waiter)
20223
20526
  return;
20224
- this.#waiters.delete(id);
20527
+ this.#waiters.delete(id2);
20225
20528
  waiter.resolve({ type: "question", answers: {}, cancelled: true });
20226
20529
  this.emit({
20227
20530
  kind: "event",
@@ -20239,22 +20542,22 @@ var HermesQuestions = class {
20239
20542
  import { randomUUID as randomUUID2 } from "node:crypto";
20240
20543
  var HermesCompactionActivity = class {
20241
20544
  #item = null;
20242
- start(text2) {
20545
+ start(text3) {
20243
20546
  if (this.#item)
20244
20547
  return null;
20245
20548
  this.#item = {
20246
20549
  type: "agentMessage",
20247
20550
  itemId: hostItemIdSchema.parse(randomUUID2()),
20248
20551
  phase: "commentary",
20249
- text: `Hermes 自动压缩:${text2 || "进行中"}`
20552
+ text: `Hermes 自动压缩:${text3 || "进行中"}`
20250
20553
  };
20251
20554
  return this.#item;
20252
20555
  }
20253
- appendNotice(text2) {
20254
- if (!this.#item || !text2)
20556
+ appendNotice(text3) {
20557
+ if (!this.#item || !text3)
20255
20558
  return null;
20256
20559
  const addition = `
20257
- Hermes 提示:${text2}`;
20560
+ Hermes 提示:${text3}`;
20258
20561
  this.#item = { ...this.#item, text: this.#item.text + addition };
20259
20562
  return { itemId: this.#item.itemId, text: addition };
20260
20563
  }
@@ -20672,9 +20975,9 @@ function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader
20672
20975
  } }));
20673
20976
  }
20674
20977
  }
20675
- function splitLines(text2) {
20676
- const hasTrailingNl = text2.endsWith("\n");
20677
- const result = text2.split("\n").map((line) => line + "\n");
20978
+ function splitLines(text3) {
20979
+ const hasTrailingNl = text3.endsWith("\n");
20980
+ const result = text3.split("\n").map((line) => line + "\n");
20678
20981
  if (hasTrailingNl) {
20679
20982
  result.pop();
20680
20983
  } else {
@@ -20795,16 +21098,16 @@ var ActiveTurn = class {
20795
21098
  this.#emittedTerminalItemIds.add(item.itemId);
20796
21099
  return snapshot;
20797
21100
  }
20798
- constructor(turnId, turnKey, input, persistsHistory, compaction) {
21101
+ constructor(turnId, turnKey, input2, persistsHistory, compaction) {
20799
21102
  this.turnId = hostTurnIdSchema.parse(turnId);
20800
21103
  this.turnKey = turnKey;
20801
- this.input = input;
21104
+ this.input = input2;
20802
21105
  this.persistsHistory = persistsHistory;
20803
21106
  this.compactionItem = compaction ? { type: "contextCompaction", itemId: hostItemIdSchema.parse(randomUUID3()) } : null;
20804
21107
  }
20805
- appendText(kind, text2) {
21108
+ appendText(kind, text3) {
20806
21109
  if (this.#currentText && this.#currentText.kind === kind) {
20807
- const item2 = { ...this.#currentText.item, text: this.#currentText.item.text + text2 };
21110
+ const item2 = { ...this.#currentText.item, text: this.#currentText.item.text + text3 };
20808
21111
  this.#currentText = { kind, item: item2 };
20809
21112
  return { startedItem: null, item: item2 };
20810
21113
  }
@@ -20815,7 +21118,7 @@ var ActiveTurn = class {
20815
21118
  });
20816
21119
  }
20817
21120
  const item = kind === "reasoning" ? { type: "reasoning", itemId: hostItemIdSchema.parse(randomUUID3()), text: "" } : { type: "agentMessage", itemId: hostItemIdSchema.parse(randomUUID3()), text: "" };
20818
- const appended = { ...item, text: text2 };
21121
+ const appended = { ...item, text: text3 };
20819
21122
  this.#currentText = { kind, item: appended };
20820
21123
  return { startedItem: item, item: appended };
20821
21124
  }
@@ -20958,13 +21261,13 @@ var HermesSession = class {
20958
21261
  const catalog = await this.commands.list();
20959
21262
  if (!catalog.ok)
20960
21263
  return catalog;
20961
- const text2 = hermesCommandText(command, catalog.value);
20962
- if (!text2.ok)
20963
- return text2;
21264
+ const text3 = hermesCommandText(command, catalog.value);
21265
+ if (!text3.ok)
21266
+ return text3;
20964
21267
  return this.#startTurn({
20965
21268
  type: "turn.start",
20966
21269
  turnId: command.turnId,
20967
- input: [{ type: "text", text: text2.value }]
21270
+ input: [{ type: "text", text: text3.value }]
20968
21271
  }, true);
20969
21272
  }
20970
21273
  };
@@ -21088,54 +21391,54 @@ var HermesSession = class {
21088
21391
  if (this.busy) {
21089
21392
  return err("sessionBusy", "Hermes Session already has an active Turn", true);
21090
21393
  }
21091
- const text2 = command.input.map((chunk) => chunk.text).join("\n");
21092
- if (text2.trim().length === 0) {
21394
+ const text3 = command.input.map((chunk) => chunk.text).join("\n");
21395
+ if (text3.trim().length === 0) {
21093
21396
  return err("invalidRequest", "turn.start requires non-empty text input");
21094
21397
  }
21095
21398
  this.#startingTurn = true;
21096
21399
  try {
21097
- if (text2.trim().startsWith("/")) {
21400
+ if (text3.trim().startsWith("/")) {
21098
21401
  const catalog = await this.commands.list();
21099
21402
  if (!catalog.ok)
21100
21403
  return catalog;
21101
- const name = /^\/([\w-]+)(?:\s|$)/u.exec(text2.trim())?.[1]?.toLowerCase();
21102
- if (name && isExcludedHermesCommand(name) || this.#transport.rejectsCommand?.(text2))
21404
+ const name = /^\/([\w-]+)(?:\s|$)/u.exec(text3.trim())?.[1]?.toLowerCase();
21405
+ if (name && isExcludedHermesCommand(name) || this.#transport.rejectsCommand?.(text3))
21103
21406
  return err("unsupported", "This Hermes command or its arguments are not supported in a Host Thread");
21104
21407
  }
21105
21408
  if (this.#closed || this.#faulted)
21106
21409
  return err("invalidState", "Hermes Session is unavailable");
21107
- return this.#acceptTurn(command, text2, requireNativeCommand);
21410
+ return this.#acceptTurn(command, text3, requireNativeCommand);
21108
21411
  } finally {
21109
21412
  this.#startingTurn = false;
21110
21413
  }
21111
21414
  }
21112
- #acceptTurn(command, text2, requireNativeCommand) {
21415
+ #acceptTurn(command, text3, requireNativeCommand) {
21113
21416
  const turnKey = randomUUID3();
21114
- const nativeCommand = this.#transport.nativeCommandName?.(text2) ?? null;
21417
+ const nativeCommand = this.#transport.nativeCommandName?.(text3) ?? null;
21115
21418
  if (requireNativeCommand && !nativeCommand)
21116
21419
  return err("unsupported", "Hermes no longer advertises this command");
21117
21420
  const isNativeCommand = nativeCommand != null;
21118
- const active = new ActiveTurn(command.turnId, turnKey, command.input, !isNativeCommand, isNativeCommand && nativeCommand === "compress");
21119
- this.#activeTurn = active;
21120
- this.#activeTurnId = active.turnId;
21121
- void this.#runTurn(active, text2);
21122
- return ok({ turnId: active.turnId });
21123
- }
21124
- async #runTurn(active, text2) {
21125
- this.#emit({ type: "turn.started", turnId: active.turnId });
21126
- if (active.compactionItem)
21127
- this.#emit({ type: "item.started", turnId: active.turnId, item: active.compactionItem });
21421
+ const active2 = new ActiveTurn(command.turnId, turnKey, command.input, !isNativeCommand, isNativeCommand && nativeCommand === "compress");
21422
+ this.#activeTurn = active2;
21423
+ this.#activeTurnId = active2.turnId;
21424
+ void this.#runTurn(active2, text3);
21425
+ return ok({ turnId: active2.turnId });
21426
+ }
21427
+ async #runTurn(active2, text3) {
21428
+ this.#emit({ type: "turn.started", turnId: active2.turnId });
21429
+ if (active2.compactionItem)
21430
+ this.#emit({ type: "item.started", turnId: active2.turnId, item: active2.compactionItem });
21128
21431
  let promptResponse = null;
21129
21432
  let failure2 = null;
21130
21433
  let previousNativeTurnKey;
21131
21434
  try {
21132
- if (active.persistsHistory && this.#transport.readNativeSnapshot)
21435
+ if (active2.persistsHistory && this.#transport.readNativeSnapshot)
21133
21436
  previousNativeTurnKey = (await this.#transport.readNativeSnapshot()).turns.at(-1)?.nativeTurnRef.nativeTurnKey;
21134
- promptResponse = await this.#transport.runTurn(text2, (event) => this.#handleTransportEvent(active, event), (request) => this.#handlePermissionRequest(active, request), (request) => this.#handleQuestionRequest(active, request));
21437
+ promptResponse = await this.#transport.runTurn(text3, (event) => this.#handleTransportEvent(active2, event), (request) => this.#handlePermissionRequest(active2, request), (request) => this.#handleQuestionRequest(active2, request));
21135
21438
  } catch (error51) {
21136
21439
  failure2 = error51 instanceof HermesTransportError ? transportErrorToHarness(error51) : harnessError("nativeFailure", error51 instanceof Error ? error51.message : String(error51));
21137
21440
  }
21138
- if (this.#activeTurn !== active) {
21441
+ if (this.#activeTurn !== active2) {
21139
21442
  return;
21140
21443
  }
21141
21444
  let outcome;
@@ -21151,12 +21454,12 @@ var HermesSession = class {
21151
21454
  } else {
21152
21455
  outcome = { status: "succeeded" };
21153
21456
  }
21154
- active.nativeCompactionOutcome = promptResponse?.compactionOutcome;
21155
- if (active.persistsHistory && this.#transport.readNativeSnapshot) {
21457
+ active2.nativeCompactionOutcome = promptResponse?.compactionOutcome;
21458
+ if (active2.persistsHistory && this.#transport.readNativeSnapshot) {
21156
21459
  try {
21157
21460
  const latest = (await this.#transport.readNativeSnapshot()).turns.at(-1);
21158
21461
  if (latest?.nativeTurnRef.nativeTurnKey !== previousNativeTurnKey)
21159
- active.nativeTurnSnapshot = latest;
21462
+ active2.nativeTurnSnapshot = latest;
21160
21463
  } catch (error51) {
21161
21464
  outcome = {
21162
21465
  status: "failed",
@@ -21166,72 +21469,72 @@ var HermesSession = class {
21166
21469
  }
21167
21470
  const terminalUsage = promptResponse?.usage ?? null;
21168
21471
  const usage = terminalUsage ? this.#usage.merge(terminalUsage) : null;
21169
- this.#completeActiveTurn(active, outcome, usage, promptResponse?.finalAnswerText);
21472
+ this.#completeActiveTurn(active2, outcome, usage, promptResponse?.finalAnswerText);
21170
21473
  }
21171
- #completeActiveTurn(active, outcome, usage = null, finalAnswerText) {
21172
- if (this.#activeTurn !== active)
21474
+ #completeActiveTurn(active2, outcome, usage = null, finalAnswerText) {
21475
+ if (this.#activeTurn !== active2)
21173
21476
  return;
21174
21477
  this.#cancelApprovalWaiters();
21175
21478
  this.#activeTurn = null;
21176
21479
  this.#activeTurnId = null;
21177
- this.#finishCompactionActivity(active, "当前 Turn 已结束;原生未确认自动压缩终态,提交结果未知。");
21178
- active.finish(outcome.status === "succeeded" ? finalAnswerText : void 0);
21179
- const compactionOutcome = active.finishCompaction(outcome);
21480
+ this.#finishCompactionActivity(active2, "当前 Turn 已结束;原生未确认自动压缩终态,提交结果未知。");
21481
+ active2.finish(outcome.status === "succeeded" ? finalAnswerText : void 0);
21482
+ const compactionOutcome = active2.finishCompaction(outcome);
21180
21483
  if (outcome.status === "succeeded" && compactionOutcome?.status === "failed") {
21181
21484
  outcome = { status: "failed", error: compactionOutcome.error };
21182
21485
  }
21183
- if (active.nativeTurnSnapshot?.checkpoint)
21184
- outcome = { ...outcome, checkpoint: active.nativeTurnSnapshot.checkpoint };
21185
- const nativeTurnRef = active.nativeTurnSnapshot?.nativeTurnRef ?? nativeTurnRefSchema.parse({
21486
+ if (active2.nativeTurnSnapshot?.checkpoint)
21487
+ outcome = { ...outcome, checkpoint: active2.nativeTurnSnapshot.checkpoint };
21488
+ const nativeTurnRef = active2.nativeTurnSnapshot?.nativeTurnRef ?? nativeTurnRefSchema.parse({
21186
21489
  harnessId: this.#nativeRef.harnessId,
21187
21490
  nativeSessionId: this.#nativeRef.nativeSessionId,
21188
- nativeTurnKey: active.turnKey,
21491
+ nativeTurnKey: active2.turnKey,
21189
21492
  formatVersion: 1
21190
21493
  });
21191
- const turnSnapshot = active.toSnapshot(nativeTurnRef, outcome, true);
21192
- for (const pending of active.drainPendingItems()) {
21193
- this.#emit({ type: "item.completed", turnId: active.turnId, snapshot: pending });
21494
+ const turnSnapshot = active2.toSnapshot(nativeTurnRef, outcome, true);
21495
+ for (const pending of active2.drainPendingItems()) {
21496
+ this.#emit({ type: "item.completed", turnId: active2.turnId, snapshot: pending });
21194
21497
  }
21195
21498
  if (usage) {
21196
- this.#emit({ type: "session.usage.changed", usage, observedForTurnId: active.turnId });
21499
+ this.#emit({ type: "session.usage.changed", usage, observedForTurnId: active2.turnId });
21197
21500
  }
21198
21501
  this.#emit({
21199
21502
  type: "turn.completed",
21200
- turnId: active.turnId,
21201
- ...active.persistsHistory && (!this.#transport.readNativeSnapshot || active.nativeTurnSnapshot) ? { nativeTurnRef } : {},
21503
+ turnId: active2.turnId,
21504
+ ...active2.persistsHistory && (!this.#transport.readNativeSnapshot || active2.nativeTurnSnapshot) ? { nativeTurnRef } : {},
21202
21505
  outcome
21203
21506
  });
21204
- if (active.persistsHistory)
21507
+ if (active2.persistsHistory)
21205
21508
  this.#completedTurns.push(turnSnapshot);
21206
21509
  void this.#usage.refresh(true);
21207
21510
  }
21208
- #handleTransportEvent(active, event) {
21209
- if (this.#activeTurn !== active)
21511
+ #handleTransportEvent(active2, event) {
21512
+ if (this.#activeTurn !== active2)
21210
21513
  return;
21211
21514
  switch (event.type) {
21212
21515
  case "usage":
21213
21516
  this.#usage.observe(event.usage);
21214
21517
  return;
21215
21518
  case "status.warning": {
21216
- const notice = active.compactionActivity.appendNotice(event.text);
21519
+ const notice = active2.compactionActivity.appendNotice(event.text);
21217
21520
  if (notice)
21218
21521
  this.#emit({
21219
21522
  type: "item.updated",
21220
- turnId: active.turnId,
21523
+ turnId: active2.turnId,
21221
21524
  itemId: notice.itemId,
21222
21525
  update: { type: "text.append", text: notice.text }
21223
21526
  });
21224
21527
  return;
21225
21528
  }
21226
21529
  case "compaction.started": {
21227
- if (active.compactionItem)
21530
+ if (active2.compactionItem)
21228
21531
  return;
21229
- const item = active.compactionActivity.start(event.text);
21532
+ const item = active2.compactionActivity.start(event.text);
21230
21533
  if (item) {
21231
- this.#emit({ type: "item.started", turnId: active.turnId, item: { ...item, text: "" } });
21534
+ this.#emit({ type: "item.started", turnId: active2.turnId, item: { ...item, text: "" } });
21232
21535
  this.#emit({
21233
21536
  type: "item.updated",
21234
- turnId: active.turnId,
21537
+ turnId: active2.turnId,
21235
21538
  itemId: item.itemId,
21236
21539
  update: { type: "text.append", text: item.text }
21237
21540
  });
@@ -21239,62 +21542,62 @@ var HermesSession = class {
21239
21542
  return;
21240
21543
  }
21241
21544
  case "compaction.finished": {
21242
- if (this.#finishCompactionActivity(active, "原生自动压缩阶段已结束;未提供压缩提交结果。"))
21545
+ if (this.#finishCompactionActivity(active2, "原生自动压缩阶段已结束;未提供压缩提交结果。"))
21243
21546
  void this.#usage.refresh(true);
21244
21547
  return;
21245
21548
  }
21246
21549
  case "agent.thought":
21247
- this.#appendTextItem(active, "reasoning", event.text);
21550
+ this.#appendTextItem(active2, "reasoning", event.text);
21248
21551
  return;
21249
21552
  case "agent.text":
21250
- this.#appendTextItem(active, "agentMessage", event.text);
21553
+ this.#appendTextItem(active2, "agentMessage", event.text);
21251
21554
  return;
21252
21555
  case "tool.call": {
21253
21556
  const update = event.update;
21254
- this.#startToolItem(active, event.toolCallId, typeof update.title === "string" ? update.title : null, typeof update.name === "string" ? update.name : null, update.rawInput);
21255
- this.#updateToolItem(active, update);
21557
+ this.#startToolItem(active2, event.toolCallId, typeof update.title === "string" ? update.title : null, typeof update.name === "string" ? update.name : null, update.rawInput);
21558
+ this.#updateToolItem(active2, update);
21256
21559
  return;
21257
21560
  }
21258
21561
  case "tool.update":
21259
- this.#updateToolItem(active, event.update);
21562
+ this.#updateToolItem(active2, event.update);
21260
21563
  return;
21261
21564
  default:
21262
21565
  return;
21263
21566
  }
21264
21567
  }
21265
- #finishCompactionActivity(active, reason) {
21266
- const snapshot = active.compactionActivity.finish(reason);
21568
+ #finishCompactionActivity(active2, reason) {
21569
+ const snapshot = active2.compactionActivity.finish(reason);
21267
21570
  if (!snapshot)
21268
21571
  return false;
21269
- active.rememberActivity(snapshot);
21572
+ active2.rememberActivity(snapshot);
21270
21573
  this.#emit({
21271
21574
  type: "item.updated",
21272
- turnId: active.turnId,
21575
+ turnId: active2.turnId,
21273
21576
  itemId: snapshot.item.itemId,
21274
21577
  update: { type: "text.append", text: `
21275
21578
  ${reason}` }
21276
21579
  });
21277
- this.#emit({ type: "item.completed", turnId: active.turnId, snapshot });
21580
+ this.#emit({ type: "item.completed", turnId: active2.turnId, snapshot });
21278
21581
  return true;
21279
21582
  }
21280
- #appendTextItem(active, kind, text2) {
21281
- const appended = active.appendText(kind, text2);
21583
+ #appendTextItem(active2, kind, text3) {
21584
+ const appended = active2.appendText(kind, text3);
21282
21585
  if (!appended)
21283
21586
  return;
21284
21587
  if (appended.startedItem) {
21285
- this.#emit({ type: "item.started", turnId: active.turnId, item: appended.startedItem });
21588
+ this.#emit({ type: "item.started", turnId: active2.turnId, item: appended.startedItem });
21286
21589
  }
21287
21590
  this.#emit({
21288
21591
  type: "item.updated",
21289
- turnId: active.turnId,
21592
+ turnId: active2.turnId,
21290
21593
  itemId: appended.item.itemId,
21291
- update: { type: "text.append", text: text2 }
21594
+ update: { type: "text.append", text: text3 }
21292
21595
  });
21293
21596
  }
21294
- #startToolItem(active, toolCallId, title, name, rawInput) {
21295
- const completedText = active.completeCurrentText();
21597
+ #startToolItem(active2, toolCallId, title, name, rawInput) {
21598
+ const completedText = active2.completeCurrentText();
21296
21599
  if (completedText) {
21297
- this.#emit({ type: "item.completed", turnId: active.turnId, snapshot: completedText });
21600
+ this.#emit({ type: "item.completed", turnId: active2.turnId, snapshot: completedText });
21298
21601
  }
21299
21602
  const item = {
21300
21603
  type: "toolExecution",
@@ -21302,39 +21605,39 @@ ${reason}` }
21302
21605
  toolName: (name ?? title ?? "").trim() || toolCallId,
21303
21606
  arguments: isPlainObjectOrArray(rawInput) ? rawInput : null
21304
21607
  };
21305
- active.addToolItem(toolCallId, { item, startedAt: Date.now() });
21306
- this.#emit({ type: "item.started", turnId: active.turnId, item });
21608
+ active2.addToolItem(toolCallId, { item, startedAt: Date.now() });
21609
+ this.#emit({ type: "item.started", turnId: active2.turnId, item });
21307
21610
  }
21308
- #updateToolItem(active, update) {
21309
- const entry = active.getToolItem(update.toolCallId);
21611
+ #updateToolItem(active2, update) {
21612
+ const entry = active2.getToolItem(update.toolCallId);
21310
21613
  if (!entry)
21311
21614
  return;
21312
- active.rememberFileChanges(update.toolCallId, update);
21615
+ active2.rememberFileChanges(update.toolCallId, update);
21313
21616
  const output = hermesToolOutput(update);
21314
21617
  if (output && output.content.length > 0) {
21315
- active.updateToolOutput(update.toolCallId, output);
21618
+ active2.updateToolOutput(update.toolCallId, output);
21316
21619
  this.#emit({
21317
21620
  type: "item.updated",
21318
- turnId: active.turnId,
21621
+ turnId: active2.turnId,
21319
21622
  itemId: entry.item.itemId,
21320
21623
  update: { type: "output.replace", output }
21321
21624
  });
21322
21625
  }
21323
21626
  if (update.status === "completed" || update.status === "failed") {
21324
- const completed = active.completeToolItem(update.toolCallId, output, update.status === "failed");
21627
+ const completed = active2.completeToolItem(update.toolCallId, output, update.status === "failed");
21325
21628
  if (completed) {
21326
- this.#emit({ type: "item.completed", turnId: active.turnId, snapshot: completed });
21629
+ this.#emit({ type: "item.completed", turnId: active2.turnId, snapshot: completed });
21327
21630
  if (update.status === "completed") {
21328
- const fileChange = active.completeFileChanges(update.toolCallId, completed.item.itemId);
21631
+ const fileChange = active2.completeFileChanges(update.toolCallId, completed.item.itemId);
21329
21632
  if (fileChange) {
21330
- this.#emit({ type: "item.started", turnId: active.turnId, item: fileChange.item });
21331
- this.#emit({ type: "item.completed", turnId: active.turnId, snapshot: fileChange });
21633
+ this.#emit({ type: "item.started", turnId: active2.turnId, item: fileChange.item });
21634
+ this.#emit({ type: "item.completed", turnId: active2.turnId, snapshot: fileChange });
21332
21635
  }
21333
21636
  }
21334
21637
  }
21335
21638
  }
21336
21639
  }
21337
- #handlePermissionRequest(active, request) {
21640
+ #handlePermissionRequest(active2, request) {
21338
21641
  if (request.options.length === 0) {
21339
21642
  return Promise.resolve(null);
21340
21643
  }
@@ -21342,7 +21645,7 @@ ${reason}` }
21342
21645
  const interaction = {
21343
21646
  type: "approval",
21344
21647
  interactionId,
21345
- turnId: active.turnId,
21648
+ turnId: active2.turnId,
21346
21649
  title: request.title?.slice(0, 200) || "Hermes 请求批准",
21347
21650
  ...request.description ? { description: request.description } : {},
21348
21651
  subject: { type: "nativeAction" },
@@ -21354,7 +21657,7 @@ ${reason}` }
21354
21657
  const pending = new Promise((resolve) => {
21355
21658
  this.#approvalWaiters.set(interactionId, {
21356
21659
  interaction,
21357
- turnId: active.turnId,
21660
+ turnId: active2.turnId,
21358
21661
  resolve
21359
21662
  });
21360
21663
  abort = () => {
@@ -21364,7 +21667,7 @@ ${reason}` }
21364
21667
  this.#emit({
21365
21668
  type: "interaction.closed",
21366
21669
  interactionId,
21367
- turnId: active.turnId,
21670
+ turnId: active2.turnId,
21368
21671
  reason: request.signal?.reason === "expired" ? "expired" : "cancelled"
21369
21672
  });
21370
21673
  };
@@ -21427,15 +21730,15 @@ ${reason}` }
21427
21730
  return { ok: false, error: failure2 };
21428
21731
  }
21429
21732
  }
21430
- #handleQuestionRequest(active, request) {
21431
- if (this.#activeTurn !== active)
21733
+ #handleQuestionRequest(active2, request) {
21734
+ if (this.#activeTurn !== active2)
21432
21735
  return Promise.resolve({ type: "question", answers: {}, cancelled: true });
21433
- return this.#questions.open(active.turnId, request);
21736
+ return this.#questions.open(active2.turnId, request);
21434
21737
  }
21435
21738
  async #selectThinking(command) {
21436
21739
  if (!this.#transport.setThinking)
21437
21740
  return err("unsupported", "Hermes does not expose Thinking options");
21438
- if (!this.#state.availableThinkingOptions?.some(({ id }) => id === command.thinkingOptionId))
21741
+ if (!this.#state.availableThinkingOptions?.some(({ id: id2 }) => id2 === command.thinkingOptionId))
21439
21742
  return err("invalidRequest", "Unknown Hermes Thinking option");
21440
21743
  try {
21441
21744
  const selected = await this.#transport.setThinking(command.thinkingOptionId);
@@ -21450,10 +21753,7 @@ ${reason}` }
21450
21753
  }
21451
21754
  }
21452
21755
  async #selectModel(command) {
21453
- const native = decodeHermesModelRefId(command.model.id);
21454
- if (!native) {
21455
- return err("invalidRequest", "Model Ref does not belong to Hermes");
21456
- }
21756
+ const native = command.model.id;
21457
21757
  try {
21458
21758
  await this.#transport.setModel(native);
21459
21759
  } catch (error51) {
@@ -21553,20 +21853,20 @@ function gatewayPermissionModes() {
21553
21853
  function isGatewayRef(ref) {
21554
21854
  return ref.harnessId === "hermes" && gatewayRecord(ref.locator).transport === "gateway";
21555
21855
  }
21556
- async function openGatewaySession(input, transport, onSettle, inheritedPermissionMode) {
21557
- const source = input.kind === "create" ? null : input.kind === "resume" ? input.nativeRef : input.sourceRef;
21558
- if (source && !isGatewayRef(source) && !(input.kind === "resume" && source.harnessId === "hermes" && !source.locator))
21856
+ async function openGatewaySession(input2, transport, onSettle, inheritedPermissionMode) {
21857
+ const source = input2.kind === "create" ? null : input2.kind === "resume" ? input2.nativeRef : input2.sourceRef;
21858
+ if (source && !isGatewayRef(source) && !(input2.kind === "resume" && source.harnessId === "hermes" && !source.locator))
21559
21859
  throw new HermesGatewayHistoryError("unsupported", "This Hermes native reference is not a supported gateway Session");
21560
21860
  const savedMode = source ? gatewayRecord(source.locator).permissionModeId : void 0;
21561
- const mode = (input.kind === "fork" ? inheritedPermissionMode : input.permissionModeId) ?? (typeof savedMode === "string" ? savedMode : void 0);
21861
+ const mode = (input2.kind === "fork" ? inheritedPermissionMode : input2.permissionModeId) ?? (typeof savedMode === "string" ? savedMode : void 0);
21562
21862
  if (mode && mode !== "default" && mode !== "dont_ask")
21563
21863
  throw new HermesGatewayHistoryError("unsupported", "Hermes gateway supports only native approval policy and session YOLO");
21564
- if (input.kind === "create" && input.executionPolicy === "unattended-full-access" && mode && mode !== "dont_ask")
21864
+ if (input2.kind === "create" && input2.executionPolicy === "unattended-full-access" && mode && mode !== "dont_ask")
21565
21865
  throw new HermesGatewayHistoryError("invalidRequest", "unattended-full-access requires dont_ask");
21566
- const model2 = input.kind !== "fork" && input.model ? decodeHermesModelRefId(input.model.id) : null;
21567
- if (input.kind !== "fork" && input.model && !model2)
21866
+ const model2 = input2.kind !== "fork" ? input2.model?.id : void 0;
21867
+ if (input2.kind !== "fork" && input2.model && !model2)
21568
21868
  throw new HermesGatewayHistoryError("invalidRequest", "Model Ref does not belong to Hermes");
21569
- if (source && gatewayRecord(source.locator).cwd && !await sameDirectory(String(gatewayRecord(source?.locator).cwd), input.cwd))
21869
+ if (source && gatewayRecord(source.locator).cwd && !await sameDirectory(String(gatewayRecord(source?.locator).cwd), input2.cwd))
21570
21870
  throw new HermesGatewayHistoryError("unsupported", "Hermes gateway preserves the native Session working directory");
21571
21871
  let nativeRef = source;
21572
21872
  let sourceHistory;
@@ -21575,23 +21875,23 @@ async function openGatewaySession(input, transport, onSettle, inheritedPermissio
21575
21875
  await transport.prepareSession();
21576
21876
  await transport.start();
21577
21877
  }
21578
- if (source && (input.kind === "fork" || input.kind === "rollbackLastTurn")) {
21878
+ if (source && (input2.kind === "fork" || input2.kind === "rollbackLastTurn")) {
21579
21879
  sourceHistory = new HermesGatewayHistory({
21580
21880
  python: transport.runtime,
21581
21881
  cwd: transport.cwd,
21582
21882
  environment: transport.environment,
21583
21883
  nativeSessionId: source.nativeSessionId
21584
21884
  });
21585
- nativeRef = await sourceHistory.derive(input.kind === "fork" ? { checkpoint: input.checkpoint } : { rollbackLastTurn: true });
21885
+ nativeRef = await sourceHistory.derive(input2.kind === "fork" ? { checkpoint: input2.checkpoint } : { rollbackLastTurn: true });
21586
21886
  }
21587
21887
  const response = await transport.request(
21588
21888
  nativeRef ? "session.resume" : "session.create",
21589
21889
  // Canonical wire (hermes-gateway-v1, CanonicalCreateParams/CanonicalResumeParams):
21590
21890
  // no close_on_disconnect / eager_build keys, and the effort key is "reasoning".
21591
21891
  nativeRef ? { session_id: nativeRef.nativeSessionId, omit_messages: true } : {
21592
- cwd: input.cwd,
21892
+ cwd: input2.cwd,
21593
21893
  ...model2 ? { model: model2 } : {},
21594
- ...input.kind === "create" && input.thinkingOptionId ? { reasoning: input.thinkingOptionId } : {}
21894
+ ...input2.kind === "create" && input2.thinkingOptionId ? { reasoning: input2.thinkingOptionId } : {}
21595
21895
  }
21596
21896
  );
21597
21897
  const runtimeId = gatewayString(response.session_id);
@@ -21600,7 +21900,7 @@ async function openGatewaySession(input, transport, onSettle, inheritedPermissio
21600
21900
  throw new Error("Hermes gateway did not return Session identity");
21601
21901
  const info = gatewayRecord(response.info);
21602
21902
  const nativeCwd = gatewayString(info.cwd);
21603
- if (nativeCwd && !await sameDirectory(nativeCwd, input.cwd))
21903
+ if (nativeCwd && !await sameDirectory(nativeCwd, input2.cwd))
21604
21904
  throw new HermesGatewayHistoryError("unsupported", "Hermes resumed a different native working directory");
21605
21905
  const bridge = new HermesGatewaySessionTransport(transport, runtimeId, storedId, info, {
21606
21906
  revision: response.revision,
@@ -21613,9 +21913,9 @@ async function openGatewaySession(input, transport, onSettle, inheritedPermissio
21613
21913
  }
21614
21914
  if (model2)
21615
21915
  await bridge.setModel(model2);
21616
- if (input.kind !== "fork" && input.thinkingOptionId)
21617
- await bridge.setThinking(input.thinkingOptionId);
21618
- const desiredMode = input.kind === "create" && input.executionPolicy === "unattended-full-access" ? "dont_ask" : mode;
21916
+ if (input2.kind !== "fork" && input2.thinkingOptionId)
21917
+ await bridge.setThinking(input2.thinkingOptionId);
21918
+ const desiredMode = input2.kind === "create" && input2.executionPolicy === "unattended-full-access" ? "dont_ask" : mode;
21619
21919
  if (desiredMode)
21620
21920
  await bridge.setPermissionMode(desiredMode);
21621
21921
  const open = await bridge.openResult();
@@ -21626,7 +21926,7 @@ async function openGatewaySession(input, transport, onSettle, inheritedPermissio
21626
21926
  formatVersion: 1,
21627
21927
  locator: {
21628
21928
  transport: "gateway",
21629
- cwd: input.cwd,
21929
+ cwd: input2.cwd,
21630
21930
  permissionModeId: open.session.modes?.currentModeId
21631
21931
  }
21632
21932
  }),
@@ -21646,6 +21946,7 @@ async function openGatewaySession(input, transport, onSettle, inheritedPermissio
21646
21946
  var hermesHarnessId = harnessIdSchema.parse("hermes");
21647
21947
  var IMPORT_TIMEOUT_MS = 2e4;
21648
21948
  var HermesAdapter = class {
21949
+ normalizeStoredModelRef = normalizeStoredHermesModelRef;
21649
21950
  commandCatalog = HERMES_COMMAND_CATALOG;
21650
21951
  liveCommandCatalog = true;
21651
21952
  harnessId = hermesHarnessId;
@@ -21670,11 +21971,11 @@ var HermesAdapter = class {
21670
21971
  this.#options = options;
21671
21972
  this.usageStatistics = createHermesUsageStatistics(options.environment ?? process.env);
21672
21973
  }
21673
- async inspect(input = {}) {
21674
- const cwd = input.cwd ?? process.cwd();
21675
- if (!input.refresh && this.#inspectionCache && this.#inspectionCacheScope === cwd)
21974
+ async inspect(input2 = {}) {
21975
+ const cwd = input2.cwd ?? process.cwd();
21976
+ if (!input2.refresh && this.#inspectionCache && this.#inspectionCacheScope === cwd)
21676
21977
  return this.#inspectionCache;
21677
- if (input.refresh)
21978
+ if (input2.refresh)
21678
21979
  this.#gatewayProbes.clear();
21679
21980
  try {
21680
21981
  if (!await this.#gatewayRuntime(cwd, this.#effectiveEnvironment()))
@@ -21727,24 +22028,24 @@ var HermesAdapter = class {
21727
22028
  });
21728
22029
  return this.#inventoryRead;
21729
22030
  }
21730
- async open(input) {
22031
+ async open(input2) {
21731
22032
  if (this.#closed)
21732
22033
  return failure("invalidState", "Hermes Adapter is closed");
21733
- if (typeof input.cwd !== "string" || input.cwd.trim().length === 0)
22034
+ if (typeof input2.cwd !== "string" || input2.cwd.trim().length === 0)
21734
22035
  return failure("invalidRequest", "open requires a cwd");
21735
- const nativeRef = input.kind === "create" ? null : input.kind === "resume" ? input.nativeRef : input.sourceRef;
22036
+ const nativeRef = input2.kind === "create" ? null : input2.kind === "resume" ? input2.nativeRef : input2.sourceRef;
21736
22037
  if (nativeRef && nativeRef.harnessId !== this.harnessId)
21737
22038
  return failure("invalidRequest", "Native Ref does not belong to Hermes");
21738
- if (nativeRef && !isGatewayRef(nativeRef) && !(input.kind === "resume" && !nativeRef.locator))
22039
+ if (nativeRef && !isGatewayRef(nativeRef) && !(input2.kind === "resume" && !nativeRef.locator))
21739
22040
  return failure("unsupported", "Hermes chat Sessions require a supported Gateway native reference");
21740
- const environment = this.#effectiveEnvironment(input.environment);
22041
+ const environment = this.#effectiveEnvironment(input2.environment);
21741
22042
  try {
21742
- const runtime = await this.#gatewayRuntime(input.cwd, environment);
22043
+ const runtime = await this.#gatewayRuntime(input2.cwd, environment);
21743
22044
  if (this.#closed)
21744
22045
  return failure("invalidState", "Hermes Adapter is closed");
21745
22046
  if (!runtime)
21746
22047
  return failure("unavailable", "Hermes requires a Gateway with exclusive turn support; ACP chat fallback is not supported");
21747
- return this.#openGateway(input, runtime, environment);
22048
+ return this.#openGateway(input2, runtime, environment);
21748
22049
  } catch (error51) {
21749
22050
  if (error51 instanceof HermesExecutableError)
21750
22051
  return failure("notInstalled", error51.message);
@@ -21764,32 +22065,32 @@ var HermesAdapter = class {
21764
22065
  }
21765
22066
  return pending;
21766
22067
  }
21767
- async #openGateway(input, runtime, environment) {
22068
+ async #openGateway(input2, runtime, environment) {
21768
22069
  if (this.#closed)
21769
22070
  return failure("invalidState", "Hermes Adapter is closed");
21770
- const ref = input.kind === "resume" ? input.nativeRef : null;
21771
- if (input.kind === "fork" || input.kind === "rollbackLastTurn") {
21772
- const source = [...this.#sessions].find((s) => s.initialState.nativeRef?.nativeSessionId === input.sourceRef.nativeSessionId);
22071
+ const ref = input2.kind === "resume" ? input2.nativeRef : null;
22072
+ if (input2.kind === "fork" || input2.kind === "rollbackLastTurn") {
22073
+ const source = [...this.#sessions].find((s) => s.initialState.nativeRef?.nativeSessionId === input2.sourceRef.nativeSessionId);
21773
22074
  if (source?.busy)
21774
22075
  return failure("sessionBusy", "Cannot derive a Hermes Session while its source Turn is active", true);
21775
22076
  }
21776
- const owned = (id) => this.#openingNativeIds.has(id) || [...this.#sessions].some((session) => session.initialState.nativeRef?.nativeSessionId === id);
22077
+ const owned = (id2) => this.#openingNativeIds.has(id2) || [...this.#sessions].some((session) => session.initialState.nativeRef?.nativeSessionId === id2);
21777
22078
  if (ref && owned(ref.nativeSessionId))
21778
22079
  return failure("sessionBusy", "This Hermes Session already has an owner", true);
21779
22080
  if (ref)
21780
22081
  this.#openingNativeIds.add(ref.nativeSessionId);
21781
22082
  let transport;
21782
22083
  try {
21783
- transport = this.#gatewayPool.acquire(runtime, input.cwd, environment) ?? await startGatewayTransport(runtime, input.cwd, environment, this.#options.commandTimeoutMs);
22084
+ transport = this.#gatewayPool.acquire(runtime, input2.cwd, environment) ?? await startGatewayTransport(runtime, input2.cwd, environment, this.#options.commandTimeoutMs);
21784
22085
  this.#gatewayTransports.add(transport);
21785
22086
  let inheritedMode;
21786
- if (input.kind === "fork") {
21787
- const source = [...this.#sessions].find((s) => s.initialState.nativeRef?.nativeSessionId === input.sourceRef.nativeSessionId);
22087
+ if (input2.kind === "fork") {
22088
+ const source = [...this.#sessions].find((s) => s.initialState.nativeRef?.nativeSessionId === input2.sourceRef.nativeSessionId);
21788
22089
  const snapshot = await source?.readSnapshot();
21789
22090
  if (snapshot?.ok)
21790
22091
  inheritedMode = snapshot.value.state?.effectivePermissionModeId;
21791
22092
  }
21792
- const session = await openGatewaySession(input, transport, (settled) => {
22093
+ const session = await openGatewaySession(input2, transport, (settled) => {
21793
22094
  this.#sessions.delete(settled);
21794
22095
  this.#gatewayTransports.delete(transport);
21795
22096
  this.#gatewayPool.release(transport);