@codexhost/cli-win32-x64 0.30.0 → 0.31.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 (102) hide show
  1. package/README.md +1 -1
  2. package/app/codexhost-distribution.json +1 -1
  3. package/app/console-server.mjs +54 -5
  4. package/app/console-web.js +74 -7
  5. package/app/desktop-controller.mjs +60 -9
  6. package/app/host-runtime.mjs +1367 -322
  7. package/app/plugins/antigravity/plugin.mjs +54 -5
  8. package/app/plugins/claude-code/plugin.mjs +65 -13
  9. package/app/plugins/codebuddy/plugin.mjs +253 -93
  10. package/app/plugins/codex-usage/plugin.mjs +54 -5
  11. package/app/plugins/copilot/plugin.mjs +54 -5
  12. package/app/plugins/cursor-cli/plugin.mjs +54 -5
  13. package/app/plugins/deepseek-harness/plugin.mjs +54 -5
  14. package/app/plugins/devin/plugin.mjs +54 -5
  15. package/app/plugins/grok/plugin.mjs +54 -5
  16. package/app/plugins/hermes/plugin.mjs +54 -5
  17. package/app/plugins/kimi-code/plugin.mjs +54 -5
  18. package/app/plugins/kiro-cli/plugin.mjs +54 -5
  19. package/app/plugins/omp/plugin.mjs +54 -5
  20. package/app/plugins/opencode/plugin.mjs +54 -5
  21. package/app/plugins/pi/plugin.mjs +54 -5
  22. package/app/plugins/qoder/plugin.mjs +54 -5
  23. package/app/plugins/qoder-cn/plugin.mjs +54 -5
  24. package/app/plugins/qwen-code/plugin.mjs +54 -5
  25. package/app/plugins/workbuddy/plugin.mjs +253 -93
  26. package/app/plugins/zcode/plugin.mjs +54 -5
  27. package/app/renderer-extension.js +650 -413
  28. package/app/web/assets/{abnfDiagram-XWFEHMT6-BdinLox4.js → abnfDiagram-XWFEHMT6-Bqy7uOSy.js} +1 -1
  29. package/app/web/assets/{architectureDiagram-CSQXQB3N-DgPBbtvP.js → architectureDiagram-CSQXQB3N-6aaP1YoM.js} +1 -1
  30. package/app/web/assets/{blockDiagram-BEDRHYPZ-B4ENdwtZ.js → blockDiagram-BEDRHYPZ-B4QSFXe0.js} +1 -1
  31. package/app/web/assets/{c4Diagram-M2UUVUY5-DA6Owfyu.js → c4Diagram-M2UUVUY5-BYE-C8Gq.js} +1 -1
  32. package/app/web/assets/{chunk-2Q5K7J3B-Dvh3qOmo.js → chunk-2Q5K7J3B-CiEM-GTd.js} +1 -1
  33. package/app/web/assets/{chunk-3GCGMST5-VIkqueym.js → chunk-3GCGMST5-hzY9BiB1.js} +1 -1
  34. package/app/web/assets/{chunk-5VM5RSS4-DTYof_OI.js → chunk-5VM5RSS4-DYXznY0H.js} +1 -1
  35. package/app/web/assets/{chunk-7U7NFRK5-Dp7s2dg0.js → chunk-7U7NFRK5-Bzw5MDPr.js} +1 -1
  36. package/app/web/assets/{chunk-CNRTWJTD-TKBKxZLU.js → chunk-CNRTWJTD-DMbxMfi3.js} +1 -1
  37. package/app/web/assets/{chunk-D5HYT7QG-BRZDovSS.js → chunk-D5HYT7QG-By0ZVBtD.js} +1 -1
  38. package/app/web/assets/{chunk-EBZ3SEQC-C9USZ3tT.js → chunk-EBZ3SEQC-Yyu_sMV7.js} +2 -2
  39. package/app/web/assets/{chunk-JWPE2WC7-BrdvVNVo.js → chunk-JWPE2WC7-DDzqxIPT.js} +1 -1
  40. package/app/web/assets/{chunk-KTR4FSNJ-C7qwjGba.js → chunk-KTR4FSNJ-GlKqhtpl.js} +1 -1
  41. package/app/web/assets/{chunk-XXDRQBXY-DlSrRuwN.js → chunk-XXDRQBXY-DNc-CvYu.js} +1 -1
  42. package/app/web/assets/{classDiagram-v2-KXABOMEV-BFvB4kwX.js → classDiagram-v2-KXABOMEV-4_PFS2N_.js} +1 -1
  43. package/app/web/assets/{cose-bilkent-JH36ORCC-UyCAqNvj.js → cose-bilkent-JH36ORCC-BE3foHUY.js} +1 -1
  44. package/app/web/assets/{cynefin-EF2NZ3EQ-CwawUbjJ.js → cynefin-EF2NZ3EQ-D2PqrYZ3.js} +1 -1
  45. package/app/web/assets/{cynefinDiagram-NJNITYFG-BaWEIQJ0.js → cynefinDiagram-NJNITYFG-DOObpTbq.js} +1 -1
  46. package/app/web/assets/{dagre-KIHZ2IZ3-B7ENIjLG.js → dagre-KIHZ2IZ3-Znm2jin9.js} +1 -1
  47. package/app/web/assets/{diagram-7YQZDPLS-CxRMU8xq.js → diagram-7YQZDPLS-ByZMD-uA.js} +1 -1
  48. package/app/web/assets/{diagram-QBROCOUO-qo7sxm4K.js → diagram-QBROCOUO-BiRShpnN.js} +1 -1
  49. package/app/web/assets/{diagram-RJJCUUZO-CQiGMCMe.js → diagram-RJJCUUZO-D9wLVoK2.js} +1 -1
  50. package/app/web/assets/{diagram-WERXNKYE-D0Jps1As.js → diagram-WERXNKYE-BSbIh-yC.js} +1 -1
  51. package/app/web/assets/{diagram-YHHI257C-p4AB8cqK.js → diagram-YHHI257C-DMWrHMc8.js} +1 -1
  52. package/app/web/assets/{diagram-YR4HJLHV-Bh6JKT04.js → diagram-YR4HJLHV-C4sBAFb1.js} +1 -1
  53. package/app/web/assets/{ebnfDiagram-N527522P-DRac0k4W.js → ebnfDiagram-N527522P-BZLloaoQ.js} +1 -1
  54. package/app/web/assets/{elk-O5DQBFGD-CWTz5SZP.js → elk-O5DQBFGD-Da3e5tn5.js} +1 -1
  55. package/app/web/assets/{erDiagram-K3K3BIDK-DE3w4BEY.js → erDiagram-K3K3BIDK-B2lKAIZF.js} +1 -1
  56. package/app/web/assets/{flowDiagram-Z6JWZHQI-NYs8bi5t.js → flowDiagram-Z6JWZHQI-q2EY_kmB.js} +1 -1
  57. package/app/web/assets/{ganttDiagram-3PRQTZWP-Bspp9btW.js → ganttDiagram-3PRQTZWP-BGrNZ20b.js} +1 -1
  58. package/app/web/assets/{gitGraphDiagram-VXDFKS5L-ByGW1uvv.js → gitGraphDiagram-VXDFKS5L-DIZNXREy.js} +1 -1
  59. package/app/web/assets/{grid-E2QIVN74-CegebiIw.js → grid-E2QIVN74-0cUkPG69.js} +1 -1
  60. package/app/web/assets/{index-DFPOGLS4.js → index-PN7K-15_.js} +76 -76
  61. package/app/web/assets/{infoDiagram-EZ3ZOAHP-CexmsdZx.js → infoDiagram-EZ3ZOAHP-BHhUTQCn.js} +1 -1
  62. package/app/web/assets/{ishikawaDiagram-S3EKX5GW-BbWqKhg6.js → ishikawaDiagram-S3EKX5GW-DPOxtl4c.js} +1 -1
  63. package/app/web/assets/{journeyDiagram-POQNLL5X-27YlCe-1.js → journeyDiagram-POQNLL5X-D8RyXckG.js} +1 -1
  64. package/app/web/assets/{kanban-definition-BH5XI6FM-BAhOdeck.js → kanban-definition-BH5XI6FM-COJv3Hyh.js} +1 -1
  65. package/app/web/assets/{mermaid.core-sGgCbv5y.js → mermaid.core-DYdcDKIt.js} +4 -4
  66. package/app/web/assets/{mindmap-definition-WVAN44T4-CsMIX0Lj.js → mindmap-definition-WVAN44T4-DnYIM4ja.js} +1 -1
  67. package/app/web/assets/{pegDiagram-D4NLKWP3-Cs3LXqn_.js → pegDiagram-D4NLKWP3-Ds3GAEJ6.js} +1 -1
  68. package/app/web/assets/{pieDiagram-36ENHN4W-DdQsQX9I.js → pieDiagram-36ENHN4W-BhLUJGEB.js} +1 -1
  69. package/app/web/assets/{quadrantDiagram-ZQUDMS73-D1jOKqx_.js → quadrantDiagram-ZQUDMS73-DwtX-IxK.js} +1 -1
  70. package/app/web/assets/{railroadDiagram-JIZHGYPL-XulrgX5n.js → railroadDiagram-JIZHGYPL-D2vmTTnJ.js} +1 -1
  71. package/app/web/assets/{render-VIF2ZAQL-CSsGw-0I.js → render-VIF2ZAQL-DGU1ql-Z.js} +2 -2
  72. package/app/web/assets/{requirementDiagram-AXW2TVFA-CT66GXLN.js → requirementDiagram-AXW2TVFA-u3j1sKkI.js} +1 -1
  73. package/app/web/assets/{sankeyDiagram-FBCJTAIF-CNRKebNY.js → sankeyDiagram-FBCJTAIF-k-An9VHW.js} +1 -1
  74. package/app/web/assets/{sequenceDiagram-3LA2ROMG-DVl5y64e.js → sequenceDiagram-3LA2ROMG-DUjbYb4R.js} +1 -1
  75. package/app/web/assets/{sizeCapture-2Q2CQKSF-Kg0XxSga.js → sizeCapture-2Q2CQKSF-DATTL7FZ.js} +1 -1
  76. package/app/web/assets/{stateDiagram-v2-ATKHQDJO-DYQnfMsS.js → stateDiagram-v2-ATKHQDJO-cCJX5M2u.js} +1 -1
  77. package/app/web/assets/{swimlanes-YQL5WMAO-Chqt7pxD.js → swimlanes-YQL5WMAO-B7grWEWt.js} +1 -1
  78. package/app/web/assets/swimlanesDiagram-UCCPES4V-B8Jem9gq.js +8 -0
  79. package/app/web/assets/{timeline-definition-7Z437IG3-aHFxjIT6.js → timeline-definition-7Z437IG3-BhsLa6l1.js} +1 -1
  80. package/app/web/assets/{usecaseDiagram-RDK6N6HP-DsC5tFe4.js → usecaseDiagram-RDK6N6HP-CkPQYmQw.js} +1 -1
  81. package/app/web/assets/{vennDiagram-SHRQU5PJ-C65oZxFn.js → vennDiagram-SHRQU5PJ-CufZSwvw.js} +1 -1
  82. package/app/web/assets/{wardleyDiagram-F3OXNVQS-HTkq7DT0.js → wardleyDiagram-F3OXNVQS-CSkfpFOA.js} +1 -1
  83. package/app/web/assets/{xychartDiagram-GDYJKCDI-p1LpQ9MH.js → xychartDiagram-GDYJKCDI-BhZf9scK.js} +1 -1
  84. package/app/web/codexhost-settings.js +56 -56
  85. package/app/web/index.html +1 -1
  86. package/app/web/plugins/deepseek-ai__dsh-api-remotes/client.js +1 -1
  87. package/app/web/plugins/deepseek-ai__dsh-api-session-controller/client.js +8 -8
  88. package/app/web/plugins/deepseek-ai__dsh-api-workspace-controller/client.js +3 -3
  89. package/app/web/plugins/deepseek-ai__dsh-client-ui-chat/client.js +75 -75
  90. package/app/web/plugins/deepseek-ai__dsh-client-ui-codexhost/client.js +16 -16
  91. package/app/web/plugins/deepseek-ai__dsh-client-ui-conversation/client.js +16 -16
  92. package/app/web/plugins/deepseek-ai__dsh-client-ui-tool/client.js +18 -18
  93. package/app/web/plugins/deepseek-ai__dsh-client-ui-workspace/client.js +70 -72
  94. package/app/web-modules/server.mjs +383 -148
  95. package/bin/codexhost.exe +0 -0
  96. package/libexec/codexhost-node-repl.exe +0 -0
  97. package/libexec/codexhost-screenshot.exe +0 -0
  98. package/libexec/codexhost-shell.exe +0 -0
  99. package/libexec/codexhost-shim.exe +0 -0
  100. package/libexec/codexhost-updater.exe +0 -0
  101. package/package.json +1 -1
  102. package/app/web/assets/swimlanesDiagram-UCCPES4V-BfREktNP.js +0 -8
@@ -1328,10 +1328,10 @@ function mergeDefs(...defs) {
1328
1328
  function cloneDef(schema) {
1329
1329
  return mergeDefs(schema._zod.def);
1330
1330
  }
1331
- function getElementAtPath(obj, path12) {
1332
- if (!path12)
1331
+ function getElementAtPath(obj, path13) {
1332
+ if (!path13)
1333
1333
  return obj;
1334
- return path12.reduce((acc, key) => acc?.[key], obj);
1334
+ return path13.reduce((acc, key) => acc?.[key], obj);
1335
1335
  }
1336
1336
  function promiseAllObject(promisesObj) {
1337
1337
  const keys = Object.keys(promisesObj);
@@ -1671,11 +1671,11 @@ function explicitlyAborted(x, startIndex = 0) {
1671
1671
  }
1672
1672
  return false;
1673
1673
  }
1674
- function prefixIssues(path12, issues) {
1674
+ function prefixIssues(path13, issues) {
1675
1675
  return issues.map((iss) => {
1676
1676
  var _a3;
1677
1677
  (_a3 = iss).path ?? (_a3.path = []);
1678
- iss.path.unshift(path12);
1678
+ iss.path.unshift(path13);
1679
1679
  return iss;
1680
1680
  });
1681
1681
  }
@@ -2137,16 +2137,16 @@ function flattenError(error62, mapper = (issue2) => issue2.message) {
2137
2137
  }
2138
2138
  function formatError(error62, mapper = (issue2) => issue2.message) {
2139
2139
  const fieldErrors = { _errors: [] };
2140
- const processError = (error63, path12 = []) => {
2140
+ const processError = (error63, path13 = []) => {
2141
2141
  for (const issue2 of error63.issues) {
2142
2142
  if (issue2.code === "invalid_union" && issue2.errors.length) {
2143
- issue2.errors.map((issues) => processError({ issues }, [...path12, ...issue2.path]));
2143
+ issue2.errors.map((issues) => processError({ issues }, [...path13, ...issue2.path]));
2144
2144
  } else if (issue2.code === "invalid_key") {
2145
- processError({ issues: issue2.issues }, [...path12, ...issue2.path]);
2145
+ processError({ issues: issue2.issues }, [...path13, ...issue2.path]);
2146
2146
  } else if (issue2.code === "invalid_element") {
2147
- processError({ issues: issue2.issues }, [...path12, ...issue2.path]);
2147
+ processError({ issues: issue2.issues }, [...path13, ...issue2.path]);
2148
2148
  } else {
2149
- const fullpath = [...path12, ...issue2.path];
2149
+ const fullpath = [...path13, ...issue2.path];
2150
2150
  if (fullpath.length === 0) {
2151
2151
  fieldErrors._errors.push(mapper(issue2));
2152
2152
  } else {
@@ -2185,17 +2185,17 @@ function formatError(error62, mapper = (issue2) => issue2.message) {
2185
2185
  }
2186
2186
  function treeifyError(error62, mapper = (issue2) => issue2.message) {
2187
2187
  const result = { errors: [] };
2188
- const processError = (error63, path12 = []) => {
2188
+ const processError = (error63, path13 = []) => {
2189
2189
  var _a3;
2190
2190
  for (const issue2 of error63.issues) {
2191
2191
  if (issue2.code === "invalid_union" && issue2.errors.length) {
2192
- issue2.errors.map((issues) => processError({ issues }, [...path12, ...issue2.path]));
2192
+ issue2.errors.map((issues) => processError({ issues }, [...path13, ...issue2.path]));
2193
2193
  } else if (issue2.code === "invalid_key") {
2194
- processError({ issues: issue2.issues }, [...path12, ...issue2.path]);
2194
+ processError({ issues: issue2.issues }, [...path13, ...issue2.path]);
2195
2195
  } else if (issue2.code === "invalid_element") {
2196
- processError({ issues: issue2.issues }, [...path12, ...issue2.path]);
2196
+ processError({ issues: issue2.issues }, [...path13, ...issue2.path]);
2197
2197
  } else {
2198
- const fullpath = [...path12, ...issue2.path];
2198
+ const fullpath = [...path13, ...issue2.path];
2199
2199
  if (fullpath.length === 0) {
2200
2200
  result.errors.push(mapper(issue2));
2201
2201
  continue;
@@ -2234,8 +2234,8 @@ function treeifyError(error62, mapper = (issue2) => issue2.message) {
2234
2234
  }
2235
2235
  function toDotPath(_path) {
2236
2236
  const segs = [];
2237
- const path12 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
2238
- for (const seg of path12) {
2237
+ const path13 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
2238
+ for (const seg of path13) {
2239
2239
  if (typeof seg === "number")
2240
2240
  segs.push(`[${seg}]`);
2241
2241
  else if (typeof seg === "symbol")
@@ -19373,13 +19373,13 @@ function resolveRef(ref, ctx) {
19373
19373
  if (!ref.startsWith("#")) {
19374
19374
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
19375
19375
  }
19376
- const path12 = ref.slice(1).split("/").filter(Boolean);
19377
- if (path12.length === 0) {
19376
+ const path13 = ref.slice(1).split("/").filter(Boolean);
19377
+ if (path13.length === 0) {
19378
19378
  return ctx.rootSchema;
19379
19379
  }
19380
19380
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
19381
- if (path12[0] === defsKey) {
19382
- const key = path12[1] === void 0 ? void 0 : decodeJSONPointerSegment(path12[1]);
19381
+ if (path13[0] === defsKey) {
19382
+ const key = path13[1] === void 0 ? void 0 : decodeJSONPointerSegment(path13[1]);
19383
19383
  if (!key || !ctx.defs[key]) {
19384
19384
  throw new Error(`Reference not found: ${ref}`);
19385
19385
  }
@@ -21064,7 +21064,7 @@ var desktopExtensionSettingFieldSchema = external_exports.discriminatedUnion("ty
21064
21064
  default: external_exports.string().optional()
21065
21065
  })
21066
21066
  ]).superRefine((field2, ctx) => {
21067
- const issue2 = (path12, message) => ctx.addIssue({ code: "custom", path: [path12], message });
21067
+ const issue2 = (path13, message) => ctx.addIssue({ code: "custom", path: [path13], message });
21068
21068
  if (field2.type === "number" || field2.type === "range") {
21069
21069
  const { min = -Infinity, max = Infinity, default: value } = field2;
21070
21070
  if (min > max)
@@ -21170,16 +21170,16 @@ var hostExtensionIdSchema = desktopExtensionIdSchema.refine((id2) => !reservedNa
21170
21170
  var hostExtensionTargetSchema = external_exports.enum(["desktop", "web"]);
21171
21171
  var hostExtensionDigestSchema = desktopExtensionHashSchema;
21172
21172
  var hostExtensionActivationIdSchema = external_exports.uuid();
21173
- 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((path12) => path12.split("/").length <= 32, "Extension resources may be at most 32 segments deep");
21173
+ 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");
21174
21174
  var legacy = desktopExtensionManifestSchema.shape;
21175
21175
  var localized = (max, min = 0) => external_exports.strictObject({
21176
21176
  en: external_exports.string().trim().min(min).max(max),
21177
21177
  "zh-CN": external_exports.string().trim().min(min).max(max)
21178
21178
  });
21179
- var resourceWithSuffix = (suffix) => hostExtensionResourcePathSchema.refine((path12) => path12.endsWith(suffix), `Expected a ${suffix} file`);
21179
+ var resourceWithSuffix = (suffix) => hostExtensionResourcePathSchema.refine((path13) => path13.endsWith(suffix), `Expected a ${suffix} file`);
21180
21180
  var moduleEntry = resourceWithSuffix(".mjs");
21181
21181
  var style = resourceWithSuffix(".css").optional();
21182
- var hostExtensionCanonicalPath = (path12) => path12.normalize("NFC").toLowerCase();
21182
+ var hostExtensionCanonicalPath = (path13) => path13.normalize("NFC").toLowerCase();
21183
21183
  var hostExtensionManifestV2Schema = external_exports.strictObject({
21184
21184
  manifestVersion: external_exports.literal(2),
21185
21185
  id: hostExtensionIdSchema,
@@ -21189,8 +21189,8 @@ var hostExtensionManifestV2Schema = external_exports.strictObject({
21189
21189
  details: localized(16384).optional(),
21190
21190
  author: legacy.author,
21191
21191
  repository: legacy.repository,
21192
- icon: legacy.icon.refine((path12) => path12 === void 0 || hostExtensionResourcePathSchema.safeParse(path12).success),
21193
- screenshots: legacy.screenshots.refine((paths) => paths === void 0 || paths.every((path12) => hostExtensionResourcePathSchema.safeParse(path12).success)),
21192
+ icon: legacy.icon.refine((path13) => path13 === void 0 || hostExtensionResourcePathSchema.safeParse(path13).success),
21193
+ screenshots: legacy.screenshots.refine((paths) => paths === void 0 || paths.every((path13) => hostExtensionResourcePathSchema.safeParse(path13).success)),
21194
21194
  categories: legacy.categories,
21195
21195
  settingsSchema: legacy.settingsSchema,
21196
21196
  slots: legacy.slots.removeDefault().optional(),
@@ -21312,7 +21312,7 @@ var active = {
21312
21312
  digest: hostExtensionDigestSchema
21313
21313
  };
21314
21314
  var optionalActivation = { ...id, activationId: active.activationId.optional() };
21315
- var filePath = external_exports.string().min(1).max(4096).refine((path12) => /^(?:\/|[a-z]:[/\\])/iu.test(path12) && !path12.includes("\0") && !path12.split(/[/\\]/u).some((part) => part === "." || part === ".."), "Expected an absolute local path without dot segments");
21315
+ 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");
21316
21316
  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");
21317
21317
  function base643(maxBytes) {
21318
21318
  return external_exports.string().max(4 * Math.ceil(maxBytes / 3)).refine((value) => {
@@ -21628,6 +21628,45 @@ var nativeCodexGoalResultSchema = external_exports.object({
21628
21628
  // ../../shared-contracts/dist/client-channel.js
21629
21629
  var CLIENT_CHANNEL_VERSION = 1;
21630
21630
  var CLIENT_REQUEST_LIMIT_BYTES = 128 * 1024 * 1024;
21631
+ var THREAD_SECTION_CAPABILITY = "threadSectionsV1";
21632
+ var threadSectionName = external_exports.string().trim().min(1);
21633
+ var threadSectionId = external_exports.string().min(1);
21634
+ var threadSectionAppearance = external_exports.object({
21635
+ icon: external_exports.string().nullable(),
21636
+ color: external_exports.string().nullable()
21637
+ });
21638
+ var clientThreadSectionAppearanceSchema = threadSectionAppearance.nullable();
21639
+ var CLIENT_THREAD_SECTION_MUTATIONS = {
21640
+ create: {
21641
+ method: "codexhost/thread/sections/create",
21642
+ params: external_exports.object({ name: threadSectionName }).strict()
21643
+ },
21644
+ update: {
21645
+ method: "codexhost/thread/sections/update",
21646
+ params: external_exports.object({
21647
+ sectionId: threadSectionId,
21648
+ name: threadSectionName,
21649
+ appearance: threadSectionAppearance.strict().nullable().optional()
21650
+ }).strict()
21651
+ },
21652
+ delete: {
21653
+ method: "codexhost/thread/sections/delete",
21654
+ params: external_exports.object({ sectionId: threadSectionId }).strict()
21655
+ }
21656
+ };
21657
+ var clientThreadSectionMutationResultSchema = external_exports.discriminatedUnion("status", [
21658
+ external_exports.object({ status: external_exports.literal("unknown") }),
21659
+ external_exports.object({
21660
+ status: external_exports.literal("confirmed"),
21661
+ sectionId: threadSectionId,
21662
+ section: external_exports.object({
21663
+ id: threadSectionId,
21664
+ name: external_exports.string().min(1),
21665
+ appearance: clientThreadSectionAppearanceSchema
21666
+ }).nullable(),
21667
+ syncPending: external_exports.boolean()
21668
+ })
21669
+ ]);
21631
21670
  var CLIENT_CHANNEL_METHODS = [
21632
21671
  "codexhost/skills/list",
21633
21672
  "codexhost/voice/status",
@@ -21674,6 +21713,9 @@ var CLIENT_CHANNEL_METHODS = [
21674
21713
  "codexhost/thread/pins/list",
21675
21714
  "codexhost/thread/sections/list",
21676
21715
  "codexhost/thread/sections/move",
21716
+ CLIENT_THREAD_SECTION_MUTATIONS.create.method,
21717
+ CLIENT_THREAD_SECTION_MUTATIONS.update.method,
21718
+ CLIENT_THREAD_SECTION_MUTATIONS.delete.method,
21677
21719
  "codexhost/thread/pins/set",
21678
21720
  "codexhost/harness/plugins/list",
21679
21721
  "codexhost/harness/inspect",
@@ -21724,16 +21766,21 @@ var CLIENT_CHANNEL_METHODS = [
21724
21766
  "codexhost/sessions/loaded/list"
21725
21767
  ];
21726
21768
  var clientThreadSectionsSchema = external_exports.object({
21769
+ [THREAD_SECTION_CAPABILITY]: external_exports.literal(true).optional(),
21770
+ complete: external_exports.literal(false).optional(),
21727
21771
  sections: external_exports.array(external_exports.object({
21728
21772
  id: external_exports.string().min(1),
21729
21773
  name: external_exports.string().min(1),
21774
+ appearance: clientThreadSectionAppearanceSchema.optional(),
21730
21775
  threads: external_exports.array(jsonObjectSchema)
21731
- }).strict())
21732
- }).strict();
21776
+ }))
21777
+ });
21733
21778
  var clientThreadSectionMoveSchema = external_exports.object({
21734
21779
  threadId: external_exports.string().min(1).max(1024),
21735
- sectionId: external_exports.string().min(1).max(1024).nullable()
21736
- }).strict();
21780
+ sectionId: external_exports.string().min(1).max(1024).nullable(),
21781
+ beforeThreadId: external_exports.string().min(1).max(1024).nullable().optional(),
21782
+ expectedSourceSectionId: external_exports.string().min(1).max(1024).optional()
21783
+ }).refine((move) => move.expectedSourceSectionId === void 0 || move.sectionId === null);
21737
21784
  var clientThreadPinsSchema = external_exports.object({ threadIds: external_exports.array(external_exports.string().min(1)) }).strict();
21738
21785
  var clientThreadPinParamsSchema = external_exports.object({ threadId: external_exports.string().min(1).max(1024), pinned: external_exports.boolean() }).strict();
21739
21786
  var clientThreadTreeReadParamsSchema = external_exports.object({}).strict();
@@ -21780,6 +21827,7 @@ var clientChannelEventSchema = external_exports.discriminatedUnion("type", [
21780
21827
  harnessId: external_exports.string().min(1)
21781
21828
  }),
21782
21829
  external_exports.object({ type: external_exports.literal("display-settings-changed"), cursor: clientChannelCursorSchema }),
21830
+ external_exports.object({ type: external_exports.literal("sections-changed"), cursor: clientChannelCursorSchema }),
21783
21831
  external_exports.object({
21784
21832
  type: external_exports.literal("preferences-changed"),
21785
21833
  cursor: clientChannelCursorSchema,
@@ -21946,7 +21994,8 @@ var clientChannelDescriptorSchema = external_exports.object({
21946
21994
  startedAt: external_exports.number(),
21947
21995
  epoch: external_exports.string().uuid(),
21948
21996
  capabilities: external_exports.object({
21949
- peerDelegation: external_exports.literal(1).optional()
21997
+ peerDelegation: external_exports.literal(1).optional(),
21998
+ threadReferenceContext: external_exports.literal(1).optional()
21950
21999
  }).optional()
21951
22000
  });
21952
22001
  var clientChannelResponseSchema = external_exports.object({
@@ -24849,16 +24898,16 @@ var Diff = class {
24849
24898
  }
24850
24899
  }
24851
24900
  }
24852
- addToPath(path12, added, removed, oldPosInc, options) {
24853
- const last = path12.lastComponent;
24901
+ addToPath(path13, added, removed, oldPosInc, options) {
24902
+ const last = path13.lastComponent;
24854
24903
  if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
24855
24904
  return {
24856
- oldPos: path12.oldPos + oldPosInc,
24905
+ oldPos: path13.oldPos + oldPosInc,
24857
24906
  lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
24858
24907
  };
24859
24908
  } else {
24860
24909
  return {
24861
- oldPos: path12.oldPos + oldPosInc,
24910
+ oldPos: path13.oldPos + oldPosInc,
24862
24911
  lastComponent: { count: 1, added, removed, previousComponent: last }
24863
24912
  };
24864
24913
  }
@@ -26117,7 +26166,7 @@ function createCodeBuddyUsageStatistics(environment, profile) {
26117
26166
  import { stat as stat3 } from "node:fs/promises";
26118
26167
 
26119
26168
  // dist/acp-client.js
26120
- import { execFile as execFile2, spawn } from "node:child_process";
26169
+ import { spawn } from "node:child_process";
26121
26170
  import { Readable as Readable2, Writable } from "node:stream";
26122
26171
 
26123
26172
  // ../../../node_modules/@agentclientprotocol/sdk/dist/schema/index.js
@@ -30351,6 +30400,77 @@ var CodeBuddyCopyCleanup = class {
30351
30400
  }
30352
30401
  };
30353
30402
 
30403
+ // dist/process-termination.js
30404
+ import { execFile as execFile2 } from "node:child_process";
30405
+ import path8 from "node:path";
30406
+ var WINDOWS_TASKKILL_TIMEOUT_MS = 45e3;
30407
+ var MAX_DIAGNOSTIC_LENGTH = 400;
30408
+ var taskkillQueue = Promise.resolve();
30409
+ function windowsTaskkillPath(env = process.env) {
30410
+ const root = env.SystemRoot ?? env.SYSTEMROOT;
30411
+ return root && path8.win32.isAbsolute(root) ? path8.win32.join(root, "System32", "taskkill.exe") : "taskkill";
30412
+ }
30413
+ function compactDiagnostic(value) {
30414
+ const sanitized = sanitizeDiagnosticTail(value).replace(/\s+/gu, " ").trim();
30415
+ return sanitized.length <= MAX_DIAGNOSTIC_LENGTH ? sanitized : `${sanitized.slice(0, MAX_DIAGNOSTIC_LENGTH)}...`;
30416
+ }
30417
+ function formatTaskkillError(error62, stderr) {
30418
+ const info = typeof error62 === "object" && error62 !== null ? error62 : {};
30419
+ const parts = [
30420
+ ...info.code != null ? [`code=${String(info.code)}`] : [],
30421
+ ...info.signal ? [`signal=${info.signal}`] : [],
30422
+ `killed=${Boolean(info.killed)}`
30423
+ ];
30424
+ const rawStderr = typeof stderr === "string" ? stderr : Buffer.isBuffer(stderr) ? stderr.toString("utf8") : typeof info.stderr === "string" ? info.stderr : "";
30425
+ const detail = compactDiagnostic(rawStderr);
30426
+ if (detail)
30427
+ parts.push(`stderr=${detail}`);
30428
+ else {
30429
+ const message = compactDiagnostic(error62 instanceof Error ? error62.message : String(error62));
30430
+ if (message)
30431
+ parts.push(`error=${message}`);
30432
+ }
30433
+ return `taskkill failed (${parts.join(", ")})`;
30434
+ }
30435
+ async function terminateWindowsProcessTree(child, exited, timeoutMs = WINDOWS_TASKKILL_TIMEOUT_MS) {
30436
+ const exitedNow = () => child.exitCode !== null || child.signalCode !== null;
30437
+ if (!child.pid || exitedNow())
30438
+ return void 0;
30439
+ const deadline = Date.now() + timeoutMs;
30440
+ const previous = taskkillQueue;
30441
+ const slot = Promise.withResolvers();
30442
+ taskkillQueue = previous.then(() => slot.promise);
30443
+ let timer;
30444
+ const status = await Promise.race([
30445
+ previous.then(() => "ready"),
30446
+ exited.then(() => "exited"),
30447
+ new Promise((resolve) => {
30448
+ timer = setTimeout(() => resolve("timeout"), Math.max(0, deadline - Date.now()));
30449
+ })
30450
+ ]).finally(() => clearTimeout(timer));
30451
+ if (status === "exited" || exitedNow()) {
30452
+ slot.resolve();
30453
+ return void 0;
30454
+ }
30455
+ const remainingMs = deadline - Date.now();
30456
+ if (status === "timeout" || remainingMs <= 0) {
30457
+ slot.resolve();
30458
+ return `taskkill timed out waiting in termination queue after ${timeoutMs}ms`;
30459
+ }
30460
+ const execution = new Promise((resolve) => {
30461
+ try {
30462
+ execFile2(windowsTaskkillPath(), ["/PID", String(child.pid), "/T", "/F"], { windowsHide: true, timeout: remainingMs }, (error62, _stdout, stderr) => {
30463
+ slot.resolve();
30464
+ resolve(error62 ? formatTaskkillError(error62, stderr) : void 0);
30465
+ });
30466
+ } catch (error62) {
30467
+ slot.resolve();
30468
+ resolve(formatTaskkillError(error62));
30469
+ }
30470
+ });
30471
+ return Promise.race([execution, exited.then(() => void 0)]);
30472
+ }
30473
+
30354
30474
  // dist/acp-client.js
30355
30475
  var sessionEndCarrier = "codexhost.codebuddy/sessionEnd";
30356
30476
  function carrySessionEnd(message) {
@@ -30385,6 +30505,9 @@ var CodeBuddyAcpClient = class {
30385
30505
  #child;
30386
30506
  #connection;
30387
30507
  #exited;
30508
+ #exitedSettled = false;
30509
+ #closeRequested = false;
30510
+ #stdinEnded = false;
30388
30511
  #closing;
30389
30512
  #failure;
30390
30513
  #exitFailure;
@@ -30409,14 +30532,17 @@ var CodeBuddyAcpClient = class {
30409
30532
  windowsVerbatimArguments: invocation.windowsVerbatimArguments,
30410
30533
  detached: process.platform !== "win32"
30411
30534
  });
30412
- this.#exited = new Promise((resolve) => this.#child.once("close", () => resolve()));
30535
+ this.#exited = new Promise((resolve) => this.#child.once("close", () => {
30536
+ this.#exitedSettled = true;
30537
+ resolve();
30538
+ }));
30413
30539
  this.#child.stderr.on("data", () => {
30414
30540
  });
30415
30541
  this.#child.on("error", (error62) => {
30416
30542
  this.#fault(error62);
30417
30543
  });
30418
30544
  this.#child.once("exit", (code, signal) => {
30419
- if (this.#closing || this.#failure)
30545
+ if (this.#closeRequested || this.#failure)
30420
30546
  return;
30421
30547
  const error62 = new CodeBuddyError("processExited", `ACP process exited (${code ?? signal ?? "unknown"})`);
30422
30548
  this.#exitFailure = error62;
@@ -30426,14 +30552,14 @@ var CodeBuddyAcpClient = class {
30426
30552
  });
30427
30553
  this.#connection = new ClientSideConnection(() => ({
30428
30554
  sessionUpdate: async (notification) => {
30429
- if (!this.#closing && !this.#failure)
30555
+ if (!this.#closeRequested && !this.#failure)
30430
30556
  options.handlers.update(restoreSessionEnd(notification));
30431
30557
  },
30432
- requestPermission: (request) => !this.#exitFailure && !this.#closing && !this.#failure ? options.handlers.permission(request) : Promise.resolve({ outcome: { outcome: "cancelled" } }),
30558
+ requestPermission: (request) => !this.#exitFailure && !this.#closeRequested && !this.#failure ? options.handlers.permission(request) : Promise.resolve({ outcome: { outcome: "cancelled" } }),
30433
30559
  extMethod: async (method, params) => {
30434
30560
  if (method !== "_codebuddy.ai/question")
30435
30561
  throw RequestError.methodNotFound(method);
30436
- if (this.#exitFailure || this.#closing || this.#failure)
30562
+ if (this.#exitFailure || this.#closeRequested || this.#failure)
30437
30563
  return { outcome: "cancelled" };
30438
30564
  return options.handlers.question(params);
30439
30565
  }
@@ -30456,7 +30582,7 @@ var CodeBuddyAcpClient = class {
30456
30582
  };
30457
30583
  }
30458
30584
  #fault(error62) {
30459
- if (this.#closing || this.#failure)
30585
+ if (this.#closeRequested || this.#failure)
30460
30586
  return;
30461
30587
  clearTimeout(this.#exitDrainTimer);
30462
30588
  this.#failure = error62;
@@ -30470,7 +30596,7 @@ var CodeBuddyAcpClient = class {
30470
30596
  throw this.#failure;
30471
30597
  if (this.#exitFailure)
30472
30598
  throw this.#exitFailure;
30473
- if (this.#closing)
30599
+ if (this.#closeRequested)
30474
30600
  throw new CodeBuddyError("invalidState", "ACP client is closed");
30475
30601
  const work = Promise.race([operation(), this.#failed]);
30476
30602
  return label ? bounded(work, timeout, label, (error62) => this.#fault(error62)) : work;
@@ -30523,16 +30649,29 @@ var CodeBuddyAcpClient = class {
30523
30649
  throw new CodeBuddyError("protocolError", "Native question is no longer pending");
30524
30650
  }
30525
30651
  close() {
30652
+ this.#closeRequested = true;
30526
30653
  clearTimeout(this.#exitDrainTimer);
30527
30654
  this.#rejectFailure(new CodeBuddyError("invalidState", "ACP client is closed"));
30528
- this.#closing ??= this.#closeProcess();
30529
- return this.#closing;
30655
+ if (this.#closing)
30656
+ return this.#closing;
30657
+ const closing = this.#closeProcess().catch((error62) => {
30658
+ if (this.#closing === closing)
30659
+ this.#closing = void 0;
30660
+ throw error62;
30661
+ });
30662
+ this.#closing = closing;
30663
+ return closing;
30530
30664
  }
30531
30665
  async #closeProcess() {
30532
- this.#child.stdin.end();
30533
- const exited = await bounded(this.#exited.then(() => true), 1e3, "ACP shutdown").catch(() => false);
30534
- if (exited)
30666
+ if (this.#exitedSettled)
30535
30667
  return;
30668
+ if (!this.#stdinEnded) {
30669
+ this.#stdinEnded = true;
30670
+ this.#child.stdin.end();
30671
+ const exited = await bounded(this.#exited.then(() => true), 1e3, "ACP shutdown").catch(() => false);
30672
+ if (exited)
30673
+ return;
30674
+ }
30536
30675
  if (this.#child.exitCode !== null || this.#child.signalCode !== null) {
30537
30676
  this.#child.stdout.destroy();
30538
30677
  this.#child.stderr.destroy();
@@ -30540,23 +30679,31 @@ var CodeBuddyAcpClient = class {
30540
30679
  return;
30541
30680
  }
30542
30681
  const pid = this.#child.pid;
30682
+ let terminationDetail;
30543
30683
  if (pid && process.platform === "win32") {
30544
- await new Promise((resolve) => execFile2("taskkill", ["/PID", String(pid), "/T", "/F"], { windowsHide: true, timeout: 3e3 }, () => resolve()));
30684
+ terminationDetail = await terminateWindowsProcessTree(this.#child, this.#exited);
30545
30685
  } else if (pid) {
30546
30686
  try {
30547
30687
  process.kill(-pid, "SIGKILL");
30548
30688
  } catch {
30549
30689
  }
30550
30690
  }
30551
- await bounded(this.#exited, 3e3, "ACP process exit");
30691
+ try {
30692
+ await bounded(this.#exited, 3e3, "ACP process exit");
30693
+ } catch (error62) {
30694
+ if (terminationDetail && error62 instanceof CodeBuddyError) {
30695
+ throw new CodeBuddyError(error62.code, `${error62.message} (${terminationDetail})`);
30696
+ }
30697
+ throw error62;
30698
+ }
30552
30699
  }
30553
30700
  };
30554
30701
 
30555
30702
  // dist/derivation.js
30556
30703
  import { randomUUID as randomUUID2 } from "node:crypto";
30557
- import { execFile as execFile3, spawn as spawn2 } from "node:child_process";
30704
+ import { spawn as spawn2 } from "node:child_process";
30558
30705
  import { lstat as lstat2, mkdir, readFile as readFile3, realpath as realpath5, unlink, writeFile as writeFile2 } from "node:fs/promises";
30559
- import path8 from "node:path";
30706
+ import path9 from "node:path";
30560
30707
  import { isDeepStrictEqual as isDeepStrictEqual3 } from "node:util";
30561
30708
 
30562
30709
  // dist/child-provenance.js
@@ -30793,8 +30940,10 @@ async function copyCodeBuddySession(cwd, sourceId, targetId, environment, signal
30793
30940
  windowsVerbatimArguments: invocation.windowsVerbatimArguments,
30794
30941
  detached: process.platform !== "win32"
30795
30942
  });
30943
+ const exited = new Promise((resolve2) => child.once("close", () => resolve2()));
30796
30944
  let output2 = "", bytes = 0, failed = false;
30797
30945
  let termination = Promise.resolve();
30946
+ let terminationDetail;
30798
30947
  const stop = () => {
30799
30948
  if (failed)
30800
30949
  return;
@@ -30803,11 +30952,10 @@ async function copyCodeBuddySession(cwd, sourceId, targetId, environment, signal
30803
30952
  child.stdout.destroy();
30804
30953
  child.stderr.destroy();
30805
30954
  } else if (process.platform === "win32" && child.pid) {
30806
- termination = new Promise((done) => {
30807
- execFile3("taskkill", ["/PID", String(child.pid), "/T", "/F"], { windowsHide: true, timeout: 3e3 }, () => {
30955
+ termination = terminateWindowsProcessTree(child, exited).then((detail) => {
30956
+ terminationDetail = detail;
30957
+ if (child.exitCode === null && child.signalCode === null)
30808
30958
  child.kill();
30809
- done();
30810
- });
30811
30959
  });
30812
30960
  } else if (child.pid) {
30813
30961
  try {
@@ -30837,7 +30985,8 @@ async function copyCodeBuddySession(cwd, sourceId, targetId, environment, signal
30837
30985
  clearTimeout(timer);
30838
30986
  signal.removeEventListener("abort", stop);
30839
30987
  if (failed || signal.aborted || code !== 0) {
30840
- reject(new CodeBuddyError("nativeFailure", "Native history copy failed or was interrupted"));
30988
+ const message = terminationDetail ? `Native history copy failed or was interrupted (${terminationDetail})` : "Native history copy failed or was interrupted";
30989
+ reject(new CodeBuddyError("nativeFailure", message));
30841
30990
  return;
30842
30991
  }
30843
30992
  try {
@@ -30913,14 +31062,14 @@ async function bridgeCopyToTarget(sourceCwd, targetCwd, ref, contents, environme
30913
31062
  const targetFile = codeBuddyPrimaryHistoryPath(targetCwd, ref, environment, profile);
30914
31063
  if (sameResolvedPath(sourceFile, targetFile))
30915
31064
  return void 0;
30916
- const targetDirectory = path8.dirname(targetFile);
30917
- const projectsDirectory = path8.dirname(targetDirectory);
31065
+ const targetDirectory = path9.dirname(targetFile);
31066
+ const projectsDirectory = path9.dirname(targetDirectory);
30918
31067
  await mkdir(targetDirectory, { recursive: true });
30919
31068
  const [realProjects, realTargetDirectory] = await Promise.all([
30920
31069
  realpath5(projectsDirectory),
30921
31070
  realpath5(targetDirectory)
30922
31071
  ]);
30923
- if (!sameResolvedPath(realTargetDirectory, path8.join(realProjects, codeBuddyProjectSlug(targetCwd, profile))))
31072
+ if (!sameResolvedPath(realTargetDirectory, path9.join(realProjects, codeBuddyProjectSlug(targetCwd, profile))))
30924
31073
  throw new CodeBuddyError("invalidRequest", "Cross-directory history bridge target escaped the native projects root");
30925
31074
  const expected = Buffer.from(contents, "utf8");
30926
31075
  await writeFile2(targetFile, expected, { flag: "wx", mode: 384 });
@@ -31030,7 +31179,7 @@ function assertChildRanges(rows2, child) {
31030
31179
  }
31031
31180
  }
31032
31181
  async function plainDirectory(parent, name) {
31033
- const directory = path8.join(parent, name);
31182
+ const directory = path9.join(parent, name);
31034
31183
  await mkdir(directory, { mode: 448 }).catch((error62) => {
31035
31184
  if (record3(error62).code !== "EEXIST")
31036
31185
  throw error62;
@@ -31076,18 +31225,18 @@ async function copyInheritedChildren(options) {
31076
31225
  if (!references.length)
31077
31226
  return { descriptors: [], created: [] };
31078
31227
  const sourceHistoryFile = await realpath5(options.sourceHistoryFile);
31079
- const sourceProject = path8.dirname(sourceHistoryFile);
31080
- if (!sameResolvedPath(sourceHistoryFile, path8.join(sourceProject, `${options.sourceRef.nativeSessionId}.jsonl`)))
31228
+ const sourceProject = path9.dirname(sourceHistoryFile);
31229
+ if (!sameResolvedPath(sourceHistoryFile, path9.join(sourceProject, `${options.sourceRef.nativeSessionId}.jsonl`)))
31081
31230
  throw new CodeBuddyError("invalidRequest", "Unexpected source history location");
31082
- const sourceDirectory = path8.join(sourceProject, options.sourceRef.nativeSessionId, "subagents");
31231
+ const sourceDirectory = path9.join(sourceProject, options.sourceRef.nativeSessionId, "subagents");
31083
31232
  const sourceDirectoryInfo = await lstat2(sourceDirectory);
31084
31233
  if (!sourceDirectoryInfo.isDirectory() || sourceDirectoryInfo.isSymbolicLink())
31085
31234
  throw new CodeBuddyError("invalidRequest", "Redirected source Subagent directory");
31086
31235
  if (!sameResolvedPath(await realpath5(sourceDirectory), sourceDirectory))
31087
31236
  throw new CodeBuddyError("invalidRequest", "Redirected source Subagent directory");
31088
31237
  const targetHistoryFile = await realpath5(options.targetHistoryFile);
31089
- const targetProject = path8.dirname(targetHistoryFile);
31090
- if (!sameResolvedPath(targetHistoryFile, path8.join(targetProject, `${options.targetRef.nativeSessionId}.jsonl`)))
31238
+ const targetProject = path9.dirname(targetHistoryFile);
31239
+ if (!sameResolvedPath(targetHistoryFile, path9.join(targetProject, `${options.targetRef.nativeSessionId}.jsonl`)))
31091
31240
  throw new CodeBuddyError("invalidRequest", "Unexpected target history location");
31092
31241
  const targetSessionDirectory = await plainDirectory(targetProject, options.targetRef.nativeSessionId);
31093
31242
  const targetDirectory = await plainDirectory(targetSessionDirectory, "subagents");
@@ -31095,7 +31244,7 @@ async function copyInheritedChildren(options) {
31095
31244
  const created = [];
31096
31245
  try {
31097
31246
  for (const reference of references) {
31098
- const sourceFile = path8.join(sourceDirectory, `${reference.childId}.jsonl`);
31247
+ const sourceFile = path9.join(sourceDirectory, `${reference.childId}.jsonl`);
31099
31248
  const sourceInfo = await lstat2(sourceFile);
31100
31249
  if (!sourceInfo.isFile() || sourceInfo.isSymbolicLink())
31101
31250
  throw new CodeBuddyError("invalidRequest", "Redirected source Subagent transcript");
@@ -31114,7 +31263,7 @@ async function copyInheritedChildren(options) {
31114
31263
  throw new CodeBuddyError("protocolError", "Missing Agent result child range");
31115
31264
  const prefix = await codeBuddyChildPrefixThrough(source.contents, last, validated);
31116
31265
  const expected = Buffer.from(prefix.contents, "utf8");
31117
- const targetFile = path8.join(targetDirectory, `${reference.childId}.jsonl`);
31266
+ const targetFile = path9.join(targetDirectory, `${reference.childId}.jsonl`);
31118
31267
  const copy = await persistChildCopy(targetFile, expected);
31119
31268
  if (copy)
31120
31269
  created.push(copy);
@@ -31354,7 +31503,7 @@ async function deriveCodeBuddySession(options) {
31354
31503
  // dist/session-import.js
31355
31504
  import { createReadStream as createReadStream2 } from "node:fs";
31356
31505
  import { opendir, readFile as readFile4, stat as stat2 } from "node:fs/promises";
31357
- import path9 from "node:path";
31506
+ import path10 from "node:path";
31358
31507
  import { createInterface as createInterface2 } from "node:readline";
31359
31508
 
31360
31509
  // ../../harness-adapter/dist/session-import.js
@@ -31517,7 +31666,7 @@ async function readFacts(file2, signal) {
31517
31666
  return null;
31518
31667
  }
31519
31668
  const row = record3(parsed);
31520
- if (typeof row.cwd === "string" && path9.isAbsolute(row.cwd))
31669
+ if (typeof row.cwd === "string" && path10.isAbsolute(row.cwd))
31521
31670
  cwd ??= row.cwd;
31522
31671
  if (typeof row.timestamp === "number" && Number.isFinite(row.timestamp))
31523
31672
  updatedAt = row.timestamp;
@@ -31590,7 +31739,7 @@ var CodeBuddySessionImport = class {
31590
31739
  /** IDs a live native process registered in `<config>/sessions/<pid>.json`. */
31591
31740
  async #activeSessions(signal) {
31592
31741
  const active2 = /* @__PURE__ */ new Set();
31593
- const directory = path9.join(this.#root(), "sessions");
31742
+ const directory = path10.join(this.#root(), "sessions");
31594
31743
  const markers = await opendir(directory).catch((error62) => {
31595
31744
  if (isMissingFileError(error62) || record3(error62).code === "ENOTDIR")
31596
31745
  return null;
@@ -31603,7 +31752,7 @@ var CodeBuddySessionImport = class {
31603
31752
  if (!marker.isFile() || !marker.name.endsWith(".json"))
31604
31753
  continue;
31605
31754
  try {
31606
- const file2 = path9.join(directory, marker.name);
31755
+ const file2 = path10.join(directory, marker.name);
31607
31756
  if ((await stat2(file2)).size > MAX_MARKER_BYTES)
31608
31757
  continue;
31609
31758
  const entry = record3(JSON.parse(await readFile4(file2, { encoding: "utf8", signal })));
@@ -31619,7 +31768,7 @@ var CodeBuddySessionImport = class {
31619
31768
  }
31620
31769
  /** Session ID to every project file claiming it. Enumerated links are not followed. */
31621
31770
  async #sessionFiles(signal) {
31622
- const root = path9.join(this.#root(), "projects");
31771
+ const root = path10.join(this.#root(), "projects");
31623
31772
  const found = /* @__PURE__ */ new Map();
31624
31773
  const info = await optionalLstat(root);
31625
31774
  if (!info)
@@ -31630,7 +31779,7 @@ var CodeBuddySessionImport = class {
31630
31779
  signal.throwIfAborted();
31631
31780
  if (!project2.isDirectory())
31632
31781
  continue;
31633
- const projectDirectory = path9.join(root, project2.name);
31782
+ const projectDirectory = path10.join(root, project2.name);
31634
31783
  const entries = await opendir(projectDirectory).catch((error62) => {
31635
31784
  if (isMissingFileError(error62))
31636
31785
  return null;
@@ -31644,7 +31793,7 @@ var CodeBuddySessionImport = class {
31644
31793
  if (!nativeSessionId)
31645
31794
  continue;
31646
31795
  const files = found.get(nativeSessionId) ?? [];
31647
- files.push(path9.join(projectDirectory, entry.name));
31796
+ files.push(path10.join(projectDirectory, entry.name));
31648
31797
  found.set(nativeSessionId, files);
31649
31798
  }
31650
31799
  }
@@ -31659,7 +31808,7 @@ var CodeBuddySessionImport = class {
31659
31808
  const facts = await readFacts(file2, signal);
31660
31809
  if (!facts)
31661
31810
  return null;
31662
- const cwd = path9.resolve(facts.cwd);
31811
+ const cwd = path10.resolve(facts.cwd);
31663
31812
  if (!(await stat2(cwd)).isDirectory())
31664
31813
  return null;
31665
31814
  const nativeRef = nativeSessionRefSchema.parse({
@@ -31669,7 +31818,7 @@ var CodeBuddySessionImport = class {
31669
31818
  });
31670
31819
  signal.throwIfAborted();
31671
31820
  const history = await codeBuddyNativeHistory(cwd, nativeRef, this.#environment, this.#profile);
31672
- if (path9.resolve(history.file) !== path9.resolve(file2))
31821
+ if (path10.resolve(history.file) !== path10.resolve(file2))
31673
31822
  return null;
31674
31823
  const candidate = sessionImportCandidate({
31675
31824
  nativeSessionId,
@@ -31952,7 +32101,7 @@ var CodeBuddyInteractions = class {
31952
32101
 
31953
32102
  // dist/subagent-history.js
31954
32103
  import { readdir as readdir3, realpath as realpath6 } from "node:fs/promises";
31955
- import path10 from "node:path";
32104
+ import path11 from "node:path";
31956
32105
  var equalPath2 = (a, b) => process.platform === "win32" ? a.toLowerCase() === b.toLowerCase() : a === b;
31957
32106
  var MAX_CACHED_CHILDREN = 16;
31958
32107
  var CodeBuddyChildObserver = class {
@@ -32016,8 +32165,8 @@ var CodeBuddyChildObserver = class {
32016
32165
  }
32017
32166
  async #directory() {
32018
32167
  const history = await this.#parentHistory();
32019
- const project2 = path10.dirname(await realpath6(history.file));
32020
- const expected = path10.join(project2, this.parent.nativeSessionId, "subagents");
32168
+ const project2 = path11.dirname(await realpath6(history.file));
32169
+ const expected = path11.join(project2, this.parent.nativeSessionId, "subagents");
32021
32170
  const actual = await realpath6(expected);
32022
32171
  this.#assertOpen();
32023
32172
  if (!equalPath2(actual, expected))
@@ -32027,7 +32176,7 @@ var CodeBuddyChildObserver = class {
32027
32176
  async #child(directory, childId) {
32028
32177
  if (!validCodeBuddyChildId(childId))
32029
32178
  throw new CodeBuddyError("invalidRequest", "Invalid native Subagent ID");
32030
- const file2 = path10.join(directory, `${childId}.jsonl`);
32179
+ const file2 = path11.join(directory, `${childId}.jsonl`);
32031
32180
  const before = await codeBuddyFileVersion(file2);
32032
32181
  if (!equalPath2(before.realFile, file2))
32033
32182
  throw new CodeBuddyError("invalidRequest", "Redirected Subagent transcript");
@@ -32354,6 +32503,7 @@ var CodeBuddySession = class {
32354
32503
  #autonomous = new CodeBuddyAutonomousTurns();
32355
32504
  #busy = false;
32356
32505
  #closed = false;
32506
+ #closeNotified = false;
32357
32507
  #closing;
32358
32508
  #fault;
32359
32509
  #hasTurn = false;
@@ -33035,8 +33185,15 @@ var CodeBuddySession = class {
33035
33185
  this.#channel.end();
33036
33186
  }
33037
33187
  close() {
33038
- this.#closing ??= this.#close();
33039
- return this.#closing;
33188
+ if (this.#closing)
33189
+ return this.#closing;
33190
+ const closing = this.#close().catch((error62) => {
33191
+ if (this.#closing === closing)
33192
+ this.#closing = void 0;
33193
+ throw error62;
33194
+ });
33195
+ this.#closing = closing;
33196
+ return closing;
33040
33197
  }
33041
33198
  async #close() {
33042
33199
  this.#closed = true;
@@ -33053,7 +33210,10 @@ var CodeBuddySession = class {
33053
33210
  } finally {
33054
33211
  this.subagents.close();
33055
33212
  this.#channel.end();
33056
- this.onClose();
33213
+ if (!this.#closeNotified) {
33214
+ this.#closeNotified = true;
33215
+ this.onClose();
33216
+ }
33057
33217
  }
33058
33218
  }
33059
33219
  };
@@ -33278,7 +33438,7 @@ function createCodeBuddyInstallation(environment) {
33278
33438
  }
33279
33439
 
33280
33440
  // ../../harness-broker/dist/client.js
33281
- import { execFile as execFile4 } from "node:child_process";
33441
+ import { execFile as execFile3 } from "node:child_process";
33282
33442
  import { randomUUID as randomUUID4 } from "node:crypto";
33283
33443
  import { lstat as lstat4, readFile as readFile5 } from "node:fs/promises";
33284
33444
  import net, {} from "node:net";
@@ -33889,18 +34049,18 @@ function createBrokerSessionImportCapability(input3) {
33889
34049
 
33890
34050
  // ../../harness-broker/dist/paths.js
33891
34051
  import os2 from "node:os";
33892
- import path11 from "node:path";
34052
+ import path12 from "node:path";
33893
34053
  var HARNESS_BROKER_DESCRIPTOR_ENV = "CODEXHOST_CLAUDE_BROKER_DESCRIPTOR";
33894
34054
  var HARNESS_BROKER_DESCRIPTOR_FILE = "claude-code-broker-v1.json";
33895
34055
  function defaultHarnessBrokerDirectory(environment = process.env) {
33896
34056
  const home = environment.HOME || os2.homedir();
33897
- return path11.join(home, ".codexhost", "harness-broker");
34057
+ return path12.join(home, ".codexhost", "harness-broker");
33898
34058
  }
33899
34059
  function defaultHarnessBrokerDescriptorPath(environment = process.env, harnessId = "claude-code") {
33900
34060
  harnessPluginIdSchema.parse(harnessId);
33901
34061
  if (harnessId !== "claude-code")
33902
- return path11.join(defaultHarnessBrokerDirectory(environment), `${harnessId}-broker-v1.json`);
33903
- return environment[HARNESS_BROKER_DESCRIPTOR_ENV] ?? path11.join(defaultHarnessBrokerDirectory(environment), HARNESS_BROKER_DESCRIPTOR_FILE);
34062
+ return path12.join(defaultHarnessBrokerDirectory(environment), `${harnessId}-broker-v1.json`);
34063
+ return environment[HARNESS_BROKER_DESCRIPTOR_ENV] ?? path12.join(defaultHarnessBrokerDirectory(environment), HARNESS_BROKER_DESCRIPTOR_FILE);
33904
34064
  }
33905
34065
  function harnessBrokerLaunchAgentLabel(harnessId = "claude-code") {
33906
34066
  harnessPluginIdSchema.parse(harnessId);
@@ -33908,7 +34068,7 @@ function harnessBrokerLaunchAgentLabel(harnessId = "claude-code") {
33908
34068
  }
33909
34069
  function harnessBrokerLaunchAgentPlistPath(environment = process.env, harnessId = "claude-code") {
33910
34070
  const home = environment.HOME || os2.homedir();
33911
- return path11.join(home, "Library", "LaunchAgents", `${harnessBrokerLaunchAgentLabel(harnessId)}.plist`);
34071
+ return path12.join(home, "Library", "LaunchAgents", `${harnessBrokerLaunchAgentLabel(harnessId)}.plist`);
33912
34072
  }
33913
34073
 
33914
34074
  // ../../harness-broker/dist/client.js
@@ -34038,7 +34198,7 @@ function describeBrokerFailure(error62, harnessId) {
34038
34198
  }
34039
34199
  function runLaunchctl(arguments_) {
34040
34200
  return new Promise((resolve) => {
34041
- execFile4("/bin/launchctl", arguments_, { timeout: 1e4 }, (error62) => resolve(!error62));
34201
+ execFile3("/bin/launchctl", arguments_, { timeout: 1e4 }, (error62) => resolve(!error62));
34042
34202
  });
34043
34203
  }
34044
34204
  async function startBrokerLaunchAgent(harnessId, environment) {