@usepowerplant/cli 0.4.4 → 0.4.5

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.
package/dist/cli.js CHANGED
@@ -6877,19 +6877,19 @@ var require_module_details_from_path = __commonJS({
6877
6877
  basedir += segments[i] + sep2;
6878
6878
  }
6879
6879
  }
6880
- var path25 = "";
6880
+ var path27 = "";
6881
6881
  var lastSegmentIndex = segments.length - 1;
6882
6882
  for (var i2 = index + offset; i2 <= lastSegmentIndex; i2++) {
6883
6883
  if (i2 === lastSegmentIndex) {
6884
- path25 += segments[i2];
6884
+ path27 += segments[i2];
6885
6885
  } else {
6886
- path25 += segments[i2] + sep2;
6886
+ path27 += segments[i2] + sep2;
6887
6887
  }
6888
6888
  }
6889
6889
  return {
6890
6890
  name,
6891
6891
  basedir,
6892
- path: path25
6892
+ path: path27
6893
6893
  };
6894
6894
  };
6895
6895
  }
@@ -6899,7 +6899,7 @@ var require_module_details_from_path = __commonJS({
6899
6899
  var require_require_in_the_middle = __commonJS({
6900
6900
  "../../node_modules/.pnpm/require-in-the-middle@8.0.1/node_modules/require-in-the-middle/index.js"(exports, module2) {
6901
6901
  "use strict";
6902
- var path25 = __require("path");
6902
+ var path27 = __require("path");
6903
6903
  var Module = __require("module");
6904
6904
  var debug2 = require_src3()("require-in-the-middle");
6905
6905
  var moduleDetailsFromPath = require_module_details_from_path();
@@ -7044,7 +7044,7 @@ var require_require_in_the_middle = __commonJS({
7044
7044
  }
7045
7045
  moduleName = filename;
7046
7046
  } else if (hasWhitelist === true && modules.includes(filename)) {
7047
- const parsedPath = path25.parse(filename);
7047
+ const parsedPath = path27.parse(filename);
7048
7048
  moduleName = parsedPath.name;
7049
7049
  basedir = parsedPath.dir;
7050
7050
  } else {
@@ -7082,7 +7082,7 @@ var require_require_in_the_middle = __commonJS({
7082
7082
  }
7083
7083
  if (res !== filename) {
7084
7084
  if (internals === true) {
7085
- moduleName = moduleName + path25.sep + path25.relative(basedir, filename);
7085
+ moduleName = moduleName + path27.sep + path27.relative(basedir, filename);
7086
7086
  debug2("preparing to process require of internal file: %s", moduleName);
7087
7087
  } else {
7088
7088
  debug2("ignoring require of non-main module file: %s", res);
@@ -7118,8 +7118,8 @@ var require_require_in_the_middle = __commonJS({
7118
7118
  }
7119
7119
  };
7120
7120
  function resolveModuleName(stat) {
7121
- const normalizedPath = path25.sep !== "/" ? stat.path.split(path25.sep).join("/") : stat.path;
7122
- return path25.posix.join(stat.name, normalizedPath).replace(normalize3, "");
7121
+ const normalizedPath = path27.sep !== "/" ? stat.path.split(path27.sep).join("/") : stat.path;
7122
+ return path27.posix.join(stat.name, normalizedPath).replace(normalize3, "");
7123
7123
  }
7124
7124
  }
7125
7125
  });
@@ -7204,7 +7204,7 @@ var require_RequireInTheMiddleSingleton = __commonJS({
7204
7204
  Object.defineProperty(exports, "__esModule", { value: true });
7205
7205
  exports.RequireInTheMiddleSingleton = void 0;
7206
7206
  var require_in_the_middle_1 = require_require_in_the_middle();
7207
- var path25 = __require("path");
7207
+ var path27 = __require("path");
7208
7208
  var ModuleNameTrie_1 = require_ModuleNameTrie();
7209
7209
  var isMocha = [
7210
7210
  "afterEach",
@@ -7268,7 +7268,7 @@ var require_RequireInTheMiddleSingleton = __commonJS({
7268
7268
  };
7269
7269
  exports.RequireInTheMiddleSingleton = RequireInTheMiddleSingleton;
7270
7270
  function normalizePathSeparators(moduleNameOrPath) {
7271
- return path25.sep !== ModuleNameTrie_1.ModuleNameSeparator ? moduleNameOrPath.split(path25.sep).join(ModuleNameTrie_1.ModuleNameSeparator) : moduleNameOrPath;
7271
+ return path27.sep !== ModuleNameTrie_1.ModuleNameSeparator ? moduleNameOrPath.split(path27.sep).join(ModuleNameTrie_1.ModuleNameSeparator) : moduleNameOrPath;
7272
7272
  }
7273
7273
  }
7274
7274
  });
@@ -7434,7 +7434,7 @@ var require_register = __commonJS({
7434
7434
  // ../../node_modules/.pnpm/import-in-the-middle@3.4.0/node_modules/import-in-the-middle/index.js
7435
7435
  var require_import_in_the_middle = __commonJS({
7436
7436
  "../../node_modules/.pnpm/import-in-the-middle@3.4.0/node_modules/import-in-the-middle/index.js"(exports, module2) {
7437
- var path25 = __require("path");
7437
+ var path27 = __require("path");
7438
7438
  var moduleDetailsFromPath = require_module_details_from_path();
7439
7439
  var { fileURLToPath: fileURLToPath3 } = __require("url");
7440
7440
  var { MessageChannel } = __require("worker_threads");
@@ -7553,7 +7553,7 @@ var require_import_in_the_middle = __commonJS({
7553
7553
  } else if (baseDir.endsWith(specifiers.get(loadUrl)) || isTurbopackSpecifier(specifiers.get(loadUrl), baseDir)) {
7554
7554
  callHookFn(hookFn, namespace, name, baseDir);
7555
7555
  } else if (internals) {
7556
- const internalPath = name + path25.sep + path25.relative(baseDir, filePath);
7556
+ const internalPath = name + path27.sep + path27.relative(baseDir, filePath);
7557
7557
  callHookFn(hookFn, namespace, internalPath, baseDir);
7558
7558
  }
7559
7559
  } else if (matchArg === specifier) {
@@ -7628,7 +7628,7 @@ var require_instrumentation2 = __commonJS({
7628
7628
  "use strict";
7629
7629
  Object.defineProperty(exports, "__esModule", { value: true });
7630
7630
  exports.InstrumentationBase = void 0;
7631
- var path25 = __require("path");
7631
+ var path27 = __require("path");
7632
7632
  var util_1 = __require("util");
7633
7633
  var semver_1 = require_semver();
7634
7634
  var shimmer_1 = require_shimmer();
@@ -7729,7 +7729,7 @@ var require_instrumentation2 = __commonJS({
7729
7729
  }
7730
7730
  _extractPackageVersion(baseDir) {
7731
7731
  try {
7732
- const json2 = (0, fs_1.readFileSync)(path25.join(baseDir, "package.json"), {
7732
+ const json2 = (0, fs_1.readFileSync)(path27.join(baseDir, "package.json"), {
7733
7733
  encoding: "utf8"
7734
7734
  });
7735
7735
  const version2 = JSON.parse(json2).version;
@@ -7771,7 +7771,7 @@ var require_instrumentation2 = __commonJS({
7771
7771
  return exports2;
7772
7772
  }
7773
7773
  const files = module3.files ?? [];
7774
- const normalizedName = path25.normalize(name);
7774
+ const normalizedName = path27.normalize(name);
7775
7775
  const supportedFileInstrumentations = files.filter((f) => f.name === normalizedName && isSupported(f.supportedVersions, version2, module3.includePrerelease));
7776
7776
  return supportedFileInstrumentations.reduce((patchedExports, file2) => {
7777
7777
  file2.moduleExports = patchedExports;
@@ -7817,8 +7817,8 @@ var require_instrumentation2 = __commonJS({
7817
7817
  this._warnOnPreloadedModules();
7818
7818
  for (const module3 of this._modules) {
7819
7819
  const hookFn = (exports2, name, baseDir) => {
7820
- if (!baseDir && path25.isAbsolute(name)) {
7821
- const parsedPath = path25.parse(name);
7820
+ if (!baseDir && path27.isAbsolute(name)) {
7821
+ const parsedPath = path27.parse(name);
7822
7822
  name = parsedPath.name;
7823
7823
  baseDir = parsedPath.dir;
7824
7824
  }
@@ -7827,7 +7827,7 @@ var require_instrumentation2 = __commonJS({
7827
7827
  const onRequire = (exports2, name, baseDir) => {
7828
7828
  return this._onRequire(module3, exports2, name, baseDir);
7829
7829
  };
7830
- const hook = path25.isAbsolute(module3.name) ? new require_in_the_middle_1.Hook([module3.name], { internals: true }, onRequire) : this._requireInTheMiddleSingleton.register(module3.name, onRequire);
7830
+ const hook = path27.isAbsolute(module3.name) ? new require_in_the_middle_1.Hook([module3.name], { internals: true }, onRequire) : this._requireInTheMiddleSingleton.register(module3.name, onRequire);
7831
7831
  this._hooks.push(hook);
7832
7832
  const esmHook = new import_in_the_middle_1.Hook([module3.name], { internals: true }, hookFn);
7833
7833
  this._hooks.push(esmHook);
@@ -8435,9 +8435,9 @@ var require_getMachineId_linux = __commonJS({
8435
8435
  var api_1 = (init_esm(), __toCommonJS(esm_exports));
8436
8436
  async function getMachineId() {
8437
8437
  const paths = ["/etc/machine-id", "/var/lib/dbus/machine-id"];
8438
- for (const path25 of paths) {
8438
+ for (const path27 of paths) {
8439
8439
  try {
8440
- const result = await fs_1.promises.readFile(path25, { encoding: "utf8" });
8440
+ const result = await fs_1.promises.readFile(path27, { encoding: "utf8" });
8441
8441
  return result.trim();
8442
8442
  } catch (e) {
8443
8443
  api_1.diag.debug(`error reading machine id: ${e}`);
@@ -8643,7 +8643,7 @@ var require_ProcessDetector = __commonJS({
8643
8643
  exports.processDetector = void 0;
8644
8644
  var api_1 = (init_esm(), __toCommonJS(esm_exports));
8645
8645
  var semconv_1 = require_semconv2();
8646
- var os19 = __require("os");
8646
+ var os21 = __require("os");
8647
8647
  var ProcessDetector = class {
8648
8648
  detect(_config) {
8649
8649
  const attributes = {
@@ -8663,7 +8663,7 @@ var require_ProcessDetector = __commonJS({
8663
8663
  attributes[semconv_1.ATTR_PROCESS_COMMAND] = process.argv[1];
8664
8664
  }
8665
8665
  try {
8666
- const userInfo = os19.userInfo();
8666
+ const userInfo = os21.userInfo();
8667
8667
  attributes[semconv_1.ATTR_PROCESS_OWNER] = userInfo.username;
8668
8668
  } catch (e) {
8669
8669
  api_1.diag.debug(`error obtaining process owner: ${e}`);
@@ -11797,14 +11797,14 @@ var require_util = __commonJS({
11797
11797
  }
11798
11798
  const port = url2.port != null ? url2.port : url2.protocol === "https:" ? 443 : 80;
11799
11799
  let origin = url2.origin != null ? url2.origin : `${url2.protocol || ""}//${url2.hostname || ""}:${port}`;
11800
- let path25 = url2.path != null ? url2.path : `${url2.pathname || ""}${url2.search || ""}`;
11800
+ let path27 = url2.path != null ? url2.path : `${url2.pathname || ""}${url2.search || ""}`;
11801
11801
  if (origin[origin.length - 1] === "/") {
11802
11802
  origin = origin.slice(0, origin.length - 1);
11803
11803
  }
11804
- if (path25 && path25[0] !== "/") {
11805
- path25 = `/${path25}`;
11804
+ if (path27 && path27[0] !== "/") {
11805
+ path27 = `/${path27}`;
11806
11806
  }
11807
- return new URL(`${origin}${path25}`);
11807
+ return new URL(`${origin}${path27}`);
11808
11808
  }
11809
11809
  if (!isHttpOrHttpsPrefixed(url2.origin || url2.protocol)) {
11810
11810
  throw new InvalidArgumentError("Invalid URL protocol: the URL must start with `http:` or `https:`.");
@@ -12625,9 +12625,9 @@ var require_diagnostics = __commonJS({
12625
12625
  "undici:client:sendHeaders",
12626
12626
  (evt) => {
12627
12627
  const {
12628
- request: { method, path: path25, origin }
12628
+ request: { method, path: path27, origin }
12629
12629
  } = evt;
12630
- debugLog3("sending request to %s %s%s", method, origin, path25);
12630
+ debugLog3("sending request to %s %s%s", method, origin, path27);
12631
12631
  }
12632
12632
  );
12633
12633
  }
@@ -12645,14 +12645,14 @@ var require_diagnostics = __commonJS({
12645
12645
  "undici:request:headers",
12646
12646
  (evt) => {
12647
12647
  const {
12648
- request: { method, path: path25, origin },
12648
+ request: { method, path: path27, origin },
12649
12649
  response: { statusCode }
12650
12650
  } = evt;
12651
12651
  debugLog3(
12652
12652
  "received response to %s %s%s - HTTP %d",
12653
12653
  method,
12654
12654
  origin,
12655
- path25,
12655
+ path27,
12656
12656
  statusCode
12657
12657
  );
12658
12658
  }
@@ -12661,23 +12661,23 @@ var require_diagnostics = __commonJS({
12661
12661
  "undici:request:trailers",
12662
12662
  (evt) => {
12663
12663
  const {
12664
- request: { method, path: path25, origin }
12664
+ request: { method, path: path27, origin }
12665
12665
  } = evt;
12666
- debugLog3("trailers received from %s %s%s", method, origin, path25);
12666
+ debugLog3("trailers received from %s %s%s", method, origin, path27);
12667
12667
  }
12668
12668
  );
12669
12669
  diagnosticsChannel9.subscribe(
12670
12670
  "undici:request:error",
12671
12671
  (evt) => {
12672
12672
  const {
12673
- request: { method, path: path25, origin },
12673
+ request: { method, path: path27, origin },
12674
12674
  error: error62
12675
12675
  } = evt;
12676
12676
  debugLog3(
12677
12677
  "request to %s %s%s errored - %s",
12678
12678
  method,
12679
12679
  origin,
12680
- path25,
12680
+ path27,
12681
12681
  error62.message
12682
12682
  );
12683
12683
  }
@@ -12792,7 +12792,7 @@ var require_request = __commonJS({
12792
12792
  var kHandler = /* @__PURE__ */ Symbol("handler");
12793
12793
  var Request2 = class {
12794
12794
  constructor(origin, {
12795
- path: path25,
12795
+ path: path27,
12796
12796
  method,
12797
12797
  body,
12798
12798
  headers,
@@ -12809,11 +12809,11 @@ var require_request = __commonJS({
12809
12809
  maxRedirections,
12810
12810
  typeOfService
12811
12811
  }, handler) {
12812
- if (typeof path25 !== "string") {
12812
+ if (typeof path27 !== "string") {
12813
12813
  throw new InvalidArgumentError("path must be a string");
12814
- } else if (path25[0] !== "/" && !(path25.startsWith("http://") || path25.startsWith("https://")) && method !== "CONNECT") {
12814
+ } else if (path27[0] !== "/" && !(path27.startsWith("http://") || path27.startsWith("https://")) && method !== "CONNECT") {
12815
12815
  throw new InvalidArgumentError("path must be an absolute URL or start with a slash");
12816
- } else if (invalidPathRegex.test(path25)) {
12816
+ } else if (invalidPathRegex.test(path27)) {
12817
12817
  throw new InvalidArgumentError("invalid request path");
12818
12818
  }
12819
12819
  if (typeof method !== "string") {
@@ -12888,7 +12888,7 @@ var require_request = __commonJS({
12888
12888
  this.completed = false;
12889
12889
  this.aborted = false;
12890
12890
  this.upgrade = upgrade || null;
12891
- this.path = query ? serializePathWithQuery(path25, query) : path25;
12891
+ this.path = query ? serializePathWithQuery(path27, query) : path27;
12892
12892
  this.origin = origin;
12893
12893
  this.protocol = getProtocolFromUrlString(origin);
12894
12894
  this.idempotent = idempotent == null ? method === "HEAD" || method === "GET" : idempotent;
@@ -18070,7 +18070,7 @@ var require_client_h1 = __commonJS({
18070
18070
  return method !== "GET" && method !== "HEAD" && method !== "OPTIONS" && method !== "TRACE" && method !== "CONNECT";
18071
18071
  }
18072
18072
  function writeH1(client, request2) {
18073
- const { method, path: path25, host, upgrade, blocking, reset } = request2;
18073
+ const { method, path: path27, host, upgrade, blocking, reset } = request2;
18074
18074
  let { body, headers, contentLength } = request2;
18075
18075
  const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH" || method === "QUERY" || method === "PROPFIND" || method === "PROPPATCH";
18076
18076
  if (util2.isFormDataLike(body)) {
@@ -18148,7 +18148,7 @@ var require_client_h1 = __commonJS({
18148
18148
  if (socket.setTypeOfService) {
18149
18149
  socket.setTypeOfService(request2.typeOfService);
18150
18150
  }
18151
- let header = `${method} ${path25} HTTP/1.1\r
18151
+ let header = `${method} ${path27} HTTP/1.1\r
18152
18152
  `;
18153
18153
  if (typeof host === "string") {
18154
18154
  header += `host: ${host}\r
@@ -18827,7 +18827,7 @@ var require_client_h2 = __commonJS({
18827
18827
  const headersTimeout = request2.headersTimeout ?? client[kHeadersTimeout];
18828
18828
  const bodyTimeout = request2.bodyTimeout ?? client[kBodyTimeout];
18829
18829
  const session = client[kHTTP2Session];
18830
- const { method, path: path25, host, upgrade, expectContinue, signal, protocol, headers: reqHeaders } = request2;
18830
+ const { method, path: path27, host, upgrade, expectContinue, signal, protocol, headers: reqHeaders } = request2;
18831
18831
  let { body } = request2;
18832
18832
  if (upgrade != null && upgrade !== "websocket") {
18833
18833
  util2.errorRequest(client, request2, new InvalidArgumentError(`Custom upgrade "${upgrade}" not supported over HTTP/2`));
@@ -18896,7 +18896,7 @@ var require_client_h2 = __commonJS({
18896
18896
  }
18897
18897
  headers[HTTP2_HEADER_METHOD] = "CONNECT";
18898
18898
  headers[HTTP2_HEADER_PROTOCOL] = "websocket";
18899
- headers[HTTP2_HEADER_PATH] = path25;
18899
+ headers[HTTP2_HEADER_PATH] = path27;
18900
18900
  if (protocol === "ws:" || protocol === "wss:") {
18901
18901
  headers[HTTP2_HEADER_SCHEME] = protocol === "ws:" ? "http" : "https";
18902
18902
  } else {
@@ -18938,7 +18938,7 @@ var require_client_h2 = __commonJS({
18938
18938
  stream.setTimeout(headersTimeout);
18939
18939
  return true;
18940
18940
  }
18941
- headers[HTTP2_HEADER_PATH] = path25;
18941
+ headers[HTTP2_HEADER_PATH] = path27;
18942
18942
  headers[HTTP2_HEADER_SCHEME] = protocol === "http:" ? "http" : "https";
18943
18943
  const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH";
18944
18944
  if (body && typeof body.read === "function") {
@@ -21290,10 +21290,10 @@ var require_proxy_agent = __commonJS({
21290
21290
  };
21291
21291
  const {
21292
21292
  origin,
21293
- path: path25 = "/",
21293
+ path: path27 = "/",
21294
21294
  headers = {}
21295
21295
  } = opts;
21296
- opts.path = origin + path25;
21296
+ opts.path = origin + path27;
21297
21297
  if (!("host" in headers) && !("Host" in headers)) {
21298
21298
  const { host } = new URL(origin);
21299
21299
  headers.host = host;
@@ -23402,20 +23402,20 @@ var require_mock_utils = __commonJS({
23402
23402
  }
23403
23403
  return normalizedQp;
23404
23404
  }
23405
- function safeUrl(path25) {
23406
- if (typeof path25 !== "string") {
23407
- return path25;
23405
+ function safeUrl(path27) {
23406
+ if (typeof path27 !== "string") {
23407
+ return path27;
23408
23408
  }
23409
- const pathSegments = path25.split("?", 3);
23409
+ const pathSegments = path27.split("?", 3);
23410
23410
  if (pathSegments.length !== 2) {
23411
- return path25;
23411
+ return path27;
23412
23412
  }
23413
23413
  const qp = new URLSearchParams(pathSegments.pop());
23414
23414
  qp.sort();
23415
23415
  return [...pathSegments, qp.toString()].join("?");
23416
23416
  }
23417
- function matchKey(mockDispatch2, { path: path25, method, body, headers }) {
23418
- const pathMatch = matchValue(mockDispatch2.path, path25);
23417
+ function matchKey(mockDispatch2, { path: path27, method, body, headers }) {
23418
+ const pathMatch = matchValue(mockDispatch2.path, path27);
23419
23419
  const methodMatch = matchValue(mockDispatch2.method, method);
23420
23420
  const bodyMatch = typeof mockDispatch2.body !== "undefined" ? matchValue(mockDispatch2.body, body) : true;
23421
23421
  const headersMatch = matchHeaders(mockDispatch2, headers);
@@ -23440,8 +23440,8 @@ var require_mock_utils = __commonJS({
23440
23440
  const basePath = key.query ? serializePathWithQuery(key.path, key.query) : key.path;
23441
23441
  const resolvedPath = typeof basePath === "string" ? safeUrl(basePath) : basePath;
23442
23442
  const resolvedPathWithoutTrailingSlash = removeTrailingSlash(resolvedPath);
23443
- let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path: path25, ignoreTrailingSlash }) => {
23444
- return ignoreTrailingSlash ? matchValue(removeTrailingSlash(safeUrl(path25)), resolvedPathWithoutTrailingSlash) : matchValue(safeUrl(path25), resolvedPath);
23443
+ let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path: path27, ignoreTrailingSlash }) => {
23444
+ return ignoreTrailingSlash ? matchValue(removeTrailingSlash(safeUrl(path27)), resolvedPathWithoutTrailingSlash) : matchValue(safeUrl(path27), resolvedPath);
23445
23445
  });
23446
23446
  if (matchedMockDispatches.length === 0) {
23447
23447
  throw new MockNotMatchedError(`Mock dispatch not matched for path '${resolvedPath}'`);
@@ -23480,19 +23480,19 @@ var require_mock_utils = __commonJS({
23480
23480
  mockDispatches.splice(index, 1);
23481
23481
  }
23482
23482
  }
23483
- function removeTrailingSlash(path25) {
23484
- while (path25.endsWith("/")) {
23485
- path25 = path25.slice(0, -1);
23483
+ function removeTrailingSlash(path27) {
23484
+ while (path27.endsWith("/")) {
23485
+ path27 = path27.slice(0, -1);
23486
23486
  }
23487
- if (path25.length === 0) {
23488
- path25 = "/";
23487
+ if (path27.length === 0) {
23488
+ path27 = "/";
23489
23489
  }
23490
- return path25;
23490
+ return path27;
23491
23491
  }
23492
23492
  function buildKey(opts) {
23493
- const { path: path25, method, body, headers, query } = opts;
23493
+ const { path: path27, method, body, headers, query } = opts;
23494
23494
  return {
23495
- path: path25,
23495
+ path: path27,
23496
23496
  method,
23497
23497
  body,
23498
23498
  headers,
@@ -24182,10 +24182,10 @@ var require_pending_interceptors_formatter = __commonJS({
24182
24182
  }
24183
24183
  format(pendingInterceptors) {
24184
24184
  const withPrettyHeaders = pendingInterceptors.map(
24185
- ({ method, path: path25, data: { statusCode }, persist, times, timesInvoked, origin }) => ({
24185
+ ({ method, path: path27, data: { statusCode }, persist, times, timesInvoked, origin }) => ({
24186
24186
  Method: method,
24187
24187
  Origin: origin,
24188
- Path: path25,
24188
+ Path: path27,
24189
24189
  "Status code": statusCode,
24190
24190
  Persistent: persist ? PERSISTENT : NOT_PERSISTENT,
24191
24191
  Invocations: timesInvoked,
@@ -24267,9 +24267,9 @@ var require_mock_agent = __commonJS({
24267
24267
  const acceptNonStandardSearchParameters = this[kMockAgentAcceptsNonStandardSearchParameters];
24268
24268
  const dispatchOpts = { ...opts };
24269
24269
  if (acceptNonStandardSearchParameters && dispatchOpts.path) {
24270
- const [path25, searchParams] = dispatchOpts.path.split("?");
24270
+ const [path27, searchParams] = dispatchOpts.path.split("?");
24271
24271
  const normalizedSearchParams = normalizeSearchParams(searchParams, acceptNonStandardSearchParameters);
24272
- dispatchOpts.path = `${path25}?${normalizedSearchParams}`;
24272
+ dispatchOpts.path = `${path27}?${normalizedSearchParams}`;
24273
24273
  }
24274
24274
  return this[kAgent].dispatch(dispatchOpts, handler);
24275
24275
  }
@@ -24670,12 +24670,12 @@ var require_snapshot_recorder = __commonJS({
24670
24670
  * @return {Promise<void>} - Resolves when snapshots are loaded
24671
24671
  */
24672
24672
  async loadSnapshots(filePath) {
24673
- const path25 = filePath || this.#snapshotPath;
24674
- if (!path25) {
24673
+ const path27 = filePath || this.#snapshotPath;
24674
+ if (!path27) {
24675
24675
  throw new InvalidArgumentError("Snapshot path is required");
24676
24676
  }
24677
24677
  try {
24678
- const data = await readFile3(resolve2(path25), "utf8");
24678
+ const data = await readFile3(resolve2(path27), "utf8");
24679
24679
  const parsed = JSON.parse(data);
24680
24680
  if (Array.isArray(parsed)) {
24681
24681
  this.#snapshots.clear();
@@ -24689,7 +24689,7 @@ var require_snapshot_recorder = __commonJS({
24689
24689
  if (error62.code === "ENOENT") {
24690
24690
  this.#snapshots.clear();
24691
24691
  } else {
24692
- throw new UndiciError(`Failed to load snapshots from ${path25}`, { cause: error62 });
24692
+ throw new UndiciError(`Failed to load snapshots from ${path27}`, { cause: error62 });
24693
24693
  }
24694
24694
  }
24695
24695
  }
@@ -24700,11 +24700,11 @@ var require_snapshot_recorder = __commonJS({
24700
24700
  * @returns {Promise<void>} - Resolves when snapshots are saved
24701
24701
  */
24702
24702
  async saveSnapshots(filePath) {
24703
- const path25 = filePath || this.#snapshotPath;
24704
- if (!path25) {
24703
+ const path27 = filePath || this.#snapshotPath;
24704
+ if (!path27) {
24705
24705
  throw new InvalidArgumentError("Snapshot path is required");
24706
24706
  }
24707
- const resolvedPath = resolve2(path25);
24707
+ const resolvedPath = resolve2(path27);
24708
24708
  await mkdir(dirname2(resolvedPath), { recursive: true });
24709
24709
  const data = Array.from(this.#snapshots.entries()).map(([hash2, snapshot]) => ({
24710
24710
  hash: hash2,
@@ -25336,15 +25336,15 @@ var require_redirect_handler = __commonJS({
25336
25336
  return;
25337
25337
  }
25338
25338
  const { origin, pathname, search } = util2.parseURL(new URL(this.location, this.opts.origin && new URL(this.opts.path, this.opts.origin)));
25339
- const path25 = search ? `${pathname}${search}` : pathname;
25340
- const redirectUrlString = `${origin}${path25}`;
25339
+ const path27 = search ? `${pathname}${search}` : pathname;
25340
+ const redirectUrlString = `${origin}${path27}`;
25341
25341
  for (const historyUrl of this.history) {
25342
25342
  if (historyUrl.toString() === redirectUrlString) {
25343
25343
  throw new InvalidArgumentError(`Redirect loop detected. Cannot redirect to ${origin}. This typically happens when using a Client or Pool with cross-origin redirects. Use an Agent for cross-origin redirects.`);
25344
25344
  }
25345
25345
  }
25346
25346
  this.opts.headers = cleanRequestHeaders(this.opts.headers, statusCode === 303, this.opts.origin !== origin);
25347
- this.opts.path = path25;
25347
+ this.opts.path = path27;
25348
25348
  this.opts.origin = origin;
25349
25349
  this.opts.query = null;
25350
25350
  }
@@ -27104,10 +27104,10 @@ var require_cache_handler = __commonJS({
27104
27104
  }
27105
27105
  return locationUrl.pathname + locationUrl.search;
27106
27106
  }
27107
- function deleteCachedUri(store, cacheKey, path25) {
27107
+ function deleteCachedUri(store, cacheKey, path27) {
27108
27108
  deleteCachedValue(store, {
27109
27109
  ...cacheKey,
27110
- path: path25
27110
+ path: path27
27111
27111
  });
27112
27112
  for (let i = 0; i < util2.safeHTTPMethods.length; i++) {
27113
27113
  const method = util2.safeHTTPMethods[i];
@@ -27115,7 +27115,7 @@ var require_cache_handler = __commonJS({
27115
27115
  deleteCachedValue(store, {
27116
27116
  ...cacheKey,
27117
27117
  method,
27118
- path: path25
27118
+ path: path27
27119
27119
  });
27120
27120
  }
27121
27121
  }
@@ -27126,9 +27126,9 @@ var require_cache_handler = __commonJS({
27126
27126
  }
27127
27127
  const values = Array.isArray(headerValue) ? headerValue : [headerValue];
27128
27128
  for (let i = 0; i < values.length; i++) {
27129
- const path25 = getSameOriginPath(cacheKey, values[i]);
27130
- if (path25 !== void 0) {
27131
- deleteCachedUri(store, cacheKey, path25);
27129
+ const path27 = getSameOriginPath(cacheKey, values[i]);
27130
+ if (path27 !== void 0) {
27131
+ deleteCachedUri(store, cacheKey, path27);
27132
27132
  }
27133
27133
  }
27134
27134
  }
@@ -32128,11 +32128,11 @@ var require_fetch = __commonJS({
32128
32128
  function dispatch({ body }) {
32129
32129
  const url2 = requestCurrentURL(request2);
32130
32130
  const agent = fetchParams.controller.dispatcher;
32131
- const path25 = url2.pathname + url2.search;
32131
+ const path27 = url2.pathname + url2.search;
32132
32132
  const hasTrailingQuestionMark = url2.search.length === 0 && url2.href[url2.href.length - url2.hash.length - 1] === "?";
32133
32133
  return new Promise((resolve2, reject) => agent.dispatch(
32134
32134
  {
32135
- path: hasTrailingQuestionMark ? `${path25}?` : path25,
32135
+ path: hasTrailingQuestionMark ? `${path27}?` : path27,
32136
32136
  origin: url2.origin,
32137
32137
  method: request2.method,
32138
32138
  body: agent.isMockActive ? request2.body && (request2.body.source || request2.body.stream) : body,
@@ -33079,9 +33079,9 @@ var require_util4 = __commonJS({
33079
33079
  }
33080
33080
  }
33081
33081
  }
33082
- function validateCookiePath(path25) {
33083
- for (let i = 0; i < path25.length; ++i) {
33084
- const code = path25.charCodeAt(i);
33082
+ function validateCookiePath(path27) {
33083
+ for (let i = 0; i < path27.length; ++i) {
33084
+ const code = path27.charCodeAt(i);
33085
33085
  if (code < 32 || // exclude CTLs (0-31)
33086
33086
  code > 126 || // exclude DEL and non-ascii
33087
33087
  code === 59) {
@@ -36429,11 +36429,11 @@ var require_undici = __commonJS({
36429
36429
  if (typeof opts.path !== "string") {
36430
36430
  throw new InvalidArgumentError("invalid opts.path");
36431
36431
  }
36432
- let path25 = opts.path;
36432
+ let path27 = opts.path;
36433
36433
  if (!opts.path.startsWith("/")) {
36434
- path25 = `/${path25}`;
36434
+ path27 = `/${path27}`;
36435
36435
  }
36436
- url2 = new URL(util2.parseOrigin(url2).origin + path25);
36436
+ url2 = new URL(util2.parseOrigin(url2).origin + path27);
36437
36437
  } else {
36438
36438
  if (!opts) {
36439
36439
  opts = typeof url2 === "object" ? url2 : {};
@@ -36543,9 +36543,9 @@ ${captureLines}` : capture.stack;
36543
36543
  });
36544
36544
 
36545
36545
  // src/cli.ts
36546
- import { spawn as spawn2, spawnSync as spawnSync4 } from "node:child_process";
36547
- import { existsSync as existsSync10, mkdirSync as mkdirSync10, openSync as openSync5, realpathSync as realpathSync4, rmSync as rmSync5 } from "node:fs";
36548
- import path24 from "node:path";
36546
+ import { spawn as spawn2, spawnSync as spawnSync5 } from "node:child_process";
36547
+ import { existsSync as existsSync12, mkdirSync as mkdirSync11, openSync as openSync5, realpathSync as realpathSync4, rmSync as rmSync6 } from "node:fs";
36548
+ import path26 from "node:path";
36549
36549
  import { parseArgs } from "node:util";
36550
36550
 
36551
36551
  // ../../apps/collector/src/credentials.ts
@@ -37298,10 +37298,10 @@ function mergeDefs(...defs) {
37298
37298
  function cloneDef(schema) {
37299
37299
  return mergeDefs(schema._zod.def);
37300
37300
  }
37301
- function getElementAtPath(obj, path25) {
37302
- if (!path25)
37301
+ function getElementAtPath(obj, path27) {
37302
+ if (!path27)
37303
37303
  return obj;
37304
- return path25.reduce((acc, key) => acc?.[key], obj);
37304
+ return path27.reduce((acc, key) => acc?.[key], obj);
37305
37305
  }
37306
37306
  function promiseAllObject(promisesObj) {
37307
37307
  const keys = Object.keys(promisesObj);
@@ -37713,11 +37713,11 @@ function explicitlyAborted(x, startIndex = 0) {
37713
37713
  }
37714
37714
  return false;
37715
37715
  }
37716
- function prefixIssues(path25, issues) {
37716
+ function prefixIssues(path27, issues) {
37717
37717
  return issues.map((iss) => {
37718
37718
  var _a4;
37719
37719
  (_a4 = iss).path ?? (_a4.path = []);
37720
- iss.path.unshift(path25);
37720
+ iss.path.unshift(path27);
37721
37721
  return iss;
37722
37722
  });
37723
37723
  }
@@ -38150,16 +38150,16 @@ function flattenError(error62, mapper = (issue2) => issue2.message) {
38150
38150
  }
38151
38151
  function formatError(error62, mapper = (issue2) => issue2.message) {
38152
38152
  const fieldErrors = { _errors: [] };
38153
- const processError = (error63, path25 = []) => {
38153
+ const processError = (error63, path27 = []) => {
38154
38154
  for (const issue2 of error63.issues) {
38155
38155
  if (issue2.code === "invalid_union" && issue2.errors.length) {
38156
- issue2.errors.map((issues) => processError({ issues }, [...path25, ...issue2.path]));
38156
+ issue2.errors.map((issues) => processError({ issues }, [...path27, ...issue2.path]));
38157
38157
  } else if (issue2.code === "invalid_key") {
38158
- processError({ issues: issue2.issues }, [...path25, ...issue2.path]);
38158
+ processError({ issues: issue2.issues }, [...path27, ...issue2.path]);
38159
38159
  } else if (issue2.code === "invalid_element") {
38160
- processError({ issues: issue2.issues }, [...path25, ...issue2.path]);
38160
+ processError({ issues: issue2.issues }, [...path27, ...issue2.path]);
38161
38161
  } else {
38162
- const fullpath = [...path25, ...issue2.path];
38162
+ const fullpath = [...path27, ...issue2.path];
38163
38163
  if (fullpath.length === 0) {
38164
38164
  fieldErrors._errors.push(mapper(issue2));
38165
38165
  } else {
@@ -38198,17 +38198,17 @@ function formatError(error62, mapper = (issue2) => issue2.message) {
38198
38198
  }
38199
38199
  function treeifyError(error62, mapper = (issue2) => issue2.message) {
38200
38200
  const result = { errors: [] };
38201
- const processError = (error63, path25 = []) => {
38201
+ const processError = (error63, path27 = []) => {
38202
38202
  var _a4;
38203
38203
  for (const issue2 of error63.issues) {
38204
38204
  if (issue2.code === "invalid_union" && issue2.errors.length) {
38205
- issue2.errors.map((issues) => processError({ issues }, [...path25, ...issue2.path]));
38205
+ issue2.errors.map((issues) => processError({ issues }, [...path27, ...issue2.path]));
38206
38206
  } else if (issue2.code === "invalid_key") {
38207
- processError({ issues: issue2.issues }, [...path25, ...issue2.path]);
38207
+ processError({ issues: issue2.issues }, [...path27, ...issue2.path]);
38208
38208
  } else if (issue2.code === "invalid_element") {
38209
- processError({ issues: issue2.issues }, [...path25, ...issue2.path]);
38209
+ processError({ issues: issue2.issues }, [...path27, ...issue2.path]);
38210
38210
  } else {
38211
- const fullpath = [...path25, ...issue2.path];
38211
+ const fullpath = [...path27, ...issue2.path];
38212
38212
  if (fullpath.length === 0) {
38213
38213
  result.errors.push(mapper(issue2));
38214
38214
  continue;
@@ -38247,8 +38247,8 @@ function treeifyError(error62, mapper = (issue2) => issue2.message) {
38247
38247
  }
38248
38248
  function toDotPath(_path) {
38249
38249
  const segs = [];
38250
- const path25 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
38251
- for (const seg of path25) {
38250
+ const path27 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
38251
+ for (const seg of path27) {
38252
38252
  if (typeof seg === "number")
38253
38253
  segs.push(`[${seg}]`);
38254
38254
  else if (typeof seg === "symbol")
@@ -54758,13 +54758,13 @@ function resolveRef(ref, ctx) {
54758
54758
  if (!ref.startsWith("#")) {
54759
54759
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
54760
54760
  }
54761
- const path25 = ref.slice(1).split("/").filter(Boolean);
54762
- if (path25.length === 0) {
54761
+ const path27 = ref.slice(1).split("/").filter(Boolean);
54762
+ if (path27.length === 0) {
54763
54763
  return ctx.rootSchema;
54764
54764
  }
54765
54765
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
54766
- if (path25[0] === defsKey) {
54767
- const key = path25[1] === void 0 ? void 0 : decodeJSONPointerSegment(path25[1]);
54766
+ if (path27[0] === defsKey) {
54767
+ const key = path27[1] === void 0 ? void 0 : decodeJSONPointerSegment(path27[1]);
54768
54768
  if (!key || !ctx.defs[key]) {
54769
54769
  throw new Error(`Reference not found: ${ref}`);
54770
54770
  }
@@ -56053,8 +56053,8 @@ function primaryArg(args) {
56053
56053
  function readFilePath(name, primary) {
56054
56054
  if (!primary || !READ_TOOLS.has(name)) return null;
56055
56055
  if (ARTIFACT_PATH_RE.test(primary)) return null;
56056
- const path25 = primary.startsWith("/workspace/") ? primary.slice("/workspace/".length) : primary;
56057
- return path25.length > 0 ? path25 : null;
56056
+ const path27 = primary.startsWith("/workspace/") ? primary.slice("/workspace/".length) : primary;
56057
+ return path27.length > 0 ? path27 : null;
56058
56058
  }
56059
56059
  function asRecord3(value) {
56060
56060
  return value !== null && typeof value === "object" && !Array.isArray(value) ? value : null;
@@ -56452,6 +56452,42 @@ var collectorDiagnosticSchema = external_exports.strictObject({
56452
56452
  pass: collectorPassDiagnosticSchema.nullable()
56453
56453
  });
56454
56454
 
56455
+ // ../core/src/harnessSessionFacts.ts
56456
+ var trueFlag = external_exports.union([external_exports.literal(true), external_exports.literal(1)]);
56457
+ var HARNESS_SESSION_RULES = {
56458
+ codex: [
56459
+ {
56460
+ fact: "subagent",
56461
+ evidence: external_exports.object({ thread_source: external_exports.enum(["subagent", "guardian_review"]) })
56462
+ },
56463
+ { fact: "subagent", evidence: external_exports.object({ source: external_exports.object({ subagent: external_exports.object({}) }) }) },
56464
+ { fact: "archived", evidence: external_exports.object({ archived: trueFlag }) }
56465
+ ],
56466
+ cursor: [
56467
+ { fact: "subagent", evidence: external_exports.object({ isSubagent: trueFlag }) },
56468
+ { fact: "archived", evidence: external_exports.object({ isArchived: trueFlag }) }
56469
+ ]
56470
+ };
56471
+ function harnessSessionFacts(source, evidence) {
56472
+ const facts = {};
56473
+ for (const rule of Object.hasOwn(HARNESS_SESSION_RULES, source) ? HARNESS_SESSION_RULES[source] ?? [] : []) {
56474
+ if (rule.evidence.safeParse(evidence).success) facts[rule.fact] = true;
56475
+ }
56476
+ return facts;
56477
+ }
56478
+
56479
+ // ../core/src/recentSessionPage.ts
56480
+ var RECENT_SESSION_WINDOW_MS = 72 * 60 * 60 * 1e3;
56481
+ var RECENT_SESSION_VISIBLE_LIMIT = 12;
56482
+ var recentSessionOptionsSchema = external_exports.object({
56483
+ windowHours: external_exports.coerce.number().int().min(1).max(120).default(72),
56484
+ limit: external_exports.coerce.number().int().min(1).max(40).default(12)
56485
+ });
56486
+ var recentSessionCursorSchema = external_exports.object({
56487
+ at: external_exports.iso.datetime({ offset: true }),
56488
+ id: external_exports.uuid()
56489
+ });
56490
+
56455
56491
  // ../../node_modules/.pnpm/@sentry+core@10.73.0/node_modules/@sentry/core/build/esm/debug-build.js
56456
56492
  var DEBUG_BUILD = typeof __SENTRY_DEBUG__ === "undefined" || __SENTRY_DEBUG__;
56457
56493
 
@@ -56632,8 +56668,8 @@ function getFunctionName(fn) {
56632
56668
  return defaultFunctionName;
56633
56669
  }
56634
56670
  }
56635
- function normalizeStackTracePath(path25) {
56636
- let filename = path25?.startsWith("file://") ? path25.slice(7) : path25;
56671
+ function normalizeStackTracePath(path27) {
56672
+ let filename = path27?.startsWith("file://") ? path27.slice(7) : path27;
56637
56673
  if (filename?.match(/\/[A-Z]:/)) {
56638
56674
  filename = filename.slice(1);
56639
56675
  }
@@ -58443,8 +58479,8 @@ function isValidProtocol(protocol) {
58443
58479
  return protocol === "http" || protocol === "https";
58444
58480
  }
58445
58481
  function dsnToString(dsn, withPassword = false) {
58446
- const { host, path: path25, pass, port, projectId, protocol, publicKey } = dsn;
58447
- return `${protocol}://${publicKey}${withPassword && pass ? `:${pass}` : ""}@${host}${port ? `:${port}` : ""}/${path25 ? `${path25}/` : path25}${projectId}`;
58482
+ const { host, path: path27, pass, port, projectId, protocol, publicKey } = dsn;
58483
+ return `${protocol}://${publicKey}${withPassword && pass ? `:${pass}` : ""}@${host}${port ? `:${port}` : ""}/${path27 ? `${path27}/` : path27}${projectId}`;
58448
58484
  }
58449
58485
  function dsnFromString(str) {
58450
58486
  const match = DSN_REGEX.exec(str);
@@ -58455,11 +58491,11 @@ function dsnFromString(str) {
58455
58491
  return void 0;
58456
58492
  }
58457
58493
  const [protocol, publicKey, pass = "", host = "", port = "", lastPath = ""] = match.slice(1);
58458
- let path25 = "";
58494
+ let path27 = "";
58459
58495
  let projectId = lastPath;
58460
58496
  const split = projectId.split("/");
58461
58497
  if (split.length > 1) {
58462
- path25 = split.slice(0, -1).join("/");
58498
+ path27 = split.slice(0, -1).join("/");
58463
58499
  projectId = split.pop();
58464
58500
  }
58465
58501
  if (projectId) {
@@ -58468,7 +58504,7 @@ function dsnFromString(str) {
58468
58504
  projectId = projectMatch[0];
58469
58505
  }
58470
58506
  }
58471
- return dsnFromComponents({ host, pass, path: path25, projectId, port, protocol, publicKey });
58507
+ return dsnFromComponents({ host, pass, path: path27, projectId, port, protocol, publicKey });
58472
58508
  }
58473
58509
  function dsnFromComponents(components) {
58474
58510
  return {
@@ -63002,9 +63038,9 @@ function stripUrlQueryAndFragment(urlPath) {
63002
63038
  return urlPath.split(/[?#]/, 1)[0];
63003
63039
  }
63004
63040
  function getSanitizedUrlString(url2) {
63005
- const { protocol, host, path: path25 } = url2;
63041
+ const { protocol, host, path: path27 } = url2;
63006
63042
  const filteredHost = host?.replace(/^.*@/, "[filtered]:[filtered]@").replace(/(:80)$/, "").replace(/(:443)$/, "") || "";
63007
- return `${protocol ? `${protocol}://` : ""}${filteredHost}${path25}`;
63043
+ return `${protocol ? `${protocol}://` : ""}${filteredHost}${path27}`;
63008
63044
  }
63009
63045
  function stripDataUrlContent(url2, includeDataPrefix = true) {
63010
63046
  if (url2.startsWith("data:")) {
@@ -63947,8 +63983,8 @@ function splitPath(filename) {
63947
63983
  const parts = splitPathRe.exec(truncated);
63948
63984
  return parts ? parts.slice(1) : [];
63949
63985
  }
63950
- function dirname(path25) {
63951
- const result = splitPath(path25);
63986
+ function dirname(path27) {
63987
+ const result = splitPath(path27);
63952
63988
  const root = result[0] || "";
63953
63989
  let dir = result[1];
63954
63990
  if (!root && !dir) {
@@ -67771,15 +67807,15 @@ var getLayerMetadata = (route, layer, layerPath) => {
67771
67807
  };
67772
67808
  }
67773
67809
  };
67774
- var getRouterPath = (path25, layer) => {
67810
+ var getRouterPath = (path27, layer) => {
67775
67811
  const stackLayer = Array.isArray(layer.handle?.stack) ? layer.handle?.stack?.[0] : void 0;
67776
67812
  if (stackLayer?.route?.path) {
67777
- return `${path25}${stackLayer.route.path}`;
67813
+ return `${path27}${stackLayer.route.path}`;
67778
67814
  }
67779
67815
  if (stackLayer && Array.isArray(stackLayer?.handle?.stack)) {
67780
- return getRouterPath(path25, stackLayer);
67816
+ return getRouterPath(path27, stackLayer);
67781
67817
  }
67782
- return path25;
67818
+ return path27;
67783
67819
  };
67784
67820
  var isLayerIgnored = (name, type, config2) => {
67785
67821
  if (Array.isArray(config2?.ignoreLayersType) && config2?.ignoreLayersType?.includes(type)) {
@@ -67799,7 +67835,7 @@ function getActualMatchedRoute(req, constructedRoute) {
67799
67835
  if (layersStore.length === 0) {
67800
67836
  return void 0;
67801
67837
  }
67802
- if (layersStore.every((path25) => path25 === "/")) {
67838
+ if (layersStore.every((path27) => path27 === "/")) {
67803
67839
  return req.originalUrl === "/" ? "/" : void 0;
67804
67840
  }
67805
67841
  if (constructedRoute === "*") {
@@ -67815,11 +67851,11 @@ function getActualMatchedRoute(req, constructedRoute) {
67815
67851
  function getConstructedRoute(req) {
67816
67852
  const layersStore = getStoredLayers(req);
67817
67853
  let constructedRoute = "";
67818
- for (const path25 of layersStore) {
67819
- if (path25 === "/" || path25 === "/*") {
67854
+ for (const path27 of layersStore) {
67855
+ if (path27 === "/" || path27 === "/*") {
67820
67856
  continue;
67821
67857
  }
67822
- constructedRoute += !constructedRoute || constructedRoute.endsWith("/") ? path25 : `/${path25}`;
67858
+ constructedRoute += !constructedRoute || constructedRoute.endsWith("/") ? path27 : `/${path27}`;
67823
67859
  }
67824
67860
  return constructedRoute.replace(/\/{2,}/g, "/");
67825
67861
  }
@@ -68324,9 +68360,9 @@ function getRequestUrlObject(requestOptions) {
68324
68360
  const hostHeader = requestOptions.headers?.host && String(requestOptions.headers?.host);
68325
68361
  const hostname4 = hostHeader || requestOptions.hostname || requestOptions.host || "";
68326
68362
  const port = !requestOptions.port || requestOptions.port === 80 || requestOptions.port === 443 || /^(.*):(\d+)$/.test(hostname4) ? "" : `:${requestOptions.port}`;
68327
- const path25 = requestOptions.path ? requestOptions.path : "/";
68363
+ const path27 = requestOptions.path ? requestOptions.path : "/";
68328
68364
  const base = `${protocol}//${hostname4}${port}`;
68329
- return new URL(path25.startsWith("//") ? `${base}${path25}` : path25, base);
68365
+ return new URL(path27.startsWith("//") ? `${base}${path27}` : path27, base);
68330
68366
  }
68331
68367
  function getRequestUrlFromClientRequest(request2) {
68332
68368
  return String(getRequestUrl(getRequestOptions(request2)));
@@ -68999,11 +69035,11 @@ function shouldIgnoreSpansForIncomingRequest(request2, {
68999
69035
  return false;
69000
69036
  }
69001
69037
  function isStaticAssetRequest(urlPath) {
69002
- const path25 = stripUrlQueryAndFragment(urlPath);
69003
- if (path25.match(/\.(ico|png|jpg|jpeg|gif|svg|css|js|woff|woff2|ttf|eot|webp|avif)$/)) {
69038
+ const path27 = stripUrlQueryAndFragment(urlPath);
69039
+ if (path27.match(/\.(ico|png|jpg|jpeg|gif|svg|css|js|woff|woff2|ttf|eot|webp|avif)$/)) {
69004
69040
  return true;
69005
69041
  }
69006
- if (path25.match(/^\/(robots\.txt|sitemap\.xml|manifest\.json|browserconfig\.xml)$/)) {
69042
+ if (path27.match(/^\/(robots\.txt|sitemap\.xml|manifest\.json|browserconfig\.xml)$/)) {
69007
69043
  return true;
69008
69044
  }
69009
69045
  return false;
@@ -69244,11 +69280,11 @@ function isKnownPrefetchRequest2(req) {
69244
69280
  return req.headers["next-router-prefetch"] === "1";
69245
69281
  }
69246
69282
  function isStaticAssetRequest2(urlPath) {
69247
- const path25 = stripUrlQueryAndFragment(urlPath);
69248
- if (path25.match(/\.(ico|png|jpg|jpeg|gif|svg|css|js|woff|woff2|ttf|eot|webp|avif)$/)) {
69283
+ const path27 = stripUrlQueryAndFragment(urlPath);
69284
+ if (path27.match(/\.(ico|png|jpg|jpeg|gif|svg|css|js|woff|woff2|ttf|eot|webp|avif)$/)) {
69249
69285
  return true;
69250
69286
  }
69251
- if (path25.match(/^\/(robots\.txt|sitemap\.xml|manifest\.json|browserconfig\.xml)$/)) {
69287
+ if (path27.match(/^\/(robots\.txt|sitemap\.xml|manifest\.json|browserconfig\.xml)$/)) {
69252
69288
  return true;
69253
69289
  }
69254
69290
  return false;
@@ -69608,19 +69644,19 @@ function getBreadcrumbData(request2) {
69608
69644
  return {};
69609
69645
  }
69610
69646
  }
69611
- function getAbsoluteUrl2(origin, path25 = "/") {
69647
+ function getAbsoluteUrl2(origin, path27 = "/") {
69612
69648
  try {
69613
- const url2 = new URL(path25, origin);
69649
+ const url2 = new URL(path27, origin);
69614
69650
  return url2.toString();
69615
69651
  } catch {
69616
69652
  const url2 = `${origin}`;
69617
- if (url2.endsWith("/") && path25.startsWith("/")) {
69618
- return `${url2}${path25.slice(1)}`;
69653
+ if (url2.endsWith("/") && path27.startsWith("/")) {
69654
+ return `${url2}${path27.slice(1)}`;
69619
69655
  }
69620
- if (!url2.endsWith("/") && !path25.startsWith("/")) {
69621
- return `${url2}/${path25}`;
69656
+ if (!url2.endsWith("/") && !path27.startsWith("/")) {
69657
+ return `${url2}/${path27}`;
69622
69658
  }
69623
- return `${url2}${path25}`;
69659
+ return `${url2}${path27}`;
69624
69660
  }
69625
69661
  }
69626
69662
 
@@ -69865,15 +69901,15 @@ function getRequestMethod(original) {
69865
69901
  }
69866
69902
  return "_OTHER";
69867
69903
  }
69868
- function getAbsoluteUrl3(origin, path25 = "/") {
69904
+ function getAbsoluteUrl3(origin, path27 = "/") {
69869
69905
  const url2 = `${origin}`;
69870
- if (url2.endsWith("/") && path25.startsWith("/")) {
69871
- return `${url2}${path25.slice(1)}`;
69906
+ if (url2.endsWith("/") && path27.startsWith("/")) {
69907
+ return `${url2}${path27.slice(1)}`;
69872
69908
  }
69873
- if (!url2.endsWith("/") && !path25.startsWith("/")) {
69874
- return `${url2}/${path25}`;
69909
+ if (!url2.endsWith("/") && !path27.startsWith("/")) {
69910
+ return `${url2}/${path27}`;
69875
69911
  }
69876
- return `${url2}${path25}`;
69912
+ return `${url2}${path27}`;
69877
69913
  }
69878
69914
 
69879
69915
  // ../../node_modules/.pnpm/@sentry+node-core@10.73.0_@opentelemetry+api@1.9.1_@opentelemetry+core@2.11.0_@opentele_0c1f249c3fa9afb330ae7de0346c118f/node_modules/@sentry/node-core/build/esm/integrations/node-fetch/index.js
@@ -72359,12 +72395,12 @@ function emplace(map2, key, contents) {
72359
72395
  }
72360
72396
  return value;
72361
72397
  }
72362
- function shouldSkipContextLinesForFile(path25) {
72363
- if (path25.startsWith("node:")) return true;
72364
- if (path25.endsWith(".min.js")) return true;
72365
- if (path25.endsWith(".min.cjs")) return true;
72366
- if (path25.endsWith(".min.mjs")) return true;
72367
- if (path25.startsWith("data:")) return true;
72398
+ function shouldSkipContextLinesForFile(path27) {
72399
+ if (path27.startsWith("node:")) return true;
72400
+ if (path27.endsWith(".min.js")) return true;
72401
+ if (path27.endsWith(".min.cjs")) return true;
72402
+ if (path27.endsWith(".min.mjs")) return true;
72403
+ if (path27.startsWith("data:")) return true;
72368
72404
  return false;
72369
72405
  }
72370
72406
  function shouldSkipContextLinesForFrame(frame) {
@@ -72412,9 +72448,9 @@ function makeLineReaderRanges(lines, linecontext) {
72412
72448
  }
72413
72449
  return out;
72414
72450
  }
72415
- function getContextLinesFromFile(path25, ranges, output2) {
72451
+ function getContextLinesFromFile(path27, ranges, output2) {
72416
72452
  return new Promise((resolve2, _reject) => {
72417
- const stream = createReadStream(path25);
72453
+ const stream = createReadStream(path27);
72418
72454
  const lineReaded = createInterface({
72419
72455
  input: stream
72420
72456
  });
@@ -72432,8 +72468,8 @@ function getContextLinesFromFile(path25, ranges, output2) {
72432
72468
  let rangeStart = range[0];
72433
72469
  let rangeEnd = range[1];
72434
72470
  function onStreamError(e) {
72435
- LRU_FILE_CONTENTS_FS_READ_FAILED.set(path25, 1);
72436
- DEBUG_BUILD2 && debug.error(`Failed to read file: ${path25}. Error: ${e}`);
72471
+ LRU_FILE_CONTENTS_FS_READ_FAILED.set(path27, 1);
72472
+ DEBUG_BUILD2 && debug.error(`Failed to read file: ${path27}. Error: ${e}`);
72437
72473
  lineReaded.close();
72438
72474
  lineReaded.removeAllListeners();
72439
72475
  destroyStreamAndResolve();
@@ -73872,8 +73908,8 @@ function getSpotlightConfig(optionsSpotlight) {
73872
73908
 
73873
73909
  // ../../node_modules/.pnpm/@sentry+node-core@10.73.0_@opentelemetry+api@1.9.1_@opentelemetry+core@2.11.0_@opentele_0c1f249c3fa9afb330ae7de0346c118f/node_modules/@sentry/node-core/build/esm/utils/module.js
73874
73910
  import { posix, sep } from "node:path";
73875
- function normalizeWindowsPath(path25) {
73876
- return path25.replace(/^[A-Z]:/, "").replace(/\\/g, "/");
73911
+ function normalizeWindowsPath(path27) {
73912
+ return path27.replace(/^[A-Z]:/, "").replace(/\\/g, "/");
73877
73913
  }
73878
73914
  function createGetModuleFromFilename(basePath = process.argv[1] ? dirname(process.argv[1]) : process.cwd(), isWindows = sep === "\\") {
73879
73915
  const normalizedBase = isWindows ? normalizeWindowsPath(basePath) : basePath;
@@ -76749,22 +76785,22 @@ function addSpanSource(span, loc, start, end) {
76749
76785
  span.setAttribute(AttributeNames2.SOURCE, source);
76750
76786
  }
76751
76787
  }
76752
- function createFieldIfNotExists(contextValue, info, path25) {
76753
- let field = getField(contextValue, path25);
76788
+ function createFieldIfNotExists(contextValue, info, path27) {
76789
+ let field = getField(contextValue, path27);
76754
76790
  if (field) {
76755
76791
  return { field, spanAdded: false };
76756
76792
  }
76757
- const parentSpan = getParentFieldSpan(contextValue, path25);
76793
+ const parentSpan = getParentFieldSpan(contextValue, path27);
76758
76794
  field = {
76759
- span: createResolverSpan(contextValue, info, path25, parentSpan)
76795
+ span: createResolverSpan(contextValue, info, path27, parentSpan)
76760
76796
  };
76761
- addField(contextValue, path25, field);
76797
+ addField(contextValue, path27, field);
76762
76798
  return { field, spanAdded: true };
76763
76799
  }
76764
- function createResolverSpan(contextValue, info, path25, parentSpan) {
76800
+ function createResolverSpan(contextValue, info, path27, parentSpan) {
76765
76801
  const attributes = {
76766
76802
  [AttributeNames2.FIELD_NAME]: info.fieldName,
76767
- [AttributeNames2.FIELD_PATH]: path25.join("."),
76803
+ [AttributeNames2.FIELD_PATH]: path27.join("."),
76768
76804
  [AttributeNames2.FIELD_TYPE]: info.returnType.toString(),
76769
76805
  [AttributeNames2.PARENT_NAME]: info.parentType.name
76770
76806
  };
@@ -76796,15 +76832,15 @@ function getOperation(document2, operationName) {
76796
76832
  return document2.definitions.find((definition) => OPERATION_VALUES.indexOf(definition?.operation) !== -1);
76797
76833
  }
76798
76834
  }
76799
- function addField(contextValue, path25, field) {
76800
- return contextValue[OTEL_GRAPHQL_DATA_SYMBOL].fields[path25.join(".")] = field;
76835
+ function addField(contextValue, path27, field) {
76836
+ return contextValue[OTEL_GRAPHQL_DATA_SYMBOL].fields[path27.join(".")] = field;
76801
76837
  }
76802
- function getField(contextValue, path25) {
76803
- return contextValue[OTEL_GRAPHQL_DATA_SYMBOL].fields[path25.join(".")];
76838
+ function getField(contextValue, path27) {
76839
+ return contextValue[OTEL_GRAPHQL_DATA_SYMBOL].fields[path27.join(".")];
76804
76840
  }
76805
- function getParentFieldSpan(contextValue, path25) {
76806
- for (let i = path25.length - 1; i > 0; i--) {
76807
- const field = getField(contextValue, path25.slice(0, i));
76841
+ function getParentFieldSpan(contextValue, path27) {
76842
+ for (let i = path27.length - 1; i > 0; i--) {
76843
+ const field = getField(contextValue, path27.slice(0, i));
76808
76844
  if (field) {
76809
76845
  return field.span;
76810
76846
  }
@@ -76814,9 +76850,9 @@ function getParentFieldSpan(contextValue, path25) {
76814
76850
  function getRootSpan2(contextValue) {
76815
76851
  return contextValue[OTEL_GRAPHQL_DATA_SYMBOL].span;
76816
76852
  }
76817
- function pathToArray(path25) {
76853
+ function pathToArray(path27) {
76818
76854
  const flattened = [];
76819
- let curr = path25;
76855
+ let curr = path27;
76820
76856
  while (curr) {
76821
76857
  flattened.push(String(curr.key));
76822
76858
  curr = curr.prev;
@@ -76957,8 +76993,8 @@ function wrapFieldResolver(getConfig3, fieldResolver, isDefaultResolver = false)
76957
76993
  if (!contextValue[OTEL_GRAPHQL_DATA_SYMBOL]) {
76958
76994
  return fieldResolver.call(this, source, args, contextValue, info);
76959
76995
  }
76960
- const path25 = pathToArray(info?.path);
76961
- const { field, spanAdded } = createFieldIfNotExists(contextValue, info, path25);
76996
+ const path27 = pathToArray(info?.path);
76997
+ const { field, spanAdded } = createFieldIfNotExists(contextValue, info, path27);
76962
76998
  const span = field.span;
76963
76999
  const shouldEndSpan = spanAdded;
76964
77000
  return withActiveSpan(span, () => {
@@ -79941,10 +79977,10 @@ var PostgresJsInstrumentation = class extends import_instrumentation24.Instrumen
79941
79977
  },
79942
79978
  (exports) => exports
79943
79979
  );
79944
- ["src", "cf/src", "cjs/src"].forEach((path25) => {
79980
+ ["src", "cf/src", "cjs/src"].forEach((path27) => {
79945
79981
  module2.files.push(
79946
79982
  new InstrumentationNodeModuleFile(
79947
- `postgres/${path25}/query.js`,
79983
+ `postgres/${path27}/query.js`,
79948
79984
  SUPPORTED_VERSIONS4,
79949
79985
  this._patchQueryPrototype.bind(this),
79950
79986
  this._unpatchQueryPrototype.bind(this)
@@ -80575,13 +80611,13 @@ var HonoInstrumentation = class extends import_instrumentation27.Instrumentation
80575
80611
  return function(original) {
80576
80612
  return function wrappedHandler(...args) {
80577
80613
  if (typeof args[0] === "string") {
80578
- const path25 = args[0];
80614
+ const path27 = args[0];
80579
80615
  if (args.length === 1) {
80580
- return original.apply(this, [path25]);
80616
+ return original.apply(this, [path27]);
80581
80617
  }
80582
80618
  const handlers2 = args.slice(1);
80583
80619
  return original.apply(this, [
80584
- path25,
80620
+ path27,
80585
80621
  ...handlers2.map((handler) => instrumentation._wrapHandler(handler))
80586
80622
  ]);
80587
80623
  }
@@ -80615,13 +80651,13 @@ var HonoInstrumentation = class extends import_instrumentation27.Instrumentation
80615
80651
  return function(original) {
80616
80652
  return function wrappedHandler(...args) {
80617
80653
  if (typeof args[0] === "string") {
80618
- const path25 = args[0];
80654
+ const path27 = args[0];
80619
80655
  if (args.length === 1) {
80620
- return original.apply(this, [path25]);
80656
+ return original.apply(this, [path27]);
80621
80657
  }
80622
80658
  const handlers2 = args.slice(1);
80623
80659
  return original.apply(this, [
80624
- path25,
80660
+ path27,
80625
80661
  ...handlers2.map((handler) => instrumentation._wrapHandler(handler))
80626
80662
  ]);
80627
80663
  }
@@ -80641,8 +80677,8 @@ var HonoInstrumentation = class extends import_instrumentation27.Instrumentation
80641
80677
  if (!instrumentation.isEnabled()) {
80642
80678
  return handler.apply(this, [c, next]);
80643
80679
  }
80644
- const path25 = c.req.path;
80645
- const span = instrumentation.tracer.startSpan(path25);
80680
+ const path27 = c.req.path;
80681
+ const span = instrumentation.tracer.startSpan(path27);
80646
80682
  return context.with(trace.setSpan(context.active(), span), () => {
80647
80683
  return instrumentation._safeExecute(
80648
80684
  () => {
@@ -80652,7 +80688,7 @@ var HonoInstrumentation = class extends import_instrumentation27.Instrumentation
80652
80688
  const type = instrumentation._determineHandlerType(result2);
80653
80689
  span.setAttributes({
80654
80690
  [AttributeNames5.HONO_TYPE]: type,
80655
- [AttributeNames5.HONO_NAME]: type === HonoTypes.REQUEST_HANDLER ? path25 : handler.name || "anonymous"
80691
+ [AttributeNames5.HONO_NAME]: type === HonoTypes.REQUEST_HANDLER ? path27 : handler.name || "anonymous"
80656
80692
  });
80657
80693
  instrumentation.getConfig().responseHook?.(span);
80658
80694
  return result2;
@@ -80661,7 +80697,7 @@ var HonoInstrumentation = class extends import_instrumentation27.Instrumentation
80661
80697
  const type = instrumentation._determineHandlerType(result);
80662
80698
  span.setAttributes({
80663
80699
  [AttributeNames5.HONO_TYPE]: type,
80664
- [AttributeNames5.HONO_NAME]: type === HonoTypes.REQUEST_HANDLER ? path25 : handler.name || "anonymous"
80700
+ [AttributeNames5.HONO_NAME]: type === HonoTypes.REQUEST_HANDLER ? path27 : handler.name || "anonymous"
80665
80701
  });
80666
80702
  instrumentation.getConfig().responseHook?.(span);
80667
80703
  return result;
@@ -80865,11 +80901,11 @@ var KoaInstrumentation = class extends import_instrumentation29.InstrumentationB
80865
80901
  const router = dispatchLayer.router;
80866
80902
  const routesStack = router?.stack ?? [];
80867
80903
  for (const pathLayer of routesStack) {
80868
- const path25 = pathLayer.path;
80904
+ const path27 = pathLayer.path;
80869
80905
  const pathStack = pathLayer.stack;
80870
80906
  for (let j = 0; j < pathStack.length; j++) {
80871
80907
  const routedMiddleware = pathStack[j];
80872
- pathStack[j] = this._patchLayer(routedMiddleware, true, path25);
80908
+ pathStack[j] = this._patchLayer(routedMiddleware, true, path27);
80873
80909
  }
80874
80910
  }
80875
80911
  return dispatchLayer;
@@ -83323,7 +83359,7 @@ import os6 from "node:os";
83323
83359
  // ../../apps/collector/src/http.ts
83324
83360
  var import_undici = __toESM(require_undici(), 1);
83325
83361
  var CLI_VERSION_HEADER = "x-powerplant-cli-version";
83326
- var cliVersion = true ? "0.4.4" : "0.0.0-checkout";
83362
+ var cliVersion = true ? "0.4.5" : "0.0.0-checkout";
83327
83363
  function cliVersionHeaders() {
83328
83364
  return { [CLI_VERSION_HEADER]: cliVersion, "user-agent": `powerplant-cli/${cliVersion}` };
83329
83365
  }
@@ -85124,8 +85160,7 @@ function addCodexTotals(a, b2) {
85124
85160
  return { input: a.input + b2.input, cached: a.cached + b2.cached, output: a.output + b2.output };
85125
85161
  }
85126
85162
  function isSidecarThread(meta3) {
85127
- const source = meta3.source;
85128
- return meta3.thread_source === "subagent" || meta3.thread_source === "guardian_review" || typeof source === "object" && source !== null && "subagent" in source;
85163
+ return harnessSessionFacts("codex", meta3).subagent === true;
85129
85164
  }
85130
85165
  function repoFullNameFrom(url2) {
85131
85166
  const fullName = parseGithubRepo(url2);
@@ -85612,7 +85647,7 @@ function loadSqlite() {
85612
85647
  );
85613
85648
  return sqliteModule;
85614
85649
  }
85615
- async function openCursorDatabase(dbPath) {
85650
+ async function openLocalDatabase(dbPath) {
85616
85651
  const sqlite = await loadSqlite();
85617
85652
  return new sqlite.DatabaseSync(dbPath, { readOnly: true });
85618
85653
  }
@@ -85787,7 +85822,7 @@ async function collectCursorSessions(options = {}) {
85787
85822
  const dbPath = path9.join(userDir, "globalStorage", "state.vscdb");
85788
85823
  let db;
85789
85824
  try {
85790
- if (statIfExists(dbPath) !== null) db = await openCursorDatabase(dbPath);
85825
+ if (statIfExists(dbPath) !== null) db = await openLocalDatabase(dbPath);
85791
85826
  } catch (error62) {
85792
85827
  result.unavailable = `Cursor's session store couldn't be opened (${describeReadError(error62)})`;
85793
85828
  }
@@ -85837,7 +85872,7 @@ function collectFromStore(db, userDir, options, result, knownIds) {
85837
85872
  continue;
85838
85873
  }
85839
85874
  const facts = headerFactsOf(value);
85840
- if (raw.isSubagent === 1 || raw.isSubagent === true) {
85875
+ if (harnessSessionFacts("cursor", raw).subagent === true) {
85841
85876
  result.skippedSubagentComposers += 1;
85842
85877
  continue;
85843
85878
  }
@@ -85914,7 +85949,7 @@ function collectFromStore(db, userDir, options, result, knownIds) {
85914
85949
  externalId: raw.composerId,
85915
85950
  status: now - lastUpdatedAt < ACTIVE_GRACE_MS ? "active" : "inactive",
85916
85951
  // The header's own archive fact — Cursor's UI archive flag.
85917
- archived: raw.isArchived === 1 || raw.isArchived === true,
85952
+ archived: harnessSessionFacts("cursor", raw).archived === true,
85918
85953
  ...typeof raw.createdAt === "number" && {
85919
85954
  startedAt: new Date(raw.createdAt).toISOString()
85920
85955
  },
@@ -87782,20 +87817,110 @@ function describeDelay(ms) {
87782
87817
  return seconds < 120 ? `${seconds}s` : `${Math.round(seconds / 60)} minutes`;
87783
87818
  }
87784
87819
 
87820
+ // ../../apps/collector/src/localSessionFacts.ts
87821
+ import { existsSync as existsSync7, readdirSync as readdirSync4 } from "node:fs";
87822
+ import os16 from "node:os";
87823
+ import path17 from "node:path";
87824
+ var STORES = [
87825
+ {
87826
+ source: "codex",
87827
+ file: (home) => {
87828
+ const directory = path17.join(home, ".codex");
87829
+ if (!existsSync7(directory)) return null;
87830
+ const files = readdirSync4(directory).filter((name) => /^state_\d+\.sqlite$/.test(name)).sort((a, b2) => Number(b2.match(/\d+/)?.[0]) - Number(a.match(/\d+/)?.[0]));
87831
+ return files[0] ? path17.join(directory, files[0]) : null;
87832
+ },
87833
+ id: (externalId) => /([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$/i.exec(externalId)?.[1],
87834
+ table: "threads",
87835
+ key: "id",
87836
+ fields: ["source", "thread_source", "archived"],
87837
+ decode: (row) => {
87838
+ const parsed = external_exports.object({
87839
+ source: external_exports.unknown().optional(),
87840
+ thread_source: external_exports.unknown().optional(),
87841
+ archived: external_exports.unknown().optional()
87842
+ }).parse(row);
87843
+ let source = parsed.source;
87844
+ if (typeof parsed.source === "string") {
87845
+ try {
87846
+ source = JSON.parse(parsed.source);
87847
+ } catch {
87848
+ }
87849
+ }
87850
+ return { ...parsed, source };
87851
+ }
87852
+ },
87853
+ {
87854
+ source: "cursor",
87855
+ file: (home) => path17.join(defaultCursorUserDir(home), "globalStorage", "state.vscdb"),
87856
+ id: (externalId) => externalId,
87857
+ table: "composerHeaders",
87858
+ key: "composerId",
87859
+ fields: ["isArchived", "isSubagent"],
87860
+ decode: (row) => row
87861
+ }
87862
+ ];
87863
+ async function readLocalSessionFacts(sessions, onError2, home = os16.homedir()) {
87864
+ const result = /* @__PURE__ */ new Map();
87865
+ for (const store of STORES) {
87866
+ const wanted = sessions.filter((session) => session.source === store.source);
87867
+ if (wanted.length === 0) continue;
87868
+ try {
87869
+ const file2 = store.file(home);
87870
+ if (file2 === null || !existsSync7(file2)) continue;
87871
+ const db = await openLocalDatabase(file2);
87872
+ try {
87873
+ const columns = new Set(
87874
+ external_exports.array(external_exports.object({ name: external_exports.string() })).parse(db.prepare(`pragma table_info(${store.table})`).all()).map((column) => column.name)
87875
+ );
87876
+ if (!columns.has(store.key))
87877
+ throw new Error(`Unrecognized ${store.source} session metadata table`);
87878
+ const fields = store.fields.filter((field) => columns.has(field));
87879
+ if (fields.length === 0) continue;
87880
+ const statement = db.prepare(
87881
+ `select ${fields.join(", ")} from ${store.table} where ${store.key} = ?`
87882
+ );
87883
+ for (const session of wanted) {
87884
+ const id = store.id(session.externalId);
87885
+ if (!id) continue;
87886
+ try {
87887
+ const row = statement.get(id);
87888
+ if (row !== void 0)
87889
+ result.set(
87890
+ localSessionKey(session),
87891
+ harnessSessionFacts(store.source, store.decode(row))
87892
+ );
87893
+ } catch (error62) {
87894
+ onError2(error62, store.source);
87895
+ }
87896
+ }
87897
+ } finally {
87898
+ db.close();
87899
+ }
87900
+ } catch (error62) {
87901
+ onError2(error62, store.source);
87902
+ }
87903
+ }
87904
+ return result;
87905
+ }
87906
+ function localSessionKey(session) {
87907
+ return JSON.stringify([session.source, session.externalId]);
87908
+ }
87909
+
87785
87910
  // src/connect.ts
87786
87911
  import { execFileSync as execFileSync4, spawnSync } from "node:child_process";
87787
87912
  import {
87788
- existsSync as existsSync7,
87913
+ existsSync as existsSync8,
87789
87914
  mkdirSync as mkdirSync8,
87790
87915
  mkdtempSync,
87791
- readdirSync as readdirSync4,
87916
+ readdirSync as readdirSync5,
87792
87917
  readFileSync as readFileSync11,
87793
87918
  realpathSync as realpathSync3,
87794
87919
  statSync as statSync4,
87795
87920
  writeFileSync as writeFileSync8
87796
87921
  } from "node:fs";
87797
- import os16 from "node:os";
87798
- import path17 from "node:path";
87922
+ import os17 from "node:os";
87923
+ import path18 from "node:path";
87799
87924
  import { emitKeypressEvents } from "node:readline";
87800
87925
 
87801
87926
  // src/agentVersions.ts
@@ -87864,10 +87989,10 @@ function startTimeBudget(totalMs, now = Date.now) {
87864
87989
  return { remainingMs: () => Math.max(0, deadline - now()) };
87865
87990
  }
87866
87991
  function defaultApplicationsDirs(homeDir) {
87867
- return process.platform === "darwin" ? ["/Applications", path17.join(homeDir, "Applications")] : [];
87992
+ return process.platform === "darwin" ? ["/Applications", path18.join(homeDir, "Applications")] : [];
87868
87993
  }
87869
87994
  function detectClients(options = {}) {
87870
- const homeDir = options.homeDir ?? os16.homedir();
87995
+ const homeDir = options.homeDir ?? os17.homedir();
87871
87996
  const whichAll = options.whichAll ?? defaultWhichAll;
87872
87997
  const env = options.env ?? process.env;
87873
87998
  const applicationsDirs = options.applicationsDirs ?? defaultApplicationsDirs(homeDir);
@@ -87892,20 +88017,20 @@ function detectClients(options = {}) {
87892
88017
  clients.push({ client, bin, ...configDir !== void 0 && { configDir } });
87893
88018
  };
87894
88019
  for (const bin of whichAll("claude")) add("claude", bin);
87895
- const localClaude = path17.join(homeDir, ".local", "bin", "claude");
87896
- if (existsSync7(localClaude)) add("claude", localClaude);
88020
+ const localClaude = path18.join(homeDir, ".local", "bin", "claude");
88021
+ if (existsSync8(localClaude)) add("claude", localClaude);
87897
88022
  for (const bin of desktopClaudeBinaries(homeDir)) add("claude", bin);
87898
88023
  const claudeBins = clients.filter((client) => client.client === "claude" && client.configDir === void 0).map((client) => client.bin);
87899
88024
  for (const configDir of claudeConfigHomes(homeDir, env)) {
87900
88025
  for (const bin of claudeBins) add("claude", bin, configDir);
87901
88026
  }
87902
88027
  for (const bin of whichAll("codex")) add("codex", bin);
87903
- const localCodex = path17.join(homeDir, ".local", "bin", "codex");
87904
- if (existsSync7(localCodex)) add("codex", localCodex);
88028
+ const localCodex = path18.join(homeDir, ".local", "bin", "codex");
88029
+ if (existsSync8(localCodex)) add("codex", localCodex);
87905
88030
  for (const bin of codexBundleBinaries(applicationsDirs, bundleSeams)) add("codex", bin);
87906
- const cursorDir = path17.join(homeDir, ".cursor");
87907
- if (existsSync7(cursorDir) || cursorAppInstalled(applicationsDirs, bundleSeams)) {
87908
- clients.push({ client: "cursor", bin: path17.join(cursorDir, "mcp.json") });
88031
+ const cursorDir = path18.join(homeDir, ".cursor");
88032
+ if (existsSync8(cursorDir) || cursorAppInstalled(applicationsDirs, bundleSeams)) {
88033
+ clients.push({ client: "cursor", bin: path18.join(cursorDir, "mcp.json") });
87909
88034
  }
87910
88035
  return clients;
87911
88036
  }
@@ -87913,7 +88038,7 @@ function claudeConfigHomes(homeDir, env) {
87913
88038
  const homes = [];
87914
88039
  const seen = /* @__PURE__ */ new Set();
87915
88040
  try {
87916
- seen.add(realpathSync3(path17.join(homeDir, ".claude")));
88041
+ seen.add(realpathSync3(path18.join(homeDir, ".claude")));
87917
88042
  } catch {
87918
88043
  }
87919
88044
  const add = (configDir) => {
@@ -87925,16 +88050,16 @@ function claudeConfigHomes(homeDir, env) {
87925
88050
  }
87926
88051
  if (seen.has(real)) return;
87927
88052
  seen.add(real);
87928
- homes.push(path17.resolve(configDir));
88053
+ homes.push(path18.resolve(configDir));
87929
88054
  };
87930
88055
  let entries = [];
87931
88056
  try {
87932
- entries = readdirSync4(homeDir);
88057
+ entries = readdirSync5(homeDir);
87933
88058
  } catch {
87934
88059
  }
87935
88060
  for (const entry of entries.sort()) {
87936
- if (entry.startsWith(".claude-") && existsSync7(path17.join(homeDir, entry, ".claude.json"))) {
87937
- add(path17.join(homeDir, entry));
88061
+ if (entry.startsWith(".claude-") && existsSync8(path18.join(homeDir, entry, ".claude.json"))) {
88062
+ add(path18.join(homeDir, entry));
87938
88063
  }
87939
88064
  }
87940
88065
  if (env.CLAUDE_CONFIG_DIR) add(env.CLAUDE_CONFIG_DIR);
@@ -87955,14 +88080,14 @@ function appBundles(applicationsDirs, namePrefixes) {
87955
88080
  for (const dir of applicationsDirs) {
87956
88081
  let entries;
87957
88082
  try {
87958
- entries = readdirSync4(dir);
88083
+ entries = readdirSync5(dir);
87959
88084
  } catch {
87960
88085
  continue;
87961
88086
  }
87962
88087
  for (const entry of entries) {
87963
88088
  if (!entry.endsWith(".app")) continue;
87964
88089
  if (!namePrefixes.some((prefix) => entry.startsWith(prefix))) continue;
87965
- bundles.push(path17.join(dir, entry));
88090
+ bundles.push(path18.join(dir, entry));
87966
88091
  }
87967
88092
  }
87968
88093
  return bundles;
@@ -87982,7 +88107,7 @@ function codexBundleBinaries(applicationsDirs, seams) {
87982
88107
  const infoTimeoutMs = budgetedTimeout(BUNDLE_INFO_TIMEOUT_MS, appDir, seams);
87983
88108
  if (infoTimeoutMs === null) continue;
87984
88109
  if (seams.readBundleInfo(appDir, infoTimeoutMs)?.bundleId !== CODEX_BUNDLE_ID) continue;
87985
- const bin = path17.join(appDir, "Contents", "Resources", "codex");
88110
+ const bin = path18.join(appDir, "Contents", "Resources", "codex");
87986
88111
  if (!isExecutableFile(bin)) continue;
87987
88112
  if (!signedByTeam(bin, OPENAI_TEAM_ID, "OpenAI", appDir, seams)) continue;
87988
88113
  found.push(bin);
@@ -87994,7 +88119,7 @@ function trustedCursorBundle(appDir, seams) {
87994
88119
  if (infoTimeoutMs === null) return null;
87995
88120
  const info = seams.readBundleInfo(appDir, infoTimeoutMs);
87996
88121
  if (info?.executable === void 0) return null;
87997
- const bin = path17.join(appDir, "Contents", "MacOS", info.executable);
88122
+ const bin = path18.join(appDir, "Contents", "MacOS", info.executable);
87998
88123
  if (!isExecutableFile(bin)) return null;
87999
88124
  if (!signedByTeam(bin, CURSOR_TEAM_ID, "Cursor", appDir, seams)) return null;
88000
88125
  return info;
@@ -88031,7 +88156,7 @@ var bundleInfoSchema = external_exports.object({
88031
88156
  function realReadBundleInfo(appDir, timeoutMs) {
88032
88157
  const result = spawnSync(
88033
88158
  "plutil",
88034
- ["-convert", "json", "-o", "-", path17.join(appDir, "Contents", "Info.plist")],
88159
+ ["-convert", "json", "-o", "-", path18.join(appDir, "Contents", "Info.plist")],
88035
88160
  { encoding: "utf8", timeout: timeoutMs }
88036
88161
  );
88037
88162
  if (result.status !== 0) return null;
@@ -88053,14 +88178,14 @@ function realVerifySignature(binPath, teamId, timeoutMs) {
88053
88178
  }).status === 0;
88054
88179
  }
88055
88180
  function desktopClaudeBinaries(homeDir) {
88056
- const root = path17.join(homeDir, "Library", "Application Support", "Claude", "claude-code");
88181
+ const root = path18.join(homeDir, "Library", "Application Support", "Claude", "claude-code");
88057
88182
  let versions;
88058
88183
  try {
88059
- versions = readdirSync4(root);
88184
+ versions = readdirSync5(root);
88060
88185
  } catch {
88061
88186
  return [];
88062
88187
  }
88063
- return versions.map((version2) => path17.join(root, version2, "claude.app", "Contents", "MacOS", "claude")).filter((bin) => existsSync7(bin));
88188
+ return versions.map((version2) => path18.join(root, version2, "claude.app", "Contents", "MacOS", "claude")).filter((bin) => existsSync8(bin));
88064
88189
  }
88065
88190
  function defaultWhichAll(name) {
88066
88191
  try {
@@ -88159,9 +88284,9 @@ function displayName(client, all) {
88159
88284
  const sameTarget = peers.filter((peer) => peer.configDir === client.configDir);
88160
88285
  const details = [];
88161
88286
  if (profiles.size > 1) {
88162
- details.push(client.configDir?.replace(os16.homedir(), "~") ?? "default profile");
88287
+ details.push(client.configDir?.replace(os17.homedir(), "~") ?? "default profile");
88163
88288
  }
88164
- if (sameTarget.length > 1) details.push(client.bin.replace(os16.homedir(), "~"));
88289
+ if (sameTarget.length > 1) details.push(client.bin.replace(os17.homedir(), "~"));
88165
88290
  return details.length > 0 ? `${product} (${details.join(", ")})` : product;
88166
88291
  }
88167
88292
  function pickerAllowed(options) {
@@ -88611,7 +88736,7 @@ function connectCursor(mcpJsonPath, name, deps) {
88611
88736
  );
88612
88737
  if (patch.error !== void 0 || patch.entry === void 0) {
88613
88738
  return failed(
88614
- `${mcpJsonPath.replace(os16.homedir(), "~")} is ${patch.error}, fix it by hand, then re-run ${deps.connectCommand}.`
88739
+ `${mcpJsonPath.replace(os17.homedir(), "~")} is ${patch.error}, fix it by hand, then re-run ${deps.connectCommand}.`
88615
88740
  );
88616
88741
  }
88617
88742
  if (patch.changed) deps.writeTextFile(mcpJsonPath, patch.content);
@@ -88667,7 +88792,7 @@ function disconnectTarget(agent, candidates, deps) {
88667
88792
  try {
88668
88793
  last = candidate.client === "claude" ? disconnectClaude(candidate, deps) : candidate.client === "codex" ? disconnectCodex(candidate.bin, deps) : disconnectCursor(candidate.bin, deps);
88669
88794
  } catch (error62) {
88670
- const name = candidate.client === "cursor" ? `Cursor (${candidate.bin.replace(os16.homedir(), "~")})` : describeBinary(candidate.bin);
88795
+ const name = candidate.client === "cursor" ? `Cursor (${candidate.bin.replace(os17.homedir(), "~")})` : describeBinary(candidate.bin);
88671
88796
  deps.log(`\u2717 ${name}: ${error62 instanceof Error ? error62.message : String(error62)}`);
88672
88797
  last = "failed";
88673
88798
  }
@@ -88729,7 +88854,7 @@ function disconnectCodex(bin, deps) {
88729
88854
  return "disconnected";
88730
88855
  }
88731
88856
  function disconnectCursor(mcpJsonPath, deps) {
88732
- const name = `Cursor (${mcpJsonPath.replace(os16.homedir(), "~")})`;
88857
+ const name = `Cursor (${mcpJsonPath.replace(os17.homedir(), "~")})`;
88733
88858
  const patch = unpatchCursorMcpJson(deps.readTextFile(mcpJsonPath), MCP_SERVER_NAME);
88734
88859
  if (patch.error !== void 0) {
88735
88860
  deps.log(`\u2717 ${name}: mcp.json is ${patch.error}, fix it by hand, then re-run powerplant disconnect.`);
@@ -88759,11 +88884,11 @@ function anyClientStillConnected(clients, deps) {
88759
88884
  });
88760
88885
  }
88761
88886
  function describeBinary(bin) {
88762
- return `${path17.basename(bin)} (${bin.replace(os16.homedir(), "~")})`;
88887
+ return `${path18.basename(bin)} (${bin.replace(os17.homedir(), "~")})`;
88763
88888
  }
88764
88889
  function describeClaudeTarget(client) {
88765
88890
  if (client.configDir === void 0) return describeBinary(client.bin);
88766
- return `${path17.basename(client.bin)} (${client.configDir.replace(os16.homedir(), "~")})`;
88891
+ return `${path18.basename(client.bin)} (${client.configDir.replace(os17.homedir(), "~")})`;
88767
88892
  }
88768
88893
  var FAILURE_DETAIL_MAX_CHARS = 200;
88769
88894
  function describeFailure(result) {
@@ -88776,7 +88901,7 @@ function describeFailure(result) {
88776
88901
  }
88777
88902
  var neutralDirMemo;
88778
88903
  function neutralWorkdir() {
88779
- neutralDirMemo ??= mkdtempSync(path17.join(os16.tmpdir(), "powerplant-connect-"));
88904
+ neutralDirMemo ??= mkdtempSync(path18.join(os17.tmpdir(), "powerplant-connect-"));
88780
88905
  return neutralDirMemo;
88781
88906
  }
88782
88907
  async function fetchOfficialClients(apiUrl, log3) {
@@ -88820,11 +88945,11 @@ function realReadTextFileStrict(filePath) {
88820
88945
  }
88821
88946
  }
88822
88947
  function realWriteTextFile(filePath, content) {
88823
- mkdirSync8(path17.dirname(filePath), { recursive: true });
88948
+ mkdirSync8(path18.dirname(filePath), { recursive: true });
88824
88949
  writeFileSync8(filePath, content);
88825
88950
  }
88826
- function codexConfigPath(homeDir = os16.homedir()) {
88827
- return path17.join(process.env.CODEX_HOME ?? path17.join(homeDir, ".codex"), "config.toml");
88951
+ function codexConfigPath(homeDir = os17.homedir()) {
88952
+ return path18.join(process.env.CODEX_HOME ?? path18.join(homeDir, ".codex"), "config.toml");
88828
88953
  }
88829
88954
  function realOpenUrl(url2) {
88830
88955
  const bin = process.platform === "darwin" ? "open" : process.platform === "linux" ? "xdg-open" : null;
@@ -88844,7 +88969,7 @@ function commandEnv(overrides) {
88844
88969
  }
88845
88970
  function realAgentVersion(client) {
88846
88971
  if (client.client === "cursor") {
88847
- return cursorAppVersion(defaultApplicationsDirs(os16.homedir()), {
88972
+ return cursorAppVersion(defaultApplicationsDirs(os17.homedir()), {
88848
88973
  readBundleInfo: realReadBundleInfo,
88849
88974
  verifySignature: realVerifySignature,
88850
88975
  budget: UNLIMITED_TIME_BUDGET,
@@ -88886,7 +89011,7 @@ function realRunInteractive(bin, args, env) {
88886
89011
  // src/connections.ts
88887
89012
  import { execFileSync as execFileSync5, spawnSync as spawnSync2 } from "node:child_process";
88888
89013
  import { mkdirSync as mkdirSync9, writeFileSync as writeFileSync9 } from "node:fs";
88889
- import path18 from "node:path";
89014
+ import path19 from "node:path";
88890
89015
  function probeConnections(clients, deps) {
88891
89016
  const reports = [];
88892
89017
  for (const kind of ["claude", "codex", "cursor"]) {
@@ -88930,7 +89055,7 @@ function aggregateClaudeTargets(targets) {
88930
89055
  if (targets.length === 1 || worst.report.state === "signed-in") return worst.report;
88931
89056
  return {
88932
89057
  ...worst.report,
88933
- target: worst.configDir === void 0 ? "default profile" : path18.basename(worst.configDir)
89058
+ target: worst.configDir === void 0 ? "default profile" : path19.basename(worst.configDir)
88934
89059
  };
88935
89060
  }
88936
89061
  function probeClient(client, deps) {
@@ -89009,12 +89134,12 @@ var detectedClientsSchema = external_exports.object({
89009
89134
  )
89010
89135
  });
89011
89136
  function detectedClientsPath(homeDir) {
89012
- return path18.join(collectorStateDir(homeDir), "detected-clients.json");
89137
+ return path19.join(collectorStateDir(homeDir), "detected-clients.json");
89013
89138
  }
89014
89139
  function saveDetectedClients(clients, pathValue, homeDir) {
89015
89140
  try {
89016
89141
  const file2 = detectedClientsPath(homeDir);
89017
- mkdirSync9(path18.dirname(file2), { recursive: true });
89142
+ mkdirSync9(path19.dirname(file2), { recursive: true });
89018
89143
  const record2 = {
89019
89144
  detectedAt: (/* @__PURE__ */ new Date()).toISOString(),
89020
89145
  path: pathValue,
@@ -89101,7 +89226,7 @@ function whichAllWith(pathValue) {
89101
89226
  import { closeSync as closeSync4, fstatSync, openSync as openSync4, readSync as readSync4 } from "node:fs";
89102
89227
 
89103
89228
  // src/update.ts
89104
- import path20 from "node:path";
89229
+ import path21 from "node:path";
89105
89230
 
89106
89231
  // src/duration.ts
89107
89232
  function duration3(ms) {
@@ -89120,10 +89245,10 @@ function ago(ms) {
89120
89245
 
89121
89246
  // src/installOwner.ts
89122
89247
  import { accessSync, constants } from "node:fs";
89123
- import path19 from "node:path";
89248
+ import path20 from "node:path";
89124
89249
 
89125
89250
  // src/version.ts
89126
- var CLI_VERSION = true ? "0.4.4" : "0.0.0-checkout";
89251
+ var CLI_VERSION = true ? "0.4.5" : "0.0.0-checkout";
89127
89252
  var CLI_RELEASE_BUILD = true ? true : false;
89128
89253
  var CLI_PACKAGE_NAME = "@usepowerplant/cli";
89129
89254
 
@@ -89147,8 +89272,8 @@ function inspectInstall(entryPath2, env) {
89147
89272
  inPlace: { ok: false, reason: `the install at ${packageDir} isn't a layout this CLI recognises` }
89148
89273
  };
89149
89274
  }
89150
- const modulesDir = path19.dirname(path19.dirname(packageDir));
89151
- const prefix = manager === "npm" ? path19.dirname(path19.dirname(modulesDir)) : null;
89275
+ const modulesDir = path20.dirname(path20.dirname(packageDir));
89276
+ const prefix = manager === "npm" ? path20.dirname(path20.dirname(modulesDir)) : null;
89152
89277
  if (!env.isWritableDirectory(modulesDir)) {
89153
89278
  return { manager, packageDir, prefix, inPlace: { ok: false, reason: `${modulesDir} isn't writable by you` } };
89154
89279
  }
@@ -89169,8 +89294,8 @@ function linkedEntryPath(realEntryPath) {
89169
89294
  if (at === -1) return realEntryPath;
89170
89295
  return `${realEntryPath.slice(0, store)}${realEntryPath.slice(at)}`;
89171
89296
  }
89172
- function updateCommand(manager, version2, prefix = null) {
89173
- const spec = version2 !== null && parseReleaseVersion(version2) !== null ? `${CLI_PACKAGE_NAME}@${version2}` : CLI_PACKAGE_NAME;
89297
+ function updateCommand(manager, version2, prefix = null, channel3 = "latest") {
89298
+ const spec = version2 !== null && parseReleaseVersion(version2) !== null ? `${CLI_PACKAGE_NAME}@${version2}` : `${CLI_PACKAGE_NAME}@${channel3}`;
89174
89299
  switch (manager) {
89175
89300
  case "npm":
89176
89301
  return { bin: "npm", args: prefix === null ? ["install", "-g", spec] : ["install", "-g", "--prefix", prefix, spec] };
@@ -89182,12 +89307,12 @@ function updateCommand(manager, version2, prefix = null) {
89182
89307
  return { bin: "yarn", args: ["global", "add", spec] };
89183
89308
  }
89184
89309
  }
89185
- function manualUpdateCommand(manager, version2, prefix = null) {
89186
- const { bin, args } = updateCommand(manager ?? "npm", version2, prefix);
89310
+ function manualUpdateCommand(manager, version2, prefix = null, channel3 = "latest") {
89311
+ const { bin, args } = updateCommand(manager ?? "npm", version2, prefix, channel3);
89187
89312
  return [bin, ...args].join(" ");
89188
89313
  }
89189
89314
  function installedVersion(packageDir, readTextFile) {
89190
- const raw = readTextFile(path19.join(packageDir, "package.json"));
89315
+ const raw = readTextFile(path20.join(packageDir, "package.json"));
89191
89316
  if (raw === null) return null;
89192
89317
  try {
89193
89318
  const parsed = JSON.parse(raw);
@@ -89228,10 +89353,10 @@ var updateProgressSchema = external_exports.object({
89228
89353
  });
89229
89354
  var UPDATE_PROGRESS_STALE_MS = 15 * 6e4;
89230
89355
  function updateProgressPath(homeDir) {
89231
- return path20.join(collectorStateDir(homeDir), "cli-update.json");
89356
+ return path21.join(collectorStateDir(homeDir), "cli-update.json");
89232
89357
  }
89233
89358
  function updateLogPath(homeDir) {
89234
- return path20.join(collectorStateDir(homeDir), "cli-update.log");
89359
+ return path21.join(collectorStateDir(homeDir), "cli-update.log");
89235
89360
  }
89236
89361
  function readUpdateProgress(readTextFile, file2 = updateProgressPath()) {
89237
89362
  const raw = readTextFile(file2);
@@ -89258,10 +89383,12 @@ function updateProgressView(progress, cliVersion2, now) {
89258
89383
  async function runUpdate(deps) {
89259
89384
  const { inspection } = deps;
89260
89385
  if (inspection.manager === null) {
89261
- throw new ExpectedCliError(cannotUpdateMessage(null, inspection.inPlace.reason, null));
89386
+ throw new ExpectedCliError(cannotUpdateMessage(null, inspection.inPlace.reason, null, deps.channel));
89262
89387
  }
89263
89388
  if (!inspection.inPlace.ok) {
89264
- throw new ExpectedCliError(cannotUpdateMessage(inspection.manager, inspection.inPlace.reason, inspection.prefix));
89389
+ throw new ExpectedCliError(
89390
+ cannotUpdateMessage(inspection.manager, inspection.inPlace.reason, inspection.prefix, deps.channel)
89391
+ );
89265
89392
  }
89266
89393
  const manager = inspection.manager;
89267
89394
  const running = deps.readProgress();
@@ -89281,7 +89408,7 @@ async function runUpdate(deps) {
89281
89408
  );
89282
89409
  }
89283
89410
  deps.writeProgress({ state: "installing", target, startedAt, pid: deps.pid });
89284
- const { bin, args } = updateCommand(manager, target, inspection.prefix);
89411
+ const { bin, args } = updateCommand(manager, target, inspection.prefix, deps.channel);
89285
89412
  deps.log(`Updating ${CLI_PACKAGE_NAME}${target === null ? "" : ` to ${target}`} via ${manager}\u2026`);
89286
89413
  const result = deps.run(bin, args);
89287
89414
  if (result.error !== void 0 || result.status !== 0) {
@@ -89294,7 +89421,7 @@ async function runUpdate(deps) {
89294
89421
  finishedAt: new Date(deps.now()).toISOString(),
89295
89422
  detail
89296
89423
  });
89297
- throw new ExpectedCliError(`${detail}. Update by hand: ${manualUpdateCommand(manager, target, inspection.prefix)}`);
89424
+ throw new ExpectedCliError(`${detail}. Update by hand: ${manualUpdateCommand(manager, target, inspection.prefix, deps.channel)}`);
89298
89425
  }
89299
89426
  const installed = deps.readInstalledVersion(inspection.packageDir);
89300
89427
  if (installed !== null && target !== null && compareReleaseVersions(installed, target) === -1) {
@@ -89307,13 +89434,13 @@ async function runUpdate(deps) {
89307
89434
  finishedAt: new Date(deps.now()).toISOString(),
89308
89435
  detail
89309
89436
  });
89310
- throw new ExpectedCliError(`${detail}. Update by hand: ${manualUpdateCommand(manager, target, inspection.prefix)}`);
89437
+ throw new ExpectedCliError(`${detail}. Update by hand: ${manualUpdateCommand(manager, target, inspection.prefix, deps.channel)}`);
89311
89438
  }
89312
89439
  deps.clearProgress();
89313
89440
  deps.log(updatedMessage(installed, deps.restartService()));
89314
89441
  }
89315
- function cannotUpdateMessage(manager, reason, prefix) {
89316
- return `powerplant update can't replace this install: ${reason}. Update by hand: ${manualUpdateCommand(manager, null, prefix)}`;
89442
+ function cannotUpdateMessage(manager, reason, prefix, channel3) {
89443
+ return `powerplant update can't replace this install: ${reason}. Update by hand: ${manualUpdateCommand(manager, null, prefix, channel3)}`;
89317
89444
  }
89318
89445
  function isFresh(progress, now) {
89319
89446
  return now - Date.parse(progress.startedAt) <= UPDATE_PROGRESS_STALE_MS;
@@ -89422,13 +89549,13 @@ function redactedLogTail(raw) {
89422
89549
  while (lines.length > 0 && lines[lines.length - 1]?.trim() === "") lines.pop();
89423
89550
  return lines.slice(-DOCTOR_LOG_TAIL_LINES);
89424
89551
  }
89425
- function readDoctorLogTail(path25) {
89552
+ function readDoctorLogTail(path27) {
89426
89553
  let fd;
89427
89554
  try {
89428
- fd = openSync4(path25, "r");
89555
+ fd = openSync4(path27, "r");
89429
89556
  } catch (error62) {
89430
- if (error62.code === "ENOENT") return { path: path25, lines: null };
89431
- return { path: path25, lines: null, readError: error62 instanceof Error ? error62.message : String(error62) };
89557
+ if (error62.code === "ENOENT") return { path: path27, lines: null };
89558
+ return { path: path27, lines: null, readError: error62 instanceof Error ? error62.message : String(error62) };
89432
89559
  }
89433
89560
  try {
89434
89561
  const size = fstatSync(fd).size;
@@ -89437,9 +89564,9 @@ function readDoctorLogTail(path25) {
89437
89564
  readSync4(fd, buffer, 0, buffer.length, offset);
89438
89565
  let text = buffer.toString("utf8");
89439
89566
  if (offset > 0) text = text.slice(text.indexOf("\n") + 1);
89440
- return { path: path25, lines: redactedLogTail(text) };
89567
+ return { path: path27, lines: redactedLogTail(text) };
89441
89568
  } catch (error62) {
89442
- return { path: path25, lines: null, readError: error62 instanceof Error ? error62.message : String(error62) };
89569
+ return { path: path27, lines: null, readError: error62 instanceof Error ? error62.message : String(error62) };
89443
89570
  } finally {
89444
89571
  closeSync4(fd);
89445
89572
  }
@@ -89454,7 +89581,7 @@ function renderDoctorReport(i) {
89454
89581
  );
89455
89582
  lines.push("");
89456
89583
  lines.push(
89457
- `CLI: powerplant ${i.cliVersion}` + (i.latestVersion !== null && i.latestVersion !== i.cliVersion ? ` (${i.latestVersion} is available)` : "")
89584
+ `CLI: powerplant ${i.cliVersion}` + (isUpdateAvailable(i.cliVersion, i.latestVersion) ? ` (${i.latestVersion} is available)` : "")
89458
89585
  );
89459
89586
  const unsupported = unsupportedVersionNotice(i.cliVersion, i.oldestSupportedVersion);
89460
89587
  if (unsupported !== null) lines.push(unsupported);
@@ -89640,12 +89767,12 @@ function pauseSyncing(appEnv) {
89640
89767
  function resumeSyncing(appEnv) {
89641
89768
  writeCollectorControl(appEnv, resumedControl(readCollectorControl(appEnv), Date.now()));
89642
89769
  }
89643
- function realPauseDeps(appEnv, resumeCommand, promptLine) {
89770
+ function realPauseDeps(appEnv, resumeCommand2, promptLine) {
89644
89771
  return {
89645
89772
  readControl: () => readCollectorControl(appEnv),
89646
89773
  resume: () => resumeSyncing(appEnv),
89647
89774
  promptLine,
89648
- resumeCommand,
89775
+ resumeCommand: resumeCommand2,
89649
89776
  now: Date.now
89650
89777
  };
89651
89778
  }
@@ -89658,13 +89785,13 @@ function pausedSince(control, now) {
89658
89785
  const age = pausedFor(control, now);
89659
89786
  return age === null ? "Syncing is paused" : `Syncing has been paused for ${age}`;
89660
89787
  }
89661
- function pausedNotice(control, resumeCommand, now) {
89788
+ function pausedNotice(control, resumeCommand2, now) {
89662
89789
  if (!control.paused) return null;
89663
- return `\u23F8 ${pausedSince(control, now)}. Nothing uploads until you run \`${resumeCommand}\`.`;
89790
+ return `\u23F8 ${pausedSince(control, now)}. Nothing uploads until you run \`${resumeCommand2}\`.`;
89664
89791
  }
89665
- function pausedSyncNotice(control, resumeCommand, now, dryRun) {
89666
- if (!control.paused || dryRun) return pausedNotice(control, resumeCommand, now);
89667
- return `\u23F8 ${pausedSince(control, now)}. This pass uploads because you asked for it. Background syncing stays paused until you run \`${resumeCommand}\`.`;
89792
+ function pausedSyncNotice(control, resumeCommand2, now, dryRun) {
89793
+ if (!control.paused || dryRun) return pausedNotice(control, resumeCommand2, now);
89794
+ return `\u23F8 ${pausedSince(control, now)}. This pass uploads because you asked for it. Background syncing stays paused until you run \`${resumeCommand2}\`.`;
89668
89795
  }
89669
89796
  async function offerResume(deps, options) {
89670
89797
  const { log: log3, indent } = options;
@@ -89740,6 +89867,7 @@ async function runInit(deps) {
89740
89867
  let repoDiscoveryEnabled = false;
89741
89868
  let protectedFoldersNeedAttention = false;
89742
89869
  let installed = false;
89870
+ let menubarDidWork = false;
89743
89871
  let pauseOffer = "not-paused";
89744
89872
  log3("2/3 Start background sync");
89745
89873
  log3(" When syncing is enabled, session transcripts upload to Powerplant for the team whose capture settings match the repository.");
@@ -89817,6 +89945,10 @@ async function runInit(deps) {
89817
89945
  pauseOffer = await offerResume(deps.pause, { log: log3, indent: " ", promptAllowed: deps.promptAllowed });
89818
89946
  if (pauseOffer === "not-paused") log3(fresh ? " \u2713 Background sync is running" : "\u2713 Background sync is running");
89819
89947
  await offerAutomaticUpdates(deps.autoUpdate, { log: log3, indent: " ", promptAllowed: deps.promptAllowed });
89948
+ if (deps.menubarApp !== null) {
89949
+ const app = await deps.activity("Setting up the menu bar app\u2026", deps.menubarApp);
89950
+ menubarDidWork = narrateMenubarApp(log3, app);
89951
+ }
89820
89952
  }
89821
89953
  log3("");
89822
89954
  log3("3/3 Give your agents Powerplant MCP access");
@@ -89834,7 +89966,7 @@ async function runInit(deps) {
89834
89966
  log3("");
89835
89967
  const connectDidWork = outcome !== null && outcome.connected + outcome.configured > outcome.unchanged;
89836
89968
  const connectSettled = outcome !== null && outcome.found > 0 && outcome.pending === 0 && outcome.failed === 0 && outcome.skipped === 0 && outcome.unchanged === outcome.found && !connectDidWork;
89837
- if (!enrolled && !installed && !repoDiscoveryEnabled && !protectedFoldersNeedAttention && pauseOffer === "not-paused" && connectSettled) {
89969
+ if (!enrolled && !installed && !menubarDidWork && !repoDiscoveryEnabled && !protectedFoldersNeedAttention && pauseOffer === "not-paused" && connectSettled) {
89838
89970
  log3("Everything is already set up.");
89839
89971
  return;
89840
89972
  }
@@ -89874,6 +90006,25 @@ async function runInit(deps) {
89874
90006
  log3(` Add MCP to the agents you skipped any time: ${deps.connectCommand}`);
89875
90007
  }
89876
90008
  }
90009
+ function narrateMenubarApp(log3, outcome) {
90010
+ switch (outcome.kind) {
90011
+ case "installed":
90012
+ log3(" \u2713 Menu bar app installed, look for the bolt in your menu bar");
90013
+ return true;
90014
+ case "updated":
90015
+ log3(" \u2713 Menu bar app updated to match this CLI");
90016
+ return true;
90017
+ case "already-current":
90018
+ log3(" \u2713 Menu bar app is installed");
90019
+ return outcome.launched;
90020
+ case "skipped":
90021
+ return false;
90022
+ case "failed":
90023
+ log3(` ! Could not set up the menu bar app: ${outcome.detail}`);
90024
+ log3(" Rerun `powerplant init` to try again.");
90025
+ return true;
90026
+ }
90027
+ }
89877
90028
  async function confirmProtectedRepoDiscovery(deps) {
89878
90029
  for (; ; ) {
89879
90030
  const answer = await deps.promptLine(
@@ -89926,10 +90077,10 @@ async function realPromptLine(question) {
89926
90077
 
89927
90078
  // src/memberSessions.ts
89928
90079
  import { execFileSync as execFileSync6 } from "node:child_process";
89929
- import { existsSync as existsSync8 } from "node:fs";
90080
+ import { existsSync as existsSync9 } from "node:fs";
89930
90081
  import { open as open2, readdir as readdir2 } from "node:fs/promises";
89931
- import os17 from "node:os";
89932
- import path21 from "node:path";
90082
+ import os18 from "node:os";
90083
+ import path22 from "node:path";
89933
90084
  var memberSessionSchema = external_exports.object({
89934
90085
  id: external_exports.string().min(1),
89935
90086
  source: external_exports.string().min(1),
@@ -89938,22 +90089,36 @@ var memberSessionSchema = external_exports.object({
89938
90089
  repoDir: external_exports.string().nullable(),
89939
90090
  machineId: external_exports.string().nullable(),
89940
90091
  lastActivityAt: external_exports.string().min(1),
89941
- providerUrl: external_exports.string().nullable()
90092
+ providerUrl: external_exports.string().nullable(),
90093
+ archived: external_exports.boolean().optional(),
90094
+ subagent: external_exports.boolean().optional()
89942
90095
  });
89943
- var FETCH_TIMEOUT_MS2 = 3e3;
89944
- async function fetchMemberSessions(credentials, fetchImpl = fetch) {
90096
+ async function fetchMemberSessions(credentials, fetchImpl = fetch, options = { windowHours: RECENT_SESSION_WINDOW_MS / 36e5, limit: RECENT_SESSION_VISIBLE_LIMIT }) {
90097
+ const { windowHours, limit } = recentSessionOptionsSchema.parse(options);
89945
90098
  try {
89946
- const response = await fetchImpl(`${credentials.apiUrl}/api/collector/member-sessions`, {
90099
+ const query = new URLSearchParams({ view: "recent", windowHours: String(windowHours), limit: String(limit) });
90100
+ const response = await fetchImpl(`${credentials.apiUrl}/api/collector/member-sessions?${query.toString()}`, {
89947
90101
  headers: { authorization: `Bearer ${credentials.token}`, ...cliVersionHeaders() },
89948
- signal: AbortSignal.timeout(FETCH_TIMEOUT_MS2)
90102
+ signal: AbortSignal.timeout(1e4)
89949
90103
  });
89950
- if (!response.ok) return null;
89951
- const envelope = external_exports.object({ data: external_exports.object({ sessions: external_exports.array(memberSessionSchema) }) }).safeParse(await response.json());
89952
- return envelope.success ? envelope.data.data.sessions : null;
90104
+ if (!response.ok) throw new Error(`session read returned ${response.status}`);
90105
+ const { data } = external_exports.object({ data: external_exports.object({
90106
+ sessions: external_exports.array(memberSessionSchema).max(50),
90107
+ nextCursor: external_exports.string().max(512).nullable().optional()
90108
+ }) }).parse(await response.json());
90109
+ return {
90110
+ sessions: data.sessions.slice(0, limit),
90111
+ // Older servers ignore the recent window and omit this field.
90112
+ // A cursor on a supported server is an intentional cap, not a failure.
90113
+ incomplete: data.nextCursor === void 0
90114
+ };
89953
90115
  } catch {
89954
90116
  return null;
89955
90117
  }
89956
90118
  }
90119
+ function resumeCommand(source, sessionId, powerplantUrl) {
90120
+ return ["resume-session", source, sessionId, "--open", powerplantUrl];
90121
+ }
89957
90122
  function sessionLinks(session, webUrl, options) {
89958
90123
  const powerplantUrl = `${webUrl}/rooms/${session.id}`;
89959
90124
  switch (session.source) {
@@ -89966,7 +90131,7 @@ function sessionLinks(session, webUrl, options) {
89966
90131
  extra: {
89967
90132
  label: `Show in ${appName}`,
89968
90133
  focus: { tty, appPid },
89969
- terminal: ["resume-session", "claude-code", session.externalId]
90134
+ terminal: resumeCommand("claude-code", session.externalId, powerplantUrl)
89970
90135
  }
89971
90136
  };
89972
90137
  }
@@ -89983,7 +90148,7 @@ function sessionLinks(session, webUrl, options) {
89983
90148
  powerplantUrl,
89984
90149
  extra: {
89985
90150
  label: "Resume in terminal",
89986
- terminal: ["resume-session", "claude-code", session.externalId]
90151
+ terminal: resumeCommand("claude-code", session.externalId, powerplantUrl)
89987
90152
  }
89988
90153
  };
89989
90154
  case "codex": {
@@ -89991,7 +90156,7 @@ function sessionLinks(session, webUrl, options) {
89991
90156
  if (threadId2 === null || !options.localMachine) return { powerplantUrl };
89992
90157
  return {
89993
90158
  powerplantUrl,
89994
- extra: options.codexDesktop ? { label: "Open in Codex", url: `codex://threads/${threadId2}` } : { label: "Resume in terminal", terminal: ["resume-session", "codex", threadId2] }
90159
+ extra: options.codexDesktop ? { label: "Open in Codex", url: `codex://threads/${threadId2}` } : { label: "Resume in terminal", terminal: resumeCommand("codex", threadId2, powerplantUrl) }
89995
90160
  };
89996
90161
  }
89997
90162
  case "claude-cloud":
@@ -90015,11 +90180,11 @@ function detectCodexDesktop(probe) {
90015
90180
  function detectClaudeDesktop(probe) {
90016
90181
  return detectDesktopScheme(["Claude.app"], "claude", probe);
90017
90182
  }
90018
- function detectDesktopScheme(bundles, scheme, probe = { exists: existsSync8, readUrlSchemes: realReadUrlSchemes }) {
90019
- const roots = ["/Applications", path21.join(os17.homedir(), "Applications")];
90183
+ function detectDesktopScheme(bundles, scheme, probe = { exists: existsSync9, readUrlSchemes: realReadUrlSchemes }) {
90184
+ const roots = ["/Applications", path22.join(os18.homedir(), "Applications")];
90020
90185
  return roots.some(
90021
90186
  (root) => bundles.some((bundle) => {
90022
- const bundlePath = path21.join(root, bundle);
90187
+ const bundlePath = path22.join(root, bundle);
90023
90188
  return probe.exists(bundlePath) && probe.readUrlSchemes(bundlePath).includes(scheme);
90024
90189
  })
90025
90190
  );
@@ -90029,7 +90194,7 @@ function realReadUrlSchemes(bundlePath) {
90029
90194
  try {
90030
90195
  const json2 = execFileSync6(
90031
90196
  "plutil",
90032
- ["-extract", "CFBundleURLTypes", "json", "-o", "-", path21.join(bundlePath, "Contents", "Info.plist")],
90197
+ ["-extract", "CFBundleURLTypes", "json", "-o", "-", path22.join(bundlePath, "Contents", "Info.plist")],
90033
90198
  { stdio: ["ignore", "pipe", "ignore"] }
90034
90199
  ).toString();
90035
90200
  const parsed = urlSchemesSchema.safeParse(JSON.parse(json2));
@@ -90043,7 +90208,7 @@ var claudeDesktopSessionSchema = external_exports.object({
90043
90208
  sessionId: external_exports.string().regex(/^local_[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
90044
90209
  cliSessionId: external_exports.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i)
90045
90210
  });
90046
- async function readClaudeDesktopSessions(wanted, root = path21.join(os17.homedir(), "Library/Application Support/Claude/claude-code-sessions")) {
90211
+ async function readClaudeDesktopSessions(wanted, root = path22.join(os18.homedir(), "Library/Application Support/Claude/claude-code-sessions")) {
90047
90212
  const sessions = /* @__PURE__ */ new Map();
90048
90213
  const ambiguous = /* @__PURE__ */ new Set();
90049
90214
  if (wanted.size === 0) return sessions;
@@ -90054,7 +90219,7 @@ async function readClaudeDesktopSessions(wanted, root = path21.join(os17.homedir
90054
90219
  throw error62;
90055
90220
  });
90056
90221
  for (const entry of entries) {
90057
- const file2 = path21.join(directory, entry.name);
90222
+ const file2 = path22.join(directory, entry.name);
90058
90223
  if (entry.isDirectory() && depth < 2) {
90059
90224
  await visit3(file2, depth + 1);
90060
90225
  } else if (depth === 2 && entry.isFile() && /^local_.*\.json$/.test(entry.name)) {
@@ -90094,7 +90259,7 @@ function isMissingFile(error62) {
90094
90259
  }
90095
90260
 
90096
90261
  // src/menu.ts
90097
- import path22 from "node:path";
90262
+ import path23 from "node:path";
90098
90263
  var MENU_CONTRACT = 1;
90099
90264
  var CLIENT_NAMES = { claude: "Claude Code", codex: "Codex", cursor: "Cursor" };
90100
90265
  function renderMenu(i) {
@@ -90149,10 +90314,10 @@ function renderMenu(i) {
90149
90314
  items.push({ type: "separator" });
90150
90315
  items.push(...collectorBlock(i, envArgs, problem));
90151
90316
  }
90152
- const agents = activeAgentItems(i);
90317
+ const agents = recentAgentItems(i);
90153
90318
  if (agents !== null) {
90154
90319
  items.push({ type: "separator" });
90155
- items.push({ type: "section", title: "Active agents" });
90320
+ items.push({ type: "section", title: "Recent sessions" });
90156
90321
  items.push(...agents);
90157
90322
  }
90158
90323
  if (!unsupported && (isUpdateAvailable(i.cliVersion, i.latestVersion) || progress.kind !== "none")) {
@@ -90288,20 +90453,23 @@ function collectorBlock(i, envArgs, problem) {
90288
90453
  { type: "status", mark: "ok", title: "Background sync running", subtitle: lastUploadLine(i) }
90289
90454
  ];
90290
90455
  }
90291
- var MAX_ACTIVE_AGENTS = 8;
90292
90456
  var AGENT_TITLE_MAX = 48;
90293
- function activeAgentItems(i) {
90457
+ function recentAgentItems(i) {
90294
90458
  if (i.memberSessions === null) return null;
90295
- const active = i.memberSessions.filter((session) => i.now - Date.parse(session.lastActivityAt) < SESSION_ACTIVE_WINDOW_MS).sort((a, b2) => Date.parse(b2.lastActivityAt) - Date.parse(a.lastActivityAt)).map((session) => agentRow(session, i));
90296
- if (active.length === 0) {
90297
- return [{ type: "status", mark: "muted", title: "No active agents" }];
90298
- }
90299
- const openable = active.filter((row) => row.agent?.harness !== void 0).slice(0, MAX_ACTIVE_AGENTS);
90300
- const unavailable = active.filter((row) => row.agent?.harness === void 0).slice(0, MAX_ACTIVE_AGENTS - openable.length);
90301
- return [
90302
- ...openable,
90303
- ...unavailable.length > 0 ? [{ type: "section", title: "Not on this Mac" }, ...unavailable] : []
90304
- ];
90459
+ const recent = i.memberSessions.filter((session) => i.now - Date.parse(session.lastActivityAt) < RECENT_SESSION_WINDOW_MS).filter((session) => session.archived !== true && session.subagent !== true).sort((a, b2) => Date.parse(b2.lastActivityAt) - Date.parse(a.lastActivityAt)).map((session) => agentRow(session, i));
90460
+ const rows = recent.length === 0 ? [{ type: "status", mark: "muted", title: i.memberSessionsIncomplete ? "No sessions found in the partial list" : "No eligible sessions in the latest results" }] : groupedAgentRows(recent.slice(0, RECENT_SESSION_VISIBLE_LIMIT));
90461
+ if (i.memberSessionsIncomplete) rows.push({
90462
+ type: "status",
90463
+ mark: "muted",
90464
+ title: "Session list may be incomplete",
90465
+ subtitle: "Some sessions could not be loaded. The menu will retry on refresh."
90466
+ });
90467
+ return rows;
90468
+ }
90469
+ function groupedAgentRows(rows) {
90470
+ const openable = rows.filter((row) => row.agent?.harness !== void 0);
90471
+ const unavailable = rows.filter((row) => row.agent?.harness === void 0);
90472
+ return [...openable, ...unavailable.length > 0 ? [{ type: "section", title: "Not on this Mac" }, ...unavailable] : []];
90305
90473
  }
90306
90474
  function agentRow(session, i) {
90307
90475
  const name = session.title ?? session.repoDir ?? "Untitled session";
@@ -90395,7 +90563,7 @@ function moreItems(i) {
90395
90563
  muted(captureLine(i.credentials)),
90396
90564
  muted(`Machine "${i.credentials.machineName}"`, i.credentials.machineId),
90397
90565
  muted(`Enrolled ${i.credentials.enrolledAt.slice(0, 10)}`),
90398
- muted(`CLI ${i.cliVersion}`, daemonVersionNote(i))
90566
+ muted(`${parseReleaseVersion(i.cliVersion) === null ? "Development CLI" : "CLI"} ${i.cliVersion}`, daemonVersionNote(i))
90399
90567
  ];
90400
90568
  more.push({ type: "submenu", title: "Background sync details", items: details });
90401
90569
  }
@@ -90435,7 +90603,7 @@ function daemonVersionNote(i) {
90435
90603
  }
90436
90604
  var VERSION_CACHE_TTL_MS = 60 * 6e4;
90437
90605
  function versionCachePath(homeDir, source = "npm") {
90438
- return path22.join(collectorStateDir(homeDir), source === "npm" ? "version-check.json" : "version-check-promoted.json");
90606
+ return path23.join(collectorStateDir(homeDir), source === "npm" ? "version-check.json" : "version-check-promoted.json");
90439
90607
  }
90440
90608
  async function cachedLatestVersion(options) {
90441
90609
  const raw = options.readTextFile(options.cacheFile);
@@ -90463,8 +90631,8 @@ async function cachedLatestVersion(options) {
90463
90631
  // src/liveTerminalSessions.ts
90464
90632
  import { execFileSync as execFileSync7 } from "node:child_process";
90465
90633
  import { readdir as readdir3, readFile as readFile2 } from "node:fs/promises";
90466
- import os18 from "node:os";
90467
- import path23 from "node:path";
90634
+ import os19 from "node:os";
90635
+ import path24 from "node:path";
90468
90636
  var sessionFileAsObserved = external_exports.looseObject({
90469
90637
  pid: external_exports.number().int().positive(),
90470
90638
  sessionId: external_exports.string().min(1),
@@ -90472,8 +90640,8 @@ var sessionFileAsObserved = external_exports.looseObject({
90472
90640
  });
90473
90641
  var START_TIME_TOLERANCE_MS = 3e4;
90474
90642
  var SESSION_FILE = /^(\d+)\.json$/;
90475
- function claudeSessionsDir(homeDir = os18.homedir()) {
90476
- return path23.join(homeDir, ".claude", "sessions");
90643
+ function claudeSessionsDir(homeDir = os19.homedir()) {
90644
+ return path24.join(homeDir, ".claude", "sessions");
90477
90645
  }
90478
90646
  async function readLiveTerminalSessions(wanted, deps = {}) {
90479
90647
  const found = /* @__PURE__ */ new Map();
@@ -90498,7 +90666,7 @@ async function readLiveTerminalSessions(wanted, deps = {}) {
90498
90666
  }
90499
90667
  continue;
90500
90668
  }
90501
- const session = await readSessionFile(path23.join(sessionsDir, entry), report2);
90669
+ const session = await readSessionFile(path24.join(sessionsDir, entry), report2);
90502
90670
  if (session === null) continue;
90503
90671
  if (session.pid !== Number(match[1])) {
90504
90672
  report2({
@@ -90536,7 +90704,7 @@ async function readSessionFile(file2, report2) {
90536
90704
  report2({
90537
90705
  operation: "claude-session-registry-shape",
90538
90706
  message: "A Claude Code session file has a shape this CLI can't read",
90539
- context: { file: path23.basename(file2), shape: describeShape(raw) }
90707
+ context: { file: path24.basename(file2), shape: describeShape(raw) }
90540
90708
  });
90541
90709
  return null;
90542
90710
  }
@@ -90600,7 +90768,7 @@ function parseProcessTable(output2) {
90600
90768
 
90601
90769
  // src/resumeSession.ts
90602
90770
  import { spawnSync as spawnSync3 } from "node:child_process";
90603
- import { existsSync as existsSync9 } from "node:fs";
90771
+ import { existsSync as existsSync10 } from "node:fs";
90604
90772
  var PROVIDERS = {
90605
90773
  "claude-code": {
90606
90774
  resume: (sessionId) => ["claude", ["--resume", sessionId]],
@@ -90622,7 +90790,7 @@ function resumeSessionArgv(source, sessionId) {
90622
90790
  }
90623
90791
  function resumeFolder(source, sessionId, deps = {}) {
90624
90792
  const lookup = deps.sessionFolder ?? ((s, id) => PROVIDERS[s]?.folder(id));
90625
- const exists = deps.exists ?? existsSync9;
90793
+ const exists = deps.exists ?? existsSync10;
90626
90794
  const report2 = deps.report ?? reportCollectorError;
90627
90795
  let recorded;
90628
90796
  try {
@@ -90631,30 +90799,32 @@ function resumeFolder(source, sessionId, deps = {}) {
90631
90799
  report2(error62, "powerplant-resume-session-folder");
90632
90800
  }
90633
90801
  if (recorded === void 0) {
90634
- return {
90635
- cwd: void 0,
90636
- notice: "Couldn't find this session's folder on this Mac, resuming in the current folder."
90637
- };
90802
+ throw new ExpectedCliError(
90803
+ deps.powerplantUrl === void 0 ? "Couldn't find this session's transcript on this Mac, so nothing was started. Open the session in Powerplant instead." : `Couldn't find this session's transcript on this Mac, so nothing was started. You can open it in Powerplant on the web instead: ${deps.powerplantUrl}`
90804
+ );
90638
90805
  }
90639
90806
  if (!exists(recorded)) {
90640
- return {
90641
- cwd: void 0,
90642
- notice: `The session's folder ${recorded} no longer exists, resuming in the current folder.`
90643
- };
90807
+ const [binary, args] = resumeSessionArgv(source, sessionId);
90808
+ throw new ExpectedCliError(
90809
+ `The session's folder ${recorded} no longer exists, so nothing was started. Restore that folder, then run from inside it: ${binary} ${args.join(" ")}`
90810
+ );
90644
90811
  }
90645
- return { cwd: recorded, notice: `Resuming in ${recorded}` };
90812
+ return recorded;
90646
90813
  }
90647
- function runResumeSession(source, sessionId, spawn3 = spawnSync3, folder = resumeFolder, log3 = console.log) {
90814
+ function runResumeSession(source, sessionId, deps = {}) {
90648
90815
  if (source === void 0 || sessionId === void 0) {
90649
90816
  throw new ExpectedCliError("Usage: powerplant resume-session <claude-code|codex> <session-id>");
90650
90817
  }
90818
+ const spawn3 = deps.spawn ?? spawnSync3;
90819
+ const folder = deps.folder ?? resumeFolder;
90820
+ const log3 = deps.log ?? console.log;
90651
90821
  const [binary, args] = resumeSessionArgv(source, sessionId);
90652
- const { cwd, notice } = folder(source, sessionId);
90653
- log3(notice);
90654
- const result = spawn3(binary, args, { stdio: "inherit", ...cwd !== void 0 && { cwd } });
90822
+ const cwd = folder(source, sessionId, { powerplantUrl: deps.powerplantUrl });
90823
+ log3(`Resuming in ${cwd}`);
90824
+ const result = spawn3(binary, args, { stdio: "inherit", cwd });
90655
90825
  if (result.error !== void 0) {
90656
90826
  throw new ExpectedCliError(
90657
- cwd === void 0 ? `Could not run ${binary} (${result.error.message}), is the ${binary} CLI installed on this machine?` : `Could not run ${binary} in ${cwd} (${result.error.message}), does that folder still exist and is the ${binary} CLI installed?`
90827
+ `Could not run ${binary} in ${cwd} (${result.error.message}), does that folder still exist and is the ${binary} CLI installed?`
90658
90828
  );
90659
90829
  }
90660
90830
  if (result.status !== null && result.status !== 0) {
@@ -90677,7 +90847,7 @@ function renderStatus(i) {
90677
90847
  const lines = [];
90678
90848
  lines.push(`Environment: ${i.config.appEnv} (API ${i.config.apiUrl})`);
90679
90849
  lines.push(
90680
- `CLI: powerplant ${i.cliVersion}` + (i.latestVersion !== null && i.latestVersion !== i.cliVersion ? `, ${i.latestVersion} is available: powerplant update` : "")
90850
+ `CLI: powerplant ${i.cliVersion}` + (isUpdateAvailable(i.cliVersion, i.latestVersion) ? `, ${i.latestVersion} is available: powerplant update` : "")
90681
90851
  );
90682
90852
  const unsupported = unsupportedVersionNotice(i.cliVersion, i.oldestSupportedVersion);
90683
90853
  if (unsupported !== null) lines.push(unsupported);
@@ -90793,19 +90963,27 @@ function supportedFlag(cliVersion2, oldestSupportedVersion) {
90793
90963
  return order === null ? null : order !== -1;
90794
90964
  }
90795
90965
  var npmLatestSchema = external_exports.object({ version: external_exports.string().min(1) });
90796
- async function fetchLatestVersion(packageName, fetchImpl = fetch) {
90966
+ async function fetchDistTag(packageName, distTag, fetchImpl = fetch) {
90797
90967
  try {
90798
90968
  const response = await fetchImpl(
90799
- `https://registry.npmjs.org/${encodeURIComponent(packageName)}/latest`,
90969
+ `https://registry.npmjs.org/${encodeURIComponent(packageName)}/${distTag}`,
90800
90970
  { signal: AbortSignal.timeout(3e3) }
90801
90971
  );
90802
- if (!response.ok) return null;
90972
+ if (response.status === 404) return { kind: "absent" };
90973
+ if (!response.ok) return { kind: "unreachable" };
90803
90974
  const parsed = npmLatestSchema.safeParse(await response.json());
90804
- return parsed.success ? parsed.data.version : null;
90975
+ return parsed.success ? { kind: "found", version: parsed.data.version } : { kind: "unreachable" };
90805
90976
  } catch {
90806
- return null;
90977
+ return { kind: "unreachable" };
90807
90978
  }
90808
90979
  }
90980
+ async function fetchNewestRelease(packageName, fetchImpl = fetch) {
90981
+ const next = await fetchDistTag(packageName, "next", fetchImpl);
90982
+ if (next.kind === "found") return next.version;
90983
+ if (next.kind === "unreachable") return null;
90984
+ const latest = await fetchDistTag(packageName, "latest", fetchImpl);
90985
+ return latest.kind === "found" ? latest.version : null;
90986
+ }
90809
90987
  function releaseSource(appEnv) {
90810
90988
  return appEnv === "production" ? "promoted" : "npm";
90811
90989
  }
@@ -90921,6 +91099,137 @@ function createTerminalOutput(options) {
90921
91099
  return { log: log3, activity };
90922
91100
  }
90923
91101
 
91102
+ // src/menubarApp.ts
91103
+ import { existsSync as existsSync11, mkdirSync as mkdirSync10, renameSync as renameSync3, rmSync as rmSync5 } from "node:fs";
91104
+ import os20 from "node:os";
91105
+ import path25 from "node:path";
91106
+ import { spawnSync as spawnSync4 } from "node:child_process";
91107
+ var MENUBAR_APP_ZIP = "dist/menubar/Powerplant.app.zip";
91108
+ var MENUBAR_APP_NAME = "Powerplant.app";
91109
+ var BUNDLE_INFO_TIMEOUT_MS2 = 5e3;
91110
+ async function syncMenubarApp(ops, context2) {
91111
+ const zip = ops.packagedZip();
91112
+ if (zip === null) return { kind: "skipped", reason: "no-packaged-app" };
91113
+ try {
91114
+ const installed = ops.installedApp();
91115
+ if (!installed.present) {
91116
+ if (context2 === "daemon") return { kind: "skipped", reason: "not-installed" };
91117
+ const appPath = ops.freshInstallPath();
91118
+ ops.replace(zip, appPath);
91119
+ ops.launch(appPath);
91120
+ return { kind: "installed" };
91121
+ }
91122
+ const comparison = installed.version === null ? null : compareReleaseVersions(installed.version, ops.cliVersion);
91123
+ if (comparison === 0 || comparison === 1) {
91124
+ const launched = context2 === "init" && !ops.isRunning(installed.appPath);
91125
+ if (launched) ops.launch(installed.appPath);
91126
+ return { kind: "already-current", launched };
91127
+ }
91128
+ const wasRunning = ops.isRunning(installed.appPath);
91129
+ if (wasRunning) await ops.quit(installed.appPath);
91130
+ try {
91131
+ ops.replace(zip, installed.appPath);
91132
+ } catch (error62) {
91133
+ if (wasRunning) ops.launch(installed.appPath);
91134
+ throw error62;
91135
+ }
91136
+ if (wasRunning || context2 === "init") ops.launch(installed.appPath);
91137
+ return { kind: "updated", from: installed.version };
91138
+ } catch (error62) {
91139
+ return { kind: "failed", detail: error62 instanceof Error ? error62.message : String(error62) };
91140
+ }
91141
+ }
91142
+ function realMenubarAppOps(input2) {
91143
+ const home = input2.homeDir ?? os20.homedir();
91144
+ const userAppPath = path25.join(home, "Applications", MENUBAR_APP_NAME);
91145
+ const candidates = [userAppPath, path25.join("/Applications", MENUBAR_APP_NAME)];
91146
+ return {
91147
+ cliVersion: input2.cliVersion,
91148
+ packagedZip: () => {
91149
+ if (input2.packageDir === null) return null;
91150
+ const zip = path25.join(input2.packageDir, MENUBAR_APP_ZIP);
91151
+ return existsSync11(zip) ? zip : null;
91152
+ },
91153
+ installedApp: () => {
91154
+ const appPath = candidates.find((candidate) => existsSync11(candidate));
91155
+ if (appPath === void 0) return { present: false };
91156
+ const info = realReadBundleInfo(appPath, BUNDLE_INFO_TIMEOUT_MS2);
91157
+ return { present: true, appPath, version: info?.version ?? null };
91158
+ },
91159
+ isRunning: (appPath) => appProcessIds(appPath).length > 0,
91160
+ quit: async (appPath) => {
91161
+ const pids = appProcessIds(appPath);
91162
+ for (const pid of pids) tryKill(pid, "SIGTERM");
91163
+ for (let waited = 0; waited < 5e3; waited += 250) {
91164
+ if (pids.every((pid) => !tryKill(pid, 0))) return;
91165
+ await new Promise((resolve2) => setTimeout(resolve2, 250));
91166
+ }
91167
+ throw new Error(`the running app at ${appPath} did not quit`);
91168
+ },
91169
+ replace: (zip, appPath) => {
91170
+ const parent = path25.dirname(appPath);
91171
+ mkdirSync10(parent, { recursive: true });
91172
+ const staging = path25.join(parent, `.${MENUBAR_APP_NAME}.swap-${process.pid}`);
91173
+ const retired = path25.join(parent, `.${MENUBAR_APP_NAME}.old-${process.pid}`);
91174
+ rmSync5(staging, { recursive: true, force: true });
91175
+ rmSync5(retired, { recursive: true, force: true });
91176
+ try {
91177
+ const extract = spawnSync4("ditto", ["-xk", zip, staging]);
91178
+ if (extract.status !== 0) {
91179
+ throw new Error(
91180
+ `ditto could not extract ${zip} (${extract.stderr?.toString().trim() || `exit ${extract.status}`})`
91181
+ );
91182
+ }
91183
+ const extracted = path25.join(staging, MENUBAR_APP_NAME);
91184
+ if (!existsSync11(path25.join(extracted, "Contents", "Info.plist"))) {
91185
+ throw new Error(`${zip} does not contain ${MENUBAR_APP_NAME}`);
91186
+ }
91187
+ const hadOld = existsSync11(appPath);
91188
+ if (hadOld) renameSync3(appPath, retired);
91189
+ try {
91190
+ renameSync3(extracted, appPath);
91191
+ } catch (error62) {
91192
+ if (hadOld) renameSync3(retired, appPath);
91193
+ throw error62;
91194
+ }
91195
+ } finally {
91196
+ rmSync5(staging, { recursive: true, force: true });
91197
+ rmSync5(retired, { recursive: true, force: true });
91198
+ }
91199
+ },
91200
+ launch: (appPath) => {
91201
+ const result = spawnSync4("open", ["-g", appPath]);
91202
+ if (result.status !== 0) {
91203
+ throw new Error(
91204
+ `open could not launch ${appPath} (${result.stderr?.toString().trim() || `exit ${result.status}`})`
91205
+ );
91206
+ }
91207
+ },
91208
+ freshInstallPath: () => userAppPath
91209
+ };
91210
+ }
91211
+ function appProcessIds(appPath) {
91212
+ const executable = path25.join(appPath, "Contents", "MacOS", "PowerplantMenubar");
91213
+ const result = spawnSync4("ps", ["-axo", "pid=,comm="], { encoding: "utf8" });
91214
+ if (result.status !== 0) {
91215
+ throw new Error(`ps could not list processes (${result.error?.message ?? `exit ${result.status}`})`);
91216
+ }
91217
+ const pids = [];
91218
+ for (const line of result.stdout.split("\n")) {
91219
+ const match = /^\s*(\d+)\s+(.*)$/.exec(line);
91220
+ if (match && match[2] === executable) pids.push(Number(match[1]));
91221
+ }
91222
+ return pids;
91223
+ }
91224
+ function tryKill(pid, signal) {
91225
+ try {
91226
+ process.kill(pid, signal);
91227
+ return true;
91228
+ } catch (error62) {
91229
+ return error62 instanceof Error && "code" in error62 && error62.code === "EPERM";
91230
+ }
91231
+ }
91232
+
90924
91233
  // src/workspace.ts
90925
91234
  var workspaceSchema = external_exports.object({
90926
91235
  id: external_exports.string().min(1),
@@ -90928,18 +91237,18 @@ var workspaceSchema = external_exports.object({
90928
91237
  role: external_exports.string().min(1),
90929
91238
  active: external_exports.boolean()
90930
91239
  });
90931
- var FETCH_TIMEOUT_MS3 = 1e4;
90932
- async function callApi(credentials, path25, init3, fetchImpl) {
91240
+ var FETCH_TIMEOUT_MS2 = 1e4;
91241
+ async function callApi(credentials, path27, init3, fetchImpl) {
90933
91242
  let response;
90934
91243
  try {
90935
- response = await fetchImpl(`${credentials.apiUrl}${path25}`, {
91244
+ response = await fetchImpl(`${credentials.apiUrl}${path27}`, {
90936
91245
  ...init3,
90937
91246
  headers: {
90938
91247
  authorization: `Bearer ${credentials.token}`,
90939
91248
  "content-type": "application/json",
90940
91249
  ...cliVersionHeaders()
90941
91250
  },
90942
- signal: AbortSignal.timeout(FETCH_TIMEOUT_MS3)
91251
+ signal: AbortSignal.timeout(FETCH_TIMEOUT_MS2)
90943
91252
  });
90944
91253
  } catch (error62) {
90945
91254
  const detail = error62 instanceof Error ? error62.message : String(error62);
@@ -90951,7 +91260,7 @@ async function callApi(credentials, path25, init3, fetchImpl) {
90951
91260
  );
90952
91261
  }
90953
91262
  if (!response.ok) {
90954
- throw new ExpectedCliError(`Powerplant answered ${response.status} for ${path25}.`);
91263
+ throw new ExpectedCliError(`Powerplant answered ${response.status} for ${path27}.`);
90955
91264
  }
90956
91265
  return response.json();
90957
91266
  }
@@ -91027,6 +91336,7 @@ Commands:
91027
91336
  --client claude|codex|cursor adds just those (repeatable).
91028
91337
  disconnect The inverse of connect: remove the Powerplant MCP entry (and
91029
91338
  its sign-in) from every installed coding agent.
91339
+ --client claude|codex|cursor removes just those (repeatable).
91030
91340
  enroll (Re-)enroll this machine into your org (browser approval).
91031
91341
  status What the background sync is doing on this machine (--json for tools).
91032
91342
  doctor A diagnostics summary for support: status plus the redacted
@@ -91048,7 +91358,8 @@ Commands:
91048
91358
  agents use: powerplant workspace [<name>] switches to <name>.
91049
91359
  resume-session Reopen a synced session in its own CLI, right here in
91050
91360
  this terminal: powerplant resume-session <claude-code|codex>
91051
- <session-id>.
91361
+ <session-id> [--open <its Powerplant page, named when the
91362
+ session can't resume here>].
91052
91363
  watch Run the background sync in the foreground.
91053
91364
  uninstall Remove the background sync [--forget also deletes this
91054
91365
  machine's stored credentials].
@@ -91081,6 +91392,7 @@ function parseCliArgs() {
91081
91392
  // Internal: selects a non-production environment for dogfooding. Keep
91082
91393
  // it out of USAGE and the README — customers only ever see production.
91083
91394
  env: { type: "string" },
91395
+ open: { type: "string" },
91084
91396
  client: { type: "string", multiple: true },
91085
91397
  name: { type: "string" },
91086
91398
  email: { type: "string" },
@@ -91255,6 +91567,7 @@ ${USAGE}`);
91255
91567
  promptLine: realPromptLine
91256
91568
  },
91257
91569
  connect: () => connect3((line) => terminal.log(` ${line}`)),
91570
+ menubarApp: managesMenubarApp(config2) ? () => syncMenubarApp(thisInstallMenubarAppOps(), "init") : null,
91258
91571
  connectCommand,
91259
91572
  environmentName: config2.appEnv,
91260
91573
  webUrl: config2.webUrl
@@ -91270,7 +91583,13 @@ ${USAGE}`);
91270
91583
  return;
91271
91584
  }
91272
91585
  case "disconnect": {
91273
- const outcome = runDisconnect(detectClients({ warn: console.log }), {
91586
+ const detected = detectClients({ warn: console.log });
91587
+ const clients = clientFilter === void 0 ? detected : detected.filter((client) => clientFilter.has(client.client));
91588
+ if (clientFilter !== void 0 && clients.length === 0) {
91589
+ console.log(`No ${[...clientFilter].join(" or ")} installation found on this machine, nothing to disconnect.`);
91590
+ return;
91591
+ }
91592
+ const outcome = runDisconnect(clients, {
91274
91593
  log: console.log,
91275
91594
  run: realRun,
91276
91595
  readTextFile: realReadTextFileStrict,
@@ -91354,7 +91673,7 @@ The access you granted these agents stays on your Powerplant account until you r
91354
91673
  const clients = mergeDetectedClients(
91355
91674
  detectClients({ whichAll: whichAllWith(probePath), budget }),
91356
91675
  saved,
91357
- existsSync10
91676
+ existsSync12
91358
91677
  );
91359
91678
  const [latestVersion, oldestSupportedVersion, memberSessions, grantedClientIds] = await Promise.all([
91360
91679
  cachedAvailableVersion(config2, credentials),
@@ -91368,8 +91687,16 @@ The access you granted these agents stays on your Powerplant account until you r
91368
91687
  readTextFile: realReadTextFile,
91369
91688
  writeTextFile: realWriteTextFile
91370
91689
  });
91690
+ const localFacts = await readLocalSessionFacts(
91691
+ (memberSessions?.sessions ?? []).filter((session) => credentials !== null && session.machineId === credentials.machineId),
91692
+ (error62, source) => reportDaily(error62, `powerplant-menu-${source}-metadata`)
91693
+ );
91694
+ const menuSessions = memberSessions?.sessions.map((session) => ({
91695
+ ...session,
91696
+ ...session.machineId === credentials?.machineId ? localFacts.get(localSessionKey(session)) : {}
91697
+ })) ?? null;
91371
91698
  const localClaudeIds = new Set(
91372
- (memberSessions ?? []).filter((session) => credentials !== null && session.machineId === credentials.machineId && session.source === "claude-code").map((session) => session.externalId)
91699
+ (memberSessions?.sessions ?? []).filter((session) => credentials !== null && session.machineId === credentials.machineId && session.source === "claude-code").map((session) => session.externalId)
91373
91700
  );
91374
91701
  const claudeDesktopSessions = detectClaudeDesktop() ? await readClaudeDesktopSessions(localClaudeIds).catch((error62) => {
91375
91702
  reportDaily(error62, "powerplant-menu-desktop-sessions");
@@ -91402,7 +91729,8 @@ The access you granted these agents stays on your Powerplant account until you r
91402
91729
  readTextFile: realReadTextFileStrict,
91403
91730
  grantedClientIds
91404
91731
  }),
91405
- memberSessions,
91732
+ memberSessions: menuSessions,
91733
+ memberSessionsIncomplete: memberSessions?.incomplete,
91406
91734
  codexDesktop: detectCodexDesktop(),
91407
91735
  claudeDesktopSessions,
91408
91736
  liveTerminalSessions,
@@ -91425,7 +91753,7 @@ The access you granted these agents stays on your Powerplant account until you r
91425
91753
  return;
91426
91754
  }
91427
91755
  case "resume-session": {
91428
- runResumeSession(positionals[1], positionals[2]);
91756
+ runResumeSession(positionals[1], positionals[2], { powerplantUrl: values.open });
91429
91757
  return;
91430
91758
  }
91431
91759
  case "update": {
@@ -91446,13 +91774,14 @@ The access you granted these agents stays on your Powerplant account until you r
91446
91774
  await runUpdate({
91447
91775
  inspection,
91448
91776
  resolveTarget: () => fetchAvailableVersion(config2, loadCredentialsSafely(config2).credentials),
91777
+ channel: releaseSource(config2.appEnv) === "npm" ? "next" : "latest",
91449
91778
  targetRequired: releaseSource(config2.appEnv) === "promoted",
91450
91779
  claimsReservation: process.env[UPDATE_CHILD_ENV] === "1",
91451
91780
  now: Date.now,
91452
91781
  pid: process.pid,
91453
91782
  isProcessAlive: processIsAlive,
91454
91783
  run: (bin, args) => {
91455
- const result = spawnSync4(bin, args, { stdio: "inherit" });
91784
+ const result = spawnSync5(bin, args, { stdio: "inherit" });
91456
91785
  return result.error ? { status: result.status, error: result.error.message } : { status: result.status };
91457
91786
  },
91458
91787
  readInstalledVersion: (packageDir) => installedVersion(packageDir, realReadTextFile),
@@ -91572,7 +91901,7 @@ function inspectThisInstall() {
91572
91901
  }
91573
91902
  var UPDATE_CHILD_ENV = "POWERPLANT_UPDATE_CHILD";
91574
91903
  function fetchAvailableVersion(config2, credentials) {
91575
- if (releaseSource(config2.appEnv) === "npm") return fetchLatestVersion(CLI_PACKAGE_NAME);
91904
+ if (releaseSource(config2.appEnv) === "npm") return fetchNewestRelease(CLI_PACKAGE_NAME);
91576
91905
  if (credentials === null) return Promise.resolve(null);
91577
91906
  return fetchVersionPolicy(credentials.apiUrl, credentials.token).then(
91578
91907
  (policy) => policy?.promotedVersion ?? null
@@ -91595,7 +91924,7 @@ function startBackgroundUpdate(config2, target) {
91595
91924
  readProgress: updateProgress.read,
91596
91925
  writeProgress: updateProgress.write,
91597
91926
  spawnChild: () => {
91598
- mkdirSync10(path24.dirname(updateLogPath()), { recursive: true });
91927
+ mkdirSync11(path26.dirname(updateLogPath()), { recursive: true });
91599
91928
  const log3 = openSync5(updateLogPath(), "a");
91600
91929
  const child = spawn2(process.execPath, [entryPath(), "update", ...envArgsFor(config2)], {
91601
91930
  detached: true,
@@ -91609,10 +91938,21 @@ function startBackgroundUpdate(config2, target) {
91609
91938
  }
91610
91939
  function automaticUpdateCheck(config2) {
91611
91940
  let saidCannot = false;
91941
+ let menubarSynced = false;
91612
91942
  return async (log3) => {
91943
+ const inspection = inspectThisInstall();
91944
+ if (managesMenubarApp(config2) && !menubarSynced) {
91945
+ menubarSynced = true;
91946
+ const app = await syncMenubarApp(
91947
+ realMenubarAppOps({ cliVersion: CLI_VERSION, packageDir: inspection.packageDir }),
91948
+ "daemon"
91949
+ );
91950
+ if (app.kind === "updated") log3(`menu bar app updated to ${CLI_VERSION}`);
91951
+ if (app.kind === "failed") log3(`\u26A0 menu bar app could not be updated: ${app.detail}`);
91952
+ }
91613
91953
  const decision = autoUpdateDecision({
91614
91954
  control: readCollectorControl(config2.appEnv),
91615
- inspection: inspectThisInstall(),
91955
+ inspection,
91616
91956
  cliVersion: CLI_VERSION,
91617
91957
  latestVersion: await cachedAvailableVersion(config2, loadCredentialsSafely(config2).credentials),
91618
91958
  progress: updateProgress.read(),
@@ -91630,6 +91970,12 @@ function automaticUpdateCheck(config2) {
91630
91970
  }
91631
91971
  };
91632
91972
  }
91973
+ function managesMenubarApp(config2) {
91974
+ return config2.appEnv === "production" && process.platform === "darwin";
91975
+ }
91976
+ function thisInstallMenubarAppOps() {
91977
+ return realMenubarAppOps({ cliVersion: CLI_VERSION, packageDir: inspectThisInstall().packageDir });
91978
+ }
91633
91979
  function restartSyncOnNewCode(config2) {
91634
91980
  const state = serviceState(config2);
91635
91981
  if (state === "unsupported" || state === "not-installed") return state;
@@ -91641,7 +91987,7 @@ function restartSyncOnNewCode(config2) {
91641
91987
  var updateProgress = {
91642
91988
  read: () => readUpdateProgress(realReadTextFile),
91643
91989
  write: (record2) => realWriteTextFile(updateProgressPath(), JSON.stringify(record2, null, 2)),
91644
- clear: () => rmSync5(updateProgressPath(), { force: true })
91990
+ clear: () => rmSync6(updateProgressPath(), { force: true })
91645
91991
  };
91646
91992
  function envArgsFor(config2) {
91647
91993
  return config2.appEnv === "production" ? [] : ["--env", config2.appEnv];
@@ -91665,8 +92011,13 @@ function entryPath() {
91665
92011
  }
91666
92012
  var cliCommand = "none";
91667
92013
  main().catch(async (error62) => {
91668
- if (error62 instanceof ExpectedCliError) console.error(error62.message);
91669
- else console.error(error62);
92014
+ if (error62 instanceof ExpectedCliError) {
92015
+ console.error(
92016
+ terminalUsesEffects(process.stderr.isTTY === true, process.env) ? styleLine(error62.message) : error62.message
92017
+ );
92018
+ } else {
92019
+ console.error(error62);
92020
+ }
91670
92021
  reportCollectorError(error62, `powerplant-cli-${cliCommand}`);
91671
92022
  await flushReporting();
91672
92023
  process.exitCode = 1;