@osfactory/har 0.24.0 → 0.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +39 -254
  2. package/dist/index.js +446 -283
  3. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -765,14 +765,14 @@ var require_url_state_machine = __commonJS({
765
765
  return url.replace(/\u0009|\u000A|\u000D/g, "");
766
766
  }
767
767
  function shortenPath(url) {
768
- const path54 = url.path;
769
- if (path54.length === 0) {
768
+ const path55 = url.path;
769
+ if (path55.length === 0) {
770
770
  return;
771
771
  }
772
- if (url.scheme === "file" && path54.length === 1 && isNormalizedWindowsDriveLetter(path54[0])) {
772
+ if (url.scheme === "file" && path55.length === 1 && isNormalizedWindowsDriveLetter(path55[0])) {
773
773
  return;
774
774
  }
775
- path54.pop();
775
+ path55.pop();
776
776
  }
777
777
  function includesCredentials(url) {
778
778
  return url.username !== "" || url.password !== "";
@@ -2092,7 +2092,7 @@ var require_lib2 = __commonJS({
2092
2092
  let accum = [];
2093
2093
  let accumBytes = 0;
2094
2094
  let abort = false;
2095
- return new Body.Promise(function(resolve38, reject) {
2095
+ return new Body.Promise(function(resolve39, reject) {
2096
2096
  let resTimeout;
2097
2097
  if (_this4.timeout) {
2098
2098
  resTimeout = setTimeout(function() {
@@ -2126,7 +2126,7 @@ var require_lib2 = __commonJS({
2126
2126
  }
2127
2127
  clearTimeout(resTimeout);
2128
2128
  try {
2129
- resolve38(Buffer.concat(accum, accumBytes));
2129
+ resolve39(Buffer.concat(accum, accumBytes));
2130
2130
  } catch (err) {
2131
2131
  reject(new FetchError(`Could not create Buffer from response body for ${_this4.url}: ${err.message}`, "system", err));
2132
2132
  }
@@ -2801,7 +2801,7 @@ var require_lib2 = __commonJS({
2801
2801
  throw new Error("native promise missing, set fetch.Promise to your favorite alternative");
2802
2802
  }
2803
2803
  Body.Promise = fetch3.Promise;
2804
- return new fetch3.Promise(function(resolve38, reject) {
2804
+ return new fetch3.Promise(function(resolve39, reject) {
2805
2805
  const request = new Request3(url, opts);
2806
2806
  const options = getNodeRequestOptions(request);
2807
2807
  const send = (options.protocol === "https:" ? https : http2).request;
@@ -2934,7 +2934,7 @@ var require_lib2 = __commonJS({
2934
2934
  requestOpts.body = void 0;
2935
2935
  requestOpts.headers.delete("content-length");
2936
2936
  }
2937
- resolve38(fetch3(new Request3(locationURL, requestOpts)));
2937
+ resolve39(fetch3(new Request3(locationURL, requestOpts)));
2938
2938
  finalize();
2939
2939
  return;
2940
2940
  }
@@ -2955,7 +2955,7 @@ var require_lib2 = __commonJS({
2955
2955
  const codings = headers.get("Content-Encoding");
2956
2956
  if (!request.compress || request.method === "HEAD" || codings === null || res.statusCode === 204 || res.statusCode === 304) {
2957
2957
  response = new Response3(body, response_options);
2958
- resolve38(response);
2958
+ resolve39(response);
2959
2959
  return;
2960
2960
  }
2961
2961
  const zlibOptions = {
@@ -2965,7 +2965,7 @@ var require_lib2 = __commonJS({
2965
2965
  if (codings == "gzip" || codings == "x-gzip") {
2966
2966
  body = body.pipe(zlib.createGunzip(zlibOptions));
2967
2967
  response = new Response3(body, response_options);
2968
- resolve38(response);
2968
+ resolve39(response);
2969
2969
  return;
2970
2970
  }
2971
2971
  if (codings == "deflate" || codings == "x-deflate") {
@@ -2977,12 +2977,12 @@ var require_lib2 = __commonJS({
2977
2977
  body = body.pipe(zlib.createInflateRaw());
2978
2978
  }
2979
2979
  response = new Response3(body, response_options);
2980
- resolve38(response);
2980
+ resolve39(response);
2981
2981
  });
2982
2982
  raw.on("end", function() {
2983
2983
  if (!response) {
2984
2984
  response = new Response3(body, response_options);
2985
- resolve38(response);
2985
+ resolve39(response);
2986
2986
  }
2987
2987
  });
2988
2988
  return;
@@ -2990,11 +2990,11 @@ var require_lib2 = __commonJS({
2990
2990
  if (codings == "br" && typeof zlib.createBrotliDecompress === "function") {
2991
2991
  body = body.pipe(zlib.createBrotliDecompress());
2992
2992
  response = new Response3(body, response_options);
2993
- resolve38(response);
2993
+ resolve39(response);
2994
2994
  return;
2995
2995
  }
2996
2996
  response = new Response3(body, response_options);
2997
- resolve38(response);
2997
+ resolve39(response);
2998
2998
  });
2999
2999
  writeToStream(req, request);
3000
3000
  });
@@ -6351,14 +6351,14 @@ __export(fileFromPath_exports, {
6351
6351
  fileFromPathSync: () => fileFromPathSync,
6352
6352
  isFile: () => isFile
6353
6353
  });
6354
- function createFileFromPath(path54, { mtimeMs, size }, filenameOrOptions, options = {}) {
6354
+ function createFileFromPath(path55, { mtimeMs, size }, filenameOrOptions, options = {}) {
6355
6355
  let filename;
6356
6356
  if (isPlainObject_default2(filenameOrOptions)) {
6357
6357
  [options, filename] = [filenameOrOptions, void 0];
6358
6358
  } else {
6359
6359
  filename = filenameOrOptions;
6360
6360
  }
6361
- const file = new FileFromPath({ path: path54, size, lastModified: mtimeMs });
6361
+ const file = new FileFromPath({ path: path55, size, lastModified: mtimeMs });
6362
6362
  if (!filename) {
6363
6363
  filename = file.name;
6364
6364
  }
@@ -6367,13 +6367,13 @@ function createFileFromPath(path54, { mtimeMs, size }, filenameOrOptions, option
6367
6367
  lastModified: file.lastModified
6368
6368
  });
6369
6369
  }
6370
- function fileFromPathSync(path54, filenameOrOptions, options = {}) {
6371
- const stats = (0, import_fs5.statSync)(path54);
6372
- return createFileFromPath(path54, stats, filenameOrOptions, options);
6370
+ function fileFromPathSync(path55, filenameOrOptions, options = {}) {
6371
+ const stats = (0, import_fs5.statSync)(path55);
6372
+ return createFileFromPath(path55, stats, filenameOrOptions, options);
6373
6373
  }
6374
- async function fileFromPath2(path54, filenameOrOptions, options) {
6375
- const stats = await import_fs5.promises.stat(path54);
6376
- return createFileFromPath(path54, stats, filenameOrOptions, options);
6374
+ async function fileFromPath2(path55, filenameOrOptions, options) {
6375
+ const stats = await import_fs5.promises.stat(path55);
6376
+ return createFileFromPath(path55, stats, filenameOrOptions, options);
6377
6377
  }
6378
6378
  var import_fs5, import_path5, import_node_domexception, __classPrivateFieldSet5, __classPrivateFieldGet6, _FileFromPath_path, _FileFromPath_start, MESSAGE, FileFromPath;
6379
6379
  var init_fileFromPath = __esm({
@@ -6625,15 +6625,15 @@ __export(otel_hooks_exports, {
6625
6625
  });
6626
6626
  function getOtelHooksHome() {
6627
6627
  if (process.env.HAR_OTEL_HOOKS_HOME) {
6628
- return path43.resolve(process.env.HAR_OTEL_HOOKS_HOME);
6628
+ return path44.resolve(process.env.HAR_OTEL_HOOKS_HOME);
6629
6629
  }
6630
- return path43.join(os13.homedir(), ".har", "otel-hooks");
6630
+ return path44.join(os13.homedir(), ".har", "otel-hooks");
6631
6631
  }
6632
6632
  function getOtelHooksConfigPath(hooksHome = getOtelHooksHome()) {
6633
- return path43.join(hooksHome, "otel_config.json");
6633
+ return path44.join(hooksHome, "otel_config.json");
6634
6634
  }
6635
6635
  function getOtelHooksWrapperPath(hooksHome = getOtelHooksHome()) {
6636
- return path43.join(hooksHome, "run-otel-hook.sh");
6636
+ return path44.join(hooksHome, "run-otel-hook.sh");
6637
6637
  }
6638
6638
  function buildOtelHooksConfig(options) {
6639
6639
  const enabled = options?.enabled ?? isTelemetryEnabled();
@@ -6802,9 +6802,9 @@ function rewriteHookCommandsToWrapper(filePath, wrapperPath) {
6802
6802
  function rewriteKnownHookRegistrations(wrapperPath) {
6803
6803
  const home = os13.homedir();
6804
6804
  const candidates = [
6805
- path43.join(home, ".cursor", "hooks.json"),
6806
- path43.join(home, ".claude", "settings.json"),
6807
- path43.join(home, ".codex", "hooks.json")
6805
+ path44.join(home, ".cursor", "hooks.json"),
6806
+ path44.join(home, ".claude", "settings.json"),
6807
+ path44.join(home, ".codex", "hooks.json")
6808
6808
  ];
6809
6809
  for (const filePath of candidates) {
6810
6810
  try {
@@ -6886,14 +6886,14 @@ function ensureOtelHooks(options) {
6886
6886
  function disableOtelHooksExport() {
6887
6887
  return writeOtelHooksConfig(buildOtelHooksConfig({ enabled: false }));
6888
6888
  }
6889
- var import_child_process10, fs41, os13, path43, OTEL_HOOKS_PACKAGE, OTEL_HOOKS_AGENTS;
6889
+ var import_child_process10, fs41, os13, path44, OTEL_HOOKS_PACKAGE, OTEL_HOOKS_AGENTS;
6890
6890
  var init_otel_hooks = __esm({
6891
6891
  "src/core/otel-hooks.ts"() {
6892
6892
  "use strict";
6893
6893
  import_child_process10 = require("child_process");
6894
6894
  fs41 = __toESM(require("fs"));
6895
6895
  os13 = __toESM(require("os"));
6896
- path43 = __toESM(require("path"));
6896
+ path44 = __toESM(require("path"));
6897
6897
  init_control_config();
6898
6898
  init_telemetry_config();
6899
6899
  OTEL_HOOKS_PACKAGE = "opentelemetry-hooks==0.14.0";
@@ -9852,7 +9852,7 @@ var require_compile = __commonJS({
9852
9852
  const schOrFunc = root.refs[ref];
9853
9853
  if (schOrFunc)
9854
9854
  return schOrFunc;
9855
- let _sch = resolve38.call(this, root, ref);
9855
+ let _sch = resolve39.call(this, root, ref);
9856
9856
  if (_sch === void 0) {
9857
9857
  const schema = (_a3 = root.localRefs) === null || _a3 === void 0 ? void 0 : _a3[ref];
9858
9858
  const { schemaId } = this.opts;
@@ -9879,7 +9879,7 @@ var require_compile = __commonJS({
9879
9879
  function sameSchemaEnv(s1, s2) {
9880
9880
  return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
9881
9881
  }
9882
- function resolve38(root, ref) {
9882
+ function resolve39(root, ref) {
9883
9883
  let sch;
9884
9884
  while (typeof (sch = this.refs[ref]) == "string")
9885
9885
  ref = sch;
@@ -10097,8 +10097,8 @@ var require_utils2 = __commonJS({
10097
10097
  }
10098
10098
  return ind;
10099
10099
  }
10100
- function removeDotSegments(path54) {
10101
- let input = path54;
10100
+ function removeDotSegments(path55) {
10101
+ let input = path55;
10102
10102
  const output = [];
10103
10103
  let nextSlash = -1;
10104
10104
  let len = 0;
@@ -10350,8 +10350,8 @@ var require_schemes = __commonJS({
10350
10350
  wsComponent.secure = void 0;
10351
10351
  }
10352
10352
  if (wsComponent.resourceName) {
10353
- const [path54, query] = wsComponent.resourceName.split("?");
10354
- wsComponent.path = path54 && path54 !== "/" ? path54 : void 0;
10353
+ const [path55, query] = wsComponent.resourceName.split("?");
10354
+ wsComponent.path = path55 && path55 !== "/" ? path55 : void 0;
10355
10355
  wsComponent.query = query;
10356
10356
  wsComponent.resourceName = void 0;
10357
10357
  }
@@ -10510,7 +10510,7 @@ var require_fast_uri = __commonJS({
10510
10510
  }
10511
10511
  return uri;
10512
10512
  }
10513
- function resolve38(baseURI, relativeURI, options) {
10513
+ function resolve39(baseURI, relativeURI, options) {
10514
10514
  const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
10515
10515
  const resolved = resolveComponent(parse4(baseURI, schemelessOptions), parse4(relativeURI, schemelessOptions), schemelessOptions, true);
10516
10516
  schemelessOptions.skipEscape = true;
@@ -10768,7 +10768,7 @@ var require_fast_uri = __commonJS({
10768
10768
  var fastUri = {
10769
10769
  SCHEMES,
10770
10770
  normalize: normalize3,
10771
- resolve: resolve38,
10771
+ resolve: resolve39,
10772
10772
  resolveComponent,
10773
10773
  equal,
10774
10774
  serialize,
@@ -14849,15 +14849,15 @@ var require_route = __commonJS({
14849
14849
  };
14850
14850
  }
14851
14851
  function wrapConversion(toModel, graph) {
14852
- const path54 = [graph[toModel].parent, toModel];
14852
+ const path55 = [graph[toModel].parent, toModel];
14853
14853
  let fn = conversions[graph[toModel].parent][toModel];
14854
14854
  let cur = graph[toModel].parent;
14855
14855
  while (graph[cur].parent) {
14856
- path54.unshift(graph[cur].parent);
14856
+ path55.unshift(graph[cur].parent);
14857
14857
  fn = link(conversions[graph[cur].parent][cur], fn);
14858
14858
  cur = graph[cur].parent;
14859
14859
  }
14860
- fn.conversion = path54;
14860
+ fn.conversion = path55;
14861
14861
  return fn;
14862
14862
  }
14863
14863
  module2.exports = function(fromModel) {
@@ -24347,16 +24347,16 @@ var require_os_tmpdir = __commonJS({
24347
24347
  var isWindows = process.platform === "win32";
24348
24348
  var trailingSlashRe = isWindows ? /[^:]\\$/ : /.\/$/;
24349
24349
  module2.exports = function() {
24350
- var path54;
24350
+ var path55;
24351
24351
  if (isWindows) {
24352
- path54 = process.env.TEMP || process.env.TMP || (process.env.SystemRoot || process.env.windir) + "\\temp";
24352
+ path55 = process.env.TEMP || process.env.TMP || (process.env.SystemRoot || process.env.windir) + "\\temp";
24353
24353
  } else {
24354
- path54 = process.env.TMPDIR || process.env.TMP || process.env.TEMP || "/tmp";
24354
+ path55 = process.env.TMPDIR || process.env.TMP || process.env.TEMP || "/tmp";
24355
24355
  }
24356
- if (trailingSlashRe.test(path54)) {
24357
- path54 = path54.slice(0, -1);
24356
+ if (trailingSlashRe.test(path55)) {
24357
+ path55 = path55.slice(0, -1);
24358
24358
  }
24359
- return path54;
24359
+ return path55;
24360
24360
  };
24361
24361
  }
24362
24362
  });
@@ -24365,7 +24365,7 @@ var require_os_tmpdir = __commonJS({
24365
24365
  var require_tmp = __commonJS({
24366
24366
  "node_modules/tmp/lib/tmp.js"(exports2, module2) {
24367
24367
  var fs46 = require("fs");
24368
- var path54 = require("path");
24368
+ var path55 = require("path");
24369
24369
  var crypto6 = require("crypto");
24370
24370
  var osTmpDir = require_os_tmpdir();
24371
24371
  var _c2 = process.binding("constants");
@@ -24407,7 +24407,7 @@ var require_tmp = __commonJS({
24407
24407
  }
24408
24408
  function _generateTmpName(opts) {
24409
24409
  if (opts.name) {
24410
- return path54.join(opts.dir || tmpDir, opts.name);
24410
+ return path55.join(opts.dir || tmpDir, opts.name);
24411
24411
  }
24412
24412
  if (opts.template) {
24413
24413
  return opts.template.replace(TEMPLATE_PATTERN, _randomChars(6));
@@ -24418,7 +24418,7 @@ var require_tmp = __commonJS({
24418
24418
  _randomChars(12),
24419
24419
  opts.postfix || ""
24420
24420
  ].join("");
24421
- return path54.join(opts.dir || tmpDir, name);
24421
+ return path55.join(opts.dir || tmpDir, name);
24422
24422
  }
24423
24423
  function tmpName(options, callback) {
24424
24424
  var args = _parseArguments(options, callback), opts = args[0], cb = args[1], tries = opts.name ? 1 : opts.tries || DEFAULT_TRIES;
@@ -24503,7 +24503,7 @@ var require_tmp = __commonJS({
24503
24503
  do {
24504
24504
  var dir2 = dirs.pop(), deferred = false, files = fs46.readdirSync(dir2);
24505
24505
  for (var i2 = 0, length = files.length; i2 < length; i2++) {
24506
- var file2 = path54.join(dir2, files[i2]), stat = fs46.lstatSync(file2);
24506
+ var file2 = path55.join(dir2, files[i2]), stat = fs46.lstatSync(file2);
24507
24507
  if (stat.isDirectory()) {
24508
24508
  if (!deferred) {
24509
24509
  deferred = true;
@@ -25714,7 +25714,7 @@ var require_Observable = __commonJS({
25714
25714
  Observable2.prototype.forEach = function(next, promiseCtor) {
25715
25715
  var _this = this;
25716
25716
  promiseCtor = getPromiseCtor(promiseCtor);
25717
- return new promiseCtor(function(resolve38, reject) {
25717
+ return new promiseCtor(function(resolve39, reject) {
25718
25718
  var subscriber = new Subscriber_1.SafeSubscriber({
25719
25719
  next: function(value) {
25720
25720
  try {
@@ -25725,7 +25725,7 @@ var require_Observable = __commonJS({
25725
25725
  }
25726
25726
  },
25727
25727
  error: reject,
25728
- complete: resolve38
25728
+ complete: resolve39
25729
25729
  });
25730
25730
  _this.subscribe(subscriber);
25731
25731
  });
@@ -25747,14 +25747,14 @@ var require_Observable = __commonJS({
25747
25747
  Observable2.prototype.toPromise = function(promiseCtor) {
25748
25748
  var _this = this;
25749
25749
  promiseCtor = getPromiseCtor(promiseCtor);
25750
- return new promiseCtor(function(resolve38, reject) {
25750
+ return new promiseCtor(function(resolve39, reject) {
25751
25751
  var value;
25752
25752
  _this.subscribe(function(x2) {
25753
25753
  return value = x2;
25754
25754
  }, function(err) {
25755
25755
  return reject(err);
25756
25756
  }, function() {
25757
- return resolve38(value);
25757
+ return resolve39(value);
25758
25758
  });
25759
25759
  });
25760
25760
  };
@@ -27850,11 +27850,11 @@ var require_innerFrom = __commonJS({
27850
27850
  "use strict";
27851
27851
  var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P2, generator) {
27852
27852
  function adopt(value) {
27853
- return value instanceof P2 ? value : new P2(function(resolve38) {
27854
- resolve38(value);
27853
+ return value instanceof P2 ? value : new P2(function(resolve39) {
27854
+ resolve39(value);
27855
27855
  });
27856
27856
  }
27857
- return new (P2 || (P2 = Promise))(function(resolve38, reject) {
27857
+ return new (P2 || (P2 = Promise))(function(resolve39, reject) {
27858
27858
  function fulfilled(value) {
27859
27859
  try {
27860
27860
  step(generator.next(value));
@@ -27870,7 +27870,7 @@ var require_innerFrom = __commonJS({
27870
27870
  }
27871
27871
  }
27872
27872
  function step(result) {
27873
- result.done ? resolve38(result.value) : adopt(result.value).then(fulfilled, rejected);
27873
+ result.done ? resolve39(result.value) : adopt(result.value).then(fulfilled, rejected);
27874
27874
  }
27875
27875
  step((generator = generator.apply(thisArg, _arguments || [])).next());
27876
27876
  });
@@ -27952,14 +27952,14 @@ var require_innerFrom = __commonJS({
27952
27952
  }, i2);
27953
27953
  function verb(n2) {
27954
27954
  i2[n2] = o2[n2] && function(v2) {
27955
- return new Promise(function(resolve38, reject) {
27956
- v2 = o2[n2](v2), settle(resolve38, reject, v2.done, v2.value);
27955
+ return new Promise(function(resolve39, reject) {
27956
+ v2 = o2[n2](v2), settle(resolve39, reject, v2.done, v2.value);
27957
27957
  });
27958
27958
  };
27959
27959
  }
27960
- function settle(resolve38, reject, d2, v2) {
27960
+ function settle(resolve39, reject, d2, v2) {
27961
27961
  Promise.resolve(v2).then(function(v3) {
27962
- resolve38({ value: v3, done: d2 });
27962
+ resolve39({ value: v3, done: d2 });
27963
27963
  }, reject);
27964
27964
  }
27965
27965
  };
@@ -28578,7 +28578,7 @@ var require_lastValueFrom = __commonJS({
28578
28578
  var EmptyError_1 = require_EmptyError();
28579
28579
  function lastValueFrom2(source, config2) {
28580
28580
  var hasConfig = typeof config2 === "object";
28581
- return new Promise(function(resolve38, reject) {
28581
+ return new Promise(function(resolve39, reject) {
28582
28582
  var _hasValue = false;
28583
28583
  var _value;
28584
28584
  source.subscribe({
@@ -28589,9 +28589,9 @@ var require_lastValueFrom = __commonJS({
28589
28589
  error: reject,
28590
28590
  complete: function() {
28591
28591
  if (_hasValue) {
28592
- resolve38(_value);
28592
+ resolve39(_value);
28593
28593
  } else if (hasConfig) {
28594
- resolve38(config2.defaultValue);
28594
+ resolve39(config2.defaultValue);
28595
28595
  } else {
28596
28596
  reject(new EmptyError_1.EmptyError());
28597
28597
  }
@@ -28613,16 +28613,16 @@ var require_firstValueFrom = __commonJS({
28613
28613
  var Subscriber_1 = require_Subscriber();
28614
28614
  function firstValueFrom(source, config2) {
28615
28615
  var hasConfig = typeof config2 === "object";
28616
- return new Promise(function(resolve38, reject) {
28616
+ return new Promise(function(resolve39, reject) {
28617
28617
  var subscriber = new Subscriber_1.SafeSubscriber({
28618
28618
  next: function(value) {
28619
- resolve38(value);
28619
+ resolve39(value);
28620
28620
  subscriber.unsubscribe();
28621
28621
  },
28622
28622
  error: reject,
28623
28623
  complete: function() {
28624
28624
  if (hasConfig) {
28625
- resolve38(config2.defaultValue);
28625
+ resolve39(config2.defaultValue);
28626
28626
  } else {
28627
28627
  reject(new EmptyError_1.EmptyError());
28628
28628
  }
@@ -34415,14 +34415,14 @@ var require_run_async = __commonJS({
34415
34415
  return function() {
34416
34416
  var args = arguments;
34417
34417
  var originalThis = this;
34418
- var promise = new Promise(function(resolve38, reject) {
34418
+ var promise = new Promise(function(resolve39, reject) {
34419
34419
  var resolved = false;
34420
34420
  const wrappedResolve = function(value) {
34421
34421
  if (resolved) {
34422
34422
  console.warn("Run-async promise already resolved.");
34423
34423
  }
34424
34424
  resolved = true;
34425
- resolve38(value);
34425
+ resolve39(value);
34426
34426
  };
34427
34427
  var rejected = false;
34428
34428
  const wrappedReject = function(value) {
@@ -35681,8 +35681,8 @@ var YargsParser = class {
35681
35681
  type = DefaultValuesForTypeKey.ARRAY;
35682
35682
  return type;
35683
35683
  }
35684
- function isUndefined(num) {
35685
- return num === void 0;
35684
+ function isUndefined(num2) {
35685
+ return num2 === void 0;
35686
35686
  }
35687
35687
  function checkConfiguration() {
35688
35688
  Object.keys(flags.counts).find((key) => {
@@ -35776,11 +35776,11 @@ var parser = new YargsParser({
35776
35776
  resolve: import_path2.resolve,
35777
35777
  // TODO: figure out a way to combine ESM and CJS coverage, such that
35778
35778
  // we can exercise all the lines below:
35779
- require: (path54) => {
35779
+ require: (path55) => {
35780
35780
  if (typeof require !== "undefined") {
35781
- return require(path54);
35782
- } else if (path54.match(/\.json$/)) {
35783
- return JSON.parse((0, import_fs2.readFileSync)(path54, "utf8"));
35781
+ return require(path55);
35782
+ } else if (path55.match(/\.json$/)) {
35783
+ return JSON.parse((0, import_fs2.readFileSync)(path55, "utf8"));
35784
35784
  } else {
35785
35785
  throw Error("only .json config files are supported in ESM");
35786
35786
  }
@@ -37689,8 +37689,8 @@ ${customMsgs.join("\n")}` : "";
37689
37689
  return implied;
37690
37690
  };
37691
37691
  function keyExists(argv, val) {
37692
- const num = Number(val);
37693
- val = isNaN(num) ? val : num;
37692
+ const num2 = Number(val);
37693
+ val = isNaN(num2) ? val : num2;
37694
37694
  if (typeof val === "number") {
37695
37695
  val = argv._.length >= val;
37696
37696
  } else if (val.match(/^--no-.+/)) {
@@ -38306,12 +38306,12 @@ var YargsInstance = class {
38306
38306
  async getCompletion(args, done) {
38307
38307
  argsert("<array> [function]", [args, done], arguments.length);
38308
38308
  if (!done) {
38309
- return new Promise((resolve38, reject) => {
38309
+ return new Promise((resolve39, reject) => {
38310
38310
  __classPrivateFieldGet(this, _YargsInstance_completion, "f").getCompletion(args, (err, completions) => {
38311
38311
  if (err)
38312
38312
  reject(err);
38313
38313
  else
38314
- resolve38(completions);
38314
+ resolve39(completions);
38315
38315
  });
38316
38316
  });
38317
38317
  } else {
@@ -40461,8 +40461,8 @@ function getErrorMap() {
40461
40461
 
40462
40462
  // node_modules/zod/v3/helpers/parseUtil.js
40463
40463
  var makeIssue = (params) => {
40464
- const { data, path: path54, errorMaps, issueData } = params;
40465
- const fullPath = [...path54, ...issueData.path || []];
40464
+ const { data, path: path55, errorMaps, issueData } = params;
40465
+ const fullPath = [...path55, ...issueData.path || []];
40466
40466
  const fullIssue = {
40467
40467
  ...issueData,
40468
40468
  path: fullPath
@@ -40578,11 +40578,11 @@ var errorUtil;
40578
40578
 
40579
40579
  // node_modules/zod/v3/types.js
40580
40580
  var ParseInputLazyPath = class {
40581
- constructor(parent, value, path54, key) {
40581
+ constructor(parent, value, path55, key) {
40582
40582
  this._cachedPath = [];
40583
40583
  this.parent = parent;
40584
40584
  this.data = value;
40585
- this._path = path54;
40585
+ this._path = path55;
40586
40586
  this._key = key;
40587
40587
  }
40588
40588
  get path() {
@@ -44721,16 +44721,16 @@ async function handleAgentSkills(options) {
44721
44721
  }
44722
44722
  async function askYesNo(question) {
44723
44723
  const rl = readline.createInterface({ input: process.stdin, output: process.stderr });
44724
- return new Promise((resolve38) => {
44724
+ return new Promise((resolve39) => {
44725
44725
  process.stderr.write(`${question} `);
44726
44726
  rl.once("line", (answer) => {
44727
44727
  rl.close();
44728
44728
  const trimmed = answer.trim();
44729
44729
  if (trimmed === "") {
44730
- resolve38(true);
44730
+ resolve39(true);
44731
44731
  return;
44732
44732
  }
44733
- resolve38(/^y(es)?$/i.test(trimmed));
44733
+ resolve39(/^y(es)?$/i.test(trimmed));
44734
44734
  });
44735
44735
  });
44736
44736
  }
@@ -44809,7 +44809,7 @@ function handleRemove(argv) {
44809
44809
  }
44810
44810
 
44811
44811
  // src/cli/commands/env.ts
44812
- var path47 = __toESM(require("path"));
44812
+ var path48 = __toESM(require("path"));
44813
44813
 
44814
44814
  // src/core/harness.ts
44815
44815
  var fs20 = __toESM(require("fs"));
@@ -45588,13 +45588,13 @@ var MultipartBody = class {
45588
45588
  // node_modules/@anthropic-ai/sdk/_shims/node-runtime.mjs
45589
45589
  var import_web = require("node:stream/web");
45590
45590
  var fileFromPathWarned = false;
45591
- async function fileFromPath3(path54, ...args) {
45591
+ async function fileFromPath3(path55, ...args) {
45592
45592
  const { fileFromPath: _fileFromPath } = await Promise.resolve().then(() => (init_fileFromPath(), fileFromPath_exports));
45593
45593
  if (!fileFromPathWarned) {
45594
- console.warn(`fileFromPath is deprecated; use fs.createReadStream(${JSON.stringify(path54)}) instead`);
45594
+ console.warn(`fileFromPath is deprecated; use fs.createReadStream(${JSON.stringify(path55)}) instead`);
45595
45595
  fileFromPathWarned = true;
45596
45596
  }
45597
- return await _fileFromPath(path54, ...args);
45597
+ return await _fileFromPath(path55, ...args);
45598
45598
  }
45599
45599
  var defaultHttpAgent = new import_agentkeepalive.default({ keepAlive: true, timeout: 5 * 60 * 1e3 });
45600
45600
  var defaultHttpsAgent = new import_agentkeepalive.default.HttpsAgent({ keepAlive: true, timeout: 5 * 60 * 1e3 });
@@ -46090,8 +46090,8 @@ async function defaultParseResponse(props) {
46090
46090
  }
46091
46091
  var APIPromise = class _APIPromise extends Promise {
46092
46092
  constructor(responsePromise, parseResponse = defaultParseResponse) {
46093
- super((resolve38) => {
46094
- resolve38(null);
46093
+ super((resolve39) => {
46094
+ resolve39(null);
46095
46095
  });
46096
46096
  this.responsePromise = responsePromise;
46097
46097
  this.parseResponse = parseResponse;
@@ -46191,29 +46191,29 @@ var APIClient = class {
46191
46191
  defaultIdempotencyKey() {
46192
46192
  return `stainless-node-retry-${uuid4()}`;
46193
46193
  }
46194
- get(path54, opts) {
46195
- return this.methodRequest("get", path54, opts);
46194
+ get(path55, opts) {
46195
+ return this.methodRequest("get", path55, opts);
46196
46196
  }
46197
- post(path54, opts) {
46198
- return this.methodRequest("post", path54, opts);
46197
+ post(path55, opts) {
46198
+ return this.methodRequest("post", path55, opts);
46199
46199
  }
46200
- patch(path54, opts) {
46201
- return this.methodRequest("patch", path54, opts);
46200
+ patch(path55, opts) {
46201
+ return this.methodRequest("patch", path55, opts);
46202
46202
  }
46203
- put(path54, opts) {
46204
- return this.methodRequest("put", path54, opts);
46203
+ put(path55, opts) {
46204
+ return this.methodRequest("put", path55, opts);
46205
46205
  }
46206
- delete(path54, opts) {
46207
- return this.methodRequest("delete", path54, opts);
46206
+ delete(path55, opts) {
46207
+ return this.methodRequest("delete", path55, opts);
46208
46208
  }
46209
- methodRequest(method, path54, opts) {
46209
+ methodRequest(method, path55, opts) {
46210
46210
  return this.request(Promise.resolve(opts).then(async (opts2) => {
46211
46211
  const body = opts2 && isBlobLike(opts2?.body) ? new DataView(await opts2.body.arrayBuffer()) : opts2?.body instanceof DataView ? opts2.body : opts2?.body instanceof ArrayBuffer ? new DataView(opts2.body) : opts2 && ArrayBuffer.isView(opts2?.body) ? new DataView(opts2.body.buffer) : opts2?.body;
46212
- return { method, path: path54, ...opts2, body };
46212
+ return { method, path: path55, ...opts2, body };
46213
46213
  }));
46214
46214
  }
46215
- getAPIList(path54, Page, opts) {
46216
- return this.requestAPIList(Page, { method: "get", path: path54, ...opts });
46215
+ getAPIList(path55, Page, opts) {
46216
+ return this.requestAPIList(Page, { method: "get", path: path55, ...opts });
46217
46217
  }
46218
46218
  calculateContentLength(body) {
46219
46219
  if (typeof body === "string") {
@@ -46231,10 +46231,10 @@ var APIClient = class {
46231
46231
  return null;
46232
46232
  }
46233
46233
  buildRequest(options) {
46234
- const { method, path: path54, query, headers = {} } = options;
46234
+ const { method, path: path55, query, headers = {} } = options;
46235
46235
  const body = ArrayBuffer.isView(options.body) || options.__binaryRequest && typeof options.body === "string" ? options.body : isMultipartBody(options.body) ? options.body.body : options.body ? JSON.stringify(options.body, null, 2) : null;
46236
46236
  const contentLength = this.calculateContentLength(body);
46237
- const url = this.buildURL(path54, query);
46237
+ const url = this.buildURL(path55, query);
46238
46238
  if ("timeout" in options)
46239
46239
  validatePositiveInteger("timeout", options.timeout);
46240
46240
  const timeout = options.timeout ?? this.timeout;
@@ -46343,8 +46343,8 @@ var APIClient = class {
46343
46343
  const request = this.makeRequest(options, null);
46344
46344
  return new PagePromise(this, request, Page);
46345
46345
  }
46346
- buildURL(path54, query) {
46347
- const url = isAbsoluteURL(path54) ? new URL(path54) : new URL(this.baseURL + (this.baseURL.endsWith("/") && path54.startsWith("/") ? path54.slice(1) : path54));
46346
+ buildURL(path55, query) {
46347
+ const url = isAbsoluteURL(path55) ? new URL(path55) : new URL(this.baseURL + (this.baseURL.endsWith("/") && path55.startsWith("/") ? path55.slice(1) : path55));
46348
46348
  const defaultQuery = this.defaultQuery();
46349
46349
  if (!isEmptyObj(defaultQuery)) {
46350
46350
  query = { ...defaultQuery, ...query };
@@ -46629,7 +46629,7 @@ var startsWithSchemeRegexp = new RegExp("^(?:[a-z]+:)?//", "i");
46629
46629
  var isAbsoluteURL = (url) => {
46630
46630
  return startsWithSchemeRegexp.test(url);
46631
46631
  };
46632
- var sleep = (ms) => new Promise((resolve38) => setTimeout(resolve38, ms));
46632
+ var sleep = (ms) => new Promise((resolve39) => setTimeout(resolve39, ms));
46633
46633
  var validatePositiveInteger = (name, n2) => {
46634
46634
  if (typeof n2 !== "number" || !Number.isInteger(n2)) {
46635
46635
  throw new AnthropicError(`${name} must be an integer`);
@@ -47120,12 +47120,12 @@ var PromptCachingBetaMessageStream = class _PromptCachingBetaMessageStream {
47120
47120
  }
47121
47121
  return this._emit("error", new AnthropicError(String(error3)));
47122
47122
  });
47123
- __classPrivateFieldSet7(this, _PromptCachingBetaMessageStream_connectedPromise, new Promise((resolve38, reject) => {
47124
- __classPrivateFieldSet7(this, _PromptCachingBetaMessageStream_resolveConnectedPromise, resolve38, "f");
47123
+ __classPrivateFieldSet7(this, _PromptCachingBetaMessageStream_connectedPromise, new Promise((resolve39, reject) => {
47124
+ __classPrivateFieldSet7(this, _PromptCachingBetaMessageStream_resolveConnectedPromise, resolve39, "f");
47125
47125
  __classPrivateFieldSet7(this, _PromptCachingBetaMessageStream_rejectConnectedPromise, reject, "f");
47126
47126
  }), "f");
47127
- __classPrivateFieldSet7(this, _PromptCachingBetaMessageStream_endPromise, new Promise((resolve38, reject) => {
47128
- __classPrivateFieldSet7(this, _PromptCachingBetaMessageStream_resolveEndPromise, resolve38, "f");
47127
+ __classPrivateFieldSet7(this, _PromptCachingBetaMessageStream_endPromise, new Promise((resolve39, reject) => {
47128
+ __classPrivateFieldSet7(this, _PromptCachingBetaMessageStream_resolveEndPromise, resolve39, "f");
47129
47129
  __classPrivateFieldSet7(this, _PromptCachingBetaMessageStream_rejectEndPromise, reject, "f");
47130
47130
  }), "f");
47131
47131
  __classPrivateFieldGet8(this, _PromptCachingBetaMessageStream_connectedPromise, "f").catch(() => {
@@ -47254,11 +47254,11 @@ var PromptCachingBetaMessageStream = class _PromptCachingBetaMessageStream {
47254
47254
  * const message = await stream.emitted('message') // rejects if the stream errors
47255
47255
  */
47256
47256
  emitted(event) {
47257
- return new Promise((resolve38, reject) => {
47257
+ return new Promise((resolve39, reject) => {
47258
47258
  __classPrivateFieldSet7(this, _PromptCachingBetaMessageStream_catchingPromiseCreated, true, "f");
47259
47259
  if (event !== "error")
47260
47260
  this.once("error", reject);
47261
- this.once(event, resolve38);
47261
+ this.once(event, resolve39);
47262
47262
  });
47263
47263
  }
47264
47264
  async done() {
@@ -47485,7 +47485,7 @@ var PromptCachingBetaMessageStream = class _PromptCachingBetaMessageStream {
47485
47485
  if (done) {
47486
47486
  return { value: void 0, done: true };
47487
47487
  }
47488
- return new Promise((resolve38, reject) => readQueue.push({ resolve: resolve38, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
47488
+ return new Promise((resolve39, reject) => readQueue.push({ resolve: resolve39, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
47489
47489
  }
47490
47490
  const chunk = pushQueue.shift();
47491
47491
  return { value: chunk, done: false };
@@ -47633,12 +47633,12 @@ var MessageStream = class _MessageStream {
47633
47633
  }
47634
47634
  return this._emit("error", new AnthropicError(String(error3)));
47635
47635
  });
47636
- __classPrivateFieldSet8(this, _MessageStream_connectedPromise, new Promise((resolve38, reject) => {
47637
- __classPrivateFieldSet8(this, _MessageStream_resolveConnectedPromise, resolve38, "f");
47636
+ __classPrivateFieldSet8(this, _MessageStream_connectedPromise, new Promise((resolve39, reject) => {
47637
+ __classPrivateFieldSet8(this, _MessageStream_resolveConnectedPromise, resolve39, "f");
47638
47638
  __classPrivateFieldSet8(this, _MessageStream_rejectConnectedPromise, reject, "f");
47639
47639
  }), "f");
47640
- __classPrivateFieldSet8(this, _MessageStream_endPromise, new Promise((resolve38, reject) => {
47641
- __classPrivateFieldSet8(this, _MessageStream_resolveEndPromise, resolve38, "f");
47640
+ __classPrivateFieldSet8(this, _MessageStream_endPromise, new Promise((resolve39, reject) => {
47641
+ __classPrivateFieldSet8(this, _MessageStream_resolveEndPromise, resolve39, "f");
47642
47642
  __classPrivateFieldSet8(this, _MessageStream_rejectEndPromise, reject, "f");
47643
47643
  }), "f");
47644
47644
  __classPrivateFieldGet9(this, _MessageStream_connectedPromise, "f").catch(() => {
@@ -47767,11 +47767,11 @@ var MessageStream = class _MessageStream {
47767
47767
  * const message = await stream.emitted('message') // rejects if the stream errors
47768
47768
  */
47769
47769
  emitted(event) {
47770
- return new Promise((resolve38, reject) => {
47770
+ return new Promise((resolve39, reject) => {
47771
47771
  __classPrivateFieldSet8(this, _MessageStream_catchingPromiseCreated, true, "f");
47772
47772
  if (event !== "error")
47773
47773
  this.once("error", reject);
47774
- this.once(event, resolve38);
47774
+ this.once(event, resolve39);
47775
47775
  });
47776
47776
  }
47777
47777
  async done() {
@@ -47998,7 +47998,7 @@ var MessageStream = class _MessageStream {
47998
47998
  if (done) {
47999
47999
  return { value: void 0, done: true };
48000
48000
  }
48001
- return new Promise((resolve38, reject) => readQueue.push({ resolve: resolve38, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
48001
+ return new Promise((resolve39, reject) => readQueue.push({ resolve: resolve39, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
48002
48002
  }
48003
48003
  const chunk = pushQueue.shift();
48004
48004
  return { value: chunk, done: false };
@@ -48258,11 +48258,11 @@ async function promptApplyAgentMdProposal(repoPath) {
48258
48258
  }
48259
48259
  async function askYesNo2(question) {
48260
48260
  const rl = readline2.createInterface({ input: process.stdin, output: process.stderr });
48261
- return new Promise((resolve38) => {
48261
+ return new Promise((resolve39) => {
48262
48262
  process.stderr.write(`${question} `);
48263
48263
  rl.once("line", (answer) => {
48264
48264
  rl.close();
48265
- resolve38(/^y(es)?$/i.test(answer.trim()));
48265
+ resolve39(/^y(es)?$/i.test(answer.trim()));
48266
48266
  });
48267
48267
  });
48268
48268
  }
@@ -48492,7 +48492,7 @@ async function executeAuthoringToolCall(toolName, input, repoPath, harnessDir, c
48492
48492
  }
48493
48493
  async function askUser(question, options) {
48494
48494
  const rl = readline3.createInterface({ input: process.stdin, output: process.stderr });
48495
- return new Promise((resolve38) => {
48495
+ return new Promise((resolve39) => {
48496
48496
  process.stderr.write("\n");
48497
48497
  process.stderr.write(`\u2753 ${question}
48498
48498
  `);
@@ -48503,7 +48503,7 @@ async function askUser(question, options) {
48503
48503
  process.stderr.write("> ");
48504
48504
  rl.once("line", (answer) => {
48505
48505
  rl.close();
48506
- resolve38(answer.trim());
48506
+ resolve39(answer.trim());
48507
48507
  });
48508
48508
  });
48509
48509
  }
@@ -48647,7 +48647,7 @@ function runScript(scriptPath, args = [], options = {}) {
48647
48647
  function runScriptCapture(scriptPath, args = [], options = {}) {
48648
48648
  const stream = options.stream ?? false;
48649
48649
  const { stream: _stream, ...spawnOptions } = options;
48650
- return new Promise((resolve38) => {
48650
+ return new Promise((resolve39) => {
48651
48651
  const proc = (0, import_child_process.spawn)("bash", [scriptPath, ...args], {
48652
48652
  ...spawnOptions,
48653
48653
  stdio: ["inherit", "pipe", "pipe"]
@@ -48662,13 +48662,13 @@ function runScriptCapture(scriptPath, args = [], options = {}) {
48662
48662
  stderr += d2;
48663
48663
  if (stream) process.stderr.write(d2);
48664
48664
  });
48665
- proc.on("close", (code) => resolve38({ stdout, stderr, code: code ?? 0 }));
48665
+ proc.on("close", (code) => resolve39({ stdout, stderr, code: code ?? 0 }));
48666
48666
  });
48667
48667
  }
48668
48668
  function runShellCommand(command2, options = {}) {
48669
48669
  const stream = options.stream ?? false;
48670
48670
  const { stream: _stream, ...spawnOptions } = options;
48671
- return new Promise((resolve38) => {
48671
+ return new Promise((resolve39) => {
48672
48672
  const proc = (0, import_child_process.spawn)("bash", ["-lc", command2], {
48673
48673
  ...spawnOptions,
48674
48674
  stdio: ["inherit", "pipe", "pipe"]
@@ -48683,7 +48683,7 @@ function runShellCommand(command2, options = {}) {
48683
48683
  stderr += d2;
48684
48684
  if (stream) process.stderr.write(d2);
48685
48685
  });
48686
- proc.on("close", (code) => resolve38({ stdout, stderr, code: code ?? 0 }));
48686
+ proc.on("close", (code) => resolve39({ stdout, stderr, code: code ?? 0 }));
48687
48687
  });
48688
48688
  }
48689
48689
 
@@ -49513,12 +49513,12 @@ function requireApiKey() {
49513
49513
  return key;
49514
49514
  }
49515
49515
  function validateAgentId(id, repoPath) {
49516
- const num = Number(id);
49516
+ const num2 = Number(id);
49517
49517
  const range = getAgentSlotRange(repoPath);
49518
- if (!Number.isInteger(num) || num < range.min || num > range.max) {
49518
+ if (!Number.isInteger(num2) || num2 < range.min || num2 > range.max) {
49519
49519
  throw new Error(`agent-id must be a number between ${range.min} and ${range.max}`);
49520
49520
  }
49521
- return num;
49521
+ return num2;
49522
49522
  }
49523
49523
 
49524
49524
  // src/core/harness.ts
@@ -49866,12 +49866,12 @@ function printAdaptationPrompt(content) {
49866
49866
  }
49867
49867
  function askYesNo3(question) {
49868
49868
  const rl = readline4.createInterface({ input: process.stdin, output: process.stderr });
49869
- return new Promise((resolve38) => {
49869
+ return new Promise((resolve39) => {
49870
49870
  process.stderr.write(`${question} `);
49871
49871
  rl.once("line", (answer) => {
49872
49872
  rl.close();
49873
49873
  const trimmed = answer.trim();
49874
- resolve38(trimmed === "" || /^y(es)?$/i.test(trimmed));
49874
+ resolve39(trimmed === "" || /^y(es)?$/i.test(trimmed));
49875
49875
  });
49876
49876
  });
49877
49877
  }
@@ -49958,16 +49958,16 @@ async function promptScaffoldCursorRule(exists) {
49958
49958
  }
49959
49959
  async function askYesNo4(question) {
49960
49960
  const rl = readline5.createInterface({ input: process.stdin, output: process.stderr });
49961
- return new Promise((resolve38) => {
49961
+ return new Promise((resolve39) => {
49962
49962
  process.stderr.write(`${question} `);
49963
49963
  rl.once("line", (answer) => {
49964
49964
  rl.close();
49965
49965
  const trimmed = answer.trim();
49966
49966
  if (trimmed === "") {
49967
- resolve38(true);
49967
+ resolve39(true);
49968
49968
  return;
49969
49969
  }
49970
- resolve38(/^y(es)?$/i.test(trimmed));
49970
+ resolve39(/^y(es)?$/i.test(trimmed));
49971
49971
  });
49972
49972
  });
49973
49973
  }
@@ -50277,7 +50277,7 @@ var LocalScriptExecutor = class {
50277
50277
  var localScriptExecutor = new LocalScriptExecutor();
50278
50278
 
50279
50279
  // src/core/control-sync.ts
50280
- var path41 = __toESM(require("path"));
50280
+ var path42 = __toESM(require("path"));
50281
50281
  init_control_config();
50282
50282
 
50283
50283
  // src/core/control-registry.ts
@@ -52132,6 +52132,166 @@ function harvestEventsForSlot(slot) {
52132
52132
  return harvestClaudeEvents(slot);
52133
52133
  }
52134
52134
 
52135
+ // src/core/control-persisted-usage.ts
52136
+ var path41 = __toESM(require("path"));
52137
+ var FETCH_TIMEOUT_MS = 3e3;
52138
+ async function getJson(url) {
52139
+ try {
52140
+ const response = await fetch(url, {
52141
+ method: "GET",
52142
+ signal: AbortSignal.timeout(FETCH_TIMEOUT_MS)
52143
+ });
52144
+ if (!response.ok) return null;
52145
+ return await response.json();
52146
+ } catch {
52147
+ return null;
52148
+ }
52149
+ }
52150
+ async function resolveControlRepoId(apiUrl, repoPath) {
52151
+ const repos = await getJson(`${apiUrl}/api/repos`);
52152
+ if (!Array.isArray(repos)) return null;
52153
+ const target = path41.resolve(repoPath);
52154
+ return repos.find((repo) => path41.resolve(repo.path) === target)?.id ?? null;
52155
+ }
52156
+ function optionalString(value) {
52157
+ return value == null ? void 0 : value;
52158
+ }
52159
+ function toSources(value) {
52160
+ if (!Array.isArray(value)) return [];
52161
+ return value.filter((v2) => v2 === "otel" || v2 === "harvest");
52162
+ }
52163
+ function normalizeUsage(row) {
52164
+ return {
52165
+ sessionKey: row.sessionKey,
52166
+ agentId: row.agentId,
52167
+ agentTool: row.agentTool,
52168
+ ...optionalString(row.workDir) !== void 0 ? { workDir: row.workDir } : {},
52169
+ ...optionalString(row.branch) !== void 0 ? { branch: row.branch } : {},
52170
+ ...optionalString(row.suffix) !== void 0 ? { suffix: row.suffix } : {},
52171
+ ...optionalString(row.workUnitId) !== void 0 ? { workUnitId: row.workUnitId } : {},
52172
+ ...optionalString(row.attemptId) !== void 0 ? { attemptId: row.attemptId } : {},
52173
+ tokensInput: Number(row.tokensInput ?? 0),
52174
+ tokensOutput: Number(row.tokensOutput ?? 0),
52175
+ tokensCacheRead: Number(row.tokensCacheRead ?? 0),
52176
+ tokensCacheCreation: Number(row.tokensCacheCreation ?? 0),
52177
+ tokensTotal: Number(row.tokensTotal ?? 0),
52178
+ costUsd: row.costUsd == null ? null : Number(row.costUsd),
52179
+ ...row.modelBreakdown ? { modelBreakdown: row.modelBreakdown } : {},
52180
+ sources: toSources(row.sources),
52181
+ firstSeenAt: row.firstSeenAt,
52182
+ lastSeenAt: row.lastSeenAt
52183
+ };
52184
+ }
52185
+ function normalizeEvent(row) {
52186
+ return {
52187
+ sessionKey: row.sessionKey,
52188
+ agentId: row.agentId,
52189
+ agentTool: row.agentTool,
52190
+ eventName: row.eventName,
52191
+ sequence: Number(row.sequence ?? 0),
52192
+ timestamp: row.timestamp,
52193
+ ...optionalString(row.workUnitId) !== void 0 ? { workUnitId: row.workUnitId } : {},
52194
+ ...optionalString(row.attemptId) !== void 0 ? { attemptId: row.attemptId } : {},
52195
+ ...row.attributes ? { attributes: row.attributes } : {},
52196
+ promptText: row.promptText ?? null,
52197
+ responseText: row.responseText ?? null,
52198
+ rawTruncated: row.rawTruncated ?? null,
52199
+ source: row.source === "harvest" ? "harvest" : "otel"
52200
+ };
52201
+ }
52202
+ async function fetchPersistedPortalTelemetry(repoPath, apiUrl) {
52203
+ const repoId = await resolveControlRepoId(apiUrl, repoPath);
52204
+ if (!repoId) return { usage: [], events: [] };
52205
+ const [usageResponse, eventsResponse] = await Promise.all([
52206
+ getJson(`${apiUrl}/api/repos/${repoId}/usage`),
52207
+ getJson(`${apiUrl}/api/repos/${repoId}/events`)
52208
+ ]);
52209
+ return {
52210
+ usage: (usageResponse?.usage ?? []).map(normalizeUsage),
52211
+ events: (eventsResponse?.events ?? []).map(normalizeEvent)
52212
+ };
52213
+ }
52214
+
52215
+ // src/core/portal-usage-merge.ts
52216
+ var KEY_SEP = "\0";
52217
+ function usageKey(row) {
52218
+ return `${row.sessionKey}${KEY_SEP}${row.agentTool}`;
52219
+ }
52220
+ function eventKey(event) {
52221
+ return [event.sessionKey, event.agentTool, event.eventName, event.sequence ?? 0].join(KEY_SEP);
52222
+ }
52223
+ function num(value) {
52224
+ return typeof value === "number" && Number.isFinite(value) ? value : 0;
52225
+ }
52226
+ function earlier(a2, b2) {
52227
+ return new Date(a2).getTime() <= new Date(b2).getTime() ? a2 : b2;
52228
+ }
52229
+ function later(a2, b2) {
52230
+ return new Date(a2).getTime() >= new Date(b2).getTime() ? a2 : b2;
52231
+ }
52232
+ function mergeModelBreakdown(a2, b2) {
52233
+ if (!a2) return b2;
52234
+ if (!b2) return a2;
52235
+ const out = {};
52236
+ for (const model of /* @__PURE__ */ new Set([...Object.keys(a2), ...Object.keys(b2)])) {
52237
+ const left2 = a2[model];
52238
+ const right2 = b2[model];
52239
+ if (left2 && typeof left2 === "object" && right2 && typeof right2 === "object") {
52240
+ const l2 = left2;
52241
+ const r2 = right2;
52242
+ const totals = {};
52243
+ for (const field of /* @__PURE__ */ new Set([...Object.keys(l2), ...Object.keys(r2)])) {
52244
+ totals[field] = Math.max(num(l2[field]), num(r2[field]));
52245
+ }
52246
+ out[model] = totals;
52247
+ } else {
52248
+ out[model] = right2 ?? left2;
52249
+ }
52250
+ }
52251
+ return out;
52252
+ }
52253
+ function mergeUsageRow(a2, b2) {
52254
+ const costA = a2.costUsd ?? null;
52255
+ const costB = b2.costUsd ?? null;
52256
+ const costUsd = costA != null || costB != null ? Math.max(num(costA), num(costB)) : a2.costUsd ?? b2.costUsd;
52257
+ return {
52258
+ ...a2,
52259
+ ...b2,
52260
+ workDir: b2.workDir ?? a2.workDir,
52261
+ branch: b2.branch ?? a2.branch,
52262
+ suffix: b2.suffix ?? a2.suffix,
52263
+ workUnitId: b2.workUnitId ?? a2.workUnitId,
52264
+ attemptId: b2.attemptId ?? a2.attemptId,
52265
+ tokensInput: Math.max(num(a2.tokensInput), num(b2.tokensInput)),
52266
+ tokensOutput: Math.max(num(a2.tokensOutput), num(b2.tokensOutput)),
52267
+ tokensCacheRead: Math.max(num(a2.tokensCacheRead), num(b2.tokensCacheRead)),
52268
+ tokensCacheCreation: Math.max(num(a2.tokensCacheCreation), num(b2.tokensCacheCreation)),
52269
+ tokensTotal: Math.max(num(a2.tokensTotal), num(b2.tokensTotal)),
52270
+ costUsd,
52271
+ modelBreakdown: mergeModelBreakdown(a2.modelBreakdown, b2.modelBreakdown),
52272
+ sources: [.../* @__PURE__ */ new Set([...a2.sources ?? [], ...b2.sources ?? []])],
52273
+ firstSeenAt: earlier(a2.firstSeenAt, b2.firstSeenAt),
52274
+ lastSeenAt: later(a2.lastSeenAt, b2.lastSeenAt)
52275
+ };
52276
+ }
52277
+ function mergePortalUsage(live, persisted) {
52278
+ const merged = /* @__PURE__ */ new Map();
52279
+ for (const row of [...live, ...persisted]) {
52280
+ const key = usageKey(row);
52281
+ const existing = merged.get(key);
52282
+ merged.set(key, existing ? mergeUsageRow(existing, row) : row);
52283
+ }
52284
+ return [...merged.values()];
52285
+ }
52286
+ function dedupePortalEvents(live, persisted) {
52287
+ const merged = /* @__PURE__ */ new Map();
52288
+ for (const event of [...live, ...persisted]) {
52289
+ const key = eventKey(event);
52290
+ if (!merged.has(key)) merged.set(key, event);
52291
+ }
52292
+ return [...merged.values()];
52293
+ }
52294
+
52135
52295
  // src/core/control-sync.ts
52136
52296
  async function postJson(url, body, dryRun) {
52137
52297
  if (dryRun) return null;
@@ -52179,11 +52339,11 @@ function modelsFromBreakdown(breakdown) {
52179
52339
  ...totals && typeof totals === "object" ? totals : {}
52180
52340
  }));
52181
52341
  }
52182
- function collectPortalTelemetry(repoPath, slots) {
52342
+ async function collectPortalTelemetry(repoPath, slots, controlApiUrl) {
52183
52343
  if (!isTelemetryEnabled()) return { usage: [], events: [] };
52184
52344
  try {
52185
52345
  const userEmail = resolvePortalUserEmail();
52186
- const usage2 = slots.flatMap(
52346
+ const liveUsage = slots.flatMap(
52187
52347
  (slot) => harvestUsageForSlot({
52188
52348
  agentId: slot.agentId,
52189
52349
  workDir: slot.workDir,
@@ -52192,26 +52352,19 @@ function collectPortalTelemetry(repoPath, slots) {
52192
52352
  suffix: slot.suffix,
52193
52353
  sessionCreatedAt: slot.sessionCreatedAt,
52194
52354
  repoPath
52195
- }).map((row) => {
52196
- const models = modelsFromBreakdown(
52197
- row.modelBreakdown
52198
- );
52199
- return {
52200
- ...row,
52201
- workUnitId: slot.workUnitId ?? row.workUnitId,
52202
- attemptId: slot.attemptId ?? row.attemptId,
52203
- sessionKey: row.sessionKey || buildSessionKey({
52204
- branch: slot.branch,
52205
- agentId: slot.agentId,
52206
- suffix: slot.suffix,
52207
- createdAt: slot.sessionCreatedAt
52208
- }),
52209
- ...userEmail ? { userEmail } : {},
52210
- ...models.length > 0 ? { models } : {}
52211
- };
52212
- })
52355
+ }).map((row) => ({
52356
+ ...row,
52357
+ workUnitId: slot.workUnitId ?? row.workUnitId,
52358
+ attemptId: slot.attemptId ?? row.attemptId,
52359
+ sessionKey: row.sessionKey || buildSessionKey({
52360
+ branch: slot.branch,
52361
+ agentId: slot.agentId,
52362
+ suffix: slot.suffix,
52363
+ createdAt: slot.sessionCreatedAt
52364
+ })
52365
+ }))
52213
52366
  );
52214
- const events = slots.flatMap(
52367
+ const liveEvents = slots.flatMap(
52215
52368
  (slot) => harvestEventsForSlot({
52216
52369
  agentId: slot.agentId,
52217
52370
  workDir: slot.workDir,
@@ -52220,20 +52373,30 @@ function collectPortalTelemetry(repoPath, slots) {
52220
52373
  suffix: slot.suffix,
52221
52374
  sessionCreatedAt: slot.sessionCreatedAt,
52222
52375
  repoPath
52223
- }).map(
52224
- (event) => dropNullFields({
52225
- ...event,
52226
- workUnitId: slot.workUnitId ?? event.workUnitId,
52227
- attemptId: slot.attemptId ?? event.attemptId
52228
- })
52229
- )
52376
+ }).map((event) => ({
52377
+ ...event,
52378
+ workUnitId: slot.workUnitId ?? event.workUnitId,
52379
+ attemptId: slot.attemptId ?? event.attemptId
52380
+ }))
52381
+ );
52382
+ const persisted = await fetchPersistedPortalTelemetry(repoPath, controlApiUrl);
52383
+ const usage2 = mergePortalUsage(liveUsage, persisted.usage).map((row) => {
52384
+ const models = modelsFromBreakdown(row.modelBreakdown);
52385
+ return {
52386
+ ...row,
52387
+ ...userEmail ? { userEmail } : {},
52388
+ ...models.length > 0 ? { models } : {}
52389
+ };
52390
+ });
52391
+ const events = dedupePortalEvents(liveEvents, persisted.events).map(
52392
+ (event) => dropNullFields({ ...event })
52230
52393
  );
52231
52394
  return { usage: usage2, events };
52232
52395
  } catch {
52233
52396
  return { usage: [], events: [] };
52234
52397
  }
52235
52398
  }
52236
- function buildPortalPayload(repoPath) {
52399
+ async function buildPortalPayload(repoPath, controlApiUrl) {
52237
52400
  const runs = listRuns(repoPath);
52238
52401
  const status = collectEnvironmentStatus(repoPath);
52239
52402
  const manifest = readManifest(repoPath);
@@ -52243,7 +52406,7 @@ function buildPortalPayload(repoPath) {
52243
52406
  const workUnits = listWorkUnits(harnessRoot);
52244
52407
  const attempts = listWorkAttempts(harnessRoot);
52245
52408
  const validationBindings = listValidationBindings(harnessRoot);
52246
- const { usage: usage2, events } = collectPortalTelemetry(repoPath, status.slots);
52409
+ const { usage: usage2, events } = await collectPortalTelemetry(repoPath, status.slots, controlApiUrl);
52247
52410
  const syncBody = {
52248
52411
  path: repoPath,
52249
52412
  ...manifest ? { manifest } : {},
@@ -52274,7 +52437,7 @@ async function waitForControlApi(apiUrl = getControlApiUrl(), timeoutMs = 6e4, i
52274
52437
  const deadline = Date.now() + timeoutMs;
52275
52438
  while (Date.now() < deadline) {
52276
52439
  if (await isControlApiReachable(apiUrl)) return true;
52277
- await new Promise((resolve38) => setTimeout(resolve38, intervalMs));
52440
+ await new Promise((resolve39) => setTimeout(resolve39, intervalMs));
52278
52441
  }
52279
52442
  return false;
52280
52443
  }
@@ -52375,7 +52538,7 @@ async function syncRepoWithControl(options) {
52375
52538
  }
52376
52539
  const portal = getPortalTarget();
52377
52540
  if (portal) {
52378
- const { syncBody, events } = buildPortalPayload(repoPath);
52541
+ const { syncBody, events } = await buildPortalPayload(repoPath, apiUrl);
52379
52542
  await postPortal(portal, "/api/sync", syncBody, options.dryRun);
52380
52543
  if (events.length > 0) {
52381
52544
  await postPortal(
@@ -52393,7 +52556,7 @@ async function syncRepoWithControl(options) {
52393
52556
  const listResponse = await fetch(`${apiUrl}/api/repos`);
52394
52557
  if (!listResponse.ok) throw new Error("Failed to list repos from Control API");
52395
52558
  const repos = await listResponse.json();
52396
- const existing = repos.find((r2) => path41.resolve(r2.path) === repoPath);
52559
+ const existing = repos.find((r2) => path42.resolve(r2.path) === repoPath);
52397
52560
  if (!existing) {
52398
52561
  return;
52399
52562
  }
@@ -52546,7 +52709,7 @@ init_control_config();
52546
52709
 
52547
52710
  // src/core/control-lifecycle.ts
52548
52711
  var import_child_process9 = require("child_process");
52549
- var path42 = __toESM(require("path"));
52712
+ var path43 = __toESM(require("path"));
52550
52713
 
52551
52714
  // src/core/control-image.ts
52552
52715
  var DEFAULT_CONTROL_IMAGE = "theosfactory/har-control";
@@ -52570,10 +52733,10 @@ var CONTROL_DATA_VOLUME = "har_control_data";
52570
52733
  var CONTROL_CONTAINER_PORT = 3847;
52571
52734
  var CONTROL_DATA_DB_URL = "file:/data/har_control.db";
52572
52735
  function resolveControlDir() {
52573
- return path42.resolve(__dirname, "..", "control");
52736
+ return path43.resolve(__dirname, "..", "control");
52574
52737
  }
52575
52738
  function resolveControlBuildContext() {
52576
- return path42.resolve(resolveControlDir(), "..");
52739
+ return path43.resolve(resolveControlDir(), "..");
52577
52740
  }
52578
52741
  function buildDockerRunArgs(options) {
52579
52742
  const name = options.containerName ?? CONTROL_CONTAINER_NAME;
@@ -52629,7 +52792,7 @@ async function startMissionControl(options) {
52629
52792
  "-t",
52630
52793
  imageRef,
52631
52794
  "-f",
52632
- path42.join(resolveControlDir(), "Dockerfile"),
52795
+ path43.join(resolveControlDir(), "Dockerfile"),
52633
52796
  resolveControlBuildContext()
52634
52797
  ]);
52635
52798
  if (buildCode !== 0) {
@@ -52773,7 +52936,7 @@ async function ensureTelemetryInfrastructure(options) {
52773
52936
 
52774
52937
  // src/core/run-service.ts
52775
52938
  init_telemetry_config();
52776
- var path44 = __toESM(require("path"));
52939
+ var path45 = __toESM(require("path"));
52777
52940
  function extractShellOutput(result) {
52778
52941
  const stdout = result.logs?.find((log) => log.stream === "stdout")?.content ?? result.logs?.find((log) => !log.stream)?.content ?? "";
52779
52942
  const stderr = result.logs?.find((log) => log.stream === "stderr")?.content ?? "";
@@ -52983,12 +53146,12 @@ Usage from Cursor / Claude / Codex (opentelemetry-hooks) will appear under Workt
52983
53146
  suffix: session.suffix,
52984
53147
  createdAt: session.createdAt
52985
53148
  });
52986
- const envFile = path44.join(session.workDir, `.env.agent.${options.agentId}`);
53149
+ const envFile = path45.join(session.workDir, `.env.agent.${options.agentId}`);
52987
53150
  try {
52988
53151
  appendTelemetryEnvToFile(envFile, {
52989
53152
  sessionKey,
52990
53153
  agentId: options.agentId,
52991
- repoPath: path44.resolve(options.repoPath),
53154
+ repoPath: path45.resolve(options.repoPath),
52992
53155
  workDir: session.workDir,
52993
53156
  branch: session.branch,
52994
53157
  suffix: session.suffix,
@@ -53222,7 +53385,7 @@ var readline6 = __toESM(require("readline"));
53222
53385
  // src/core/hooks.ts
53223
53386
  var fs42 = __toESM(require("fs"));
53224
53387
  var os14 = __toESM(require("os"));
53225
- var path45 = __toESM(require("path"));
53388
+ var path46 = __toESM(require("path"));
53226
53389
  var MARKER_START = "# >>> har commit gate (managed by `har hooks`) >>>";
53227
53390
  var MARKER_END = "# <<< har commit gate <<<";
53228
53391
  var PRE_COMMIT_BLOCK = [
@@ -53247,7 +53410,7 @@ function resolveCheckoutRoot(cwd) {
53247
53410
  function resolveHooksDir(checkoutDir) {
53248
53411
  const hooksPath = tryGit3(checkoutDir, "rev-parse --git-path hooks");
53249
53412
  if (!hooksPath) throw new Error(`Not a git checkout: ${checkoutDir}`);
53250
- return path45.resolve(checkoutDir, hooksPath);
53413
+ return path46.resolve(checkoutDir, hooksPath);
53251
53414
  }
53252
53415
  function getConfiguredHooksPath(checkoutDir) {
53253
53416
  return tryGit3(checkoutDir, "config core.hooksPath") || void 0;
@@ -53255,9 +53418,9 @@ function getConfiguredHooksPath(checkoutDir) {
53255
53418
  function defaultHarInvocation() {
53256
53419
  const entry = process.argv[1];
53257
53420
  if (entry && entry.endsWith(".js")) {
53258
- return `"${process.execPath}" "${path45.resolve(entry)}"`;
53421
+ return `"${process.execPath}" "${path46.resolve(entry)}"`;
53259
53422
  }
53260
- if (entry) return `"${path45.resolve(entry)}"`;
53423
+ if (entry) return `"${path46.resolve(entry)}"`;
53261
53424
  return "har";
53262
53425
  }
53263
53426
  function buildHookScript(harInvocation, subcommand, failOpenNotice) {
@@ -53336,17 +53499,17 @@ Or re-run with --force to write into that directory anyway.`
53336
53499
  fs42.mkdirSync(hooksDir, { recursive: true });
53337
53500
  const invocation = options.harInvocation ?? defaultHarInvocation();
53338
53501
  fs42.writeFileSync(
53339
- path45.join(hooksDir, "har-pre-commit"),
53502
+ path46.join(hooksDir, "har-pre-commit"),
53340
53503
  buildHookScript(invocation, "check", "har: binary not found; skipping commit gate (reinstall with har hooks install)"),
53341
53504
  { mode: 493 }
53342
53505
  );
53343
53506
  fs42.writeFileSync(
53344
- path45.join(hooksDir, "har-post-commit"),
53507
+ path46.join(hooksDir, "har-post-commit"),
53345
53508
  buildHookScript(invocation, "record-commit", "har: binary not found; skipping commit association"),
53346
53509
  { mode: 493 }
53347
53510
  );
53348
- const preCommit = upsertMarkedBlock(path45.join(hooksDir, "pre-commit"), PRE_COMMIT_BLOCK);
53349
- const postCommit = upsertMarkedBlock(path45.join(hooksDir, "post-commit"), POST_COMMIT_BLOCK);
53511
+ const preCommit = upsertMarkedBlock(path46.join(hooksDir, "pre-commit"), PRE_COMMIT_BLOCK);
53512
+ const postCommit = upsertMarkedBlock(path46.join(hooksDir, "post-commit"), POST_COMMIT_BLOCK);
53350
53513
  ensureValidationsIgnored(checkout);
53351
53514
  return { hooksDir, preCommit, postCommit };
53352
53515
  }
@@ -53355,10 +53518,10 @@ function uninstallHooks(repoPath) {
53355
53518
  if (!checkout) throw new Error(`Not a git repository: ${repoPath}`);
53356
53519
  const hooksDir = resolveHooksDir(checkout);
53357
53520
  let removed = false;
53358
- removed = removeMarkedBlock(path45.join(hooksDir, "pre-commit")) || removed;
53359
- removed = removeMarkedBlock(path45.join(hooksDir, "post-commit")) || removed;
53521
+ removed = removeMarkedBlock(path46.join(hooksDir, "pre-commit")) || removed;
53522
+ removed = removeMarkedBlock(path46.join(hooksDir, "post-commit")) || removed;
53360
53523
  for (const file of ["har-pre-commit", "har-post-commit"]) {
53361
- const full = path45.join(hooksDir, file);
53524
+ const full = path46.join(hooksDir, file);
53362
53525
  if (fs42.existsSync(full)) {
53363
53526
  fs42.rmSync(full);
53364
53527
  removed = true;
@@ -53379,10 +53542,10 @@ function isAgentWorktree(checkoutDir) {
53379
53542
  if (branch && (/^har-agent-\d+$/.test(branch) || /-har-agent-\d+-[a-z0-9]+$/.test(branch))) {
53380
53543
  return true;
53381
53544
  }
53382
- const worktreesRoot = path45.join(os14.homedir(), "worktrees");
53383
- const resolved = path45.resolve(checkoutDir);
53384
- const name = path45.basename(resolved);
53385
- return resolved.startsWith(`${worktreesRoot}${path45.sep}`) && (/-agent-\d+$/.test(name) || /-har-agent-\d+-[a-z0-9]+$/.test(name));
53545
+ const worktreesRoot = path46.join(os14.homedir(), "worktrees");
53546
+ const resolved = path46.resolve(checkoutDir);
53547
+ const name = path46.basename(resolved);
53548
+ return resolved.startsWith(`${worktreesRoot}${path46.sep}`) && (/-agent-\d+$/.test(name) || /-har-agent-\d+-[a-z0-9]+$/.test(name));
53386
53549
  }
53387
53550
  function resolveEffectiveMode(checkoutDir, gate) {
53388
53551
  if (!gate.enabled) return "off";
@@ -53395,15 +53558,15 @@ function getHooksStatus(repoPath) {
53395
53558
  const hooksDir = resolveHooksDir(checkout);
53396
53559
  const gate = getCommitGateConfig(checkout);
53397
53560
  const hasBlock = (name) => {
53398
- const file = path45.join(hooksDir, name);
53561
+ const file = path46.join(hooksDir, name);
53399
53562
  return fs42.existsSync(file) && fs42.readFileSync(file, "utf8").includes(MARKER_START);
53400
53563
  };
53401
53564
  return {
53402
53565
  checkout,
53403
53566
  hooksDir,
53404
53567
  configuredHooksPath: getConfiguredHooksPath(checkout),
53405
- preCommitInstalled: hasBlock("pre-commit") && fs42.existsSync(path45.join(hooksDir, "har-pre-commit")),
53406
- postCommitInstalled: hasBlock("post-commit") && fs42.existsSync(path45.join(hooksDir, "har-post-commit")),
53568
+ preCommitInstalled: hasBlock("pre-commit") && fs42.existsSync(path46.join(hooksDir, "har-pre-commit")),
53569
+ postCommitInstalled: hasBlock("post-commit") && fs42.existsSync(path46.join(hooksDir, "har-post-commit")),
53407
53570
  gate,
53408
53571
  effectiveMode: resolveEffectiveMode(checkout, gate)
53409
53572
  };
@@ -53414,7 +53577,7 @@ function checkCommitGate(cwd) {
53414
53577
  }
53415
53578
  const checkout = resolveCheckoutRoot(cwd);
53416
53579
  if (!checkout) return { exitCode: 0, messages: [] };
53417
- if (!fs42.existsSync(path45.join(checkout, ".har", "stages.json"))) {
53580
+ if (!fs42.existsSync(path46.join(checkout, ".har", "stages.json"))) {
53418
53581
  return { exitCode: 0, messages: [] };
53419
53582
  }
53420
53583
  const gate = getCommitGateConfig(checkout);
@@ -53487,12 +53650,12 @@ async function recordCommitAssociation(cwd) {
53487
53650
  // src/core/commit-gate-onboarding.ts
53488
53651
  function askYesNo5(question) {
53489
53652
  const rl = readline6.createInterface({ input: process.stdin, output: process.stderr });
53490
- return new Promise((resolve38) => {
53653
+ return new Promise((resolve39) => {
53491
53654
  process.stderr.write(`${question} `);
53492
53655
  rl.once("line", (answer) => {
53493
53656
  rl.close();
53494
53657
  const trimmed = answer.trim();
53495
- resolve38(trimmed === "" || /^y(es)?$/i.test(trimmed));
53658
+ resolve39(trimmed === "" || /^y(es)?$/i.test(trimmed));
53496
53659
  });
53497
53660
  });
53498
53661
  }
@@ -53536,12 +53699,12 @@ async function handleCommitGateOnboarding(options) {
53536
53699
  // src/core/onboarding-preferences.ts
53537
53700
  var fs43 = __toESM(require("fs"));
53538
53701
  var os15 = __toESM(require("os"));
53539
- var path46 = __toESM(require("path"));
53702
+ var path47 = __toESM(require("path"));
53540
53703
  function getOnboardingPreferencesPath() {
53541
53704
  if (process.env.HAR_PREFERENCES_PATH) {
53542
- return path46.resolve(process.env.HAR_PREFERENCES_PATH);
53705
+ return path47.resolve(process.env.HAR_PREFERENCES_PATH);
53543
53706
  }
53544
- return path46.join(os15.homedir(), ".har", "preferences.json");
53707
+ return path47.join(os15.homedir(), ".har", "preferences.json");
53545
53708
  }
53546
53709
  function readOnboardingPreferences() {
53547
53710
  const preferencePath = getOnboardingPreferencesPath();
@@ -53572,7 +53735,7 @@ function writeOnboardingPreferences(overrides) {
53572
53735
  };
53573
53736
  const parsed = OnboardingPreferencesSchema.parse(preference);
53574
53737
  const preferencePath = getOnboardingPreferencesPath();
53575
- fs43.mkdirSync(path46.dirname(preferencePath), { recursive: true });
53738
+ fs43.mkdirSync(path47.dirname(preferencePath), { recursive: true });
53576
53739
  fs43.writeFileSync(preferencePath, `${JSON.stringify(parsed, null, 2)}
53577
53740
  `);
53578
53741
  return parsed;
@@ -53853,7 +54016,7 @@ var envCommand = {
53853
54016
  }
53854
54017
  };
53855
54018
  async function handleInit(argv) {
53856
- const repoPath = path47.resolve(argv.repo);
54019
+ const repoPath = path48.resolve(argv.repo);
53857
54020
  const onboarding = resolveOnboardingOptions(argv);
53858
54021
  header("har env init");
53859
54022
  info(`Repository: ${repoPath}`);
@@ -53917,7 +54080,7 @@ async function handleInit(argv) {
53917
54080
  }
53918
54081
  }
53919
54082
  async function handleMaintain(argv) {
53920
- const repoPath = path47.resolve(argv.repo);
54083
+ const repoPath = path48.resolve(argv.repo);
53921
54084
  const onboarding = resolveOnboardingOptions(argv);
53922
54085
  header("har env maintain");
53923
54086
  info(`Repository: ${repoPath}`);
@@ -54039,7 +54202,7 @@ async function handleAgentMdProposal(repoPath, autoYes) {
54039
54202
  if (autoYes) {
54040
54203
  const proposal = readAgentMdProposal(repoPath);
54041
54204
  if (proposal) {
54042
- writeFileSafe(path47.join(repoPath, "AGENT.md"), proposal.content);
54205
+ writeFileSafe(path48.join(repoPath, "AGENT.md"), proposal.content);
54043
54206
  clearAgentMdProposal(repoPath);
54044
54207
  info("Applied AGENT.md proposal (--yes)");
54045
54208
  }
@@ -54048,7 +54211,7 @@ async function handleAgentMdProposal(repoPath, autoYes) {
54048
54211
  await promptApplyAgentMdProposal(repoPath);
54049
54212
  }
54050
54213
  async function handleAddStage(argv) {
54051
- const repoPath = path47.resolve(argv.repo);
54214
+ const repoPath = path48.resolve(argv.repo);
54052
54215
  const available = listStageTemplateIds();
54053
54216
  if (argv.list) {
54054
54217
  for (const id of available) {
@@ -54125,7 +54288,7 @@ async function handleAddStage(argv) {
54125
54288
  }
54126
54289
  }
54127
54290
  async function handlePreflight(argv) {
54128
- const repo = path47.resolve(argv.repo);
54291
+ const repo = path48.resolve(argv.repo);
54129
54292
  const agentId = validateAgentId(argv.id, repo);
54130
54293
  const result = await preflightEnvironment({
54131
54294
  repoPath: repo,
@@ -54143,7 +54306,7 @@ async function handlePreflight(argv) {
54143
54306
  process.exit(result.code);
54144
54307
  }
54145
54308
  async function handleLaunch(argv) {
54146
- const repo = path47.resolve(argv.repo);
54309
+ const repo = path48.resolve(argv.repo);
54147
54310
  const agentId = validateAgentId(argv.id, repo);
54148
54311
  let confirmReplace = argv.replace;
54149
54312
  let force = argv.force;
@@ -54155,8 +54318,8 @@ async function handleLaunch(argv) {
54155
54318
  console.error(guard.reason ?? "");
54156
54319
  const readline10 = await import("readline");
54157
54320
  const rl = readline10.createInterface({ input: process.stdin, output: process.stderr });
54158
- const answer = await new Promise((resolve38) => {
54159
- rl.question("Replace this slot? [y/N] ", resolve38);
54321
+ const answer = await new Promise((resolve39) => {
54322
+ rl.question("Replace this slot? [y/N] ", resolve39);
54160
54323
  });
54161
54324
  rl.close();
54162
54325
  if (!/^[Yy]$/.test(answer.trim())) {
@@ -54172,8 +54335,8 @@ async function handleLaunch(argv) {
54172
54335
  warn("Worktree has uncommitted changes.");
54173
54336
  const readline10 = await import("readline");
54174
54337
  const rl = readline10.createInterface({ input: process.stdin, output: process.stderr });
54175
- const answer = await new Promise((resolve38) => {
54176
- rl.question("Discard uncommitted changes? [y/N] ", resolve38);
54338
+ const answer = await new Promise((resolve39) => {
54339
+ rl.question("Discard uncommitted changes? [y/N] ", resolve39);
54177
54340
  });
54178
54341
  rl.close();
54179
54342
  if (!/^[Yy]$/.test(answer.trim())) {
@@ -54237,7 +54400,7 @@ async function handleRecover(argv) {
54237
54400
  });
54238
54401
  }
54239
54402
  async function handleVerify(argv) {
54240
- const repo = path47.resolve(argv.repo);
54403
+ const repo = path48.resolve(argv.repo);
54241
54404
  const agentId = validateAgentId(argv.id, repo);
54242
54405
  const result = await runVerification({
54243
54406
  repoPath: repo,
@@ -54249,7 +54412,7 @@ async function handleVerify(argv) {
54249
54412
  process.exit(result.code);
54250
54413
  }
54251
54414
  async function handleTeardown(argv) {
54252
- const repo = path47.resolve(argv.repo);
54415
+ const repo = path48.resolve(argv.repo);
54253
54416
  const agentId = validateAgentId(argv.id, repo);
54254
54417
  const result = await teardownEnvironment({
54255
54418
  repoPath: repo,
@@ -54260,7 +54423,7 @@ async function handleTeardown(argv) {
54260
54423
  process.exit(result.code);
54261
54424
  }
54262
54425
  async function handleComplete(argv) {
54263
- const repo = path47.resolve(argv.repo);
54426
+ const repo = path48.resolve(argv.repo);
54264
54427
  const agentId = validateAgentId(argv.id, repo);
54265
54428
  const result = await completeEnvironment({
54266
54429
  repoPath: repo,
@@ -54281,7 +54444,7 @@ async function handleComplete(argv) {
54281
54444
  process.exit(result.code);
54282
54445
  }
54283
54446
  async function handleStatus(argv) {
54284
- const repoPath = path47.resolve(argv.repo);
54447
+ const repoPath = path48.resolve(argv.repo);
54285
54448
  if (argv.json) {
54286
54449
  const status = collectEnvironmentStatus(repoPath);
54287
54450
  const output = EnvironmentStatusSchema.parse(status);
@@ -54294,7 +54457,7 @@ async function handleStatus(argv) {
54294
54457
  });
54295
54458
  }
54296
54459
  async function handleRunsList(argv) {
54297
- const repoPath = path47.resolve(argv.repo);
54460
+ const repoPath = path48.resolve(argv.repo);
54298
54461
  const runs = listRuns(repoPath, { stageId: argv.stage, limit: argv.limit });
54299
54462
  if (argv.json) {
54300
54463
  process.stdout.write(JSON.stringify({ runs }, null, 2) + "\n");
@@ -54311,7 +54474,7 @@ async function handleRunsList(argv) {
54311
54474
  }
54312
54475
  }
54313
54476
  async function handleRunsGet(argv) {
54314
- const run2 = getRun(path47.resolve(argv.repo), argv.runId);
54477
+ const run2 = getRun(path48.resolve(argv.repo), argv.runId);
54315
54478
  if (!run2) {
54316
54479
  error(`Run not found: ${argv.runId}`);
54317
54480
  process.exit(1);
@@ -54390,7 +54553,7 @@ function printNextSteps(auto2) {
54390
54553
  }
54391
54554
 
54392
54555
  // src/cli/commands/control.ts
54393
- var path49 = __toESM(require("path"));
54556
+ var path50 = __toESM(require("path"));
54394
54557
  init_control_config();
54395
54558
  init_portal_credentials();
54396
54559
 
@@ -54412,7 +54575,7 @@ function openBrowser(url) {
54412
54575
  }
54413
54576
  async function loginViaBrowser(portalUrl, openUrl = openBrowser) {
54414
54577
  const state = (0, import_crypto.randomUUID)();
54415
- return new Promise((resolve38, reject) => {
54578
+ return new Promise((resolve39, reject) => {
54416
54579
  let timer;
54417
54580
  const server = http.createServer((req, res) => {
54418
54581
  const requestUrl = new URL(req.url ?? "", "http://127.0.0.1");
@@ -54435,7 +54598,7 @@ async function loginViaBrowser(portalUrl, openUrl = openBrowser) {
54435
54598
  res.writeHead(200, { "Content-Type": "text/html" });
54436
54599
  res.end("<h1>Logged in</h1><p>You can close this tab and return to the terminal.</p>");
54437
54600
  cleanup();
54438
- resolve38({ portalUrl, token, workspace, email: email2, createdAt: (/* @__PURE__ */ new Date()).toISOString() });
54601
+ resolve39({ portalUrl, token, workspace, email: email2, createdAt: (/* @__PURE__ */ new Date()).toISOString() });
54439
54602
  });
54440
54603
  const cleanup = () => {
54441
54604
  clearTimeout(timer);
@@ -54463,13 +54626,13 @@ If your browser did not open, paste that URL.
54463
54626
 
54464
54627
  // src/core/control-unregister.ts
54465
54628
  var fs44 = __toESM(require("fs"));
54466
- var path48 = __toESM(require("path"));
54629
+ var path49 = __toESM(require("path"));
54467
54630
  init_control_config();
54468
54631
  function listUnregisterWorktreeCandidates(repoPath) {
54469
54632
  const harnessRoot = canonicalizeControlRepoPath(repoPath);
54470
54633
  const byPath = /* @__PURE__ */ new Map();
54471
54634
  const add = (partial2) => {
54472
- const resolved = path48.resolve(partial2.worktreePath);
54635
+ const resolved = path49.resolve(partial2.worktreePath);
54473
54636
  if (!resolved || resolved === harnessRoot) return;
54474
54637
  const exists = partial2.exists ?? fs44.existsSync(resolved);
54475
54638
  const prev = byPath.get(resolved);
@@ -54522,8 +54685,8 @@ async function askYesNo6(question) {
54522
54685
  if (!process.stdin.isTTY || !process.stdout.isTTY) return false;
54523
54686
  const readline10 = await import("readline");
54524
54687
  const rl = readline10.createInterface({ input: process.stdin, output: process.stderr });
54525
- const answer = await new Promise((resolve38) => {
54526
- rl.question(question, resolve38);
54688
+ const answer = await new Promise((resolve39) => {
54689
+ rl.question(question, resolve39);
54527
54690
  });
54528
54691
  rl.close();
54529
54692
  return /^[Yy]$/.test(answer.trim());
@@ -54791,7 +54954,7 @@ async function handleDown() {
54791
54954
  process.exit(code);
54792
54955
  }
54793
54956
  async function handleRegister(argv) {
54794
- const repoPath = path49.resolve(argv.repo);
54957
+ const repoPath = path50.resolve(argv.repo);
54795
54958
  header("har control register");
54796
54959
  info(`Repository: ${repoPath}`);
54797
54960
  try {
@@ -54815,7 +54978,7 @@ async function handleRegister(argv) {
54815
54978
  }
54816
54979
  }
54817
54980
  async function handleUnregister(argv) {
54818
- const repoPath = path49.resolve(argv.repo);
54981
+ const repoPath = path50.resolve(argv.repo);
54819
54982
  const worktrees = listUnregisterWorktreeCandidates(repoPath);
54820
54983
  try {
54821
54984
  let deleteWorktrees = argv.deleteWorktrees;
@@ -54884,7 +55047,7 @@ async function handleUnregister(argv) {
54884
55047
  }
54885
55048
  }
54886
55049
  async function handleSync(argv) {
54887
- const repoPath = path49.resolve(argv.repo);
55050
+ const repoPath = path50.resolve(argv.repo);
54888
55051
  try {
54889
55052
  await syncRepoWithControl({
54890
55053
  repoPath,
@@ -54923,7 +55086,7 @@ async function handleWatch(argv) {
54923
55086
  };
54924
55087
  const tick = async () => {
54925
55088
  if (argv.repo) {
54926
- await syncOne(path49.resolve(argv.repo));
55089
+ await syncOne(path50.resolve(argv.repo));
54927
55090
  return;
54928
55091
  }
54929
55092
  try {
@@ -54973,11 +55136,11 @@ async function handleLogin(argv) {
54973
55136
  }
54974
55137
 
54975
55138
  // src/cli/commands/hooks.ts
54976
- var path51 = __toESM(require("path"));
55139
+ var path52 = __toESM(require("path"));
54977
55140
 
54978
55141
  // src/core/claude-hooks.ts
54979
55142
  var fs45 = __toESM(require("fs"));
54980
- var path50 = __toESM(require("path"));
55143
+ var path51 = __toESM(require("path"));
54981
55144
  var CLAUDE_GUARD_RELATIVE_PATH = ".har/hooks/claude-worktree-guard.sh";
54982
55145
  var CLAUDE_SETTINGS_RELATIVE_PATH = ".claude/settings.json";
54983
55146
  var GUARD_MATCHER = "Edit|Write|MultiEdit|NotebookEdit";
@@ -54998,7 +55161,7 @@ function readSettings(settingsPath) {
54998
55161
  return parsed;
54999
55162
  }
55000
55163
  function writeSettings(settingsPath, settings) {
55001
- fs45.mkdirSync(path50.dirname(settingsPath), { recursive: true });
55164
+ fs45.mkdirSync(path51.dirname(settingsPath), { recursive: true });
55002
55165
  fs45.writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + "\n");
55003
55166
  }
55004
55167
  function installClaudeGuard(repoPath) {
@@ -55006,11 +55169,11 @@ function installClaudeGuard(repoPath) {
55006
55169
  if (!templatePath) {
55007
55170
  throw new Error("Guard template not found (claude-worktree-guard.sh.template). Run npm run build.");
55008
55171
  }
55009
- const guardScript = path50.join(repoPath, CLAUDE_GUARD_RELATIVE_PATH);
55010
- fs45.mkdirSync(path50.dirname(guardScript), { recursive: true });
55172
+ const guardScript = path51.join(repoPath, CLAUDE_GUARD_RELATIVE_PATH);
55173
+ fs45.mkdirSync(path51.dirname(guardScript), { recursive: true });
55011
55174
  fs45.copyFileSync(templatePath, guardScript);
55012
55175
  fs45.chmodSync(guardScript, 493);
55013
- const settingsPath = path50.join(repoPath, CLAUDE_SETTINGS_RELATIVE_PATH);
55176
+ const settingsPath = path51.join(repoPath, CLAUDE_SETTINGS_RELATIVE_PATH);
55014
55177
  const settings = readSettings(settingsPath);
55015
55178
  const hooks = settings.hooks ?? {};
55016
55179
  const preToolUse = (hooks.PreToolUse ?? []).filter((entry) => !isHarGuardEntry(entry));
@@ -55024,14 +55187,14 @@ function installClaudeGuard(repoPath) {
55024
55187
  }
55025
55188
  function uninstallClaudeGuard(repoPath) {
55026
55189
  let removed = false;
55027
- const guardScript = path50.join(repoPath, CLAUDE_GUARD_RELATIVE_PATH);
55190
+ const guardScript = path51.join(repoPath, CLAUDE_GUARD_RELATIVE_PATH);
55028
55191
  if (fs45.existsSync(guardScript)) {
55029
55192
  fs45.rmSync(guardScript);
55030
55193
  removed = true;
55031
- const parent = path50.dirname(guardScript);
55194
+ const parent = path51.dirname(guardScript);
55032
55195
  if (fs45.existsSync(parent) && fs45.readdirSync(parent).length === 0) fs45.rmdirSync(parent);
55033
55196
  }
55034
- const settingsPath = path50.join(repoPath, CLAUDE_SETTINGS_RELATIVE_PATH);
55197
+ const settingsPath = path51.join(repoPath, CLAUDE_SETTINGS_RELATIVE_PATH);
55035
55198
  if (fs45.existsSync(settingsPath)) {
55036
55199
  const settings = readSettings(settingsPath);
55037
55200
  const preToolUse = settings.hooks?.PreToolUse;
@@ -55057,7 +55220,7 @@ function uninstallClaudeGuard(repoPath) {
55057
55220
  return { removed };
55058
55221
  }
55059
55222
  function claudeGuardInstalled(repoPath) {
55060
- const settingsPath = path50.join(repoPath, CLAUDE_SETTINGS_RELATIVE_PATH);
55223
+ const settingsPath = path51.join(repoPath, CLAUDE_SETTINGS_RELATIVE_PATH);
55061
55224
  if (!fs45.existsSync(settingsPath)) return false;
55062
55225
  try {
55063
55226
  const settings = readSettings(settingsPath);
@@ -55074,7 +55237,7 @@ function repoOption(y2) {
55074
55237
  function handleInstall2(argv) {
55075
55238
  try {
55076
55239
  if (argv.claude) {
55077
- const result2 = installClaudeGuard(path51.resolve(argv.repo));
55240
+ const result2 = installClaudeGuard(path52.resolve(argv.repo));
55078
55241
  success("Claude Code worktree guard installed.");
55079
55242
  info(`Guard script: ${result2.guardScript}`);
55080
55243
  info(`Settings: ${result2.settingsPath} (PreToolUse: Edit|Write|MultiEdit|NotebookEdit)`);
@@ -55082,7 +55245,7 @@ function handleInstall2(argv) {
55082
55245
  info("Commit both files so the guard travels with the repo.");
55083
55246
  return;
55084
55247
  }
55085
- const result = installHooks({ repoPath: path51.resolve(argv.repo), force: argv.force });
55248
+ const result = installHooks({ repoPath: path52.resolve(argv.repo), force: argv.force });
55086
55249
  success(`Commit gate installed in ${result.hooksDir}`);
55087
55250
  info(`pre-commit: ${result.preCommit}, post-commit: ${result.postCommit}`);
55088
55251
  info("Commits of unverified change batches will be blocked in agent worktrees.");
@@ -55095,7 +55258,7 @@ function handleInstall2(argv) {
55095
55258
  function handleUninstall(argv) {
55096
55259
  try {
55097
55260
  if (argv.claude) {
55098
- const result2 = uninstallClaudeGuard(path51.resolve(argv.repo));
55261
+ const result2 = uninstallClaudeGuard(path52.resolve(argv.repo));
55099
55262
  if (result2.removed) {
55100
55263
  success("Claude Code worktree guard removed.");
55101
55264
  } else {
@@ -55103,7 +55266,7 @@ function handleUninstall(argv) {
55103
55266
  }
55104
55267
  return;
55105
55268
  }
55106
- const result = uninstallHooks(path51.resolve(argv.repo));
55269
+ const result = uninstallHooks(path52.resolve(argv.repo));
55107
55270
  if (result.removed) {
55108
55271
  success(`Commit gate removed from ${result.hooksDir}`);
55109
55272
  } else {
@@ -55116,7 +55279,7 @@ function handleUninstall(argv) {
55116
55279
  }
55117
55280
  function handleStatus2(argv) {
55118
55281
  try {
55119
- const status = getHooksStatus(path51.resolve(argv.repo));
55282
+ const status = getHooksStatus(path52.resolve(argv.repo));
55120
55283
  if (argv.json) {
55121
55284
  process.stdout.write(`${JSON.stringify(status, null, 2)}
55122
55285
  `);
@@ -55134,7 +55297,7 @@ function handleStatus2(argv) {
55134
55297
  );
55135
55298
  info(`Effective: ${status.effectiveMode} (in this checkout)`);
55136
55299
  info(
55137
- `Claude guard: ${claudeGuardInstalled(path51.resolve(argv.repo)) ? `installed (${CLAUDE_GUARD_RELATIVE_PATH})` : "not installed"}`
55300
+ `Claude guard: ${claudeGuardInstalled(path52.resolve(argv.repo)) ? `installed (${CLAUDE_GUARD_RELATIVE_PATH})` : "not installed"}`
55138
55301
  );
55139
55302
  } catch (err) {
55140
55303
  error(err instanceof Error ? err.message : String(err));
@@ -55395,10 +55558,10 @@ function assignProp(target, prop, value) {
55395
55558
  configurable: true
55396
55559
  });
55397
55560
  }
55398
- function getElementAtPath(obj, path54) {
55399
- if (!path54)
55561
+ function getElementAtPath(obj, path55) {
55562
+ if (!path55)
55400
55563
  return obj;
55401
- return path54.reduce((acc, key) => acc?.[key], obj);
55564
+ return path55.reduce((acc, key) => acc?.[key], obj);
55402
55565
  }
55403
55566
  function promiseAllObject(promisesObj) {
55404
55567
  const keys = Object.keys(promisesObj);
@@ -55718,11 +55881,11 @@ function aborted(x2, startIndex = 0) {
55718
55881
  }
55719
55882
  return false;
55720
55883
  }
55721
- function prefixIssues(path54, issues) {
55884
+ function prefixIssues(path55, issues) {
55722
55885
  return issues.map((iss) => {
55723
55886
  var _a3;
55724
55887
  (_a3 = iss).path ?? (_a3.path = []);
55725
- iss.path.unshift(path54);
55888
+ iss.path.unshift(path55);
55726
55889
  return iss;
55727
55890
  });
55728
55891
  }
@@ -61045,7 +61208,7 @@ var Protocol = class {
61045
61208
  return;
61046
61209
  }
61047
61210
  const pollInterval = task2.pollInterval ?? this._options?.defaultTaskPollInterval ?? 1e3;
61048
- await new Promise((resolve38) => setTimeout(resolve38, pollInterval));
61211
+ await new Promise((resolve39) => setTimeout(resolve39, pollInterval));
61049
61212
  options?.signal?.throwIfAborted();
61050
61213
  }
61051
61214
  } catch (error3) {
@@ -61062,7 +61225,7 @@ var Protocol = class {
61062
61225
  */
61063
61226
  request(request, resultSchema, options) {
61064
61227
  const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
61065
- return new Promise((resolve38, reject) => {
61228
+ return new Promise((resolve39, reject) => {
61066
61229
  const earlyReject = (error3) => {
61067
61230
  reject(error3);
61068
61231
  };
@@ -61140,7 +61303,7 @@ var Protocol = class {
61140
61303
  if (!parseResult.success) {
61141
61304
  reject(parseResult.error);
61142
61305
  } else {
61143
- resolve38(parseResult.data);
61306
+ resolve39(parseResult.data);
61144
61307
  }
61145
61308
  } catch (error3) {
61146
61309
  reject(error3);
@@ -61401,12 +61564,12 @@ var Protocol = class {
61401
61564
  }
61402
61565
  } catch {
61403
61566
  }
61404
- return new Promise((resolve38, reject) => {
61567
+ return new Promise((resolve39, reject) => {
61405
61568
  if (signal.aborted) {
61406
61569
  reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
61407
61570
  return;
61408
61571
  }
61409
- const timeoutId = setTimeout(resolve38, interval);
61572
+ const timeoutId = setTimeout(resolve39, interval);
61410
61573
  signal.addEventListener("abort", () => {
61411
61574
  clearTimeout(timeoutId);
61412
61575
  reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
@@ -62196,7 +62359,7 @@ var Server = class extends Protocol {
62196
62359
  };
62197
62360
 
62198
62361
  // src/mcp/server.ts
62199
- var path52 = __toESM(require("path"));
62362
+ var path53 = __toESM(require("path"));
62200
62363
 
62201
62364
  // node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
62202
62365
  var import_node_process2 = __toESM(require("node:process"), 1);
@@ -62279,12 +62442,12 @@ var StdioServerTransport = class {
62279
62442
  this.onclose?.();
62280
62443
  }
62281
62444
  send(message) {
62282
- return new Promise((resolve38) => {
62445
+ return new Promise((resolve39) => {
62283
62446
  const json = serializeMessage(message);
62284
62447
  if (this._stdout.write(json)) {
62285
- resolve38();
62448
+ resolve39();
62286
62449
  } else {
62287
- this._stdout.once("drain", resolve38);
62450
+ this._stdout.once("drain", resolve39);
62288
62451
  }
62289
62452
  });
62290
62453
  }
@@ -62856,7 +63019,7 @@ async function handleMcpToolCall(toolName, args, defaultRepo = ".") {
62856
63019
  const input = ControlUpInputSchema.parse({ ...args, repo });
62857
63020
  const result = await startControlAndSync({
62858
63021
  detach: input.detach,
62859
- cwd: path52.resolve(input.repo)
63022
+ cwd: path53.resolve(input.repo)
62860
63023
  });
62861
63024
  if (result.code !== 0) {
62862
63025
  return {
@@ -63936,13 +64099,13 @@ var PromisePolyfill = class extends Promise {
63936
64099
  // Available starting from Node 22
63937
64100
  // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/withResolvers
63938
64101
  static withResolver() {
63939
- let resolve38;
64102
+ let resolve39;
63940
64103
  let reject;
63941
64104
  const promise = new Promise((res, rej) => {
63942
- resolve38 = res;
64105
+ resolve39 = res;
63943
64106
  reject = rej;
63944
64107
  });
63945
- return { promise, resolve: resolve38, reject };
64108
+ return { promise, resolve: resolve39, reject };
63946
64109
  }
63947
64110
  };
63948
64111
 
@@ -63959,7 +64122,7 @@ function createPrompt(view) {
63959
64122
  output
63960
64123
  });
63961
64124
  const screen = new ScreenManager(rl);
63962
- const { promise, resolve: resolve38, reject } = PromisePolyfill.withResolver();
64125
+ const { promise, resolve: resolve39, reject } = PromisePolyfill.withResolver();
63963
64126
  const cancel = () => reject(new CancelPromptError());
63964
64127
  if (signal) {
63965
64128
  const abort = () => reject(new AbortPromptError({ cause: signal.reason }));
@@ -63983,7 +64146,7 @@ function createPrompt(view) {
63983
64146
  cycle(() => {
63984
64147
  try {
63985
64148
  const nextView = view(config2, (value) => {
63986
- setImmediate(() => resolve38(value));
64149
+ setImmediate(() => resolve39(value));
63987
64150
  });
63988
64151
  const [content, bottomContent] = typeof nextView === "string" ? [nextView] : nextView;
63989
64152
  screen.render(content, bottomContent);
@@ -64970,9 +65133,9 @@ var import_run_async = __toESM(require_run_async(), 1);
64970
65133
  var import_mute_stream2 = __toESM(require_lib3(), 1);
64971
65134
  var import_ansi_escapes5 = __toESM(require_ansi_escapes(), 1);
64972
65135
  var _2 = {
64973
- set: (obj, path54 = "", value) => {
65136
+ set: (obj, path55 = "", value) => {
64974
65137
  let pointer = obj;
64975
- path54.split(".").forEach((key, index, arr) => {
65138
+ path55.split(".").forEach((key, index, arr) => {
64976
65139
  if (key === "__proto__" || key === "constructor")
64977
65140
  return;
64978
65141
  if (index === arr.length - 1) {
@@ -64983,8 +65146,8 @@ var _2 = {
64983
65146
  pointer = pointer[key];
64984
65147
  });
64985
65148
  },
64986
- get: (obj, path54 = "", defaultValue) => {
64987
- const travel = (regexp) => String.prototype.split.call(path54, regexp).filter(Boolean).reduce(
65149
+ get: (obj, path55 = "", defaultValue) => {
65150
+ const travel = (regexp) => String.prototype.split.call(path55, regexp).filter(Boolean).reduce(
64988
65151
  // @ts-expect-error implicit any on res[key]
64989
65152
  (res, key) => res !== null && res !== void 0 ? res[key] : res,
64990
65153
  obj
@@ -65098,7 +65261,7 @@ var PromptsRunner = class {
65098
65261
  throw new Error(`Prompt for type ${question.type} not found`);
65099
65262
  }
65100
65263
  let cleanupSignal;
65101
- const promptFn = isPromptConstructor(prompt2) ? (q2, { signal: signal2 } = {}) => new Promise((resolve38, reject) => {
65264
+ const promptFn = isPromptConstructor(prompt2) ? (q2, { signal: signal2 } = {}) => new Promise((resolve39, reject) => {
65102
65265
  const rl = import_node_readline.default.createInterface(setupReadlineOptions(this.opt));
65103
65266
  rl.resume();
65104
65267
  const onClose = () => {
@@ -65134,7 +65297,7 @@ var PromptsRunner = class {
65134
65297
  cleanupSignal = void 0;
65135
65298
  };
65136
65299
  }
65137
- activePrompt.run().then(resolve38, reject).finally(cleanup);
65300
+ activePrompt.run().then(resolve39, reject).finally(cleanup);
65138
65301
  }) : prompt2;
65139
65302
  const { signal: moduleSignal } = this.opt;
65140
65303
  if (moduleSignal?.aborted) {
@@ -65348,7 +65511,7 @@ var preferencesCommand = {
65348
65511
  };
65349
65512
 
65350
65513
  // src/cli/commands/telemetry.ts
65351
- var path53 = __toESM(require("path"));
65514
+ var path54 = __toESM(require("path"));
65352
65515
  init_control_config();
65353
65516
  init_otel_hooks();
65354
65517
  init_telemetry_config();
@@ -65433,7 +65596,7 @@ async function handleOff() {
65433
65596
  info("Mission Control will not auto-start. Existing usage rows are kept.");
65434
65597
  }
65435
65598
  async function handleWriteEnv(argv) {
65436
- const repoPath = path53.resolve(argv.repo);
65599
+ const repoPath = path54.resolve(argv.repo);
65437
65600
  const harnessRoot = resolveHarnessRoot(repoPath);
65438
65601
  const session = readSlotRegistry(harnessRoot, argv.agentId);
65439
65602
  const workDir = argv.workDir ?? session?.workDir ?? repoPath;
@@ -65445,7 +65608,7 @@ async function handleWriteEnv(argv) {
65445
65608
  suffix,
65446
65609
  createdAt: session?.createdAt
65447
65610
  });
65448
- const envFile = argv.envFile ?? path53.join(workDir, `.env.agent.${argv.agentId}`);
65611
+ const envFile = argv.envFile ?? path54.join(workDir, `.env.agent.${argv.agentId}`);
65449
65612
  const attrs = {
65450
65613
  sessionKey,
65451
65614
  agentId: argv.agentId,
@@ -65464,7 +65627,7 @@ async function handleWriteEnv(argv) {
65464
65627
  success(`Wrote session attribution to ${envFile}`);
65465
65628
  }
65466
65629
  function handlePrintEnv(argv) {
65467
- const repoPath = path53.resolve(argv.repo);
65630
+ const repoPath = path54.resolve(argv.repo);
65468
65631
  const workDir = argv.workDir ?? repoPath;
65469
65632
  const sessionKey = buildSessionKey({
65470
65633
  branch: argv.branch,