@usepowerplant/cli 0.4.4 → 0.4.6
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/README.md +108 -19
- package/dist/cli.js +1127 -560
- package/dist/menubar/Powerplant.app.zip +0 -0
- package/package.json +1 -1
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
|
|
6880
|
+
var path29 = "";
|
|
6881
6881
|
var lastSegmentIndex = segments.length - 1;
|
|
6882
6882
|
for (var i2 = index + offset; i2 <= lastSegmentIndex; i2++) {
|
|
6883
6883
|
if (i2 === lastSegmentIndex) {
|
|
6884
|
-
|
|
6884
|
+
path29 += segments[i2];
|
|
6885
6885
|
} else {
|
|
6886
|
-
|
|
6886
|
+
path29 += segments[i2] + sep2;
|
|
6887
6887
|
}
|
|
6888
6888
|
}
|
|
6889
6889
|
return {
|
|
6890
6890
|
name,
|
|
6891
6891
|
basedir,
|
|
6892
|
-
path:
|
|
6892
|
+
path: path29
|
|
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
|
|
6902
|
+
var path29 = __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 =
|
|
7047
|
+
const parsedPath = path29.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 +
|
|
7085
|
+
moduleName = moduleName + path29.sep + path29.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 =
|
|
7122
|
-
return
|
|
7121
|
+
const normalizedPath = path29.sep !== "/" ? stat.path.split(path29.sep).join("/") : stat.path;
|
|
7122
|
+
return path29.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
|
|
7207
|
+
var path29 = __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
|
|
7271
|
+
return path29.sep !== ModuleNameTrie_1.ModuleNameSeparator ? moduleNameOrPath.split(path29.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
|
|
7437
|
+
var path29 = __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 +
|
|
7556
|
+
const internalPath = name + path29.sep + path29.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
|
|
7631
|
+
var path29 = __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)(
|
|
7732
|
+
const json2 = (0, fs_1.readFileSync)(path29.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 =
|
|
7774
|
+
const normalizedName = path29.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 &&
|
|
7821
|
-
const parsedPath =
|
|
7820
|
+
if (!baseDir && path29.isAbsolute(name)) {
|
|
7821
|
+
const parsedPath = path29.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 =
|
|
7830
|
+
const hook = path29.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
|
|
8438
|
+
for (const path29 of paths) {
|
|
8439
8439
|
try {
|
|
8440
|
-
const result = await fs_1.promises.readFile(
|
|
8440
|
+
const result = await fs_1.promises.readFile(path29, { 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
|
|
8646
|
+
var os22 = __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 =
|
|
8666
|
+
const userInfo = os22.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
|
|
11800
|
+
let path29 = 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 (
|
|
11805
|
-
|
|
11804
|
+
if (path29 && path29[0] !== "/") {
|
|
11805
|
+
path29 = `/${path29}`;
|
|
11806
11806
|
}
|
|
11807
|
-
return new URL(`${origin}${
|
|
11807
|
+
return new URL(`${origin}${path29}`);
|
|
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:
|
|
12628
|
+
request: { method, path: path29, origin }
|
|
12629
12629
|
} = evt;
|
|
12630
|
-
debugLog3("sending request to %s %s%s", method, origin,
|
|
12630
|
+
debugLog3("sending request to %s %s%s", method, origin, path29);
|
|
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:
|
|
12648
|
+
request: { method, path: path29, 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
|
-
|
|
12655
|
+
path29,
|
|
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:
|
|
12664
|
+
request: { method, path: path29, origin }
|
|
12665
12665
|
} = evt;
|
|
12666
|
-
debugLog3("trailers received from %s %s%s", method, origin,
|
|
12666
|
+
debugLog3("trailers received from %s %s%s", method, origin, path29);
|
|
12667
12667
|
}
|
|
12668
12668
|
);
|
|
12669
12669
|
diagnosticsChannel9.subscribe(
|
|
12670
12670
|
"undici:request:error",
|
|
12671
12671
|
(evt) => {
|
|
12672
12672
|
const {
|
|
12673
|
-
request: { method, path:
|
|
12673
|
+
request: { method, path: path29, 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
|
-
|
|
12680
|
+
path29,
|
|
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:
|
|
12795
|
+
path: path29,
|
|
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
|
|
12812
|
+
if (typeof path29 !== "string") {
|
|
12813
12813
|
throw new InvalidArgumentError("path must be a string");
|
|
12814
|
-
} else if (
|
|
12814
|
+
} else if (path29[0] !== "/" && !(path29.startsWith("http://") || path29.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(
|
|
12816
|
+
} else if (invalidPathRegex.test(path29)) {
|
|
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(
|
|
12891
|
+
this.path = query ? serializePathWithQuery(path29, query) : path29;
|
|
12892
12892
|
this.origin = origin;
|
|
12893
12893
|
this.protocol = getProtocolFromUrlString(origin);
|
|
12894
12894
|
this.idempotent = idempotent == null ? method === "HEAD" || method === "GET" : idempotent;
|
|
@@ -17281,7 +17281,7 @@ var require_client_h1 = __commonJS({
|
|
|
17281
17281
|
kHTTPContext,
|
|
17282
17282
|
kClosed
|
|
17283
17283
|
} = require_symbols();
|
|
17284
|
-
var
|
|
17284
|
+
var constants3 = require_constants3();
|
|
17285
17285
|
var EMPTY_BUF = Buffer.alloc(0);
|
|
17286
17286
|
var FastBuffer = Buffer[Symbol.species];
|
|
17287
17287
|
var removeAllListeners = util2.removeAllListeners;
|
|
@@ -17410,7 +17410,7 @@ var require_client_h1 = __commonJS({
|
|
|
17410
17410
|
*/
|
|
17411
17411
|
constructor(client, socket, { exports: exports2 }) {
|
|
17412
17412
|
this.llhttp = exports2;
|
|
17413
|
-
this.ptr = this.llhttp.llhttp_alloc(
|
|
17413
|
+
this.ptr = this.llhttp.llhttp_alloc(constants3.TYPE.RESPONSE);
|
|
17414
17414
|
this.client = client;
|
|
17415
17415
|
this.socket = socket;
|
|
17416
17416
|
this.timeout = null;
|
|
@@ -17506,11 +17506,11 @@ var require_client_h1 = __commonJS({
|
|
|
17506
17506
|
currentParser = null;
|
|
17507
17507
|
currentBufferRef = null;
|
|
17508
17508
|
}
|
|
17509
|
-
if (ret !==
|
|
17509
|
+
if (ret !== constants3.ERROR.OK) {
|
|
17510
17510
|
const data = chunk.subarray(llhttp.llhttp_get_error_pos(this.ptr) - currentBufferPtr);
|
|
17511
|
-
if (ret ===
|
|
17511
|
+
if (ret === constants3.ERROR.PAUSED_UPGRADE) {
|
|
17512
17512
|
this.onUpgrade(data);
|
|
17513
|
-
} else if (ret ===
|
|
17513
|
+
} else if (ret === constants3.ERROR.PAUSED) {
|
|
17514
17514
|
this.paused = true;
|
|
17515
17515
|
socket.unshift(data);
|
|
17516
17516
|
} else {
|
|
@@ -17533,10 +17533,10 @@ var require_client_h1 = __commonJS({
|
|
|
17533
17533
|
} finally {
|
|
17534
17534
|
currentParser = null;
|
|
17535
17535
|
}
|
|
17536
|
-
if (ret ===
|
|
17536
|
+
if (ret === constants3.ERROR.OK) {
|
|
17537
17537
|
return null;
|
|
17538
17538
|
}
|
|
17539
|
-
if (ret ===
|
|
17539
|
+
if (ret === constants3.ERROR.PAUSED || ret === constants3.ERROR.PAUSED_UPGRADE) {
|
|
17540
17540
|
this.paused = true;
|
|
17541
17541
|
return null;
|
|
17542
17542
|
}
|
|
@@ -17553,7 +17553,7 @@ var require_client_h1 = __commonJS({
|
|
|
17553
17553
|
const len = new Uint8Array(llhttp.memory.buffer, ptr).indexOf(0);
|
|
17554
17554
|
message2 = "Response does not match the HTTP/1.1 protocol (" + Buffer.from(llhttp.memory.buffer, ptr, len).toString() + ")";
|
|
17555
17555
|
}
|
|
17556
|
-
return new HTTPParserError(message2,
|
|
17556
|
+
return new HTTPParserError(message2, constants3.ERROR[ret], data);
|
|
17557
17557
|
}
|
|
17558
17558
|
destroy() {
|
|
17559
17559
|
assert2(currentParser === null);
|
|
@@ -17763,7 +17763,7 @@ var require_client_h1 = __commonJS({
|
|
|
17763
17763
|
socket[kBlocking] = false;
|
|
17764
17764
|
client[kResume]();
|
|
17765
17765
|
}
|
|
17766
|
-
return pause ?
|
|
17766
|
+
return pause ? constants3.ERROR.PAUSED : 0;
|
|
17767
17767
|
}
|
|
17768
17768
|
/**
|
|
17769
17769
|
* @param {Buffer} buf
|
|
@@ -17789,7 +17789,7 @@ var require_client_h1 = __commonJS({
|
|
|
17789
17789
|
}
|
|
17790
17790
|
this.bytesRead += buf.length;
|
|
17791
17791
|
if (request2.onData(buf) === false) {
|
|
17792
|
-
return
|
|
17792
|
+
return constants3.ERROR.PAUSED;
|
|
17793
17793
|
}
|
|
17794
17794
|
return 0;
|
|
17795
17795
|
}
|
|
@@ -17829,13 +17829,13 @@ var require_client_h1 = __commonJS({
|
|
|
17829
17829
|
if (socket[kWriting]) {
|
|
17830
17830
|
assert2(client[kRunning] === 0);
|
|
17831
17831
|
util2.destroy(socket, new InformationalError("reset"));
|
|
17832
|
-
return
|
|
17832
|
+
return constants3.ERROR.PAUSED;
|
|
17833
17833
|
} else if (!shouldKeepAlive) {
|
|
17834
17834
|
util2.destroy(socket, new InformationalError("reset"));
|
|
17835
|
-
return
|
|
17835
|
+
return constants3.ERROR.PAUSED;
|
|
17836
17836
|
} else if (socket[kReset] && client[kRunning] === 0) {
|
|
17837
17837
|
util2.destroy(socket, new InformationalError("reset"));
|
|
17838
|
-
return
|
|
17838
|
+
return constants3.ERROR.PAUSED;
|
|
17839
17839
|
} else if (client[kPipelining] == null || client[kPipelining] === 1) {
|
|
17840
17840
|
setImmediate(client[kResume]);
|
|
17841
17841
|
} else {
|
|
@@ -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:
|
|
18073
|
+
const { method, path: path29, 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} ${
|
|
18151
|
+
let header = `${method} ${path29} 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:
|
|
18830
|
+
const { method, path: path29, 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] =
|
|
18899
|
+
headers[HTTP2_HEADER_PATH] = path29;
|
|
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] =
|
|
18941
|
+
headers[HTTP2_HEADER_PATH] = path29;
|
|
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:
|
|
21293
|
+
path: path29 = "/",
|
|
21294
21294
|
headers = {}
|
|
21295
21295
|
} = opts;
|
|
21296
|
-
opts.path = origin +
|
|
21296
|
+
opts.path = origin + path29;
|
|
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(
|
|
23406
|
-
if (typeof
|
|
23407
|
-
return
|
|
23405
|
+
function safeUrl(path29) {
|
|
23406
|
+
if (typeof path29 !== "string") {
|
|
23407
|
+
return path29;
|
|
23408
23408
|
}
|
|
23409
|
-
const pathSegments =
|
|
23409
|
+
const pathSegments = path29.split("?", 3);
|
|
23410
23410
|
if (pathSegments.length !== 2) {
|
|
23411
|
-
return
|
|
23411
|
+
return path29;
|
|
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:
|
|
23418
|
-
const pathMatch = matchValue(mockDispatch2.path,
|
|
23417
|
+
function matchKey(mockDispatch2, { path: path29, method, body, headers }) {
|
|
23418
|
+
const pathMatch = matchValue(mockDispatch2.path, path29);
|
|
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:
|
|
23444
|
-
return ignoreTrailingSlash ? matchValue(removeTrailingSlash(safeUrl(
|
|
23443
|
+
let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path: path29, ignoreTrailingSlash }) => {
|
|
23444
|
+
return ignoreTrailingSlash ? matchValue(removeTrailingSlash(safeUrl(path29)), resolvedPathWithoutTrailingSlash) : matchValue(safeUrl(path29), 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(
|
|
23484
|
-
while (
|
|
23485
|
-
|
|
23483
|
+
function removeTrailingSlash(path29) {
|
|
23484
|
+
while (path29.endsWith("/")) {
|
|
23485
|
+
path29 = path29.slice(0, -1);
|
|
23486
23486
|
}
|
|
23487
|
-
if (
|
|
23488
|
-
|
|
23487
|
+
if (path29.length === 0) {
|
|
23488
|
+
path29 = "/";
|
|
23489
23489
|
}
|
|
23490
|
-
return
|
|
23490
|
+
return path29;
|
|
23491
23491
|
}
|
|
23492
23492
|
function buildKey(opts) {
|
|
23493
|
-
const { path:
|
|
23493
|
+
const { path: path29, method, body, headers, query } = opts;
|
|
23494
23494
|
return {
|
|
23495
|
-
path:
|
|
23495
|
+
path: path29,
|
|
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:
|
|
24185
|
+
({ method, path: path29, data: { statusCode }, persist, times, timesInvoked, origin }) => ({
|
|
24186
24186
|
Method: method,
|
|
24187
24187
|
Origin: origin,
|
|
24188
|
-
Path:
|
|
24188
|
+
Path: path29,
|
|
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 [
|
|
24270
|
+
const [path29, searchParams] = dispatchOpts.path.split("?");
|
|
24271
24271
|
const normalizedSearchParams = normalizeSearchParams(searchParams, acceptNonStandardSearchParameters);
|
|
24272
|
-
dispatchOpts.path = `${
|
|
24272
|
+
dispatchOpts.path = `${path29}?${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
|
|
24674
|
-
if (!
|
|
24673
|
+
const path29 = filePath || this.#snapshotPath;
|
|
24674
|
+
if (!path29) {
|
|
24675
24675
|
throw new InvalidArgumentError("Snapshot path is required");
|
|
24676
24676
|
}
|
|
24677
24677
|
try {
|
|
24678
|
-
const data = await readFile3(resolve2(
|
|
24678
|
+
const data = await readFile3(resolve2(path29), "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 ${
|
|
24692
|
+
throw new UndiciError(`Failed to load snapshots from ${path29}`, { 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
|
|
24704
|
-
if (!
|
|
24703
|
+
const path29 = filePath || this.#snapshotPath;
|
|
24704
|
+
if (!path29) {
|
|
24705
24705
|
throw new InvalidArgumentError("Snapshot path is required");
|
|
24706
24706
|
}
|
|
24707
|
-
const resolvedPath = resolve2(
|
|
24707
|
+
const resolvedPath = resolve2(path29);
|
|
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
|
|
25340
|
-
const redirectUrlString = `${origin}${
|
|
25339
|
+
const path29 = search ? `${pathname}${search}` : pathname;
|
|
25340
|
+
const redirectUrlString = `${origin}${path29}`;
|
|
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 =
|
|
25347
|
+
this.opts.path = path29;
|
|
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,
|
|
27107
|
+
function deleteCachedUri(store, cacheKey, path29) {
|
|
27108
27108
|
deleteCachedValue(store, {
|
|
27109
27109
|
...cacheKey,
|
|
27110
|
-
path:
|
|
27110
|
+
path: path29
|
|
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:
|
|
27118
|
+
path: path29
|
|
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
|
|
27130
|
-
if (
|
|
27131
|
-
deleteCachedUri(store, cacheKey,
|
|
27129
|
+
const path29 = getSameOriginPath(cacheKey, values[i]);
|
|
27130
|
+
if (path29 !== void 0) {
|
|
27131
|
+
deleteCachedUri(store, cacheKey, path29);
|
|
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
|
|
32131
|
+
const path29 = 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 ? `${
|
|
32135
|
+
path: hasTrailingQuestionMark ? `${path29}?` : path29,
|
|
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(
|
|
33083
|
-
for (let i = 0; i <
|
|
33084
|
-
const code =
|
|
33082
|
+
function validateCookiePath(path29) {
|
|
33083
|
+
for (let i = 0; i < path29.length; ++i) {
|
|
33084
|
+
const code = path29.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
|
|
36432
|
+
let path29 = opts.path;
|
|
36433
36433
|
if (!opts.path.startsWith("/")) {
|
|
36434
|
-
|
|
36434
|
+
path29 = `/${path29}`;
|
|
36435
36435
|
}
|
|
36436
|
-
url2 = new URL(util2.parseOrigin(url2).origin +
|
|
36436
|
+
url2 = new URL(util2.parseOrigin(url2).origin + path29);
|
|
36437
36437
|
} else {
|
|
36438
36438
|
if (!opts) {
|
|
36439
36439
|
opts = typeof url2 === "object" ? url2 : {};
|
|
@@ -36542,11 +36542,8 @@ ${captureLines}` : capture.stack;
|
|
|
36542
36542
|
}
|
|
36543
36543
|
});
|
|
36544
36544
|
|
|
36545
|
-
// src/
|
|
36546
|
-
import {
|
|
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";
|
|
36549
|
-
import { parseArgs } from "node:util";
|
|
36545
|
+
// src/clientFailure.ts
|
|
36546
|
+
import { constants } from "node:os";
|
|
36550
36547
|
|
|
36551
36548
|
// ../../apps/collector/src/credentials.ts
|
|
36552
36549
|
import { execFileSync } from "node:child_process";
|
|
@@ -37298,10 +37295,10 @@ function mergeDefs(...defs) {
|
|
|
37298
37295
|
function cloneDef(schema) {
|
|
37299
37296
|
return mergeDefs(schema._zod.def);
|
|
37300
37297
|
}
|
|
37301
|
-
function getElementAtPath(obj,
|
|
37302
|
-
if (!
|
|
37298
|
+
function getElementAtPath(obj, path29) {
|
|
37299
|
+
if (!path29)
|
|
37303
37300
|
return obj;
|
|
37304
|
-
return
|
|
37301
|
+
return path29.reduce((acc, key) => acc?.[key], obj);
|
|
37305
37302
|
}
|
|
37306
37303
|
function promiseAllObject(promisesObj) {
|
|
37307
37304
|
const keys = Object.keys(promisesObj);
|
|
@@ -37713,11 +37710,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
37713
37710
|
}
|
|
37714
37711
|
return false;
|
|
37715
37712
|
}
|
|
37716
|
-
function prefixIssues(
|
|
37713
|
+
function prefixIssues(path29, issues) {
|
|
37717
37714
|
return issues.map((iss) => {
|
|
37718
37715
|
var _a4;
|
|
37719
37716
|
(_a4 = iss).path ?? (_a4.path = []);
|
|
37720
|
-
iss.path.unshift(
|
|
37717
|
+
iss.path.unshift(path29);
|
|
37721
37718
|
return iss;
|
|
37722
37719
|
});
|
|
37723
37720
|
}
|
|
@@ -38150,16 +38147,16 @@ function flattenError(error62, mapper = (issue2) => issue2.message) {
|
|
|
38150
38147
|
}
|
|
38151
38148
|
function formatError(error62, mapper = (issue2) => issue2.message) {
|
|
38152
38149
|
const fieldErrors = { _errors: [] };
|
|
38153
|
-
const processError = (error63,
|
|
38150
|
+
const processError = (error63, path29 = []) => {
|
|
38154
38151
|
for (const issue2 of error63.issues) {
|
|
38155
38152
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
38156
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
38153
|
+
issue2.errors.map((issues) => processError({ issues }, [...path29, ...issue2.path]));
|
|
38157
38154
|
} else if (issue2.code === "invalid_key") {
|
|
38158
|
-
processError({ issues: issue2.issues }, [...
|
|
38155
|
+
processError({ issues: issue2.issues }, [...path29, ...issue2.path]);
|
|
38159
38156
|
} else if (issue2.code === "invalid_element") {
|
|
38160
|
-
processError({ issues: issue2.issues }, [...
|
|
38157
|
+
processError({ issues: issue2.issues }, [...path29, ...issue2.path]);
|
|
38161
38158
|
} else {
|
|
38162
|
-
const fullpath = [...
|
|
38159
|
+
const fullpath = [...path29, ...issue2.path];
|
|
38163
38160
|
if (fullpath.length === 0) {
|
|
38164
38161
|
fieldErrors._errors.push(mapper(issue2));
|
|
38165
38162
|
} else {
|
|
@@ -38198,17 +38195,17 @@ function formatError(error62, mapper = (issue2) => issue2.message) {
|
|
|
38198
38195
|
}
|
|
38199
38196
|
function treeifyError(error62, mapper = (issue2) => issue2.message) {
|
|
38200
38197
|
const result = { errors: [] };
|
|
38201
|
-
const processError = (error63,
|
|
38198
|
+
const processError = (error63, path29 = []) => {
|
|
38202
38199
|
var _a4;
|
|
38203
38200
|
for (const issue2 of error63.issues) {
|
|
38204
38201
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
38205
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
38202
|
+
issue2.errors.map((issues) => processError({ issues }, [...path29, ...issue2.path]));
|
|
38206
38203
|
} else if (issue2.code === "invalid_key") {
|
|
38207
|
-
processError({ issues: issue2.issues }, [...
|
|
38204
|
+
processError({ issues: issue2.issues }, [...path29, ...issue2.path]);
|
|
38208
38205
|
} else if (issue2.code === "invalid_element") {
|
|
38209
|
-
processError({ issues: issue2.issues }, [...
|
|
38206
|
+
processError({ issues: issue2.issues }, [...path29, ...issue2.path]);
|
|
38210
38207
|
} else {
|
|
38211
|
-
const fullpath = [...
|
|
38208
|
+
const fullpath = [...path29, ...issue2.path];
|
|
38212
38209
|
if (fullpath.length === 0) {
|
|
38213
38210
|
result.errors.push(mapper(issue2));
|
|
38214
38211
|
continue;
|
|
@@ -38247,8 +38244,8 @@ function treeifyError(error62, mapper = (issue2) => issue2.message) {
|
|
|
38247
38244
|
}
|
|
38248
38245
|
function toDotPath(_path) {
|
|
38249
38246
|
const segs = [];
|
|
38250
|
-
const
|
|
38251
|
-
for (const seg of
|
|
38247
|
+
const path29 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
38248
|
+
for (const seg of path29) {
|
|
38252
38249
|
if (typeof seg === "number")
|
|
38253
38250
|
segs.push(`[${seg}]`);
|
|
38254
38251
|
else if (typeof seg === "symbol")
|
|
@@ -54758,13 +54755,13 @@ function resolveRef(ref, ctx) {
|
|
|
54758
54755
|
if (!ref.startsWith("#")) {
|
|
54759
54756
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
54760
54757
|
}
|
|
54761
|
-
const
|
|
54762
|
-
if (
|
|
54758
|
+
const path29 = ref.slice(1).split("/").filter(Boolean);
|
|
54759
|
+
if (path29.length === 0) {
|
|
54763
54760
|
return ctx.rootSchema;
|
|
54764
54761
|
}
|
|
54765
54762
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
54766
|
-
if (
|
|
54767
|
-
const key =
|
|
54763
|
+
if (path29[0] === defsKey) {
|
|
54764
|
+
const key = path29[1] === void 0 ? void 0 : decodeJSONPointerSegment(path29[1]);
|
|
54768
54765
|
if (!key || !ctx.defs[key]) {
|
|
54769
54766
|
throw new Error(`Reference not found: ${ref}`);
|
|
54770
54767
|
}
|
|
@@ -56053,8 +56050,8 @@ function primaryArg(args) {
|
|
|
56053
56050
|
function readFilePath(name, primary) {
|
|
56054
56051
|
if (!primary || !READ_TOOLS.has(name)) return null;
|
|
56055
56052
|
if (ARTIFACT_PATH_RE.test(primary)) return null;
|
|
56056
|
-
const
|
|
56057
|
-
return
|
|
56053
|
+
const path29 = primary.startsWith("/workspace/") ? primary.slice("/workspace/".length) : primary;
|
|
56054
|
+
return path29.length > 0 ? path29 : null;
|
|
56058
56055
|
}
|
|
56059
56056
|
function asRecord3(value) {
|
|
56060
56057
|
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
@@ -56452,6 +56449,57 @@ var collectorDiagnosticSchema = external_exports.strictObject({
|
|
|
56452
56449
|
pass: collectorPassDiagnosticSchema.nullable()
|
|
56453
56450
|
});
|
|
56454
56451
|
|
|
56452
|
+
// ../core/src/harnessSessionFacts.ts
|
|
56453
|
+
var trueFlag = external_exports.union([external_exports.literal(true), external_exports.literal(1)]);
|
|
56454
|
+
var HARNESS_SESSION_RULES = {
|
|
56455
|
+
codex: [
|
|
56456
|
+
{
|
|
56457
|
+
fact: "subagent",
|
|
56458
|
+
evidence: external_exports.object({ thread_source: external_exports.enum(["subagent", "guardian_review"]) })
|
|
56459
|
+
},
|
|
56460
|
+
{ fact: "subagent", evidence: external_exports.object({ source: external_exports.object({ subagent: external_exports.object({}) }) }) },
|
|
56461
|
+
{
|
|
56462
|
+
fact: "standaloneReview",
|
|
56463
|
+
evidence: external_exports.object({
|
|
56464
|
+
source: external_exports.literal("exec"),
|
|
56465
|
+
thread_source: external_exports.literal("user"),
|
|
56466
|
+
// The adapter supplies the record immediately after session_meta.
|
|
56467
|
+
initialEvent: external_exports.object({
|
|
56468
|
+
type: external_exports.literal("event_msg"),
|
|
56469
|
+
payload: external_exports.object({
|
|
56470
|
+
type: external_exports.literal("item_completed"),
|
|
56471
|
+
item: external_exports.object({ type: external_exports.literal("EnteredReviewMode") })
|
|
56472
|
+
})
|
|
56473
|
+
})
|
|
56474
|
+
})
|
|
56475
|
+
},
|
|
56476
|
+
{ fact: "archived", evidence: external_exports.object({ archived: trueFlag }) }
|
|
56477
|
+
],
|
|
56478
|
+
cursor: [
|
|
56479
|
+
{ fact: "subagent", evidence: external_exports.object({ isSubagent: trueFlag }) },
|
|
56480
|
+
{ fact: "archived", evidence: external_exports.object({ isArchived: trueFlag }) }
|
|
56481
|
+
]
|
|
56482
|
+
};
|
|
56483
|
+
function harnessSessionFacts(source, evidence) {
|
|
56484
|
+
const facts = {};
|
|
56485
|
+
for (const rule of Object.hasOwn(HARNESS_SESSION_RULES, source) ? HARNESS_SESSION_RULES[source] ?? [] : []) {
|
|
56486
|
+
if (rule.evidence.safeParse(evidence).success) facts[rule.fact] = true;
|
|
56487
|
+
}
|
|
56488
|
+
return facts;
|
|
56489
|
+
}
|
|
56490
|
+
|
|
56491
|
+
// ../core/src/recentSessionPage.ts
|
|
56492
|
+
var RECENT_SESSION_WINDOW_MS = 72 * 60 * 60 * 1e3;
|
|
56493
|
+
var RECENT_SESSION_VISIBLE_LIMIT = 12;
|
|
56494
|
+
var recentSessionOptionsSchema = external_exports.object({
|
|
56495
|
+
windowHours: external_exports.coerce.number().int().min(1).max(120).default(72),
|
|
56496
|
+
limit: external_exports.coerce.number().int().min(1).max(40).default(12)
|
|
56497
|
+
});
|
|
56498
|
+
var recentSessionCursorSchema = external_exports.object({
|
|
56499
|
+
at: external_exports.iso.datetime({ offset: true }),
|
|
56500
|
+
id: external_exports.uuid()
|
|
56501
|
+
});
|
|
56502
|
+
|
|
56455
56503
|
// ../../node_modules/.pnpm/@sentry+core@10.73.0/node_modules/@sentry/core/build/esm/debug-build.js
|
|
56456
56504
|
var DEBUG_BUILD = typeof __SENTRY_DEBUG__ === "undefined" || __SENTRY_DEBUG__;
|
|
56457
56505
|
|
|
@@ -56632,8 +56680,8 @@ function getFunctionName(fn) {
|
|
|
56632
56680
|
return defaultFunctionName;
|
|
56633
56681
|
}
|
|
56634
56682
|
}
|
|
56635
|
-
function normalizeStackTracePath(
|
|
56636
|
-
let filename =
|
|
56683
|
+
function normalizeStackTracePath(path29) {
|
|
56684
|
+
let filename = path29?.startsWith("file://") ? path29.slice(7) : path29;
|
|
56637
56685
|
if (filename?.match(/\/[A-Z]:/)) {
|
|
56638
56686
|
filename = filename.slice(1);
|
|
56639
56687
|
}
|
|
@@ -58443,8 +58491,8 @@ function isValidProtocol(protocol) {
|
|
|
58443
58491
|
return protocol === "http" || protocol === "https";
|
|
58444
58492
|
}
|
|
58445
58493
|
function dsnToString(dsn, withPassword = false) {
|
|
58446
|
-
const { host, path:
|
|
58447
|
-
return `${protocol}://${publicKey}${withPassword && pass ? `:${pass}` : ""}@${host}${port ? `:${port}` : ""}/${
|
|
58494
|
+
const { host, path: path29, pass, port, projectId, protocol, publicKey } = dsn;
|
|
58495
|
+
return `${protocol}://${publicKey}${withPassword && pass ? `:${pass}` : ""}@${host}${port ? `:${port}` : ""}/${path29 ? `${path29}/` : path29}${projectId}`;
|
|
58448
58496
|
}
|
|
58449
58497
|
function dsnFromString(str) {
|
|
58450
58498
|
const match = DSN_REGEX.exec(str);
|
|
@@ -58455,11 +58503,11 @@ function dsnFromString(str) {
|
|
|
58455
58503
|
return void 0;
|
|
58456
58504
|
}
|
|
58457
58505
|
const [protocol, publicKey, pass = "", host = "", port = "", lastPath = ""] = match.slice(1);
|
|
58458
|
-
let
|
|
58506
|
+
let path29 = "";
|
|
58459
58507
|
let projectId = lastPath;
|
|
58460
58508
|
const split = projectId.split("/");
|
|
58461
58509
|
if (split.length > 1) {
|
|
58462
|
-
|
|
58510
|
+
path29 = split.slice(0, -1).join("/");
|
|
58463
58511
|
projectId = split.pop();
|
|
58464
58512
|
}
|
|
58465
58513
|
if (projectId) {
|
|
@@ -58468,7 +58516,7 @@ function dsnFromString(str) {
|
|
|
58468
58516
|
projectId = projectMatch[0];
|
|
58469
58517
|
}
|
|
58470
58518
|
}
|
|
58471
|
-
return dsnFromComponents({ host, pass, path:
|
|
58519
|
+
return dsnFromComponents({ host, pass, path: path29, projectId, port, protocol, publicKey });
|
|
58472
58520
|
}
|
|
58473
58521
|
function dsnFromComponents(components) {
|
|
58474
58522
|
return {
|
|
@@ -63002,9 +63050,9 @@ function stripUrlQueryAndFragment(urlPath) {
|
|
|
63002
63050
|
return urlPath.split(/[?#]/, 1)[0];
|
|
63003
63051
|
}
|
|
63004
63052
|
function getSanitizedUrlString(url2) {
|
|
63005
|
-
const { protocol, host, path:
|
|
63053
|
+
const { protocol, host, path: path29 } = url2;
|
|
63006
63054
|
const filteredHost = host?.replace(/^.*@/, "[filtered]:[filtered]@").replace(/(:80)$/, "").replace(/(:443)$/, "") || "";
|
|
63007
|
-
return `${protocol ? `${protocol}://` : ""}${filteredHost}${
|
|
63055
|
+
return `${protocol ? `${protocol}://` : ""}${filteredHost}${path29}`;
|
|
63008
63056
|
}
|
|
63009
63057
|
function stripDataUrlContent(url2, includeDataPrefix = true) {
|
|
63010
63058
|
if (url2.startsWith("data:")) {
|
|
@@ -63947,8 +63995,8 @@ function splitPath(filename) {
|
|
|
63947
63995
|
const parts = splitPathRe.exec(truncated);
|
|
63948
63996
|
return parts ? parts.slice(1) : [];
|
|
63949
63997
|
}
|
|
63950
|
-
function dirname(
|
|
63951
|
-
const result = splitPath(
|
|
63998
|
+
function dirname(path29) {
|
|
63999
|
+
const result = splitPath(path29);
|
|
63952
64000
|
const root = result[0] || "";
|
|
63953
64001
|
let dir = result[1];
|
|
63954
64002
|
if (!root && !dir) {
|
|
@@ -67771,15 +67819,15 @@ var getLayerMetadata = (route, layer, layerPath) => {
|
|
|
67771
67819
|
};
|
|
67772
67820
|
}
|
|
67773
67821
|
};
|
|
67774
|
-
var getRouterPath = (
|
|
67822
|
+
var getRouterPath = (path29, layer) => {
|
|
67775
67823
|
const stackLayer = Array.isArray(layer.handle?.stack) ? layer.handle?.stack?.[0] : void 0;
|
|
67776
67824
|
if (stackLayer?.route?.path) {
|
|
67777
|
-
return `${
|
|
67825
|
+
return `${path29}${stackLayer.route.path}`;
|
|
67778
67826
|
}
|
|
67779
67827
|
if (stackLayer && Array.isArray(stackLayer?.handle?.stack)) {
|
|
67780
|
-
return getRouterPath(
|
|
67828
|
+
return getRouterPath(path29, stackLayer);
|
|
67781
67829
|
}
|
|
67782
|
-
return
|
|
67830
|
+
return path29;
|
|
67783
67831
|
};
|
|
67784
67832
|
var isLayerIgnored = (name, type, config2) => {
|
|
67785
67833
|
if (Array.isArray(config2?.ignoreLayersType) && config2?.ignoreLayersType?.includes(type)) {
|
|
@@ -67799,7 +67847,7 @@ function getActualMatchedRoute(req, constructedRoute) {
|
|
|
67799
67847
|
if (layersStore.length === 0) {
|
|
67800
67848
|
return void 0;
|
|
67801
67849
|
}
|
|
67802
|
-
if (layersStore.every((
|
|
67850
|
+
if (layersStore.every((path29) => path29 === "/")) {
|
|
67803
67851
|
return req.originalUrl === "/" ? "/" : void 0;
|
|
67804
67852
|
}
|
|
67805
67853
|
if (constructedRoute === "*") {
|
|
@@ -67815,11 +67863,11 @@ function getActualMatchedRoute(req, constructedRoute) {
|
|
|
67815
67863
|
function getConstructedRoute(req) {
|
|
67816
67864
|
const layersStore = getStoredLayers(req);
|
|
67817
67865
|
let constructedRoute = "";
|
|
67818
|
-
for (const
|
|
67819
|
-
if (
|
|
67866
|
+
for (const path29 of layersStore) {
|
|
67867
|
+
if (path29 === "/" || path29 === "/*") {
|
|
67820
67868
|
continue;
|
|
67821
67869
|
}
|
|
67822
|
-
constructedRoute += !constructedRoute || constructedRoute.endsWith("/") ?
|
|
67870
|
+
constructedRoute += !constructedRoute || constructedRoute.endsWith("/") ? path29 : `/${path29}`;
|
|
67823
67871
|
}
|
|
67824
67872
|
return constructedRoute.replace(/\/{2,}/g, "/");
|
|
67825
67873
|
}
|
|
@@ -68324,9 +68372,9 @@ function getRequestUrlObject(requestOptions) {
|
|
|
68324
68372
|
const hostHeader = requestOptions.headers?.host && String(requestOptions.headers?.host);
|
|
68325
68373
|
const hostname4 = hostHeader || requestOptions.hostname || requestOptions.host || "";
|
|
68326
68374
|
const port = !requestOptions.port || requestOptions.port === 80 || requestOptions.port === 443 || /^(.*):(\d+)$/.test(hostname4) ? "" : `:${requestOptions.port}`;
|
|
68327
|
-
const
|
|
68375
|
+
const path29 = requestOptions.path ? requestOptions.path : "/";
|
|
68328
68376
|
const base = `${protocol}//${hostname4}${port}`;
|
|
68329
|
-
return new URL(
|
|
68377
|
+
return new URL(path29.startsWith("//") ? `${base}${path29}` : path29, base);
|
|
68330
68378
|
}
|
|
68331
68379
|
function getRequestUrlFromClientRequest(request2) {
|
|
68332
68380
|
return String(getRequestUrl(getRequestOptions(request2)));
|
|
@@ -68999,11 +69047,11 @@ function shouldIgnoreSpansForIncomingRequest(request2, {
|
|
|
68999
69047
|
return false;
|
|
69000
69048
|
}
|
|
69001
69049
|
function isStaticAssetRequest(urlPath) {
|
|
69002
|
-
const
|
|
69003
|
-
if (
|
|
69050
|
+
const path29 = stripUrlQueryAndFragment(urlPath);
|
|
69051
|
+
if (path29.match(/\.(ico|png|jpg|jpeg|gif|svg|css|js|woff|woff2|ttf|eot|webp|avif)$/)) {
|
|
69004
69052
|
return true;
|
|
69005
69053
|
}
|
|
69006
|
-
if (
|
|
69054
|
+
if (path29.match(/^\/(robots\.txt|sitemap\.xml|manifest\.json|browserconfig\.xml)$/)) {
|
|
69007
69055
|
return true;
|
|
69008
69056
|
}
|
|
69009
69057
|
return false;
|
|
@@ -69244,11 +69292,11 @@ function isKnownPrefetchRequest2(req) {
|
|
|
69244
69292
|
return req.headers["next-router-prefetch"] === "1";
|
|
69245
69293
|
}
|
|
69246
69294
|
function isStaticAssetRequest2(urlPath) {
|
|
69247
|
-
const
|
|
69248
|
-
if (
|
|
69295
|
+
const path29 = stripUrlQueryAndFragment(urlPath);
|
|
69296
|
+
if (path29.match(/\.(ico|png|jpg|jpeg|gif|svg|css|js|woff|woff2|ttf|eot|webp|avif)$/)) {
|
|
69249
69297
|
return true;
|
|
69250
69298
|
}
|
|
69251
|
-
if (
|
|
69299
|
+
if (path29.match(/^\/(robots\.txt|sitemap\.xml|manifest\.json|browserconfig\.xml)$/)) {
|
|
69252
69300
|
return true;
|
|
69253
69301
|
}
|
|
69254
69302
|
return false;
|
|
@@ -69608,19 +69656,19 @@ function getBreadcrumbData(request2) {
|
|
|
69608
69656
|
return {};
|
|
69609
69657
|
}
|
|
69610
69658
|
}
|
|
69611
|
-
function getAbsoluteUrl2(origin,
|
|
69659
|
+
function getAbsoluteUrl2(origin, path29 = "/") {
|
|
69612
69660
|
try {
|
|
69613
|
-
const url2 = new URL(
|
|
69661
|
+
const url2 = new URL(path29, origin);
|
|
69614
69662
|
return url2.toString();
|
|
69615
69663
|
} catch {
|
|
69616
69664
|
const url2 = `${origin}`;
|
|
69617
|
-
if (url2.endsWith("/") &&
|
|
69618
|
-
return `${url2}${
|
|
69665
|
+
if (url2.endsWith("/") && path29.startsWith("/")) {
|
|
69666
|
+
return `${url2}${path29.slice(1)}`;
|
|
69619
69667
|
}
|
|
69620
|
-
if (!url2.endsWith("/") && !
|
|
69621
|
-
return `${url2}/${
|
|
69668
|
+
if (!url2.endsWith("/") && !path29.startsWith("/")) {
|
|
69669
|
+
return `${url2}/${path29}`;
|
|
69622
69670
|
}
|
|
69623
|
-
return `${url2}${
|
|
69671
|
+
return `${url2}${path29}`;
|
|
69624
69672
|
}
|
|
69625
69673
|
}
|
|
69626
69674
|
|
|
@@ -69865,15 +69913,15 @@ function getRequestMethod(original) {
|
|
|
69865
69913
|
}
|
|
69866
69914
|
return "_OTHER";
|
|
69867
69915
|
}
|
|
69868
|
-
function getAbsoluteUrl3(origin,
|
|
69916
|
+
function getAbsoluteUrl3(origin, path29 = "/") {
|
|
69869
69917
|
const url2 = `${origin}`;
|
|
69870
|
-
if (url2.endsWith("/") &&
|
|
69871
|
-
return `${url2}${
|
|
69918
|
+
if (url2.endsWith("/") && path29.startsWith("/")) {
|
|
69919
|
+
return `${url2}${path29.slice(1)}`;
|
|
69872
69920
|
}
|
|
69873
|
-
if (!url2.endsWith("/") && !
|
|
69874
|
-
return `${url2}/${
|
|
69921
|
+
if (!url2.endsWith("/") && !path29.startsWith("/")) {
|
|
69922
|
+
return `${url2}/${path29}`;
|
|
69875
69923
|
}
|
|
69876
|
-
return `${url2}${
|
|
69924
|
+
return `${url2}${path29}`;
|
|
69877
69925
|
}
|
|
69878
69926
|
|
|
69879
69927
|
// ../../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 +72407,12 @@ function emplace(map2, key, contents) {
|
|
|
72359
72407
|
}
|
|
72360
72408
|
return value;
|
|
72361
72409
|
}
|
|
72362
|
-
function shouldSkipContextLinesForFile(
|
|
72363
|
-
if (
|
|
72364
|
-
if (
|
|
72365
|
-
if (
|
|
72366
|
-
if (
|
|
72367
|
-
if (
|
|
72410
|
+
function shouldSkipContextLinesForFile(path29) {
|
|
72411
|
+
if (path29.startsWith("node:")) return true;
|
|
72412
|
+
if (path29.endsWith(".min.js")) return true;
|
|
72413
|
+
if (path29.endsWith(".min.cjs")) return true;
|
|
72414
|
+
if (path29.endsWith(".min.mjs")) return true;
|
|
72415
|
+
if (path29.startsWith("data:")) return true;
|
|
72368
72416
|
return false;
|
|
72369
72417
|
}
|
|
72370
72418
|
function shouldSkipContextLinesForFrame(frame) {
|
|
@@ -72412,9 +72460,9 @@ function makeLineReaderRanges(lines, linecontext) {
|
|
|
72412
72460
|
}
|
|
72413
72461
|
return out;
|
|
72414
72462
|
}
|
|
72415
|
-
function getContextLinesFromFile(
|
|
72463
|
+
function getContextLinesFromFile(path29, ranges, output2) {
|
|
72416
72464
|
return new Promise((resolve2, _reject) => {
|
|
72417
|
-
const stream = createReadStream(
|
|
72465
|
+
const stream = createReadStream(path29);
|
|
72418
72466
|
const lineReaded = createInterface({
|
|
72419
72467
|
input: stream
|
|
72420
72468
|
});
|
|
@@ -72432,8 +72480,8 @@ function getContextLinesFromFile(path25, ranges, output2) {
|
|
|
72432
72480
|
let rangeStart = range[0];
|
|
72433
72481
|
let rangeEnd = range[1];
|
|
72434
72482
|
function onStreamError(e) {
|
|
72435
|
-
LRU_FILE_CONTENTS_FS_READ_FAILED.set(
|
|
72436
|
-
DEBUG_BUILD2 && debug.error(`Failed to read file: ${
|
|
72483
|
+
LRU_FILE_CONTENTS_FS_READ_FAILED.set(path29, 1);
|
|
72484
|
+
DEBUG_BUILD2 && debug.error(`Failed to read file: ${path29}. Error: ${e}`);
|
|
72437
72485
|
lineReaded.close();
|
|
72438
72486
|
lineReaded.removeAllListeners();
|
|
72439
72487
|
destroyStreamAndResolve();
|
|
@@ -73872,8 +73920,8 @@ function getSpotlightConfig(optionsSpotlight) {
|
|
|
73872
73920
|
|
|
73873
73921
|
// ../../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
73922
|
import { posix, sep } from "node:path";
|
|
73875
|
-
function normalizeWindowsPath(
|
|
73876
|
-
return
|
|
73923
|
+
function normalizeWindowsPath(path29) {
|
|
73924
|
+
return path29.replace(/^[A-Z]:/, "").replace(/\\/g, "/");
|
|
73877
73925
|
}
|
|
73878
73926
|
function createGetModuleFromFilename(basePath = process.argv[1] ? dirname(process.argv[1]) : process.cwd(), isWindows = sep === "\\") {
|
|
73879
73927
|
const normalizedBase = isWindows ? normalizeWindowsPath(basePath) : basePath;
|
|
@@ -76749,22 +76797,22 @@ function addSpanSource(span, loc, start, end) {
|
|
|
76749
76797
|
span.setAttribute(AttributeNames2.SOURCE, source);
|
|
76750
76798
|
}
|
|
76751
76799
|
}
|
|
76752
|
-
function createFieldIfNotExists(contextValue, info,
|
|
76753
|
-
let field = getField(contextValue,
|
|
76800
|
+
function createFieldIfNotExists(contextValue, info, path29) {
|
|
76801
|
+
let field = getField(contextValue, path29);
|
|
76754
76802
|
if (field) {
|
|
76755
76803
|
return { field, spanAdded: false };
|
|
76756
76804
|
}
|
|
76757
|
-
const parentSpan = getParentFieldSpan(contextValue,
|
|
76805
|
+
const parentSpan = getParentFieldSpan(contextValue, path29);
|
|
76758
76806
|
field = {
|
|
76759
|
-
span: createResolverSpan(contextValue, info,
|
|
76807
|
+
span: createResolverSpan(contextValue, info, path29, parentSpan)
|
|
76760
76808
|
};
|
|
76761
|
-
addField(contextValue,
|
|
76809
|
+
addField(contextValue, path29, field);
|
|
76762
76810
|
return { field, spanAdded: true };
|
|
76763
76811
|
}
|
|
76764
|
-
function createResolverSpan(contextValue, info,
|
|
76812
|
+
function createResolverSpan(contextValue, info, path29, parentSpan) {
|
|
76765
76813
|
const attributes = {
|
|
76766
76814
|
[AttributeNames2.FIELD_NAME]: info.fieldName,
|
|
76767
|
-
[AttributeNames2.FIELD_PATH]:
|
|
76815
|
+
[AttributeNames2.FIELD_PATH]: path29.join("."),
|
|
76768
76816
|
[AttributeNames2.FIELD_TYPE]: info.returnType.toString(),
|
|
76769
76817
|
[AttributeNames2.PARENT_NAME]: info.parentType.name
|
|
76770
76818
|
};
|
|
@@ -76796,15 +76844,15 @@ function getOperation(document2, operationName) {
|
|
|
76796
76844
|
return document2.definitions.find((definition) => OPERATION_VALUES.indexOf(definition?.operation) !== -1);
|
|
76797
76845
|
}
|
|
76798
76846
|
}
|
|
76799
|
-
function addField(contextValue,
|
|
76800
|
-
return contextValue[OTEL_GRAPHQL_DATA_SYMBOL].fields[
|
|
76847
|
+
function addField(contextValue, path29, field) {
|
|
76848
|
+
return contextValue[OTEL_GRAPHQL_DATA_SYMBOL].fields[path29.join(".")] = field;
|
|
76801
76849
|
}
|
|
76802
|
-
function getField(contextValue,
|
|
76803
|
-
return contextValue[OTEL_GRAPHQL_DATA_SYMBOL].fields[
|
|
76850
|
+
function getField(contextValue, path29) {
|
|
76851
|
+
return contextValue[OTEL_GRAPHQL_DATA_SYMBOL].fields[path29.join(".")];
|
|
76804
76852
|
}
|
|
76805
|
-
function getParentFieldSpan(contextValue,
|
|
76806
|
-
for (let i =
|
|
76807
|
-
const field = getField(contextValue,
|
|
76853
|
+
function getParentFieldSpan(contextValue, path29) {
|
|
76854
|
+
for (let i = path29.length - 1; i > 0; i--) {
|
|
76855
|
+
const field = getField(contextValue, path29.slice(0, i));
|
|
76808
76856
|
if (field) {
|
|
76809
76857
|
return field.span;
|
|
76810
76858
|
}
|
|
@@ -76814,9 +76862,9 @@ function getParentFieldSpan(contextValue, path25) {
|
|
|
76814
76862
|
function getRootSpan2(contextValue) {
|
|
76815
76863
|
return contextValue[OTEL_GRAPHQL_DATA_SYMBOL].span;
|
|
76816
76864
|
}
|
|
76817
|
-
function pathToArray(
|
|
76865
|
+
function pathToArray(path29) {
|
|
76818
76866
|
const flattened = [];
|
|
76819
|
-
let curr =
|
|
76867
|
+
let curr = path29;
|
|
76820
76868
|
while (curr) {
|
|
76821
76869
|
flattened.push(String(curr.key));
|
|
76822
76870
|
curr = curr.prev;
|
|
@@ -76957,8 +77005,8 @@ function wrapFieldResolver(getConfig3, fieldResolver, isDefaultResolver = false)
|
|
|
76957
77005
|
if (!contextValue[OTEL_GRAPHQL_DATA_SYMBOL]) {
|
|
76958
77006
|
return fieldResolver.call(this, source, args, contextValue, info);
|
|
76959
77007
|
}
|
|
76960
|
-
const
|
|
76961
|
-
const { field, spanAdded } = createFieldIfNotExists(contextValue, info,
|
|
77008
|
+
const path29 = pathToArray(info?.path);
|
|
77009
|
+
const { field, spanAdded } = createFieldIfNotExists(contextValue, info, path29);
|
|
76962
77010
|
const span = field.span;
|
|
76963
77011
|
const shouldEndSpan = spanAdded;
|
|
76964
77012
|
return withActiveSpan(span, () => {
|
|
@@ -79941,10 +79989,10 @@ var PostgresJsInstrumentation = class extends import_instrumentation24.Instrumen
|
|
|
79941
79989
|
},
|
|
79942
79990
|
(exports) => exports
|
|
79943
79991
|
);
|
|
79944
|
-
["src", "cf/src", "cjs/src"].forEach((
|
|
79992
|
+
["src", "cf/src", "cjs/src"].forEach((path29) => {
|
|
79945
79993
|
module2.files.push(
|
|
79946
79994
|
new InstrumentationNodeModuleFile(
|
|
79947
|
-
`postgres/${
|
|
79995
|
+
`postgres/${path29}/query.js`,
|
|
79948
79996
|
SUPPORTED_VERSIONS4,
|
|
79949
79997
|
this._patchQueryPrototype.bind(this),
|
|
79950
79998
|
this._unpatchQueryPrototype.bind(this)
|
|
@@ -80575,13 +80623,13 @@ var HonoInstrumentation = class extends import_instrumentation27.Instrumentation
|
|
|
80575
80623
|
return function(original) {
|
|
80576
80624
|
return function wrappedHandler(...args) {
|
|
80577
80625
|
if (typeof args[0] === "string") {
|
|
80578
|
-
const
|
|
80626
|
+
const path29 = args[0];
|
|
80579
80627
|
if (args.length === 1) {
|
|
80580
|
-
return original.apply(this, [
|
|
80628
|
+
return original.apply(this, [path29]);
|
|
80581
80629
|
}
|
|
80582
80630
|
const handlers2 = args.slice(1);
|
|
80583
80631
|
return original.apply(this, [
|
|
80584
|
-
|
|
80632
|
+
path29,
|
|
80585
80633
|
...handlers2.map((handler) => instrumentation._wrapHandler(handler))
|
|
80586
80634
|
]);
|
|
80587
80635
|
}
|
|
@@ -80615,13 +80663,13 @@ var HonoInstrumentation = class extends import_instrumentation27.Instrumentation
|
|
|
80615
80663
|
return function(original) {
|
|
80616
80664
|
return function wrappedHandler(...args) {
|
|
80617
80665
|
if (typeof args[0] === "string") {
|
|
80618
|
-
const
|
|
80666
|
+
const path29 = args[0];
|
|
80619
80667
|
if (args.length === 1) {
|
|
80620
|
-
return original.apply(this, [
|
|
80668
|
+
return original.apply(this, [path29]);
|
|
80621
80669
|
}
|
|
80622
80670
|
const handlers2 = args.slice(1);
|
|
80623
80671
|
return original.apply(this, [
|
|
80624
|
-
|
|
80672
|
+
path29,
|
|
80625
80673
|
...handlers2.map((handler) => instrumentation._wrapHandler(handler))
|
|
80626
80674
|
]);
|
|
80627
80675
|
}
|
|
@@ -80641,8 +80689,8 @@ var HonoInstrumentation = class extends import_instrumentation27.Instrumentation
|
|
|
80641
80689
|
if (!instrumentation.isEnabled()) {
|
|
80642
80690
|
return handler.apply(this, [c, next]);
|
|
80643
80691
|
}
|
|
80644
|
-
const
|
|
80645
|
-
const span = instrumentation.tracer.startSpan(
|
|
80692
|
+
const path29 = c.req.path;
|
|
80693
|
+
const span = instrumentation.tracer.startSpan(path29);
|
|
80646
80694
|
return context.with(trace.setSpan(context.active(), span), () => {
|
|
80647
80695
|
return instrumentation._safeExecute(
|
|
80648
80696
|
() => {
|
|
@@ -80652,7 +80700,7 @@ var HonoInstrumentation = class extends import_instrumentation27.Instrumentation
|
|
|
80652
80700
|
const type = instrumentation._determineHandlerType(result2);
|
|
80653
80701
|
span.setAttributes({
|
|
80654
80702
|
[AttributeNames5.HONO_TYPE]: type,
|
|
80655
|
-
[AttributeNames5.HONO_NAME]: type === HonoTypes.REQUEST_HANDLER ?
|
|
80703
|
+
[AttributeNames5.HONO_NAME]: type === HonoTypes.REQUEST_HANDLER ? path29 : handler.name || "anonymous"
|
|
80656
80704
|
});
|
|
80657
80705
|
instrumentation.getConfig().responseHook?.(span);
|
|
80658
80706
|
return result2;
|
|
@@ -80661,7 +80709,7 @@ var HonoInstrumentation = class extends import_instrumentation27.Instrumentation
|
|
|
80661
80709
|
const type = instrumentation._determineHandlerType(result);
|
|
80662
80710
|
span.setAttributes({
|
|
80663
80711
|
[AttributeNames5.HONO_TYPE]: type,
|
|
80664
|
-
[AttributeNames5.HONO_NAME]: type === HonoTypes.REQUEST_HANDLER ?
|
|
80712
|
+
[AttributeNames5.HONO_NAME]: type === HonoTypes.REQUEST_HANDLER ? path29 : handler.name || "anonymous"
|
|
80665
80713
|
});
|
|
80666
80714
|
instrumentation.getConfig().responseHook?.(span);
|
|
80667
80715
|
return result;
|
|
@@ -80865,11 +80913,11 @@ var KoaInstrumentation = class extends import_instrumentation29.InstrumentationB
|
|
|
80865
80913
|
const router = dispatchLayer.router;
|
|
80866
80914
|
const routesStack = router?.stack ?? [];
|
|
80867
80915
|
for (const pathLayer of routesStack) {
|
|
80868
|
-
const
|
|
80916
|
+
const path29 = pathLayer.path;
|
|
80869
80917
|
const pathStack = pathLayer.stack;
|
|
80870
80918
|
for (let j = 0; j < pathStack.length; j++) {
|
|
80871
80919
|
const routedMiddleware = pathStack[j];
|
|
80872
|
-
pathStack[j] = this._patchLayer(routedMiddleware, true,
|
|
80920
|
+
pathStack[j] = this._patchLayer(routedMiddleware, true, path29);
|
|
80873
80921
|
}
|
|
80874
80922
|
}
|
|
80875
80923
|
return dispatchLayer;
|
|
@@ -83323,7 +83371,7 @@ import os6 from "node:os";
|
|
|
83323
83371
|
// ../../apps/collector/src/http.ts
|
|
83324
83372
|
var import_undici = __toESM(require_undici(), 1);
|
|
83325
83373
|
var CLI_VERSION_HEADER = "x-powerplant-cli-version";
|
|
83326
|
-
var cliVersion = true ? "0.4.
|
|
83374
|
+
var cliVersion = true ? "0.4.6" : "0.0.0-checkout";
|
|
83327
83375
|
function cliVersionHeaders() {
|
|
83328
83376
|
return { [CLI_VERSION_HEADER]: cliVersion, "user-agent": `powerplant-cli/${cliVersion}` };
|
|
83329
83377
|
}
|
|
@@ -85124,8 +85172,7 @@ function addCodexTotals(a, b2) {
|
|
|
85124
85172
|
return { input: a.input + b2.input, cached: a.cached + b2.cached, output: a.output + b2.output };
|
|
85125
85173
|
}
|
|
85126
85174
|
function isSidecarThread(meta3) {
|
|
85127
|
-
|
|
85128
|
-
return meta3.thread_source === "subagent" || meta3.thread_source === "guardian_review" || typeof source === "object" && source !== null && "subagent" in source;
|
|
85175
|
+
return harnessSessionFacts("codex", meta3).subagent === true;
|
|
85129
85176
|
}
|
|
85130
85177
|
function repoFullNameFrom(url2) {
|
|
85131
85178
|
const fullName = parseGithubRepo(url2);
|
|
@@ -85612,7 +85659,7 @@ function loadSqlite() {
|
|
|
85612
85659
|
);
|
|
85613
85660
|
return sqliteModule;
|
|
85614
85661
|
}
|
|
85615
|
-
async function
|
|
85662
|
+
async function openLocalDatabase(dbPath) {
|
|
85616
85663
|
const sqlite = await loadSqlite();
|
|
85617
85664
|
return new sqlite.DatabaseSync(dbPath, { readOnly: true });
|
|
85618
85665
|
}
|
|
@@ -85787,7 +85834,7 @@ async function collectCursorSessions(options = {}) {
|
|
|
85787
85834
|
const dbPath = path9.join(userDir, "globalStorage", "state.vscdb");
|
|
85788
85835
|
let db;
|
|
85789
85836
|
try {
|
|
85790
|
-
if (statIfExists(dbPath) !== null) db = await
|
|
85837
|
+
if (statIfExists(dbPath) !== null) db = await openLocalDatabase(dbPath);
|
|
85791
85838
|
} catch (error62) {
|
|
85792
85839
|
result.unavailable = `Cursor's session store couldn't be opened (${describeReadError(error62)})`;
|
|
85793
85840
|
}
|
|
@@ -85837,7 +85884,7 @@ function collectFromStore(db, userDir, options, result, knownIds) {
|
|
|
85837
85884
|
continue;
|
|
85838
85885
|
}
|
|
85839
85886
|
const facts = headerFactsOf(value);
|
|
85840
|
-
if (
|
|
85887
|
+
if (harnessSessionFacts("cursor", raw).subagent === true) {
|
|
85841
85888
|
result.skippedSubagentComposers += 1;
|
|
85842
85889
|
continue;
|
|
85843
85890
|
}
|
|
@@ -85914,7 +85961,7 @@ function collectFromStore(db, userDir, options, result, knownIds) {
|
|
|
85914
85961
|
externalId: raw.composerId,
|
|
85915
85962
|
status: now - lastUpdatedAt < ACTIVE_GRACE_MS ? "active" : "inactive",
|
|
85916
85963
|
// The header's own archive fact — Cursor's UI archive flag.
|
|
85917
|
-
archived:
|
|
85964
|
+
archived: harnessSessionFacts("cursor", raw).archived === true,
|
|
85918
85965
|
...typeof raw.createdAt === "number" && {
|
|
85919
85966
|
startedAt: new Date(raw.createdAt).toISOString()
|
|
85920
85967
|
},
|
|
@@ -86074,13 +86121,22 @@ function allowProtectedRepoDiscovery(config2, found, environment = {}, deps = de
|
|
|
86074
86121
|
const needsReview = new ProtectedRootTally(environment);
|
|
86075
86122
|
for (const entry of found) {
|
|
86076
86123
|
const probes = entry.folders.flatMap(
|
|
86077
|
-
(folder) => folder.cwds.map((cwd) => ({ cwd, probe: probeOf(cwd),
|
|
86124
|
+
(folder) => folder.cwds.map((cwd) => ({ cwd, probe: probeOf(cwd), folder }))
|
|
86078
86125
|
);
|
|
86079
86126
|
let unconsented = 0;
|
|
86080
|
-
|
|
86127
|
+
const countedFolderTargets = /* @__PURE__ */ new Set();
|
|
86128
|
+
for (const { cwd, probe, folder } of probes) {
|
|
86081
86129
|
if (probe.kind !== "unconsented") continue;
|
|
86082
86130
|
unconsented += 1;
|
|
86083
|
-
|
|
86131
|
+
const checkout = checkoutOfGitDir(probe.path);
|
|
86132
|
+
const target = [folder.path, probe.root, checkout].join("\0");
|
|
86133
|
+
needsReview.add(
|
|
86134
|
+
probe.root,
|
|
86135
|
+
checkout,
|
|
86136
|
+
cwd,
|
|
86137
|
+
countedFolderTargets.has(target) ? 0 : folder.sessionCount
|
|
86138
|
+
);
|
|
86139
|
+
countedFolderTargets.add(target);
|
|
86084
86140
|
}
|
|
86085
86141
|
if (probes.some(({ probe }) => probe.kind === "found")) outcome.enabled.push(entry);
|
|
86086
86142
|
else if (probes.some(({ probe }) => probe.kind === "denied")) outcome.blocked.push(entry);
|
|
@@ -87782,20 +87838,469 @@ function describeDelay(ms) {
|
|
|
87782
87838
|
return seconds < 120 ? `${seconds}s` : `${Math.round(seconds / 60)} minutes`;
|
|
87783
87839
|
}
|
|
87784
87840
|
|
|
87841
|
+
// ../../apps/collector/src/localSessionFacts.ts
|
|
87842
|
+
import { existsSync as existsSync7, readdirSync as readdirSync4, statSync as statSync4 } from "node:fs";
|
|
87843
|
+
import os16 from "node:os";
|
|
87844
|
+
import path18 from "node:path";
|
|
87845
|
+
|
|
87846
|
+
// ../../apps/collector/src/codexReviewFacts.ts
|
|
87847
|
+
import { closeSync as closeSync4, lstatSync as lstatSync4, openSync as openSync4, readSync as readSync4, realpathSync as realpathSync3 } from "node:fs";
|
|
87848
|
+
import path17 from "node:path";
|
|
87849
|
+
var pointerSchema = external_exports.object({
|
|
87850
|
+
source: external_exports.unknown().optional(),
|
|
87851
|
+
rollout_path: external_exports.string().nullish()
|
|
87852
|
+
});
|
|
87853
|
+
var metaSchema = external_exports.object({
|
|
87854
|
+
type: external_exports.literal("session_meta"),
|
|
87855
|
+
payload: external_exports.object({
|
|
87856
|
+
id: external_exports.string(),
|
|
87857
|
+
source: external_exports.unknown().optional(),
|
|
87858
|
+
thread_source: external_exports.string().optional()
|
|
87859
|
+
})
|
|
87860
|
+
});
|
|
87861
|
+
var MAX_PREFIX_BYTES = 256 * 1024;
|
|
87862
|
+
function readCodexReviewFacts(row, id, home) {
|
|
87863
|
+
const pointer = pointerSchema.parse(row);
|
|
87864
|
+
if (pointer.source !== "exec" || !pointer.rollout_path) return {};
|
|
87865
|
+
const file2 = pointer.rollout_path;
|
|
87866
|
+
if (!path17.isAbsolute(file2) || !file2.endsWith(".jsonl")) return {};
|
|
87867
|
+
const root = ["sessions", "archived_sessions"].map((store) => path17.join(home, ".codex", store)).find((store) => {
|
|
87868
|
+
const relative2 = path17.relative(store, file2);
|
|
87869
|
+
return relative2 !== "" && relative2 !== ".." && !relative2.startsWith(`..${path17.sep}`) && !path17.isAbsolute(relative2);
|
|
87870
|
+
});
|
|
87871
|
+
if (!root) return {};
|
|
87872
|
+
try {
|
|
87873
|
+
if (!lstatSync4(file2).isFile() || realpathSync3(file2) !== path17.join(realpathSync3(root), path17.relative(root, file2))) return {};
|
|
87874
|
+
const records = readPrefix(file2);
|
|
87875
|
+
if (records === null) return {};
|
|
87876
|
+
const meta3 = metaSchema.safeParse(records[0]);
|
|
87877
|
+
if (!meta3.success || meta3.data.payload.id !== id) return {};
|
|
87878
|
+
return harnessSessionFacts("codex", { ...meta3.data.payload, initialEvent: records[1] });
|
|
87879
|
+
} catch (error62) {
|
|
87880
|
+
if (error62 instanceof Error && "code" in error62 && error62.code === "ENOENT") return {};
|
|
87881
|
+
throw error62;
|
|
87882
|
+
}
|
|
87883
|
+
}
|
|
87884
|
+
function readPrefix(file2) {
|
|
87885
|
+
const fd = openSync4(file2, "r");
|
|
87886
|
+
const buffer = Buffer.alloc(MAX_PREFIX_BYTES);
|
|
87887
|
+
let used = 0;
|
|
87888
|
+
let first = -1;
|
|
87889
|
+
let second = -1;
|
|
87890
|
+
try {
|
|
87891
|
+
while (used < buffer.length && second < 0) {
|
|
87892
|
+
const bytes = readSync4(fd, buffer, used, Math.min(4096, buffer.length - used), null);
|
|
87893
|
+
if (bytes === 0) break;
|
|
87894
|
+
const end = used + bytes;
|
|
87895
|
+
for (let i = used; i < end; i++) {
|
|
87896
|
+
if (buffer[i] !== 10) continue;
|
|
87897
|
+
if (first < 0) first = i;
|
|
87898
|
+
else {
|
|
87899
|
+
second = i;
|
|
87900
|
+
break;
|
|
87901
|
+
}
|
|
87902
|
+
}
|
|
87903
|
+
used = end;
|
|
87904
|
+
}
|
|
87905
|
+
} finally {
|
|
87906
|
+
closeSync4(fd);
|
|
87907
|
+
}
|
|
87908
|
+
if (first < 0 || second < 0) return null;
|
|
87909
|
+
try {
|
|
87910
|
+
return [JSON.parse(buffer.subarray(0, first).toString("utf8")), JSON.parse(buffer.subarray(first + 1, second).toString("utf8"))];
|
|
87911
|
+
} catch {
|
|
87912
|
+
return null;
|
|
87913
|
+
}
|
|
87914
|
+
}
|
|
87915
|
+
|
|
87916
|
+
// ../../apps/collector/src/localSessionFacts.ts
|
|
87917
|
+
var WORKING_FRESH_MS = 9e4;
|
|
87918
|
+
var STORES = [
|
|
87919
|
+
{
|
|
87920
|
+
source: "codex",
|
|
87921
|
+
file: (home) => {
|
|
87922
|
+
const directory = path18.join(home, ".codex");
|
|
87923
|
+
if (!existsSync7(directory)) return null;
|
|
87924
|
+
const files = readdirSync4(directory).filter((name) => /^state_\d+\.sqlite$/.test(name)).sort((a, b2) => Number(b2.match(/\d+/)?.[0]) - Number(a.match(/\d+/)?.[0]));
|
|
87925
|
+
return files[0] ? path18.join(directory, files[0]) : null;
|
|
87926
|
+
},
|
|
87927
|
+
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],
|
|
87928
|
+
table: "threads",
|
|
87929
|
+
key: "id",
|
|
87930
|
+
fields: ["source", "thread_source", "archived", "rollout_path"],
|
|
87931
|
+
additionalFacts: readCodexReviewFacts,
|
|
87932
|
+
decode: (row) => {
|
|
87933
|
+
const parsed = external_exports.object({
|
|
87934
|
+
source: external_exports.unknown().optional(),
|
|
87935
|
+
thread_source: external_exports.unknown().optional(),
|
|
87936
|
+
archived: external_exports.unknown().optional()
|
|
87937
|
+
}).parse(row);
|
|
87938
|
+
let source = parsed.source;
|
|
87939
|
+
if (typeof parsed.source === "string") {
|
|
87940
|
+
try {
|
|
87941
|
+
source = JSON.parse(parsed.source);
|
|
87942
|
+
} catch {
|
|
87943
|
+
}
|
|
87944
|
+
}
|
|
87945
|
+
return { ...parsed, source };
|
|
87946
|
+
},
|
|
87947
|
+
written: (row) => {
|
|
87948
|
+
const rollout = external_exports.object({ rollout_path: external_exports.string() }).safeParse(row);
|
|
87949
|
+
return rollout.success ? fileWrittenAt(rollout.data.rollout_path) : null;
|
|
87950
|
+
}
|
|
87951
|
+
},
|
|
87952
|
+
{
|
|
87953
|
+
source: "cursor",
|
|
87954
|
+
file: (home) => path18.join(defaultCursorUserDir(home), "globalStorage", "state.vscdb"),
|
|
87955
|
+
id: (externalId) => externalId,
|
|
87956
|
+
table: "composerHeaders",
|
|
87957
|
+
key: "composerId",
|
|
87958
|
+
fields: ["isArchived", "isSubagent", "lastUpdatedAt"],
|
|
87959
|
+
decode: (row) => row,
|
|
87960
|
+
written: (row) => {
|
|
87961
|
+
const stamp = external_exports.object({ lastUpdatedAt: external_exports.number() }).safeParse(row);
|
|
87962
|
+
return stamp.success ? stamp.data.lastUpdatedAt : null;
|
|
87963
|
+
}
|
|
87964
|
+
}
|
|
87965
|
+
];
|
|
87966
|
+
async function readLocalSessionFacts(sessions, onError2, home = os16.homedir(), now = Date.now()) {
|
|
87967
|
+
const result = /* @__PURE__ */ new Map();
|
|
87968
|
+
const working = (writtenAt) => writtenAt !== null && now - writtenAt < WORKING_FRESH_MS ? { working: true } : {};
|
|
87969
|
+
for (const store of STORES) {
|
|
87970
|
+
const wanted = sessions.filter((session) => session.source === store.source);
|
|
87971
|
+
if (wanted.length === 0) continue;
|
|
87972
|
+
try {
|
|
87973
|
+
const file2 = store.file(home);
|
|
87974
|
+
if (file2 === null || !existsSync7(file2)) continue;
|
|
87975
|
+
const db = await openLocalDatabase(file2);
|
|
87976
|
+
try {
|
|
87977
|
+
const columns = new Set(
|
|
87978
|
+
external_exports.array(external_exports.object({ name: external_exports.string() })).parse(db.prepare(`pragma table_info(${store.table})`).all()).map((column) => column.name)
|
|
87979
|
+
);
|
|
87980
|
+
if (!columns.has(store.key))
|
|
87981
|
+
throw new Error(`Unrecognized ${store.source} session metadata table`);
|
|
87982
|
+
const fields = store.fields.filter((field) => columns.has(field));
|
|
87983
|
+
if (fields.length === 0) continue;
|
|
87984
|
+
const statement = db.prepare(
|
|
87985
|
+
`select ${fields.join(", ")} from ${store.table} where ${store.key} = ?`
|
|
87986
|
+
);
|
|
87987
|
+
for (const session of wanted) {
|
|
87988
|
+
const id = store.id(session.externalId);
|
|
87989
|
+
if (!id) continue;
|
|
87990
|
+
try {
|
|
87991
|
+
const row = statement.get(id);
|
|
87992
|
+
if (row !== void 0) {
|
|
87993
|
+
const key = localSessionKey(session);
|
|
87994
|
+
const facts = {
|
|
87995
|
+
...harnessSessionFacts(store.source, store.decode(row)),
|
|
87996
|
+
...working(store.written(row))
|
|
87997
|
+
};
|
|
87998
|
+
result.set(key, facts);
|
|
87999
|
+
if ("additionalFacts" in store && facts.archived !== true && facts.subagent !== true)
|
|
88000
|
+
result.set(key, { ...facts, ...store.additionalFacts(row, id, home) });
|
|
88001
|
+
}
|
|
88002
|
+
} catch (error62) {
|
|
88003
|
+
onError2(error62, store.source);
|
|
88004
|
+
}
|
|
88005
|
+
}
|
|
88006
|
+
} finally {
|
|
88007
|
+
db.close();
|
|
88008
|
+
}
|
|
88009
|
+
} catch (error62) {
|
|
88010
|
+
onError2(error62, store.source);
|
|
88011
|
+
}
|
|
88012
|
+
}
|
|
88013
|
+
try {
|
|
88014
|
+
for (const session of sessions.filter((session2) => session2.source === "claude-code")) {
|
|
88015
|
+
const facts = working(claudeTranscriptWrittenAt(session.externalId, home));
|
|
88016
|
+
if (facts.working) result.set(localSessionKey(session), facts);
|
|
88017
|
+
}
|
|
88018
|
+
} catch (error62) {
|
|
88019
|
+
onError2(error62, "claude-code");
|
|
88020
|
+
}
|
|
88021
|
+
return result;
|
|
88022
|
+
}
|
|
88023
|
+
function claudeTranscriptWrittenAt(sessionId, home) {
|
|
88024
|
+
if (!/^[0-9a-f-]{36}$/i.test(sessionId)) return null;
|
|
88025
|
+
const projects = path18.join(home, ".claude", "projects");
|
|
88026
|
+
if (!existsSync7(projects)) return null;
|
|
88027
|
+
for (const entry of readdirSync4(projects, { withFileTypes: true })) {
|
|
88028
|
+
if (!entry.isDirectory()) continue;
|
|
88029
|
+
const writtenAt = fileWrittenAt(path18.join(projects, entry.name, `${sessionId}.jsonl`));
|
|
88030
|
+
if (writtenAt !== null) return writtenAt;
|
|
88031
|
+
}
|
|
88032
|
+
return null;
|
|
88033
|
+
}
|
|
88034
|
+
function fileWrittenAt(file2) {
|
|
88035
|
+
try {
|
|
88036
|
+
return statSync4(file2).mtimeMs;
|
|
88037
|
+
} catch {
|
|
88038
|
+
return null;
|
|
88039
|
+
}
|
|
88040
|
+
}
|
|
88041
|
+
function localSessionKey(session) {
|
|
88042
|
+
return JSON.stringify([session.source, session.externalId]);
|
|
88043
|
+
}
|
|
88044
|
+
|
|
88045
|
+
// src/clientFailure.ts
|
|
88046
|
+
function clientFailure(error62) {
|
|
88047
|
+
if (error62 instanceof ExpectedCliError) {
|
|
88048
|
+
return { outcome: "failed", domain: "Powerplant", code: "EXPECTED_CLI_OUTCOME" };
|
|
88049
|
+
}
|
|
88050
|
+
const code = error62 instanceof Error && "code" in error62 && typeof error62.code === "string" && /^E[A-Z0-9_]{1,31}$/.test(error62.code) ? error62.code : void 0;
|
|
88051
|
+
return {
|
|
88052
|
+
outcome: code === "ENOENT" ? "missing" : code === "EACCES" || code === "EPERM" ? "denied" : "failed",
|
|
88053
|
+
domain: code ? Object.hasOwn(constants.errno, code) ? "POSIX" : "Node" : "JavaScript",
|
|
88054
|
+
code: code ?? (error62 instanceof TypeError ? "TypeError" : error62 instanceof RangeError ? "RangeError" : "unclassified")
|
|
88055
|
+
};
|
|
88056
|
+
}
|
|
88057
|
+
function nativeFailureRecord(error62) {
|
|
88058
|
+
return `POWERPLANT_DIAGNOSTIC ${JSON.stringify({ version: 1, failure: clientFailure(error62) })}`;
|
|
88059
|
+
}
|
|
88060
|
+
|
|
88061
|
+
// src/desktopDiagnostics.ts
|
|
88062
|
+
import os18 from "node:os";
|
|
88063
|
+
import path20 from "node:path";
|
|
88064
|
+
|
|
88065
|
+
// src/memberSessions.ts
|
|
88066
|
+
import { execFileSync as execFileSync4 } from "node:child_process";
|
|
88067
|
+
import { existsSync as existsSync8 } from "node:fs";
|
|
88068
|
+
import { open as open2, readdir as readdir2 } from "node:fs/promises";
|
|
88069
|
+
import os17 from "node:os";
|
|
88070
|
+
import path19 from "node:path";
|
|
88071
|
+
var memberSessionSchema = external_exports.object({
|
|
88072
|
+
id: external_exports.string().min(1),
|
|
88073
|
+
source: external_exports.string().min(1),
|
|
88074
|
+
externalId: external_exports.string().min(1),
|
|
88075
|
+
title: external_exports.string().nullable(),
|
|
88076
|
+
repoDir: external_exports.string().nullable(),
|
|
88077
|
+
machineId: external_exports.string().nullable(),
|
|
88078
|
+
lastActivityAt: external_exports.string().min(1),
|
|
88079
|
+
providerUrl: external_exports.string().nullable(),
|
|
88080
|
+
archived: external_exports.boolean().optional(),
|
|
88081
|
+
subagent: external_exports.boolean().optional(),
|
|
88082
|
+
standaloneReview: external_exports.boolean().optional(),
|
|
88083
|
+
/** The harness wrote to the session moments ago (this machine only, see
|
|
88084
|
+
* the collector's LocalSessionFacts). Absent is unknown, never idle. */
|
|
88085
|
+
working: external_exports.boolean().optional()
|
|
88086
|
+
});
|
|
88087
|
+
function applyLocalFacts(sessions, machineId, localFacts, localKey, claudeDesktop) {
|
|
88088
|
+
return sessions.map((session) => {
|
|
88089
|
+
if (machineId === null || session.machineId !== machineId) return session;
|
|
88090
|
+
const desktop = session.source === "claude-code" ? claudeDesktop.get(session.externalId) : void 0;
|
|
88091
|
+
return {
|
|
88092
|
+
...session,
|
|
88093
|
+
...localFacts.get(localKey(session)),
|
|
88094
|
+
...desktop?.archived === true && { archived: true }
|
|
88095
|
+
};
|
|
88096
|
+
});
|
|
88097
|
+
}
|
|
88098
|
+
async function fetchMemberSessions(credentials, fetchImpl = fetch, options = { windowHours: RECENT_SESSION_WINDOW_MS / 36e5, limit: RECENT_SESSION_VISIBLE_LIMIT }) {
|
|
88099
|
+
const { windowHours, limit } = recentSessionOptionsSchema.parse(options);
|
|
88100
|
+
try {
|
|
88101
|
+
const query = new URLSearchParams({ view: "recent", windowHours: String(windowHours), limit: String(limit) });
|
|
88102
|
+
const response = await fetchImpl(`${credentials.apiUrl}/api/collector/member-sessions?${query.toString()}`, {
|
|
88103
|
+
headers: { authorization: `Bearer ${credentials.token}`, ...cliVersionHeaders() },
|
|
88104
|
+
signal: AbortSignal.timeout(1e4)
|
|
88105
|
+
});
|
|
88106
|
+
if (!response.ok) throw new Error(`session read returned ${response.status}`);
|
|
88107
|
+
const { data } = external_exports.object({ data: external_exports.object({
|
|
88108
|
+
sessions: external_exports.array(memberSessionSchema).max(50),
|
|
88109
|
+
nextCursor: external_exports.string().max(512).nullable().optional()
|
|
88110
|
+
}) }).parse(await response.json());
|
|
88111
|
+
return {
|
|
88112
|
+
sessions: data.sessions.slice(0, limit),
|
|
88113
|
+
// Older servers ignore the recent window and omit this field.
|
|
88114
|
+
// A cursor on a supported server is an intentional cap, not a failure.
|
|
88115
|
+
incomplete: data.nextCursor === void 0
|
|
88116
|
+
};
|
|
88117
|
+
} catch {
|
|
88118
|
+
return null;
|
|
88119
|
+
}
|
|
88120
|
+
}
|
|
88121
|
+
function resumeCommand(source, sessionId, powerplantUrl) {
|
|
88122
|
+
return ["resume-session", source, sessionId, "--open", powerplantUrl];
|
|
88123
|
+
}
|
|
88124
|
+
function sessionLinks(session, webUrl, options) {
|
|
88125
|
+
const powerplantUrl = `${webUrl}/rooms/${session.id}`;
|
|
88126
|
+
switch (session.source) {
|
|
88127
|
+
case "claude-code":
|
|
88128
|
+
if (!options.localMachine) return { powerplantUrl };
|
|
88129
|
+
if (options.terminalSession !== void 0) {
|
|
88130
|
+
const { tty, appPid, appName } = options.terminalSession;
|
|
88131
|
+
return {
|
|
88132
|
+
powerplantUrl,
|
|
88133
|
+
extra: {
|
|
88134
|
+
label: `Show in ${appName}`,
|
|
88135
|
+
focus: { tty, appPid },
|
|
88136
|
+
terminal: resumeCommand("claude-code", session.externalId, powerplantUrl)
|
|
88137
|
+
}
|
|
88138
|
+
};
|
|
88139
|
+
}
|
|
88140
|
+
if (options.claudeDesktopSessionId !== void 0) {
|
|
88141
|
+
return {
|
|
88142
|
+
powerplantUrl,
|
|
88143
|
+
extra: {
|
|
88144
|
+
label: "Open in Claude",
|
|
88145
|
+
url: `claude://claude.ai/epitaxy/${encodeURIComponent(options.claudeDesktopSessionId)}`
|
|
88146
|
+
}
|
|
88147
|
+
};
|
|
88148
|
+
}
|
|
88149
|
+
return {
|
|
88150
|
+
powerplantUrl,
|
|
88151
|
+
extra: {
|
|
88152
|
+
label: "Resume in terminal",
|
|
88153
|
+
terminal: resumeCommand("claude-code", session.externalId, powerplantUrl)
|
|
88154
|
+
}
|
|
88155
|
+
};
|
|
88156
|
+
case "codex": {
|
|
88157
|
+
const threadId2 = codexThreadId(session.externalId);
|
|
88158
|
+
if (threadId2 === null || !options.localMachine) return { powerplantUrl };
|
|
88159
|
+
return {
|
|
88160
|
+
powerplantUrl,
|
|
88161
|
+
extra: options.codexDesktop ? { label: "Open in Codex", url: `codex://threads/${threadId2}` } : { label: "Resume in terminal", terminal: resumeCommand("codex", threadId2, powerplantUrl) }
|
|
88162
|
+
};
|
|
88163
|
+
}
|
|
88164
|
+
case "claude-cloud":
|
|
88165
|
+
return {
|
|
88166
|
+
powerplantUrl,
|
|
88167
|
+
extra: { label: "Open on claude.ai", url: `https://claude.ai/code/${encodeURIComponent(session.externalId)}` }
|
|
88168
|
+
};
|
|
88169
|
+
default:
|
|
88170
|
+
return session.providerUrl === null ? { powerplantUrl } : { powerplantUrl, extra: { label: "Open in Cursor", url: session.providerUrl } };
|
|
88171
|
+
}
|
|
88172
|
+
}
|
|
88173
|
+
var TRAILING_UUID = /([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$/i;
|
|
88174
|
+
function codexThreadId(externalId) {
|
|
88175
|
+
return TRAILING_UUID.exec(externalId)?.[1] ?? null;
|
|
88176
|
+
}
|
|
88177
|
+
var CODEX_APP_BUNDLES = ["ChatGPT.app", "Codex.app"];
|
|
88178
|
+
var urlSchemesSchema = external_exports.array(external_exports.object({ CFBundleURLSchemes: external_exports.array(external_exports.string()).optional() }));
|
|
88179
|
+
function detectCodexDesktop(probe) {
|
|
88180
|
+
return detectDesktopScheme(CODEX_APP_BUNDLES, "codex", probe);
|
|
88181
|
+
}
|
|
88182
|
+
function detectClaudeDesktop(probe) {
|
|
88183
|
+
return detectDesktopScheme(["Claude.app"], "claude", probe);
|
|
88184
|
+
}
|
|
88185
|
+
function detectDesktopScheme(bundles, scheme, probe = { exists: existsSync8, readUrlSchemes: realReadUrlSchemes }) {
|
|
88186
|
+
const roots = ["/Applications", path19.join(os17.homedir(), "Applications")];
|
|
88187
|
+
return roots.some(
|
|
88188
|
+
(root) => bundles.some((bundle) => {
|
|
88189
|
+
const bundlePath = path19.join(root, bundle);
|
|
88190
|
+
return probe.exists(bundlePath) && probe.readUrlSchemes(bundlePath).includes(scheme);
|
|
88191
|
+
})
|
|
88192
|
+
);
|
|
88193
|
+
}
|
|
88194
|
+
function realReadUrlSchemes(bundlePath) {
|
|
88195
|
+
if (process.platform !== "darwin") return [];
|
|
88196
|
+
try {
|
|
88197
|
+
const json2 = execFileSync4(
|
|
88198
|
+
"plutil",
|
|
88199
|
+
["-extract", "CFBundleURLTypes", "json", "-o", "-", path19.join(bundlePath, "Contents", "Info.plist")],
|
|
88200
|
+
{ stdio: ["ignore", "pipe", "ignore"] }
|
|
88201
|
+
).toString();
|
|
88202
|
+
const parsed = urlSchemesSchema.safeParse(JSON.parse(json2));
|
|
88203
|
+
if (!parsed.success) return [];
|
|
88204
|
+
return parsed.data.flatMap((entry) => entry.CFBundleURLSchemes ?? []);
|
|
88205
|
+
} catch {
|
|
88206
|
+
return [];
|
|
88207
|
+
}
|
|
88208
|
+
}
|
|
88209
|
+
var claudeDesktopSessionSchema = external_exports.object({
|
|
88210
|
+
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),
|
|
88211
|
+
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),
|
|
88212
|
+
/** Observed 2026-09-10 on Claude 1.52386.0: the app sets this itself on
|
|
88213
|
+
* older sessions as well as on a user's archive action. A file without
|
|
88214
|
+
* it, or with another shape, is not archived as far as this read knows,
|
|
88215
|
+
* and still links: the flag must never cost the row its desktop link. */
|
|
88216
|
+
isArchived: external_exports.unknown().optional()
|
|
88217
|
+
});
|
|
88218
|
+
async function readClaudeDesktopSessions(wanted, root = path19.join(os17.homedir(), "Library/Application Support/Claude/claude-code-sessions")) {
|
|
88219
|
+
const sessions = /* @__PURE__ */ new Map();
|
|
88220
|
+
const ambiguous = /* @__PURE__ */ new Set();
|
|
88221
|
+
if (wanted.size === 0) return sessions;
|
|
88222
|
+
const buffer = Buffer.alloc(1024 * 1024 + 1);
|
|
88223
|
+
async function visit3(directory, depth) {
|
|
88224
|
+
const entries = await readdir2(directory, { withFileTypes: true }).catch((error62) => {
|
|
88225
|
+
if (depth > 0 && isMissingFile(error62)) return [];
|
|
88226
|
+
throw error62;
|
|
88227
|
+
});
|
|
88228
|
+
for (const entry of entries) {
|
|
88229
|
+
const file2 = path19.join(directory, entry.name);
|
|
88230
|
+
if (entry.isDirectory() && depth < 2) {
|
|
88231
|
+
await visit3(file2, depth + 1);
|
|
88232
|
+
} else if (depth === 2 && entry.isFile() && /^local_.*\.json$/.test(entry.name)) {
|
|
88233
|
+
const handle = await open2(file2, "r").catch((error62) => {
|
|
88234
|
+
if (isMissingFile(error62)) return null;
|
|
88235
|
+
throw error62;
|
|
88236
|
+
});
|
|
88237
|
+
if (handle === null) continue;
|
|
88238
|
+
try {
|
|
88239
|
+
const { bytesRead } = await handle.read(buffer);
|
|
88240
|
+
if (bytesRead > 1024 * 1024) continue;
|
|
88241
|
+
const parsed = claudeDesktopSessionSchema.safeParse(
|
|
88242
|
+
JSON.parse(buffer.subarray(0, bytesRead).toString())
|
|
88243
|
+
);
|
|
88244
|
+
if (!parsed.success || !wanted.has(parsed.data.cliSessionId)) continue;
|
|
88245
|
+
const { cliSessionId, sessionId, isArchived } = parsed.data;
|
|
88246
|
+
if (ambiguous.has(cliSessionId)) continue;
|
|
88247
|
+
if (sessions.has(cliSessionId) && sessions.get(cliSessionId)?.sessionId !== sessionId) {
|
|
88248
|
+
sessions.delete(cliSessionId);
|
|
88249
|
+
ambiguous.add(cliSessionId);
|
|
88250
|
+
} else {
|
|
88251
|
+
sessions.set(cliSessionId, { sessionId, archived: isArchived === true });
|
|
88252
|
+
}
|
|
88253
|
+
} catch (error62) {
|
|
88254
|
+
if (!(error62 instanceof SyntaxError)) throw error62;
|
|
88255
|
+
} finally {
|
|
88256
|
+
await handle.close();
|
|
88257
|
+
}
|
|
88258
|
+
}
|
|
88259
|
+
}
|
|
88260
|
+
}
|
|
88261
|
+
await visit3(root, 0);
|
|
88262
|
+
return sessions;
|
|
88263
|
+
}
|
|
88264
|
+
function isMissingFile(error62) {
|
|
88265
|
+
return error62 instanceof Error && "code" in error62 && error62.code === "ENOENT";
|
|
88266
|
+
}
|
|
88267
|
+
|
|
88268
|
+
// src/desktopDiagnostics.ts
|
|
88269
|
+
async function probeClaudeDesktopSessions(wanted, installed, reportFault, root = path20.join(os18.homedir(), "Library/Application Support/Claude/claude-code-sessions"), read = readClaudeDesktopSessions) {
|
|
88270
|
+
if (!installed || wanted.size === 0) {
|
|
88271
|
+
return { sessions: /* @__PURE__ */ new Map(), diagnostic: { outcome: "not-needed" } };
|
|
88272
|
+
}
|
|
88273
|
+
try {
|
|
88274
|
+
return { sessions: await read(wanted, root), diagnostic: { outcome: "available" } };
|
|
88275
|
+
} catch (error62) {
|
|
88276
|
+
const diagnostic = clientFailure(error62);
|
|
88277
|
+
if (diagnostic.domain === "JavaScript" || diagnostic.domain === "Node") {
|
|
88278
|
+
reportFault(new Error(`Claude desktop registry failed (${diagnostic.domain}:${diagnostic.code})`));
|
|
88279
|
+
}
|
|
88280
|
+
return { sessions: /* @__PURE__ */ new Map(), diagnostic };
|
|
88281
|
+
}
|
|
88282
|
+
}
|
|
88283
|
+
|
|
88284
|
+
// src/cli.ts
|
|
88285
|
+
import { spawn as spawn2, spawnSync as spawnSync5 } from "node:child_process";
|
|
88286
|
+
import { existsSync as existsSync12, mkdirSync as mkdirSync11, openSync as openSync6, realpathSync as realpathSync5, rmSync as rmSync6 } from "node:fs";
|
|
88287
|
+
import path28 from "node:path";
|
|
88288
|
+
import { parseArgs } from "node:util";
|
|
88289
|
+
|
|
87785
88290
|
// src/connect.ts
|
|
87786
|
-
import { execFileSync as
|
|
88291
|
+
import { execFileSync as execFileSync5, spawnSync } from "node:child_process";
|
|
87787
88292
|
import {
|
|
87788
|
-
existsSync as
|
|
88293
|
+
existsSync as existsSync9,
|
|
87789
88294
|
mkdirSync as mkdirSync8,
|
|
87790
88295
|
mkdtempSync,
|
|
87791
|
-
readdirSync as
|
|
88296
|
+
readdirSync as readdirSync5,
|
|
87792
88297
|
readFileSync as readFileSync11,
|
|
87793
|
-
realpathSync as
|
|
87794
|
-
statSync as
|
|
88298
|
+
realpathSync as realpathSync4,
|
|
88299
|
+
statSync as statSync5,
|
|
87795
88300
|
writeFileSync as writeFileSync8
|
|
87796
88301
|
} from "node:fs";
|
|
87797
|
-
import
|
|
87798
|
-
import
|
|
88302
|
+
import os19 from "node:os";
|
|
88303
|
+
import path21 from "node:path";
|
|
87799
88304
|
import { emitKeypressEvents } from "node:readline";
|
|
87800
88305
|
|
|
87801
88306
|
// src/agentVersions.ts
|
|
@@ -87853,6 +88358,11 @@ var officialClientsSchema = external_exports.object({
|
|
|
87853
88358
|
cursor: external_exports.object({ clientId: external_exports.string().min(1) })
|
|
87854
88359
|
}).nullable();
|
|
87855
88360
|
var officialClientsDocumentSchema = external_exports.object({ clients: officialClientsSchema });
|
|
88361
|
+
function connectExitCode(outcome, background) {
|
|
88362
|
+
if (outcome.failed > 0) return 1;
|
|
88363
|
+
if (background && (outcome.pending > 0 || outcome.connected + outcome.configured === 0)) return 1;
|
|
88364
|
+
return 0;
|
|
88365
|
+
}
|
|
87856
88366
|
var OPENAI_TEAM_ID = "2DC432GLL2";
|
|
87857
88367
|
var CURSOR_TEAM_ID = "VDXQ22DGB9";
|
|
87858
88368
|
var CODEX_BUNDLE_ID = "com.openai.codex";
|
|
@@ -87864,10 +88374,10 @@ function startTimeBudget(totalMs, now = Date.now) {
|
|
|
87864
88374
|
return { remainingMs: () => Math.max(0, deadline - now()) };
|
|
87865
88375
|
}
|
|
87866
88376
|
function defaultApplicationsDirs(homeDir) {
|
|
87867
|
-
return process.platform === "darwin" ? ["/Applications",
|
|
88377
|
+
return process.platform === "darwin" ? ["/Applications", path21.join(homeDir, "Applications")] : [];
|
|
87868
88378
|
}
|
|
87869
88379
|
function detectClients(options = {}) {
|
|
87870
|
-
const homeDir = options.homeDir ??
|
|
88380
|
+
const homeDir = options.homeDir ?? os19.homedir();
|
|
87871
88381
|
const whichAll = options.whichAll ?? defaultWhichAll;
|
|
87872
88382
|
const env = options.env ?? process.env;
|
|
87873
88383
|
const applicationsDirs = options.applicationsDirs ?? defaultApplicationsDirs(homeDir);
|
|
@@ -87882,7 +88392,7 @@ function detectClients(options = {}) {
|
|
|
87882
88392
|
const add = (client, bin, configDir) => {
|
|
87883
88393
|
let real;
|
|
87884
88394
|
try {
|
|
87885
|
-
real =
|
|
88395
|
+
real = realpathSync4(bin);
|
|
87886
88396
|
} catch {
|
|
87887
88397
|
return;
|
|
87888
88398
|
}
|
|
@@ -87892,20 +88402,20 @@ function detectClients(options = {}) {
|
|
|
87892
88402
|
clients.push({ client, bin, ...configDir !== void 0 && { configDir } });
|
|
87893
88403
|
};
|
|
87894
88404
|
for (const bin of whichAll("claude")) add("claude", bin);
|
|
87895
|
-
const localClaude =
|
|
87896
|
-
if (
|
|
88405
|
+
const localClaude = path21.join(homeDir, ".local", "bin", "claude");
|
|
88406
|
+
if (existsSync9(localClaude)) add("claude", localClaude);
|
|
87897
88407
|
for (const bin of desktopClaudeBinaries(homeDir)) add("claude", bin);
|
|
87898
88408
|
const claudeBins = clients.filter((client) => client.client === "claude" && client.configDir === void 0).map((client) => client.bin);
|
|
87899
88409
|
for (const configDir of claudeConfigHomes(homeDir, env)) {
|
|
87900
88410
|
for (const bin of claudeBins) add("claude", bin, configDir);
|
|
87901
88411
|
}
|
|
87902
88412
|
for (const bin of whichAll("codex")) add("codex", bin);
|
|
87903
|
-
const localCodex =
|
|
87904
|
-
if (
|
|
88413
|
+
const localCodex = path21.join(homeDir, ".local", "bin", "codex");
|
|
88414
|
+
if (existsSync9(localCodex)) add("codex", localCodex);
|
|
87905
88415
|
for (const bin of codexBundleBinaries(applicationsDirs, bundleSeams)) add("codex", bin);
|
|
87906
|
-
const cursorDir =
|
|
87907
|
-
if (
|
|
87908
|
-
clients.push({ client: "cursor", bin:
|
|
88416
|
+
const cursorDir = path21.join(homeDir, ".cursor");
|
|
88417
|
+
if (existsSync9(cursorDir) || cursorAppInstalled(applicationsDirs, bundleSeams)) {
|
|
88418
|
+
clients.push({ client: "cursor", bin: path21.join(cursorDir, "mcp.json") });
|
|
87909
88419
|
}
|
|
87910
88420
|
return clients;
|
|
87911
88421
|
}
|
|
@@ -87913,28 +88423,28 @@ function claudeConfigHomes(homeDir, env) {
|
|
|
87913
88423
|
const homes = [];
|
|
87914
88424
|
const seen = /* @__PURE__ */ new Set();
|
|
87915
88425
|
try {
|
|
87916
|
-
seen.add(
|
|
88426
|
+
seen.add(realpathSync4(path21.join(homeDir, ".claude")));
|
|
87917
88427
|
} catch {
|
|
87918
88428
|
}
|
|
87919
88429
|
const add = (configDir) => {
|
|
87920
88430
|
let real;
|
|
87921
88431
|
try {
|
|
87922
|
-
real =
|
|
88432
|
+
real = realpathSync4(configDir);
|
|
87923
88433
|
} catch {
|
|
87924
88434
|
return;
|
|
87925
88435
|
}
|
|
87926
88436
|
if (seen.has(real)) return;
|
|
87927
88437
|
seen.add(real);
|
|
87928
|
-
homes.push(
|
|
88438
|
+
homes.push(path21.resolve(configDir));
|
|
87929
88439
|
};
|
|
87930
88440
|
let entries = [];
|
|
87931
88441
|
try {
|
|
87932
|
-
entries =
|
|
88442
|
+
entries = readdirSync5(homeDir);
|
|
87933
88443
|
} catch {
|
|
87934
88444
|
}
|
|
87935
88445
|
for (const entry of entries.sort()) {
|
|
87936
|
-
if (entry.startsWith(".claude-") &&
|
|
87937
|
-
add(
|
|
88446
|
+
if (entry.startsWith(".claude-") && existsSync9(path21.join(homeDir, entry, ".claude.json"))) {
|
|
88447
|
+
add(path21.join(homeDir, entry));
|
|
87938
88448
|
}
|
|
87939
88449
|
}
|
|
87940
88450
|
if (env.CLAUDE_CONFIG_DIR) add(env.CLAUDE_CONFIG_DIR);
|
|
@@ -87955,14 +88465,14 @@ function appBundles(applicationsDirs, namePrefixes) {
|
|
|
87955
88465
|
for (const dir of applicationsDirs) {
|
|
87956
88466
|
let entries;
|
|
87957
88467
|
try {
|
|
87958
|
-
entries =
|
|
88468
|
+
entries = readdirSync5(dir);
|
|
87959
88469
|
} catch {
|
|
87960
88470
|
continue;
|
|
87961
88471
|
}
|
|
87962
88472
|
for (const entry of entries) {
|
|
87963
88473
|
if (!entry.endsWith(".app")) continue;
|
|
87964
88474
|
if (!namePrefixes.some((prefix) => entry.startsWith(prefix))) continue;
|
|
87965
|
-
bundles.push(
|
|
88475
|
+
bundles.push(path21.join(dir, entry));
|
|
87966
88476
|
}
|
|
87967
88477
|
}
|
|
87968
88478
|
return bundles;
|
|
@@ -87982,7 +88492,7 @@ function codexBundleBinaries(applicationsDirs, seams) {
|
|
|
87982
88492
|
const infoTimeoutMs = budgetedTimeout(BUNDLE_INFO_TIMEOUT_MS, appDir, seams);
|
|
87983
88493
|
if (infoTimeoutMs === null) continue;
|
|
87984
88494
|
if (seams.readBundleInfo(appDir, infoTimeoutMs)?.bundleId !== CODEX_BUNDLE_ID) continue;
|
|
87985
|
-
const bin =
|
|
88495
|
+
const bin = path21.join(appDir, "Contents", "Resources", "codex");
|
|
87986
88496
|
if (!isExecutableFile(bin)) continue;
|
|
87987
88497
|
if (!signedByTeam(bin, OPENAI_TEAM_ID, "OpenAI", appDir, seams)) continue;
|
|
87988
88498
|
found.push(bin);
|
|
@@ -87994,7 +88504,7 @@ function trustedCursorBundle(appDir, seams) {
|
|
|
87994
88504
|
if (infoTimeoutMs === null) return null;
|
|
87995
88505
|
const info = seams.readBundleInfo(appDir, infoTimeoutMs);
|
|
87996
88506
|
if (info?.executable === void 0) return null;
|
|
87997
|
-
const bin =
|
|
88507
|
+
const bin = path21.join(appDir, "Contents", "MacOS", info.executable);
|
|
87998
88508
|
if (!isExecutableFile(bin)) return null;
|
|
87999
88509
|
if (!signedByTeam(bin, CURSOR_TEAM_ID, "Cursor", appDir, seams)) return null;
|
|
88000
88510
|
return info;
|
|
@@ -88017,7 +88527,7 @@ function cursorAppVersion(applicationsDirs, seams) {
|
|
|
88017
88527
|
}
|
|
88018
88528
|
function isExecutableFile(filePath) {
|
|
88019
88529
|
try {
|
|
88020
|
-
const stats =
|
|
88530
|
+
const stats = statSync5(filePath);
|
|
88021
88531
|
return stats.isFile() && (stats.mode & 73) !== 0;
|
|
88022
88532
|
} catch {
|
|
88023
88533
|
return false;
|
|
@@ -88031,7 +88541,7 @@ var bundleInfoSchema = external_exports.object({
|
|
|
88031
88541
|
function realReadBundleInfo(appDir, timeoutMs) {
|
|
88032
88542
|
const result = spawnSync(
|
|
88033
88543
|
"plutil",
|
|
88034
|
-
["-convert", "json", "-o", "-",
|
|
88544
|
+
["-convert", "json", "-o", "-", path21.join(appDir, "Contents", "Info.plist")],
|
|
88035
88545
|
{ encoding: "utf8", timeout: timeoutMs }
|
|
88036
88546
|
);
|
|
88037
88547
|
if (result.status !== 0) return null;
|
|
@@ -88053,18 +88563,18 @@ function realVerifySignature(binPath, teamId, timeoutMs) {
|
|
|
88053
88563
|
}).status === 0;
|
|
88054
88564
|
}
|
|
88055
88565
|
function desktopClaudeBinaries(homeDir) {
|
|
88056
|
-
const root =
|
|
88566
|
+
const root = path21.join(homeDir, "Library", "Application Support", "Claude", "claude-code");
|
|
88057
88567
|
let versions;
|
|
88058
88568
|
try {
|
|
88059
|
-
versions =
|
|
88569
|
+
versions = readdirSync5(root);
|
|
88060
88570
|
} catch {
|
|
88061
88571
|
return [];
|
|
88062
88572
|
}
|
|
88063
|
-
return versions.map((version2) =>
|
|
88573
|
+
return versions.map((version2) => path21.join(root, version2, "claude.app", "Contents", "MacOS", "claude")).filter((bin) => existsSync9(bin));
|
|
88064
88574
|
}
|
|
88065
88575
|
function defaultWhichAll(name) {
|
|
88066
88576
|
try {
|
|
88067
|
-
return
|
|
88577
|
+
return execFileSync5("which", ["-a", name], { encoding: "utf8" }).split("\n").map((line) => line.trim()).filter(Boolean);
|
|
88068
88578
|
} catch {
|
|
88069
88579
|
return [];
|
|
88070
88580
|
}
|
|
@@ -88159,9 +88669,9 @@ function displayName(client, all) {
|
|
|
88159
88669
|
const sameTarget = peers.filter((peer) => peer.configDir === client.configDir);
|
|
88160
88670
|
const details = [];
|
|
88161
88671
|
if (profiles.size > 1) {
|
|
88162
|
-
details.push(client.configDir?.replace(
|
|
88672
|
+
details.push(client.configDir?.replace(os19.homedir(), "~") ?? "default profile");
|
|
88163
88673
|
}
|
|
88164
|
-
if (sameTarget.length > 1) details.push(client.bin.replace(
|
|
88674
|
+
if (sameTarget.length > 1) details.push(client.bin.replace(os19.homedir(), "~"));
|
|
88165
88675
|
return details.length > 0 ? `${product} (${details.join(", ")})` : product;
|
|
88166
88676
|
}
|
|
88167
88677
|
function pickerAllowed(options) {
|
|
@@ -88611,7 +89121,7 @@ function connectCursor(mcpJsonPath, name, deps) {
|
|
|
88611
89121
|
);
|
|
88612
89122
|
if (patch.error !== void 0 || patch.entry === void 0) {
|
|
88613
89123
|
return failed(
|
|
88614
|
-
`${mcpJsonPath.replace(
|
|
89124
|
+
`${mcpJsonPath.replace(os19.homedir(), "~")} is ${patch.error}, fix it by hand, then re-run ${deps.connectCommand}.`
|
|
88615
89125
|
);
|
|
88616
89126
|
}
|
|
88617
89127
|
if (patch.changed) deps.writeTextFile(mcpJsonPath, patch.content);
|
|
@@ -88667,7 +89177,7 @@ function disconnectTarget(agent, candidates, deps) {
|
|
|
88667
89177
|
try {
|
|
88668
89178
|
last = candidate.client === "claude" ? disconnectClaude(candidate, deps) : candidate.client === "codex" ? disconnectCodex(candidate.bin, deps) : disconnectCursor(candidate.bin, deps);
|
|
88669
89179
|
} catch (error62) {
|
|
88670
|
-
const name = candidate.client === "cursor" ? `Cursor (${candidate.bin.replace(
|
|
89180
|
+
const name = candidate.client === "cursor" ? `Cursor (${candidate.bin.replace(os19.homedir(), "~")})` : describeBinary(candidate.bin);
|
|
88671
89181
|
deps.log(`\u2717 ${name}: ${error62 instanceof Error ? error62.message : String(error62)}`);
|
|
88672
89182
|
last = "failed";
|
|
88673
89183
|
}
|
|
@@ -88729,7 +89239,7 @@ function disconnectCodex(bin, deps) {
|
|
|
88729
89239
|
return "disconnected";
|
|
88730
89240
|
}
|
|
88731
89241
|
function disconnectCursor(mcpJsonPath, deps) {
|
|
88732
|
-
const name = `Cursor (${mcpJsonPath.replace(
|
|
89242
|
+
const name = `Cursor (${mcpJsonPath.replace(os19.homedir(), "~")})`;
|
|
88733
89243
|
const patch = unpatchCursorMcpJson(deps.readTextFile(mcpJsonPath), MCP_SERVER_NAME);
|
|
88734
89244
|
if (patch.error !== void 0) {
|
|
88735
89245
|
deps.log(`\u2717 ${name}: mcp.json is ${patch.error}, fix it by hand, then re-run powerplant disconnect.`);
|
|
@@ -88759,11 +89269,11 @@ function anyClientStillConnected(clients, deps) {
|
|
|
88759
89269
|
});
|
|
88760
89270
|
}
|
|
88761
89271
|
function describeBinary(bin) {
|
|
88762
|
-
return `${
|
|
89272
|
+
return `${path21.basename(bin)} (${bin.replace(os19.homedir(), "~")})`;
|
|
88763
89273
|
}
|
|
88764
89274
|
function describeClaudeTarget(client) {
|
|
88765
89275
|
if (client.configDir === void 0) return describeBinary(client.bin);
|
|
88766
|
-
return `${
|
|
89276
|
+
return `${path21.basename(client.bin)} (${client.configDir.replace(os19.homedir(), "~")})`;
|
|
88767
89277
|
}
|
|
88768
89278
|
var FAILURE_DETAIL_MAX_CHARS = 200;
|
|
88769
89279
|
function describeFailure(result) {
|
|
@@ -88776,7 +89286,7 @@ function describeFailure(result) {
|
|
|
88776
89286
|
}
|
|
88777
89287
|
var neutralDirMemo;
|
|
88778
89288
|
function neutralWorkdir() {
|
|
88779
|
-
neutralDirMemo ??= mkdtempSync(
|
|
89289
|
+
neutralDirMemo ??= mkdtempSync(path21.join(os19.tmpdir(), "powerplant-connect-"));
|
|
88780
89290
|
return neutralDirMemo;
|
|
88781
89291
|
}
|
|
88782
89292
|
async function fetchOfficialClients(apiUrl, log3) {
|
|
@@ -88820,11 +89330,11 @@ function realReadTextFileStrict(filePath) {
|
|
|
88820
89330
|
}
|
|
88821
89331
|
}
|
|
88822
89332
|
function realWriteTextFile(filePath, content) {
|
|
88823
|
-
mkdirSync8(
|
|
89333
|
+
mkdirSync8(path21.dirname(filePath), { recursive: true });
|
|
88824
89334
|
writeFileSync8(filePath, content);
|
|
88825
89335
|
}
|
|
88826
|
-
function codexConfigPath(homeDir =
|
|
88827
|
-
return
|
|
89336
|
+
function codexConfigPath(homeDir = os19.homedir()) {
|
|
89337
|
+
return path21.join(process.env.CODEX_HOME ?? path21.join(homeDir, ".codex"), "config.toml");
|
|
88828
89338
|
}
|
|
88829
89339
|
function realOpenUrl(url2) {
|
|
88830
89340
|
const bin = process.platform === "darwin" ? "open" : process.platform === "linux" ? "xdg-open" : null;
|
|
@@ -88844,7 +89354,7 @@ function commandEnv(overrides) {
|
|
|
88844
89354
|
}
|
|
88845
89355
|
function realAgentVersion(client) {
|
|
88846
89356
|
if (client.client === "cursor") {
|
|
88847
|
-
return cursorAppVersion(defaultApplicationsDirs(
|
|
89357
|
+
return cursorAppVersion(defaultApplicationsDirs(os19.homedir()), {
|
|
88848
89358
|
readBundleInfo: realReadBundleInfo,
|
|
88849
89359
|
verifySignature: realVerifySignature,
|
|
88850
89360
|
budget: UNLIMITED_TIME_BUDGET,
|
|
@@ -88884,9 +89394,9 @@ function realRunInteractive(bin, args, env) {
|
|
|
88884
89394
|
}
|
|
88885
89395
|
|
|
88886
89396
|
// src/connections.ts
|
|
88887
|
-
import { execFileSync as
|
|
89397
|
+
import { execFileSync as execFileSync6, spawnSync as spawnSync2 } from "node:child_process";
|
|
88888
89398
|
import { mkdirSync as mkdirSync9, writeFileSync as writeFileSync9 } from "node:fs";
|
|
88889
|
-
import
|
|
89399
|
+
import path22 from "node:path";
|
|
88890
89400
|
function probeConnections(clients, deps) {
|
|
88891
89401
|
const reports = [];
|
|
88892
89402
|
for (const kind of ["claude", "codex", "cursor"]) {
|
|
@@ -88930,7 +89440,7 @@ function aggregateClaudeTargets(targets) {
|
|
|
88930
89440
|
if (targets.length === 1 || worst.report.state === "signed-in") return worst.report;
|
|
88931
89441
|
return {
|
|
88932
89442
|
...worst.report,
|
|
88933
|
-
target: worst.configDir === void 0 ? "default profile" :
|
|
89443
|
+
target: worst.configDir === void 0 ? "default profile" : path22.basename(worst.configDir)
|
|
88934
89444
|
};
|
|
88935
89445
|
}
|
|
88936
89446
|
function probeClient(client, deps) {
|
|
@@ -89009,12 +89519,12 @@ var detectedClientsSchema = external_exports.object({
|
|
|
89009
89519
|
)
|
|
89010
89520
|
});
|
|
89011
89521
|
function detectedClientsPath(homeDir) {
|
|
89012
|
-
return
|
|
89522
|
+
return path22.join(collectorStateDir(homeDir), "detected-clients.json");
|
|
89013
89523
|
}
|
|
89014
89524
|
function saveDetectedClients(clients, pathValue, homeDir) {
|
|
89015
89525
|
try {
|
|
89016
89526
|
const file2 = detectedClientsPath(homeDir);
|
|
89017
|
-
mkdirSync9(
|
|
89527
|
+
mkdirSync9(path22.dirname(file2), { recursive: true });
|
|
89018
89528
|
const record2 = {
|
|
89019
89529
|
detectedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
89020
89530
|
path: pathValue,
|
|
@@ -89087,7 +89597,7 @@ function runWithPath(pathValue, budget = UNLIMITED_TIME_BUDGET) {
|
|
|
89087
89597
|
function whichAllWith(pathValue) {
|
|
89088
89598
|
return (name) => {
|
|
89089
89599
|
try {
|
|
89090
|
-
return
|
|
89600
|
+
return execFileSync6("which", ["-a", name], {
|
|
89091
89601
|
encoding: "utf8",
|
|
89092
89602
|
env: { ...process.env, PATH: pathValue }
|
|
89093
89603
|
}).split("\n").map((line) => line.trim()).filter(Boolean);
|
|
@@ -89098,10 +89608,10 @@ function whichAllWith(pathValue) {
|
|
|
89098
89608
|
}
|
|
89099
89609
|
|
|
89100
89610
|
// src/doctor.ts
|
|
89101
|
-
import { closeSync as
|
|
89611
|
+
import { closeSync as closeSync5, fstatSync, openSync as openSync5, readSync as readSync5 } from "node:fs";
|
|
89102
89612
|
|
|
89103
89613
|
// src/update.ts
|
|
89104
|
-
import
|
|
89614
|
+
import path24 from "node:path";
|
|
89105
89615
|
|
|
89106
89616
|
// src/duration.ts
|
|
89107
89617
|
function duration3(ms) {
|
|
@@ -89119,11 +89629,11 @@ function ago(ms) {
|
|
|
89119
89629
|
}
|
|
89120
89630
|
|
|
89121
89631
|
// src/installOwner.ts
|
|
89122
|
-
import { accessSync, constants } from "node:fs";
|
|
89123
|
-
import
|
|
89632
|
+
import { accessSync, constants as constants2 } from "node:fs";
|
|
89633
|
+
import path23 from "node:path";
|
|
89124
89634
|
|
|
89125
89635
|
// src/version.ts
|
|
89126
|
-
var CLI_VERSION = true ? "0.4.
|
|
89636
|
+
var CLI_VERSION = true ? "0.4.6" : "0.0.0-checkout";
|
|
89127
89637
|
var CLI_RELEASE_BUILD = true ? true : false;
|
|
89128
89638
|
var CLI_PACKAGE_NAME = "@usepowerplant/cli";
|
|
89129
89639
|
|
|
@@ -89147,8 +89657,8 @@ function inspectInstall(entryPath2, env) {
|
|
|
89147
89657
|
inPlace: { ok: false, reason: `the install at ${packageDir} isn't a layout this CLI recognises` }
|
|
89148
89658
|
};
|
|
89149
89659
|
}
|
|
89150
|
-
const modulesDir =
|
|
89151
|
-
const prefix = manager === "npm" ?
|
|
89660
|
+
const modulesDir = path23.dirname(path23.dirname(packageDir));
|
|
89661
|
+
const prefix = manager === "npm" ? path23.dirname(path23.dirname(modulesDir)) : null;
|
|
89152
89662
|
if (!env.isWritableDirectory(modulesDir)) {
|
|
89153
89663
|
return { manager, packageDir, prefix, inPlace: { ok: false, reason: `${modulesDir} isn't writable by you` } };
|
|
89154
89664
|
}
|
|
@@ -89169,8 +89679,8 @@ function linkedEntryPath(realEntryPath) {
|
|
|
89169
89679
|
if (at === -1) return realEntryPath;
|
|
89170
89680
|
return `${realEntryPath.slice(0, store)}${realEntryPath.slice(at)}`;
|
|
89171
89681
|
}
|
|
89172
|
-
function updateCommand(manager, version2, prefix = null) {
|
|
89173
|
-
const spec = version2 !== null && parseReleaseVersion(version2) !== null ? `${CLI_PACKAGE_NAME}@${version2}` : CLI_PACKAGE_NAME
|
|
89682
|
+
function updateCommand(manager, version2, prefix = null, channel3 = "latest") {
|
|
89683
|
+
const spec = version2 !== null && parseReleaseVersion(version2) !== null ? `${CLI_PACKAGE_NAME}@${version2}` : `${CLI_PACKAGE_NAME}@${channel3}`;
|
|
89174
89684
|
switch (manager) {
|
|
89175
89685
|
case "npm":
|
|
89176
89686
|
return { bin: "npm", args: prefix === null ? ["install", "-g", spec] : ["install", "-g", "--prefix", prefix, spec] };
|
|
@@ -89182,12 +89692,12 @@ function updateCommand(manager, version2, prefix = null) {
|
|
|
89182
89692
|
return { bin: "yarn", args: ["global", "add", spec] };
|
|
89183
89693
|
}
|
|
89184
89694
|
}
|
|
89185
|
-
function manualUpdateCommand(manager, version2, prefix = null) {
|
|
89186
|
-
const { bin, args } = updateCommand(manager ?? "npm", version2, prefix);
|
|
89695
|
+
function manualUpdateCommand(manager, version2, prefix = null, channel3 = "latest") {
|
|
89696
|
+
const { bin, args } = updateCommand(manager ?? "npm", version2, prefix, channel3);
|
|
89187
89697
|
return [bin, ...args].join(" ");
|
|
89188
89698
|
}
|
|
89189
89699
|
function installedVersion(packageDir, readTextFile) {
|
|
89190
|
-
const raw = readTextFile(
|
|
89700
|
+
const raw = readTextFile(path23.join(packageDir, "package.json"));
|
|
89191
89701
|
if (raw === null) return null;
|
|
89192
89702
|
try {
|
|
89193
89703
|
const parsed = JSON.parse(raw);
|
|
@@ -89204,7 +89714,7 @@ function realInspectEnvironment() {
|
|
|
89204
89714
|
pnpmHome: process.env.PNPM_HOME,
|
|
89205
89715
|
isWritableDirectory: (dir) => {
|
|
89206
89716
|
try {
|
|
89207
|
-
accessSync(dir,
|
|
89717
|
+
accessSync(dir, constants2.W_OK);
|
|
89208
89718
|
return true;
|
|
89209
89719
|
} catch {
|
|
89210
89720
|
return false;
|
|
@@ -89228,10 +89738,10 @@ var updateProgressSchema = external_exports.object({
|
|
|
89228
89738
|
});
|
|
89229
89739
|
var UPDATE_PROGRESS_STALE_MS = 15 * 6e4;
|
|
89230
89740
|
function updateProgressPath(homeDir) {
|
|
89231
|
-
return
|
|
89741
|
+
return path24.join(collectorStateDir(homeDir), "cli-update.json");
|
|
89232
89742
|
}
|
|
89233
89743
|
function updateLogPath(homeDir) {
|
|
89234
|
-
return
|
|
89744
|
+
return path24.join(collectorStateDir(homeDir), "cli-update.log");
|
|
89235
89745
|
}
|
|
89236
89746
|
function readUpdateProgress(readTextFile, file2 = updateProgressPath()) {
|
|
89237
89747
|
const raw = readTextFile(file2);
|
|
@@ -89258,10 +89768,12 @@ function updateProgressView(progress, cliVersion2, now) {
|
|
|
89258
89768
|
async function runUpdate(deps) {
|
|
89259
89769
|
const { inspection } = deps;
|
|
89260
89770
|
if (inspection.manager === null) {
|
|
89261
|
-
throw new ExpectedCliError(cannotUpdateMessage(null, inspection.inPlace.reason, null));
|
|
89771
|
+
throw new ExpectedCliError(cannotUpdateMessage(null, inspection.inPlace.reason, null, deps.channel));
|
|
89262
89772
|
}
|
|
89263
89773
|
if (!inspection.inPlace.ok) {
|
|
89264
|
-
throw new ExpectedCliError(
|
|
89774
|
+
throw new ExpectedCliError(
|
|
89775
|
+
cannotUpdateMessage(inspection.manager, inspection.inPlace.reason, inspection.prefix, deps.channel)
|
|
89776
|
+
);
|
|
89265
89777
|
}
|
|
89266
89778
|
const manager = inspection.manager;
|
|
89267
89779
|
const running = deps.readProgress();
|
|
@@ -89281,7 +89793,7 @@ async function runUpdate(deps) {
|
|
|
89281
89793
|
);
|
|
89282
89794
|
}
|
|
89283
89795
|
deps.writeProgress({ state: "installing", target, startedAt, pid: deps.pid });
|
|
89284
|
-
const { bin, args } = updateCommand(manager, target, inspection.prefix);
|
|
89796
|
+
const { bin, args } = updateCommand(manager, target, inspection.prefix, deps.channel);
|
|
89285
89797
|
deps.log(`Updating ${CLI_PACKAGE_NAME}${target === null ? "" : ` to ${target}`} via ${manager}\u2026`);
|
|
89286
89798
|
const result = deps.run(bin, args);
|
|
89287
89799
|
if (result.error !== void 0 || result.status !== 0) {
|
|
@@ -89294,7 +89806,7 @@ async function runUpdate(deps) {
|
|
|
89294
89806
|
finishedAt: new Date(deps.now()).toISOString(),
|
|
89295
89807
|
detail
|
|
89296
89808
|
});
|
|
89297
|
-
throw new ExpectedCliError(`${detail}. Update by hand: ${manualUpdateCommand(manager, target, inspection.prefix)}`);
|
|
89809
|
+
throw new ExpectedCliError(`${detail}. Update by hand: ${manualUpdateCommand(manager, target, inspection.prefix, deps.channel)}`);
|
|
89298
89810
|
}
|
|
89299
89811
|
const installed = deps.readInstalledVersion(inspection.packageDir);
|
|
89300
89812
|
if (installed !== null && target !== null && compareReleaseVersions(installed, target) === -1) {
|
|
@@ -89307,13 +89819,13 @@ async function runUpdate(deps) {
|
|
|
89307
89819
|
finishedAt: new Date(deps.now()).toISOString(),
|
|
89308
89820
|
detail
|
|
89309
89821
|
});
|
|
89310
|
-
throw new ExpectedCliError(`${detail}. Update by hand: ${manualUpdateCommand(manager, target, inspection.prefix)}`);
|
|
89822
|
+
throw new ExpectedCliError(`${detail}. Update by hand: ${manualUpdateCommand(manager, target, inspection.prefix, deps.channel)}`);
|
|
89311
89823
|
}
|
|
89312
89824
|
deps.clearProgress();
|
|
89313
89825
|
deps.log(updatedMessage(installed, deps.restartService()));
|
|
89314
89826
|
}
|
|
89315
|
-
function cannotUpdateMessage(manager, reason, prefix) {
|
|
89316
|
-
return `powerplant update can't replace this install: ${reason}. Update by hand: ${manualUpdateCommand(manager, null, prefix)}`;
|
|
89827
|
+
function cannotUpdateMessage(manager, reason, prefix, channel3) {
|
|
89828
|
+
return `powerplant update can't replace this install: ${reason}. Update by hand: ${manualUpdateCommand(manager, null, prefix, channel3)}`;
|
|
89317
89829
|
}
|
|
89318
89830
|
function isFresh(progress, now) {
|
|
89319
89831
|
return now - Date.parse(progress.startedAt) <= UPDATE_PROGRESS_STALE_MS;
|
|
@@ -89422,26 +89934,26 @@ function redactedLogTail(raw) {
|
|
|
89422
89934
|
while (lines.length > 0 && lines[lines.length - 1]?.trim() === "") lines.pop();
|
|
89423
89935
|
return lines.slice(-DOCTOR_LOG_TAIL_LINES);
|
|
89424
89936
|
}
|
|
89425
|
-
function readDoctorLogTail(
|
|
89937
|
+
function readDoctorLogTail(path29) {
|
|
89426
89938
|
let fd;
|
|
89427
89939
|
try {
|
|
89428
|
-
fd =
|
|
89940
|
+
fd = openSync5(path29, "r");
|
|
89429
89941
|
} catch (error62) {
|
|
89430
|
-
if (error62.code === "ENOENT") return { path:
|
|
89431
|
-
return { path:
|
|
89942
|
+
if (error62.code === "ENOENT") return { path: path29, lines: null };
|
|
89943
|
+
return { path: path29, lines: null, readError: error62 instanceof Error ? error62.message : String(error62) };
|
|
89432
89944
|
}
|
|
89433
89945
|
try {
|
|
89434
89946
|
const size = fstatSync(fd).size;
|
|
89435
89947
|
const offset = Math.max(0, size - LOG_TAIL_READ_BYTES);
|
|
89436
89948
|
const buffer = Buffer.alloc(Math.min(size, LOG_TAIL_READ_BYTES));
|
|
89437
|
-
|
|
89949
|
+
readSync5(fd, buffer, 0, buffer.length, offset);
|
|
89438
89950
|
let text = buffer.toString("utf8");
|
|
89439
89951
|
if (offset > 0) text = text.slice(text.indexOf("\n") + 1);
|
|
89440
|
-
return { path:
|
|
89952
|
+
return { path: path29, lines: redactedLogTail(text) };
|
|
89441
89953
|
} catch (error62) {
|
|
89442
|
-
return { path:
|
|
89954
|
+
return { path: path29, lines: null, readError: error62 instanceof Error ? error62.message : String(error62) };
|
|
89443
89955
|
} finally {
|
|
89444
|
-
|
|
89956
|
+
closeSync5(fd);
|
|
89445
89957
|
}
|
|
89446
89958
|
}
|
|
89447
89959
|
function renderDoctorReport(i) {
|
|
@@ -89454,7 +89966,7 @@ function renderDoctorReport(i) {
|
|
|
89454
89966
|
);
|
|
89455
89967
|
lines.push("");
|
|
89456
89968
|
lines.push(
|
|
89457
|
-
`CLI: powerplant ${i.cliVersion}` + (i.
|
|
89969
|
+
`CLI: powerplant ${i.cliVersion}` + (isUpdateAvailable(i.cliVersion, i.latestVersion) ? ` (${i.latestVersion} is available)` : "")
|
|
89458
89970
|
);
|
|
89459
89971
|
const unsupported = unsupportedVersionNotice(i.cliVersion, i.oldestSupportedVersion);
|
|
89460
89972
|
if (unsupported !== null) lines.push(unsupported);
|
|
@@ -89640,12 +90152,12 @@ function pauseSyncing(appEnv) {
|
|
|
89640
90152
|
function resumeSyncing(appEnv) {
|
|
89641
90153
|
writeCollectorControl(appEnv, resumedControl(readCollectorControl(appEnv), Date.now()));
|
|
89642
90154
|
}
|
|
89643
|
-
function realPauseDeps(appEnv,
|
|
90155
|
+
function realPauseDeps(appEnv, resumeCommand2, promptLine) {
|
|
89644
90156
|
return {
|
|
89645
90157
|
readControl: () => readCollectorControl(appEnv),
|
|
89646
90158
|
resume: () => resumeSyncing(appEnv),
|
|
89647
90159
|
promptLine,
|
|
89648
|
-
resumeCommand,
|
|
90160
|
+
resumeCommand: resumeCommand2,
|
|
89649
90161
|
now: Date.now
|
|
89650
90162
|
};
|
|
89651
90163
|
}
|
|
@@ -89658,13 +90170,13 @@ function pausedSince(control, now) {
|
|
|
89658
90170
|
const age = pausedFor(control, now);
|
|
89659
90171
|
return age === null ? "Syncing is paused" : `Syncing has been paused for ${age}`;
|
|
89660
90172
|
}
|
|
89661
|
-
function pausedNotice(control,
|
|
90173
|
+
function pausedNotice(control, resumeCommand2, now) {
|
|
89662
90174
|
if (!control.paused) return null;
|
|
89663
|
-
return `\u23F8 ${pausedSince(control, now)}. Nothing uploads until you run \`${
|
|
90175
|
+
return `\u23F8 ${pausedSince(control, now)}. Nothing uploads until you run \`${resumeCommand2}\`.`;
|
|
89664
90176
|
}
|
|
89665
|
-
function pausedSyncNotice(control,
|
|
89666
|
-
if (!control.paused || dryRun) return pausedNotice(control,
|
|
89667
|
-
return `\u23F8 ${pausedSince(control, now)}. This pass uploads because you asked for it. Background syncing stays paused until you run \`${
|
|
90177
|
+
function pausedSyncNotice(control, resumeCommand2, now, dryRun) {
|
|
90178
|
+
if (!control.paused || dryRun) return pausedNotice(control, resumeCommand2, now);
|
|
90179
|
+
return `\u23F8 ${pausedSince(control, now)}. This pass uploads because you asked for it. Background syncing stays paused until you run \`${resumeCommand2}\`.`;
|
|
89668
90180
|
}
|
|
89669
90181
|
async function offerResume(deps, options) {
|
|
89670
90182
|
const { log: log3, indent } = options;
|
|
@@ -89740,6 +90252,7 @@ async function runInit(deps) {
|
|
|
89740
90252
|
let repoDiscoveryEnabled = false;
|
|
89741
90253
|
let protectedFoldersNeedAttention = false;
|
|
89742
90254
|
let installed = false;
|
|
90255
|
+
let menubarDidWork = false;
|
|
89743
90256
|
let pauseOffer = "not-paused";
|
|
89744
90257
|
log3("2/3 Start background sync");
|
|
89745
90258
|
log3(" When syncing is enabled, session transcripts upload to Powerplant for the team whose capture settings match the repository.");
|
|
@@ -89817,6 +90330,10 @@ async function runInit(deps) {
|
|
|
89817
90330
|
pauseOffer = await offerResume(deps.pause, { log: log3, indent: " ", promptAllowed: deps.promptAllowed });
|
|
89818
90331
|
if (pauseOffer === "not-paused") log3(fresh ? " \u2713 Background sync is running" : "\u2713 Background sync is running");
|
|
89819
90332
|
await offerAutomaticUpdates(deps.autoUpdate, { log: log3, indent: " ", promptAllowed: deps.promptAllowed });
|
|
90333
|
+
if (deps.menubarApp !== null) {
|
|
90334
|
+
const app = await deps.activity("Setting up the menu bar app\u2026", deps.menubarApp);
|
|
90335
|
+
menubarDidWork = narrateMenubarApp(log3, app);
|
|
90336
|
+
}
|
|
89820
90337
|
}
|
|
89821
90338
|
log3("");
|
|
89822
90339
|
log3("3/3 Give your agents Powerplant MCP access");
|
|
@@ -89834,7 +90351,7 @@ async function runInit(deps) {
|
|
|
89834
90351
|
log3("");
|
|
89835
90352
|
const connectDidWork = outcome !== null && outcome.connected + outcome.configured > outcome.unchanged;
|
|
89836
90353
|
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) {
|
|
90354
|
+
if (!enrolled && !installed && !menubarDidWork && !repoDiscoveryEnabled && !protectedFoldersNeedAttention && pauseOffer === "not-paused" && connectSettled) {
|
|
89838
90355
|
log3("Everything is already set up.");
|
|
89839
90356
|
return;
|
|
89840
90357
|
}
|
|
@@ -89874,6 +90391,25 @@ async function runInit(deps) {
|
|
|
89874
90391
|
log3(` Add MCP to the agents you skipped any time: ${deps.connectCommand}`);
|
|
89875
90392
|
}
|
|
89876
90393
|
}
|
|
90394
|
+
function narrateMenubarApp(log3, outcome) {
|
|
90395
|
+
switch (outcome.kind) {
|
|
90396
|
+
case "installed":
|
|
90397
|
+
log3(" \u2713 Menu bar app installed, look for the bolt in your menu bar");
|
|
90398
|
+
return true;
|
|
90399
|
+
case "updated":
|
|
90400
|
+
log3(" \u2713 Menu bar app updated to match this CLI");
|
|
90401
|
+
return true;
|
|
90402
|
+
case "already-current":
|
|
90403
|
+
log3(" \u2713 Menu bar app is installed");
|
|
90404
|
+
return outcome.launched;
|
|
90405
|
+
case "skipped":
|
|
90406
|
+
return false;
|
|
90407
|
+
case "failed":
|
|
90408
|
+
log3(` ! Could not set up the menu bar app: ${outcome.detail}`);
|
|
90409
|
+
log3(" Rerun `powerplant init` to try again.");
|
|
90410
|
+
return true;
|
|
90411
|
+
}
|
|
90412
|
+
}
|
|
89877
90413
|
async function confirmProtectedRepoDiscovery(deps) {
|
|
89878
90414
|
for (; ; ) {
|
|
89879
90415
|
const answer = await deps.promptLine(
|
|
@@ -89924,177 +90460,8 @@ async function realPromptLine(question) {
|
|
|
89924
90460
|
}
|
|
89925
90461
|
}
|
|
89926
90462
|
|
|
89927
|
-
// src/memberSessions.ts
|
|
89928
|
-
import { execFileSync as execFileSync6 } from "node:child_process";
|
|
89929
|
-
import { existsSync as existsSync8 } from "node:fs";
|
|
89930
|
-
import { open as open2, readdir as readdir2 } from "node:fs/promises";
|
|
89931
|
-
import os17 from "node:os";
|
|
89932
|
-
import path21 from "node:path";
|
|
89933
|
-
var memberSessionSchema = external_exports.object({
|
|
89934
|
-
id: external_exports.string().min(1),
|
|
89935
|
-
source: external_exports.string().min(1),
|
|
89936
|
-
externalId: external_exports.string().min(1),
|
|
89937
|
-
title: external_exports.string().nullable(),
|
|
89938
|
-
repoDir: external_exports.string().nullable(),
|
|
89939
|
-
machineId: external_exports.string().nullable(),
|
|
89940
|
-
lastActivityAt: external_exports.string().min(1),
|
|
89941
|
-
providerUrl: external_exports.string().nullable()
|
|
89942
|
-
});
|
|
89943
|
-
var FETCH_TIMEOUT_MS2 = 3e3;
|
|
89944
|
-
async function fetchMemberSessions(credentials, fetchImpl = fetch) {
|
|
89945
|
-
try {
|
|
89946
|
-
const response = await fetchImpl(`${credentials.apiUrl}/api/collector/member-sessions`, {
|
|
89947
|
-
headers: { authorization: `Bearer ${credentials.token}`, ...cliVersionHeaders() },
|
|
89948
|
-
signal: AbortSignal.timeout(FETCH_TIMEOUT_MS2)
|
|
89949
|
-
});
|
|
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;
|
|
89953
|
-
} catch {
|
|
89954
|
-
return null;
|
|
89955
|
-
}
|
|
89956
|
-
}
|
|
89957
|
-
function sessionLinks(session, webUrl, options) {
|
|
89958
|
-
const powerplantUrl = `${webUrl}/rooms/${session.id}`;
|
|
89959
|
-
switch (session.source) {
|
|
89960
|
-
case "claude-code":
|
|
89961
|
-
if (!options.localMachine) return { powerplantUrl };
|
|
89962
|
-
if (options.terminalSession !== void 0) {
|
|
89963
|
-
const { tty, appPid, appName } = options.terminalSession;
|
|
89964
|
-
return {
|
|
89965
|
-
powerplantUrl,
|
|
89966
|
-
extra: {
|
|
89967
|
-
label: `Show in ${appName}`,
|
|
89968
|
-
focus: { tty, appPid },
|
|
89969
|
-
terminal: ["resume-session", "claude-code", session.externalId]
|
|
89970
|
-
}
|
|
89971
|
-
};
|
|
89972
|
-
}
|
|
89973
|
-
if (options.claudeDesktopSessionId !== void 0) {
|
|
89974
|
-
return {
|
|
89975
|
-
powerplantUrl,
|
|
89976
|
-
extra: {
|
|
89977
|
-
label: "Open in Claude",
|
|
89978
|
-
url: `claude://claude.ai/epitaxy/${encodeURIComponent(options.claudeDesktopSessionId)}`
|
|
89979
|
-
}
|
|
89980
|
-
};
|
|
89981
|
-
}
|
|
89982
|
-
return {
|
|
89983
|
-
powerplantUrl,
|
|
89984
|
-
extra: {
|
|
89985
|
-
label: "Resume in terminal",
|
|
89986
|
-
terminal: ["resume-session", "claude-code", session.externalId]
|
|
89987
|
-
}
|
|
89988
|
-
};
|
|
89989
|
-
case "codex": {
|
|
89990
|
-
const threadId2 = codexThreadId(session.externalId);
|
|
89991
|
-
if (threadId2 === null || !options.localMachine) return { powerplantUrl };
|
|
89992
|
-
return {
|
|
89993
|
-
powerplantUrl,
|
|
89994
|
-
extra: options.codexDesktop ? { label: "Open in Codex", url: `codex://threads/${threadId2}` } : { label: "Resume in terminal", terminal: ["resume-session", "codex", threadId2] }
|
|
89995
|
-
};
|
|
89996
|
-
}
|
|
89997
|
-
case "claude-cloud":
|
|
89998
|
-
return {
|
|
89999
|
-
powerplantUrl,
|
|
90000
|
-
extra: { label: "Open on claude.ai", url: `https://claude.ai/code/${encodeURIComponent(session.externalId)}` }
|
|
90001
|
-
};
|
|
90002
|
-
default:
|
|
90003
|
-
return session.providerUrl === null ? { powerplantUrl } : { powerplantUrl, extra: { label: "Open in Cursor", url: session.providerUrl } };
|
|
90004
|
-
}
|
|
90005
|
-
}
|
|
90006
|
-
var TRAILING_UUID = /([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$/i;
|
|
90007
|
-
function codexThreadId(externalId) {
|
|
90008
|
-
return TRAILING_UUID.exec(externalId)?.[1] ?? null;
|
|
90009
|
-
}
|
|
90010
|
-
var CODEX_APP_BUNDLES = ["ChatGPT.app", "Codex.app"];
|
|
90011
|
-
var urlSchemesSchema = external_exports.array(external_exports.object({ CFBundleURLSchemes: external_exports.array(external_exports.string()).optional() }));
|
|
90012
|
-
function detectCodexDesktop(probe) {
|
|
90013
|
-
return detectDesktopScheme(CODEX_APP_BUNDLES, "codex", probe);
|
|
90014
|
-
}
|
|
90015
|
-
function detectClaudeDesktop(probe) {
|
|
90016
|
-
return detectDesktopScheme(["Claude.app"], "claude", probe);
|
|
90017
|
-
}
|
|
90018
|
-
function detectDesktopScheme(bundles, scheme, probe = { exists: existsSync8, readUrlSchemes: realReadUrlSchemes }) {
|
|
90019
|
-
const roots = ["/Applications", path21.join(os17.homedir(), "Applications")];
|
|
90020
|
-
return roots.some(
|
|
90021
|
-
(root) => bundles.some((bundle) => {
|
|
90022
|
-
const bundlePath = path21.join(root, bundle);
|
|
90023
|
-
return probe.exists(bundlePath) && probe.readUrlSchemes(bundlePath).includes(scheme);
|
|
90024
|
-
})
|
|
90025
|
-
);
|
|
90026
|
-
}
|
|
90027
|
-
function realReadUrlSchemes(bundlePath) {
|
|
90028
|
-
if (process.platform !== "darwin") return [];
|
|
90029
|
-
try {
|
|
90030
|
-
const json2 = execFileSync6(
|
|
90031
|
-
"plutil",
|
|
90032
|
-
["-extract", "CFBundleURLTypes", "json", "-o", "-", path21.join(bundlePath, "Contents", "Info.plist")],
|
|
90033
|
-
{ stdio: ["ignore", "pipe", "ignore"] }
|
|
90034
|
-
).toString();
|
|
90035
|
-
const parsed = urlSchemesSchema.safeParse(JSON.parse(json2));
|
|
90036
|
-
if (!parsed.success) return [];
|
|
90037
|
-
return parsed.data.flatMap((entry) => entry.CFBundleURLSchemes ?? []);
|
|
90038
|
-
} catch {
|
|
90039
|
-
return [];
|
|
90040
|
-
}
|
|
90041
|
-
}
|
|
90042
|
-
var claudeDesktopSessionSchema = external_exports.object({
|
|
90043
|
-
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
|
-
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
|
-
});
|
|
90046
|
-
async function readClaudeDesktopSessions(wanted, root = path21.join(os17.homedir(), "Library/Application Support/Claude/claude-code-sessions")) {
|
|
90047
|
-
const sessions = /* @__PURE__ */ new Map();
|
|
90048
|
-
const ambiguous = /* @__PURE__ */ new Set();
|
|
90049
|
-
if (wanted.size === 0) return sessions;
|
|
90050
|
-
const buffer = Buffer.alloc(1024 * 1024 + 1);
|
|
90051
|
-
async function visit3(directory, depth) {
|
|
90052
|
-
const entries = await readdir2(directory, { withFileTypes: true }).catch((error62) => {
|
|
90053
|
-
if (isMissingFile(error62)) return [];
|
|
90054
|
-
throw error62;
|
|
90055
|
-
});
|
|
90056
|
-
for (const entry of entries) {
|
|
90057
|
-
const file2 = path21.join(directory, entry.name);
|
|
90058
|
-
if (entry.isDirectory() && depth < 2) {
|
|
90059
|
-
await visit3(file2, depth + 1);
|
|
90060
|
-
} else if (depth === 2 && entry.isFile() && /^local_.*\.json$/.test(entry.name)) {
|
|
90061
|
-
const handle = await open2(file2, "r").catch((error62) => {
|
|
90062
|
-
if (isMissingFile(error62)) return null;
|
|
90063
|
-
throw error62;
|
|
90064
|
-
});
|
|
90065
|
-
if (handle === null) continue;
|
|
90066
|
-
try {
|
|
90067
|
-
const { bytesRead } = await handle.read(buffer);
|
|
90068
|
-
if (bytesRead > 1024 * 1024) continue;
|
|
90069
|
-
const parsed = claudeDesktopSessionSchema.safeParse(
|
|
90070
|
-
JSON.parse(buffer.subarray(0, bytesRead).toString())
|
|
90071
|
-
);
|
|
90072
|
-
if (!parsed.success || !wanted.has(parsed.data.cliSessionId)) continue;
|
|
90073
|
-
const { cliSessionId, sessionId } = parsed.data;
|
|
90074
|
-
if (ambiguous.has(cliSessionId)) continue;
|
|
90075
|
-
if (sessions.has(cliSessionId) && sessions.get(cliSessionId) !== sessionId) {
|
|
90076
|
-
sessions.delete(cliSessionId);
|
|
90077
|
-
ambiguous.add(cliSessionId);
|
|
90078
|
-
} else {
|
|
90079
|
-
sessions.set(cliSessionId, sessionId);
|
|
90080
|
-
}
|
|
90081
|
-
} catch (error62) {
|
|
90082
|
-
if (!(error62 instanceof SyntaxError)) throw error62;
|
|
90083
|
-
} finally {
|
|
90084
|
-
await handle.close();
|
|
90085
|
-
}
|
|
90086
|
-
}
|
|
90087
|
-
}
|
|
90088
|
-
}
|
|
90089
|
-
await visit3(root, 0);
|
|
90090
|
-
return sessions;
|
|
90091
|
-
}
|
|
90092
|
-
function isMissingFile(error62) {
|
|
90093
|
-
return error62 instanceof Error && "code" in error62 && error62.code === "ENOENT";
|
|
90094
|
-
}
|
|
90095
|
-
|
|
90096
90463
|
// src/menu.ts
|
|
90097
|
-
import
|
|
90464
|
+
import path25 from "node:path";
|
|
90098
90465
|
var MENU_CONTRACT = 1;
|
|
90099
90466
|
var CLIENT_NAMES = { claude: "Claude Code", codex: "Codex", cursor: "Cursor" };
|
|
90100
90467
|
function renderMenu(i) {
|
|
@@ -90149,10 +90516,16 @@ function renderMenu(i) {
|
|
|
90149
90516
|
items.push({ type: "separator" });
|
|
90150
90517
|
items.push(...collectorBlock(i, envArgs, problem));
|
|
90151
90518
|
}
|
|
90152
|
-
const agents =
|
|
90519
|
+
const agents = recentAgentItems(i);
|
|
90153
90520
|
if (agents !== null) {
|
|
90154
90521
|
items.push({ type: "separator" });
|
|
90155
|
-
items.push({ type: "section", title: "
|
|
90522
|
+
items.push({ type: "section", title: "Recent sessions" });
|
|
90523
|
+
if (i.desktopDiagnostic?.outcome === "denied" || i.desktopDiagnostic?.outcome === "failed") {
|
|
90524
|
+
items.push(problem(
|
|
90525
|
+
i.desktopDiagnostic.outcome === "denied" ? "Claude desktop session access was denied" : "Claude desktop sessions could not be read",
|
|
90526
|
+
"Desktop links are unavailable. Retry by reopening this menu; use Terminal or Powerplant in the meantime."
|
|
90527
|
+
));
|
|
90528
|
+
}
|
|
90156
90529
|
items.push(...agents);
|
|
90157
90530
|
}
|
|
90158
90531
|
if (!unsupported && (isUpdateAvailable(i.cliVersion, i.latestVersion) || progress.kind !== "none")) {
|
|
@@ -90175,6 +90548,7 @@ function renderMenu(i) {
|
|
|
90175
90548
|
const icon = attention ? "attention" : i.control.paused ? "paused" : "running";
|
|
90176
90549
|
return {
|
|
90177
90550
|
contract: MENU_CONTRACT,
|
|
90551
|
+
...i.desktopDiagnostic && { desktopDiagnostic: i.desktopDiagnostic },
|
|
90178
90552
|
appEnv: i.config.appEnv,
|
|
90179
90553
|
cliVersion: i.cliVersion,
|
|
90180
90554
|
icon,
|
|
@@ -90288,27 +90662,30 @@ function collectorBlock(i, envArgs, problem) {
|
|
|
90288
90662
|
{ type: "status", mark: "ok", title: "Background sync running", subtitle: lastUploadLine(i) }
|
|
90289
90663
|
];
|
|
90290
90664
|
}
|
|
90291
|
-
var MAX_ACTIVE_AGENTS = 8;
|
|
90292
90665
|
var AGENT_TITLE_MAX = 48;
|
|
90293
|
-
function
|
|
90666
|
+
function recentAgentItems(i) {
|
|
90294
90667
|
if (i.memberSessions === null) return null;
|
|
90295
|
-
const
|
|
90296
|
-
|
|
90297
|
-
|
|
90298
|
-
|
|
90299
|
-
|
|
90300
|
-
|
|
90301
|
-
|
|
90302
|
-
|
|
90303
|
-
|
|
90304
|
-
|
|
90668
|
+
const recent = i.memberSessions.filter((session) => i.now - Date.parse(session.lastActivityAt) < RECENT_SESSION_WINDOW_MS).filter((session) => session.archived !== true && session.subagent !== true && session.standaloneReview !== true).sort((a, b2) => Date.parse(b2.lastActivityAt) - Date.parse(a.lastActivityAt)).map((session) => agentRow(session, i));
|
|
90669
|
+
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));
|
|
90670
|
+
if (i.memberSessionsIncomplete) rows.push({
|
|
90671
|
+
type: "status",
|
|
90672
|
+
mark: "muted",
|
|
90673
|
+
title: "Session list may be incomplete",
|
|
90674
|
+
subtitle: "Some sessions could not be loaded. The menu will retry on refresh."
|
|
90675
|
+
});
|
|
90676
|
+
return rows;
|
|
90677
|
+
}
|
|
90678
|
+
function groupedAgentRows(rows) {
|
|
90679
|
+
const openable = rows.filter((row) => row.agent?.harness !== void 0);
|
|
90680
|
+
const unavailable = rows.filter((row) => row.agent?.harness === void 0);
|
|
90681
|
+
return [...openable, ...unavailable.length > 0 ? [{ type: "section", title: "Not on this Mac" }, ...unavailable] : []];
|
|
90305
90682
|
}
|
|
90306
90683
|
function agentRow(session, i) {
|
|
90307
90684
|
const name = session.title ?? session.repoDir ?? "Untitled session";
|
|
90308
90685
|
const trimmed = name.length > AGENT_TITLE_MAX ? `${name.slice(0, AGENT_TITLE_MAX - 1)}\u2026` : name;
|
|
90309
90686
|
const when = ago(i.now - Date.parse(session.lastActivityAt));
|
|
90310
90687
|
const localMachine = i.credentials !== null && session.machineId === i.credentials.machineId;
|
|
90311
|
-
const desktopSessionId = localMachine && session.source === "claude-code" ? i.claudeDesktopSessions?.get(session.externalId) : void 0;
|
|
90688
|
+
const desktopSessionId = localMachine && session.source === "claude-code" ? i.claudeDesktopSessions?.get(session.externalId)?.sessionId : void 0;
|
|
90312
90689
|
const app = desktopSessionId !== void 0 ? "Claude desktop" : isSessionSource(session.source) ? describeSessionSource(session.source) : session.source;
|
|
90313
90690
|
const links = sessionLinks(session, i.config.webUrl, {
|
|
90314
90691
|
codexDesktop: i.codexDesktop,
|
|
@@ -90317,7 +90694,8 @@ function agentRow(session, i) {
|
|
|
90317
90694
|
terminalSession: i.liveTerminalSessions?.get(session.externalId)
|
|
90318
90695
|
});
|
|
90319
90696
|
const agent = {
|
|
90320
|
-
icon: session.source === "codex" ? "chatgpt" : session.source === "cursor" || session.source === "cursor-cloud" ? "cursor" : session.source === "claude-code" || session.source === "claude-cloud" ? "claude" : "unknown"
|
|
90697
|
+
icon: session.source === "codex" ? "chatgpt" : session.source === "cursor" || session.source === "cursor-cloud" ? "cursor" : session.source === "claude-code" || session.source === "claude-cloud" ? "claude" : "unknown",
|
|
90698
|
+
...session.working === true && { working: true }
|
|
90321
90699
|
};
|
|
90322
90700
|
if (links.extra !== void 0) {
|
|
90323
90701
|
const envArgs = i.config.appEnv === "production" ? [] : ["--env", i.config.appEnv];
|
|
@@ -90347,6 +90725,11 @@ function connectionRow(connection, envArgs) {
|
|
|
90347
90725
|
const fix = (title) => ({
|
|
90348
90726
|
type: "action",
|
|
90349
90727
|
title,
|
|
90728
|
+
background: {
|
|
90729
|
+
argv: ["connect", "--background", "--client", connection.client, ...envArgs],
|
|
90730
|
+
progress: `Connecting ${name}\u2026`,
|
|
90731
|
+
detail: connection.client === "cursor" ? "Finish setup in Cursor if prompted." : "Complete sign-in in your browser if prompted."
|
|
90732
|
+
},
|
|
90350
90733
|
terminal: ["connect", "--client", connection.client, ...envArgs]
|
|
90351
90734
|
});
|
|
90352
90735
|
const row = (mark, state) => ({
|
|
@@ -90395,7 +90778,7 @@ function moreItems(i) {
|
|
|
90395
90778
|
muted(captureLine(i.credentials)),
|
|
90396
90779
|
muted(`Machine "${i.credentials.machineName}"`, i.credentials.machineId),
|
|
90397
90780
|
muted(`Enrolled ${i.credentials.enrolledAt.slice(0, 10)}`),
|
|
90398
|
-
muted(
|
|
90781
|
+
muted(`${parseReleaseVersion(i.cliVersion) === null ? "Development CLI" : "CLI"} ${i.cliVersion}`, daemonVersionNote(i))
|
|
90399
90782
|
];
|
|
90400
90783
|
more.push({ type: "submenu", title: "Background sync details", items: details });
|
|
90401
90784
|
}
|
|
@@ -90435,7 +90818,7 @@ function daemonVersionNote(i) {
|
|
|
90435
90818
|
}
|
|
90436
90819
|
var VERSION_CACHE_TTL_MS = 60 * 6e4;
|
|
90437
90820
|
function versionCachePath(homeDir, source = "npm") {
|
|
90438
|
-
return
|
|
90821
|
+
return path25.join(collectorStateDir(homeDir), source === "npm" ? "version-check.json" : "version-check-promoted.json");
|
|
90439
90822
|
}
|
|
90440
90823
|
async function cachedLatestVersion(options) {
|
|
90441
90824
|
const raw = options.readTextFile(options.cacheFile);
|
|
@@ -90463,8 +90846,8 @@ async function cachedLatestVersion(options) {
|
|
|
90463
90846
|
// src/liveTerminalSessions.ts
|
|
90464
90847
|
import { execFileSync as execFileSync7 } from "node:child_process";
|
|
90465
90848
|
import { readdir as readdir3, readFile as readFile2 } from "node:fs/promises";
|
|
90466
|
-
import
|
|
90467
|
-
import
|
|
90849
|
+
import os20 from "node:os";
|
|
90850
|
+
import path26 from "node:path";
|
|
90468
90851
|
var sessionFileAsObserved = external_exports.looseObject({
|
|
90469
90852
|
pid: external_exports.number().int().positive(),
|
|
90470
90853
|
sessionId: external_exports.string().min(1),
|
|
@@ -90472,8 +90855,8 @@ var sessionFileAsObserved = external_exports.looseObject({
|
|
|
90472
90855
|
});
|
|
90473
90856
|
var START_TIME_TOLERANCE_MS = 3e4;
|
|
90474
90857
|
var SESSION_FILE = /^(\d+)\.json$/;
|
|
90475
|
-
function claudeSessionsDir(homeDir =
|
|
90476
|
-
return
|
|
90858
|
+
function claudeSessionsDir(homeDir = os20.homedir()) {
|
|
90859
|
+
return path26.join(homeDir, ".claude", "sessions");
|
|
90477
90860
|
}
|
|
90478
90861
|
async function readLiveTerminalSessions(wanted, deps = {}) {
|
|
90479
90862
|
const found = /* @__PURE__ */ new Map();
|
|
@@ -90498,7 +90881,7 @@ async function readLiveTerminalSessions(wanted, deps = {}) {
|
|
|
90498
90881
|
}
|
|
90499
90882
|
continue;
|
|
90500
90883
|
}
|
|
90501
|
-
const session = await readSessionFile(
|
|
90884
|
+
const session = await readSessionFile(path26.join(sessionsDir, entry), report2);
|
|
90502
90885
|
if (session === null) continue;
|
|
90503
90886
|
if (session.pid !== Number(match[1])) {
|
|
90504
90887
|
report2({
|
|
@@ -90536,7 +90919,7 @@ async function readSessionFile(file2, report2) {
|
|
|
90536
90919
|
report2({
|
|
90537
90920
|
operation: "claude-session-registry-shape",
|
|
90538
90921
|
message: "A Claude Code session file has a shape this CLI can't read",
|
|
90539
|
-
context: { file:
|
|
90922
|
+
context: { file: path26.basename(file2), shape: describeShape(raw) }
|
|
90540
90923
|
});
|
|
90541
90924
|
return null;
|
|
90542
90925
|
}
|
|
@@ -90600,7 +90983,7 @@ function parseProcessTable(output2) {
|
|
|
90600
90983
|
|
|
90601
90984
|
// src/resumeSession.ts
|
|
90602
90985
|
import { spawnSync as spawnSync3 } from "node:child_process";
|
|
90603
|
-
import { existsSync as
|
|
90986
|
+
import { existsSync as existsSync10 } from "node:fs";
|
|
90604
90987
|
var PROVIDERS = {
|
|
90605
90988
|
"claude-code": {
|
|
90606
90989
|
resume: (sessionId) => ["claude", ["--resume", sessionId]],
|
|
@@ -90622,7 +91005,7 @@ function resumeSessionArgv(source, sessionId) {
|
|
|
90622
91005
|
}
|
|
90623
91006
|
function resumeFolder(source, sessionId, deps = {}) {
|
|
90624
91007
|
const lookup = deps.sessionFolder ?? ((s, id) => PROVIDERS[s]?.folder(id));
|
|
90625
|
-
const exists = deps.exists ??
|
|
91008
|
+
const exists = deps.exists ?? existsSync10;
|
|
90626
91009
|
const report2 = deps.report ?? reportCollectorError;
|
|
90627
91010
|
let recorded;
|
|
90628
91011
|
try {
|
|
@@ -90631,30 +91014,32 @@ function resumeFolder(source, sessionId, deps = {}) {
|
|
|
90631
91014
|
report2(error62, "powerplant-resume-session-folder");
|
|
90632
91015
|
}
|
|
90633
91016
|
if (recorded === void 0) {
|
|
90634
|
-
|
|
90635
|
-
|
|
90636
|
-
|
|
90637
|
-
};
|
|
91017
|
+
throw new ExpectedCliError(
|
|
91018
|
+
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}`
|
|
91019
|
+
);
|
|
90638
91020
|
}
|
|
90639
91021
|
if (!exists(recorded)) {
|
|
90640
|
-
|
|
90641
|
-
|
|
90642
|
-
|
|
90643
|
-
|
|
91022
|
+
const [binary, args] = resumeSessionArgv(source, sessionId);
|
|
91023
|
+
throw new ExpectedCliError(
|
|
91024
|
+
`The session's folder ${recorded} no longer exists, so nothing was started. Restore that folder, then run from inside it: ${binary} ${args.join(" ")}`
|
|
91025
|
+
);
|
|
90644
91026
|
}
|
|
90645
|
-
return
|
|
91027
|
+
return recorded;
|
|
90646
91028
|
}
|
|
90647
|
-
function runResumeSession(source, sessionId,
|
|
91029
|
+
function runResumeSession(source, sessionId, deps = {}) {
|
|
90648
91030
|
if (source === void 0 || sessionId === void 0) {
|
|
90649
91031
|
throw new ExpectedCliError("Usage: powerplant resume-session <claude-code|codex> <session-id>");
|
|
90650
91032
|
}
|
|
91033
|
+
const spawn3 = deps.spawn ?? spawnSync3;
|
|
91034
|
+
const folder = deps.folder ?? resumeFolder;
|
|
91035
|
+
const log3 = deps.log ?? console.log;
|
|
90651
91036
|
const [binary, args] = resumeSessionArgv(source, sessionId);
|
|
90652
|
-
const
|
|
90653
|
-
log3(
|
|
90654
|
-
const result = spawn3(binary, args, { stdio: "inherit",
|
|
91037
|
+
const cwd = folder(source, sessionId, { powerplantUrl: deps.powerplantUrl });
|
|
91038
|
+
log3(`Resuming in ${cwd}`);
|
|
91039
|
+
const result = spawn3(binary, args, { stdio: "inherit", cwd });
|
|
90655
91040
|
if (result.error !== void 0) {
|
|
90656
91041
|
throw new ExpectedCliError(
|
|
90657
|
-
|
|
91042
|
+
`Could not run ${binary} in ${cwd} (${result.error.message}), does that folder still exist and is the ${binary} CLI installed?`
|
|
90658
91043
|
);
|
|
90659
91044
|
}
|
|
90660
91045
|
if (result.status !== null && result.status !== 0) {
|
|
@@ -90677,7 +91062,7 @@ function renderStatus(i) {
|
|
|
90677
91062
|
const lines = [];
|
|
90678
91063
|
lines.push(`Environment: ${i.config.appEnv} (API ${i.config.apiUrl})`);
|
|
90679
91064
|
lines.push(
|
|
90680
|
-
`CLI: powerplant ${i.cliVersion}` + (i.
|
|
91065
|
+
`CLI: powerplant ${i.cliVersion}` + (isUpdateAvailable(i.cliVersion, i.latestVersion) ? `, ${i.latestVersion} is available: powerplant update` : "")
|
|
90681
91066
|
);
|
|
90682
91067
|
const unsupported = unsupportedVersionNotice(i.cliVersion, i.oldestSupportedVersion);
|
|
90683
91068
|
if (unsupported !== null) lines.push(unsupported);
|
|
@@ -90793,19 +91178,27 @@ function supportedFlag(cliVersion2, oldestSupportedVersion) {
|
|
|
90793
91178
|
return order === null ? null : order !== -1;
|
|
90794
91179
|
}
|
|
90795
91180
|
var npmLatestSchema = external_exports.object({ version: external_exports.string().min(1) });
|
|
90796
|
-
async function
|
|
91181
|
+
async function fetchDistTag(packageName, distTag, fetchImpl = fetch) {
|
|
90797
91182
|
try {
|
|
90798
91183
|
const response = await fetchImpl(
|
|
90799
|
-
`https://registry.npmjs.org/${encodeURIComponent(packageName)}
|
|
91184
|
+
`https://registry.npmjs.org/${encodeURIComponent(packageName)}/${distTag}`,
|
|
90800
91185
|
{ signal: AbortSignal.timeout(3e3) }
|
|
90801
91186
|
);
|
|
90802
|
-
if (
|
|
91187
|
+
if (response.status === 404) return { kind: "absent" };
|
|
91188
|
+
if (!response.ok) return { kind: "unreachable" };
|
|
90803
91189
|
const parsed = npmLatestSchema.safeParse(await response.json());
|
|
90804
|
-
return parsed.success ? parsed.data.version :
|
|
91190
|
+
return parsed.success ? { kind: "found", version: parsed.data.version } : { kind: "unreachable" };
|
|
90805
91191
|
} catch {
|
|
90806
|
-
return
|
|
91192
|
+
return { kind: "unreachable" };
|
|
90807
91193
|
}
|
|
90808
91194
|
}
|
|
91195
|
+
async function fetchNewestRelease(packageName, fetchImpl = fetch) {
|
|
91196
|
+
const next = await fetchDistTag(packageName, "next", fetchImpl);
|
|
91197
|
+
if (next.kind === "found") return next.version;
|
|
91198
|
+
if (next.kind === "unreachable") return null;
|
|
91199
|
+
const latest = await fetchDistTag(packageName, "latest", fetchImpl);
|
|
91200
|
+
return latest.kind === "found" ? latest.version : null;
|
|
91201
|
+
}
|
|
90809
91202
|
function releaseSource(appEnv) {
|
|
90810
91203
|
return appEnv === "production" ? "promoted" : "npm";
|
|
90811
91204
|
}
|
|
@@ -90921,6 +91314,137 @@ function createTerminalOutput(options) {
|
|
|
90921
91314
|
return { log: log3, activity };
|
|
90922
91315
|
}
|
|
90923
91316
|
|
|
91317
|
+
// src/menubarApp.ts
|
|
91318
|
+
import { existsSync as existsSync11, mkdirSync as mkdirSync10, renameSync as renameSync3, rmSync as rmSync5 } from "node:fs";
|
|
91319
|
+
import os21 from "node:os";
|
|
91320
|
+
import path27 from "node:path";
|
|
91321
|
+
import { spawnSync as spawnSync4 } from "node:child_process";
|
|
91322
|
+
var MENUBAR_APP_ZIP = "dist/menubar/Powerplant.app.zip";
|
|
91323
|
+
var MENUBAR_APP_NAME = "Powerplant.app";
|
|
91324
|
+
var BUNDLE_INFO_TIMEOUT_MS2 = 5e3;
|
|
91325
|
+
async function syncMenubarApp(ops, context2) {
|
|
91326
|
+
const zip = ops.packagedZip();
|
|
91327
|
+
if (zip === null) return { kind: "skipped", reason: "no-packaged-app" };
|
|
91328
|
+
try {
|
|
91329
|
+
const installed = ops.installedApp();
|
|
91330
|
+
if (!installed.present) {
|
|
91331
|
+
if (context2 === "daemon") return { kind: "skipped", reason: "not-installed" };
|
|
91332
|
+
const appPath = ops.freshInstallPath();
|
|
91333
|
+
ops.replace(zip, appPath);
|
|
91334
|
+
ops.launch(appPath);
|
|
91335
|
+
return { kind: "installed" };
|
|
91336
|
+
}
|
|
91337
|
+
const comparison = installed.version === null ? null : compareReleaseVersions(installed.version, ops.cliVersion);
|
|
91338
|
+
if (comparison === 0 || comparison === 1) {
|
|
91339
|
+
const launched = context2 === "init" && !ops.isRunning(installed.appPath);
|
|
91340
|
+
if (launched) ops.launch(installed.appPath);
|
|
91341
|
+
return { kind: "already-current", launched };
|
|
91342
|
+
}
|
|
91343
|
+
const wasRunning = ops.isRunning(installed.appPath);
|
|
91344
|
+
if (wasRunning) await ops.quit(installed.appPath);
|
|
91345
|
+
try {
|
|
91346
|
+
ops.replace(zip, installed.appPath);
|
|
91347
|
+
} catch (error62) {
|
|
91348
|
+
if (wasRunning) ops.launch(installed.appPath);
|
|
91349
|
+
throw error62;
|
|
91350
|
+
}
|
|
91351
|
+
if (wasRunning || context2 === "init") ops.launch(installed.appPath);
|
|
91352
|
+
return { kind: "updated", from: installed.version };
|
|
91353
|
+
} catch (error62) {
|
|
91354
|
+
return { kind: "failed", detail: error62 instanceof Error ? error62.message : String(error62) };
|
|
91355
|
+
}
|
|
91356
|
+
}
|
|
91357
|
+
function realMenubarAppOps(input2) {
|
|
91358
|
+
const home = input2.homeDir ?? os21.homedir();
|
|
91359
|
+
const userAppPath = path27.join(home, "Applications", MENUBAR_APP_NAME);
|
|
91360
|
+
const candidates = [userAppPath, path27.join("/Applications", MENUBAR_APP_NAME)];
|
|
91361
|
+
return {
|
|
91362
|
+
cliVersion: input2.cliVersion,
|
|
91363
|
+
packagedZip: () => {
|
|
91364
|
+
if (input2.packageDir === null) return null;
|
|
91365
|
+
const zip = path27.join(input2.packageDir, MENUBAR_APP_ZIP);
|
|
91366
|
+
return existsSync11(zip) ? zip : null;
|
|
91367
|
+
},
|
|
91368
|
+
installedApp: () => {
|
|
91369
|
+
const appPath = candidates.find((candidate) => existsSync11(candidate));
|
|
91370
|
+
if (appPath === void 0) return { present: false };
|
|
91371
|
+
const info = realReadBundleInfo(appPath, BUNDLE_INFO_TIMEOUT_MS2);
|
|
91372
|
+
return { present: true, appPath, version: info?.version ?? null };
|
|
91373
|
+
},
|
|
91374
|
+
isRunning: (appPath) => appProcessIds(appPath).length > 0,
|
|
91375
|
+
quit: async (appPath) => {
|
|
91376
|
+
const pids = appProcessIds(appPath);
|
|
91377
|
+
for (const pid of pids) tryKill(pid, "SIGTERM");
|
|
91378
|
+
for (let waited = 0; waited < 5e3; waited += 250) {
|
|
91379
|
+
if (pids.every((pid) => !tryKill(pid, 0))) return;
|
|
91380
|
+
await new Promise((resolve2) => setTimeout(resolve2, 250));
|
|
91381
|
+
}
|
|
91382
|
+
throw new Error(`the running app at ${appPath} did not quit`);
|
|
91383
|
+
},
|
|
91384
|
+
replace: (zip, appPath) => {
|
|
91385
|
+
const parent = path27.dirname(appPath);
|
|
91386
|
+
mkdirSync10(parent, { recursive: true });
|
|
91387
|
+
const staging = path27.join(parent, `.${MENUBAR_APP_NAME}.swap-${process.pid}`);
|
|
91388
|
+
const retired = path27.join(parent, `.${MENUBAR_APP_NAME}.old-${process.pid}`);
|
|
91389
|
+
rmSync5(staging, { recursive: true, force: true });
|
|
91390
|
+
rmSync5(retired, { recursive: true, force: true });
|
|
91391
|
+
try {
|
|
91392
|
+
const extract = spawnSync4("ditto", ["-xk", zip, staging]);
|
|
91393
|
+
if (extract.status !== 0) {
|
|
91394
|
+
throw new Error(
|
|
91395
|
+
`ditto could not extract ${zip} (${extract.stderr?.toString().trim() || `exit ${extract.status}`})`
|
|
91396
|
+
);
|
|
91397
|
+
}
|
|
91398
|
+
const extracted = path27.join(staging, MENUBAR_APP_NAME);
|
|
91399
|
+
if (!existsSync11(path27.join(extracted, "Contents", "Info.plist"))) {
|
|
91400
|
+
throw new Error(`${zip} does not contain ${MENUBAR_APP_NAME}`);
|
|
91401
|
+
}
|
|
91402
|
+
const hadOld = existsSync11(appPath);
|
|
91403
|
+
if (hadOld) renameSync3(appPath, retired);
|
|
91404
|
+
try {
|
|
91405
|
+
renameSync3(extracted, appPath);
|
|
91406
|
+
} catch (error62) {
|
|
91407
|
+
if (hadOld) renameSync3(retired, appPath);
|
|
91408
|
+
throw error62;
|
|
91409
|
+
}
|
|
91410
|
+
} finally {
|
|
91411
|
+
rmSync5(staging, { recursive: true, force: true });
|
|
91412
|
+
rmSync5(retired, { recursive: true, force: true });
|
|
91413
|
+
}
|
|
91414
|
+
},
|
|
91415
|
+
launch: (appPath) => {
|
|
91416
|
+
const result = spawnSync4("open", ["-g", appPath]);
|
|
91417
|
+
if (result.status !== 0) {
|
|
91418
|
+
throw new Error(
|
|
91419
|
+
`open could not launch ${appPath} (${result.stderr?.toString().trim() || `exit ${result.status}`})`
|
|
91420
|
+
);
|
|
91421
|
+
}
|
|
91422
|
+
},
|
|
91423
|
+
freshInstallPath: () => userAppPath
|
|
91424
|
+
};
|
|
91425
|
+
}
|
|
91426
|
+
function appProcessIds(appPath) {
|
|
91427
|
+
const executable = path27.join(appPath, "Contents", "MacOS", "PowerplantMenubar");
|
|
91428
|
+
const result = spawnSync4("ps", ["-axo", "pid=,comm="], { encoding: "utf8" });
|
|
91429
|
+
if (result.status !== 0) {
|
|
91430
|
+
throw new Error(`ps could not list processes (${result.error?.message ?? `exit ${result.status}`})`);
|
|
91431
|
+
}
|
|
91432
|
+
const pids = [];
|
|
91433
|
+
for (const line of result.stdout.split("\n")) {
|
|
91434
|
+
const match = /^\s*(\d+)\s+(.*)$/.exec(line);
|
|
91435
|
+
if (match && match[2] === executable) pids.push(Number(match[1]));
|
|
91436
|
+
}
|
|
91437
|
+
return pids;
|
|
91438
|
+
}
|
|
91439
|
+
function tryKill(pid, signal) {
|
|
91440
|
+
try {
|
|
91441
|
+
process.kill(pid, signal);
|
|
91442
|
+
return true;
|
|
91443
|
+
} catch (error62) {
|
|
91444
|
+
return error62 instanceof Error && "code" in error62 && error62.code === "EPERM";
|
|
91445
|
+
}
|
|
91446
|
+
}
|
|
91447
|
+
|
|
90924
91448
|
// src/workspace.ts
|
|
90925
91449
|
var workspaceSchema = external_exports.object({
|
|
90926
91450
|
id: external_exports.string().min(1),
|
|
@@ -90928,18 +91452,18 @@ var workspaceSchema = external_exports.object({
|
|
|
90928
91452
|
role: external_exports.string().min(1),
|
|
90929
91453
|
active: external_exports.boolean()
|
|
90930
91454
|
});
|
|
90931
|
-
var
|
|
90932
|
-
async function callApi(credentials,
|
|
91455
|
+
var FETCH_TIMEOUT_MS2 = 1e4;
|
|
91456
|
+
async function callApi(credentials, path29, init3, fetchImpl) {
|
|
90933
91457
|
let response;
|
|
90934
91458
|
try {
|
|
90935
|
-
response = await fetchImpl(`${credentials.apiUrl}${
|
|
91459
|
+
response = await fetchImpl(`${credentials.apiUrl}${path29}`, {
|
|
90936
91460
|
...init3,
|
|
90937
91461
|
headers: {
|
|
90938
91462
|
authorization: `Bearer ${credentials.token}`,
|
|
90939
91463
|
"content-type": "application/json",
|
|
90940
91464
|
...cliVersionHeaders()
|
|
90941
91465
|
},
|
|
90942
|
-
signal: AbortSignal.timeout(
|
|
91466
|
+
signal: AbortSignal.timeout(FETCH_TIMEOUT_MS2)
|
|
90943
91467
|
});
|
|
90944
91468
|
} catch (error62) {
|
|
90945
91469
|
const detail = error62 instanceof Error ? error62.message : String(error62);
|
|
@@ -90951,7 +91475,7 @@ async function callApi(credentials, path25, init3, fetchImpl) {
|
|
|
90951
91475
|
);
|
|
90952
91476
|
}
|
|
90953
91477
|
if (!response.ok) {
|
|
90954
|
-
throw new ExpectedCliError(`Powerplant answered ${response.status} for ${
|
|
91478
|
+
throw new ExpectedCliError(`Powerplant answered ${response.status} for ${path29}.`);
|
|
90955
91479
|
}
|
|
90956
91480
|
return response.json();
|
|
90957
91481
|
}
|
|
@@ -91027,6 +91551,7 @@ Commands:
|
|
|
91027
91551
|
--client claude|codex|cursor adds just those (repeatable).
|
|
91028
91552
|
disconnect The inverse of connect: remove the Powerplant MCP entry (and
|
|
91029
91553
|
its sign-in) from every installed coding agent.
|
|
91554
|
+
--client claude|codex|cursor removes just those (repeatable).
|
|
91030
91555
|
enroll (Re-)enroll this machine into your org (browser approval).
|
|
91031
91556
|
status What the background sync is doing on this machine (--json for tools).
|
|
91032
91557
|
doctor A diagnostics summary for support: status plus the redacted
|
|
@@ -91048,7 +91573,8 @@ Commands:
|
|
|
91048
91573
|
agents use: powerplant workspace [<name>] switches to <name>.
|
|
91049
91574
|
resume-session Reopen a synced session in its own CLI, right here in
|
|
91050
91575
|
this terminal: powerplant resume-session <claude-code|codex>
|
|
91051
|
-
<session-id
|
|
91576
|
+
<session-id> [--open <its Powerplant page, named when the
|
|
91577
|
+
session can't resume here>].
|
|
91052
91578
|
watch Run the background sync in the foreground.
|
|
91053
91579
|
uninstall Remove the background sync [--forget also deletes this
|
|
91054
91580
|
machine's stored credentials].
|
|
@@ -91081,6 +91607,7 @@ function parseCliArgs() {
|
|
|
91081
91607
|
// Internal: selects a non-production environment for dogfooding. Keep
|
|
91082
91608
|
// it out of USAGE and the README — customers only ever see production.
|
|
91083
91609
|
env: { type: "string" },
|
|
91610
|
+
open: { type: "string" },
|
|
91084
91611
|
client: { type: "string", multiple: true },
|
|
91085
91612
|
name: { type: "string" },
|
|
91086
91613
|
email: { type: "string" },
|
|
@@ -91092,7 +91619,8 @@ function parseCliArgs() {
|
|
|
91092
91619
|
"dry-run": { type: "boolean", default: false },
|
|
91093
91620
|
json: { type: "boolean", default: false },
|
|
91094
91621
|
forget: { type: "boolean", default: false },
|
|
91095
|
-
// Internal:
|
|
91622
|
+
// Internal: connect reports unfinished login as failure to the menu.
|
|
91623
|
+
// For update, hands the update to a
|
|
91096
91624
|
// detached copy of this command so the app's verb deadline can't kill
|
|
91097
91625
|
// a package manager mid-install; progress lands in the state file the
|
|
91098
91626
|
// menu reads (update.ts).
|
|
@@ -91255,6 +91783,7 @@ ${USAGE}`);
|
|
|
91255
91783
|
promptLine: realPromptLine
|
|
91256
91784
|
},
|
|
91257
91785
|
connect: () => connect3((line) => terminal.log(` ${line}`)),
|
|
91786
|
+
menubarApp: managesMenubarApp(config2) ? () => syncMenubarApp(thisInstallMenubarAppOps(), "init") : null,
|
|
91258
91787
|
connectCommand,
|
|
91259
91788
|
environmentName: config2.appEnv,
|
|
91260
91789
|
webUrl: config2.webUrl
|
|
@@ -91266,11 +91795,17 @@ ${USAGE}`);
|
|
|
91266
91795
|
if (outcome.pending > 0) {
|
|
91267
91796
|
console.log(`Some logins are unfinished, re-run \`${connectCommand}\` any time.`);
|
|
91268
91797
|
}
|
|
91269
|
-
|
|
91798
|
+
process.exitCode = connectExitCode(outcome, values.background);
|
|
91270
91799
|
return;
|
|
91271
91800
|
}
|
|
91272
91801
|
case "disconnect": {
|
|
91273
|
-
const
|
|
91802
|
+
const detected = detectClients({ warn: console.log });
|
|
91803
|
+
const clients = clientFilter === void 0 ? detected : detected.filter((client) => clientFilter.has(client.client));
|
|
91804
|
+
if (clientFilter !== void 0 && clients.length === 0) {
|
|
91805
|
+
console.log(`No ${[...clientFilter].join(" or ")} installation found on this machine, nothing to disconnect.`);
|
|
91806
|
+
return;
|
|
91807
|
+
}
|
|
91808
|
+
const outcome = runDisconnect(clients, {
|
|
91274
91809
|
log: console.log,
|
|
91275
91810
|
run: realRun,
|
|
91276
91811
|
readTextFile: realReadTextFileStrict,
|
|
@@ -91354,7 +91889,7 @@ The access you granted these agents stays on your Powerplant account until you r
|
|
|
91354
91889
|
const clients = mergeDetectedClients(
|
|
91355
91890
|
detectClients({ whichAll: whichAllWith(probePath), budget }),
|
|
91356
91891
|
saved,
|
|
91357
|
-
|
|
91892
|
+
existsSync12
|
|
91358
91893
|
);
|
|
91359
91894
|
const [latestVersion, oldestSupportedVersion, memberSessions, grantedClientIds] = await Promise.all([
|
|
91360
91895
|
cachedAvailableVersion(config2, credentials),
|
|
@@ -91368,13 +91903,19 @@ The access you granted these agents stays on your Powerplant account until you r
|
|
|
91368
91903
|
readTextFile: realReadTextFile,
|
|
91369
91904
|
writeTextFile: realWriteTextFile
|
|
91370
91905
|
});
|
|
91906
|
+
const localFacts = await readLocalSessionFacts(
|
|
91907
|
+
(memberSessions?.sessions ?? []).filter((session) => credentials !== null && session.machineId === credentials.machineId),
|
|
91908
|
+
(error62, source) => reportDaily(error62, `powerplant-menu-${source}-metadata`)
|
|
91909
|
+
);
|
|
91371
91910
|
const localClaudeIds = new Set(
|
|
91372
|
-
(memberSessions ?? []).filter((session) => credentials !== null && session.machineId === credentials.machineId && session.source === "claude-code").map((session) => session.externalId)
|
|
91911
|
+
(memberSessions?.sessions ?? []).filter((session) => credentials !== null && session.machineId === credentials.machineId && session.source === "claude-code").map((session) => session.externalId)
|
|
91373
91912
|
);
|
|
91374
|
-
const
|
|
91375
|
-
|
|
91376
|
-
|
|
91377
|
-
|
|
91913
|
+
const desktopProbe = await probeClaudeDesktopSessions(
|
|
91914
|
+
localClaudeIds,
|
|
91915
|
+
detectClaudeDesktop(),
|
|
91916
|
+
(error62) => reportDaily(error62, "powerplant-menu-desktop-sessions")
|
|
91917
|
+
);
|
|
91918
|
+
const menuSessions = memberSessions === null ? null : applyLocalFacts(memberSessions.sessions, credentials?.machineId ?? null, localFacts, localSessionKey, desktopProbe.sessions);
|
|
91378
91919
|
const liveTerminalSessions = await readLiveTerminalSessions(localClaudeIds, {
|
|
91379
91920
|
report: (finding) => reportDaily(
|
|
91380
91921
|
new Error(finding.message),
|
|
@@ -91402,9 +91943,11 @@ The access you granted these agents stays on your Powerplant account until you r
|
|
|
91402
91943
|
readTextFile: realReadTextFileStrict,
|
|
91403
91944
|
grantedClientIds
|
|
91404
91945
|
}),
|
|
91405
|
-
memberSessions,
|
|
91946
|
+
memberSessions: menuSessions,
|
|
91947
|
+
memberSessionsIncomplete: memberSessions?.incomplete,
|
|
91406
91948
|
codexDesktop: detectCodexDesktop(),
|
|
91407
|
-
claudeDesktopSessions,
|
|
91949
|
+
claudeDesktopSessions: desktopProbe.sessions,
|
|
91950
|
+
desktopDiagnostic: desktopProbe.diagnostic,
|
|
91408
91951
|
liveTerminalSessions,
|
|
91409
91952
|
update: { inPlace: inspectThisInstall().inPlace.ok, progress: updateProgress.read() },
|
|
91410
91953
|
now: Date.now()
|
|
@@ -91425,7 +91968,7 @@ The access you granted these agents stays on your Powerplant account until you r
|
|
|
91425
91968
|
return;
|
|
91426
91969
|
}
|
|
91427
91970
|
case "resume-session": {
|
|
91428
|
-
runResumeSession(positionals[1], positionals[2]);
|
|
91971
|
+
runResumeSession(positionals[1], positionals[2], { powerplantUrl: values.open });
|
|
91429
91972
|
return;
|
|
91430
91973
|
}
|
|
91431
91974
|
case "update": {
|
|
@@ -91446,13 +91989,14 @@ The access you granted these agents stays on your Powerplant account until you r
|
|
|
91446
91989
|
await runUpdate({
|
|
91447
91990
|
inspection,
|
|
91448
91991
|
resolveTarget: () => fetchAvailableVersion(config2, loadCredentialsSafely(config2).credentials),
|
|
91992
|
+
channel: releaseSource(config2.appEnv) === "npm" ? "next" : "latest",
|
|
91449
91993
|
targetRequired: releaseSource(config2.appEnv) === "promoted",
|
|
91450
91994
|
claimsReservation: process.env[UPDATE_CHILD_ENV] === "1",
|
|
91451
91995
|
now: Date.now,
|
|
91452
91996
|
pid: process.pid,
|
|
91453
91997
|
isProcessAlive: processIsAlive,
|
|
91454
91998
|
run: (bin, args) => {
|
|
91455
|
-
const result =
|
|
91999
|
+
const result = spawnSync5(bin, args, { stdio: "inherit" });
|
|
91456
92000
|
return result.error ? { status: result.status, error: result.error.message } : { status: result.status };
|
|
91457
92001
|
},
|
|
91458
92002
|
readInstalledVersion: (packageDir) => installedVersion(packageDir, realReadTextFile),
|
|
@@ -91572,7 +92116,7 @@ function inspectThisInstall() {
|
|
|
91572
92116
|
}
|
|
91573
92117
|
var UPDATE_CHILD_ENV = "POWERPLANT_UPDATE_CHILD";
|
|
91574
92118
|
function fetchAvailableVersion(config2, credentials) {
|
|
91575
|
-
if (releaseSource(config2.appEnv) === "npm") return
|
|
92119
|
+
if (releaseSource(config2.appEnv) === "npm") return fetchNewestRelease(CLI_PACKAGE_NAME);
|
|
91576
92120
|
if (credentials === null) return Promise.resolve(null);
|
|
91577
92121
|
return fetchVersionPolicy(credentials.apiUrl, credentials.token).then(
|
|
91578
92122
|
(policy) => policy?.promotedVersion ?? null
|
|
@@ -91595,8 +92139,8 @@ function startBackgroundUpdate(config2, target) {
|
|
|
91595
92139
|
readProgress: updateProgress.read,
|
|
91596
92140
|
writeProgress: updateProgress.write,
|
|
91597
92141
|
spawnChild: () => {
|
|
91598
|
-
|
|
91599
|
-
const log3 =
|
|
92142
|
+
mkdirSync11(path28.dirname(updateLogPath()), { recursive: true });
|
|
92143
|
+
const log3 = openSync6(updateLogPath(), "a");
|
|
91600
92144
|
const child = spawn2(process.execPath, [entryPath(), "update", ...envArgsFor(config2)], {
|
|
91601
92145
|
detached: true,
|
|
91602
92146
|
stdio: ["ignore", log3, log3],
|
|
@@ -91609,10 +92153,21 @@ function startBackgroundUpdate(config2, target) {
|
|
|
91609
92153
|
}
|
|
91610
92154
|
function automaticUpdateCheck(config2) {
|
|
91611
92155
|
let saidCannot = false;
|
|
92156
|
+
let menubarSynced = false;
|
|
91612
92157
|
return async (log3) => {
|
|
92158
|
+
const inspection = inspectThisInstall();
|
|
92159
|
+
if (managesMenubarApp(config2) && !menubarSynced) {
|
|
92160
|
+
menubarSynced = true;
|
|
92161
|
+
const app = await syncMenubarApp(
|
|
92162
|
+
realMenubarAppOps({ cliVersion: CLI_VERSION, packageDir: inspection.packageDir }),
|
|
92163
|
+
"daemon"
|
|
92164
|
+
);
|
|
92165
|
+
if (app.kind === "updated") log3(`menu bar app updated to ${CLI_VERSION}`);
|
|
92166
|
+
if (app.kind === "failed") log3(`\u26A0 menu bar app could not be updated: ${app.detail}`);
|
|
92167
|
+
}
|
|
91613
92168
|
const decision = autoUpdateDecision({
|
|
91614
92169
|
control: readCollectorControl(config2.appEnv),
|
|
91615
|
-
inspection
|
|
92170
|
+
inspection,
|
|
91616
92171
|
cliVersion: CLI_VERSION,
|
|
91617
92172
|
latestVersion: await cachedAvailableVersion(config2, loadCredentialsSafely(config2).credentials),
|
|
91618
92173
|
progress: updateProgress.read(),
|
|
@@ -91630,6 +92185,12 @@ function automaticUpdateCheck(config2) {
|
|
|
91630
92185
|
}
|
|
91631
92186
|
};
|
|
91632
92187
|
}
|
|
92188
|
+
function managesMenubarApp(config2) {
|
|
92189
|
+
return config2.appEnv === "production" && process.platform === "darwin";
|
|
92190
|
+
}
|
|
92191
|
+
function thisInstallMenubarAppOps() {
|
|
92192
|
+
return realMenubarAppOps({ cliVersion: CLI_VERSION, packageDir: inspectThisInstall().packageDir });
|
|
92193
|
+
}
|
|
91633
92194
|
function restartSyncOnNewCode(config2) {
|
|
91634
92195
|
const state = serviceState(config2);
|
|
91635
92196
|
if (state === "unsupported" || state === "not-installed") return state;
|
|
@@ -91641,7 +92202,7 @@ function restartSyncOnNewCode(config2) {
|
|
|
91641
92202
|
var updateProgress = {
|
|
91642
92203
|
read: () => readUpdateProgress(realReadTextFile),
|
|
91643
92204
|
write: (record2) => realWriteTextFile(updateProgressPath(), JSON.stringify(record2, null, 2)),
|
|
91644
|
-
clear: () =>
|
|
92205
|
+
clear: () => rmSync6(updateProgressPath(), { force: true })
|
|
91645
92206
|
};
|
|
91646
92207
|
function envArgsFor(config2) {
|
|
91647
92208
|
return config2.appEnv === "production" ? [] : ["--env", config2.appEnv];
|
|
@@ -91658,15 +92219,21 @@ function entryPath() {
|
|
|
91658
92219
|
const entry = process.argv[1];
|
|
91659
92220
|
if (!entry) throw new Error("cannot resolve the CLI entry path from argv");
|
|
91660
92221
|
try {
|
|
91661
|
-
return linkedEntryPath(
|
|
92222
|
+
return linkedEntryPath(realpathSync5(entry));
|
|
91662
92223
|
} catch {
|
|
91663
92224
|
return entry;
|
|
91664
92225
|
}
|
|
91665
92226
|
}
|
|
91666
92227
|
var cliCommand = "none";
|
|
91667
92228
|
main().catch(async (error62) => {
|
|
91668
|
-
if (error62 instanceof ExpectedCliError)
|
|
91669
|
-
|
|
92229
|
+
if (error62 instanceof ExpectedCliError) {
|
|
92230
|
+
console.error(
|
|
92231
|
+
terminalUsesEffects(process.stderr.isTTY === true, process.env) ? styleLine(error62.message) : error62.message
|
|
92232
|
+
);
|
|
92233
|
+
} else {
|
|
92234
|
+
console.error(error62);
|
|
92235
|
+
}
|
|
92236
|
+
if (process.env.POWERPLANT_NATIVE_DIAGNOSTICS === "1") console.error(nativeFailureRecord(error62));
|
|
91670
92237
|
reportCollectorError(error62, `powerplant-cli-${cliCommand}`);
|
|
91671
92238
|
await flushReporting();
|
|
91672
92239
|
process.exitCode = 1;
|