@osfactory/har 0.18.0 → 0.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +486 -422
- 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 path50 = url.path;
|
|
769
|
+
if (path50.length === 0) {
|
|
770
770
|
return;
|
|
771
771
|
}
|
|
772
|
-
if (url.scheme === "file" &&
|
|
772
|
+
if (url.scheme === "file" && path50.length === 1 && isNormalizedWindowsDriveLetter(path50[0])) {
|
|
773
773
|
return;
|
|
774
774
|
}
|
|
775
|
-
|
|
775
|
+
path50.pop();
|
|
776
776
|
}
|
|
777
777
|
function includesCredentials(url) {
|
|
778
778
|
return url.username !== "" || url.password !== "";
|
|
@@ -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(resolve35, 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
|
+
resolve35(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
|
}
|
|
@@ -2801,7 +2801,7 @@ 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(resolve35, reject) {
|
|
2805
2805
|
const request = new Request3(url, opts);
|
|
2806
2806
|
const options = getNodeRequestOptions(request);
|
|
2807
2807
|
const send = (options.protocol === "https:" ? https : http).request;
|
|
@@ -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
|
+
resolve35(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
|
+
resolve35(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
|
+
resolve35(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
|
+
resolve35(response);
|
|
2981
2981
|
});
|
|
2982
2982
|
raw.on("end", function() {
|
|
2983
2983
|
if (!response) {
|
|
2984
2984
|
response = new Response3(body, response_options);
|
|
2985
|
-
|
|
2985
|
+
resolve35(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
|
+
resolve35(response);
|
|
2994
2994
|
return;
|
|
2995
2995
|
}
|
|
2996
2996
|
response = new Response3(body, response_options);
|
|
2997
|
-
|
|
2997
|
+
resolve35(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(path50, { 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: path50, size, lastModified: mtimeMs });
|
|
6362
6362
|
if (!filename) {
|
|
6363
6363
|
filename = file.name;
|
|
6364
6364
|
}
|
|
@@ -6367,13 +6367,13 @@ function createFileFromPath(path49, { 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(path50, filenameOrOptions, options = {}) {
|
|
6371
|
+
const stats = (0, import_fs5.statSync)(path50);
|
|
6372
|
+
return createFileFromPath(path50, stats, filenameOrOptions, options);
|
|
6373
6373
|
}
|
|
6374
|
-
async function fileFromPath2(
|
|
6375
|
-
const stats = await import_fs5.promises.stat(
|
|
6376
|
-
return createFileFromPath(
|
|
6374
|
+
async function fileFromPath2(path50, filenameOrOptions, options) {
|
|
6375
|
+
const stats = await import_fs5.promises.stat(path50);
|
|
6376
|
+
return createFileFromPath(path50, 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({
|
|
@@ -6451,9 +6451,9 @@ var init_control_config = __esm({
|
|
|
6451
6451
|
// src/core/telemetry-config.ts
|
|
6452
6452
|
function getPreferencePath() {
|
|
6453
6453
|
if (process.env.HAR_TELEMETRY_CONFIG_PATH) {
|
|
6454
|
-
return
|
|
6454
|
+
return path35.resolve(process.env.HAR_TELEMETRY_CONFIG_PATH);
|
|
6455
6455
|
}
|
|
6456
|
-
return
|
|
6456
|
+
return path35.join(os9.homedir(), ".har", "telemetry.json");
|
|
6457
6457
|
}
|
|
6458
6458
|
function parseEnvOverride(raw) {
|
|
6459
6459
|
if (raw === void 0 || raw === "") return void 0;
|
|
@@ -6474,10 +6474,10 @@ function normalizeSignals(enabled, raw) {
|
|
|
6474
6474
|
function readTelemetryPreference() {
|
|
6475
6475
|
const preferencePath = getPreferencePath();
|
|
6476
6476
|
try {
|
|
6477
|
-
if (!
|
|
6477
|
+
if (!fs35.existsSync(preferencePath)) {
|
|
6478
6478
|
return { enabled: true, signals: { ...DEFAULT_SIGNALS_ON } };
|
|
6479
6479
|
}
|
|
6480
|
-
const parsed = JSON.parse(
|
|
6480
|
+
const parsed = JSON.parse(fs35.readFileSync(preferencePath, "utf8"));
|
|
6481
6481
|
const enabled = parsed.enabled !== false;
|
|
6482
6482
|
return {
|
|
6483
6483
|
enabled,
|
|
@@ -6500,8 +6500,8 @@ function writeTelemetryPreference(enabled, signals) {
|
|
|
6500
6500
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
6501
6501
|
};
|
|
6502
6502
|
const preferencePath = getPreferencePath();
|
|
6503
|
-
|
|
6504
|
-
|
|
6503
|
+
fs35.mkdirSync(path35.dirname(preferencePath), { recursive: true });
|
|
6504
|
+
fs35.writeFileSync(preferencePath, JSON.stringify(preference, null, 2) + "\n");
|
|
6505
6505
|
return preference;
|
|
6506
6506
|
}
|
|
6507
6507
|
function isTelemetryEnabled() {
|
|
@@ -6516,13 +6516,13 @@ function getTelemetrySignals() {
|
|
|
6516
6516
|
function getTelemetryPreferencePath() {
|
|
6517
6517
|
return getPreferencePath();
|
|
6518
6518
|
}
|
|
6519
|
-
var
|
|
6519
|
+
var fs35, os9, path35, DEFAULT_SIGNALS_ON, DEFAULT_SIGNALS_OFF, TELEMETRY_SIGNALS;
|
|
6520
6520
|
var init_telemetry_config = __esm({
|
|
6521
6521
|
"src/core/telemetry-config.ts"() {
|
|
6522
6522
|
"use strict";
|
|
6523
|
-
|
|
6523
|
+
fs35 = __toESM(require("fs"));
|
|
6524
6524
|
os9 = __toESM(require("os"));
|
|
6525
|
-
|
|
6525
|
+
path35 = __toESM(require("path"));
|
|
6526
6526
|
DEFAULT_SIGNALS_ON = {
|
|
6527
6527
|
metrics: true,
|
|
6528
6528
|
logs: true,
|
|
@@ -6563,15 +6563,15 @@ __export(otel_hooks_exports, {
|
|
|
6563
6563
|
});
|
|
6564
6564
|
function getOtelHooksHome() {
|
|
6565
6565
|
if (process.env.HAR_OTEL_HOOKS_HOME) {
|
|
6566
|
-
return
|
|
6566
|
+
return path41.resolve(process.env.HAR_OTEL_HOOKS_HOME);
|
|
6567
6567
|
}
|
|
6568
|
-
return
|
|
6568
|
+
return path41.join(os12.homedir(), ".har", "otel-hooks");
|
|
6569
6569
|
}
|
|
6570
6570
|
function getOtelHooksConfigPath(hooksHome = getOtelHooksHome()) {
|
|
6571
|
-
return
|
|
6571
|
+
return path41.join(hooksHome, "otel_config.json");
|
|
6572
6572
|
}
|
|
6573
6573
|
function getOtelHooksWrapperPath(hooksHome = getOtelHooksHome()) {
|
|
6574
|
-
return
|
|
6574
|
+
return path41.join(hooksHome, "run-otel-hook.sh");
|
|
6575
6575
|
}
|
|
6576
6576
|
function buildOtelHooksConfig(options) {
|
|
6577
6577
|
const enabled = options?.enabled ?? isTelemetryEnabled();
|
|
@@ -6590,18 +6590,18 @@ function buildOtelHooksConfig(options) {
|
|
|
6590
6590
|
};
|
|
6591
6591
|
}
|
|
6592
6592
|
function writeOtelHooksConfig(config2, hooksHome = getOtelHooksHome()) {
|
|
6593
|
-
|
|
6593
|
+
fs39.mkdirSync(hooksHome, { recursive: true });
|
|
6594
6594
|
const configPath = getOtelHooksConfigPath(hooksHome);
|
|
6595
6595
|
const payload = {
|
|
6596
6596
|
_comment: "Managed by har telemetry \u2014 do not edit by hand; use: har telemetry on|off",
|
|
6597
6597
|
...config2
|
|
6598
6598
|
};
|
|
6599
|
-
|
|
6599
|
+
fs39.writeFileSync(configPath, `${JSON.stringify(payload, null, 2)}
|
|
6600
6600
|
`);
|
|
6601
6601
|
return configPath;
|
|
6602
6602
|
}
|
|
6603
6603
|
function writeOtelHooksWrapper(otelHookCommand, hooksHome = getOtelHooksHome()) {
|
|
6604
|
-
|
|
6604
|
+
fs39.mkdirSync(hooksHome, { recursive: true });
|
|
6605
6605
|
const wrapperPath = getOtelHooksWrapperPath(hooksHome);
|
|
6606
6606
|
const script = `#!/usr/bin/env bash
|
|
6607
6607
|
# Managed by har telemetry \u2014 invokes opentelemetry-hooks with HAR config home.
|
|
@@ -6609,9 +6609,9 @@ set -euo pipefail
|
|
|
6609
6609
|
export IDE_OTEL_HOOK_HOME="${hooksHome}"
|
|
6610
6610
|
exec "${otelHookCommand}" "$@"
|
|
6611
6611
|
`;
|
|
6612
|
-
|
|
6612
|
+
fs39.writeFileSync(wrapperPath, script, { mode: 493 });
|
|
6613
6613
|
try {
|
|
6614
|
-
|
|
6614
|
+
fs39.chmodSync(wrapperPath, 493);
|
|
6615
6615
|
} catch {
|
|
6616
6616
|
}
|
|
6617
6617
|
return wrapperPath;
|
|
@@ -6691,10 +6691,10 @@ function runSetupAgent(agent, otelHookCommand, hooksHome) {
|
|
|
6691
6691
|
};
|
|
6692
6692
|
}
|
|
6693
6693
|
function rewriteHookCommandsToWrapper(filePath, wrapperPath) {
|
|
6694
|
-
if (!
|
|
6694
|
+
if (!fs39.existsSync(filePath)) return false;
|
|
6695
6695
|
let raw;
|
|
6696
6696
|
try {
|
|
6697
|
-
raw =
|
|
6697
|
+
raw = fs39.readFileSync(filePath, "utf8");
|
|
6698
6698
|
} catch {
|
|
6699
6699
|
return false;
|
|
6700
6700
|
}
|
|
@@ -6733,16 +6733,16 @@ function rewriteHookCommandsToWrapper(filePath, wrapperPath) {
|
|
|
6733
6733
|
return changed;
|
|
6734
6734
|
};
|
|
6735
6735
|
if (!walk(parsed)) return false;
|
|
6736
|
-
|
|
6736
|
+
fs39.writeFileSync(filePath, `${JSON.stringify(parsed, null, 2)}
|
|
6737
6737
|
`);
|
|
6738
6738
|
return true;
|
|
6739
6739
|
}
|
|
6740
6740
|
function rewriteKnownHookRegistrations(wrapperPath) {
|
|
6741
6741
|
const home = os12.homedir();
|
|
6742
6742
|
const candidates = [
|
|
6743
|
-
|
|
6744
|
-
|
|
6745
|
-
|
|
6743
|
+
path41.join(home, ".cursor", "hooks.json"),
|
|
6744
|
+
path41.join(home, ".claude", "settings.json"),
|
|
6745
|
+
path41.join(home, ".codex", "hooks.json")
|
|
6746
6746
|
];
|
|
6747
6747
|
for (const filePath of candidates) {
|
|
6748
6748
|
try {
|
|
@@ -6755,7 +6755,7 @@ function ensureOtelHooks(options) {
|
|
|
6755
6755
|
const hooksHome = getOtelHooksHome();
|
|
6756
6756
|
const errors = [];
|
|
6757
6757
|
const agentsSetup = [];
|
|
6758
|
-
|
|
6758
|
+
fs39.mkdirSync(hooksHome, { recursive: true });
|
|
6759
6759
|
let otelHookCommand = resolveOtelHookCommand();
|
|
6760
6760
|
if (!otelHookCommand) {
|
|
6761
6761
|
const installed = tryInstallPackage();
|
|
@@ -6824,14 +6824,14 @@ function ensureOtelHooks(options) {
|
|
|
6824
6824
|
function disableOtelHooksExport() {
|
|
6825
6825
|
return writeOtelHooksConfig(buildOtelHooksConfig({ enabled: false }));
|
|
6826
6826
|
}
|
|
6827
|
-
var import_child_process9,
|
|
6827
|
+
var import_child_process9, fs39, os12, path41, OTEL_HOOKS_PACKAGE, OTEL_HOOKS_AGENTS;
|
|
6828
6828
|
var init_otel_hooks = __esm({
|
|
6829
6829
|
"src/core/otel-hooks.ts"() {
|
|
6830
6830
|
"use strict";
|
|
6831
6831
|
import_child_process9 = require("child_process");
|
|
6832
|
-
|
|
6832
|
+
fs39 = __toESM(require("fs"));
|
|
6833
6833
|
os12 = __toESM(require("os"));
|
|
6834
|
-
|
|
6834
|
+
path41 = __toESM(require("path"));
|
|
6835
6835
|
init_control_config();
|
|
6836
6836
|
init_telemetry_config();
|
|
6837
6837
|
OTEL_HOOKS_PACKAGE = "opentelemetry-hooks==0.14.0";
|
|
@@ -9790,7 +9790,7 @@ var require_compile = __commonJS({
|
|
|
9790
9790
|
const schOrFunc = root.refs[ref];
|
|
9791
9791
|
if (schOrFunc)
|
|
9792
9792
|
return schOrFunc;
|
|
9793
|
-
let _sch =
|
|
9793
|
+
let _sch = resolve35.call(this, root, ref);
|
|
9794
9794
|
if (_sch === void 0) {
|
|
9795
9795
|
const schema = (_a3 = root.localRefs) === null || _a3 === void 0 ? void 0 : _a3[ref];
|
|
9796
9796
|
const { schemaId } = this.opts;
|
|
@@ -9817,7 +9817,7 @@ var require_compile = __commonJS({
|
|
|
9817
9817
|
function sameSchemaEnv(s1, s2) {
|
|
9818
9818
|
return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
|
|
9819
9819
|
}
|
|
9820
|
-
function
|
|
9820
|
+
function resolve35(root, ref) {
|
|
9821
9821
|
let sch;
|
|
9822
9822
|
while (typeof (sch = this.refs[ref]) == "string")
|
|
9823
9823
|
ref = sch;
|
|
@@ -10035,8 +10035,8 @@ var require_utils2 = __commonJS({
|
|
|
10035
10035
|
}
|
|
10036
10036
|
return ind;
|
|
10037
10037
|
}
|
|
10038
|
-
function removeDotSegments(
|
|
10039
|
-
let input =
|
|
10038
|
+
function removeDotSegments(path50) {
|
|
10039
|
+
let input = path50;
|
|
10040
10040
|
const output = [];
|
|
10041
10041
|
let nextSlash = -1;
|
|
10042
10042
|
let len = 0;
|
|
@@ -10288,8 +10288,8 @@ var require_schemes = __commonJS({
|
|
|
10288
10288
|
wsComponent.secure = void 0;
|
|
10289
10289
|
}
|
|
10290
10290
|
if (wsComponent.resourceName) {
|
|
10291
|
-
const [
|
|
10292
|
-
wsComponent.path =
|
|
10291
|
+
const [path50, query] = wsComponent.resourceName.split("?");
|
|
10292
|
+
wsComponent.path = path50 && path50 !== "/" ? path50 : void 0;
|
|
10293
10293
|
wsComponent.query = query;
|
|
10294
10294
|
wsComponent.resourceName = void 0;
|
|
10295
10295
|
}
|
|
@@ -10448,55 +10448,55 @@ var require_fast_uri = __commonJS({
|
|
|
10448
10448
|
}
|
|
10449
10449
|
return uri;
|
|
10450
10450
|
}
|
|
10451
|
-
function
|
|
10451
|
+
function resolve35(baseURI, relativeURI, options) {
|
|
10452
10452
|
const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
|
|
10453
10453
|
const resolved = resolveComponent(parse4(baseURI, schemelessOptions), parse4(relativeURI, schemelessOptions), schemelessOptions, true);
|
|
10454
10454
|
schemelessOptions.skipEscape = true;
|
|
10455
10455
|
return serialize(resolved, schemelessOptions);
|
|
10456
10456
|
}
|
|
10457
|
-
function resolveComponent(base,
|
|
10457
|
+
function resolveComponent(base, relative3, options, skipNormalization) {
|
|
10458
10458
|
const target = {};
|
|
10459
10459
|
if (!skipNormalization) {
|
|
10460
10460
|
base = parse4(serialize(base, options), options);
|
|
10461
|
-
|
|
10461
|
+
relative3 = parse4(serialize(relative3, options), options);
|
|
10462
10462
|
}
|
|
10463
10463
|
options = options || {};
|
|
10464
|
-
if (!options.tolerant &&
|
|
10465
|
-
target.scheme =
|
|
10466
|
-
target.userinfo =
|
|
10467
|
-
target.host =
|
|
10468
|
-
target.port =
|
|
10469
|
-
target.path = removeDotSegments(
|
|
10470
|
-
target.query =
|
|
10464
|
+
if (!options.tolerant && relative3.scheme) {
|
|
10465
|
+
target.scheme = relative3.scheme;
|
|
10466
|
+
target.userinfo = relative3.userinfo;
|
|
10467
|
+
target.host = relative3.host;
|
|
10468
|
+
target.port = relative3.port;
|
|
10469
|
+
target.path = removeDotSegments(relative3.path || "");
|
|
10470
|
+
target.query = relative3.query;
|
|
10471
10471
|
} else {
|
|
10472
|
-
if (
|
|
10473
|
-
target.userinfo =
|
|
10474
|
-
target.host =
|
|
10475
|
-
target.port =
|
|
10476
|
-
target.path = removeDotSegments(
|
|
10477
|
-
target.query =
|
|
10472
|
+
if (relative3.userinfo !== void 0 || relative3.host !== void 0 || relative3.port !== void 0) {
|
|
10473
|
+
target.userinfo = relative3.userinfo;
|
|
10474
|
+
target.host = relative3.host;
|
|
10475
|
+
target.port = relative3.port;
|
|
10476
|
+
target.path = removeDotSegments(relative3.path || "");
|
|
10477
|
+
target.query = relative3.query;
|
|
10478
10478
|
} else {
|
|
10479
|
-
if (!
|
|
10479
|
+
if (!relative3.path) {
|
|
10480
10480
|
target.path = base.path;
|
|
10481
|
-
if (
|
|
10482
|
-
target.query =
|
|
10481
|
+
if (relative3.query !== void 0) {
|
|
10482
|
+
target.query = relative3.query;
|
|
10483
10483
|
} else {
|
|
10484
10484
|
target.query = base.query;
|
|
10485
10485
|
}
|
|
10486
10486
|
} else {
|
|
10487
|
-
if (
|
|
10488
|
-
target.path = removeDotSegments(
|
|
10487
|
+
if (relative3.path[0] === "/") {
|
|
10488
|
+
target.path = removeDotSegments(relative3.path);
|
|
10489
10489
|
} else {
|
|
10490
10490
|
if ((base.userinfo !== void 0 || base.host !== void 0 || base.port !== void 0) && !base.path) {
|
|
10491
|
-
target.path = "/" +
|
|
10491
|
+
target.path = "/" + relative3.path;
|
|
10492
10492
|
} else if (!base.path) {
|
|
10493
|
-
target.path =
|
|
10493
|
+
target.path = relative3.path;
|
|
10494
10494
|
} else {
|
|
10495
|
-
target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) +
|
|
10495
|
+
target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative3.path;
|
|
10496
10496
|
}
|
|
10497
10497
|
target.path = removeDotSegments(target.path);
|
|
10498
10498
|
}
|
|
10499
|
-
target.query =
|
|
10499
|
+
target.query = relative3.query;
|
|
10500
10500
|
}
|
|
10501
10501
|
target.userinfo = base.userinfo;
|
|
10502
10502
|
target.host = base.host;
|
|
@@ -10504,7 +10504,7 @@ var require_fast_uri = __commonJS({
|
|
|
10504
10504
|
}
|
|
10505
10505
|
target.scheme = base.scheme;
|
|
10506
10506
|
}
|
|
10507
|
-
target.fragment =
|
|
10507
|
+
target.fragment = relative3.fragment;
|
|
10508
10508
|
return target;
|
|
10509
10509
|
}
|
|
10510
10510
|
function equal(uriA, uriB, options) {
|
|
@@ -10706,7 +10706,7 @@ var require_fast_uri = __commonJS({
|
|
|
10706
10706
|
var fastUri = {
|
|
10707
10707
|
SCHEMES,
|
|
10708
10708
|
normalize: normalize3,
|
|
10709
|
-
resolve:
|
|
10709
|
+
resolve: resolve35,
|
|
10710
10710
|
resolveComponent,
|
|
10711
10711
|
equal,
|
|
10712
10712
|
serialize,
|
|
@@ -13682,12 +13682,12 @@ var require_dist = __commonJS({
|
|
|
13682
13682
|
throw new Error(`Unknown format "${name}"`);
|
|
13683
13683
|
return f2;
|
|
13684
13684
|
};
|
|
13685
|
-
function addFormats(ajv, list,
|
|
13685
|
+
function addFormats(ajv, list, fs42, exportName) {
|
|
13686
13686
|
var _a3;
|
|
13687
13687
|
var _b2;
|
|
13688
13688
|
(_a3 = (_b2 = ajv.opts.code).formats) !== null && _a3 !== void 0 ? _a3 : _b2.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
|
|
13689
13689
|
for (const f2 of list)
|
|
13690
|
-
ajv.addFormat(f2,
|
|
13690
|
+
ajv.addFormat(f2, fs42[f2]);
|
|
13691
13691
|
}
|
|
13692
13692
|
module2.exports = exports2 = formatsPlugin;
|
|
13693
13693
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
@@ -14971,11 +14971,11 @@ var parser = new YargsParser({
|
|
|
14971
14971
|
resolve: import_path2.resolve,
|
|
14972
14972
|
// TODO: figure out a way to combine ESM and CJS coverage, such that
|
|
14973
14973
|
// we can exercise all the lines below:
|
|
14974
|
-
require: (
|
|
14974
|
+
require: (path50) => {
|
|
14975
14975
|
if (typeof require !== "undefined") {
|
|
14976
|
-
return require(
|
|
14977
|
-
} else if (
|
|
14978
|
-
return JSON.parse((0, import_fs2.readFileSync)(
|
|
14976
|
+
return require(path50);
|
|
14977
|
+
} else if (path50.match(/\.json$/)) {
|
|
14978
|
+
return JSON.parse((0, import_fs2.readFileSync)(path50, "utf8"));
|
|
14979
14979
|
} else {
|
|
14980
14980
|
throw Error("only .json config files are supported in ESM");
|
|
14981
14981
|
}
|
|
@@ -16318,13 +16318,13 @@ function usage(yargs, shim3) {
|
|
|
16318
16318
|
};
|
|
16319
16319
|
self.stringifiedValues = function stringifiedValues(values, separator) {
|
|
16320
16320
|
let string3 = "";
|
|
16321
|
-
const
|
|
16321
|
+
const sep6 = separator || ", ";
|
|
16322
16322
|
const array2 = [].concat(values);
|
|
16323
16323
|
if (!values || !array2.length)
|
|
16324
16324
|
return string3;
|
|
16325
16325
|
array2.forEach((value) => {
|
|
16326
16326
|
if (string3.length)
|
|
16327
|
-
string3 +=
|
|
16327
|
+
string3 += sep6;
|
|
16328
16328
|
string3 += JSON.stringify(value);
|
|
16329
16329
|
});
|
|
16330
16330
|
return string3;
|
|
@@ -17501,12 +17501,12 @@ var YargsInstance = class {
|
|
|
17501
17501
|
async getCompletion(args, done) {
|
|
17502
17502
|
argsert("<array> [function]", [args, done], arguments.length);
|
|
17503
17503
|
if (!done) {
|
|
17504
|
-
return new Promise((
|
|
17504
|
+
return new Promise((resolve35, reject) => {
|
|
17505
17505
|
__classPrivateFieldGet(this, _YargsInstance_completion, "f").getCompletion(args, (err, completions) => {
|
|
17506
17506
|
if (err)
|
|
17507
17507
|
reject(err);
|
|
17508
17508
|
else
|
|
17509
|
-
|
|
17509
|
+
resolve35(completions);
|
|
17510
17510
|
});
|
|
17511
17511
|
});
|
|
17512
17512
|
} else {
|
|
@@ -19656,8 +19656,8 @@ function getErrorMap() {
|
|
|
19656
19656
|
|
|
19657
19657
|
// node_modules/zod/v3/helpers/parseUtil.js
|
|
19658
19658
|
var makeIssue = (params) => {
|
|
19659
|
-
const { data, path:
|
|
19660
|
-
const fullPath = [...
|
|
19659
|
+
const { data, path: path50, errorMaps, issueData } = params;
|
|
19660
|
+
const fullPath = [...path50, ...issueData.path || []];
|
|
19661
19661
|
const fullIssue = {
|
|
19662
19662
|
...issueData,
|
|
19663
19663
|
path: fullPath
|
|
@@ -19773,11 +19773,11 @@ var errorUtil;
|
|
|
19773
19773
|
|
|
19774
19774
|
// node_modules/zod/v3/types.js
|
|
19775
19775
|
var ParseInputLazyPath = class {
|
|
19776
|
-
constructor(parent, value,
|
|
19776
|
+
constructor(parent, value, path50, key) {
|
|
19777
19777
|
this._cachedPath = [];
|
|
19778
19778
|
this.parent = parent;
|
|
19779
19779
|
this.data = value;
|
|
19780
|
-
this._path =
|
|
19780
|
+
this._path = path50;
|
|
19781
19781
|
this._key = key;
|
|
19782
19782
|
}
|
|
19783
19783
|
get path() {
|
|
@@ -23816,16 +23816,16 @@ async function handleAgentSkills(options) {
|
|
|
23816
23816
|
}
|
|
23817
23817
|
async function askYesNo(question) {
|
|
23818
23818
|
const rl = readline.createInterface({ input: process.stdin, output: process.stderr });
|
|
23819
|
-
return new Promise((
|
|
23819
|
+
return new Promise((resolve35) => {
|
|
23820
23820
|
process.stderr.write(`${question} `);
|
|
23821
23821
|
rl.once("line", (answer) => {
|
|
23822
23822
|
rl.close();
|
|
23823
23823
|
const trimmed = answer.trim();
|
|
23824
23824
|
if (trimmed === "") {
|
|
23825
|
-
|
|
23825
|
+
resolve35(true);
|
|
23826
23826
|
return;
|
|
23827
23827
|
}
|
|
23828
|
-
|
|
23828
|
+
resolve35(/^y(es)?$/i.test(trimmed));
|
|
23829
23829
|
});
|
|
23830
23830
|
});
|
|
23831
23831
|
}
|
|
@@ -23904,7 +23904,7 @@ function handleRemove(argv) {
|
|
|
23904
23904
|
}
|
|
23905
23905
|
|
|
23906
23906
|
// src/cli/commands/env.ts
|
|
23907
|
-
var
|
|
23907
|
+
var path43 = __toESM(require("path"));
|
|
23908
23908
|
|
|
23909
23909
|
// src/core/harness.ts
|
|
23910
23910
|
var fs20 = __toESM(require("fs"));
|
|
@@ -24683,13 +24683,13 @@ var MultipartBody = class {
|
|
|
24683
24683
|
// node_modules/@anthropic-ai/sdk/_shims/node-runtime.mjs
|
|
24684
24684
|
var import_web = require("node:stream/web");
|
|
24685
24685
|
var fileFromPathWarned = false;
|
|
24686
|
-
async function fileFromPath3(
|
|
24686
|
+
async function fileFromPath3(path50, ...args) {
|
|
24687
24687
|
const { fileFromPath: _fileFromPath } = await Promise.resolve().then(() => (init_fileFromPath(), fileFromPath_exports));
|
|
24688
24688
|
if (!fileFromPathWarned) {
|
|
24689
|
-
console.warn(`fileFromPath is deprecated; use fs.createReadStream(${JSON.stringify(
|
|
24689
|
+
console.warn(`fileFromPath is deprecated; use fs.createReadStream(${JSON.stringify(path50)}) instead`);
|
|
24690
24690
|
fileFromPathWarned = true;
|
|
24691
24691
|
}
|
|
24692
|
-
return await _fileFromPath(
|
|
24692
|
+
return await _fileFromPath(path50, ...args);
|
|
24693
24693
|
}
|
|
24694
24694
|
var defaultHttpAgent = new import_agentkeepalive.default({ keepAlive: true, timeout: 5 * 60 * 1e3 });
|
|
24695
24695
|
var defaultHttpsAgent = new import_agentkeepalive.default.HttpsAgent({ keepAlive: true, timeout: 5 * 60 * 1e3 });
|
|
@@ -25185,8 +25185,8 @@ async function defaultParseResponse(props) {
|
|
|
25185
25185
|
}
|
|
25186
25186
|
var APIPromise = class _APIPromise extends Promise {
|
|
25187
25187
|
constructor(responsePromise, parseResponse = defaultParseResponse) {
|
|
25188
|
-
super((
|
|
25189
|
-
|
|
25188
|
+
super((resolve35) => {
|
|
25189
|
+
resolve35(null);
|
|
25190
25190
|
});
|
|
25191
25191
|
this.responsePromise = responsePromise;
|
|
25192
25192
|
this.parseResponse = parseResponse;
|
|
@@ -25286,29 +25286,29 @@ var APIClient = class {
|
|
|
25286
25286
|
defaultIdempotencyKey() {
|
|
25287
25287
|
return `stainless-node-retry-${uuid4()}`;
|
|
25288
25288
|
}
|
|
25289
|
-
get(
|
|
25290
|
-
return this.methodRequest("get",
|
|
25289
|
+
get(path50, opts) {
|
|
25290
|
+
return this.methodRequest("get", path50, opts);
|
|
25291
25291
|
}
|
|
25292
|
-
post(
|
|
25293
|
-
return this.methodRequest("post",
|
|
25292
|
+
post(path50, opts) {
|
|
25293
|
+
return this.methodRequest("post", path50, opts);
|
|
25294
25294
|
}
|
|
25295
|
-
patch(
|
|
25296
|
-
return this.methodRequest("patch",
|
|
25295
|
+
patch(path50, opts) {
|
|
25296
|
+
return this.methodRequest("patch", path50, opts);
|
|
25297
25297
|
}
|
|
25298
|
-
put(
|
|
25299
|
-
return this.methodRequest("put",
|
|
25298
|
+
put(path50, opts) {
|
|
25299
|
+
return this.methodRequest("put", path50, opts);
|
|
25300
25300
|
}
|
|
25301
|
-
delete(
|
|
25302
|
-
return this.methodRequest("delete",
|
|
25301
|
+
delete(path50, opts) {
|
|
25302
|
+
return this.methodRequest("delete", path50, opts);
|
|
25303
25303
|
}
|
|
25304
|
-
methodRequest(method,
|
|
25304
|
+
methodRequest(method, path50, opts) {
|
|
25305
25305
|
return this.request(Promise.resolve(opts).then(async (opts2) => {
|
|
25306
25306
|
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;
|
|
25307
|
-
return { method, path:
|
|
25307
|
+
return { method, path: path50, ...opts2, body };
|
|
25308
25308
|
}));
|
|
25309
25309
|
}
|
|
25310
|
-
getAPIList(
|
|
25311
|
-
return this.requestAPIList(Page, { method: "get", path:
|
|
25310
|
+
getAPIList(path50, Page, opts) {
|
|
25311
|
+
return this.requestAPIList(Page, { method: "get", path: path50, ...opts });
|
|
25312
25312
|
}
|
|
25313
25313
|
calculateContentLength(body) {
|
|
25314
25314
|
if (typeof body === "string") {
|
|
@@ -25326,10 +25326,10 @@ var APIClient = class {
|
|
|
25326
25326
|
return null;
|
|
25327
25327
|
}
|
|
25328
25328
|
buildRequest(options) {
|
|
25329
|
-
const { method, path:
|
|
25329
|
+
const { method, path: path50, query, headers = {} } = options;
|
|
25330
25330
|
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;
|
|
25331
25331
|
const contentLength = this.calculateContentLength(body);
|
|
25332
|
-
const url = this.buildURL(
|
|
25332
|
+
const url = this.buildURL(path50, query);
|
|
25333
25333
|
if ("timeout" in options)
|
|
25334
25334
|
validatePositiveInteger("timeout", options.timeout);
|
|
25335
25335
|
const timeout = options.timeout ?? this.timeout;
|
|
@@ -25438,8 +25438,8 @@ var APIClient = class {
|
|
|
25438
25438
|
const request = this.makeRequest(options, null);
|
|
25439
25439
|
return new PagePromise(this, request, Page);
|
|
25440
25440
|
}
|
|
25441
|
-
buildURL(
|
|
25442
|
-
const url = isAbsoluteURL(
|
|
25441
|
+
buildURL(path50, query) {
|
|
25442
|
+
const url = isAbsoluteURL(path50) ? new URL(path50) : new URL(this.baseURL + (this.baseURL.endsWith("/") && path50.startsWith("/") ? path50.slice(1) : path50));
|
|
25443
25443
|
const defaultQuery = this.defaultQuery();
|
|
25444
25444
|
if (!isEmptyObj(defaultQuery)) {
|
|
25445
25445
|
query = { ...defaultQuery, ...query };
|
|
@@ -25724,7 +25724,7 @@ var startsWithSchemeRegexp = new RegExp("^(?:[a-z]+:)?//", "i");
|
|
|
25724
25724
|
var isAbsoluteURL = (url) => {
|
|
25725
25725
|
return startsWithSchemeRegexp.test(url);
|
|
25726
25726
|
};
|
|
25727
|
-
var sleep = (ms) => new Promise((
|
|
25727
|
+
var sleep = (ms) => new Promise((resolve35) => setTimeout(resolve35, ms));
|
|
25728
25728
|
var validatePositiveInteger = (name, n2) => {
|
|
25729
25729
|
if (typeof n2 !== "number" || !Number.isInteger(n2)) {
|
|
25730
25730
|
throw new AnthropicError(`${name} must be an integer`);
|
|
@@ -26215,12 +26215,12 @@ var PromptCachingBetaMessageStream = class _PromptCachingBetaMessageStream {
|
|
|
26215
26215
|
}
|
|
26216
26216
|
return this._emit("error", new AnthropicError(String(error3)));
|
|
26217
26217
|
});
|
|
26218
|
-
__classPrivateFieldSet7(this, _PromptCachingBetaMessageStream_connectedPromise, new Promise((
|
|
26219
|
-
__classPrivateFieldSet7(this, _PromptCachingBetaMessageStream_resolveConnectedPromise,
|
|
26218
|
+
__classPrivateFieldSet7(this, _PromptCachingBetaMessageStream_connectedPromise, new Promise((resolve35, reject) => {
|
|
26219
|
+
__classPrivateFieldSet7(this, _PromptCachingBetaMessageStream_resolveConnectedPromise, resolve35, "f");
|
|
26220
26220
|
__classPrivateFieldSet7(this, _PromptCachingBetaMessageStream_rejectConnectedPromise, reject, "f");
|
|
26221
26221
|
}), "f");
|
|
26222
|
-
__classPrivateFieldSet7(this, _PromptCachingBetaMessageStream_endPromise, new Promise((
|
|
26223
|
-
__classPrivateFieldSet7(this, _PromptCachingBetaMessageStream_resolveEndPromise,
|
|
26222
|
+
__classPrivateFieldSet7(this, _PromptCachingBetaMessageStream_endPromise, new Promise((resolve35, reject) => {
|
|
26223
|
+
__classPrivateFieldSet7(this, _PromptCachingBetaMessageStream_resolveEndPromise, resolve35, "f");
|
|
26224
26224
|
__classPrivateFieldSet7(this, _PromptCachingBetaMessageStream_rejectEndPromise, reject, "f");
|
|
26225
26225
|
}), "f");
|
|
26226
26226
|
__classPrivateFieldGet8(this, _PromptCachingBetaMessageStream_connectedPromise, "f").catch(() => {
|
|
@@ -26349,11 +26349,11 @@ var PromptCachingBetaMessageStream = class _PromptCachingBetaMessageStream {
|
|
|
26349
26349
|
* const message = await stream.emitted('message') // rejects if the stream errors
|
|
26350
26350
|
*/
|
|
26351
26351
|
emitted(event) {
|
|
26352
|
-
return new Promise((
|
|
26352
|
+
return new Promise((resolve35, reject) => {
|
|
26353
26353
|
__classPrivateFieldSet7(this, _PromptCachingBetaMessageStream_catchingPromiseCreated, true, "f");
|
|
26354
26354
|
if (event !== "error")
|
|
26355
26355
|
this.once("error", reject);
|
|
26356
|
-
this.once(event,
|
|
26356
|
+
this.once(event, resolve35);
|
|
26357
26357
|
});
|
|
26358
26358
|
}
|
|
26359
26359
|
async done() {
|
|
@@ -26580,7 +26580,7 @@ var PromptCachingBetaMessageStream = class _PromptCachingBetaMessageStream {
|
|
|
26580
26580
|
if (done) {
|
|
26581
26581
|
return { value: void 0, done: true };
|
|
26582
26582
|
}
|
|
26583
|
-
return new Promise((
|
|
26583
|
+
return new Promise((resolve35, reject) => readQueue.push({ resolve: resolve35, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
|
|
26584
26584
|
}
|
|
26585
26585
|
const chunk = pushQueue.shift();
|
|
26586
26586
|
return { value: chunk, done: false };
|
|
@@ -26728,12 +26728,12 @@ var MessageStream = class _MessageStream {
|
|
|
26728
26728
|
}
|
|
26729
26729
|
return this._emit("error", new AnthropicError(String(error3)));
|
|
26730
26730
|
});
|
|
26731
|
-
__classPrivateFieldSet8(this, _MessageStream_connectedPromise, new Promise((
|
|
26732
|
-
__classPrivateFieldSet8(this, _MessageStream_resolveConnectedPromise,
|
|
26731
|
+
__classPrivateFieldSet8(this, _MessageStream_connectedPromise, new Promise((resolve35, reject) => {
|
|
26732
|
+
__classPrivateFieldSet8(this, _MessageStream_resolveConnectedPromise, resolve35, "f");
|
|
26733
26733
|
__classPrivateFieldSet8(this, _MessageStream_rejectConnectedPromise, reject, "f");
|
|
26734
26734
|
}), "f");
|
|
26735
|
-
__classPrivateFieldSet8(this, _MessageStream_endPromise, new Promise((
|
|
26736
|
-
__classPrivateFieldSet8(this, _MessageStream_resolveEndPromise,
|
|
26735
|
+
__classPrivateFieldSet8(this, _MessageStream_endPromise, new Promise((resolve35, reject) => {
|
|
26736
|
+
__classPrivateFieldSet8(this, _MessageStream_resolveEndPromise, resolve35, "f");
|
|
26737
26737
|
__classPrivateFieldSet8(this, _MessageStream_rejectEndPromise, reject, "f");
|
|
26738
26738
|
}), "f");
|
|
26739
26739
|
__classPrivateFieldGet9(this, _MessageStream_connectedPromise, "f").catch(() => {
|
|
@@ -26862,11 +26862,11 @@ var MessageStream = class _MessageStream {
|
|
|
26862
26862
|
* const message = await stream.emitted('message') // rejects if the stream errors
|
|
26863
26863
|
*/
|
|
26864
26864
|
emitted(event) {
|
|
26865
|
-
return new Promise((
|
|
26865
|
+
return new Promise((resolve35, reject) => {
|
|
26866
26866
|
__classPrivateFieldSet8(this, _MessageStream_catchingPromiseCreated, true, "f");
|
|
26867
26867
|
if (event !== "error")
|
|
26868
26868
|
this.once("error", reject);
|
|
26869
|
-
this.once(event,
|
|
26869
|
+
this.once(event, resolve35);
|
|
26870
26870
|
});
|
|
26871
26871
|
}
|
|
26872
26872
|
async done() {
|
|
@@ -27093,7 +27093,7 @@ var MessageStream = class _MessageStream {
|
|
|
27093
27093
|
if (done) {
|
|
27094
27094
|
return { value: void 0, done: true };
|
|
27095
27095
|
}
|
|
27096
|
-
return new Promise((
|
|
27096
|
+
return new Promise((resolve35, reject) => readQueue.push({ resolve: resolve35, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
|
|
27097
27097
|
}
|
|
27098
27098
|
const chunk = pushQueue.shift();
|
|
27099
27099
|
return { value: chunk, done: false };
|
|
@@ -27353,11 +27353,11 @@ async function promptApplyAgentMdProposal(repoPath) {
|
|
|
27353
27353
|
}
|
|
27354
27354
|
async function askYesNo2(question) {
|
|
27355
27355
|
const rl = readline2.createInterface({ input: process.stdin, output: process.stderr });
|
|
27356
|
-
return new Promise((
|
|
27356
|
+
return new Promise((resolve35) => {
|
|
27357
27357
|
process.stderr.write(`${question} `);
|
|
27358
27358
|
rl.once("line", (answer) => {
|
|
27359
27359
|
rl.close();
|
|
27360
|
-
|
|
27360
|
+
resolve35(/^y(es)?$/i.test(answer.trim()));
|
|
27361
27361
|
});
|
|
27362
27362
|
});
|
|
27363
27363
|
}
|
|
@@ -27587,7 +27587,7 @@ async function executeAuthoringToolCall(toolName, input, repoPath, harnessDir, c
|
|
|
27587
27587
|
}
|
|
27588
27588
|
async function askUser(question, options) {
|
|
27589
27589
|
const rl = readline3.createInterface({ input: process.stdin, output: process.stderr });
|
|
27590
|
-
return new Promise((
|
|
27590
|
+
return new Promise((resolve35) => {
|
|
27591
27591
|
process.stderr.write("\n");
|
|
27592
27592
|
process.stderr.write(`\u2753 ${question}
|
|
27593
27593
|
`);
|
|
@@ -27598,7 +27598,7 @@ async function askUser(question, options) {
|
|
|
27598
27598
|
process.stderr.write("> ");
|
|
27599
27599
|
rl.once("line", (answer) => {
|
|
27600
27600
|
rl.close();
|
|
27601
|
-
|
|
27601
|
+
resolve35(answer.trim());
|
|
27602
27602
|
});
|
|
27603
27603
|
});
|
|
27604
27604
|
}
|
|
@@ -27742,7 +27742,7 @@ function runScript(scriptPath, args = [], options = {}) {
|
|
|
27742
27742
|
function runScriptCapture(scriptPath, args = [], options = {}) {
|
|
27743
27743
|
const stream = options.stream ?? false;
|
|
27744
27744
|
const { stream: _stream, ...spawnOptions } = options;
|
|
27745
|
-
return new Promise((
|
|
27745
|
+
return new Promise((resolve35) => {
|
|
27746
27746
|
const proc = (0, import_child_process.spawn)("bash", [scriptPath, ...args], {
|
|
27747
27747
|
...spawnOptions,
|
|
27748
27748
|
stdio: ["inherit", "pipe", "pipe"]
|
|
@@ -27757,13 +27757,13 @@ function runScriptCapture(scriptPath, args = [], options = {}) {
|
|
|
27757
27757
|
stderr += d2;
|
|
27758
27758
|
if (stream) process.stderr.write(d2);
|
|
27759
27759
|
});
|
|
27760
|
-
proc.on("close", (code) =>
|
|
27760
|
+
proc.on("close", (code) => resolve35({ stdout, stderr, code: code ?? 0 }));
|
|
27761
27761
|
});
|
|
27762
27762
|
}
|
|
27763
27763
|
function runShellCommand(command2, options = {}) {
|
|
27764
27764
|
const stream = options.stream ?? false;
|
|
27765
27765
|
const { stream: _stream, ...spawnOptions } = options;
|
|
27766
|
-
return new Promise((
|
|
27766
|
+
return new Promise((resolve35) => {
|
|
27767
27767
|
const proc = (0, import_child_process.spawn)("bash", ["-lc", command2], {
|
|
27768
27768
|
...spawnOptions,
|
|
27769
27769
|
stdio: ["inherit", "pipe", "pipe"]
|
|
@@ -27778,7 +27778,7 @@ function runShellCommand(command2, options = {}) {
|
|
|
27778
27778
|
stderr += d2;
|
|
27779
27779
|
if (stream) process.stderr.write(d2);
|
|
27780
27780
|
});
|
|
27781
|
-
proc.on("close", (code) =>
|
|
27781
|
+
proc.on("close", (code) => resolve35({ stdout, stderr, code: code ?? 0 }));
|
|
27782
27782
|
});
|
|
27783
27783
|
}
|
|
27784
27784
|
|
|
@@ -28942,16 +28942,16 @@ async function promptScaffoldCursorRule(exists) {
|
|
|
28942
28942
|
}
|
|
28943
28943
|
async function askYesNo3(question) {
|
|
28944
28944
|
const rl = readline4.createInterface({ input: process.stdin, output: process.stderr });
|
|
28945
|
-
return new Promise((
|
|
28945
|
+
return new Promise((resolve35) => {
|
|
28946
28946
|
process.stderr.write(`${question} `);
|
|
28947
28947
|
rl.once("line", (answer) => {
|
|
28948
28948
|
rl.close();
|
|
28949
28949
|
const trimmed = answer.trim();
|
|
28950
28950
|
if (trimmed === "") {
|
|
28951
|
-
|
|
28951
|
+
resolve35(true);
|
|
28952
28952
|
return;
|
|
28953
28953
|
}
|
|
28954
|
-
|
|
28954
|
+
resolve35(/^y(es)?$/i.test(trimmed));
|
|
28955
28955
|
});
|
|
28956
28956
|
});
|
|
28957
28957
|
}
|
|
@@ -29222,16 +29222,16 @@ var LocalScriptExecutor = class {
|
|
|
29222
29222
|
const walk = (dir, prefix) => {
|
|
29223
29223
|
for (const entry of fs25.readdirSync(dir, { withFileTypes: true })) {
|
|
29224
29224
|
const full = path24.join(dir, entry.name);
|
|
29225
|
-
const
|
|
29225
|
+
const relative3 = path24.join(prefix, entry.name);
|
|
29226
29226
|
if (entry.isDirectory()) {
|
|
29227
|
-
walk(full,
|
|
29227
|
+
walk(full, relative3);
|
|
29228
29228
|
continue;
|
|
29229
29229
|
}
|
|
29230
|
-
if (filter?.stageId && !
|
|
29230
|
+
if (filter?.stageId && !relative3.includes(filter.stageId)) continue;
|
|
29231
29231
|
const stat = fs25.statSync(full);
|
|
29232
29232
|
entries.push({
|
|
29233
29233
|
path: full,
|
|
29234
|
-
relativePath:
|
|
29234
|
+
relativePath: relative3,
|
|
29235
29235
|
sizeBytes: stat.size,
|
|
29236
29236
|
modifiedAt: stat.mtime.toISOString()
|
|
29237
29237
|
});
|
|
@@ -29244,36 +29244,86 @@ var LocalScriptExecutor = class {
|
|
|
29244
29244
|
var localScriptExecutor = new LocalScriptExecutor();
|
|
29245
29245
|
|
|
29246
29246
|
// src/core/control-sync.ts
|
|
29247
|
-
var
|
|
29247
|
+
var path39 = __toESM(require("path"));
|
|
29248
29248
|
init_control_config();
|
|
29249
29249
|
|
|
29250
29250
|
// src/core/control-registry.ts
|
|
29251
|
-
var
|
|
29251
|
+
var fs27 = __toESM(require("fs"));
|
|
29252
29252
|
var os4 = __toESM(require("os"));
|
|
29253
|
+
var path26 = __toESM(require("path"));
|
|
29254
|
+
|
|
29255
|
+
// src/core/control-repo-path.ts
|
|
29256
|
+
var fs26 = __toESM(require("fs"));
|
|
29253
29257
|
var path25 = __toESM(require("path"));
|
|
29258
|
+
function tryGit(cwd, args) {
|
|
29259
|
+
if (!fs26.existsSync(cwd)) return void 0;
|
|
29260
|
+
const result = run(`git ${args}`, { cwd });
|
|
29261
|
+
return result.code === 0 ? result.stdout.trim() : void 0;
|
|
29262
|
+
}
|
|
29263
|
+
function resolveMainWorkingTree(cwd) {
|
|
29264
|
+
const toplevel = tryGit(cwd, "rev-parse --show-toplevel");
|
|
29265
|
+
if (!toplevel) return void 0;
|
|
29266
|
+
const commonDirRaw = tryGit(cwd, "rev-parse --git-common-dir");
|
|
29267
|
+
const commonDir = commonDirRaw ? path25.resolve(cwd, commonDirRaw) : void 0;
|
|
29268
|
+
if (!commonDir) return path25.resolve(toplevel);
|
|
29269
|
+
if (path25.basename(commonDir) === ".git") {
|
|
29270
|
+
return path25.dirname(commonDir);
|
|
29271
|
+
}
|
|
29272
|
+
const porcelain = tryGit(cwd, "worktree list --porcelain");
|
|
29273
|
+
if (porcelain) {
|
|
29274
|
+
for (const line of porcelain.split("\n")) {
|
|
29275
|
+
if (line.startsWith("worktree ")) {
|
|
29276
|
+
return path25.resolve(line.slice("worktree ".length));
|
|
29277
|
+
}
|
|
29278
|
+
}
|
|
29279
|
+
}
|
|
29280
|
+
return path25.resolve(toplevel);
|
|
29281
|
+
}
|
|
29282
|
+
function canonicalizeControlRepoPath(repoPath) {
|
|
29283
|
+
const resolved = path25.resolve(repoPath);
|
|
29284
|
+
const toplevel = tryGit(resolved, "rev-parse --show-toplevel");
|
|
29285
|
+
if (!toplevel) return resolved;
|
|
29286
|
+
const mainRoot = resolveMainWorkingTree(resolved);
|
|
29287
|
+
if (!mainRoot) return resolved;
|
|
29288
|
+
const top2 = path25.resolve(toplevel);
|
|
29289
|
+
const main = path25.resolve(mainRoot);
|
|
29290
|
+
if (top2 === main) return resolved;
|
|
29291
|
+
const rel = path25.relative(top2, resolved);
|
|
29292
|
+
if (!rel || rel === ".") return main;
|
|
29293
|
+
if (rel.startsWith(`..${path25.sep}`) || rel === ".." || path25.isAbsolute(rel)) {
|
|
29294
|
+
return resolved;
|
|
29295
|
+
}
|
|
29296
|
+
return path25.resolve(main, rel);
|
|
29297
|
+
}
|
|
29298
|
+
|
|
29299
|
+
// src/core/control-registry.ts
|
|
29254
29300
|
function getRegistryPath() {
|
|
29255
29301
|
if (process.env.HAR_CONTROL_REGISTRY_PATH) {
|
|
29256
|
-
return
|
|
29302
|
+
return path26.resolve(process.env.HAR_CONTROL_REGISTRY_PATH);
|
|
29257
29303
|
}
|
|
29258
|
-
return
|
|
29304
|
+
return path26.join(os4.homedir(), ".har", "repos.json");
|
|
29259
29305
|
}
|
|
29260
29306
|
function readRegistry() {
|
|
29261
29307
|
const registryPath = getRegistryPath();
|
|
29262
29308
|
try {
|
|
29263
|
-
if (!
|
|
29264
|
-
return JSON.parse(
|
|
29309
|
+
if (!fs27.existsSync(registryPath)) return { repos: [] };
|
|
29310
|
+
return JSON.parse(fs27.readFileSync(registryPath, "utf8"));
|
|
29265
29311
|
} catch {
|
|
29266
29312
|
return { repos: [] };
|
|
29267
29313
|
}
|
|
29268
29314
|
}
|
|
29269
29315
|
function writeRegistry(registry2) {
|
|
29270
29316
|
const registryPath = getRegistryPath();
|
|
29271
|
-
|
|
29272
|
-
|
|
29317
|
+
fs27.mkdirSync(path26.dirname(registryPath), { recursive: true });
|
|
29318
|
+
fs27.writeFileSync(registryPath, JSON.stringify(registry2, null, 2) + "\n");
|
|
29319
|
+
}
|
|
29320
|
+
function registryChanged(before, after) {
|
|
29321
|
+
if (before.length !== after.length) return true;
|
|
29322
|
+
return before.some((repoPath, index) => repoPath !== after[index]);
|
|
29273
29323
|
}
|
|
29274
29324
|
function recordRepoForControlSync(repoPath) {
|
|
29275
29325
|
if (process.env.HAR_CONTROL_DISABLED === "true") return;
|
|
29276
|
-
const resolved =
|
|
29326
|
+
const resolved = canonicalizeControlRepoPath(repoPath);
|
|
29277
29327
|
if (!readManifest(resolved)) return;
|
|
29278
29328
|
const registry2 = readRegistry();
|
|
29279
29329
|
if (registry2.repos.includes(resolved)) return;
|
|
@@ -29282,25 +29332,34 @@ function recordRepoForControlSync(repoPath) {
|
|
|
29282
29332
|
}
|
|
29283
29333
|
function listRegisteredRepos() {
|
|
29284
29334
|
const registry2 = readRegistry();
|
|
29285
|
-
const kept =
|
|
29286
|
-
|
|
29335
|
+
const kept = [];
|
|
29336
|
+
const seen = /* @__PURE__ */ new Set();
|
|
29337
|
+
for (const repoPath of registry2.repos) {
|
|
29338
|
+
if (!fs27.existsSync(repoPath)) continue;
|
|
29339
|
+
const canonical = canonicalizeControlRepoPath(repoPath);
|
|
29340
|
+
if (!fs27.existsSync(canonical) || !readManifest(canonical)) continue;
|
|
29341
|
+
if (seen.has(canonical)) continue;
|
|
29342
|
+
seen.add(canonical);
|
|
29343
|
+
kept.push(canonical);
|
|
29344
|
+
}
|
|
29345
|
+
if (registryChanged(registry2.repos, kept)) {
|
|
29287
29346
|
writeRegistry({ repos: kept });
|
|
29288
29347
|
}
|
|
29289
29348
|
return kept;
|
|
29290
29349
|
}
|
|
29291
29350
|
|
|
29292
29351
|
// src/core/slot-status.ts
|
|
29293
|
-
var
|
|
29352
|
+
var fs32 = __toESM(require("fs"));
|
|
29294
29353
|
var os7 = __toESM(require("os"));
|
|
29295
|
-
var
|
|
29354
|
+
var path32 = __toESM(require("path"));
|
|
29296
29355
|
var import_child_process7 = require("child_process");
|
|
29297
29356
|
|
|
29298
29357
|
// src/core/runs.ts
|
|
29299
29358
|
var crypto2 = __toESM(require("crypto"));
|
|
29300
29359
|
var import_child_process2 = require("child_process");
|
|
29301
|
-
var
|
|
29360
|
+
var fs28 = __toESM(require("fs"));
|
|
29302
29361
|
var os5 = __toESM(require("os"));
|
|
29303
|
-
var
|
|
29362
|
+
var path27 = __toESM(require("path"));
|
|
29304
29363
|
var RUNS_DIR = "runs";
|
|
29305
29364
|
function gitCommonDir(cwd) {
|
|
29306
29365
|
try {
|
|
@@ -29309,7 +29368,7 @@ function gitCommonDir(cwd) {
|
|
|
29309
29368
|
encoding: "utf8",
|
|
29310
29369
|
stdio: ["pipe", "pipe", "ignore"]
|
|
29311
29370
|
}).trim();
|
|
29312
|
-
return out ?
|
|
29371
|
+
return out ? path27.resolve(cwd, out) : void 0;
|
|
29313
29372
|
} catch {
|
|
29314
29373
|
return void 0;
|
|
29315
29374
|
}
|
|
@@ -29331,7 +29390,7 @@ function gitPrefix(cwd) {
|
|
|
29331
29390
|
}
|
|
29332
29391
|
}
|
|
29333
29392
|
function getRunsDir(harnessRoot) {
|
|
29334
|
-
return
|
|
29393
|
+
return path27.join(getHarnessDir(harnessRoot), RUNS_DIR);
|
|
29335
29394
|
}
|
|
29336
29395
|
function formatLocalDate(d2) {
|
|
29337
29396
|
const y2 = d2.getFullYear();
|
|
@@ -29351,24 +29410,24 @@ function buildRunRelativePath(stageId, agentId, startedAt, runId, runsDir) {
|
|
|
29351
29410
|
const timePart = formatLocalTime(started);
|
|
29352
29411
|
const agentPart = agentId !== void 0 ? `_agent-${agentId}` : "";
|
|
29353
29412
|
let filename = `${timePart}_${stageId}${agentPart}.json`;
|
|
29354
|
-
const fullPath =
|
|
29355
|
-
if (
|
|
29413
|
+
const fullPath = path27.join(runsDir, dateFolder, filename);
|
|
29414
|
+
if (fs28.existsSync(fullPath)) {
|
|
29356
29415
|
filename = `${timePart}_${stageId}${agentPart}-${runId.slice(0, 8)}.json`;
|
|
29357
29416
|
}
|
|
29358
|
-
return
|
|
29417
|
+
return path27.join(dateFolder, filename);
|
|
29359
29418
|
}
|
|
29360
29419
|
function resolveRunFilePath(harnessRoot, run2) {
|
|
29361
29420
|
if (run2.relativePath) {
|
|
29362
|
-
return
|
|
29421
|
+
return path27.join(getRunsDir(harnessRoot), run2.relativePath);
|
|
29363
29422
|
}
|
|
29364
|
-
return
|
|
29423
|
+
return path27.join(getRunsDir(harnessRoot), `${run2.runId}.json`);
|
|
29365
29424
|
}
|
|
29366
29425
|
function collectRunFiles(runsDir) {
|
|
29367
|
-
if (!
|
|
29426
|
+
if (!fs28.existsSync(runsDir)) return [];
|
|
29368
29427
|
const files = [];
|
|
29369
29428
|
const walk = (dir) => {
|
|
29370
|
-
for (const entry of
|
|
29371
|
-
const full =
|
|
29429
|
+
for (const entry of fs28.readdirSync(dir, { withFileTypes: true })) {
|
|
29430
|
+
const full = path27.join(dir, entry.name);
|
|
29372
29431
|
if (entry.isDirectory()) {
|
|
29373
29432
|
walk(full);
|
|
29374
29433
|
} else if (entry.name.endsWith(".json")) {
|
|
@@ -29382,30 +29441,30 @@ function collectRunFiles(runsDir) {
|
|
|
29382
29441
|
function resolveAgentWorkDir(harnessRoot, agentId) {
|
|
29383
29442
|
if (agentId === void 0) return void 0;
|
|
29384
29443
|
const entry = readSlotRegistry(harnessRoot, agentId);
|
|
29385
|
-
if (entry?.workDir &&
|
|
29444
|
+
if (entry?.workDir && fs28.existsSync(entry.workDir)) return entry.workDir;
|
|
29386
29445
|
const env3 = readHarnessEnv(harnessRoot);
|
|
29387
|
-
const projectName = env3.HARNESS_PROJECT_NAME ??
|
|
29388
|
-
const worktreeDir =
|
|
29446
|
+
const projectName = env3.HARNESS_PROJECT_NAME ?? path27.basename(harnessRoot);
|
|
29447
|
+
const worktreeDir = path27.join(os5.homedir(), "worktrees", `${projectName}-agent-${agentId}`);
|
|
29389
29448
|
const relPrefix = gitPrefix(harnessRoot);
|
|
29390
29449
|
const sessionEnvFiles = [];
|
|
29391
|
-
const worktreesRoot =
|
|
29392
|
-
if (
|
|
29450
|
+
const worktreesRoot = path27.join(os5.homedir(), "worktrees");
|
|
29451
|
+
if (fs28.existsSync(worktreesRoot)) {
|
|
29393
29452
|
const suffix = `-har-agent-${agentId}-`;
|
|
29394
|
-
for (const entry2 of
|
|
29453
|
+
for (const entry2 of fs28.readdirSync(worktreesRoot, { withFileTypes: true })) {
|
|
29395
29454
|
if (!entry2.isDirectory() || !entry2.name.includes(suffix)) continue;
|
|
29396
|
-
const sessionDir =
|
|
29455
|
+
const sessionDir = path27.join(worktreesRoot, entry2.name);
|
|
29397
29456
|
if (!sameGitCheckout(harnessRoot, sessionDir)) continue;
|
|
29398
|
-
sessionEnvFiles.push(
|
|
29457
|
+
sessionEnvFiles.push(path27.join(sessionDir, relPrefix, `.env.agent.${agentId}`));
|
|
29399
29458
|
}
|
|
29400
29459
|
}
|
|
29401
29460
|
const candidates = [
|
|
29402
|
-
|
|
29403
|
-
|
|
29461
|
+
path27.join(worktreeDir, `.env.agent.${agentId}`),
|
|
29462
|
+
path27.join(harnessRoot, `.env.agent.${agentId}`),
|
|
29404
29463
|
...sessionEnvFiles.sort()
|
|
29405
29464
|
];
|
|
29406
29465
|
for (const envFile of candidates) {
|
|
29407
|
-
if (!
|
|
29408
|
-
const content =
|
|
29466
|
+
if (!fs28.existsSync(envFile)) continue;
|
|
29467
|
+
const content = fs28.readFileSync(envFile, "utf8");
|
|
29409
29468
|
const match = content.match(/^REPO_ROOT=(.+)$/m);
|
|
29410
29469
|
if (match) return match[1].trim();
|
|
29411
29470
|
}
|
|
@@ -29417,11 +29476,11 @@ function createRun(ctx, meta) {
|
|
|
29417
29476
|
const startedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
29418
29477
|
const runId = crypto2.randomUUID();
|
|
29419
29478
|
const relativePath = buildRunRelativePath(meta.stageId, meta.agentId, startedAt, runId, runsDir);
|
|
29420
|
-
const runFilePath =
|
|
29421
|
-
|
|
29479
|
+
const runFilePath = path27.join(runsDir, relativePath);
|
|
29480
|
+
fs28.mkdirSync(path27.dirname(runFilePath), { recursive: true });
|
|
29422
29481
|
const run2 = RunRecordSchema.parse({
|
|
29423
29482
|
runId,
|
|
29424
|
-
repoPath:
|
|
29483
|
+
repoPath: path27.resolve(ctx.repoPath),
|
|
29425
29484
|
harnessRoot,
|
|
29426
29485
|
stageId: meta.stageId,
|
|
29427
29486
|
kind: meta.kind,
|
|
@@ -29432,7 +29491,7 @@ function createRun(ctx, meta) {
|
|
|
29432
29491
|
relativePath,
|
|
29433
29492
|
trigger: ctx.trigger ?? "cli"
|
|
29434
29493
|
});
|
|
29435
|
-
|
|
29494
|
+
fs28.writeFileSync(runFilePath, JSON.stringify(run2, null, 2) + "\n");
|
|
29436
29495
|
return run2;
|
|
29437
29496
|
}
|
|
29438
29497
|
function finishRun(repoPath, runId, update) {
|
|
@@ -29451,13 +29510,13 @@ function finishRun(repoPath, runId, update) {
|
|
|
29451
29510
|
finishedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
29452
29511
|
});
|
|
29453
29512
|
const runPath = resolveRunFilePath(harnessRoot, finished);
|
|
29454
|
-
|
|
29513
|
+
fs28.writeFileSync(runPath, JSON.stringify(finished, null, 2) + "\n");
|
|
29455
29514
|
return finished;
|
|
29456
29515
|
}
|
|
29457
29516
|
function findRunRecord(harnessRoot, runId) {
|
|
29458
29517
|
const runsDir = getRunsDir(harnessRoot);
|
|
29459
29518
|
for (const filePath of collectRunFiles(runsDir)) {
|
|
29460
|
-
const parsed = RunRecordSchema.safeParse(JSON.parse(
|
|
29519
|
+
const parsed = RunRecordSchema.safeParse(JSON.parse(fs28.readFileSync(filePath, "utf8")));
|
|
29461
29520
|
if (parsed.success && parsed.data.runId === runId) {
|
|
29462
29521
|
return parsed.data;
|
|
29463
29522
|
}
|
|
@@ -29469,10 +29528,10 @@ function getRun(repoPath, runId) {
|
|
|
29469
29528
|
}
|
|
29470
29529
|
function listRuns(repoPath, filter = {}) {
|
|
29471
29530
|
const runsDir = getRunsDir(resolveHarnessRoot(repoPath));
|
|
29472
|
-
if (!
|
|
29531
|
+
if (!fs28.existsSync(runsDir)) return [];
|
|
29473
29532
|
const runs = [];
|
|
29474
29533
|
for (const filePath of collectRunFiles(runsDir)) {
|
|
29475
|
-
const parsed = RunRecordSchema.safeParse(JSON.parse(
|
|
29534
|
+
const parsed = RunRecordSchema.safeParse(JSON.parse(fs28.readFileSync(filePath, "utf8")));
|
|
29476
29535
|
if (!parsed.success) continue;
|
|
29477
29536
|
if (filter.stageId && parsed.data.stageId !== filter.stageId) continue;
|
|
29478
29537
|
runs.push(parsed.data);
|
|
@@ -29485,18 +29544,18 @@ function listRuns(repoPath, filter = {}) {
|
|
|
29485
29544
|
}
|
|
29486
29545
|
|
|
29487
29546
|
// src/core/slot-preflight.ts
|
|
29488
|
-
var
|
|
29547
|
+
var path31 = __toESM(require("path"));
|
|
29489
29548
|
|
|
29490
29549
|
// src/core/control-port.ts
|
|
29491
29550
|
var import_child_process4 = require("child_process");
|
|
29492
|
-
var
|
|
29493
|
-
var
|
|
29551
|
+
var fs30 = __toESM(require("fs"));
|
|
29552
|
+
var path29 = __toESM(require("path"));
|
|
29494
29553
|
init_control_config();
|
|
29495
29554
|
|
|
29496
29555
|
// src/core/slot-ports.ts
|
|
29497
29556
|
var import_child_process3 = require("child_process");
|
|
29498
|
-
var
|
|
29499
|
-
var
|
|
29557
|
+
var fs29 = __toESM(require("fs"));
|
|
29558
|
+
var path28 = __toESM(require("path"));
|
|
29500
29559
|
function portStep(env3) {
|
|
29501
29560
|
return Number(env3.HARNESS_PORT_STEP ?? 10);
|
|
29502
29561
|
}
|
|
@@ -29552,7 +29611,7 @@ function allocateAppPorts(repoPath, agentId) {
|
|
|
29552
29611
|
}
|
|
29553
29612
|
function harnessUsesPm2(repoPath) {
|
|
29554
29613
|
const harnessRoot = resolveHarnessRoot(repoPath);
|
|
29555
|
-
return
|
|
29614
|
+
return fs29.existsSync(path28.join(harnessRoot, ".har", "ecosystem.agent.template.cjs"));
|
|
29556
29615
|
}
|
|
29557
29616
|
|
|
29558
29617
|
// src/core/control-port.ts
|
|
@@ -29607,13 +29666,13 @@ function controlDefaultPortWarnings(containers, defaultFrontendPort, allocatedFr
|
|
|
29607
29666
|
return [formatControlDefaultPortWarning(control.name, defaultFrontendPort, allocatedFrontend)];
|
|
29608
29667
|
}
|
|
29609
29668
|
function inspectControlUpReadiness(repoPath) {
|
|
29610
|
-
const resolved =
|
|
29669
|
+
const resolved = path29.resolve(repoPath);
|
|
29611
29670
|
const port = parseControlHostPort();
|
|
29612
29671
|
const containers = listDockerContainers();
|
|
29613
29672
|
const control = controlContainerOnPort(containers, port);
|
|
29614
29673
|
const warnings = [];
|
|
29615
|
-
const controlHarnessDir =
|
|
29616
|
-
const harnessSlot1Active =
|
|
29674
|
+
const controlHarnessDir = path29.join(resolved, "control", ".har");
|
|
29675
|
+
const harnessSlot1Active = fs30.existsSync(controlHarnessDir) && readSlotRegistry(path29.join(resolved, "control"), 1)?.status === "active";
|
|
29617
29676
|
if (control) {
|
|
29618
29677
|
return {
|
|
29619
29678
|
warnings,
|
|
@@ -29644,9 +29703,9 @@ function inspectControlUpReadiness(repoPath) {
|
|
|
29644
29703
|
}
|
|
29645
29704
|
|
|
29646
29705
|
// src/core/slot-launch-guard-occupied.ts
|
|
29647
|
-
var
|
|
29706
|
+
var fs31 = __toESM(require("fs"));
|
|
29648
29707
|
var os6 = __toESM(require("os"));
|
|
29649
|
-
var
|
|
29708
|
+
var path30 = __toESM(require("path"));
|
|
29650
29709
|
var import_child_process5 = require("child_process");
|
|
29651
29710
|
function runGit(cwd, args) {
|
|
29652
29711
|
try {
|
|
@@ -29665,7 +29724,7 @@ function worktreeDirty(worktreePath) {
|
|
|
29665
29724
|
}
|
|
29666
29725
|
function gitCommonDir2(cwd) {
|
|
29667
29726
|
const out = runGit(cwd, "rev-parse --git-common-dir");
|
|
29668
|
-
return out ?
|
|
29727
|
+
return out ? path30.resolve(cwd, out) : void 0;
|
|
29669
29728
|
}
|
|
29670
29729
|
function sameGitCheckout2(a2, b2) {
|
|
29671
29730
|
const left2 = gitCommonDir2(a2);
|
|
@@ -29674,20 +29733,20 @@ function sameGitCheckout2(a2, b2) {
|
|
|
29674
29733
|
}
|
|
29675
29734
|
function discoverWorktree(harnessRoot, agentId, projectName) {
|
|
29676
29735
|
const session = readSlotRegistry(harnessRoot, agentId);
|
|
29677
|
-
if (session?.worktreePath &&
|
|
29736
|
+
if (session?.worktreePath && fs31.existsSync(session.worktreePath)) {
|
|
29678
29737
|
return session.worktreePath;
|
|
29679
29738
|
}
|
|
29680
|
-
const legacy =
|
|
29681
|
-
if (
|
|
29682
|
-
const worktreesRoot =
|
|
29683
|
-
if (!
|
|
29739
|
+
const legacy = path30.join(os6.homedir(), "worktrees", `${projectName}-agent-${agentId}`);
|
|
29740
|
+
if (fs31.existsSync(legacy) && sameGitCheckout2(harnessRoot, legacy)) return legacy;
|
|
29741
|
+
const worktreesRoot = path30.join(os6.homedir(), "worktrees");
|
|
29742
|
+
if (!fs31.existsSync(worktreesRoot)) return void 0;
|
|
29684
29743
|
const suffix = `-har-agent-${agentId}-`;
|
|
29685
29744
|
const relPrefix = runGit(harnessRoot, "rev-parse --show-prefix") ?? "";
|
|
29686
|
-
for (const name of
|
|
29745
|
+
for (const name of fs31.readdirSync(worktreesRoot)) {
|
|
29687
29746
|
if (!name.includes(suffix)) continue;
|
|
29688
|
-
const candidate =
|
|
29747
|
+
const candidate = path30.join(worktreesRoot, name);
|
|
29689
29748
|
if (!sameGitCheckout2(harnessRoot, candidate)) continue;
|
|
29690
|
-
if (!
|
|
29749
|
+
if (!fs31.existsSync(path30.join(candidate, relPrefix, `.env.agent.${agentId}`))) continue;
|
|
29691
29750
|
return candidate;
|
|
29692
29751
|
}
|
|
29693
29752
|
return void 0;
|
|
@@ -29695,13 +29754,13 @@ function discoverWorktree(harnessRoot, agentId, projectName) {
|
|
|
29695
29754
|
function collectOccupiedSlot(repoPath, agentId) {
|
|
29696
29755
|
const harnessRoot = resolveHarnessRoot(repoPath);
|
|
29697
29756
|
const env3 = readHarnessEnv(harnessRoot);
|
|
29698
|
-
const projectName = env3.HARNESS_PROJECT_NAME ??
|
|
29757
|
+
const projectName = env3.HARNESS_PROJECT_NAME ?? path30.basename(harnessRoot);
|
|
29699
29758
|
const session = readSlotRegistry(harnessRoot, agentId);
|
|
29700
29759
|
const worktreePath = discoverWorktree(harnessRoot, agentId, projectName);
|
|
29701
29760
|
const workDir = session?.workDir;
|
|
29702
|
-
const envInWorkDir = workDir ?
|
|
29703
|
-
const envInRoot =
|
|
29704
|
-
const envInWorktree = worktreePath ?
|
|
29761
|
+
const envInWorkDir = workDir ? fs31.existsSync(path30.join(workDir, `.env.agent.${agentId}`)) : false;
|
|
29762
|
+
const envInRoot = fs31.existsSync(path30.join(harnessRoot, `.env.agent.${agentId}`));
|
|
29763
|
+
const envInWorktree = worktreePath ? fs31.existsSync(path30.join(worktreePath, `.env.agent.${agentId}`)) : false;
|
|
29705
29764
|
const active = session !== void 0 && session.status !== "completed" || envInWorkDir || envInRoot || envInWorktree;
|
|
29706
29765
|
if (!active) return void 0;
|
|
29707
29766
|
const dirty = worktreePath ? worktreeDirty(worktreePath) : void 0;
|
|
@@ -29854,7 +29913,7 @@ function checkInfraPort(env3, varName, defaultPort, scanStart, scanEnd) {
|
|
|
29854
29913
|
function inspectSlotReadiness(repoPath, agentId, options = {}) {
|
|
29855
29914
|
const harnessRoot = resolveHarnessRoot(repoPath);
|
|
29856
29915
|
const env3 = readHarnessEnv(harnessRoot);
|
|
29857
|
-
const projectName = env3.HARNESS_PROJECT_NAME ??
|
|
29916
|
+
const projectName = env3.HARNESS_PROJECT_NAME ?? path31.basename(harnessRoot);
|
|
29858
29917
|
const usesPm2 = harnessUsesPm2(repoPath);
|
|
29859
29918
|
const blockers = [];
|
|
29860
29919
|
const remediations = [];
|
|
@@ -30056,7 +30115,7 @@ function readWorktreeBranch(worktreePath) {
|
|
|
30056
30115
|
}
|
|
30057
30116
|
function gitCommonDir3(cwd) {
|
|
30058
30117
|
const out = runGit2(cwd, "rev-parse --git-common-dir");
|
|
30059
|
-
return out ?
|
|
30118
|
+
return out ? path32.resolve(cwd, out) : void 0;
|
|
30060
30119
|
}
|
|
30061
30120
|
function sameGitCheckout3(a2, b2) {
|
|
30062
30121
|
const left2 = gitCommonDir3(a2);
|
|
@@ -30068,12 +30127,12 @@ function gitPrefix2(cwd) {
|
|
|
30068
30127
|
return out ?? "";
|
|
30069
30128
|
}
|
|
30070
30129
|
function discoverSessionWorktreePath(harnessRoot, agentId) {
|
|
30071
|
-
const worktreesRoot =
|
|
30072
|
-
if (!
|
|
30130
|
+
const worktreesRoot = path32.join(os7.homedir(), "worktrees");
|
|
30131
|
+
if (!fs32.existsSync(worktreesRoot)) return void 0;
|
|
30073
30132
|
const suffix = `-har-agent-${agentId}-`;
|
|
30074
30133
|
const relPrefix = gitPrefix2(harnessRoot);
|
|
30075
|
-
const matches =
|
|
30076
|
-
(candidate) => sameGitCheckout3(harnessRoot, candidate) &&
|
|
30134
|
+
const matches = fs32.readdirSync(worktreesRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory() && entry.name.includes(suffix)).map((entry) => path32.join(worktreesRoot, entry.name)).filter(
|
|
30135
|
+
(candidate) => sameGitCheckout3(harnessRoot, candidate) && fs32.existsSync(path32.join(candidate, relPrefix, `.env.agent.${agentId}`))
|
|
30077
30136
|
);
|
|
30078
30137
|
return matches.sort()[0];
|
|
30079
30138
|
}
|
|
@@ -30148,18 +30207,18 @@ function detectPm2Issue(projectName, agentId, session, procs) {
|
|
|
30148
30207
|
}
|
|
30149
30208
|
function collectSlotStatus(harnessRoot, agentId, runs, pm2Procs) {
|
|
30150
30209
|
const env3 = readHarnessEnv(harnessRoot);
|
|
30151
|
-
const projectName = env3.HARNESS_PROJECT_NAME ??
|
|
30210
|
+
const projectName = env3.HARNESS_PROJECT_NAME ?? path32.basename(harnessRoot);
|
|
30152
30211
|
const session = readSlotRegistry(harnessRoot, agentId);
|
|
30153
|
-
const legacyWorktreePath =
|
|
30212
|
+
const legacyWorktreePath = path32.join(
|
|
30154
30213
|
os7.homedir(),
|
|
30155
30214
|
"worktrees",
|
|
30156
30215
|
`${projectName}-agent-${agentId}`
|
|
30157
30216
|
);
|
|
30158
|
-
const worktreePath = session?.worktreePath &&
|
|
30217
|
+
const worktreePath = session?.worktreePath && fs32.existsSync(session.worktreePath) ? session.worktreePath : fs32.existsSync(legacyWorktreePath) ? legacyWorktreePath : discoverSessionWorktreePath(harnessRoot, agentId);
|
|
30159
30218
|
const workDir = resolveAgentWorkDir(harnessRoot, agentId);
|
|
30160
|
-
const envInWorkDir = workDir ?
|
|
30161
|
-
const envInRoot =
|
|
30162
|
-
const envInWorktree = worktreePath ?
|
|
30219
|
+
const envInWorkDir = workDir ? fs32.existsSync(path32.join(workDir, `.env.agent.${agentId}`)) : false;
|
|
30220
|
+
const envInRoot = fs32.existsSync(path32.join(harnessRoot, `.env.agent.${agentId}`));
|
|
30221
|
+
const envInWorktree = worktreePath ? fs32.existsSync(path32.join(worktreePath, `.env.agent.${agentId}`)) : false;
|
|
30163
30222
|
const active = session !== void 0 && session.status !== "completed" || envInWorkDir || envInRoot || envInWorktree;
|
|
30164
30223
|
const latest = latestRunForAgent(runs, agentId);
|
|
30165
30224
|
const verifyRun = runs.find((r2) => r2.agentId === agentId && r2.stageId === "verify");
|
|
@@ -30211,7 +30270,7 @@ function collectEnvironmentStatus(repoPath) {
|
|
|
30211
30270
|
const slotIds = getAgentSlotIds(harnessRoot);
|
|
30212
30271
|
const pm2Procs = listPm2Processes2();
|
|
30213
30272
|
return {
|
|
30214
|
-
repoPath:
|
|
30273
|
+
repoPath: path32.resolve(repoPath),
|
|
30215
30274
|
harnessRoot,
|
|
30216
30275
|
gitRemote: readGitRemote(harnessRoot),
|
|
30217
30276
|
profile: manifest?.profile,
|
|
@@ -30222,13 +30281,13 @@ function collectEnvironmentStatus(repoPath) {
|
|
|
30222
30281
|
|
|
30223
30282
|
// src/core/validations.ts
|
|
30224
30283
|
var crypto3 = __toESM(require("crypto"));
|
|
30225
|
-
var
|
|
30226
|
-
var
|
|
30284
|
+
var fs34 = __toESM(require("fs"));
|
|
30285
|
+
var path34 = __toESM(require("path"));
|
|
30227
30286
|
|
|
30228
30287
|
// src/core/change-batch.ts
|
|
30229
|
-
var
|
|
30288
|
+
var fs33 = __toESM(require("fs"));
|
|
30230
30289
|
var os8 = __toESM(require("os"));
|
|
30231
|
-
var
|
|
30290
|
+
var path33 = __toESM(require("path"));
|
|
30232
30291
|
function git(checkoutDir, args, env3) {
|
|
30233
30292
|
const result = run(`git ${args}`, { cwd: checkoutDir, env: env3 });
|
|
30234
30293
|
if (result.code !== 0) {
|
|
@@ -30236,37 +30295,37 @@ function git(checkoutDir, args, env3) {
|
|
|
30236
30295
|
}
|
|
30237
30296
|
return result.stdout.trim();
|
|
30238
30297
|
}
|
|
30239
|
-
function
|
|
30298
|
+
function tryGit2(checkoutDir, args) {
|
|
30240
30299
|
const result = run(`git ${args}`, { cwd: checkoutDir });
|
|
30241
30300
|
return result.code === 0 ? result.stdout.trim() : void 0;
|
|
30242
30301
|
}
|
|
30243
30302
|
function isCheckoutRoot(checkoutDir) {
|
|
30244
|
-
const toplevel =
|
|
30303
|
+
const toplevel = tryGit2(checkoutDir, "rev-parse --show-toplevel");
|
|
30245
30304
|
if (!toplevel) return false;
|
|
30246
30305
|
try {
|
|
30247
|
-
return
|
|
30306
|
+
return fs33.realpathSync(toplevel) === fs33.realpathSync(checkoutDir);
|
|
30248
30307
|
} catch {
|
|
30249
30308
|
return false;
|
|
30250
30309
|
}
|
|
30251
30310
|
}
|
|
30252
30311
|
function getHeadTree(checkoutDir) {
|
|
30253
|
-
return
|
|
30312
|
+
return tryGit2(checkoutDir, "rev-parse -q --verify HEAD^{tree}");
|
|
30254
30313
|
}
|
|
30255
30314
|
function getHeadSha(checkoutDir) {
|
|
30256
|
-
return
|
|
30315
|
+
return tryGit2(checkoutDir, "rev-parse -q --verify HEAD");
|
|
30257
30316
|
}
|
|
30258
30317
|
function getCurrentBranch(checkoutDir) {
|
|
30259
|
-
const branch =
|
|
30318
|
+
const branch = tryGit2(checkoutDir, "rev-parse --abbrev-ref HEAD");
|
|
30260
30319
|
return branch && branch !== "HEAD" ? branch : void 0;
|
|
30261
30320
|
}
|
|
30262
30321
|
function getEmptyTree(checkoutDir) {
|
|
30263
30322
|
return git(checkoutDir, "hash-object -t tree /dev/null");
|
|
30264
30323
|
}
|
|
30265
30324
|
function isMergeOrRebaseInProgress(checkoutDir) {
|
|
30266
|
-
if (
|
|
30325
|
+
if (tryGit2(checkoutDir, "rev-parse -q --verify MERGE_HEAD") !== void 0) return true;
|
|
30267
30326
|
for (const dir of ["rebase-merge", "rebase-apply"]) {
|
|
30268
|
-
const gitPath =
|
|
30269
|
-
if (gitPath &&
|
|
30327
|
+
const gitPath = tryGit2(checkoutDir, `rev-parse --git-path ${dir}`);
|
|
30328
|
+
if (gitPath && fs33.existsSync(path33.resolve(checkoutDir, gitPath))) return true;
|
|
30270
30329
|
}
|
|
30271
30330
|
return false;
|
|
30272
30331
|
}
|
|
@@ -30289,8 +30348,8 @@ function parseNameStatus(output) {
|
|
|
30289
30348
|
return files;
|
|
30290
30349
|
}
|
|
30291
30350
|
function computeWorktreeSnapshot(checkoutDir) {
|
|
30292
|
-
const tmpDir =
|
|
30293
|
-
const tmpIndex =
|
|
30351
|
+
const tmpDir = fs33.mkdtempSync(path33.join(os8.tmpdir(), "har-idx-"));
|
|
30352
|
+
const tmpIndex = path33.join(tmpDir, "index");
|
|
30294
30353
|
const env3 = { GIT_INDEX_FILE: tmpIndex };
|
|
30295
30354
|
try {
|
|
30296
30355
|
const headTree = getHeadTree(checkoutDir);
|
|
@@ -30313,35 +30372,35 @@ function computeWorktreeSnapshot(checkoutDir) {
|
|
|
30313
30372
|
changedFiles: parseNameStatus(diffOutput)
|
|
30314
30373
|
};
|
|
30315
30374
|
} finally {
|
|
30316
|
-
|
|
30375
|
+
fs33.rmSync(tmpDir, { recursive: true, force: true });
|
|
30317
30376
|
}
|
|
30318
30377
|
}
|
|
30319
30378
|
|
|
30320
30379
|
// src/core/validations.ts
|
|
30321
30380
|
var VALIDATIONS_DIR = "validations";
|
|
30322
30381
|
function getValidationsDir(checkoutDir) {
|
|
30323
|
-
return
|
|
30382
|
+
return path34.join(checkoutDir, ".har", VALIDATIONS_DIR);
|
|
30324
30383
|
}
|
|
30325
30384
|
function validationPath(checkoutDir, treeHash) {
|
|
30326
|
-
return
|
|
30385
|
+
return path34.join(getValidationsDir(checkoutDir), `${treeHash}.json`);
|
|
30327
30386
|
}
|
|
30328
30387
|
function writeRecord(checkoutDir, record2) {
|
|
30329
30388
|
const dir = getValidationsDir(checkoutDir);
|
|
30330
|
-
|
|
30331
|
-
|
|
30389
|
+
fs34.mkdirSync(dir, { recursive: true });
|
|
30390
|
+
fs34.writeFileSync(
|
|
30332
30391
|
validationPath(checkoutDir, record2.treeHash),
|
|
30333
30392
|
`${JSON.stringify(record2, null, 2)}
|
|
30334
30393
|
`
|
|
30335
30394
|
);
|
|
30336
30395
|
}
|
|
30337
30396
|
function ensureValidationsIgnored(checkoutDir) {
|
|
30338
|
-
const harDir =
|
|
30339
|
-
if (!
|
|
30340
|
-
const gitignorePath =
|
|
30341
|
-
const content =
|
|
30397
|
+
const harDir = path34.join(checkoutDir, ".har");
|
|
30398
|
+
if (!fs34.existsSync(harDir)) return;
|
|
30399
|
+
const gitignorePath = path34.join(harDir, ".gitignore");
|
|
30400
|
+
const content = fs34.existsSync(gitignorePath) ? fs34.readFileSync(gitignorePath, "utf8") : "";
|
|
30342
30401
|
if (content.split("\n").some((line) => line.trim() === `${VALIDATIONS_DIR}/`)) return;
|
|
30343
30402
|
const suffix = content.length === 0 || content.endsWith("\n") ? "" : "\n";
|
|
30344
|
-
|
|
30403
|
+
fs34.writeFileSync(gitignorePath, `${content}${suffix}${VALIDATIONS_DIR}/
|
|
30345
30404
|
`);
|
|
30346
30405
|
}
|
|
30347
30406
|
function recordValidation(input) {
|
|
@@ -30358,8 +30417,8 @@ function recordValidation(input) {
|
|
|
30358
30417
|
treeHash: snapshot.treeHash,
|
|
30359
30418
|
headSha: snapshot.headSha,
|
|
30360
30419
|
branch: snapshot.branch,
|
|
30361
|
-
workDir:
|
|
30362
|
-
harnessRoot:
|
|
30420
|
+
workDir: path34.resolve(input.checkoutDir),
|
|
30421
|
+
harnessRoot: path34.resolve(input.harnessRoot),
|
|
30363
30422
|
agentId: input.agentId,
|
|
30364
30423
|
status: input.status,
|
|
30365
30424
|
full: input.full,
|
|
@@ -30371,16 +30430,16 @@ function recordValidation(input) {
|
|
|
30371
30430
|
committedAt: existing?.committedAt
|
|
30372
30431
|
});
|
|
30373
30432
|
writeRecord(input.checkoutDir, record2);
|
|
30374
|
-
if (
|
|
30433
|
+
if (path34.resolve(input.harnessRoot) !== path34.resolve(input.checkoutDir)) {
|
|
30375
30434
|
writeRecord(input.harnessRoot, record2);
|
|
30376
30435
|
}
|
|
30377
30436
|
return record2;
|
|
30378
30437
|
}
|
|
30379
30438
|
function findValidation(checkoutDir, treeHash) {
|
|
30380
30439
|
const file = validationPath(checkoutDir, treeHash);
|
|
30381
|
-
if (!
|
|
30440
|
+
if (!fs34.existsSync(file)) return void 0;
|
|
30382
30441
|
try {
|
|
30383
|
-
return ValidationRecordSchema.parse(JSON.parse(
|
|
30442
|
+
return ValidationRecordSchema.parse(JSON.parse(fs34.readFileSync(file, "utf8")));
|
|
30384
30443
|
} catch {
|
|
30385
30444
|
return void 0;
|
|
30386
30445
|
}
|
|
@@ -30395,19 +30454,19 @@ function attachCommit(checkoutDir, treeHash, commitSha) {
|
|
|
30395
30454
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
30396
30455
|
};
|
|
30397
30456
|
writeRecord(checkoutDir, updated);
|
|
30398
|
-
if (record2.harnessRoot &&
|
|
30457
|
+
if (record2.harnessRoot && path34.resolve(record2.harnessRoot) !== path34.resolve(checkoutDir) && fs34.existsSync(path34.join(record2.harnessRoot, ".har"))) {
|
|
30399
30458
|
writeRecord(record2.harnessRoot, updated);
|
|
30400
30459
|
}
|
|
30401
30460
|
return updated;
|
|
30402
30461
|
}
|
|
30403
30462
|
function listValidations(harnessRoot) {
|
|
30404
30463
|
const dir = getValidationsDir(harnessRoot);
|
|
30405
|
-
if (!
|
|
30464
|
+
if (!fs34.existsSync(dir)) return [];
|
|
30406
30465
|
const records = [];
|
|
30407
|
-
for (const entry of
|
|
30466
|
+
for (const entry of fs34.readdirSync(dir)) {
|
|
30408
30467
|
if (!entry.endsWith(".json")) continue;
|
|
30409
30468
|
try {
|
|
30410
|
-
records.push(ValidationRecordSchema.parse(JSON.parse(
|
|
30469
|
+
records.push(ValidationRecordSchema.parse(JSON.parse(fs34.readFileSync(path34.join(dir, entry), "utf8"))));
|
|
30411
30470
|
} catch {
|
|
30412
30471
|
}
|
|
30413
30472
|
}
|
|
@@ -30440,14 +30499,14 @@ function createRemoteExecutor(apiUrl, apiKey) {
|
|
|
30440
30499
|
init_telemetry_config();
|
|
30441
30500
|
|
|
30442
30501
|
// src/core/usage-harvest/claude.ts
|
|
30443
|
-
var
|
|
30502
|
+
var fs37 = __toESM(require("fs"));
|
|
30444
30503
|
var os10 = __toESM(require("os"));
|
|
30445
|
-
var
|
|
30504
|
+
var path37 = __toESM(require("path"));
|
|
30446
30505
|
init_telemetry_config();
|
|
30447
30506
|
|
|
30448
30507
|
// src/core/telemetry-env.ts
|
|
30449
|
-
var
|
|
30450
|
-
var
|
|
30508
|
+
var fs36 = __toESM(require("fs"));
|
|
30509
|
+
var path36 = __toESM(require("path"));
|
|
30451
30510
|
init_control_config();
|
|
30452
30511
|
function escapeAttrValue(value) {
|
|
30453
30512
|
return value.replace(/[,=]/g, "_");
|
|
@@ -30487,8 +30546,8 @@ function appendTelemetryEnvToFile(envFilePath, attrs) {
|
|
|
30487
30546
|
${TELEMETRY_MARKER_END}
|
|
30488
30547
|
`;
|
|
30489
30548
|
let existing = "";
|
|
30490
|
-
if (
|
|
30491
|
-
existing =
|
|
30549
|
+
if (fs36.existsSync(envFilePath)) {
|
|
30550
|
+
existing = fs36.readFileSync(envFilePath, "utf8");
|
|
30492
30551
|
const start = existing.indexOf(TELEMETRY_MARKER_START);
|
|
30493
30552
|
if (start >= 0) {
|
|
30494
30553
|
const end = existing.indexOf(TELEMETRY_MARKER_END, start);
|
|
@@ -30499,28 +30558,28 @@ ${TELEMETRY_MARKER_END}
|
|
|
30499
30558
|
}
|
|
30500
30559
|
}
|
|
30501
30560
|
}
|
|
30502
|
-
|
|
30561
|
+
fs36.mkdirSync(path36.dirname(envFilePath), { recursive: true });
|
|
30503
30562
|
const combined = (existing.replace(/\n+$/, "\n") + block).replace(/^\n+/, "");
|
|
30504
|
-
|
|
30563
|
+
fs36.writeFileSync(envFilePath, combined.endsWith("\n") ? combined : combined + "\n");
|
|
30505
30564
|
}
|
|
30506
30565
|
|
|
30507
30566
|
// src/core/usage-harvest/claude.ts
|
|
30508
30567
|
function pathsMatch(candidate, targets) {
|
|
30509
|
-
const norm =
|
|
30568
|
+
const norm = path37.resolve(candidate);
|
|
30510
30569
|
return targets.some((t2) => {
|
|
30511
|
-
const target =
|
|
30512
|
-
return norm === target || norm.startsWith(target +
|
|
30570
|
+
const target = path37.resolve(t2);
|
|
30571
|
+
return norm === target || norm.startsWith(target + path37.sep) || target.startsWith(norm + path37.sep);
|
|
30513
30572
|
});
|
|
30514
30573
|
}
|
|
30515
30574
|
function claudeProjectsRoot() {
|
|
30516
|
-
return process.env.HAR_CLAUDE_PROJECTS_DIR ?
|
|
30575
|
+
return process.env.HAR_CLAUDE_PROJECTS_DIR ? path37.resolve(process.env.HAR_CLAUDE_PROJECTS_DIR) : path37.join(os10.homedir(), ".claude", "projects");
|
|
30517
30576
|
}
|
|
30518
30577
|
function encodeClaudeProjectDir(cwd) {
|
|
30519
30578
|
return cwd.replace(/[^a-zA-Z0-9]/g, "-");
|
|
30520
30579
|
}
|
|
30521
30580
|
function readJsonlRecords(filePath) {
|
|
30522
|
-
if (!
|
|
30523
|
-
const lines =
|
|
30581
|
+
if (!fs37.existsSync(filePath)) return [];
|
|
30582
|
+
const lines = fs37.readFileSync(filePath, "utf8").split(/\r?\n/);
|
|
30524
30583
|
const out = [];
|
|
30525
30584
|
for (const line of lines) {
|
|
30526
30585
|
const trimmed = line.trim();
|
|
@@ -30563,16 +30622,16 @@ function findMatchingClaudeTranscripts(slot) {
|
|
|
30563
30622
|
const targets = [slot.workDir, slot.worktreePath].filter(Boolean);
|
|
30564
30623
|
if (targets.length === 0) return [];
|
|
30565
30624
|
const root = claudeProjectsRoot();
|
|
30566
|
-
if (!
|
|
30625
|
+
if (!fs37.existsSync(root)) return [];
|
|
30567
30626
|
const matches = [];
|
|
30568
|
-
for (const entry of
|
|
30627
|
+
for (const entry of fs37.readdirSync(root, { withFileTypes: true })) {
|
|
30569
30628
|
if (!entry.isDirectory()) continue;
|
|
30570
|
-
const projectDir =
|
|
30629
|
+
const projectDir = path37.join(root, entry.name);
|
|
30571
30630
|
const encodedHit = targets.some((t2) => entry.name.includes(encodeClaudeProjectDir(t2).slice(0, 40)));
|
|
30572
|
-
for (const file of
|
|
30631
|
+
for (const file of fs37.readdirSync(projectDir)) {
|
|
30573
30632
|
if (!file.endsWith(".jsonl")) continue;
|
|
30574
|
-
const filePath =
|
|
30575
|
-
const stat =
|
|
30633
|
+
const filePath = path37.join(projectDir, file);
|
|
30634
|
+
const stat = fs37.statSync(filePath);
|
|
30576
30635
|
const records = readJsonlRecords(filePath);
|
|
30577
30636
|
let cwdHit = encodedHit;
|
|
30578
30637
|
for (const record2 of records) {
|
|
@@ -30683,30 +30742,30 @@ function harvestClaudeEvents(slot) {
|
|
|
30683
30742
|
}
|
|
30684
30743
|
|
|
30685
30744
|
// src/core/usage-harvest/codex.ts
|
|
30686
|
-
var
|
|
30745
|
+
var fs38 = __toESM(require("fs"));
|
|
30687
30746
|
var os11 = __toESM(require("os"));
|
|
30688
|
-
var
|
|
30747
|
+
var path38 = __toESM(require("path"));
|
|
30689
30748
|
function pathsMatch2(candidate, targets) {
|
|
30690
|
-
const norm =
|
|
30749
|
+
const norm = path38.resolve(candidate);
|
|
30691
30750
|
return targets.some((t2) => {
|
|
30692
|
-
const target =
|
|
30693
|
-
return norm === target || norm.startsWith(target +
|
|
30751
|
+
const target = path38.resolve(t2);
|
|
30752
|
+
return norm === target || norm.startsWith(target + path38.sep) || target.startsWith(norm + path38.sep);
|
|
30694
30753
|
});
|
|
30695
30754
|
}
|
|
30696
30755
|
function codexSessionsRoot() {
|
|
30697
|
-
return process.env.HAR_CODEX_SESSIONS_DIR ?
|
|
30756
|
+
return process.env.HAR_CODEX_SESSIONS_DIR ? path38.resolve(process.env.HAR_CODEX_SESSIONS_DIR) : path38.join(os11.homedir(), ".codex", "sessions");
|
|
30698
30757
|
}
|
|
30699
30758
|
function walkJsonlFiles(dir, out = []) {
|
|
30700
|
-
if (!
|
|
30701
|
-
for (const entry of
|
|
30702
|
-
const full =
|
|
30759
|
+
if (!fs38.existsSync(dir)) return out;
|
|
30760
|
+
for (const entry of fs38.readdirSync(dir, { withFileTypes: true })) {
|
|
30761
|
+
const full = path38.join(dir, entry.name);
|
|
30703
30762
|
if (entry.isDirectory()) walkJsonlFiles(full, out);
|
|
30704
30763
|
else if (entry.isFile() && entry.name.endsWith(".jsonl")) out.push(full);
|
|
30705
30764
|
}
|
|
30706
30765
|
return out;
|
|
30707
30766
|
}
|
|
30708
30767
|
function readJsonl(filePath) {
|
|
30709
|
-
const lines =
|
|
30768
|
+
const lines = fs38.readFileSync(filePath, "utf8").split(/\r?\n/);
|
|
30710
30769
|
const out = [];
|
|
30711
30770
|
for (const line of lines) {
|
|
30712
30771
|
const trimmed = line.trim();
|
|
@@ -30770,7 +30829,7 @@ function harvestCodexUsage(slot) {
|
|
|
30770
30829
|
const extracted = extractCodexTokens(records);
|
|
30771
30830
|
if (!extracted.cwd || !pathsMatch2(extracted.cwd, targets)) continue;
|
|
30772
30831
|
if (extracted.tokensInput + extracted.tokensOutput + extracted.tokensCacheRead === 0) continue;
|
|
30773
|
-
const mtime =
|
|
30832
|
+
const mtime = fs38.statSync(file).mtimeMs;
|
|
30774
30833
|
if (mtime >= bestMtime) {
|
|
30775
30834
|
bestMtime = mtime;
|
|
30776
30835
|
best = extracted;
|
|
@@ -30840,7 +30899,7 @@ async function waitForControlApi(apiUrl = getControlApiUrl(), timeoutMs = 6e4, i
|
|
|
30840
30899
|
const deadline = Date.now() + timeoutMs;
|
|
30841
30900
|
while (Date.now() < deadline) {
|
|
30842
30901
|
if (await isControlApiReachable(apiUrl)) return true;
|
|
30843
|
-
await new Promise((
|
|
30902
|
+
await new Promise((resolve35) => setTimeout(resolve35, intervalMs));
|
|
30844
30903
|
}
|
|
30845
30904
|
return false;
|
|
30846
30905
|
}
|
|
@@ -30852,7 +30911,7 @@ async function syncAllKnownReposWithControl(options) {
|
|
|
30852
30911
|
}
|
|
30853
30912
|
const repoPaths = new Set(listRegisteredRepos());
|
|
30854
30913
|
if (options?.cwd) {
|
|
30855
|
-
const cwd =
|
|
30914
|
+
const cwd = canonicalizeControlRepoPath(options.cwd);
|
|
30856
30915
|
if (readManifest(cwd)) repoPaths.add(cwd);
|
|
30857
30916
|
}
|
|
30858
30917
|
try {
|
|
@@ -30860,7 +30919,7 @@ async function syncAllKnownReposWithControl(options) {
|
|
|
30860
30919
|
if (listResponse.ok) {
|
|
30861
30920
|
const repos = await listResponse.json();
|
|
30862
30921
|
for (const repo of repos) {
|
|
30863
|
-
const resolved =
|
|
30922
|
+
const resolved = canonicalizeControlRepoPath(repo.path);
|
|
30864
30923
|
if (readManifest(resolved)) repoPaths.add(resolved);
|
|
30865
30924
|
}
|
|
30866
30925
|
}
|
|
@@ -30879,7 +30938,7 @@ async function syncAllKnownReposWithControl(options) {
|
|
|
30879
30938
|
return { synced, failed };
|
|
30880
30939
|
}
|
|
30881
30940
|
async function registerRepoWithControl(options) {
|
|
30882
|
-
const repoPath =
|
|
30941
|
+
const repoPath = canonicalizeControlRepoPath(options.repoPath);
|
|
30883
30942
|
const apiUrl = options.apiUrl ?? getControlApiUrl();
|
|
30884
30943
|
const manifest = readManifest(repoPath);
|
|
30885
30944
|
const stagesRegistry = readStageRegistry(repoPath);
|
|
@@ -30892,7 +30951,7 @@ async function registerRepoWithControl(options) {
|
|
|
30892
30951
|
return postJson(`${apiUrl}/api/repos`, body, options.dryRun);
|
|
30893
30952
|
}
|
|
30894
30953
|
async function syncRepoWithControl(options) {
|
|
30895
|
-
const repoPath =
|
|
30954
|
+
const repoPath = canonicalizeControlRepoPath(options.repoPath);
|
|
30896
30955
|
const apiUrl = options.apiUrl ?? getControlApiUrl();
|
|
30897
30956
|
if (options.cloud) {
|
|
30898
30957
|
const remote = createRemoteExecutor();
|
|
@@ -30920,7 +30979,7 @@ async function syncRepoWithControl(options) {
|
|
|
30920
30979
|
const listResponse = await fetch(`${apiUrl}/api/repos`);
|
|
30921
30980
|
if (!listResponse.ok) throw new Error("Failed to list repos from Control API");
|
|
30922
30981
|
const repos = await listResponse.json();
|
|
30923
|
-
const existing = repos.find((r2) =>
|
|
30982
|
+
const existing = repos.find((r2) => path39.resolve(r2.path) === repoPath);
|
|
30924
30983
|
if (!existing) throw new Error(`Repo not registered: ${repoPath}`);
|
|
30925
30984
|
await syncRepoRunsAndSlots(apiUrl, existing.id, repoPath, options.dryRun);
|
|
30926
30985
|
return;
|
|
@@ -31011,7 +31070,12 @@ async function syncRepoWithControlAsync(repoPath) {
|
|
|
31011
31070
|
}
|
|
31012
31071
|
return;
|
|
31013
31072
|
}
|
|
31014
|
-
|
|
31073
|
+
const canonical = canonicalizeControlRepoPath(repoPath);
|
|
31074
|
+
await withTimeout(
|
|
31075
|
+
syncRepoWithControl({ repoPath: canonical, apiUrl }),
|
|
31076
|
+
SYNC_TIMEOUT_MS,
|
|
31077
|
+
"control sync"
|
|
31078
|
+
);
|
|
31015
31079
|
} catch (err) {
|
|
31016
31080
|
if (verbose) {
|
|
31017
31081
|
const message = err instanceof Error ? err.message : String(err);
|
|
@@ -31042,7 +31106,7 @@ init_control_config();
|
|
|
31042
31106
|
|
|
31043
31107
|
// src/core/control-lifecycle.ts
|
|
31044
31108
|
var import_child_process8 = require("child_process");
|
|
31045
|
-
var
|
|
31109
|
+
var path40 = __toESM(require("path"));
|
|
31046
31110
|
|
|
31047
31111
|
// src/core/control-image.ts
|
|
31048
31112
|
var DEFAULT_CONTROL_IMAGE = "theosfactory/har-control";
|
|
@@ -31066,10 +31130,10 @@ var CONTROL_DATA_VOLUME = "har_control_data";
|
|
|
31066
31130
|
var CONTROL_CONTAINER_PORT = 3847;
|
|
31067
31131
|
var CONTROL_DATA_DB_URL = "file:/data/har_control.db";
|
|
31068
31132
|
function resolveControlDir() {
|
|
31069
|
-
return
|
|
31133
|
+
return path40.resolve(__dirname, "..", "control");
|
|
31070
31134
|
}
|
|
31071
31135
|
function resolveControlBuildContext() {
|
|
31072
|
-
return
|
|
31136
|
+
return path40.resolve(resolveControlDir(), "..");
|
|
31073
31137
|
}
|
|
31074
31138
|
function buildDockerRunArgs(options) {
|
|
31075
31139
|
const name = options.containerName ?? CONTROL_CONTAINER_NAME;
|
|
@@ -31125,7 +31189,7 @@ async function startMissionControl(options) {
|
|
|
31125
31189
|
"-t",
|
|
31126
31190
|
imageRef,
|
|
31127
31191
|
"-f",
|
|
31128
|
-
|
|
31192
|
+
path40.join(resolveControlDir(), "Dockerfile"),
|
|
31129
31193
|
resolveControlBuildContext()
|
|
31130
31194
|
]);
|
|
31131
31195
|
if (buildCode !== 0) {
|
|
@@ -31269,7 +31333,7 @@ async function ensureTelemetryInfrastructure(options) {
|
|
|
31269
31333
|
|
|
31270
31334
|
// src/core/run-service.ts
|
|
31271
31335
|
init_telemetry_config();
|
|
31272
|
-
var
|
|
31336
|
+
var path42 = __toESM(require("path"));
|
|
31273
31337
|
function extractShellOutput(result) {
|
|
31274
31338
|
const stdout = result.logs?.find((log) => log.stream === "stdout")?.content ?? result.logs?.find((log) => !log.stream)?.content ?? "";
|
|
31275
31339
|
const stderr = result.logs?.find((log) => log.stream === "stderr")?.content ?? "";
|
|
@@ -31442,12 +31506,12 @@ Usage from Cursor / Claude / Codex (opentelemetry-hooks) will appear under Workt
|
|
|
31442
31506
|
suffix: session.suffix,
|
|
31443
31507
|
createdAt: session.createdAt
|
|
31444
31508
|
});
|
|
31445
|
-
const envFile =
|
|
31509
|
+
const envFile = path42.join(session.workDir, `.env.agent.${options.agentId}`);
|
|
31446
31510
|
try {
|
|
31447
31511
|
appendTelemetryEnvToFile(envFile, {
|
|
31448
31512
|
sessionKey,
|
|
31449
31513
|
agentId: options.agentId,
|
|
31450
|
-
repoPath:
|
|
31514
|
+
repoPath: path42.resolve(options.repoPath),
|
|
31451
31515
|
workDir: session.workDir,
|
|
31452
31516
|
branch: session.branch,
|
|
31453
31517
|
suffix: session.suffix
|
|
@@ -31810,7 +31874,7 @@ var envCommand = {
|
|
|
31810
31874
|
}
|
|
31811
31875
|
};
|
|
31812
31876
|
async function handleInit(argv) {
|
|
31813
|
-
const repoPath =
|
|
31877
|
+
const repoPath = path43.resolve(argv.repo);
|
|
31814
31878
|
header("har env init");
|
|
31815
31879
|
info(`Repository: ${repoPath}`);
|
|
31816
31880
|
try {
|
|
@@ -31868,7 +31932,7 @@ async function handleInit(argv) {
|
|
|
31868
31932
|
}
|
|
31869
31933
|
}
|
|
31870
31934
|
async function handleMaintain(argv) {
|
|
31871
|
-
const repoPath =
|
|
31935
|
+
const repoPath = path43.resolve(argv.repo);
|
|
31872
31936
|
header("har env maintain");
|
|
31873
31937
|
info(`Repository: ${repoPath}`);
|
|
31874
31938
|
try {
|
|
@@ -31966,7 +32030,7 @@ async function handleAgentMdProposal(repoPath, autoYes) {
|
|
|
31966
32030
|
if (autoYes) {
|
|
31967
32031
|
const proposal = readAgentMdProposal(repoPath);
|
|
31968
32032
|
if (proposal) {
|
|
31969
|
-
writeFileSafe(
|
|
32033
|
+
writeFileSafe(path43.join(repoPath, "AGENT.md"), proposal.content);
|
|
31970
32034
|
clearAgentMdProposal(repoPath);
|
|
31971
32035
|
info("Applied AGENT.md proposal (--yes)");
|
|
31972
32036
|
}
|
|
@@ -31975,7 +32039,7 @@ async function handleAgentMdProposal(repoPath, autoYes) {
|
|
|
31975
32039
|
await promptApplyAgentMdProposal(repoPath);
|
|
31976
32040
|
}
|
|
31977
32041
|
async function handleAddStage(argv) {
|
|
31978
|
-
const repoPath =
|
|
32042
|
+
const repoPath = path43.resolve(argv.repo);
|
|
31979
32043
|
const available = listStageTemplateIds();
|
|
31980
32044
|
if (argv.list) {
|
|
31981
32045
|
for (const id of available) {
|
|
@@ -32052,7 +32116,7 @@ async function handleAddStage(argv) {
|
|
|
32052
32116
|
}
|
|
32053
32117
|
}
|
|
32054
32118
|
async function handlePreflight(argv) {
|
|
32055
|
-
const repo =
|
|
32119
|
+
const repo = path43.resolve(argv.repo);
|
|
32056
32120
|
const agentId = validateAgentId(argv.id, repo);
|
|
32057
32121
|
const result = await preflightEnvironment({
|
|
32058
32122
|
repoPath: repo,
|
|
@@ -32070,7 +32134,7 @@ async function handlePreflight(argv) {
|
|
|
32070
32134
|
process.exit(result.code);
|
|
32071
32135
|
}
|
|
32072
32136
|
async function handleLaunch(argv) {
|
|
32073
|
-
const repo =
|
|
32137
|
+
const repo = path43.resolve(argv.repo);
|
|
32074
32138
|
const agentId = validateAgentId(argv.id, repo);
|
|
32075
32139
|
let confirmReplace = argv.replace;
|
|
32076
32140
|
let force = argv.force;
|
|
@@ -32082,8 +32146,8 @@ async function handleLaunch(argv) {
|
|
|
32082
32146
|
console.error(guard.reason ?? "");
|
|
32083
32147
|
const readline5 = await import("readline");
|
|
32084
32148
|
const rl = readline5.createInterface({ input: process.stdin, output: process.stderr });
|
|
32085
|
-
const answer = await new Promise((
|
|
32086
|
-
rl.question("Replace this slot? [y/N] ",
|
|
32149
|
+
const answer = await new Promise((resolve35) => {
|
|
32150
|
+
rl.question("Replace this slot? [y/N] ", resolve35);
|
|
32087
32151
|
});
|
|
32088
32152
|
rl.close();
|
|
32089
32153
|
if (!/^[Yy]$/.test(answer.trim())) {
|
|
@@ -32099,8 +32163,8 @@ async function handleLaunch(argv) {
|
|
|
32099
32163
|
warn("Worktree has uncommitted changes.");
|
|
32100
32164
|
const readline5 = await import("readline");
|
|
32101
32165
|
const rl = readline5.createInterface({ input: process.stdin, output: process.stderr });
|
|
32102
|
-
const answer = await new Promise((
|
|
32103
|
-
rl.question("Discard uncommitted changes? [y/N] ",
|
|
32166
|
+
const answer = await new Promise((resolve35) => {
|
|
32167
|
+
rl.question("Discard uncommitted changes? [y/N] ", resolve35);
|
|
32104
32168
|
});
|
|
32105
32169
|
rl.close();
|
|
32106
32170
|
if (!/^[Yy]$/.test(answer.trim())) {
|
|
@@ -32154,7 +32218,7 @@ async function handleRecover(argv) {
|
|
|
32154
32218
|
});
|
|
32155
32219
|
}
|
|
32156
32220
|
async function handleVerify(argv) {
|
|
32157
|
-
const repo =
|
|
32221
|
+
const repo = path43.resolve(argv.repo);
|
|
32158
32222
|
const agentId = validateAgentId(argv.id, repo);
|
|
32159
32223
|
const result = await runVerification({
|
|
32160
32224
|
repoPath: repo,
|
|
@@ -32166,7 +32230,7 @@ async function handleVerify(argv) {
|
|
|
32166
32230
|
process.exit(result.code);
|
|
32167
32231
|
}
|
|
32168
32232
|
async function handleTeardown(argv) {
|
|
32169
|
-
const repo =
|
|
32233
|
+
const repo = path43.resolve(argv.repo);
|
|
32170
32234
|
const agentId = validateAgentId(argv.id, repo);
|
|
32171
32235
|
const result = await teardownEnvironment({
|
|
32172
32236
|
repoPath: repo,
|
|
@@ -32177,7 +32241,7 @@ async function handleTeardown(argv) {
|
|
|
32177
32241
|
process.exit(result.code);
|
|
32178
32242
|
}
|
|
32179
32243
|
async function handleComplete(argv) {
|
|
32180
|
-
const repo =
|
|
32244
|
+
const repo = path43.resolve(argv.repo);
|
|
32181
32245
|
const agentId = validateAgentId(argv.id, repo);
|
|
32182
32246
|
const result = await completeEnvironment({
|
|
32183
32247
|
repoPath: repo,
|
|
@@ -32198,7 +32262,7 @@ async function handleComplete(argv) {
|
|
|
32198
32262
|
process.exit(result.code);
|
|
32199
32263
|
}
|
|
32200
32264
|
async function handleStatus(argv) {
|
|
32201
|
-
const repoPath =
|
|
32265
|
+
const repoPath = path43.resolve(argv.repo);
|
|
32202
32266
|
if (argv.json) {
|
|
32203
32267
|
const status = collectEnvironmentStatus(repoPath);
|
|
32204
32268
|
const output = EnvironmentStatusSchema.parse(status);
|
|
@@ -32211,7 +32275,7 @@ async function handleStatus(argv) {
|
|
|
32211
32275
|
});
|
|
32212
32276
|
}
|
|
32213
32277
|
async function handleRunsList(argv) {
|
|
32214
|
-
const repoPath =
|
|
32278
|
+
const repoPath = path43.resolve(argv.repo);
|
|
32215
32279
|
const runs = listRuns(repoPath, { stageId: argv.stage, limit: argv.limit });
|
|
32216
32280
|
if (argv.json) {
|
|
32217
32281
|
process.stdout.write(JSON.stringify({ runs }, null, 2) + "\n");
|
|
@@ -32228,7 +32292,7 @@ async function handleRunsList(argv) {
|
|
|
32228
32292
|
}
|
|
32229
32293
|
}
|
|
32230
32294
|
async function handleRunsGet(argv) {
|
|
32231
|
-
const run2 = getRun(
|
|
32295
|
+
const run2 = getRun(path43.resolve(argv.repo), argv.runId);
|
|
32232
32296
|
if (!run2) {
|
|
32233
32297
|
error(`Run not found: ${argv.runId}`);
|
|
32234
32298
|
process.exit(1);
|
|
@@ -32307,7 +32371,7 @@ function printNextSteps(auto2) {
|
|
|
32307
32371
|
}
|
|
32308
32372
|
|
|
32309
32373
|
// src/cli/commands/control.ts
|
|
32310
|
-
var
|
|
32374
|
+
var path44 = __toESM(require("path"));
|
|
32311
32375
|
init_control_config();
|
|
32312
32376
|
var controlCommand = {
|
|
32313
32377
|
command: "control <subcommand>",
|
|
@@ -32411,7 +32475,7 @@ async function handleDown() {
|
|
|
32411
32475
|
process.exit(code);
|
|
32412
32476
|
}
|
|
32413
32477
|
async function handleRegister(argv) {
|
|
32414
|
-
const repoPath =
|
|
32478
|
+
const repoPath = path44.resolve(argv.repo);
|
|
32415
32479
|
header("har control register");
|
|
32416
32480
|
info(`Repository: ${repoPath}`);
|
|
32417
32481
|
try {
|
|
@@ -32431,7 +32495,7 @@ async function handleRegister(argv) {
|
|
|
32431
32495
|
}
|
|
32432
32496
|
}
|
|
32433
32497
|
async function handleSync(argv) {
|
|
32434
|
-
const repoPath =
|
|
32498
|
+
const repoPath = path44.resolve(argv.repo);
|
|
32435
32499
|
try {
|
|
32436
32500
|
await syncRepoWithControl({
|
|
32437
32501
|
repoPath,
|
|
@@ -32470,7 +32534,7 @@ async function handleWatch(argv) {
|
|
|
32470
32534
|
};
|
|
32471
32535
|
const tick = async () => {
|
|
32472
32536
|
if (argv.repo) {
|
|
32473
|
-
await syncOne(
|
|
32537
|
+
await syncOne(path44.resolve(argv.repo));
|
|
32474
32538
|
return;
|
|
32475
32539
|
}
|
|
32476
32540
|
try {
|
|
@@ -32501,12 +32565,12 @@ async function handleLogin(argv) {
|
|
|
32501
32565
|
}
|
|
32502
32566
|
|
|
32503
32567
|
// src/cli/commands/hooks.ts
|
|
32504
|
-
var
|
|
32568
|
+
var path47 = __toESM(require("path"));
|
|
32505
32569
|
|
|
32506
32570
|
// src/core/hooks.ts
|
|
32507
|
-
var
|
|
32571
|
+
var fs40 = __toESM(require("fs"));
|
|
32508
32572
|
var os13 = __toESM(require("os"));
|
|
32509
|
-
var
|
|
32573
|
+
var path45 = __toESM(require("path"));
|
|
32510
32574
|
var MARKER_START = "# >>> har commit gate (managed by `har hooks`) >>>";
|
|
32511
32575
|
var MARKER_END = "# <<< har commit gate <<<";
|
|
32512
32576
|
var PRE_COMMIT_BLOCK = [
|
|
@@ -32521,27 +32585,27 @@ var POST_COMMIT_BLOCK = [
|
|
|
32521
32585
|
'"$(git rev-parse --git-path hooks)/har-post-commit" || true',
|
|
32522
32586
|
MARKER_END
|
|
32523
32587
|
].join("\n");
|
|
32524
|
-
function
|
|
32588
|
+
function tryGit3(cwd, args) {
|
|
32525
32589
|
const result = run(`git ${args}`, { cwd });
|
|
32526
32590
|
return result.code === 0 ? result.stdout.trim() : void 0;
|
|
32527
32591
|
}
|
|
32528
32592
|
function resolveCheckoutRoot(cwd) {
|
|
32529
|
-
return
|
|
32593
|
+
return tryGit3(cwd, "rev-parse --show-toplevel");
|
|
32530
32594
|
}
|
|
32531
32595
|
function resolveHooksDir(checkoutDir) {
|
|
32532
|
-
const hooksPath =
|
|
32596
|
+
const hooksPath = tryGit3(checkoutDir, "rev-parse --git-path hooks");
|
|
32533
32597
|
if (!hooksPath) throw new Error(`Not a git checkout: ${checkoutDir}`);
|
|
32534
|
-
return
|
|
32598
|
+
return path45.resolve(checkoutDir, hooksPath);
|
|
32535
32599
|
}
|
|
32536
32600
|
function getConfiguredHooksPath(checkoutDir) {
|
|
32537
|
-
return
|
|
32601
|
+
return tryGit3(checkoutDir, "config core.hooksPath") || void 0;
|
|
32538
32602
|
}
|
|
32539
32603
|
function defaultHarInvocation() {
|
|
32540
32604
|
const entry = process.argv[1];
|
|
32541
32605
|
if (entry && entry.endsWith(".js")) {
|
|
32542
|
-
return `"${process.execPath}" "${
|
|
32606
|
+
return `"${process.execPath}" "${path45.resolve(entry)}"`;
|
|
32543
32607
|
}
|
|
32544
|
-
if (entry) return `"${
|
|
32608
|
+
if (entry) return `"${path45.resolve(entry)}"`;
|
|
32545
32609
|
return "har";
|
|
32546
32610
|
}
|
|
32547
32611
|
function buildHookScript(harInvocation, subcommand, failOpenNotice) {
|
|
@@ -32562,40 +32626,40 @@ exit 0
|
|
|
32562
32626
|
`;
|
|
32563
32627
|
}
|
|
32564
32628
|
function upsertMarkedBlock(filePath, block) {
|
|
32565
|
-
if (!
|
|
32566
|
-
|
|
32629
|
+
if (!fs40.existsSync(filePath)) {
|
|
32630
|
+
fs40.writeFileSync(filePath, `#!/bin/sh
|
|
32567
32631
|
${block}
|
|
32568
32632
|
`, { mode: 493 });
|
|
32569
32633
|
return "created";
|
|
32570
32634
|
}
|
|
32571
|
-
const content =
|
|
32635
|
+
const content = fs40.readFileSync(filePath, "utf8");
|
|
32572
32636
|
if (content.includes(MARKER_START)) {
|
|
32573
32637
|
const pattern = new RegExp(
|
|
32574
32638
|
`${escapeRegExp(MARKER_START)}[\\s\\S]*?${escapeRegExp(MARKER_END)}`
|
|
32575
32639
|
);
|
|
32576
|
-
|
|
32577
|
-
|
|
32640
|
+
fs40.writeFileSync(filePath, content.replace(pattern, block));
|
|
32641
|
+
fs40.chmodSync(filePath, 493);
|
|
32578
32642
|
return "updated";
|
|
32579
32643
|
}
|
|
32580
32644
|
const suffix = content.endsWith("\n") ? "" : "\n";
|
|
32581
|
-
|
|
32645
|
+
fs40.writeFileSync(filePath, `${content}${suffix}
|
|
32582
32646
|
${block}
|
|
32583
32647
|
`);
|
|
32584
|
-
|
|
32648
|
+
fs40.chmodSync(filePath, 493);
|
|
32585
32649
|
return "appended";
|
|
32586
32650
|
}
|
|
32587
32651
|
function removeMarkedBlock(filePath) {
|
|
32588
|
-
if (!
|
|
32589
|
-
const content =
|
|
32652
|
+
if (!fs40.existsSync(filePath)) return false;
|
|
32653
|
+
const content = fs40.readFileSync(filePath, "utf8");
|
|
32590
32654
|
if (!content.includes(MARKER_START)) return false;
|
|
32591
32655
|
const pattern = new RegExp(
|
|
32592
32656
|
`\\n?${escapeRegExp(MARKER_START)}[\\s\\S]*?${escapeRegExp(MARKER_END)}\\n?`
|
|
32593
32657
|
);
|
|
32594
32658
|
const stripped = content.replace(pattern, "\n");
|
|
32595
32659
|
if (stripped.replace(/^#!\/bin\/sh\n?/, "").trim() === "") {
|
|
32596
|
-
|
|
32660
|
+
fs40.rmSync(filePath);
|
|
32597
32661
|
} else {
|
|
32598
|
-
|
|
32662
|
+
fs40.writeFileSync(filePath, stripped);
|
|
32599
32663
|
}
|
|
32600
32664
|
return true;
|
|
32601
32665
|
}
|
|
@@ -32617,20 +32681,20 @@ Or re-run with --force to write into that directory anyway.`
|
|
|
32617
32681
|
);
|
|
32618
32682
|
}
|
|
32619
32683
|
const hooksDir = resolveHooksDir(checkout);
|
|
32620
|
-
|
|
32684
|
+
fs40.mkdirSync(hooksDir, { recursive: true });
|
|
32621
32685
|
const invocation = options.harInvocation ?? defaultHarInvocation();
|
|
32622
|
-
|
|
32623
|
-
|
|
32686
|
+
fs40.writeFileSync(
|
|
32687
|
+
path45.join(hooksDir, "har-pre-commit"),
|
|
32624
32688
|
buildHookScript(invocation, "check", "har: binary not found; skipping commit gate (reinstall with har hooks install)"),
|
|
32625
32689
|
{ mode: 493 }
|
|
32626
32690
|
);
|
|
32627
|
-
|
|
32628
|
-
|
|
32691
|
+
fs40.writeFileSync(
|
|
32692
|
+
path45.join(hooksDir, "har-post-commit"),
|
|
32629
32693
|
buildHookScript(invocation, "record-commit", "har: binary not found; skipping commit association"),
|
|
32630
32694
|
{ mode: 493 }
|
|
32631
32695
|
);
|
|
32632
|
-
const preCommit = upsertMarkedBlock(
|
|
32633
|
-
const postCommit = upsertMarkedBlock(
|
|
32696
|
+
const preCommit = upsertMarkedBlock(path45.join(hooksDir, "pre-commit"), PRE_COMMIT_BLOCK);
|
|
32697
|
+
const postCommit = upsertMarkedBlock(path45.join(hooksDir, "post-commit"), POST_COMMIT_BLOCK);
|
|
32634
32698
|
ensureValidationsIgnored(checkout);
|
|
32635
32699
|
return { hooksDir, preCommit, postCommit };
|
|
32636
32700
|
}
|
|
@@ -32639,12 +32703,12 @@ function uninstallHooks(repoPath) {
|
|
|
32639
32703
|
if (!checkout) throw new Error(`Not a git repository: ${repoPath}`);
|
|
32640
32704
|
const hooksDir = resolveHooksDir(checkout);
|
|
32641
32705
|
let removed = false;
|
|
32642
|
-
removed = removeMarkedBlock(
|
|
32643
|
-
removed = removeMarkedBlock(
|
|
32706
|
+
removed = removeMarkedBlock(path45.join(hooksDir, "pre-commit")) || removed;
|
|
32707
|
+
removed = removeMarkedBlock(path45.join(hooksDir, "post-commit")) || removed;
|
|
32644
32708
|
for (const file of ["har-pre-commit", "har-post-commit"]) {
|
|
32645
|
-
const full =
|
|
32646
|
-
if (
|
|
32647
|
-
|
|
32709
|
+
const full = path45.join(hooksDir, file);
|
|
32710
|
+
if (fs40.existsSync(full)) {
|
|
32711
|
+
fs40.rmSync(full);
|
|
32648
32712
|
removed = true;
|
|
32649
32713
|
}
|
|
32650
32714
|
}
|
|
@@ -32661,9 +32725,9 @@ function getCommitGateConfig(checkoutDir) {
|
|
|
32661
32725
|
function isAgentWorktree(checkoutDir) {
|
|
32662
32726
|
const branch = getCurrentBranch(checkoutDir);
|
|
32663
32727
|
if (branch && /^har-agent-\d+$/.test(branch)) return true;
|
|
32664
|
-
const worktreesRoot =
|
|
32665
|
-
const resolved =
|
|
32666
|
-
return resolved.startsWith(`${worktreesRoot}${
|
|
32728
|
+
const worktreesRoot = path45.join(os13.homedir(), "worktrees");
|
|
32729
|
+
const resolved = path45.resolve(checkoutDir);
|
|
32730
|
+
return resolved.startsWith(`${worktreesRoot}${path45.sep}`) && /-agent-\d+$/.test(path45.basename(resolved));
|
|
32667
32731
|
}
|
|
32668
32732
|
function resolveEffectiveMode(checkoutDir, gate) {
|
|
32669
32733
|
if (!gate.enabled) return "off";
|
|
@@ -32676,15 +32740,15 @@ function getHooksStatus(repoPath) {
|
|
|
32676
32740
|
const hooksDir = resolveHooksDir(checkout);
|
|
32677
32741
|
const gate = getCommitGateConfig(checkout);
|
|
32678
32742
|
const hasBlock = (name) => {
|
|
32679
|
-
const file =
|
|
32680
|
-
return
|
|
32743
|
+
const file = path45.join(hooksDir, name);
|
|
32744
|
+
return fs40.existsSync(file) && fs40.readFileSync(file, "utf8").includes(MARKER_START);
|
|
32681
32745
|
};
|
|
32682
32746
|
return {
|
|
32683
32747
|
checkout,
|
|
32684
32748
|
hooksDir,
|
|
32685
32749
|
configuredHooksPath: getConfiguredHooksPath(checkout),
|
|
32686
|
-
preCommitInstalled: hasBlock("pre-commit") &&
|
|
32687
|
-
postCommitInstalled: hasBlock("post-commit") &&
|
|
32750
|
+
preCommitInstalled: hasBlock("pre-commit") && fs40.existsSync(path45.join(hooksDir, "har-pre-commit")),
|
|
32751
|
+
postCommitInstalled: hasBlock("post-commit") && fs40.existsSync(path45.join(hooksDir, "har-post-commit")),
|
|
32688
32752
|
gate,
|
|
32689
32753
|
effectiveMode: resolveEffectiveMode(checkout, gate)
|
|
32690
32754
|
};
|
|
@@ -32695,7 +32759,7 @@ function checkCommitGate(cwd) {
|
|
|
32695
32759
|
}
|
|
32696
32760
|
const checkout = resolveCheckoutRoot(cwd);
|
|
32697
32761
|
if (!checkout) return { exitCode: 0, messages: [] };
|
|
32698
|
-
if (!
|
|
32762
|
+
if (!fs40.existsSync(path45.join(checkout, ".har", "stages.json"))) {
|
|
32699
32763
|
return { exitCode: 0, messages: [] };
|
|
32700
32764
|
}
|
|
32701
32765
|
const gate = getCommitGateConfig(checkout);
|
|
@@ -32752,7 +32816,7 @@ async function recordCommitAssociation(cwd) {
|
|
|
32752
32816
|
const checkout = resolveCheckoutRoot(cwd);
|
|
32753
32817
|
if (!checkout) return { attached: false };
|
|
32754
32818
|
const commitSha = getHeadSha(checkout);
|
|
32755
|
-
const tree =
|
|
32819
|
+
const tree = tryGit3(checkout, "rev-parse HEAD^{tree}");
|
|
32756
32820
|
if (!commitSha || !tree) return { attached: false };
|
|
32757
32821
|
const updated = attachCommit(checkout, tree, commitSha);
|
|
32758
32822
|
if (updated) {
|
|
@@ -32766,8 +32830,8 @@ async function recordCommitAssociation(cwd) {
|
|
|
32766
32830
|
}
|
|
32767
32831
|
|
|
32768
32832
|
// src/core/claude-hooks.ts
|
|
32769
|
-
var
|
|
32770
|
-
var
|
|
32833
|
+
var fs41 = __toESM(require("fs"));
|
|
32834
|
+
var path46 = __toESM(require("path"));
|
|
32771
32835
|
var CLAUDE_GUARD_RELATIVE_PATH = ".har/hooks/claude-worktree-guard.sh";
|
|
32772
32836
|
var CLAUDE_SETTINGS_RELATIVE_PATH = ".claude/settings.json";
|
|
32773
32837
|
var GUARD_MATCHER = "Edit|Write|MultiEdit|NotebookEdit";
|
|
@@ -32778,8 +32842,8 @@ function isHarGuardEntry(entry) {
|
|
|
32778
32842
|
);
|
|
32779
32843
|
}
|
|
32780
32844
|
function readSettings(settingsPath) {
|
|
32781
|
-
if (!
|
|
32782
|
-
const raw =
|
|
32845
|
+
if (!fs41.existsSync(settingsPath)) return {};
|
|
32846
|
+
const raw = fs41.readFileSync(settingsPath, "utf8").trim();
|
|
32783
32847
|
if (raw === "") return {};
|
|
32784
32848
|
const parsed = JSON.parse(raw);
|
|
32785
32849
|
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
@@ -32788,19 +32852,19 @@ function readSettings(settingsPath) {
|
|
|
32788
32852
|
return parsed;
|
|
32789
32853
|
}
|
|
32790
32854
|
function writeSettings(settingsPath, settings) {
|
|
32791
|
-
|
|
32792
|
-
|
|
32855
|
+
fs41.mkdirSync(path46.dirname(settingsPath), { recursive: true });
|
|
32856
|
+
fs41.writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + "\n");
|
|
32793
32857
|
}
|
|
32794
32858
|
function installClaudeGuard(repoPath) {
|
|
32795
32859
|
const templatePath = resolveTemplateFile("claude-worktree-guard.sh.template");
|
|
32796
32860
|
if (!templatePath) {
|
|
32797
32861
|
throw new Error("Guard template not found (claude-worktree-guard.sh.template). Run npm run build.");
|
|
32798
32862
|
}
|
|
32799
|
-
const guardScript =
|
|
32800
|
-
|
|
32801
|
-
|
|
32802
|
-
|
|
32803
|
-
const settingsPath =
|
|
32863
|
+
const guardScript = path46.join(repoPath, CLAUDE_GUARD_RELATIVE_PATH);
|
|
32864
|
+
fs41.mkdirSync(path46.dirname(guardScript), { recursive: true });
|
|
32865
|
+
fs41.copyFileSync(templatePath, guardScript);
|
|
32866
|
+
fs41.chmodSync(guardScript, 493);
|
|
32867
|
+
const settingsPath = path46.join(repoPath, CLAUDE_SETTINGS_RELATIVE_PATH);
|
|
32804
32868
|
const settings = readSettings(settingsPath);
|
|
32805
32869
|
const hooks = settings.hooks ?? {};
|
|
32806
32870
|
const preToolUse = (hooks.PreToolUse ?? []).filter((entry) => !isHarGuardEntry(entry));
|
|
@@ -32814,15 +32878,15 @@ function installClaudeGuard(repoPath) {
|
|
|
32814
32878
|
}
|
|
32815
32879
|
function uninstallClaudeGuard(repoPath) {
|
|
32816
32880
|
let removed = false;
|
|
32817
|
-
const guardScript =
|
|
32818
|
-
if (
|
|
32819
|
-
|
|
32881
|
+
const guardScript = path46.join(repoPath, CLAUDE_GUARD_RELATIVE_PATH);
|
|
32882
|
+
if (fs41.existsSync(guardScript)) {
|
|
32883
|
+
fs41.rmSync(guardScript);
|
|
32820
32884
|
removed = true;
|
|
32821
|
-
const parent =
|
|
32822
|
-
if (
|
|
32885
|
+
const parent = path46.dirname(guardScript);
|
|
32886
|
+
if (fs41.existsSync(parent) && fs41.readdirSync(parent).length === 0) fs41.rmdirSync(parent);
|
|
32823
32887
|
}
|
|
32824
|
-
const settingsPath =
|
|
32825
|
-
if (
|
|
32888
|
+
const settingsPath = path46.join(repoPath, CLAUDE_SETTINGS_RELATIVE_PATH);
|
|
32889
|
+
if (fs41.existsSync(settingsPath)) {
|
|
32826
32890
|
const settings = readSettings(settingsPath);
|
|
32827
32891
|
const preToolUse = settings.hooks?.PreToolUse;
|
|
32828
32892
|
if (preToolUse) {
|
|
@@ -32847,8 +32911,8 @@ function uninstallClaudeGuard(repoPath) {
|
|
|
32847
32911
|
return { removed };
|
|
32848
32912
|
}
|
|
32849
32913
|
function claudeGuardInstalled(repoPath) {
|
|
32850
|
-
const settingsPath =
|
|
32851
|
-
if (!
|
|
32914
|
+
const settingsPath = path46.join(repoPath, CLAUDE_SETTINGS_RELATIVE_PATH);
|
|
32915
|
+
if (!fs41.existsSync(settingsPath)) return false;
|
|
32852
32916
|
try {
|
|
32853
32917
|
const settings = readSettings(settingsPath);
|
|
32854
32918
|
return (settings.hooks?.PreToolUse ?? []).some(isHarGuardEntry);
|
|
@@ -32864,7 +32928,7 @@ function repoOption(y2) {
|
|
|
32864
32928
|
function handleInstall2(argv) {
|
|
32865
32929
|
try {
|
|
32866
32930
|
if (argv.claude) {
|
|
32867
|
-
const result2 = installClaudeGuard(
|
|
32931
|
+
const result2 = installClaudeGuard(path47.resolve(argv.repo));
|
|
32868
32932
|
success("Claude Code worktree guard installed.");
|
|
32869
32933
|
info(`Guard script: ${result2.guardScript}`);
|
|
32870
32934
|
info(`Settings: ${result2.settingsPath} (PreToolUse: Edit|Write|MultiEdit|NotebookEdit)`);
|
|
@@ -32872,7 +32936,7 @@ function handleInstall2(argv) {
|
|
|
32872
32936
|
info("Commit both files so the guard travels with the repo.");
|
|
32873
32937
|
return;
|
|
32874
32938
|
}
|
|
32875
|
-
const result = installHooks({ repoPath:
|
|
32939
|
+
const result = installHooks({ repoPath: path47.resolve(argv.repo), force: argv.force });
|
|
32876
32940
|
success(`Commit gate installed in ${result.hooksDir}`);
|
|
32877
32941
|
info(`pre-commit: ${result.preCommit}, post-commit: ${result.postCommit}`);
|
|
32878
32942
|
info("Commits of unverified change batches will be blocked in agent worktrees.");
|
|
@@ -32885,7 +32949,7 @@ function handleInstall2(argv) {
|
|
|
32885
32949
|
function handleUninstall(argv) {
|
|
32886
32950
|
try {
|
|
32887
32951
|
if (argv.claude) {
|
|
32888
|
-
const result2 = uninstallClaudeGuard(
|
|
32952
|
+
const result2 = uninstallClaudeGuard(path47.resolve(argv.repo));
|
|
32889
32953
|
if (result2.removed) {
|
|
32890
32954
|
success("Claude Code worktree guard removed.");
|
|
32891
32955
|
} else {
|
|
@@ -32893,7 +32957,7 @@ function handleUninstall(argv) {
|
|
|
32893
32957
|
}
|
|
32894
32958
|
return;
|
|
32895
32959
|
}
|
|
32896
|
-
const result = uninstallHooks(
|
|
32960
|
+
const result = uninstallHooks(path47.resolve(argv.repo));
|
|
32897
32961
|
if (result.removed) {
|
|
32898
32962
|
success(`Commit gate removed from ${result.hooksDir}`);
|
|
32899
32963
|
} else {
|
|
@@ -32906,7 +32970,7 @@ function handleUninstall(argv) {
|
|
|
32906
32970
|
}
|
|
32907
32971
|
function handleStatus2(argv) {
|
|
32908
32972
|
try {
|
|
32909
|
-
const status = getHooksStatus(
|
|
32973
|
+
const status = getHooksStatus(path47.resolve(argv.repo));
|
|
32910
32974
|
if (argv.json) {
|
|
32911
32975
|
process.stdout.write(`${JSON.stringify(status, null, 2)}
|
|
32912
32976
|
`);
|
|
@@ -32924,7 +32988,7 @@ function handleStatus2(argv) {
|
|
|
32924
32988
|
);
|
|
32925
32989
|
info(`Effective: ${status.effectiveMode} (in this checkout)`);
|
|
32926
32990
|
info(
|
|
32927
|
-
`Claude guard: ${claudeGuardInstalled(
|
|
32991
|
+
`Claude guard: ${claudeGuardInstalled(path47.resolve(argv.repo)) ? `installed (${CLAUDE_GUARD_RELATIVE_PATH})` : "not installed"}`
|
|
32928
32992
|
);
|
|
32929
32993
|
} catch (err) {
|
|
32930
32994
|
error(err instanceof Error ? err.message : String(err));
|
|
@@ -33185,10 +33249,10 @@ function assignProp(target, prop, value) {
|
|
|
33185
33249
|
configurable: true
|
|
33186
33250
|
});
|
|
33187
33251
|
}
|
|
33188
|
-
function getElementAtPath(obj,
|
|
33189
|
-
if (!
|
|
33252
|
+
function getElementAtPath(obj, path50) {
|
|
33253
|
+
if (!path50)
|
|
33190
33254
|
return obj;
|
|
33191
|
-
return
|
|
33255
|
+
return path50.reduce((acc, key) => acc?.[key], obj);
|
|
33192
33256
|
}
|
|
33193
33257
|
function promiseAllObject(promisesObj) {
|
|
33194
33258
|
const keys = Object.keys(promisesObj);
|
|
@@ -33508,11 +33572,11 @@ function aborted(x2, startIndex = 0) {
|
|
|
33508
33572
|
}
|
|
33509
33573
|
return false;
|
|
33510
33574
|
}
|
|
33511
|
-
function prefixIssues(
|
|
33575
|
+
function prefixIssues(path50, issues) {
|
|
33512
33576
|
return issues.map((iss) => {
|
|
33513
33577
|
var _a3;
|
|
33514
33578
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
33515
|
-
iss.path.unshift(
|
|
33579
|
+
iss.path.unshift(path50);
|
|
33516
33580
|
return iss;
|
|
33517
33581
|
});
|
|
33518
33582
|
}
|
|
@@ -38835,7 +38899,7 @@ var Protocol = class {
|
|
|
38835
38899
|
return;
|
|
38836
38900
|
}
|
|
38837
38901
|
const pollInterval = task2.pollInterval ?? this._options?.defaultTaskPollInterval ?? 1e3;
|
|
38838
|
-
await new Promise((
|
|
38902
|
+
await new Promise((resolve35) => setTimeout(resolve35, pollInterval));
|
|
38839
38903
|
options?.signal?.throwIfAborted();
|
|
38840
38904
|
}
|
|
38841
38905
|
} catch (error3) {
|
|
@@ -38852,7 +38916,7 @@ var Protocol = class {
|
|
|
38852
38916
|
*/
|
|
38853
38917
|
request(request, resultSchema, options) {
|
|
38854
38918
|
const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
|
|
38855
|
-
return new Promise((
|
|
38919
|
+
return new Promise((resolve35, reject) => {
|
|
38856
38920
|
const earlyReject = (error3) => {
|
|
38857
38921
|
reject(error3);
|
|
38858
38922
|
};
|
|
@@ -38930,7 +38994,7 @@ var Protocol = class {
|
|
|
38930
38994
|
if (!parseResult.success) {
|
|
38931
38995
|
reject(parseResult.error);
|
|
38932
38996
|
} else {
|
|
38933
|
-
|
|
38997
|
+
resolve35(parseResult.data);
|
|
38934
38998
|
}
|
|
38935
38999
|
} catch (error3) {
|
|
38936
39000
|
reject(error3);
|
|
@@ -39191,12 +39255,12 @@ var Protocol = class {
|
|
|
39191
39255
|
}
|
|
39192
39256
|
} catch {
|
|
39193
39257
|
}
|
|
39194
|
-
return new Promise((
|
|
39258
|
+
return new Promise((resolve35, reject) => {
|
|
39195
39259
|
if (signal.aborted) {
|
|
39196
39260
|
reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
39197
39261
|
return;
|
|
39198
39262
|
}
|
|
39199
|
-
const timeoutId = setTimeout(
|
|
39263
|
+
const timeoutId = setTimeout(resolve35, interval);
|
|
39200
39264
|
signal.addEventListener("abort", () => {
|
|
39201
39265
|
clearTimeout(timeoutId);
|
|
39202
39266
|
reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
@@ -39986,7 +40050,7 @@ var Server = class extends Protocol {
|
|
|
39986
40050
|
};
|
|
39987
40051
|
|
|
39988
40052
|
// src/mcp/server.ts
|
|
39989
|
-
var
|
|
40053
|
+
var path48 = __toESM(require("path"));
|
|
39990
40054
|
|
|
39991
40055
|
// node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
|
|
39992
40056
|
var import_node_process2 = __toESM(require("node:process"), 1);
|
|
@@ -40069,12 +40133,12 @@ var StdioServerTransport = class {
|
|
|
40069
40133
|
this.onclose?.();
|
|
40070
40134
|
}
|
|
40071
40135
|
send(message) {
|
|
40072
|
-
return new Promise((
|
|
40136
|
+
return new Promise((resolve35) => {
|
|
40073
40137
|
const json = serializeMessage(message);
|
|
40074
40138
|
if (this._stdout.write(json)) {
|
|
40075
|
-
|
|
40139
|
+
resolve35();
|
|
40076
40140
|
} else {
|
|
40077
|
-
this._stdout.once("drain",
|
|
40141
|
+
this._stdout.once("drain", resolve35);
|
|
40078
40142
|
}
|
|
40079
40143
|
});
|
|
40080
40144
|
}
|
|
@@ -40618,7 +40682,7 @@ async function handleMcpToolCall(toolName, args, defaultRepo = ".") {
|
|
|
40618
40682
|
const input = ControlUpInputSchema.parse({ ...args, repo });
|
|
40619
40683
|
const result = await startControlAndSync({
|
|
40620
40684
|
detach: input.detach,
|
|
40621
|
-
cwd:
|
|
40685
|
+
cwd: path48.resolve(input.repo)
|
|
40622
40686
|
});
|
|
40623
40687
|
if (result.code !== 0) {
|
|
40624
40688
|
return {
|
|
@@ -40681,7 +40745,7 @@ var mcpCommand = {
|
|
|
40681
40745
|
};
|
|
40682
40746
|
|
|
40683
40747
|
// src/cli/commands/telemetry.ts
|
|
40684
|
-
var
|
|
40748
|
+
var path49 = __toESM(require("path"));
|
|
40685
40749
|
init_control_config();
|
|
40686
40750
|
init_otel_hooks();
|
|
40687
40751
|
init_telemetry_config();
|
|
@@ -40766,7 +40830,7 @@ async function handleOff() {
|
|
|
40766
40830
|
info("Mission Control will not auto-start. Existing usage rows are kept.");
|
|
40767
40831
|
}
|
|
40768
40832
|
async function handleWriteEnv(argv) {
|
|
40769
|
-
const repoPath =
|
|
40833
|
+
const repoPath = path49.resolve(argv.repo);
|
|
40770
40834
|
const harnessRoot = resolveHarnessRoot(repoPath);
|
|
40771
40835
|
const session = readSlotRegistry(harnessRoot, argv.agentId);
|
|
40772
40836
|
const workDir = argv.workDir ?? session?.workDir ?? repoPath;
|
|
@@ -40778,7 +40842,7 @@ async function handleWriteEnv(argv) {
|
|
|
40778
40842
|
suffix,
|
|
40779
40843
|
createdAt: session?.createdAt
|
|
40780
40844
|
});
|
|
40781
|
-
const envFile = argv.envFile ??
|
|
40845
|
+
const envFile = argv.envFile ?? path49.join(workDir, `.env.agent.${argv.agentId}`);
|
|
40782
40846
|
const attrs = {
|
|
40783
40847
|
sessionKey,
|
|
40784
40848
|
agentId: argv.agentId,
|
|
@@ -40797,7 +40861,7 @@ async function handleWriteEnv(argv) {
|
|
|
40797
40861
|
success(`Wrote session attribution to ${envFile}`);
|
|
40798
40862
|
}
|
|
40799
40863
|
function handlePrintEnv(argv) {
|
|
40800
|
-
const repoPath =
|
|
40864
|
+
const repoPath = path49.resolve(argv.repo);
|
|
40801
40865
|
const workDir = argv.workDir ?? repoPath;
|
|
40802
40866
|
const sessionKey = buildSessionKey({
|
|
40803
40867
|
branch: argv.branch,
|