@codexhost/cli-darwin-x64 0.22.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 (59) hide show
  1. package/README.md +1 -1
  2. package/app/codexhost-distribution.json +1 -1
  3. package/app/console-server.mjs +3117 -274
  4. package/app/console-web.js +15645 -4413
  5. package/app/desktop-controller.mjs +14057 -969
  6. package/app/host-runtime.mjs +11518 -8277
  7. package/app/plugins/antigravity/plugin.mjs +2030 -678
  8. package/app/plugins/claude-code/plugin.mjs +2116 -929
  9. package/app/plugins/codebuddy/plugin.mjs +1247 -353
  10. package/app/plugins/codex-usage/plugin.mjs +786 -163
  11. package/app/plugins/copilot/plugin.mjs +938 -296
  12. package/app/plugins/cursor-cli/plugin.mjs +1021 -232
  13. package/app/plugins/deepseek-harness/plugin.mjs +1552 -664
  14. package/app/plugins/devin/plugin.mjs +826 -185
  15. package/app/plugins/grok/plugin.mjs +1083 -424
  16. package/app/plugins/hermes/plugin.mjs +961 -338
  17. package/app/plugins/kimi-code/plugin.mjs +854 -237
  18. package/app/plugins/kiro-cli/plugin.mjs +821 -184
  19. package/app/plugins/omp/plugin.mjs +1316 -633
  20. package/app/plugins/opencode/plugin.mjs +1293 -606
  21. package/app/plugins/pi/plugin.mjs +1540 -867
  22. package/app/plugins/qoder/plugin.mjs +961 -332
  23. package/app/plugins/qoder-cn/plugin.mjs +961 -332
  24. package/app/plugins/qwen-code/plugin.mjs +937 -321
  25. package/app/plugins/workbuddy/plugin.mjs +1311 -370
  26. package/app/plugins/zcode/plugin.mjs +1516 -423
  27. package/app/renderer-extension.js +21297 -9060
  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 +6753 -31616
  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 +14 -14
  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 +94 -91
  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-browser/client.js +1 -1
  44. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-documentpreview/client.js +9 -9
  45. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-right/client.js +1 -1
  46. package/app/web/plugins/deepseek-ai__dsh-client-ui-theme/client.js +1 -1
  47. package/app/web/plugins/deepseek-ai__dsh-client-ui-tool/client.js +79 -79
  48. package/app/web/plugins/deepseek-ai__dsh-client-ui-user-questions/client.js +3 -3
  49. package/app/web/plugins/deepseek-ai__dsh-client-ui-workspace/client.js +7 -7
  50. package/app/web/sw.js +8 -1
  51. package/app/web-modules/licenses/werift-NOTICES.txt +123 -0
  52. package/app/web-modules/licenses/werift-libwebrtc-NOTICES.txt +58 -0
  53. package/app/web-modules/server.mjs +40416 -11283
  54. package/bin/codexhost +0 -0
  55. package/libexec/codexhost-shim +0 -0
  56. package/libexec/codexhost-updater +0 -0
  57. package/package.json +1 -1
  58. package/app/web/assets/index-CN4a4sj0.js +0 -201
  59. package/app/web/assets/index-DJW4bmyx.css +0 -1
@@ -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,
@@ -18709,6 +18709,9 @@ var threadPermissionModeSelectParamsSchema = external_exports.object({
18709
18709
  permissionModeId: harnessPermissionModeIdSchema
18710
18710
  }).strict();
18711
18711
 
18712
+ // ../../shared-contracts/dist/harness-route-limit.js
18713
+ var HARNESS_TRANSPORT_MODEL_ID_MAX_LENGTH = 8192;
18714
+
18712
18715
  // ../../shared-contracts/dist/thread-usage.js
18713
18716
  var nonNegativeSafeIntegerSchema = external_exports.number().int().safe().nonnegative();
18714
18717
  var finiteNonNegativeNumberSchema = external_exports.number().finite().nonnegative();
@@ -18741,7 +18744,7 @@ var composerIndicatorsSchema = external_exports.array(external_exports.object({
18741
18744
  expiresAtUnix: nonNegativeSafeIntegerSchema,
18742
18745
  label: indicatorTextSchema(256).optional(),
18743
18746
  tooltip: indicatorTextSchema(1024).optional()
18744
- }).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, {
18745
18748
  message: "Composer indicator IDs must be unique"
18746
18749
  });
18747
18750
  var threadUsageSnapshotSchema = external_exports.object({
@@ -18767,6 +18770,7 @@ var threadUsageSnapshotSchema = external_exports.object({
18767
18770
  planSevenDayResetsAtUnix: nonNegativeSafeIntegerSchema.optional(),
18768
18771
  sessionCacheHitRatePercent: cacheHitRatePercentSchema.optional(),
18769
18772
  timeToFirstOutputMs: nonNegativeSafeIntegerSchema.optional(),
18773
+ latestRequestTimeToFirstOutputMs: nonNegativeSafeIntegerSchema.optional(),
18770
18774
  costSource: external_exports.enum(["publicPrice", "native"]).optional(),
18771
18775
  unpricedModels: external_exports.array(external_exports.string().min(1)).min(1).optional()
18772
18776
  }).strict().superRefine((usage, context) => {
@@ -18864,6 +18868,13 @@ var accountCreditsSnapshotSchema = external_exports.object({
18864
18868
  productUsage: external_exports.array(accountCreditsProductUsageSchema).min(1).optional(),
18865
18869
  resetCredits: accountResetCreditsSchema.optional()
18866
18870
  }).strict();
18871
+ var accountBalanceSnapshotSchema = external_exports.object({
18872
+ amount: external_exports.number().finite().nonnegative(),
18873
+ /** ISO 4217 code as reported by the Provider, for example `CNY`. */
18874
+ currency: external_exports.string().trim().min(1).max(8),
18875
+ /** Native label when the Harness exposes several Billing Sources. */
18876
+ label: external_exports.string().trim().min(1).max(128).optional()
18877
+ }).strict();
18867
18878
  var threadUsageInspectionParamsSchema = external_exports.object({
18868
18879
  threadId: hostThreadIdSchema,
18869
18880
  refresh: external_exports.literal("exact").optional()
@@ -18872,7 +18883,10 @@ var threadUsageInspectionSchema = external_exports.object({
18872
18883
  threadId: hostThreadIdSchema,
18873
18884
  usage: threadUsageSnapshotSchema.nullable(),
18874
18885
  accountCredits: accountCreditsSnapshotSchema.optional(),
18875
- /** Whether this source can provide cached account quota independently of usage. */
18886
+ /** Prepaid funds for the Thread's Billing Source; shown only when no percentage quota exists. */
18887
+ accountBalance: accountBalanceSnapshotSchema.optional(),
18888
+ /** Whether this source can provide cached account quota (credits or a prepaid balance)
18889
+ * independently of usage. */
18876
18890
  accountCreditsSupported: external_exports.boolean().optional()
18877
18891
  }).strict();
18878
18892
 
@@ -18884,10 +18898,15 @@ var THREAD_OWNERSHIP_LIST_MAX_LENGTH = 100;
18884
18898
  var nonBlankTextSchema2 = external_exports.string().refine((value) => value.trim().length > 0, {
18885
18899
  message: "Value must not be empty or whitespace"
18886
18900
  });
18887
- 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"]);
18888
18903
  var harnessModelRefSchema = external_exports.object({
18889
- id: harnessModelRefIdSchema
18904
+ id: harnessModelRefIdSchema,
18905
+ serviceTier: harnessModelServiceTierSchema.optional()
18890
18906
  }).strict();
18907
+ function sameHarnessModelRef(left, right) {
18908
+ return left?.id === right?.id && left?.serviceTier === right?.serviceTier;
18909
+ }
18891
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();
18892
18911
  var harnessResolvedModelLabelSchema = nonBlankTextSchema2.max(HARNESS_MODEL_LABEL_MAX_LENGTH);
18893
18912
  var harnessThinkingOptionSchema = external_exports.object({
@@ -18901,7 +18920,15 @@ var harnessModelSchema = external_exports.object({
18901
18920
  /** Optional opaque selection for this same Model with priority processing enabled. */
18902
18921
  fastModel: harnessModelRefSchema.optional(),
18903
18922
  supportedThinkingOptionIds: external_exports.array(harnessThinkingOptionIdSchema).optional()
18904
- }).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
+ }
18905
18932
  var harnessThinkingOptionsSchema = external_exports.array(harnessThinkingOptionSchema).superRefine((options2, context) => {
18906
18933
  const ids = /* @__PURE__ */ new Set();
18907
18934
  for (const [index, option] of options2.entries()) {
@@ -18921,26 +18948,26 @@ var harnessModelCatalogSchema = external_exports.object({
18921
18948
  thinkingOptions: harnessThinkingOptionsSchema,
18922
18949
  defaultThinkingOptionId: harnessThinkingOptionIdSchema.optional()
18923
18950
  }).strict().superRefine((catalog, context) => {
18924
- const refs = /* @__PURE__ */ new Set();
18925
- const thinkingIds = new Set(catalog.thinkingOptions.map(({ id }) => id));
18951
+ const refs = [];
18952
+ const thinkingIds = new Set(catalog.thinkingOptions.map(({ id: id2 }) => id2));
18926
18953
  for (const [index, model2] of catalog.models.entries()) {
18927
- if (refs.has(model2.ref.id)) {
18954
+ if (refs.some((ref) => sameHarnessModelRef(ref, model2.ref))) {
18928
18955
  context.addIssue({
18929
18956
  code: "custom",
18930
18957
  message: "Model Catalog refs must be unique",
18931
18958
  path: ["models", index, "ref", "id"]
18932
18959
  });
18933
18960
  }
18934
- refs.add(model2.ref.id);
18961
+ refs.push(model2.ref);
18935
18962
  if (model2.fastModel) {
18936
- 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))) {
18937
18964
  context.addIssue({
18938
18965
  code: "custom",
18939
18966
  message: "Fast Model refs must be distinct and unique",
18940
18967
  path: ["models", index, "fastModel"]
18941
18968
  });
18942
18969
  }
18943
- refs.add(model2.fastModel.id);
18970
+ refs.push(model2.fastModel);
18944
18971
  }
18945
18972
  const supportedThinkingIds = /* @__PURE__ */ new Set();
18946
18973
  for (const [optionIndex, optionId] of (model2.supportedThinkingOptionIds ?? []).entries()) {
@@ -18961,7 +18988,7 @@ var harnessModelCatalogSchema = external_exports.object({
18961
18988
  }
18962
18989
  }
18963
18990
  }
18964
- if (catalog.defaultModel && !refs.has(catalog.defaultModel.id)) {
18991
+ if (catalog.defaultModel && !catalogModelForRef(catalog, catalog.defaultModel)) {
18965
18992
  context.addIssue({
18966
18993
  code: "custom",
18967
18994
  message: "Default Model must exist in the Model Catalog",
@@ -19001,7 +19028,12 @@ var harnessSessionCapabilitiesSchema = external_exports.object({
19001
19028
  observe: external_exports.boolean()
19002
19029
  }).strict().optional(),
19003
19030
  /** True only when `turn.steer` delivers input into the active Turn through a native primitive. */
19004
- 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()
19005
19037
  }).strict();
19006
19038
  var harnessConfigurationStateSchema = external_exports.object({
19007
19039
  effectiveModel: harnessModelRefSchema.optional(),
@@ -19010,7 +19042,7 @@ var harnessConfigurationStateSchema = external_exports.object({
19010
19042
  availableThinkingOptions: harnessThinkingOptionsSchema.optional(),
19011
19043
  effectivePermissionModeId: harnessPermissionModeIdSchema.optional()
19012
19044
  }).strict().superRefine((state, context) => {
19013
- 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)) {
19014
19046
  context.addIssue({
19015
19047
  code: "custom",
19016
19048
  message: "Effective Thinking option must be currently available",
@@ -19050,7 +19082,8 @@ var harnessInspectParamsSchema = external_exports.object({
19050
19082
  cwd: nonBlankTextSchema2.max(16384).optional(),
19051
19083
  refresh: external_exports.boolean().optional(),
19052
19084
  /** `availability` asks only whether the Harness can run; see `InspectHarnessInput.purpose`. */
19053
- purpose: external_exports.literal("availability").optional()
19085
+ purpose: external_exports.literal("availability").optional(),
19086
+ credentialAccess: external_exports.enum(["allow", "retry"]).optional()
19054
19087
  }).strict();
19055
19088
  var harnessWebUiOpenParamsSchema = external_exports.object({
19056
19089
  harnessId: harnessIdSchema
@@ -19081,7 +19114,7 @@ var codexThreadInspectionSchema = external_exports.object({
19081
19114
  var externalThreadInspectionSchema = external_exports.object({
19082
19115
  owner: external_exports.literal("external"),
19083
19116
  harnessId: nonBlankTextSchema2.max(256),
19084
- transportModelId: nonBlankTextSchema2.max(1024),
19117
+ transportModelId: nonBlankTextSchema2.max(HARNESS_TRANSPORT_MODEL_ID_MAX_LENGTH),
19085
19118
  effectiveModel: harnessModelRefSchema.optional(),
19086
19119
  resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
19087
19120
  effectiveThinkingOptionId: harnessThinkingOptionIdSchema.optional(),
@@ -19163,13 +19196,635 @@ var threadSteeringInspectResultSchema = external_exports.object({
19163
19196
  delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
19164
19197
  }).strict();
19165
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
+
19166
19744
  // ../../shared-contracts/dist/thread-archive-confirm.js
19745
+ var THREAD_ARCHIVE_CONFIRM_METHOD = "codexhost/thread/archive/confirm";
19167
19746
  var threadArchiveConfirmParamsSchema = external_exports.object({ threadId: hostThreadIdSchema }).strict();
19168
19747
  var threadArchiveConfirmResultSchema = external_exports.object({ confirmed: external_exports.boolean() }).strict();
19169
19748
 
19170
19749
  // ../../shared-contracts/dist/client-channel.js
19171
19750
  var CLIENT_CHANNEL_VERSION = 1;
19172
19751
  var CLIENT_REQUEST_LIMIT_BYTES = 128 * 1024 * 1024;
19752
+ var CLIENT_CHANNEL_METHODS = [
19753
+ "codexhost/skills/list",
19754
+ "codexhost/voice/status",
19755
+ "codexhost/voice/transcribe",
19756
+ "codexhost/harness/display-settings/get",
19757
+ "codexhost/harness/display-settings/set",
19758
+ "codexhost/harness/display-settings/capabilities",
19759
+ "codexhost/harness/preferences/get",
19760
+ "codexhost/harness/preferences/patch",
19761
+ "thread/list",
19762
+ "codexhost/thread/catalog/read",
19763
+ "thread/read",
19764
+ "thread/resume",
19765
+ "thread/fork",
19766
+ "thread/turns/list",
19767
+ "thread/revert",
19768
+ "thread/items/list",
19769
+ "thread/start",
19770
+ "thread/name/set",
19771
+ "codexhost/thread/title/generate",
19772
+ "thread/archive",
19773
+ THREAD_ARCHIVE_CONFIRM_METHOD,
19774
+ "thread/unarchive",
19775
+ "turn/start",
19776
+ "turn/interrupt",
19777
+ "turn/steer",
19778
+ "thread/queue/list",
19779
+ "thread/queue/add",
19780
+ "thread/queue/update",
19781
+ "thread/queue/delete",
19782
+ "thread/queue/reorder",
19783
+ "thread/queue/start",
19784
+ "codexhost/thread/queue/send-now",
19785
+ "codexhost/workspace/read",
19786
+ "codexhost/thread/tree/read",
19787
+ "codexhost/thread/pins/list",
19788
+ "codexhost/thread/pins/set",
19789
+ "codexhost/harness/plugins/list",
19790
+ "codexhost/harness/inspect",
19791
+ "codexhost/thread/inspect",
19792
+ "codexhost/thread/usage/inspect",
19793
+ "codexhost/thread/ownership/list",
19794
+ "codexhost/thread/model/select",
19795
+ "codexhost/thread/thinking/select",
19796
+ "codexhost/thread/permission-mode/select",
19797
+ "codexhost/thread/commands/inspect",
19798
+ "codexhost/harness/commands/inspect",
19799
+ "codexhost/thread/command/execute",
19800
+ "codexhost/thread/fork",
19801
+ "codexhost/harness/session-import/sources",
19802
+ "codexhost/harness/session-import/list",
19803
+ "codexhost/harness/session-import/import",
19804
+ // Host settings shared across Desktop and Web.
19805
+ ...HOST_EXTENSION_MANAGEMENT_METHODS,
19806
+ "codexhost/harness/installation",
19807
+ "codexhost/harness/installation/start",
19808
+ "codexhost/harness/installation/status",
19809
+ "codexhost/harness/launch-settings/get",
19810
+ "codexhost/harness/launch-settings/set",
19811
+ "codexhost/harness/web-ui/open",
19812
+ "codexhost/harness/accounts/sources",
19813
+ "codexhost/harness/accounts/list",
19814
+ "codexhost/harness/accounts/inspect",
19815
+ "codexhost/harness/credential-imports",
19816
+ "codexhost/account/list",
19817
+ "codexhost/account/refresh",
19818
+ "codexhost/account/usage/inspect",
19819
+ "codexhost/usage/model-prices/get",
19820
+ "codexhost/usage/model-prices/set",
19821
+ "codexhost/usage/model-prices/default",
19822
+ "codexhost/usage/statistics/get",
19823
+ "codexhost/update/check",
19824
+ "codexhost/update/start",
19825
+ "codexhost/update/status",
19826
+ "codexhost/sessions/loaded/list"
19827
+ ];
19173
19828
  var clientThreadPinsSchema = external_exports.object({ threadIds: external_exports.array(external_exports.string().min(1)) }).strict();
19174
19829
  var clientThreadPinParamsSchema = external_exports.object({ threadId: external_exports.string().min(1).max(1024), pinned: external_exports.boolean() }).strict();
19175
19830
  var clientThreadTreeReadParamsSchema = external_exports.object({}).strict();
@@ -19208,6 +19863,11 @@ var clientChannelEventSchema = external_exports.discriminatedUnion("type", [
19208
19863
  cursor: clientChannelCursorSchema,
19209
19864
  revision: external_exports.number().int().nonnegative()
19210
19865
  }),
19866
+ external_exports.object({
19867
+ type: external_exports.literal("extensions-changed"),
19868
+ cursor: clientChannelCursorSchema,
19869
+ revision: hostExtensionRevisionSchema
19870
+ }),
19211
19871
  external_exports.object({
19212
19872
  type: external_exports.literal("hello"),
19213
19873
  version: external_exports.literal(1),
@@ -19383,6 +20043,29 @@ var threadCatalogReadResultSchema = external_exports.object({
19383
20043
  officialCursor: external_exports.object({ live: external_exports.string().nullable(), archived: external_exports.string().nullable().optional() }).strict().optional()
19384
20044
  }).strict();
19385
20045
 
20046
+ // ../../shared-contracts/dist/thread-tree-watch.js
20047
+ var THREAD_TREE_MAX_NODES = 5e3;
20048
+ var threadTreeStatusSchema = external_exports.enum(["running", "waiting", "idle", "unknown"]);
20049
+ var threadTreeNodeSchema = external_exports.strictObject({
20050
+ harnessId: harnessIdSchema,
20051
+ title: external_exports.string().optional(),
20052
+ status: threadTreeStatusSchema,
20053
+ archived: external_exports.boolean()
20054
+ });
20055
+ var threadTreeSnapshotSchema = external_exports.strictObject({
20056
+ revision: external_exports.int().nonnegative(),
20057
+ parents: external_exports.record(hostThreadIdSchema, hostThreadIdSchema),
20058
+ nodes: external_exports.record(hostThreadIdSchema, threadTreeNodeSchema),
20059
+ truncated: external_exports.boolean()
20060
+ }).refine((snapshot) => Object.keys(snapshot.nodes).length <= THREAD_TREE_MAX_NODES, "Too many Thread tree nodes").refine(({ parents, nodes }) => Object.entries(parents).every(([child, parent]) => Object.hasOwn(nodes, child) && Object.hasOwn(nodes, parent)), "Missing Thread tree node");
20061
+ var subscriptionId = external_exports.string().min(1).max(128);
20062
+ var threadTreeWatchParamsSchema = external_exports.strictObject({});
20063
+ var threadTreeUnwatchParamsSchema = external_exports.strictObject({ subscriptionId });
20064
+ var threadTreeUnwatchResultSchema = external_exports.strictObject({});
20065
+ var threadTreeWatchResultSchema = threadTreeUnwatchParamsSchema.extend({
20066
+ snapshot: threadTreeSnapshotSchema
20067
+ });
20068
+
19386
20069
  // ../../shared-contracts/dist/voice.js
19387
20070
  var VOICE_AUDIO_MAX_BYTES = 10 * 1024 * 1024;
19388
20071
  var voiceAudioMimeTypeSchema = external_exports.string().regex(/^audio\/[a-z0-9.+-]+(?:\s*;[^\r\n]*)?$/i);
@@ -19621,7 +20304,7 @@ var DEFAULT_IDLE_RELEASE_SETTINGS = Object.freeze({
19621
20304
 
19622
20305
  // ../../shared-contracts/dist/harness-preferences.js
19623
20306
  var harnessPreferenceScopeSchema = external_exports.string().regex(/^external$/u);
19624
- var preferenceHarnessKey = harnessIdSchema.transform((id) => String(id));
20307
+ var preferenceHarnessKey = harnessIdSchema.transform((id2) => String(id2));
19625
20308
  var harnessDefaultConfigurationSchema = external_exports.strictObject({
19626
20309
  model: harnessModelRefSchema.optional(),
19627
20310
  thinkingOptionId: harnessThinkingOptionIdSchema.optional(),
@@ -19631,11 +20314,19 @@ var newThreadDefaultsSchema = external_exports.strictObject({
19631
20314
  lastHarness: harnessIdSchema.optional(),
19632
20315
  byHarness: external_exports.record(preferenceHarnessKey, harnessDefaultConfigurationSchema)
19633
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
+ });
19634
20324
  var modelId = external_exports.string().min(1).max(1024);
19635
20325
  var harnessPreferenceValuesSchema = external_exports.strictObject({
19636
20326
  idleRelease: idleReleaseSettingsSchema.optional(),
19637
20327
  favorites: external_exports.record(preferenceHarnessKey, external_exports.array(modelId).max(2048)).default({}),
19638
- newThread: newThreadDefaultsSchema.optional()
20328
+ newThread: newThreadDefaultsSchema.optional(),
20329
+ delegation: delegationDefaultsSchema.optional()
19639
20330
  });
19640
20331
  var harnessPreferenceSnapshotSchema = external_exports.strictObject({
19641
20332
  scope: harnessPreferenceScopeSchema,
@@ -19663,6 +20354,11 @@ var harnessPreferenceOperationSchema = external_exports.discriminatedUnion("kind
19663
20354
  lastHarness: harnessIdSchema.optional(),
19664
20355
  harnessId: harnessIdSchema.optional(),
19665
20356
  configuration: harnessDefaultConfigurationSchema.optional()
20357
+ }),
20358
+ external_exports.strictObject({
20359
+ kind: external_exports.literal("delegation"),
20360
+ harnessId: harnessIdSchema,
20361
+ configuration: harnessDelegationDefaultSchema.nullable()
19666
20362
  })
19667
20363
  ]);
19668
20364
  var harnessPreferencePatchSchema = external_exports.strictObject({
@@ -20013,13 +20709,6 @@ var threadManualCompactionStartedSchema = external_exports.strictObject({
20013
20709
  });
20014
20710
 
20015
20711
  // ../../shared-contracts/dist/harness-accounts.js
20016
- var accountBalanceSnapshotSchema = external_exports.object({
20017
- amount: external_exports.number().finite().nonnegative(),
20018
- /** ISO 4217 code as reported by the Provider, for example `CNY`. */
20019
- currency: external_exports.string().trim().min(1).max(8),
20020
- /** Native label when the Harness exposes several Billing Sources. */
20021
- label: external_exports.string().trim().min(1).max(128).optional()
20022
- }).strict();
20023
20712
  var harnessAccountSnapshotObject = external_exports.object({
20024
20713
  email: external_exports.string().trim().min(1).max(320).optional(),
20025
20714
  label: external_exports.string().trim().min(1).max(256).optional(),
@@ -20053,76 +20742,6 @@ var harnessAccountListResultSchema = external_exports.object({
20053
20742
  accounts: external_exports.array(requireReportedQuota(harnessAccountSnapshotObject.extend(harnessAccountIdentityShape))).max(128)
20054
20743
  }).strict();
20055
20744
 
20056
- // ../../shared-contracts/dist/harness-plugins.js
20057
- var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
20058
- var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
20059
- var HARNESS_PLUGIN_LIMIT = 128;
20060
- var installedHarnessPluginIdSchema = external_exports.string().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u).pipe(harnessIdSchema);
20061
- var harnessPluginIdSchema = installedHarnessPluginIdSchema.refine((id) => id !== "codex", "The official Codex identity is reserved");
20062
- var relativeResourceSchema = 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");
20063
- var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
20064
- var localizedTextSchema = external_exports.object({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).strict();
20065
- var harnessInstallationGuideSchema = external_exports.object({
20066
- commands: external_exports.array(external_exports.object({ terminal: external_exports.string().max(256), command: external_exports.string().max(4096) }).strict()).max(8),
20067
- before: localizedTextSchema.optional(),
20068
- after: localizedTextSchema.optional(),
20069
- downloads: external_exports.array(external_exports.object({ label: external_exports.string().max(128), url: documentationUrlSchema }).strict()).max(8).optional()
20070
- }).strict();
20071
- var pluginPresentationShape = {
20072
- id: installedHarnessPluginIdSchema,
20073
- name: external_exports.string().trim().min(1).max(128),
20074
- version: external_exports.string().min(1).max(128),
20075
- /** Capability-only plugin; omitted for existing session-capable plugins. */
20076
- kind: external_exports.literal("usage").optional(),
20077
- /** Original image styling or bounded vector paths; never arbitrary CSS/SVG markup. */
20078
- iconStyle: external_exports.object({
20079
- vector: external_exports.object({
20080
- viewBox: external_exports.string().max(128).regex(/^-?\d+(?:\.\d+)?(?: +-?\d+(?:\.\d+)?){3}$/u),
20081
- color: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu),
20082
- paths: external_exports.array(external_exports.object({
20083
- d: external_exports.string().min(1).max(32768).regex(/^[MmLlHhVvCcSsQqTtAaZz\d.,+eE\s-]+$/u),
20084
- fillRule: external_exports.enum(["evenodd", "nonzero"]).optional(),
20085
- fill: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu).optional()
20086
- }).strict()).min(1).max(32)
20087
- }).strict().optional(),
20088
- background: external_exports.string().regex(/^#[a-f0-9]{6}$/iu).optional(),
20089
- borderRadius: external_exports.number().min(0).max(50).optional(),
20090
- paddingRatio: external_exports.number().min(0).max(0.25).optional()
20091
- }).strict().optional(),
20092
- installation: harnessInstallationGuideSchema.optional(),
20093
- notice: localizedTextSchema.optional(),
20094
- /** The factory accepts a persisted local entrypoint through its construction context. */
20095
- launchCommand: external_exports.literal(true).optional(),
20096
- links: external_exports.object({
20097
- website: documentationUrlSchema.optional(),
20098
- documentation: documentationUrlSchema.optional(),
20099
- installation: documentationUrlSchema.optional()
20100
- }).strict().optional()
20101
- };
20102
- var harnessPluginManifestSchema = external_exports.object({
20103
- manifestVersion: external_exports.literal(1),
20104
- ...pluginPresentationShape,
20105
- adapterApiVersion: external_exports.number().int().positive(),
20106
- entry: relativeResourceSchema,
20107
- icon: relativeResourceSchema.optional()
20108
- }).strict();
20109
- 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);
20110
- var harnessPluginDescriptorSchema = external_exports.object({
20111
- ...pluginPresentationShape,
20112
- icon: harnessPluginIconSchema.optional()
20113
- }).strict();
20114
- var harnessPluginListParamsSchema = external_exports.object({}).strict();
20115
- var harnessPluginListResultSchema = external_exports.object({
20116
- plugins: external_exports.array(harnessPluginDescriptorSchema.extend({ id: harnessPluginIdSchema })).max(HARNESS_PLUGIN_LIMIT)
20117
- }).strict();
20118
- var harnessPluginConfigurationSchema = external_exports.object({
20119
- version: external_exports.literal(1),
20120
- enabled: external_exports.array(installedHarnessPluginIdSchema).max(HARNESS_PLUGIN_LIMIT)
20121
- }).strict().refine((value) => new Set(value.enabled).size === value.enabled.length, {
20122
- message: "Enabled plugin IDs must be unique",
20123
- path: ["enabled"]
20124
- });
20125
-
20126
20745
  // ../../shared-contracts/dist/harness-route.js
20127
20746
  var harnessPluginRouteSchema = external_exports.object({
20128
20747
  harnessId: harnessPluginIdSchema,
@@ -20563,9 +21182,12 @@ var remoteSessionOperationSchema = external_exports.discriminatedUnion("kind", [
20563
21182
  ...thread,
20564
21183
  epoch: identity,
20565
21184
  modelId: identity.optional(),
21185
+ serviceTier: harnessModelServiceTierSchema.optional(),
20566
21186
  thinkingOptionId: identity.optional(),
20567
21187
  permissionModeId: identity.optional()
20568
- }).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
+ }),
20569
21191
  external_exports.strictObject({
20570
21192
  kind: external_exports.literal("prompt"),
20571
21193
  ...thread,
@@ -20615,7 +21237,7 @@ var remoteConnectionsRequestSchema = external_exports.discriminatedUnion("action
20615
21237
  external_exports.strictObject({ action: external_exports.literal("catalog") }),
20616
21238
  external_exports.strictObject({
20617
21239
  action: external_exports.literal("read-thread"),
20618
- hostId: hostId.refine((id) => id !== "local"),
21240
+ hostId: hostId.refine((id2) => id2 !== "local"),
20619
21241
  input: delegationReadParamsSchema
20620
21242
  }),
20621
21243
  external_exports.strictObject({
@@ -20629,7 +21251,7 @@ var remoteConnectionsRequestSchema = external_exports.discriminatedUnion("action
20629
21251
  external_exports.strictObject({ action: external_exports.literal("runtime"), hostId }),
20630
21252
  external_exports.strictObject({
20631
21253
  action: external_exports.literal("update"),
20632
- hostId: hostId.refine((id) => id !== "local"),
21254
+ hostId: hostId.refine((id2) => id2 !== "local"),
20633
21255
  version: remoteUpdateParamsSchema.shape.version
20634
21256
  })
20635
21257
  ]);
@@ -27289,13 +27911,13 @@ var CopilotSession = class {
27289
27911
  );
27290
27912
  try {
27291
27913
  const sendOutcome = this.send(options2).then(
27292
- (id) => {
27293
- if (!id) {
27914
+ (id2) => {
27915
+ if (!id2) {
27294
27916
  throw new Error(
27295
27917
  "The runtime did not return a message ID for the structured send."
27296
27918
  );
27297
27919
  }
27298
- messageId = id;
27920
+ messageId = id2;
27299
27921
  for (const event of buffered) observe(event);
27300
27922
  buffered.length = 0;
27301
27923
  return outcomePromise;
@@ -32170,10 +32792,10 @@ function executableExtensions(command, platform, environment) {
32170
32792
  return [""];
32171
32793
  return (environmentValue(environment, "PATHEXT") ?? ".COM;.EXE;.BAT;.CMD").split(";").map((extension) => extension.trim()).filter(Boolean);
32172
32794
  }
32173
- function isExecutableFile(filePath, platform) {
32795
+ function isExecutableFile(filePath2, platform) {
32174
32796
  try {
32175
- fs3.accessSync(filePath, platform === "win32" ? fs3.constants.F_OK : fs3.constants.X_OK);
32176
- 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();
32177
32799
  } catch {
32178
32800
  return false;
32179
32801
  }
@@ -32665,7 +33287,7 @@ function invalidRequest(message) {
32665
33287
  return { code: "invalidRequest", message, retryable: false };
32666
33288
  }
32667
33289
  function validateHostApprovalResponse(interaction, response) {
32668
- 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");
32669
33291
  }
32670
33292
 
32671
33293
  // ../../harness-adapter/dist/question.js
@@ -32673,7 +33295,7 @@ function invalidRequest2(message) {
32673
33295
  return { code: "invalidRequest", message, retryable: false };
32674
33296
  }
32675
33297
  function validateHostQuestionResponse(interaction, response) {
32676
- const questionIds = new Set(interaction.questions.map(({ id }) => id));
33298
+ const questionIds = new Set(interaction.questions.map(({ id: id2 }) => id2));
32677
33299
  if (response.cancelled) {
32678
33300
  return Object.keys(response.answers).length === 0 ? null : invalidRequest2("Cancelled Question Response must not contain answers");
32679
33301
  }
@@ -32721,6 +33343,18 @@ function validateHostInteractionResponse(interaction, response) {
32721
33343
  return response.type === "approval" ? validateHostApprovalResponse(interaction, response) : invalidRequest3("Interaction Response type does not match the pending Interaction");
32722
33344
  }
32723
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
+
32724
33358
  // ../../harness-adapter/dist/output-channel.js
32725
33359
  var HarnessOutputChannel = class {
32726
33360
  outputs;
@@ -32805,7 +33439,8 @@ var tokenFields = [
32805
33439
  var safeIntegerFields = [
32806
33440
  "planFiveHourResetsAtUnix",
32807
33441
  "planSevenDayResetsAtUnix",
32808
- "timeToFirstOutputMs"
33442
+ "timeToFirstOutputMs",
33443
+ "latestRequestTimeToFirstOutputMs"
32809
33444
  ];
32810
33445
  var percentFields = [
32811
33446
  "cacheHitRatePercent",
@@ -33079,15 +33714,11 @@ async function bounded(promise2, milliseconds = 3e4) {
33079
33714
  }
33080
33715
 
33081
33716
  // dist/configuration.js
33082
- function modelRef(id) {
33083
- return harnessModelRefSchema.parse({ id: Buffer.from(id).toString("base64url") });
33717
+ function modelRef(id2) {
33718
+ return harnessModelRefSchema.parse({ id: id2 });
33084
33719
  }
33085
- function modelId2(ref) {
33086
- const parsed = harnessModelRefSchema.parse(ref);
33087
- const id = Buffer.from(parsed.id, "base64url").toString("utf8");
33088
- if (!id || modelRef(id).id !== parsed.id)
33089
- throw new CopilotOperationError("invalidRequest", "Invalid Copilot Model reference.");
33090
- return id;
33720
+ function normalizeStoredCopilotModelRef(ref, catalog) {
33721
+ return normalizeLegacyBase64ModelRef(ref, catalog, "");
33091
33722
  }
33092
33723
  var modelSchema = external_exports.object({
33093
33724
  id: external_exports.string().min(1),
@@ -33113,8 +33744,8 @@ async function readModels(client, session, auth, refresh = true) {
33113
33744
  models.unshift({ id: "auto", name: "Auto" });
33114
33745
  return models.filter((model2) => model2.policy?.state !== "disabled");
33115
33746
  }
33116
- function requireModel(models, id) {
33117
- const model2 = models.find((entry) => entry.id === id);
33747
+ function requireModel(models, id2) {
33748
+ const model2 = models.find((entry) => entry.id === id2);
33118
33749
  if (!model2)
33119
33750
  throw new CopilotOperationError("invalidRequest", "Copilot does not offer this Model in the current native catalog.");
33120
33751
  return model2;
@@ -33135,7 +33766,7 @@ function modelCatalog(models) {
33135
33766
  label: model2.name,
33136
33767
  supportedThinkingOptionIds: model2.supportedReasoningEfforts ?? []
33137
33768
  })),
33138
- thinkingOptions: efforts.map((id) => ({ id, label: id })),
33769
+ thinkingOptions: efforts.map((id2) => ({ id: id2, label: id2 })),
33139
33770
  ...initial ? { defaultModel: modelRef(initial.id) } : {}
33140
33771
  });
33141
33772
  }
@@ -33151,9 +33782,9 @@ async function confirmedConfiguration(session, client) {
33151
33782
  ...entry ? { resolvedModelLabel: entry.name } : {},
33152
33783
  ...model2.reasoningEffort && entry?.supportedReasoningEfforts?.includes(model2.reasoningEffort) ? { effectiveThinkingOptionId: harnessThinkingOptionIdSchema.parse(model2.reasoningEffort) } : {},
33153
33784
  ...entry ? {
33154
- availableThinkingOptions: (entry.supportedReasoningEfforts ?? []).map((id) => ({
33155
- id: harnessThinkingOptionIdSchema.parse(id),
33156
- label: id
33785
+ availableThinkingOptions: (entry.supportedReasoningEfforts ?? []).map((id2) => ({
33786
+ id: harnessThinkingOptionIdSchema.parse(id2),
33787
+ label: id2
33157
33788
  }))
33158
33789
  } : {},
33159
33790
  effectivePermissionModeId: harnessPermissionModeIdSchema.parse(permission.mode)
@@ -33234,9 +33865,9 @@ function elicitationForm(context) {
33234
33865
  const schema = context.requestedSchema;
33235
33866
  if (context.mode === "url" || !schema || schema.type !== "object" || !Object.keys(schema.properties).length)
33236
33867
  throw new CopilotOperationError("unsupported", "Copilot elicitation requires a supported primitive form; browser URL flows are unavailable.");
33237
- if (schema.required?.some((id) => !Object.hasOwn(schema.properties, id)))
33868
+ if (schema.required?.some((id2) => !Object.hasOwn(schema.properties, id2)))
33238
33869
  throw new Error("Copilot form refers to an unknown required field");
33239
- const questions = Object.entries(schema.properties).map(([id, field2]) => {
33870
+ const questions = Object.entries(schema.properties).map(([id2, field2]) => {
33240
33871
  const allowed = /* @__PURE__ */ new Set([
33241
33872
  "type",
33242
33873
  "title",
@@ -33250,12 +33881,12 @@ function elicitationForm(context) {
33250
33881
  throw new CopilotOperationError("unsupported", "Copilot form contains an unsupported text format.");
33251
33882
  if (!["string", "number", "integer", "boolean", "array"].includes(field2.type))
33252
33883
  throw new CopilotOperationError("unsupported", "Copilot form field cannot be represented");
33253
- const prompt = [field2.title ?? id, field2.description].filter(Boolean).join("\n");
33884
+ const prompt = [field2.title ?? id2, field2.description].filter(Boolean).join("\n");
33254
33885
  const choices = options(field2);
33255
- const optional2 = !schema.required?.includes(id);
33886
+ const optional2 = !schema.required?.includes(id2);
33256
33887
  if (choices)
33257
33888
  return {
33258
- id,
33889
+ id: id2,
33259
33890
  type: "choice",
33260
33891
  prompt,
33261
33892
  options: choices,
@@ -33264,7 +33895,7 @@ function elicitationForm(context) {
33264
33895
  optional: optional2
33265
33896
  };
33266
33897
  return {
33267
- id,
33898
+ id: id2,
33268
33899
  type: "text",
33269
33900
  prompt,
33270
33901
  multiline: field2.type === "string",
@@ -33277,26 +33908,26 @@ function elicitationForm(context) {
33277
33908
  if (response.cancelled)
33278
33909
  return { action: "cancel" };
33279
33910
  const content = /* @__PURE__ */ Object.create(null);
33280
- for (const [id, field2] of Object.entries(schema.properties)) {
33281
- 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] ?? [] : [];
33282
33913
  if (!values.length)
33283
33914
  continue;
33284
33915
  const value = values[0] ?? "";
33285
33916
  if (field2.type === "array") {
33286
33917
  if (field2.minItems !== void 0 && values.length < field2.minItems || field2.maxItems !== void 0 && values.length > field2.maxItems)
33287
33918
  throw new Error("The number of choices is outside the native form's limits.");
33288
- content[id] = values;
33919
+ content[id2] = values;
33289
33920
  continue;
33290
33921
  }
33291
33922
  if (field2.type === "boolean") {
33292
- content[id] = value === "true";
33923
+ content[id2] = value === "true";
33293
33924
  continue;
33294
33925
  }
33295
33926
  if (field2.type === "number" || field2.type === "integer") {
33296
33927
  const number4 = Number(value);
33297
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)
33298
33929
  throw new Error("The number is outside the native form's limits.");
33299
- content[id] = number4;
33930
+ content[id2] = number4;
33300
33931
  continue;
33301
33932
  }
33302
33933
  if (field2.type === "string") {
@@ -33307,7 +33938,7 @@ function elicitationForm(context) {
33307
33938
  if (!valid)
33308
33939
  throw new Error("The text does not match the native form's format.");
33309
33940
  }
33310
- content[id] = value;
33941
+ content[id2] = value;
33311
33942
  }
33312
33943
  }
33313
33944
  return { action: "accept", content };
@@ -33453,10 +34084,10 @@ var CopilotInteractions = class {
33453
34084
  });
33454
34085
  }
33455
34086
  cancel(turnId) {
33456
- for (const [id, pending] of this.pending) {
34087
+ for (const [id2, pending] of this.pending) {
33457
34088
  if (turnId !== void 0 && pending.interaction.turnId !== turnId)
33458
34089
  continue;
33459
- this.pending.delete(id);
34090
+ this.pending.delete(id2);
33460
34091
  pending.reject(new Error("Copilot interaction cancelled"));
33461
34092
  this.emit({
33462
34093
  kind: "event",
@@ -33504,7 +34135,7 @@ function nativeFileChanges(data) {
33504
34135
  // dist/projection.js
33505
34136
  var OUTPUT_LIMIT = 256 * 1024;
33506
34137
  var clip = (text) => text.slice(0, OUTPUT_LIMIT);
33507
- var itemId = (id) => hostItemIdSchema.parse(id);
34138
+ var itemId = (id2) => hostItemIdSchema.parse(id2);
33508
34139
  var nativeFailure = {
33509
34140
  code: "nativeFailure",
33510
34141
  message: "Copilot reported a native failure.",
@@ -33536,8 +34167,8 @@ var CopilotItems = class {
33536
34167
  this.emit = emit;
33537
34168
  }
33538
34169
  get items() {
33539
- return this.order.flatMap((id) => {
33540
- const item = this.snapshots.get(id);
34170
+ return this.order.flatMap((id2) => {
34171
+ const item = this.snapshots.get(id2);
33541
34172
  return item ? [item] : [];
33542
34173
  });
33543
34174
  }
@@ -33548,24 +34179,24 @@ var CopilotItems = class {
33548
34179
  this.order.push(item.itemId);
33549
34180
  this.emit({ type: "item.started", turnId: this.turnId, item: structuredClone(item) });
33550
34181
  }
33551
- finish(id, outcome) {
33552
- const item = this.active.get(id);
34182
+ finish(id2, outcome) {
34183
+ const item = this.active.get(id2);
33553
34184
  if (!item)
33554
34185
  return;
33555
- this.active.delete(id);
34186
+ this.active.delete(id2);
33556
34187
  const snapshot = { item: structuredClone(item), outcome };
33557
- this.snapshots.set(id, snapshot);
34188
+ this.snapshots.set(id2, snapshot);
33558
34189
  this.emit({ type: "item.completed", turnId: this.turnId, snapshot });
33559
34190
  }
33560
34191
  finishAll(outcome) {
33561
- for (const id of this.active.keys())
33562
- this.finish(id, outcome);
34192
+ for (const id2 of this.active.keys())
34193
+ this.finish(id2, outcome);
33563
34194
  }
33564
- text(id, text, type, full, phase) {
33565
- if (this.snapshots.has(id))
34195
+ text(id2, text, type, full, phase) {
34196
+ if (this.snapshots.has(id2))
33566
34197
  return;
33567
- this.start({ type, itemId: itemId(id), text: "" });
33568
- const item = this.active.get(id);
34198
+ this.start({ type, itemId: itemId(id2), text: "" });
34199
+ const item = this.active.get(id2);
33569
34200
  if (!item || item.type !== "agentMessage" && item.type !== "reasoning")
33570
34201
  return;
33571
34202
  if (item.type === "agentMessage" && (phase === "commentary" || phase === "final_answer"))
@@ -33584,7 +34215,7 @@ var CopilotItems = class {
33584
34215
  update: { type: "text.append", text: append }
33585
34216
  });
33586
34217
  if (full)
33587
- this.finish(id, { status: "succeeded" });
34218
+ this.finish(id2, { status: "succeeded" });
33588
34219
  }
33589
34220
  accept(event) {
33590
34221
  if (event.agentId)
@@ -33696,14 +34327,14 @@ var CopilotItems = class {
33696
34327
  this.finish(data.toolCallId, succeeded ? { status: "succeeded" } : { status: "failed", error: nativeFailure });
33697
34328
  const changes = nativeFileChanges(data);
33698
34329
  if (changes.length) {
33699
- const id = itemId(`files-${data.toolCallId}`);
34330
+ const id2 = itemId(`files-${data.toolCallId}`);
33700
34331
  this.start({
33701
34332
  type: "fileChange",
33702
- itemId: id,
34333
+ itemId: id2,
33703
34334
  changes,
33704
34335
  sourceItemIds: [itemId(data.toolCallId)]
33705
34336
  });
33706
- this.finish(id, { status: "succeeded" });
34337
+ this.finish(id2, { status: "succeeded" });
33707
34338
  }
33708
34339
  break;
33709
34340
  }
@@ -33878,11 +34509,11 @@ var CopilotUsageTelemetry = class {
33878
34509
  call.receipt = receipt;
33879
34510
  return this.consume(call);
33880
34511
  }
33881
- entry(id) {
33882
- let call = this.calls.get(id);
34512
+ entry(id2) {
34513
+ let call = this.calls.get(id2);
33883
34514
  if (!call) {
33884
34515
  call = {};
33885
- this.calls.set(id, call);
34516
+ this.calls.set(id2, call);
33886
34517
  }
33887
34518
  if (this.calls.size > 2048) {
33888
34519
  const oldest = this.calls.entries().next().value;
@@ -34047,7 +34678,7 @@ var CopilotHarnessSession = class {
34047
34678
  try {
34048
34679
  await bounded(client.start());
34049
34680
  if (this.input.kind === "create" && this.input.model)
34050
- requireModel(await readModels(client), modelId2(this.input.model));
34681
+ requireModel(await readModels(client), this.input.model.id);
34051
34682
  if (this.input.kind === "resume") {
34052
34683
  if ((await bounded(client.rpc.sessions.checkInUse({ sessionIds: [this.nativeId] }))).inUse.includes(this.nativeId))
34053
34684
  throw new CopilotOperationError("sessionBusy", "Copilot session is owned by another native process.");
@@ -34060,32 +34691,32 @@ var CopilotHarnessSession = class {
34060
34691
  onPermissionRequest: (request) => {
34061
34692
  if (!this.active || this.closed || this.active.cancelling)
34062
34693
  return Promise.resolve({ kind: "user-not-available" });
34063
- const active = this.active;
34064
- return active.identity.promise.then(() => {
34065
- 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)
34066
34697
  return { kind: "user-not-available" };
34067
- return this.interactions.permission(active.id, request);
34698
+ return this.interactions.permission(active2.id, request);
34068
34699
  });
34069
34700
  },
34070
34701
  onUserInputRequest: (request) => {
34071
34702
  if (!this.active || this.closed || this.active.cancelling)
34072
34703
  return Promise.reject(new Error("Copilot has no active question context"));
34073
- const active = this.active;
34074
- return active.identity.promise.then(() => {
34075
- 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)
34076
34707
  throw new Error("Copilot question context ended");
34077
- return this.interactions.question(active.id, request);
34708
+ return this.interactions.question(active2.id, request);
34078
34709
  });
34079
34710
  },
34080
34711
  onElicitationRequest: async (request) => {
34081
- const active = this.active;
34082
- if (!active || this.closed || active.cancelling)
34712
+ const active2 = this.active;
34713
+ if (!active2 || this.closed || active2.cancelling)
34083
34714
  return { action: "cancel" };
34084
- await active.identity.promise;
34085
- if (this.active !== active || this.closed || active.cancelling)
34715
+ await active2.identity.promise;
34716
+ if (this.active !== active2 || this.closed || active2.cancelling)
34086
34717
  return { action: "cancel" };
34087
34718
  try {
34088
- return await this.interactions.elicitation(active.id, request);
34719
+ return await this.interactions.elicitation(active2.id, request);
34089
34720
  } catch (error51) {
34090
34721
  this.fault(error51, "interaction");
34091
34722
  return { action: "cancel" };
@@ -34100,7 +34731,7 @@ var CopilotHarnessSession = class {
34100
34731
  const session = this.input.kind === "resume" ? await bounded(client.resumeSession(this.nativeId, { ...handlers, allowTranscriptRecovery: false })) : await bounded(client.createSession({
34101
34732
  ...handlers,
34102
34733
  sessionId: this.nativeId,
34103
- ...this.input.model ? { model: modelId2(this.input.model) } : {}
34734
+ ...this.input.model ? { model: this.input.model.id } : {}
34104
34735
  }));
34105
34736
  this.session = session;
34106
34737
  if (this.input.kind === "resume" && session.transcriptRecovery)
@@ -34126,7 +34757,7 @@ var CopilotHarnessSession = class {
34126
34757
  }
34127
34758
  if (this.input.kind === "create" && (this.input.model || this.input.thinkingOptionId)) {
34128
34759
  const current = await bounded(session.rpc.model.getCurrent());
34129
- const requestedModel = this.input.model ? modelId2(this.input.model) : current.modelId;
34760
+ const requestedModel = this.input.model?.id ?? current.modelId;
34130
34761
  if (!requestedModel)
34131
34762
  throw new CopilotOperationError("invalidState", "Copilot has not confirmed a Model.");
34132
34763
  const models = await readModels(client, session);
@@ -34176,14 +34807,14 @@ var CopilotHarnessSession = class {
34176
34807
  throw error51;
34177
34808
  }
34178
34809
  }
34179
- startTurn(id) {
34180
- this.usageTelemetry.begin(id);
34810
+ startTurn(id2) {
34811
+ this.usageTelemetry.begin(id2);
34181
34812
  const identity3 = Promise.withResolvers();
34182
34813
  void identity3.promise.catch(() => {
34183
34814
  });
34184
34815
  return {
34185
- id,
34186
- items: new CopilotItems(id, (event) => this.emit(event)),
34816
+ id: id2,
34817
+ items: new CopilotItems(id2, (event) => this.emit(event)),
34187
34818
  cancelling: false,
34188
34819
  accepted: false,
34189
34820
  identity: identity3,
@@ -34243,13 +34874,13 @@ var CopilotHarnessSession = class {
34243
34874
  if (this.retiredMessages.has(event.data.messageId))
34244
34875
  return;
34245
34876
  if (!this.active) {
34246
- const id = hostTurnIdSchema.parse(randomUUID3());
34247
- this.active = this.startTurn(id);
34877
+ const id2 = hostTurnIdSchema.parse(randomUUID3());
34878
+ this.active = this.startTurn(id2);
34248
34879
  this.active.accepted = true;
34249
34880
  this.active.identity.resolve(void 0);
34250
34881
  this.emit({
34251
34882
  type: "turn.autonomous.started",
34252
- turnId: id,
34883
+ turnId: id2,
34253
34884
  input: visibleInput(event)
34254
34885
  });
34255
34886
  }
@@ -34314,15 +34945,15 @@ var CopilotHarnessSession = class {
34314
34945
  this.background.invalidate();
34315
34946
  void this.background.refresh(this.session).catch((error51) => this.fault(error51));
34316
34947
  }
34317
- const active = this.active;
34318
- if (!active.accepted) {
34948
+ const active2 = this.active;
34949
+ if (!active2.accepted) {
34319
34950
  this.active = void 0;
34320
- 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"));
34321
34952
  return;
34322
34953
  }
34323
- if (active.cancelling && !event.data.aborted)
34954
+ if (active2.cancelling && !event.data.aborted)
34324
34955
  throw new Error("Copilot did not confirm cancellation");
34325
- 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")) };
34326
34957
  this.finish(outcome);
34327
34958
  void this.refreshUsage().catch(() => {
34328
34959
  });
@@ -34333,23 +34964,23 @@ var CopilotHarnessSession = class {
34333
34964
  }
34334
34965
  }
34335
34966
  finish(outcome) {
34336
- const active = this.active;
34337
- if (!active)
34967
+ const active2 = this.active;
34968
+ if (!active2)
34338
34969
  return;
34339
- clearTimeout(active.timer);
34340
- this.interactions.cancel(active.id);
34341
- if (!active.accepted) {
34342
- 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"));
34343
34974
  this.active = void 0;
34344
34975
  return;
34345
34976
  }
34346
- active.items.finishAll(outcome);
34347
- for (const id of active.items.completedIds())
34348
- this.retiredItems.add(id);
34349
- if (active.messageId)
34350
- this.retiredMessages.add(active.messageId);
34351
- for (const id of active.aliases)
34352
- 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);
34353
34984
  while (this.retiredItems.size > 4096)
34354
34985
  this.retiredItems.delete(this.retiredItems.values().next().value ?? "");
34355
34986
  while (this.retiredMessages.size > 128)
@@ -34357,8 +34988,8 @@ var CopilotHarnessSession = class {
34357
34988
  this.active = void 0;
34358
34989
  this.emit({
34359
34990
  type: "turn.completed",
34360
- turnId: active.id,
34361
- ...active.messageId ? { nativeTurnRef: turnRef(this.nativeId, active.messageId) } : {},
34991
+ turnId: active2.id,
34992
+ ...active2.messageId ? { nativeTurnRef: turnRef(this.nativeId, active2.messageId) } : {},
34362
34993
  outcome
34363
34994
  });
34364
34995
  }
@@ -34415,21 +35046,21 @@ var CopilotHarnessSession = class {
34415
35046
  return failure("invalidState", "Copilot has not accepted this Turn yet.");
34416
35047
  if (this.active.cancelling)
34417
35048
  return { ok: true, value: { cancellationRequested: true } };
34418
- const active = this.active;
34419
- active.cancelling = true;
34420
- active.timer = setTimeout(() => {
34421
- if (this.active === active)
35049
+ const active2 = this.active;
35050
+ active2.cancelling = true;
35051
+ active2.timer = setTimeout(() => {
35052
+ if (this.active === active2)
34422
35053
  this.fault(new Error("Copilot cancellation timed out"), "turn.cancel");
34423
35054
  }, 3e4);
34424
35055
  try {
34425
35056
  if (!this.session)
34426
35057
  throw new Error("Copilot session is not initialized");
34427
35058
  await bounded(this.session.abort());
34428
- if (this.active === active)
34429
- this.interactions.cancel(active.id);
35059
+ if (this.active === active2)
35060
+ this.interactions.cancel(active2.id);
34430
35061
  return { ok: true, value: { cancellationRequested: true } };
34431
35062
  } catch (error51) {
34432
- if (this.active === active)
35063
+ if (this.active === active2)
34433
35064
  this.fault(error51, "turn.cancel");
34434
35065
  return { ok: false, error: nativeError(error51, "turn.cancel") };
34435
35066
  }
@@ -34448,34 +35079,34 @@ var CopilotHarnessSession = class {
34448
35079
  if (!session || !client)
34449
35080
  throw new Error("Copilot session is not initialized");
34450
35081
  if (command.type === "turn.start") {
34451
- const id = hostTurnIdSchema.parse(command.turnId);
34452
- const active = this.startTurn(id);
34453
- this.active = active;
35082
+ const id2 = hostTurnIdSchema.parse(command.turnId);
35083
+ const active2 = this.startTurn(id2);
35084
+ this.active = active2;
34454
35085
  try {
34455
35086
  this.sending = [];
34456
35087
  this.sendingBytes = 0;
34457
35088
  this.draftCleanupNeeded = false;
34458
35089
  const messageId = await bounded(session.send({ prompt: command.input.map((part) => part.text).join("\n\n") }));
34459
- active.expectedMessageId = messageId;
35090
+ active2.expectedMessageId = messageId;
34460
35091
  const buffered = this.sending;
34461
35092
  this.sending = void 0;
34462
35093
  for (const event of buffered)
34463
35094
  this.receive(event);
34464
- await bounded(active.identity.promise);
35095
+ await bounded(active2.identity.promise);
34465
35096
  } catch (error51) {
34466
35097
  this.sending = void 0;
34467
- if (this.active === active)
35098
+ if (this.active === active2)
34468
35099
  this.fault(error51, "turn.start");
34469
- if (!active.accepted)
35100
+ if (!active2.accepted)
34470
35101
  return { ok: false, error: nativeError(error51, "turn.start") };
34471
35102
  }
34472
- return { ok: true, value: { turnId: id } };
35103
+ return { ok: true, value: { turnId: id2 } };
34473
35104
  }
34474
35105
  this.configurationRevision++;
34475
35106
  if (command.type === "model.select") {
34476
- const id = modelId2(command.model);
34477
- requireModel(await readModels(client, session), id);
34478
- await bounded(session.setModel(id));
35107
+ const id2 = command.model.id;
35108
+ requireModel(await readModels(client, session), id2);
35109
+ await bounded(session.setModel(id2));
34479
35110
  }
34480
35111
  if (command.type === "thinking.select") {
34481
35112
  const current = await session.rpc.model.getCurrent();
@@ -34692,9 +35323,9 @@ function projectCopilotAccount(quota) {
34692
35323
  // dist/account.js
34693
35324
  var CACHE_MS = 15e3;
34694
35325
  var identity2 = (auth) => JSON.stringify([auth.authType, auth.host, auth.login]);
34695
- async function deleteDraft(client, id) {
35326
+ async function deleteDraft(client, id2) {
34696
35327
  try {
34697
- await bounded(client.deleteSession(id), 5e3);
35328
+ await bounded(client.deleteSession(id2), 5e3);
34698
35329
  } catch (error51) {
34699
35330
  if (nativeError(error51).code !== "sessionNotFound")
34700
35331
  throw error51;
@@ -34786,9 +35417,9 @@ var CopilotAccount = class {
34786
35417
  });
34787
35418
  if (client) {
34788
35419
  if (ownedId) {
34789
- const id = ownedId;
34790
- await deleteDraft(client, id).then(() => {
34791
- this.pendingDrafts.delete(id);
35420
+ const id2 = ownedId;
35421
+ await deleteDraft(client, id2).then(() => {
35422
+ this.pendingDrafts.delete(id2);
34792
35423
  }).catch(() => {
34793
35424
  result = null;
34794
35425
  });
@@ -34833,9 +35464,9 @@ var CopilotAccount = class {
34833
35464
  this.client = client;
34834
35465
  try {
34835
35466
  await bounded(client.start(), 8e3);
34836
- for (const id of this.pendingDrafts) {
34837
- await deleteDraft(client, id);
34838
- this.pendingDrafts.delete(id);
35467
+ for (const id2 of this.pendingDrafts) {
35468
+ await deleteDraft(client, id2);
35469
+ this.pendingDrafts.delete(id2);
34839
35470
  }
34840
35471
  } finally {
34841
35472
  await bounded(client.forceStop(), 5e3);
@@ -34875,11 +35506,13 @@ var permissionModes = harnessPermissionModeCatalogSchema.parse({
34875
35506
  });
34876
35507
  var CopilotAdapter = class {
34877
35508
  environment;
35509
+ normalizeStoredModelRef = normalizeStoredCopilotModelRef;
34878
35510
  harnessId = copilotId;
34879
35511
  sessions = /* @__PURE__ */ new Map();
34880
35512
  clients = /* @__PURE__ */ new Set();
34881
35513
  inspections = /* @__PURE__ */ new Map();
34882
35514
  inspectionsInFlight = /* @__PURE__ */ new Map();
35515
+ inspectionTasks = /* @__PURE__ */ new Set();
34883
35516
  closed = false;
34884
35517
  account;
34885
35518
  constructor(environment) {
@@ -34903,15 +35536,26 @@ var CopilotAdapter = class {
34903
35536
  };
34904
35537
  const cwd = path6.resolve(input.cwd ?? this.environment.HOME ?? process.cwd());
34905
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
+ }
34906
35545
  if (pending)
34907
35546
  return pending;
34908
35547
  const cached2 = this.inspections.get(cwd);
34909
- if (!input.refresh && cached2)
35548
+ if (cached2)
34910
35549
  return cached2;
34911
- this.inspections.delete(cwd);
34912
- 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
+ });
34913
35555
  this.inspectionsInFlight.set(cwd, inspection);
35556
+ this.inspectionTasks.add(inspection);
34914
35557
  return inspection.finally(() => {
35558
+ this.inspectionTasks.delete(inspection);
34915
35559
  if (this.inspectionsInFlight.get(cwd) === inspection)
34916
35560
  this.inspectionsInFlight.delete(cwd);
34917
35561
  });
@@ -34978,8 +35622,6 @@ var CopilotAdapter = class {
34978
35622
  status: "unavailable",
34979
35623
  error: { code: "invalidState", message: "Copilot Adapter is closed.", retryable: false }
34980
35624
  };
34981
- if (result.status === "ready")
34982
- this.inspections.set(cwd, result);
34983
35625
  return result;
34984
35626
  }
34985
35627
  async open(input) {
@@ -35073,7 +35715,7 @@ var CopilotAdapter = class {
35073
35715
  const ids = (values) => rootMessages(values).map((event) => event.data.messageId);
35074
35716
  if (JSON.stringify(ids(actual)) !== JSON.stringify(ids(expected)))
35075
35717
  throw new Error("Copilot Fork returned the wrong history prefix");
35076
- 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 }) => ({
35077
35719
  input: input2,
35078
35720
  items,
35079
35721
  outcome
@@ -35177,7 +35819,7 @@ var CopilotAdapter = class {
35177
35819
  this.account.close(),
35178
35820
  ...[...this.clients].map((client) => client.forceStop())
35179
35821
  ]);
35180
- await Promise.allSettled([...this.inspectionsInFlight.values()]);
35822
+ await Promise.allSettled(this.inspectionTasks);
35181
35823
  this.inspectionsInFlight.clear();
35182
35824
  if (results.some((result) => result.status === "rejected"))
35183
35825
  throw new Error("Copilot sessions could not all be closed; retry close.");