@codexhost/cli-linux-arm64 0.23.0 → 0.24.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 (56) hide show
  1. package/README.md +1 -1
  2. package/app/codexhost-distribution.json +1 -1
  3. package/app/console-server.mjs +1565 -1805
  4. package/app/console-web.js +5786 -1600
  5. package/app/desktop-controller.mjs +13104 -2842
  6. package/app/host-runtime.mjs +50518 -51753
  7. package/app/plugins/antigravity/plugin.mjs +1932 -1148
  8. package/app/plugins/claude-code/plugin.mjs +1676 -1218
  9. package/app/plugins/codebuddy/plugin.mjs +1266 -850
  10. package/app/plugins/codex-usage/plugin.mjs +916 -737
  11. package/app/plugins/copilot/plugin.mjs +838 -640
  12. package/app/plugins/cursor-cli/plugin.mjs +1058 -747
  13. package/app/plugins/deepseek-harness/plugin.mjs +1302 -1070
  14. package/app/plugins/devin/plugin.mjs +949 -752
  15. package/app/plugins/grok/plugin.mjs +1132 -964
  16. package/app/plugins/hermes/plugin.mjs +1084 -905
  17. package/app/plugins/kimi-code/plugin.mjs +977 -804
  18. package/app/plugins/kiro-cli/plugin.mjs +951 -758
  19. package/app/plugins/omp/plugin.mjs +1408 -1169
  20. package/app/plugins/opencode/plugin.mjs +1385 -1142
  21. package/app/plugins/pi/plugin.mjs +1515 -1287
  22. package/app/plugins/qoder/plugin.mjs +861 -676
  23. package/app/plugins/qoder-cn/plugin.mjs +861 -676
  24. package/app/plugins/qwen-code/plugin.mjs +1060 -888
  25. package/app/plugins/workbuddy/plugin.mjs +1272 -856
  26. package/app/plugins/zcode/plugin.mjs +1529 -880
  27. package/app/renderer-extension.js +11568 -7827
  28. package/app/web/assets/index-CTCFIQbU.css +1 -0
  29. package/app/web/assets/index-IvFk9KT-.js +203 -0
  30. package/app/web/codexhost-settings.js +4472 -36194
  31. package/app/web/index.html +2 -2
  32. package/app/web/plugins/deepseek-ai__dsh-api-remotes/client.js +1 -1
  33. package/app/web/plugins/deepseek-ai__dsh-api-session-controller/client.js +69 -69
  34. package/app/web/plugins/deepseek-ai__dsh-client-ui-approval/client.js +1 -1
  35. package/app/web/plugins/deepseek-ai__dsh-client-ui-chat/client.js +74 -74
  36. package/app/web/plugins/deepseek-ai__dsh-client-ui-codexhost/client.js +75 -64
  37. package/app/web/plugins/deepseek-ai__dsh-client-ui-conversation/client.js +19 -16
  38. package/app/web/plugins/deepseek-ai__dsh-client-ui-input-trigger/client.js +1 -1
  39. package/app/web/plugins/deepseek-ai__dsh-client-ui-layout/client.js +2 -2
  40. package/app/web/plugins/deepseek-ai__dsh-client-ui-model-selection/client.js +2 -2
  41. package/app/web/plugins/deepseek-ai__dsh-client-ui-settings-general/client.js +1 -1
  42. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar/client.js +2 -2
  43. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-documentpreview/client.js +9 -9
  44. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-right/client.js +1 -1
  45. package/app/web/plugins/deepseek-ai__dsh-client-ui-theme/client.js +1 -1
  46. package/app/web/plugins/deepseek-ai__dsh-client-ui-tool/client.js +18 -18
  47. package/app/web/plugins/deepseek-ai__dsh-client-ui-user-questions/client.js +3 -3
  48. package/app/web/plugins/deepseek-ai__dsh-client-ui-workspace/client.js +7 -7
  49. package/app/web/sw.js +8 -1
  50. package/app/web-modules/server.mjs +2682 -5540
  51. package/bin/codexhost +0 -0
  52. package/libexec/codexhost-shim +0 -0
  53. package/libexec/codexhost-updater +0 -0
  54. package/package.json +1 -1
  55. package/app/web/assets/index-DJW4bmyx.css +0 -1
  56. package/app/web/assets/index-Dyh1KzAB.js +0 -201
@@ -979,16 +979,16 @@ var require_sharedArrayCancellation = __commonJS({
979
979
  this.buffers.set(request.id, buffer);
980
980
  request.$cancellationData = buffer;
981
981
  }
982
- async sendCancellation(_conn, id) {
983
- const buffer = this.buffers.get(id);
982
+ async sendCancellation(_conn, id2) {
983
+ const buffer = this.buffers.get(id2);
984
984
  if (buffer === void 0) {
985
985
  return;
986
986
  }
987
987
  const data = new Int32Array(buffer, 0, 1);
988
988
  Atomics.store(data, 0, CancellationState.Cancelled);
989
989
  }
990
- cleanup(id) {
991
- this.buffers.delete(id);
990
+ cleanup(id2) {
991
+ this.buffers.delete(id2);
992
992
  }
993
993
  dispose() {
994
994
  this.buffers.clear();
@@ -1727,8 +1727,8 @@ var require_connection = __commonJS({
1727
1727
  var CancellationSenderStrategy;
1728
1728
  (function(CancellationSenderStrategy2) {
1729
1729
  CancellationSenderStrategy2.Message = Object.freeze({
1730
- sendCancellation(conn, id) {
1731
- return conn.sendNotification(CancelNotification.type, { id });
1730
+ sendCancellation(conn, id2) {
1731
+ return conn.sendNotification(CancelNotification.type, { id: id2 });
1732
1732
  },
1733
1733
  cleanup(_) {
1734
1734
  }
@@ -1800,17 +1800,17 @@ var require_connection = __commonJS({
1800
1800
  const unhandledProgressEmitter = new events_1.Emitter();
1801
1801
  const disposeEmitter = new events_1.Emitter();
1802
1802
  const cancellationStrategy = options2 && options2.cancellationStrategy ? options2.cancellationStrategy : CancellationStrategy.Message;
1803
- function createRequestQueueKey(id) {
1804
- if (id === null) {
1803
+ function createRequestQueueKey(id2) {
1804
+ if (id2 === null) {
1805
1805
  throw new Error(`Can't send requests with id null since the response can't be correlated.`);
1806
1806
  }
1807
- return "req-" + id.toString();
1807
+ return "req-" + id2.toString();
1808
1808
  }
1809
- function createResponseQueueKey(id) {
1810
- if (id === null) {
1809
+ function createResponseQueueKey(id2) {
1810
+ if (id2 === null) {
1811
1811
  return "res-unknown-" + (++unknownResponseSequenceNumber).toString();
1812
1812
  } else {
1813
- return "res-" + id.toString();
1813
+ return "res-" + id2.toString();
1814
1814
  }
1815
1815
  }
1816
1816
  function createNotificationQueueKey() {
@@ -2514,24 +2514,24 @@ ${JSON.stringify(message, null, 4)}`);
2514
2514
  const numberOfParams = type.numberOfParams;
2515
2515
  token = cancellation_1.CancellationToken.is(params[numberOfParams]) ? params[numberOfParams] : void 0;
2516
2516
  }
2517
- const id = sequenceNumber++;
2517
+ const id2 = sequenceNumber++;
2518
2518
  let disposable;
2519
2519
  if (token) {
2520
2520
  disposable = token.onCancellationRequested(() => {
2521
- const p = cancellationStrategy.sender.sendCancellation(connection, id);
2521
+ const p = cancellationStrategy.sender.sendCancellation(connection, id2);
2522
2522
  if (p === void 0) {
2523
- logger.log(`Received no promise from cancellation strategy when cancelling id ${id}`);
2523
+ logger.log(`Received no promise from cancellation strategy when cancelling id ${id2}`);
2524
2524
  return Promise.resolve();
2525
2525
  } else {
2526
2526
  return p.catch(() => {
2527
- logger.log(`Sending cancellation messages for id ${id} failed`);
2527
+ logger.log(`Sending cancellation messages for id ${id2} failed`);
2528
2528
  });
2529
2529
  }
2530
2530
  });
2531
2531
  }
2532
2532
  const requestMessage = {
2533
2533
  jsonrpc: version3,
2534
- id,
2534
+ id: id2,
2535
2535
  method,
2536
2536
  params: messageParams
2537
2537
  };
@@ -2542,20 +2542,20 @@ ${JSON.stringify(message, null, 4)}`);
2542
2542
  return new Promise(async (resolve3, reject) => {
2543
2543
  const resolveWithCleanup = (r) => {
2544
2544
  resolve3(r);
2545
- cancellationStrategy.sender.cleanup(id);
2545
+ cancellationStrategy.sender.cleanup(id2);
2546
2546
  disposable?.dispose();
2547
2547
  };
2548
2548
  const rejectWithCleanup = (r) => {
2549
2549
  reject(r);
2550
- cancellationStrategy.sender.cleanup(id);
2550
+ cancellationStrategy.sender.cleanup(id2);
2551
2551
  disposable?.dispose();
2552
2552
  };
2553
2553
  const responsePromise = { method, timerStart: Date.now(), resolve: resolveWithCleanup, reject: rejectWithCleanup };
2554
2554
  try {
2555
- responsePromises.set(id, responsePromise);
2555
+ responsePromises.set(id2, responsePromise);
2556
2556
  await messageWriter.write(requestMessage);
2557
2557
  } catch (error51) {
2558
- responsePromises.delete(id);
2558
+ responsePromises.delete(id2);
2559
2559
  responsePromise.reject(new messages_1.ResponseError(messages_1.ErrorCodes.MessageWriteError, error51.message ? error51.message : "Unknown reason"));
2560
2560
  logger.error(`Sending request failed.`);
2561
2561
  throw error51;
@@ -5315,8 +5315,8 @@ function cleanEnum(obj) {
5315
5315
  return Number.isNaN(Number.parseInt(k, 10));
5316
5316
  }).map((el) => el[1]);
5317
5317
  }
5318
- function base64ToUint8Array(base643) {
5319
- const binaryString = atob(base643);
5318
+ function base64ToUint8Array(base644) {
5319
+ const binaryString = atob(base644);
5320
5320
  const bytes = new Uint8Array(binaryString.length);
5321
5321
  for (let i = 0; i < binaryString.length; i++) {
5322
5322
  bytes[i] = binaryString.charCodeAt(i);
@@ -5331,9 +5331,9 @@ function uint8ArrayToBase64(bytes) {
5331
5331
  return btoa(binaryString);
5332
5332
  }
5333
5333
  function base64urlToUint8Array(base64url3) {
5334
- const base643 = base64url3.replace(/-/g, "+").replace(/_/g, "/");
5335
- const padding = "=".repeat((4 - base643.length % 4) % 4);
5336
- return base64ToUint8Array(base643 + padding);
5334
+ const base644 = base64url3.replace(/-/g, "+").replace(/_/g, "/");
5335
+ const padding = "=".repeat((4 - base644.length % 4) % 4);
5336
+ return base64ToUint8Array(base644 + padding);
5337
5337
  }
5338
5338
  function uint8ArrayToBase64url(bytes) {
5339
5339
  return uint8ArrayToBase64(bytes).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
@@ -6699,8 +6699,8 @@ var $ZodBase64 = /* @__PURE__ */ $constructor("$ZodBase64", (inst, def) => {
6699
6699
  function isValidBase64URL(data) {
6700
6700
  if (!base64url.test(data))
6701
6701
  return false;
6702
- const base643 = data.replace(/[-_]/g, (c) => c === "-" ? "+" : "/");
6703
- const padded = base643.padEnd(Math.ceil(base643.length / 4) * 4, "=");
6702
+ const base644 = data.replace(/[-_]/g, (c) => c === "-" ? "+" : "/");
6703
+ const padded = base644.padEnd(Math.ceil(base644.length / 4) * 4, "=");
6704
6704
  return isValidBase64(padded);
6705
6705
  }
6706
6706
  var $ZodBase64URL = /* @__PURE__ */ $constructor("$ZodBase64URL", (inst, def) => {
@@ -7154,42 +7154,42 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
7154
7154
  }
7155
7155
  doc.write(`const newResult = {};`);
7156
7156
  for (const key of normalized.keys) {
7157
- const id = ids[key];
7157
+ const id2 = ids[key];
7158
7158
  const k = esc(key);
7159
7159
  const schema = shape[key];
7160
7160
  const isOptionalIn = schema?._zod?.optin === "optional";
7161
7161
  const isOptionalOut = schema?._zod?.optout === "optional";
7162
- doc.write(`const ${id} = ${parseStr(key)};`);
7162
+ doc.write(`const ${id2} = ${parseStr(key)};`);
7163
7163
  if (isOptionalIn && isOptionalOut) {
7164
7164
  doc.write(`
7165
- if (${id}.issues.length) {
7165
+ if (${id2}.issues.length) {
7166
7166
  if (${k} in input) {
7167
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
7167
+ payload.issues = payload.issues.concat(${id2}.issues.map(iss => ({
7168
7168
  ...iss,
7169
7169
  path: iss.path ? [${k}, ...iss.path] : [${k}]
7170
7170
  })));
7171
7171
  }
7172
7172
  }
7173
7173
 
7174
- if (${id}.value === undefined) {
7174
+ if (${id2}.value === undefined) {
7175
7175
  if (${k} in input) {
7176
7176
  newResult[${k}] = undefined;
7177
7177
  }
7178
7178
  } else {
7179
- newResult[${k}] = ${id}.value;
7179
+ newResult[${k}] = ${id2}.value;
7180
7180
  }
7181
7181
 
7182
7182
  `);
7183
7183
  } else if (!isOptionalIn) {
7184
7184
  doc.write(`
7185
- const ${id}_present = ${k} in input;
7186
- if (${id}.issues.length) {
7187
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
7185
+ const ${id2}_present = ${k} in input;
7186
+ if (${id2}.issues.length) {
7187
+ payload.issues = payload.issues.concat(${id2}.issues.map(iss => ({
7188
7188
  ...iss,
7189
7189
  path: iss.path ? [${k}, ...iss.path] : [${k}]
7190
7190
  })));
7191
7191
  }
7192
- if (!${id}_present && !${id}.issues.length) {
7192
+ if (!${id2}_present && !${id2}.issues.length) {
7193
7193
  payload.issues.push({
7194
7194
  code: "invalid_type",
7195
7195
  expected: "nonoptional",
@@ -7198,30 +7198,30 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
7198
7198
  });
7199
7199
  }
7200
7200
 
7201
- if (${id}_present) {
7202
- if (${id}.value === undefined) {
7201
+ if (${id2}_present) {
7202
+ if (${id2}.value === undefined) {
7203
7203
  newResult[${k}] = undefined;
7204
7204
  } else {
7205
- newResult[${k}] = ${id}.value;
7205
+ newResult[${k}] = ${id2}.value;
7206
7206
  }
7207
7207
  }
7208
7208
 
7209
7209
  `);
7210
7210
  } else {
7211
7211
  doc.write(`
7212
- if (${id}.issues.length) {
7213
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
7212
+ if (${id2}.issues.length) {
7213
+ payload.issues = payload.issues.concat(${id2}.issues.map(iss => ({
7214
7214
  ...iss,
7215
7215
  path: iss.path ? [${k}, ...iss.path] : [${k}]
7216
7216
  })));
7217
7217
  }
7218
7218
 
7219
- if (${id}.value === undefined) {
7219
+ if (${id2}.value === undefined) {
7220
7220
  if (${k} in input) {
7221
7221
  newResult[${k}] = undefined;
7222
7222
  }
7223
7223
  } else {
7224
- newResult[${k}] = ${id}.value;
7224
+ newResult[${k}] = ${id2}.value;
7225
7225
  }
7226
7226
 
7227
7227
  `);
@@ -15553,26 +15553,26 @@ function extractDefs(ctx, schema) {
15553
15553
  throw new Error("Unprocessed schema. This is a bug in Zod.");
15554
15554
  const idToSchema = /* @__PURE__ */ new Map();
15555
15555
  for (const entry of ctx.seen.entries()) {
15556
- const id = ctx.metadataRegistry.get(entry[0])?.id;
15557
- if (id) {
15558
- const existing = idToSchema.get(id);
15556
+ const id2 = ctx.metadataRegistry.get(entry[0])?.id;
15557
+ if (id2) {
15558
+ const existing = idToSchema.get(id2);
15559
15559
  if (existing && existing !== entry[0]) {
15560
- throw new Error(`Duplicate schema id "${id}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
15560
+ throw new Error(`Duplicate schema id "${id2}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
15561
15561
  }
15562
- idToSchema.set(id, entry[0]);
15562
+ idToSchema.set(id2, entry[0]);
15563
15563
  }
15564
15564
  }
15565
15565
  const makeURI = (entry) => {
15566
15566
  const defsSegment = ctx.target === "draft-2020-12" ? "$defs" : "definitions";
15567
15567
  if (ctx.external) {
15568
15568
  const externalId = ctx.external.registry.get(entry[0])?.id;
15569
- const uriGenerator = ctx.external.uri ?? ((id2) => id2);
15569
+ const uriGenerator = ctx.external.uri ?? ((id3) => id3);
15570
15570
  if (externalId) {
15571
15571
  return { ref: uriGenerator(externalId) };
15572
15572
  }
15573
- const id = entry[1].defId ?? entry[1].schema.id ?? `schema${ctx.counter++}`;
15574
- entry[1].defId = id;
15575
- return { defId: id, ref: `${uriGenerator("__shared")}#/${defsSegment}/${id}` };
15573
+ const id2 = entry[1].defId ?? entry[1].schema.id ?? `schema${ctx.counter++}`;
15574
+ entry[1].defId = id2;
15575
+ return { defId: id2, ref: `${uriGenerator("__shared")}#/${defsSegment}/${id2}` };
15576
15576
  }
15577
15577
  if (entry[1] === root) {
15578
15578
  return { ref: "#" };
@@ -15620,8 +15620,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15620
15620
  continue;
15621
15621
  }
15622
15622
  }
15623
- const id = ctx.metadataRegistry.get(entry[0])?.id;
15624
- if (id) {
15623
+ const id2 = ctx.metadataRegistry.get(entry[0])?.id;
15624
+ if (id2) {
15625
15625
  extractToDef(entry);
15626
15626
  continue;
15627
15627
  }
@@ -15717,10 +15717,10 @@ function finalize(ctx, schema) {
15717
15717
  } else {
15718
15718
  }
15719
15719
  if (ctx.external?.uri) {
15720
- const id = ctx.external.registry.get(schema)?.id;
15721
- if (!id)
15720
+ const id2 = ctx.external.registry.get(schema)?.id;
15721
+ if (!id2)
15722
15722
  throw new Error("Schema is missing an `id` property");
15723
- result.$id = ctx.external.uri(id);
15723
+ result.$id = ctx.external.uri(id2);
15724
15724
  }
15725
15725
  Object.assign(result, root.def ?? root.schema);
15726
15726
  const rootMetaId = ctx.metadataRegistry.get(schema)?.id;
@@ -15880,9 +15880,9 @@ var numberProcessor = (schema, ctx, _json, _params) => {
15880
15880
  json2.type = "number";
15881
15881
  const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
15882
15882
  const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
15883
- const legacy = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
15883
+ const legacy2 = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
15884
15884
  if (exMin) {
15885
- if (legacy) {
15885
+ if (legacy2) {
15886
15886
  json2.minimum = exclusiveMinimum;
15887
15887
  json2.exclusiveMinimum = true;
15888
15888
  } else {
@@ -15892,7 +15892,7 @@ var numberProcessor = (schema, ctx, _json, _params) => {
15892
15892
  json2.minimum = minimum;
15893
15893
  }
15894
15894
  if (exMax) {
15895
- if (legacy) {
15895
+ if (legacy2) {
15896
15896
  json2.maximum = exclusiveMaximum;
15897
15897
  json2.exclusiveMaximum = true;
15898
15898
  } else {
@@ -16754,7 +16754,7 @@ var safeDecodeAsync2 = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
16754
16754
 
16755
16755
  // ../../../node_modules/zod/v4/classic/schemas.js
16756
16756
  var _installedGroups = /* @__PURE__ */ new WeakMap();
16757
- function _installLazyMethods(inst, group, methods) {
16757
+ function _installLazyMethods(inst, group, methods2) {
16758
16758
  const proto = Object.getPrototypeOf(inst);
16759
16759
  let installed = _installedGroups.get(proto);
16760
16760
  if (!installed) {
@@ -16764,8 +16764,8 @@ function _installLazyMethods(inst, group, methods) {
16764
16764
  if (installed.has(group))
16765
16765
  return;
16766
16766
  installed.add(group);
16767
- for (const key in methods) {
16768
- const fn = methods[key];
16767
+ for (const key in methods2) {
16768
+ const fn = methods2[key];
16769
16769
  Object.defineProperty(proto, key, {
16770
16770
  configurable: true,
16771
16771
  enumerable: false,
@@ -18576,87 +18576,6 @@ function date4(params) {
18576
18576
  // ../../../node_modules/zod/v4/classic/external.js
18577
18577
  config(en_default());
18578
18578
 
18579
- // ../../shared-contracts/dist/ids.js
18580
- var opaqueIdSchema = external_exports.string().refine((value) => value.trim().length > 0, {
18581
- message: "Identifier must not be empty or whitespace"
18582
- });
18583
- var harnessIdSchema = opaqueIdSchema.brand();
18584
- var hostThreadIdSchema = opaqueIdSchema.brand();
18585
- var hostTurnIdSchema = opaqueIdSchema.brand();
18586
- var hostItemIdSchema = opaqueIdSchema.brand();
18587
- var hostInteractionIdSchema = opaqueIdSchema.brand();
18588
-
18589
- // ../../shared-contracts/dist/harness-plugins.js
18590
- var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
18591
- var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
18592
- var HARNESS_PLUGIN_LIMIT = 128;
18593
- var installedPluginIdSchema = external_exports.string().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u);
18594
- var installedHarnessPluginIdSchema = installedPluginIdSchema.pipe(harnessIdSchema);
18595
- var harnessPluginIdSchema = installedHarnessPluginIdSchema.refine((id) => id !== "codex", "The official Codex identity is reserved");
18596
- 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");
18597
- var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
18598
- var localizedTextSchema = external_exports.object({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).strict();
18599
- var harnessInstallationGuideSchema = external_exports.object({
18600
- commands: external_exports.array(external_exports.object({ terminal: external_exports.string().max(256), command: external_exports.string().max(4096) }).strict()).max(8),
18601
- before: localizedTextSchema.optional(),
18602
- after: localizedTextSchema.optional(),
18603
- downloads: external_exports.array(external_exports.object({ label: external_exports.string().max(128), url: documentationUrlSchema }).strict()).max(8).optional()
18604
- }).strict();
18605
- var pluginPresentationShape = {
18606
- id: installedHarnessPluginIdSchema,
18607
- name: external_exports.string().trim().min(1).max(128),
18608
- version: external_exports.string().min(1).max(128),
18609
- /** Capability-only plugin; omitted for existing session-capable plugins. */
18610
- kind: external_exports.literal("usage").optional(),
18611
- /** Original image styling or bounded vector paths; never arbitrary CSS/SVG markup. */
18612
- iconStyle: external_exports.object({
18613
- vector: external_exports.object({
18614
- viewBox: external_exports.string().max(128).regex(/^-?\d+(?:\.\d+)?(?: +-?\d+(?:\.\d+)?){3}$/u),
18615
- color: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu),
18616
- paths: external_exports.array(external_exports.object({
18617
- d: external_exports.string().min(1).max(32768).regex(/^[MmLlHhVvCcSsQqTtAaZz\d.,+eE\s-]+$/u),
18618
- fillRule: external_exports.enum(["evenodd", "nonzero"]).optional(),
18619
- fill: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu).optional()
18620
- }).strict()).min(1).max(32)
18621
- }).strict().optional(),
18622
- background: external_exports.string().regex(/^#[a-f0-9]{6}$/iu).optional(),
18623
- borderRadius: external_exports.number().min(0).max(50).optional(),
18624
- paddingRatio: external_exports.number().min(0).max(0.25).optional()
18625
- }).strict().optional(),
18626
- installation: harnessInstallationGuideSchema.optional(),
18627
- notice: localizedTextSchema.optional(),
18628
- /** The factory accepts a persisted local entrypoint through its construction context. */
18629
- launchCommand: external_exports.literal(true).optional(),
18630
- links: external_exports.object({
18631
- website: documentationUrlSchema.optional(),
18632
- documentation: documentationUrlSchema.optional(),
18633
- installation: documentationUrlSchema.optional()
18634
- }).strict().optional()
18635
- };
18636
- var harnessPluginManifestSchema = external_exports.object({
18637
- manifestVersion: external_exports.literal(1),
18638
- ...pluginPresentationShape,
18639
- adapterApiVersion: external_exports.number().int().positive(),
18640
- entry: pluginRelativeResourceSchema,
18641
- icon: pluginRelativeResourceSchema.optional()
18642
- }).strict();
18643
- 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);
18644
- var harnessPluginDescriptorSchema = external_exports.object({
18645
- ...pluginPresentationShape,
18646
- icon: harnessPluginIconSchema.optional()
18647
- }).strict();
18648
- var harnessPluginListParamsSchema = external_exports.object({}).strict();
18649
- var harnessPluginListResultSchema = external_exports.object({
18650
- plugins: external_exports.array(harnessPluginDescriptorSchema.extend({ id: harnessPluginIdSchema })).max(HARNESS_PLUGIN_LIMIT)
18651
- }).strict();
18652
- var harnessPluginConfigurationSchema = external_exports.object({
18653
- version: external_exports.literal(1),
18654
- enabled: external_exports.array(installedHarnessPluginIdSchema).max(HARNESS_PLUGIN_LIMIT)
18655
- }).strict().refine((value) => new Set(value.enabled).size === value.enabled.length, {
18656
- message: "Enabled plugin IDs must be unique",
18657
- path: ["enabled"]
18658
- });
18659
-
18660
18579
  // ../../shared-contracts/dist/json-value.js
18661
18580
  function rejectExplicitUndefined(keys) {
18662
18581
  return (value, context) => {
@@ -18716,346 +18635,6 @@ var jsonValueSchema = nonCircularSchema.pipe(recursiveJsonValueSchema);
18716
18635
  var jsonArraySchema = nonCircularSchema.pipe(external_exports.array(recursiveJsonValueSchema));
18717
18636
  var jsonObjectSchema = nonCircularSchema.pipe(external_exports.record(external_exports.string(), recursiveJsonValueSchema));
18718
18637
 
18719
- // ../../shared-contracts/dist/desktop-extensions.js
18720
- var DESKTOP_EXTENSION_API_VERSION = 1;
18721
- var DESKTOP_EXTENSION_LIMIT = 64;
18722
- var DESKTOP_EXTENSION_ZIP_MAX_BYTES = 64 * 1024 * 1024;
18723
- var DESKTOP_EXTENSION_ZIP_MAX_BASE64_LENGTH = 4 * Math.ceil(DESKTOP_EXTENSION_ZIP_MAX_BYTES / 3);
18724
- var DESKTOP_EXTENSION_MANIFEST_MAX_BYTES = 128 * 1024;
18725
- var DESKTOP_EXTENSION_SCRIPT_MAX_BYTES = 2 * 1024 * 1024;
18726
- var DESKTOP_EXTENSION_STYLE_MAX_BYTES = 256 * 1024;
18727
- var DESKTOP_EXTENSION_ICON_MAX_BYTES = 128 * 1024;
18728
- var DESKTOP_EXTENSION_SCREENSHOT_LIMIT = 4;
18729
- var DESKTOP_EXTENSION_SCREENSHOT_MAX_BYTES = 512 * 1024;
18730
- var DESKTOP_EXTENSION_LIST_SCREENSHOTS_MAX_BYTES = 8 * 1024 * 1024;
18731
- var DESKTOP_EXTENSION_SNAPSHOT_MAX_BYTES = 8 * 1024 * 1024;
18732
- var DESKTOP_EXTENSION_ASSET_MAX_BYTES = 16 * 1024 * 1024;
18733
- var DESKTOP_EXTENSION_SETTINGS_MAX_BYTES = 1024 * 1024;
18734
- var desktopExtensionIdSchema = installedPluginIdSchema;
18735
- var desktopExtensionSlotSchema = external_exports.enum([
18736
- "sidebar.thread-layout",
18737
- "sidebar.thread-badge",
18738
- "appearance.theme"
18739
- ]);
18740
- var desktopExtensionCategorySchema = external_exports.enum([
18741
- "appearance",
18742
- "interface",
18743
- "workflow",
18744
- "analytics",
18745
- "integrations",
18746
- "tools"
18747
- ]);
18748
- var extensionName = external_exports.string().trim().min(1).max(128);
18749
- function desktopExtensionScreenshotMimeType(resource) {
18750
- switch (resource.match(/\.([^./]+)$/u)?.[1]?.toLowerCase()) {
18751
- case "png":
18752
- return "image/png";
18753
- case "jpg":
18754
- case "jpeg":
18755
- return "image/jpeg";
18756
- case "webp":
18757
- return "image/webp";
18758
- default:
18759
- return void 0;
18760
- }
18761
- }
18762
- function desktopExtensionAssetMimeType(resource) {
18763
- switch (resource.match(/\.([^./]+)$/u)?.[1]?.toLowerCase()) {
18764
- case "gif":
18765
- return "image/gif";
18766
- case "svg":
18767
- return "image/svg+xml";
18768
- case "woff2":
18769
- return "font/woff2";
18770
- case "json":
18771
- return "application/json";
18772
- case "css":
18773
- return "text/css";
18774
- default:
18775
- return desktopExtensionScreenshotMimeType(resource);
18776
- }
18777
- }
18778
- var hasPortableSegments = (resource) => resource.split("/").every((segment) => !/[. ]$/u.test(segment));
18779
- var desktopExtensionAssetPathSchema = pluginRelativeResourceSchema.refine((resource) => hasPortableSegments(resource) && desktopExtensionAssetMimeType(resource) !== void 0, "Expected a relative Desktop extension asset path with a supported suffix");
18780
- 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");
18781
- 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) => {
18782
- const { username, password } = new URL(value);
18783
- return !username && !password && !/[\\\s]/u.test(value);
18784
- }, "URL must not contain credentials, backslashes, or whitespace");
18785
- function localizedText(text) {
18786
- return external_exports.strictObject({ en: text, "zh-CN": text });
18787
- }
18788
- var desktopExtensionLocalizedTextSchema = localizedText(external_exports.string().trim().min(1));
18789
- var categoriesSchema = external_exports.array(desktopExtensionCategorySchema).max(desktopExtensionCategorySchema.options.length).refine((categories) => new Set(categories).size === categories.length, "Duplicate categories");
18790
- var slotsSchema = external_exports.array(desktopExtensionSlotSchema).max(desktopExtensionSlotSchema.options.length).refine((slots) => new Set(slots).size === slots.length, "Duplicate slots");
18791
- var settingField = {
18792
- key: external_exports.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/u),
18793
- label: desktopExtensionLocalizedTextSchema,
18794
- description: desktopExtensionLocalizedTextSchema.optional()
18795
- };
18796
- var numericSetting = {
18797
- ...settingField,
18798
- step: external_exports.number().positive().optional(),
18799
- default: external_exports.number().optional()
18800
- };
18801
- var settingOption = external_exports.strictObject({
18802
- value: external_exports.string(),
18803
- label: desktopExtensionLocalizedTextSchema
18804
- });
18805
- var desktopExtensionSettingFieldSchema = external_exports.discriminatedUnion("type", [
18806
- external_exports.strictObject({
18807
- ...settingField,
18808
- type: external_exports.literal("boolean"),
18809
- default: external_exports.boolean().optional()
18810
- }),
18811
- external_exports.strictObject({
18812
- ...settingField,
18813
- type: external_exports.literal("string"),
18814
- placeholder: desktopExtensionLocalizedTextSchema.optional(),
18815
- default: external_exports.string().optional()
18816
- }),
18817
- external_exports.strictObject({
18818
- ...numericSetting,
18819
- type: external_exports.literal("number"),
18820
- min: external_exports.number().optional(),
18821
- max: external_exports.number().optional()
18822
- }),
18823
- external_exports.strictObject({
18824
- ...numericSetting,
18825
- type: external_exports.literal("range"),
18826
- min: external_exports.number(),
18827
- max: external_exports.number()
18828
- }),
18829
- external_exports.strictObject({
18830
- ...settingField,
18831
- type: external_exports.literal("select"),
18832
- options: external_exports.array(settingOption).min(1),
18833
- default: external_exports.string().optional()
18834
- })
18835
- ]).superRefine((field2, ctx) => {
18836
- const issue2 = (path7, message) => ctx.addIssue({ code: "custom", path: [path7], message });
18837
- if (field2.type === "number" || field2.type === "range") {
18838
- const { min = -Infinity, max = Infinity, default: value } = field2;
18839
- if (min > max)
18840
- issue2("max", "Must be at least min");
18841
- if (value !== void 0 && (value < min || value > max))
18842
- issue2("default", "Must be within min and max");
18843
- } else if (field2.type === "select") {
18844
- const values = new Set(field2.options.map(({ value }) => value));
18845
- if (values.size !== field2.options.length)
18846
- issue2("options", "Duplicate option values");
18847
- if (field2.default !== void 0 && !values.has(field2.default))
18848
- issue2("default", "Must match an option value");
18849
- }
18850
- });
18851
- var manifestHeader = external_exports.object({
18852
- manifestVersion: external_exports.int().positive(),
18853
- id: desktopExtensionIdSchema,
18854
- name: external_exports.union([extensionName, localizedText(extensionName)]),
18855
- version: external_exports.string().min(1).max(128),
18856
- desktopApi: external_exports.int().positive()
18857
- }).passthrough();
18858
- var desktopExtensionManifestSchema = manifestHeader.extend({
18859
- manifestVersion: external_exports.literal(1),
18860
- desktopApi: external_exports.literal(DESKTOP_EXTENSION_API_VERSION),
18861
- description: external_exports.strictObject({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).optional(),
18862
- author: external_exports.string().trim().min(1).max(128).optional(),
18863
- repository: desktopExtensionHttpUrlSchema.optional(),
18864
- details: external_exports.strictObject({ en: external_exports.string().max(16384), "zh-CN": external_exports.string().max(16384).optional() }).optional(),
18865
- icon: imagePathSchema.optional(),
18866
- screenshots: external_exports.array(imagePathSchema).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).refine((screenshots) => new Set(screenshots).size === screenshots.length, "Duplicate screenshots").optional(),
18867
- desktop: external_exports.strictObject({
18868
- script: pluginRelativeResourceSchema,
18869
- style: pluginRelativeResourceSchema.optional()
18870
- }).optional(),
18871
- backend: external_exports.strictObject({ script: pluginRelativeResourceSchema.refine(hasPortableSegments) }).optional(),
18872
- slots: slotsSchema.default(() => []),
18873
- settingsSchema: external_exports.array(desktopExtensionSettingFieldSchema).max(32).refine((fields) => new Set(fields.map(({ key }) => key)).size === fields.length, "Duplicate setting keys").optional(),
18874
- categories: categoriesSchema.optional()
18875
- }).strict().refine((manifest) => manifest.desktop !== void 0 || manifest.backend !== void 0, "Expected at least one desktop or backend entry");
18876
- var desktopExtensionConfigurationSchema = external_exports.strictObject({
18877
- version: external_exports.literal(1),
18878
- revision: external_exports.int().nonnegative(),
18879
- enabled: external_exports.array(desktopExtensionIdSchema).max(DESKTOP_EXTENSION_LIMIT).refine((ids) => new Set(ids).size === ids.length, "Duplicate extension IDs"),
18880
- reloadToken: external_exports.uuid().optional()
18881
- });
18882
- var desktopExtensionHashSchema = external_exports.string().regex(/^[a-f0-9]{64}$/u);
18883
- var desktopExtensionStatusSchema = external_exports.strictObject({
18884
- state: external_exports.enum([
18885
- "running",
18886
- "disabled",
18887
- "invalid",
18888
- "incompatible",
18889
- "conflict",
18890
- "failed",
18891
- "waiting"
18892
- ]),
18893
- hash: desktopExtensionHashSchema.optional(),
18894
- error: external_exports.string().optional(),
18895
- conflictWith: desktopExtensionIdSchema.optional()
18896
- });
18897
- var desktopExtensionsDiagnosticSchema = external_exports.strictObject({
18898
- controllerPid: external_exports.int().positive(),
18899
- targetId: external_exports.string().nullable(),
18900
- updatedAt: external_exports.iso.datetime(),
18901
- handledReloadToken: external_exports.uuid().optional(),
18902
- extensions: external_exports.record(external_exports.string(), desktopExtensionStatusSchema)
18903
- });
18904
- var desktopExtensionTrustTierSchema = external_exports.enum(["official", "community"]);
18905
- function isGitHubDesktopExtensionZipballUrl(url2) {
18906
- return url2.origin === "https://api.github.com" && /^\/repos\/[\w-]+\/[\w.-]+\/zipball(?:\/[^/]+)?\/?$/u.test(url2.pathname);
18907
- }
18908
- var desktopExtensionZipUrlSchema = desktopExtensionHttpUrlSchema.refine((input) => {
18909
- const url2 = new URL(input);
18910
- 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);
18911
- }, "Expected a .zip download URL or a GitHub zipball URL");
18912
- var desktopExtensionCatalogEntrySchema = external_exports.strictObject({
18913
- id: desktopExtensionIdSchema,
18914
- version: external_exports.string().trim().min(1).max(128),
18915
- name: desktopExtensionLocalizedTextSchema.extend({ en: extensionName, "zh-CN": extensionName }),
18916
- description: localizedText(external_exports.string().trim().min(1).max(4096)),
18917
- details: localizedText(external_exports.string().trim().min(1).max(16384)).optional(),
18918
- author: external_exports.string().trim().min(1).max(128),
18919
- repository: desktopExtensionHttpUrlSchema,
18920
- stars: external_exports.number().int().min(0).optional(),
18921
- downloads: external_exports.number().int().min(0).optional(),
18922
- categories: categoriesSchema.optional(),
18923
- trustTier: desktopExtensionTrustTierSchema.default("community"),
18924
- icon: desktopExtensionHttpUrlSchema.optional(),
18925
- screenshots: external_exports.array(desktopExtensionHttpUrlSchema).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).optional(),
18926
- downloadUrl: desktopExtensionZipUrlSchema,
18927
- sha256: desktopExtensionHashSchema,
18928
- slots: slotsSchema.optional(),
18929
- publishedAt: external_exports.string().optional(),
18930
- updatedAt: external_exports.string().optional(),
18931
- minCodexHostVersion: external_exports.string().optional()
18932
- });
18933
- var desktopExtensionCatalogSchema = external_exports.strictObject({
18934
- schemaVersion: external_exports.literal(1),
18935
- generatedAt: external_exports.string(),
18936
- extensions: external_exports.array(desktopExtensionCatalogEntrySchema).refine((entries) => new Set(entries.map(({ id }) => id)).size === entries.length, "Duplicate extension IDs")
18937
- });
18938
- var DESKTOP_EXTENSIONS_ASSET_METHOD = "codexhost/desktop/extensions/asset";
18939
- var DESKTOP_EXTENSIONS_SETTINGS_GET_METHOD = "codexhost/desktop/extensions/settings/get";
18940
- var DESKTOP_EXTENSIONS_SETTINGS_SET_METHOD = "codexhost/desktop/extensions/settings/set";
18941
- var DESKTOP_EXTENSIONS_BACKEND_INVOKE_METHOD = "codexhost/desktop/extensions/backend/invoke";
18942
- var extensionIdParams = { id: desktopExtensionIdSchema };
18943
- var desktopExtensionsAssetParamsSchema = external_exports.strictObject({
18944
- ...extensionIdParams,
18945
- path: desktopExtensionAssetPathSchema
18946
- });
18947
- var desktopExtensionsAssetResultSchema = external_exports.strictObject({
18948
- mimeType: external_exports.string(),
18949
- dataUrl: external_exports.string()
18950
- });
18951
- var desktopExtensionsSettingsGetParamsSchema = external_exports.strictObject(extensionIdParams);
18952
- var desktopExtensionsSettingsSetParamsSchema = external_exports.strictObject({
18953
- ...extensionIdParams,
18954
- values: jsonObjectSchema
18955
- });
18956
- var desktopExtensionsSettingsResultSchema = external_exports.strictObject({ values: jsonObjectSchema });
18957
- var desktopExtensionBackendMethodSchema = external_exports.string().trim().min(1).max(128);
18958
- var desktopExtensionsBackendInvokeParamsSchema = external_exports.strictObject({
18959
- ...extensionIdParams,
18960
- method: desktopExtensionBackendMethodSchema,
18961
- params: jsonValueSchema.optional()
18962
- });
18963
- var desktopExtensionsBackendInvokeResultSchema = external_exports.strictObject({
18964
- result: jsonValueSchema
18965
- });
18966
-
18967
- // ../../shared-contracts/dist/desktop-extension-management.js
18968
- var DESKTOP_EXTENSIONS_LIST_METHOD = "codexhost/desktop/extensions/list";
18969
- var DESKTOP_EXTENSIONS_ENABLE_METHOD = "codexhost/desktop/extensions/enable";
18970
- var DESKTOP_EXTENSIONS_DISABLE_METHOD = "codexhost/desktop/extensions/disable";
18971
- var DESKTOP_EXTENSIONS_CATALOG_METHOD = "codexhost/desktop/extensions/catalog";
18972
- var DESKTOP_EXTENSIONS_INSTALL_METHOD = "codexhost/desktop/extensions/install";
18973
- var DESKTOP_EXTENSIONS_UNINSTALL_METHOD = "codexhost/desktop/extensions/uninstall";
18974
- var DESKTOP_EXTENSIONS_RECOVER_METHOD = "codexhost/desktop/extensions/disable-all-and-reload";
18975
- var DESKTOP_EXTENSION_MANAGEMENT_METHODS = [
18976
- DESKTOP_EXTENSIONS_LIST_METHOD,
18977
- DESKTOP_EXTENSIONS_ENABLE_METHOD,
18978
- DESKTOP_EXTENSIONS_DISABLE_METHOD,
18979
- DESKTOP_EXTENSIONS_RECOVER_METHOD,
18980
- DESKTOP_EXTENSIONS_CATALOG_METHOD,
18981
- DESKTOP_EXTENSIONS_INSTALL_METHOD,
18982
- DESKTOP_EXTENSIONS_UNINSTALL_METHOD,
18983
- DESKTOP_EXTENSIONS_ASSET_METHOD,
18984
- DESKTOP_EXTENSIONS_SETTINGS_GET_METHOD,
18985
- DESKTOP_EXTENSIONS_SETTINGS_SET_METHOD,
18986
- DESKTOP_EXTENSIONS_BACKEND_INVOKE_METHOD
18987
- ];
18988
- var revisionSchema = external_exports.int().nonnegative();
18989
- var desktopExtensionsListParamsSchema = external_exports.strictObject({});
18990
- var desktopExtensionSelectionParamsSchema = external_exports.strictObject({
18991
- id: desktopExtensionIdSchema,
18992
- expectedRevision: revisionSchema
18993
- });
18994
- var desktopExtensionsRecoveryParamsSchema = external_exports.strictObject({
18995
- expectedRevision: revisionSchema.optional()
18996
- });
18997
- 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);
18998
- var desktopExtensionListItemSchema = external_exports.strictObject({
18999
- // An invalid discovery can have a directory name that isn't a valid extension ID.
19000
- id: external_exports.string().min(1),
19001
- manifest: desktopExtensionManifestSchema.optional(),
19002
- iconDataUrl: rasterDataUrlSchema(DESKTOP_EXTENSION_ICON_MAX_BYTES).optional(),
19003
- screenshotDataUrls: external_exports.array(rasterDataUrlSchema(DESKTOP_EXTENSION_SCREENSHOT_MAX_BYTES)).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).optional(),
19004
- enabled: external_exports.boolean(),
19005
- status: desktopExtensionStatusSchema
19006
- });
19007
- var desktopExtensionsListResultSchema = external_exports.strictObject({
19008
- configuration: desktopExtensionConfigurationSchema,
19009
- desktopConnected: external_exports.boolean(),
19010
- diagnostics: external_exports.array(external_exports.string()),
19011
- extensions: external_exports.array(desktopExtensionListItemSchema)
19012
- });
19013
- var desktopExtensionsCatalogParamsSchema = external_exports.strictObject({
19014
- forceRefresh: external_exports.boolean().optional()
19015
- });
19016
- var desktopExtensionsCatalogResultSchema = external_exports.strictObject({
19017
- catalogUrl: external_exports.string(),
19018
- source: external_exports.enum(["remote", "fallback"]),
19019
- fetchedAt: external_exports.string(),
19020
- cached: external_exports.boolean(),
19021
- extensions: desktopExtensionCatalogSchema.shape.extensions,
19022
- error: external_exports.string().optional()
19023
- });
19024
- var desktopExtensionsInstallParamsSchema = external_exports.strictObject({
19025
- source: external_exports.discriminatedUnion("type", [
19026
- external_exports.strictObject({ type: external_exports.literal("catalog"), id: desktopExtensionIdSchema }),
19027
- external_exports.strictObject({
19028
- type: external_exports.literal("url"),
19029
- url: desktopExtensionHttpUrlSchema,
19030
- expectedSha256: desktopExtensionHashSchema.optional()
19031
- }),
19032
- external_exports.strictObject({
19033
- type: external_exports.literal("zip-base64"),
19034
- fileName: external_exports.string().trim().min(1).max(255),
19035
- 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")
19036
- })
19037
- ])
19038
- });
19039
- var desktopExtensionsInstallResultSchema = external_exports.strictObject({
19040
- extensionId: desktopExtensionIdSchema,
19041
- version: external_exports.string().min(1),
19042
- replaced: external_exports.boolean(),
19043
- installedPath: external_exports.string(),
19044
- list: desktopExtensionsListResultSchema
19045
- });
19046
- var desktopExtensionsUninstallParamsSchema = external_exports.strictObject({
19047
- id: desktopExtensionIdSchema
19048
- });
19049
- var desktopExtensionsUninstallResultSchema = external_exports.strictObject({
19050
- removedId: desktopExtensionIdSchema,
19051
- list: desktopExtensionsListResultSchema
19052
- });
19053
- var desktopExtensionMutationResultSchema = external_exports.discriminatedUnion("state", [
19054
- external_exports.strictObject({ state: external_exports.literal("saved"), configuration: desktopExtensionConfigurationSchema }),
19055
- external_exports.strictObject({ state: external_exports.literal("slot-conflict"), conflictWith: desktopExtensionIdSchema }),
19056
- external_exports.strictObject({ state: external_exports.literal("revision-conflict"), revision: revisionSchema })
19057
- ]);
19058
-
19059
18638
  // ../../shared-contracts/dist/errors.js
19060
18639
  var codexhostErrorSchema = external_exports.strictObject({
19061
18640
  code: external_exports.string().min(1),
@@ -19076,6 +18655,16 @@ var harnessLocalizationsSchema = external_exports.record(localeSchema, external_
19076
18655
  }).strict()).refine((entries) => Object.keys(entries).length <= 16, "Too many locales");
19077
18656
  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");
19078
18657
 
18658
+ // ../../shared-contracts/dist/ids.js
18659
+ var opaqueIdSchema = external_exports.string().refine((value) => value.trim().length > 0, {
18660
+ message: "Identifier must not be empty or whitespace"
18661
+ });
18662
+ var harnessIdSchema = opaqueIdSchema.brand();
18663
+ var hostThreadIdSchema = opaqueIdSchema.brand();
18664
+ var hostTurnIdSchema = opaqueIdSchema.brand();
18665
+ var hostItemIdSchema = opaqueIdSchema.brand();
18666
+ var hostInteractionIdSchema = opaqueIdSchema.brand();
18667
+
19079
18668
  // ../../shared-contracts/dist/harness-permission-modes.js
19080
18669
  var HARNESS_PERMISSION_MODE_ID_MAX_LENGTH = 128;
19081
18670
  var HARNESS_PERMISSION_MODE_LABEL_MAX_LENGTH = 256;
@@ -19120,6 +18709,9 @@ var threadPermissionModeSelectParamsSchema = external_exports.object({
19120
18709
  permissionModeId: harnessPermissionModeIdSchema
19121
18710
  }).strict();
19122
18711
 
18712
+ // ../../shared-contracts/dist/harness-route-limit.js
18713
+ var HARNESS_TRANSPORT_MODEL_ID_MAX_LENGTH = 8192;
18714
+
19123
18715
  // ../../shared-contracts/dist/thread-usage.js
19124
18716
  var nonNegativeSafeIntegerSchema = external_exports.number().int().safe().nonnegative();
19125
18717
  var finiteNonNegativeNumberSchema = external_exports.number().finite().nonnegative();
@@ -19152,7 +18744,7 @@ var composerIndicatorsSchema = external_exports.array(external_exports.object({
19152
18744
  expiresAtUnix: nonNegativeSafeIntegerSchema,
19153
18745
  label: indicatorTextSchema(256).optional(),
19154
18746
  tooltip: indicatorTextSchema(1024).optional()
19155
- }).strict()).max(2).refine((entries) => new Set(entries.map(({ id }) => id)).size === entries.length, {
18747
+ }).strict()).max(2).refine((entries) => new Set(entries.map(({ id: id2 }) => id2)).size === entries.length, {
19156
18748
  message: "Composer indicator IDs must be unique"
19157
18749
  });
19158
18750
  var threadUsageSnapshotSchema = external_exports.object({
@@ -19178,6 +18770,7 @@ var threadUsageSnapshotSchema = external_exports.object({
19178
18770
  planSevenDayResetsAtUnix: nonNegativeSafeIntegerSchema.optional(),
19179
18771
  sessionCacheHitRatePercent: cacheHitRatePercentSchema.optional(),
19180
18772
  timeToFirstOutputMs: nonNegativeSafeIntegerSchema.optional(),
18773
+ latestRequestTimeToFirstOutputMs: nonNegativeSafeIntegerSchema.optional(),
19181
18774
  costSource: external_exports.enum(["publicPrice", "native"]).optional(),
19182
18775
  unpricedModels: external_exports.array(external_exports.string().min(1)).min(1).optional()
19183
18776
  }).strict().superRefine((usage, context) => {
@@ -19305,10 +18898,15 @@ var THREAD_OWNERSHIP_LIST_MAX_LENGTH = 100;
19305
18898
  var nonBlankTextSchema2 = external_exports.string().refine((value) => value.trim().length > 0, {
19306
18899
  message: "Value must not be empty or whitespace"
19307
18900
  });
19308
- var harnessModelRefIdSchema = nonBlankTextSchema2.max(HARNESS_MODEL_REF_MAX_LENGTH).regex(/^[A-Za-z0-9._~-]+$/u, "Model Ref must use transport-safe opaque characters").brand();
18901
+ 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();
18902
+ var harnessModelServiceTierSchema = external_exports.enum(["priority", "ultrafast"]);
19309
18903
  var harnessModelRefSchema = external_exports.object({
19310
- id: harnessModelRefIdSchema
18904
+ id: harnessModelRefIdSchema,
18905
+ serviceTier: harnessModelServiceTierSchema.optional()
19311
18906
  }).strict();
18907
+ function sameHarnessModelRef(left, right) {
18908
+ return left?.id === right?.id && left?.serviceTier === right?.serviceTier;
18909
+ }
19312
18910
  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();
19313
18911
  var harnessResolvedModelLabelSchema = nonBlankTextSchema2.max(HARNESS_MODEL_LABEL_MAX_LENGTH);
19314
18912
  var harnessThinkingOptionSchema = external_exports.object({
@@ -19322,7 +18920,15 @@ var harnessModelSchema = external_exports.object({
19322
18920
  /** Optional opaque selection for this same Model with priority processing enabled. */
19323
18921
  fastModel: harnessModelRefSchema.optional(),
19324
18922
  supportedThinkingOptionIds: external_exports.array(harnessThinkingOptionIdSchema).optional()
19325
- }).strict();
18923
+ }).strict().refine((model2) => model2.fastModel?.serviceTier === void 0 || model2.fastModel.id === model2.ref.id, {
18924
+ path: ["fastModel", "id"],
18925
+ message: "A tiered Fast Model must share the base Model ID"
18926
+ });
18927
+ function catalogModelForRef(catalog, ref) {
18928
+ if (!ref)
18929
+ return void 0;
18930
+ return catalog?.models.find((model2) => sameHarnessModelRef(model2.ref, ref) || sameHarnessModelRef(model2.fastModel, ref));
18931
+ }
19326
18932
  var harnessThinkingOptionsSchema = external_exports.array(harnessThinkingOptionSchema).superRefine((options2, context) => {
19327
18933
  const ids = /* @__PURE__ */ new Set();
19328
18934
  for (const [index, option] of options2.entries()) {
@@ -19342,26 +18948,26 @@ var harnessModelCatalogSchema = external_exports.object({
19342
18948
  thinkingOptions: harnessThinkingOptionsSchema,
19343
18949
  defaultThinkingOptionId: harnessThinkingOptionIdSchema.optional()
19344
18950
  }).strict().superRefine((catalog, context) => {
19345
- const refs = /* @__PURE__ */ new Set();
19346
- const thinkingIds = new Set(catalog.thinkingOptions.map(({ id }) => id));
18951
+ const refs = [];
18952
+ const thinkingIds = new Set(catalog.thinkingOptions.map(({ id: id2 }) => id2));
19347
18953
  for (const [index, model2] of catalog.models.entries()) {
19348
- if (refs.has(model2.ref.id)) {
18954
+ if (refs.some((ref) => sameHarnessModelRef(ref, model2.ref))) {
19349
18955
  context.addIssue({
19350
18956
  code: "custom",
19351
18957
  message: "Model Catalog refs must be unique",
19352
18958
  path: ["models", index, "ref", "id"]
19353
18959
  });
19354
18960
  }
19355
- refs.add(model2.ref.id);
18961
+ refs.push(model2.ref);
19356
18962
  if (model2.fastModel) {
19357
- if (refs.has(model2.fastModel.id) || catalog.models.some((entry) => entry.ref.id === model2.fastModel?.id)) {
18963
+ if (refs.some((ref) => sameHarnessModelRef(ref, model2.fastModel))) {
19358
18964
  context.addIssue({
19359
18965
  code: "custom",
19360
18966
  message: "Fast Model refs must be distinct and unique",
19361
18967
  path: ["models", index, "fastModel"]
19362
18968
  });
19363
18969
  }
19364
- refs.add(model2.fastModel.id);
18970
+ refs.push(model2.fastModel);
19365
18971
  }
19366
18972
  const supportedThinkingIds = /* @__PURE__ */ new Set();
19367
18973
  for (const [optionIndex, optionId] of (model2.supportedThinkingOptionIds ?? []).entries()) {
@@ -19382,7 +18988,7 @@ var harnessModelCatalogSchema = external_exports.object({
19382
18988
  }
19383
18989
  }
19384
18990
  }
19385
- if (catalog.defaultModel && !refs.has(catalog.defaultModel.id)) {
18991
+ if (catalog.defaultModel && !catalogModelForRef(catalog, catalog.defaultModel)) {
19386
18992
  context.addIssue({
19387
18993
  code: "custom",
19388
18994
  message: "Default Model must exist in the Model Catalog",
@@ -19422,7 +19028,12 @@ var harnessSessionCapabilitiesSchema = external_exports.object({
19422
19028
  observe: external_exports.boolean()
19423
19029
  }).strict().optional(),
19424
19030
  /** True only when `turn.steer` delivers input into the active Turn through a native primitive. */
19425
- steer: external_exports.boolean().optional()
19031
+ steer: external_exports.boolean().optional(),
19032
+ /**
19033
+ * True when the native plan (task list) outlives the Turn that changed it, so a reopened
19034
+ * Thread gets its latest plan again. Otherwise a plan stays with the Turn that made it.
19035
+ */
19036
+ persistentPlan: external_exports.boolean().optional()
19426
19037
  }).strict();
19427
19038
  var harnessConfigurationStateSchema = external_exports.object({
19428
19039
  effectiveModel: harnessModelRefSchema.optional(),
@@ -19431,7 +19042,7 @@ var harnessConfigurationStateSchema = external_exports.object({
19431
19042
  availableThinkingOptions: harnessThinkingOptionsSchema.optional(),
19432
19043
  effectivePermissionModeId: harnessPermissionModeIdSchema.optional()
19433
19044
  }).strict().superRefine((state, context) => {
19434
- if (state.effectiveThinkingOptionId && state.availableThinkingOptions && !state.availableThinkingOptions.some(({ id }) => id === state.effectiveThinkingOptionId)) {
19045
+ if (state.effectiveThinkingOptionId && state.availableThinkingOptions && !state.availableThinkingOptions.some(({ id: id2 }) => id2 === state.effectiveThinkingOptionId)) {
19435
19046
  context.addIssue({
19436
19047
  code: "custom",
19437
19048
  message: "Effective Thinking option must be currently available",
@@ -19471,7 +19082,8 @@ var harnessInspectParamsSchema = external_exports.object({
19471
19082
  cwd: nonBlankTextSchema2.max(16384).optional(),
19472
19083
  refresh: external_exports.boolean().optional(),
19473
19084
  /** `availability` asks only whether the Harness can run; see `InspectHarnessInput.purpose`. */
19474
- purpose: external_exports.literal("availability").optional()
19085
+ purpose: external_exports.literal("availability").optional(),
19086
+ credentialAccess: external_exports.enum(["allow", "retry"]).optional()
19475
19087
  }).strict();
19476
19088
  var harnessWebUiOpenParamsSchema = external_exports.object({
19477
19089
  harnessId: harnessIdSchema
@@ -19502,7 +19114,7 @@ var codexThreadInspectionSchema = external_exports.object({
19502
19114
  var externalThreadInspectionSchema = external_exports.object({
19503
19115
  owner: external_exports.literal("external"),
19504
19116
  harnessId: nonBlankTextSchema2.max(256),
19505
- transportModelId: nonBlankTextSchema2.max(1024),
19117
+ transportModelId: nonBlankTextSchema2.max(HARNESS_TRANSPORT_MODEL_ID_MAX_LENGTH),
19506
19118
  effectiveModel: harnessModelRefSchema.optional(),
19507
19119
  resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
19508
19120
  effectiveThinkingOptionId: harnessThinkingOptionIdSchema.optional(),
@@ -19584,6 +19196,551 @@ var threadSteeringInspectResultSchema = external_exports.object({
19584
19196
  delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
19585
19197
  }).strict();
19586
19198
 
19199
+ // ../../shared-contracts/dist/harness-plugins.js
19200
+ var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
19201
+ var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
19202
+ var HARNESS_PLUGIN_LIMIT = 128;
19203
+ var installedPluginIdSchema = external_exports.string().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u);
19204
+ var installedHarnessPluginIdSchema = installedPluginIdSchema.pipe(harnessIdSchema);
19205
+ var harnessPluginIdSchema = installedHarnessPluginIdSchema.refine((id2) => id2 !== "codex", "The official Codex identity is reserved");
19206
+ 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");
19207
+ var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
19208
+ var localizedTextSchema = external_exports.object({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).strict();
19209
+ var harnessInstallationGuideSchema = external_exports.object({
19210
+ commands: external_exports.array(external_exports.object({ terminal: external_exports.string().max(256), command: external_exports.string().max(4096) }).strict()).max(8),
19211
+ before: localizedTextSchema.optional(),
19212
+ after: localizedTextSchema.optional(),
19213
+ downloads: external_exports.array(external_exports.object({ label: external_exports.string().max(128), url: documentationUrlSchema }).strict()).max(8).optional()
19214
+ }).strict();
19215
+ var pluginPresentationShape = {
19216
+ id: installedHarnessPluginIdSchema,
19217
+ name: external_exports.string().trim().min(1).max(128),
19218
+ version: external_exports.string().min(1).max(128),
19219
+ /** Capability-only plugin; omitted for existing session-capable plugins. */
19220
+ kind: external_exports.literal("usage").optional(),
19221
+ /** Original image styling or bounded vector paths; never arbitrary CSS/SVG markup. */
19222
+ iconStyle: external_exports.object({
19223
+ vector: external_exports.object({
19224
+ viewBox: external_exports.string().max(128).regex(/^-?\d+(?:\.\d+)?(?: +-?\d+(?:\.\d+)?){3}$/u),
19225
+ color: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu),
19226
+ paths: external_exports.array(external_exports.object({
19227
+ d: external_exports.string().min(1).max(32768).regex(/^[MmLlHhVvCcSsQqTtAaZz\d.,+eE\s-]+$/u),
19228
+ fillRule: external_exports.enum(["evenodd", "nonzero"]).optional(),
19229
+ fill: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu).optional()
19230
+ }).strict()).min(1).max(32)
19231
+ }).strict().optional(),
19232
+ background: external_exports.string().regex(/^#[a-f0-9]{6}$/iu).optional(),
19233
+ borderRadius: external_exports.number().min(0).max(50).optional(),
19234
+ paddingRatio: external_exports.number().min(0).max(0.25).optional()
19235
+ }).strict().optional(),
19236
+ installation: harnessInstallationGuideSchema.optional(),
19237
+ notice: localizedTextSchema.optional(),
19238
+ /** The factory accepts a persisted local entrypoint through its construction context. */
19239
+ launchCommand: external_exports.literal(true).optional(),
19240
+ links: external_exports.object({
19241
+ website: documentationUrlSchema.optional(),
19242
+ documentation: documentationUrlSchema.optional(),
19243
+ installation: documentationUrlSchema.optional()
19244
+ }).strict().optional()
19245
+ };
19246
+ var harnessPluginManifestSchema = external_exports.object({
19247
+ manifestVersion: external_exports.literal(1),
19248
+ ...pluginPresentationShape,
19249
+ adapterApiVersion: external_exports.number().int().positive(),
19250
+ entry: pluginRelativeResourceSchema,
19251
+ icon: pluginRelativeResourceSchema.optional()
19252
+ }).strict();
19253
+ 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);
19254
+ var harnessPluginDescriptorSchema = external_exports.object({
19255
+ ...pluginPresentationShape,
19256
+ icon: harnessPluginIconSchema.optional()
19257
+ }).strict();
19258
+ var harnessPluginListParamsSchema = external_exports.object({}).strict();
19259
+ var harnessPluginListResultSchema = external_exports.object({
19260
+ plugins: external_exports.array(harnessPluginDescriptorSchema.extend({ id: harnessPluginIdSchema })).max(HARNESS_PLUGIN_LIMIT)
19261
+ }).strict();
19262
+ var harnessPluginConfigurationSchema = external_exports.object({
19263
+ version: external_exports.literal(1),
19264
+ enabled: external_exports.array(installedHarnessPluginIdSchema).max(HARNESS_PLUGIN_LIMIT)
19265
+ }).strict().refine((value) => new Set(value.enabled).size === value.enabled.length, {
19266
+ message: "Enabled plugin IDs must be unique",
19267
+ path: ["enabled"]
19268
+ });
19269
+
19270
+ // ../../shared-contracts/dist/desktop-extensions.js
19271
+ var DESKTOP_EXTENSION_API_VERSION = 1;
19272
+ var DESKTOP_EXTENSION_LIMIT = 64;
19273
+ var DESKTOP_EXTENSION_ZIP_MAX_BYTES = 64 * 1024 * 1024;
19274
+ var DESKTOP_EXTENSION_MANIFEST_MAX_BYTES = 128 * 1024;
19275
+ var DESKTOP_EXTENSION_SCRIPT_MAX_BYTES = 2 * 1024 * 1024;
19276
+ var DESKTOP_EXTENSION_STYLE_MAX_BYTES = 256 * 1024;
19277
+ var DESKTOP_EXTENSION_ICON_MAX_BYTES = 128 * 1024;
19278
+ var DESKTOP_EXTENSION_SCREENSHOT_LIMIT = 4;
19279
+ var DESKTOP_EXTENSION_SCREENSHOT_MAX_BYTES = 512 * 1024;
19280
+ var DESKTOP_EXTENSION_LIST_SCREENSHOTS_MAX_BYTES = 8 * 1024 * 1024;
19281
+ var DESKTOP_EXTENSION_SNAPSHOT_MAX_BYTES = 8 * 1024 * 1024;
19282
+ var DESKTOP_EXTENSION_ASSET_MAX_BYTES = 16 * 1024 * 1024;
19283
+ var DESKTOP_EXTENSION_SETTINGS_MAX_BYTES = 1024 * 1024;
19284
+ var desktopExtensionIdSchema = installedPluginIdSchema;
19285
+ var desktopExtensionSlotSchema = external_exports.enum([
19286
+ "sidebar.thread-layout",
19287
+ "sidebar.thread-badge",
19288
+ "appearance.theme"
19289
+ ]);
19290
+ var desktopExtensionCategorySchema = external_exports.enum([
19291
+ "appearance",
19292
+ "interface",
19293
+ "workflow",
19294
+ "analytics",
19295
+ "integrations",
19296
+ "tools"
19297
+ ]);
19298
+ var extensionName = external_exports.string().trim().min(1).max(128);
19299
+ function desktopExtensionScreenshotMimeType(resource) {
19300
+ switch (resource.match(/\.([^./]+)$/u)?.[1]?.toLowerCase()) {
19301
+ case "png":
19302
+ return "image/png";
19303
+ case "jpg":
19304
+ case "jpeg":
19305
+ return "image/jpeg";
19306
+ case "webp":
19307
+ return "image/webp";
19308
+ default:
19309
+ return void 0;
19310
+ }
19311
+ }
19312
+ var hasPortableSegments = (resource) => resource.split("/").every((segment) => !/[. ]$/u.test(segment));
19313
+ 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");
19314
+ 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) => {
19315
+ const { username, password } = new URL(value);
19316
+ return !username && !password && !/[\\\s]/u.test(value);
19317
+ }, "URL must not contain credentials, backslashes, or whitespace");
19318
+ function localizedText(text) {
19319
+ return external_exports.strictObject({ en: text, "zh-CN": text });
19320
+ }
19321
+ var desktopExtensionLocalizedTextSchema = localizedText(external_exports.string().trim().min(1));
19322
+ var categoriesSchema = external_exports.array(desktopExtensionCategorySchema).max(desktopExtensionCategorySchema.options.length).refine((categories) => new Set(categories).size === categories.length, "Duplicate categories");
19323
+ var slotsSchema = external_exports.array(desktopExtensionSlotSchema).max(desktopExtensionSlotSchema.options.length).refine((slots) => new Set(slots).size === slots.length, "Duplicate slots");
19324
+ var settingField = {
19325
+ key: external_exports.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/u),
19326
+ label: desktopExtensionLocalizedTextSchema,
19327
+ description: desktopExtensionLocalizedTextSchema.optional()
19328
+ };
19329
+ var numericSetting = {
19330
+ ...settingField,
19331
+ step: external_exports.number().positive().optional(),
19332
+ default: external_exports.number().optional()
19333
+ };
19334
+ var settingOption = external_exports.strictObject({
19335
+ value: external_exports.string(),
19336
+ label: desktopExtensionLocalizedTextSchema
19337
+ });
19338
+ var desktopExtensionSettingFieldSchema = external_exports.discriminatedUnion("type", [
19339
+ external_exports.strictObject({
19340
+ ...settingField,
19341
+ type: external_exports.literal("boolean"),
19342
+ default: external_exports.boolean().optional()
19343
+ }),
19344
+ external_exports.strictObject({
19345
+ ...settingField,
19346
+ type: external_exports.literal("string"),
19347
+ placeholder: desktopExtensionLocalizedTextSchema.optional(),
19348
+ default: external_exports.string().optional()
19349
+ }),
19350
+ external_exports.strictObject({
19351
+ ...numericSetting,
19352
+ type: external_exports.literal("number"),
19353
+ min: external_exports.number().optional(),
19354
+ max: external_exports.number().optional()
19355
+ }),
19356
+ external_exports.strictObject({
19357
+ ...numericSetting,
19358
+ type: external_exports.literal("range"),
19359
+ min: external_exports.number(),
19360
+ max: external_exports.number()
19361
+ }),
19362
+ external_exports.strictObject({
19363
+ ...settingField,
19364
+ type: external_exports.literal("select"),
19365
+ options: external_exports.array(settingOption).min(1),
19366
+ default: external_exports.string().optional()
19367
+ })
19368
+ ]).superRefine((field2, ctx) => {
19369
+ const issue2 = (path7, message) => ctx.addIssue({ code: "custom", path: [path7], message });
19370
+ if (field2.type === "number" || field2.type === "range") {
19371
+ const { min = -Infinity, max = Infinity, default: value } = field2;
19372
+ if (min > max)
19373
+ issue2("max", "Must be at least min");
19374
+ if (value !== void 0 && (value < min || value > max))
19375
+ issue2("default", "Must be within min and max");
19376
+ } else if (field2.type === "select") {
19377
+ const values = new Set(field2.options.map(({ value }) => value));
19378
+ if (values.size !== field2.options.length)
19379
+ issue2("options", "Duplicate option values");
19380
+ if (field2.default !== void 0 && !values.has(field2.default))
19381
+ issue2("default", "Must match an option value");
19382
+ }
19383
+ });
19384
+ var manifestHeader = external_exports.object({
19385
+ manifestVersion: external_exports.int().positive(),
19386
+ id: desktopExtensionIdSchema,
19387
+ name: external_exports.union([extensionName, localizedText(extensionName)]),
19388
+ version: external_exports.string().min(1).max(128),
19389
+ desktopApi: external_exports.int().positive()
19390
+ }).passthrough();
19391
+ var desktopExtensionManifestSchema = manifestHeader.extend({
19392
+ manifestVersion: external_exports.literal(1),
19393
+ desktopApi: external_exports.literal(DESKTOP_EXTENSION_API_VERSION),
19394
+ description: external_exports.strictObject({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).optional(),
19395
+ author: external_exports.string().trim().min(1).max(128).optional(),
19396
+ repository: desktopExtensionHttpUrlSchema.optional(),
19397
+ details: external_exports.strictObject({ en: external_exports.string().max(16384), "zh-CN": external_exports.string().max(16384).optional() }).optional(),
19398
+ icon: imagePathSchema.optional(),
19399
+ screenshots: external_exports.array(imagePathSchema).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).refine((screenshots) => new Set(screenshots).size === screenshots.length, "Duplicate screenshots").optional(),
19400
+ desktop: external_exports.strictObject({
19401
+ script: pluginRelativeResourceSchema,
19402
+ style: pluginRelativeResourceSchema.optional()
19403
+ }).optional(),
19404
+ backend: external_exports.strictObject({ script: pluginRelativeResourceSchema.refine(hasPortableSegments) }).optional(),
19405
+ slots: slotsSchema.default(() => []),
19406
+ settingsSchema: external_exports.array(desktopExtensionSettingFieldSchema).max(32).refine((fields) => new Set(fields.map(({ key }) => key)).size === fields.length, "Duplicate setting keys").optional(),
19407
+ categories: categoriesSchema.optional()
19408
+ }).strict().refine((manifest) => manifest.desktop !== void 0 || manifest.backend !== void 0, "Expected at least one desktop or backend entry");
19409
+ var desktopExtensionHashSchema = external_exports.string().regex(/^[a-f0-9]{64}$/u);
19410
+ var desktopExtensionStatusSchema = external_exports.strictObject({
19411
+ state: external_exports.enum([
19412
+ "running",
19413
+ "disabled",
19414
+ "invalid",
19415
+ "incompatible",
19416
+ "conflict",
19417
+ "failed",
19418
+ "waiting"
19419
+ ]),
19420
+ hash: desktopExtensionHashSchema.optional(),
19421
+ error: external_exports.string().optional(),
19422
+ conflictWith: desktopExtensionIdSchema.optional()
19423
+ });
19424
+ var desktopExtensionsDiagnosticSchema = external_exports.strictObject({
19425
+ controllerPid: external_exports.int().positive(),
19426
+ targetId: external_exports.string().nullable(),
19427
+ updatedAt: external_exports.iso.datetime(),
19428
+ handledReloadToken: external_exports.uuid().optional(),
19429
+ extensions: external_exports.record(external_exports.string(), desktopExtensionStatusSchema),
19430
+ surfaces: external_exports.record(external_exports.string(), desktopExtensionStatusSchema).optional()
19431
+ });
19432
+ var desktopExtensionTrustTierSchema = external_exports.enum(["official", "community"]);
19433
+ function isGitHubDesktopExtensionZipballUrl(url2) {
19434
+ return url2.origin === "https://api.github.com" && /^\/repos\/[\w-]+\/[\w.-]+\/zipball(?:\/[^/]+)?\/?$/u.test(url2.pathname);
19435
+ }
19436
+ var desktopExtensionZipUrlSchema = desktopExtensionHttpUrlSchema.refine((input) => {
19437
+ const url2 = new URL(input);
19438
+ 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);
19439
+ }, "Expected a .zip download URL or a GitHub zipball URL");
19440
+ var desktopExtensionCatalogEntrySchema = external_exports.strictObject({
19441
+ id: desktopExtensionIdSchema,
19442
+ version: external_exports.string().trim().min(1).max(128),
19443
+ name: desktopExtensionLocalizedTextSchema.extend({ en: extensionName, "zh-CN": extensionName }),
19444
+ description: localizedText(external_exports.string().trim().min(1).max(4096)),
19445
+ details: localizedText(external_exports.string().trim().min(1).max(16384)).optional(),
19446
+ author: external_exports.string().trim().min(1).max(128),
19447
+ repository: desktopExtensionHttpUrlSchema,
19448
+ stars: external_exports.number().int().min(0).optional(),
19449
+ downloads: external_exports.number().int().min(0).optional(),
19450
+ categories: categoriesSchema.optional(),
19451
+ trustTier: desktopExtensionTrustTierSchema.default("community"),
19452
+ icon: desktopExtensionHttpUrlSchema.optional(),
19453
+ screenshots: external_exports.array(desktopExtensionHttpUrlSchema).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).optional(),
19454
+ downloadUrl: desktopExtensionZipUrlSchema,
19455
+ sha256: desktopExtensionHashSchema,
19456
+ slots: slotsSchema.optional(),
19457
+ publishedAt: external_exports.string().optional(),
19458
+ updatedAt: external_exports.string().optional(),
19459
+ minCodexHostVersion: external_exports.string().optional()
19460
+ });
19461
+ var desktopExtensionCatalogSchema = external_exports.strictObject({
19462
+ schemaVersion: external_exports.literal(1),
19463
+ generatedAt: external_exports.string(),
19464
+ extensions: external_exports.array(desktopExtensionCatalogEntrySchema).refine((entries) => new Set(entries.map(({ id: id2 }) => id2)).size === entries.length, "Duplicate extension IDs")
19465
+ });
19466
+ var desktopExtensionBackendMethodSchema = external_exports.string().trim().min(1).max(128);
19467
+
19468
+ // ../../shared-contracts/dist/host-extensions.js
19469
+ var reservedName = /^(?:con|prn|aux|nul|com[1-9¹²³]|lpt[1-9¹²³]) *(?:\.|$)/iu;
19470
+ var HOST_EXTENSION_PAGE_API_VERSION = 1;
19471
+ var hostExtensionIdSchema = desktopExtensionIdSchema.refine((id2) => !reservedName.test(id2), "Reserved extension ID");
19472
+ var hostExtensionTargetSchema = external_exports.enum(["desktop", "web"]);
19473
+ var hostExtensionDigestSchema = desktopExtensionHashSchema;
19474
+ var hostExtensionActivationIdSchema = external_exports.uuid();
19475
+ 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((path7) => path7.split("/").length <= 32, "Extension resources may be at most 32 segments deep");
19476
+ var legacy = desktopExtensionManifestSchema.shape;
19477
+ var localized = (max, min = 0) => external_exports.strictObject({
19478
+ en: external_exports.string().trim().min(min).max(max),
19479
+ "zh-CN": external_exports.string().trim().min(min).max(max)
19480
+ });
19481
+ var resourceWithSuffix = (suffix) => hostExtensionResourcePathSchema.refine((path7) => path7.endsWith(suffix), `Expected a ${suffix} file`);
19482
+ var moduleEntry = resourceWithSuffix(".mjs");
19483
+ var style = resourceWithSuffix(".css").optional();
19484
+ var hostExtensionCanonicalPath = (path7) => path7.normalize("NFC").toLowerCase();
19485
+ var hostExtensionManifestV2Schema = external_exports.strictObject({
19486
+ manifestVersion: external_exports.literal(2),
19487
+ id: hostExtensionIdSchema,
19488
+ name: localized(128, 1),
19489
+ version: external_exports.string().trim().min(1).max(128),
19490
+ description: localized(4096),
19491
+ details: localized(16384).optional(),
19492
+ author: legacy.author,
19493
+ repository: legacy.repository,
19494
+ icon: legacy.icon.refine((path7) => path7 === void 0 || hostExtensionResourcePathSchema.safeParse(path7).success),
19495
+ screenshots: legacy.screenshots.refine((paths) => paths === void 0 || paths.every((path7) => hostExtensionResourcePathSchema.safeParse(path7).success)),
19496
+ categories: legacy.categories,
19497
+ settingsSchema: legacy.settingsSchema,
19498
+ slots: legacy.slots.removeDefault().optional(),
19499
+ page: external_exports.strictObject({
19500
+ apiVersion: external_exports.literal(HOST_EXTENSION_PAGE_API_VERSION),
19501
+ entry: moduleEntry,
19502
+ style,
19503
+ title: localized(128, 1).optional()
19504
+ }).optional(),
19505
+ widget: external_exports.strictObject({
19506
+ apiVersion: external_exports.literal(HOST_EXTENSION_PAGE_API_VERSION),
19507
+ entry: moduleEntry,
19508
+ style
19509
+ }).optional(),
19510
+ desktop: external_exports.strictObject({ apiVersion: external_exports.literal(1), script: resourceWithSuffix(".js"), style }).optional(),
19511
+ 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(),
19512
+ backend: external_exports.strictObject({ apiVersion: external_exports.literal(1), entry: moduleEntry }).optional()
19513
+ }).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" });
19514
+ function targetsForCapabilities({ hasPage, hasWidget, hasDesktop, hasWeb, hasBackend }) {
19515
+ if (hasPage || hasWidget || hasBackend && !hasDesktop && !hasWeb)
19516
+ return ["desktop", "web"];
19517
+ const targets = [];
19518
+ if (hasDesktop)
19519
+ targets.push("desktop");
19520
+ if (hasWeb)
19521
+ targets.push("web");
19522
+ return targets;
19523
+ }
19524
+ var hostExtensionBackendMethodSchema = desktopExtensionBackendMethodSchema;
19525
+
19526
+ // ../../shared-contracts/dist/host-extension-management.js
19527
+ var HOST_EXTENSION_ZIP_MAX_BYTES = DESKTOP_EXTENSION_ZIP_MAX_BYTES;
19528
+ var hostExtensionRevisionSchema = external_exports.int().nonnegative();
19529
+ var hostExtensionConfigurationSchema = external_exports.strictObject({
19530
+ revision: hostExtensionRevisionSchema,
19531
+ enabled: external_exports.array(hostExtensionIdSchema).max(DESKTOP_EXTENSION_LIMIT).refine((ids) => new Set(ids).size === ids.length, "Duplicate extension IDs")
19532
+ });
19533
+ var { downloadUrl, ...catalogMetadata } = desktopExtensionCatalogEntrySchema.shape;
19534
+ var hostExtensionCatalogEntrySchema = external_exports.object({
19535
+ ...catalogMetadata,
19536
+ id: hostExtensionIdSchema,
19537
+ format: external_exports.literal("codexhost"),
19538
+ targets: external_exports.array(hostExtensionTargetSchema).min(1).max(2).refine((targets) => new Set(targets).size === targets.length, "Duplicate targets"),
19539
+ apis: external_exports.strictObject({
19540
+ page: external_exports.int().positive().optional(),
19541
+ widget: external_exports.int().positive().optional(),
19542
+ desktop: external_exports.int().positive().optional(),
19543
+ web: external_exports.int().positive().optional(),
19544
+ backend: external_exports.int().positive().optional()
19545
+ }),
19546
+ downloadUrl: downloadUrl.refine((url2) => url2.startsWith("https://"), "Expected HTTPS")
19547
+ }).refine(({ targets, apis }) => {
19548
+ const derived = targetsForCapabilities({
19549
+ hasPage: Boolean(apis.page),
19550
+ hasWidget: Boolean(apis.widget),
19551
+ hasDesktop: Boolean(apis.desktop),
19552
+ hasWeb: Boolean(apis.web),
19553
+ hasBackend: Boolean(apis.backend)
19554
+ });
19555
+ return targets.length === derived.length && derived.every((target2) => targets.includes(target2));
19556
+ }, "Catalog targets must match the declared APIs");
19557
+ var hostExtensionCatalogSchema = external_exports.object({
19558
+ schemaVersion: external_exports.literal(2),
19559
+ generatedAt: external_exports.string().min(1),
19560
+ extensions: external_exports.array(hostExtensionCatalogEntrySchema).max(1e4).refine((entries) => new Set(entries.map(({ id: id2 }) => id2)).size === entries.length, "Duplicate extension IDs")
19561
+ });
19562
+ var hostExtensionsCatalogResultSchema = hostExtensionCatalogSchema.extend({
19563
+ catalogUrl: desktopExtensionHttpUrlSchema,
19564
+ fetchedAt: external_exports.iso.datetime(),
19565
+ cached: external_exports.boolean()
19566
+ });
19567
+ var id = { id: hostExtensionIdSchema };
19568
+ var active = {
19569
+ ...id,
19570
+ activationId: hostExtensionActivationIdSchema,
19571
+ digest: hostExtensionDigestSchema
19572
+ };
19573
+ var optionalActivation = { ...id, activationId: active.activationId.optional() };
19574
+ var filePath = external_exports.string().min(1).max(4096).refine((path7) => /^(?:\/|[a-z]:[/\\])/iu.test(path7) && !path7.includes("\0") && !path7.split(/[/\\]/u).some((part) => part === "." || part === ".."), "Expected an absolute local path without dot segments");
19575
+ 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");
19576
+ function base643(maxBytes) {
19577
+ return external_exports.string().max(4 * Math.ceil(maxBytes / 3)).refine((value) => {
19578
+ const padding = value.endsWith("==") ? 2 : value.endsWith("=") ? 1 : 0;
19579
+ return value.length % 4 === 0 && value.length * 3 / 4 - padding <= maxBytes && /^[A-Za-z0-9+/]*={0,2}$/u.test(value);
19580
+ }, "Expected bounded standard padded base64");
19581
+ }
19582
+ var hostExtensionGitHubSourceSchema = external_exports.strictObject({
19583
+ type: external_exports.literal("github"),
19584
+ repository: external_exports.string().max(150).regex(/^[a-z0-9-]+\/[a-z0-9_-][a-z0-9_.-]*$/iu),
19585
+ ref: gitRef.optional(),
19586
+ tag: gitRef.optional(),
19587
+ asset: external_exports.string().max(255).regex(/^[a-z0-9_.-]+\.zip$/iu).optional(),
19588
+ subpath: hostExtensionResourcePathSchema.optional()
19589
+ }).refine(({ ref, tag, asset }) => !ref || !tag && !asset, "Use either a zipball ref or a release tag/asset");
19590
+ var hostExtensionInstallSourceSchema = external_exports.union([
19591
+ external_exports.strictObject({ type: external_exports.literal("catalog"), ...id }),
19592
+ hostExtensionGitHubSourceSchema,
19593
+ external_exports.strictObject({ type: external_exports.literal("zip"), base64: base643(HOST_EXTENSION_ZIP_MAX_BYTES).min(4) }),
19594
+ external_exports.strictObject({ type: external_exports.literal("zip"), localZipPath: filePath }),
19595
+ external_exports.strictObject({ type: external_exports.literal("localDir"), localDir: filePath })
19596
+ ]);
19597
+ var hostExtensionProvenanceSchema = external_exports.discriminatedUnion("type", [
19598
+ external_exports.strictObject({ type: external_exports.literal("catalog"), ...id }),
19599
+ hostExtensionGitHubSourceSchema,
19600
+ external_exports.strictObject({ type: external_exports.literal("zip") }),
19601
+ external_exports.strictObject({ type: external_exports.literal("localDir") })
19602
+ ]);
19603
+ var hostExtensionInstallationSchema = external_exports.strictObject({
19604
+ ...active,
19605
+ manifest: hostExtensionManifestV2Schema,
19606
+ installedAt: external_exports.iso.datetime(),
19607
+ source: hostExtensionProvenanceSchema.optional()
19608
+ });
19609
+ 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);
19610
+ var desktopConflict = { desktopConflictWith: hostExtensionIdSchema.optional() };
19611
+ var backendState = external_exports.enum(["none", "inactive", "starting", "running", "failed"]);
19612
+ var hostExtensionListItemSchema = external_exports.discriminatedUnion("state", [
19613
+ hostExtensionInstallationSchema.extend({
19614
+ state: external_exports.literal("valid"),
19615
+ enabled: external_exports.boolean(),
19616
+ ...desktopConflict,
19617
+ iconDataUrl: rasterDataUrlSchema(DESKTOP_EXTENSION_ICON_MAX_BYTES).optional(),
19618
+ screenshotDataUrls: external_exports.array(rasterDataUrlSchema(DESKTOP_EXTENSION_SCREENSHOT_MAX_BYTES)).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).optional(),
19619
+ backendState: backendState.optional(),
19620
+ backendError: external_exports.string().optional()
19621
+ }),
19622
+ external_exports.strictObject({
19623
+ state: external_exports.enum(["invalid", "incompatible"]),
19624
+ id: external_exports.string().min(1),
19625
+ enabled: external_exports.boolean(),
19626
+ error: external_exports.string()
19627
+ })
19628
+ ]);
19629
+ var hostExtensionsListResultSchema = external_exports.strictObject({
19630
+ revision: hostExtensionRevisionSchema,
19631
+ configuration: hostExtensionConfigurationSchema,
19632
+ diagnostics: external_exports.array(external_exports.string()),
19633
+ extensions: external_exports.array(hostExtensionListItemSchema)
19634
+ });
19635
+ var hostExtensionRuntimeEntrySchema = hostExtensionInstallationSchema.extend({
19636
+ ...desktopConflict,
19637
+ settingsRevision: hostExtensionRevisionSchema
19638
+ });
19639
+ var hostExtensionsSnapshotResultSchema = external_exports.strictObject({
19640
+ /** The Host publishes this revision in extensions-changed, independent of enabled.json's revision. */
19641
+ revision: hostExtensionRevisionSchema,
19642
+ // Enabled, valid activations only. A Desktop conflict does not hide other capabilities.
19643
+ extensions: external_exports.array(hostExtensionRuntimeEntrySchema).max(DESKTOP_EXTENSION_LIMIT)
19644
+ });
19645
+ var HOST_EXTENSIONS_RPC = {
19646
+ list: "codexhost/extensions/list",
19647
+ snapshot: "codexhost/extensions/snapshot",
19648
+ catalog: "codexhost/extensions/catalog",
19649
+ install: "codexhost/extensions/install",
19650
+ update: "codexhost/extensions/update",
19651
+ enable: "codexhost/extensions/enable",
19652
+ disable: "codexhost/extensions/disable",
19653
+ uninstall: "codexhost/extensions/uninstall",
19654
+ recover: "codexhost/extensions/recover",
19655
+ asset: "codexhost/extensions/asset",
19656
+ settingsGet: "codexhost/extensions/settings/get",
19657
+ settingsSet: "codexhost/extensions/settings/set",
19658
+ backendInvoke: "codexhost/extensions/backend/invoke"
19659
+ };
19660
+ var HOST_EXTENSION_MANAGEMENT_METHODS = Object.freeze(Object.values(HOST_EXTENSIONS_RPC));
19661
+ var methods = new Set(HOST_EXTENSION_MANAGEMENT_METHODS);
19662
+ var noParams = external_exports.strictObject({});
19663
+ var expectedRevision = { expectedRevision: hostExtensionRevisionSchema };
19664
+ var selection = external_exports.strictObject({ ...id, ...expectedRevision });
19665
+ var installationResult = hostExtensionInstallationSchema.extend({ replaced: external_exports.boolean() });
19666
+ var mutationResult = external_exports.discriminatedUnion("state", [
19667
+ external_exports.strictObject({ state: external_exports.literal("saved"), configuration: hostExtensionConfigurationSchema }),
19668
+ external_exports.strictObject({ state: external_exports.literal("revision-conflict"), revision: hostExtensionRevisionSchema })
19669
+ ]);
19670
+ var hostExtensionsAssetParamsSchema = external_exports.strictObject({
19671
+ ...optionalActivation,
19672
+ digest: active.digest.optional(),
19673
+ path: hostExtensionResourcePathSchema
19674
+ });
19675
+ var hostExtensionsAssetResultSchema = external_exports.strictObject({
19676
+ mimeType: external_exports.string().min(1),
19677
+ base64: base643(DESKTOP_EXTENSION_ASSET_MAX_BYTES),
19678
+ digest: active.digest
19679
+ });
19680
+ var hostExtensionSettingsSchema = external_exports.strictObject({
19681
+ settingsRevision: hostExtensionRevisionSchema,
19682
+ values: jsonObjectSchema
19683
+ });
19684
+ var hostExtensionsRpcSchemas = {
19685
+ [HOST_EXTENSIONS_RPC.list]: { params: noParams, result: hostExtensionsListResultSchema },
19686
+ [HOST_EXTENSIONS_RPC.snapshot]: { params: noParams, result: hostExtensionsSnapshotResultSchema },
19687
+ [HOST_EXTENSIONS_RPC.catalog]: {
19688
+ params: external_exports.strictObject({ forceRefresh: external_exports.boolean().optional() }),
19689
+ result: hostExtensionsCatalogResultSchema
19690
+ },
19691
+ [HOST_EXTENSIONS_RPC.install]: {
19692
+ params: external_exports.strictObject({ source: hostExtensionInstallSourceSchema }),
19693
+ result: installationResult
19694
+ },
19695
+ [HOST_EXTENSIONS_RPC.update]: {
19696
+ params: external_exports.strictObject({
19697
+ ...id,
19698
+ expectedDigest: active.digest,
19699
+ expectedActivationId: active.activationId.optional(),
19700
+ source: hostExtensionInstallSourceSchema.optional()
19701
+ }),
19702
+ result: installationResult
19703
+ },
19704
+ [HOST_EXTENSIONS_RPC.enable]: { params: selection, result: mutationResult },
19705
+ [HOST_EXTENSIONS_RPC.disable]: { params: selection, result: mutationResult },
19706
+ [HOST_EXTENSIONS_RPC.uninstall]: {
19707
+ params: external_exports.strictObject({
19708
+ ...id,
19709
+ removeData: external_exports.boolean().optional(),
19710
+ expectedDigest: active.digest.optional()
19711
+ }),
19712
+ result: external_exports.strictObject({ ...id, removed: external_exports.boolean() })
19713
+ },
19714
+ [HOST_EXTENSIONS_RPC.recover]: {
19715
+ params: external_exports.strictObject({ expectedRevision: expectedRevision.expectedRevision.optional() }),
19716
+ result: mutationResult
19717
+ },
19718
+ [HOST_EXTENSIONS_RPC.asset]: {
19719
+ params: hostExtensionsAssetParamsSchema,
19720
+ result: hostExtensionsAssetResultSchema
19721
+ },
19722
+ [HOST_EXTENSIONS_RPC.settingsGet]: {
19723
+ params: external_exports.strictObject(optionalActivation),
19724
+ result: hostExtensionSettingsSchema
19725
+ },
19726
+ [HOST_EXTENSIONS_RPC.settingsSet]: {
19727
+ params: external_exports.strictObject({
19728
+ ...optionalActivation,
19729
+ expectedSettingsRevision: hostExtensionRevisionSchema,
19730
+ values: jsonObjectSchema
19731
+ }),
19732
+ result: hostExtensionSettingsSchema
19733
+ },
19734
+ [HOST_EXTENSIONS_RPC.backendInvoke]: {
19735
+ params: external_exports.strictObject({
19736
+ ...optionalActivation,
19737
+ method: hostExtensionBackendMethodSchema,
19738
+ params: jsonValueSchema.optional()
19739
+ }),
19740
+ result: external_exports.strictObject({ result: jsonValueSchema })
19741
+ }
19742
+ };
19743
+
19587
19744
  // ../../shared-contracts/dist/thread-archive-confirm.js
19588
19745
  var THREAD_ARCHIVE_CONFIRM_METHOD = "codexhost/thread/archive/confirm";
19589
19746
  var threadArchiveConfirmParamsSchema = external_exports.object({ threadId: hostThreadIdSchema }).strict();
@@ -19645,7 +19802,7 @@ var CLIENT_CHANNEL_METHODS = [
19645
19802
  "codexhost/harness/session-import/list",
19646
19803
  "codexhost/harness/session-import/import",
19647
19804
  // Host settings shared across Desktop and Web.
19648
- ...DESKTOP_EXTENSION_MANAGEMENT_METHODS,
19805
+ ...HOST_EXTENSION_MANAGEMENT_METHODS,
19649
19806
  "codexhost/harness/installation",
19650
19807
  "codexhost/harness/installation/start",
19651
19808
  "codexhost/harness/installation/status",
@@ -19706,6 +19863,11 @@ var clientChannelEventSchema = external_exports.discriminatedUnion("type", [
19706
19863
  cursor: clientChannelCursorSchema,
19707
19864
  revision: external_exports.number().int().nonnegative()
19708
19865
  }),
19866
+ external_exports.object({
19867
+ type: external_exports.literal("extensions-changed"),
19868
+ cursor: clientChannelCursorSchema,
19869
+ revision: hostExtensionRevisionSchema
19870
+ }),
19709
19871
  external_exports.object({
19710
19872
  type: external_exports.literal("hello"),
19711
19873
  version: external_exports.literal(1),
@@ -20142,7 +20304,7 @@ var DEFAULT_IDLE_RELEASE_SETTINGS = Object.freeze({
20142
20304
 
20143
20305
  // ../../shared-contracts/dist/harness-preferences.js
20144
20306
  var harnessPreferenceScopeSchema = external_exports.string().regex(/^external$/u);
20145
- var preferenceHarnessKey = harnessIdSchema.transform((id) => String(id));
20307
+ var preferenceHarnessKey = harnessIdSchema.transform((id2) => String(id2));
20146
20308
  var harnessDefaultConfigurationSchema = external_exports.strictObject({
20147
20309
  model: harnessModelRefSchema.optional(),
20148
20310
  thinkingOptionId: harnessThinkingOptionIdSchema.optional(),
@@ -20152,11 +20314,19 @@ var newThreadDefaultsSchema = external_exports.strictObject({
20152
20314
  lastHarness: harnessIdSchema.optional(),
20153
20315
  byHarness: external_exports.record(preferenceHarnessKey, harnessDefaultConfigurationSchema)
20154
20316
  });
20317
+ var harnessDelegationDefaultSchema = external_exports.strictObject({
20318
+ model: harnessModelRefSchema.optional(),
20319
+ thinkingOptionId: harnessThinkingOptionIdSchema.optional()
20320
+ }).refine((value) => Boolean(value.model || value.thinkingOptionId), "A delegation default must contain a Model or Thinking option");
20321
+ var delegationDefaultsSchema = external_exports.strictObject({
20322
+ byHarness: external_exports.record(preferenceHarnessKey, harnessDelegationDefaultSchema)
20323
+ });
20155
20324
  var modelId = external_exports.string().min(1).max(1024);
20156
20325
  var harnessPreferenceValuesSchema = external_exports.strictObject({
20157
20326
  idleRelease: idleReleaseSettingsSchema.optional(),
20158
20327
  favorites: external_exports.record(preferenceHarnessKey, external_exports.array(modelId).max(2048)).default({}),
20159
- newThread: newThreadDefaultsSchema.optional()
20328
+ newThread: newThreadDefaultsSchema.optional(),
20329
+ delegation: delegationDefaultsSchema.optional()
20160
20330
  });
20161
20331
  var harnessPreferenceSnapshotSchema = external_exports.strictObject({
20162
20332
  scope: harnessPreferenceScopeSchema,
@@ -20184,6 +20354,11 @@ var harnessPreferenceOperationSchema = external_exports.discriminatedUnion("kind
20184
20354
  lastHarness: harnessIdSchema.optional(),
20185
20355
  harnessId: harnessIdSchema.optional(),
20186
20356
  configuration: harnessDefaultConfigurationSchema.optional()
20357
+ }),
20358
+ external_exports.strictObject({
20359
+ kind: external_exports.literal("delegation"),
20360
+ harnessId: harnessIdSchema,
20361
+ configuration: harnessDelegationDefaultSchema.nullable()
20187
20362
  })
20188
20363
  ]);
20189
20364
  var harnessPreferencePatchSchema = external_exports.strictObject({
@@ -21007,9 +21182,12 @@ var remoteSessionOperationSchema = external_exports.discriminatedUnion("kind", [
21007
21182
  ...thread,
21008
21183
  epoch: identity,
21009
21184
  modelId: identity.optional(),
21185
+ serviceTier: harnessModelServiceTierSchema.optional(),
21010
21186
  thinkingOptionId: identity.optional(),
21011
21187
  permissionModeId: identity.optional()
21012
- }).refine((value) => [value.modelId, value.thinkingOptionId, value.permissionModeId].filter((v) => v !== void 0).length === 1, "Select exactly one remote setting"),
21188
+ }).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, {
21189
+ message: "A service tier requires a Model ID"
21190
+ }),
21013
21191
  external_exports.strictObject({
21014
21192
  kind: external_exports.literal("prompt"),
21015
21193
  ...thread,
@@ -21059,7 +21237,7 @@ var remoteConnectionsRequestSchema = external_exports.discriminatedUnion("action
21059
21237
  external_exports.strictObject({ action: external_exports.literal("catalog") }),
21060
21238
  external_exports.strictObject({
21061
21239
  action: external_exports.literal("read-thread"),
21062
- hostId: hostId.refine((id) => id !== "local"),
21240
+ hostId: hostId.refine((id2) => id2 !== "local"),
21063
21241
  input: delegationReadParamsSchema
21064
21242
  }),
21065
21243
  external_exports.strictObject({
@@ -21073,7 +21251,7 @@ var remoteConnectionsRequestSchema = external_exports.discriminatedUnion("action
21073
21251
  external_exports.strictObject({ action: external_exports.literal("runtime"), hostId }),
21074
21252
  external_exports.strictObject({
21075
21253
  action: external_exports.literal("update"),
21076
- hostId: hostId.refine((id) => id !== "local"),
21254
+ hostId: hostId.refine((id2) => id2 !== "local"),
21077
21255
  version: remoteUpdateParamsSchema.shape.version
21078
21256
  })
21079
21257
  ]);
@@ -27733,13 +27911,13 @@ var CopilotSession = class {
27733
27911
  );
27734
27912
  try {
27735
27913
  const sendOutcome = this.send(options2).then(
27736
- (id) => {
27737
- if (!id) {
27914
+ (id2) => {
27915
+ if (!id2) {
27738
27916
  throw new Error(
27739
27917
  "The runtime did not return a message ID for the structured send."
27740
27918
  );
27741
27919
  }
27742
- messageId = id;
27920
+ messageId = id2;
27743
27921
  for (const event of buffered) observe(event);
27744
27922
  buffered.length = 0;
27745
27923
  return outcomePromise;
@@ -32614,10 +32792,10 @@ function executableExtensions(command, platform, environment) {
32614
32792
  return [""];
32615
32793
  return (environmentValue(environment, "PATHEXT") ?? ".COM;.EXE;.BAT;.CMD").split(";").map((extension) => extension.trim()).filter(Boolean);
32616
32794
  }
32617
- function isExecutableFile(filePath, platform) {
32795
+ function isExecutableFile(filePath2, platform) {
32618
32796
  try {
32619
- fs3.accessSync(filePath, platform === "win32" ? fs3.constants.F_OK : fs3.constants.X_OK);
32620
- return fs3.statSync(filePath).isFile();
32797
+ fs3.accessSync(filePath2, platform === "win32" ? fs3.constants.F_OK : fs3.constants.X_OK);
32798
+ return fs3.statSync(filePath2).isFile();
32621
32799
  } catch {
32622
32800
  return false;
32623
32801
  }
@@ -33109,7 +33287,7 @@ function invalidRequest(message) {
33109
33287
  return { code: "invalidRequest", message, retryable: false };
33110
33288
  }
33111
33289
  function validateHostApprovalResponse(interaction, response) {
33112
- return interaction.actions.some(({ id }) => id === response.actionId) ? null : invalidRequest("Approval Response contains an undeclared action ID");
33290
+ return interaction.actions.some(({ id: id2 }) => id2 === response.actionId) ? null : invalidRequest("Approval Response contains an undeclared action ID");
33113
33291
  }
33114
33292
 
33115
33293
  // ../../harness-adapter/dist/question.js
@@ -33117,7 +33295,7 @@ function invalidRequest2(message) {
33117
33295
  return { code: "invalidRequest", message, retryable: false };
33118
33296
  }
33119
33297
  function validateHostQuestionResponse(interaction, response) {
33120
- const questionIds = new Set(interaction.questions.map(({ id }) => id));
33298
+ const questionIds = new Set(interaction.questions.map(({ id: id2 }) => id2));
33121
33299
  if (response.cancelled) {
33122
33300
  return Object.keys(response.answers).length === 0 ? null : invalidRequest2("Cancelled Question Response must not contain answers");
33123
33301
  }
@@ -33165,6 +33343,18 @@ function validateHostInteractionResponse(interaction, response) {
33165
33343
  return response.type === "approval" ? validateHostApprovalResponse(interaction, response) : invalidRequest3("Interaction Response type does not match the pending Interaction");
33166
33344
  }
33167
33345
 
33346
+ // ../../harness-adapter/dist/legacy-model-ref.js
33347
+ import { Buffer as Buffer2 } from "node:buffer";
33348
+ function normalizeLegacyBase64ModelRef(ref, catalog, prefix) {
33349
+ if (ref.serviceTier || !ref.id.startsWith(prefix))
33350
+ return void 0;
33351
+ const encoded = ref.id.slice(prefix.length);
33352
+ const id2 = Buffer2.from(encoded, "base64url").toString("utf8");
33353
+ if (Buffer2.from(id2).toString("base64url") !== encoded)
33354
+ return void 0;
33355
+ return catalog.models.find(({ ref: ref2 }) => ref2.id === id2 && !ref2.serviceTier)?.ref;
33356
+ }
33357
+
33168
33358
  // ../../harness-adapter/dist/output-channel.js
33169
33359
  var HarnessOutputChannel = class {
33170
33360
  outputs;
@@ -33249,7 +33439,8 @@ var tokenFields = [
33249
33439
  var safeIntegerFields = [
33250
33440
  "planFiveHourResetsAtUnix",
33251
33441
  "planSevenDayResetsAtUnix",
33252
- "timeToFirstOutputMs"
33442
+ "timeToFirstOutputMs",
33443
+ "latestRequestTimeToFirstOutputMs"
33253
33444
  ];
33254
33445
  var percentFields = [
33255
33446
  "cacheHitRatePercent",
@@ -33523,15 +33714,11 @@ async function bounded(promise2, milliseconds = 3e4) {
33523
33714
  }
33524
33715
 
33525
33716
  // dist/configuration.js
33526
- function modelRef(id) {
33527
- return harnessModelRefSchema.parse({ id: Buffer.from(id).toString("base64url") });
33717
+ function modelRef(id2) {
33718
+ return harnessModelRefSchema.parse({ id: id2 });
33528
33719
  }
33529
- function modelId2(ref) {
33530
- const parsed = harnessModelRefSchema.parse(ref);
33531
- const id = Buffer.from(parsed.id, "base64url").toString("utf8");
33532
- if (!id || modelRef(id).id !== parsed.id)
33533
- throw new CopilotOperationError("invalidRequest", "Invalid Copilot Model reference.");
33534
- return id;
33720
+ function normalizeStoredCopilotModelRef(ref, catalog) {
33721
+ return normalizeLegacyBase64ModelRef(ref, catalog, "");
33535
33722
  }
33536
33723
  var modelSchema = external_exports.object({
33537
33724
  id: external_exports.string().min(1),
@@ -33557,8 +33744,8 @@ async function readModels(client, session, auth, refresh = true) {
33557
33744
  models.unshift({ id: "auto", name: "Auto" });
33558
33745
  return models.filter((model2) => model2.policy?.state !== "disabled");
33559
33746
  }
33560
- function requireModel(models, id) {
33561
- const model2 = models.find((entry) => entry.id === id);
33747
+ function requireModel(models, id2) {
33748
+ const model2 = models.find((entry) => entry.id === id2);
33562
33749
  if (!model2)
33563
33750
  throw new CopilotOperationError("invalidRequest", "Copilot does not offer this Model in the current native catalog.");
33564
33751
  return model2;
@@ -33579,7 +33766,7 @@ function modelCatalog(models) {
33579
33766
  label: model2.name,
33580
33767
  supportedThinkingOptionIds: model2.supportedReasoningEfforts ?? []
33581
33768
  })),
33582
- thinkingOptions: efforts.map((id) => ({ id, label: id })),
33769
+ thinkingOptions: efforts.map((id2) => ({ id: id2, label: id2 })),
33583
33770
  ...initial ? { defaultModel: modelRef(initial.id) } : {}
33584
33771
  });
33585
33772
  }
@@ -33595,9 +33782,9 @@ async function confirmedConfiguration(session, client) {
33595
33782
  ...entry ? { resolvedModelLabel: entry.name } : {},
33596
33783
  ...model2.reasoningEffort && entry?.supportedReasoningEfforts?.includes(model2.reasoningEffort) ? { effectiveThinkingOptionId: harnessThinkingOptionIdSchema.parse(model2.reasoningEffort) } : {},
33597
33784
  ...entry ? {
33598
- availableThinkingOptions: (entry.supportedReasoningEfforts ?? []).map((id) => ({
33599
- id: harnessThinkingOptionIdSchema.parse(id),
33600
- label: id
33785
+ availableThinkingOptions: (entry.supportedReasoningEfforts ?? []).map((id2) => ({
33786
+ id: harnessThinkingOptionIdSchema.parse(id2),
33787
+ label: id2
33601
33788
  }))
33602
33789
  } : {},
33603
33790
  effectivePermissionModeId: harnessPermissionModeIdSchema.parse(permission.mode)
@@ -33678,9 +33865,9 @@ function elicitationForm(context) {
33678
33865
  const schema = context.requestedSchema;
33679
33866
  if (context.mode === "url" || !schema || schema.type !== "object" || !Object.keys(schema.properties).length)
33680
33867
  throw new CopilotOperationError("unsupported", "Copilot elicitation requires a supported primitive form; browser URL flows are unavailable.");
33681
- if (schema.required?.some((id) => !Object.hasOwn(schema.properties, id)))
33868
+ if (schema.required?.some((id2) => !Object.hasOwn(schema.properties, id2)))
33682
33869
  throw new Error("Copilot form refers to an unknown required field");
33683
- const questions = Object.entries(schema.properties).map(([id, field2]) => {
33870
+ const questions = Object.entries(schema.properties).map(([id2, field2]) => {
33684
33871
  const allowed = /* @__PURE__ */ new Set([
33685
33872
  "type",
33686
33873
  "title",
@@ -33694,12 +33881,12 @@ function elicitationForm(context) {
33694
33881
  throw new CopilotOperationError("unsupported", "Copilot form contains an unsupported text format.");
33695
33882
  if (!["string", "number", "integer", "boolean", "array"].includes(field2.type))
33696
33883
  throw new CopilotOperationError("unsupported", "Copilot form field cannot be represented");
33697
- const prompt = [field2.title ?? id, field2.description].filter(Boolean).join("\n");
33884
+ const prompt = [field2.title ?? id2, field2.description].filter(Boolean).join("\n");
33698
33885
  const choices = options(field2);
33699
- const optional2 = !schema.required?.includes(id);
33886
+ const optional2 = !schema.required?.includes(id2);
33700
33887
  if (choices)
33701
33888
  return {
33702
- id,
33889
+ id: id2,
33703
33890
  type: "choice",
33704
33891
  prompt,
33705
33892
  options: choices,
@@ -33708,7 +33895,7 @@ function elicitationForm(context) {
33708
33895
  optional: optional2
33709
33896
  };
33710
33897
  return {
33711
- id,
33898
+ id: id2,
33712
33899
  type: "text",
33713
33900
  prompt,
33714
33901
  multiline: field2.type === "string",
@@ -33721,26 +33908,26 @@ function elicitationForm(context) {
33721
33908
  if (response.cancelled)
33722
33909
  return { action: "cancel" };
33723
33910
  const content = /* @__PURE__ */ Object.create(null);
33724
- for (const [id, field2] of Object.entries(schema.properties)) {
33725
- const values = Object.hasOwn(response.answers, id) ? response.answers[id] ?? [] : [];
33911
+ for (const [id2, field2] of Object.entries(schema.properties)) {
33912
+ const values = Object.hasOwn(response.answers, id2) ? response.answers[id2] ?? [] : [];
33726
33913
  if (!values.length)
33727
33914
  continue;
33728
33915
  const value = values[0] ?? "";
33729
33916
  if (field2.type === "array") {
33730
33917
  if (field2.minItems !== void 0 && values.length < field2.minItems || field2.maxItems !== void 0 && values.length > field2.maxItems)
33731
33918
  throw new Error("The number of choices is outside the native form's limits.");
33732
- content[id] = values;
33919
+ content[id2] = values;
33733
33920
  continue;
33734
33921
  }
33735
33922
  if (field2.type === "boolean") {
33736
- content[id] = value === "true";
33923
+ content[id2] = value === "true";
33737
33924
  continue;
33738
33925
  }
33739
33926
  if (field2.type === "number" || field2.type === "integer") {
33740
33927
  const number4 = Number(value);
33741
33928
  if (!value.trim() || !Number.isFinite(number4) || field2.type === "integer" && !Number.isSafeInteger(number4) || field2.minimum !== void 0 && number4 < field2.minimum || field2.maximum !== void 0 && number4 > field2.maximum)
33742
33929
  throw new Error("The number is outside the native form's limits.");
33743
- content[id] = number4;
33930
+ content[id2] = number4;
33744
33931
  continue;
33745
33932
  }
33746
33933
  if (field2.type === "string") {
@@ -33751,7 +33938,7 @@ function elicitationForm(context) {
33751
33938
  if (!valid)
33752
33939
  throw new Error("The text does not match the native form's format.");
33753
33940
  }
33754
- content[id] = value;
33941
+ content[id2] = value;
33755
33942
  }
33756
33943
  }
33757
33944
  return { action: "accept", content };
@@ -33897,10 +34084,10 @@ var CopilotInteractions = class {
33897
34084
  });
33898
34085
  }
33899
34086
  cancel(turnId) {
33900
- for (const [id, pending] of this.pending) {
34087
+ for (const [id2, pending] of this.pending) {
33901
34088
  if (turnId !== void 0 && pending.interaction.turnId !== turnId)
33902
34089
  continue;
33903
- this.pending.delete(id);
34090
+ this.pending.delete(id2);
33904
34091
  pending.reject(new Error("Copilot interaction cancelled"));
33905
34092
  this.emit({
33906
34093
  kind: "event",
@@ -33948,7 +34135,7 @@ function nativeFileChanges(data) {
33948
34135
  // dist/projection.js
33949
34136
  var OUTPUT_LIMIT = 256 * 1024;
33950
34137
  var clip = (text) => text.slice(0, OUTPUT_LIMIT);
33951
- var itemId = (id) => hostItemIdSchema.parse(id);
34138
+ var itemId = (id2) => hostItemIdSchema.parse(id2);
33952
34139
  var nativeFailure = {
33953
34140
  code: "nativeFailure",
33954
34141
  message: "Copilot reported a native failure.",
@@ -33980,8 +34167,8 @@ var CopilotItems = class {
33980
34167
  this.emit = emit;
33981
34168
  }
33982
34169
  get items() {
33983
- return this.order.flatMap((id) => {
33984
- const item = this.snapshots.get(id);
34170
+ return this.order.flatMap((id2) => {
34171
+ const item = this.snapshots.get(id2);
33985
34172
  return item ? [item] : [];
33986
34173
  });
33987
34174
  }
@@ -33992,24 +34179,24 @@ var CopilotItems = class {
33992
34179
  this.order.push(item.itemId);
33993
34180
  this.emit({ type: "item.started", turnId: this.turnId, item: structuredClone(item) });
33994
34181
  }
33995
- finish(id, outcome) {
33996
- const item = this.active.get(id);
34182
+ finish(id2, outcome) {
34183
+ const item = this.active.get(id2);
33997
34184
  if (!item)
33998
34185
  return;
33999
- this.active.delete(id);
34186
+ this.active.delete(id2);
34000
34187
  const snapshot = { item: structuredClone(item), outcome };
34001
- this.snapshots.set(id, snapshot);
34188
+ this.snapshots.set(id2, snapshot);
34002
34189
  this.emit({ type: "item.completed", turnId: this.turnId, snapshot });
34003
34190
  }
34004
34191
  finishAll(outcome) {
34005
- for (const id of this.active.keys())
34006
- this.finish(id, outcome);
34192
+ for (const id2 of this.active.keys())
34193
+ this.finish(id2, outcome);
34007
34194
  }
34008
- text(id, text, type, full, phase) {
34009
- if (this.snapshots.has(id))
34195
+ text(id2, text, type, full, phase) {
34196
+ if (this.snapshots.has(id2))
34010
34197
  return;
34011
- this.start({ type, itemId: itemId(id), text: "" });
34012
- const item = this.active.get(id);
34198
+ this.start({ type, itemId: itemId(id2), text: "" });
34199
+ const item = this.active.get(id2);
34013
34200
  if (!item || item.type !== "agentMessage" && item.type !== "reasoning")
34014
34201
  return;
34015
34202
  if (item.type === "agentMessage" && (phase === "commentary" || phase === "final_answer"))
@@ -34028,7 +34215,7 @@ var CopilotItems = class {
34028
34215
  update: { type: "text.append", text: append }
34029
34216
  });
34030
34217
  if (full)
34031
- this.finish(id, { status: "succeeded" });
34218
+ this.finish(id2, { status: "succeeded" });
34032
34219
  }
34033
34220
  accept(event) {
34034
34221
  if (event.agentId)
@@ -34140,14 +34327,14 @@ var CopilotItems = class {
34140
34327
  this.finish(data.toolCallId, succeeded ? { status: "succeeded" } : { status: "failed", error: nativeFailure });
34141
34328
  const changes = nativeFileChanges(data);
34142
34329
  if (changes.length) {
34143
- const id = itemId(`files-${data.toolCallId}`);
34330
+ const id2 = itemId(`files-${data.toolCallId}`);
34144
34331
  this.start({
34145
34332
  type: "fileChange",
34146
- itemId: id,
34333
+ itemId: id2,
34147
34334
  changes,
34148
34335
  sourceItemIds: [itemId(data.toolCallId)]
34149
34336
  });
34150
- this.finish(id, { status: "succeeded" });
34337
+ this.finish(id2, { status: "succeeded" });
34151
34338
  }
34152
34339
  break;
34153
34340
  }
@@ -34322,11 +34509,11 @@ var CopilotUsageTelemetry = class {
34322
34509
  call.receipt = receipt;
34323
34510
  return this.consume(call);
34324
34511
  }
34325
- entry(id) {
34326
- let call = this.calls.get(id);
34512
+ entry(id2) {
34513
+ let call = this.calls.get(id2);
34327
34514
  if (!call) {
34328
34515
  call = {};
34329
- this.calls.set(id, call);
34516
+ this.calls.set(id2, call);
34330
34517
  }
34331
34518
  if (this.calls.size > 2048) {
34332
34519
  const oldest = this.calls.entries().next().value;
@@ -34491,7 +34678,7 @@ var CopilotHarnessSession = class {
34491
34678
  try {
34492
34679
  await bounded(client.start());
34493
34680
  if (this.input.kind === "create" && this.input.model)
34494
- requireModel(await readModels(client), modelId2(this.input.model));
34681
+ requireModel(await readModels(client), this.input.model.id);
34495
34682
  if (this.input.kind === "resume") {
34496
34683
  if ((await bounded(client.rpc.sessions.checkInUse({ sessionIds: [this.nativeId] }))).inUse.includes(this.nativeId))
34497
34684
  throw new CopilotOperationError("sessionBusy", "Copilot session is owned by another native process.");
@@ -34504,32 +34691,32 @@ var CopilotHarnessSession = class {
34504
34691
  onPermissionRequest: (request) => {
34505
34692
  if (!this.active || this.closed || this.active.cancelling)
34506
34693
  return Promise.resolve({ kind: "user-not-available" });
34507
- const active = this.active;
34508
- return active.identity.promise.then(() => {
34509
- if (this.active !== active || this.closed || active.cancelling)
34694
+ const active2 = this.active;
34695
+ return active2.identity.promise.then(() => {
34696
+ if (this.active !== active2 || this.closed || active2.cancelling)
34510
34697
  return { kind: "user-not-available" };
34511
- return this.interactions.permission(active.id, request);
34698
+ return this.interactions.permission(active2.id, request);
34512
34699
  });
34513
34700
  },
34514
34701
  onUserInputRequest: (request) => {
34515
34702
  if (!this.active || this.closed || this.active.cancelling)
34516
34703
  return Promise.reject(new Error("Copilot has no active question context"));
34517
- const active = this.active;
34518
- return active.identity.promise.then(() => {
34519
- if (this.active !== active || this.closed || active.cancelling)
34704
+ const active2 = this.active;
34705
+ return active2.identity.promise.then(() => {
34706
+ if (this.active !== active2 || this.closed || active2.cancelling)
34520
34707
  throw new Error("Copilot question context ended");
34521
- return this.interactions.question(active.id, request);
34708
+ return this.interactions.question(active2.id, request);
34522
34709
  });
34523
34710
  },
34524
34711
  onElicitationRequest: async (request) => {
34525
- const active = this.active;
34526
- if (!active || this.closed || active.cancelling)
34712
+ const active2 = this.active;
34713
+ if (!active2 || this.closed || active2.cancelling)
34527
34714
  return { action: "cancel" };
34528
- await active.identity.promise;
34529
- if (this.active !== active || this.closed || active.cancelling)
34715
+ await active2.identity.promise;
34716
+ if (this.active !== active2 || this.closed || active2.cancelling)
34530
34717
  return { action: "cancel" };
34531
34718
  try {
34532
- return await this.interactions.elicitation(active.id, request);
34719
+ return await this.interactions.elicitation(active2.id, request);
34533
34720
  } catch (error51) {
34534
34721
  this.fault(error51, "interaction");
34535
34722
  return { action: "cancel" };
@@ -34544,7 +34731,7 @@ var CopilotHarnessSession = class {
34544
34731
  const session = this.input.kind === "resume" ? await bounded(client.resumeSession(this.nativeId, { ...handlers, allowTranscriptRecovery: false })) : await bounded(client.createSession({
34545
34732
  ...handlers,
34546
34733
  sessionId: this.nativeId,
34547
- ...this.input.model ? { model: modelId2(this.input.model) } : {}
34734
+ ...this.input.model ? { model: this.input.model.id } : {}
34548
34735
  }));
34549
34736
  this.session = session;
34550
34737
  if (this.input.kind === "resume" && session.transcriptRecovery)
@@ -34570,7 +34757,7 @@ var CopilotHarnessSession = class {
34570
34757
  }
34571
34758
  if (this.input.kind === "create" && (this.input.model || this.input.thinkingOptionId)) {
34572
34759
  const current = await bounded(session.rpc.model.getCurrent());
34573
- const requestedModel = this.input.model ? modelId2(this.input.model) : current.modelId;
34760
+ const requestedModel = this.input.model?.id ?? current.modelId;
34574
34761
  if (!requestedModel)
34575
34762
  throw new CopilotOperationError("invalidState", "Copilot has not confirmed a Model.");
34576
34763
  const models = await readModels(client, session);
@@ -34620,14 +34807,14 @@ var CopilotHarnessSession = class {
34620
34807
  throw error51;
34621
34808
  }
34622
34809
  }
34623
- startTurn(id) {
34624
- this.usageTelemetry.begin(id);
34810
+ startTurn(id2) {
34811
+ this.usageTelemetry.begin(id2);
34625
34812
  const identity3 = Promise.withResolvers();
34626
34813
  void identity3.promise.catch(() => {
34627
34814
  });
34628
34815
  return {
34629
- id,
34630
- items: new CopilotItems(id, (event) => this.emit(event)),
34816
+ id: id2,
34817
+ items: new CopilotItems(id2, (event) => this.emit(event)),
34631
34818
  cancelling: false,
34632
34819
  accepted: false,
34633
34820
  identity: identity3,
@@ -34687,13 +34874,13 @@ var CopilotHarnessSession = class {
34687
34874
  if (this.retiredMessages.has(event.data.messageId))
34688
34875
  return;
34689
34876
  if (!this.active) {
34690
- const id = hostTurnIdSchema.parse(randomUUID3());
34691
- this.active = this.startTurn(id);
34877
+ const id2 = hostTurnIdSchema.parse(randomUUID3());
34878
+ this.active = this.startTurn(id2);
34692
34879
  this.active.accepted = true;
34693
34880
  this.active.identity.resolve(void 0);
34694
34881
  this.emit({
34695
34882
  type: "turn.autonomous.started",
34696
- turnId: id,
34883
+ turnId: id2,
34697
34884
  input: visibleInput(event)
34698
34885
  });
34699
34886
  }
@@ -34758,15 +34945,15 @@ var CopilotHarnessSession = class {
34758
34945
  this.background.invalidate();
34759
34946
  void this.background.refresh(this.session).catch((error51) => this.fault(error51));
34760
34947
  }
34761
- const active = this.active;
34762
- if (!active.accepted) {
34948
+ const active2 = this.active;
34949
+ if (!active2.accepted) {
34763
34950
  this.active = void 0;
34764
- active.identity.reject(new Error("Copilot stopped before accepting the user message"));
34951
+ active2.identity.reject(new Error("Copilot stopped before accepting the user message"));
34765
34952
  return;
34766
34953
  }
34767
- if (active.cancelling && !event.data.aborted)
34954
+ if (active2.cancelling && !event.data.aborted)
34768
34955
  throw new Error("Copilot did not confirm cancellation");
34769
- const outcome = event.data.aborted ? { status: "cancelled" } : active.error ? { status: "failed", error: active.error } : active.messageId ? { status: "succeeded", checkpoint: checkpoint(this.nativeId, active.messageId) } : { status: "failed", error: nativeError(new Error("Missing logical identity")) };
34956
+ const outcome = event.data.aborted ? { status: "cancelled" } : active2.error ? { status: "failed", error: active2.error } : active2.messageId ? { status: "succeeded", checkpoint: checkpoint(this.nativeId, active2.messageId) } : { status: "failed", error: nativeError(new Error("Missing logical identity")) };
34770
34957
  this.finish(outcome);
34771
34958
  void this.refreshUsage().catch(() => {
34772
34959
  });
@@ -34777,23 +34964,23 @@ var CopilotHarnessSession = class {
34777
34964
  }
34778
34965
  }
34779
34966
  finish(outcome) {
34780
- const active = this.active;
34781
- if (!active)
34967
+ const active2 = this.active;
34968
+ if (!active2)
34782
34969
  return;
34783
- clearTimeout(active.timer);
34784
- this.interactions.cancel(active.id);
34785
- if (!active.accepted) {
34786
- active.identity.reject(new Error("Copilot did not accept the user message"));
34970
+ clearTimeout(active2.timer);
34971
+ this.interactions.cancel(active2.id);
34972
+ if (!active2.accepted) {
34973
+ active2.identity.reject(new Error("Copilot did not accept the user message"));
34787
34974
  this.active = void 0;
34788
34975
  return;
34789
34976
  }
34790
- active.items.finishAll(outcome);
34791
- for (const id of active.items.completedIds())
34792
- this.retiredItems.add(id);
34793
- if (active.messageId)
34794
- this.retiredMessages.add(active.messageId);
34795
- for (const id of active.aliases)
34796
- this.retiredMessages.add(id);
34977
+ active2.items.finishAll(outcome);
34978
+ for (const id2 of active2.items.completedIds())
34979
+ this.retiredItems.add(id2);
34980
+ if (active2.messageId)
34981
+ this.retiredMessages.add(active2.messageId);
34982
+ for (const id2 of active2.aliases)
34983
+ this.retiredMessages.add(id2);
34797
34984
  while (this.retiredItems.size > 4096)
34798
34985
  this.retiredItems.delete(this.retiredItems.values().next().value ?? "");
34799
34986
  while (this.retiredMessages.size > 128)
@@ -34801,8 +34988,8 @@ var CopilotHarnessSession = class {
34801
34988
  this.active = void 0;
34802
34989
  this.emit({
34803
34990
  type: "turn.completed",
34804
- turnId: active.id,
34805
- ...active.messageId ? { nativeTurnRef: turnRef(this.nativeId, active.messageId) } : {},
34991
+ turnId: active2.id,
34992
+ ...active2.messageId ? { nativeTurnRef: turnRef(this.nativeId, active2.messageId) } : {},
34806
34993
  outcome
34807
34994
  });
34808
34995
  }
@@ -34859,21 +35046,21 @@ var CopilotHarnessSession = class {
34859
35046
  return failure("invalidState", "Copilot has not accepted this Turn yet.");
34860
35047
  if (this.active.cancelling)
34861
35048
  return { ok: true, value: { cancellationRequested: true } };
34862
- const active = this.active;
34863
- active.cancelling = true;
34864
- active.timer = setTimeout(() => {
34865
- if (this.active === active)
35049
+ const active2 = this.active;
35050
+ active2.cancelling = true;
35051
+ active2.timer = setTimeout(() => {
35052
+ if (this.active === active2)
34866
35053
  this.fault(new Error("Copilot cancellation timed out"), "turn.cancel");
34867
35054
  }, 3e4);
34868
35055
  try {
34869
35056
  if (!this.session)
34870
35057
  throw new Error("Copilot session is not initialized");
34871
35058
  await bounded(this.session.abort());
34872
- if (this.active === active)
34873
- this.interactions.cancel(active.id);
35059
+ if (this.active === active2)
35060
+ this.interactions.cancel(active2.id);
34874
35061
  return { ok: true, value: { cancellationRequested: true } };
34875
35062
  } catch (error51) {
34876
- if (this.active === active)
35063
+ if (this.active === active2)
34877
35064
  this.fault(error51, "turn.cancel");
34878
35065
  return { ok: false, error: nativeError(error51, "turn.cancel") };
34879
35066
  }
@@ -34892,34 +35079,34 @@ var CopilotHarnessSession = class {
34892
35079
  if (!session || !client)
34893
35080
  throw new Error("Copilot session is not initialized");
34894
35081
  if (command.type === "turn.start") {
34895
- const id = hostTurnIdSchema.parse(command.turnId);
34896
- const active = this.startTurn(id);
34897
- this.active = active;
35082
+ const id2 = hostTurnIdSchema.parse(command.turnId);
35083
+ const active2 = this.startTurn(id2);
35084
+ this.active = active2;
34898
35085
  try {
34899
35086
  this.sending = [];
34900
35087
  this.sendingBytes = 0;
34901
35088
  this.draftCleanupNeeded = false;
34902
35089
  const messageId = await bounded(session.send({ prompt: command.input.map((part) => part.text).join("\n\n") }));
34903
- active.expectedMessageId = messageId;
35090
+ active2.expectedMessageId = messageId;
34904
35091
  const buffered = this.sending;
34905
35092
  this.sending = void 0;
34906
35093
  for (const event of buffered)
34907
35094
  this.receive(event);
34908
- await bounded(active.identity.promise);
35095
+ await bounded(active2.identity.promise);
34909
35096
  } catch (error51) {
34910
35097
  this.sending = void 0;
34911
- if (this.active === active)
35098
+ if (this.active === active2)
34912
35099
  this.fault(error51, "turn.start");
34913
- if (!active.accepted)
35100
+ if (!active2.accepted)
34914
35101
  return { ok: false, error: nativeError(error51, "turn.start") };
34915
35102
  }
34916
- return { ok: true, value: { turnId: id } };
35103
+ return { ok: true, value: { turnId: id2 } };
34917
35104
  }
34918
35105
  this.configurationRevision++;
34919
35106
  if (command.type === "model.select") {
34920
- const id = modelId2(command.model);
34921
- requireModel(await readModels(client, session), id);
34922
- await bounded(session.setModel(id));
35107
+ const id2 = command.model.id;
35108
+ requireModel(await readModels(client, session), id2);
35109
+ await bounded(session.setModel(id2));
34923
35110
  }
34924
35111
  if (command.type === "thinking.select") {
34925
35112
  const current = await session.rpc.model.getCurrent();
@@ -35136,9 +35323,9 @@ function projectCopilotAccount(quota) {
35136
35323
  // dist/account.js
35137
35324
  var CACHE_MS = 15e3;
35138
35325
  var identity2 = (auth) => JSON.stringify([auth.authType, auth.host, auth.login]);
35139
- async function deleteDraft(client, id) {
35326
+ async function deleteDraft(client, id2) {
35140
35327
  try {
35141
- await bounded(client.deleteSession(id), 5e3);
35328
+ await bounded(client.deleteSession(id2), 5e3);
35142
35329
  } catch (error51) {
35143
35330
  if (nativeError(error51).code !== "sessionNotFound")
35144
35331
  throw error51;
@@ -35230,9 +35417,9 @@ var CopilotAccount = class {
35230
35417
  });
35231
35418
  if (client) {
35232
35419
  if (ownedId) {
35233
- const id = ownedId;
35234
- await deleteDraft(client, id).then(() => {
35235
- this.pendingDrafts.delete(id);
35420
+ const id2 = ownedId;
35421
+ await deleteDraft(client, id2).then(() => {
35422
+ this.pendingDrafts.delete(id2);
35236
35423
  }).catch(() => {
35237
35424
  result = null;
35238
35425
  });
@@ -35277,9 +35464,9 @@ var CopilotAccount = class {
35277
35464
  this.client = client;
35278
35465
  try {
35279
35466
  await bounded(client.start(), 8e3);
35280
- for (const id of this.pendingDrafts) {
35281
- await deleteDraft(client, id);
35282
- this.pendingDrafts.delete(id);
35467
+ for (const id2 of this.pendingDrafts) {
35468
+ await deleteDraft(client, id2);
35469
+ this.pendingDrafts.delete(id2);
35283
35470
  }
35284
35471
  } finally {
35285
35472
  await bounded(client.forceStop(), 5e3);
@@ -35319,11 +35506,13 @@ var permissionModes = harnessPermissionModeCatalogSchema.parse({
35319
35506
  });
35320
35507
  var CopilotAdapter = class {
35321
35508
  environment;
35509
+ normalizeStoredModelRef = normalizeStoredCopilotModelRef;
35322
35510
  harnessId = copilotId;
35323
35511
  sessions = /* @__PURE__ */ new Map();
35324
35512
  clients = /* @__PURE__ */ new Set();
35325
35513
  inspections = /* @__PURE__ */ new Map();
35326
35514
  inspectionsInFlight = /* @__PURE__ */ new Map();
35515
+ inspectionTasks = /* @__PURE__ */ new Set();
35327
35516
  closed = false;
35328
35517
  account;
35329
35518
  constructor(environment) {
@@ -35347,15 +35536,26 @@ var CopilotAdapter = class {
35347
35536
  };
35348
35537
  const cwd = path6.resolve(input.cwd ?? this.environment.HOME ?? process.cwd());
35349
35538
  const pending = this.inspectionsInFlight.get(cwd);
35539
+ if (input.refresh) {
35540
+ this.inspections.clear();
35541
+ this.inspectionsInFlight.clear();
35542
+ if (pending)
35543
+ this.inspectionsInFlight.set(cwd, pending);
35544
+ }
35350
35545
  if (pending)
35351
35546
  return pending;
35352
35547
  const cached2 = this.inspections.get(cwd);
35353
- if (!input.refresh && cached2)
35548
+ if (cached2)
35354
35549
  return cached2;
35355
- this.inspections.delete(cwd);
35356
- const inspection = this.inspectCwd(cwd);
35550
+ const inspection = this.inspectCwd(cwd).then((result) => {
35551
+ if (!this.closed && result.status === "ready" && this.inspectionsInFlight.get(cwd) === inspection)
35552
+ this.inspections.set(cwd, result);
35553
+ return result;
35554
+ });
35357
35555
  this.inspectionsInFlight.set(cwd, inspection);
35556
+ this.inspectionTasks.add(inspection);
35358
35557
  return inspection.finally(() => {
35558
+ this.inspectionTasks.delete(inspection);
35359
35559
  if (this.inspectionsInFlight.get(cwd) === inspection)
35360
35560
  this.inspectionsInFlight.delete(cwd);
35361
35561
  });
@@ -35422,8 +35622,6 @@ var CopilotAdapter = class {
35422
35622
  status: "unavailable",
35423
35623
  error: { code: "invalidState", message: "Copilot Adapter is closed.", retryable: false }
35424
35624
  };
35425
- if (result.status === "ready")
35426
- this.inspections.set(cwd, result);
35427
35625
  return result;
35428
35626
  }
35429
35627
  async open(input) {
@@ -35517,7 +35715,7 @@ var CopilotAdapter = class {
35517
35715
  const ids = (values) => rootMessages(values).map((event) => event.data.messageId);
35518
35716
  if (JSON.stringify(ids(actual)) !== JSON.stringify(ids(expected)))
35519
35717
  throw new Error("Copilot Fork returned the wrong history prefix");
35520
- const content = (id, values) => projectHistory(id, values).turns.map(({ input: input2, items, outcome }) => ({
35718
+ const content = (id2, values) => projectHistory(id2, values).turns.map(({ input: input2, items, outcome }) => ({
35521
35719
  input: input2,
35522
35720
  items,
35523
35721
  outcome
@@ -35621,7 +35819,7 @@ var CopilotAdapter = class {
35621
35819
  this.account.close(),
35622
35820
  ...[...this.clients].map((client) => client.forceStop())
35623
35821
  ]);
35624
- await Promise.allSettled([...this.inspectionsInFlight.values()]);
35822
+ await Promise.allSettled(this.inspectionTasks);
35625
35823
  this.inspectionsInFlight.clear();
35626
35824
  if (results.some((result) => result.status === "rejected"))
35627
35825
  throw new Error("Copilot sessions could not all be closed; retry close.");