@codexhost/cli-win32-x64 0.33.0 → 0.35.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 (122) hide show
  1. package/README.md +2 -1
  2. package/app/codexhost-distribution.json +1 -1
  3. package/app/console-server.mjs +670 -116
  4. package/app/console-web.js +2032 -309
  5. package/app/desktop-controller.mjs +621 -74
  6. package/app/desktop-mcp-client.mjs +619 -0
  7. package/app/host-runtime.mjs +7134 -3865
  8. package/app/plugins/antigravity/plugin.mjs +1411 -121
  9. package/app/plugins/claude-code/plugin.mjs +527 -70
  10. package/app/plugins/codebuddy/plugin.mjs +592 -98
  11. package/app/plugins/codex-usage/plugin.mjs +659 -74
  12. package/app/plugins/copilot/plugin.mjs +527 -72
  13. package/app/plugins/cursor-cli/plugin.mjs +527 -70
  14. package/app/plugins/deepseek-harness/plugin.mjs +527 -70
  15. package/app/plugins/devin/plugin.mjs +527 -70
  16. package/app/plugins/enabled.json +1 -0
  17. package/app/plugins/grok/plugin.mjs +580 -92
  18. package/app/plugins/hermes/plugin.mjs +526 -69
  19. package/app/plugins/kimi-code/plugin.mjs +527 -70
  20. package/app/plugins/kiro-cli/plugin.mjs +527 -70
  21. package/app/plugins/omp/plugin.mjs +1338 -301
  22. package/app/plugins/opencode/plugin.mjs +527 -70
  23. package/app/plugins/pi/plugin.mjs +527 -70
  24. package/app/plugins/qoder/plugin.mjs +528 -71
  25. package/app/plugins/qoder-cn/plugin.mjs +528 -71
  26. package/app/plugins/qwen-code/plugin.mjs +526 -69
  27. package/app/plugins/workbuddy/plugin.mjs +1231 -546
  28. package/app/plugins/workbuddy-cn/assets/icon.svg +27 -0
  29. package/app/plugins/workbuddy-cn/manifest.json +32 -0
  30. package/app/plugins/workbuddy-cn/plugin.mjs +36524 -0
  31. package/app/plugins/zcode/plugin.mjs +528 -70
  32. package/app/renderer-extension.js +3898 -478
  33. package/app/web/assets/{abnfDiagram-XWFEHMT6-VnfRaHM6.js → abnfDiagram-XWFEHMT6-CGkBtBVj.js} +1 -1
  34. package/app/web/assets/{architectureDiagram-CSQXQB3N-BA1ehtvi.js → architectureDiagram-CSQXQB3N-Byv-cZeH.js} +1 -1
  35. package/app/web/assets/{blockDiagram-BEDRHYPZ-31BZSfd4.js → blockDiagram-BEDRHYPZ-DjLzUtwg.js} +1 -1
  36. package/app/web/assets/{c4Diagram-M2UUVUY5-CNzGWc5k.js → c4Diagram-M2UUVUY5-CJlsb6QO.js} +1 -1
  37. package/app/web/assets/{chunk-2Q5K7J3B-ahAIR-NM.js → chunk-2Q5K7J3B-CWm537bw.js} +1 -1
  38. package/app/web/assets/{chunk-3GCGMST5-BIV5YeRJ.js → chunk-3GCGMST5-NpcInIx4.js} +1 -1
  39. package/app/web/assets/{chunk-5VM5RSS4-CluTMPJG.js → chunk-5VM5RSS4-CeyyP0dm.js} +1 -1
  40. package/app/web/assets/{chunk-7U7NFRK5-4NIQuFbE.js → chunk-7U7NFRK5-Bto5OgbF.js} +1 -1
  41. package/app/web/assets/{chunk-CNRTWJTD-_0bEfGn3.js → chunk-CNRTWJTD-CuRMFCjT.js} +1 -1
  42. package/app/web/assets/{chunk-D5HYT7QG-_kTC6f8F.js → chunk-D5HYT7QG-DtQM1-2k.js} +1 -1
  43. package/app/web/assets/{chunk-EBZ3SEQC-CykaYOrL.js → chunk-EBZ3SEQC-DbUb3ZJ4.js} +2 -2
  44. package/app/web/assets/{chunk-JWPE2WC7-3vVOQ_py.js → chunk-JWPE2WC7-Dxh3d9Ag.js} +1 -1
  45. package/app/web/assets/{chunk-KTR4FSNJ-aVg5vgrm.js → chunk-KTR4FSNJ-BfwavXUO.js} +1 -1
  46. package/app/web/assets/{chunk-XXDRQBXY-_gVwGeSp.js → chunk-XXDRQBXY-CxR1flID.js} +1 -1
  47. package/app/web/assets/{classDiagram-v2-KXABOMEV-fI1LfeBf.js → classDiagram-v2-KXABOMEV-2WV2q_X2.js} +1 -1
  48. package/app/web/assets/{cose-bilkent-JH36ORCC-DFXMlWov.js → cose-bilkent-JH36ORCC-C-ENrCL_.js} +1 -1
  49. package/app/web/assets/{cynefin-EF2NZ3EQ-lZy7X6FO.js → cynefin-EF2NZ3EQ-Bg5LeTZO.js} +1 -1
  50. package/app/web/assets/{cynefinDiagram-NJNITYFG-N4DwFSW1.js → cynefinDiagram-NJNITYFG-CRAdbGGt.js} +1 -1
  51. package/app/web/assets/{dagre-KIHZ2IZ3-B7-8baTH.js → dagre-KIHZ2IZ3-dNHEvUqL.js} +1 -1
  52. package/app/web/assets/{diagram-7YQZDPLS-DLfjiBXV.js → diagram-7YQZDPLS-7F4O37o5.js} +1 -1
  53. package/app/web/assets/{diagram-QBROCOUO-CQnRzSTi.js → diagram-QBROCOUO-B-5KpeI2.js} +1 -1
  54. package/app/web/assets/{diagram-RJJCUUZO-DPnxazRT.js → diagram-RJJCUUZO-DqDsyDaL.js} +1 -1
  55. package/app/web/assets/{diagram-WERXNKYE-BBuEFRvD.js → diagram-WERXNKYE-f1oaPKos.js} +1 -1
  56. package/app/web/assets/{diagram-YHHI257C-BQ92JNJs.js → diagram-YHHI257C-DVMtl9Bt.js} +1 -1
  57. package/app/web/assets/{diagram-YR4HJLHV-Ce6BQO3J.js → diagram-YR4HJLHV-BWFCNFFF.js} +1 -1
  58. package/app/web/assets/{ebnfDiagram-N527522P-DYknE2Jy.js → ebnfDiagram-N527522P-B4N7d-Bi.js} +1 -1
  59. package/app/web/assets/{elk-O5DQBFGD-4S6_JJFF.js → elk-O5DQBFGD-DRdfF_UQ.js} +1 -1
  60. package/app/web/assets/{erDiagram-K3K3BIDK-DRtF7JVQ.js → erDiagram-K3K3BIDK-BW4-_5sZ.js} +1 -1
  61. package/app/web/assets/{flowDiagram-Z6JWZHQI-7Ho8CyR9.js → flowDiagram-Z6JWZHQI-DIQa5yEv.js} +1 -1
  62. package/app/web/assets/{ganttDiagram-3PRQTZWP-CW8Ig5y4.js → ganttDiagram-3PRQTZWP-JBK9PM7A.js} +1 -1
  63. package/app/web/assets/{gitGraphDiagram-VXDFKS5L-CzS8Xg2D.js → gitGraphDiagram-VXDFKS5L-TPI9Su0g.js} +1 -1
  64. package/app/web/assets/{grid-E2QIVN74-Cq284lCe.js → grid-E2QIVN74-DmHbunuP.js} +1 -1
  65. package/app/web/assets/index-BKDmniRf.js +209 -0
  66. package/app/web/assets/index-BPMnQdGr.css +1 -0
  67. package/app/web/assets/{infoDiagram-EZ3ZOAHP-BZgN6qlY.js → infoDiagram-EZ3ZOAHP-BeFwO9PI.js} +1 -1
  68. package/app/web/assets/{ishikawaDiagram-S3EKX5GW-BH9YHc-1.js → ishikawaDiagram-S3EKX5GW-BTbrKF_p.js} +1 -1
  69. package/app/web/assets/{journeyDiagram-POQNLL5X-D50KYOLe.js → journeyDiagram-POQNLL5X-DR0yWxJi.js} +1 -1
  70. package/app/web/assets/{kanban-definition-BH5XI6FM-Crw_5mMP.js → kanban-definition-BH5XI6FM-DMHrC9oV.js} +1 -1
  71. package/app/web/assets/{mermaid.core-o2Qjrppc.js → mermaid.core-Brmc1kJw.js} +4 -4
  72. package/app/web/assets/{mindmap-definition-WVAN44T4-B_bEbpAH.js → mindmap-definition-WVAN44T4-NT_XVwlI.js} +1 -1
  73. package/app/web/assets/{pegDiagram-D4NLKWP3-VecAHoyw.js → pegDiagram-D4NLKWP3-K67_THcc.js} +1 -1
  74. package/app/web/assets/{pieDiagram-36ENHN4W-o3ei2T-6.js → pieDiagram-36ENHN4W-GlTgKnTi.js} +1 -1
  75. package/app/web/assets/{quadrantDiagram-ZQUDMS73-DHndOAcn.js → quadrantDiagram-ZQUDMS73-yMEZ6-Nr.js} +1 -1
  76. package/app/web/assets/{railroadDiagram-JIZHGYPL-DRd_lfii.js → railroadDiagram-JIZHGYPL-MXCqwbuq.js} +1 -1
  77. package/app/web/assets/{render-VIF2ZAQL-awM3hUqB.js → render-VIF2ZAQL-BRUlhHPG.js} +2 -2
  78. package/app/web/assets/{requirementDiagram-AXW2TVFA-Ce1ePsOe.js → requirementDiagram-AXW2TVFA-Dqx4p0Bz.js} +1 -1
  79. package/app/web/assets/{sankeyDiagram-FBCJTAIF-cP-LtgW-.js → sankeyDiagram-FBCJTAIF-COp3IWvs.js} +1 -1
  80. package/app/web/assets/{sequenceDiagram-3LA2ROMG-C3JStTuW.js → sequenceDiagram-3LA2ROMG-j1xwrmp8.js} +1 -1
  81. package/app/web/assets/{sizeCapture-2Q2CQKSF-Dyyelr9K.js → sizeCapture-2Q2CQKSF-ZEXdxLeY.js} +1 -1
  82. package/app/web/assets/{stateDiagram-v2-ATKHQDJO-DkYRBVTd.js → stateDiagram-v2-ATKHQDJO-2pt2L-Zd.js} +1 -1
  83. package/app/web/assets/{swimlanes-YQL5WMAO-B2FwJU5_.js → swimlanes-YQL5WMAO-BHpgfPPd.js} +1 -1
  84. package/app/web/assets/swimlanesDiagram-UCCPES4V-BrYKheZO.js +8 -0
  85. package/app/web/assets/{timeline-definition-7Z437IG3-Di-qRIIi.js → timeline-definition-7Z437IG3-Cw4F_3FM.js} +1 -1
  86. package/app/web/assets/{usecaseDiagram-RDK6N6HP-yAImn62t.js → usecaseDiagram-RDK6N6HP-DefiMBIg.js} +1 -1
  87. package/app/web/assets/{vennDiagram-SHRQU5PJ-BEv8jpfv.js → vennDiagram-SHRQU5PJ-D30EMFrI.js} +1 -1
  88. package/app/web/assets/{wardleyDiagram-F3OXNVQS-7irksA0b.js → wardleyDiagram-F3OXNVQS-4ok25PKp.js} +1 -1
  89. package/app/web/assets/{xychartDiagram-GDYJKCDI-BokJGG2y.js → xychartDiagram-GDYJKCDI-BB0uAQX5.js} +1 -1
  90. package/app/web/codexhost-settings.js +429 -159
  91. package/app/web/index.html +2 -2
  92. package/app/web/plugins/deepseek-ai__dsh-api-gateway/client.js +1 -1
  93. package/app/web/plugins/deepseek-ai__dsh-api-remotes/client.js +63 -63
  94. package/app/web/plugins/deepseek-ai__dsh-api-session-controller/client.js +70 -70
  95. package/app/web/plugins/deepseek-ai__dsh-client-file-upload/client.js +1 -1
  96. package/app/web/plugins/deepseek-ai__dsh-client-ui-chat/client.js +75 -75
  97. package/app/web/plugins/deepseek-ai__dsh-client-ui-codexhost/client.js +172 -77
  98. package/app/web/plugins/deepseek-ai__dsh-client-ui-conversation/client.js +104 -100
  99. package/app/web/plugins/deepseek-ai__dsh-client-ui-model-selection/client.js +65 -65
  100. package/app/web/plugins/deepseek-ai__dsh-client-ui-session/client.js +1 -1
  101. package/app/web/plugins/deepseek-ai__dsh-client-ui-settings-general/client.js +5 -5
  102. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-documentpreview/client.js +6 -6
  103. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-documentpreview/client.pdf.js +1 -1
  104. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-right/client.js +62 -62
  105. package/app/web/plugins/deepseek-ai__dsh-client-ui-tool/client.js +72 -72
  106. package/app/web/plugins/deepseek-ai__dsh-client-ui-workspace/client.js +70 -70
  107. package/app/web/plugins.json +1 -0
  108. package/app/web/role-avatars/builtin/advisor-otter.webp +0 -0
  109. package/app/web/role-avatars/builtin/builder-otter.webp +0 -0
  110. package/app/web/role-avatars/builtin/sailor-otter.webp +0 -0
  111. package/app/web/role-avatars/builtin/wizard-otter.webp +0 -0
  112. package/app/web-modules/server.mjs +7262 -2970
  113. package/bin/codexhost.exe +0 -0
  114. package/libexec/codexhost-node-repl.exe +0 -0
  115. package/libexec/codexhost-screenshot.exe +0 -0
  116. package/libexec/codexhost-shell.exe +0 -0
  117. package/libexec/codexhost-shim.exe +0 -0
  118. package/libexec/codexhost-updater.exe +0 -0
  119. package/package.json +1 -1
  120. package/app/web/assets/index-CINZ6P-q.css +0 -1
  121. package/app/web/assets/index-CvV6veuY.js +0 -208
  122. package/app/web/assets/swimlanesDiagram-UCCPES4V-BkMsxCPb.js +0 -8
@@ -828,10 +828,10 @@ function mergeDefs(...defs) {
828
828
  function cloneDef(schema) {
829
829
  return mergeDefs(schema._zod.def);
830
830
  }
831
- function getElementAtPath(obj, path13) {
832
- if (!path13)
831
+ function getElementAtPath(obj, path14) {
832
+ if (!path14)
833
833
  return obj;
834
- return path13.reduce((acc, key) => acc?.[key], obj);
834
+ return path14.reduce((acc, key) => acc?.[key], obj);
835
835
  }
836
836
  function promiseAllObject(promisesObj) {
837
837
  const keys = Object.keys(promisesObj);
@@ -1171,11 +1171,11 @@ function explicitlyAborted(x, startIndex = 0) {
1171
1171
  }
1172
1172
  return false;
1173
1173
  }
1174
- function prefixIssues(path13, issues) {
1174
+ function prefixIssues(path14, issues) {
1175
1175
  return issues.map((iss) => {
1176
1176
  var _a3;
1177
1177
  (_a3 = iss).path ?? (_a3.path = []);
1178
- iss.path.unshift(path13);
1178
+ iss.path.unshift(path14);
1179
1179
  return iss;
1180
1180
  });
1181
1181
  }
@@ -1637,16 +1637,16 @@ function flattenError(error62, mapper = (issue2) => issue2.message) {
1637
1637
  }
1638
1638
  function formatError(error62, mapper = (issue2) => issue2.message) {
1639
1639
  const fieldErrors = { _errors: [] };
1640
- const processError = (error63, path13 = []) => {
1640
+ const processError = (error63, path14 = []) => {
1641
1641
  for (const issue2 of error63.issues) {
1642
1642
  if (issue2.code === "invalid_union" && issue2.errors.length) {
1643
- issue2.errors.map((issues) => processError({ issues }, [...path13, ...issue2.path]));
1643
+ issue2.errors.map((issues) => processError({ issues }, [...path14, ...issue2.path]));
1644
1644
  } else if (issue2.code === "invalid_key") {
1645
- processError({ issues: issue2.issues }, [...path13, ...issue2.path]);
1645
+ processError({ issues: issue2.issues }, [...path14, ...issue2.path]);
1646
1646
  } else if (issue2.code === "invalid_element") {
1647
- processError({ issues: issue2.issues }, [...path13, ...issue2.path]);
1647
+ processError({ issues: issue2.issues }, [...path14, ...issue2.path]);
1648
1648
  } else {
1649
- const fullpath = [...path13, ...issue2.path];
1649
+ const fullpath = [...path14, ...issue2.path];
1650
1650
  if (fullpath.length === 0) {
1651
1651
  fieldErrors._errors.push(mapper(issue2));
1652
1652
  } else {
@@ -1685,17 +1685,17 @@ function formatError(error62, mapper = (issue2) => issue2.message) {
1685
1685
  }
1686
1686
  function treeifyError(error62, mapper = (issue2) => issue2.message) {
1687
1687
  const result = { errors: [] };
1688
- const processError = (error63, path13 = []) => {
1688
+ const processError = (error63, path14 = []) => {
1689
1689
  var _a3;
1690
1690
  for (const issue2 of error63.issues) {
1691
1691
  if (issue2.code === "invalid_union" && issue2.errors.length) {
1692
- issue2.errors.map((issues) => processError({ issues }, [...path13, ...issue2.path]));
1692
+ issue2.errors.map((issues) => processError({ issues }, [...path14, ...issue2.path]));
1693
1693
  } else if (issue2.code === "invalid_key") {
1694
- processError({ issues: issue2.issues }, [...path13, ...issue2.path]);
1694
+ processError({ issues: issue2.issues }, [...path14, ...issue2.path]);
1695
1695
  } else if (issue2.code === "invalid_element") {
1696
- processError({ issues: issue2.issues }, [...path13, ...issue2.path]);
1696
+ processError({ issues: issue2.issues }, [...path14, ...issue2.path]);
1697
1697
  } else {
1698
- const fullpath = [...path13, ...issue2.path];
1698
+ const fullpath = [...path14, ...issue2.path];
1699
1699
  if (fullpath.length === 0) {
1700
1700
  result.errors.push(mapper(issue2));
1701
1701
  continue;
@@ -1734,8 +1734,8 @@ function treeifyError(error62, mapper = (issue2) => issue2.message) {
1734
1734
  }
1735
1735
  function toDotPath(_path) {
1736
1736
  const segs = [];
1737
- const path13 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
1738
- for (const seg of path13) {
1737
+ const path14 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
1738
+ for (const seg of path14) {
1739
1739
  if (typeof seg === "number")
1740
1740
  segs.push(`[${seg}]`);
1741
1741
  else if (typeof seg === "symbol")
@@ -18873,13 +18873,13 @@ function resolveRef(ref, ctx) {
18873
18873
  if (!ref.startsWith("#")) {
18874
18874
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
18875
18875
  }
18876
- const path13 = ref.slice(1).split("/").filter(Boolean);
18877
- if (path13.length === 0) {
18876
+ const path14 = ref.slice(1).split("/").filter(Boolean);
18877
+ if (path14.length === 0) {
18878
18878
  return ctx.rootSchema;
18879
18879
  }
18880
18880
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
18881
- if (path13[0] === defsKey) {
18882
- const key = path13[1] === void 0 ? void 0 : decodeJSONPointerSegment(path13[1]);
18881
+ if (path14[0] === defsKey) {
18882
+ const key = path14[1] === void 0 ? void 0 : decodeJSONPointerSegment(path14[1]);
18883
18883
  if (!key || !ctx.defs[key]) {
18884
18884
  throw new Error(`Reference not found: ${ref}`);
18885
18885
  }
@@ -19748,26 +19748,51 @@ var jsonPrimitiveSchema = external_exports.union([
19748
19748
  external_exports.boolean(),
19749
19749
  external_exports.null()
19750
19750
  ]);
19751
- function hasNoCircularReferences(value) {
19752
- const ancestors = /* @__PURE__ */ new WeakSet();
19753
- const stack = [{ value, leaving: false }];
19751
+ function isPlainObject2(value) {
19752
+ const prototype = Object.getPrototypeOf(value);
19753
+ return prototype === Object.prototype || prototype === null;
19754
+ }
19755
+ var JSON_VALIDATION_LEAVE = /* @__PURE__ */ Symbol("json-validation-leave");
19756
+ function isValidJsonValue(value) {
19757
+ if (value === null || typeof value === "string" || typeof value === "boolean" || typeof value === "number" && Number.isFinite(value)) {
19758
+ return true;
19759
+ }
19760
+ if (typeof value !== "object")
19761
+ return false;
19762
+ const ancestors = /* @__PURE__ */ new Set();
19763
+ const stack = [value];
19754
19764
  try {
19755
19765
  while (stack.length > 0) {
19756
- const frame = stack.pop();
19757
- if (!frame)
19758
- break;
19759
- if (frame.leaving) {
19760
- ancestors.delete(frame.value);
19766
+ const current = stack.pop();
19767
+ if (current === JSON_VALIDATION_LEAVE) {
19768
+ ancestors.delete(stack.pop());
19761
19769
  continue;
19762
19770
  }
19763
- if (typeof frame.value !== "object" || frame.value === null)
19771
+ if (current === null || typeof current === "string" || typeof current === "boolean" || typeof current === "number" && Number.isFinite(current)) {
19764
19772
  continue;
19765
- if (ancestors.has(frame.value))
19773
+ }
19774
+ if (typeof current !== "object")
19775
+ return false;
19776
+ if (ancestors.has(current))
19766
19777
  return false;
19767
- ancestors.add(frame.value);
19768
- stack.push({ value: frame.value, leaving: true });
19769
- for (const child of Object.values(frame.value)) {
19770
- stack.push({ value: child, leaving: false });
19778
+ if (Array.isArray(current)) {
19779
+ ancestors.add(current);
19780
+ stack.push(current, JSON_VALIDATION_LEAVE);
19781
+ for (let index = current.length - 1; index >= 0; index -= 1) {
19782
+ stack.push(current[index]);
19783
+ }
19784
+ continue;
19785
+ }
19786
+ if (!isPlainObject2(current))
19787
+ return false;
19788
+ ancestors.add(current);
19789
+ stack.push(current, JSON_VALIDATION_LEAVE);
19790
+ for (const key in current) {
19791
+ if (Object.hasOwn(current, key)) {
19792
+ if (key === "__proto__")
19793
+ return false;
19794
+ stack.push(current[key]);
19795
+ }
19771
19796
  }
19772
19797
  }
19773
19798
  } catch {
@@ -19775,17 +19800,11 @@ function hasNoCircularReferences(value) {
19775
19800
  }
19776
19801
  return true;
19777
19802
  }
19778
- var nonCircularSchema = external_exports.custom(hasNoCircularReferences, {
19779
- message: "JSON value must not contain circular references"
19780
- });
19781
- var recursiveJsonValueSchema = external_exports.lazy(() => external_exports.union([
19782
- jsonPrimitiveSchema,
19783
- external_exports.array(recursiveJsonValueSchema),
19784
- external_exports.record(external_exports.string(), recursiveJsonValueSchema)
19785
- ]));
19786
- var jsonValueSchema = nonCircularSchema.pipe(recursiveJsonValueSchema);
19787
- var jsonArraySchema = nonCircularSchema.pipe(external_exports.array(recursiveJsonValueSchema));
19788
- var jsonObjectSchema = nonCircularSchema.pipe(external_exports.record(external_exports.string(), recursiveJsonValueSchema));
19803
+ var jsonValueSchema = external_exports.custom(isValidJsonValue, {
19804
+ message: "Invalid JSON value"
19805
+ });
19806
+ var jsonArraySchema = external_exports.custom((value) => Array.isArray(value) && isValidJsonValue(value), { message: "Invalid JSON array" });
19807
+ var jsonObjectSchema = external_exports.custom((value) => typeof value === "object" && value !== null && !Array.isArray(value) && isValidJsonValue(value), { message: "Invalid JSON object" });
19789
19808
 
19790
19809
  // ../../shared-contracts/dist/errors.js
19791
19810
  var codexhostErrorSchema = external_exports.strictObject({
@@ -19918,7 +19937,11 @@ var BUILTIN_ROLE_AVATAR_IDS = [
19918
19937
  "security-otter",
19919
19938
  "audio-otter",
19920
19939
  "scholar-otter",
19921
- "data-otter"
19940
+ "data-otter",
19941
+ "advisor-otter",
19942
+ "builder-otter",
19943
+ "wizard-otter",
19944
+ "sailor-otter"
19922
19945
  ];
19923
19946
  var builtinRoleAvatarSchema = external_exports.templateLiteral([
19924
19947
  "builtin:",
@@ -20684,7 +20707,7 @@ var desktopExtensionSettingFieldSchema = external_exports.discriminatedUnion("ty
20684
20707
  default: external_exports.string().optional()
20685
20708
  })
20686
20709
  ]).superRefine((field2, ctx) => {
20687
- const issue2 = (path13, message) => ctx.addIssue({ code: "custom", path: [path13], message });
20710
+ const issue2 = (path14, message) => ctx.addIssue({ code: "custom", path: [path14], message });
20688
20711
  if (field2.type === "number" || field2.type === "range") {
20689
20712
  const { min = -Infinity, max = Infinity, default: value } = field2;
20690
20713
  if (min > max)
@@ -20790,16 +20813,16 @@ var hostExtensionIdSchema = desktopExtensionIdSchema.refine((id2) => !reservedNa
20790
20813
  var hostExtensionTargetSchema = external_exports.enum(["desktop", "web"]);
20791
20814
  var hostExtensionDigestSchema = desktopExtensionHashSchema;
20792
20815
  var hostExtensionActivationIdSchema = external_exports.uuid();
20793
- 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((path13) => path13.split("/").length <= 32, "Extension resources may be at most 32 segments deep");
20816
+ 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((path14) => path14.split("/").length <= 32, "Extension resources may be at most 32 segments deep");
20794
20817
  var legacy = desktopExtensionManifestSchema.shape;
20795
20818
  var localized = (max, min = 0) => external_exports.strictObject({
20796
20819
  en: external_exports.string().trim().min(min).max(max),
20797
20820
  "zh-CN": external_exports.string().trim().min(min).max(max)
20798
20821
  });
20799
- var resourceWithSuffix = (suffix) => hostExtensionResourcePathSchema.refine((path13) => path13.endsWith(suffix), `Expected a ${suffix} file`);
20822
+ var resourceWithSuffix = (suffix) => hostExtensionResourcePathSchema.refine((path14) => path14.endsWith(suffix), `Expected a ${suffix} file`);
20800
20823
  var moduleEntry = resourceWithSuffix(".mjs");
20801
20824
  var style = resourceWithSuffix(".css").optional();
20802
- var hostExtensionCanonicalPath = (path13) => path13.normalize("NFC").toLowerCase();
20825
+ var hostExtensionCanonicalPath = (path14) => path14.normalize("NFC").toLowerCase();
20803
20826
  var hostExtensionManifestV2Schema = external_exports.strictObject({
20804
20827
  manifestVersion: external_exports.literal(2),
20805
20828
  id: hostExtensionIdSchema,
@@ -20809,8 +20832,8 @@ var hostExtensionManifestV2Schema = external_exports.strictObject({
20809
20832
  details: localized(16384).optional(),
20810
20833
  author: legacy.author,
20811
20834
  repository: legacy.repository,
20812
- icon: legacy.icon.refine((path13) => path13 === void 0 || hostExtensionResourcePathSchema.safeParse(path13).success),
20813
- screenshots: legacy.screenshots.refine((paths) => paths === void 0 || paths.every((path13) => hostExtensionResourcePathSchema.safeParse(path13).success)),
20835
+ icon: legacy.icon.refine((path14) => path14 === void 0 || hostExtensionResourcePathSchema.safeParse(path14).success),
20836
+ screenshots: legacy.screenshots.refine((paths) => paths === void 0 || paths.every((path14) => hostExtensionResourcePathSchema.safeParse(path14).success)),
20814
20837
  categories: legacy.categories,
20815
20838
  settingsSchema: legacy.settingsSchema,
20816
20839
  slots: legacy.slots.removeDefault().optional(),
@@ -20905,6 +20928,7 @@ var hostExtensionCatalogEntrySchema = external_exports.object({
20905
20928
  backend: external_exports.int().positive().optional()
20906
20929
  }),
20907
20930
  downloadUrl: downloadUrl.refine((url2) => url2.startsWith("https://"), "Expected HTTPS"),
20931
+ downloads7d: external_exports.number().int().min(0).optional(),
20908
20932
  featured: external_exports.boolean().optional(),
20909
20933
  featuredOrder: external_exports.int().nonnegative().optional(),
20910
20934
  changelog: external_exports.array(hostExtensionChangelogEntrySchema).max(20).optional()
@@ -20936,7 +20960,7 @@ var active = {
20936
20960
  digest: hostExtensionDigestSchema
20937
20961
  };
20938
20962
  var optionalActivation = { ...id, activationId: active.activationId.optional() };
20939
- var filePath = external_exports.string().min(1).max(4096).refine((path13) => /^(?:\/|[a-z]:[/\\])/iu.test(path13) && !path13.includes("\0") && !path13.split(/[/\\]/u).some((part) => part === "." || part === ".."), "Expected an absolute local path without dot segments");
20963
+ var filePath = external_exports.string().min(1).max(4096).refine((path14) => /^(?:\/|[a-z]:[/\\])/iu.test(path14) && !path14.includes("\0") && !path14.split(/[/\\]/u).some((part) => part === "." || part === ".."), "Expected an absolute local path without dot segments");
20940
20964
  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");
20941
20965
  function base643(maxBytes) {
20942
20966
  return external_exports.string().max(4 * Math.ceil(maxBytes / 3)).refine((value) => {
@@ -20974,24 +20998,42 @@ var hostExtensionInstallationSchema = external_exports.strictObject({
20974
20998
  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);
20975
20999
  var desktopConflict = { desktopConflictWith: hostExtensionIdSchema.optional() };
20976
21000
  var backendState = external_exports.enum(["none", "inactive", "starting", "running", "failed"]);
21001
+ var HOST_EXTENSION_OPERATION_ERROR_MAX_LENGTH = 512;
21002
+ var hostExtensionOperationStatusSchema = external_exports.discriminatedUnion("state", [
21003
+ external_exports.object({
21004
+ state: external_exports.literal("updating"),
21005
+ targetVersion: external_exports.string().trim().min(1).max(128).optional(),
21006
+ startedAt: external_exports.iso.datetime()
21007
+ }),
21008
+ external_exports.object({
21009
+ state: external_exports.literal("failed"),
21010
+ targetVersion: external_exports.string().trim().min(1).max(128).optional(),
21011
+ startedAt: external_exports.iso.datetime(),
21012
+ updatedAt: external_exports.iso.datetime(),
21013
+ error: external_exports.string().min(1).max(HOST_EXTENSION_OPERATION_ERROR_MAX_LENGTH),
21014
+ interruptedByShutdown: external_exports.boolean().optional()
21015
+ })
21016
+ ]);
20977
21017
  var hostExtensionListItemSchema = external_exports.discriminatedUnion("state", [
20978
- hostExtensionInstallationSchema.extend({
21018
+ external_exports.object({
21019
+ ...hostExtensionInstallationSchema.shape,
20979
21020
  state: external_exports.literal("valid"),
20980
21021
  enabled: external_exports.boolean(),
20981
21022
  ...desktopConflict,
20982
21023
  iconDataUrl: rasterDataUrlSchema(DESKTOP_EXTENSION_ICON_MAX_BYTES).optional(),
20983
21024
  screenshotDataUrls: external_exports.array(rasterDataUrlSchema(DESKTOP_EXTENSION_SCREENSHOT_MAX_BYTES)).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).optional(),
20984
21025
  backendState: backendState.optional(),
20985
- backendError: external_exports.string().optional()
21026
+ backendError: external_exports.string().optional(),
21027
+ operation: hostExtensionOperationStatusSchema.optional()
20986
21028
  }),
20987
- external_exports.strictObject({
21029
+ external_exports.object({
20988
21030
  state: external_exports.enum(["invalid", "incompatible"]),
20989
21031
  id: external_exports.string().min(1),
20990
21032
  enabled: external_exports.boolean(),
20991
21033
  error: external_exports.string()
20992
21034
  })
20993
21035
  ]);
20994
- var hostExtensionsListResultSchema = external_exports.strictObject({
21036
+ var hostExtensionsListResultSchema = external_exports.object({
20995
21037
  revision: hostExtensionRevisionSchema,
20996
21038
  configuration: hostExtensionConfigurationSchema,
20997
21039
  diagnostics: external_exports.array(external_exports.string()),
@@ -21030,7 +21072,10 @@ var methods = new Set(HOST_EXTENSION_MANAGEMENT_METHODS);
21030
21072
  var noParams = external_exports.strictObject({});
21031
21073
  var expectedRevision = { expectedRevision: hostExtensionRevisionSchema };
21032
21074
  var selection = external_exports.strictObject({ ...id, ...expectedRevision });
21033
- var installationResult = hostExtensionInstallationSchema.extend({ replaced: external_exports.boolean() });
21075
+ var installationResult = external_exports.object({
21076
+ ...hostExtensionInstallationSchema.shape,
21077
+ replaced: external_exports.boolean()
21078
+ });
21034
21079
  var mutationResult = external_exports.discriminatedUnion("state", [
21035
21080
  external_exports.strictObject({ state: external_exports.literal("saved"), configuration: hostExtensionConfigurationSchema }),
21036
21081
  external_exports.strictObject({ state: external_exports.literal("revision-conflict"), revision: hostExtensionRevisionSchema })
@@ -21059,7 +21104,12 @@ var hostExtensionSettingsSchema = external_exports.strictObject({
21059
21104
  values: jsonObjectSchema
21060
21105
  });
21061
21106
  var hostExtensionsRpcSchemas = {
21062
- [HOST_EXTENSIONS_RPC.list]: { params: noParams, result: hostExtensionsListResultSchema },
21107
+ [HOST_EXTENSIONS_RPC.list]: {
21108
+ params: external_exports.object({
21109
+ includeOperations: external_exports.boolean().optional()
21110
+ }),
21111
+ result: hostExtensionsListResultSchema
21112
+ },
21063
21113
  [HOST_EXTENSIONS_RPC.snapshot]: { params: noParams, result: hostExtensionsSnapshotResultSchema },
21064
21114
  [HOST_EXTENSIONS_RPC.catalog]: {
21065
21115
  params: external_exports.strictObject({
@@ -21085,6 +21135,7 @@ var hostExtensionsRpcSchemas = {
21085
21135
  ...id,
21086
21136
  expectedDigest: active.digest,
21087
21137
  expectedActivationId: active.activationId.optional(),
21138
+ expectedVersion: external_exports.string().trim().min(1).max(128).optional(),
21088
21139
  source: hostExtensionInstallSourceSchema.optional()
21089
21140
  }),
21090
21141
  result: installationResult
@@ -21134,8 +21185,39 @@ var hostExtensionsRpcSchemas = {
21134
21185
  };
21135
21186
 
21136
21187
  // ../../shared-contracts/dist/group-chat.js
21137
- var DEFAULT_GROUP_MAX_AGENT_HOPS = 5;
21138
- var MAX_GROUP_AGENT_HOPS = 20;
21188
+ var GROUP_MEMORY_MAX_BYTES = 4096;
21189
+ var DEFAULT_GROUP_MAX_AGENT_HOPS = 10;
21190
+ var MAX_GROUP_AGENT_HOPS = 200;
21191
+ var GROUP_NOTICE_MAX_LENGTH = 2e3;
21192
+ var cachedUtf8Encoder;
21193
+ function groupUtf8ByteLength(text3) {
21194
+ if (cachedUtf8Encoder === void 0) {
21195
+ cachedUtf8Encoder = typeof TextEncoder === "function" ? new TextEncoder() : null;
21196
+ }
21197
+ if (cachedUtf8Encoder !== null) {
21198
+ return cachedUtf8Encoder.encode(text3).length;
21199
+ }
21200
+ let bytes = 0;
21201
+ for (let i = 0; i < text3.length; i += 1) {
21202
+ const code = text3.charCodeAt(i);
21203
+ if (code <= 127) {
21204
+ bytes += 1;
21205
+ } else if (code <= 2047) {
21206
+ bytes += 2;
21207
+ } else if (code >= 55296 && code <= 56319 && i + 1 < text3.length) {
21208
+ const next = text3.charCodeAt(i + 1);
21209
+ if (next >= 56320 && next <= 57343) {
21210
+ bytes += 4;
21211
+ i += 1;
21212
+ } else {
21213
+ bytes += 3;
21214
+ }
21215
+ } else {
21216
+ bytes += 3;
21217
+ }
21218
+ }
21219
+ return bytes;
21220
+ }
21139
21221
  var remoteGroupRoomIdSchema = external_exports.string().regex(/^remote:[A-Za-z0-9_-]{8,512}$/u);
21140
21222
  var groupRoomIdSchema = external_exports.union([external_exports.uuidv4(), remoteGroupRoomIdSchema]);
21141
21223
  var groupMemberIdSchema = external_exports.uuidv4();
@@ -21144,7 +21226,7 @@ var groupUnmentionedPolicySchema = external_exports.enum(["none", "last_speaker"
21144
21226
  var groupMemberStatusSchema = external_exports.enum(["active", "muted", "removed"]);
21145
21227
  var nonnegativeInteger = external_exports.int().nonnegative();
21146
21228
  var positiveInteger = external_exports.int().positive();
21147
- var maxAgentHopsSchema = positiveInteger.max(MAX_GROUP_AGENT_HOPS);
21229
+ var maxAgentHopsSchema = nonnegativeInteger.max(MAX_GROUP_AGENT_HOPS);
21148
21230
  var nonblankString = external_exports.string().refine((value) => value.trim().length > 0);
21149
21231
  var timestamp = external_exports.iso.datetime();
21150
21232
  var optionalMemberEdits = {
@@ -21162,28 +21244,42 @@ var groupMemberSchema = external_exports.object({
21162
21244
  roleSnapshot: threadRoleSnapshotSchema.optional(),
21163
21245
  harnessId: harnessIdSchema,
21164
21246
  status: groupMemberStatusSchema,
21247
+ projectless: external_exports.boolean().optional(),
21248
+ showInSidebar: external_exports.boolean().optional(),
21165
21249
  joinedAtSeq: nonnegativeInteger,
21166
21250
  lastDeliveredSeq: nonnegativeInteger,
21167
21251
  lastRosterVersion: nonnegativeInteger,
21252
+ lastMemoryVersion: nonnegativeInteger.default(0),
21168
21253
  createdAt: timestamp
21169
21254
  });
21255
+ var groupProjectlessWorkspaceSchema = external_exports.object({
21256
+ workspaceRoot: nonblankString,
21257
+ outputDirectory: nonblankString
21258
+ });
21170
21259
  var groupRoomRemoteHostSchema = external_exports.object({
21171
21260
  hostId: nonblankString,
21172
21261
  displayName: nonblankString,
21173
21262
  state: nonblankString.optional(),
21174
21263
  color: external_exports.string().optional(),
21175
- filePreview: external_exports.boolean().optional()
21264
+ filePreview: external_exports.boolean().optional(),
21265
+ memberSidebarVisibility: external_exports.boolean().optional(),
21266
+ sharedMemory: external_exports.boolean().optional()
21176
21267
  });
21177
- var groupRoomSchema = external_exports.object({
21268
+ var groupRoomObjectSchema = external_exports.object({
21178
21269
  roomId: groupRoomIdSchema,
21179
21270
  title: nonblankString,
21180
21271
  defaultCwd: nonblankString,
21272
+ projectlessWorkspace: groupProjectlessWorkspaceSchema.optional(),
21181
21273
  unmentionedPolicy: groupUnmentionedPolicySchema.default("none"),
21274
+ unmentionedMemberId: groupMemberIdSchema.optional(),
21182
21275
  allowAgentMentions: external_exports.boolean().default(true),
21183
21276
  maxAgentHops: maxAgentHopsSchema.default(DEFAULT_GROUP_MAX_AGENT_HOPS),
21277
+ relayHopLimit: maxAgentHopsSchema.optional(),
21184
21278
  lastSeq: nonnegativeInteger,
21185
21279
  lastSpeakerMemberId: groupMemberIdSchema.optional(),
21186
21280
  rosterVersion: nonnegativeInteger,
21281
+ memoryVersion: nonnegativeInteger.default(0),
21282
+ memorySha256: external_exports.string().regex(/^[0-9a-f]{64}$/u).optional(),
21187
21283
  humanEpoch: nonnegativeInteger,
21188
21284
  relayPaused: external_exports.boolean(),
21189
21285
  pinned: external_exports.boolean(),
@@ -21191,7 +21287,14 @@ var groupRoomSchema = external_exports.object({
21191
21287
  updatedAt: timestamp,
21192
21288
  members: external_exports.array(groupMemberSchema),
21193
21289
  remote: groupRoomRemoteHostSchema.optional()
21194
- }).superRefine(({ members: members2 }, context) => {
21290
+ }).superRefine(({ members: members2, unmentionedPolicy, unmentionedMemberId }, context) => {
21291
+ if (unmentionedMemberId !== void 0 && unmentionedPolicy !== "none") {
21292
+ context.addIssue({
21293
+ code: "custom",
21294
+ path: ["unmentionedMemberId"],
21295
+ message: 'A default member can only be set when unmentionedPolicy is "none"'
21296
+ });
21297
+ }
21195
21298
  const handles = /* @__PURE__ */ new Set();
21196
21299
  for (const [index, { handle, status }] of members2.entries()) {
21197
21300
  if (status === "removed")
@@ -21206,6 +21309,15 @@ var groupRoomSchema = external_exports.object({
21206
21309
  handles.add(handle);
21207
21310
  }
21208
21311
  });
21312
+ var groupRoomSchema = external_exports.preprocess((value) => {
21313
+ if (typeof value === "object" && value !== null && !Array.isArray(value)) {
21314
+ const record6 = value;
21315
+ if (record6.unmentionedPolicy === "member" && record6.unmentionedMemberId !== void 0) {
21316
+ return { ...record6, unmentionedPolicy: "none" };
21317
+ }
21318
+ }
21319
+ return value;
21320
+ }, groupRoomObjectSchema);
21209
21321
  var groupAttachmentSchema = external_exports.object({
21210
21322
  kind: external_exports.enum(["image", "file"]),
21211
21323
  attachmentId: nonblankString.max(256),
@@ -21232,6 +21344,7 @@ var groupMessageSchema = external_exports.object({
21232
21344
  mentionedMemberIds: external_exports.array(groupMemberIdSchema),
21233
21345
  mentionAll: external_exports.boolean().optional(),
21234
21346
  hopCount: nonnegativeInteger,
21347
+ durationMs: nonnegativeInteger.optional(),
21235
21348
  createdAt: timestamp
21236
21349
  });
21237
21350
  var newThreadOptions = {
@@ -21258,8 +21371,12 @@ var GROUPS_DELETE_METHOD = "codexhost/groups/delete";
21258
21371
  var GROUPS_ADD_MEMBER_METHOD = "codexhost/groups/member/add";
21259
21372
  var GROUPS_UPDATE_MEMBER_METHOD = "codexhost/groups/member/update";
21260
21373
  var GROUPS_REMOVE_MEMBER_METHOD = "codexhost/groups/member/remove";
21374
+ var GROUPS_REBIND_MEMBER_METHOD = "codexhost/groups/member/rebind";
21261
21375
  var GROUPS_POST_MESSAGE_METHOD = "codexhost/groups/message/post";
21262
21376
  var GROUPS_READ_MESSAGES_METHOD = "codexhost/groups/messages/read";
21377
+ var GROUPS_READ_MEMORY_METHOD = "codexhost/groups/memory/read";
21378
+ var GROUPS_UPDATE_MEMORY_METHOD = "codexhost/groups/memory/update";
21379
+ var GROUPS_INSPECT_CWD_METHOD = "codexhost/groups/cwd/inspect";
21263
21380
  var roomIdentity = { roomId: groupRoomIdSchema };
21264
21381
  var memberIdentity = { ...roomIdentity, memberId: groupMemberIdSchema };
21265
21382
  var roomEdits = {
@@ -21282,15 +21399,24 @@ var groupsGetResultSchema = external_exports.object({
21282
21399
  });
21283
21400
  var groupsCreateParamsSchema = external_exports.strictObject({
21284
21401
  ...roomEdits,
21285
- defaultCwd: nonblankString,
21402
+ defaultCwd: nonblankString.optional(),
21286
21403
  members: external_exports.array(groupCreateMemberInputSchema)
21287
21404
  });
21288
21405
  var groupsCreateResultSchema = external_exports.object({ room: groupRoomSchema });
21289
21406
  var groupsUpdateParamsSchema = external_exports.strictObject({
21290
21407
  ...roomIdentity,
21291
21408
  ...roomEdits,
21409
+ unmentionedMemberId: groupMemberIdSchema.nullable().optional(),
21292
21410
  pinned: external_exports.boolean().optional(),
21293
21411
  relayPaused: external_exports.boolean().optional()
21412
+ }).superRefine(({ unmentionedPolicy, unmentionedMemberId }, context) => {
21413
+ if (unmentionedMemberId !== void 0 && unmentionedMemberId !== null && unmentionedPolicy !== void 0 && unmentionedPolicy !== "none") {
21414
+ context.addIssue({
21415
+ code: "custom",
21416
+ path: ["unmentionedMemberId"],
21417
+ message: 'A default member can only be set when unmentionedPolicy is "none"'
21418
+ });
21419
+ }
21294
21420
  });
21295
21421
  var groupsDeleteParamsSchema = external_exports.strictObject(roomIdentity);
21296
21422
  var groupsDeleteResultSchema = external_exports.object({ deleted: external_exports.boolean() });
@@ -21305,17 +21431,94 @@ var groupsAddMemberResultSchema = external_exports.object({
21305
21431
  var groupsUpdateMemberParamsSchema = external_exports.strictObject({
21306
21432
  ...memberIdentity,
21307
21433
  ...optionalMemberEdits,
21308
- status: groupMemberStatusSchema.optional()
21434
+ status: groupMemberStatusSchema.optional(),
21435
+ showInSidebar: external_exports.boolean().optional()
21309
21436
  });
21310
21437
  var groupsRemoveMemberParamsSchema = external_exports.strictObject(memberIdentity);
21438
+ var groupsRebindMemberParamsSchema = external_exports.strictObject({
21439
+ ...memberIdentity,
21440
+ threadId: hostThreadIdSchema,
21441
+ redeliverFrom: positiveInteger.optional(),
21442
+ note: external_exports.string().optional()
21443
+ });
21444
+ var groupCliRebindMemberParamsSchema = external_exports.strictObject({
21445
+ ...roomIdentity,
21446
+ memberId: groupMemberIdSchema.optional(),
21447
+ memberHandle: groupMemberHandleSchema.optional(),
21448
+ threadId: hostThreadIdSchema,
21449
+ redeliverFrom: positiveInteger.optional(),
21450
+ note: external_exports.string().optional()
21451
+ }).refine((value) => value.memberId !== void 0 !== (value.memberHandle !== void 0), "Provide exactly one of memberId or memberHandle");
21452
+ var groupsRebindMemberResultSchema = external_exports.object({
21453
+ room: groupRoomSchema,
21454
+ member: groupMemberSchema,
21455
+ previousThreadId: hostThreadIdSchema,
21456
+ awakened: external_exports.boolean()
21457
+ });
21458
+ var groupCliListMemberSchema = external_exports.object({
21459
+ memberId: groupMemberIdSchema,
21460
+ threadId: hostThreadIdSchema,
21461
+ handle: groupMemberHandleSchema,
21462
+ displayName: nonblankString,
21463
+ status: groupMemberStatusSchema,
21464
+ harnessId: harnessIdSchema,
21465
+ roleSlug: roleSlugSchema.optional(),
21466
+ roleName: nonblankString.optional()
21467
+ });
21468
+ var groupCliListEntrySchema = external_exports.object({
21469
+ roomId: groupRoomIdSchema,
21470
+ title: nonblankString,
21471
+ memberCount: nonnegativeInteger,
21472
+ updatedAt: timestamp,
21473
+ member: groupCliListMemberSchema.optional()
21474
+ });
21475
+ var groupCliListParamsSchema = external_exports.strictObject({
21476
+ threadId: hostThreadIdSchema.optional()
21477
+ });
21478
+ var groupCliListResultSchema = external_exports.object({
21479
+ rooms: external_exports.array(groupCliListEntrySchema)
21480
+ });
21311
21481
  var groupsPostMessageParamsSchema = external_exports.strictObject({
21312
21482
  ...roomIdentity,
21313
21483
  content: external_exports.string().max(64e3),
21314
21484
  attachments: external_exports.array(groupAttachmentSchema).max(12).optional(),
21315
21485
  replyToSeq: positiveInteger.optional(),
21316
21486
  targetMemberIds: external_exports.array(groupMemberIdSchema).optional(),
21317
- mentionAll: external_exports.boolean().optional()
21318
- }).refine((value) => value.content.trim().length > 0 || (value.attachments?.length ?? 0) > 0, "Message content or at least one attachment is required");
21487
+ mentionAll: external_exports.boolean().optional(),
21488
+ notice: external_exports.boolean().optional()
21489
+ }).superRefine((value, context) => {
21490
+ if (value.notice === true) {
21491
+ if (value.content.trim().length === 0) {
21492
+ context.addIssue({
21493
+ code: "custom",
21494
+ path: ["content"],
21495
+ message: "Notice content is required"
21496
+ });
21497
+ }
21498
+ if (value.content.length > GROUP_NOTICE_MAX_LENGTH) {
21499
+ context.addIssue({
21500
+ code: "custom",
21501
+ path: ["content"],
21502
+ message: `Notice content must be at most ${GROUP_NOTICE_MAX_LENGTH} characters`
21503
+ });
21504
+ }
21505
+ if ((value.targetMemberIds?.length ?? 0) > 0 || value.mentionAll === true || (value.attachments?.length ?? 0) > 0) {
21506
+ context.addIssue({
21507
+ code: "custom",
21508
+ path: ["notice"],
21509
+ message: "System notices cannot target members or include attachments"
21510
+ });
21511
+ }
21512
+ return;
21513
+ }
21514
+ if (value.content.trim().length === 0 && (value.attachments?.length ?? 0) === 0) {
21515
+ context.addIssue({
21516
+ code: "custom",
21517
+ path: ["content"],
21518
+ message: "Message content or at least one attachment is required"
21519
+ });
21520
+ }
21521
+ });
21319
21522
  var groupsPostMessageResultSchema = external_exports.object({
21320
21523
  room: groupRoomSchema,
21321
21524
  message: groupMessageSchema,
@@ -21332,6 +21535,31 @@ var groupsReadMessagesResultSchema = external_exports.object({
21332
21535
  messages: external_exports.array(groupMessageSchema),
21333
21536
  totalSeq: nonnegativeInteger
21334
21537
  });
21538
+ var groupsReadMemoryParamsSchema = external_exports.strictObject(roomIdentity);
21539
+ var groupsReadMemoryResultSchema = external_exports.object({
21540
+ ...roomIdentity,
21541
+ memoryVersion: nonnegativeInteger,
21542
+ content: external_exports.string(),
21543
+ updatedAt: timestamp
21544
+ });
21545
+ var groupsUpdateMemoryParamsSchema = external_exports.strictObject({
21546
+ ...roomIdentity,
21547
+ content: external_exports.string().refine((value) => groupUtf8ByteLength(value) <= GROUP_MEMORY_MAX_BYTES, `Shared room memory must be at most ${GROUP_MEMORY_MAX_BYTES} UTF-8 bytes`),
21548
+ expectedVersion: nonnegativeInteger.optional()
21549
+ });
21550
+ var groupsUpdateMemoryResultSchema = external_exports.object({
21551
+ room: groupRoomSchema,
21552
+ memoryVersion: nonnegativeInteger,
21553
+ content: external_exports.string(),
21554
+ updatedAt: timestamp
21555
+ });
21556
+ var groupsInspectCwdParamsSchema = external_exports.strictObject({
21557
+ cwd: nonblankString,
21558
+ roomId: groupRoomIdSchema.optional()
21559
+ });
21560
+ var groupsInspectCwdResultSchema = external_exports.object({
21561
+ isGitRepo: external_exports.boolean()
21562
+ });
21335
21563
 
21336
21564
  // ../../shared-contracts/dist/thread-archive-confirm.js
21337
21565
  var THREAD_ARCHIVE_CONFIRM_METHOD = "codexhost/thread/archive/confirm";
@@ -21378,6 +21606,7 @@ var TELEMETRY_OFFICIAL_HARNESSES = [
21378
21606
  "kiro-cli",
21379
21607
  "codebuddy",
21380
21608
  "workbuddy",
21609
+ "workbuddy-cn",
21381
21610
  "devin",
21382
21611
  "hermes",
21383
21612
  "qoder",
@@ -21459,6 +21688,149 @@ var nativeCodexGoalResultSchema = external_exports.object({
21459
21688
  }).nullable()
21460
21689
  });
21461
21690
 
21691
+ // ../../shared-contracts/dist/voice.js
21692
+ var VOICE_AUDIO_MAX_BYTES = 10 * 1024 * 1024;
21693
+ var VOICE_CONFIG_GET_METHOD = "codexhost/voice/config/get";
21694
+ var VOICE_CONFIG_SET_METHOD = "codexhost/voice/config/set";
21695
+ var voiceProviderModeSchema = external_exports.enum([
21696
+ "codex",
21697
+ "openai-compatible",
21698
+ "deepseek-asr",
21699
+ "openai-chat-audio"
21700
+ ]);
21701
+ var voiceAudioFormatSchema = external_exports.enum(["native", "wav"]);
21702
+ var SENSITIVE_VOICE_QUERY_PARAM = /(?:^|[_-])(?:key|token|secret|password|passwd|pwd|auth|authorization|credential|signature|sig)(?:$|[_-])|(?:api|access|auth|client|app|private|bearer)[_-]?(?:key|token|secret)/i;
21703
+ function isLoopbackVoiceHost(hostname3) {
21704
+ const bare = hostname3.trim().toLowerCase().replace(/^\[|\]$/g, "");
21705
+ if (bare === "localhost" || bare.endsWith(".localhost") || bare === "::1")
21706
+ return true;
21707
+ return /^127(?:\.(?:25[0-5]|2[0-4]\d|1?\d?\d)){3}$/.test(bare);
21708
+ }
21709
+ function isValidVoiceBaseUrl(value) {
21710
+ const trimmed = value.trim();
21711
+ if (!trimmed)
21712
+ return false;
21713
+ try {
21714
+ const parsed = new URL(trimmed);
21715
+ if (!parsed.hostname)
21716
+ return false;
21717
+ if (parsed.username !== "" || parsed.password !== "" || parsed.hash !== "")
21718
+ return false;
21719
+ if (parsed.protocol === "https:") {
21720
+ } else if (parsed.protocol === "http:") {
21721
+ if (!isLoopbackVoiceHost(parsed.hostname))
21722
+ return false;
21723
+ } else {
21724
+ return false;
21725
+ }
21726
+ for (const key of parsed.searchParams.keys()) {
21727
+ if (SENSITIVE_VOICE_QUERY_PARAM.test(key))
21728
+ return false;
21729
+ }
21730
+ return true;
21731
+ } catch {
21732
+ return false;
21733
+ }
21734
+ }
21735
+ var voiceBaseUrlSchema = external_exports.string().max(2048).refine((value) => value === "" || isValidVoiceBaseUrl(value), {
21736
+ message: "Base URL must be empty or a valid https:// URL (http:// is allowed only for localhost/127.0.0.1/[::1]) without embedded credentials"
21737
+ });
21738
+ var voiceProviderConfigSnapshotSchema = external_exports.object({
21739
+ baseUrl: voiceBaseUrlSchema,
21740
+ model: external_exports.string().max(256),
21741
+ hasApiKey: external_exports.boolean(),
21742
+ apiKeyHint: external_exports.string().max(64).optional(),
21743
+ apiKey: external_exports.never().optional()
21744
+ });
21745
+ var voiceConfigSnapshotSchema = external_exports.object({
21746
+ mode: voiceProviderModeSchema,
21747
+ baseUrl: voiceBaseUrlSchema,
21748
+ model: external_exports.string().max(256),
21749
+ hasApiKey: external_exports.boolean(),
21750
+ apiKeyHint: external_exports.string().max(64).optional(),
21751
+ apiKey: external_exports.never().optional(),
21752
+ audioFormat: voiceAudioFormatSchema.optional(),
21753
+ providers: external_exports.object({
21754
+ "openai-compatible": voiceProviderConfigSnapshotSchema,
21755
+ "deepseek-asr": voiceProviderConfigSnapshotSchema,
21756
+ "openai-chat-audio": voiceProviderConfigSnapshotSchema
21757
+ }).optional(),
21758
+ codexAvailable: external_exports.boolean(),
21759
+ available: external_exports.boolean()
21760
+ });
21761
+ var voiceConfigUpdateParamsSchema = external_exports.object({
21762
+ mode: voiceProviderModeSchema,
21763
+ baseUrl: external_exports.string().max(2048).optional(),
21764
+ model: external_exports.string().max(256).optional(),
21765
+ apiKey: external_exports.string().max(4096).nullable().optional()
21766
+ }).strict().superRefine((value, ctx) => {
21767
+ const trimmedBaseUrl = value.baseUrl?.trim() ?? "";
21768
+ const trimmedModel = value.model?.trim() ?? "";
21769
+ if (value.mode === "openai-compatible") {
21770
+ if (!isValidVoiceBaseUrl(trimmedBaseUrl)) {
21771
+ ctx.addIssue({
21772
+ code: external_exports.ZodIssueCode.custom,
21773
+ path: ["baseUrl"],
21774
+ message: "OpenAI-compatible mode requires a valid https:// base URL (http:// is allowed only for loopback hosts)"
21775
+ });
21776
+ }
21777
+ return;
21778
+ }
21779
+ if (value.mode === "openai-chat-audio") {
21780
+ if (!isValidVoiceBaseUrl(trimmedBaseUrl)) {
21781
+ ctx.addIssue({
21782
+ code: external_exports.ZodIssueCode.custom,
21783
+ path: ["baseUrl"],
21784
+ message: "Multimodal Chat Audio mode requires a valid https:// base URL (http:// is allowed only for loopback hosts)"
21785
+ });
21786
+ }
21787
+ if (!trimmedModel) {
21788
+ ctx.addIssue({
21789
+ code: external_exports.ZodIssueCode.custom,
21790
+ path: ["model"],
21791
+ message: "Multimodal Chat Audio mode requires a model name"
21792
+ });
21793
+ }
21794
+ return;
21795
+ }
21796
+ if (trimmedBaseUrl !== "" && !isValidVoiceBaseUrl(trimmedBaseUrl)) {
21797
+ ctx.addIssue({
21798
+ code: external_exports.ZodIssueCode.custom,
21799
+ path: ["baseUrl"],
21800
+ message: "Base URL must be empty or a valid https:// URL (http:// is allowed only for loopback hosts)"
21801
+ });
21802
+ }
21803
+ });
21804
+ var voiceAudioMimeTypeSchema = external_exports.string().regex(/^audio\/[a-z0-9.+-]+(?:\s*;[^\r\n]*)?$/i);
21805
+ var voiceStatusResultSchema = external_exports.object({
21806
+ available: external_exports.boolean(),
21807
+ audioFormat: voiceAudioFormatSchema.optional()
21808
+ });
21809
+ var voiceTranscribeParamsSchema = external_exports.object({ path: external_exports.string().min(1), mimeType: voiceAudioMimeTypeSchema }).strict();
21810
+ var voiceErrorCodeSchema = external_exports.enum([
21811
+ "credentials-unavailable",
21812
+ "login-expired",
21813
+ "rate-limited",
21814
+ "service-rejected",
21815
+ "host-incompatible",
21816
+ "network",
21817
+ "timeout",
21818
+ "audio-empty",
21819
+ "audio-too-large",
21820
+ "audio-format",
21821
+ "audio-invalid"
21822
+ ]);
21823
+ var voiceTranscribeResultSchema = external_exports.discriminatedUnion("ok", [
21824
+ external_exports.object({ ok: external_exports.literal(true), text: external_exports.string() }).strict(),
21825
+ external_exports.object({ ok: external_exports.literal(false), error: external_exports.object({ code: voiceErrorCodeSchema }).strict() }).strict()
21826
+ ]);
21827
+
21828
+ // ../../shared-contracts/dist/github-star.js
21829
+ var GITHUB_STAR_STATUS_METHOD = "codexhost/githubStar/status";
21830
+ var GITHUB_STAR_ADD_METHOD = "codexhost/githubStar/star";
21831
+ var githubStarParamsSchema = external_exports.object({}).strict();
21832
+ var githubStarStateSchema = external_exports.object({ ghAvailable: external_exports.boolean(), starred: external_exports.boolean() });
21833
+
21462
21834
  // ../../shared-contracts/dist/client-channel.js
21463
21835
  var CLIENT_CHANNEL_VERSION = 1;
21464
21836
  var CLIENT_REQUEST_LIMIT_BYTES = 128 * 1024 * 1024;
@@ -21517,10 +21889,16 @@ var CLIENT_CHANNEL_METHODS = [
21517
21889
  GROUPS_ADD_MEMBER_METHOD,
21518
21890
  GROUPS_UPDATE_MEMBER_METHOD,
21519
21891
  GROUPS_REMOVE_MEMBER_METHOD,
21892
+ GROUPS_REBIND_MEMBER_METHOD,
21520
21893
  GROUPS_POST_MESSAGE_METHOD,
21521
21894
  GROUPS_READ_MESSAGES_METHOD,
21895
+ GROUPS_READ_MEMORY_METHOD,
21896
+ GROUPS_UPDATE_MEMORY_METHOD,
21897
+ GROUPS_INSPECT_CWD_METHOD,
21522
21898
  "codexhost/voice/status",
21523
21899
  "codexhost/voice/transcribe",
21900
+ VOICE_CONFIG_GET_METHOD,
21901
+ VOICE_CONFIG_SET_METHOD,
21524
21902
  "codexhost/harness/display-settings/get",
21525
21903
  "codexhost/harness/display-settings/set",
21526
21904
  "codexhost/harness/display-settings/capabilities",
@@ -21586,6 +21964,8 @@ var CLIENT_CHANNEL_METHODS = [
21586
21964
  "codexhost/harness/session-import/list",
21587
21965
  "codexhost/harness/session-import/import",
21588
21966
  // Host settings shared across Desktop and Web.
21967
+ GITHUB_STAR_STATUS_METHOD,
21968
+ GITHUB_STAR_ADD_METHOD,
21589
21969
  ...HOST_EXTENSION_MANAGEMENT_METHODS,
21590
21970
  "codexhost/harness/installation",
21591
21971
  "codexhost/harness/installation/start",
@@ -21925,28 +22305,16 @@ var extensionActivitySchema = external_exports.strictObject({
21925
22305
  })).max(256)
21926
22306
  });
21927
22307
 
21928
- // ../../shared-contracts/dist/voice.js
21929
- var VOICE_AUDIO_MAX_BYTES = 10 * 1024 * 1024;
21930
- var voiceAudioMimeTypeSchema = external_exports.string().regex(/^audio\/[a-z0-9.+-]+(?:\s*;[^\r\n]*)?$/i);
21931
- var voiceStatusResultSchema = external_exports.object({ available: external_exports.boolean() }).strict();
21932
- var voiceTranscribeParamsSchema = external_exports.object({ path: external_exports.string().min(1), mimeType: voiceAudioMimeTypeSchema }).strict();
21933
- var voiceErrorCodeSchema = external_exports.enum([
21934
- "credentials-unavailable",
21935
- "login-expired",
21936
- "rate-limited",
21937
- "service-rejected",
21938
- "host-incompatible",
21939
- "network",
21940
- "timeout",
21941
- "audio-empty",
21942
- "audio-too-large",
21943
- "audio-format",
21944
- "audio-invalid"
21945
- ]);
21946
- var voiceTranscribeResultSchema = external_exports.discriminatedUnion("ok", [
21947
- external_exports.object({ ok: external_exports.literal(true), text: external_exports.string() }).strict(),
21948
- external_exports.object({ ok: external_exports.literal(false), error: external_exports.object({ code: voiceErrorCodeSchema }).strict() }).strict()
21949
- ]);
22308
+ // ../../shared-contracts/dist/host-extension-ranking.js
22309
+ var DAY_MS = 24 * 60 * 60 * 1e3;
22310
+ var CATEGORY_SEARCH_LABELS = Object.freeze({
22311
+ appearance: ["appearance", "外观主题"],
22312
+ interface: ["interface", "界面增强"],
22313
+ workflow: ["workflow", "效率与协作"],
22314
+ analytics: ["analytics", "数据与统计"],
22315
+ integrations: ["integrations", "外部集成"],
22316
+ tools: ["tools", "实用工具"]
22317
+ });
21950
22318
 
21951
22319
  // ../../shared-contracts/dist/skills.js
21952
22320
  var skillsListParamsSchema = external_exports.object({
@@ -22083,7 +22451,23 @@ var REMOTE_PEER_ID_PATTERN = /^[a-zA-Z0-9_-]{1,64}$/u;
22083
22451
  var remotePeerIdSchema = external_exports.string().regex(REMOTE_PEER_ID_PATTERN);
22084
22452
  var remotePeerNodeIdSchema = external_exports.string().regex(REMOTE_PEER_ID_PATTERN);
22085
22453
  var remotePeerHostIdSchema = external_exports.string().regex(/^remote-peer:[a-zA-Z0-9_-]{1,64}$/u);
22086
- var remotePeerTransportKindSchema = external_exports.enum(["relay", "tailscale", "lan", "custom"]);
22454
+ var remotePeerTransportKindSchema = external_exports.enum(["relay", "tailscale", "lan", "ssh", "custom"]);
22455
+ var remotePeerSshAuthModeSchema = external_exports.enum(["auto", "key", "password"]);
22456
+ var remotePeerSshConfigSchema = external_exports.object({
22457
+ host: external_exports.string().trim().min(1).max(255),
22458
+ port: external_exports.number().int().min(1).max(65535).optional(),
22459
+ user: external_exports.string().trim().min(1).max(128).optional(),
22460
+ identityFile: external_exports.string().trim().min(1).max(1024).optional(),
22461
+ authMode: remotePeerSshAuthModeSchema.default("auto"),
22462
+ remoteDataDir: external_exports.string().trim().min(1).max(1024).optional()
22463
+ });
22464
+ var remotePeerSshSummarySchema = external_exports.object({
22465
+ host: external_exports.string().min(1).max(255),
22466
+ port: external_exports.number().int().min(1).max(65535).optional(),
22467
+ user: external_exports.string().min(1).max(128).optional(),
22468
+ authMode: remotePeerSshAuthModeSchema,
22469
+ keyInstalled: external_exports.boolean().optional()
22470
+ });
22087
22471
  var REMOTE_PEER_COLORS = [
22088
22472
  "blue",
22089
22473
  "purple",
@@ -22110,6 +22494,7 @@ var remotePeerSummarySchema = external_exports.object({
22110
22494
  color: remotePeerColorSchema.optional(),
22111
22495
  origin: external_exports.string().min(1).max(2048),
22112
22496
  transportKind: remotePeerTransportKindSchema,
22497
+ ssh: remotePeerSshSummarySchema.optional(),
22113
22498
  encrypted: external_exports.boolean(),
22114
22499
  enabled: external_exports.boolean(),
22115
22500
  state: remotePeerStateSchema,
@@ -22238,7 +22623,13 @@ var remotePeerCapabilitiesSchema = external_exports.object({
22238
22623
  /** /api/peer/v1/delegation is available for fixed-whitelist cross-host delegation. */
22239
22624
  delegation: external_exports.literal(1).optional(),
22240
22625
  /** POST /api/peer/v1/peers is available. */
22241
- peerPairing: external_exports.literal(1).optional()
22626
+ peerPairing: external_exports.literal(1).optional(),
22627
+ /** Host supports includeOperations on extensions/list and expectedVersion on extensions/update. */
22628
+ extensionUpdateTracking: external_exports.literal(1).optional(),
22629
+ /** Peer supports per-member `showInSidebar` in `codexhost/groups/member/update`. */
22630
+ groupMemberSidebarVisibility: external_exports.literal(1).optional(),
22631
+ /** Peer supports `codexhost/groups/memory/read` and `codexhost/groups/memory/update`. */
22632
+ groupSharedMemory: external_exports.literal(1).optional()
22242
22633
  });
22243
22634
  var remotePeerManifestSchema = external_exports.object({
22244
22635
  version: external_exports.string().max(128),
@@ -22357,8 +22748,66 @@ var delegationHostHarnessOptionSchema = external_exports.object({
22357
22748
  var delegationHostHarnessesResultSchema = external_exports.object({
22358
22749
  harnesses: external_exports.array(delegationHostHarnessOptionSchema)
22359
22750
  });
22751
+ var sshConfigHostEntrySchema = external_exports.object({
22752
+ alias: external_exports.string().min(1).max(255),
22753
+ hostName: external_exports.string().max(255).optional(),
22754
+ user: external_exports.string().max(128).optional(),
22755
+ port: external_exports.number().int().min(1).max(65535).optional(),
22756
+ identityFile: external_exports.string().max(1024).optional()
22757
+ });
22758
+ var remotePeerListSshConfigHostsResultSchema = external_exports.object({
22759
+ hosts: external_exports.array(sshConfigHostEntrySchema)
22760
+ });
22761
+ var remotePeerSshConnectParamsSchema = external_exports.object({
22762
+ host: external_exports.string().trim().min(1).max(255),
22763
+ port: external_exports.number().int().min(1).max(65535).optional(),
22764
+ user: external_exports.string().trim().min(1).max(128).optional(),
22765
+ identityFile: external_exports.string().trim().min(1).max(1024).optional(),
22766
+ authMode: remotePeerSshAuthModeSchema.default("auto"),
22767
+ password: external_exports.string().max(1024).optional(),
22768
+ installAuthorizedKey: external_exports.boolean().optional(),
22769
+ name: external_exports.string().trim().min(1).max(120).optional(),
22770
+ color: remotePeerColorSchema.optional(),
22771
+ remoteDataDir: external_exports.string().trim().min(1).max(1024).optional(),
22772
+ sessionId: external_exports.string().min(1).max(128).optional()
22773
+ });
22774
+ var remotePeerSshTestResultSchema = external_exports.object({
22775
+ ok: external_exports.boolean(),
22776
+ codexhostInstalled: external_exports.boolean(),
22777
+ version: external_exports.string().max(128).optional(),
22778
+ nodeId: remotePeerNodeIdSchema.optional(),
22779
+ platform: external_exports.string().max(64).optional(),
22780
+ hostname: external_exports.string().max(255).optional(),
22781
+ latencyMs: external_exports.number().int().nonnegative().optional(),
22782
+ errorCode: external_exports.string().max(128).optional(),
22783
+ error: external_exports.string().max(1e3).optional()
22784
+ });
22785
+ var remotePeerSshInstallResultSchema = external_exports.object({
22786
+ ok: external_exports.boolean(),
22787
+ version: external_exports.string().max(128).optional(),
22788
+ message: external_exports.string().max(1e3).optional()
22789
+ });
22790
+ var remotePeerSshAuthPromptSchema = external_exports.object({
22791
+ promptId: external_exports.string().min(1).max(128),
22792
+ sessionId: external_exports.string().min(1).max(128).optional(),
22793
+ peerId: remotePeerIdSchema.optional(),
22794
+ host: external_exports.string().min(1).max(255),
22795
+ kind: external_exports.enum(["host-key", "password", "passphrase", "otp", "generic"]),
22796
+ prompt: external_exports.string().min(1).max(1e3),
22797
+ echo: external_exports.boolean()
22798
+ });
22799
+ var remotePeerSshRespondAuthParamsSchema = external_exports.object({
22800
+ promptId: external_exports.string().min(1).max(128),
22801
+ sessionId: external_exports.string().min(1).max(128).optional(),
22802
+ response: external_exports.string().max(1024).optional(),
22803
+ cancel: external_exports.boolean().optional()
22804
+ });
22360
22805
 
22361
22806
  // ../../shared-contracts/dist/peer-delegation.js
22807
+ var peerWatchNudgeParamsSchema = external_exports.strictObject({
22808
+ hostId: remotePeerHostIdSchema,
22809
+ threadId: external_exports.string().min(1).max(1024).optional()
22810
+ });
22362
22811
  var PEER_DELEGATION_BRIDGE_VERSION = 1;
22363
22812
  var PEER_DELEGATION_OPERATIONS = [
22364
22813
  "listHarnesses",
@@ -22542,11 +22991,12 @@ var delegationDefaultsSchema = external_exports.strictObject({
22542
22991
  byHarness: external_exports.record(preferenceHarnessKey, harnessDelegationDefaultSchema)
22543
22992
  });
22544
22993
  var modelId = external_exports.string().min(1).max(1024);
22545
- var harnessPreferenceValuesSchema = external_exports.strictObject({
22994
+ var harnessPreferenceValuesSchema = external_exports.object({
22546
22995
  idleRelease: idleReleaseSettingsSchema.optional(),
22547
22996
  favorites: external_exports.record(preferenceHarnessKey, external_exports.array(modelId).max(2048)).default({}),
22548
22997
  newThread: newThreadDefaultsSchema.optional(),
22549
- delegation: delegationDefaultsSchema.optional()
22998
+ delegation: delegationDefaultsSchema.optional(),
22999
+ showGroupChatsInSidebar: external_exports.boolean().optional()
22550
23000
  });
22551
23001
  var harnessPreferenceSnapshotSchema = external_exports.strictObject({
22552
23002
  scope: harnessPreferenceScopeSchema,
@@ -22579,6 +23029,10 @@ var harnessPreferenceOperationSchema = external_exports.discriminatedUnion("kind
22579
23029
  kind: external_exports.literal("delegation"),
22580
23030
  harnessId: harnessIdSchema,
22581
23031
  configuration: harnessDelegationDefaultSchema.nullable()
23032
+ }),
23033
+ external_exports.strictObject({
23034
+ kind: external_exports.literal("groupChatsSidebar"),
23035
+ visible: external_exports.boolean()
22582
23036
  })
22583
23037
  ]);
22584
23038
  var harnessPreferencePatchSchema = external_exports.strictObject({
@@ -23415,7 +23869,7 @@ var THREAD_WATCH_NOTICE_OUTCOMES = [
23415
23869
  "unreadable",
23416
23870
  "notFound"
23417
23871
  ];
23418
- var ENTRY_PATTERN = new RegExp(String.raw`^- \[([^\]\n]+)\]\(thread://([^\s()<>"?#/]+)\): ` + `(${THREAD_WATCH_NOTICE_OUTCOMES.join("|")})(?:. (.+))?$`, "u");
23872
+ var ENTRY_PATTERN = new RegExp(String.raw`^- \[([^\]\n]+)\]\(thread://([^\s()<>"?#/]+)(?:\?hostId=([^\s()<>"?#/&]+))?\): ` + `(${THREAD_WATCH_NOTICE_OUTCOMES.join("|")})(?:. (.+))?$`, "u");
23419
23873
 
23420
23874
  // ../../shared-contracts/dist/remote-runtime.js
23421
23875
  var remoteUpdatePhaseSchema = external_exports.enum([
@@ -23444,7 +23898,7 @@ var remoteSshSetupParamsSchema = external_exports.object({
23444
23898
  hostname: external_exports.string().min(1).max(1024).refine((value) => !value.startsWith("-") && !/\s/u.test(value)),
23445
23899
  port: external_exports.number().int().min(1).max(65535).nullable(),
23446
23900
  identity: external_exports.string().max(4096).nullable(),
23447
- action: external_exports.enum(["inspect", "install", "update", "repair", "uninstall"]),
23901
+ action: external_exports.enum(["inspect", "install", "update", "restart", "repair", "uninstall"]),
23448
23902
  uninstallPackage: external_exports.boolean().optional(),
23449
23903
  version: external_exports.string().regex(/^\d+\.\d+\.\d+$/u).nullable()
23450
23904
  }).strict();
@@ -23460,6 +23914,7 @@ var target = {
23460
23914
  var thread2 = { ...target, threadId: identity };
23461
23915
  var text = external_exports.string().min(1).max(8e3);
23462
23916
  var input2 = { text, requestId: identity };
23917
+ var queueReorderItemIdsSchema = external_exports.array(identity).min(2).max(100).refine((ids) => new Set(ids).size === ids.length, "Queued submission IDs must be distinct");
23463
23918
  var remoteDeliveryReplySchema = external_exports.discriminatedUnion("accepted", [
23464
23919
  external_exports.object({ accepted: external_exports.literal(true), startQueuedItemId: identity.optional() }),
23465
23920
  external_exports.object({
@@ -23479,6 +23934,7 @@ var remoteQueueSnapshotSchema = external_exports.discriminatedUnion("available",
23479
23934
  external_exports.object({ available: external_exports.literal(false) }),
23480
23935
  external_exports.object({
23481
23936
  available: external_exports.literal(true),
23937
+ canReorder: external_exports.literal(true).optional(),
23482
23938
  items: external_exports.array(external_exports.object({ id: identity, clientUserMessageId: identity, preview: external_exports.string().max(801) })).max(100)
23483
23939
  })
23484
23940
  ]);
@@ -23556,6 +24012,7 @@ var remoteSessionOperationSchema = external_exports.discriminatedUnion("kind", [
23556
24012
  external_exports.strictObject({ kind: external_exports.literal("enqueue"), ...input2 }),
23557
24013
  external_exports.strictObject({ kind: external_exports.literal("steer"), ...input2, turnId: identity }),
23558
24014
  external_exports.strictObject({ kind: external_exports.literal("remove"), itemId: identity }),
24015
+ external_exports.strictObject({ kind: external_exports.literal("reorder"), itemIds: queueReorderItemIdsSchema }),
23559
24016
  external_exports.strictObject({
23560
24017
  kind: external_exports.literal("start"),
23561
24018
  itemId: identity,
@@ -25547,7 +26004,7 @@ var BrokeredHarnessAdapter = class {
25547
26004
  };
25548
26005
 
25549
26006
  // ../codebuddy/dist/usage-statistics.js
25550
- import path4 from "node:path";
26007
+ import path7 from "node:path";
25551
26008
 
25552
26009
  // ../../harness-adapter/dist/usage-statistics.js
25553
26010
  import { createReadStream } from "node:fs";
@@ -25723,10 +26180,338 @@ function nativeTimeMs(value) {
25723
26180
  import { createHash } from "node:crypto";
25724
26181
  import { realpathSync } from "node:fs";
25725
26182
  import { access, readdir as readdir2, realpath as realpath2 } from "node:fs/promises";
25726
- import { homedir } from "node:os";
25727
- import path3 from "node:path";
26183
+ import { homedir as homedir2 } from "node:os";
26184
+ import path6 from "node:path";
25728
26185
  import { isDeepStrictEqual } from "node:util";
25729
26186
 
26187
+ // ../../harness-discovery/dist/environment.js
26188
+ import fs from "node:fs";
26189
+ import path3 from "node:path";
26190
+ function targetPath(platform) {
26191
+ return platform === "win32" ? path3.win32 : path3.posix;
26192
+ }
26193
+ function environmentValue(environment, name) {
26194
+ const lowered = name.toLowerCase();
26195
+ for (const [key, value] of Object.entries(environment)) {
26196
+ if (key.toLowerCase() === lowered)
26197
+ return value;
26198
+ }
26199
+ return void 0;
26200
+ }
26201
+ function pathDelimiter(platform) {
26202
+ return platform === "win32" ? ";" : ":";
26203
+ }
26204
+ function pathDirectories(environment, platform) {
26205
+ return (environmentValue(environment, "PATH") ?? "").split(pathDelimiter(platform)).map((directory) => directory.trim().replace(/^"|"$/gu, "")).filter(Boolean);
26206
+ }
26207
+ function executableExtensions(command, platform, environment) {
26208
+ if (platform !== "win32")
26209
+ return [""];
26210
+ if (targetPath(platform).extname(command) !== "")
26211
+ return [""];
26212
+ return (environmentValue(environment, "PATHEXT") ?? ".COM;.EXE;.BAT;.CMD").split(";").map((extension) => extension.trim()).filter(Boolean);
26213
+ }
26214
+ function isExecutableFile(filePath2, platform) {
26215
+ try {
26216
+ fs.accessSync(filePath2, platform === "win32" ? fs.constants.F_OK : fs.constants.X_OK);
26217
+ return fs.statSync(filePath2).isFile();
26218
+ } catch {
26219
+ return false;
26220
+ }
26221
+ }
26222
+ function isDirectory(candidate) {
26223
+ try {
26224
+ return fs.statSync(candidate).isDirectory();
26225
+ } catch {
26226
+ return false;
26227
+ }
26228
+ }
26229
+ function subdirectoryNames(directory) {
26230
+ try {
26231
+ return fs.readdirSync(directory, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
26232
+ } catch {
26233
+ return [];
26234
+ }
26235
+ }
26236
+ function newestFirst(names) {
26237
+ return [...names].sort((left, right) => right.localeCompare(left, void 0, { numeric: true }));
26238
+ }
26239
+
26240
+ // ../../harness-discovery/dist/invocation.js
26241
+ import path4 from "node:path";
26242
+ function commandInvocation(command, arguments_, environment, platform = process.platform) {
26243
+ const extension = path4.win32.extname(command).toLowerCase();
26244
+ if (platform !== "win32" || ![".cmd", ".bat"].includes(extension)) {
26245
+ return { command, arguments: [...arguments_], windowsVerbatimArguments: false };
26246
+ }
26247
+ const quote = (value) => `"${value.replaceAll("%", "%%").replaceAll('"', '""')}"`;
26248
+ const commandLine = [command, ...arguments_].map(quote).join(" ");
26249
+ return {
26250
+ command: environmentValue(environment, "ComSpec") ?? "cmd.exe",
26251
+ arguments: ["/d", "/v:off", "/s", "/c", `"${commandLine}"`],
26252
+ windowsVerbatimArguments: true
26253
+ };
26254
+ }
26255
+
26256
+ // ../../harness-discovery/dist/node-runtime.js
26257
+ import path5 from "node:path";
26258
+ function withNodeRuntimeOnPath(environment, runtimeExecutable = process.execPath, platform = process.platform) {
26259
+ const pathKey = Object.keys(environment).find((name) => name.toLowerCase() === "path") ?? "PATH";
26260
+ const delimiter = platform === "win32" ? ";" : ":";
26261
+ const runtimeDirectory = path5.dirname(runtimeExecutable);
26262
+ const directories = (environment[pathKey] ?? "").split(delimiter).filter(Boolean);
26263
+ const equal = platform === "win32" ? (value) => value.toLowerCase() : (value) => value;
26264
+ if (!directories.some((directory) => equal(directory) === equal(runtimeDirectory))) {
26265
+ directories.push(runtimeDirectory);
26266
+ }
26267
+ return { ...environment, [pathKey]: directories.join(delimiter) };
26268
+ }
26269
+
26270
+ // ../../harness-discovery/dist/resolve.js
26271
+ import os2 from "node:os";
26272
+
26273
+ // ../../harness-discovery/dist/version-managers.js
26274
+ function versionManagerBinaryDirectories(context) {
26275
+ const { platform, environment, home } = context;
26276
+ const list = context.subdirectories ?? subdirectoryNames;
26277
+ const pathFlavor = targetPath(platform);
26278
+ const value = (name) => environmentValue(environment, name);
26279
+ const directories = [];
26280
+ const versioned = (root, ...tail) => {
26281
+ for (const version2 of newestFirst(list(root))) {
26282
+ directories.push(pathFlavor.join(root, version2, ...tail));
26283
+ }
26284
+ };
26285
+ if (platform === "win32") {
26286
+ const appData = value("APPDATA") ?? pathFlavor.join(home, "AppData", "Roaming");
26287
+ const localAppData = value("LOCALAPPDATA") ?? pathFlavor.join(home, "AppData", "Local");
26288
+ versioned(pathFlavor.join(appData, "nvm"));
26289
+ versioned(value("FNM_DIR") ?? pathFlavor.join(appData, "fnm", "node-versions"), "installation");
26290
+ directories.push(pathFlavor.join(localAppData, "Volta", "bin"));
26291
+ directories.push(pathFlavor.join(home, ".bun", "bin"));
26292
+ const pnpmHome2 = value("PNPM_HOME");
26293
+ if (pnpmHome2)
26294
+ directories.push(pnpmHome2);
26295
+ directories.push(pathFlavor.join(localAppData, "pnpm"));
26296
+ return directories;
26297
+ }
26298
+ versioned(pathFlavor.join(value("NVM_DIR") ?? pathFlavor.join(home, ".nvm"), "versions", "node"), "bin");
26299
+ const fnmRoots = [
26300
+ value("FNM_DIR"),
26301
+ pathFlavor.join(home, ".local", "share", "fnm"),
26302
+ pathFlavor.join(home, "Library", "Application Support", "fnm")
26303
+ ].filter((root) => root !== void 0);
26304
+ for (const root of fnmRoots) {
26305
+ versioned(pathFlavor.join(root, "node-versions"), "installation", "bin");
26306
+ }
26307
+ const voltaHome = value("VOLTA_HOME") ?? pathFlavor.join(home, ".volta");
26308
+ versioned(pathFlavor.join(voltaHome, "tools", "image", "node"), "bin");
26309
+ directories.push(pathFlavor.join(voltaHome, "bin"));
26310
+ const asdfHome = value("ASDF_DATA_DIR") ?? pathFlavor.join(home, ".asdf");
26311
+ versioned(pathFlavor.join(asdfHome, "installs", "nodejs"), "bin");
26312
+ directories.push(pathFlavor.join(asdfHome, "shims"));
26313
+ const nodenvHome = value("NODENV_ROOT") ?? pathFlavor.join(home, ".nodenv");
26314
+ versioned(pathFlavor.join(nodenvHome, "versions"), "bin");
26315
+ directories.push(pathFlavor.join(nodenvHome, "shims"));
26316
+ versioned(pathFlavor.join(value("N_PREFIX") ?? "/usr/local", "n", "versions", "node"), "bin");
26317
+ directories.push(pathFlavor.join(home, ".bun", "bin"));
26318
+ const pnpmHome = value("PNPM_HOME");
26319
+ if (pnpmHome)
26320
+ directories.push(pnpmHome);
26321
+ directories.push(pathFlavor.join(home, "Library", "pnpm"));
26322
+ directories.push(pathFlavor.join(home, ".local", "share", "pnpm"));
26323
+ for (const prefix of ["/opt/homebrew/opt", "/usr/local/opt"]) {
26324
+ for (const formula of newestFirst(list(prefix).filter((name) => name.startsWith("node@")))) {
26325
+ directories.push(pathFlavor.join(prefix, formula, "bin"));
26326
+ }
26327
+ }
26328
+ return directories;
26329
+ }
26330
+
26331
+ // ../../harness-discovery/dist/resolve.js
26332
+ var VERSION_MANAGER_ROOTS = "<version-managers>";
26333
+ function installRootExtensions(platform) {
26334
+ return platform === "win32" ? [".exe", ".cmd"] : [""];
26335
+ }
26336
+ function resolveHomeDirectory(input3) {
26337
+ return input3.homeDirectory ?? environmentValue(input3.environment, "HOME") ?? environmentValue(input3.environment, "USERPROFILE") ?? os2.homedir();
26338
+ }
26339
+ function templateVariables(environment, platform, home) {
26340
+ const pathFlavor = targetPath(platform);
26341
+ return {
26342
+ HOME: home,
26343
+ USERPROFILE: home,
26344
+ APPDATA: environmentValue(environment, "APPDATA") ?? pathFlavor.join(home, "AppData", "Roaming"),
26345
+ LOCALAPPDATA: environmentValue(environment, "LOCALAPPDATA") ?? pathFlavor.join(home, "AppData", "Local")
26346
+ };
26347
+ }
26348
+ function joinTemplate(platform, value) {
26349
+ const pathFlavor = targetPath(platform);
26350
+ const segments = value.split("/");
26351
+ const head = segments[0] ?? "";
26352
+ const tail = segments.slice(1);
26353
+ if (head === "")
26354
+ return pathFlavor.join(pathFlavor.sep, ...tail);
26355
+ return tail.length === 0 ? head : pathFlavor.join(head, ...tail);
26356
+ }
26357
+ function expandInstallRoot(template, environment, platform, home) {
26358
+ const variables = templateVariables(environment, platform, home);
26359
+ let unresolved = false;
26360
+ const substituted = template.replace(/^~(?=\/|$)/u, home).replace(/\$\{(\w+)\}/gu, (_match, name) => {
26361
+ const value = variables[name] ?? environmentValue(environment, name);
26362
+ if (value === void 0 || value === "") {
26363
+ unresolved = true;
26364
+ return "";
26365
+ }
26366
+ return value;
26367
+ });
26368
+ return unresolved ? void 0 : joinTemplate(platform, substituted);
26369
+ }
26370
+ function installRootDirectories(spec, input3, dependencies, platform, home) {
26371
+ const templates = (platform === "win32" ? spec.installRoots?.windows : spec.installRoots?.posix) ?? [];
26372
+ const directories = [];
26373
+ for (const template of templates) {
26374
+ if (template === VERSION_MANAGER_ROOTS) {
26375
+ directories.push(...versionManagerBinaryDirectories({
26376
+ platform,
26377
+ environment: input3.environment,
26378
+ home,
26379
+ ...dependencies.subdirectories ? { subdirectories: dependencies.subdirectories } : {}
26380
+ }));
26381
+ continue;
26382
+ }
26383
+ const directory = expandInstallRoot(template, input3.environment, platform, home);
26384
+ if (directory !== void 0)
26385
+ directories.push(directory);
26386
+ }
26387
+ return directories;
26388
+ }
26389
+ function harnessCandidates(spec, input3, dependencies = {}) {
26390
+ const platform = input3.platform ?? process.platform;
26391
+ const pathFlavor = targetPath(platform);
26392
+ const configured = input3.command ?? (spec.commandEnvironmentVariable ? environmentValue(input3.environment, spec.commandEnvironmentVariable) : void 0);
26393
+ const command = configured ?? spec.command;
26394
+ if (pathFlavor.isAbsolute(command) || command.includes("/") || command.includes("\\")) {
26395
+ return [{ candidate: command, source: "configured" }];
26396
+ }
26397
+ const candidates = [];
26398
+ const extensions = executableExtensions(command, platform, input3.environment);
26399
+ for (const directory of pathDirectories(input3.environment, platform)) {
26400
+ for (const extension of extensions) {
26401
+ candidates.push({
26402
+ candidate: pathFlavor.join(directory, command + extension),
26403
+ source: "path"
26404
+ });
26405
+ }
26406
+ }
26407
+ if (configured !== void 0)
26408
+ return candidates;
26409
+ const home = resolveHomeDirectory(input3);
26410
+ for (const directory of installRootDirectories(spec, input3, dependencies, platform, home)) {
26411
+ for (const extension of installRootExtensions(platform)) {
26412
+ candidates.push({
26413
+ candidate: pathFlavor.join(directory, spec.command + extension),
26414
+ source: "install-root"
26415
+ });
26416
+ }
26417
+ }
26418
+ return candidates;
26419
+ }
26420
+ function resolveHarnessExecutable(spec, input3, dependencies = {}) {
26421
+ const platform = input3.platform ?? process.platform;
26422
+ const isExecutable = dependencies.isExecutable ?? ((candidate) => isExecutableFile(candidate, platform));
26423
+ const runnable = spec.runnableCandidate ?? ((candidate) => candidate);
26424
+ const context = { platform, isExecutable };
26425
+ for (const { candidate, source } of harnessCandidates(spec, input3, dependencies)) {
26426
+ const executable = runnable(candidate, context);
26427
+ if (executable !== void 0 && isExecutable(executable))
26428
+ return { executable, source };
26429
+ }
26430
+ return void 0;
26431
+ }
26432
+
26433
+ // ../../harness-discovery/dist/installation.js
26434
+ import { execFile as execFile2 } from "node:child_process";
26435
+ import { homedir } from "node:os";
26436
+ function runInstallationCommand(command, args, environment, timeout = 3e4, cwd) {
26437
+ const env = withNodeRuntimeOnPath(environment);
26438
+ const invocation = /\.[cm]?js$/i.test(command) ? commandInvocation(process.execPath, [command, ...args], env) : commandInvocation(command, args, env);
26439
+ return new Promise((resolve, reject) => {
26440
+ const child = execFile2(invocation.command, invocation.arguments, {
26441
+ env,
26442
+ cwd: cwd ?? env.HOME ?? env.USERPROFILE ?? homedir(),
26443
+ encoding: "utf8",
26444
+ timeout,
26445
+ killSignal: "SIGKILL",
26446
+ maxBuffer: 1024 * 1024,
26447
+ windowsHide: true,
26448
+ windowsVerbatimArguments: invocation.windowsVerbatimArguments
26449
+ }, (error62, stdout, stderr) => {
26450
+ if (error62)
26451
+ reject(new Error(error62.killed ? "Harness command timed out" : "Harness command failed; check the native installation and retry"));
26452
+ else
26453
+ resolve((stdout || stderr).trim());
26454
+ });
26455
+ child.stdin?.end();
26456
+ });
26457
+ }
26458
+ function installationVersion(value) {
26459
+ if (typeof value !== "string" || !/^v?\d+(?:\.\d+){1,3}(?:-[\w.-]+)?(?:\+[\w.-]+)?$/.test(value.trim()))
26460
+ throw new Error("Harness returned an invalid version");
26461
+ return value.trim().replace(/^v/, "");
26462
+ }
26463
+ function versionFromOutput(output2) {
26464
+ return installationVersion(output2.match(/\b\d+(?:\.\d+){1,3}(?:-[\w.-]+)?(?:\+[\w.-]+)?\b/)?.[0]);
26465
+ }
26466
+ function newerInstallationVersion(current, latest) {
26467
+ const a = installationVersion(current).replace(/\+.*/, "");
26468
+ const b = installationVersion(latest).replace(/\+.*/, "");
26469
+ const coreA = a.replace(/-.*/, "").split(".").map(BigInt);
26470
+ const coreB = b.replace(/-.*/, "").split(".").map(BigInt);
26471
+ for (let i = 0; i < Math.max(coreA.length, coreB.length); i++) {
26472
+ if ((coreA[i] ?? 0n) !== (coreB[i] ?? 0n))
26473
+ return (coreB[i] ?? 0n) > (coreA[i] ?? 0n);
26474
+ }
26475
+ const preA = a.includes("-") ? a.slice(a.indexOf("-") + 1).split(".") : [];
26476
+ const preB = b.includes("-") ? b.slice(b.indexOf("-") + 1).split(".") : [];
26477
+ if (!preA.length || !preB.length)
26478
+ return !!preA.length && !preB.length;
26479
+ for (let i = 0; i < Math.max(preA.length, preB.length); i++) {
26480
+ const x = preA[i];
26481
+ const y = preB[i];
26482
+ if (x === y)
26483
+ continue;
26484
+ if (x === void 0 || y === void 0)
26485
+ return x === void 0;
26486
+ const numericX = /^\d+$/.test(x);
26487
+ const numericY = /^\d+$/.test(y);
26488
+ if (numericX && numericY) {
26489
+ if (BigInt(x) === BigInt(y))
26490
+ continue;
26491
+ return BigInt(y) > BigInt(x);
26492
+ }
26493
+ if (numericX !== numericY)
26494
+ return numericX;
26495
+ return y > x;
26496
+ }
26497
+ return false;
26498
+ }
26499
+ async function fetchInstallationText(url2) {
26500
+ const request = async () => {
26501
+ const response = await fetch(url2, { signal: AbortSignal.timeout(15e3) });
26502
+ if (!response.ok)
26503
+ throw new Error("Could not check the latest Harness version");
26504
+ return response.text();
26505
+ };
26506
+ try {
26507
+ return await request();
26508
+ } catch (error62) {
26509
+ if (error62 instanceof DOMException && (error62.name === "AbortError" || error62.name === "TimeoutError"))
26510
+ throw error62;
26511
+ return request();
26512
+ }
26513
+ }
26514
+
25730
26515
  // ../codebuddy/dist/common.js
25731
26516
  var CODEBUDDY_ID = harnessIdSchema.parse("codebuddy");
25732
26517
  var CODEBUDDY_RUNTIME_PROFILE = {
@@ -25861,16 +26646,37 @@ function modelRef(modelId2) {
25861
26646
  function normalizeStoredCodeBuddyModelRef(ref, catalog) {
25862
26647
  return normalizeLegacyBase64ModelRef(ref, catalog, "cb.");
25863
26648
  }
25864
- function configuration(value, profile = CODEBUDDY_RUNTIME_PROFILE) {
26649
+ function configuration(value, profile = CODEBUDDY_RUNTIME_PROFILE, nativeModels = []) {
25865
26650
  const options = rows(value);
25866
26651
  const get = (id2) => options.find((option) => option.id === id2) ?? {};
25867
26652
  const model2 = get("model"), mode = get("mode"), thought = get("thought_level");
25868
- const thinkingOptions = rows(thought.options).map((option) => harnessThinkingOptionSchema.parse({ id: option.value, label: option.name }));
25869
- const currentThinking = thinkingOptions.find((option) => option.id === thought.currentValue);
25870
- const models = rows(model2.options).map((option) => ({
25871
- ref: modelRef(text2(option.value)),
25872
- label: text2(option.name)
25873
- }));
26653
+ const nativeThinkingOptions = rows(thought.options).map((option) => harnessThinkingOptionSchema.parse({ id: option.value, label: option.name }));
26654
+ const metadata = new Map(rows(nativeModels).map((row) => [row.modelId, record3(row._meta)]));
26655
+ const thinkingById = new Map(nativeThinkingOptions.map((option) => [option.id, option]));
26656
+ const models = rows(model2.options).map((option) => {
26657
+ const details = metadata.get(option.value);
26658
+ const label = text2(option.name);
26659
+ const rate = profile.modelRates ? /^x(\d+(?:\.\d+)?)(?:\s+credits)?$/iu.exec((text2(details?.credits) || text2(option.description)).trim()) : null;
26660
+ const annotatedLabel = rate ? `${label} · ${Number(rate[1]) === 0 ? "Free" : `${rate[1]}x`}` : label;
26661
+ let supportedThinkingOptionIds;
26662
+ if (details && (Array.isArray(details.effortOptions) || details.supportsReasoning === false)) {
26663
+ const efforts = details.supportsReasoning === false ? [] : rows(details.effortOptions);
26664
+ const supported = efforts.map((effort) => harnessThinkingOptionSchema.parse({ id: effort.value, label: effort.name }));
26665
+ const defaultOption = nativeThinkingOptions.find((entry) => entry.id === profile.defaultThinkingOptionId);
26666
+ if (defaultOption && details.supportsReasoning !== false) {
26667
+ supported.push(defaultOption);
26668
+ }
26669
+ for (const entry of supported) {
26670
+ thinkingById.set(entry.id, entry);
26671
+ }
26672
+ supportedThinkingOptionIds = [...new Set(supported.map((entry) => entry.id))];
26673
+ }
26674
+ return {
26675
+ ref: modelRef(text2(option.value)),
26676
+ label: annotatedLabel.length <= HARNESS_MODEL_LABEL_MAX_LENGTH ? annotatedLabel : label,
26677
+ ...supportedThinkingOptionIds ? { supportedThinkingOptionIds } : {}
26678
+ };
26679
+ });
25874
26680
  const currentModelRef = modelRef(text2(model2.currentValue));
25875
26681
  let currentModel = models.find((item) => item.ref.id === currentModelRef.id);
25876
26682
  if (!currentModel && !profile.allowUnlistedModelSelection && !currentModelRef.id.startsWith(CUSTOM_LOCAL_MODEL_PREFIX)) {
@@ -25880,17 +26686,23 @@ function configuration(value, profile = CODEBUDDY_RUNTIME_PROFILE) {
25880
26686
  currentModel = { ref: currentModelRef, label: text2(model2.currentValue) };
25881
26687
  models.push(currentModel);
25882
26688
  }
25883
- if (!currentModel)
26689
+ if (!currentModel) {
25884
26690
  throw new CodeBuddyError("protocolError", "ACP did not report a valid current Model");
26691
+ }
26692
+ const availableThinkingOptions = currentModel.supportedThinkingOptionIds ? currentModel.supportedThinkingOptionIds.map((id2) => thinkingById.get(id2)) : nativeThinkingOptions;
26693
+ const currentThinking = availableThinkingOptions.find((option) => option.id === thought.currentValue);
26694
+ const defaultThinking = profile.defaultThinkingOptionId ? [...thinkingById.values()].find((option) => option.id === profile.defaultThinkingOptionId) : currentThinking;
26695
+ const thinkingOptions = [...thinkingById.values()];
26696
+ const completeModelThinking = models.every((item) => item.supportedThinkingOptionIds !== void 0);
25885
26697
  const catalog = harnessModelCatalogSchema.parse({
25886
26698
  models: models.map((item) => ({
25887
26699
  ...item,
25888
- ...item === currentModel ? { supportedThinkingOptionIds: thinkingOptions.map((option) => option.id) } : {}
26700
+ ...item === currentModel && item.supportedThinkingOptionIds === void 0 ? { supportedThinkingOptionIds: availableThinkingOptions.map((option) => option.id) } : {}
25889
26701
  })),
25890
26702
  defaultModel: currentModel.ref,
25891
26703
  thinkingOptions,
25892
- thinkingOptionsScope: "activeModel",
25893
- ...currentThinking ? { defaultThinkingOptionId: currentThinking.id } : {}
26704
+ thinkingOptionsScope: completeModelThinking ? "catalog" : "activeModel",
26705
+ ...defaultThinking ? { defaultThinkingOptionId: defaultThinking.id } : {}
25894
26706
  });
25895
26707
  const permissionModes = harnessPermissionModeCatalogSchema.parse({
25896
26708
  modes: rows(mode.options).map((option) => ({
@@ -25906,10 +26718,10 @@ function configuration(value, profile = CODEBUDDY_RUNTIME_PROFILE) {
25906
26718
  effectiveModel: currentModel.ref,
25907
26719
  resolvedModelLabel: currentModel.label,
25908
26720
  effectivePermissionModeId: harnessPermissionModeIdSchema.parse(mode.currentValue),
25909
- availableThinkingOptions: thinkingOptions,
26721
+ availableThinkingOptions,
25910
26722
  ...currentThinking ? { effectiveThinkingOptionId: currentThinking.id } : {}
25911
26723
  };
25912
- return { catalog, permissionModes, state, options };
26724
+ return { catalog, permissionModes, state, options, nativeModels };
25913
26725
  }
25914
26726
  function effectiveOptionValue(config2, id2) {
25915
26727
  if (id2 === "model")
@@ -25918,10 +26730,11 @@ function effectiveOptionValue(config2, id2) {
25918
26730
  }
25919
26731
  async function selectConfiguration(config2, id2, value, profile, request) {
25920
26732
  const option = config2?.options.find((option2) => option2.id === id2);
25921
- const listed = rows(option?.options).some((option2) => option2.value === value);
25922
- if (!listed && !(id2 === "model" && profile.allowUnlistedModelSelection))
26733
+ const listed = id2 === "thought_level" ? config2?.state.availableThinkingOptions?.some((option2) => option2.id === value) : rows(option?.options).some((option2) => option2.value === value);
26734
+ if (!listed && !(id2 === "model" && profile.allowUnlistedModelSelection)) {
25923
26735
  throw new CodeBuddyError("invalidRequest", `Unavailable ${profile.displayName} ${id2} selection`);
25924
- return confirmedConfiguration(await request(id2, value), id2, value, profile);
26736
+ }
26737
+ return confirmedConfiguration(await request(id2, value), id2, value, profile, config2?.nativeModels);
25925
26738
  }
25926
26739
  async function restoreConfiguration(config2, saved, profile, request) {
25927
26740
  const selections = [
@@ -25940,8 +26753,9 @@ async function restoreConfiguration(config2, saved, profile, request) {
25940
26753
  }
25941
26754
  return config2;
25942
26755
  }
25943
- function confirmedConfiguration(response, id2, value, profile = CODEBUDDY_RUNTIME_PROFILE) {
25944
- const result = configuration(record3(response).configOptions, profile);
26756
+ function confirmedConfiguration(response, id2, value, profile = CODEBUDDY_RUNTIME_PROFILE, nativeModels = []) {
26757
+ const reply = record3(response);
26758
+ const result = configuration(reply.configOptions, profile, record3(reply.models).availableModels ?? nativeModels);
25945
26759
  if (effectiveOptionValue(result, id2) !== value) {
25946
26760
  throw new CodeBuddyError("protocolError", `ACP did not confirm ${id2}`);
25947
26761
  }
@@ -26051,16 +26865,16 @@ var Diff = class {
26051
26865
  }
26052
26866
  }
26053
26867
  }
26054
- addToPath(path13, added, removed, oldPosInc, options) {
26055
- const last = path13.lastComponent;
26868
+ addToPath(path14, added, removed, oldPosInc, options) {
26869
+ const last = path14.lastComponent;
26056
26870
  if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
26057
26871
  return {
26058
- oldPos: path13.oldPos + oldPosInc,
26872
+ oldPos: path14.oldPos + oldPosInc,
26059
26873
  lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
26060
26874
  };
26061
26875
  } else {
26062
26876
  return {
26063
- oldPos: path13.oldPos + oldPosInc,
26877
+ oldPos: path14.oldPos + oldPosInc,
26064
26878
  lastComponent: { count: 1, added, removed, previousComponent: last }
26065
26879
  };
26066
26880
  }
@@ -26749,15 +27563,18 @@ function codeBuddyCanonicalCwd(cwd) {
26749
27563
  try {
26750
27564
  return realpathSync.native(cwd);
26751
27565
  } catch {
26752
- return path3.resolve(cwd);
27566
+ return path6.resolve(cwd);
26753
27567
  }
26754
27568
  }
26755
- function codeBuddyConfigRoot(environment, profile) {
26756
- const configuredRoot = profile.configDirectoryEnvironmentVariables.map((name) => environment[name]).find((value) => typeof value === "string" && value.trim().length > 0);
26757
- return configuredRoot || path3.join(environment.HOME || environment.USERPROFILE || homedir(), profile.defaultConfigDirectoryName);
27569
+ function codeBuddyConfigRoot(environment, profile, source) {
27570
+ const value = (name) => process.platform === "win32" ? environmentValue(environment, name) : environment[name];
27571
+ const configuredRoot = profile.configDirectoryEnvironmentVariables.map((name) => value(name)).find((value2) => typeof value2 === "string" && value2.trim().length > 0);
27572
+ const root = configuredRoot || path6.join(value("HOME") || value("USERPROFILE") || homedir2(), profile.defaultConfigDirectoryName);
27573
+ profile.validateConfigRoot?.(root, source);
27574
+ return root;
26758
27575
  }
26759
27576
  function codeBuddyPrimaryHistoryPath(cwd, ref, environment, profile = CODEBUDDY_RUNTIME_PROFILE) {
26760
- return path3.join(codeBuddyConfigRoot(environment, profile), "projects", codeBuddyProjectSlug(cwd, profile), `${ref.nativeSessionId}.jsonl`);
27577
+ return path6.join(codeBuddyConfigRoot(environment, profile), "projects", codeBuddyProjectSlug(cwd, profile), `${ref.nativeSessionId}.jsonl`);
26761
27578
  }
26762
27579
  function derivedLocator(ref) {
26763
27580
  const locator = record3(ref.locator);
@@ -26800,9 +27617,9 @@ async function sameCwd(left, right) {
26800
27617
  return process.platform === "win32" ? a.toLowerCase() === b.toLowerCase() : a === b;
26801
27618
  }
26802
27619
  async function matchesAnyHistoricalCwd(value, candidates) {
26803
- const resolved = path3.resolve(value);
27620
+ const resolved = path6.resolve(value);
26804
27621
  for (const candidate of candidates) {
26805
- const other = path3.resolve(candidate);
27622
+ const other = path6.resolve(candidate);
26806
27623
  if (process.platform === "win32" ? resolved.toLowerCase() === other.toLowerCase() : resolved === other)
26807
27624
  return true;
26808
27625
  try {
@@ -26826,9 +27643,9 @@ async function codeBuddyLiveNativeHistory(cwd, ref, environment, profile = CODEB
26826
27643
  async function codeBuddyHistory(cwd, ref, environment, tolerateIncompleteTail, profile, transaction) {
26827
27644
  validateNativeRef(ref, profile);
26828
27645
  const configRoot = codeBuddyConfigRoot(environment, profile);
26829
- const root = path3.join(configRoot, "projects");
27646
+ const root = path6.join(configRoot, "projects");
26830
27647
  const slug = codeBuddyProjectSlug(cwd, profile);
26831
- const primary = path3.join(root, slug, `${ref.nativeSessionId}.jsonl`);
27648
+ const primary = path6.join(root, slug, `${ref.nativeSessionId}.jsonl`);
26832
27649
  const provenance = derivedLocator(ref);
26833
27650
  let candidates = [];
26834
27651
  try {
@@ -26847,7 +27664,7 @@ async function codeBuddyHistory(cwd, ref, environment, tolerateIncompleteTail, p
26847
27664
  for (const directory of directories) {
26848
27665
  if (!directory.isDirectory())
26849
27666
  continue;
26850
- const file3 = path3.join(root, directory.name, `${ref.nativeSessionId}.jsonl`);
27667
+ const file3 = path6.join(root, directory.name, `${ref.nativeSessionId}.jsonl`);
26851
27668
  try {
26852
27669
  await access(file3);
26853
27670
  candidates.push(file3);
@@ -26862,7 +27679,7 @@ async function codeBuddyHistory(cwd, ref, environment, tolerateIncompleteTail, p
26862
27679
  const file2 = candidates[0];
26863
27680
  if (!file2)
26864
27681
  throw new CodeBuddyError("sessionNotFound", "Native Session history was not found");
26865
- if (profile.historyCapabilities?.fork && !transaction && path3.resolve(file2) !== path3.resolve(primary))
27682
+ if (profile.historyCapabilities?.fork && !transaction && path6.resolve(file2) !== path6.resolve(primary))
26866
27683
  throw new CodeBuddyError("invalidRequest", "Native Session is not stored in the requested working directory");
26867
27684
  const source = await readCodeBuddyVersionedText(file2, 64e6, "Native history exceeds the supported 64 MB snapshot size"), parsed = parseJsonl(source.contents, tolerateIncompleteTail);
26868
27685
  const checkedDirectories = /* @__PURE__ */ new Set();
@@ -26891,7 +27708,7 @@ async function codeBuddyHistory(cwd, ref, environment, tolerateIncompleteTail, p
26891
27708
  }
26892
27709
  }
26893
27710
  } else if (provenance) {
26894
- if (!await sameCwd(provenance.boundCwd, cwd) || provenance.targetProjectSlug !== slug || path3.resolve(file2) !== path3.resolve(primary))
27711
+ if (!await sameCwd(provenance.boundCwd, cwd) || provenance.targetProjectSlug !== slug || path6.resolve(file2) !== path6.resolve(primary))
26895
27712
  throw new CodeBuddyError("invalidRequest", "Derived Native Session target binding changed");
26896
27713
  const active2 = nativeHistoryRows(parsed.contents);
26897
27714
  if (provenance.inheritedPrefixRows > active2.length || nativeRowsDigest(active2.slice(0, provenance.inheritedPrefixRows)) !== provenance.inheritedPrefixSha256)
@@ -27454,8 +28271,11 @@ async function readCodeBuddyUsage(file2, signal) {
27454
28271
  function createCodeBuddyUsageStatistics(environment, profile) {
27455
28272
  return Object.freeze({
27456
28273
  // projects/<project>/<session>.jsonl and <session>/subagents/*.jsonl
27457
- listSources: (signal) => jsonlUsageSources(path4.join(codeBuddyConfigRoot(environment, profile), "projects"), 3, signal),
27458
- readSource: (id2, signal) => readCodeBuddyUsage(id2, signal)
28274
+ listSources: async (signal) => jsonlUsageSources(path7.join(codeBuddyConfigRoot(environment, profile), "projects"), 3, signal),
28275
+ readSource: async (id2, signal) => {
28276
+ codeBuddyConfigRoot(environment, profile, id2);
28277
+ return readCodeBuddyUsage(id2, signal);
28278
+ }
27459
28279
  });
27460
28280
  }
27461
28281
 
@@ -31697,334 +32517,6 @@ var CodeBuddyCopyCleanup = class {
31697
32517
  }
31698
32518
  };
31699
32519
 
31700
- // ../../harness-discovery/dist/environment.js
31701
- import fs from "node:fs";
31702
- import path5 from "node:path";
31703
- function targetPath(platform) {
31704
- return platform === "win32" ? path5.win32 : path5.posix;
31705
- }
31706
- function environmentValue(environment, name) {
31707
- const lowered = name.toLowerCase();
31708
- for (const [key, value] of Object.entries(environment)) {
31709
- if (key.toLowerCase() === lowered)
31710
- return value;
31711
- }
31712
- return void 0;
31713
- }
31714
- function pathDelimiter(platform) {
31715
- return platform === "win32" ? ";" : ":";
31716
- }
31717
- function pathDirectories(environment, platform) {
31718
- return (environmentValue(environment, "PATH") ?? "").split(pathDelimiter(platform)).map((directory) => directory.trim().replace(/^"|"$/gu, "")).filter(Boolean);
31719
- }
31720
- function executableExtensions(command, platform, environment) {
31721
- if (platform !== "win32")
31722
- return [""];
31723
- if (targetPath(platform).extname(command) !== "")
31724
- return [""];
31725
- return (environmentValue(environment, "PATHEXT") ?? ".COM;.EXE;.BAT;.CMD").split(";").map((extension) => extension.trim()).filter(Boolean);
31726
- }
31727
- function isExecutableFile(filePath2, platform) {
31728
- try {
31729
- fs.accessSync(filePath2, platform === "win32" ? fs.constants.F_OK : fs.constants.X_OK);
31730
- return fs.statSync(filePath2).isFile();
31731
- } catch {
31732
- return false;
31733
- }
31734
- }
31735
- function isDirectory(candidate) {
31736
- try {
31737
- return fs.statSync(candidate).isDirectory();
31738
- } catch {
31739
- return false;
31740
- }
31741
- }
31742
- function subdirectoryNames(directory) {
31743
- try {
31744
- return fs.readdirSync(directory, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
31745
- } catch {
31746
- return [];
31747
- }
31748
- }
31749
- function newestFirst(names) {
31750
- return [...names].sort((left, right) => right.localeCompare(left, void 0, { numeric: true }));
31751
- }
31752
-
31753
- // ../../harness-discovery/dist/invocation.js
31754
- import path6 from "node:path";
31755
- function commandInvocation(command, arguments_, environment, platform = process.platform) {
31756
- const extension = path6.win32.extname(command).toLowerCase();
31757
- if (platform !== "win32" || ![".cmd", ".bat"].includes(extension)) {
31758
- return { command, arguments: [...arguments_], windowsVerbatimArguments: false };
31759
- }
31760
- const quote = (value) => `"${value.replaceAll("%", "%%").replaceAll('"', '""')}"`;
31761
- const commandLine = [command, ...arguments_].map(quote).join(" ");
31762
- return {
31763
- command: environmentValue(environment, "ComSpec") ?? "cmd.exe",
31764
- arguments: ["/d", "/v:off", "/s", "/c", `"${commandLine}"`],
31765
- windowsVerbatimArguments: true
31766
- };
31767
- }
31768
-
31769
- // ../../harness-discovery/dist/node-runtime.js
31770
- import path7 from "node:path";
31771
- function withNodeRuntimeOnPath(environment, runtimeExecutable = process.execPath, platform = process.platform) {
31772
- const pathKey = Object.keys(environment).find((name) => name.toLowerCase() === "path") ?? "PATH";
31773
- const delimiter = platform === "win32" ? ";" : ":";
31774
- const runtimeDirectory = path7.dirname(runtimeExecutable);
31775
- const directories = (environment[pathKey] ?? "").split(delimiter).filter(Boolean);
31776
- const equal = platform === "win32" ? (value) => value.toLowerCase() : (value) => value;
31777
- if (!directories.some((directory) => equal(directory) === equal(runtimeDirectory))) {
31778
- directories.push(runtimeDirectory);
31779
- }
31780
- return { ...environment, [pathKey]: directories.join(delimiter) };
31781
- }
31782
-
31783
- // ../../harness-discovery/dist/resolve.js
31784
- import os2 from "node:os";
31785
-
31786
- // ../../harness-discovery/dist/version-managers.js
31787
- function versionManagerBinaryDirectories(context) {
31788
- const { platform, environment, home } = context;
31789
- const list = context.subdirectories ?? subdirectoryNames;
31790
- const pathFlavor = targetPath(platform);
31791
- const value = (name) => environmentValue(environment, name);
31792
- const directories = [];
31793
- const versioned = (root, ...tail) => {
31794
- for (const version2 of newestFirst(list(root))) {
31795
- directories.push(pathFlavor.join(root, version2, ...tail));
31796
- }
31797
- };
31798
- if (platform === "win32") {
31799
- const appData = value("APPDATA") ?? pathFlavor.join(home, "AppData", "Roaming");
31800
- const localAppData = value("LOCALAPPDATA") ?? pathFlavor.join(home, "AppData", "Local");
31801
- versioned(pathFlavor.join(appData, "nvm"));
31802
- versioned(value("FNM_DIR") ?? pathFlavor.join(appData, "fnm", "node-versions"), "installation");
31803
- directories.push(pathFlavor.join(localAppData, "Volta", "bin"));
31804
- directories.push(pathFlavor.join(home, ".bun", "bin"));
31805
- const pnpmHome2 = value("PNPM_HOME");
31806
- if (pnpmHome2)
31807
- directories.push(pnpmHome2);
31808
- directories.push(pathFlavor.join(localAppData, "pnpm"));
31809
- return directories;
31810
- }
31811
- versioned(pathFlavor.join(value("NVM_DIR") ?? pathFlavor.join(home, ".nvm"), "versions", "node"), "bin");
31812
- const fnmRoots = [
31813
- value("FNM_DIR"),
31814
- pathFlavor.join(home, ".local", "share", "fnm"),
31815
- pathFlavor.join(home, "Library", "Application Support", "fnm")
31816
- ].filter((root) => root !== void 0);
31817
- for (const root of fnmRoots) {
31818
- versioned(pathFlavor.join(root, "node-versions"), "installation", "bin");
31819
- }
31820
- const voltaHome = value("VOLTA_HOME") ?? pathFlavor.join(home, ".volta");
31821
- versioned(pathFlavor.join(voltaHome, "tools", "image", "node"), "bin");
31822
- directories.push(pathFlavor.join(voltaHome, "bin"));
31823
- const asdfHome = value("ASDF_DATA_DIR") ?? pathFlavor.join(home, ".asdf");
31824
- versioned(pathFlavor.join(asdfHome, "installs", "nodejs"), "bin");
31825
- directories.push(pathFlavor.join(asdfHome, "shims"));
31826
- const nodenvHome = value("NODENV_ROOT") ?? pathFlavor.join(home, ".nodenv");
31827
- versioned(pathFlavor.join(nodenvHome, "versions"), "bin");
31828
- directories.push(pathFlavor.join(nodenvHome, "shims"));
31829
- versioned(pathFlavor.join(value("N_PREFIX") ?? "/usr/local", "n", "versions", "node"), "bin");
31830
- directories.push(pathFlavor.join(home, ".bun", "bin"));
31831
- const pnpmHome = value("PNPM_HOME");
31832
- if (pnpmHome)
31833
- directories.push(pnpmHome);
31834
- directories.push(pathFlavor.join(home, "Library", "pnpm"));
31835
- directories.push(pathFlavor.join(home, ".local", "share", "pnpm"));
31836
- for (const prefix of ["/opt/homebrew/opt", "/usr/local/opt"]) {
31837
- for (const formula of newestFirst(list(prefix).filter((name) => name.startsWith("node@")))) {
31838
- directories.push(pathFlavor.join(prefix, formula, "bin"));
31839
- }
31840
- }
31841
- return directories;
31842
- }
31843
-
31844
- // ../../harness-discovery/dist/resolve.js
31845
- var VERSION_MANAGER_ROOTS = "<version-managers>";
31846
- function installRootExtensions(platform) {
31847
- return platform === "win32" ? [".exe", ".cmd"] : [""];
31848
- }
31849
- function resolveHomeDirectory(input3) {
31850
- return input3.homeDirectory ?? environmentValue(input3.environment, "HOME") ?? environmentValue(input3.environment, "USERPROFILE") ?? os2.homedir();
31851
- }
31852
- function templateVariables(environment, platform, home) {
31853
- const pathFlavor = targetPath(platform);
31854
- return {
31855
- HOME: home,
31856
- USERPROFILE: home,
31857
- APPDATA: environmentValue(environment, "APPDATA") ?? pathFlavor.join(home, "AppData", "Roaming"),
31858
- LOCALAPPDATA: environmentValue(environment, "LOCALAPPDATA") ?? pathFlavor.join(home, "AppData", "Local")
31859
- };
31860
- }
31861
- function joinTemplate(platform, value) {
31862
- const pathFlavor = targetPath(platform);
31863
- const segments = value.split("/");
31864
- const head = segments[0] ?? "";
31865
- const tail = segments.slice(1);
31866
- if (head === "")
31867
- return pathFlavor.join(pathFlavor.sep, ...tail);
31868
- return tail.length === 0 ? head : pathFlavor.join(head, ...tail);
31869
- }
31870
- function expandInstallRoot(template, environment, platform, home) {
31871
- const variables = templateVariables(environment, platform, home);
31872
- let unresolved = false;
31873
- const substituted = template.replace(/^~(?=\/|$)/u, home).replace(/\$\{(\w+)\}/gu, (_match, name) => {
31874
- const value = variables[name] ?? environmentValue(environment, name);
31875
- if (value === void 0 || value === "") {
31876
- unresolved = true;
31877
- return "";
31878
- }
31879
- return value;
31880
- });
31881
- return unresolved ? void 0 : joinTemplate(platform, substituted);
31882
- }
31883
- function installRootDirectories(spec, input3, dependencies, platform, home) {
31884
- const templates = (platform === "win32" ? spec.installRoots?.windows : spec.installRoots?.posix) ?? [];
31885
- const directories = [];
31886
- for (const template of templates) {
31887
- if (template === VERSION_MANAGER_ROOTS) {
31888
- directories.push(...versionManagerBinaryDirectories({
31889
- platform,
31890
- environment: input3.environment,
31891
- home,
31892
- ...dependencies.subdirectories ? { subdirectories: dependencies.subdirectories } : {}
31893
- }));
31894
- continue;
31895
- }
31896
- const directory = expandInstallRoot(template, input3.environment, platform, home);
31897
- if (directory !== void 0)
31898
- directories.push(directory);
31899
- }
31900
- return directories;
31901
- }
31902
- function harnessCandidates(spec, input3, dependencies = {}) {
31903
- const platform = input3.platform ?? process.platform;
31904
- const pathFlavor = targetPath(platform);
31905
- const configured = input3.command ?? (spec.commandEnvironmentVariable ? environmentValue(input3.environment, spec.commandEnvironmentVariable) : void 0);
31906
- const command = configured ?? spec.command;
31907
- if (pathFlavor.isAbsolute(command) || command.includes("/") || command.includes("\\")) {
31908
- return [{ candidate: command, source: "configured" }];
31909
- }
31910
- const candidates = [];
31911
- const extensions = executableExtensions(command, platform, input3.environment);
31912
- for (const directory of pathDirectories(input3.environment, platform)) {
31913
- for (const extension of extensions) {
31914
- candidates.push({
31915
- candidate: pathFlavor.join(directory, command + extension),
31916
- source: "path"
31917
- });
31918
- }
31919
- }
31920
- if (configured !== void 0)
31921
- return candidates;
31922
- const home = resolveHomeDirectory(input3);
31923
- for (const directory of installRootDirectories(spec, input3, dependencies, platform, home)) {
31924
- for (const extension of installRootExtensions(platform)) {
31925
- candidates.push({
31926
- candidate: pathFlavor.join(directory, spec.command + extension),
31927
- source: "install-root"
31928
- });
31929
- }
31930
- }
31931
- return candidates;
31932
- }
31933
- function resolveHarnessExecutable(spec, input3, dependencies = {}) {
31934
- const platform = input3.platform ?? process.platform;
31935
- const isExecutable = dependencies.isExecutable ?? ((candidate) => isExecutableFile(candidate, platform));
31936
- const runnable = spec.runnableCandidate ?? ((candidate) => candidate);
31937
- const context = { platform, isExecutable };
31938
- for (const { candidate, source } of harnessCandidates(spec, input3, dependencies)) {
31939
- const executable = runnable(candidate, context);
31940
- if (executable !== void 0 && isExecutable(executable))
31941
- return { executable, source };
31942
- }
31943
- return void 0;
31944
- }
31945
-
31946
- // ../../harness-discovery/dist/installation.js
31947
- import { execFile as execFile2 } from "node:child_process";
31948
- import { homedir as homedir2 } from "node:os";
31949
- function runInstallationCommand(command, args, environment, timeout = 3e4, cwd) {
31950
- const env = withNodeRuntimeOnPath(environment);
31951
- const invocation = /\.[cm]?js$/i.test(command) ? commandInvocation(process.execPath, [command, ...args], env) : commandInvocation(command, args, env);
31952
- return new Promise((resolve, reject) => {
31953
- const child = execFile2(invocation.command, invocation.arguments, {
31954
- env,
31955
- cwd: cwd ?? env.HOME ?? env.USERPROFILE ?? homedir2(),
31956
- encoding: "utf8",
31957
- timeout,
31958
- killSignal: "SIGKILL",
31959
- maxBuffer: 1024 * 1024,
31960
- windowsHide: true,
31961
- windowsVerbatimArguments: invocation.windowsVerbatimArguments
31962
- }, (error62, stdout, stderr) => {
31963
- if (error62)
31964
- reject(new Error(error62.killed ? "Harness command timed out" : "Harness command failed; check the native installation and retry"));
31965
- else
31966
- resolve((stdout || stderr).trim());
31967
- });
31968
- child.stdin?.end();
31969
- });
31970
- }
31971
- function installationVersion(value) {
31972
- if (typeof value !== "string" || !/^v?\d+(?:\.\d+){1,3}(?:-[\w.-]+)?(?:\+[\w.-]+)?$/.test(value.trim()))
31973
- throw new Error("Harness returned an invalid version");
31974
- return value.trim().replace(/^v/, "");
31975
- }
31976
- function versionFromOutput(output2) {
31977
- return installationVersion(output2.match(/\b\d+(?:\.\d+){1,3}(?:-[\w.-]+)?(?:\+[\w.-]+)?\b/)?.[0]);
31978
- }
31979
- function newerInstallationVersion(current, latest) {
31980
- const a = installationVersion(current).replace(/\+.*/, "");
31981
- const b = installationVersion(latest).replace(/\+.*/, "");
31982
- const coreA = a.replace(/-.*/, "").split(".").map(BigInt);
31983
- const coreB = b.replace(/-.*/, "").split(".").map(BigInt);
31984
- for (let i = 0; i < Math.max(coreA.length, coreB.length); i++) {
31985
- if ((coreA[i] ?? 0n) !== (coreB[i] ?? 0n))
31986
- return (coreB[i] ?? 0n) > (coreA[i] ?? 0n);
31987
- }
31988
- const preA = a.includes("-") ? a.slice(a.indexOf("-") + 1).split(".") : [];
31989
- const preB = b.includes("-") ? b.slice(b.indexOf("-") + 1).split(".") : [];
31990
- if (!preA.length || !preB.length)
31991
- return !!preA.length && !preB.length;
31992
- for (let i = 0; i < Math.max(preA.length, preB.length); i++) {
31993
- const x = preA[i];
31994
- const y = preB[i];
31995
- if (x === y)
31996
- continue;
31997
- if (x === void 0 || y === void 0)
31998
- return x === void 0;
31999
- const numericX = /^\d+$/.test(x);
32000
- const numericY = /^\d+$/.test(y);
32001
- if (numericX && numericY) {
32002
- if (BigInt(x) === BigInt(y))
32003
- continue;
32004
- return BigInt(y) > BigInt(x);
32005
- }
32006
- if (numericX !== numericY)
32007
- return numericX;
32008
- return y > x;
32009
- }
32010
- return false;
32011
- }
32012
- async function fetchInstallationText(url2) {
32013
- const request = async () => {
32014
- const response = await fetch(url2, { signal: AbortSignal.timeout(15e3) });
32015
- if (!response.ok)
32016
- throw new Error("Could not check the latest Harness version");
32017
- return response.text();
32018
- };
32019
- try {
32020
- return await request();
32021
- } catch (error62) {
32022
- if (error62 instanceof DOMException && (error62.name === "AbortError" || error62.name === "TimeoutError"))
32023
- throw error62;
32024
- return request();
32025
- }
32026
- }
32027
-
32028
32520
  // ../codebuddy/dist/command.js
32029
32521
  var codeBuddyDiscoverySpec = {
32030
32522
  id: "codebuddy",
@@ -33811,6 +34303,7 @@ var CodeBuddyChildObserver = class {
33811
34303
  throw error62;
33812
34304
  });
33813
34305
  if (sameCodeBuddyFileVersion(current, this.#parent.version)) {
34306
+ codeBuddyConfigRoot(this.environment, this.profile);
33814
34307
  await this.#validateWorkspaces(this.#parent.historicalCwds);
33815
34308
  this.#assertOpen();
33816
34309
  return this.#parent;
@@ -34316,7 +34809,7 @@ var CodeBuddySession = class {
34316
34809
  }
34317
34810
  } : {}
34318
34811
  });
34319
- this.#apply(configuration(opened.configOptions, this.profile), false);
34812
+ this.#apply(configuration(opened.configOptions, this.profile, record3(opened.models).availableModels), false);
34320
34813
  if (this.input.kind === "create" && this.input.executionPolicy === "unattended-full-access") {
34321
34814
  await this.#configure("mode", "fullAccess");
34322
34815
  } else if (this.input.permissionModeId || text2(saved.mode))
@@ -34418,8 +34911,9 @@ var CodeBuddySession = class {
34418
34911
  #applyUpdate(update) {
34419
34912
  if ((text2(record3(update._meta)["codebuddy.ai/parentToolCallId"]) || !this.#active?.output.hasItem(`tool-${text2(update.toolCallId)}`)) && this.subagents.update(update))
34420
34913
  return;
34421
- if (update.sessionUpdate === "config_option_update" && this.#config)
34422
- this.#apply(configuration(update.configOptions, this.profile));
34914
+ if (update.sessionUpdate === "config_option_update" && this.#config) {
34915
+ this.#apply(configuration(update.configOptions, this.profile, this.#config.nativeModels));
34916
+ }
34423
34917
  if (update.sessionUpdate === "usage_update" && typeof update.used === "number" && typeof update.size === "number" && update.size > 0) {
34424
34918
  this.#context = {
34425
34919
  contextUsedTokens: update.used,
@@ -34796,7 +35290,7 @@ var CodeBuddySession = class {
34796
35290
  this.#client = candidate = this.#createClient();
34797
35291
  const generation = this.#generation;
34798
35292
  const loaded = await this.#openClient();
34799
- const restored = await restoreConfiguration(configuration(loaded.configOptions, this.profile), this.#state, this.profile, this.#configurationRequest());
35293
+ const restored = await restoreConfiguration(configuration(loaded.configOptions, this.profile, record3(loaded.models).availableModels), this.#state, this.profile, this.#configurationRequest());
34800
35294
  this.#assertClient(generation);
34801
35295
  this.#apply(restored);
34802
35296
  if (!this.profile.staticCommandCatalog)
@@ -34967,7 +35461,7 @@ var CodeBuddyAdapter = class {
34967
35461
  this.#inspections.add(client2);
34968
35462
  await client2.initialize();
34969
35463
  const opened = await client2.open(cwd);
34970
- const config2 = configuration(opened.configOptions, this.#profile);
35464
+ const config2 = configuration(opened.configOptions, this.#profile, record3(opened.models).availableModels);
34971
35465
  return harnessInspectionSchema.parse({
34972
35466
  status: "ready",
34973
35467
  catalog: config2.catalog,
@@ -35070,8 +35564,8 @@ var CodeBuddyAdapter = class {
35070
35564
  };
35071
35565
 
35072
35566
  // dist/command.js
35073
- import { lstatSync, statSync } from "node:fs";
35074
35567
  import { randomBytes as randomBytes2 } from "node:crypto";
35568
+ import { lstatSync, statSync as statSync2 } from "node:fs";
35075
35569
  import { homedir as homedir3 } from "node:os";
35076
35570
 
35077
35571
  // dist/delegation.js
@@ -35300,6 +35794,107 @@ var WORKBUDDY_CREDENTIAL_PRELOAD = String.raw`
35300
35794
  })();
35301
35795
  `;
35302
35796
 
35797
+ // dist/distribution.js
35798
+ import { readFileSync, realpathSync as realpathSync2, statSync } from "node:fs";
35799
+ import path12 from "node:path";
35800
+ var WORKBUDDY_DISTRIBUTIONS = {
35801
+ global: {
35802
+ harnessId: harnessIdSchema.parse("workbuddy"),
35803
+ displayName: "WorkBuddy",
35804
+ commandEnvironmentVariable: "CODEXHOST_WORKBUDDY_COMMAND",
35805
+ configDirectoryEnvironmentVariable: "WORKBUDDY_CONFIG_DIR",
35806
+ dataFolderName: ".workbuddy-ai",
35807
+ endpoint: "https://www.workbuddy.ai",
35808
+ authenticationId: "workbuddy-desktop-ai"
35809
+ },
35810
+ cn: {
35811
+ harnessId: harnessIdSchema.parse("workbuddy-cn"),
35812
+ displayName: "WorkBuddy CN",
35813
+ commandEnvironmentVariable: "CODEXHOST_WORKBUDDYCN_COMMAND",
35814
+ configDirectoryEnvironmentVariable: "WORKBUDDYCN_CONFIG_DIR",
35815
+ dataFolderName: ".workbuddy",
35816
+ endpoint: "https://www.workbuddy.cn",
35817
+ authenticationId: "workbuddy-desktop"
35818
+ }
35819
+ };
35820
+ var RELEASES = Object.keys(WORKBUDDY_DISTRIBUTIONS);
35821
+ function readWorkBuddyProduct(cliScript) {
35822
+ const packageRoot = path12.dirname(path12.dirname(realpathSync2(cliScript)));
35823
+ return JSON.parse(readWorkBuddyProductConfiguration(path12.join(packageRoot, "product.json")));
35824
+ }
35825
+ function readWorkBuddyProductConfiguration(file2) {
35826
+ if (!statSync(file2).isFile())
35827
+ throw new CodeBuddyError("invalidRequest", "WorkBuddy product configuration is not a regular file");
35828
+ return readFileSync(file2, "utf8");
35829
+ }
35830
+ function serviceOrigin(endpoint) {
35831
+ if (typeof endpoint !== "string")
35832
+ return;
35833
+ try {
35834
+ return new URL(endpoint).origin;
35835
+ } catch {
35836
+ return;
35837
+ }
35838
+ }
35839
+ function workBuddyReleasesDeclaredBy(product) {
35840
+ if (product === null || typeof product !== "object")
35841
+ return [];
35842
+ const { dataFolderName, endpoint, authentication } = product;
35843
+ const service = serviceOrigin(endpoint);
35844
+ const authenticationId = authentication !== null && typeof authentication === "object" ? authentication.id : void 0;
35845
+ return RELEASES.filter((release) => {
35846
+ const identity2 = WORKBUDDY_DISTRIBUTIONS[release];
35847
+ return identity2.dataFolderName === dataFolderName || new URL(identity2.endpoint).origin === service || identity2.authenticationId === authenticationId;
35848
+ });
35849
+ }
35850
+ function foreignWorkBuddyProduct(product, distribution) {
35851
+ const foreign = workBuddyReleasesDeclaredBy(product).find((release) => release !== distribution);
35852
+ if (foreign)
35853
+ return foreign;
35854
+ const dataFolderName = product !== null && typeof product === "object" ? product.dataFolderName : void 0;
35855
+ return dataFolderName !== void 0 && dataFolderName !== WORKBUDDY_DISTRIBUTIONS[distribution].dataFolderName ? "other" : void 0;
35856
+ }
35857
+ function rejectForeignWorkBuddyProduct(source, product, distribution) {
35858
+ const foreign = foreignWorkBuddyProduct(product, distribution);
35859
+ const { displayName } = WORKBUDDY_DISTRIBUTIONS[distribution];
35860
+ if (foreign === "other")
35861
+ throw new CodeBuddyError("invalidRequest", `${source} declares another product's data root, not ${displayName}`);
35862
+ if (foreign)
35863
+ throw new CodeBuddyError("invalidRequest", `${source} declares ${WORKBUDDY_DISTRIBUTIONS[foreign].displayName}, not ${displayName}; select the ${WORKBUDDY_DISTRIBUTIONS[foreign].harnessId} Harness for it`);
35864
+ }
35865
+ function verifiedWorkBuddyRootSnapshot(root, distribution, platform = process.platform, readText = readWorkBuddyProductConfiguration, source) {
35866
+ if (source) {
35867
+ const relative = path12.relative(path12.join(realpathSync2(root), "projects"), realpathSync2(source));
35868
+ if (path12.isAbsolute(relative) || relative === ".." || relative.startsWith(`..${path12.sep}`))
35869
+ throw new CodeBuddyError("invalidRequest", "WorkBuddy usage source is outside the selected data root");
35870
+ }
35871
+ const candidate = targetPath(platform).join(root, "cache", "acc-product-config-v3.json");
35872
+ let product;
35873
+ try {
35874
+ product = JSON.parse(readText(candidate));
35875
+ } catch (error62) {
35876
+ if (error62 instanceof CodeBuddyError)
35877
+ throw error62;
35878
+ return;
35879
+ }
35880
+ rejectForeignWorkBuddyProduct("The product snapshot in this WorkBuddy root", product, distribution);
35881
+ return candidate;
35882
+ }
35883
+ function workBuddyDistributionOfProduct(product) {
35884
+ const declared = workBuddyReleasesDeclaredBy(product);
35885
+ const release = declared.length === 1 ? declared[0] : void 0;
35886
+ return release && !foreignWorkBuddyProduct(product, release) ? release : void 0;
35887
+ }
35888
+ function workBuddyDistributionOf(cliScript, readProduct2 = readWorkBuddyProduct) {
35889
+ let product;
35890
+ try {
35891
+ product = readProduct2(cliScript);
35892
+ } catch {
35893
+ return void 0;
35894
+ }
35895
+ return workBuddyDistributionOfProduct(product);
35896
+ }
35897
+
35303
35898
  // dist/discovery.js
35304
35899
  var WORKBUDDY_MACOS_ELECTRON = "/Applications/WorkBuddy AI.app/Contents/MacOS/Electron";
35305
35900
  var windowsRoots = [
@@ -35323,16 +35918,16 @@ var macSpec = {
35323
35918
  ]
35324
35919
  }
35325
35920
  };
35326
- var linuxSpec = {
35921
+ var linuxSpecs = ["workbuddy", "workbuddyai"].map((command) => ({
35327
35922
  id: "workbuddy",
35328
- command: "workbuddy",
35923
+ command,
35329
35924
  installRoots: { posix: linuxRoots }
35330
- };
35925
+ }));
35331
35926
  function resolveWorkBuddyInstallDirectory(directory, environment, platform, isExecutable, subdirectories = subdirectoryNames) {
35332
35927
  const paths = targetPath(platform);
35333
- const entries = platform === "win32" ? ["WorkBuddy-app.exe", "WorkBuddy.exe", "WorkBuddy AI.exe", "WorkBuddyAI.exe"] : platform === "darwin" ? [paths.join("Contents", "MacOS", "Electron")] : platform === "linux" ? ["workbuddy"] : [];
35928
+ const entries = platform === "win32" ? ["WorkBuddy-app.exe", "WorkBuddy.exe", "WorkBuddy AI.exe", "WorkBuddyAI.exe"] : platform === "darwin" ? [paths.join("Contents", "MacOS", "Electron")] : platform === "linux" ? ["workbuddy", "workbuddyai"] : [];
35334
35929
  for (const entry of entries) {
35335
- const bundle = resolveWorkBuddyBundle(environment, platform, isExecutable, paths.join(directory, entry), subdirectories);
35930
+ const bundle = resolveWorkBuddyBundle(environment, platform, isExecutable, paths.join(directory, entry), () => true, subdirectories);
35336
35931
  if (bundle)
35337
35932
  return bundle;
35338
35933
  }
@@ -35365,12 +35960,12 @@ function resolveWorkBuddyLauncherLayout(directory, platform, isExecutable, subdi
35365
35960
  }
35366
35961
  return void 0;
35367
35962
  }
35368
- function resolveWorkBuddyBundle(environment, platform, isExecutable, explicitExecutable, subdirectories = subdirectoryNames) {
35963
+ function resolveWorkBuddyBundle(environment, platform, isExecutable, explicitExecutable, accept, subdirectories = subdirectoryNames) {
35369
35964
  const specs = platform === "darwin" ? [macSpec] : platform === "win32" ? ["WorkBuddy AI", "WorkBuddy", "WorkBuddyAI"].map((command) => ({
35370
35965
  id: "workbuddy",
35371
35966
  command,
35372
35967
  installRoots: { windows: windowsRoots }
35373
- })) : platform === "linux" ? [linuxSpec] : [];
35968
+ })) : platform === "linux" ? linuxSpecs : [];
35374
35969
  const paths = targetPath(platform);
35375
35970
  const candidates = explicitExecutable ? [{ candidate: explicitExecutable, source: "configured" }] : specs.flatMap((spec) => harnessCandidates(spec, { environment, platform }));
35376
35971
  for (const { candidate, source } of candidates) {
@@ -35381,11 +35976,14 @@ function resolveWorkBuddyBundle(environment, platform, isExecutable, explicitExe
35381
35976
  if (!isExecutable(candidate))
35382
35977
  continue;
35383
35978
  const launcher = resolveWorkBuddyLauncherLayout(paths.dirname(candidate), platform, isExecutable, subdirectories);
35384
- if (launcher)
35385
- return launcher;
35979
+ if (launcher) {
35980
+ if (accept(launcher.cli))
35981
+ return launcher;
35982
+ continue;
35983
+ }
35386
35984
  const resources = platform === "darwin" ? paths.resolve(paths.dirname(candidate), "..", "Resources") : paths.join(paths.dirname(candidate), "resources");
35387
35985
  const cli = paths.join(resources, "app.asar.unpacked", "cli", "bin", "codebuddy");
35388
- if (isExecutable(cli))
35986
+ if (isExecutable(cli) && accept(cli))
35389
35987
  return { executable: candidate, cli };
35390
35988
  }
35391
35989
  return void 0;
@@ -35404,18 +36002,29 @@ var WORKBUDDY_PRODUCT_CONFIG_INLINE_ENVS = [
35404
36002
  "ACC_PRODUCT_CONFIG_V2",
35405
36003
  "ACC_PRODUCT_CONFIG"
35406
36004
  ];
35407
- function bundledProductConfigPath(environment, platform, dependencies) {
35408
- if (environment[WORKBUDDY_PRODUCT_CONFIG_PATH_ENV] !== void 0 || WORKBUDDY_PRODUCT_CONFIG_INLINE_ENVS.some((name) => environment[name] !== void 0))
35409
- return;
35410
- const root = environment.WORKBUDDY_CONFIG_DIR;
35411
- if (!root)
35412
- return;
36005
+ function platformEnvironmentValue(environment, name, platform) {
36006
+ return platform === "win32" ? environmentValue(environment, name) : environment[name];
36007
+ }
36008
+ function setPlatformEnvironmentValue(environment, name, value, platform) {
36009
+ if (platform === "win32") {
36010
+ const lowered = name.toLowerCase();
36011
+ for (const key of Object.keys(environment)) {
36012
+ if (key !== name && key.toLowerCase() === lowered)
36013
+ Reflect.deleteProperty(environment, key);
36014
+ }
36015
+ }
36016
+ environment[name] = value;
36017
+ }
36018
+ function hasExplicitProductConfiguration(environment, platform) {
36019
+ return platformEnvironmentValue(environment, WORKBUDDY_PRODUCT_CONFIG_PATH_ENV, platform) !== void 0 || WORKBUDDY_PRODUCT_CONFIG_INLINE_ENVS.some((name) => platformEnvironmentValue(environment, name, platform) !== void 0);
36020
+ }
36021
+ function forwardableRootProductConfigPath(candidate, platform, dependencies) {
35413
36022
  const paths = targetPath(platform);
35414
- const candidate = paths.join(root, "cache", "acc-product-config-v3.json");
35415
36023
  try {
35416
36024
  const inspect = dependencies.lstat ?? lstatSync;
35417
36025
  const uid = (dependencies.getuid ?? (() => process.getuid?.()))();
35418
- for (const directory of [root, paths.dirname(candidate)]) {
36026
+ const cache = paths.dirname(candidate);
36027
+ for (const directory of [paths.dirname(cache), cache]) {
35419
36028
  const metadata2 = inspect(directory);
35420
36029
  if (!metadata2.isDirectory() || metadata2.isSymbolicLink())
35421
36030
  return;
@@ -35440,14 +36049,38 @@ function bundledProductConfigPath(environment, platform, dependencies) {
35440
36049
  return;
35441
36050
  }
35442
36051
  }
35443
- function workBuddyEnvironment(environment, platform = process.platform) {
36052
+ function verifyExplicitProductConfiguration(environment, distribution, platform, readText) {
36053
+ const path14 = platformEnvironmentValue(environment, WORKBUDDY_PRODUCT_CONFIG_PATH_ENV, platform)?.trim();
36054
+ const sources = [
36055
+ ...path14 ? [[WORKBUDDY_PRODUCT_CONFIG_PATH_ENV, () => readText(path14)]] : [],
36056
+ ...WORKBUDDY_PRODUCT_CONFIG_INLINE_ENVS.flatMap((name) => {
36057
+ const value = platformEnvironmentValue(environment, name, platform);
36058
+ return value?.trim() ? [[name, () => value]] : [];
36059
+ })
36060
+ ];
36061
+ for (const [name, read] of sources) {
36062
+ let product;
36063
+ try {
36064
+ product = JSON.parse(read());
36065
+ } catch {
36066
+ throw new CodeBuddyError("invalidRequest", `${name} cannot be verified as ${WORKBUDDY_DISTRIBUTIONS[distribution].displayName} product configuration`);
36067
+ }
36068
+ rejectForeignWorkBuddyProduct(name, product, distribution);
36069
+ }
36070
+ }
36071
+ function workBuddyEnvironment(environment, platform = process.platform, distribution = "global") {
35444
36072
  const paths = targetPath(platform);
35445
- const configuredRoot = environment.WORKBUDDY_CONFIG_DIR;
35446
- const root = paths.resolve(configuredRoot?.trim() ? configuredRoot : paths.join(environment.HOME || environment.USERPROFILE || homedir3(), platform === "linux" ? ".workbuddy" : ".workbuddy-ai"));
36073
+ const { configDirectoryEnvironmentVariable, dataFolderName } = WORKBUDDY_DISTRIBUTIONS[distribution];
36074
+ const configuredRoot = platformEnvironmentValue(environment, configDirectoryEnvironmentVariable, platform);
36075
+ const root = paths.resolve(configuredRoot?.trim() ? configuredRoot : paths.join(platformEnvironmentValue(environment, "HOME", platform) || platformEnvironmentValue(environment, "USERPROFILE", platform) || homedir3(), dataFolderName));
36076
+ const rootedEnvironment = { ...environment };
36077
+ setPlatformEnvironmentValue(rootedEnvironment, "CODEBUDDY_CONFIG_DIR", root, platform);
36078
+ setPlatformEnvironmentValue(rootedEnvironment, "WORKBUDDY_CONFIG_DIR", root, platform);
35447
36079
  return {
35448
- ...environment,
35449
- // The bundled core reads CODEBUDDY_CONFIG_DIR. Force both names to one
35450
- // WorkBuddy-owned root so a global CodeBuddy setting cannot leak history.
36080
+ ...rootedEnvironment,
36081
+ // The native CLI runs one product and reads WORKBUDDY_CONFIG_DIR/CODEBUDDY_CONFIG_DIR.
36082
+ // Force both to this release's root so neither a global CodeBuddy nor the other
36083
+ // release's Host override can leak history, authentication or settings.
35451
36084
  CODEBUDDY_CONFIG_DIR: root,
35452
36085
  WORKBUDDY_CONFIG_DIR: root,
35453
36086
  DISABLE_AUTOUPDATER: environment.DISABLE_AUTOUPDATER ?? "1"
@@ -35455,31 +36088,49 @@ function workBuddyEnvironment(environment, platform = process.platform) {
35455
36088
  }
35456
36089
  function resolveWorkBuddyLaunch(environment, dependencies = {}) {
35457
36090
  const platform = dependencies.platform ?? process.platform;
35458
- const configured = environmentValue(environment, "CODEXHOST_WORKBUDDY_COMMAND")?.trim() || void 0;
36091
+ const distribution = dependencies.distribution ?? "global";
36092
+ const { displayName, commandEnvironmentVariable } = WORKBUDDY_DISTRIBUTIONS[distribution];
36093
+ const releaseOf = (cli) => workBuddyDistributionOf(cli, dependencies.readProduct);
36094
+ const configured = environmentValue(environment, commandEnvironmentVariable)?.trim() || void 0;
35459
36095
  if (!configured && platform !== "darwin" && platform !== "win32" && platform !== "linux")
35460
- throw new CodeBuddyError("notInstalled", "WorkBuddy app discovery is unavailable on this platform; set CODEXHOST_WORKBUDDY_COMMAND for a compatible native runtime");
36096
+ throw new CodeBuddyError("notInstalled", `${displayName} app discovery is unavailable on this platform; set ${commandEnvironmentVariable} for a compatible native runtime`);
35461
36097
  const isExecutable = dependencies.isExecutable ?? ((candidate) => isExecutableFile(candidate, platform));
35462
36098
  const subdirectories = dependencies.subdirectories ?? subdirectoryNames;
35463
36099
  const configuredDirectory = configured && (dependencies.isDirectory ?? isDirectory)(configured) ? configured : void 0;
35464
36100
  const explicitExecutable = configured && !configuredDirectory ? resolveHarnessExecutable(workBuddyDiscoverySpec, { environment, platform, command: configured }, { isExecutable })?.executable : void 0;
35465
- const explicitBundle = explicitExecutable ? resolveWorkBuddyBundle(environment, platform, isExecutable, explicitExecutable, subdirectories) : void 0;
35466
- const explicitDesktop = explicitExecutable !== void 0 && (platform === "win32" && /^(?:WorkBuddy(?:-app)?|WorkBuddy AI|WorkBuddyAI)\.exe$/iu.test(targetPath(platform).basename(explicitExecutable)) || platform === "darwin" && /\/(?:WorkBuddy|WorkBuddy AI)\.app\/Contents\/MacOS\/Electron$/u.test(explicitExecutable) || platform === "linux" && targetPath(platform).basename(explicitExecutable) === "workbuddy");
35467
- const bundle = configuredDirectory ? resolveWorkBuddyInstallDirectory(configuredDirectory, environment, platform, isExecutable, subdirectories) : !configured ? resolveWorkBuddyBundle(environment, platform, isExecutable, void 0, subdirectories) : explicitDesktop ? explicitBundle : void 0;
36101
+ const explicitBundle = explicitExecutable ? resolveWorkBuddyBundle(environment, platform, isExecutable, explicitExecutable, () => true, subdirectories) : void 0;
36102
+ let explicitCliProduct;
36103
+ let hasExplicitCliProduct = false;
36104
+ if (explicitExecutable && !explicitBundle) {
36105
+ try {
36106
+ explicitCliProduct = (dependencies.readProduct ?? readWorkBuddyProduct)(explicitExecutable);
36107
+ hasExplicitCliProduct = true;
36108
+ } catch {
36109
+ }
36110
+ }
36111
+ const explicitDesktop = explicitExecutable !== void 0 && (explicitBundle !== void 0 || !hasExplicitCliProduct && (platform === "linux" || platform === "win32" && /^(?:WorkBuddy(?:-app)?|WorkBuddy AI|WorkBuddyAI)\.exe$/iu.test(targetPath(platform).basename(explicitExecutable)) || platform === "darwin" && /\/(?:WorkBuddy|WorkBuddy AI)\.app\/Contents\/MacOS\/Electron$/u.test(explicitExecutable)));
36112
+ const bundle = configuredDirectory ? resolveWorkBuddyInstallDirectory(configuredDirectory, environment, platform, isExecutable, subdirectories) : !configured ? resolveWorkBuddyBundle(environment, platform, isExecutable, void 0, (cli) => releaseOf(cli) === distribution, subdirectories) : explicitDesktop ? explicitBundle : void 0;
35468
36113
  const executable = configured && !explicitDesktop && !configuredDirectory ? explicitExecutable : bundle?.executable;
35469
36114
  if (!executable)
35470
- throw new CodeBuddyError("notInstalled", "WorkBuddy AI app or its bundled CLI is unavailable");
36115
+ throw new CodeBuddyError("notInstalled", `${displayName} app or its bundled CLI is unavailable`);
36116
+ if (configured) {
36117
+ const release = hasExplicitCliProduct && executable === explicitExecutable ? workBuddyDistributionOfProduct(explicitCliProduct) : releaseOf(bundle?.cli ?? executable);
36118
+ if (release !== distribution)
36119
+ throw new CodeBuddyError("invalidRequest", release ? `${configured} is ${WORKBUDDY_DISTRIBUTIONS[release].displayName}, not ${displayName}; select the ${WORKBUDDY_DISTRIBUTIONS[release].harnessId} Harness for it` : `${configured} does not declare ${displayName} product metadata`);
36120
+ }
35471
36121
  return { executable, bundle };
35472
36122
  }
35473
36123
  function workBuddyInvocation(environment, ephemeral, dependenciesOrArguments = {}, argumentsOverride) {
35474
36124
  const dependencies = Array.isArray(dependenciesOrArguments) ? {} : dependenciesOrArguments;
35475
36125
  const nativeArguments = Array.isArray(dependenciesOrArguments) ? dependenciesOrArguments : argumentsOverride;
35476
36126
  const platform = dependencies.platform ?? process.platform;
36127
+ const distribution = dependencies.distribution ?? "global";
35477
36128
  const { executable, bundle } = resolveWorkBuddyLaunch(environment, dependencies);
35478
36129
  const paths = targetPath(platform);
35479
36130
  const cliDist = bundle && paths.join(paths.dirname(paths.dirname(bundle.cli)), "dist");
35480
36131
  const isFile = dependencies.isFile ?? ((candidate) => {
35481
36132
  try {
35482
- return statSync(candidate).isFile();
36133
+ return statSync2(candidate).isFile();
35483
36134
  } catch {
35484
36135
  return false;
35485
36136
  }
@@ -35491,8 +36142,15 @@ function workBuddyInvocation(environment, ephemeral, dependenciesOrArguments = {
35491
36142
  ...workBuddyDelegationArguments(environment, ephemeral)
35492
36143
  ];
35493
36144
  const serve = liteOnly && acpArguments.includes("--acp") && !acpArguments.includes("--serve");
35494
- const configuredEnvironment = withNodeRuntimeOnPath(workBuddyEnvironment(environment, platform), process.execPath, platform);
35495
- const productConfigPath = bundle ? bundledProductConfigPath(configuredEnvironment, platform, dependencies) : void 0;
36145
+ const rootEnvironment = workBuddyEnvironment(environment, platform, distribution);
36146
+ const configuredEnvironment = withNodeRuntimeOnPath(rootEnvironment, process.execPath, platform);
36147
+ const explicitProductConfigPath = platformEnvironmentValue(configuredEnvironment, WORKBUDDY_PRODUCT_CONFIG_PATH_ENV, platform)?.trim();
36148
+ if (explicitProductConfigPath)
36149
+ setPlatformEnvironmentValue(configuredEnvironment, WORKBUDDY_PRODUCT_CONFIG_PATH_ENV, paths.resolve(explicitProductConfigPath), platform);
36150
+ const readText = dependencies.readText ?? readWorkBuddyProductConfiguration;
36151
+ verifyExplicitProductConfiguration(configuredEnvironment, distribution, platform, readText);
36152
+ const rootSnapshot = verifiedWorkBuddyRootSnapshot(rootEnvironment.WORKBUDDY_CONFIG_DIR, distribution, platform, readText);
36153
+ const productConfigPath = bundle && rootSnapshot && !hasExplicitProductConfiguration(configuredEnvironment, platform) ? forwardableRootProductConfigPath(rootSnapshot, platform, dependencies) : void 0;
35496
36154
  const childEnvironment = bundle ? {
35497
36155
  ...configuredEnvironment,
35498
36156
  // EOF-only native Fork copies do no model work. The bundled CLI otherwise
@@ -35520,7 +36178,7 @@ require(process.argv[1]);`, bundle.cli] : [],
35520
36178
  }
35521
36179
 
35522
36180
  // dist/common.js
35523
- var WORKBUDDY_ID = harnessIdSchema.parse("workbuddy");
36181
+ var WORKBUDDY_ID = WORKBUDDY_DISTRIBUTIONS.global.harnessId;
35524
36182
  var WORKBUDDY_COMMAND_CATALOG = harnessCommandCatalogSchema.parse({
35525
36183
  commands: [
35526
36184
  {
@@ -35540,22 +36198,32 @@ var WORKBUDDY_COMMAND_CATALOG = harnessCommandCatalogSchema.parse({
35540
36198
  }
35541
36199
  ]
35542
36200
  });
35543
- var WORKBUDDY_RUNTIME_PROFILE = {
35544
- harnessId: WORKBUDDY_ID,
35545
- displayName: "WorkBuddy",
35546
- interactionIdPrefix: "workbuddy",
35547
- configDirectoryEnvironmentVariables: ["WORKBUDDY_CONFIG_DIR"],
35548
- defaultConfigDirectoryName: ".workbuddy-ai",
35549
- // WorkBuddy's native PathUtils.compressPath preserves case, dots, spaces and Unicode.
35550
- projectDirectoryName: (cwd) => cwd.replace(/[/\\:]/gu, "-").replace(/^-+/u, "").replace(/-+$/u, "").replace(/-+/gu, "-"),
35551
- staticCommandCatalog: WORKBUDDY_COMMAND_CATALOG,
35552
- nativeCommands: true,
35553
- historyCapabilities: { fork: true, forkAcrossCwd: true, rollbackLastTurn: true }
35554
- };
36201
+ function workBuddyRuntimeProfile(distribution) {
36202
+ const { harnessId, displayName, configDirectoryEnvironmentVariable, dataFolderName } = WORKBUDDY_DISTRIBUTIONS[distribution];
36203
+ return {
36204
+ harnessId,
36205
+ displayName,
36206
+ interactionIdPrefix: harnessId,
36207
+ // History, subagents and Fork read the same Host key the spawned CLI root is mapped from.
36208
+ configDirectoryEnvironmentVariables: [configDirectoryEnvironmentVariable],
36209
+ defaultConfigDirectoryName: dataFolderName,
36210
+ validateConfigRoot: (root, source) => verifiedWorkBuddyRootSnapshot(root, distribution, process.platform, void 0, source),
36211
+ // WorkBuddy's native PathUtils.compressPath preserves case, dots, spaces and Unicode.
36212
+ projectDirectoryName: (cwd) => cwd.replace(/[/\\:]/gu, "-").replace(/^-+/u, "").replace(/-+$/u, "").replace(/-+/gu, "-"),
36213
+ staticCommandCatalog: WORKBUDDY_COMMAND_CATALOG,
36214
+ nativeCommands: true,
36215
+ modelRates: true,
36216
+ defaultThinkingOptionId: "enabled",
36217
+ // Verified online on the international CLI 2.137.1. The China CLI 2.147.0 ships the same
36218
+ // public `--fork-session` mode and `_codebuddy.ai/session/rollback` extension.
36219
+ historyCapabilities: { fork: true, forkAcrossCwd: true, rollbackLastTurn: true }
36220
+ };
36221
+ }
36222
+ var WORKBUDDY_RUNTIME_PROFILE = workBuddyRuntimeProfile("global");
35555
36223
 
35556
36224
  // dist/product-models.js
35557
36225
  import { readFile as readFile5, stat as stat4 } from "node:fs/promises";
35558
- import path12 from "node:path";
36226
+ import path13 from "node:path";
35559
36227
  var MAX_PRODUCT_SNAPSHOT_BYTES = 8 * 1024 * 1024;
35560
36228
  var PRODUCT_CONFIG_PATH_ENV = "ACC_PRODUCT_CONFIG_PATH";
35561
36229
  var PRODUCT_CONFIG_INLINE_ENVS = [
@@ -35617,10 +36285,10 @@ function bundledFallbackProductPath(invocation) {
35617
36285
  const cli = invocation.bundledCliPath;
35618
36286
  if (!cli)
35619
36287
  return;
35620
- return path12.join(path12.dirname(path12.dirname(cli)), "product.json");
36288
+ return path13.join(path13.dirname(path13.dirname(cli)), "product.json");
35621
36289
  }
35622
- async function loadWorkBuddyProductModels(environment) {
35623
- const invocation = workBuddyInvocation(environment, true);
36290
+ async function loadWorkBuddyProductModels(environment, distribution) {
36291
+ const invocation = workBuddyInvocation(environment, true, { distribution });
35624
36292
  const productEnvironment = invocation.environment;
35625
36293
  const configuredPath = nonBlank(productEnvironment[PRODUCT_CONFIG_PATH_ENV]);
35626
36294
  if (configuredPath) {
@@ -35649,44 +36317,53 @@ async function loadWorkBuddyProductModels(environment) {
35649
36317
  return [];
35650
36318
  }
35651
36319
  }
35652
- function normalizedLabel(value) {
35653
- return value.trim().toLocaleLowerCase();
35654
- }
35655
36320
  function mergeWorkBuddyProductModels(catalog, productModels) {
35656
36321
  const refs = new Set(catalog.models.map((model2) => model2.ref.id));
35657
- const labels2 = new Set(catalog.models.map((model2) => normalizedLabel(model2.label)));
35658
- const models = [...catalog.models];
36322
+ const models = [];
35659
36323
  for (const productModel of productModels) {
35660
36324
  const ref = modelRef(productModel.id);
35661
- const labelKey = normalizedLabel(productModel.name);
35662
- if (refs.has(ref.id) || labels2.has(labelKey))
36325
+ if (refs.has(ref.id)) {
35663
36326
  continue;
36327
+ }
35664
36328
  refs.add(ref.id);
35665
- labels2.add(labelKey);
35666
- const creditLabel = productModel.credits?.replace(/^x/iu, "").replace(/\s*credits$/iu, "x");
35667
- const annotatedLabel = creditLabel ? `${productModel.name} · ${creditLabel}` : productModel.name;
36329
+ const creditLabel = productModel.credits?.trim().replace(/^x(\d+(?:\.\d+)?)(?:\s+credits)?$/iu, "$1x");
36330
+ const rateLabel = /^0+(?:\.0+)?x$/iu.test(creditLabel ?? "") ? "Free" : creditLabel;
36331
+ const annotatedLabel = rateLabel ? `${productModel.name} · ${rateLabel}` : productModel.name;
35668
36332
  models.push({
35669
36333
  ref,
35670
36334
  label: annotatedLabel.length <= HARNESS_MODEL_LABEL_MAX_LENGTH ? annotatedLabel : productModel.name
35671
36335
  });
35672
36336
  }
35673
- return harnessModelCatalogSchema.parse({ ...catalog, models });
36337
+ if (models.length === 0) {
36338
+ return catalog;
36339
+ }
36340
+ return harnessModelCatalogSchema.parse({
36341
+ ...catalog,
36342
+ thinkingOptionsScope: "activeModel",
36343
+ models: [
36344
+ ...catalog.models.map((model2) => catalog.thinkingOptionsScope === "activeModel" || model2.supportedThinkingOptionIds !== void 0 ? model2 : { ...model2, supportedThinkingOptionIds: [] }),
36345
+ ...models
36346
+ ]
36347
+ });
35674
36348
  }
35675
36349
 
35676
36350
  // dist/workbuddy-adapter.js
35677
36351
  var WorkBuddyAdapter = class extends CodeBuddyAdapter {
36352
+ #displayName;
35678
36353
  #productModels;
35679
36354
  constructor(options = {}) {
35680
- const { productModels, platform = process.platform, ...codeBuddyOptions } = options;
36355
+ const { productModels, platform = process.platform, distribution = "global", ...codeBuddyOptions } = options;
35681
36356
  const environment = { ...codeBuddyOptions.environment ?? process.env };
35682
- const profile = platform === "win32" ? { ...WORKBUDDY_RUNTIME_PROFILE, allowUnlistedModelSelection: true } : platform === "linux" ? { ...WORKBUDDY_RUNTIME_PROFILE, defaultConfigDirectoryName: ".workbuddy" } : WORKBUDDY_RUNTIME_PROFILE;
36357
+ const baseProfile = workBuddyRuntimeProfile(distribution);
36358
+ const profile = platform === "win32" ? { ...baseProfile, allowUnlistedModelSelection: true } : baseProfile;
36359
+ const invocation = (invocationEnvironment, ephemeral, args) => workBuddyInvocation(invocationEnvironment, ephemeral, { distribution, platform }, args);
35683
36360
  super({
35684
36361
  ...codeBuddyOptions,
35685
36362
  profile,
35686
- invocationFactory: workBuddyInvocation,
35687
- clientFactory: codeBuddyOptions.clientFactory ?? ((clientOptions) => new CodeBuddyAcpClient(clientOptions, void 0, workBuddyInvocation))
36363
+ invocationFactory: invocation
35688
36364
  });
35689
- this.#productModels = platform === "win32" ? productModels ?? (() => loadWorkBuddyProductModels(environment)) : async () => [];
36365
+ this.#displayName = baseProfile.displayName;
36366
+ this.#productModels = platform === "win32" ? productModels ?? (() => loadWorkBuddyProductModels(environment, distribution)) : async () => [];
35690
36367
  }
35691
36368
  async inspect(input3 = {}) {
35692
36369
  const inspection = await super.inspect(input3);
@@ -35706,7 +36383,7 @@ var WorkBuddyAdapter = class extends CodeBuddyAdapter {
35706
36383
  ok: false,
35707
36384
  error: {
35708
36385
  code: "invalidRequest",
35709
- message: "WorkBuddy: unattended execution requires native fullAccess permissions",
36386
+ message: `${this.#displayName}: unattended execution requires native fullAccess permissions`,
35710
36387
  retryable: false
35711
36388
  }
35712
36389
  };
@@ -35734,10 +36411,14 @@ async function readProduct(file2) {
35734
36411
  function createWorkBuddyInstallation(environment, dependencies = {}) {
35735
36412
  const platform = dependencies.platform ?? process.platform;
35736
36413
  const arch = dependencies.arch ?? process.arch;
36414
+ const distribution = dependencies.distribution ?? "global";
35737
36415
  return async (action) => {
35738
36416
  if (action === "update")
35739
36417
  throw new Error("Complete the update with WorkBuddy's official desktop installer");
35740
- const { executable, bundle } = resolveWorkBuddyLaunch(environment, { platform });
36418
+ const { executable, bundle } = resolveWorkBuddyLaunch(environment, {
36419
+ platform,
36420
+ distribution
36421
+ });
35741
36422
  if (!bundle)
35742
36423
  return {
35743
36424
  currentVersion: versionFromOutput(await runInstallationCommand(executable, ["--version"], environment)),
@@ -35796,22 +36477,23 @@ function createWorkBuddyInstallation(environment, dependencies = {}) {
35796
36477
  }
35797
36478
 
35798
36479
  // dist/plugin.js
35799
- function createHarnessAdapter(context) {
36480
+ function createHarnessAdapter(context, distribution = "global") {
36481
+ const { harnessId, commandEnvironmentVariable } = WORKBUDDY_DISTRIBUTIONS[distribution];
35800
36482
  if (context.platform === "darwin" && context.managedRemoteHost) {
35801
36483
  const environment2 = {
35802
36484
  ...context.environment,
35803
- ...context.launchCommand ? { CODEXHOST_WORKBUDDY_COMMAND: context.launchCommand } : {}
36485
+ ...context.launchCommand ? { [commandEnvironmentVariable]: context.launchCommand } : {}
35804
36486
  };
35805
36487
  return new BrokeredHarnessAdapter({
35806
36488
  sessionImport: true,
35807
36489
  accountCredits: false,
35808
- harnessId: "workbuddy",
36490
+ harnessId,
35809
36491
  commandCatalog: WORKBUDDY_COMMAND_CATALOG,
35810
36492
  forwardDelegationEnvironment: true,
35811
36493
  environment: { ...context.environment },
35812
36494
  isInstalled: () => {
35813
36495
  try {
35814
- workBuddyInvocation(environment2, true);
36496
+ workBuddyInvocation(environment2, true, { distribution });
35815
36497
  return true;
35816
36498
  } catch (error62) {
35817
36499
  return !(error62 instanceof CodeBuddyError && error62.code === "notInstalled");
@@ -35822,11 +36504,14 @@ function createHarnessAdapter(context) {
35822
36504
  }
35823
36505
  const environment = {
35824
36506
  ...context.environment,
35825
- ...context.launchCommand ? { CODEXHOST_WORKBUDDY_COMMAND: context.launchCommand } : {}
36507
+ ...context.launchCommand ? { [commandEnvironmentVariable]: context.launchCommand } : {}
35826
36508
  };
35827
36509
  const platform = context.platform === "darwin" || context.platform === "win32" || context.platform === "linux" ? context.platform : void 0;
35828
- return Object.assign(new WorkBuddyAdapter({ environment, ...platform ? { platform } : {} }), {
35829
- installation: createWorkBuddyInstallation(environment, platform ? { platform } : {})
36510
+ return Object.assign(new WorkBuddyAdapter({ distribution, environment, ...platform ? { platform } : {} }), {
36511
+ installation: createWorkBuddyInstallation(environment, {
36512
+ distribution,
36513
+ ...platform ? { platform } : {}
36514
+ })
35830
36515
  });
35831
36516
  }
35832
36517
  export {