@osfactory/har 0.26.0 → 0.28.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 (2) hide show
  1. package/dist/index.js +712 -359
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -873,14 +873,14 @@ var require_url_state_machine = __commonJS({
873
873
  return url.replace(/\u0009|\u000A|\u000D/g, "");
874
874
  }
875
875
  function shortenPath(url) {
876
- const path56 = url.path;
877
- if (path56.length === 0) {
876
+ const path58 = url.path;
877
+ if (path58.length === 0) {
878
878
  return;
879
879
  }
880
- if (url.scheme === "file" && path56.length === 1 && isNormalizedWindowsDriveLetter(path56[0])) {
880
+ if (url.scheme === "file" && path58.length === 1 && isNormalizedWindowsDriveLetter(path58[0])) {
881
881
  return;
882
882
  }
883
- path56.pop();
883
+ path58.pop();
884
884
  }
885
885
  function includesCredentials(url) {
886
886
  return url.username !== "" || url.password !== "";
@@ -2200,7 +2200,7 @@ var require_lib2 = __commonJS({
2200
2200
  let accum = [];
2201
2201
  let accumBytes = 0;
2202
2202
  let abort = false;
2203
- return new Body.Promise(function(resolve40, reject) {
2203
+ return new Body.Promise(function(resolve42, reject) {
2204
2204
  let resTimeout;
2205
2205
  if (_this4.timeout) {
2206
2206
  resTimeout = setTimeout(function() {
@@ -2234,7 +2234,7 @@ var require_lib2 = __commonJS({
2234
2234
  }
2235
2235
  clearTimeout(resTimeout);
2236
2236
  try {
2237
- resolve40(Buffer.concat(accum, accumBytes));
2237
+ resolve42(Buffer.concat(accum, accumBytes));
2238
2238
  } catch (err) {
2239
2239
  reject(new FetchError(`Could not create Buffer from response body for ${_this4.url}: ${err.message}`, "system", err));
2240
2240
  }
@@ -2909,7 +2909,7 @@ var require_lib2 = __commonJS({
2909
2909
  throw new Error("native promise missing, set fetch.Promise to your favorite alternative");
2910
2910
  }
2911
2911
  Body.Promise = fetch3.Promise;
2912
- return new fetch3.Promise(function(resolve40, reject) {
2912
+ return new fetch3.Promise(function(resolve42, reject) {
2913
2913
  const request = new Request3(url, opts);
2914
2914
  const options = getNodeRequestOptions(request);
2915
2915
  const send = (options.protocol === "https:" ? https : http2).request;
@@ -3042,7 +3042,7 @@ var require_lib2 = __commonJS({
3042
3042
  requestOpts.body = void 0;
3043
3043
  requestOpts.headers.delete("content-length");
3044
3044
  }
3045
- resolve40(fetch3(new Request3(locationURL, requestOpts)));
3045
+ resolve42(fetch3(new Request3(locationURL, requestOpts)));
3046
3046
  finalize();
3047
3047
  return;
3048
3048
  }
@@ -3063,7 +3063,7 @@ var require_lib2 = __commonJS({
3063
3063
  const codings = headers.get("Content-Encoding");
3064
3064
  if (!request.compress || request.method === "HEAD" || codings === null || res.statusCode === 204 || res.statusCode === 304) {
3065
3065
  response = new Response3(body, response_options);
3066
- resolve40(response);
3066
+ resolve42(response);
3067
3067
  return;
3068
3068
  }
3069
3069
  const zlibOptions = {
@@ -3073,7 +3073,7 @@ var require_lib2 = __commonJS({
3073
3073
  if (codings == "gzip" || codings == "x-gzip") {
3074
3074
  body = body.pipe(zlib.createGunzip(zlibOptions));
3075
3075
  response = new Response3(body, response_options);
3076
- resolve40(response);
3076
+ resolve42(response);
3077
3077
  return;
3078
3078
  }
3079
3079
  if (codings == "deflate" || codings == "x-deflate") {
@@ -3085,12 +3085,12 @@ var require_lib2 = __commonJS({
3085
3085
  body = body.pipe(zlib.createInflateRaw());
3086
3086
  }
3087
3087
  response = new Response3(body, response_options);
3088
- resolve40(response);
3088
+ resolve42(response);
3089
3089
  });
3090
3090
  raw.on("end", function() {
3091
3091
  if (!response) {
3092
3092
  response = new Response3(body, response_options);
3093
- resolve40(response);
3093
+ resolve42(response);
3094
3094
  }
3095
3095
  });
3096
3096
  return;
@@ -3098,11 +3098,11 @@ var require_lib2 = __commonJS({
3098
3098
  if (codings == "br" && typeof zlib.createBrotliDecompress === "function") {
3099
3099
  body = body.pipe(zlib.createBrotliDecompress());
3100
3100
  response = new Response3(body, response_options);
3101
- resolve40(response);
3101
+ resolve42(response);
3102
3102
  return;
3103
3103
  }
3104
3104
  response = new Response3(body, response_options);
3105
- resolve40(response);
3105
+ resolve42(response);
3106
3106
  });
3107
3107
  writeToStream(req, request);
3108
3108
  });
@@ -6459,14 +6459,14 @@ __export(fileFromPath_exports, {
6459
6459
  fileFromPathSync: () => fileFromPathSync,
6460
6460
  isFile: () => isFile
6461
6461
  });
6462
- function createFileFromPath(path56, { mtimeMs, size }, filenameOrOptions, options = {}) {
6462
+ function createFileFromPath(path58, { mtimeMs, size }, filenameOrOptions, options = {}) {
6463
6463
  let filename;
6464
6464
  if (isPlainObject_default2(filenameOrOptions)) {
6465
6465
  [options, filename] = [filenameOrOptions, void 0];
6466
6466
  } else {
6467
6467
  filename = filenameOrOptions;
6468
6468
  }
6469
- const file = new FileFromPath({ path: path56, size, lastModified: mtimeMs });
6469
+ const file = new FileFromPath({ path: path58, size, lastModified: mtimeMs });
6470
6470
  if (!filename) {
6471
6471
  filename = file.name;
6472
6472
  }
@@ -6475,13 +6475,13 @@ function createFileFromPath(path56, { mtimeMs, size }, filenameOrOptions, option
6475
6475
  lastModified: file.lastModified
6476
6476
  });
6477
6477
  }
6478
- function fileFromPathSync(path56, filenameOrOptions, options = {}) {
6479
- const stats = (0, import_fs5.statSync)(path56);
6480
- return createFileFromPath(path56, stats, filenameOrOptions, options);
6478
+ function fileFromPathSync(path58, filenameOrOptions, options = {}) {
6479
+ const stats = (0, import_fs5.statSync)(path58);
6480
+ return createFileFromPath(path58, stats, filenameOrOptions, options);
6481
6481
  }
6482
- async function fileFromPath2(path56, filenameOrOptions, options) {
6483
- const stats = await import_fs5.promises.stat(path56);
6484
- return createFileFromPath(path56, stats, filenameOrOptions, options);
6482
+ async function fileFromPath2(path58, filenameOrOptions, options) {
6483
+ const stats = await import_fs5.promises.stat(path58);
6484
+ return createFileFromPath(path58, stats, filenameOrOptions, options);
6485
6485
  }
6486
6486
  var import_fs5, import_path5, import_node_domexception, __classPrivateFieldSet5, __classPrivateFieldGet6, _FileFromPath_path, _FileFromPath_start, MESSAGE, FileFromPath;
6487
6487
  var init_fileFromPath = __esm({
@@ -6635,15 +6635,15 @@ __export(otel_hooks_exports, {
6635
6635
  });
6636
6636
  function getOtelHooksHome() {
6637
6637
  if (process.env.HAR_OTEL_HOOKS_HOME) {
6638
- return path44.resolve(process.env.HAR_OTEL_HOOKS_HOME);
6638
+ return path45.resolve(process.env.HAR_OTEL_HOOKS_HOME);
6639
6639
  }
6640
- return path44.join(os13.homedir(), ".har", "otel-hooks");
6640
+ return path45.join(os14.homedir(), ".har", "otel-hooks");
6641
6641
  }
6642
6642
  function getOtelHooksConfigPath(hooksHome = getOtelHooksHome()) {
6643
- return path44.join(hooksHome, "otel_config.json");
6643
+ return path45.join(hooksHome, "otel_config.json");
6644
6644
  }
6645
6645
  function getOtelHooksWrapperPath(hooksHome = getOtelHooksHome()) {
6646
- return path44.join(hooksHome, "run-otel-hook.sh");
6646
+ return path45.join(hooksHome, "run-otel-hook.sh");
6647
6647
  }
6648
6648
  function buildOtelHooksConfig(options) {
6649
6649
  const enabled = options?.enabled ?? isTelemetryEnabled();
@@ -6662,18 +6662,18 @@ function buildOtelHooksConfig(options) {
6662
6662
  };
6663
6663
  }
6664
6664
  function writeOtelHooksConfig(config2, hooksHome = getOtelHooksHome()) {
6665
- fs41.mkdirSync(hooksHome, { recursive: true });
6665
+ fs42.mkdirSync(hooksHome, { recursive: true });
6666
6666
  const configPath = getOtelHooksConfigPath(hooksHome);
6667
6667
  const payload = {
6668
6668
  _comment: "Managed by har telemetry \u2014 do not edit by hand; use: har telemetry on|off",
6669
6669
  ...config2
6670
6670
  };
6671
- fs41.writeFileSync(configPath, `${JSON.stringify(payload, null, 2)}
6671
+ fs42.writeFileSync(configPath, `${JSON.stringify(payload, null, 2)}
6672
6672
  `);
6673
6673
  return configPath;
6674
6674
  }
6675
6675
  function writeOtelHooksWrapper(otelHookCommand, hooksHome = getOtelHooksHome()) {
6676
- fs41.mkdirSync(hooksHome, { recursive: true });
6676
+ fs42.mkdirSync(hooksHome, { recursive: true });
6677
6677
  const wrapperPath = getOtelHooksWrapperPath(hooksHome);
6678
6678
  const script = `#!/usr/bin/env bash
6679
6679
  # Managed by har telemetry \u2014 invokes opentelemetry-hooks with HAR config home.
@@ -6681,9 +6681,9 @@ set -euo pipefail
6681
6681
  export IDE_OTEL_HOOK_HOME="${hooksHome}"
6682
6682
  exec "${otelHookCommand}" "$@"
6683
6683
  `;
6684
- fs41.writeFileSync(wrapperPath, script, { mode: 493 });
6684
+ fs42.writeFileSync(wrapperPath, script, { mode: 493 });
6685
6685
  try {
6686
- fs41.chmodSync(wrapperPath, 493);
6686
+ fs42.chmodSync(wrapperPath, 493);
6687
6687
  } catch {
6688
6688
  }
6689
6689
  return wrapperPath;
@@ -6763,10 +6763,10 @@ function runSetupAgent(agent, otelHookCommand, hooksHome) {
6763
6763
  };
6764
6764
  }
6765
6765
  function rewriteHookCommandsToWrapper(filePath, wrapperPath) {
6766
- if (!fs41.existsSync(filePath)) return false;
6766
+ if (!fs42.existsSync(filePath)) return false;
6767
6767
  let raw;
6768
6768
  try {
6769
- raw = fs41.readFileSync(filePath, "utf8");
6769
+ raw = fs42.readFileSync(filePath, "utf8");
6770
6770
  } catch {
6771
6771
  return false;
6772
6772
  }
@@ -6805,16 +6805,16 @@ function rewriteHookCommandsToWrapper(filePath, wrapperPath) {
6805
6805
  return changed;
6806
6806
  };
6807
6807
  if (!walk(parsed)) return false;
6808
- fs41.writeFileSync(filePath, `${JSON.stringify(parsed, null, 2)}
6808
+ fs42.writeFileSync(filePath, `${JSON.stringify(parsed, null, 2)}
6809
6809
  `);
6810
6810
  return true;
6811
6811
  }
6812
6812
  function rewriteKnownHookRegistrations(wrapperPath) {
6813
- const home = os13.homedir();
6813
+ const home = os14.homedir();
6814
6814
  const candidates = [
6815
- path44.join(home, ".cursor", "hooks.json"),
6816
- path44.join(home, ".claude", "settings.json"),
6817
- path44.join(home, ".codex", "hooks.json")
6815
+ path45.join(home, ".cursor", "hooks.json"),
6816
+ path45.join(home, ".claude", "settings.json"),
6817
+ path45.join(home, ".codex", "hooks.json")
6818
6818
  ];
6819
6819
  for (const filePath of candidates) {
6820
6820
  try {
@@ -6827,7 +6827,7 @@ function ensureOtelHooks(options) {
6827
6827
  const hooksHome = getOtelHooksHome();
6828
6828
  const errors = [];
6829
6829
  const agentsSetup = [];
6830
- fs41.mkdirSync(hooksHome, { recursive: true });
6830
+ fs42.mkdirSync(hooksHome, { recursive: true });
6831
6831
  let otelHookCommand = resolveOtelHookCommand();
6832
6832
  if (!otelHookCommand) {
6833
6833
  const installed = tryInstallPackage();
@@ -6896,14 +6896,14 @@ function ensureOtelHooks(options) {
6896
6896
  function disableOtelHooksExport() {
6897
6897
  return writeOtelHooksConfig(buildOtelHooksConfig({ enabled: false }));
6898
6898
  }
6899
- var import_child_process10, fs41, os13, path44, OTEL_HOOKS_PACKAGE, OTEL_HOOKS_AGENTS;
6899
+ var import_child_process10, fs42, os14, path45, OTEL_HOOKS_PACKAGE, OTEL_HOOKS_AGENTS;
6900
6900
  var init_otel_hooks = __esm({
6901
6901
  "src/core/otel-hooks.ts"() {
6902
6902
  "use strict";
6903
6903
  import_child_process10 = require("child_process");
6904
- fs41 = __toESM(require("fs"));
6905
- os13 = __toESM(require("os"));
6906
- path44 = __toESM(require("path"));
6904
+ fs42 = __toESM(require("fs"));
6905
+ os14 = __toESM(require("os"));
6906
+ path45 = __toESM(require("path"));
6907
6907
  init_control_config();
6908
6908
  init_telemetry_config();
6909
6909
  OTEL_HOOKS_PACKAGE = "opentelemetry-hooks==0.14.0";
@@ -8003,15 +8003,15 @@ var require_route = __commonJS({
8003
8003
  };
8004
8004
  }
8005
8005
  function wrapConversion(toModel, graph) {
8006
- const path56 = [graph[toModel].parent, toModel];
8006
+ const path58 = [graph[toModel].parent, toModel];
8007
8007
  let fn = conversions[graph[toModel].parent][toModel];
8008
8008
  let cur = graph[toModel].parent;
8009
8009
  while (graph[cur].parent) {
8010
- path56.unshift(graph[cur].parent);
8010
+ path58.unshift(graph[cur].parent);
8011
8011
  fn = link(conversions[graph[cur].parent][cur], fn);
8012
8012
  cur = graph[cur].parent;
8013
8013
  }
8014
- fn.conversion = path56;
8014
+ fn.conversion = path58;
8015
8015
  return fn;
8016
8016
  }
8017
8017
  module2.exports = function(fromModel) {
@@ -13941,7 +13941,7 @@ var require_iso2022 = __commonJS({
13941
13941
  // node_modules/chardet/index.js
13942
13942
  var require_chardet = __commonJS({
13943
13943
  "node_modules/chardet/index.js"(exports2, module2) {
13944
- var fs47 = require("fs");
13944
+ var fs49 = require("fs");
13945
13945
  var utf8 = require_utf8();
13946
13946
  var unicode = require_unicode();
13947
13947
  var mbcs = require_mbcs();
@@ -14015,28 +14015,28 @@ var require_chardet = __commonJS({
14015
14015
  var fd;
14016
14016
  var handler = function(err, buffer) {
14017
14017
  if (fd) {
14018
- fs47.closeSync(fd);
14018
+ fs49.closeSync(fd);
14019
14019
  }
14020
14020
  if (err) return cb(err, null);
14021
14021
  cb(null, self.detect(buffer, opts));
14022
14022
  };
14023
14023
  if (opts && opts.sampleSize) {
14024
- fd = fs47.openSync(filepath, "r"), sample = Buffer.allocUnsafe(opts.sampleSize);
14025
- fs47.read(fd, sample, 0, opts.sampleSize, null, function(err) {
14024
+ fd = fs49.openSync(filepath, "r"), sample = Buffer.allocUnsafe(opts.sampleSize);
14025
+ fs49.read(fd, sample, 0, opts.sampleSize, null, function(err) {
14026
14026
  handler(err, sample);
14027
14027
  });
14028
14028
  return;
14029
14029
  }
14030
- fs47.readFile(filepath, handler);
14030
+ fs49.readFile(filepath, handler);
14031
14031
  };
14032
14032
  module2.exports.detectFileSync = function(filepath, opts) {
14033
14033
  if (opts && opts.sampleSize) {
14034
- var fd = fs47.openSync(filepath, "r"), sample2 = Buffer.allocUnsafe(opts.sampleSize);
14035
- fs47.readSync(fd, sample2, 0, opts.sampleSize);
14036
- fs47.closeSync(fd);
14034
+ var fd = fs49.openSync(filepath, "r"), sample2 = Buffer.allocUnsafe(opts.sampleSize);
14035
+ fs49.readSync(fd, sample2, 0, opts.sampleSize);
14036
+ fs49.closeSync(fd);
14037
14037
  return self.detect(sample2, opts);
14038
14038
  }
14039
- return self.detect(fs47.readFileSync(filepath), opts);
14039
+ return self.detect(fs49.readFileSync(filepath), opts);
14040
14040
  };
14041
14041
  module2.exports.detectAll = function(buffer, opts) {
14042
14042
  if (typeof opts !== "object") {
@@ -17501,16 +17501,16 @@ var require_os_tmpdir = __commonJS({
17501
17501
  var isWindows = process.platform === "win32";
17502
17502
  var trailingSlashRe = isWindows ? /[^:]\\$/ : /.\/$/;
17503
17503
  module2.exports = function() {
17504
- var path56;
17504
+ var path58;
17505
17505
  if (isWindows) {
17506
- path56 = process.env.TEMP || process.env.TMP || (process.env.SystemRoot || process.env.windir) + "\\temp";
17506
+ path58 = process.env.TEMP || process.env.TMP || (process.env.SystemRoot || process.env.windir) + "\\temp";
17507
17507
  } else {
17508
- path56 = process.env.TMPDIR || process.env.TMP || process.env.TEMP || "/tmp";
17508
+ path58 = process.env.TMPDIR || process.env.TMP || process.env.TEMP || "/tmp";
17509
17509
  }
17510
- if (trailingSlashRe.test(path56)) {
17511
- path56 = path56.slice(0, -1);
17510
+ if (trailingSlashRe.test(path58)) {
17511
+ path58 = path58.slice(0, -1);
17512
17512
  }
17513
- return path56;
17513
+ return path58;
17514
17514
  };
17515
17515
  }
17516
17516
  });
@@ -17518,8 +17518,8 @@ var require_os_tmpdir = __commonJS({
17518
17518
  // node_modules/tmp/lib/tmp.js
17519
17519
  var require_tmp = __commonJS({
17520
17520
  "node_modules/tmp/lib/tmp.js"(exports2, module2) {
17521
- var fs47 = require("fs");
17522
- var path56 = require("path");
17521
+ var fs49 = require("fs");
17522
+ var path58 = require("path");
17523
17523
  var crypto6 = require("crypto");
17524
17524
  var osTmpDir = require_os_tmpdir();
17525
17525
  var _c2 = process.binding("constants");
@@ -17561,7 +17561,7 @@ var require_tmp = __commonJS({
17561
17561
  }
17562
17562
  function _generateTmpName(opts) {
17563
17563
  if (opts.name) {
17564
- return path56.join(opts.dir || tmpDir, opts.name);
17564
+ return path58.join(opts.dir || tmpDir, opts.name);
17565
17565
  }
17566
17566
  if (opts.template) {
17567
17567
  return opts.template.replace(TEMPLATE_PATTERN, _randomChars(6));
@@ -17572,7 +17572,7 @@ var require_tmp = __commonJS({
17572
17572
  _randomChars(12),
17573
17573
  opts.postfix || ""
17574
17574
  ].join("");
17575
- return path56.join(opts.dir || tmpDir, name);
17575
+ return path58.join(opts.dir || tmpDir, name);
17576
17576
  }
17577
17577
  function tmpName(options, callback) {
17578
17578
  var args = _parseArguments(options, callback), opts = args[0], cb = args[1], tries = opts.name ? 1 : opts.tries || DEFAULT_TRIES;
@@ -17582,7 +17582,7 @@ var require_tmp = __commonJS({
17582
17582
  return cb(new Error("Invalid template provided"));
17583
17583
  (function _getUniqueName() {
17584
17584
  const name = _generateTmpName(opts);
17585
- fs47.stat(name, function(err) {
17585
+ fs49.stat(name, function(err) {
17586
17586
  if (!err) {
17587
17587
  if (tries-- > 0) return _getUniqueName();
17588
17588
  return cb(new Error("Could not get a unique tmp filename, max tries reached " + name));
@@ -17600,7 +17600,7 @@ var require_tmp = __commonJS({
17600
17600
  do {
17601
17601
  const name = _generateTmpName(opts);
17602
17602
  try {
17603
- fs47.statSync(name);
17603
+ fs49.statSync(name);
17604
17604
  } catch (e2) {
17605
17605
  return name;
17606
17606
  }
@@ -17612,13 +17612,13 @@ var require_tmp = __commonJS({
17612
17612
  opts.postfix = _isUndefined(opts.postfix) ? ".tmp" : opts.postfix;
17613
17613
  tmpName(opts, function _tmpNameCreated(err, name) {
17614
17614
  if (err) return cb(err);
17615
- fs47.open(name, CREATE_FLAGS, opts.mode || FILE_MODE, function _fileCreated(err2, fd) {
17615
+ fs49.open(name, CREATE_FLAGS, opts.mode || FILE_MODE, function _fileCreated(err2, fd) {
17616
17616
  if (err2) return cb(err2);
17617
17617
  if (opts.discardDescriptor) {
17618
- return fs47.close(fd, function _discardCallback(err3) {
17618
+ return fs49.close(fd, function _discardCallback(err3) {
17619
17619
  if (err3) {
17620
17620
  try {
17621
- fs47.unlinkSync(name);
17621
+ fs49.unlinkSync(name);
17622
17622
  } catch (e2) {
17623
17623
  if (!isENOENT(e2)) {
17624
17624
  err3 = e2;
@@ -17641,9 +17641,9 @@ var require_tmp = __commonJS({
17641
17641
  opts.postfix = opts.postfix || ".tmp";
17642
17642
  const discardOrDetachDescriptor = opts.discardDescriptor || opts.detachDescriptor;
17643
17643
  const name = tmpNameSync(opts);
17644
- var fd = fs47.openSync(name, CREATE_FLAGS, opts.mode || FILE_MODE);
17644
+ var fd = fs49.openSync(name, CREATE_FLAGS, opts.mode || FILE_MODE);
17645
17645
  if (opts.discardDescriptor) {
17646
- fs47.closeSync(fd);
17646
+ fs49.closeSync(fd);
17647
17647
  fd = void 0;
17648
17648
  }
17649
17649
  return {
@@ -17655,9 +17655,9 @@ var require_tmp = __commonJS({
17655
17655
  function _rmdirRecursiveSync(root) {
17656
17656
  const dirs = [root];
17657
17657
  do {
17658
- var dir2 = dirs.pop(), deferred = false, files = fs47.readdirSync(dir2);
17658
+ var dir2 = dirs.pop(), deferred = false, files = fs49.readdirSync(dir2);
17659
17659
  for (var i2 = 0, length = files.length; i2 < length; i2++) {
17660
- var file2 = path56.join(dir2, files[i2]), stat = fs47.lstatSync(file2);
17660
+ var file2 = path58.join(dir2, files[i2]), stat = fs49.lstatSync(file2);
17661
17661
  if (stat.isDirectory()) {
17662
17662
  if (!deferred) {
17663
17663
  deferred = true;
@@ -17665,11 +17665,11 @@ var require_tmp = __commonJS({
17665
17665
  }
17666
17666
  dirs.push(file2);
17667
17667
  } else {
17668
- fs47.unlinkSync(file2);
17668
+ fs49.unlinkSync(file2);
17669
17669
  }
17670
17670
  }
17671
17671
  if (!deferred) {
17672
- fs47.rmdirSync(dir2);
17672
+ fs49.rmdirSync(dir2);
17673
17673
  }
17674
17674
  } while (dirs.length !== 0);
17675
17675
  }
@@ -17677,7 +17677,7 @@ var require_tmp = __commonJS({
17677
17677
  var args = _parseArguments(options, callback), opts = args[0], cb = args[1];
17678
17678
  tmpName(opts, function _tmpNameCreated(err, name) {
17679
17679
  if (err) return cb(err);
17680
- fs47.mkdir(name, opts.mode || DIR_MODE, function _dirCreated(err2) {
17680
+ fs49.mkdir(name, opts.mode || DIR_MODE, function _dirCreated(err2) {
17681
17681
  if (err2) return cb(err2);
17682
17682
  cb(null, name, _prepareTmpDirRemoveCallback(name, opts));
17683
17683
  });
@@ -17686,7 +17686,7 @@ var require_tmp = __commonJS({
17686
17686
  function dirSync(options) {
17687
17687
  var args = _parseArguments(options), opts = args[0];
17688
17688
  const name = tmpNameSync(opts);
17689
- fs47.mkdirSync(name, opts.mode || DIR_MODE);
17689
+ fs49.mkdirSync(name, opts.mode || DIR_MODE);
17690
17690
  return {
17691
17691
  name,
17692
17692
  removeCallback: _prepareTmpDirRemoveCallback(name, opts)
@@ -17696,7 +17696,7 @@ var require_tmp = __commonJS({
17696
17696
  const removeCallback = _prepareRemoveCallback(function _removeCallback(fdPath) {
17697
17697
  try {
17698
17698
  if (0 <= fdPath[0]) {
17699
- fs47.closeSync(fdPath[0]);
17699
+ fs49.closeSync(fdPath[0]);
17700
17700
  }
17701
17701
  } catch (e2) {
17702
17702
  if (!isEBADF(e2) && !isENOENT(e2)) {
@@ -17704,7 +17704,7 @@ var require_tmp = __commonJS({
17704
17704
  }
17705
17705
  }
17706
17706
  try {
17707
- fs47.unlinkSync(fdPath[1]);
17707
+ fs49.unlinkSync(fdPath[1]);
17708
17708
  } catch (e2) {
17709
17709
  if (!isENOENT(e2)) {
17710
17710
  throw e2;
@@ -17717,7 +17717,7 @@ var require_tmp = __commonJS({
17717
17717
  return removeCallback;
17718
17718
  }
17719
17719
  function _prepareTmpDirRemoveCallback(name, opts) {
17720
- const removeFunction = opts.unsafeCleanup ? _rmdirRecursiveSync : fs47.rmdirSync.bind(fs47);
17720
+ const removeFunction = opts.unsafeCleanup ? _rmdirRecursiveSync : fs49.rmdirSync.bind(fs49);
17721
17721
  const removeCallback = _prepareRemoveCallback(removeFunction, name);
17722
17722
  if (!opts.keep) {
17723
17723
  _removeObjects.unshift(removeCallback);
@@ -18868,7 +18868,7 @@ var require_Observable = __commonJS({
18868
18868
  Observable2.prototype.forEach = function(next, promiseCtor) {
18869
18869
  var _this = this;
18870
18870
  promiseCtor = getPromiseCtor(promiseCtor);
18871
- return new promiseCtor(function(resolve40, reject) {
18871
+ return new promiseCtor(function(resolve42, reject) {
18872
18872
  var subscriber = new Subscriber_1.SafeSubscriber({
18873
18873
  next: function(value) {
18874
18874
  try {
@@ -18879,7 +18879,7 @@ var require_Observable = __commonJS({
18879
18879
  }
18880
18880
  },
18881
18881
  error: reject,
18882
- complete: resolve40
18882
+ complete: resolve42
18883
18883
  });
18884
18884
  _this.subscribe(subscriber);
18885
18885
  });
@@ -18901,14 +18901,14 @@ var require_Observable = __commonJS({
18901
18901
  Observable2.prototype.toPromise = function(promiseCtor) {
18902
18902
  var _this = this;
18903
18903
  promiseCtor = getPromiseCtor(promiseCtor);
18904
- return new promiseCtor(function(resolve40, reject) {
18904
+ return new promiseCtor(function(resolve42, reject) {
18905
18905
  var value;
18906
18906
  _this.subscribe(function(x2) {
18907
18907
  return value = x2;
18908
18908
  }, function(err) {
18909
18909
  return reject(err);
18910
18910
  }, function() {
18911
- return resolve40(value);
18911
+ return resolve42(value);
18912
18912
  });
18913
18913
  });
18914
18914
  };
@@ -21004,11 +21004,11 @@ var require_innerFrom = __commonJS({
21004
21004
  "use strict";
21005
21005
  var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P2, generator) {
21006
21006
  function adopt(value) {
21007
- return value instanceof P2 ? value : new P2(function(resolve40) {
21008
- resolve40(value);
21007
+ return value instanceof P2 ? value : new P2(function(resolve42) {
21008
+ resolve42(value);
21009
21009
  });
21010
21010
  }
21011
- return new (P2 || (P2 = Promise))(function(resolve40, reject) {
21011
+ return new (P2 || (P2 = Promise))(function(resolve42, reject) {
21012
21012
  function fulfilled(value) {
21013
21013
  try {
21014
21014
  step(generator.next(value));
@@ -21024,7 +21024,7 @@ var require_innerFrom = __commonJS({
21024
21024
  }
21025
21025
  }
21026
21026
  function step(result) {
21027
- result.done ? resolve40(result.value) : adopt(result.value).then(fulfilled, rejected);
21027
+ result.done ? resolve42(result.value) : adopt(result.value).then(fulfilled, rejected);
21028
21028
  }
21029
21029
  step((generator = generator.apply(thisArg, _arguments || [])).next());
21030
21030
  });
@@ -21106,14 +21106,14 @@ var require_innerFrom = __commonJS({
21106
21106
  }, i2);
21107
21107
  function verb(n2) {
21108
21108
  i2[n2] = o2[n2] && function(v2) {
21109
- return new Promise(function(resolve40, reject) {
21110
- v2 = o2[n2](v2), settle(resolve40, reject, v2.done, v2.value);
21109
+ return new Promise(function(resolve42, reject) {
21110
+ v2 = o2[n2](v2), settle(resolve42, reject, v2.done, v2.value);
21111
21111
  });
21112
21112
  };
21113
21113
  }
21114
- function settle(resolve40, reject, d2, v2) {
21114
+ function settle(resolve42, reject, d2, v2) {
21115
21115
  Promise.resolve(v2).then(function(v3) {
21116
- resolve40({ value: v3, done: d2 });
21116
+ resolve42({ value: v3, done: d2 });
21117
21117
  }, reject);
21118
21118
  }
21119
21119
  };
@@ -21732,7 +21732,7 @@ var require_lastValueFrom = __commonJS({
21732
21732
  var EmptyError_1 = require_EmptyError();
21733
21733
  function lastValueFrom2(source, config2) {
21734
21734
  var hasConfig = typeof config2 === "object";
21735
- return new Promise(function(resolve40, reject) {
21735
+ return new Promise(function(resolve42, reject) {
21736
21736
  var _hasValue = false;
21737
21737
  var _value;
21738
21738
  source.subscribe({
@@ -21743,9 +21743,9 @@ var require_lastValueFrom = __commonJS({
21743
21743
  error: reject,
21744
21744
  complete: function() {
21745
21745
  if (_hasValue) {
21746
- resolve40(_value);
21746
+ resolve42(_value);
21747
21747
  } else if (hasConfig) {
21748
- resolve40(config2.defaultValue);
21748
+ resolve42(config2.defaultValue);
21749
21749
  } else {
21750
21750
  reject(new EmptyError_1.EmptyError());
21751
21751
  }
@@ -21767,16 +21767,16 @@ var require_firstValueFrom = __commonJS({
21767
21767
  var Subscriber_1 = require_Subscriber();
21768
21768
  function firstValueFrom(source, config2) {
21769
21769
  var hasConfig = typeof config2 === "object";
21770
- return new Promise(function(resolve40, reject) {
21770
+ return new Promise(function(resolve42, reject) {
21771
21771
  var subscriber = new Subscriber_1.SafeSubscriber({
21772
21772
  next: function(value) {
21773
- resolve40(value);
21773
+ resolve42(value);
21774
21774
  subscriber.unsubscribe();
21775
21775
  },
21776
21776
  error: reject,
21777
21777
  complete: function() {
21778
21778
  if (hasConfig) {
21779
- resolve40(config2.defaultValue);
21779
+ resolve42(config2.defaultValue);
21780
21780
  } else {
21781
21781
  reject(new EmptyError_1.EmptyError());
21782
21782
  }
@@ -25739,7 +25739,7 @@ var require_share = __commonJS({
25739
25739
  subscriber.add(function() {
25740
25740
  refCount--;
25741
25741
  if (refCount === 0 && !hasErrored && !hasCompleted) {
25742
- resetConnection = handleReset(resetAndUnsubscribe, resetOnRefCountZero);
25742
+ resetConnection = handleReset2(resetAndUnsubscribe, resetOnRefCountZero);
25743
25743
  }
25744
25744
  });
25745
25745
  dest.subscribe(subscriber);
@@ -25751,13 +25751,13 @@ var require_share = __commonJS({
25751
25751
  error: function(err) {
25752
25752
  hasErrored = true;
25753
25753
  cancelReset();
25754
- resetConnection = handleReset(reset, resetOnError, err);
25754
+ resetConnection = handleReset2(reset, resetOnError, err);
25755
25755
  dest.error(err);
25756
25756
  },
25757
25757
  complete: function() {
25758
25758
  hasCompleted = true;
25759
25759
  cancelReset();
25760
- resetConnection = handleReset(reset, resetOnComplete);
25760
+ resetConnection = handleReset2(reset, resetOnComplete);
25761
25761
  dest.complete();
25762
25762
  }
25763
25763
  });
@@ -25767,7 +25767,7 @@ var require_share = __commonJS({
25767
25767
  };
25768
25768
  }
25769
25769
  exports2.share = share;
25770
- function handleReset(reset, on) {
25770
+ function handleReset2(reset, on) {
25771
25771
  var args = [];
25772
25772
  for (var _i = 2; _i < arguments.length; _i++) {
25773
25773
  args[_i - 2] = arguments[_i];
@@ -27569,14 +27569,14 @@ var require_run_async = __commonJS({
27569
27569
  return function() {
27570
27570
  var args = arguments;
27571
27571
  var originalThis = this;
27572
- var promise = new Promise(function(resolve40, reject) {
27572
+ var promise = new Promise(function(resolve42, reject) {
27573
27573
  var resolved = false;
27574
27574
  const wrappedResolve = function(value) {
27575
27575
  if (resolved) {
27576
27576
  console.warn("Run-async promise already resolved.");
27577
27577
  }
27578
27578
  resolved = true;
27579
- resolve40(value);
27579
+ resolve42(value);
27580
27580
  };
27581
27581
  var rejected = false;
27582
27582
  const wrappedReject = function(value) {
@@ -30605,7 +30605,7 @@ var require_compile = __commonJS({
30605
30605
  const schOrFunc = root.refs[ref];
30606
30606
  if (schOrFunc)
30607
30607
  return schOrFunc;
30608
- let _sch = resolve40.call(this, root, ref);
30608
+ let _sch = resolve42.call(this, root, ref);
30609
30609
  if (_sch === void 0) {
30610
30610
  const schema = (_a3 = root.localRefs) === null || _a3 === void 0 ? void 0 : _a3[ref];
30611
30611
  const { schemaId } = this.opts;
@@ -30632,7 +30632,7 @@ var require_compile = __commonJS({
30632
30632
  function sameSchemaEnv(s1, s2) {
30633
30633
  return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
30634
30634
  }
30635
- function resolve40(root, ref) {
30635
+ function resolve42(root, ref) {
30636
30636
  let sch;
30637
30637
  while (typeof (sch = this.refs[ref]) == "string")
30638
30638
  ref = sch;
@@ -30850,8 +30850,8 @@ var require_utils2 = __commonJS({
30850
30850
  }
30851
30851
  return ind;
30852
30852
  }
30853
- function removeDotSegments(path56) {
30854
- let input = path56;
30853
+ function removeDotSegments(path58) {
30854
+ let input = path58;
30855
30855
  const output = [];
30856
30856
  let nextSlash = -1;
30857
30857
  let len = 0;
@@ -31103,8 +31103,8 @@ var require_schemes = __commonJS({
31103
31103
  wsComponent.secure = void 0;
31104
31104
  }
31105
31105
  if (wsComponent.resourceName) {
31106
- const [path56, query] = wsComponent.resourceName.split("?");
31107
- wsComponent.path = path56 && path56 !== "/" ? path56 : void 0;
31106
+ const [path58, query] = wsComponent.resourceName.split("?");
31107
+ wsComponent.path = path58 && path58 !== "/" ? path58 : void 0;
31108
31108
  wsComponent.query = query;
31109
31109
  wsComponent.resourceName = void 0;
31110
31110
  }
@@ -31263,7 +31263,7 @@ var require_fast_uri = __commonJS({
31263
31263
  }
31264
31264
  return uri;
31265
31265
  }
31266
- function resolve40(baseURI, relativeURI, options) {
31266
+ function resolve42(baseURI, relativeURI, options) {
31267
31267
  const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
31268
31268
  const resolved = resolveComponent(parse4(baseURI, schemelessOptions), parse4(relativeURI, schemelessOptions), schemelessOptions, true);
31269
31269
  schemelessOptions.skipEscape = true;
@@ -31521,7 +31521,7 @@ var require_fast_uri = __commonJS({
31521
31521
  var fastUri = {
31522
31522
  SCHEMES,
31523
31523
  normalize: normalize3,
31524
- resolve: resolve40,
31524
+ resolve: resolve42,
31525
31525
  resolveComponent,
31526
31526
  equal,
31527
31527
  serialize,
@@ -34497,12 +34497,12 @@ var require_dist = __commonJS({
34497
34497
  throw new Error(`Unknown format "${name}"`);
34498
34498
  return f2;
34499
34499
  };
34500
- function addFormats(ajv, list, fs47, exportName) {
34500
+ function addFormats(ajv, list, fs49, exportName) {
34501
34501
  var _a3;
34502
34502
  var _b2;
34503
34503
  (_a3 = (_b2 = ajv.opts.code).formats) !== null && _a3 !== void 0 ? _a3 : _b2.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
34504
34504
  for (const f2 of list)
34505
- ajv.addFormat(f2, fs47[f2]);
34505
+ ajv.addFormat(f2, fs49[f2]);
34506
34506
  }
34507
34507
  module2.exports = exports2 = formatsPlugin;
34508
34508
  Object.defineProperty(exports2, "__esModule", { value: true });
@@ -35786,11 +35786,11 @@ var parser = new YargsParser({
35786
35786
  resolve: import_path2.resolve,
35787
35787
  // TODO: figure out a way to combine ESM and CJS coverage, such that
35788
35788
  // we can exercise all the lines below:
35789
- require: (path56) => {
35789
+ require: (path58) => {
35790
35790
  if (typeof require !== "undefined") {
35791
- return require(path56);
35792
- } else if (path56.match(/\.json$/)) {
35793
- return JSON.parse((0, import_fs2.readFileSync)(path56, "utf8"));
35791
+ return require(path58);
35792
+ } else if (path58.match(/\.json$/)) {
35793
+ return JSON.parse((0, import_fs2.readFileSync)(path58, "utf8"));
35794
35794
  } else {
35795
35795
  throw Error("only .json config files are supported in ESM");
35796
35796
  }
@@ -38316,12 +38316,12 @@ var YargsInstance = class {
38316
38316
  async getCompletion(args, done) {
38317
38317
  argsert("<array> [function]", [args, done], arguments.length);
38318
38318
  if (!done) {
38319
- return new Promise((resolve40, reject) => {
38319
+ return new Promise((resolve42, reject) => {
38320
38320
  __classPrivateFieldGet(this, _YargsInstance_completion, "f").getCompletion(args, (err, completions) => {
38321
38321
  if (err)
38322
38322
  reject(err);
38323
38323
  else
38324
- resolve40(completions);
38324
+ resolve42(completions);
38325
38325
  });
38326
38326
  });
38327
38327
  } else {
@@ -40474,8 +40474,8 @@ function getErrorMap() {
40474
40474
 
40475
40475
  // node_modules/zod/v3/helpers/parseUtil.js
40476
40476
  var makeIssue = (params) => {
40477
- const { data, path: path56, errorMaps, issueData } = params;
40478
- const fullPath = [...path56, ...issueData.path || []];
40477
+ const { data, path: path58, errorMaps, issueData } = params;
40478
+ const fullPath = [...path58, ...issueData.path || []];
40479
40479
  const fullIssue = {
40480
40480
  ...issueData,
40481
40481
  path: fullPath
@@ -40591,11 +40591,11 @@ var errorUtil;
40591
40591
 
40592
40592
  // node_modules/zod/v3/types.js
40593
40593
  var ParseInputLazyPath = class {
40594
- constructor(parent, value, path56, key) {
40594
+ constructor(parent, value, path58, key) {
40595
40595
  this._cachedPath = [];
40596
40596
  this.parent = parent;
40597
40597
  this.data = value;
40598
- this._path = path56;
40598
+ this._path = path58;
40599
40599
  this._key = key;
40600
40600
  }
40601
40601
  get path() {
@@ -44378,6 +44378,28 @@ var UnregisterRepoResultSchema = external_exports.object({
44378
44378
  deleteWorktrees: external_exports.boolean(),
44379
44379
  worktrees: external_exports.array(UnregisterWorktreeResultSchema)
44380
44380
  });
44381
+ var ResetMissionControlInputSchema = external_exports.object({
44382
+ confirm: external_exports.literal("RESET"),
44383
+ /**
44384
+ * When true, delete `.har/{runs,validations,state,slots}` under each registered
44385
+ * repository path (best-effort; Docker often cannot see host paths).
44386
+ */
44387
+ scrubLocalHarness: external_exports.boolean().optional().default(true)
44388
+ });
44389
+ var HarnessScrubResultSchema = external_exports.object({
44390
+ path: external_exports.string(),
44391
+ directory: external_exports.string(),
44392
+ deleted: external_exports.boolean(),
44393
+ error: external_exports.string().optional()
44394
+ });
44395
+ var ResetMissionControlResultSchema = external_exports.object({
44396
+ ok: external_exports.literal(true),
44397
+ repositoriesDeleted: external_exports.number().int().nonnegative(),
44398
+ unregisteredCleared: external_exports.number().int().nonnegative(),
44399
+ scrubLocalHarness: external_exports.boolean(),
44400
+ scrubbed: external_exports.array(HarnessScrubResultSchema),
44401
+ repoPaths: external_exports.array(external_exports.string())
44402
+ });
44381
44403
  var SyncRunsInputSchema = external_exports.object({
44382
44404
  runs: external_exports.array(RunRecordSchema)
44383
44405
  });
@@ -44734,16 +44756,16 @@ async function handleAgentSkills(options) {
44734
44756
  }
44735
44757
  async function askYesNo(question) {
44736
44758
  const rl = readline.createInterface({ input: process.stdin, output: process.stderr });
44737
- return new Promise((resolve40) => {
44759
+ return new Promise((resolve42) => {
44738
44760
  process.stderr.write(`${question} `);
44739
44761
  rl.once("line", (answer) => {
44740
44762
  rl.close();
44741
44763
  const trimmed = answer.trim();
44742
44764
  if (trimmed === "") {
44743
- resolve40(true);
44765
+ resolve42(true);
44744
44766
  return;
44745
44767
  }
44746
- resolve40(/^y(es)?$/i.test(trimmed));
44768
+ resolve42(/^y(es)?$/i.test(trimmed));
44747
44769
  });
44748
44770
  });
44749
44771
  }
@@ -44822,7 +44844,7 @@ function handleRemove(argv) {
44822
44844
  }
44823
44845
 
44824
44846
  // src/cli/commands/env.ts
44825
- var path48 = __toESM(require("path"));
44847
+ var path49 = __toESM(require("path"));
44826
44848
 
44827
44849
  // src/core/harness.ts
44828
44850
  var fs21 = __toESM(require("fs"));
@@ -45601,13 +45623,13 @@ var MultipartBody = class {
45601
45623
  // node_modules/@anthropic-ai/sdk/_shims/node-runtime.mjs
45602
45624
  var import_web = require("node:stream/web");
45603
45625
  var fileFromPathWarned = false;
45604
- async function fileFromPath3(path56, ...args) {
45626
+ async function fileFromPath3(path58, ...args) {
45605
45627
  const { fileFromPath: _fileFromPath } = await Promise.resolve().then(() => (init_fileFromPath(), fileFromPath_exports));
45606
45628
  if (!fileFromPathWarned) {
45607
- console.warn(`fileFromPath is deprecated; use fs.createReadStream(${JSON.stringify(path56)}) instead`);
45629
+ console.warn(`fileFromPath is deprecated; use fs.createReadStream(${JSON.stringify(path58)}) instead`);
45608
45630
  fileFromPathWarned = true;
45609
45631
  }
45610
- return await _fileFromPath(path56, ...args);
45632
+ return await _fileFromPath(path58, ...args);
45611
45633
  }
45612
45634
  var defaultHttpAgent = new import_agentkeepalive.default({ keepAlive: true, timeout: 5 * 60 * 1e3 });
45613
45635
  var defaultHttpsAgent = new import_agentkeepalive.default.HttpsAgent({ keepAlive: true, timeout: 5 * 60 * 1e3 });
@@ -46103,8 +46125,8 @@ async function defaultParseResponse(props) {
46103
46125
  }
46104
46126
  var APIPromise = class _APIPromise extends Promise {
46105
46127
  constructor(responsePromise, parseResponse = defaultParseResponse) {
46106
- super((resolve40) => {
46107
- resolve40(null);
46128
+ super((resolve42) => {
46129
+ resolve42(null);
46108
46130
  });
46109
46131
  this.responsePromise = responsePromise;
46110
46132
  this.parseResponse = parseResponse;
@@ -46204,29 +46226,29 @@ var APIClient = class {
46204
46226
  defaultIdempotencyKey() {
46205
46227
  return `stainless-node-retry-${uuid4()}`;
46206
46228
  }
46207
- get(path56, opts) {
46208
- return this.methodRequest("get", path56, opts);
46229
+ get(path58, opts) {
46230
+ return this.methodRequest("get", path58, opts);
46209
46231
  }
46210
- post(path56, opts) {
46211
- return this.methodRequest("post", path56, opts);
46232
+ post(path58, opts) {
46233
+ return this.methodRequest("post", path58, opts);
46212
46234
  }
46213
- patch(path56, opts) {
46214
- return this.methodRequest("patch", path56, opts);
46235
+ patch(path58, opts) {
46236
+ return this.methodRequest("patch", path58, opts);
46215
46237
  }
46216
- put(path56, opts) {
46217
- return this.methodRequest("put", path56, opts);
46238
+ put(path58, opts) {
46239
+ return this.methodRequest("put", path58, opts);
46218
46240
  }
46219
- delete(path56, opts) {
46220
- return this.methodRequest("delete", path56, opts);
46241
+ delete(path58, opts) {
46242
+ return this.methodRequest("delete", path58, opts);
46221
46243
  }
46222
- methodRequest(method, path56, opts) {
46244
+ methodRequest(method, path58, opts) {
46223
46245
  return this.request(Promise.resolve(opts).then(async (opts2) => {
46224
46246
  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;
46225
- return { method, path: path56, ...opts2, body };
46247
+ return { method, path: path58, ...opts2, body };
46226
46248
  }));
46227
46249
  }
46228
- getAPIList(path56, Page, opts) {
46229
- return this.requestAPIList(Page, { method: "get", path: path56, ...opts });
46250
+ getAPIList(path58, Page, opts) {
46251
+ return this.requestAPIList(Page, { method: "get", path: path58, ...opts });
46230
46252
  }
46231
46253
  calculateContentLength(body) {
46232
46254
  if (typeof body === "string") {
@@ -46244,10 +46266,10 @@ var APIClient = class {
46244
46266
  return null;
46245
46267
  }
46246
46268
  buildRequest(options) {
46247
- const { method, path: path56, query, headers = {} } = options;
46269
+ const { method, path: path58, query, headers = {} } = options;
46248
46270
  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;
46249
46271
  const contentLength = this.calculateContentLength(body);
46250
- const url = this.buildURL(path56, query);
46272
+ const url = this.buildURL(path58, query);
46251
46273
  if ("timeout" in options)
46252
46274
  validatePositiveInteger("timeout", options.timeout);
46253
46275
  const timeout = options.timeout ?? this.timeout;
@@ -46356,8 +46378,8 @@ var APIClient = class {
46356
46378
  const request = this.makeRequest(options, null);
46357
46379
  return new PagePromise(this, request, Page);
46358
46380
  }
46359
- buildURL(path56, query) {
46360
- const url = isAbsoluteURL(path56) ? new URL(path56) : new URL(this.baseURL + (this.baseURL.endsWith("/") && path56.startsWith("/") ? path56.slice(1) : path56));
46381
+ buildURL(path58, query) {
46382
+ const url = isAbsoluteURL(path58) ? new URL(path58) : new URL(this.baseURL + (this.baseURL.endsWith("/") && path58.startsWith("/") ? path58.slice(1) : path58));
46361
46383
  const defaultQuery = this.defaultQuery();
46362
46384
  if (!isEmptyObj(defaultQuery)) {
46363
46385
  query = { ...defaultQuery, ...query };
@@ -46642,7 +46664,7 @@ var startsWithSchemeRegexp = new RegExp("^(?:[a-z]+:)?//", "i");
46642
46664
  var isAbsoluteURL = (url) => {
46643
46665
  return startsWithSchemeRegexp.test(url);
46644
46666
  };
46645
- var sleep = (ms) => new Promise((resolve40) => setTimeout(resolve40, ms));
46667
+ var sleep = (ms) => new Promise((resolve42) => setTimeout(resolve42, ms));
46646
46668
  var validatePositiveInteger = (name, n2) => {
46647
46669
  if (typeof n2 !== "number" || !Number.isInteger(n2)) {
46648
46670
  throw new AnthropicError(`${name} must be an integer`);
@@ -47133,12 +47155,12 @@ var PromptCachingBetaMessageStream = class _PromptCachingBetaMessageStream {
47133
47155
  }
47134
47156
  return this._emit("error", new AnthropicError(String(error3)));
47135
47157
  });
47136
- __classPrivateFieldSet7(this, _PromptCachingBetaMessageStream_connectedPromise, new Promise((resolve40, reject) => {
47137
- __classPrivateFieldSet7(this, _PromptCachingBetaMessageStream_resolveConnectedPromise, resolve40, "f");
47158
+ __classPrivateFieldSet7(this, _PromptCachingBetaMessageStream_connectedPromise, new Promise((resolve42, reject) => {
47159
+ __classPrivateFieldSet7(this, _PromptCachingBetaMessageStream_resolveConnectedPromise, resolve42, "f");
47138
47160
  __classPrivateFieldSet7(this, _PromptCachingBetaMessageStream_rejectConnectedPromise, reject, "f");
47139
47161
  }), "f");
47140
- __classPrivateFieldSet7(this, _PromptCachingBetaMessageStream_endPromise, new Promise((resolve40, reject) => {
47141
- __classPrivateFieldSet7(this, _PromptCachingBetaMessageStream_resolveEndPromise, resolve40, "f");
47162
+ __classPrivateFieldSet7(this, _PromptCachingBetaMessageStream_endPromise, new Promise((resolve42, reject) => {
47163
+ __classPrivateFieldSet7(this, _PromptCachingBetaMessageStream_resolveEndPromise, resolve42, "f");
47142
47164
  __classPrivateFieldSet7(this, _PromptCachingBetaMessageStream_rejectEndPromise, reject, "f");
47143
47165
  }), "f");
47144
47166
  __classPrivateFieldGet8(this, _PromptCachingBetaMessageStream_connectedPromise, "f").catch(() => {
@@ -47267,11 +47289,11 @@ var PromptCachingBetaMessageStream = class _PromptCachingBetaMessageStream {
47267
47289
  * const message = await stream.emitted('message') // rejects if the stream errors
47268
47290
  */
47269
47291
  emitted(event) {
47270
- return new Promise((resolve40, reject) => {
47292
+ return new Promise((resolve42, reject) => {
47271
47293
  __classPrivateFieldSet7(this, _PromptCachingBetaMessageStream_catchingPromiseCreated, true, "f");
47272
47294
  if (event !== "error")
47273
47295
  this.once("error", reject);
47274
- this.once(event, resolve40);
47296
+ this.once(event, resolve42);
47275
47297
  });
47276
47298
  }
47277
47299
  async done() {
@@ -47498,7 +47520,7 @@ var PromptCachingBetaMessageStream = class _PromptCachingBetaMessageStream {
47498
47520
  if (done) {
47499
47521
  return { value: void 0, done: true };
47500
47522
  }
47501
- return new Promise((resolve40, reject) => readQueue.push({ resolve: resolve40, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
47523
+ return new Promise((resolve42, reject) => readQueue.push({ resolve: resolve42, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
47502
47524
  }
47503
47525
  const chunk = pushQueue.shift();
47504
47526
  return { value: chunk, done: false };
@@ -47646,12 +47668,12 @@ var MessageStream = class _MessageStream {
47646
47668
  }
47647
47669
  return this._emit("error", new AnthropicError(String(error3)));
47648
47670
  });
47649
- __classPrivateFieldSet8(this, _MessageStream_connectedPromise, new Promise((resolve40, reject) => {
47650
- __classPrivateFieldSet8(this, _MessageStream_resolveConnectedPromise, resolve40, "f");
47671
+ __classPrivateFieldSet8(this, _MessageStream_connectedPromise, new Promise((resolve42, reject) => {
47672
+ __classPrivateFieldSet8(this, _MessageStream_resolveConnectedPromise, resolve42, "f");
47651
47673
  __classPrivateFieldSet8(this, _MessageStream_rejectConnectedPromise, reject, "f");
47652
47674
  }), "f");
47653
- __classPrivateFieldSet8(this, _MessageStream_endPromise, new Promise((resolve40, reject) => {
47654
- __classPrivateFieldSet8(this, _MessageStream_resolveEndPromise, resolve40, "f");
47675
+ __classPrivateFieldSet8(this, _MessageStream_endPromise, new Promise((resolve42, reject) => {
47676
+ __classPrivateFieldSet8(this, _MessageStream_resolveEndPromise, resolve42, "f");
47655
47677
  __classPrivateFieldSet8(this, _MessageStream_rejectEndPromise, reject, "f");
47656
47678
  }), "f");
47657
47679
  __classPrivateFieldGet9(this, _MessageStream_connectedPromise, "f").catch(() => {
@@ -47780,11 +47802,11 @@ var MessageStream = class _MessageStream {
47780
47802
  * const message = await stream.emitted('message') // rejects if the stream errors
47781
47803
  */
47782
47804
  emitted(event) {
47783
- return new Promise((resolve40, reject) => {
47805
+ return new Promise((resolve42, reject) => {
47784
47806
  __classPrivateFieldSet8(this, _MessageStream_catchingPromiseCreated, true, "f");
47785
47807
  if (event !== "error")
47786
47808
  this.once("error", reject);
47787
- this.once(event, resolve40);
47809
+ this.once(event, resolve42);
47788
47810
  });
47789
47811
  }
47790
47812
  async done() {
@@ -48011,7 +48033,7 @@ var MessageStream = class _MessageStream {
48011
48033
  if (done) {
48012
48034
  return { value: void 0, done: true };
48013
48035
  }
48014
- return new Promise((resolve40, reject) => readQueue.push({ resolve: resolve40, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
48036
+ return new Promise((resolve42, reject) => readQueue.push({ resolve: resolve42, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
48015
48037
  }
48016
48038
  const chunk = pushQueue.shift();
48017
48039
  return { value: chunk, done: false };
@@ -48271,11 +48293,11 @@ async function promptApplyAgentMdProposal(repoPath) {
48271
48293
  }
48272
48294
  async function askYesNo2(question) {
48273
48295
  const rl = readline2.createInterface({ input: process.stdin, output: process.stderr });
48274
- return new Promise((resolve40) => {
48296
+ return new Promise((resolve42) => {
48275
48297
  process.stderr.write(`${question} `);
48276
48298
  rl.once("line", (answer) => {
48277
48299
  rl.close();
48278
- resolve40(/^y(es)?$/i.test(answer.trim()));
48300
+ resolve42(/^y(es)?$/i.test(answer.trim()));
48279
48301
  });
48280
48302
  });
48281
48303
  }
@@ -48505,7 +48527,7 @@ async function executeAuthoringToolCall(toolName, input, repoPath, harnessDir, c
48505
48527
  }
48506
48528
  async function askUser(question, options) {
48507
48529
  const rl = readline3.createInterface({ input: process.stdin, output: process.stderr });
48508
- return new Promise((resolve40) => {
48530
+ return new Promise((resolve42) => {
48509
48531
  process.stderr.write("\n");
48510
48532
  process.stderr.write(`\u2753 ${question}
48511
48533
  `);
@@ -48516,7 +48538,7 @@ async function askUser(question, options) {
48516
48538
  process.stderr.write("> ");
48517
48539
  rl.once("line", (answer) => {
48518
48540
  rl.close();
48519
- resolve40(answer.trim());
48541
+ resolve42(answer.trim());
48520
48542
  });
48521
48543
  });
48522
48544
  }
@@ -48660,7 +48682,7 @@ function runScript(scriptPath, args = [], options = {}) {
48660
48682
  function runScriptCapture(scriptPath, args = [], options = {}) {
48661
48683
  const stream = options.stream ?? false;
48662
48684
  const { stream: _stream, ...spawnOptions } = options;
48663
- return new Promise((resolve40) => {
48685
+ return new Promise((resolve42) => {
48664
48686
  const proc = (0, import_child_process.spawn)("bash", [scriptPath, ...args], {
48665
48687
  ...spawnOptions,
48666
48688
  stdio: ["inherit", "pipe", "pipe"]
@@ -48675,13 +48697,13 @@ function runScriptCapture(scriptPath, args = [], options = {}) {
48675
48697
  stderr += d2;
48676
48698
  if (stream) process.stderr.write(d2);
48677
48699
  });
48678
- proc.on("close", (code) => resolve40({ stdout, stderr, code: code ?? 0 }));
48700
+ proc.on("close", (code) => resolve42({ stdout, stderr, code: code ?? 0 }));
48679
48701
  });
48680
48702
  }
48681
48703
  function runShellCommand(command2, options = {}) {
48682
48704
  const stream = options.stream ?? false;
48683
48705
  const { stream: _stream, ...spawnOptions } = options;
48684
- return new Promise((resolve40) => {
48706
+ return new Promise((resolve42) => {
48685
48707
  const proc = (0, import_child_process.spawn)("bash", ["-lc", command2], {
48686
48708
  ...spawnOptions,
48687
48709
  stdio: ["inherit", "pipe", "pipe"]
@@ -48696,7 +48718,7 @@ function runShellCommand(command2, options = {}) {
48696
48718
  stderr += d2;
48697
48719
  if (stream) process.stderr.write(d2);
48698
48720
  });
48699
- proc.on("close", (code) => resolve40({ stdout, stderr, code: code ?? 0 }));
48721
+ proc.on("close", (code) => resolve42({ stdout, stderr, code: code ?? 0 }));
48700
48722
  });
48701
48723
  }
48702
48724
 
@@ -49877,12 +49899,12 @@ function printAdaptationPrompt(content) {
49877
49899
  }
49878
49900
  function askYesNo3(question) {
49879
49901
  const rl = readline4.createInterface({ input: process.stdin, output: process.stderr });
49880
- return new Promise((resolve40) => {
49902
+ return new Promise((resolve42) => {
49881
49903
  process.stderr.write(`${question} `);
49882
49904
  rl.once("line", (answer) => {
49883
49905
  rl.close();
49884
49906
  const trimmed = answer.trim();
49885
- resolve40(trimmed === "" || /^y(es)?$/i.test(trimmed));
49907
+ resolve42(trimmed === "" || /^y(es)?$/i.test(trimmed));
49886
49908
  });
49887
49909
  });
49888
49910
  }
@@ -49969,16 +49991,16 @@ async function promptScaffoldCursorRule(exists) {
49969
49991
  }
49970
49992
  async function askYesNo4(question) {
49971
49993
  const rl = readline5.createInterface({ input: process.stdin, output: process.stderr });
49972
- return new Promise((resolve40) => {
49994
+ return new Promise((resolve42) => {
49973
49995
  process.stderr.write(`${question} `);
49974
49996
  rl.once("line", (answer) => {
49975
49997
  rl.close();
49976
49998
  const trimmed = answer.trim();
49977
49999
  if (trimmed === "") {
49978
- resolve40(true);
50000
+ resolve42(true);
49979
50001
  return;
49980
50002
  }
49981
- resolve40(/^y(es)?$/i.test(trimmed));
50003
+ resolve42(/^y(es)?$/i.test(trimmed));
49982
50004
  });
49983
50005
  });
49984
50006
  }
@@ -50288,7 +50310,7 @@ var LocalScriptExecutor = class {
50288
50310
  var localScriptExecutor = new LocalScriptExecutor();
50289
50311
 
50290
50312
  // src/core/control-sync.ts
50291
- var path42 = __toESM(require("path"));
50313
+ var path43 = __toESM(require("path"));
50292
50314
  init_control_config();
50293
50315
 
50294
50316
  // src/core/control-registry.ts
@@ -50405,6 +50427,13 @@ function listRegisteredRepos() {
50405
50427
  }
50406
50428
  return kept;
50407
50429
  }
50430
+ function clearRegisteredRepos() {
50431
+ const registry2 = readRegistry();
50432
+ const count = registry2.repos.length;
50433
+ if (count === 0) return 0;
50434
+ writeRegistry({ repos: [] });
50435
+ return count;
50436
+ }
50408
50437
 
50409
50438
  // src/core/control-sync.ts
50410
50439
  init_portal_credentials();
@@ -52144,7 +52173,66 @@ function harvestEventsForSlot(slot) {
52144
52173
  }
52145
52174
 
52146
52175
  // src/core/control-persisted-usage.ts
52176
+ var path42 = __toESM(require("path"));
52177
+
52178
+ // src/core/portal-watermark.ts
52179
+ var fs41 = __toESM(require("fs"));
52180
+ var os13 = __toESM(require("os"));
52147
52181
  var path41 = __toESM(require("path"));
52182
+ function getStatePath() {
52183
+ if (process.env.HAR_PORTAL_SYNC_STATE_PATH) {
52184
+ return path41.resolve(process.env.HAR_PORTAL_SYNC_STATE_PATH);
52185
+ }
52186
+ return path41.join(os13.homedir(), ".har", "portal-sync-state.json");
52187
+ }
52188
+ function readState() {
52189
+ const statePath = getStatePath();
52190
+ try {
52191
+ if (!fs41.existsSync(statePath)) return { states: [] };
52192
+ const parsed = JSON.parse(fs41.readFileSync(statePath, "utf8"));
52193
+ return Array.isArray(parsed.states) ? parsed : { states: [] };
52194
+ } catch {
52195
+ return { states: [] };
52196
+ }
52197
+ }
52198
+ function writeState(state) {
52199
+ const statePath = getStatePath();
52200
+ fs41.mkdirSync(path41.dirname(statePath), { recursive: true });
52201
+ fs41.writeFileSync(statePath, JSON.stringify(state, null, 2) + "\n");
52202
+ }
52203
+ function readPortalWatermark(repoPath, portalUrl) {
52204
+ const canonical = canonicalizeControlRepoPath(repoPath);
52205
+ const entry = readState().states.find(
52206
+ (state) => state.repoPath === canonical && state.portalUrl === portalUrl
52207
+ );
52208
+ return entry?.lastSyncedAt ?? null;
52209
+ }
52210
+ function writePortalWatermark(repoPath, portalUrl, lastSyncedAt) {
52211
+ const canonical = canonicalizeControlRepoPath(repoPath);
52212
+ const state = readState();
52213
+ const existing = state.states.find(
52214
+ (entry) => entry.repoPath === canonical && entry.portalUrl === portalUrl
52215
+ );
52216
+ if (existing) {
52217
+ existing.lastSyncedAt = lastSyncedAt;
52218
+ } else {
52219
+ state.states.push({ repoPath: canonical, portalUrl, lastSyncedAt });
52220
+ }
52221
+ writeState(state);
52222
+ }
52223
+ function selectSince(rows, since, getTimestamp) {
52224
+ let maxSyncedAt = null;
52225
+ const selected = [];
52226
+ for (const row of rows) {
52227
+ const ts = getTimestamp(row);
52228
+ if (since && ts && ts <= since) continue;
52229
+ selected.push(row);
52230
+ if (ts && (maxSyncedAt === null || ts > maxSyncedAt)) maxSyncedAt = ts;
52231
+ }
52232
+ return { selected, maxSyncedAt };
52233
+ }
52234
+
52235
+ // src/core/control-persisted-usage.ts
52148
52236
  var FETCH_TIMEOUT_MS = 3e3;
52149
52237
  async function getJson(url) {
52150
52238
  try {
@@ -52161,8 +52249,8 @@ async function getJson(url) {
52161
52249
  async function resolveControlRepoId(apiUrl, repoPath) {
52162
52250
  const repos = await getJson(`${apiUrl}/api/repos`);
52163
52251
  if (!Array.isArray(repos)) return null;
52164
- const target = path41.resolve(repoPath);
52165
- return repos.find((repo) => path41.resolve(repo.path) === target)?.id ?? null;
52252
+ const target = path42.resolve(repoPath);
52253
+ return repos.find((repo) => path42.resolve(repo.path) === target)?.id ?? null;
52166
52254
  }
52167
52255
  function optionalString(value) {
52168
52256
  return value == null ? void 0 : value;
@@ -52210,16 +52298,25 @@ function normalizeEvent(row) {
52210
52298
  source: row.source === "harvest" ? "harvest" : "otel"
52211
52299
  };
52212
52300
  }
52213
- async function fetchPersistedPortalTelemetry(repoPath, apiUrl) {
52301
+ function maxTimestamp(a2, b2) {
52302
+ if (a2 === null) return b2;
52303
+ if (b2 === null) return a2;
52304
+ return a2 > b2 ? a2 : b2;
52305
+ }
52306
+ async function fetchPersistedPortalTelemetry(repoPath, apiUrl, options) {
52214
52307
  const repoId = await resolveControlRepoId(apiUrl, repoPath);
52215
- if (!repoId) return { usage: [], events: [] };
52308
+ if (!repoId) return { usage: [], events: [], maxSyncedAt: null };
52309
+ const since = options?.since ?? null;
52216
52310
  const [usageResponse, eventsResponse] = await Promise.all([
52217
52311
  getJson(`${apiUrl}/api/repos/${repoId}/usage`),
52218
52312
  getJson(`${apiUrl}/api/repos/${repoId}/events`)
52219
52313
  ]);
52314
+ const usage2 = selectSince(usageResponse?.usage ?? [], since, (row) => row.updatedAt ?? row.lastSeenAt);
52315
+ const events = selectSince(eventsResponse?.events ?? [], since, (row) => row.createdAt ?? row.timestamp);
52220
52316
  return {
52221
- usage: (usageResponse?.usage ?? []).map(normalizeUsage),
52222
- events: (eventsResponse?.events ?? []).map(normalizeEvent)
52317
+ usage: usage2.selected.map(normalizeUsage),
52318
+ events: events.selected.map(normalizeEvent),
52319
+ maxSyncedAt: maxTimestamp(usage2.maxSyncedAt, events.maxSyncedAt)
52223
52320
  };
52224
52321
  }
52225
52322
 
@@ -52350,8 +52447,8 @@ function modelsFromBreakdown(breakdown) {
52350
52447
  ...totals && typeof totals === "object" ? totals : {}
52351
52448
  }));
52352
52449
  }
52353
- async function collectPortalTelemetry(repoPath, slots, controlApiUrl) {
52354
- if (!isTelemetryEnabled()) return { usage: [], events: [] };
52450
+ async function collectPortalTelemetry(repoPath, slots, controlApiUrl, since) {
52451
+ if (!isTelemetryEnabled()) return { usage: [], events: [], maxSyncedAt: null };
52355
52452
  try {
52356
52453
  const userEmail = resolvePortalUserEmail();
52357
52454
  const liveUsage = slots.flatMap(
@@ -52390,7 +52487,7 @@ async function collectPortalTelemetry(repoPath, slots, controlApiUrl) {
52390
52487
  attemptId: slot.attemptId ?? event.attemptId
52391
52488
  }))
52392
52489
  );
52393
- const persisted = await fetchPersistedPortalTelemetry(repoPath, controlApiUrl);
52490
+ const persisted = await fetchPersistedPortalTelemetry(repoPath, controlApiUrl, { since });
52394
52491
  const usage2 = mergePortalUsage(liveUsage, persisted.usage).map((row) => {
52395
52492
  const models = modelsFromBreakdown(row.modelBreakdown);
52396
52493
  return {
@@ -52402,12 +52499,12 @@ async function collectPortalTelemetry(repoPath, slots, controlApiUrl) {
52402
52499
  const events = dedupePortalEvents(liveEvents, persisted.events).map(
52403
52500
  (event) => dropNullFields({ ...event })
52404
52501
  );
52405
- return { usage: usage2, events };
52502
+ return { usage: usage2, events, maxSyncedAt: persisted.maxSyncedAt };
52406
52503
  } catch {
52407
- return { usage: [], events: [] };
52504
+ return { usage: [], events: [], maxSyncedAt: null };
52408
52505
  }
52409
52506
  }
52410
- async function buildPortalPayload(repoPath, controlApiUrl) {
52507
+ async function buildPortalPayload(repoPath, controlApiUrl, since) {
52411
52508
  const runs = listRuns(repoPath);
52412
52509
  const status = collectEnvironmentStatus(repoPath);
52413
52510
  const manifest = readManifest(repoPath);
@@ -52417,7 +52514,12 @@ async function buildPortalPayload(repoPath, controlApiUrl) {
52417
52514
  const workUnits = listWorkUnits(harnessRoot);
52418
52515
  const attempts = listWorkAttempts(harnessRoot);
52419
52516
  const validationBindings = listValidationBindings(harnessRoot);
52420
- const { usage: usage2, events } = await collectPortalTelemetry(repoPath, status.slots, controlApiUrl);
52517
+ const { usage: usage2, events, maxSyncedAt } = await collectPortalTelemetry(
52518
+ repoPath,
52519
+ status.slots,
52520
+ controlApiUrl,
52521
+ since
52522
+ );
52421
52523
  const syncBody = {
52422
52524
  path: repoPath,
52423
52525
  ...manifest ? { manifest } : {},
@@ -52431,7 +52533,7 @@ async function buildPortalPayload(repoPath, controlApiUrl) {
52431
52533
  ...validationBindings.length > 0 ? { validationBindings } : {},
52432
52534
  ...usage2.length > 0 ? { usage: usage2 } : {}
52433
52535
  };
52434
- return { syncBody, events };
52536
+ return { syncBody, events, maxSyncedAt };
52435
52537
  }
52436
52538
  async function isControlApiReachable(apiUrl = getControlApiUrl()) {
52437
52539
  try {
@@ -52448,7 +52550,7 @@ async function waitForControlApi(apiUrl = getControlApiUrl(), timeoutMs = 6e4, i
52448
52550
  const deadline = Date.now() + timeoutMs;
52449
52551
  while (Date.now() < deadline) {
52450
52552
  if (await isControlApiReachable(apiUrl)) return true;
52451
- await new Promise((resolve40) => setTimeout(resolve40, intervalMs));
52553
+ await new Promise((resolve42) => setTimeout(resolve42, intervalMs));
52452
52554
  }
52453
52555
  return false;
52454
52556
  }
@@ -52480,7 +52582,7 @@ async function syncReposWithControl(options) {
52480
52582
  for (const repoPath of options.repoPaths) {
52481
52583
  try {
52482
52584
  await withTimeout(
52483
- syncRepoWithControl({ repoPath, apiUrl, dryRun: options.dryRun, cloud: options.cloud }),
52585
+ syncRepoWithControl({ repoPath, apiUrl, dryRun: options.dryRun, cloud: options.cloud, full: options.full }),
52484
52586
  SYNC_TIMEOUT_MS,
52485
52587
  "control sync"
52486
52588
  );
@@ -52566,7 +52668,8 @@ async function syncRepoWithControl(options) {
52566
52668
  }
52567
52669
  const portal = getPortalTarget();
52568
52670
  if (portal) {
52569
- const { syncBody, events } = await buildPortalPayload(repoPath, apiUrl);
52671
+ const since = options.full ? null : readPortalWatermark(repoPath, portal.url);
52672
+ const { syncBody, events, maxSyncedAt } = await buildPortalPayload(repoPath, apiUrl, since);
52570
52673
  await postPortal(portal, "/api/sync", syncBody, options.dryRun);
52571
52674
  if (events.length > 0) {
52572
52675
  await postPortal(
@@ -52576,6 +52679,9 @@ async function syncRepoWithControl(options) {
52576
52679
  options.dryRun
52577
52680
  );
52578
52681
  }
52682
+ if (!options.dryRun && maxSyncedAt) {
52683
+ writePortalWatermark(repoPath, portal.url, maxSyncedAt);
52684
+ }
52579
52685
  return;
52580
52686
  }
52581
52687
  const registerResult = await registerRepoWithControl({ ...options, repoPath });
@@ -52584,7 +52690,7 @@ async function syncRepoWithControl(options) {
52584
52690
  const listResponse = await fetch(`${apiUrl}/api/repos`);
52585
52691
  if (!listResponse.ok) throw new Error("Failed to list repos from Control API");
52586
52692
  const repos = await listResponse.json();
52587
- const existing = repos.find((r2) => path42.resolve(r2.path) === repoPath);
52693
+ const existing = repos.find((r2) => path43.resolve(r2.path) === repoPath);
52588
52694
  if (!existing) {
52589
52695
  return;
52590
52696
  }
@@ -52737,7 +52843,7 @@ init_control_config();
52737
52843
 
52738
52844
  // src/core/control-lifecycle.ts
52739
52845
  var import_child_process9 = require("child_process");
52740
- var path43 = __toESM(require("path"));
52846
+ var path44 = __toESM(require("path"));
52741
52847
 
52742
52848
  // src/core/control-image.ts
52743
52849
  var DEFAULT_CONTROL_IMAGE = "theosfactory/har-control";
@@ -52761,10 +52867,10 @@ var CONTROL_DATA_VOLUME = "har_control_data";
52761
52867
  var CONTROL_CONTAINER_PORT = 3847;
52762
52868
  var CONTROL_DATA_DB_URL = "file:/data/har_control.db";
52763
52869
  function resolveControlDir() {
52764
- return path43.resolve(__dirname, "..", "control");
52870
+ return path44.resolve(__dirname, "..", "control");
52765
52871
  }
52766
52872
  function resolveControlBuildContext() {
52767
- return path43.resolve(resolveControlDir(), "..");
52873
+ return path44.resolve(resolveControlDir(), "..");
52768
52874
  }
52769
52875
  function buildDockerRunArgs(options) {
52770
52876
  const name = options.containerName ?? CONTROL_CONTAINER_NAME;
@@ -52820,7 +52926,7 @@ async function startMissionControl(options) {
52820
52926
  "-t",
52821
52927
  imageRef,
52822
52928
  "-f",
52823
- path43.join(resolveControlDir(), "Dockerfile"),
52929
+ path44.join(resolveControlDir(), "Dockerfile"),
52824
52930
  resolveControlBuildContext()
52825
52931
  ]);
52826
52932
  if (buildCode !== 0) {
@@ -52965,7 +53071,7 @@ async function ensureTelemetryInfrastructure(options) {
52965
53071
 
52966
53072
  // src/core/run-service.ts
52967
53073
  init_telemetry_config();
52968
- var path45 = __toESM(require("path"));
53074
+ var path46 = __toESM(require("path"));
52969
53075
  function extractShellOutput(result) {
52970
53076
  const stdout = result.logs?.find((log) => log.stream === "stdout")?.content ?? result.logs?.find((log) => !log.stream)?.content ?? "";
52971
53077
  const stderr = result.logs?.find((log) => log.stream === "stderr")?.content ?? "";
@@ -53175,12 +53281,12 @@ Usage from Cursor / Claude / Codex (opentelemetry-hooks) will appear under Workt
53175
53281
  suffix: session.suffix,
53176
53282
  createdAt: session.createdAt
53177
53283
  });
53178
- const envFile = path45.join(session.workDir, `.env.agent.${options.agentId}`);
53284
+ const envFile = path46.join(session.workDir, `.env.agent.${options.agentId}`);
53179
53285
  try {
53180
53286
  appendTelemetryEnvToFile(envFile, {
53181
53287
  sessionKey,
53182
53288
  agentId: options.agentId,
53183
- repoPath: path45.resolve(options.repoPath),
53289
+ repoPath: path46.resolve(options.repoPath),
53184
53290
  workDir: session.workDir,
53185
53291
  branch: session.branch,
53186
53292
  suffix: session.suffix,
@@ -53412,9 +53518,9 @@ var getEnvironmentLogs = defaultRunService.getEnvironmentLogs.bind(defaultRunSer
53412
53518
  var readline6 = __toESM(require("readline"));
53413
53519
 
53414
53520
  // src/core/hooks.ts
53415
- var fs42 = __toESM(require("fs"));
53416
- var os14 = __toESM(require("os"));
53417
- var path46 = __toESM(require("path"));
53521
+ var fs43 = __toESM(require("fs"));
53522
+ var os15 = __toESM(require("os"));
53523
+ var path47 = __toESM(require("path"));
53418
53524
  var MARKER_START = "# >>> har commit gate (managed by `har hooks`) >>>";
53419
53525
  var MARKER_END = "# <<< har commit gate <<<";
53420
53526
  var PRE_COMMIT_BLOCK = [
@@ -53439,7 +53545,7 @@ function resolveCheckoutRoot(cwd) {
53439
53545
  function resolveHooksDir(checkoutDir) {
53440
53546
  const hooksPath = tryGit3(checkoutDir, "rev-parse --git-path hooks");
53441
53547
  if (!hooksPath) throw new Error(`Not a git checkout: ${checkoutDir}`);
53442
- return path46.resolve(checkoutDir, hooksPath);
53548
+ return path47.resolve(checkoutDir, hooksPath);
53443
53549
  }
53444
53550
  function getConfiguredHooksPath(checkoutDir) {
53445
53551
  return tryGit3(checkoutDir, "config core.hooksPath") || void 0;
@@ -53447,9 +53553,9 @@ function getConfiguredHooksPath(checkoutDir) {
53447
53553
  function defaultHarInvocation() {
53448
53554
  const entry = process.argv[1];
53449
53555
  if (entry && entry.endsWith(".js")) {
53450
- return `"${process.execPath}" "${path46.resolve(entry)}"`;
53556
+ return `"${process.execPath}" "${path47.resolve(entry)}"`;
53451
53557
  }
53452
- if (entry) return `"${path46.resolve(entry)}"`;
53558
+ if (entry) return `"${path47.resolve(entry)}"`;
53453
53559
  return "har";
53454
53560
  }
53455
53561
  function buildHookScript(harInvocation, subcommand, failOpenNotice) {
@@ -53470,40 +53576,40 @@ exit 0
53470
53576
  `;
53471
53577
  }
53472
53578
  function upsertMarkedBlock(filePath, block) {
53473
- if (!fs42.existsSync(filePath)) {
53474
- fs42.writeFileSync(filePath, `#!/bin/sh
53579
+ if (!fs43.existsSync(filePath)) {
53580
+ fs43.writeFileSync(filePath, `#!/bin/sh
53475
53581
  ${block}
53476
53582
  `, { mode: 493 });
53477
53583
  return "created";
53478
53584
  }
53479
- const content = fs42.readFileSync(filePath, "utf8");
53585
+ const content = fs43.readFileSync(filePath, "utf8");
53480
53586
  if (content.includes(MARKER_START)) {
53481
53587
  const pattern = new RegExp(
53482
53588
  `${escapeRegExp(MARKER_START)}[\\s\\S]*?${escapeRegExp(MARKER_END)}`
53483
53589
  );
53484
- fs42.writeFileSync(filePath, content.replace(pattern, block));
53485
- fs42.chmodSync(filePath, 493);
53590
+ fs43.writeFileSync(filePath, content.replace(pattern, block));
53591
+ fs43.chmodSync(filePath, 493);
53486
53592
  return "updated";
53487
53593
  }
53488
53594
  const suffix = content.endsWith("\n") ? "" : "\n";
53489
- fs42.writeFileSync(filePath, `${content}${suffix}
53595
+ fs43.writeFileSync(filePath, `${content}${suffix}
53490
53596
  ${block}
53491
53597
  `);
53492
- fs42.chmodSync(filePath, 493);
53598
+ fs43.chmodSync(filePath, 493);
53493
53599
  return "appended";
53494
53600
  }
53495
53601
  function removeMarkedBlock(filePath) {
53496
- if (!fs42.existsSync(filePath)) return false;
53497
- const content = fs42.readFileSync(filePath, "utf8");
53602
+ if (!fs43.existsSync(filePath)) return false;
53603
+ const content = fs43.readFileSync(filePath, "utf8");
53498
53604
  if (!content.includes(MARKER_START)) return false;
53499
53605
  const pattern = new RegExp(
53500
53606
  `\\n?${escapeRegExp(MARKER_START)}[\\s\\S]*?${escapeRegExp(MARKER_END)}\\n?`
53501
53607
  );
53502
53608
  const stripped = content.replace(pattern, "\n");
53503
53609
  if (stripped.replace(/^#!\/bin\/sh\n?/, "").trim() === "") {
53504
- fs42.rmSync(filePath);
53610
+ fs43.rmSync(filePath);
53505
53611
  } else {
53506
- fs42.writeFileSync(filePath, stripped);
53612
+ fs43.writeFileSync(filePath, stripped);
53507
53613
  }
53508
53614
  return true;
53509
53615
  }
@@ -53525,20 +53631,20 @@ Or re-run with --force to write into that directory anyway.`
53525
53631
  );
53526
53632
  }
53527
53633
  const hooksDir = resolveHooksDir(checkout);
53528
- fs42.mkdirSync(hooksDir, { recursive: true });
53634
+ fs43.mkdirSync(hooksDir, { recursive: true });
53529
53635
  const invocation = options.harInvocation ?? defaultHarInvocation();
53530
- fs42.writeFileSync(
53531
- path46.join(hooksDir, "har-pre-commit"),
53636
+ fs43.writeFileSync(
53637
+ path47.join(hooksDir, "har-pre-commit"),
53532
53638
  buildHookScript(invocation, "check", "har: binary not found; skipping commit gate (reinstall with har hooks install)"),
53533
53639
  { mode: 493 }
53534
53640
  );
53535
- fs42.writeFileSync(
53536
- path46.join(hooksDir, "har-post-commit"),
53641
+ fs43.writeFileSync(
53642
+ path47.join(hooksDir, "har-post-commit"),
53537
53643
  buildHookScript(invocation, "record-commit", "har: binary not found; skipping commit association"),
53538
53644
  { mode: 493 }
53539
53645
  );
53540
- const preCommit = upsertMarkedBlock(path46.join(hooksDir, "pre-commit"), PRE_COMMIT_BLOCK);
53541
- const postCommit = upsertMarkedBlock(path46.join(hooksDir, "post-commit"), POST_COMMIT_BLOCK);
53646
+ const preCommit = upsertMarkedBlock(path47.join(hooksDir, "pre-commit"), PRE_COMMIT_BLOCK);
53647
+ const postCommit = upsertMarkedBlock(path47.join(hooksDir, "post-commit"), POST_COMMIT_BLOCK);
53542
53648
  ensureValidationsIgnored(checkout);
53543
53649
  return { hooksDir, preCommit, postCommit };
53544
53650
  }
@@ -53547,12 +53653,12 @@ function uninstallHooks(repoPath) {
53547
53653
  if (!checkout) throw new Error(`Not a git repository: ${repoPath}`);
53548
53654
  const hooksDir = resolveHooksDir(checkout);
53549
53655
  let removed = false;
53550
- removed = removeMarkedBlock(path46.join(hooksDir, "pre-commit")) || removed;
53551
- removed = removeMarkedBlock(path46.join(hooksDir, "post-commit")) || removed;
53656
+ removed = removeMarkedBlock(path47.join(hooksDir, "pre-commit")) || removed;
53657
+ removed = removeMarkedBlock(path47.join(hooksDir, "post-commit")) || removed;
53552
53658
  for (const file of ["har-pre-commit", "har-post-commit"]) {
53553
- const full = path46.join(hooksDir, file);
53554
- if (fs42.existsSync(full)) {
53555
- fs42.rmSync(full);
53659
+ const full = path47.join(hooksDir, file);
53660
+ if (fs43.existsSync(full)) {
53661
+ fs43.rmSync(full);
53556
53662
  removed = true;
53557
53663
  }
53558
53664
  }
@@ -53571,10 +53677,10 @@ function isAgentWorktree(checkoutDir) {
53571
53677
  if (branch && (/^har-agent-\d+$/.test(branch) || /-har-agent-\d+-[a-z0-9]+$/.test(branch))) {
53572
53678
  return true;
53573
53679
  }
53574
- const worktreesRoot = path46.join(os14.homedir(), "worktrees");
53575
- const resolved = path46.resolve(checkoutDir);
53576
- const name = path46.basename(resolved);
53577
- return resolved.startsWith(`${worktreesRoot}${path46.sep}`) && (/-agent-\d+$/.test(name) || /-har-agent-\d+-[a-z0-9]+$/.test(name));
53680
+ const worktreesRoot = path47.join(os15.homedir(), "worktrees");
53681
+ const resolved = path47.resolve(checkoutDir);
53682
+ const name = path47.basename(resolved);
53683
+ return resolved.startsWith(`${worktreesRoot}${path47.sep}`) && (/-agent-\d+$/.test(name) || /-har-agent-\d+-[a-z0-9]+$/.test(name));
53578
53684
  }
53579
53685
  function resolveEffectiveMode(checkoutDir, gate) {
53580
53686
  if (!gate.enabled) return "off";
@@ -53587,15 +53693,15 @@ function getHooksStatus(repoPath) {
53587
53693
  const hooksDir = resolveHooksDir(checkout);
53588
53694
  const gate = getCommitGateConfig(checkout);
53589
53695
  const hasBlock = (name) => {
53590
- const file = path46.join(hooksDir, name);
53591
- return fs42.existsSync(file) && fs42.readFileSync(file, "utf8").includes(MARKER_START);
53696
+ const file = path47.join(hooksDir, name);
53697
+ return fs43.existsSync(file) && fs43.readFileSync(file, "utf8").includes(MARKER_START);
53592
53698
  };
53593
53699
  return {
53594
53700
  checkout,
53595
53701
  hooksDir,
53596
53702
  configuredHooksPath: getConfiguredHooksPath(checkout),
53597
- preCommitInstalled: hasBlock("pre-commit") && fs42.existsSync(path46.join(hooksDir, "har-pre-commit")),
53598
- postCommitInstalled: hasBlock("post-commit") && fs42.existsSync(path46.join(hooksDir, "har-post-commit")),
53703
+ preCommitInstalled: hasBlock("pre-commit") && fs43.existsSync(path47.join(hooksDir, "har-pre-commit")),
53704
+ postCommitInstalled: hasBlock("post-commit") && fs43.existsSync(path47.join(hooksDir, "har-post-commit")),
53599
53705
  gate,
53600
53706
  effectiveMode: resolveEffectiveMode(checkout, gate)
53601
53707
  };
@@ -53606,7 +53712,7 @@ function checkCommitGate(cwd) {
53606
53712
  }
53607
53713
  const checkout = resolveCheckoutRoot(cwd);
53608
53714
  if (!checkout) return { exitCode: 0, messages: [] };
53609
- if (!fs42.existsSync(path46.join(checkout, ".har", "stages.json"))) {
53715
+ if (!fs43.existsSync(path47.join(checkout, ".har", "stages.json"))) {
53610
53716
  return { exitCode: 0, messages: [] };
53611
53717
  }
53612
53718
  const gate = getCommitGateConfig(checkout);
@@ -53679,12 +53785,12 @@ async function recordCommitAssociation(cwd) {
53679
53785
  // src/core/commit-gate-onboarding.ts
53680
53786
  function askYesNo5(question) {
53681
53787
  const rl = readline6.createInterface({ input: process.stdin, output: process.stderr });
53682
- return new Promise((resolve40) => {
53788
+ return new Promise((resolve42) => {
53683
53789
  process.stderr.write(`${question} `);
53684
53790
  rl.once("line", (answer) => {
53685
53791
  rl.close();
53686
53792
  const trimmed = answer.trim();
53687
- resolve40(trimmed === "" || /^y(es)?$/i.test(trimmed));
53793
+ resolve42(trimmed === "" || /^y(es)?$/i.test(trimmed));
53688
53794
  });
53689
53795
  });
53690
53796
  }
@@ -53726,20 +53832,20 @@ async function handleCommitGateOnboarding(options) {
53726
53832
  }
53727
53833
 
53728
53834
  // src/core/onboarding-preferences.ts
53729
- var fs43 = __toESM(require("fs"));
53730
- var os15 = __toESM(require("os"));
53731
- var path47 = __toESM(require("path"));
53835
+ var fs44 = __toESM(require("fs"));
53836
+ var os16 = __toESM(require("os"));
53837
+ var path48 = __toESM(require("path"));
53732
53838
  function getOnboardingPreferencesPath() {
53733
53839
  if (process.env.HAR_PREFERENCES_PATH) {
53734
- return path47.resolve(process.env.HAR_PREFERENCES_PATH);
53840
+ return path48.resolve(process.env.HAR_PREFERENCES_PATH);
53735
53841
  }
53736
- return path47.join(os15.homedir(), ".har", "preferences.json");
53842
+ return path48.join(os16.homedir(), ".har", "preferences.json");
53737
53843
  }
53738
53844
  function readOnboardingPreferences() {
53739
53845
  const preferencePath = getOnboardingPreferencesPath();
53740
53846
  try {
53741
- if (!fs43.existsSync(preferencePath)) return OnboardingPreferencesSchema.parse({});
53742
- return OnboardingPreferencesSchema.parse(JSON.parse(fs43.readFileSync(preferencePath, "utf8")));
53847
+ if (!fs44.existsSync(preferencePath)) return OnboardingPreferencesSchema.parse({});
53848
+ return OnboardingPreferencesSchema.parse(JSON.parse(fs44.readFileSync(preferencePath, "utf8")));
53743
53849
  } catch {
53744
53850
  return OnboardingPreferencesSchema.parse({});
53745
53851
  }
@@ -53764,8 +53870,8 @@ function writeOnboardingPreferences(overrides) {
53764
53870
  };
53765
53871
  const parsed = OnboardingPreferencesSchema.parse(preference);
53766
53872
  const preferencePath = getOnboardingPreferencesPath();
53767
- fs43.mkdirSync(path47.dirname(preferencePath), { recursive: true });
53768
- fs43.writeFileSync(preferencePath, `${JSON.stringify(parsed, null, 2)}
53873
+ fs44.mkdirSync(path48.dirname(preferencePath), { recursive: true });
53874
+ fs44.writeFileSync(preferencePath, `${JSON.stringify(parsed, null, 2)}
53769
53875
  `);
53770
53876
  return parsed;
53771
53877
  }
@@ -54065,7 +54171,7 @@ var envCommand = {
54065
54171
  }
54066
54172
  };
54067
54173
  async function handleInit(argv) {
54068
- const repoPath = path48.resolve(argv.repo);
54174
+ const repoPath = path49.resolve(argv.repo);
54069
54175
  const onboarding = resolveOnboardingOptions(argv);
54070
54176
  header("har env init");
54071
54177
  info(`Repository: ${repoPath}`);
@@ -54129,7 +54235,7 @@ async function handleInit(argv) {
54129
54235
  }
54130
54236
  }
54131
54237
  async function handleMaintain(argv) {
54132
- const repoPath = path48.resolve(argv.repo);
54238
+ const repoPath = path49.resolve(argv.repo);
54133
54239
  const onboarding = resolveOnboardingOptions(argv);
54134
54240
  header("har env maintain");
54135
54241
  info(`Repository: ${repoPath}`);
@@ -54251,7 +54357,7 @@ async function handleAgentMdProposal(repoPath, autoYes) {
54251
54357
  if (autoYes) {
54252
54358
  const proposal = readAgentMdProposal(repoPath);
54253
54359
  if (proposal) {
54254
- writeFileSafe(path48.join(repoPath, "AGENT.md"), proposal.content);
54360
+ writeFileSafe(path49.join(repoPath, "AGENT.md"), proposal.content);
54255
54361
  clearAgentMdProposal(repoPath);
54256
54362
  info("Applied AGENT.md proposal (--yes)");
54257
54363
  }
@@ -54260,7 +54366,7 @@ async function handleAgentMdProposal(repoPath, autoYes) {
54260
54366
  await promptApplyAgentMdProposal(repoPath);
54261
54367
  }
54262
54368
  async function handleAddPlugin(argv) {
54263
- const repoPath = path48.resolve(argv.repo);
54369
+ const repoPath = path49.resolve(argv.repo);
54264
54370
  const available = listPluginIds();
54265
54371
  if (argv.list) {
54266
54372
  for (const id of available) {
@@ -54298,7 +54404,7 @@ async function handleAddPlugin(argv) {
54298
54404
  }
54299
54405
  }
54300
54406
  async function handleAddStage(argv) {
54301
- const repoPath = path48.resolve(argv.repo);
54407
+ const repoPath = path49.resolve(argv.repo);
54302
54408
  const available = listPluginIds();
54303
54409
  if (argv.list) {
54304
54410
  warn("har env add-stage --list is deprecated; prefer: har env add-plugin --list");
@@ -54364,7 +54470,7 @@ async function handleAddStage(argv) {
54364
54470
  });
54365
54471
  }
54366
54472
  async function handlePreflight(argv) {
54367
- const repo = path48.resolve(argv.repo);
54473
+ const repo = path49.resolve(argv.repo);
54368
54474
  const agentId = validateAgentId(argv.id, repo);
54369
54475
  const result = await preflightEnvironment({
54370
54476
  repoPath: repo,
@@ -54382,7 +54488,7 @@ async function handlePreflight(argv) {
54382
54488
  process.exit(result.code);
54383
54489
  }
54384
54490
  async function handleLaunch(argv) {
54385
- const repo = path48.resolve(argv.repo);
54491
+ const repo = path49.resolve(argv.repo);
54386
54492
  const agentId = validateAgentId(argv.id, repo);
54387
54493
  let confirmReplace = argv.replace;
54388
54494
  let force = argv.force;
@@ -54394,8 +54500,8 @@ async function handleLaunch(argv) {
54394
54500
  console.error(guard.reason ?? "");
54395
54501
  const readline10 = await import("readline");
54396
54502
  const rl = readline10.createInterface({ input: process.stdin, output: process.stderr });
54397
- const answer = await new Promise((resolve40) => {
54398
- rl.question("Replace this slot? [y/N] ", resolve40);
54503
+ const answer = await new Promise((resolve42) => {
54504
+ rl.question("Replace this slot? [y/N] ", resolve42);
54399
54505
  });
54400
54506
  rl.close();
54401
54507
  if (!/^[Yy]$/.test(answer.trim())) {
@@ -54411,8 +54517,8 @@ async function handleLaunch(argv) {
54411
54517
  warn("Worktree has uncommitted changes.");
54412
54518
  const readline10 = await import("readline");
54413
54519
  const rl = readline10.createInterface({ input: process.stdin, output: process.stderr });
54414
- const answer = await new Promise((resolve40) => {
54415
- rl.question("Discard uncommitted changes? [y/N] ", resolve40);
54520
+ const answer = await new Promise((resolve42) => {
54521
+ rl.question("Discard uncommitted changes? [y/N] ", resolve42);
54416
54522
  });
54417
54523
  rl.close();
54418
54524
  if (!/^[Yy]$/.test(answer.trim())) {
@@ -54476,7 +54582,7 @@ async function handleRecover(argv) {
54476
54582
  });
54477
54583
  }
54478
54584
  async function handleVerify(argv) {
54479
- const repo = path48.resolve(argv.repo);
54585
+ const repo = path49.resolve(argv.repo);
54480
54586
  const agentId = validateAgentId(argv.id, repo);
54481
54587
  const result = await runVerification({
54482
54588
  repoPath: repo,
@@ -54488,7 +54594,7 @@ async function handleVerify(argv) {
54488
54594
  process.exit(result.code);
54489
54595
  }
54490
54596
  async function handleTeardown(argv) {
54491
- const repo = path48.resolve(argv.repo);
54597
+ const repo = path49.resolve(argv.repo);
54492
54598
  const agentId = validateAgentId(argv.id, repo);
54493
54599
  const result = await teardownEnvironment({
54494
54600
  repoPath: repo,
@@ -54499,7 +54605,7 @@ async function handleTeardown(argv) {
54499
54605
  process.exit(result.code);
54500
54606
  }
54501
54607
  async function handleComplete(argv) {
54502
- const repo = path48.resolve(argv.repo);
54608
+ const repo = path49.resolve(argv.repo);
54503
54609
  const agentId = validateAgentId(argv.id, repo);
54504
54610
  const result = await completeEnvironment({
54505
54611
  repoPath: repo,
@@ -54520,7 +54626,7 @@ async function handleComplete(argv) {
54520
54626
  process.exit(result.code);
54521
54627
  }
54522
54628
  async function handleStatus(argv) {
54523
- const repoPath = path48.resolve(argv.repo);
54629
+ const repoPath = path49.resolve(argv.repo);
54524
54630
  if (argv.json) {
54525
54631
  const status = collectEnvironmentStatus(repoPath);
54526
54632
  const output = EnvironmentStatusSchema.parse(status);
@@ -54533,7 +54639,7 @@ async function handleStatus(argv) {
54533
54639
  });
54534
54640
  }
54535
54641
  async function handleRunsList(argv) {
54536
- const repoPath = path48.resolve(argv.repo);
54642
+ const repoPath = path49.resolve(argv.repo);
54537
54643
  const runs = listRuns(repoPath, { stageId: argv.stage, limit: argv.limit });
54538
54644
  if (argv.json) {
54539
54645
  process.stdout.write(JSON.stringify({ runs }, null, 2) + "\n");
@@ -54550,7 +54656,7 @@ async function handleRunsList(argv) {
54550
54656
  }
54551
54657
  }
54552
54658
  async function handleRunsGet(argv) {
54553
- const run2 = getRun(path48.resolve(argv.repo), argv.runId);
54659
+ const run2 = getRun(path49.resolve(argv.repo), argv.runId);
54554
54660
  if (!run2) {
54555
54661
  error(`Run not found: ${argv.runId}`);
54556
54662
  process.exit(1);
@@ -54629,7 +54735,7 @@ function printNextSteps(auto2) {
54629
54735
  }
54630
54736
 
54631
54737
  // src/cli/commands/control.ts
54632
- var path51 = __toESM(require("path"));
54738
+ var path53 = __toESM(require("path"));
54633
54739
 
54634
54740
  // node_modules/@inquirer/core/dist/esm/lib/key.mjs
54635
54741
  var isUpKey = (key) => (
@@ -55649,13 +55755,13 @@ var PromisePolyfill = class extends Promise {
55649
55755
  // Available starting from Node 22
55650
55756
  // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/withResolvers
55651
55757
  static withResolver() {
55652
- let resolve40;
55758
+ let resolve42;
55653
55759
  let reject;
55654
55760
  const promise = new Promise((res, rej) => {
55655
- resolve40 = res;
55761
+ resolve42 = res;
55656
55762
  reject = rej;
55657
55763
  });
55658
- return { promise, resolve: resolve40, reject };
55764
+ return { promise, resolve: resolve42, reject };
55659
55765
  }
55660
55766
  };
55661
55767
 
@@ -55672,7 +55778,7 @@ function createPrompt(view) {
55672
55778
  output
55673
55779
  });
55674
55780
  const screen = new ScreenManager(rl);
55675
- const { promise, resolve: resolve40, reject } = PromisePolyfill.withResolver();
55781
+ const { promise, resolve: resolve42, reject } = PromisePolyfill.withResolver();
55676
55782
  const cancel = () => reject(new CancelPromptError());
55677
55783
  if (signal) {
55678
55784
  const abort = () => reject(new AbortPromptError({ cause: signal.reason }));
@@ -55696,7 +55802,7 @@ function createPrompt(view) {
55696
55802
  cycle(() => {
55697
55803
  try {
55698
55804
  const nextView = view(config2, (value) => {
55699
- setImmediate(() => resolve40(value));
55805
+ setImmediate(() => resolve42(value));
55700
55806
  });
55701
55807
  const [content, bottomContent] = typeof nextView === "string" ? [nextView] : nextView;
55702
55808
  screen.render(content, bottomContent);
@@ -56683,9 +56789,9 @@ var import_run_async = __toESM(require_run_async(), 1);
56683
56789
  var import_mute_stream2 = __toESM(require_lib3(), 1);
56684
56790
  var import_ansi_escapes5 = __toESM(require_ansi_escapes(), 1);
56685
56791
  var _2 = {
56686
- set: (obj, path56 = "", value) => {
56792
+ set: (obj, path58 = "", value) => {
56687
56793
  let pointer = obj;
56688
- path56.split(".").forEach((key, index, arr) => {
56794
+ path58.split(".").forEach((key, index, arr) => {
56689
56795
  if (key === "__proto__" || key === "constructor")
56690
56796
  return;
56691
56797
  if (index === arr.length - 1) {
@@ -56696,8 +56802,8 @@ var _2 = {
56696
56802
  pointer = pointer[key];
56697
56803
  });
56698
56804
  },
56699
- get: (obj, path56 = "", defaultValue) => {
56700
- const travel = (regexp) => String.prototype.split.call(path56, regexp).filter(Boolean).reduce(
56805
+ get: (obj, path58 = "", defaultValue) => {
56806
+ const travel = (regexp) => String.prototype.split.call(path58, regexp).filter(Boolean).reduce(
56701
56807
  // @ts-expect-error implicit any on res[key]
56702
56808
  (res, key) => res !== null && res !== void 0 ? res[key] : res,
56703
56809
  obj
@@ -56811,7 +56917,7 @@ var PromptsRunner = class {
56811
56917
  throw new Error(`Prompt for type ${question.type} not found`);
56812
56918
  }
56813
56919
  let cleanupSignal;
56814
- const promptFn = isPromptConstructor(prompt2) ? (q2, { signal: signal2 } = {}) => new Promise((resolve40, reject) => {
56920
+ const promptFn = isPromptConstructor(prompt2) ? (q2, { signal: signal2 } = {}) => new Promise((resolve42, reject) => {
56815
56921
  const rl = import_node_readline.default.createInterface(setupReadlineOptions(this.opt));
56816
56922
  rl.resume();
56817
56923
  const onClose = () => {
@@ -56847,7 +56953,7 @@ var PromptsRunner = class {
56847
56953
  cleanupSignal = void 0;
56848
56954
  };
56849
56955
  }
56850
- activePrompt.run().then(resolve40, reject).finally(cleanup);
56956
+ activePrompt.run().then(resolve42, reject).finally(cleanup);
56851
56957
  }) : prompt2;
56852
56958
  const { signal: moduleSignal } = this.opt;
56853
56959
  if (moduleSignal?.aborted) {
@@ -56949,20 +57055,20 @@ var esm_default13 = inquirer;
56949
57055
  init_control_config();
56950
57056
 
56951
57057
  // src/core/control-sync-selection.ts
56952
- var fs44 = __toESM(require("fs"));
56953
- var os16 = __toESM(require("os"));
56954
- var path49 = __toESM(require("path"));
57058
+ var fs45 = __toESM(require("fs"));
57059
+ var os17 = __toESM(require("os"));
57060
+ var path50 = __toESM(require("path"));
56955
57061
  function getSelectionPath() {
56956
57062
  if (process.env.HAR_CONTROL_SYNC_SELECTION_PATH) {
56957
- return path49.resolve(process.env.HAR_CONTROL_SYNC_SELECTION_PATH);
57063
+ return path50.resolve(process.env.HAR_CONTROL_SYNC_SELECTION_PATH);
56958
57064
  }
56959
- return path49.join(os16.homedir(), ".har", "sync-selection.json");
57065
+ return path50.join(os17.homedir(), ".har", "sync-selection.json");
56960
57066
  }
56961
57067
  function readSyncSelection() {
56962
57068
  const selectionPath = getSelectionPath();
56963
57069
  try {
56964
- if (!fs44.existsSync(selectionPath)) return null;
56965
- const parsed = JSON.parse(fs44.readFileSync(selectionPath, "utf8"));
57070
+ if (!fs45.existsSync(selectionPath)) return null;
57071
+ const parsed = JSON.parse(fs45.readFileSync(selectionPath, "utf8"));
56966
57072
  if (!Array.isArray(parsed.repos)) return null;
56967
57073
  return parsed.repos.map((repoPath) => canonicalizeControlRepoPath(repoPath));
56968
57074
  } catch {
@@ -56972,8 +57078,8 @@ function readSyncSelection() {
56972
57078
  function writeSyncSelection(repos) {
56973
57079
  const selectionPath = getSelectionPath();
56974
57080
  const canonical = Array.from(new Set(repos.map((repoPath) => canonicalizeControlRepoPath(repoPath))));
56975
- fs44.mkdirSync(path49.dirname(selectionPath), { recursive: true });
56976
- fs44.writeFileSync(selectionPath, JSON.stringify({ repos: canonical }, null, 2) + "\n");
57081
+ fs45.mkdirSync(path50.dirname(selectionPath), { recursive: true });
57082
+ fs45.writeFileSync(selectionPath, JSON.stringify({ repos: canonical }, null, 2) + "\n");
56977
57083
  }
56978
57084
  function resolveSyncSelection(input) {
56979
57085
  const { discovered, stored, forceSelect, isTTY } = input;
@@ -57020,7 +57126,7 @@ function openBrowser(url) {
57020
57126
  }
57021
57127
  async function loginViaBrowser(portalUrl, openUrl = openBrowser) {
57022
57128
  const state = (0, import_crypto.randomUUID)();
57023
- return new Promise((resolve40, reject) => {
57129
+ return new Promise((resolve42, reject) => {
57024
57130
  let timer;
57025
57131
  const server = http.createServer((req, res) => {
57026
57132
  const requestUrl = new URL(req.url ?? "", "http://127.0.0.1");
@@ -57043,7 +57149,7 @@ async function loginViaBrowser(portalUrl, openUrl = openBrowser) {
57043
57149
  res.writeHead(200, { "Content-Type": "text/html" });
57044
57150
  res.end("<h1>Logged in</h1><p>You can close this tab and return to the terminal.</p>");
57045
57151
  cleanup();
57046
- resolve40({ portalUrl, token, workspace, email: email2, createdAt: (/* @__PURE__ */ new Date()).toISOString() });
57152
+ resolve42({ portalUrl, token, workspace, email: email2, createdAt: (/* @__PURE__ */ new Date()).toISOString() });
57047
57153
  });
57048
57154
  const cleanup = () => {
57049
57155
  clearTimeout(timer);
@@ -57070,16 +57176,16 @@ If your browser did not open, paste that URL.
57070
57176
  }
57071
57177
 
57072
57178
  // src/core/control-unregister.ts
57073
- var fs45 = __toESM(require("fs"));
57074
- var path50 = __toESM(require("path"));
57179
+ var fs46 = __toESM(require("fs"));
57180
+ var path51 = __toESM(require("path"));
57075
57181
  init_control_config();
57076
57182
  function listUnregisterWorktreeCandidates(repoPath) {
57077
57183
  const harnessRoot = canonicalizeControlRepoPath(repoPath);
57078
57184
  const byPath = /* @__PURE__ */ new Map();
57079
57185
  const add = (partial2) => {
57080
- const resolved = path50.resolve(partial2.worktreePath);
57186
+ const resolved = path51.resolve(partial2.worktreePath);
57081
57187
  if (!resolved || resolved === harnessRoot) return;
57082
- const exists = partial2.exists ?? fs45.existsSync(resolved);
57188
+ const exists = partial2.exists ?? fs46.existsSync(resolved);
57083
57189
  const prev = byPath.get(resolved);
57084
57190
  if (prev) {
57085
57191
  byPath.set(resolved, {
@@ -57130,8 +57236,8 @@ async function askYesNo6(question) {
57130
57236
  if (!process.stdin.isTTY || !process.stdout.isTTY) return false;
57131
57237
  const readline10 = await import("readline");
57132
57238
  const rl = readline10.createInterface({ input: process.stdin, output: process.stderr });
57133
- const answer = await new Promise((resolve40) => {
57134
- rl.question(question, resolve40);
57239
+ const answer = await new Promise((resolve42) => {
57240
+ rl.question(question, resolve42);
57135
57241
  });
57136
57242
  rl.close();
57137
57243
  return /^[Yy]$/.test(answer.trim());
@@ -57193,28 +57299,28 @@ async function teardownWorktrees(repoPath, candidates, dryRun) {
57193
57299
  trigger: "cli"
57194
57300
  });
57195
57301
  if (result.code !== 0) {
57196
- if (fs45.existsSync(candidate.worktreePath)) {
57197
- fs45.rmSync(candidate.worktreePath, { recursive: true, force: true });
57302
+ if (fs46.existsSync(candidate.worktreePath)) {
57303
+ fs46.rmSync(candidate.worktreePath, { recursive: true, force: true });
57198
57304
  }
57199
57305
  }
57200
57306
  outcomes.push({
57201
57307
  path: candidate.worktreePath,
57202
57308
  agentId: candidate.agentId,
57203
- deleted: !fs45.existsSync(candidate.worktreePath),
57204
- error: result.code !== 0 && fs45.existsSync(candidate.worktreePath) ? result.stderr : void 0
57309
+ deleted: !fs46.existsSync(candidate.worktreePath),
57310
+ error: result.code !== 0 && fs46.existsSync(candidate.worktreePath) ? result.stderr : void 0
57205
57311
  });
57206
57312
  } catch (err) {
57207
57313
  const message = err instanceof Error ? err.message : String(err);
57208
57314
  try {
57209
- if (fs45.existsSync(candidate.worktreePath)) {
57210
- fs45.rmSync(candidate.worktreePath, { recursive: true, force: true });
57315
+ if (fs46.existsSync(candidate.worktreePath)) {
57316
+ fs46.rmSync(candidate.worktreePath, { recursive: true, force: true });
57211
57317
  }
57212
57318
  } catch {
57213
57319
  }
57214
57320
  outcomes.push({
57215
57321
  path: candidate.worktreePath,
57216
57322
  agentId: candidate.agentId,
57217
- deleted: !fs45.existsSync(candidate.worktreePath),
57323
+ deleted: !fs46.existsSync(candidate.worktreePath),
57218
57324
  error: message
57219
57325
  });
57220
57326
  }
@@ -57272,6 +57378,162 @@ async function unregisterRepoWithControl(options) {
57272
57378
  };
57273
57379
  }
57274
57380
 
57381
+ // src/core/control-reset.ts
57382
+ init_control_config();
57383
+
57384
+ // src/core/harness-scrub.ts
57385
+ var fs47 = __toESM(require("fs"));
57386
+ var path52 = __toESM(require("path"));
57387
+ var HARNESS_SCRUB_DIRS = ["runs", "validations", "state", "slots"];
57388
+ function scrubLocalHarnessDirs(repoPath) {
57389
+ const results = [];
57390
+ const resolved = path52.resolve(repoPath);
57391
+ if (!fs47.existsSync(resolved)) {
57392
+ for (const directory of HARNESS_SCRUB_DIRS) {
57393
+ results.push({
57394
+ path: path52.join(resolved, ".har", directory),
57395
+ directory,
57396
+ deleted: false,
57397
+ error: "repository path does not exist"
57398
+ });
57399
+ }
57400
+ return results;
57401
+ }
57402
+ for (const directory of HARNESS_SCRUB_DIRS) {
57403
+ const target = path52.join(resolved, ".har", directory);
57404
+ if (!fs47.existsSync(target)) {
57405
+ results.push({ path: target, directory, deleted: true });
57406
+ continue;
57407
+ }
57408
+ try {
57409
+ fs47.rmSync(target, { recursive: true, force: true });
57410
+ results.push({
57411
+ path: target,
57412
+ directory,
57413
+ deleted: !fs47.existsSync(target),
57414
+ error: fs47.existsSync(target) ? "failed to remove directory" : void 0
57415
+ });
57416
+ } catch (err) {
57417
+ results.push({
57418
+ path: target,
57419
+ directory,
57420
+ deleted: !fs47.existsSync(target),
57421
+ error: err instanceof Error ? err.message : String(err)
57422
+ });
57423
+ }
57424
+ }
57425
+ return results;
57426
+ }
57427
+ function scrubLocalHarnessForRepos(repoPaths) {
57428
+ const results = [];
57429
+ const seen = /* @__PURE__ */ new Set();
57430
+ for (const repoPath of repoPaths) {
57431
+ const key = path52.resolve(repoPath);
57432
+ if (seen.has(key)) continue;
57433
+ seen.add(key);
57434
+ results.push(...scrubLocalHarnessDirs(key));
57435
+ }
57436
+ return results;
57437
+ }
57438
+
57439
+ // src/core/control-reset.ts
57440
+ async function askYesNo7(question) {
57441
+ if (!process.stdin.isTTY || !process.stdout.isTTY) return false;
57442
+ const readline10 = await import("readline");
57443
+ const rl = readline10.createInterface({ input: process.stdin, output: process.stderr });
57444
+ const answer = await new Promise((resolve42) => {
57445
+ rl.question(question, resolve42);
57446
+ });
57447
+ rl.close();
57448
+ return /^[Yy]$/.test(answer.trim());
57449
+ }
57450
+ async function confirmControlReset(options) {
57451
+ if (options.yes) return true;
57452
+ if (!process.stdin.isTTY || !process.stdout.isTTY) {
57453
+ throw new Error("Non-interactive terminal \u2014 pass --yes");
57454
+ }
57455
+ return askYesNo7(
57456
+ `Clear Mission Control data for ${options.repoCount} registered repositor${options.repoCount === 1 ? "y" : "ies"} (and scrub local .har history)? [y/N] `
57457
+ );
57458
+ }
57459
+ async function resetMissionControlFromCli(options = {}) {
57460
+ const apiUrl = options.apiUrl ?? getControlApiUrl();
57461
+ const scrubLocalHarness = options.scrubLocalHarness !== false;
57462
+ const clearRegistry = options.clearRegistry !== false;
57463
+ const registryPaths = listRegisteredRepos();
57464
+ let apiRepoPaths = [];
57465
+ let apiUnreachable = false;
57466
+ let repositoriesDeleted = 0;
57467
+ let unregisteredCleared = 0;
57468
+ let apiScrubbed = [];
57469
+ if (!options.dryRun) {
57470
+ try {
57471
+ const listResponse = await fetch(`${apiUrl}/api/repos`, {
57472
+ signal: AbortSignal.timeout(5e3)
57473
+ });
57474
+ if (listResponse.ok) {
57475
+ const repos = await listResponse.json();
57476
+ apiRepoPaths = repos.map((repo) => repo.path);
57477
+ } else {
57478
+ apiUnreachable = true;
57479
+ }
57480
+ } catch {
57481
+ apiUnreachable = true;
57482
+ }
57483
+ }
57484
+ const repoPaths = [.../* @__PURE__ */ new Set([...registryPaths, ...apiRepoPaths])].sort();
57485
+ let scrubbed = [];
57486
+ if (scrubLocalHarness) {
57487
+ scrubbed = options.dryRun ? repoPaths.flatMap(
57488
+ (repoPath) => ["runs", "validations", "state", "slots"].map((directory) => ({
57489
+ path: `${repoPath}/.har/${directory}`,
57490
+ directory,
57491
+ deleted: false
57492
+ }))
57493
+ ) : scrubLocalHarnessForRepos(repoPaths);
57494
+ }
57495
+ if (!options.dryRun && !apiUnreachable) {
57496
+ const response = await fetch(`${apiUrl}/api/reset`, {
57497
+ method: "POST",
57498
+ headers: { "Content-Type": "application/json" },
57499
+ body: JSON.stringify({
57500
+ confirm: "RESET",
57501
+ // Host scrub already ran; skip duplicate best-effort inside Docker/API.
57502
+ scrubLocalHarness: false
57503
+ })
57504
+ });
57505
+ if (!response.ok) {
57506
+ const text = await response.text().catch(() => "");
57507
+ throw new Error(`Control API ${response.status}: ${text || response.statusText}`);
57508
+ }
57509
+ const payload = await response.json();
57510
+ repositoriesDeleted = payload.repositoriesDeleted;
57511
+ unregisteredCleared = payload.unregisteredCleared;
57512
+ apiScrubbed = payload.scrubbed ?? [];
57513
+ } else if (!options.dryRun && apiUnreachable) {
57514
+ }
57515
+ let registryCleared = false;
57516
+ if (clearRegistry) {
57517
+ if (options.dryRun) {
57518
+ registryCleared = registryPaths.length > 0;
57519
+ } else {
57520
+ registryCleared = clearRegisteredRepos() > 0;
57521
+ }
57522
+ }
57523
+ return {
57524
+ ok: true,
57525
+ dryRun: options.dryRun === true,
57526
+ repositoriesDeleted: options.dryRun ? repoPaths.length : repositoriesDeleted,
57527
+ unregisteredCleared,
57528
+ scrubLocalHarness,
57529
+ clearRegistry,
57530
+ registryCleared,
57531
+ repoPaths,
57532
+ scrubbed: scrubbed.length > 0 ? scrubbed : apiScrubbed,
57533
+ apiUnreachable: apiUnreachable || void 0
57534
+ };
57535
+ }
57536
+
57275
57537
  // src/cli/commands/control.ts
57276
57538
  var controlCommand = {
57277
57539
  command: "control <subcommand>",
@@ -57325,6 +57587,10 @@ var controlCommand = {
57325
57587
  type: "boolean",
57326
57588
  default: false,
57327
57589
  describe: "Sync to HAR Cloud instead of local Mission Control"
57590
+ }).option("full", {
57591
+ type: "boolean",
57592
+ default: false,
57593
+ describe: "Ignore the portal watermark and resend the complete payload"
57328
57594
  }),
57329
57595
  handleSync
57330
57596
  ).command(
@@ -57340,9 +57606,27 @@ var controlCommand = {
57340
57606
  describe: "Store this ingest token directly instead of browser login"
57341
57607
  }),
57342
57608
  handleLogin
57609
+ ).command(
57610
+ "reset",
57611
+ "Clear all Mission Control data and optionally scrub local .har history",
57612
+ (y2) => y2.option("api-url", { type: "string", describe: "Control API URL" }).option("yes", {
57613
+ alias: "y",
57614
+ type: "boolean",
57615
+ default: false,
57616
+ describe: "Skip confirmation prompt"
57617
+ }).option("no-scrub-local", {
57618
+ type: "boolean",
57619
+ default: false,
57620
+ describe: "Keep local .har/{runs,validations,state,slots} directories"
57621
+ }).option("keep-registry", {
57622
+ type: "boolean",
57623
+ default: false,
57624
+ describe: "Keep ~/.har/repos.json entries (default clears them)"
57625
+ }).option("dry-run", { type: "boolean", default: false }).option("json", { type: "boolean", default: false }),
57626
+ handleReset
57343
57627
  ).demandCommand(
57344
57628
  1,
57345
- "Please specify a subcommand: up, down, register, unregister, sync, watch, login"
57629
+ "Please specify a subcommand: up, down, register, unregister, sync, watch, login, reset"
57346
57630
  ),
57347
57631
  handler: () => {
57348
57632
  }
@@ -57403,7 +57687,7 @@ async function handleDown() {
57403
57687
  process.exit(code);
57404
57688
  }
57405
57689
  async function handleRegister(argv) {
57406
- const repoPath = path51.resolve(argv.repo);
57690
+ const repoPath = path53.resolve(argv.repo);
57407
57691
  header("har control register");
57408
57692
  info(`Repository: ${repoPath}`);
57409
57693
  try {
@@ -57426,8 +57710,76 @@ async function handleRegister(argv) {
57426
57710
  process.exit(1);
57427
57711
  }
57428
57712
  }
57713
+ async function handleReset(argv) {
57714
+ try {
57715
+ const repoCount = listRegisteredRepos().length;
57716
+ if (!argv.yes && !argv.dryRun) {
57717
+ const proceed = await confirmControlReset({ yes: false, repoCount });
57718
+ if (!proceed) {
57719
+ error("Aborted \u2014 Mission Control left unchanged.");
57720
+ process.exit(2);
57721
+ }
57722
+ }
57723
+ const result = await resetMissionControlFromCli({
57724
+ apiUrl: argv.apiUrl,
57725
+ dryRun: argv.dryRun,
57726
+ scrubLocalHarness: !argv.noScrubLocal,
57727
+ clearRegistry: !argv.keepRegistry
57728
+ });
57729
+ if (argv.json) {
57730
+ process.stdout.write(JSON.stringify(result, null, 2) + "\n");
57731
+ return;
57732
+ }
57733
+ header("har control reset");
57734
+ if (argv.dryRun) {
57735
+ info(
57736
+ `Dry run \u2014 would clear Mission Control for ${result.repoPaths.length} repositor${result.repoPaths.length === 1 ? "y" : "ies"}`
57737
+ );
57738
+ if (result.scrubLocalHarness) {
57739
+ info(`Would scrub ${result.scrubbed.length} local .har director${result.scrubbed.length === 1 ? "y" : "ies"}`);
57740
+ }
57741
+ if (result.clearRegistry) {
57742
+ info("Would clear local sync registry (~/.har/repos.json)");
57743
+ }
57744
+ return;
57745
+ }
57746
+ if (result.apiUnreachable) {
57747
+ warn("Mission Control API unreachable \u2014 dashboard DB not cleared");
57748
+ } else {
57749
+ success(
57750
+ `Cleared ${result.repositoriesDeleted} repositor${result.repositoriesDeleted === 1 ? "y" : "ies"} from Mission Control`
57751
+ );
57752
+ if (result.unregisteredCleared > 0) {
57753
+ success(`Cleared ${result.unregisteredCleared} unregister blocklist entr${result.unregisteredCleared === 1 ? "y" : "ies"}`);
57754
+ }
57755
+ }
57756
+ if (result.scrubLocalHarness) {
57757
+ const deleted = result.scrubbed.filter((row) => row.deleted).length;
57758
+ const failed = result.scrubbed.filter((row) => !row.deleted && row.error);
57759
+ success(`Scrubbed ${deleted} local .har director${deleted === 1 ? "y" : "ies"}`);
57760
+ for (const failure of failed) {
57761
+ warn(`Failed to delete ${failure.path}: ${failure.error}`);
57762
+ }
57763
+ }
57764
+ if (result.registryCleared) {
57765
+ success("Cleared local sync registry (~/.har/repos.json)");
57766
+ } else if (result.clearRegistry) {
57767
+ info("Local sync registry was already empty");
57768
+ }
57769
+ info("Re-register with: har control register --repo <path>");
57770
+ } catch (err) {
57771
+ if (argv.json) {
57772
+ process.stdout.write(
57773
+ JSON.stringify({ ok: false, error: err.message }, null, 2) + "\n"
57774
+ );
57775
+ process.exit(1);
57776
+ }
57777
+ error(err.message);
57778
+ process.exit(1);
57779
+ }
57780
+ }
57429
57781
  async function handleUnregister(argv) {
57430
- const repoPath = path51.resolve(argv.repo);
57782
+ const repoPath = path53.resolve(argv.repo);
57431
57783
  const worktrees = listUnregisterWorktreeCandidates(repoPath);
57432
57784
  try {
57433
57785
  let deleteWorktrees = argv.deleteWorktrees;
@@ -57551,7 +57903,8 @@ async function handleSync(argv) {
57551
57903
  repoPaths,
57552
57904
  apiUrl: argv.apiUrl,
57553
57905
  dryRun: argv.dryRun,
57554
- cloud: argv.cloud
57906
+ cloud: argv.cloud,
57907
+ full: argv.full
57555
57908
  });
57556
57909
  if (argv.json) {
57557
57910
  process.stdout.write(JSON.stringify({ ok: failed === 0, synced, failed, results }, null, 2) + "\n");
@@ -57587,7 +57940,7 @@ async function handleWatch(argv) {
57587
57940
  };
57588
57941
  const tick = async () => {
57589
57942
  if (argv.repo) {
57590
- await syncOne(path51.resolve(argv.repo));
57943
+ await syncOne(path53.resolve(argv.repo));
57591
57944
  return;
57592
57945
  }
57593
57946
  try {
@@ -57637,11 +57990,11 @@ async function handleLogin(argv) {
57637
57990
  }
57638
57991
 
57639
57992
  // src/cli/commands/hooks.ts
57640
- var path53 = __toESM(require("path"));
57993
+ var path55 = __toESM(require("path"));
57641
57994
 
57642
57995
  // src/core/claude-hooks.ts
57643
- var fs46 = __toESM(require("fs"));
57644
- var path52 = __toESM(require("path"));
57996
+ var fs48 = __toESM(require("fs"));
57997
+ var path54 = __toESM(require("path"));
57645
57998
  var CLAUDE_GUARD_RELATIVE_PATH = ".har/hooks/claude-worktree-guard.sh";
57646
57999
  var CLAUDE_SETTINGS_RELATIVE_PATH = ".claude/settings.json";
57647
58000
  var GUARD_MATCHER = "Edit|Write|MultiEdit|NotebookEdit";
@@ -57652,8 +58005,8 @@ function isHarGuardEntry(entry) {
57652
58005
  );
57653
58006
  }
57654
58007
  function readSettings(settingsPath) {
57655
- if (!fs46.existsSync(settingsPath)) return {};
57656
- const raw = fs46.readFileSync(settingsPath, "utf8").trim();
58008
+ if (!fs48.existsSync(settingsPath)) return {};
58009
+ const raw = fs48.readFileSync(settingsPath, "utf8").trim();
57657
58010
  if (raw === "") return {};
57658
58011
  const parsed = JSON.parse(raw);
57659
58012
  if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
@@ -57662,19 +58015,19 @@ function readSettings(settingsPath) {
57662
58015
  return parsed;
57663
58016
  }
57664
58017
  function writeSettings(settingsPath, settings) {
57665
- fs46.mkdirSync(path52.dirname(settingsPath), { recursive: true });
57666
- fs46.writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + "\n");
58018
+ fs48.mkdirSync(path54.dirname(settingsPath), { recursive: true });
58019
+ fs48.writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + "\n");
57667
58020
  }
57668
58021
  function installClaudeGuard(repoPath) {
57669
58022
  const templatePath = resolveTemplateFile("claude-worktree-guard.sh.template");
57670
58023
  if (!templatePath) {
57671
58024
  throw new Error("Guard template not found (claude-worktree-guard.sh.template). Run npm run build.");
57672
58025
  }
57673
- const guardScript = path52.join(repoPath, CLAUDE_GUARD_RELATIVE_PATH);
57674
- fs46.mkdirSync(path52.dirname(guardScript), { recursive: true });
57675
- fs46.copyFileSync(templatePath, guardScript);
57676
- fs46.chmodSync(guardScript, 493);
57677
- const settingsPath = path52.join(repoPath, CLAUDE_SETTINGS_RELATIVE_PATH);
58026
+ const guardScript = path54.join(repoPath, CLAUDE_GUARD_RELATIVE_PATH);
58027
+ fs48.mkdirSync(path54.dirname(guardScript), { recursive: true });
58028
+ fs48.copyFileSync(templatePath, guardScript);
58029
+ fs48.chmodSync(guardScript, 493);
58030
+ const settingsPath = path54.join(repoPath, CLAUDE_SETTINGS_RELATIVE_PATH);
57678
58031
  const settings = readSettings(settingsPath);
57679
58032
  const hooks = settings.hooks ?? {};
57680
58033
  const preToolUse = (hooks.PreToolUse ?? []).filter((entry) => !isHarGuardEntry(entry));
@@ -57688,15 +58041,15 @@ function installClaudeGuard(repoPath) {
57688
58041
  }
57689
58042
  function uninstallClaudeGuard(repoPath) {
57690
58043
  let removed = false;
57691
- const guardScript = path52.join(repoPath, CLAUDE_GUARD_RELATIVE_PATH);
57692
- if (fs46.existsSync(guardScript)) {
57693
- fs46.rmSync(guardScript);
58044
+ const guardScript = path54.join(repoPath, CLAUDE_GUARD_RELATIVE_PATH);
58045
+ if (fs48.existsSync(guardScript)) {
58046
+ fs48.rmSync(guardScript);
57694
58047
  removed = true;
57695
- const parent = path52.dirname(guardScript);
57696
- if (fs46.existsSync(parent) && fs46.readdirSync(parent).length === 0) fs46.rmdirSync(parent);
58048
+ const parent = path54.dirname(guardScript);
58049
+ if (fs48.existsSync(parent) && fs48.readdirSync(parent).length === 0) fs48.rmdirSync(parent);
57697
58050
  }
57698
- const settingsPath = path52.join(repoPath, CLAUDE_SETTINGS_RELATIVE_PATH);
57699
- if (fs46.existsSync(settingsPath)) {
58051
+ const settingsPath = path54.join(repoPath, CLAUDE_SETTINGS_RELATIVE_PATH);
58052
+ if (fs48.existsSync(settingsPath)) {
57700
58053
  const settings = readSettings(settingsPath);
57701
58054
  const preToolUse = settings.hooks?.PreToolUse;
57702
58055
  if (preToolUse) {
@@ -57721,8 +58074,8 @@ function uninstallClaudeGuard(repoPath) {
57721
58074
  return { removed };
57722
58075
  }
57723
58076
  function claudeGuardInstalled(repoPath) {
57724
- const settingsPath = path52.join(repoPath, CLAUDE_SETTINGS_RELATIVE_PATH);
57725
- if (!fs46.existsSync(settingsPath)) return false;
58077
+ const settingsPath = path54.join(repoPath, CLAUDE_SETTINGS_RELATIVE_PATH);
58078
+ if (!fs48.existsSync(settingsPath)) return false;
57726
58079
  try {
57727
58080
  const settings = readSettings(settingsPath);
57728
58081
  return (settings.hooks?.PreToolUse ?? []).some(isHarGuardEntry);
@@ -57738,7 +58091,7 @@ function repoOption(y2) {
57738
58091
  function handleInstall2(argv) {
57739
58092
  try {
57740
58093
  if (argv.claude) {
57741
- const result2 = installClaudeGuard(path53.resolve(argv.repo));
58094
+ const result2 = installClaudeGuard(path55.resolve(argv.repo));
57742
58095
  success("Claude Code worktree guard installed.");
57743
58096
  info(`Guard script: ${result2.guardScript}`);
57744
58097
  info(`Settings: ${result2.settingsPath} (PreToolUse: Edit|Write|MultiEdit|NotebookEdit)`);
@@ -57746,7 +58099,7 @@ function handleInstall2(argv) {
57746
58099
  info("Commit both files so the guard travels with the repo.");
57747
58100
  return;
57748
58101
  }
57749
- const result = installHooks({ repoPath: path53.resolve(argv.repo), force: argv.force });
58102
+ const result = installHooks({ repoPath: path55.resolve(argv.repo), force: argv.force });
57750
58103
  success(`Commit gate installed in ${result.hooksDir}`);
57751
58104
  info(`pre-commit: ${result.preCommit}, post-commit: ${result.postCommit}`);
57752
58105
  info("Commits of unverified change batches will be blocked in agent worktrees.");
@@ -57759,7 +58112,7 @@ function handleInstall2(argv) {
57759
58112
  function handleUninstall(argv) {
57760
58113
  try {
57761
58114
  if (argv.claude) {
57762
- const result2 = uninstallClaudeGuard(path53.resolve(argv.repo));
58115
+ const result2 = uninstallClaudeGuard(path55.resolve(argv.repo));
57763
58116
  if (result2.removed) {
57764
58117
  success("Claude Code worktree guard removed.");
57765
58118
  } else {
@@ -57767,7 +58120,7 @@ function handleUninstall(argv) {
57767
58120
  }
57768
58121
  return;
57769
58122
  }
57770
- const result = uninstallHooks(path53.resolve(argv.repo));
58123
+ const result = uninstallHooks(path55.resolve(argv.repo));
57771
58124
  if (result.removed) {
57772
58125
  success(`Commit gate removed from ${result.hooksDir}`);
57773
58126
  } else {
@@ -57780,7 +58133,7 @@ function handleUninstall(argv) {
57780
58133
  }
57781
58134
  function handleStatus2(argv) {
57782
58135
  try {
57783
- const status = getHooksStatus(path53.resolve(argv.repo));
58136
+ const status = getHooksStatus(path55.resolve(argv.repo));
57784
58137
  if (argv.json) {
57785
58138
  process.stdout.write(`${JSON.stringify(status, null, 2)}
57786
58139
  `);
@@ -57798,7 +58151,7 @@ function handleStatus2(argv) {
57798
58151
  );
57799
58152
  info(`Effective: ${status.effectiveMode} (in this checkout)`);
57800
58153
  info(
57801
- `Claude guard: ${claudeGuardInstalled(path53.resolve(argv.repo)) ? `installed (${CLAUDE_GUARD_RELATIVE_PATH})` : "not installed"}`
58154
+ `Claude guard: ${claudeGuardInstalled(path55.resolve(argv.repo)) ? `installed (${CLAUDE_GUARD_RELATIVE_PATH})` : "not installed"}`
57802
58155
  );
57803
58156
  } catch (err) {
57804
58157
  error(err instanceof Error ? err.message : String(err));
@@ -58059,10 +58412,10 @@ function assignProp(target, prop, value) {
58059
58412
  configurable: true
58060
58413
  });
58061
58414
  }
58062
- function getElementAtPath(obj, path56) {
58063
- if (!path56)
58415
+ function getElementAtPath(obj, path58) {
58416
+ if (!path58)
58064
58417
  return obj;
58065
- return path56.reduce((acc, key) => acc?.[key], obj);
58418
+ return path58.reduce((acc, key) => acc?.[key], obj);
58066
58419
  }
58067
58420
  function promiseAllObject(promisesObj) {
58068
58421
  const keys = Object.keys(promisesObj);
@@ -58382,11 +58735,11 @@ function aborted(x2, startIndex = 0) {
58382
58735
  }
58383
58736
  return false;
58384
58737
  }
58385
- function prefixIssues(path56, issues) {
58738
+ function prefixIssues(path58, issues) {
58386
58739
  return issues.map((iss) => {
58387
58740
  var _a3;
58388
58741
  (_a3 = iss).path ?? (_a3.path = []);
58389
- iss.path.unshift(path56);
58742
+ iss.path.unshift(path58);
58390
58743
  return iss;
58391
58744
  });
58392
58745
  }
@@ -63709,7 +64062,7 @@ var Protocol = class {
63709
64062
  return;
63710
64063
  }
63711
64064
  const pollInterval = task2.pollInterval ?? this._options?.defaultTaskPollInterval ?? 1e3;
63712
- await new Promise((resolve40) => setTimeout(resolve40, pollInterval));
64065
+ await new Promise((resolve42) => setTimeout(resolve42, pollInterval));
63713
64066
  options?.signal?.throwIfAborted();
63714
64067
  }
63715
64068
  } catch (error3) {
@@ -63726,7 +64079,7 @@ var Protocol = class {
63726
64079
  */
63727
64080
  request(request, resultSchema, options) {
63728
64081
  const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
63729
- return new Promise((resolve40, reject) => {
64082
+ return new Promise((resolve42, reject) => {
63730
64083
  const earlyReject = (error3) => {
63731
64084
  reject(error3);
63732
64085
  };
@@ -63804,7 +64157,7 @@ var Protocol = class {
63804
64157
  if (!parseResult.success) {
63805
64158
  reject(parseResult.error);
63806
64159
  } else {
63807
- resolve40(parseResult.data);
64160
+ resolve42(parseResult.data);
63808
64161
  }
63809
64162
  } catch (error3) {
63810
64163
  reject(error3);
@@ -64065,12 +64418,12 @@ var Protocol = class {
64065
64418
  }
64066
64419
  } catch {
64067
64420
  }
64068
- return new Promise((resolve40, reject) => {
64421
+ return new Promise((resolve42, reject) => {
64069
64422
  if (signal.aborted) {
64070
64423
  reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
64071
64424
  return;
64072
64425
  }
64073
- const timeoutId = setTimeout(resolve40, interval);
64426
+ const timeoutId = setTimeout(resolve42, interval);
64074
64427
  signal.addEventListener("abort", () => {
64075
64428
  clearTimeout(timeoutId);
64076
64429
  reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
@@ -64860,7 +65213,7 @@ var Server = class extends Protocol {
64860
65213
  };
64861
65214
 
64862
65215
  // src/mcp/server.ts
64863
- var path54 = __toESM(require("path"));
65216
+ var path56 = __toESM(require("path"));
64864
65217
 
64865
65218
  // node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
64866
65219
  var import_node_process3 = __toESM(require("node:process"), 1);
@@ -64943,12 +65296,12 @@ var StdioServerTransport = class {
64943
65296
  this.onclose?.();
64944
65297
  }
64945
65298
  send(message) {
64946
- return new Promise((resolve40) => {
65299
+ return new Promise((resolve42) => {
64947
65300
  const json = serializeMessage(message);
64948
65301
  if (this._stdout.write(json)) {
64949
- resolve40();
65302
+ resolve42();
64950
65303
  } else {
64951
- this._stdout.once("drain", resolve40);
65304
+ this._stdout.once("drain", resolve42);
64952
65305
  }
64953
65306
  });
64954
65307
  }
@@ -65523,7 +65876,7 @@ async function handleMcpToolCall(toolName, args, defaultRepo = ".") {
65523
65876
  const input = ControlUpInputSchema.parse({ ...args, repo });
65524
65877
  const result = await startControlAndSync({
65525
65878
  detach: input.detach,
65526
- cwd: path54.resolve(input.repo)
65879
+ cwd: path56.resolve(input.repo)
65527
65880
  });
65528
65881
  if (result.code !== 0) {
65529
65882
  return {
@@ -65702,7 +66055,7 @@ var preferencesCommand = {
65702
66055
  };
65703
66056
 
65704
66057
  // src/cli/commands/telemetry.ts
65705
- var path55 = __toESM(require("path"));
66058
+ var path57 = __toESM(require("path"));
65706
66059
  init_control_config();
65707
66060
  init_otel_hooks();
65708
66061
  init_telemetry_config();
@@ -65789,7 +66142,7 @@ async function handleOff() {
65789
66142
  info("Mission Control will not auto-start. Existing usage rows are kept.");
65790
66143
  }
65791
66144
  async function handleWriteEnv(argv) {
65792
- const repoPath = path55.resolve(argv.repo);
66145
+ const repoPath = path57.resolve(argv.repo);
65793
66146
  const harnessRoot = resolveHarnessRoot(repoPath);
65794
66147
  const session = readSlotRegistry(harnessRoot, argv.agentId);
65795
66148
  const workDir = argv.workDir ?? session?.workDir ?? repoPath;
@@ -65801,7 +66154,7 @@ async function handleWriteEnv(argv) {
65801
66154
  suffix,
65802
66155
  createdAt: session?.createdAt
65803
66156
  });
65804
- const envFile = argv.envFile ?? path55.join(workDir, `.env.agent.${argv.agentId}`);
66157
+ const envFile = argv.envFile ?? path57.join(workDir, `.env.agent.${argv.agentId}`);
65805
66158
  const attrs = {
65806
66159
  sessionKey,
65807
66160
  agentId: argv.agentId,
@@ -65820,7 +66173,7 @@ async function handleWriteEnv(argv) {
65820
66173
  success(`Wrote session attribution to ${envFile}`);
65821
66174
  }
65822
66175
  function handlePrintEnv(argv) {
65823
- const repoPath = path55.resolve(argv.repo);
66176
+ const repoPath = path57.resolve(argv.repo);
65824
66177
  const workDir = argv.workDir ?? repoPath;
65825
66178
  const sessionKey = buildSessionKey({
65826
66179
  branch: argv.branch,