@osfactory/har 0.32.3 → 0.33.1

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 +693 -210
  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 path58 = url.path;
877
- if (path58.length === 0) {
876
+ const path60 = url.path;
877
+ if (path60.length === 0) {
878
878
  return;
879
879
  }
880
- if (url.scheme === "file" && path58.length === 1 && isNormalizedWindowsDriveLetter(path58[0])) {
880
+ if (url.scheme === "file" && path60.length === 1 && isNormalizedWindowsDriveLetter(path60[0])) {
881
881
  return;
882
882
  }
883
- path58.pop();
883
+ path60.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(resolve42, reject) {
2203
+ return new Body.Promise(function(resolve44, 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
- resolve42(Buffer.concat(accum, accumBytes));
2237
+ resolve44(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(resolve42, reject) {
2912
+ return new fetch3.Promise(function(resolve44, 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
- resolve42(fetch3(new Request3(locationURL, requestOpts)));
3045
+ resolve44(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
- resolve42(response);
3066
+ resolve44(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
- resolve42(response);
3076
+ resolve44(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
- resolve42(response);
3088
+ resolve44(response);
3089
3089
  });
3090
3090
  raw.on("end", function() {
3091
3091
  if (!response) {
3092
3092
  response = new Response3(body, response_options);
3093
- resolve42(response);
3093
+ resolve44(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
- resolve42(response);
3101
+ resolve44(response);
3102
3102
  return;
3103
3103
  }
3104
3104
  response = new Response3(body, response_options);
3105
- resolve42(response);
3105
+ resolve44(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(path58, { mtimeMs, size }, filenameOrOptions, options = {}) {
6462
+ function createFileFromPath(path60, { 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: path58, size, lastModified: mtimeMs });
6469
+ const file = new FileFromPath({ path: path60, size, lastModified: mtimeMs });
6470
6470
  if (!filename) {
6471
6471
  filename = file.name;
6472
6472
  }
@@ -6475,13 +6475,13 @@ function createFileFromPath(path58, { mtimeMs, size }, filenameOrOptions, option
6475
6475
  lastModified: file.lastModified
6476
6476
  });
6477
6477
  }
6478
- function fileFromPathSync(path58, filenameOrOptions, options = {}) {
6479
- const stats = (0, import_fs5.statSync)(path58);
6480
- return createFileFromPath(path58, stats, filenameOrOptions, options);
6478
+ function fileFromPathSync(path60, filenameOrOptions, options = {}) {
6479
+ const stats = (0, import_fs5.statSync)(path60);
6480
+ return createFileFromPath(path60, stats, filenameOrOptions, options);
6481
6481
  }
6482
- async function fileFromPath2(path58, filenameOrOptions, options) {
6483
- const stats = await import_fs5.promises.stat(path58);
6484
- return createFileFromPath(path58, stats, filenameOrOptions, options);
6482
+ async function fileFromPath2(path60, filenameOrOptions, options) {
6483
+ const stats = await import_fs5.promises.stat(path60);
6484
+ return createFileFromPath(path60, 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({
@@ -8181,15 +8181,15 @@ var require_route = __commonJS({
8181
8181
  };
8182
8182
  }
8183
8183
  function wrapConversion(toModel, graph) {
8184
- const path58 = [graph[toModel].parent, toModel];
8184
+ const path60 = [graph[toModel].parent, toModel];
8185
8185
  let fn = conversions[graph[toModel].parent][toModel];
8186
8186
  let cur = graph[toModel].parent;
8187
8187
  while (graph[cur].parent) {
8188
- path58.unshift(graph[cur].parent);
8188
+ path60.unshift(graph[cur].parent);
8189
8189
  fn = link(conversions[graph[cur].parent][cur], fn);
8190
8190
  cur = graph[cur].parent;
8191
8191
  }
8192
- fn.conversion = path58;
8192
+ fn.conversion = path60;
8193
8193
  return fn;
8194
8194
  }
8195
8195
  module2.exports = function(fromModel) {
@@ -17679,16 +17679,16 @@ var require_os_tmpdir = __commonJS({
17679
17679
  var isWindows = process.platform === "win32";
17680
17680
  var trailingSlashRe = isWindows ? /[^:]\\$/ : /.\/$/;
17681
17681
  module2.exports = function() {
17682
- var path58;
17682
+ var path60;
17683
17683
  if (isWindows) {
17684
- path58 = process.env.TEMP || process.env.TMP || (process.env.SystemRoot || process.env.windir) + "\\temp";
17684
+ path60 = process.env.TEMP || process.env.TMP || (process.env.SystemRoot || process.env.windir) + "\\temp";
17685
17685
  } else {
17686
- path58 = process.env.TMPDIR || process.env.TMP || process.env.TEMP || "/tmp";
17686
+ path60 = process.env.TMPDIR || process.env.TMP || process.env.TEMP || "/tmp";
17687
17687
  }
17688
- if (trailingSlashRe.test(path58)) {
17689
- path58 = path58.slice(0, -1);
17688
+ if (trailingSlashRe.test(path60)) {
17689
+ path60 = path60.slice(0, -1);
17690
17690
  }
17691
- return path58;
17691
+ return path60;
17692
17692
  };
17693
17693
  }
17694
17694
  });
@@ -17697,7 +17697,7 @@ var require_os_tmpdir = __commonJS({
17697
17697
  var require_tmp = __commonJS({
17698
17698
  "node_modules/tmp/lib/tmp.js"(exports2, module2) {
17699
17699
  var fs49 = require("fs");
17700
- var path58 = require("path");
17700
+ var path60 = require("path");
17701
17701
  var crypto6 = require("crypto");
17702
17702
  var osTmpDir = require_os_tmpdir();
17703
17703
  var _c2 = process.binding("constants");
@@ -17739,7 +17739,7 @@ var require_tmp = __commonJS({
17739
17739
  }
17740
17740
  function _generateTmpName(opts) {
17741
17741
  if (opts.name) {
17742
- return path58.join(opts.dir || tmpDir, opts.name);
17742
+ return path60.join(opts.dir || tmpDir, opts.name);
17743
17743
  }
17744
17744
  if (opts.template) {
17745
17745
  return opts.template.replace(TEMPLATE_PATTERN, _randomChars(6));
@@ -17750,7 +17750,7 @@ var require_tmp = __commonJS({
17750
17750
  _randomChars(12),
17751
17751
  opts.postfix || ""
17752
17752
  ].join("");
17753
- return path58.join(opts.dir || tmpDir, name);
17753
+ return path60.join(opts.dir || tmpDir, name);
17754
17754
  }
17755
17755
  function tmpName(options, callback) {
17756
17756
  var args = _parseArguments(options, callback), opts = args[0], cb = args[1], tries = opts.name ? 1 : opts.tries || DEFAULT_TRIES;
@@ -17835,7 +17835,7 @@ var require_tmp = __commonJS({
17835
17835
  do {
17836
17836
  var dir2 = dirs.pop(), deferred = false, files = fs49.readdirSync(dir2);
17837
17837
  for (var i2 = 0, length = files.length; i2 < length; i2++) {
17838
- var file2 = path58.join(dir2, files[i2]), stat = fs49.lstatSync(file2);
17838
+ var file2 = path60.join(dir2, files[i2]), stat = fs49.lstatSync(file2);
17839
17839
  if (stat.isDirectory()) {
17840
17840
  if (!deferred) {
17841
17841
  deferred = true;
@@ -19046,7 +19046,7 @@ var require_Observable = __commonJS({
19046
19046
  Observable2.prototype.forEach = function(next, promiseCtor) {
19047
19047
  var _this = this;
19048
19048
  promiseCtor = getPromiseCtor(promiseCtor);
19049
- return new promiseCtor(function(resolve42, reject) {
19049
+ return new promiseCtor(function(resolve44, reject) {
19050
19050
  var subscriber = new Subscriber_1.SafeSubscriber({
19051
19051
  next: function(value) {
19052
19052
  try {
@@ -19057,7 +19057,7 @@ var require_Observable = __commonJS({
19057
19057
  }
19058
19058
  },
19059
19059
  error: reject,
19060
- complete: resolve42
19060
+ complete: resolve44
19061
19061
  });
19062
19062
  _this.subscribe(subscriber);
19063
19063
  });
@@ -19079,14 +19079,14 @@ var require_Observable = __commonJS({
19079
19079
  Observable2.prototype.toPromise = function(promiseCtor) {
19080
19080
  var _this = this;
19081
19081
  promiseCtor = getPromiseCtor(promiseCtor);
19082
- return new promiseCtor(function(resolve42, reject) {
19082
+ return new promiseCtor(function(resolve44, reject) {
19083
19083
  var value;
19084
19084
  _this.subscribe(function(x2) {
19085
19085
  return value = x2;
19086
19086
  }, function(err) {
19087
19087
  return reject(err);
19088
19088
  }, function() {
19089
- return resolve42(value);
19089
+ return resolve44(value);
19090
19090
  });
19091
19091
  });
19092
19092
  };
@@ -21182,11 +21182,11 @@ var require_innerFrom = __commonJS({
21182
21182
  "use strict";
21183
21183
  var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P3, generator) {
21184
21184
  function adopt(value) {
21185
- return value instanceof P3 ? value : new P3(function(resolve42) {
21186
- resolve42(value);
21185
+ return value instanceof P3 ? value : new P3(function(resolve44) {
21186
+ resolve44(value);
21187
21187
  });
21188
21188
  }
21189
- return new (P3 || (P3 = Promise))(function(resolve42, reject) {
21189
+ return new (P3 || (P3 = Promise))(function(resolve44, reject) {
21190
21190
  function fulfilled(value) {
21191
21191
  try {
21192
21192
  step(generator.next(value));
@@ -21202,7 +21202,7 @@ var require_innerFrom = __commonJS({
21202
21202
  }
21203
21203
  }
21204
21204
  function step(result) {
21205
- result.done ? resolve42(result.value) : adopt(result.value).then(fulfilled, rejected);
21205
+ result.done ? resolve44(result.value) : adopt(result.value).then(fulfilled, rejected);
21206
21206
  }
21207
21207
  step((generator = generator.apply(thisArg, _arguments || [])).next());
21208
21208
  });
@@ -21284,14 +21284,14 @@ var require_innerFrom = __commonJS({
21284
21284
  }, i2);
21285
21285
  function verb(n2) {
21286
21286
  i2[n2] = o2[n2] && function(v3) {
21287
- return new Promise(function(resolve42, reject) {
21288
- v3 = o2[n2](v3), settle(resolve42, reject, v3.done, v3.value);
21287
+ return new Promise(function(resolve44, reject) {
21288
+ v3 = o2[n2](v3), settle(resolve44, reject, v3.done, v3.value);
21289
21289
  });
21290
21290
  };
21291
21291
  }
21292
- function settle(resolve42, reject, d2, v3) {
21292
+ function settle(resolve44, reject, d2, v3) {
21293
21293
  Promise.resolve(v3).then(function(v4) {
21294
- resolve42({ value: v4, done: d2 });
21294
+ resolve44({ value: v4, done: d2 });
21295
21295
  }, reject);
21296
21296
  }
21297
21297
  };
@@ -21910,7 +21910,7 @@ var require_lastValueFrom = __commonJS({
21910
21910
  var EmptyError_1 = require_EmptyError();
21911
21911
  function lastValueFrom2(source, config2) {
21912
21912
  var hasConfig = typeof config2 === "object";
21913
- return new Promise(function(resolve42, reject) {
21913
+ return new Promise(function(resolve44, reject) {
21914
21914
  var _hasValue = false;
21915
21915
  var _value;
21916
21916
  source.subscribe({
@@ -21921,9 +21921,9 @@ var require_lastValueFrom = __commonJS({
21921
21921
  error: reject,
21922
21922
  complete: function() {
21923
21923
  if (_hasValue) {
21924
- resolve42(_value);
21924
+ resolve44(_value);
21925
21925
  } else if (hasConfig) {
21926
- resolve42(config2.defaultValue);
21926
+ resolve44(config2.defaultValue);
21927
21927
  } else {
21928
21928
  reject(new EmptyError_1.EmptyError());
21929
21929
  }
@@ -21945,16 +21945,16 @@ var require_firstValueFrom = __commonJS({
21945
21945
  var Subscriber_1 = require_Subscriber();
21946
21946
  function firstValueFrom(source, config2) {
21947
21947
  var hasConfig = typeof config2 === "object";
21948
- return new Promise(function(resolve42, reject) {
21948
+ return new Promise(function(resolve44, reject) {
21949
21949
  var subscriber = new Subscriber_1.SafeSubscriber({
21950
21950
  next: function(value) {
21951
- resolve42(value);
21951
+ resolve44(value);
21952
21952
  subscriber.unsubscribe();
21953
21953
  },
21954
21954
  error: reject,
21955
21955
  complete: function() {
21956
21956
  if (hasConfig) {
21957
- resolve42(config2.defaultValue);
21957
+ resolve44(config2.defaultValue);
21958
21958
  } else {
21959
21959
  reject(new EmptyError_1.EmptyError());
21960
21960
  }
@@ -27747,14 +27747,14 @@ var require_run_async = __commonJS({
27747
27747
  return function() {
27748
27748
  var args = arguments;
27749
27749
  var originalThis = this;
27750
- var promise = new Promise(function(resolve42, reject) {
27750
+ var promise = new Promise(function(resolve44, reject) {
27751
27751
  var resolved = false;
27752
27752
  const wrappedResolve = function(value) {
27753
27753
  if (resolved) {
27754
27754
  console.warn("Run-async promise already resolved.");
27755
27755
  }
27756
27756
  resolved = true;
27757
- resolve42(value);
27757
+ resolve44(value);
27758
27758
  };
27759
27759
  var rejected = false;
27760
27760
  const wrappedReject = function(value) {
@@ -30783,7 +30783,7 @@ var require_compile = __commonJS({
30783
30783
  const schOrFunc = root.refs[ref];
30784
30784
  if (schOrFunc)
30785
30785
  return schOrFunc;
30786
- let _sch = resolve42.call(this, root, ref);
30786
+ let _sch = resolve44.call(this, root, ref);
30787
30787
  if (_sch === void 0) {
30788
30788
  const schema = (_a3 = root.localRefs) === null || _a3 === void 0 ? void 0 : _a3[ref];
30789
30789
  const { schemaId } = this.opts;
@@ -30810,7 +30810,7 @@ var require_compile = __commonJS({
30810
30810
  function sameSchemaEnv(s1, s2) {
30811
30811
  return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
30812
30812
  }
30813
- function resolve42(root, ref) {
30813
+ function resolve44(root, ref) {
30814
30814
  let sch;
30815
30815
  while (typeof (sch = this.refs[ref]) == "string")
30816
30816
  ref = sch;
@@ -31028,8 +31028,8 @@ var require_utils2 = __commonJS({
31028
31028
  }
31029
31029
  return ind;
31030
31030
  }
31031
- function removeDotSegments(path58) {
31032
- let input = path58;
31031
+ function removeDotSegments(path60) {
31032
+ let input = path60;
31033
31033
  const output = [];
31034
31034
  let nextSlash = -1;
31035
31035
  let len = 0;
@@ -31281,8 +31281,8 @@ var require_schemes = __commonJS({
31281
31281
  wsComponent.secure = void 0;
31282
31282
  }
31283
31283
  if (wsComponent.resourceName) {
31284
- const [path58, query] = wsComponent.resourceName.split("?");
31285
- wsComponent.path = path58 && path58 !== "/" ? path58 : void 0;
31284
+ const [path60, query] = wsComponent.resourceName.split("?");
31285
+ wsComponent.path = path60 && path60 !== "/" ? path60 : void 0;
31286
31286
  wsComponent.query = query;
31287
31287
  wsComponent.resourceName = void 0;
31288
31288
  }
@@ -31441,7 +31441,7 @@ var require_fast_uri = __commonJS({
31441
31441
  }
31442
31442
  return uri;
31443
31443
  }
31444
- function resolve42(baseURI, relativeURI, options) {
31444
+ function resolve44(baseURI, relativeURI, options) {
31445
31445
  const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
31446
31446
  const resolved = resolveComponent(parse4(baseURI, schemelessOptions), parse4(relativeURI, schemelessOptions), schemelessOptions, true);
31447
31447
  schemelessOptions.skipEscape = true;
@@ -31699,7 +31699,7 @@ var require_fast_uri = __commonJS({
31699
31699
  var fastUri = {
31700
31700
  SCHEMES,
31701
31701
  normalize: normalize3,
31702
- resolve: resolve42,
31702
+ resolve: resolve44,
31703
31703
  resolveComponent,
31704
31704
  equal,
31705
31705
  serialize,
@@ -35964,11 +35964,11 @@ var parser = new YargsParser({
35964
35964
  resolve: import_path2.resolve,
35965
35965
  // TODO: figure out a way to combine ESM and CJS coverage, such that
35966
35966
  // we can exercise all the lines below:
35967
- require: (path58) => {
35967
+ require: (path60) => {
35968
35968
  if (typeof require !== "undefined") {
35969
- return require(path58);
35970
- } else if (path58.match(/\.json$/)) {
35971
- return JSON.parse((0, import_fs2.readFileSync)(path58, "utf8"));
35969
+ return require(path60);
35970
+ } else if (path60.match(/\.json$/)) {
35971
+ return JSON.parse((0, import_fs2.readFileSync)(path60, "utf8"));
35972
35972
  } else {
35973
35973
  throw Error("only .json config files are supported in ESM");
35974
35974
  }
@@ -38494,12 +38494,12 @@ var YargsInstance = class {
38494
38494
  async getCompletion(args, done) {
38495
38495
  argsert("<array> [function]", [args, done], arguments.length);
38496
38496
  if (!done) {
38497
- return new Promise((resolve42, reject) => {
38497
+ return new Promise((resolve44, reject) => {
38498
38498
  __classPrivateFieldGet(this, _YargsInstance_completion, "f").getCompletion(args, (err, completions) => {
38499
38499
  if (err)
38500
38500
  reject(err);
38501
38501
  else
38502
- resolve42(completions);
38502
+ resolve44(completions);
38503
38503
  });
38504
38504
  });
38505
38505
  } else {
@@ -40652,8 +40652,8 @@ function getErrorMap() {
40652
40652
 
40653
40653
  // node_modules/zod/v3/helpers/parseUtil.js
40654
40654
  var makeIssue = (params) => {
40655
- const { data, path: path58, errorMaps, issueData } = params;
40656
- const fullPath = [...path58, ...issueData.path || []];
40655
+ const { data, path: path60, errorMaps, issueData } = params;
40656
+ const fullPath = [...path60, ...issueData.path || []];
40657
40657
  const fullIssue = {
40658
40658
  ...issueData,
40659
40659
  path: fullPath
@@ -40769,11 +40769,11 @@ var errorUtil;
40769
40769
 
40770
40770
  // node_modules/zod/v3/types.js
40771
40771
  var ParseInputLazyPath = class {
40772
- constructor(parent, value, path58, key) {
40772
+ constructor(parent, value, path60, key) {
40773
40773
  this._cachedPath = [];
40774
40774
  this.parent = parent;
40775
40775
  this.data = value;
40776
- this._path = path58;
40776
+ this._path = path60;
40777
40777
  this._key = key;
40778
40778
  }
40779
40779
  get path() {
@@ -68312,16 +68312,16 @@ async function handleAgentSkills(options) {
68312
68312
  }
68313
68313
  async function askYesNo(question) {
68314
68314
  const rl = readline.createInterface({ input: process.stdin, output: process.stderr });
68315
- return new Promise((resolve42) => {
68315
+ return new Promise((resolve44) => {
68316
68316
  process.stderr.write(`${question} `);
68317
68317
  rl.once("line", (answer) => {
68318
68318
  rl.close();
68319
68319
  const trimmed = answer.trim();
68320
68320
  if (trimmed === "") {
68321
- resolve42(true);
68321
+ resolve44(true);
68322
68322
  return;
68323
68323
  }
68324
- resolve42(/^y(es)?$/i.test(trimmed));
68324
+ resolve44(/^y(es)?$/i.test(trimmed));
68325
68325
  });
68326
68326
  });
68327
68327
  }
@@ -69179,13 +69179,13 @@ var MultipartBody = class {
69179
69179
  // node_modules/@anthropic-ai/sdk/_shims/node-runtime.mjs
69180
69180
  var import_web = require("node:stream/web");
69181
69181
  var fileFromPathWarned = false;
69182
- async function fileFromPath3(path58, ...args) {
69182
+ async function fileFromPath3(path60, ...args) {
69183
69183
  const { fileFromPath: _fileFromPath } = await Promise.resolve().then(() => (init_fileFromPath(), fileFromPath_exports));
69184
69184
  if (!fileFromPathWarned) {
69185
- console.warn(`fileFromPath is deprecated; use fs.createReadStream(${JSON.stringify(path58)}) instead`);
69185
+ console.warn(`fileFromPath is deprecated; use fs.createReadStream(${JSON.stringify(path60)}) instead`);
69186
69186
  fileFromPathWarned = true;
69187
69187
  }
69188
- return await _fileFromPath(path58, ...args);
69188
+ return await _fileFromPath(path60, ...args);
69189
69189
  }
69190
69190
  var defaultHttpAgent = new import_agentkeepalive.default({ keepAlive: true, timeout: 5 * 60 * 1e3 });
69191
69191
  var defaultHttpsAgent = new import_agentkeepalive.default.HttpsAgent({ keepAlive: true, timeout: 5 * 60 * 1e3 });
@@ -69681,8 +69681,8 @@ async function defaultParseResponse(props) {
69681
69681
  }
69682
69682
  var APIPromise = class _APIPromise extends Promise {
69683
69683
  constructor(responsePromise, parseResponse = defaultParseResponse) {
69684
- super((resolve42) => {
69685
- resolve42(null);
69684
+ super((resolve44) => {
69685
+ resolve44(null);
69686
69686
  });
69687
69687
  this.responsePromise = responsePromise;
69688
69688
  this.parseResponse = parseResponse;
@@ -69782,29 +69782,29 @@ var APIClient = class {
69782
69782
  defaultIdempotencyKey() {
69783
69783
  return `stainless-node-retry-${uuid4()}`;
69784
69784
  }
69785
- get(path58, opts) {
69786
- return this.methodRequest("get", path58, opts);
69785
+ get(path60, opts) {
69786
+ return this.methodRequest("get", path60, opts);
69787
69787
  }
69788
- post(path58, opts) {
69789
- return this.methodRequest("post", path58, opts);
69788
+ post(path60, opts) {
69789
+ return this.methodRequest("post", path60, opts);
69790
69790
  }
69791
- patch(path58, opts) {
69792
- return this.methodRequest("patch", path58, opts);
69791
+ patch(path60, opts) {
69792
+ return this.methodRequest("patch", path60, opts);
69793
69793
  }
69794
- put(path58, opts) {
69795
- return this.methodRequest("put", path58, opts);
69794
+ put(path60, opts) {
69795
+ return this.methodRequest("put", path60, opts);
69796
69796
  }
69797
- delete(path58, opts) {
69798
- return this.methodRequest("delete", path58, opts);
69797
+ delete(path60, opts) {
69798
+ return this.methodRequest("delete", path60, opts);
69799
69799
  }
69800
- methodRequest(method, path58, opts) {
69800
+ methodRequest(method, path60, opts) {
69801
69801
  return this.request(Promise.resolve(opts).then(async (opts2) => {
69802
69802
  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;
69803
- return { method, path: path58, ...opts2, body };
69803
+ return { method, path: path60, ...opts2, body };
69804
69804
  }));
69805
69805
  }
69806
- getAPIList(path58, Page, opts) {
69807
- return this.requestAPIList(Page, { method: "get", path: path58, ...opts });
69806
+ getAPIList(path60, Page, opts) {
69807
+ return this.requestAPIList(Page, { method: "get", path: path60, ...opts });
69808
69808
  }
69809
69809
  calculateContentLength(body) {
69810
69810
  if (typeof body === "string") {
@@ -69822,10 +69822,10 @@ var APIClient = class {
69822
69822
  return null;
69823
69823
  }
69824
69824
  buildRequest(options) {
69825
- const { method, path: path58, query, headers = {} } = options;
69825
+ const { method, path: path60, query, headers = {} } = options;
69826
69826
  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;
69827
69827
  const contentLength = this.calculateContentLength(body);
69828
- const url = this.buildURL(path58, query);
69828
+ const url = this.buildURL(path60, query);
69829
69829
  if ("timeout" in options)
69830
69830
  validatePositiveInteger("timeout", options.timeout);
69831
69831
  const timeout = options.timeout ?? this.timeout;
@@ -69934,8 +69934,8 @@ var APIClient = class {
69934
69934
  const request = this.makeRequest(options, null);
69935
69935
  return new PagePromise(this, request, Page);
69936
69936
  }
69937
- buildURL(path58, query) {
69938
- const url = isAbsoluteURL(path58) ? new URL(path58) : new URL(this.baseURL + (this.baseURL.endsWith("/") && path58.startsWith("/") ? path58.slice(1) : path58));
69937
+ buildURL(path60, query) {
69938
+ const url = isAbsoluteURL(path60) ? new URL(path60) : new URL(this.baseURL + (this.baseURL.endsWith("/") && path60.startsWith("/") ? path60.slice(1) : path60));
69939
69939
  const defaultQuery = this.defaultQuery();
69940
69940
  if (!isEmptyObj(defaultQuery)) {
69941
69941
  query = { ...defaultQuery, ...query };
@@ -70220,7 +70220,7 @@ var startsWithSchemeRegexp = new RegExp("^(?:[a-z]+:)?//", "i");
70220
70220
  var isAbsoluteURL = (url) => {
70221
70221
  return startsWithSchemeRegexp.test(url);
70222
70222
  };
70223
- var sleep = (ms) => new Promise((resolve42) => setTimeout(resolve42, ms));
70223
+ var sleep = (ms) => new Promise((resolve44) => setTimeout(resolve44, ms));
70224
70224
  var validatePositiveInteger = (name, n2) => {
70225
70225
  if (typeof n2 !== "number" || !Number.isInteger(n2)) {
70226
70226
  throw new AnthropicError(`${name} must be an integer`);
@@ -70711,12 +70711,12 @@ var PromptCachingBetaMessageStream = class _PromptCachingBetaMessageStream {
70711
70711
  }
70712
70712
  return this._emit("error", new AnthropicError(String(error3)));
70713
70713
  });
70714
- __classPrivateFieldSet7(this, _PromptCachingBetaMessageStream_connectedPromise, new Promise((resolve42, reject) => {
70715
- __classPrivateFieldSet7(this, _PromptCachingBetaMessageStream_resolveConnectedPromise, resolve42, "f");
70714
+ __classPrivateFieldSet7(this, _PromptCachingBetaMessageStream_connectedPromise, new Promise((resolve44, reject) => {
70715
+ __classPrivateFieldSet7(this, _PromptCachingBetaMessageStream_resolveConnectedPromise, resolve44, "f");
70716
70716
  __classPrivateFieldSet7(this, _PromptCachingBetaMessageStream_rejectConnectedPromise, reject, "f");
70717
70717
  }), "f");
70718
- __classPrivateFieldSet7(this, _PromptCachingBetaMessageStream_endPromise, new Promise((resolve42, reject) => {
70719
- __classPrivateFieldSet7(this, _PromptCachingBetaMessageStream_resolveEndPromise, resolve42, "f");
70718
+ __classPrivateFieldSet7(this, _PromptCachingBetaMessageStream_endPromise, new Promise((resolve44, reject) => {
70719
+ __classPrivateFieldSet7(this, _PromptCachingBetaMessageStream_resolveEndPromise, resolve44, "f");
70720
70720
  __classPrivateFieldSet7(this, _PromptCachingBetaMessageStream_rejectEndPromise, reject, "f");
70721
70721
  }), "f");
70722
70722
  __classPrivateFieldGet8(this, _PromptCachingBetaMessageStream_connectedPromise, "f").catch(() => {
@@ -70845,11 +70845,11 @@ var PromptCachingBetaMessageStream = class _PromptCachingBetaMessageStream {
70845
70845
  * const message = await stream.emitted('message') // rejects if the stream errors
70846
70846
  */
70847
70847
  emitted(event) {
70848
- return new Promise((resolve42, reject) => {
70848
+ return new Promise((resolve44, reject) => {
70849
70849
  __classPrivateFieldSet7(this, _PromptCachingBetaMessageStream_catchingPromiseCreated, true, "f");
70850
70850
  if (event !== "error")
70851
70851
  this.once("error", reject);
70852
- this.once(event, resolve42);
70852
+ this.once(event, resolve44);
70853
70853
  });
70854
70854
  }
70855
70855
  async done() {
@@ -71076,7 +71076,7 @@ var PromptCachingBetaMessageStream = class _PromptCachingBetaMessageStream {
71076
71076
  if (done) {
71077
71077
  return { value: void 0, done: true };
71078
71078
  }
71079
- return new Promise((resolve42, reject) => readQueue.push({ resolve: resolve42, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
71079
+ return new Promise((resolve44, reject) => readQueue.push({ resolve: resolve44, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
71080
71080
  }
71081
71081
  const chunk = pushQueue.shift();
71082
71082
  return { value: chunk, done: false };
@@ -71224,12 +71224,12 @@ var MessageStream = class _MessageStream {
71224
71224
  }
71225
71225
  return this._emit("error", new AnthropicError(String(error3)));
71226
71226
  });
71227
- __classPrivateFieldSet8(this, _MessageStream_connectedPromise, new Promise((resolve42, reject) => {
71228
- __classPrivateFieldSet8(this, _MessageStream_resolveConnectedPromise, resolve42, "f");
71227
+ __classPrivateFieldSet8(this, _MessageStream_connectedPromise, new Promise((resolve44, reject) => {
71228
+ __classPrivateFieldSet8(this, _MessageStream_resolveConnectedPromise, resolve44, "f");
71229
71229
  __classPrivateFieldSet8(this, _MessageStream_rejectConnectedPromise, reject, "f");
71230
71230
  }), "f");
71231
- __classPrivateFieldSet8(this, _MessageStream_endPromise, new Promise((resolve42, reject) => {
71232
- __classPrivateFieldSet8(this, _MessageStream_resolveEndPromise, resolve42, "f");
71231
+ __classPrivateFieldSet8(this, _MessageStream_endPromise, new Promise((resolve44, reject) => {
71232
+ __classPrivateFieldSet8(this, _MessageStream_resolveEndPromise, resolve44, "f");
71233
71233
  __classPrivateFieldSet8(this, _MessageStream_rejectEndPromise, reject, "f");
71234
71234
  }), "f");
71235
71235
  __classPrivateFieldGet9(this, _MessageStream_connectedPromise, "f").catch(() => {
@@ -71358,11 +71358,11 @@ var MessageStream = class _MessageStream {
71358
71358
  * const message = await stream.emitted('message') // rejects if the stream errors
71359
71359
  */
71360
71360
  emitted(event) {
71361
- return new Promise((resolve42, reject) => {
71361
+ return new Promise((resolve44, reject) => {
71362
71362
  __classPrivateFieldSet8(this, _MessageStream_catchingPromiseCreated, true, "f");
71363
71363
  if (event !== "error")
71364
71364
  this.once("error", reject);
71365
- this.once(event, resolve42);
71365
+ this.once(event, resolve44);
71366
71366
  });
71367
71367
  }
71368
71368
  async done() {
@@ -71589,7 +71589,7 @@ var MessageStream = class _MessageStream {
71589
71589
  if (done) {
71590
71590
  return { value: void 0, done: true };
71591
71591
  }
71592
- return new Promise((resolve42, reject) => readQueue.push({ resolve: resolve42, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
71592
+ return new Promise((resolve44, reject) => readQueue.push({ resolve: resolve44, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
71593
71593
  }
71594
71594
  const chunk = pushQueue.shift();
71595
71595
  return { value: chunk, done: false };
@@ -71849,11 +71849,11 @@ async function promptApplyAgentMdProposal(repoPath) {
71849
71849
  }
71850
71850
  async function askYesNo2(question) {
71851
71851
  const rl = readline2.createInterface({ input: process.stdin, output: process.stderr });
71852
- return new Promise((resolve42) => {
71852
+ return new Promise((resolve44) => {
71853
71853
  process.stderr.write(`${question} `);
71854
71854
  rl.once("line", (answer) => {
71855
71855
  rl.close();
71856
- resolve42(/^y(es)?$/i.test(answer.trim()));
71856
+ resolve44(/^y(es)?$/i.test(answer.trim()));
71857
71857
  });
71858
71858
  });
71859
71859
  }
@@ -72083,7 +72083,7 @@ async function executeAuthoringToolCall(toolName, input, repoPath, harnessDir, c
72083
72083
  }
72084
72084
  async function askUser(question, options) {
72085
72085
  const rl = readline3.createInterface({ input: process.stdin, output: process.stderr });
72086
- return new Promise((resolve42) => {
72086
+ return new Promise((resolve44) => {
72087
72087
  process.stderr.write("\n");
72088
72088
  process.stderr.write(`\u2753 ${question}
72089
72089
  `);
@@ -72094,7 +72094,7 @@ async function askUser(question, options) {
72094
72094
  process.stderr.write("> ");
72095
72095
  rl.once("line", (answer) => {
72096
72096
  rl.close();
72097
- resolve42(answer.trim());
72097
+ resolve44(answer.trim());
72098
72098
  });
72099
72099
  });
72100
72100
  }
@@ -72238,7 +72238,7 @@ function runScript(scriptPath, args = [], options = {}) {
72238
72238
  function runScriptCapture(scriptPath, args = [], options = {}) {
72239
72239
  const stream = options.stream ?? false;
72240
72240
  const { stream: _stream, ...spawnOptions } = options;
72241
- return new Promise((resolve42) => {
72241
+ return new Promise((resolve44) => {
72242
72242
  const proc = (0, import_child_process.spawn)("bash", [scriptPath, ...args], {
72243
72243
  ...spawnOptions,
72244
72244
  stdio: ["inherit", "pipe", "pipe"]
@@ -72253,13 +72253,13 @@ function runScriptCapture(scriptPath, args = [], options = {}) {
72253
72253
  stderr += d2;
72254
72254
  if (stream) process.stderr.write(d2);
72255
72255
  });
72256
- proc.on("close", (code) => resolve42({ stdout, stderr, code: code ?? 0 }));
72256
+ proc.on("close", (code) => resolve44({ stdout, stderr, code: code ?? 0 }));
72257
72257
  });
72258
72258
  }
72259
72259
  function runShellCommand(command2, options = {}) {
72260
72260
  const stream = options.stream ?? false;
72261
72261
  const { stream: _stream, ...spawnOptions } = options;
72262
- return new Promise((resolve42) => {
72262
+ return new Promise((resolve44) => {
72263
72263
  const proc = (0, import_child_process.spawn)("bash", ["-lc", command2], {
72264
72264
  ...spawnOptions,
72265
72265
  stdio: ["inherit", "pipe", "pipe"]
@@ -72274,7 +72274,7 @@ function runShellCommand(command2, options = {}) {
72274
72274
  stderr += d2;
72275
72275
  if (stream) process.stderr.write(d2);
72276
72276
  });
72277
- proc.on("close", (code) => resolve42({ stdout, stderr, code: code ?? 0 }));
72277
+ proc.on("close", (code) => resolve44({ stdout, stderr, code: code ?? 0 }));
72278
72278
  });
72279
72279
  }
72280
72280
 
@@ -73455,12 +73455,12 @@ function printAdaptationPrompt(content) {
73455
73455
  }
73456
73456
  function askYesNo3(question) {
73457
73457
  const rl = readline4.createInterface({ input: process.stdin, output: process.stderr });
73458
- return new Promise((resolve42) => {
73458
+ return new Promise((resolve44) => {
73459
73459
  process.stderr.write(`${question} `);
73460
73460
  rl.once("line", (answer) => {
73461
73461
  rl.close();
73462
73462
  const trimmed = answer.trim();
73463
- resolve42(trimmed === "" || /^y(es)?$/i.test(trimmed));
73463
+ resolve44(trimmed === "" || /^y(es)?$/i.test(trimmed));
73464
73464
  });
73465
73465
  });
73466
73466
  }
@@ -73547,16 +73547,16 @@ async function promptScaffoldCursorRule(exists) {
73547
73547
  }
73548
73548
  async function askYesNo4(question) {
73549
73549
  const rl = readline5.createInterface({ input: process.stdin, output: process.stderr });
73550
- return new Promise((resolve42) => {
73550
+ return new Promise((resolve44) => {
73551
73551
  process.stderr.write(`${question} `);
73552
73552
  rl.once("line", (answer) => {
73553
73553
  rl.close();
73554
73554
  const trimmed = answer.trim();
73555
73555
  if (trimmed === "") {
73556
- resolve42(true);
73556
+ resolve44(true);
73557
73557
  return;
73558
73558
  }
73559
- resolve42(/^y(es)?$/i.test(trimmed));
73559
+ resolve44(/^y(es)?$/i.test(trimmed));
73560
73560
  });
73561
73561
  });
73562
73562
  }
@@ -76115,7 +76115,7 @@ async function waitForControlApi(apiUrl = getControlApiUrl(), timeoutMs = 6e4, i
76115
76115
  const deadline = Date.now() + timeoutMs;
76116
76116
  while (Date.now() < deadline) {
76117
76117
  if (await isControlApiReachable(apiUrl)) return true;
76118
- await new Promise((resolve42) => setTimeout(resolve42, intervalMs));
76118
+ await new Promise((resolve44) => setTimeout(resolve44, intervalMs));
76119
76119
  }
76120
76120
  return false;
76121
76121
  }
@@ -76163,8 +76163,7 @@ async function syncReposWithControl(options) {
76163
76163
  async function syncAllKnownReposWithControl(options) {
76164
76164
  if (!isControlEnabled()) return { synced: 0, failed: 0 };
76165
76165
  const apiUrl = options?.apiUrl ?? getControlApiUrl();
76166
- const portal = getPortalTarget();
76167
- if (!await isControlApiReachable(portal ? portal.url : apiUrl)) {
76166
+ if (!await isControlApiReachable(apiUrl)) {
76168
76167
  return { synced: 0, failed: 0 };
76169
76168
  }
76170
76169
  const repoPaths = await discoverHarRepos({ apiUrl, cwd: options?.cwd });
@@ -76199,6 +76198,40 @@ async function registerRepoWithControl(options) {
76199
76198
  }
76200
76199
  return await response.json();
76201
76200
  }
76201
+ async function syncRepoWithLocalControl(options) {
76202
+ const apiUrl = options.apiUrl ?? getControlApiUrl();
76203
+ const { repoPath, dryRun } = options;
76204
+ const registerResult = await registerRepoWithControl({ ...options, repoPath });
76205
+ const repoId = registerResult?.id;
76206
+ if (!repoId && !dryRun) {
76207
+ const listResponse = await fetch(`${apiUrl}/api/repos`);
76208
+ if (!listResponse.ok) throw new Error("Failed to list repos from Control API");
76209
+ const repos = await listResponse.json();
76210
+ const existing = repos.find((r2) => path43.resolve(r2.path) === repoPath);
76211
+ if (!existing) {
76212
+ return;
76213
+ }
76214
+ await syncRepoRunsAndSlots(apiUrl, existing.id, repoPath, dryRun);
76215
+ return;
76216
+ }
76217
+ if (repoId) {
76218
+ await syncRepoRunsAndSlots(apiUrl, repoId, repoPath, dryRun);
76219
+ }
76220
+ }
76221
+ async function syncRepoWithPortal(options, controlApiUrl) {
76222
+ const portal = getPortalTarget();
76223
+ if (!portal) return;
76224
+ const { repoPath, dryRun, full } = options;
76225
+ const since = full ? null : readPortalWatermark(repoPath, portal.url);
76226
+ const { syncBody, events, maxSyncedAt } = await buildPortalPayload(repoPath, controlApiUrl, since);
76227
+ await postPortal(portal, "/api/sync", syncBody, dryRun);
76228
+ if (events.length > 0) {
76229
+ await postPortal(portal, "/api/otel", { path: repoPath, events, spans: [] }, dryRun);
76230
+ }
76231
+ if (!dryRun && maxSyncedAt) {
76232
+ writePortalWatermark(repoPath, portal.url, maxSyncedAt);
76233
+ }
76234
+ }
76202
76235
  async function syncRepoWithControl(options) {
76203
76236
  const repoPath = canonicalizeControlRepoPath(options.repoPath);
76204
76237
  const apiUrl = options.apiUrl ?? getControlApiUrl();
@@ -76231,40 +76264,8 @@ async function syncRepoWithControl(options) {
76231
76264
  }
76232
76265
  return;
76233
76266
  }
76234
- const portal = getPortalTarget();
76235
- if (portal) {
76236
- const since = options.full ? null : readPortalWatermark(repoPath, portal.url);
76237
- const { syncBody, events, maxSyncedAt } = await buildPortalPayload(repoPath, apiUrl, since);
76238
- await postPortal(portal, "/api/sync", syncBody, options.dryRun);
76239
- if (events.length > 0) {
76240
- await postPortal(
76241
- portal,
76242
- "/api/otel",
76243
- { path: repoPath, events, spans: [] },
76244
- options.dryRun
76245
- );
76246
- }
76247
- if (!options.dryRun && maxSyncedAt) {
76248
- writePortalWatermark(repoPath, portal.url, maxSyncedAt);
76249
- }
76250
- return;
76251
- }
76252
- const registerResult = await registerRepoWithControl({ ...options, repoPath });
76253
- const repoId = registerResult?.id;
76254
- if (!repoId && !options.dryRun) {
76255
- const listResponse = await fetch(`${apiUrl}/api/repos`);
76256
- if (!listResponse.ok) throw new Error("Failed to list repos from Control API");
76257
- const repos = await listResponse.json();
76258
- const existing = repos.find((r2) => path43.resolve(r2.path) === repoPath);
76259
- if (!existing) {
76260
- return;
76261
- }
76262
- await syncRepoRunsAndSlots(apiUrl, existing.id, repoPath, options.dryRun);
76263
- return;
76264
- }
76265
- if (repoId) {
76266
- await syncRepoRunsAndSlots(apiUrl, repoId, repoPath, options.dryRun);
76267
- }
76267
+ await syncRepoWithLocalControl({ ...options, repoPath, apiUrl });
76268
+ await syncRepoWithPortal({ ...options, repoPath }, apiUrl);
76268
76269
  }
76269
76270
  async function syncRepoRunsAndSlots(apiUrl, repoId, repoPath, dryRun) {
76270
76271
  const runs = listRuns(repoPath);
@@ -76365,11 +76366,10 @@ async function syncRepoWithControlAsync(repoPath) {
76365
76366
  if (process.env.HAR_CONTROL_DISABLED === "true" || process.env.NODE_ENV === "test") return;
76366
76367
  const verbose = process.env.HAR_CONTROL_VERBOSE === "true";
76367
76368
  try {
76368
- const portal = getPortalTarget();
76369
- const healthUrl = portal ? portal.url : getControlApiUrl();
76370
- if (!await isControlApiReachable(healthUrl)) {
76369
+ const apiUrl = getControlApiUrl();
76370
+ if (!await isControlApiReachable(apiUrl)) {
76371
76371
  if (verbose) {
76372
- process.stderr.write(`[har control] sync skipped: not reachable at ${healthUrl}
76372
+ process.stderr.write(`[har control] sync skipped: not reachable at ${apiUrl}
76373
76373
  `);
76374
76374
  }
76375
76375
  return;
@@ -77356,12 +77356,12 @@ async function recordCommitAssociation(cwd) {
77356
77356
  // src/core/commit-gate-onboarding.ts
77357
77357
  function askYesNo5(question) {
77358
77358
  const rl = readline6.createInterface({ input: process.stdin, output: process.stderr });
77359
- return new Promise((resolve42) => {
77359
+ return new Promise((resolve44) => {
77360
77360
  process.stderr.write(`${question} `);
77361
77361
  rl.once("line", (answer) => {
77362
77362
  rl.close();
77363
77363
  const trimmed = answer.trim();
77364
- resolve42(trimmed === "" || /^y(es)?$/i.test(trimmed));
77364
+ resolve44(trimmed === "" || /^y(es)?$/i.test(trimmed));
77365
77365
  });
77366
77366
  });
77367
77367
  }
@@ -77448,7 +77448,10 @@ function writeOnboardingPreferences(overrides) {
77448
77448
  }
77449
77449
 
77450
77450
  // src/cli/help-text.ts
77451
- var HAR_ROOT_EPILOG = `Typical agent workflow:
77451
+ var HAR_ROOT_EPILOG = `First time in a repo:
77452
+ har onboard # guided setup \u2192 adaptation prompt on clipboard
77453
+
77454
+ Typical agent workflow:
77452
77455
  har env status # see which slots are free / occupied
77453
77456
  har env launch <id> # new session from the main checkout's HEAD
77454
77457
  # \u2026edit only under the printed work dir\u2026
@@ -78071,8 +78074,8 @@ async function handleLaunch(argv) {
78071
78074
  console.error(guard.reason ?? "");
78072
78075
  const readline10 = await import("readline");
78073
78076
  const rl = readline10.createInterface({ input: process.stdin, output: process.stderr });
78074
- const answer = await new Promise((resolve42) => {
78075
- rl.question("Replace this slot? [y/N] ", resolve42);
78077
+ const answer = await new Promise((resolve44) => {
78078
+ rl.question("Replace this slot? [y/N] ", resolve44);
78076
78079
  });
78077
78080
  rl.close();
78078
78081
  if (!/^[Yy]$/.test(answer.trim())) {
@@ -78088,8 +78091,8 @@ async function handleLaunch(argv) {
78088
78091
  warn("Worktree has uncommitted changes.");
78089
78092
  const readline10 = await import("readline");
78090
78093
  const rl = readline10.createInterface({ input: process.stdin, output: process.stderr });
78091
- const answer = await new Promise((resolve42) => {
78092
- rl.question("Discard uncommitted changes? [y/N] ", resolve42);
78094
+ const answer = await new Promise((resolve44) => {
78095
+ rl.question("Discard uncommitted changes? [y/N] ", resolve44);
78093
78096
  });
78094
78097
  rl.close();
78095
78098
  if (!/^[Yy]$/.test(answer.trim())) {
@@ -79326,13 +79329,13 @@ var PromisePolyfill = class extends Promise {
79326
79329
  // Available starting from Node 22
79327
79330
  // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/withResolvers
79328
79331
  static withResolver() {
79329
- let resolve42;
79332
+ let resolve44;
79330
79333
  let reject;
79331
79334
  const promise = new Promise((res, rej) => {
79332
- resolve42 = res;
79335
+ resolve44 = res;
79333
79336
  reject = rej;
79334
79337
  });
79335
- return { promise, resolve: resolve42, reject };
79338
+ return { promise, resolve: resolve44, reject };
79336
79339
  }
79337
79340
  };
79338
79341
 
@@ -79349,7 +79352,7 @@ function createPrompt(view) {
79349
79352
  output
79350
79353
  });
79351
79354
  const screen = new ScreenManager(rl);
79352
- const { promise, resolve: resolve42, reject } = PromisePolyfill.withResolver();
79355
+ const { promise, resolve: resolve44, reject } = PromisePolyfill.withResolver();
79353
79356
  const cancel = () => reject(new CancelPromptError());
79354
79357
  if (signal) {
79355
79358
  const abort = () => reject(new AbortPromptError({ cause: signal.reason }));
@@ -79373,7 +79376,7 @@ function createPrompt(view) {
79373
79376
  cycle(() => {
79374
79377
  try {
79375
79378
  const nextView = view(config2, (value) => {
79376
- setImmediate(() => resolve42(value));
79379
+ setImmediate(() => resolve44(value));
79377
79380
  });
79378
79381
  const [content, bottomContent] = typeof nextView === "string" ? [nextView] : nextView;
79379
79382
  screen.render(content, bottomContent);
@@ -80360,9 +80363,9 @@ var import_run_async = __toESM(require_run_async(), 1);
80360
80363
  var import_mute_stream2 = __toESM(require_lib3(), 1);
80361
80364
  var import_ansi_escapes5 = __toESM(require_ansi_escapes(), 1);
80362
80365
  var _2 = {
80363
- set: (obj, path58 = "", value) => {
80366
+ set: (obj, path60 = "", value) => {
80364
80367
  let pointer = obj;
80365
- path58.split(".").forEach((key, index, arr) => {
80368
+ path60.split(".").forEach((key, index, arr) => {
80366
80369
  if (key === "__proto__" || key === "constructor")
80367
80370
  return;
80368
80371
  if (index === arr.length - 1) {
@@ -80373,8 +80376,8 @@ var _2 = {
80373
80376
  pointer = pointer[key];
80374
80377
  });
80375
80378
  },
80376
- get: (obj, path58 = "", defaultValue) => {
80377
- const travel = (regexp) => String.prototype.split.call(path58, regexp).filter(Boolean).reduce(
80379
+ get: (obj, path60 = "", defaultValue) => {
80380
+ const travel = (regexp) => String.prototype.split.call(path60, regexp).filter(Boolean).reduce(
80378
80381
  // @ts-expect-error implicit any on res[key]
80379
80382
  (res, key) => res !== null && res !== void 0 ? res[key] : res,
80380
80383
  obj
@@ -80488,7 +80491,7 @@ var PromptsRunner = class {
80488
80491
  throw new Error(`Prompt for type ${question.type} not found`);
80489
80492
  }
80490
80493
  let cleanupSignal;
80491
- const promptFn = isPromptConstructor(prompt2) ? (q2, { signal: signal2 } = {}) => new Promise((resolve42, reject) => {
80494
+ const promptFn = isPromptConstructor(prompt2) ? (q2, { signal: signal2 } = {}) => new Promise((resolve44, reject) => {
80492
80495
  const rl = import_node_readline.default.createInterface(setupReadlineOptions(this.opt));
80493
80496
  rl.resume();
80494
80497
  const onClose = () => {
@@ -80524,7 +80527,7 @@ var PromptsRunner = class {
80524
80527
  cleanupSignal = void 0;
80525
80528
  };
80526
80529
  }
80527
- activePrompt.run().then(resolve42, reject).finally(cleanup);
80530
+ activePrompt.run().then(resolve44, reject).finally(cleanup);
80528
80531
  }) : prompt2;
80529
80532
  const { signal: moduleSignal } = this.opt;
80530
80533
  if (moduleSignal?.aborted) {
@@ -80697,7 +80700,7 @@ function openBrowser(url) {
80697
80700
  }
80698
80701
  async function loginViaBrowser(portalUrl, openUrl = openBrowser) {
80699
80702
  const state = (0, import_crypto.randomUUID)();
80700
- return new Promise((resolve42, reject) => {
80703
+ return new Promise((resolve44, reject) => {
80701
80704
  let timer;
80702
80705
  const server = http.createServer((req, res) => {
80703
80706
  const requestUrl = new URL(req.url ?? "", "http://127.0.0.1");
@@ -80720,7 +80723,7 @@ async function loginViaBrowser(portalUrl, openUrl = openBrowser) {
80720
80723
  res.writeHead(200, { "Content-Type": "text/html" });
80721
80724
  res.end("<h1>Logged in</h1><p>You can close this tab and return to the terminal.</p>");
80722
80725
  cleanup();
80723
- resolve42({ portalUrl, token, workspace, email: email2, createdAt: (/* @__PURE__ */ new Date()).toISOString() });
80726
+ resolve44({ portalUrl, token, workspace, email: email2, createdAt: (/* @__PURE__ */ new Date()).toISOString() });
80724
80727
  });
80725
80728
  const cleanup = () => {
80726
80729
  clearTimeout(timer);
@@ -80807,8 +80810,8 @@ async function askYesNo6(question) {
80807
80810
  if (!process.stdin.isTTY || !process.stdout.isTTY) return false;
80808
80811
  const readline10 = await import("readline");
80809
80812
  const rl = readline10.createInterface({ input: process.stdin, output: process.stderr });
80810
- const answer = await new Promise((resolve42) => {
80811
- rl.question(question, resolve42);
80813
+ const answer = await new Promise((resolve44) => {
80814
+ rl.question(question, resolve44);
80812
80815
  });
80813
80816
  rl.close();
80814
80817
  return /^[Yy]$/.test(answer.trim());
@@ -81012,8 +81015,8 @@ async function askYesNo7(question) {
81012
81015
  if (!process.stdin.isTTY || !process.stdout.isTTY) return false;
81013
81016
  const readline10 = await import("readline");
81014
81017
  const rl = readline10.createInterface({ input: process.stdin, output: process.stderr });
81015
- const answer = await new Promise((resolve42) => {
81016
- rl.question(question, resolve42);
81018
+ const answer = await new Promise((resolve44) => {
81019
+ rl.question(question, resolve44);
81017
81020
  });
81018
81021
  rl.close();
81019
81022
  return /^[Yy]$/.test(answer.trim());
@@ -81983,10 +81986,10 @@ function assignProp(target, prop, value) {
81983
81986
  configurable: true
81984
81987
  });
81985
81988
  }
81986
- function getElementAtPath(obj, path58) {
81987
- if (!path58)
81989
+ function getElementAtPath(obj, path60) {
81990
+ if (!path60)
81988
81991
  return obj;
81989
- return path58.reduce((acc, key) => acc?.[key], obj);
81992
+ return path60.reduce((acc, key) => acc?.[key], obj);
81990
81993
  }
81991
81994
  function promiseAllObject(promisesObj) {
81992
81995
  const keys = Object.keys(promisesObj);
@@ -82306,11 +82309,11 @@ function aborted(x2, startIndex = 0) {
82306
82309
  }
82307
82310
  return false;
82308
82311
  }
82309
- function prefixIssues(path58, issues) {
82312
+ function prefixIssues(path60, issues) {
82310
82313
  return issues.map((iss) => {
82311
82314
  var _a3;
82312
82315
  (_a3 = iss).path ?? (_a3.path = []);
82313
- iss.path.unshift(path58);
82316
+ iss.path.unshift(path60);
82314
82317
  return iss;
82315
82318
  });
82316
82319
  }
@@ -87633,7 +87636,7 @@ var Protocol = class {
87633
87636
  return;
87634
87637
  }
87635
87638
  const pollInterval = task2.pollInterval ?? this._options?.defaultTaskPollInterval ?? 1e3;
87636
- await new Promise((resolve42) => setTimeout(resolve42, pollInterval));
87639
+ await new Promise((resolve44) => setTimeout(resolve44, pollInterval));
87637
87640
  options?.signal?.throwIfAborted();
87638
87641
  }
87639
87642
  } catch (error3) {
@@ -87650,7 +87653,7 @@ var Protocol = class {
87650
87653
  */
87651
87654
  request(request, resultSchema, options) {
87652
87655
  const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
87653
- return new Promise((resolve42, reject) => {
87656
+ return new Promise((resolve44, reject) => {
87654
87657
  const earlyReject = (error3) => {
87655
87658
  reject(error3);
87656
87659
  };
@@ -87728,7 +87731,7 @@ var Protocol = class {
87728
87731
  if (!parseResult.success) {
87729
87732
  reject(parseResult.error);
87730
87733
  } else {
87731
- resolve42(parseResult.data);
87734
+ resolve44(parseResult.data);
87732
87735
  }
87733
87736
  } catch (error3) {
87734
87737
  reject(error3);
@@ -87989,12 +87992,12 @@ var Protocol = class {
87989
87992
  }
87990
87993
  } catch {
87991
87994
  }
87992
- return new Promise((resolve42, reject) => {
87995
+ return new Promise((resolve44, reject) => {
87993
87996
  if (signal.aborted) {
87994
87997
  reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
87995
87998
  return;
87996
87999
  }
87997
- const timeoutId = setTimeout(resolve42, interval);
88000
+ const timeoutId = setTimeout(resolve44, interval);
87998
88001
  signal.addEventListener("abort", () => {
87999
88002
  clearTimeout(timeoutId);
88000
88003
  reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
@@ -88867,12 +88870,12 @@ var StdioServerTransport = class {
88867
88870
  this.onclose?.();
88868
88871
  }
88869
88872
  send(message) {
88870
- return new Promise((resolve42) => {
88873
+ return new Promise((resolve44) => {
88871
88874
  const json = serializeMessage(message);
88872
88875
  if (this._stdout.write(json)) {
88873
- resolve42();
88876
+ resolve44();
88874
88877
  } else {
88875
- this._stdout.once("drain", resolve42);
88878
+ this._stdout.once("drain", resolve44);
88876
88879
  }
88877
88880
  });
88878
88881
  }
@@ -89510,6 +89513,486 @@ var mcpCommand = {
89510
89513
  }
89511
89514
  };
89512
89515
 
89516
+ // src/cli/commands/onboard.ts
89517
+ var path58 = __toESM(require("path"));
89518
+
89519
+ // src/core/onboarding.ts
89520
+ var path57 = __toESM(require("path"));
89521
+ init_control_config();
89522
+ init_otel_hooks();
89523
+ init_telemetry_config();
89524
+ var ONBOARDING_GUIDE_STEPS = [
89525
+ {
89526
+ title: "What HAR is",
89527
+ body: [
89528
+ "HAR (Harness) gives coding agents a reproducible environment for your repo:",
89529
+ "an editable `.har/` scaffold, isolated git worktree sessions, and a verify \u2192 complete loop.",
89530
+ "You adapt the scaffold once to your stack; agents then use the same launch/verify/teardown contract."
89531
+ ].join("\n")
89532
+ },
89533
+ {
89534
+ title: "Sessions and slots",
89535
+ body: [
89536
+ "Each `har env launch <id>` creates a fresh session worktree from your main checkout HEAD.",
89537
+ "Edit only under the printed work dir \u2014 never the main checkout while a slot is active.",
89538
+ "Use separate slot ids for parallel tasks. Prefer `complete` / `teardown` before starting unrelated work."
89539
+ ].join("\n")
89540
+ },
89541
+ {
89542
+ title: "Verify and finish",
89543
+ body: [
89544
+ "Quick: har env verify <id>",
89545
+ "Done: har env verify <id> --full then har env complete <id>",
89546
+ "`complete` records a validation, frees the slot, and keeps the session branch for a PR."
89547
+ ].join("\n")
89548
+ },
89549
+ {
89550
+ title: "Mission Control and plugins",
89551
+ body: [
89552
+ "Mission Control is a local dashboard for slots, runs, and (optional) agent usage telemetry.",
89553
+ "Plugins (`har env add-plugin`) add optional verification stages such as Playwright browser-e2e.",
89554
+ "After setup, paste the adaptation prompt into your coding agent to tailor `.har/` to this repo."
89555
+ ].join("\n")
89556
+ }
89557
+ ];
89558
+ function listPluginChoices() {
89559
+ return listPluginIds().map((id) => {
89560
+ try {
89561
+ const manifest = readPluginManifest(id);
89562
+ const description = typeof manifest.stage.description === "string" ? manifest.stage.description : `Adds stage ${manifest.stageId}`;
89563
+ return {
89564
+ id,
89565
+ label: `${id} \u2014 ${description}`,
89566
+ description
89567
+ };
89568
+ } catch {
89569
+ return { id, label: id, description: id };
89570
+ }
89571
+ });
89572
+ }
89573
+ function printOnboardingGuide() {
89574
+ divider();
89575
+ info("How HAR works");
89576
+ divider();
89577
+ for (const [index, step] of ONBOARDING_GUIDE_STEPS.entries()) {
89578
+ info(`${index + 1}. ${step.title}`);
89579
+ for (const line of step.body.split("\n")) {
89580
+ info(` ${line}`);
89581
+ }
89582
+ info("");
89583
+ }
89584
+ }
89585
+ async function applyOnboardingTelemetry(choice, options = {}) {
89586
+ const setupHooks = options.setupHooks !== false;
89587
+ if (choice === "off") {
89588
+ writeTelemetryPreference(false);
89589
+ if (setupHooks) {
89590
+ try {
89591
+ disableOtelHooksExport();
89592
+ } catch (err) {
89593
+ warn(`Could not refresh hooks config: ${err instanceof Error ? err.message : String(err)}`);
89594
+ }
89595
+ }
89596
+ success("Telemetry disabled");
89597
+ return;
89598
+ }
89599
+ const prompts = choice === "on";
89600
+ writeTelemetryPreference(true, { prompts, traces: true });
89601
+ success(
89602
+ prompts ? "Telemetry enabled (including prompts) \u2192 Mission Control via @osfactory/otel-hook" : "Telemetry enabled without prompt capture"
89603
+ );
89604
+ if (setupHooks) {
89605
+ const hooks = ensureOtelHooks({ setupAgents: true });
89606
+ if (hooks.message) success(hooks.message);
89607
+ if (hooks.warning) warn(hooks.warning);
89608
+ }
89609
+ }
89610
+ async function defaultEnsureControl(options) {
89611
+ const apiUrl = getControlApiUrl();
89612
+ if (!options.startControl) {
89613
+ if (options.telemetry !== "off") {
89614
+ await ensureTelemetryInfrastructure({ startIfNeeded: false });
89615
+ const reachable = await isControlApiReachable(apiUrl);
89616
+ if (!reachable) {
89617
+ return {
89618
+ started: false,
89619
+ apiUrl,
89620
+ warning: "Telemetry is on but Mission Control is not running. Start later with: har control up"
89621
+ };
89622
+ }
89623
+ }
89624
+ return { started: false, apiUrl };
89625
+ }
89626
+ if (options.telemetry !== "off") {
89627
+ const ensured = await ensureTelemetryInfrastructure({ startIfNeeded: true });
89628
+ if (ensured.message) success(ensured.message);
89629
+ if (ensured.warning) warn(ensured.warning);
89630
+ return {
89631
+ started: ensured.started || ensured.reachable,
89632
+ apiUrl: ensured.apiUrl,
89633
+ warning: ensured.warning
89634
+ };
89635
+ }
89636
+ const result = await startControlAndSync({ detach: true, cwd: options.cwd });
89637
+ if (result.code !== 0) {
89638
+ return {
89639
+ started: false,
89640
+ apiUrl: result.apiUrl,
89641
+ warning: "Failed to start Mission Control (is Docker available?)"
89642
+ };
89643
+ }
89644
+ success(`Mission Control started at ${result.apiUrl}`);
89645
+ return { started: true, apiUrl: result.apiUrl };
89646
+ }
89647
+ async function runOnboarding(options, deps = {}) {
89648
+ const repoPath = path57.resolve(options.repoPath);
89649
+ const applyTelemetry = deps.applyTelemetry ?? applyOnboardingTelemetry;
89650
+ const ensureControl = deps.ensureControl ?? defaultEnsureControl;
89651
+ const init = deps.initHarness ?? initHarness;
89652
+ const applyPlugin2 = deps.addPlugin ?? addPlugin;
89653
+ const offerClipboard = deps.offerClipboard ?? offerAdaptationPromptClipboard;
89654
+ await applyTelemetry(options.telemetry);
89655
+ const control = await ensureControl({
89656
+ startControl: options.startControl,
89657
+ telemetry: options.telemetry,
89658
+ cwd: repoPath
89659
+ });
89660
+ if (control.warning) warn(control.warning);
89661
+ const alreadyPresent = harnessExists(repoPath);
89662
+ let harnessInitialized = false;
89663
+ const shouldInit = !options.skipInit && !(alreadyPresent && options.skipInitIfPresent !== false);
89664
+ if (options.skipInit) {
89665
+ info("Skipping harness scaffold (--skip-init)");
89666
+ } else if (alreadyPresent && options.skipInitIfPresent !== false) {
89667
+ info("Harness already present \u2014 skipping scaffold");
89668
+ } else if (shouldInit) {
89669
+ divider();
89670
+ info(`Scaffolding .har/ (profile: ${options.profile})...`);
89671
+ const result = await init({
89672
+ repoPath,
89673
+ profile: options.profile,
89674
+ force: alreadyPresent,
89675
+ auto: false
89676
+ });
89677
+ if (!result.validation.pass) {
89678
+ warn("Harness has validation errors \u2014 review .har/ after adaptation.");
89679
+ }
89680
+ harnessInitialized = true;
89681
+ recordRepoForControlSync(repoPath);
89682
+ success("Harness scaffolded");
89683
+ }
89684
+ const pluginsApplied = [];
89685
+ const pluginWarnings = [];
89686
+ if (options.plugins.length > 0) {
89687
+ if (!harnessExists(repoPath)) {
89688
+ warn("Cannot install plugins without a harness \u2014 skipping");
89689
+ } else {
89690
+ divider();
89691
+ info(`Installing plugins: ${options.plugins.join(", ")}`);
89692
+ for (const pluginId of options.plugins) {
89693
+ try {
89694
+ const result = applyPlugin2(repoPath, pluginId, {
89695
+ force: options.forcePlugins === true
89696
+ });
89697
+ pluginsApplied.push(pluginId);
89698
+ success(`Plugin ${pluginId} \u2192 stage ${result.stageId}`);
89699
+ for (const w3 of result.warnings) pluginWarnings.push(w3);
89700
+ } catch (err) {
89701
+ const message = err instanceof Error ? err.message : String(err);
89702
+ pluginWarnings.push(`${pluginId}: ${message}`);
89703
+ warn(`Plugin ${pluginId} failed: ${message}`);
89704
+ }
89705
+ }
89706
+ }
89707
+ }
89708
+ let adaptationPromptPath = null;
89709
+ let adaptationPromptCopied = false;
89710
+ if (!options.deferAdaptationPrompt && harnessExists(repoPath)) {
89711
+ const finalized = await finalizeOnboardingAdaptation({
89712
+ repoPath,
89713
+ profile: options.profile,
89714
+ harnessInitialized,
89715
+ autoYes: options.autoYes,
89716
+ offerClipboard
89717
+ });
89718
+ adaptationPromptPath = finalized.path;
89719
+ adaptationPromptCopied = finalized.copied;
89720
+ }
89721
+ return {
89722
+ repoPath,
89723
+ profile: options.profile,
89724
+ harnessInitialized,
89725
+ harnessAlreadyPresent: alreadyPresent,
89726
+ telemetry: options.telemetry,
89727
+ controlStarted: control.started,
89728
+ controlApiUrl: control.apiUrl,
89729
+ pluginsApplied,
89730
+ pluginWarnings,
89731
+ adaptationPromptPath,
89732
+ adaptationPromptCopied
89733
+ };
89734
+ }
89735
+ async function finalizeOnboardingAdaptation(options) {
89736
+ const offerClipboard = options.offerClipboard ?? offerAdaptationPromptClipboard;
89737
+ const mode = options.harnessInitialized ? "init" : "maintain";
89738
+ const prompt2 = mode === "init" ? buildInitAdaptationPrompt(options.repoPath, options.profile) : buildMaintainAdaptationPrompt(options.repoPath);
89739
+ const filePath = writeAdaptationPrompt(options.repoPath, prompt2);
89740
+ divider();
89741
+ info(
89742
+ mode === "init" ? "Adapt the harness with your coding agent (final step):" : "Optional: paste this maintenance prompt into your coding agent:"
89743
+ );
89744
+ info(" Also saved to .har/ADAPT-PROMPT.md");
89745
+ printAdaptationPrompt(prompt2);
89746
+ const copied = await offerClipboard(prompt2, { autoYes: options.autoYes });
89747
+ return { path: filePath, copied };
89748
+ }
89749
+
89750
+ // src/cli/commands/onboard.ts
89751
+ function parsePluginsFlag(raw) {
89752
+ if (raw === void 0) return void 0;
89753
+ if (raw === false) return [];
89754
+ const available = listPluginChoices().map((p2) => p2.id);
89755
+ if (raw.trim() === "" || raw === "none") return [];
89756
+ const selected = raw.split(",").map((value) => value.trim()).filter(Boolean);
89757
+ const invalid = selected.filter((id) => !available.includes(id));
89758
+ if (invalid.length > 0) {
89759
+ throw new Error(`Unknown plugin(s): ${invalid.join(", ")}. Available: ${available.join(", ")}`);
89760
+ }
89761
+ return selected;
89762
+ }
89763
+ async function pauseForGuide(autoYes) {
89764
+ if (autoYes || !process.stdin.isTTY || !process.stdout.isTTY) return;
89765
+ await esm_default13.prompt([
89766
+ {
89767
+ type: "input",
89768
+ name: "continue",
89769
+ message: "Press Enter to continue"
89770
+ }
89771
+ ]);
89772
+ }
89773
+ async function promptChoices(args) {
89774
+ if (args.yes) {
89775
+ const telemetry2 = args.telemetry ?? "on";
89776
+ return {
89777
+ profile: args.profile ?? "default",
89778
+ telemetry: telemetry2,
89779
+ startControl: args.control ?? telemetry2 !== "off",
89780
+ plugins: parsePluginsFlag(args.plugins) ?? []
89781
+ };
89782
+ }
89783
+ const interactive = Boolean(process.stdin.isTTY && process.stdout.isTTY);
89784
+ if (!interactive) {
89785
+ if (args.telemetry === void 0 && args.control === void 0 && args.plugins === void 0 && args.profile === void 0) {
89786
+ throw new Error(
89787
+ "Interactive onboarding requires a TTY. Pass --yes or flags (--profile, --telemetry, --control/--no-control, --plugins)."
89788
+ );
89789
+ }
89790
+ const telemetry2 = args.telemetry ?? "on";
89791
+ return {
89792
+ profile: args.profile ?? "default",
89793
+ telemetry: telemetry2,
89794
+ startControl: args.control ?? telemetry2 !== "off",
89795
+ plugins: parsePluginsFlag(args.plugins) ?? []
89796
+ };
89797
+ }
89798
+ const pluginChoices = listPluginChoices();
89799
+ const alreadyPresent = harnessExists(path58.resolve(args.repo));
89800
+ const needProfile = !alreadyPresent && !args.skipInit && args.profile === void 0;
89801
+ const answers = await esm_default13.prompt([
89802
+ {
89803
+ type: "list",
89804
+ name: "profile",
89805
+ message: "Harness profile",
89806
+ when: () => needProfile,
89807
+ choices: [
89808
+ { name: "default \u2014 web / full-stack apps", value: "default" },
89809
+ { name: "cli \u2014 libraries and CLI tools (no PM2)", value: "cli" },
89810
+ { name: "ios \u2014 Xcode / iOS Simulator", value: "ios" }
89811
+ ],
89812
+ default: "default"
89813
+ },
89814
+ {
89815
+ type: "list",
89816
+ name: "telemetry",
89817
+ message: "Agent usage telemetry (Cursor / Claude / Codex \u2192 Mission Control)",
89818
+ when: () => args.telemetry === void 0,
89819
+ choices: [
89820
+ { name: "Full on (traces, logs, metrics, prompts) \u2014 recommended", value: "on" },
89821
+ { name: "On without prompt text", value: "on-no-prompts" },
89822
+ { name: "Off", value: "off" }
89823
+ ],
89824
+ default: "on"
89825
+ },
89826
+ {
89827
+ type: "confirm",
89828
+ name: "startControl",
89829
+ message: "Start Mission Control now?",
89830
+ when: () => args.control === void 0,
89831
+ default: (current) => (args.telemetry ?? current.telemetry ?? "on") !== "off"
89832
+ },
89833
+ {
89834
+ type: "checkbox",
89835
+ name: "plugins",
89836
+ message: "Optional plugins to install (space to toggle, enter to confirm)",
89837
+ when: () => args.plugins === void 0,
89838
+ choices: pluginChoices.map((plugin) => ({
89839
+ name: plugin.label,
89840
+ value: plugin.id
89841
+ }))
89842
+ }
89843
+ ]);
89844
+ const telemetry = args.telemetry ?? answers.telemetry ?? "on";
89845
+ return {
89846
+ profile: args.profile ?? answers.profile ?? "default",
89847
+ telemetry,
89848
+ startControl: args.control ?? answers.startControl ?? telemetry !== "off",
89849
+ plugins: parsePluginsFlag(args.plugins) ?? answers.plugins ?? []
89850
+ };
89851
+ }
89852
+ function printSummary(result) {
89853
+ divider();
89854
+ success("Onboarding complete");
89855
+ info(`Repository: ${result.repoPath}`);
89856
+ info(
89857
+ `Harness: ${result.harnessInitialized ? "scaffolded" : result.harnessAlreadyPresent ? "already present" : "skipped"}`
89858
+ );
89859
+ info(`Telemetry: ${result.telemetry}`);
89860
+ info(
89861
+ `Mission Control:${result.controlStarted ? ` started (${result.controlApiUrl})` : ` not started (${result.controlApiUrl})`}`
89862
+ );
89863
+ info(
89864
+ `Plugins: ${result.pluginsApplied.length > 0 ? result.pluginsApplied.join(", ") : "none"}`
89865
+ );
89866
+ if (result.adaptationPromptPath) {
89867
+ info(`Adapt prompt: ${result.adaptationPromptPath}`);
89868
+ info(
89869
+ result.adaptationPromptCopied ? "Clipboard: copied \u2014 paste into your coding agent" : "Clipboard: open .har/ADAPT-PROMPT.md and paste into your coding agent"
89870
+ );
89871
+ }
89872
+ console.error("");
89873
+ console.error(" Next:");
89874
+ console.error(" Adapt: paste the prompt into your coding agent");
89875
+ console.error(" Launch: har env launch 1");
89876
+ console.error(" Verify: har env verify 1 --full");
89877
+ console.error(" Control: har control up # if you skipped Mission Control");
89878
+ console.error("");
89879
+ }
89880
+ async function handleOnboard(argv) {
89881
+ const repoPath = path58.resolve(argv.repo);
89882
+ header("har onboard");
89883
+ info(`Repository: ${repoPath}`);
89884
+ try {
89885
+ if (!argv.skipGuide) {
89886
+ printOnboardingGuide();
89887
+ await pauseForGuide(argv.yes);
89888
+ } else {
89889
+ info(`Skipped guide (${ONBOARDING_GUIDE_STEPS.length} steps available without --skip-guide)`);
89890
+ }
89891
+ const choices = await promptChoices(argv);
89892
+ const onboarding = resolveOnboardingOptions(argv);
89893
+ const result = await runOnboarding({
89894
+ repoPath,
89895
+ profile: choices.profile,
89896
+ telemetry: choices.telemetry,
89897
+ startControl: choices.startControl,
89898
+ plugins: choices.plugins,
89899
+ skipInit: argv.skipInit,
89900
+ deferAdaptationPrompt: true,
89901
+ autoYes: argv.yes,
89902
+ forcePlugins: argv.force
89903
+ });
89904
+ if (result.harnessInitialized || harnessExists(repoPath)) {
89905
+ await handleCommitGateOnboarding({
89906
+ repoPath,
89907
+ ...onboarding.commitGate,
89908
+ autoYes: argv.yes
89909
+ });
89910
+ await handleCursorRule({
89911
+ repoPath,
89912
+ cursorRule: onboarding.cursorRule,
89913
+ autoYes: argv.yes,
89914
+ mode: result.harnessInitialized ? "init" : "maintain"
89915
+ });
89916
+ await handleAgentSkills({
89917
+ repoPath,
89918
+ ...onboarding.agentSkills,
89919
+ autoYes: argv.yes,
89920
+ force: argv.force,
89921
+ mode: result.harnessInitialized ? "init" : "maintain"
89922
+ });
89923
+ }
89924
+ if (harnessExists(repoPath)) {
89925
+ const finalized = await finalizeOnboardingAdaptation({
89926
+ repoPath,
89927
+ profile: result.profile,
89928
+ harnessInitialized: result.harnessInitialized,
89929
+ autoYes: argv.yes
89930
+ });
89931
+ result.adaptationPromptPath = finalized.path;
89932
+ result.adaptationPromptCopied = finalized.copied;
89933
+ }
89934
+ for (const warning of result.pluginWarnings) {
89935
+ warn(warning);
89936
+ }
89937
+ printSummary(result);
89938
+ } catch (err) {
89939
+ error(err instanceof Error ? err.message : String(err));
89940
+ process.exit(1);
89941
+ }
89942
+ }
89943
+ var onboardCommand = {
89944
+ command: "onboard",
89945
+ describe: "Interactive first-run guide: how HAR works, telemetry, Mission Control, plugins, adapt prompt",
89946
+ builder: (yargs) => yargs.option("repo", { type: "string", default: ".", describe: "Path to the repository" }).option("yes", {
89947
+ alias: "y",
89948
+ type: "boolean",
89949
+ default: false,
89950
+ describe: "Accept defaults without prompting (telemetry on, start Mission Control, no plugins)"
89951
+ }).option("profile", {
89952
+ type: "string",
89953
+ choices: ["default", "cli", "ios"],
89954
+ describe: "Harness profile when scaffolding (default: default)"
89955
+ }).option("telemetry", {
89956
+ type: "string",
89957
+ choices: ["on", "on-no-prompts", "off"],
89958
+ describe: "Telemetry preference"
89959
+ }).option("control", {
89960
+ type: "boolean",
89961
+ describe: "Start Mission Control (use --no-control to skip)"
89962
+ }).option("plugins", {
89963
+ type: "string",
89964
+ describe: "Comma-separated plugins to install (e.g. playwright); --no-plugins to skip; interactive checkbox when omitted"
89965
+ }).option("skip-guide", {
89966
+ type: "boolean",
89967
+ default: false,
89968
+ describe: "Skip the how-HAR-works introduction"
89969
+ }).option("skip-init", {
89970
+ type: "boolean",
89971
+ default: false,
89972
+ describe: "Do not scaffold .har/ even when missing"
89973
+ }).option("force", {
89974
+ type: "boolean",
89975
+ default: false,
89976
+ describe: "Overwrite existing plugin files when installing"
89977
+ }).option("cursor-rule", {
89978
+ type: "boolean",
89979
+ describe: "Create .cursor/rules/har-workflow.mdc without prompting (use --no-cursor-rule to skip)"
89980
+ }).option("agents", {
89981
+ type: "string",
89982
+ describe: "Scaffold agent skills for these targets (comma-separated: claude,cursor,codex); --no-agents to skip"
89983
+ }).option("commit-gate", {
89984
+ choices: ["prompt", "always", "never"],
89985
+ describe: "Install commit hooks during onboarding (defaults to user preferences)"
89986
+ }).option("gate-mode", {
89987
+ choices: ["block", "warn"],
89988
+ describe: "Policy for commits without a passing full verification"
89989
+ }).option("gate-scope", {
89990
+ choices: ["worktrees", "all"],
89991
+ describe: "Apply the commit policy to HAR worktrees or every checkout"
89992
+ }),
89993
+ handler: (argv) => handleOnboard(argv)
89994
+ };
89995
+
89513
89996
  // src/cli/commands/preferences.ts
89514
89997
  function parseAgents(raw) {
89515
89998
  if (raw === "auto") return "auto";
@@ -89626,7 +90109,7 @@ var preferencesCommand = {
89626
90109
  };
89627
90110
 
89628
90111
  // src/cli/commands/telemetry.ts
89629
- var path57 = __toESM(require("path"));
90112
+ var path59 = __toESM(require("path"));
89630
90113
  init_control_config();
89631
90114
  init_otel_hooks();
89632
90115
  init_telemetry_config();
@@ -89713,7 +90196,7 @@ async function handleOff() {
89713
90196
  info("Mission Control will not auto-start. Existing usage rows are kept.");
89714
90197
  }
89715
90198
  async function handleWriteEnv(argv) {
89716
- const repoPath = path57.resolve(argv.repo);
90199
+ const repoPath = path59.resolve(argv.repo);
89717
90200
  const harnessRoot = resolveHarnessRoot(repoPath);
89718
90201
  const session = readSlotRegistry(harnessRoot, argv.agentId);
89719
90202
  const workDir = argv.workDir ?? session?.workDir ?? repoPath;
@@ -89725,7 +90208,7 @@ async function handleWriteEnv(argv) {
89725
90208
  suffix,
89726
90209
  createdAt: session?.createdAt
89727
90210
  });
89728
- const envFile = argv.envFile ?? path57.join(workDir, `.env.agent.${argv.agentId}`);
90211
+ const envFile = argv.envFile ?? path59.join(workDir, `.env.agent.${argv.agentId}`);
89729
90212
  const attrs = {
89730
90213
  sessionKey,
89731
90214
  agentId: argv.agentId,
@@ -89741,7 +90224,7 @@ async function handleWriteEnv(argv) {
89741
90224
  success(`Wrote session attribution to ${envFile}`);
89742
90225
  }
89743
90226
  function handlePrintEnv(argv) {
89744
- const repoPath = path57.resolve(argv.repo);
90227
+ const repoPath = path59.resolve(argv.repo);
89745
90228
  const workDir = argv.workDir ?? repoPath;
89746
90229
  const sessionKey = buildSessionKey({
89747
90230
  branch: argv.branch,
@@ -89861,7 +90344,7 @@ var telemetryCommand = {
89861
90344
  // src/cli/index.ts
89862
90345
  async function runCli() {
89863
90346
  ensureDefaultTelemetryPreference();
89864
- await yargs_default(hideBin(process.argv)).scriptName("har").usage("$0 <command> [options]").command(envCommand).command(agentsCommand).command(controlCommand).command(hooksCommand).command(mcpCommand).command(preferencesCommand).command(telemetryCommand).demandCommand(1, "Please specify a command. Try: har env --help").epilog(HAR_ROOT_EPILOG).strict().help().version(getHarPackageVersion()).parse();
90347
+ await yargs_default(hideBin(process.argv)).scriptName("har").usage("$0 <command> [options]").command(onboardCommand).command(envCommand).command(agentsCommand).command(controlCommand).command(hooksCommand).command(mcpCommand).command(preferencesCommand).command(telemetryCommand).demandCommand(1, "Please specify a command. Try: har onboard or har env --help").epilog(HAR_ROOT_EPILOG).strict().help().version(getHarPackageVersion()).parse();
89865
90348
  }
89866
90349
 
89867
90350
  // src/index.ts