@osfactory/har 0.21.0 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +727 -534
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -765,14 +765,14 @@ var require_url_state_machine = __commonJS({
|
|
|
765
765
|
return url.replace(/\u0009|\u000A|\u000D/g, "");
|
|
766
766
|
}
|
|
767
767
|
function shortenPath(url) {
|
|
768
|
-
const
|
|
769
|
-
if (
|
|
768
|
+
const path54 = url.path;
|
|
769
|
+
if (path54.length === 0) {
|
|
770
770
|
return;
|
|
771
771
|
}
|
|
772
|
-
if (url.scheme === "file" &&
|
|
772
|
+
if (url.scheme === "file" && path54.length === 1 && isNormalizedWindowsDriveLetter(path54[0])) {
|
|
773
773
|
return;
|
|
774
774
|
}
|
|
775
|
-
|
|
775
|
+
path54.pop();
|
|
776
776
|
}
|
|
777
777
|
function includesCredentials(url) {
|
|
778
778
|
return url.username !== "" || url.password !== "";
|
|
@@ -1811,7 +1811,7 @@ var require_lib2 = __commonJS({
|
|
|
1811
1811
|
return ex && typeof ex === "object" && "default" in ex ? ex["default"] : ex;
|
|
1812
1812
|
}
|
|
1813
1813
|
var Stream2 = _interopDefault(require("stream"));
|
|
1814
|
-
var
|
|
1814
|
+
var http2 = _interopDefault(require("http"));
|
|
1815
1815
|
var Url = _interopDefault(require("url"));
|
|
1816
1816
|
var whatwgUrl = _interopDefault(require_public_api());
|
|
1817
1817
|
var https = _interopDefault(require("https"));
|
|
@@ -2092,7 +2092,7 @@ var require_lib2 = __commonJS({
|
|
|
2092
2092
|
let accum = [];
|
|
2093
2093
|
let accumBytes = 0;
|
|
2094
2094
|
let abort = false;
|
|
2095
|
-
return new Body.Promise(function(
|
|
2095
|
+
return new Body.Promise(function(resolve38, reject) {
|
|
2096
2096
|
let resTimeout;
|
|
2097
2097
|
if (_this4.timeout) {
|
|
2098
2098
|
resTimeout = setTimeout(function() {
|
|
@@ -2126,7 +2126,7 @@ var require_lib2 = __commonJS({
|
|
|
2126
2126
|
}
|
|
2127
2127
|
clearTimeout(resTimeout);
|
|
2128
2128
|
try {
|
|
2129
|
-
|
|
2129
|
+
resolve38(Buffer.concat(accum, accumBytes));
|
|
2130
2130
|
} catch (err) {
|
|
2131
2131
|
reject(new FetchError(`Could not create Buffer from response body for ${_this4.url}: ${err.message}`, "system", err));
|
|
2132
2132
|
}
|
|
@@ -2551,7 +2551,7 @@ var require_lib2 = __commonJS({
|
|
|
2551
2551
|
return headers;
|
|
2552
2552
|
}
|
|
2553
2553
|
var INTERNALS$1 = Symbol("Response internals");
|
|
2554
|
-
var STATUS_CODES =
|
|
2554
|
+
var STATUS_CODES = http2.STATUS_CODES;
|
|
2555
2555
|
var Response3 = class _Response {
|
|
2556
2556
|
constructor() {
|
|
2557
2557
|
let body = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : null;
|
|
@@ -2801,10 +2801,10 @@ var require_lib2 = __commonJS({
|
|
|
2801
2801
|
throw new Error("native promise missing, set fetch.Promise to your favorite alternative");
|
|
2802
2802
|
}
|
|
2803
2803
|
Body.Promise = fetch3.Promise;
|
|
2804
|
-
return new fetch3.Promise(function(
|
|
2804
|
+
return new fetch3.Promise(function(resolve38, reject) {
|
|
2805
2805
|
const request = new Request3(url, opts);
|
|
2806
2806
|
const options = getNodeRequestOptions(request);
|
|
2807
|
-
const send = (options.protocol === "https:" ? https :
|
|
2807
|
+
const send = (options.protocol === "https:" ? https : http2).request;
|
|
2808
2808
|
const signal = request.signal;
|
|
2809
2809
|
let response = null;
|
|
2810
2810
|
const abort = function abort2() {
|
|
@@ -2934,7 +2934,7 @@ var require_lib2 = __commonJS({
|
|
|
2934
2934
|
requestOpts.body = void 0;
|
|
2935
2935
|
requestOpts.headers.delete("content-length");
|
|
2936
2936
|
}
|
|
2937
|
-
|
|
2937
|
+
resolve38(fetch3(new Request3(locationURL, requestOpts)));
|
|
2938
2938
|
finalize();
|
|
2939
2939
|
return;
|
|
2940
2940
|
}
|
|
@@ -2955,7 +2955,7 @@ var require_lib2 = __commonJS({
|
|
|
2955
2955
|
const codings = headers.get("Content-Encoding");
|
|
2956
2956
|
if (!request.compress || request.method === "HEAD" || codings === null || res.statusCode === 204 || res.statusCode === 304) {
|
|
2957
2957
|
response = new Response3(body, response_options);
|
|
2958
|
-
|
|
2958
|
+
resolve38(response);
|
|
2959
2959
|
return;
|
|
2960
2960
|
}
|
|
2961
2961
|
const zlibOptions = {
|
|
@@ -2965,7 +2965,7 @@ var require_lib2 = __commonJS({
|
|
|
2965
2965
|
if (codings == "gzip" || codings == "x-gzip") {
|
|
2966
2966
|
body = body.pipe(zlib.createGunzip(zlibOptions));
|
|
2967
2967
|
response = new Response3(body, response_options);
|
|
2968
|
-
|
|
2968
|
+
resolve38(response);
|
|
2969
2969
|
return;
|
|
2970
2970
|
}
|
|
2971
2971
|
if (codings == "deflate" || codings == "x-deflate") {
|
|
@@ -2977,12 +2977,12 @@ var require_lib2 = __commonJS({
|
|
|
2977
2977
|
body = body.pipe(zlib.createInflateRaw());
|
|
2978
2978
|
}
|
|
2979
2979
|
response = new Response3(body, response_options);
|
|
2980
|
-
|
|
2980
|
+
resolve38(response);
|
|
2981
2981
|
});
|
|
2982
2982
|
raw.on("end", function() {
|
|
2983
2983
|
if (!response) {
|
|
2984
2984
|
response = new Response3(body, response_options);
|
|
2985
|
-
|
|
2985
|
+
resolve38(response);
|
|
2986
2986
|
}
|
|
2987
2987
|
});
|
|
2988
2988
|
return;
|
|
@@ -2990,11 +2990,11 @@ var require_lib2 = __commonJS({
|
|
|
2990
2990
|
if (codings == "br" && typeof zlib.createBrotliDecompress === "function") {
|
|
2991
2991
|
body = body.pipe(zlib.createBrotliDecompress());
|
|
2992
2992
|
response = new Response3(body, response_options);
|
|
2993
|
-
|
|
2993
|
+
resolve38(response);
|
|
2994
2994
|
return;
|
|
2995
2995
|
}
|
|
2996
2996
|
response = new Response3(body, response_options);
|
|
2997
|
-
|
|
2997
|
+
resolve38(response);
|
|
2998
2998
|
});
|
|
2999
2999
|
writeToStream(req, request);
|
|
3000
3000
|
});
|
|
@@ -6351,14 +6351,14 @@ __export(fileFromPath_exports, {
|
|
|
6351
6351
|
fileFromPathSync: () => fileFromPathSync,
|
|
6352
6352
|
isFile: () => isFile
|
|
6353
6353
|
});
|
|
6354
|
-
function createFileFromPath(
|
|
6354
|
+
function createFileFromPath(path54, { mtimeMs, size }, filenameOrOptions, options = {}) {
|
|
6355
6355
|
let filename;
|
|
6356
6356
|
if (isPlainObject_default2(filenameOrOptions)) {
|
|
6357
6357
|
[options, filename] = [filenameOrOptions, void 0];
|
|
6358
6358
|
} else {
|
|
6359
6359
|
filename = filenameOrOptions;
|
|
6360
6360
|
}
|
|
6361
|
-
const file = new FileFromPath({ path:
|
|
6361
|
+
const file = new FileFromPath({ path: path54, size, lastModified: mtimeMs });
|
|
6362
6362
|
if (!filename) {
|
|
6363
6363
|
filename = file.name;
|
|
6364
6364
|
}
|
|
@@ -6367,13 +6367,13 @@ function createFileFromPath(path53, { mtimeMs, size }, filenameOrOptions, option
|
|
|
6367
6367
|
lastModified: file.lastModified
|
|
6368
6368
|
});
|
|
6369
6369
|
}
|
|
6370
|
-
function fileFromPathSync(
|
|
6371
|
-
const stats = (0, import_fs5.statSync)(
|
|
6372
|
-
return createFileFromPath(
|
|
6370
|
+
function fileFromPathSync(path54, filenameOrOptions, options = {}) {
|
|
6371
|
+
const stats = (0, import_fs5.statSync)(path54);
|
|
6372
|
+
return createFileFromPath(path54, stats, filenameOrOptions, options);
|
|
6373
6373
|
}
|
|
6374
|
-
async function fileFromPath2(
|
|
6375
|
-
const stats = await import_fs5.promises.stat(
|
|
6376
|
-
return createFileFromPath(
|
|
6374
|
+
async function fileFromPath2(path54, filenameOrOptions, options) {
|
|
6375
|
+
const stats = await import_fs5.promises.stat(path54);
|
|
6376
|
+
return createFileFromPath(path54, stats, filenameOrOptions, options);
|
|
6377
6377
|
}
|
|
6378
6378
|
var import_fs5, import_path5, import_node_domexception, __classPrivateFieldSet5, __classPrivateFieldGet6, _FileFromPath_path, _FileFromPath_start, MESSAGE, FileFromPath;
|
|
6379
6379
|
var init_fileFromPath = __esm({
|
|
@@ -6433,6 +6433,44 @@ var init_fileFromPath = __esm({
|
|
|
6433
6433
|
}
|
|
6434
6434
|
});
|
|
6435
6435
|
|
|
6436
|
+
// src/core/portal-credentials.ts
|
|
6437
|
+
function portalCredentialsPath() {
|
|
6438
|
+
if (process.env.HAR_CREDENTIALS_PATH) {
|
|
6439
|
+
return path25.resolve(process.env.HAR_CREDENTIALS_PATH);
|
|
6440
|
+
}
|
|
6441
|
+
return path25.join(os4.homedir(), ".har", "credentials.json");
|
|
6442
|
+
}
|
|
6443
|
+
function readPortalCredentials() {
|
|
6444
|
+
try {
|
|
6445
|
+
const raw = fs26.readFileSync(portalCredentialsPath(), "utf8");
|
|
6446
|
+
const parsed = JSON.parse(raw);
|
|
6447
|
+
if (!parsed.portalUrl || !parsed.token) return null;
|
|
6448
|
+
return {
|
|
6449
|
+
portalUrl: parsed.portalUrl,
|
|
6450
|
+
token: parsed.token,
|
|
6451
|
+
workspace: parsed.workspace,
|
|
6452
|
+
createdAt: parsed.createdAt ?? ""
|
|
6453
|
+
};
|
|
6454
|
+
} catch {
|
|
6455
|
+
return null;
|
|
6456
|
+
}
|
|
6457
|
+
}
|
|
6458
|
+
function writePortalCredentials(creds) {
|
|
6459
|
+
const file = portalCredentialsPath();
|
|
6460
|
+
fs26.mkdirSync(path25.dirname(file), { recursive: true });
|
|
6461
|
+
fs26.writeFileSync(file, JSON.stringify(creds, null, 2), { mode: 384 });
|
|
6462
|
+
fs26.chmodSync(file, 384);
|
|
6463
|
+
}
|
|
6464
|
+
var fs26, os4, path25;
|
|
6465
|
+
var init_portal_credentials = __esm({
|
|
6466
|
+
"src/core/portal-credentials.ts"() {
|
|
6467
|
+
"use strict";
|
|
6468
|
+
fs26 = __toESM(require("fs"));
|
|
6469
|
+
os4 = __toESM(require("os"));
|
|
6470
|
+
path25 = __toESM(require("path"));
|
|
6471
|
+
}
|
|
6472
|
+
});
|
|
6473
|
+
|
|
6436
6474
|
// src/core/control-config.ts
|
|
6437
6475
|
function getControlApiUrl() {
|
|
6438
6476
|
return process.env.HAR_CONTROL_API_URL ?? DEFAULT_CONTROL_API_URL;
|
|
@@ -6440,10 +6478,33 @@ function getControlApiUrl() {
|
|
|
6440
6478
|
function isControlEnabled() {
|
|
6441
6479
|
return process.env.HAR_CONTROL_DISABLED !== "true";
|
|
6442
6480
|
}
|
|
6481
|
+
function normalizeUrl(url) {
|
|
6482
|
+
return url.replace(/\/+$/, "");
|
|
6483
|
+
}
|
|
6484
|
+
function getPortalTarget() {
|
|
6485
|
+
if (process.env.HAR_PORTAL_URL && process.env.HAR_PORTAL_TOKEN) {
|
|
6486
|
+
return {
|
|
6487
|
+
url: normalizeUrl(process.env.HAR_PORTAL_URL),
|
|
6488
|
+
token: process.env.HAR_PORTAL_TOKEN
|
|
6489
|
+
};
|
|
6490
|
+
}
|
|
6491
|
+
const stored = readPortalCredentials();
|
|
6492
|
+
if (stored) {
|
|
6493
|
+
return { url: normalizeUrl(stored.portalUrl), token: stored.token };
|
|
6494
|
+
}
|
|
6495
|
+
if (process.env.HAR_CLOUD_API_URL && process.env.HAR_CLOUD_API_KEY) {
|
|
6496
|
+
return {
|
|
6497
|
+
url: normalizeUrl(process.env.HAR_CLOUD_API_URL),
|
|
6498
|
+
token: process.env.HAR_CLOUD_API_KEY
|
|
6499
|
+
};
|
|
6500
|
+
}
|
|
6501
|
+
return null;
|
|
6502
|
+
}
|
|
6443
6503
|
var DEFAULT_CONTROL_API_URL;
|
|
6444
6504
|
var init_control_config = __esm({
|
|
6445
6505
|
"src/core/control-config.ts"() {
|
|
6446
6506
|
"use strict";
|
|
6507
|
+
init_portal_credentials();
|
|
6447
6508
|
DEFAULT_CONTROL_API_URL = "http://localhost:3847";
|
|
6448
6509
|
}
|
|
6449
6510
|
});
|
|
@@ -6451,9 +6512,9 @@ var init_control_config = __esm({
|
|
|
6451
6512
|
// src/core/telemetry-config.ts
|
|
6452
6513
|
function getPreferencePath() {
|
|
6453
6514
|
if (process.env.HAR_TELEMETRY_CONFIG_PATH) {
|
|
6454
|
-
return
|
|
6515
|
+
return path37.resolve(process.env.HAR_TELEMETRY_CONFIG_PATH);
|
|
6455
6516
|
}
|
|
6456
|
-
return
|
|
6517
|
+
return path37.join(os10.homedir(), ".har", "telemetry.json");
|
|
6457
6518
|
}
|
|
6458
6519
|
function parseEnvOverride(raw) {
|
|
6459
6520
|
if (raw === void 0 || raw === "") return void 0;
|
|
@@ -6474,10 +6535,10 @@ function normalizeSignals(enabled, raw) {
|
|
|
6474
6535
|
function readTelemetryPreference() {
|
|
6475
6536
|
const preferencePath = getPreferencePath();
|
|
6476
6537
|
try {
|
|
6477
|
-
if (!
|
|
6538
|
+
if (!fs37.existsSync(preferencePath)) {
|
|
6478
6539
|
return { enabled: true, signals: { ...DEFAULT_SIGNALS_ON } };
|
|
6479
6540
|
}
|
|
6480
|
-
const parsed = JSON.parse(
|
|
6541
|
+
const parsed = JSON.parse(fs37.readFileSync(preferencePath, "utf8"));
|
|
6481
6542
|
const enabled = parsed.enabled !== false;
|
|
6482
6543
|
return {
|
|
6483
6544
|
enabled,
|
|
@@ -6500,8 +6561,8 @@ function writeTelemetryPreference(enabled, signals2) {
|
|
|
6500
6561
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
6501
6562
|
};
|
|
6502
6563
|
const preferencePath = getPreferencePath();
|
|
6503
|
-
|
|
6504
|
-
|
|
6564
|
+
fs37.mkdirSync(path37.dirname(preferencePath), { recursive: true });
|
|
6565
|
+
fs37.writeFileSync(preferencePath, JSON.stringify(preference, null, 2) + "\n");
|
|
6505
6566
|
return preference;
|
|
6506
6567
|
}
|
|
6507
6568
|
function isTelemetryEnabled() {
|
|
@@ -6516,13 +6577,13 @@ function getTelemetrySignals() {
|
|
|
6516
6577
|
function getTelemetryPreferencePath() {
|
|
6517
6578
|
return getPreferencePath();
|
|
6518
6579
|
}
|
|
6519
|
-
var
|
|
6580
|
+
var fs37, os10, path37, DEFAULT_SIGNALS_ON, DEFAULT_SIGNALS_OFF, TELEMETRY_SIGNALS;
|
|
6520
6581
|
var init_telemetry_config = __esm({
|
|
6521
6582
|
"src/core/telemetry-config.ts"() {
|
|
6522
6583
|
"use strict";
|
|
6523
|
-
|
|
6524
|
-
|
|
6525
|
-
|
|
6584
|
+
fs37 = __toESM(require("fs"));
|
|
6585
|
+
os10 = __toESM(require("os"));
|
|
6586
|
+
path37 = __toESM(require("path"));
|
|
6526
6587
|
DEFAULT_SIGNALS_ON = {
|
|
6527
6588
|
metrics: true,
|
|
6528
6589
|
logs: true,
|
|
@@ -6563,15 +6624,15 @@ __export(otel_hooks_exports, {
|
|
|
6563
6624
|
});
|
|
6564
6625
|
function getOtelHooksHome() {
|
|
6565
6626
|
if (process.env.HAR_OTEL_HOOKS_HOME) {
|
|
6566
|
-
return
|
|
6627
|
+
return path43.resolve(process.env.HAR_OTEL_HOOKS_HOME);
|
|
6567
6628
|
}
|
|
6568
|
-
return
|
|
6629
|
+
return path43.join(os13.homedir(), ".har", "otel-hooks");
|
|
6569
6630
|
}
|
|
6570
6631
|
function getOtelHooksConfigPath(hooksHome = getOtelHooksHome()) {
|
|
6571
|
-
return
|
|
6632
|
+
return path43.join(hooksHome, "otel_config.json");
|
|
6572
6633
|
}
|
|
6573
6634
|
function getOtelHooksWrapperPath(hooksHome = getOtelHooksHome()) {
|
|
6574
|
-
return
|
|
6635
|
+
return path43.join(hooksHome, "run-otel-hook.sh");
|
|
6575
6636
|
}
|
|
6576
6637
|
function buildOtelHooksConfig(options) {
|
|
6577
6638
|
const enabled = options?.enabled ?? isTelemetryEnabled();
|
|
@@ -6590,18 +6651,18 @@ function buildOtelHooksConfig(options) {
|
|
|
6590
6651
|
};
|
|
6591
6652
|
}
|
|
6592
6653
|
function writeOtelHooksConfig(config2, hooksHome = getOtelHooksHome()) {
|
|
6593
|
-
|
|
6654
|
+
fs41.mkdirSync(hooksHome, { recursive: true });
|
|
6594
6655
|
const configPath = getOtelHooksConfigPath(hooksHome);
|
|
6595
6656
|
const payload = {
|
|
6596
6657
|
_comment: "Managed by har telemetry \u2014 do not edit by hand; use: har telemetry on|off",
|
|
6597
6658
|
...config2
|
|
6598
6659
|
};
|
|
6599
|
-
|
|
6660
|
+
fs41.writeFileSync(configPath, `${JSON.stringify(payload, null, 2)}
|
|
6600
6661
|
`);
|
|
6601
6662
|
return configPath;
|
|
6602
6663
|
}
|
|
6603
6664
|
function writeOtelHooksWrapper(otelHookCommand, hooksHome = getOtelHooksHome()) {
|
|
6604
|
-
|
|
6665
|
+
fs41.mkdirSync(hooksHome, { recursive: true });
|
|
6605
6666
|
const wrapperPath = getOtelHooksWrapperPath(hooksHome);
|
|
6606
6667
|
const script = `#!/usr/bin/env bash
|
|
6607
6668
|
# Managed by har telemetry \u2014 invokes opentelemetry-hooks with HAR config home.
|
|
@@ -6609,9 +6670,9 @@ set -euo pipefail
|
|
|
6609
6670
|
export IDE_OTEL_HOOK_HOME="${hooksHome}"
|
|
6610
6671
|
exec "${otelHookCommand}" "$@"
|
|
6611
6672
|
`;
|
|
6612
|
-
|
|
6673
|
+
fs41.writeFileSync(wrapperPath, script, { mode: 493 });
|
|
6613
6674
|
try {
|
|
6614
|
-
|
|
6675
|
+
fs41.chmodSync(wrapperPath, 493);
|
|
6615
6676
|
} catch {
|
|
6616
6677
|
}
|
|
6617
6678
|
return wrapperPath;
|
|
@@ -6691,10 +6752,10 @@ function runSetupAgent(agent, otelHookCommand, hooksHome) {
|
|
|
6691
6752
|
};
|
|
6692
6753
|
}
|
|
6693
6754
|
function rewriteHookCommandsToWrapper(filePath, wrapperPath) {
|
|
6694
|
-
if (!
|
|
6755
|
+
if (!fs41.existsSync(filePath)) return false;
|
|
6695
6756
|
let raw;
|
|
6696
6757
|
try {
|
|
6697
|
-
raw =
|
|
6758
|
+
raw = fs41.readFileSync(filePath, "utf8");
|
|
6698
6759
|
} catch {
|
|
6699
6760
|
return false;
|
|
6700
6761
|
}
|
|
@@ -6733,16 +6794,16 @@ function rewriteHookCommandsToWrapper(filePath, wrapperPath) {
|
|
|
6733
6794
|
return changed;
|
|
6734
6795
|
};
|
|
6735
6796
|
if (!walk(parsed)) return false;
|
|
6736
|
-
|
|
6797
|
+
fs41.writeFileSync(filePath, `${JSON.stringify(parsed, null, 2)}
|
|
6737
6798
|
`);
|
|
6738
6799
|
return true;
|
|
6739
6800
|
}
|
|
6740
6801
|
function rewriteKnownHookRegistrations(wrapperPath) {
|
|
6741
|
-
const home =
|
|
6802
|
+
const home = os13.homedir();
|
|
6742
6803
|
const candidates = [
|
|
6743
|
-
|
|
6744
|
-
|
|
6745
|
-
|
|
6804
|
+
path43.join(home, ".cursor", "hooks.json"),
|
|
6805
|
+
path43.join(home, ".claude", "settings.json"),
|
|
6806
|
+
path43.join(home, ".codex", "hooks.json")
|
|
6746
6807
|
];
|
|
6747
6808
|
for (const filePath of candidates) {
|
|
6748
6809
|
try {
|
|
@@ -6755,7 +6816,7 @@ function ensureOtelHooks(options) {
|
|
|
6755
6816
|
const hooksHome = getOtelHooksHome();
|
|
6756
6817
|
const errors = [];
|
|
6757
6818
|
const agentsSetup = [];
|
|
6758
|
-
|
|
6819
|
+
fs41.mkdirSync(hooksHome, { recursive: true });
|
|
6759
6820
|
let otelHookCommand = resolveOtelHookCommand();
|
|
6760
6821
|
if (!otelHookCommand) {
|
|
6761
6822
|
const installed = tryInstallPackage();
|
|
@@ -6824,14 +6885,14 @@ function ensureOtelHooks(options) {
|
|
|
6824
6885
|
function disableOtelHooksExport() {
|
|
6825
6886
|
return writeOtelHooksConfig(buildOtelHooksConfig({ enabled: false }));
|
|
6826
6887
|
}
|
|
6827
|
-
var import_child_process9,
|
|
6888
|
+
var import_child_process9, fs41, os13, path43, OTEL_HOOKS_PACKAGE, OTEL_HOOKS_AGENTS;
|
|
6828
6889
|
var init_otel_hooks = __esm({
|
|
6829
6890
|
"src/core/otel-hooks.ts"() {
|
|
6830
6891
|
"use strict";
|
|
6831
6892
|
import_child_process9 = require("child_process");
|
|
6832
|
-
|
|
6833
|
-
|
|
6834
|
-
|
|
6893
|
+
fs41 = __toESM(require("fs"));
|
|
6894
|
+
os13 = __toESM(require("os"));
|
|
6895
|
+
path43 = __toESM(require("path"));
|
|
6835
6896
|
init_control_config();
|
|
6836
6897
|
init_telemetry_config();
|
|
6837
6898
|
OTEL_HOOKS_PACKAGE = "opentelemetry-hooks==0.14.0";
|
|
@@ -9790,7 +9851,7 @@ var require_compile = __commonJS({
|
|
|
9790
9851
|
const schOrFunc = root.refs[ref];
|
|
9791
9852
|
if (schOrFunc)
|
|
9792
9853
|
return schOrFunc;
|
|
9793
|
-
let _sch =
|
|
9854
|
+
let _sch = resolve38.call(this, root, ref);
|
|
9794
9855
|
if (_sch === void 0) {
|
|
9795
9856
|
const schema = (_a3 = root.localRefs) === null || _a3 === void 0 ? void 0 : _a3[ref];
|
|
9796
9857
|
const { schemaId } = this.opts;
|
|
@@ -9817,7 +9878,7 @@ var require_compile = __commonJS({
|
|
|
9817
9878
|
function sameSchemaEnv(s1, s2) {
|
|
9818
9879
|
return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
|
|
9819
9880
|
}
|
|
9820
|
-
function
|
|
9881
|
+
function resolve38(root, ref) {
|
|
9821
9882
|
let sch;
|
|
9822
9883
|
while (typeof (sch = this.refs[ref]) == "string")
|
|
9823
9884
|
ref = sch;
|
|
@@ -10035,8 +10096,8 @@ var require_utils2 = __commonJS({
|
|
|
10035
10096
|
}
|
|
10036
10097
|
return ind;
|
|
10037
10098
|
}
|
|
10038
|
-
function removeDotSegments(
|
|
10039
|
-
let input =
|
|
10099
|
+
function removeDotSegments(path54) {
|
|
10100
|
+
let input = path54;
|
|
10040
10101
|
const output = [];
|
|
10041
10102
|
let nextSlash = -1;
|
|
10042
10103
|
let len = 0;
|
|
@@ -10288,8 +10349,8 @@ var require_schemes = __commonJS({
|
|
|
10288
10349
|
wsComponent.secure = void 0;
|
|
10289
10350
|
}
|
|
10290
10351
|
if (wsComponent.resourceName) {
|
|
10291
|
-
const [
|
|
10292
|
-
wsComponent.path =
|
|
10352
|
+
const [path54, query] = wsComponent.resourceName.split("?");
|
|
10353
|
+
wsComponent.path = path54 && path54 !== "/" ? path54 : void 0;
|
|
10293
10354
|
wsComponent.query = query;
|
|
10294
10355
|
wsComponent.resourceName = void 0;
|
|
10295
10356
|
}
|
|
@@ -10348,7 +10409,7 @@ var require_schemes = __commonJS({
|
|
|
10348
10409
|
urnComponent.nss = (uuidComponent.uuid || "").toLowerCase();
|
|
10349
10410
|
return urnComponent;
|
|
10350
10411
|
}
|
|
10351
|
-
var
|
|
10412
|
+
var http2 = (
|
|
10352
10413
|
/** @type {SchemeHandler} */
|
|
10353
10414
|
{
|
|
10354
10415
|
scheme: "http",
|
|
@@ -10361,7 +10422,7 @@ var require_schemes = __commonJS({
|
|
|
10361
10422
|
/** @type {SchemeHandler} */
|
|
10362
10423
|
{
|
|
10363
10424
|
scheme: "https",
|
|
10364
|
-
domainHost:
|
|
10425
|
+
domainHost: http2.domainHost,
|
|
10365
10426
|
parse: httpParse,
|
|
10366
10427
|
serialize: httpSerialize
|
|
10367
10428
|
}
|
|
@@ -10405,7 +10466,7 @@ var require_schemes = __commonJS({
|
|
|
10405
10466
|
var SCHEMES = (
|
|
10406
10467
|
/** @type {Record<SchemeName, SchemeHandler>} */
|
|
10407
10468
|
{
|
|
10408
|
-
http,
|
|
10469
|
+
http: http2,
|
|
10409
10470
|
https,
|
|
10410
10471
|
ws,
|
|
10411
10472
|
wss,
|
|
@@ -10448,7 +10509,7 @@ var require_fast_uri = __commonJS({
|
|
|
10448
10509
|
}
|
|
10449
10510
|
return uri;
|
|
10450
10511
|
}
|
|
10451
|
-
function
|
|
10512
|
+
function resolve38(baseURI, relativeURI, options) {
|
|
10452
10513
|
const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
|
|
10453
10514
|
const resolved = resolveComponent(parse4(baseURI, schemelessOptions), parse4(relativeURI, schemelessOptions), schemelessOptions, true);
|
|
10454
10515
|
schemelessOptions.skipEscape = true;
|
|
@@ -10706,7 +10767,7 @@ var require_fast_uri = __commonJS({
|
|
|
10706
10767
|
var fastUri = {
|
|
10707
10768
|
SCHEMES,
|
|
10708
10769
|
normalize: normalize3,
|
|
10709
|
-
resolve:
|
|
10770
|
+
resolve: resolve38,
|
|
10710
10771
|
resolveComponent,
|
|
10711
10772
|
equal,
|
|
10712
10773
|
serialize,
|
|
@@ -13682,12 +13743,12 @@ var require_dist = __commonJS({
|
|
|
13682
13743
|
throw new Error(`Unknown format "${name}"`);
|
|
13683
13744
|
return f2;
|
|
13684
13745
|
};
|
|
13685
|
-
function addFormats(ajv, list,
|
|
13746
|
+
function addFormats(ajv, list, fs46, exportName) {
|
|
13686
13747
|
var _a3;
|
|
13687
13748
|
var _b2;
|
|
13688
13749
|
(_a3 = (_b2 = ajv.opts.code).formats) !== null && _a3 !== void 0 ? _a3 : _b2.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
|
|
13689
13750
|
for (const f2 of list)
|
|
13690
|
-
ajv.addFormat(f2,
|
|
13751
|
+
ajv.addFormat(f2, fs46[f2]);
|
|
13691
13752
|
}
|
|
13692
13753
|
module2.exports = exports2 = formatsPlugin;
|
|
13693
13754
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
@@ -14787,15 +14848,15 @@ var require_route = __commonJS({
|
|
|
14787
14848
|
};
|
|
14788
14849
|
}
|
|
14789
14850
|
function wrapConversion(toModel, graph) {
|
|
14790
|
-
const
|
|
14851
|
+
const path54 = [graph[toModel].parent, toModel];
|
|
14791
14852
|
let fn = conversions[graph[toModel].parent][toModel];
|
|
14792
14853
|
let cur = graph[toModel].parent;
|
|
14793
14854
|
while (graph[cur].parent) {
|
|
14794
|
-
|
|
14855
|
+
path54.unshift(graph[cur].parent);
|
|
14795
14856
|
fn = link(conversions[graph[cur].parent][cur], fn);
|
|
14796
14857
|
cur = graph[cur].parent;
|
|
14797
14858
|
}
|
|
14798
|
-
fn.conversion =
|
|
14859
|
+
fn.conversion = path54;
|
|
14799
14860
|
return fn;
|
|
14800
14861
|
}
|
|
14801
14862
|
module2.exports = function(fromModel) {
|
|
@@ -20725,7 +20786,7 @@ var require_iso2022 = __commonJS({
|
|
|
20725
20786
|
// node_modules/chardet/index.js
|
|
20726
20787
|
var require_chardet = __commonJS({
|
|
20727
20788
|
"node_modules/chardet/index.js"(exports2, module2) {
|
|
20728
|
-
var
|
|
20789
|
+
var fs46 = require("fs");
|
|
20729
20790
|
var utf8 = require_utf8();
|
|
20730
20791
|
var unicode = require_unicode();
|
|
20731
20792
|
var mbcs = require_mbcs();
|
|
@@ -20799,28 +20860,28 @@ var require_chardet = __commonJS({
|
|
|
20799
20860
|
var fd;
|
|
20800
20861
|
var handler = function(err, buffer) {
|
|
20801
20862
|
if (fd) {
|
|
20802
|
-
|
|
20863
|
+
fs46.closeSync(fd);
|
|
20803
20864
|
}
|
|
20804
20865
|
if (err) return cb(err, null);
|
|
20805
20866
|
cb(null, self.detect(buffer, opts));
|
|
20806
20867
|
};
|
|
20807
20868
|
if (opts && opts.sampleSize) {
|
|
20808
|
-
fd =
|
|
20809
|
-
|
|
20869
|
+
fd = fs46.openSync(filepath, "r"), sample = Buffer.allocUnsafe(opts.sampleSize);
|
|
20870
|
+
fs46.read(fd, sample, 0, opts.sampleSize, null, function(err) {
|
|
20810
20871
|
handler(err, sample);
|
|
20811
20872
|
});
|
|
20812
20873
|
return;
|
|
20813
20874
|
}
|
|
20814
|
-
|
|
20875
|
+
fs46.readFile(filepath, handler);
|
|
20815
20876
|
};
|
|
20816
20877
|
module2.exports.detectFileSync = function(filepath, opts) {
|
|
20817
20878
|
if (opts && opts.sampleSize) {
|
|
20818
|
-
var fd =
|
|
20819
|
-
|
|
20820
|
-
|
|
20879
|
+
var fd = fs46.openSync(filepath, "r"), sample2 = Buffer.allocUnsafe(opts.sampleSize);
|
|
20880
|
+
fs46.readSync(fd, sample2, 0, opts.sampleSize);
|
|
20881
|
+
fs46.closeSync(fd);
|
|
20821
20882
|
return self.detect(sample2, opts);
|
|
20822
20883
|
}
|
|
20823
|
-
return self.detect(
|
|
20884
|
+
return self.detect(fs46.readFileSync(filepath), opts);
|
|
20824
20885
|
};
|
|
20825
20886
|
module2.exports.detectAll = function(buffer, opts) {
|
|
20826
20887
|
if (typeof opts !== "object") {
|
|
@@ -24285,16 +24346,16 @@ var require_os_tmpdir = __commonJS({
|
|
|
24285
24346
|
var isWindows = process.platform === "win32";
|
|
24286
24347
|
var trailingSlashRe = isWindows ? /[^:]\\$/ : /.\/$/;
|
|
24287
24348
|
module2.exports = function() {
|
|
24288
|
-
var
|
|
24349
|
+
var path54;
|
|
24289
24350
|
if (isWindows) {
|
|
24290
|
-
|
|
24351
|
+
path54 = process.env.TEMP || process.env.TMP || (process.env.SystemRoot || process.env.windir) + "\\temp";
|
|
24291
24352
|
} else {
|
|
24292
|
-
|
|
24353
|
+
path54 = process.env.TMPDIR || process.env.TMP || process.env.TEMP || "/tmp";
|
|
24293
24354
|
}
|
|
24294
|
-
if (trailingSlashRe.test(
|
|
24295
|
-
|
|
24355
|
+
if (trailingSlashRe.test(path54)) {
|
|
24356
|
+
path54 = path54.slice(0, -1);
|
|
24296
24357
|
}
|
|
24297
|
-
return
|
|
24358
|
+
return path54;
|
|
24298
24359
|
};
|
|
24299
24360
|
}
|
|
24300
24361
|
});
|
|
@@ -24302,8 +24363,8 @@ var require_os_tmpdir = __commonJS({
|
|
|
24302
24363
|
// node_modules/tmp/lib/tmp.js
|
|
24303
24364
|
var require_tmp = __commonJS({
|
|
24304
24365
|
"node_modules/tmp/lib/tmp.js"(exports2, module2) {
|
|
24305
|
-
var
|
|
24306
|
-
var
|
|
24366
|
+
var fs46 = require("fs");
|
|
24367
|
+
var path54 = require("path");
|
|
24307
24368
|
var crypto6 = require("crypto");
|
|
24308
24369
|
var osTmpDir = require_os_tmpdir();
|
|
24309
24370
|
var _c2 = process.binding("constants");
|
|
@@ -24345,7 +24406,7 @@ var require_tmp = __commonJS({
|
|
|
24345
24406
|
}
|
|
24346
24407
|
function _generateTmpName(opts) {
|
|
24347
24408
|
if (opts.name) {
|
|
24348
|
-
return
|
|
24409
|
+
return path54.join(opts.dir || tmpDir, opts.name);
|
|
24349
24410
|
}
|
|
24350
24411
|
if (opts.template) {
|
|
24351
24412
|
return opts.template.replace(TEMPLATE_PATTERN, _randomChars(6));
|
|
@@ -24356,7 +24417,7 @@ var require_tmp = __commonJS({
|
|
|
24356
24417
|
_randomChars(12),
|
|
24357
24418
|
opts.postfix || ""
|
|
24358
24419
|
].join("");
|
|
24359
|
-
return
|
|
24420
|
+
return path54.join(opts.dir || tmpDir, name);
|
|
24360
24421
|
}
|
|
24361
24422
|
function tmpName(options, callback) {
|
|
24362
24423
|
var args = _parseArguments(options, callback), opts = args[0], cb = args[1], tries = opts.name ? 1 : opts.tries || DEFAULT_TRIES;
|
|
@@ -24366,7 +24427,7 @@ var require_tmp = __commonJS({
|
|
|
24366
24427
|
return cb(new Error("Invalid template provided"));
|
|
24367
24428
|
(function _getUniqueName() {
|
|
24368
24429
|
const name = _generateTmpName(opts);
|
|
24369
|
-
|
|
24430
|
+
fs46.stat(name, function(err) {
|
|
24370
24431
|
if (!err) {
|
|
24371
24432
|
if (tries-- > 0) return _getUniqueName();
|
|
24372
24433
|
return cb(new Error("Could not get a unique tmp filename, max tries reached " + name));
|
|
@@ -24384,7 +24445,7 @@ var require_tmp = __commonJS({
|
|
|
24384
24445
|
do {
|
|
24385
24446
|
const name = _generateTmpName(opts);
|
|
24386
24447
|
try {
|
|
24387
|
-
|
|
24448
|
+
fs46.statSync(name);
|
|
24388
24449
|
} catch (e2) {
|
|
24389
24450
|
return name;
|
|
24390
24451
|
}
|
|
@@ -24396,13 +24457,13 @@ var require_tmp = __commonJS({
|
|
|
24396
24457
|
opts.postfix = _isUndefined(opts.postfix) ? ".tmp" : opts.postfix;
|
|
24397
24458
|
tmpName(opts, function _tmpNameCreated(err, name) {
|
|
24398
24459
|
if (err) return cb(err);
|
|
24399
|
-
|
|
24460
|
+
fs46.open(name, CREATE_FLAGS, opts.mode || FILE_MODE, function _fileCreated(err2, fd) {
|
|
24400
24461
|
if (err2) return cb(err2);
|
|
24401
24462
|
if (opts.discardDescriptor) {
|
|
24402
|
-
return
|
|
24463
|
+
return fs46.close(fd, function _discardCallback(err3) {
|
|
24403
24464
|
if (err3) {
|
|
24404
24465
|
try {
|
|
24405
|
-
|
|
24466
|
+
fs46.unlinkSync(name);
|
|
24406
24467
|
} catch (e2) {
|
|
24407
24468
|
if (!isENOENT(e2)) {
|
|
24408
24469
|
err3 = e2;
|
|
@@ -24425,9 +24486,9 @@ var require_tmp = __commonJS({
|
|
|
24425
24486
|
opts.postfix = opts.postfix || ".tmp";
|
|
24426
24487
|
const discardOrDetachDescriptor = opts.discardDescriptor || opts.detachDescriptor;
|
|
24427
24488
|
const name = tmpNameSync(opts);
|
|
24428
|
-
var fd =
|
|
24489
|
+
var fd = fs46.openSync(name, CREATE_FLAGS, opts.mode || FILE_MODE);
|
|
24429
24490
|
if (opts.discardDescriptor) {
|
|
24430
|
-
|
|
24491
|
+
fs46.closeSync(fd);
|
|
24431
24492
|
fd = void 0;
|
|
24432
24493
|
}
|
|
24433
24494
|
return {
|
|
@@ -24439,9 +24500,9 @@ var require_tmp = __commonJS({
|
|
|
24439
24500
|
function _rmdirRecursiveSync(root) {
|
|
24440
24501
|
const dirs = [root];
|
|
24441
24502
|
do {
|
|
24442
|
-
var dir2 = dirs.pop(), deferred = false, files =
|
|
24503
|
+
var dir2 = dirs.pop(), deferred = false, files = fs46.readdirSync(dir2);
|
|
24443
24504
|
for (var i2 = 0, length = files.length; i2 < length; i2++) {
|
|
24444
|
-
var file2 =
|
|
24505
|
+
var file2 = path54.join(dir2, files[i2]), stat = fs46.lstatSync(file2);
|
|
24445
24506
|
if (stat.isDirectory()) {
|
|
24446
24507
|
if (!deferred) {
|
|
24447
24508
|
deferred = true;
|
|
@@ -24449,11 +24510,11 @@ var require_tmp = __commonJS({
|
|
|
24449
24510
|
}
|
|
24450
24511
|
dirs.push(file2);
|
|
24451
24512
|
} else {
|
|
24452
|
-
|
|
24513
|
+
fs46.unlinkSync(file2);
|
|
24453
24514
|
}
|
|
24454
24515
|
}
|
|
24455
24516
|
if (!deferred) {
|
|
24456
|
-
|
|
24517
|
+
fs46.rmdirSync(dir2);
|
|
24457
24518
|
}
|
|
24458
24519
|
} while (dirs.length !== 0);
|
|
24459
24520
|
}
|
|
@@ -24461,7 +24522,7 @@ var require_tmp = __commonJS({
|
|
|
24461
24522
|
var args = _parseArguments(options, callback), opts = args[0], cb = args[1];
|
|
24462
24523
|
tmpName(opts, function _tmpNameCreated(err, name) {
|
|
24463
24524
|
if (err) return cb(err);
|
|
24464
|
-
|
|
24525
|
+
fs46.mkdir(name, opts.mode || DIR_MODE, function _dirCreated(err2) {
|
|
24465
24526
|
if (err2) return cb(err2);
|
|
24466
24527
|
cb(null, name, _prepareTmpDirRemoveCallback(name, opts));
|
|
24467
24528
|
});
|
|
@@ -24470,7 +24531,7 @@ var require_tmp = __commonJS({
|
|
|
24470
24531
|
function dirSync(options) {
|
|
24471
24532
|
var args = _parseArguments(options), opts = args[0];
|
|
24472
24533
|
const name = tmpNameSync(opts);
|
|
24473
|
-
|
|
24534
|
+
fs46.mkdirSync(name, opts.mode || DIR_MODE);
|
|
24474
24535
|
return {
|
|
24475
24536
|
name,
|
|
24476
24537
|
removeCallback: _prepareTmpDirRemoveCallback(name, opts)
|
|
@@ -24480,7 +24541,7 @@ var require_tmp = __commonJS({
|
|
|
24480
24541
|
const removeCallback = _prepareRemoveCallback(function _removeCallback(fdPath) {
|
|
24481
24542
|
try {
|
|
24482
24543
|
if (0 <= fdPath[0]) {
|
|
24483
|
-
|
|
24544
|
+
fs46.closeSync(fdPath[0]);
|
|
24484
24545
|
}
|
|
24485
24546
|
} catch (e2) {
|
|
24486
24547
|
if (!isEBADF(e2) && !isENOENT(e2)) {
|
|
@@ -24488,7 +24549,7 @@ var require_tmp = __commonJS({
|
|
|
24488
24549
|
}
|
|
24489
24550
|
}
|
|
24490
24551
|
try {
|
|
24491
|
-
|
|
24552
|
+
fs46.unlinkSync(fdPath[1]);
|
|
24492
24553
|
} catch (e2) {
|
|
24493
24554
|
if (!isENOENT(e2)) {
|
|
24494
24555
|
throw e2;
|
|
@@ -24501,7 +24562,7 @@ var require_tmp = __commonJS({
|
|
|
24501
24562
|
return removeCallback;
|
|
24502
24563
|
}
|
|
24503
24564
|
function _prepareTmpDirRemoveCallback(name, opts) {
|
|
24504
|
-
const removeFunction = opts.unsafeCleanup ? _rmdirRecursiveSync :
|
|
24565
|
+
const removeFunction = opts.unsafeCleanup ? _rmdirRecursiveSync : fs46.rmdirSync.bind(fs46);
|
|
24505
24566
|
const removeCallback = _prepareRemoveCallback(removeFunction, name);
|
|
24506
24567
|
if (!opts.keep) {
|
|
24507
24568
|
_removeObjects.unshift(removeCallback);
|
|
@@ -25652,7 +25713,7 @@ var require_Observable = __commonJS({
|
|
|
25652
25713
|
Observable2.prototype.forEach = function(next, promiseCtor) {
|
|
25653
25714
|
var _this = this;
|
|
25654
25715
|
promiseCtor = getPromiseCtor(promiseCtor);
|
|
25655
|
-
return new promiseCtor(function(
|
|
25716
|
+
return new promiseCtor(function(resolve38, reject) {
|
|
25656
25717
|
var subscriber = new Subscriber_1.SafeSubscriber({
|
|
25657
25718
|
next: function(value) {
|
|
25658
25719
|
try {
|
|
@@ -25663,7 +25724,7 @@ var require_Observable = __commonJS({
|
|
|
25663
25724
|
}
|
|
25664
25725
|
},
|
|
25665
25726
|
error: reject,
|
|
25666
|
-
complete:
|
|
25727
|
+
complete: resolve38
|
|
25667
25728
|
});
|
|
25668
25729
|
_this.subscribe(subscriber);
|
|
25669
25730
|
});
|
|
@@ -25685,14 +25746,14 @@ var require_Observable = __commonJS({
|
|
|
25685
25746
|
Observable2.prototype.toPromise = function(promiseCtor) {
|
|
25686
25747
|
var _this = this;
|
|
25687
25748
|
promiseCtor = getPromiseCtor(promiseCtor);
|
|
25688
|
-
return new promiseCtor(function(
|
|
25749
|
+
return new promiseCtor(function(resolve38, reject) {
|
|
25689
25750
|
var value;
|
|
25690
25751
|
_this.subscribe(function(x2) {
|
|
25691
25752
|
return value = x2;
|
|
25692
25753
|
}, function(err) {
|
|
25693
25754
|
return reject(err);
|
|
25694
25755
|
}, function() {
|
|
25695
|
-
return
|
|
25756
|
+
return resolve38(value);
|
|
25696
25757
|
});
|
|
25697
25758
|
});
|
|
25698
25759
|
};
|
|
@@ -27788,11 +27849,11 @@ var require_innerFrom = __commonJS({
|
|
|
27788
27849
|
"use strict";
|
|
27789
27850
|
var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P2, generator) {
|
|
27790
27851
|
function adopt(value) {
|
|
27791
|
-
return value instanceof P2 ? value : new P2(function(
|
|
27792
|
-
|
|
27852
|
+
return value instanceof P2 ? value : new P2(function(resolve38) {
|
|
27853
|
+
resolve38(value);
|
|
27793
27854
|
});
|
|
27794
27855
|
}
|
|
27795
|
-
return new (P2 || (P2 = Promise))(function(
|
|
27856
|
+
return new (P2 || (P2 = Promise))(function(resolve38, reject) {
|
|
27796
27857
|
function fulfilled(value) {
|
|
27797
27858
|
try {
|
|
27798
27859
|
step(generator.next(value));
|
|
@@ -27808,7 +27869,7 @@ var require_innerFrom = __commonJS({
|
|
|
27808
27869
|
}
|
|
27809
27870
|
}
|
|
27810
27871
|
function step(result) {
|
|
27811
|
-
result.done ?
|
|
27872
|
+
result.done ? resolve38(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
27812
27873
|
}
|
|
27813
27874
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
27814
27875
|
});
|
|
@@ -27890,14 +27951,14 @@ var require_innerFrom = __commonJS({
|
|
|
27890
27951
|
}, i2);
|
|
27891
27952
|
function verb(n2) {
|
|
27892
27953
|
i2[n2] = o2[n2] && function(v2) {
|
|
27893
|
-
return new Promise(function(
|
|
27894
|
-
v2 = o2[n2](v2), settle(
|
|
27954
|
+
return new Promise(function(resolve38, reject) {
|
|
27955
|
+
v2 = o2[n2](v2), settle(resolve38, reject, v2.done, v2.value);
|
|
27895
27956
|
});
|
|
27896
27957
|
};
|
|
27897
27958
|
}
|
|
27898
|
-
function settle(
|
|
27959
|
+
function settle(resolve38, reject, d2, v2) {
|
|
27899
27960
|
Promise.resolve(v2).then(function(v3) {
|
|
27900
|
-
|
|
27961
|
+
resolve38({ value: v3, done: d2 });
|
|
27901
27962
|
}, reject);
|
|
27902
27963
|
}
|
|
27903
27964
|
};
|
|
@@ -28516,7 +28577,7 @@ var require_lastValueFrom = __commonJS({
|
|
|
28516
28577
|
var EmptyError_1 = require_EmptyError();
|
|
28517
28578
|
function lastValueFrom2(source, config2) {
|
|
28518
28579
|
var hasConfig = typeof config2 === "object";
|
|
28519
|
-
return new Promise(function(
|
|
28580
|
+
return new Promise(function(resolve38, reject) {
|
|
28520
28581
|
var _hasValue = false;
|
|
28521
28582
|
var _value;
|
|
28522
28583
|
source.subscribe({
|
|
@@ -28527,9 +28588,9 @@ var require_lastValueFrom = __commonJS({
|
|
|
28527
28588
|
error: reject,
|
|
28528
28589
|
complete: function() {
|
|
28529
28590
|
if (_hasValue) {
|
|
28530
|
-
|
|
28591
|
+
resolve38(_value);
|
|
28531
28592
|
} else if (hasConfig) {
|
|
28532
|
-
|
|
28593
|
+
resolve38(config2.defaultValue);
|
|
28533
28594
|
} else {
|
|
28534
28595
|
reject(new EmptyError_1.EmptyError());
|
|
28535
28596
|
}
|
|
@@ -28551,16 +28612,16 @@ var require_firstValueFrom = __commonJS({
|
|
|
28551
28612
|
var Subscriber_1 = require_Subscriber();
|
|
28552
28613
|
function firstValueFrom(source, config2) {
|
|
28553
28614
|
var hasConfig = typeof config2 === "object";
|
|
28554
|
-
return new Promise(function(
|
|
28615
|
+
return new Promise(function(resolve38, reject) {
|
|
28555
28616
|
var subscriber = new Subscriber_1.SafeSubscriber({
|
|
28556
28617
|
next: function(value) {
|
|
28557
|
-
|
|
28618
|
+
resolve38(value);
|
|
28558
28619
|
subscriber.unsubscribe();
|
|
28559
28620
|
},
|
|
28560
28621
|
error: reject,
|
|
28561
28622
|
complete: function() {
|
|
28562
28623
|
if (hasConfig) {
|
|
28563
|
-
|
|
28624
|
+
resolve38(config2.defaultValue);
|
|
28564
28625
|
} else {
|
|
28565
28626
|
reject(new EmptyError_1.EmptyError());
|
|
28566
28627
|
}
|
|
@@ -34353,14 +34414,14 @@ var require_run_async = __commonJS({
|
|
|
34353
34414
|
return function() {
|
|
34354
34415
|
var args = arguments;
|
|
34355
34416
|
var originalThis = this;
|
|
34356
|
-
var promise = new Promise(function(
|
|
34417
|
+
var promise = new Promise(function(resolve38, reject) {
|
|
34357
34418
|
var resolved = false;
|
|
34358
34419
|
const wrappedResolve = function(value) {
|
|
34359
34420
|
if (resolved) {
|
|
34360
34421
|
console.warn("Run-async promise already resolved.");
|
|
34361
34422
|
}
|
|
34362
34423
|
resolved = true;
|
|
34363
|
-
|
|
34424
|
+
resolve38(value);
|
|
34364
34425
|
};
|
|
34365
34426
|
var rejected = false;
|
|
34366
34427
|
const wrappedReject = function(value) {
|
|
@@ -35714,11 +35775,11 @@ var parser = new YargsParser({
|
|
|
35714
35775
|
resolve: import_path2.resolve,
|
|
35715
35776
|
// TODO: figure out a way to combine ESM and CJS coverage, such that
|
|
35716
35777
|
// we can exercise all the lines below:
|
|
35717
|
-
require: (
|
|
35778
|
+
require: (path54) => {
|
|
35718
35779
|
if (typeof require !== "undefined") {
|
|
35719
|
-
return require(
|
|
35720
|
-
} else if (
|
|
35721
|
-
return JSON.parse((0, import_fs2.readFileSync)(
|
|
35780
|
+
return require(path54);
|
|
35781
|
+
} else if (path54.match(/\.json$/)) {
|
|
35782
|
+
return JSON.parse((0, import_fs2.readFileSync)(path54, "utf8"));
|
|
35722
35783
|
} else {
|
|
35723
35784
|
throw Error("only .json config files are supported in ESM");
|
|
35724
35785
|
}
|
|
@@ -38244,12 +38305,12 @@ var YargsInstance = class {
|
|
|
38244
38305
|
async getCompletion(args, done) {
|
|
38245
38306
|
argsert("<array> [function]", [args, done], arguments.length);
|
|
38246
38307
|
if (!done) {
|
|
38247
|
-
return new Promise((
|
|
38308
|
+
return new Promise((resolve38, reject) => {
|
|
38248
38309
|
__classPrivateFieldGet(this, _YargsInstance_completion, "f").getCompletion(args, (err, completions) => {
|
|
38249
38310
|
if (err)
|
|
38250
38311
|
reject(err);
|
|
38251
38312
|
else
|
|
38252
|
-
|
|
38313
|
+
resolve38(completions);
|
|
38253
38314
|
});
|
|
38254
38315
|
});
|
|
38255
38316
|
} else {
|
|
@@ -40399,8 +40460,8 @@ function getErrorMap() {
|
|
|
40399
40460
|
|
|
40400
40461
|
// node_modules/zod/v3/helpers/parseUtil.js
|
|
40401
40462
|
var makeIssue = (params) => {
|
|
40402
|
-
const { data, path:
|
|
40403
|
-
const fullPath = [...
|
|
40463
|
+
const { data, path: path54, errorMaps, issueData } = params;
|
|
40464
|
+
const fullPath = [...path54, ...issueData.path || []];
|
|
40404
40465
|
const fullIssue = {
|
|
40405
40466
|
...issueData,
|
|
40406
40467
|
path: fullPath
|
|
@@ -40516,11 +40577,11 @@ var errorUtil;
|
|
|
40516
40577
|
|
|
40517
40578
|
// node_modules/zod/v3/types.js
|
|
40518
40579
|
var ParseInputLazyPath = class {
|
|
40519
|
-
constructor(parent, value,
|
|
40580
|
+
constructor(parent, value, path54, key) {
|
|
40520
40581
|
this._cachedPath = [];
|
|
40521
40582
|
this.parent = parent;
|
|
40522
40583
|
this.data = value;
|
|
40523
|
-
this._path =
|
|
40584
|
+
this._path = path54;
|
|
40524
40585
|
this._key = key;
|
|
40525
40586
|
}
|
|
40526
40587
|
get path() {
|
|
@@ -44659,16 +44720,16 @@ async function handleAgentSkills(options) {
|
|
|
44659
44720
|
}
|
|
44660
44721
|
async function askYesNo(question) {
|
|
44661
44722
|
const rl = readline.createInterface({ input: process.stdin, output: process.stderr });
|
|
44662
|
-
return new Promise((
|
|
44723
|
+
return new Promise((resolve38) => {
|
|
44663
44724
|
process.stderr.write(`${question} `);
|
|
44664
44725
|
rl.once("line", (answer) => {
|
|
44665
44726
|
rl.close();
|
|
44666
44727
|
const trimmed = answer.trim();
|
|
44667
44728
|
if (trimmed === "") {
|
|
44668
|
-
|
|
44729
|
+
resolve38(true);
|
|
44669
44730
|
return;
|
|
44670
44731
|
}
|
|
44671
|
-
|
|
44732
|
+
resolve38(/^y(es)?$/i.test(trimmed));
|
|
44672
44733
|
});
|
|
44673
44734
|
});
|
|
44674
44735
|
}
|
|
@@ -44747,7 +44808,7 @@ function handleRemove(argv) {
|
|
|
44747
44808
|
}
|
|
44748
44809
|
|
|
44749
44810
|
// src/cli/commands/env.ts
|
|
44750
|
-
var
|
|
44811
|
+
var path47 = __toESM(require("path"));
|
|
44751
44812
|
|
|
44752
44813
|
// src/core/harness.ts
|
|
44753
44814
|
var fs20 = __toESM(require("fs"));
|
|
@@ -45526,13 +45587,13 @@ var MultipartBody = class {
|
|
|
45526
45587
|
// node_modules/@anthropic-ai/sdk/_shims/node-runtime.mjs
|
|
45527
45588
|
var import_web = require("node:stream/web");
|
|
45528
45589
|
var fileFromPathWarned = false;
|
|
45529
|
-
async function fileFromPath3(
|
|
45590
|
+
async function fileFromPath3(path54, ...args) {
|
|
45530
45591
|
const { fileFromPath: _fileFromPath } = await Promise.resolve().then(() => (init_fileFromPath(), fileFromPath_exports));
|
|
45531
45592
|
if (!fileFromPathWarned) {
|
|
45532
|
-
console.warn(`fileFromPath is deprecated; use fs.createReadStream(${JSON.stringify(
|
|
45593
|
+
console.warn(`fileFromPath is deprecated; use fs.createReadStream(${JSON.stringify(path54)}) instead`);
|
|
45533
45594
|
fileFromPathWarned = true;
|
|
45534
45595
|
}
|
|
45535
|
-
return await _fileFromPath(
|
|
45596
|
+
return await _fileFromPath(path54, ...args);
|
|
45536
45597
|
}
|
|
45537
45598
|
var defaultHttpAgent = new import_agentkeepalive.default({ keepAlive: true, timeout: 5 * 60 * 1e3 });
|
|
45538
45599
|
var defaultHttpsAgent = new import_agentkeepalive.default.HttpsAgent({ keepAlive: true, timeout: 5 * 60 * 1e3 });
|
|
@@ -46028,8 +46089,8 @@ async function defaultParseResponse(props) {
|
|
|
46028
46089
|
}
|
|
46029
46090
|
var APIPromise = class _APIPromise extends Promise {
|
|
46030
46091
|
constructor(responsePromise, parseResponse = defaultParseResponse) {
|
|
46031
|
-
super((
|
|
46032
|
-
|
|
46092
|
+
super((resolve38) => {
|
|
46093
|
+
resolve38(null);
|
|
46033
46094
|
});
|
|
46034
46095
|
this.responsePromise = responsePromise;
|
|
46035
46096
|
this.parseResponse = parseResponse;
|
|
@@ -46129,29 +46190,29 @@ var APIClient = class {
|
|
|
46129
46190
|
defaultIdempotencyKey() {
|
|
46130
46191
|
return `stainless-node-retry-${uuid4()}`;
|
|
46131
46192
|
}
|
|
46132
|
-
get(
|
|
46133
|
-
return this.methodRequest("get",
|
|
46193
|
+
get(path54, opts) {
|
|
46194
|
+
return this.methodRequest("get", path54, opts);
|
|
46134
46195
|
}
|
|
46135
|
-
post(
|
|
46136
|
-
return this.methodRequest("post",
|
|
46196
|
+
post(path54, opts) {
|
|
46197
|
+
return this.methodRequest("post", path54, opts);
|
|
46137
46198
|
}
|
|
46138
|
-
patch(
|
|
46139
|
-
return this.methodRequest("patch",
|
|
46199
|
+
patch(path54, opts) {
|
|
46200
|
+
return this.methodRequest("patch", path54, opts);
|
|
46140
46201
|
}
|
|
46141
|
-
put(
|
|
46142
|
-
return this.methodRequest("put",
|
|
46202
|
+
put(path54, opts) {
|
|
46203
|
+
return this.methodRequest("put", path54, opts);
|
|
46143
46204
|
}
|
|
46144
|
-
delete(
|
|
46145
|
-
return this.methodRequest("delete",
|
|
46205
|
+
delete(path54, opts) {
|
|
46206
|
+
return this.methodRequest("delete", path54, opts);
|
|
46146
46207
|
}
|
|
46147
|
-
methodRequest(method,
|
|
46208
|
+
methodRequest(method, path54, opts) {
|
|
46148
46209
|
return this.request(Promise.resolve(opts).then(async (opts2) => {
|
|
46149
46210
|
const body = opts2 && isBlobLike(opts2?.body) ? new DataView(await opts2.body.arrayBuffer()) : opts2?.body instanceof DataView ? opts2.body : opts2?.body instanceof ArrayBuffer ? new DataView(opts2.body) : opts2 && ArrayBuffer.isView(opts2?.body) ? new DataView(opts2.body.buffer) : opts2?.body;
|
|
46150
|
-
return { method, path:
|
|
46211
|
+
return { method, path: path54, ...opts2, body };
|
|
46151
46212
|
}));
|
|
46152
46213
|
}
|
|
46153
|
-
getAPIList(
|
|
46154
|
-
return this.requestAPIList(Page, { method: "get", path:
|
|
46214
|
+
getAPIList(path54, Page, opts) {
|
|
46215
|
+
return this.requestAPIList(Page, { method: "get", path: path54, ...opts });
|
|
46155
46216
|
}
|
|
46156
46217
|
calculateContentLength(body) {
|
|
46157
46218
|
if (typeof body === "string") {
|
|
@@ -46169,10 +46230,10 @@ var APIClient = class {
|
|
|
46169
46230
|
return null;
|
|
46170
46231
|
}
|
|
46171
46232
|
buildRequest(options) {
|
|
46172
|
-
const { method, path:
|
|
46233
|
+
const { method, path: path54, query, headers = {} } = options;
|
|
46173
46234
|
const body = ArrayBuffer.isView(options.body) || options.__binaryRequest && typeof options.body === "string" ? options.body : isMultipartBody(options.body) ? options.body.body : options.body ? JSON.stringify(options.body, null, 2) : null;
|
|
46174
46235
|
const contentLength = this.calculateContentLength(body);
|
|
46175
|
-
const url = this.buildURL(
|
|
46236
|
+
const url = this.buildURL(path54, query);
|
|
46176
46237
|
if ("timeout" in options)
|
|
46177
46238
|
validatePositiveInteger("timeout", options.timeout);
|
|
46178
46239
|
const timeout = options.timeout ?? this.timeout;
|
|
@@ -46281,8 +46342,8 @@ var APIClient = class {
|
|
|
46281
46342
|
const request = this.makeRequest(options, null);
|
|
46282
46343
|
return new PagePromise(this, request, Page);
|
|
46283
46344
|
}
|
|
46284
|
-
buildURL(
|
|
46285
|
-
const url = isAbsoluteURL(
|
|
46345
|
+
buildURL(path54, query) {
|
|
46346
|
+
const url = isAbsoluteURL(path54) ? new URL(path54) : new URL(this.baseURL + (this.baseURL.endsWith("/") && path54.startsWith("/") ? path54.slice(1) : path54));
|
|
46286
46347
|
const defaultQuery = this.defaultQuery();
|
|
46287
46348
|
if (!isEmptyObj(defaultQuery)) {
|
|
46288
46349
|
query = { ...defaultQuery, ...query };
|
|
@@ -46567,7 +46628,7 @@ var startsWithSchemeRegexp = new RegExp("^(?:[a-z]+:)?//", "i");
|
|
|
46567
46628
|
var isAbsoluteURL = (url) => {
|
|
46568
46629
|
return startsWithSchemeRegexp.test(url);
|
|
46569
46630
|
};
|
|
46570
|
-
var sleep = (ms) => new Promise((
|
|
46631
|
+
var sleep = (ms) => new Promise((resolve38) => setTimeout(resolve38, ms));
|
|
46571
46632
|
var validatePositiveInteger = (name, n2) => {
|
|
46572
46633
|
if (typeof n2 !== "number" || !Number.isInteger(n2)) {
|
|
46573
46634
|
throw new AnthropicError(`${name} must be an integer`);
|
|
@@ -47058,12 +47119,12 @@ var PromptCachingBetaMessageStream = class _PromptCachingBetaMessageStream {
|
|
|
47058
47119
|
}
|
|
47059
47120
|
return this._emit("error", new AnthropicError(String(error3)));
|
|
47060
47121
|
});
|
|
47061
|
-
__classPrivateFieldSet7(this, _PromptCachingBetaMessageStream_connectedPromise, new Promise((
|
|
47062
|
-
__classPrivateFieldSet7(this, _PromptCachingBetaMessageStream_resolveConnectedPromise,
|
|
47122
|
+
__classPrivateFieldSet7(this, _PromptCachingBetaMessageStream_connectedPromise, new Promise((resolve38, reject) => {
|
|
47123
|
+
__classPrivateFieldSet7(this, _PromptCachingBetaMessageStream_resolveConnectedPromise, resolve38, "f");
|
|
47063
47124
|
__classPrivateFieldSet7(this, _PromptCachingBetaMessageStream_rejectConnectedPromise, reject, "f");
|
|
47064
47125
|
}), "f");
|
|
47065
|
-
__classPrivateFieldSet7(this, _PromptCachingBetaMessageStream_endPromise, new Promise((
|
|
47066
|
-
__classPrivateFieldSet7(this, _PromptCachingBetaMessageStream_resolveEndPromise,
|
|
47126
|
+
__classPrivateFieldSet7(this, _PromptCachingBetaMessageStream_endPromise, new Promise((resolve38, reject) => {
|
|
47127
|
+
__classPrivateFieldSet7(this, _PromptCachingBetaMessageStream_resolveEndPromise, resolve38, "f");
|
|
47067
47128
|
__classPrivateFieldSet7(this, _PromptCachingBetaMessageStream_rejectEndPromise, reject, "f");
|
|
47068
47129
|
}), "f");
|
|
47069
47130
|
__classPrivateFieldGet8(this, _PromptCachingBetaMessageStream_connectedPromise, "f").catch(() => {
|
|
@@ -47192,11 +47253,11 @@ var PromptCachingBetaMessageStream = class _PromptCachingBetaMessageStream {
|
|
|
47192
47253
|
* const message = await stream.emitted('message') // rejects if the stream errors
|
|
47193
47254
|
*/
|
|
47194
47255
|
emitted(event) {
|
|
47195
|
-
return new Promise((
|
|
47256
|
+
return new Promise((resolve38, reject) => {
|
|
47196
47257
|
__classPrivateFieldSet7(this, _PromptCachingBetaMessageStream_catchingPromiseCreated, true, "f");
|
|
47197
47258
|
if (event !== "error")
|
|
47198
47259
|
this.once("error", reject);
|
|
47199
|
-
this.once(event,
|
|
47260
|
+
this.once(event, resolve38);
|
|
47200
47261
|
});
|
|
47201
47262
|
}
|
|
47202
47263
|
async done() {
|
|
@@ -47423,7 +47484,7 @@ var PromptCachingBetaMessageStream = class _PromptCachingBetaMessageStream {
|
|
|
47423
47484
|
if (done) {
|
|
47424
47485
|
return { value: void 0, done: true };
|
|
47425
47486
|
}
|
|
47426
|
-
return new Promise((
|
|
47487
|
+
return new Promise((resolve38, reject) => readQueue.push({ resolve: resolve38, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
|
|
47427
47488
|
}
|
|
47428
47489
|
const chunk = pushQueue.shift();
|
|
47429
47490
|
return { value: chunk, done: false };
|
|
@@ -47571,12 +47632,12 @@ var MessageStream = class _MessageStream {
|
|
|
47571
47632
|
}
|
|
47572
47633
|
return this._emit("error", new AnthropicError(String(error3)));
|
|
47573
47634
|
});
|
|
47574
|
-
__classPrivateFieldSet8(this, _MessageStream_connectedPromise, new Promise((
|
|
47575
|
-
__classPrivateFieldSet8(this, _MessageStream_resolveConnectedPromise,
|
|
47635
|
+
__classPrivateFieldSet8(this, _MessageStream_connectedPromise, new Promise((resolve38, reject) => {
|
|
47636
|
+
__classPrivateFieldSet8(this, _MessageStream_resolveConnectedPromise, resolve38, "f");
|
|
47576
47637
|
__classPrivateFieldSet8(this, _MessageStream_rejectConnectedPromise, reject, "f");
|
|
47577
47638
|
}), "f");
|
|
47578
|
-
__classPrivateFieldSet8(this, _MessageStream_endPromise, new Promise((
|
|
47579
|
-
__classPrivateFieldSet8(this, _MessageStream_resolveEndPromise,
|
|
47639
|
+
__classPrivateFieldSet8(this, _MessageStream_endPromise, new Promise((resolve38, reject) => {
|
|
47640
|
+
__classPrivateFieldSet8(this, _MessageStream_resolveEndPromise, resolve38, "f");
|
|
47580
47641
|
__classPrivateFieldSet8(this, _MessageStream_rejectEndPromise, reject, "f");
|
|
47581
47642
|
}), "f");
|
|
47582
47643
|
__classPrivateFieldGet9(this, _MessageStream_connectedPromise, "f").catch(() => {
|
|
@@ -47705,11 +47766,11 @@ var MessageStream = class _MessageStream {
|
|
|
47705
47766
|
* const message = await stream.emitted('message') // rejects if the stream errors
|
|
47706
47767
|
*/
|
|
47707
47768
|
emitted(event) {
|
|
47708
|
-
return new Promise((
|
|
47769
|
+
return new Promise((resolve38, reject) => {
|
|
47709
47770
|
__classPrivateFieldSet8(this, _MessageStream_catchingPromiseCreated, true, "f");
|
|
47710
47771
|
if (event !== "error")
|
|
47711
47772
|
this.once("error", reject);
|
|
47712
|
-
this.once(event,
|
|
47773
|
+
this.once(event, resolve38);
|
|
47713
47774
|
});
|
|
47714
47775
|
}
|
|
47715
47776
|
async done() {
|
|
@@ -47936,7 +47997,7 @@ var MessageStream = class _MessageStream {
|
|
|
47936
47997
|
if (done) {
|
|
47937
47998
|
return { value: void 0, done: true };
|
|
47938
47999
|
}
|
|
47939
|
-
return new Promise((
|
|
48000
|
+
return new Promise((resolve38, reject) => readQueue.push({ resolve: resolve38, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
|
|
47940
48001
|
}
|
|
47941
48002
|
const chunk = pushQueue.shift();
|
|
47942
48003
|
return { value: chunk, done: false };
|
|
@@ -48196,11 +48257,11 @@ async function promptApplyAgentMdProposal(repoPath) {
|
|
|
48196
48257
|
}
|
|
48197
48258
|
async function askYesNo2(question) {
|
|
48198
48259
|
const rl = readline2.createInterface({ input: process.stdin, output: process.stderr });
|
|
48199
|
-
return new Promise((
|
|
48260
|
+
return new Promise((resolve38) => {
|
|
48200
48261
|
process.stderr.write(`${question} `);
|
|
48201
48262
|
rl.once("line", (answer) => {
|
|
48202
48263
|
rl.close();
|
|
48203
|
-
|
|
48264
|
+
resolve38(/^y(es)?$/i.test(answer.trim()));
|
|
48204
48265
|
});
|
|
48205
48266
|
});
|
|
48206
48267
|
}
|
|
@@ -48430,7 +48491,7 @@ async function executeAuthoringToolCall(toolName, input, repoPath, harnessDir, c
|
|
|
48430
48491
|
}
|
|
48431
48492
|
async function askUser(question, options) {
|
|
48432
48493
|
const rl = readline3.createInterface({ input: process.stdin, output: process.stderr });
|
|
48433
|
-
return new Promise((
|
|
48494
|
+
return new Promise((resolve38) => {
|
|
48434
48495
|
process.stderr.write("\n");
|
|
48435
48496
|
process.stderr.write(`\u2753 ${question}
|
|
48436
48497
|
`);
|
|
@@ -48441,7 +48502,7 @@ async function askUser(question, options) {
|
|
|
48441
48502
|
process.stderr.write("> ");
|
|
48442
48503
|
rl.once("line", (answer) => {
|
|
48443
48504
|
rl.close();
|
|
48444
|
-
|
|
48505
|
+
resolve38(answer.trim());
|
|
48445
48506
|
});
|
|
48446
48507
|
});
|
|
48447
48508
|
}
|
|
@@ -48585,7 +48646,7 @@ function runScript(scriptPath, args = [], options = {}) {
|
|
|
48585
48646
|
function runScriptCapture(scriptPath, args = [], options = {}) {
|
|
48586
48647
|
const stream = options.stream ?? false;
|
|
48587
48648
|
const { stream: _stream, ...spawnOptions } = options;
|
|
48588
|
-
return new Promise((
|
|
48649
|
+
return new Promise((resolve38) => {
|
|
48589
48650
|
const proc = (0, import_child_process.spawn)("bash", [scriptPath, ...args], {
|
|
48590
48651
|
...spawnOptions,
|
|
48591
48652
|
stdio: ["inherit", "pipe", "pipe"]
|
|
@@ -48600,13 +48661,13 @@ function runScriptCapture(scriptPath, args = [], options = {}) {
|
|
|
48600
48661
|
stderr += d2;
|
|
48601
48662
|
if (stream) process.stderr.write(d2);
|
|
48602
48663
|
});
|
|
48603
|
-
proc.on("close", (code) =>
|
|
48664
|
+
proc.on("close", (code) => resolve38({ stdout, stderr, code: code ?? 0 }));
|
|
48604
48665
|
});
|
|
48605
48666
|
}
|
|
48606
48667
|
function runShellCommand(command2, options = {}) {
|
|
48607
48668
|
const stream = options.stream ?? false;
|
|
48608
48669
|
const { stream: _stream, ...spawnOptions } = options;
|
|
48609
|
-
return new Promise((
|
|
48670
|
+
return new Promise((resolve38) => {
|
|
48610
48671
|
const proc = (0, import_child_process.spawn)("bash", ["-lc", command2], {
|
|
48611
48672
|
...spawnOptions,
|
|
48612
48673
|
stdio: ["inherit", "pipe", "pipe"]
|
|
@@ -48621,7 +48682,7 @@ function runShellCommand(command2, options = {}) {
|
|
|
48621
48682
|
stderr += d2;
|
|
48622
48683
|
if (stream) process.stderr.write(d2);
|
|
48623
48684
|
});
|
|
48624
|
-
proc.on("close", (code) =>
|
|
48685
|
+
proc.on("close", (code) => resolve38({ stdout, stderr, code: code ?? 0 }));
|
|
48625
48686
|
});
|
|
48626
48687
|
}
|
|
48627
48688
|
|
|
@@ -49785,16 +49846,16 @@ async function promptScaffoldCursorRule(exists) {
|
|
|
49785
49846
|
}
|
|
49786
49847
|
async function askYesNo3(question) {
|
|
49787
49848
|
const rl = readline4.createInterface({ input: process.stdin, output: process.stderr });
|
|
49788
|
-
return new Promise((
|
|
49849
|
+
return new Promise((resolve38) => {
|
|
49789
49850
|
process.stderr.write(`${question} `);
|
|
49790
49851
|
rl.once("line", (answer) => {
|
|
49791
49852
|
rl.close();
|
|
49792
49853
|
const trimmed = answer.trim();
|
|
49793
49854
|
if (trimmed === "") {
|
|
49794
|
-
|
|
49855
|
+
resolve38(true);
|
|
49795
49856
|
return;
|
|
49796
49857
|
}
|
|
49797
|
-
|
|
49858
|
+
resolve38(/^y(es)?$/i.test(trimmed));
|
|
49798
49859
|
});
|
|
49799
49860
|
});
|
|
49800
49861
|
}
|
|
@@ -50104,19 +50165,19 @@ var LocalScriptExecutor = class {
|
|
|
50104
50165
|
var localScriptExecutor = new LocalScriptExecutor();
|
|
50105
50166
|
|
|
50106
50167
|
// src/core/control-sync.ts
|
|
50107
|
-
var
|
|
50168
|
+
var path41 = __toESM(require("path"));
|
|
50108
50169
|
init_control_config();
|
|
50109
50170
|
|
|
50110
50171
|
// src/core/control-registry.ts
|
|
50111
|
-
var
|
|
50112
|
-
var
|
|
50113
|
-
var
|
|
50172
|
+
var fs28 = __toESM(require("fs"));
|
|
50173
|
+
var os5 = __toESM(require("os"));
|
|
50174
|
+
var path27 = __toESM(require("path"));
|
|
50114
50175
|
|
|
50115
50176
|
// src/core/control-repo-path.ts
|
|
50116
|
-
var
|
|
50117
|
-
var
|
|
50177
|
+
var fs27 = __toESM(require("fs"));
|
|
50178
|
+
var path26 = __toESM(require("path"));
|
|
50118
50179
|
function tryGit(cwd, args) {
|
|
50119
|
-
if (!
|
|
50180
|
+
if (!fs27.existsSync(cwd)) return void 0;
|
|
50120
50181
|
const result = run(`git ${args}`, { cwd });
|
|
50121
50182
|
return result.code === 0 ? result.stdout.trim() : void 0;
|
|
50122
50183
|
}
|
|
@@ -50124,58 +50185,58 @@ function resolveMainWorkingTree(cwd) {
|
|
|
50124
50185
|
const toplevel = tryGit(cwd, "rev-parse --show-toplevel");
|
|
50125
50186
|
if (!toplevel) return void 0;
|
|
50126
50187
|
const commonDirRaw = tryGit(cwd, "rev-parse --git-common-dir");
|
|
50127
|
-
const commonDir = commonDirRaw ?
|
|
50128
|
-
if (!commonDir) return
|
|
50129
|
-
if (
|
|
50130
|
-
return
|
|
50188
|
+
const commonDir = commonDirRaw ? path26.resolve(cwd, commonDirRaw) : void 0;
|
|
50189
|
+
if (!commonDir) return path26.resolve(toplevel);
|
|
50190
|
+
if (path26.basename(commonDir) === ".git") {
|
|
50191
|
+
return path26.dirname(commonDir);
|
|
50131
50192
|
}
|
|
50132
50193
|
const porcelain = tryGit(cwd, "worktree list --porcelain");
|
|
50133
50194
|
if (porcelain) {
|
|
50134
50195
|
for (const line of porcelain.split("\n")) {
|
|
50135
50196
|
if (line.startsWith("worktree ")) {
|
|
50136
|
-
return
|
|
50197
|
+
return path26.resolve(line.slice("worktree ".length));
|
|
50137
50198
|
}
|
|
50138
50199
|
}
|
|
50139
50200
|
}
|
|
50140
|
-
return
|
|
50201
|
+
return path26.resolve(toplevel);
|
|
50141
50202
|
}
|
|
50142
50203
|
function canonicalizeControlRepoPath(repoPath) {
|
|
50143
|
-
const resolved =
|
|
50204
|
+
const resolved = path26.resolve(repoPath);
|
|
50144
50205
|
const toplevel = tryGit(resolved, "rev-parse --show-toplevel");
|
|
50145
50206
|
if (!toplevel) return resolved;
|
|
50146
50207
|
const mainRoot = resolveMainWorkingTree(resolved);
|
|
50147
50208
|
if (!mainRoot) return resolved;
|
|
50148
|
-
const top2 =
|
|
50149
|
-
const main =
|
|
50209
|
+
const top2 = path26.resolve(toplevel);
|
|
50210
|
+
const main = path26.resolve(mainRoot);
|
|
50150
50211
|
if (top2 === main) return resolved;
|
|
50151
|
-
const rel =
|
|
50212
|
+
const rel = path26.relative(top2, resolved);
|
|
50152
50213
|
if (!rel || rel === ".") return main;
|
|
50153
|
-
if (rel.startsWith(`..${
|
|
50214
|
+
if (rel.startsWith(`..${path26.sep}`) || rel === ".." || path26.isAbsolute(rel)) {
|
|
50154
50215
|
return resolved;
|
|
50155
50216
|
}
|
|
50156
|
-
return
|
|
50217
|
+
return path26.resolve(main, rel);
|
|
50157
50218
|
}
|
|
50158
50219
|
|
|
50159
50220
|
// src/core/control-registry.ts
|
|
50160
50221
|
function getRegistryPath() {
|
|
50161
50222
|
if (process.env.HAR_CONTROL_REGISTRY_PATH) {
|
|
50162
|
-
return
|
|
50223
|
+
return path27.resolve(process.env.HAR_CONTROL_REGISTRY_PATH);
|
|
50163
50224
|
}
|
|
50164
|
-
return
|
|
50225
|
+
return path27.join(os5.homedir(), ".har", "repos.json");
|
|
50165
50226
|
}
|
|
50166
50227
|
function readRegistry() {
|
|
50167
50228
|
const registryPath = getRegistryPath();
|
|
50168
50229
|
try {
|
|
50169
|
-
if (!
|
|
50170
|
-
return JSON.parse(
|
|
50230
|
+
if (!fs28.existsSync(registryPath)) return { repos: [] };
|
|
50231
|
+
return JSON.parse(fs28.readFileSync(registryPath, "utf8"));
|
|
50171
50232
|
} catch {
|
|
50172
50233
|
return { repos: [] };
|
|
50173
50234
|
}
|
|
50174
50235
|
}
|
|
50175
50236
|
function writeRegistry(registry2) {
|
|
50176
50237
|
const registryPath = getRegistryPath();
|
|
50177
|
-
|
|
50178
|
-
|
|
50238
|
+
fs28.mkdirSync(path27.dirname(registryPath), { recursive: true });
|
|
50239
|
+
fs28.writeFileSync(registryPath, JSON.stringify(registry2, null, 2) + "\n");
|
|
50179
50240
|
}
|
|
50180
50241
|
function registryChanged(before, after) {
|
|
50181
50242
|
if (before.length !== after.length) return true;
|
|
@@ -50197,7 +50258,7 @@ function removeRegisteredRepo(repoPath) {
|
|
|
50197
50258
|
try {
|
|
50198
50259
|
return canonicalizeControlRepoPath(entry) !== resolved;
|
|
50199
50260
|
} catch {
|
|
50200
|
-
return
|
|
50261
|
+
return path27.resolve(entry) !== resolved;
|
|
50201
50262
|
}
|
|
50202
50263
|
});
|
|
50203
50264
|
if (next.length === registry2.repos.length) return false;
|
|
@@ -50209,9 +50270,9 @@ function listRegisteredRepos() {
|
|
|
50209
50270
|
const kept = [];
|
|
50210
50271
|
const seen = /* @__PURE__ */ new Set();
|
|
50211
50272
|
for (const repoPath of registry2.repos) {
|
|
50212
|
-
if (!
|
|
50273
|
+
if (!fs28.existsSync(repoPath)) continue;
|
|
50213
50274
|
const canonical = canonicalizeControlRepoPath(repoPath);
|
|
50214
|
-
if (!
|
|
50275
|
+
if (!fs28.existsSync(canonical) || !readManifest(canonical)) continue;
|
|
50215
50276
|
if (seen.has(canonical)) continue;
|
|
50216
50277
|
seen.add(canonical);
|
|
50217
50278
|
kept.push(canonical);
|
|
@@ -50223,17 +50284,17 @@ function listRegisteredRepos() {
|
|
|
50223
50284
|
}
|
|
50224
50285
|
|
|
50225
50286
|
// src/core/slot-status.ts
|
|
50226
|
-
var
|
|
50227
|
-
var
|
|
50228
|
-
var
|
|
50287
|
+
var fs33 = __toESM(require("fs"));
|
|
50288
|
+
var os8 = __toESM(require("os"));
|
|
50289
|
+
var path33 = __toESM(require("path"));
|
|
50229
50290
|
var import_child_process7 = require("child_process");
|
|
50230
50291
|
|
|
50231
50292
|
// src/core/runs.ts
|
|
50232
50293
|
var crypto2 = __toESM(require("crypto"));
|
|
50233
50294
|
var import_child_process2 = require("child_process");
|
|
50234
|
-
var
|
|
50235
|
-
var
|
|
50236
|
-
var
|
|
50295
|
+
var fs29 = __toESM(require("fs"));
|
|
50296
|
+
var os6 = __toESM(require("os"));
|
|
50297
|
+
var path28 = __toESM(require("path"));
|
|
50237
50298
|
var RUNS_DIR = "runs";
|
|
50238
50299
|
function gitCommonDir(cwd) {
|
|
50239
50300
|
try {
|
|
@@ -50242,7 +50303,7 @@ function gitCommonDir(cwd) {
|
|
|
50242
50303
|
encoding: "utf8",
|
|
50243
50304
|
stdio: ["pipe", "pipe", "ignore"]
|
|
50244
50305
|
}).trim();
|
|
50245
|
-
return out ?
|
|
50306
|
+
return out ? path28.resolve(cwd, out) : void 0;
|
|
50246
50307
|
} catch {
|
|
50247
50308
|
return void 0;
|
|
50248
50309
|
}
|
|
@@ -50264,7 +50325,7 @@ function gitPrefix(cwd) {
|
|
|
50264
50325
|
}
|
|
50265
50326
|
}
|
|
50266
50327
|
function getRunsDir(harnessRoot) {
|
|
50267
|
-
return
|
|
50328
|
+
return path28.join(getHarnessDir(harnessRoot), RUNS_DIR);
|
|
50268
50329
|
}
|
|
50269
50330
|
function formatLocalDate(d2) {
|
|
50270
50331
|
const y2 = d2.getFullYear();
|
|
@@ -50284,24 +50345,24 @@ function buildRunRelativePath(stageId, agentId, startedAt, runId, runsDir) {
|
|
|
50284
50345
|
const timePart = formatLocalTime(started);
|
|
50285
50346
|
const agentPart = agentId !== void 0 ? `_agent-${agentId}` : "";
|
|
50286
50347
|
let filename = `${timePart}_${stageId}${agentPart}.json`;
|
|
50287
|
-
const fullPath =
|
|
50288
|
-
if (
|
|
50348
|
+
const fullPath = path28.join(runsDir, dateFolder, filename);
|
|
50349
|
+
if (fs29.existsSync(fullPath)) {
|
|
50289
50350
|
filename = `${timePart}_${stageId}${agentPart}-${runId.slice(0, 8)}.json`;
|
|
50290
50351
|
}
|
|
50291
|
-
return
|
|
50352
|
+
return path28.join(dateFolder, filename);
|
|
50292
50353
|
}
|
|
50293
50354
|
function resolveRunFilePath(harnessRoot, run2) {
|
|
50294
50355
|
if (run2.relativePath) {
|
|
50295
|
-
return
|
|
50356
|
+
return path28.join(getRunsDir(harnessRoot), run2.relativePath);
|
|
50296
50357
|
}
|
|
50297
|
-
return
|
|
50358
|
+
return path28.join(getRunsDir(harnessRoot), `${run2.runId}.json`);
|
|
50298
50359
|
}
|
|
50299
50360
|
function collectRunFiles(runsDir) {
|
|
50300
|
-
if (!
|
|
50361
|
+
if (!fs29.existsSync(runsDir)) return [];
|
|
50301
50362
|
const files = [];
|
|
50302
50363
|
const walk = (dir) => {
|
|
50303
|
-
for (const entry of
|
|
50304
|
-
const full =
|
|
50364
|
+
for (const entry of fs29.readdirSync(dir, { withFileTypes: true })) {
|
|
50365
|
+
const full = path28.join(dir, entry.name);
|
|
50305
50366
|
if (entry.isDirectory()) {
|
|
50306
50367
|
walk(full);
|
|
50307
50368
|
} else if (entry.name.endsWith(".json")) {
|
|
@@ -50315,30 +50376,30 @@ function collectRunFiles(runsDir) {
|
|
|
50315
50376
|
function resolveAgentWorkDir(harnessRoot, agentId) {
|
|
50316
50377
|
if (agentId === void 0) return void 0;
|
|
50317
50378
|
const entry = readSlotRegistry(harnessRoot, agentId);
|
|
50318
|
-
if (entry?.workDir &&
|
|
50379
|
+
if (entry?.workDir && fs29.existsSync(entry.workDir)) return entry.workDir;
|
|
50319
50380
|
const env3 = readHarnessEnv(harnessRoot);
|
|
50320
|
-
const projectName = env3.HARNESS_PROJECT_NAME ??
|
|
50321
|
-
const worktreeDir =
|
|
50381
|
+
const projectName = env3.HARNESS_PROJECT_NAME ?? path28.basename(harnessRoot);
|
|
50382
|
+
const worktreeDir = path28.join(os6.homedir(), "worktrees", `${projectName}-agent-${agentId}`);
|
|
50322
50383
|
const relPrefix = gitPrefix(harnessRoot);
|
|
50323
50384
|
const sessionEnvFiles = [];
|
|
50324
|
-
const worktreesRoot =
|
|
50325
|
-
if (
|
|
50385
|
+
const worktreesRoot = path28.join(os6.homedir(), "worktrees");
|
|
50386
|
+
if (fs29.existsSync(worktreesRoot)) {
|
|
50326
50387
|
const suffix = `-har-agent-${agentId}-`;
|
|
50327
|
-
for (const entry2 of
|
|
50388
|
+
for (const entry2 of fs29.readdirSync(worktreesRoot, { withFileTypes: true })) {
|
|
50328
50389
|
if (!entry2.isDirectory() || !entry2.name.includes(suffix)) continue;
|
|
50329
|
-
const sessionDir =
|
|
50390
|
+
const sessionDir = path28.join(worktreesRoot, entry2.name);
|
|
50330
50391
|
if (!sameGitCheckout(harnessRoot, sessionDir)) continue;
|
|
50331
|
-
sessionEnvFiles.push(
|
|
50392
|
+
sessionEnvFiles.push(path28.join(sessionDir, relPrefix, `.env.agent.${agentId}`));
|
|
50332
50393
|
}
|
|
50333
50394
|
}
|
|
50334
50395
|
const candidates = [
|
|
50335
|
-
|
|
50336
|
-
|
|
50396
|
+
path28.join(worktreeDir, `.env.agent.${agentId}`),
|
|
50397
|
+
path28.join(harnessRoot, `.env.agent.${agentId}`),
|
|
50337
50398
|
...sessionEnvFiles.sort()
|
|
50338
50399
|
];
|
|
50339
50400
|
for (const envFile of candidates) {
|
|
50340
|
-
if (!
|
|
50341
|
-
const content =
|
|
50401
|
+
if (!fs29.existsSync(envFile)) continue;
|
|
50402
|
+
const content = fs29.readFileSync(envFile, "utf8");
|
|
50342
50403
|
const match = content.match(/^REPO_ROOT=(.+)$/m);
|
|
50343
50404
|
if (match) return match[1].trim();
|
|
50344
50405
|
}
|
|
@@ -50350,11 +50411,11 @@ function createRun(ctx, meta) {
|
|
|
50350
50411
|
const startedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
50351
50412
|
const runId = crypto2.randomUUID();
|
|
50352
50413
|
const relativePath = buildRunRelativePath(meta.stageId, meta.agentId, startedAt, runId, runsDir);
|
|
50353
|
-
const runFilePath =
|
|
50354
|
-
|
|
50414
|
+
const runFilePath = path28.join(runsDir, relativePath);
|
|
50415
|
+
fs29.mkdirSync(path28.dirname(runFilePath), { recursive: true });
|
|
50355
50416
|
const run2 = RunRecordSchema.parse({
|
|
50356
50417
|
runId,
|
|
50357
|
-
repoPath:
|
|
50418
|
+
repoPath: path28.resolve(ctx.repoPath),
|
|
50358
50419
|
harnessRoot,
|
|
50359
50420
|
stageId: meta.stageId,
|
|
50360
50421
|
kind: meta.kind,
|
|
@@ -50367,7 +50428,7 @@ function createRun(ctx, meta) {
|
|
|
50367
50428
|
workUnitId: ctx.workUnitId,
|
|
50368
50429
|
attemptId: ctx.attemptId
|
|
50369
50430
|
});
|
|
50370
|
-
|
|
50431
|
+
fs29.writeFileSync(runFilePath, JSON.stringify(run2, null, 2) + "\n");
|
|
50371
50432
|
return run2;
|
|
50372
50433
|
}
|
|
50373
50434
|
function finishRun(repoPath, runId, update) {
|
|
@@ -50386,13 +50447,13 @@ function finishRun(repoPath, runId, update) {
|
|
|
50386
50447
|
finishedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
50387
50448
|
});
|
|
50388
50449
|
const runPath = resolveRunFilePath(harnessRoot, finished);
|
|
50389
|
-
|
|
50450
|
+
fs29.writeFileSync(runPath, JSON.stringify(finished, null, 2) + "\n");
|
|
50390
50451
|
return finished;
|
|
50391
50452
|
}
|
|
50392
50453
|
function findRunRecord(harnessRoot, runId) {
|
|
50393
50454
|
const runsDir = getRunsDir(harnessRoot);
|
|
50394
50455
|
for (const filePath of collectRunFiles(runsDir)) {
|
|
50395
|
-
const parsed = RunRecordSchema.safeParse(JSON.parse(
|
|
50456
|
+
const parsed = RunRecordSchema.safeParse(JSON.parse(fs29.readFileSync(filePath, "utf8")));
|
|
50396
50457
|
if (parsed.success && parsed.data.runId === runId) {
|
|
50397
50458
|
return parsed.data;
|
|
50398
50459
|
}
|
|
@@ -50404,10 +50465,10 @@ function getRun(repoPath, runId) {
|
|
|
50404
50465
|
}
|
|
50405
50466
|
function listRuns(repoPath, filter2 = {}) {
|
|
50406
50467
|
const runsDir = getRunsDir(resolveHarnessRoot(repoPath));
|
|
50407
|
-
if (!
|
|
50468
|
+
if (!fs29.existsSync(runsDir)) return [];
|
|
50408
50469
|
const runs = [];
|
|
50409
50470
|
for (const filePath of collectRunFiles(runsDir)) {
|
|
50410
|
-
const parsed = RunRecordSchema.safeParse(JSON.parse(
|
|
50471
|
+
const parsed = RunRecordSchema.safeParse(JSON.parse(fs29.readFileSync(filePath, "utf8")));
|
|
50411
50472
|
if (!parsed.success) continue;
|
|
50412
50473
|
if (filter2.stageId && parsed.data.stageId !== filter2.stageId) continue;
|
|
50413
50474
|
runs.push(parsed.data);
|
|
@@ -50420,18 +50481,18 @@ function listRuns(repoPath, filter2 = {}) {
|
|
|
50420
50481
|
}
|
|
50421
50482
|
|
|
50422
50483
|
// src/core/slot-preflight.ts
|
|
50423
|
-
var
|
|
50484
|
+
var path32 = __toESM(require("path"));
|
|
50424
50485
|
|
|
50425
50486
|
// src/core/control-port.ts
|
|
50426
50487
|
var import_child_process4 = require("child_process");
|
|
50427
|
-
var
|
|
50428
|
-
var
|
|
50488
|
+
var fs31 = __toESM(require("fs"));
|
|
50489
|
+
var path30 = __toESM(require("path"));
|
|
50429
50490
|
init_control_config();
|
|
50430
50491
|
|
|
50431
50492
|
// src/core/slot-ports.ts
|
|
50432
50493
|
var import_child_process3 = require("child_process");
|
|
50433
|
-
var
|
|
50434
|
-
var
|
|
50494
|
+
var fs30 = __toESM(require("fs"));
|
|
50495
|
+
var path29 = __toESM(require("path"));
|
|
50435
50496
|
function portStep(env3) {
|
|
50436
50497
|
return Number(env3.HARNESS_PORT_STEP ?? 10);
|
|
50437
50498
|
}
|
|
@@ -50487,7 +50548,7 @@ function allocateAppPorts(repoPath, agentId) {
|
|
|
50487
50548
|
}
|
|
50488
50549
|
function harnessUsesPm2(repoPath) {
|
|
50489
50550
|
const harnessRoot = resolveHarnessRoot(repoPath);
|
|
50490
|
-
return
|
|
50551
|
+
return fs30.existsSync(path29.join(harnessRoot, ".har", "ecosystem.agent.template.cjs"));
|
|
50491
50552
|
}
|
|
50492
50553
|
|
|
50493
50554
|
// src/core/control-port.ts
|
|
@@ -50542,13 +50603,13 @@ function controlDefaultPortWarnings(containers, defaultFrontendPort, allocatedFr
|
|
|
50542
50603
|
return [formatControlDefaultPortWarning(control.name, defaultFrontendPort, allocatedFrontend)];
|
|
50543
50604
|
}
|
|
50544
50605
|
function inspectControlUpReadiness(repoPath) {
|
|
50545
|
-
const resolved =
|
|
50606
|
+
const resolved = path30.resolve(repoPath);
|
|
50546
50607
|
const port = parseControlHostPort();
|
|
50547
50608
|
const containers = listDockerContainers();
|
|
50548
50609
|
const control = controlContainerOnPort(containers, port);
|
|
50549
50610
|
const warnings = [];
|
|
50550
|
-
const controlHarnessDir =
|
|
50551
|
-
const harnessSlot1Active =
|
|
50611
|
+
const controlHarnessDir = path30.join(resolved, "control", ".har");
|
|
50612
|
+
const harnessSlot1Active = fs31.existsSync(controlHarnessDir) && readSlotRegistry(path30.join(resolved, "control"), 1)?.status === "active";
|
|
50552
50613
|
if (control) {
|
|
50553
50614
|
return {
|
|
50554
50615
|
warnings,
|
|
@@ -50579,9 +50640,9 @@ function inspectControlUpReadiness(repoPath) {
|
|
|
50579
50640
|
}
|
|
50580
50641
|
|
|
50581
50642
|
// src/core/slot-launch-guard-occupied.ts
|
|
50582
|
-
var
|
|
50583
|
-
var
|
|
50584
|
-
var
|
|
50643
|
+
var fs32 = __toESM(require("fs"));
|
|
50644
|
+
var os7 = __toESM(require("os"));
|
|
50645
|
+
var path31 = __toESM(require("path"));
|
|
50585
50646
|
var import_child_process5 = require("child_process");
|
|
50586
50647
|
function runGit(cwd, args) {
|
|
50587
50648
|
try {
|
|
@@ -50600,7 +50661,7 @@ function worktreeDirty(worktreePath) {
|
|
|
50600
50661
|
}
|
|
50601
50662
|
function gitCommonDir2(cwd) {
|
|
50602
50663
|
const out = runGit(cwd, "rev-parse --git-common-dir");
|
|
50603
|
-
return out ?
|
|
50664
|
+
return out ? path31.resolve(cwd, out) : void 0;
|
|
50604
50665
|
}
|
|
50605
50666
|
function sameGitCheckout2(a2, b2) {
|
|
50606
50667
|
const left2 = gitCommonDir2(a2);
|
|
@@ -50609,20 +50670,20 @@ function sameGitCheckout2(a2, b2) {
|
|
|
50609
50670
|
}
|
|
50610
50671
|
function discoverWorktree(harnessRoot, agentId, projectName) {
|
|
50611
50672
|
const session = readSlotRegistry(harnessRoot, agentId);
|
|
50612
|
-
if (session?.worktreePath &&
|
|
50673
|
+
if (session?.worktreePath && fs32.existsSync(session.worktreePath)) {
|
|
50613
50674
|
return session.worktreePath;
|
|
50614
50675
|
}
|
|
50615
|
-
const legacy =
|
|
50616
|
-
if (
|
|
50617
|
-
const worktreesRoot =
|
|
50618
|
-
if (!
|
|
50676
|
+
const legacy = path31.join(os7.homedir(), "worktrees", `${projectName}-agent-${agentId}`);
|
|
50677
|
+
if (fs32.existsSync(legacy) && sameGitCheckout2(harnessRoot, legacy)) return legacy;
|
|
50678
|
+
const worktreesRoot = path31.join(os7.homedir(), "worktrees");
|
|
50679
|
+
if (!fs32.existsSync(worktreesRoot)) return void 0;
|
|
50619
50680
|
const suffix = `-har-agent-${agentId}-`;
|
|
50620
50681
|
const relPrefix = runGit(harnessRoot, "rev-parse --show-prefix") ?? "";
|
|
50621
|
-
for (const name of
|
|
50682
|
+
for (const name of fs32.readdirSync(worktreesRoot)) {
|
|
50622
50683
|
if (!name.includes(suffix)) continue;
|
|
50623
|
-
const candidate =
|
|
50684
|
+
const candidate = path31.join(worktreesRoot, name);
|
|
50624
50685
|
if (!sameGitCheckout2(harnessRoot, candidate)) continue;
|
|
50625
|
-
if (!
|
|
50686
|
+
if (!fs32.existsSync(path31.join(candidate, relPrefix, `.env.agent.${agentId}`))) continue;
|
|
50626
50687
|
return candidate;
|
|
50627
50688
|
}
|
|
50628
50689
|
return void 0;
|
|
@@ -50630,13 +50691,13 @@ function discoverWorktree(harnessRoot, agentId, projectName) {
|
|
|
50630
50691
|
function collectOccupiedSlot(repoPath, agentId) {
|
|
50631
50692
|
const harnessRoot = resolveHarnessRoot(repoPath);
|
|
50632
50693
|
const env3 = readHarnessEnv(harnessRoot);
|
|
50633
|
-
const projectName = env3.HARNESS_PROJECT_NAME ??
|
|
50694
|
+
const projectName = env3.HARNESS_PROJECT_NAME ?? path31.basename(harnessRoot);
|
|
50634
50695
|
const session = readSlotRegistry(harnessRoot, agentId);
|
|
50635
50696
|
const worktreePath = discoverWorktree(harnessRoot, agentId, projectName);
|
|
50636
50697
|
const workDir = session?.workDir;
|
|
50637
|
-
const envInWorkDir = workDir ?
|
|
50638
|
-
const envInRoot =
|
|
50639
|
-
const envInWorktree = worktreePath ?
|
|
50698
|
+
const envInWorkDir = workDir ? fs32.existsSync(path31.join(workDir, `.env.agent.${agentId}`)) : false;
|
|
50699
|
+
const envInRoot = fs32.existsSync(path31.join(harnessRoot, `.env.agent.${agentId}`));
|
|
50700
|
+
const envInWorktree = worktreePath ? fs32.existsSync(path31.join(worktreePath, `.env.agent.${agentId}`)) : false;
|
|
50640
50701
|
const active = session !== void 0 && session.status !== "completed" || envInWorkDir || envInRoot || envInWorktree;
|
|
50641
50702
|
if (!active) return void 0;
|
|
50642
50703
|
const dirty = worktreePath ? worktreeDirty(worktreePath) : void 0;
|
|
@@ -50802,7 +50863,7 @@ function checkInfraPort(env3, varName, defaultPort, scanStart, scanEnd) {
|
|
|
50802
50863
|
function inspectSlotReadiness(repoPath, agentId, options = {}) {
|
|
50803
50864
|
const harnessRoot = resolveHarnessRoot(repoPath);
|
|
50804
50865
|
const env3 = readHarnessEnv(harnessRoot);
|
|
50805
|
-
const projectName = env3.HARNESS_PROJECT_NAME ??
|
|
50866
|
+
const projectName = env3.HARNESS_PROJECT_NAME ?? path32.basename(harnessRoot);
|
|
50806
50867
|
const usesPm2 = harnessUsesPm2(repoPath);
|
|
50807
50868
|
const blockers = [];
|
|
50808
50869
|
const remediations = [];
|
|
@@ -51004,7 +51065,7 @@ function readWorktreeBranch(worktreePath) {
|
|
|
51004
51065
|
}
|
|
51005
51066
|
function gitCommonDir3(cwd) {
|
|
51006
51067
|
const out = runGit2(cwd, "rev-parse --git-common-dir");
|
|
51007
|
-
return out ?
|
|
51068
|
+
return out ? path33.resolve(cwd, out) : void 0;
|
|
51008
51069
|
}
|
|
51009
51070
|
function sameGitCheckout3(a2, b2) {
|
|
51010
51071
|
const left2 = gitCommonDir3(a2);
|
|
@@ -51016,12 +51077,12 @@ function gitPrefix2(cwd) {
|
|
|
51016
51077
|
return out ?? "";
|
|
51017
51078
|
}
|
|
51018
51079
|
function discoverSessionWorktreePath(harnessRoot, agentId) {
|
|
51019
|
-
const worktreesRoot =
|
|
51020
|
-
if (!
|
|
51080
|
+
const worktreesRoot = path33.join(os8.homedir(), "worktrees");
|
|
51081
|
+
if (!fs33.existsSync(worktreesRoot)) return void 0;
|
|
51021
51082
|
const suffix = `-har-agent-${agentId}-`;
|
|
51022
51083
|
const relPrefix = gitPrefix2(harnessRoot);
|
|
51023
|
-
const matches =
|
|
51024
|
-
(candidate) => sameGitCheckout3(harnessRoot, candidate) &&
|
|
51084
|
+
const matches = fs33.readdirSync(worktreesRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory() && entry.name.includes(suffix)).map((entry) => path33.join(worktreesRoot, entry.name)).filter(
|
|
51085
|
+
(candidate) => sameGitCheckout3(harnessRoot, candidate) && fs33.existsSync(path33.join(candidate, relPrefix, `.env.agent.${agentId}`))
|
|
51025
51086
|
);
|
|
51026
51087
|
return matches.sort()[0];
|
|
51027
51088
|
}
|
|
@@ -51096,18 +51157,18 @@ function detectPm2Issue(projectName, agentId, session, procs) {
|
|
|
51096
51157
|
}
|
|
51097
51158
|
function collectSlotStatus(harnessRoot, agentId, runs, pm2Procs) {
|
|
51098
51159
|
const env3 = readHarnessEnv(harnessRoot);
|
|
51099
|
-
const projectName = env3.HARNESS_PROJECT_NAME ??
|
|
51160
|
+
const projectName = env3.HARNESS_PROJECT_NAME ?? path33.basename(harnessRoot);
|
|
51100
51161
|
const session = readSlotRegistry(harnessRoot, agentId);
|
|
51101
|
-
const legacyWorktreePath =
|
|
51102
|
-
|
|
51162
|
+
const legacyWorktreePath = path33.join(
|
|
51163
|
+
os8.homedir(),
|
|
51103
51164
|
"worktrees",
|
|
51104
51165
|
`${projectName}-agent-${agentId}`
|
|
51105
51166
|
);
|
|
51106
|
-
const worktreePath = session?.worktreePath &&
|
|
51167
|
+
const worktreePath = session?.worktreePath && fs33.existsSync(session.worktreePath) ? session.worktreePath : fs33.existsSync(legacyWorktreePath) ? legacyWorktreePath : discoverSessionWorktreePath(harnessRoot, agentId);
|
|
51107
51168
|
const workDir = resolveAgentWorkDir(harnessRoot, agentId);
|
|
51108
|
-
const envInWorkDir = workDir ?
|
|
51109
|
-
const envInRoot =
|
|
51110
|
-
const envInWorktree = worktreePath ?
|
|
51169
|
+
const envInWorkDir = workDir ? fs33.existsSync(path33.join(workDir, `.env.agent.${agentId}`)) : false;
|
|
51170
|
+
const envInRoot = fs33.existsSync(path33.join(harnessRoot, `.env.agent.${agentId}`));
|
|
51171
|
+
const envInWorktree = worktreePath ? fs33.existsSync(path33.join(worktreePath, `.env.agent.${agentId}`)) : false;
|
|
51111
51172
|
const active = session !== void 0 && session.status !== "completed" || envInWorkDir || envInRoot || envInWorktree;
|
|
51112
51173
|
const latest = latestRunForAgent(runs, agentId);
|
|
51113
51174
|
const verifyRun = runs.find((r2) => r2.agentId === agentId && r2.stageId === "verify");
|
|
@@ -51161,7 +51222,7 @@ function collectEnvironmentStatus(repoPath) {
|
|
|
51161
51222
|
const slotIds = getAgentSlotIds(harnessRoot);
|
|
51162
51223
|
const pm2Procs = listPm2Processes2();
|
|
51163
51224
|
return {
|
|
51164
|
-
repoPath:
|
|
51225
|
+
repoPath: path33.resolve(repoPath),
|
|
51165
51226
|
harnessRoot,
|
|
51166
51227
|
gitRemote: readGitRemote(harnessRoot),
|
|
51167
51228
|
profile: manifest?.profile,
|
|
@@ -51172,13 +51233,13 @@ function collectEnvironmentStatus(repoPath) {
|
|
|
51172
51233
|
|
|
51173
51234
|
// src/core/validations.ts
|
|
51174
51235
|
var crypto3 = __toESM(require("crypto"));
|
|
51175
|
-
var
|
|
51176
|
-
var
|
|
51236
|
+
var fs35 = __toESM(require("fs"));
|
|
51237
|
+
var path35 = __toESM(require("path"));
|
|
51177
51238
|
|
|
51178
51239
|
// src/core/change-batch.ts
|
|
51179
|
-
var
|
|
51180
|
-
var
|
|
51181
|
-
var
|
|
51240
|
+
var fs34 = __toESM(require("fs"));
|
|
51241
|
+
var os9 = __toESM(require("os"));
|
|
51242
|
+
var path34 = __toESM(require("path"));
|
|
51182
51243
|
function git(checkoutDir, args, env3) {
|
|
51183
51244
|
const result = run(`git ${args}`, { cwd: checkoutDir, env: env3 });
|
|
51184
51245
|
if (result.code !== 0) {
|
|
@@ -51194,7 +51255,7 @@ function isCheckoutRoot(checkoutDir) {
|
|
|
51194
51255
|
const toplevel = tryGit2(checkoutDir, "rev-parse --show-toplevel");
|
|
51195
51256
|
if (!toplevel) return false;
|
|
51196
51257
|
try {
|
|
51197
|
-
return
|
|
51258
|
+
return fs34.realpathSync(toplevel) === fs34.realpathSync(checkoutDir);
|
|
51198
51259
|
} catch {
|
|
51199
51260
|
return false;
|
|
51200
51261
|
}
|
|
@@ -51216,7 +51277,7 @@ function isMergeOrRebaseInProgress(checkoutDir) {
|
|
|
51216
51277
|
if (tryGit2(checkoutDir, "rev-parse -q --verify MERGE_HEAD") !== void 0) return true;
|
|
51217
51278
|
for (const dir of ["rebase-merge", "rebase-apply"]) {
|
|
51218
51279
|
const gitPath = tryGit2(checkoutDir, `rev-parse --git-path ${dir}`);
|
|
51219
|
-
if (gitPath &&
|
|
51280
|
+
if (gitPath && fs34.existsSync(path34.resolve(checkoutDir, gitPath))) return true;
|
|
51220
51281
|
}
|
|
51221
51282
|
return false;
|
|
51222
51283
|
}
|
|
@@ -51239,8 +51300,8 @@ function parseNameStatus(output) {
|
|
|
51239
51300
|
return files;
|
|
51240
51301
|
}
|
|
51241
51302
|
function computeWorktreeSnapshot(checkoutDir) {
|
|
51242
|
-
const tmpDir =
|
|
51243
|
-
const tmpIndex =
|
|
51303
|
+
const tmpDir = fs34.mkdtempSync(path34.join(os9.tmpdir(), "har-idx-"));
|
|
51304
|
+
const tmpIndex = path34.join(tmpDir, "index");
|
|
51244
51305
|
const env3 = { GIT_INDEX_FILE: tmpIndex };
|
|
51245
51306
|
try {
|
|
51246
51307
|
const headTree = getHeadTree(checkoutDir);
|
|
@@ -51263,35 +51324,35 @@ function computeWorktreeSnapshot(checkoutDir) {
|
|
|
51263
51324
|
changedFiles: parseNameStatus(diffOutput)
|
|
51264
51325
|
};
|
|
51265
51326
|
} finally {
|
|
51266
|
-
|
|
51327
|
+
fs34.rmSync(tmpDir, { recursive: true, force: true });
|
|
51267
51328
|
}
|
|
51268
51329
|
}
|
|
51269
51330
|
|
|
51270
51331
|
// src/core/validations.ts
|
|
51271
51332
|
var VALIDATIONS_DIR = "validations";
|
|
51272
51333
|
function getValidationsDir(checkoutDir) {
|
|
51273
|
-
return
|
|
51334
|
+
return path35.join(checkoutDir, ".har", VALIDATIONS_DIR);
|
|
51274
51335
|
}
|
|
51275
51336
|
function validationPath(checkoutDir, treeHash) {
|
|
51276
|
-
return
|
|
51337
|
+
return path35.join(getValidationsDir(checkoutDir), `${treeHash}.json`);
|
|
51277
51338
|
}
|
|
51278
51339
|
function writeRecord(checkoutDir, record2) {
|
|
51279
51340
|
const dir = getValidationsDir(checkoutDir);
|
|
51280
|
-
|
|
51281
|
-
|
|
51341
|
+
fs35.mkdirSync(dir, { recursive: true });
|
|
51342
|
+
fs35.writeFileSync(
|
|
51282
51343
|
validationPath(checkoutDir, record2.treeHash),
|
|
51283
51344
|
`${JSON.stringify(record2, null, 2)}
|
|
51284
51345
|
`
|
|
51285
51346
|
);
|
|
51286
51347
|
}
|
|
51287
51348
|
function ensureValidationsIgnored(checkoutDir) {
|
|
51288
|
-
const harDir =
|
|
51289
|
-
if (!
|
|
51290
|
-
const gitignorePath =
|
|
51291
|
-
const content =
|
|
51349
|
+
const harDir = path35.join(checkoutDir, ".har");
|
|
51350
|
+
if (!fs35.existsSync(harDir)) return;
|
|
51351
|
+
const gitignorePath = path35.join(harDir, ".gitignore");
|
|
51352
|
+
const content = fs35.existsSync(gitignorePath) ? fs35.readFileSync(gitignorePath, "utf8") : "";
|
|
51292
51353
|
if (content.split("\n").some((line) => line.trim() === `${VALIDATIONS_DIR}/`)) return;
|
|
51293
51354
|
const suffix = content.length === 0 || content.endsWith("\n") ? "" : "\n";
|
|
51294
|
-
|
|
51355
|
+
fs35.writeFileSync(gitignorePath, `${content}${suffix}${VALIDATIONS_DIR}/
|
|
51295
51356
|
`);
|
|
51296
51357
|
}
|
|
51297
51358
|
function recordValidation(input) {
|
|
@@ -51308,8 +51369,8 @@ function recordValidation(input) {
|
|
|
51308
51369
|
treeHash: snapshot.treeHash,
|
|
51309
51370
|
headSha: snapshot.headSha,
|
|
51310
51371
|
branch: snapshot.branch,
|
|
51311
|
-
workDir:
|
|
51312
|
-
harnessRoot:
|
|
51372
|
+
workDir: path35.resolve(input.checkoutDir),
|
|
51373
|
+
harnessRoot: path35.resolve(input.harnessRoot),
|
|
51313
51374
|
agentId: input.agentId,
|
|
51314
51375
|
status: input.status,
|
|
51315
51376
|
full: input.full,
|
|
@@ -51321,16 +51382,16 @@ function recordValidation(input) {
|
|
|
51321
51382
|
committedAt: existing?.committedAt
|
|
51322
51383
|
});
|
|
51323
51384
|
writeRecord(input.checkoutDir, record2);
|
|
51324
|
-
if (
|
|
51385
|
+
if (path35.resolve(input.harnessRoot) !== path35.resolve(input.checkoutDir)) {
|
|
51325
51386
|
writeRecord(input.harnessRoot, record2);
|
|
51326
51387
|
}
|
|
51327
51388
|
return record2;
|
|
51328
51389
|
}
|
|
51329
51390
|
function findValidation(checkoutDir, treeHash) {
|
|
51330
51391
|
const file = validationPath(checkoutDir, treeHash);
|
|
51331
|
-
if (!
|
|
51392
|
+
if (!fs35.existsSync(file)) return void 0;
|
|
51332
51393
|
try {
|
|
51333
|
-
return ValidationRecordSchema.parse(JSON.parse(
|
|
51394
|
+
return ValidationRecordSchema.parse(JSON.parse(fs35.readFileSync(file, "utf8")));
|
|
51334
51395
|
} catch {
|
|
51335
51396
|
return void 0;
|
|
51336
51397
|
}
|
|
@@ -51345,19 +51406,19 @@ function attachCommit(checkoutDir, treeHash, commitSha) {
|
|
|
51345
51406
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
51346
51407
|
};
|
|
51347
51408
|
writeRecord(checkoutDir, updated);
|
|
51348
|
-
if (record2.harnessRoot &&
|
|
51409
|
+
if (record2.harnessRoot && path35.resolve(record2.harnessRoot) !== path35.resolve(checkoutDir) && fs35.existsSync(path35.join(record2.harnessRoot, ".har"))) {
|
|
51349
51410
|
writeRecord(record2.harnessRoot, updated);
|
|
51350
51411
|
}
|
|
51351
51412
|
return updated;
|
|
51352
51413
|
}
|
|
51353
51414
|
function listValidations(harnessRoot) {
|
|
51354
51415
|
const dir = getValidationsDir(harnessRoot);
|
|
51355
|
-
if (!
|
|
51416
|
+
if (!fs35.existsSync(dir)) return [];
|
|
51356
51417
|
const records = [];
|
|
51357
|
-
for (const entry of
|
|
51418
|
+
for (const entry of fs35.readdirSync(dir)) {
|
|
51358
51419
|
if (!entry.endsWith(".json")) continue;
|
|
51359
51420
|
try {
|
|
51360
|
-
records.push(ValidationRecordSchema.parse(JSON.parse(
|
|
51421
|
+
records.push(ValidationRecordSchema.parse(JSON.parse(fs35.readFileSync(path35.join(dir, entry), "utf8"))));
|
|
51361
51422
|
} catch {
|
|
51362
51423
|
}
|
|
51363
51424
|
}
|
|
@@ -51366,46 +51427,46 @@ function listValidations(harnessRoot) {
|
|
|
51366
51427
|
|
|
51367
51428
|
// src/core/work-units.ts
|
|
51368
51429
|
var crypto4 = __toESM(require("crypto"));
|
|
51369
|
-
var
|
|
51370
|
-
var
|
|
51430
|
+
var fs36 = __toESM(require("fs"));
|
|
51431
|
+
var path36 = __toESM(require("path"));
|
|
51371
51432
|
var WORK_UNITS_DIR = "work-units";
|
|
51372
51433
|
var WORK_ATTEMPTS_DIR = "work-attempts";
|
|
51373
51434
|
var VALIDATION_BINDINGS_DIR = "validation-bindings";
|
|
51374
51435
|
var EVIDENCE_DIRS = [WORK_UNITS_DIR, WORK_ATTEMPTS_DIR, VALIDATION_BINDINGS_DIR];
|
|
51375
51436
|
function harEvidenceDir(harnessRoot, name) {
|
|
51376
|
-
return
|
|
51437
|
+
return path36.join(harnessRoot, ".har", name);
|
|
51377
51438
|
}
|
|
51378
51439
|
function hashedRecordPath(harnessRoot, dir, id) {
|
|
51379
51440
|
const digest = crypto4.createHash("sha256").update(id).digest("hex");
|
|
51380
|
-
return
|
|
51441
|
+
return path36.join(harEvidenceDir(harnessRoot, dir), `${digest}.json`);
|
|
51381
51442
|
}
|
|
51382
51443
|
function writeRecord2(file, value) {
|
|
51383
|
-
|
|
51444
|
+
fs36.mkdirSync(path36.dirname(file), { recursive: true });
|
|
51384
51445
|
const temp = `${file}.${process.pid}.tmp`;
|
|
51385
|
-
|
|
51446
|
+
fs36.writeFileSync(temp, `${JSON.stringify(value, null, 2)}
|
|
51386
51447
|
`);
|
|
51387
|
-
|
|
51448
|
+
fs36.renameSync(temp, file);
|
|
51388
51449
|
}
|
|
51389
51450
|
function ensureWorkEvidenceIgnored(harnessRoot) {
|
|
51390
|
-
const harDir =
|
|
51391
|
-
if (!
|
|
51392
|
-
const gitignorePath =
|
|
51393
|
-
const content =
|
|
51451
|
+
const harDir = path36.join(harnessRoot, ".har");
|
|
51452
|
+
if (!fs36.existsSync(harDir)) return;
|
|
51453
|
+
const gitignorePath = path36.join(harDir, ".gitignore");
|
|
51454
|
+
const content = fs36.existsSync(gitignorePath) ? fs36.readFileSync(gitignorePath, "utf8") : "";
|
|
51394
51455
|
const lines2 = new Set(content.split("\n").map((line) => line.trim()));
|
|
51395
51456
|
const missing = EVIDENCE_DIRS.map((dir) => `${dir}/`).filter((dir) => !lines2.has(dir));
|
|
51396
51457
|
if (missing.length === 0) return;
|
|
51397
51458
|
const separator = content.length === 0 || content.endsWith("\n") ? "" : "\n";
|
|
51398
|
-
|
|
51459
|
+
fs36.writeFileSync(gitignorePath, `${content}${separator}${missing.join("\n")}
|
|
51399
51460
|
`);
|
|
51400
51461
|
}
|
|
51401
51462
|
function listRecords(harnessRoot, dir, parse4) {
|
|
51402
51463
|
const recordDir = harEvidenceDir(harnessRoot, dir);
|
|
51403
|
-
if (!
|
|
51464
|
+
if (!fs36.existsSync(recordDir)) return [];
|
|
51404
51465
|
const records = [];
|
|
51405
|
-
for (const name of
|
|
51466
|
+
for (const name of fs36.readdirSync(recordDir)) {
|
|
51406
51467
|
if (!name.endsWith(".json")) continue;
|
|
51407
51468
|
try {
|
|
51408
|
-
records.push(parse4(JSON.parse(
|
|
51469
|
+
records.push(parse4(JSON.parse(fs36.readFileSync(path36.join(recordDir, name), "utf8"))));
|
|
51409
51470
|
} catch {
|
|
51410
51471
|
}
|
|
51411
51472
|
}
|
|
@@ -51414,9 +51475,9 @@ function listRecords(harnessRoot, dir, parse4) {
|
|
|
51414
51475
|
function findWorkUnit(harnessRoot, workUnitId) {
|
|
51415
51476
|
const metadata = WorkUnitMetadataSchema.parse({ workUnitId });
|
|
51416
51477
|
const file = hashedRecordPath(harnessRoot, WORK_UNITS_DIR, metadata.workUnitId);
|
|
51417
|
-
if (!
|
|
51478
|
+
if (!fs36.existsSync(file)) return void 0;
|
|
51418
51479
|
try {
|
|
51419
|
-
return WorkUnitRecordSchema.parse(JSON.parse(
|
|
51480
|
+
return WorkUnitRecordSchema.parse(JSON.parse(fs36.readFileSync(file, "utf8")));
|
|
51420
51481
|
} catch {
|
|
51421
51482
|
return void 0;
|
|
51422
51483
|
}
|
|
@@ -51493,10 +51554,10 @@ function bindValidationToAttempt(harnessRoot, input) {
|
|
|
51493
51554
|
VALIDATION_BINDINGS_DIR,
|
|
51494
51555
|
stableKey
|
|
51495
51556
|
);
|
|
51496
|
-
if (
|
|
51557
|
+
if (fs36.existsSync(existingFile)) {
|
|
51497
51558
|
try {
|
|
51498
51559
|
return ValidationBindingRecordSchema.parse(
|
|
51499
|
-
JSON.parse(
|
|
51560
|
+
JSON.parse(fs36.readFileSync(existingFile, "utf8"))
|
|
51500
51561
|
);
|
|
51501
51562
|
} catch {
|
|
51502
51563
|
}
|
|
@@ -51557,14 +51618,14 @@ function createRemoteExecutor(apiUrl, apiKey) {
|
|
|
51557
51618
|
init_telemetry_config();
|
|
51558
51619
|
|
|
51559
51620
|
// src/core/usage-harvest/claude.ts
|
|
51560
|
-
var
|
|
51561
|
-
var
|
|
51562
|
-
var
|
|
51621
|
+
var fs39 = __toESM(require("fs"));
|
|
51622
|
+
var os11 = __toESM(require("os"));
|
|
51623
|
+
var path39 = __toESM(require("path"));
|
|
51563
51624
|
init_telemetry_config();
|
|
51564
51625
|
|
|
51565
51626
|
// src/core/telemetry-env.ts
|
|
51566
|
-
var
|
|
51567
|
-
var
|
|
51627
|
+
var fs38 = __toESM(require("fs"));
|
|
51628
|
+
var path38 = __toESM(require("path"));
|
|
51568
51629
|
init_control_config();
|
|
51569
51630
|
function escapeAttrValue(value) {
|
|
51570
51631
|
return value.replace(/[,=]/g, "_");
|
|
@@ -51610,8 +51671,8 @@ function appendTelemetryEnvToFile(envFilePath, attrs) {
|
|
|
51610
51671
|
${TELEMETRY_MARKER_END}
|
|
51611
51672
|
`;
|
|
51612
51673
|
let existing = "";
|
|
51613
|
-
if (
|
|
51614
|
-
existing =
|
|
51674
|
+
if (fs38.existsSync(envFilePath)) {
|
|
51675
|
+
existing = fs38.readFileSync(envFilePath, "utf8");
|
|
51615
51676
|
const start = existing.indexOf(TELEMETRY_MARKER_START);
|
|
51616
51677
|
if (start >= 0) {
|
|
51617
51678
|
const end = existing.indexOf(TELEMETRY_MARKER_END, start);
|
|
@@ -51622,28 +51683,28 @@ ${TELEMETRY_MARKER_END}
|
|
|
51622
51683
|
}
|
|
51623
51684
|
}
|
|
51624
51685
|
}
|
|
51625
|
-
|
|
51686
|
+
fs38.mkdirSync(path38.dirname(envFilePath), { recursive: true });
|
|
51626
51687
|
const combined = (existing.replace(/\n+$/, "\n") + block).replace(/^\n+/, "");
|
|
51627
|
-
|
|
51688
|
+
fs38.writeFileSync(envFilePath, combined.endsWith("\n") ? combined : combined + "\n");
|
|
51628
51689
|
}
|
|
51629
51690
|
|
|
51630
51691
|
// src/core/usage-harvest/claude.ts
|
|
51631
51692
|
function pathsMatch(candidate, targets) {
|
|
51632
|
-
const norm =
|
|
51693
|
+
const norm = path39.resolve(candidate);
|
|
51633
51694
|
return targets.some((t2) => {
|
|
51634
|
-
const target =
|
|
51635
|
-
return norm === target || norm.startsWith(target +
|
|
51695
|
+
const target = path39.resolve(t2);
|
|
51696
|
+
return norm === target || norm.startsWith(target + path39.sep) || target.startsWith(norm + path39.sep);
|
|
51636
51697
|
});
|
|
51637
51698
|
}
|
|
51638
51699
|
function claudeProjectsRoot() {
|
|
51639
|
-
return process.env.HAR_CLAUDE_PROJECTS_DIR ?
|
|
51700
|
+
return process.env.HAR_CLAUDE_PROJECTS_DIR ? path39.resolve(process.env.HAR_CLAUDE_PROJECTS_DIR) : path39.join(os11.homedir(), ".claude", "projects");
|
|
51640
51701
|
}
|
|
51641
51702
|
function encodeClaudeProjectDir(cwd) {
|
|
51642
51703
|
return cwd.replace(/[^a-zA-Z0-9]/g, "-");
|
|
51643
51704
|
}
|
|
51644
51705
|
function readJsonlRecords(filePath) {
|
|
51645
|
-
if (!
|
|
51646
|
-
const lines2 =
|
|
51706
|
+
if (!fs39.existsSync(filePath)) return [];
|
|
51707
|
+
const lines2 = fs39.readFileSync(filePath, "utf8").split(/\r?\n/);
|
|
51647
51708
|
const out = [];
|
|
51648
51709
|
for (const line of lines2) {
|
|
51649
51710
|
const trimmed = line.trim();
|
|
@@ -51686,16 +51747,16 @@ function findMatchingClaudeTranscripts(slot) {
|
|
|
51686
51747
|
const targets = [slot.workDir, slot.worktreePath].filter(Boolean);
|
|
51687
51748
|
if (targets.length === 0) return [];
|
|
51688
51749
|
const root = claudeProjectsRoot();
|
|
51689
|
-
if (!
|
|
51750
|
+
if (!fs39.existsSync(root)) return [];
|
|
51690
51751
|
const matches = [];
|
|
51691
|
-
for (const entry of
|
|
51752
|
+
for (const entry of fs39.readdirSync(root, { withFileTypes: true })) {
|
|
51692
51753
|
if (!entry.isDirectory()) continue;
|
|
51693
|
-
const projectDir =
|
|
51754
|
+
const projectDir = path39.join(root, entry.name);
|
|
51694
51755
|
const encodedHit = targets.some((t2) => entry.name.includes(encodeClaudeProjectDir(t2).slice(0, 40)));
|
|
51695
|
-
for (const file of
|
|
51756
|
+
for (const file of fs39.readdirSync(projectDir)) {
|
|
51696
51757
|
if (!file.endsWith(".jsonl")) continue;
|
|
51697
|
-
const filePath =
|
|
51698
|
-
const stat =
|
|
51758
|
+
const filePath = path39.join(projectDir, file);
|
|
51759
|
+
const stat = fs39.statSync(filePath);
|
|
51699
51760
|
const records = readJsonlRecords(filePath);
|
|
51700
51761
|
let cwdHit = encodedHit;
|
|
51701
51762
|
for (const record2 of records) {
|
|
@@ -51806,30 +51867,30 @@ function harvestClaudeEvents(slot) {
|
|
|
51806
51867
|
}
|
|
51807
51868
|
|
|
51808
51869
|
// src/core/usage-harvest/codex.ts
|
|
51809
|
-
var
|
|
51810
|
-
var
|
|
51811
|
-
var
|
|
51870
|
+
var fs40 = __toESM(require("fs"));
|
|
51871
|
+
var os12 = __toESM(require("os"));
|
|
51872
|
+
var path40 = __toESM(require("path"));
|
|
51812
51873
|
function pathsMatch2(candidate, targets) {
|
|
51813
|
-
const norm =
|
|
51874
|
+
const norm = path40.resolve(candidate);
|
|
51814
51875
|
return targets.some((t2) => {
|
|
51815
|
-
const target =
|
|
51816
|
-
return norm === target || norm.startsWith(target +
|
|
51876
|
+
const target = path40.resolve(t2);
|
|
51877
|
+
return norm === target || norm.startsWith(target + path40.sep) || target.startsWith(norm + path40.sep);
|
|
51817
51878
|
});
|
|
51818
51879
|
}
|
|
51819
51880
|
function codexSessionsRoot() {
|
|
51820
|
-
return process.env.HAR_CODEX_SESSIONS_DIR ?
|
|
51881
|
+
return process.env.HAR_CODEX_SESSIONS_DIR ? path40.resolve(process.env.HAR_CODEX_SESSIONS_DIR) : path40.join(os12.homedir(), ".codex", "sessions");
|
|
51821
51882
|
}
|
|
51822
51883
|
function walkJsonlFiles(dir, out = []) {
|
|
51823
|
-
if (!
|
|
51824
|
-
for (const entry of
|
|
51825
|
-
const full =
|
|
51884
|
+
if (!fs40.existsSync(dir)) return out;
|
|
51885
|
+
for (const entry of fs40.readdirSync(dir, { withFileTypes: true })) {
|
|
51886
|
+
const full = path40.join(dir, entry.name);
|
|
51826
51887
|
if (entry.isDirectory()) walkJsonlFiles(full, out);
|
|
51827
51888
|
else if (entry.isFile() && entry.name.endsWith(".jsonl")) out.push(full);
|
|
51828
51889
|
}
|
|
51829
51890
|
return out;
|
|
51830
51891
|
}
|
|
51831
51892
|
function readJsonl(filePath) {
|
|
51832
|
-
const lines2 =
|
|
51893
|
+
const lines2 = fs40.readFileSync(filePath, "utf8").split(/\r?\n/);
|
|
51833
51894
|
const out = [];
|
|
51834
51895
|
for (const line of lines2) {
|
|
51835
51896
|
const trimmed = line.trim();
|
|
@@ -51893,7 +51954,7 @@ function harvestCodexUsage(slot) {
|
|
|
51893
51954
|
const extracted = extractCodexTokens(records);
|
|
51894
51955
|
if (!extracted.cwd || !pathsMatch2(extracted.cwd, targets)) continue;
|
|
51895
51956
|
if (extracted.tokensInput + extracted.tokensOutput + extracted.tokensCacheRead === 0) continue;
|
|
51896
|
-
const mtime =
|
|
51957
|
+
const mtime = fs40.statSync(file).mtimeMs;
|
|
51897
51958
|
if (mtime >= bestMtime) {
|
|
51898
51959
|
bestMtime = mtime;
|
|
51899
51960
|
best = extracted;
|
|
@@ -51948,6 +52009,42 @@ async function postJson(url, body, dryRun) {
|
|
|
51948
52009
|
}
|
|
51949
52010
|
return await response.json();
|
|
51950
52011
|
}
|
|
52012
|
+
async function postPortalSync(target, body, dryRun) {
|
|
52013
|
+
if (dryRun) return;
|
|
52014
|
+
const response = await fetch(`${target.url}/api/sync`, {
|
|
52015
|
+
method: "POST",
|
|
52016
|
+
headers: {
|
|
52017
|
+
"Content-Type": "application/json",
|
|
52018
|
+
Authorization: `Bearer ${target.token}`
|
|
52019
|
+
},
|
|
52020
|
+
body: JSON.stringify(body)
|
|
52021
|
+
});
|
|
52022
|
+
if (!response.ok) {
|
|
52023
|
+
if (response.status === 401 || response.status === 403) {
|
|
52024
|
+
throw new Error(
|
|
52025
|
+
`har-portal rejected the ingest token (HTTP ${response.status}) \u2014 check HAR_PORTAL_TOKEN.`
|
|
52026
|
+
);
|
|
52027
|
+
}
|
|
52028
|
+
const text = await response.text().catch(() => "");
|
|
52029
|
+
throw new Error(`har-portal sync failed: HTTP ${response.status}${text ? ` \u2014 ${text}` : ""}`);
|
|
52030
|
+
}
|
|
52031
|
+
}
|
|
52032
|
+
function buildPortalSyncBody(repoPath) {
|
|
52033
|
+
const runs = listRuns(repoPath);
|
|
52034
|
+
const status = collectEnvironmentStatus(repoPath);
|
|
52035
|
+
const manifest = readManifest(repoPath);
|
|
52036
|
+
const stagesRegistry = readStageRegistry(repoPath);
|
|
52037
|
+
const validations = listValidations(resolveHarnessRoot(repoPath));
|
|
52038
|
+
return {
|
|
52039
|
+
path: repoPath,
|
|
52040
|
+
...manifest ? { manifest } : {},
|
|
52041
|
+
...stagesRegistry ? { stagesRegistry } : {},
|
|
52042
|
+
runs,
|
|
52043
|
+
slots: status.slots,
|
|
52044
|
+
generatedAt: status.generatedAt,
|
|
52045
|
+
...validations.length > 0 ? { validations } : {}
|
|
52046
|
+
};
|
|
52047
|
+
}
|
|
51951
52048
|
async function isControlApiReachable(apiUrl = getControlApiUrl()) {
|
|
51952
52049
|
try {
|
|
51953
52050
|
const response = await fetch(`${apiUrl}/api/health`, {
|
|
@@ -51963,14 +52060,15 @@ async function waitForControlApi(apiUrl = getControlApiUrl(), timeoutMs = 6e4, i
|
|
|
51963
52060
|
const deadline = Date.now() + timeoutMs;
|
|
51964
52061
|
while (Date.now() < deadline) {
|
|
51965
52062
|
if (await isControlApiReachable(apiUrl)) return true;
|
|
51966
|
-
await new Promise((
|
|
52063
|
+
await new Promise((resolve38) => setTimeout(resolve38, intervalMs));
|
|
51967
52064
|
}
|
|
51968
52065
|
return false;
|
|
51969
52066
|
}
|
|
51970
52067
|
async function syncAllKnownReposWithControl(options) {
|
|
51971
52068
|
if (!isControlEnabled()) return { synced: 0, failed: 0 };
|
|
51972
52069
|
const apiUrl = options?.apiUrl ?? getControlApiUrl();
|
|
51973
|
-
|
|
52070
|
+
const portal = getPortalTarget();
|
|
52071
|
+
if (!await isControlApiReachable(portal ? portal.url : apiUrl)) {
|
|
51974
52072
|
return { synced: 0, failed: 0 };
|
|
51975
52073
|
}
|
|
51976
52074
|
const repoPaths = new Set(listRegisteredRepos());
|
|
@@ -52061,13 +52159,18 @@ async function syncRepoWithControl(options) {
|
|
|
52061
52159
|
}
|
|
52062
52160
|
return;
|
|
52063
52161
|
}
|
|
52162
|
+
const portal = getPortalTarget();
|
|
52163
|
+
if (portal) {
|
|
52164
|
+
await postPortalSync(portal, buildPortalSyncBody(repoPath), options.dryRun);
|
|
52165
|
+
return;
|
|
52166
|
+
}
|
|
52064
52167
|
const registerResult = await registerRepoWithControl({ ...options, repoPath });
|
|
52065
52168
|
const repoId = registerResult?.id;
|
|
52066
52169
|
if (!repoId && !options.dryRun) {
|
|
52067
52170
|
const listResponse = await fetch(`${apiUrl}/api/repos`);
|
|
52068
52171
|
if (!listResponse.ok) throw new Error("Failed to list repos from Control API");
|
|
52069
52172
|
const repos = await listResponse.json();
|
|
52070
|
-
const existing = repos.find((r2) =>
|
|
52173
|
+
const existing = repos.find((r2) => path41.resolve(r2.path) === repoPath);
|
|
52071
52174
|
if (!existing) {
|
|
52072
52175
|
return;
|
|
52073
52176
|
}
|
|
@@ -52175,17 +52278,18 @@ async function syncRepoWithControlAsync(repoPath) {
|
|
|
52175
52278
|
if (process.env.HAR_CONTROL_DISABLED === "true" || process.env.NODE_ENV === "test") return;
|
|
52176
52279
|
const verbose = process.env.HAR_CONTROL_VERBOSE === "true";
|
|
52177
52280
|
try {
|
|
52178
|
-
const
|
|
52179
|
-
|
|
52281
|
+
const portal = getPortalTarget();
|
|
52282
|
+
const healthUrl = portal ? portal.url : getControlApiUrl();
|
|
52283
|
+
if (!await isControlApiReachable(healthUrl)) {
|
|
52180
52284
|
if (verbose) {
|
|
52181
|
-
process.stderr.write(`[har control] sync skipped:
|
|
52285
|
+
process.stderr.write(`[har control] sync skipped: not reachable at ${healthUrl}
|
|
52182
52286
|
`);
|
|
52183
52287
|
}
|
|
52184
52288
|
return;
|
|
52185
52289
|
}
|
|
52186
52290
|
const canonical = canonicalizeControlRepoPath(repoPath);
|
|
52187
52291
|
await withTimeout(
|
|
52188
|
-
syncRepoWithControl({ repoPath: canonical
|
|
52292
|
+
syncRepoWithControl({ repoPath: canonical }),
|
|
52189
52293
|
SYNC_TIMEOUT_MS,
|
|
52190
52294
|
"control sync"
|
|
52191
52295
|
);
|
|
@@ -52219,7 +52323,7 @@ init_control_config();
|
|
|
52219
52323
|
|
|
52220
52324
|
// src/core/control-lifecycle.ts
|
|
52221
52325
|
var import_child_process8 = require("child_process");
|
|
52222
|
-
var
|
|
52326
|
+
var path42 = __toESM(require("path"));
|
|
52223
52327
|
|
|
52224
52328
|
// src/core/control-image.ts
|
|
52225
52329
|
var DEFAULT_CONTROL_IMAGE = "theosfactory/har-control";
|
|
@@ -52243,10 +52347,10 @@ var CONTROL_DATA_VOLUME = "har_control_data";
|
|
|
52243
52347
|
var CONTROL_CONTAINER_PORT = 3847;
|
|
52244
52348
|
var CONTROL_DATA_DB_URL = "file:/data/har_control.db";
|
|
52245
52349
|
function resolveControlDir() {
|
|
52246
|
-
return
|
|
52350
|
+
return path42.resolve(__dirname, "..", "control");
|
|
52247
52351
|
}
|
|
52248
52352
|
function resolveControlBuildContext() {
|
|
52249
|
-
return
|
|
52353
|
+
return path42.resolve(resolveControlDir(), "..");
|
|
52250
52354
|
}
|
|
52251
52355
|
function buildDockerRunArgs(options) {
|
|
52252
52356
|
const name = options.containerName ?? CONTROL_CONTAINER_NAME;
|
|
@@ -52302,7 +52406,7 @@ async function startMissionControl(options) {
|
|
|
52302
52406
|
"-t",
|
|
52303
52407
|
imageRef,
|
|
52304
52408
|
"-f",
|
|
52305
|
-
|
|
52409
|
+
path42.join(resolveControlDir(), "Dockerfile"),
|
|
52306
52410
|
resolveControlBuildContext()
|
|
52307
52411
|
]);
|
|
52308
52412
|
if (buildCode !== 0) {
|
|
@@ -52446,7 +52550,7 @@ async function ensureTelemetryInfrastructure(options) {
|
|
|
52446
52550
|
|
|
52447
52551
|
// src/core/run-service.ts
|
|
52448
52552
|
init_telemetry_config();
|
|
52449
|
-
var
|
|
52553
|
+
var path44 = __toESM(require("path"));
|
|
52450
52554
|
function extractShellOutput(result) {
|
|
52451
52555
|
const stdout = result.logs?.find((log) => log.stream === "stdout")?.content ?? result.logs?.find((log) => !log.stream)?.content ?? "";
|
|
52452
52556
|
const stderr = result.logs?.find((log) => log.stream === "stderr")?.content ?? "";
|
|
@@ -52656,12 +52760,12 @@ Usage from Cursor / Claude / Codex (opentelemetry-hooks) will appear under Workt
|
|
|
52656
52760
|
suffix: session.suffix,
|
|
52657
52761
|
createdAt: session.createdAt
|
|
52658
52762
|
});
|
|
52659
|
-
const envFile =
|
|
52763
|
+
const envFile = path44.join(session.workDir, `.env.agent.${options.agentId}`);
|
|
52660
52764
|
try {
|
|
52661
52765
|
appendTelemetryEnvToFile(envFile, {
|
|
52662
52766
|
sessionKey,
|
|
52663
52767
|
agentId: options.agentId,
|
|
52664
|
-
repoPath:
|
|
52768
|
+
repoPath: path44.resolve(options.repoPath),
|
|
52665
52769
|
workDir: session.workDir,
|
|
52666
52770
|
branch: session.branch,
|
|
52667
52771
|
suffix: session.suffix,
|
|
@@ -52893,9 +52997,9 @@ var getEnvironmentLogs = defaultRunService.getEnvironmentLogs.bind(defaultRunSer
|
|
|
52893
52997
|
var readline5 = __toESM(require("readline"));
|
|
52894
52998
|
|
|
52895
52999
|
// src/core/hooks.ts
|
|
52896
|
-
var
|
|
52897
|
-
var
|
|
52898
|
-
var
|
|
53000
|
+
var fs42 = __toESM(require("fs"));
|
|
53001
|
+
var os14 = __toESM(require("os"));
|
|
53002
|
+
var path45 = __toESM(require("path"));
|
|
52899
53003
|
var MARKER_START = "# >>> har commit gate (managed by `har hooks`) >>>";
|
|
52900
53004
|
var MARKER_END = "# <<< har commit gate <<<";
|
|
52901
53005
|
var PRE_COMMIT_BLOCK = [
|
|
@@ -52920,7 +53024,7 @@ function resolveCheckoutRoot(cwd) {
|
|
|
52920
53024
|
function resolveHooksDir(checkoutDir) {
|
|
52921
53025
|
const hooksPath = tryGit3(checkoutDir, "rev-parse --git-path hooks");
|
|
52922
53026
|
if (!hooksPath) throw new Error(`Not a git checkout: ${checkoutDir}`);
|
|
52923
|
-
return
|
|
53027
|
+
return path45.resolve(checkoutDir, hooksPath);
|
|
52924
53028
|
}
|
|
52925
53029
|
function getConfiguredHooksPath(checkoutDir) {
|
|
52926
53030
|
return tryGit3(checkoutDir, "config core.hooksPath") || void 0;
|
|
@@ -52928,9 +53032,9 @@ function getConfiguredHooksPath(checkoutDir) {
|
|
|
52928
53032
|
function defaultHarInvocation() {
|
|
52929
53033
|
const entry = process.argv[1];
|
|
52930
53034
|
if (entry && entry.endsWith(".js")) {
|
|
52931
|
-
return `"${process.execPath}" "${
|
|
53035
|
+
return `"${process.execPath}" "${path45.resolve(entry)}"`;
|
|
52932
53036
|
}
|
|
52933
|
-
if (entry) return `"${
|
|
53037
|
+
if (entry) return `"${path45.resolve(entry)}"`;
|
|
52934
53038
|
return "har";
|
|
52935
53039
|
}
|
|
52936
53040
|
function buildHookScript(harInvocation, subcommand, failOpenNotice) {
|
|
@@ -52951,40 +53055,40 @@ exit 0
|
|
|
52951
53055
|
`;
|
|
52952
53056
|
}
|
|
52953
53057
|
function upsertMarkedBlock(filePath, block) {
|
|
52954
|
-
if (!
|
|
52955
|
-
|
|
53058
|
+
if (!fs42.existsSync(filePath)) {
|
|
53059
|
+
fs42.writeFileSync(filePath, `#!/bin/sh
|
|
52956
53060
|
${block}
|
|
52957
53061
|
`, { mode: 493 });
|
|
52958
53062
|
return "created";
|
|
52959
53063
|
}
|
|
52960
|
-
const content =
|
|
53064
|
+
const content = fs42.readFileSync(filePath, "utf8");
|
|
52961
53065
|
if (content.includes(MARKER_START)) {
|
|
52962
53066
|
const pattern = new RegExp(
|
|
52963
53067
|
`${escapeRegExp(MARKER_START)}[\\s\\S]*?${escapeRegExp(MARKER_END)}`
|
|
52964
53068
|
);
|
|
52965
|
-
|
|
52966
|
-
|
|
53069
|
+
fs42.writeFileSync(filePath, content.replace(pattern, block));
|
|
53070
|
+
fs42.chmodSync(filePath, 493);
|
|
52967
53071
|
return "updated";
|
|
52968
53072
|
}
|
|
52969
53073
|
const suffix = content.endsWith("\n") ? "" : "\n";
|
|
52970
|
-
|
|
53074
|
+
fs42.writeFileSync(filePath, `${content}${suffix}
|
|
52971
53075
|
${block}
|
|
52972
53076
|
`);
|
|
52973
|
-
|
|
53077
|
+
fs42.chmodSync(filePath, 493);
|
|
52974
53078
|
return "appended";
|
|
52975
53079
|
}
|
|
52976
53080
|
function removeMarkedBlock(filePath) {
|
|
52977
|
-
if (!
|
|
52978
|
-
const content =
|
|
53081
|
+
if (!fs42.existsSync(filePath)) return false;
|
|
53082
|
+
const content = fs42.readFileSync(filePath, "utf8");
|
|
52979
53083
|
if (!content.includes(MARKER_START)) return false;
|
|
52980
53084
|
const pattern = new RegExp(
|
|
52981
53085
|
`\\n?${escapeRegExp(MARKER_START)}[\\s\\S]*?${escapeRegExp(MARKER_END)}\\n?`
|
|
52982
53086
|
);
|
|
52983
53087
|
const stripped = content.replace(pattern, "\n");
|
|
52984
53088
|
if (stripped.replace(/^#!\/bin\/sh\n?/, "").trim() === "") {
|
|
52985
|
-
|
|
53089
|
+
fs42.rmSync(filePath);
|
|
52986
53090
|
} else {
|
|
52987
|
-
|
|
53091
|
+
fs42.writeFileSync(filePath, stripped);
|
|
52988
53092
|
}
|
|
52989
53093
|
return true;
|
|
52990
53094
|
}
|
|
@@ -53006,20 +53110,20 @@ Or re-run with --force to write into that directory anyway.`
|
|
|
53006
53110
|
);
|
|
53007
53111
|
}
|
|
53008
53112
|
const hooksDir = resolveHooksDir(checkout);
|
|
53009
|
-
|
|
53113
|
+
fs42.mkdirSync(hooksDir, { recursive: true });
|
|
53010
53114
|
const invocation = options.harInvocation ?? defaultHarInvocation();
|
|
53011
|
-
|
|
53012
|
-
|
|
53115
|
+
fs42.writeFileSync(
|
|
53116
|
+
path45.join(hooksDir, "har-pre-commit"),
|
|
53013
53117
|
buildHookScript(invocation, "check", "har: binary not found; skipping commit gate (reinstall with har hooks install)"),
|
|
53014
53118
|
{ mode: 493 }
|
|
53015
53119
|
);
|
|
53016
|
-
|
|
53017
|
-
|
|
53120
|
+
fs42.writeFileSync(
|
|
53121
|
+
path45.join(hooksDir, "har-post-commit"),
|
|
53018
53122
|
buildHookScript(invocation, "record-commit", "har: binary not found; skipping commit association"),
|
|
53019
53123
|
{ mode: 493 }
|
|
53020
53124
|
);
|
|
53021
|
-
const preCommit = upsertMarkedBlock(
|
|
53022
|
-
const postCommit = upsertMarkedBlock(
|
|
53125
|
+
const preCommit = upsertMarkedBlock(path45.join(hooksDir, "pre-commit"), PRE_COMMIT_BLOCK);
|
|
53126
|
+
const postCommit = upsertMarkedBlock(path45.join(hooksDir, "post-commit"), POST_COMMIT_BLOCK);
|
|
53023
53127
|
ensureValidationsIgnored(checkout);
|
|
53024
53128
|
return { hooksDir, preCommit, postCommit };
|
|
53025
53129
|
}
|
|
@@ -53028,12 +53132,12 @@ function uninstallHooks(repoPath) {
|
|
|
53028
53132
|
if (!checkout) throw new Error(`Not a git repository: ${repoPath}`);
|
|
53029
53133
|
const hooksDir = resolveHooksDir(checkout);
|
|
53030
53134
|
let removed = false;
|
|
53031
|
-
removed = removeMarkedBlock(
|
|
53032
|
-
removed = removeMarkedBlock(
|
|
53135
|
+
removed = removeMarkedBlock(path45.join(hooksDir, "pre-commit")) || removed;
|
|
53136
|
+
removed = removeMarkedBlock(path45.join(hooksDir, "post-commit")) || removed;
|
|
53033
53137
|
for (const file of ["har-pre-commit", "har-post-commit"]) {
|
|
53034
|
-
const full =
|
|
53035
|
-
if (
|
|
53036
|
-
|
|
53138
|
+
const full = path45.join(hooksDir, file);
|
|
53139
|
+
if (fs42.existsSync(full)) {
|
|
53140
|
+
fs42.rmSync(full);
|
|
53037
53141
|
removed = true;
|
|
53038
53142
|
}
|
|
53039
53143
|
}
|
|
@@ -53052,10 +53156,10 @@ function isAgentWorktree(checkoutDir) {
|
|
|
53052
53156
|
if (branch && (/^har-agent-\d+$/.test(branch) || /-har-agent-\d+-[a-z0-9]+$/.test(branch))) {
|
|
53053
53157
|
return true;
|
|
53054
53158
|
}
|
|
53055
|
-
const worktreesRoot =
|
|
53056
|
-
const resolved =
|
|
53057
|
-
const name =
|
|
53058
|
-
return resolved.startsWith(`${worktreesRoot}${
|
|
53159
|
+
const worktreesRoot = path45.join(os14.homedir(), "worktrees");
|
|
53160
|
+
const resolved = path45.resolve(checkoutDir);
|
|
53161
|
+
const name = path45.basename(resolved);
|
|
53162
|
+
return resolved.startsWith(`${worktreesRoot}${path45.sep}`) && (/-agent-\d+$/.test(name) || /-har-agent-\d+-[a-z0-9]+$/.test(name));
|
|
53059
53163
|
}
|
|
53060
53164
|
function resolveEffectiveMode(checkoutDir, gate) {
|
|
53061
53165
|
if (!gate.enabled) return "off";
|
|
@@ -53068,15 +53172,15 @@ function getHooksStatus(repoPath) {
|
|
|
53068
53172
|
const hooksDir = resolveHooksDir(checkout);
|
|
53069
53173
|
const gate = getCommitGateConfig(checkout);
|
|
53070
53174
|
const hasBlock = (name) => {
|
|
53071
|
-
const file =
|
|
53072
|
-
return
|
|
53175
|
+
const file = path45.join(hooksDir, name);
|
|
53176
|
+
return fs42.existsSync(file) && fs42.readFileSync(file, "utf8").includes(MARKER_START);
|
|
53073
53177
|
};
|
|
53074
53178
|
return {
|
|
53075
53179
|
checkout,
|
|
53076
53180
|
hooksDir,
|
|
53077
53181
|
configuredHooksPath: getConfiguredHooksPath(checkout),
|
|
53078
|
-
preCommitInstalled: hasBlock("pre-commit") &&
|
|
53079
|
-
postCommitInstalled: hasBlock("post-commit") &&
|
|
53182
|
+
preCommitInstalled: hasBlock("pre-commit") && fs42.existsSync(path45.join(hooksDir, "har-pre-commit")),
|
|
53183
|
+
postCommitInstalled: hasBlock("post-commit") && fs42.existsSync(path45.join(hooksDir, "har-post-commit")),
|
|
53080
53184
|
gate,
|
|
53081
53185
|
effectiveMode: resolveEffectiveMode(checkout, gate)
|
|
53082
53186
|
};
|
|
@@ -53087,7 +53191,7 @@ function checkCommitGate(cwd) {
|
|
|
53087
53191
|
}
|
|
53088
53192
|
const checkout = resolveCheckoutRoot(cwd);
|
|
53089
53193
|
if (!checkout) return { exitCode: 0, messages: [] };
|
|
53090
|
-
if (!
|
|
53194
|
+
if (!fs42.existsSync(path45.join(checkout, ".har", "stages.json"))) {
|
|
53091
53195
|
return { exitCode: 0, messages: [] };
|
|
53092
53196
|
}
|
|
53093
53197
|
const gate = getCommitGateConfig(checkout);
|
|
@@ -53160,12 +53264,12 @@ async function recordCommitAssociation(cwd) {
|
|
|
53160
53264
|
// src/core/commit-gate-onboarding.ts
|
|
53161
53265
|
function askYesNo4(question) {
|
|
53162
53266
|
const rl = readline5.createInterface({ input: process.stdin, output: process.stderr });
|
|
53163
|
-
return new Promise((
|
|
53267
|
+
return new Promise((resolve38) => {
|
|
53164
53268
|
process.stderr.write(`${question} `);
|
|
53165
53269
|
rl.once("line", (answer) => {
|
|
53166
53270
|
rl.close();
|
|
53167
53271
|
const trimmed = answer.trim();
|
|
53168
|
-
|
|
53272
|
+
resolve38(trimmed === "" || /^y(es)?$/i.test(trimmed));
|
|
53169
53273
|
});
|
|
53170
53274
|
});
|
|
53171
53275
|
}
|
|
@@ -53207,20 +53311,20 @@ async function handleCommitGateOnboarding(options) {
|
|
|
53207
53311
|
}
|
|
53208
53312
|
|
|
53209
53313
|
// src/core/onboarding-preferences.ts
|
|
53210
|
-
var
|
|
53211
|
-
var
|
|
53212
|
-
var
|
|
53314
|
+
var fs43 = __toESM(require("fs"));
|
|
53315
|
+
var os15 = __toESM(require("os"));
|
|
53316
|
+
var path46 = __toESM(require("path"));
|
|
53213
53317
|
function getOnboardingPreferencesPath() {
|
|
53214
53318
|
if (process.env.HAR_PREFERENCES_PATH) {
|
|
53215
|
-
return
|
|
53319
|
+
return path46.resolve(process.env.HAR_PREFERENCES_PATH);
|
|
53216
53320
|
}
|
|
53217
|
-
return
|
|
53321
|
+
return path46.join(os15.homedir(), ".har", "preferences.json");
|
|
53218
53322
|
}
|
|
53219
53323
|
function readOnboardingPreferences() {
|
|
53220
53324
|
const preferencePath = getOnboardingPreferencesPath();
|
|
53221
53325
|
try {
|
|
53222
|
-
if (!
|
|
53223
|
-
return OnboardingPreferencesSchema.parse(JSON.parse(
|
|
53326
|
+
if (!fs43.existsSync(preferencePath)) return OnboardingPreferencesSchema.parse({});
|
|
53327
|
+
return OnboardingPreferencesSchema.parse(JSON.parse(fs43.readFileSync(preferencePath, "utf8")));
|
|
53224
53328
|
} catch {
|
|
53225
53329
|
return OnboardingPreferencesSchema.parse({});
|
|
53226
53330
|
}
|
|
@@ -53245,8 +53349,8 @@ function writeOnboardingPreferences(overrides) {
|
|
|
53245
53349
|
};
|
|
53246
53350
|
const parsed = OnboardingPreferencesSchema.parse(preference);
|
|
53247
53351
|
const preferencePath = getOnboardingPreferencesPath();
|
|
53248
|
-
|
|
53249
|
-
|
|
53352
|
+
fs43.mkdirSync(path46.dirname(preferencePath), { recursive: true });
|
|
53353
|
+
fs43.writeFileSync(preferencePath, `${JSON.stringify(parsed, null, 2)}
|
|
53250
53354
|
`);
|
|
53251
53355
|
return parsed;
|
|
53252
53356
|
}
|
|
@@ -53526,7 +53630,7 @@ var envCommand = {
|
|
|
53526
53630
|
}
|
|
53527
53631
|
};
|
|
53528
53632
|
async function handleInit(argv) {
|
|
53529
|
-
const repoPath =
|
|
53633
|
+
const repoPath = path47.resolve(argv.repo);
|
|
53530
53634
|
const onboarding = resolveOnboardingOptions(argv);
|
|
53531
53635
|
header("har env init");
|
|
53532
53636
|
info(`Repository: ${repoPath}`);
|
|
@@ -53590,7 +53694,7 @@ async function handleInit(argv) {
|
|
|
53590
53694
|
}
|
|
53591
53695
|
}
|
|
53592
53696
|
async function handleMaintain(argv) {
|
|
53593
|
-
const repoPath =
|
|
53697
|
+
const repoPath = path47.resolve(argv.repo);
|
|
53594
53698
|
const onboarding = resolveOnboardingOptions(argv);
|
|
53595
53699
|
header("har env maintain");
|
|
53596
53700
|
info(`Repository: ${repoPath}`);
|
|
@@ -53705,7 +53809,7 @@ async function handleAgentMdProposal(repoPath, autoYes) {
|
|
|
53705
53809
|
if (autoYes) {
|
|
53706
53810
|
const proposal = readAgentMdProposal(repoPath);
|
|
53707
53811
|
if (proposal) {
|
|
53708
|
-
writeFileSafe(
|
|
53812
|
+
writeFileSafe(path47.join(repoPath, "AGENT.md"), proposal.content);
|
|
53709
53813
|
clearAgentMdProposal(repoPath);
|
|
53710
53814
|
info("Applied AGENT.md proposal (--yes)");
|
|
53711
53815
|
}
|
|
@@ -53714,7 +53818,7 @@ async function handleAgentMdProposal(repoPath, autoYes) {
|
|
|
53714
53818
|
await promptApplyAgentMdProposal(repoPath);
|
|
53715
53819
|
}
|
|
53716
53820
|
async function handleAddStage(argv) {
|
|
53717
|
-
const repoPath =
|
|
53821
|
+
const repoPath = path47.resolve(argv.repo);
|
|
53718
53822
|
const available = listStageTemplateIds();
|
|
53719
53823
|
if (argv.list) {
|
|
53720
53824
|
for (const id of available) {
|
|
@@ -53791,7 +53895,7 @@ async function handleAddStage(argv) {
|
|
|
53791
53895
|
}
|
|
53792
53896
|
}
|
|
53793
53897
|
async function handlePreflight(argv) {
|
|
53794
|
-
const repo =
|
|
53898
|
+
const repo = path47.resolve(argv.repo);
|
|
53795
53899
|
const agentId = validateAgentId(argv.id, repo);
|
|
53796
53900
|
const result = await preflightEnvironment({
|
|
53797
53901
|
repoPath: repo,
|
|
@@ -53809,7 +53913,7 @@ async function handlePreflight(argv) {
|
|
|
53809
53913
|
process.exit(result.code);
|
|
53810
53914
|
}
|
|
53811
53915
|
async function handleLaunch(argv) {
|
|
53812
|
-
const repo =
|
|
53916
|
+
const repo = path47.resolve(argv.repo);
|
|
53813
53917
|
const agentId = validateAgentId(argv.id, repo);
|
|
53814
53918
|
let confirmReplace = argv.replace;
|
|
53815
53919
|
let force = argv.force;
|
|
@@ -53821,8 +53925,8 @@ async function handleLaunch(argv) {
|
|
|
53821
53925
|
console.error(guard.reason ?? "");
|
|
53822
53926
|
const readline9 = await import("readline");
|
|
53823
53927
|
const rl = readline9.createInterface({ input: process.stdin, output: process.stderr });
|
|
53824
|
-
const answer = await new Promise((
|
|
53825
|
-
rl.question("Replace this slot? [y/N] ",
|
|
53928
|
+
const answer = await new Promise((resolve38) => {
|
|
53929
|
+
rl.question("Replace this slot? [y/N] ", resolve38);
|
|
53826
53930
|
});
|
|
53827
53931
|
rl.close();
|
|
53828
53932
|
if (!/^[Yy]$/.test(answer.trim())) {
|
|
@@ -53838,8 +53942,8 @@ async function handleLaunch(argv) {
|
|
|
53838
53942
|
warn("Worktree has uncommitted changes.");
|
|
53839
53943
|
const readline9 = await import("readline");
|
|
53840
53944
|
const rl = readline9.createInterface({ input: process.stdin, output: process.stderr });
|
|
53841
|
-
const answer = await new Promise((
|
|
53842
|
-
rl.question("Discard uncommitted changes? [y/N] ",
|
|
53945
|
+
const answer = await new Promise((resolve38) => {
|
|
53946
|
+
rl.question("Discard uncommitted changes? [y/N] ", resolve38);
|
|
53843
53947
|
});
|
|
53844
53948
|
rl.close();
|
|
53845
53949
|
if (!/^[Yy]$/.test(answer.trim())) {
|
|
@@ -53903,7 +54007,7 @@ async function handleRecover(argv) {
|
|
|
53903
54007
|
});
|
|
53904
54008
|
}
|
|
53905
54009
|
async function handleVerify(argv) {
|
|
53906
|
-
const repo =
|
|
54010
|
+
const repo = path47.resolve(argv.repo);
|
|
53907
54011
|
const agentId = validateAgentId(argv.id, repo);
|
|
53908
54012
|
const result = await runVerification({
|
|
53909
54013
|
repoPath: repo,
|
|
@@ -53915,7 +54019,7 @@ async function handleVerify(argv) {
|
|
|
53915
54019
|
process.exit(result.code);
|
|
53916
54020
|
}
|
|
53917
54021
|
async function handleTeardown(argv) {
|
|
53918
|
-
const repo =
|
|
54022
|
+
const repo = path47.resolve(argv.repo);
|
|
53919
54023
|
const agentId = validateAgentId(argv.id, repo);
|
|
53920
54024
|
const result = await teardownEnvironment({
|
|
53921
54025
|
repoPath: repo,
|
|
@@ -53926,7 +54030,7 @@ async function handleTeardown(argv) {
|
|
|
53926
54030
|
process.exit(result.code);
|
|
53927
54031
|
}
|
|
53928
54032
|
async function handleComplete(argv) {
|
|
53929
|
-
const repo =
|
|
54033
|
+
const repo = path47.resolve(argv.repo);
|
|
53930
54034
|
const agentId = validateAgentId(argv.id, repo);
|
|
53931
54035
|
const result = await completeEnvironment({
|
|
53932
54036
|
repoPath: repo,
|
|
@@ -53947,7 +54051,7 @@ async function handleComplete(argv) {
|
|
|
53947
54051
|
process.exit(result.code);
|
|
53948
54052
|
}
|
|
53949
54053
|
async function handleStatus(argv) {
|
|
53950
|
-
const repoPath =
|
|
54054
|
+
const repoPath = path47.resolve(argv.repo);
|
|
53951
54055
|
if (argv.json) {
|
|
53952
54056
|
const status = collectEnvironmentStatus(repoPath);
|
|
53953
54057
|
const output = EnvironmentStatusSchema.parse(status);
|
|
@@ -53960,7 +54064,7 @@ async function handleStatus(argv) {
|
|
|
53960
54064
|
});
|
|
53961
54065
|
}
|
|
53962
54066
|
async function handleRunsList(argv) {
|
|
53963
|
-
const repoPath =
|
|
54067
|
+
const repoPath = path47.resolve(argv.repo);
|
|
53964
54068
|
const runs = listRuns(repoPath, { stageId: argv.stage, limit: argv.limit });
|
|
53965
54069
|
if (argv.json) {
|
|
53966
54070
|
process.stdout.write(JSON.stringify({ runs }, null, 2) + "\n");
|
|
@@ -53977,7 +54081,7 @@ async function handleRunsList(argv) {
|
|
|
53977
54081
|
}
|
|
53978
54082
|
}
|
|
53979
54083
|
async function handleRunsGet(argv) {
|
|
53980
|
-
const run2 = getRun(
|
|
54084
|
+
const run2 = getRun(path47.resolve(argv.repo), argv.runId);
|
|
53981
54085
|
if (!run2) {
|
|
53982
54086
|
error(`Run not found: ${argv.runId}`);
|
|
53983
54087
|
process.exit(1);
|
|
@@ -54056,20 +54160,87 @@ function printNextSteps(auto2) {
|
|
|
54056
54160
|
}
|
|
54057
54161
|
|
|
54058
54162
|
// src/cli/commands/control.ts
|
|
54059
|
-
var
|
|
54163
|
+
var path49 = __toESM(require("path"));
|
|
54060
54164
|
init_control_config();
|
|
54165
|
+
init_portal_credentials();
|
|
54166
|
+
|
|
54167
|
+
// src/core/portal-login.ts
|
|
54168
|
+
var http = __toESM(require("http"));
|
|
54169
|
+
var import_crypto = require("crypto");
|
|
54170
|
+
var import_child_process10 = require("child_process");
|
|
54171
|
+
var CALLBACK_PATH = "/callback";
|
|
54172
|
+
var LOGIN_TIMEOUT_MS = 3 * 6e4;
|
|
54173
|
+
function openBrowser(url) {
|
|
54174
|
+
const [cmd, args] = process.platform === "darwin" ? ["open", [url]] : process.platform === "win32" ? ["cmd", ["/c", "start", "", url]] : ["xdg-open", [url]];
|
|
54175
|
+
try {
|
|
54176
|
+
const child = (0, import_child_process10.spawn)(cmd, args, { stdio: "ignore", detached: true });
|
|
54177
|
+
child.on("error", () => {
|
|
54178
|
+
});
|
|
54179
|
+
child.unref();
|
|
54180
|
+
} catch {
|
|
54181
|
+
}
|
|
54182
|
+
}
|
|
54183
|
+
async function loginViaBrowser(portalUrl, openUrl = openBrowser) {
|
|
54184
|
+
const state = (0, import_crypto.randomUUID)();
|
|
54185
|
+
return new Promise((resolve38, reject) => {
|
|
54186
|
+
let timer;
|
|
54187
|
+
const server = http.createServer((req, res) => {
|
|
54188
|
+
const requestUrl = new URL(req.url ?? "", "http://127.0.0.1");
|
|
54189
|
+
if (requestUrl.pathname !== CALLBACK_PATH) {
|
|
54190
|
+
res.writeHead(404);
|
|
54191
|
+
res.end("Not found");
|
|
54192
|
+
return;
|
|
54193
|
+
}
|
|
54194
|
+
const token = requestUrl.searchParams.get("token");
|
|
54195
|
+
const returnedState = requestUrl.searchParams.get("state");
|
|
54196
|
+
const workspace = requestUrl.searchParams.get("workspace") ?? void 0;
|
|
54197
|
+
if (returnedState !== state || !token) {
|
|
54198
|
+
res.writeHead(400, { "Content-Type": "text/html" });
|
|
54199
|
+
res.end("<h1>Login failed</h1><p>You can close this tab and try again.</p>");
|
|
54200
|
+
cleanup();
|
|
54201
|
+
reject(new Error("state mismatch or missing token"));
|
|
54202
|
+
return;
|
|
54203
|
+
}
|
|
54204
|
+
res.writeHead(200, { "Content-Type": "text/html" });
|
|
54205
|
+
res.end("<h1>Logged in</h1><p>You can close this tab and return to the terminal.</p>");
|
|
54206
|
+
cleanup();
|
|
54207
|
+
resolve38({ portalUrl, token, workspace, createdAt: (/* @__PURE__ */ new Date()).toISOString() });
|
|
54208
|
+
});
|
|
54209
|
+
const cleanup = () => {
|
|
54210
|
+
clearTimeout(timer);
|
|
54211
|
+
server.close();
|
|
54212
|
+
};
|
|
54213
|
+
server.on("error", (err) => {
|
|
54214
|
+
cleanup();
|
|
54215
|
+
reject(err);
|
|
54216
|
+
});
|
|
54217
|
+
server.listen(0, "127.0.0.1", () => {
|
|
54218
|
+
const { port } = server.address();
|
|
54219
|
+
const callback = `http://127.0.0.1:${port}${CALLBACK_PATH}`;
|
|
54220
|
+
const loginUrl = `${portalUrl}/cli/login?callback=${encodeURIComponent(callback)}&state=${state}`;
|
|
54221
|
+
openUrl(loginUrl);
|
|
54222
|
+
process.stderr.write(`Opening ${loginUrl}
|
|
54223
|
+
If your browser did not open, paste that URL.
|
|
54224
|
+
`);
|
|
54225
|
+
timer = setTimeout(() => {
|
|
54226
|
+
cleanup();
|
|
54227
|
+
reject(new Error("timed out"));
|
|
54228
|
+
}, LOGIN_TIMEOUT_MS);
|
|
54229
|
+
});
|
|
54230
|
+
});
|
|
54231
|
+
}
|
|
54061
54232
|
|
|
54062
54233
|
// src/core/control-unregister.ts
|
|
54063
|
-
var
|
|
54064
|
-
var
|
|
54234
|
+
var fs44 = __toESM(require("fs"));
|
|
54235
|
+
var path48 = __toESM(require("path"));
|
|
54065
54236
|
init_control_config();
|
|
54066
54237
|
function listUnregisterWorktreeCandidates(repoPath) {
|
|
54067
54238
|
const harnessRoot = canonicalizeControlRepoPath(repoPath);
|
|
54068
54239
|
const byPath = /* @__PURE__ */ new Map();
|
|
54069
54240
|
const add = (partial2) => {
|
|
54070
|
-
const resolved =
|
|
54241
|
+
const resolved = path48.resolve(partial2.worktreePath);
|
|
54071
54242
|
if (!resolved || resolved === harnessRoot) return;
|
|
54072
|
-
const exists = partial2.exists ??
|
|
54243
|
+
const exists = partial2.exists ?? fs44.existsSync(resolved);
|
|
54073
54244
|
const prev = byPath.get(resolved);
|
|
54074
54245
|
if (prev) {
|
|
54075
54246
|
byPath.set(resolved, {
|
|
@@ -54120,8 +54291,8 @@ async function askYesNo5(question) {
|
|
|
54120
54291
|
if (!process.stdin.isTTY || !process.stdout.isTTY) return false;
|
|
54121
54292
|
const readline9 = await import("readline");
|
|
54122
54293
|
const rl = readline9.createInterface({ input: process.stdin, output: process.stderr });
|
|
54123
|
-
const answer = await new Promise((
|
|
54124
|
-
rl.question(question,
|
|
54294
|
+
const answer = await new Promise((resolve38) => {
|
|
54295
|
+
rl.question(question, resolve38);
|
|
54125
54296
|
});
|
|
54126
54297
|
rl.close();
|
|
54127
54298
|
return /^[Yy]$/.test(answer.trim());
|
|
@@ -54183,28 +54354,28 @@ async function teardownWorktrees(repoPath, candidates, dryRun) {
|
|
|
54183
54354
|
trigger: "cli"
|
|
54184
54355
|
});
|
|
54185
54356
|
if (result.code !== 0) {
|
|
54186
|
-
if (
|
|
54187
|
-
|
|
54357
|
+
if (fs44.existsSync(candidate.worktreePath)) {
|
|
54358
|
+
fs44.rmSync(candidate.worktreePath, { recursive: true, force: true });
|
|
54188
54359
|
}
|
|
54189
54360
|
}
|
|
54190
54361
|
outcomes.push({
|
|
54191
54362
|
path: candidate.worktreePath,
|
|
54192
54363
|
agentId: candidate.agentId,
|
|
54193
|
-
deleted: !
|
|
54194
|
-
error: result.code !== 0 &&
|
|
54364
|
+
deleted: !fs44.existsSync(candidate.worktreePath),
|
|
54365
|
+
error: result.code !== 0 && fs44.existsSync(candidate.worktreePath) ? result.stderr : void 0
|
|
54195
54366
|
});
|
|
54196
54367
|
} catch (err) {
|
|
54197
54368
|
const message = err instanceof Error ? err.message : String(err);
|
|
54198
54369
|
try {
|
|
54199
|
-
if (
|
|
54200
|
-
|
|
54370
|
+
if (fs44.existsSync(candidate.worktreePath)) {
|
|
54371
|
+
fs44.rmSync(candidate.worktreePath, { recursive: true, force: true });
|
|
54201
54372
|
}
|
|
54202
54373
|
} catch {
|
|
54203
54374
|
}
|
|
54204
54375
|
outcomes.push({
|
|
54205
54376
|
path: candidate.worktreePath,
|
|
54206
54377
|
agentId: candidate.agentId,
|
|
54207
|
-
deleted: !
|
|
54378
|
+
deleted: !fs44.existsSync(candidate.worktreePath),
|
|
54208
54379
|
error: message
|
|
54209
54380
|
});
|
|
54210
54381
|
}
|
|
@@ -54320,8 +54491,11 @@ var controlCommand = {
|
|
|
54320
54491
|
handleWatch
|
|
54321
54492
|
).command(
|
|
54322
54493
|
"login",
|
|
54323
|
-
"
|
|
54324
|
-
(y2) => y2.option("
|
|
54494
|
+
"Log in to a har-portal (browser SSO) and store an ingest token",
|
|
54495
|
+
(y2) => y2.option("portal", { type: "string", describe: "Portal base URL (or set HAR_PORTAL_URL)" }).option("api-key", {
|
|
54496
|
+
type: "string",
|
|
54497
|
+
describe: "Store this ingest token directly instead of browser login"
|
|
54498
|
+
}),
|
|
54325
54499
|
handleLogin
|
|
54326
54500
|
).demandCommand(
|
|
54327
54501
|
1,
|
|
@@ -54386,7 +54560,7 @@ async function handleDown() {
|
|
|
54386
54560
|
process.exit(code);
|
|
54387
54561
|
}
|
|
54388
54562
|
async function handleRegister(argv) {
|
|
54389
|
-
const repoPath =
|
|
54563
|
+
const repoPath = path49.resolve(argv.repo);
|
|
54390
54564
|
header("har control register");
|
|
54391
54565
|
info(`Repository: ${repoPath}`);
|
|
54392
54566
|
try {
|
|
@@ -54410,7 +54584,7 @@ async function handleRegister(argv) {
|
|
|
54410
54584
|
}
|
|
54411
54585
|
}
|
|
54412
54586
|
async function handleUnregister(argv) {
|
|
54413
|
-
const repoPath =
|
|
54587
|
+
const repoPath = path49.resolve(argv.repo);
|
|
54414
54588
|
const worktrees = listUnregisterWorktreeCandidates(repoPath);
|
|
54415
54589
|
try {
|
|
54416
54590
|
let deleteWorktrees = argv.deleteWorktrees;
|
|
@@ -54479,7 +54653,7 @@ async function handleUnregister(argv) {
|
|
|
54479
54653
|
}
|
|
54480
54654
|
}
|
|
54481
54655
|
async function handleSync(argv) {
|
|
54482
|
-
const repoPath =
|
|
54656
|
+
const repoPath = path49.resolve(argv.repo);
|
|
54483
54657
|
try {
|
|
54484
54658
|
await syncRepoWithControl({
|
|
54485
54659
|
repoPath,
|
|
@@ -54518,7 +54692,7 @@ async function handleWatch(argv) {
|
|
|
54518
54692
|
};
|
|
54519
54693
|
const tick = async () => {
|
|
54520
54694
|
if (argv.repo) {
|
|
54521
|
-
await syncOne(
|
|
54695
|
+
await syncOne(path49.resolve(argv.repo));
|
|
54522
54696
|
return;
|
|
54523
54697
|
}
|
|
54524
54698
|
try {
|
|
@@ -54539,21 +54713,40 @@ async function handleWatch(argv) {
|
|
|
54539
54713
|
}
|
|
54540
54714
|
async function handleLogin(argv) {
|
|
54541
54715
|
header("har control login");
|
|
54542
|
-
|
|
54543
|
-
|
|
54716
|
+
const portalUrl = (argv.portal ?? process.env.HAR_PORTAL_URL ?? "").replace(/\/+$/, "");
|
|
54717
|
+
if (!portalUrl) {
|
|
54718
|
+
error("Provide --portal <url> (or set HAR_PORTAL_URL)");
|
|
54719
|
+
process.exit(1);
|
|
54720
|
+
}
|
|
54721
|
+
if (argv.apiKey) {
|
|
54722
|
+
writePortalCredentials({
|
|
54723
|
+
portalUrl,
|
|
54724
|
+
token: argv.apiKey,
|
|
54725
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
54726
|
+
});
|
|
54727
|
+
success(`Saved ingest token for ${portalUrl}`);
|
|
54728
|
+
info("Sync: har control sync");
|
|
54729
|
+
return;
|
|
54730
|
+
}
|
|
54731
|
+
try {
|
|
54732
|
+
const creds = await loginViaBrowser(portalUrl);
|
|
54733
|
+
writePortalCredentials(creds);
|
|
54734
|
+
success(
|
|
54735
|
+
`Logged in to ${portalUrl}${creds.workspace ? ` (workspace: ${creds.workspace})` : ""}`
|
|
54736
|
+
);
|
|
54737
|
+
info("Sync: har control sync");
|
|
54738
|
+
} catch (err) {
|
|
54739
|
+
error(`Login failed: ${err.message}`);
|
|
54544
54740
|
process.exit(1);
|
|
54545
54741
|
}
|
|
54546
|
-
process.env.HAR_CLOUD_API_KEY = argv.apiKey;
|
|
54547
|
-
success("HAR_CLOUD_API_KEY set for this process. Export it in your shell for persistence.");
|
|
54548
|
-
info("Sync to cloud: har control sync --cloud");
|
|
54549
54742
|
}
|
|
54550
54743
|
|
|
54551
54744
|
// src/cli/commands/hooks.ts
|
|
54552
|
-
var
|
|
54745
|
+
var path51 = __toESM(require("path"));
|
|
54553
54746
|
|
|
54554
54747
|
// src/core/claude-hooks.ts
|
|
54555
|
-
var
|
|
54556
|
-
var
|
|
54748
|
+
var fs45 = __toESM(require("fs"));
|
|
54749
|
+
var path50 = __toESM(require("path"));
|
|
54557
54750
|
var CLAUDE_GUARD_RELATIVE_PATH = ".har/hooks/claude-worktree-guard.sh";
|
|
54558
54751
|
var CLAUDE_SETTINGS_RELATIVE_PATH = ".claude/settings.json";
|
|
54559
54752
|
var GUARD_MATCHER = "Edit|Write|MultiEdit|NotebookEdit";
|
|
@@ -54564,8 +54757,8 @@ function isHarGuardEntry(entry) {
|
|
|
54564
54757
|
);
|
|
54565
54758
|
}
|
|
54566
54759
|
function readSettings(settingsPath) {
|
|
54567
|
-
if (!
|
|
54568
|
-
const raw =
|
|
54760
|
+
if (!fs45.existsSync(settingsPath)) return {};
|
|
54761
|
+
const raw = fs45.readFileSync(settingsPath, "utf8").trim();
|
|
54569
54762
|
if (raw === "") return {};
|
|
54570
54763
|
const parsed = JSON.parse(raw);
|
|
54571
54764
|
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
@@ -54574,19 +54767,19 @@ function readSettings(settingsPath) {
|
|
|
54574
54767
|
return parsed;
|
|
54575
54768
|
}
|
|
54576
54769
|
function writeSettings(settingsPath, settings) {
|
|
54577
|
-
|
|
54578
|
-
|
|
54770
|
+
fs45.mkdirSync(path50.dirname(settingsPath), { recursive: true });
|
|
54771
|
+
fs45.writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + "\n");
|
|
54579
54772
|
}
|
|
54580
54773
|
function installClaudeGuard(repoPath) {
|
|
54581
54774
|
const templatePath = resolveTemplateFile("claude-worktree-guard.sh.template");
|
|
54582
54775
|
if (!templatePath) {
|
|
54583
54776
|
throw new Error("Guard template not found (claude-worktree-guard.sh.template). Run npm run build.");
|
|
54584
54777
|
}
|
|
54585
|
-
const guardScript =
|
|
54586
|
-
|
|
54587
|
-
|
|
54588
|
-
|
|
54589
|
-
const settingsPath =
|
|
54778
|
+
const guardScript = path50.join(repoPath, CLAUDE_GUARD_RELATIVE_PATH);
|
|
54779
|
+
fs45.mkdirSync(path50.dirname(guardScript), { recursive: true });
|
|
54780
|
+
fs45.copyFileSync(templatePath, guardScript);
|
|
54781
|
+
fs45.chmodSync(guardScript, 493);
|
|
54782
|
+
const settingsPath = path50.join(repoPath, CLAUDE_SETTINGS_RELATIVE_PATH);
|
|
54590
54783
|
const settings = readSettings(settingsPath);
|
|
54591
54784
|
const hooks = settings.hooks ?? {};
|
|
54592
54785
|
const preToolUse = (hooks.PreToolUse ?? []).filter((entry) => !isHarGuardEntry(entry));
|
|
@@ -54600,15 +54793,15 @@ function installClaudeGuard(repoPath) {
|
|
|
54600
54793
|
}
|
|
54601
54794
|
function uninstallClaudeGuard(repoPath) {
|
|
54602
54795
|
let removed = false;
|
|
54603
|
-
const guardScript =
|
|
54604
|
-
if (
|
|
54605
|
-
|
|
54796
|
+
const guardScript = path50.join(repoPath, CLAUDE_GUARD_RELATIVE_PATH);
|
|
54797
|
+
if (fs45.existsSync(guardScript)) {
|
|
54798
|
+
fs45.rmSync(guardScript);
|
|
54606
54799
|
removed = true;
|
|
54607
|
-
const parent =
|
|
54608
|
-
if (
|
|
54800
|
+
const parent = path50.dirname(guardScript);
|
|
54801
|
+
if (fs45.existsSync(parent) && fs45.readdirSync(parent).length === 0) fs45.rmdirSync(parent);
|
|
54609
54802
|
}
|
|
54610
|
-
const settingsPath =
|
|
54611
|
-
if (
|
|
54803
|
+
const settingsPath = path50.join(repoPath, CLAUDE_SETTINGS_RELATIVE_PATH);
|
|
54804
|
+
if (fs45.existsSync(settingsPath)) {
|
|
54612
54805
|
const settings = readSettings(settingsPath);
|
|
54613
54806
|
const preToolUse = settings.hooks?.PreToolUse;
|
|
54614
54807
|
if (preToolUse) {
|
|
@@ -54633,8 +54826,8 @@ function uninstallClaudeGuard(repoPath) {
|
|
|
54633
54826
|
return { removed };
|
|
54634
54827
|
}
|
|
54635
54828
|
function claudeGuardInstalled(repoPath) {
|
|
54636
|
-
const settingsPath =
|
|
54637
|
-
if (!
|
|
54829
|
+
const settingsPath = path50.join(repoPath, CLAUDE_SETTINGS_RELATIVE_PATH);
|
|
54830
|
+
if (!fs45.existsSync(settingsPath)) return false;
|
|
54638
54831
|
try {
|
|
54639
54832
|
const settings = readSettings(settingsPath);
|
|
54640
54833
|
return (settings.hooks?.PreToolUse ?? []).some(isHarGuardEntry);
|
|
@@ -54650,7 +54843,7 @@ function repoOption(y2) {
|
|
|
54650
54843
|
function handleInstall2(argv) {
|
|
54651
54844
|
try {
|
|
54652
54845
|
if (argv.claude) {
|
|
54653
|
-
const result2 = installClaudeGuard(
|
|
54846
|
+
const result2 = installClaudeGuard(path51.resolve(argv.repo));
|
|
54654
54847
|
success("Claude Code worktree guard installed.");
|
|
54655
54848
|
info(`Guard script: ${result2.guardScript}`);
|
|
54656
54849
|
info(`Settings: ${result2.settingsPath} (PreToolUse: Edit|Write|MultiEdit|NotebookEdit)`);
|
|
@@ -54658,7 +54851,7 @@ function handleInstall2(argv) {
|
|
|
54658
54851
|
info("Commit both files so the guard travels with the repo.");
|
|
54659
54852
|
return;
|
|
54660
54853
|
}
|
|
54661
|
-
const result = installHooks({ repoPath:
|
|
54854
|
+
const result = installHooks({ repoPath: path51.resolve(argv.repo), force: argv.force });
|
|
54662
54855
|
success(`Commit gate installed in ${result.hooksDir}`);
|
|
54663
54856
|
info(`pre-commit: ${result.preCommit}, post-commit: ${result.postCommit}`);
|
|
54664
54857
|
info("Commits of unverified change batches will be blocked in agent worktrees.");
|
|
@@ -54671,7 +54864,7 @@ function handleInstall2(argv) {
|
|
|
54671
54864
|
function handleUninstall(argv) {
|
|
54672
54865
|
try {
|
|
54673
54866
|
if (argv.claude) {
|
|
54674
|
-
const result2 = uninstallClaudeGuard(
|
|
54867
|
+
const result2 = uninstallClaudeGuard(path51.resolve(argv.repo));
|
|
54675
54868
|
if (result2.removed) {
|
|
54676
54869
|
success("Claude Code worktree guard removed.");
|
|
54677
54870
|
} else {
|
|
@@ -54679,7 +54872,7 @@ function handleUninstall(argv) {
|
|
|
54679
54872
|
}
|
|
54680
54873
|
return;
|
|
54681
54874
|
}
|
|
54682
|
-
const result = uninstallHooks(
|
|
54875
|
+
const result = uninstallHooks(path51.resolve(argv.repo));
|
|
54683
54876
|
if (result.removed) {
|
|
54684
54877
|
success(`Commit gate removed from ${result.hooksDir}`);
|
|
54685
54878
|
} else {
|
|
@@ -54692,7 +54885,7 @@ function handleUninstall(argv) {
|
|
|
54692
54885
|
}
|
|
54693
54886
|
function handleStatus2(argv) {
|
|
54694
54887
|
try {
|
|
54695
|
-
const status = getHooksStatus(
|
|
54888
|
+
const status = getHooksStatus(path51.resolve(argv.repo));
|
|
54696
54889
|
if (argv.json) {
|
|
54697
54890
|
process.stdout.write(`${JSON.stringify(status, null, 2)}
|
|
54698
54891
|
`);
|
|
@@ -54710,7 +54903,7 @@ function handleStatus2(argv) {
|
|
|
54710
54903
|
);
|
|
54711
54904
|
info(`Effective: ${status.effectiveMode} (in this checkout)`);
|
|
54712
54905
|
info(
|
|
54713
|
-
`Claude guard: ${claudeGuardInstalled(
|
|
54906
|
+
`Claude guard: ${claudeGuardInstalled(path51.resolve(argv.repo)) ? `installed (${CLAUDE_GUARD_RELATIVE_PATH})` : "not installed"}`
|
|
54714
54907
|
);
|
|
54715
54908
|
} catch (err) {
|
|
54716
54909
|
error(err instanceof Error ? err.message : String(err));
|
|
@@ -54971,10 +55164,10 @@ function assignProp(target, prop, value) {
|
|
|
54971
55164
|
configurable: true
|
|
54972
55165
|
});
|
|
54973
55166
|
}
|
|
54974
|
-
function getElementAtPath(obj,
|
|
54975
|
-
if (!
|
|
55167
|
+
function getElementAtPath(obj, path54) {
|
|
55168
|
+
if (!path54)
|
|
54976
55169
|
return obj;
|
|
54977
|
-
return
|
|
55170
|
+
return path54.reduce((acc, key) => acc?.[key], obj);
|
|
54978
55171
|
}
|
|
54979
55172
|
function promiseAllObject(promisesObj) {
|
|
54980
55173
|
const keys = Object.keys(promisesObj);
|
|
@@ -55294,11 +55487,11 @@ function aborted(x2, startIndex = 0) {
|
|
|
55294
55487
|
}
|
|
55295
55488
|
return false;
|
|
55296
55489
|
}
|
|
55297
|
-
function prefixIssues(
|
|
55490
|
+
function prefixIssues(path54, issues) {
|
|
55298
55491
|
return issues.map((iss) => {
|
|
55299
55492
|
var _a3;
|
|
55300
55493
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
55301
|
-
iss.path.unshift(
|
|
55494
|
+
iss.path.unshift(path54);
|
|
55302
55495
|
return iss;
|
|
55303
55496
|
});
|
|
55304
55497
|
}
|
|
@@ -60621,7 +60814,7 @@ var Protocol = class {
|
|
|
60621
60814
|
return;
|
|
60622
60815
|
}
|
|
60623
60816
|
const pollInterval = task2.pollInterval ?? this._options?.defaultTaskPollInterval ?? 1e3;
|
|
60624
|
-
await new Promise((
|
|
60817
|
+
await new Promise((resolve38) => setTimeout(resolve38, pollInterval));
|
|
60625
60818
|
options?.signal?.throwIfAborted();
|
|
60626
60819
|
}
|
|
60627
60820
|
} catch (error3) {
|
|
@@ -60638,7 +60831,7 @@ var Protocol = class {
|
|
|
60638
60831
|
*/
|
|
60639
60832
|
request(request, resultSchema, options) {
|
|
60640
60833
|
const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
|
|
60641
|
-
return new Promise((
|
|
60834
|
+
return new Promise((resolve38, reject) => {
|
|
60642
60835
|
const earlyReject = (error3) => {
|
|
60643
60836
|
reject(error3);
|
|
60644
60837
|
};
|
|
@@ -60716,7 +60909,7 @@ var Protocol = class {
|
|
|
60716
60909
|
if (!parseResult.success) {
|
|
60717
60910
|
reject(parseResult.error);
|
|
60718
60911
|
} else {
|
|
60719
|
-
|
|
60912
|
+
resolve38(parseResult.data);
|
|
60720
60913
|
}
|
|
60721
60914
|
} catch (error3) {
|
|
60722
60915
|
reject(error3);
|
|
@@ -60977,12 +61170,12 @@ var Protocol = class {
|
|
|
60977
61170
|
}
|
|
60978
61171
|
} catch {
|
|
60979
61172
|
}
|
|
60980
|
-
return new Promise((
|
|
61173
|
+
return new Promise((resolve38, reject) => {
|
|
60981
61174
|
if (signal.aborted) {
|
|
60982
61175
|
reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
60983
61176
|
return;
|
|
60984
61177
|
}
|
|
60985
|
-
const timeoutId = setTimeout(
|
|
61178
|
+
const timeoutId = setTimeout(resolve38, interval);
|
|
60986
61179
|
signal.addEventListener("abort", () => {
|
|
60987
61180
|
clearTimeout(timeoutId);
|
|
60988
61181
|
reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
@@ -61772,7 +61965,7 @@ var Server = class extends Protocol {
|
|
|
61772
61965
|
};
|
|
61773
61966
|
|
|
61774
61967
|
// src/mcp/server.ts
|
|
61775
|
-
var
|
|
61968
|
+
var path52 = __toESM(require("path"));
|
|
61776
61969
|
|
|
61777
61970
|
// node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
|
|
61778
61971
|
var import_node_process2 = __toESM(require("node:process"), 1);
|
|
@@ -61855,12 +62048,12 @@ var StdioServerTransport = class {
|
|
|
61855
62048
|
this.onclose?.();
|
|
61856
62049
|
}
|
|
61857
62050
|
send(message) {
|
|
61858
|
-
return new Promise((
|
|
62051
|
+
return new Promise((resolve38) => {
|
|
61859
62052
|
const json = serializeMessage(message);
|
|
61860
62053
|
if (this._stdout.write(json)) {
|
|
61861
|
-
|
|
62054
|
+
resolve38();
|
|
61862
62055
|
} else {
|
|
61863
|
-
this._stdout.once("drain",
|
|
62056
|
+
this._stdout.once("drain", resolve38);
|
|
61864
62057
|
}
|
|
61865
62058
|
});
|
|
61866
62059
|
}
|
|
@@ -62432,7 +62625,7 @@ async function handleMcpToolCall(toolName, args, defaultRepo = ".") {
|
|
|
62432
62625
|
const input = ControlUpInputSchema.parse({ ...args, repo });
|
|
62433
62626
|
const result = await startControlAndSync({
|
|
62434
62627
|
detach: input.detach,
|
|
62435
|
-
cwd:
|
|
62628
|
+
cwd: path52.resolve(input.repo)
|
|
62436
62629
|
});
|
|
62437
62630
|
if (result.code !== 0) {
|
|
62438
62631
|
return {
|
|
@@ -63512,13 +63705,13 @@ var PromisePolyfill = class extends Promise {
|
|
|
63512
63705
|
// Available starting from Node 22
|
|
63513
63706
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/withResolvers
|
|
63514
63707
|
static withResolver() {
|
|
63515
|
-
let
|
|
63708
|
+
let resolve38;
|
|
63516
63709
|
let reject;
|
|
63517
63710
|
const promise = new Promise((res, rej) => {
|
|
63518
|
-
|
|
63711
|
+
resolve38 = res;
|
|
63519
63712
|
reject = rej;
|
|
63520
63713
|
});
|
|
63521
|
-
return { promise, resolve:
|
|
63714
|
+
return { promise, resolve: resolve38, reject };
|
|
63522
63715
|
}
|
|
63523
63716
|
};
|
|
63524
63717
|
|
|
@@ -63535,7 +63728,7 @@ function createPrompt(view) {
|
|
|
63535
63728
|
output
|
|
63536
63729
|
});
|
|
63537
63730
|
const screen = new ScreenManager(rl);
|
|
63538
|
-
const { promise, resolve:
|
|
63731
|
+
const { promise, resolve: resolve38, reject } = PromisePolyfill.withResolver();
|
|
63539
63732
|
const cancel = () => reject(new CancelPromptError());
|
|
63540
63733
|
if (signal) {
|
|
63541
63734
|
const abort = () => reject(new AbortPromptError({ cause: signal.reason }));
|
|
@@ -63559,7 +63752,7 @@ function createPrompt(view) {
|
|
|
63559
63752
|
cycle(() => {
|
|
63560
63753
|
try {
|
|
63561
63754
|
const nextView = view(config2, (value) => {
|
|
63562
|
-
setImmediate(() =>
|
|
63755
|
+
setImmediate(() => resolve38(value));
|
|
63563
63756
|
});
|
|
63564
63757
|
const [content, bottomContent] = typeof nextView === "string" ? [nextView] : nextView;
|
|
63565
63758
|
screen.render(content, bottomContent);
|
|
@@ -64546,9 +64739,9 @@ var import_run_async = __toESM(require_run_async(), 1);
|
|
|
64546
64739
|
var import_mute_stream2 = __toESM(require_lib3(), 1);
|
|
64547
64740
|
var import_ansi_escapes5 = __toESM(require_ansi_escapes(), 1);
|
|
64548
64741
|
var _2 = {
|
|
64549
|
-
set: (obj,
|
|
64742
|
+
set: (obj, path54 = "", value) => {
|
|
64550
64743
|
let pointer = obj;
|
|
64551
|
-
|
|
64744
|
+
path54.split(".").forEach((key, index, arr) => {
|
|
64552
64745
|
if (key === "__proto__" || key === "constructor")
|
|
64553
64746
|
return;
|
|
64554
64747
|
if (index === arr.length - 1) {
|
|
@@ -64559,8 +64752,8 @@ var _2 = {
|
|
|
64559
64752
|
pointer = pointer[key];
|
|
64560
64753
|
});
|
|
64561
64754
|
},
|
|
64562
|
-
get: (obj,
|
|
64563
|
-
const travel = (regexp) => String.prototype.split.call(
|
|
64755
|
+
get: (obj, path54 = "", defaultValue) => {
|
|
64756
|
+
const travel = (regexp) => String.prototype.split.call(path54, regexp).filter(Boolean).reduce(
|
|
64564
64757
|
// @ts-expect-error implicit any on res[key]
|
|
64565
64758
|
(res, key) => res !== null && res !== void 0 ? res[key] : res,
|
|
64566
64759
|
obj
|
|
@@ -64674,7 +64867,7 @@ var PromptsRunner = class {
|
|
|
64674
64867
|
throw new Error(`Prompt for type ${question.type} not found`);
|
|
64675
64868
|
}
|
|
64676
64869
|
let cleanupSignal;
|
|
64677
|
-
const promptFn = isPromptConstructor(prompt2) ? (q2, { signal: signal2 } = {}) => new Promise((
|
|
64870
|
+
const promptFn = isPromptConstructor(prompt2) ? (q2, { signal: signal2 } = {}) => new Promise((resolve38, reject) => {
|
|
64678
64871
|
const rl = import_node_readline.default.createInterface(setupReadlineOptions(this.opt));
|
|
64679
64872
|
rl.resume();
|
|
64680
64873
|
const onClose = () => {
|
|
@@ -64710,7 +64903,7 @@ var PromptsRunner = class {
|
|
|
64710
64903
|
cleanupSignal = void 0;
|
|
64711
64904
|
};
|
|
64712
64905
|
}
|
|
64713
|
-
activePrompt.run().then(
|
|
64906
|
+
activePrompt.run().then(resolve38, reject).finally(cleanup);
|
|
64714
64907
|
}) : prompt2;
|
|
64715
64908
|
const { signal: moduleSignal } = this.opt;
|
|
64716
64909
|
if (moduleSignal?.aborted) {
|
|
@@ -64924,7 +65117,7 @@ var preferencesCommand = {
|
|
|
64924
65117
|
};
|
|
64925
65118
|
|
|
64926
65119
|
// src/cli/commands/telemetry.ts
|
|
64927
|
-
var
|
|
65120
|
+
var path53 = __toESM(require("path"));
|
|
64928
65121
|
init_control_config();
|
|
64929
65122
|
init_otel_hooks();
|
|
64930
65123
|
init_telemetry_config();
|
|
@@ -65009,7 +65202,7 @@ async function handleOff() {
|
|
|
65009
65202
|
info("Mission Control will not auto-start. Existing usage rows are kept.");
|
|
65010
65203
|
}
|
|
65011
65204
|
async function handleWriteEnv(argv) {
|
|
65012
|
-
const repoPath =
|
|
65205
|
+
const repoPath = path53.resolve(argv.repo);
|
|
65013
65206
|
const harnessRoot = resolveHarnessRoot(repoPath);
|
|
65014
65207
|
const session = readSlotRegistry(harnessRoot, argv.agentId);
|
|
65015
65208
|
const workDir = argv.workDir ?? session?.workDir ?? repoPath;
|
|
@@ -65021,7 +65214,7 @@ async function handleWriteEnv(argv) {
|
|
|
65021
65214
|
suffix,
|
|
65022
65215
|
createdAt: session?.createdAt
|
|
65023
65216
|
});
|
|
65024
|
-
const envFile = argv.envFile ??
|
|
65217
|
+
const envFile = argv.envFile ?? path53.join(workDir, `.env.agent.${argv.agentId}`);
|
|
65025
65218
|
const attrs = {
|
|
65026
65219
|
sessionKey,
|
|
65027
65220
|
agentId: argv.agentId,
|
|
@@ -65040,7 +65233,7 @@ async function handleWriteEnv(argv) {
|
|
|
65040
65233
|
success(`Wrote session attribution to ${envFile}`);
|
|
65041
65234
|
}
|
|
65042
65235
|
function handlePrintEnv(argv) {
|
|
65043
|
-
const repoPath =
|
|
65236
|
+
const repoPath = path53.resolve(argv.repo);
|
|
65044
65237
|
const workDir = argv.workDir ?? repoPath;
|
|
65045
65238
|
const sessionKey = buildSessionKey({
|
|
65046
65239
|
branch: argv.branch,
|