@osfactory/har 0.26.0 → 0.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +436 -354
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -873,14 +873,14 @@ var require_url_state_machine = __commonJS({
|
|
|
873
873
|
return url.replace(/\u0009|\u000A|\u000D/g, "");
|
|
874
874
|
}
|
|
875
875
|
function shortenPath(url) {
|
|
876
|
-
const
|
|
877
|
-
if (
|
|
876
|
+
const path57 = url.path;
|
|
877
|
+
if (path57.length === 0) {
|
|
878
878
|
return;
|
|
879
879
|
}
|
|
880
|
-
if (url.scheme === "file" &&
|
|
880
|
+
if (url.scheme === "file" && path57.length === 1 && isNormalizedWindowsDriveLetter(path57[0])) {
|
|
881
881
|
return;
|
|
882
882
|
}
|
|
883
|
-
|
|
883
|
+
path57.pop();
|
|
884
884
|
}
|
|
885
885
|
function includesCredentials(url) {
|
|
886
886
|
return url.username !== "" || url.password !== "";
|
|
@@ -2200,7 +2200,7 @@ var require_lib2 = __commonJS({
|
|
|
2200
2200
|
let accum = [];
|
|
2201
2201
|
let accumBytes = 0;
|
|
2202
2202
|
let abort = false;
|
|
2203
|
-
return new Body.Promise(function(
|
|
2203
|
+
return new Body.Promise(function(resolve41, reject) {
|
|
2204
2204
|
let resTimeout;
|
|
2205
2205
|
if (_this4.timeout) {
|
|
2206
2206
|
resTimeout = setTimeout(function() {
|
|
@@ -2234,7 +2234,7 @@ var require_lib2 = __commonJS({
|
|
|
2234
2234
|
}
|
|
2235
2235
|
clearTimeout(resTimeout);
|
|
2236
2236
|
try {
|
|
2237
|
-
|
|
2237
|
+
resolve41(Buffer.concat(accum, accumBytes));
|
|
2238
2238
|
} catch (err) {
|
|
2239
2239
|
reject(new FetchError(`Could not create Buffer from response body for ${_this4.url}: ${err.message}`, "system", err));
|
|
2240
2240
|
}
|
|
@@ -2909,7 +2909,7 @@ var require_lib2 = __commonJS({
|
|
|
2909
2909
|
throw new Error("native promise missing, set fetch.Promise to your favorite alternative");
|
|
2910
2910
|
}
|
|
2911
2911
|
Body.Promise = fetch3.Promise;
|
|
2912
|
-
return new fetch3.Promise(function(
|
|
2912
|
+
return new fetch3.Promise(function(resolve41, reject) {
|
|
2913
2913
|
const request = new Request3(url, opts);
|
|
2914
2914
|
const options = getNodeRequestOptions(request);
|
|
2915
2915
|
const send = (options.protocol === "https:" ? https : http2).request;
|
|
@@ -3042,7 +3042,7 @@ var require_lib2 = __commonJS({
|
|
|
3042
3042
|
requestOpts.body = void 0;
|
|
3043
3043
|
requestOpts.headers.delete("content-length");
|
|
3044
3044
|
}
|
|
3045
|
-
|
|
3045
|
+
resolve41(fetch3(new Request3(locationURL, requestOpts)));
|
|
3046
3046
|
finalize();
|
|
3047
3047
|
return;
|
|
3048
3048
|
}
|
|
@@ -3063,7 +3063,7 @@ var require_lib2 = __commonJS({
|
|
|
3063
3063
|
const codings = headers.get("Content-Encoding");
|
|
3064
3064
|
if (!request.compress || request.method === "HEAD" || codings === null || res.statusCode === 204 || res.statusCode === 304) {
|
|
3065
3065
|
response = new Response3(body, response_options);
|
|
3066
|
-
|
|
3066
|
+
resolve41(response);
|
|
3067
3067
|
return;
|
|
3068
3068
|
}
|
|
3069
3069
|
const zlibOptions = {
|
|
@@ -3073,7 +3073,7 @@ var require_lib2 = __commonJS({
|
|
|
3073
3073
|
if (codings == "gzip" || codings == "x-gzip") {
|
|
3074
3074
|
body = body.pipe(zlib.createGunzip(zlibOptions));
|
|
3075
3075
|
response = new Response3(body, response_options);
|
|
3076
|
-
|
|
3076
|
+
resolve41(response);
|
|
3077
3077
|
return;
|
|
3078
3078
|
}
|
|
3079
3079
|
if (codings == "deflate" || codings == "x-deflate") {
|
|
@@ -3085,12 +3085,12 @@ var require_lib2 = __commonJS({
|
|
|
3085
3085
|
body = body.pipe(zlib.createInflateRaw());
|
|
3086
3086
|
}
|
|
3087
3087
|
response = new Response3(body, response_options);
|
|
3088
|
-
|
|
3088
|
+
resolve41(response);
|
|
3089
3089
|
});
|
|
3090
3090
|
raw.on("end", function() {
|
|
3091
3091
|
if (!response) {
|
|
3092
3092
|
response = new Response3(body, response_options);
|
|
3093
|
-
|
|
3093
|
+
resolve41(response);
|
|
3094
3094
|
}
|
|
3095
3095
|
});
|
|
3096
3096
|
return;
|
|
@@ -3098,11 +3098,11 @@ var require_lib2 = __commonJS({
|
|
|
3098
3098
|
if (codings == "br" && typeof zlib.createBrotliDecompress === "function") {
|
|
3099
3099
|
body = body.pipe(zlib.createBrotliDecompress());
|
|
3100
3100
|
response = new Response3(body, response_options);
|
|
3101
|
-
|
|
3101
|
+
resolve41(response);
|
|
3102
3102
|
return;
|
|
3103
3103
|
}
|
|
3104
3104
|
response = new Response3(body, response_options);
|
|
3105
|
-
|
|
3105
|
+
resolve41(response);
|
|
3106
3106
|
});
|
|
3107
3107
|
writeToStream(req, request);
|
|
3108
3108
|
});
|
|
@@ -6459,14 +6459,14 @@ __export(fileFromPath_exports, {
|
|
|
6459
6459
|
fileFromPathSync: () => fileFromPathSync,
|
|
6460
6460
|
isFile: () => isFile
|
|
6461
6461
|
});
|
|
6462
|
-
function createFileFromPath(
|
|
6462
|
+
function createFileFromPath(path57, { mtimeMs, size }, filenameOrOptions, options = {}) {
|
|
6463
6463
|
let filename;
|
|
6464
6464
|
if (isPlainObject_default2(filenameOrOptions)) {
|
|
6465
6465
|
[options, filename] = [filenameOrOptions, void 0];
|
|
6466
6466
|
} else {
|
|
6467
6467
|
filename = filenameOrOptions;
|
|
6468
6468
|
}
|
|
6469
|
-
const file = new FileFromPath({ path:
|
|
6469
|
+
const file = new FileFromPath({ path: path57, size, lastModified: mtimeMs });
|
|
6470
6470
|
if (!filename) {
|
|
6471
6471
|
filename = file.name;
|
|
6472
6472
|
}
|
|
@@ -6475,13 +6475,13 @@ function createFileFromPath(path56, { mtimeMs, size }, filenameOrOptions, option
|
|
|
6475
6475
|
lastModified: file.lastModified
|
|
6476
6476
|
});
|
|
6477
6477
|
}
|
|
6478
|
-
function fileFromPathSync(
|
|
6479
|
-
const stats = (0, import_fs5.statSync)(
|
|
6480
|
-
return createFileFromPath(
|
|
6478
|
+
function fileFromPathSync(path57, filenameOrOptions, options = {}) {
|
|
6479
|
+
const stats = (0, import_fs5.statSync)(path57);
|
|
6480
|
+
return createFileFromPath(path57, stats, filenameOrOptions, options);
|
|
6481
6481
|
}
|
|
6482
|
-
async function fileFromPath2(
|
|
6483
|
-
const stats = await import_fs5.promises.stat(
|
|
6484
|
-
return createFileFromPath(
|
|
6482
|
+
async function fileFromPath2(path57, filenameOrOptions, options) {
|
|
6483
|
+
const stats = await import_fs5.promises.stat(path57);
|
|
6484
|
+
return createFileFromPath(path57, stats, filenameOrOptions, options);
|
|
6485
6485
|
}
|
|
6486
6486
|
var import_fs5, import_path5, import_node_domexception, __classPrivateFieldSet5, __classPrivateFieldGet6, _FileFromPath_path, _FileFromPath_start, MESSAGE, FileFromPath;
|
|
6487
6487
|
var init_fileFromPath = __esm({
|
|
@@ -6635,15 +6635,15 @@ __export(otel_hooks_exports, {
|
|
|
6635
6635
|
});
|
|
6636
6636
|
function getOtelHooksHome() {
|
|
6637
6637
|
if (process.env.HAR_OTEL_HOOKS_HOME) {
|
|
6638
|
-
return
|
|
6638
|
+
return path45.resolve(process.env.HAR_OTEL_HOOKS_HOME);
|
|
6639
6639
|
}
|
|
6640
|
-
return
|
|
6640
|
+
return path45.join(os14.homedir(), ".har", "otel-hooks");
|
|
6641
6641
|
}
|
|
6642
6642
|
function getOtelHooksConfigPath(hooksHome = getOtelHooksHome()) {
|
|
6643
|
-
return
|
|
6643
|
+
return path45.join(hooksHome, "otel_config.json");
|
|
6644
6644
|
}
|
|
6645
6645
|
function getOtelHooksWrapperPath(hooksHome = getOtelHooksHome()) {
|
|
6646
|
-
return
|
|
6646
|
+
return path45.join(hooksHome, "run-otel-hook.sh");
|
|
6647
6647
|
}
|
|
6648
6648
|
function buildOtelHooksConfig(options) {
|
|
6649
6649
|
const enabled = options?.enabled ?? isTelemetryEnabled();
|
|
@@ -6662,18 +6662,18 @@ function buildOtelHooksConfig(options) {
|
|
|
6662
6662
|
};
|
|
6663
6663
|
}
|
|
6664
6664
|
function writeOtelHooksConfig(config2, hooksHome = getOtelHooksHome()) {
|
|
6665
|
-
|
|
6665
|
+
fs42.mkdirSync(hooksHome, { recursive: true });
|
|
6666
6666
|
const configPath = getOtelHooksConfigPath(hooksHome);
|
|
6667
6667
|
const payload = {
|
|
6668
6668
|
_comment: "Managed by har telemetry \u2014 do not edit by hand; use: har telemetry on|off",
|
|
6669
6669
|
...config2
|
|
6670
6670
|
};
|
|
6671
|
-
|
|
6671
|
+
fs42.writeFileSync(configPath, `${JSON.stringify(payload, null, 2)}
|
|
6672
6672
|
`);
|
|
6673
6673
|
return configPath;
|
|
6674
6674
|
}
|
|
6675
6675
|
function writeOtelHooksWrapper(otelHookCommand, hooksHome = getOtelHooksHome()) {
|
|
6676
|
-
|
|
6676
|
+
fs42.mkdirSync(hooksHome, { recursive: true });
|
|
6677
6677
|
const wrapperPath = getOtelHooksWrapperPath(hooksHome);
|
|
6678
6678
|
const script = `#!/usr/bin/env bash
|
|
6679
6679
|
# Managed by har telemetry \u2014 invokes opentelemetry-hooks with HAR config home.
|
|
@@ -6681,9 +6681,9 @@ set -euo pipefail
|
|
|
6681
6681
|
export IDE_OTEL_HOOK_HOME="${hooksHome}"
|
|
6682
6682
|
exec "${otelHookCommand}" "$@"
|
|
6683
6683
|
`;
|
|
6684
|
-
|
|
6684
|
+
fs42.writeFileSync(wrapperPath, script, { mode: 493 });
|
|
6685
6685
|
try {
|
|
6686
|
-
|
|
6686
|
+
fs42.chmodSync(wrapperPath, 493);
|
|
6687
6687
|
} catch {
|
|
6688
6688
|
}
|
|
6689
6689
|
return wrapperPath;
|
|
@@ -6763,10 +6763,10 @@ function runSetupAgent(agent, otelHookCommand, hooksHome) {
|
|
|
6763
6763
|
};
|
|
6764
6764
|
}
|
|
6765
6765
|
function rewriteHookCommandsToWrapper(filePath, wrapperPath) {
|
|
6766
|
-
if (!
|
|
6766
|
+
if (!fs42.existsSync(filePath)) return false;
|
|
6767
6767
|
let raw;
|
|
6768
6768
|
try {
|
|
6769
|
-
raw =
|
|
6769
|
+
raw = fs42.readFileSync(filePath, "utf8");
|
|
6770
6770
|
} catch {
|
|
6771
6771
|
return false;
|
|
6772
6772
|
}
|
|
@@ -6805,16 +6805,16 @@ function rewriteHookCommandsToWrapper(filePath, wrapperPath) {
|
|
|
6805
6805
|
return changed;
|
|
6806
6806
|
};
|
|
6807
6807
|
if (!walk(parsed)) return false;
|
|
6808
|
-
|
|
6808
|
+
fs42.writeFileSync(filePath, `${JSON.stringify(parsed, null, 2)}
|
|
6809
6809
|
`);
|
|
6810
6810
|
return true;
|
|
6811
6811
|
}
|
|
6812
6812
|
function rewriteKnownHookRegistrations(wrapperPath) {
|
|
6813
|
-
const home =
|
|
6813
|
+
const home = os14.homedir();
|
|
6814
6814
|
const candidates = [
|
|
6815
|
-
|
|
6816
|
-
|
|
6817
|
-
|
|
6815
|
+
path45.join(home, ".cursor", "hooks.json"),
|
|
6816
|
+
path45.join(home, ".claude", "settings.json"),
|
|
6817
|
+
path45.join(home, ".codex", "hooks.json")
|
|
6818
6818
|
];
|
|
6819
6819
|
for (const filePath of candidates) {
|
|
6820
6820
|
try {
|
|
@@ -6827,7 +6827,7 @@ function ensureOtelHooks(options) {
|
|
|
6827
6827
|
const hooksHome = getOtelHooksHome();
|
|
6828
6828
|
const errors = [];
|
|
6829
6829
|
const agentsSetup = [];
|
|
6830
|
-
|
|
6830
|
+
fs42.mkdirSync(hooksHome, { recursive: true });
|
|
6831
6831
|
let otelHookCommand = resolveOtelHookCommand();
|
|
6832
6832
|
if (!otelHookCommand) {
|
|
6833
6833
|
const installed = tryInstallPackage();
|
|
@@ -6896,14 +6896,14 @@ function ensureOtelHooks(options) {
|
|
|
6896
6896
|
function disableOtelHooksExport() {
|
|
6897
6897
|
return writeOtelHooksConfig(buildOtelHooksConfig({ enabled: false }));
|
|
6898
6898
|
}
|
|
6899
|
-
var import_child_process10,
|
|
6899
|
+
var import_child_process10, fs42, os14, path45, OTEL_HOOKS_PACKAGE, OTEL_HOOKS_AGENTS;
|
|
6900
6900
|
var init_otel_hooks = __esm({
|
|
6901
6901
|
"src/core/otel-hooks.ts"() {
|
|
6902
6902
|
"use strict";
|
|
6903
6903
|
import_child_process10 = require("child_process");
|
|
6904
|
-
|
|
6905
|
-
|
|
6906
|
-
|
|
6904
|
+
fs42 = __toESM(require("fs"));
|
|
6905
|
+
os14 = __toESM(require("os"));
|
|
6906
|
+
path45 = __toESM(require("path"));
|
|
6907
6907
|
init_control_config();
|
|
6908
6908
|
init_telemetry_config();
|
|
6909
6909
|
OTEL_HOOKS_PACKAGE = "opentelemetry-hooks==0.14.0";
|
|
@@ -8003,15 +8003,15 @@ var require_route = __commonJS({
|
|
|
8003
8003
|
};
|
|
8004
8004
|
}
|
|
8005
8005
|
function wrapConversion(toModel, graph) {
|
|
8006
|
-
const
|
|
8006
|
+
const path57 = [graph[toModel].parent, toModel];
|
|
8007
8007
|
let fn = conversions[graph[toModel].parent][toModel];
|
|
8008
8008
|
let cur = graph[toModel].parent;
|
|
8009
8009
|
while (graph[cur].parent) {
|
|
8010
|
-
|
|
8010
|
+
path57.unshift(graph[cur].parent);
|
|
8011
8011
|
fn = link(conversions[graph[cur].parent][cur], fn);
|
|
8012
8012
|
cur = graph[cur].parent;
|
|
8013
8013
|
}
|
|
8014
|
-
fn.conversion =
|
|
8014
|
+
fn.conversion = path57;
|
|
8015
8015
|
return fn;
|
|
8016
8016
|
}
|
|
8017
8017
|
module2.exports = function(fromModel) {
|
|
@@ -13941,7 +13941,7 @@ var require_iso2022 = __commonJS({
|
|
|
13941
13941
|
// node_modules/chardet/index.js
|
|
13942
13942
|
var require_chardet = __commonJS({
|
|
13943
13943
|
"node_modules/chardet/index.js"(exports2, module2) {
|
|
13944
|
-
var
|
|
13944
|
+
var fs48 = require("fs");
|
|
13945
13945
|
var utf8 = require_utf8();
|
|
13946
13946
|
var unicode = require_unicode();
|
|
13947
13947
|
var mbcs = require_mbcs();
|
|
@@ -14015,28 +14015,28 @@ var require_chardet = __commonJS({
|
|
|
14015
14015
|
var fd;
|
|
14016
14016
|
var handler = function(err, buffer) {
|
|
14017
14017
|
if (fd) {
|
|
14018
|
-
|
|
14018
|
+
fs48.closeSync(fd);
|
|
14019
14019
|
}
|
|
14020
14020
|
if (err) return cb(err, null);
|
|
14021
14021
|
cb(null, self.detect(buffer, opts));
|
|
14022
14022
|
};
|
|
14023
14023
|
if (opts && opts.sampleSize) {
|
|
14024
|
-
fd =
|
|
14025
|
-
|
|
14024
|
+
fd = fs48.openSync(filepath, "r"), sample = Buffer.allocUnsafe(opts.sampleSize);
|
|
14025
|
+
fs48.read(fd, sample, 0, opts.sampleSize, null, function(err) {
|
|
14026
14026
|
handler(err, sample);
|
|
14027
14027
|
});
|
|
14028
14028
|
return;
|
|
14029
14029
|
}
|
|
14030
|
-
|
|
14030
|
+
fs48.readFile(filepath, handler);
|
|
14031
14031
|
};
|
|
14032
14032
|
module2.exports.detectFileSync = function(filepath, opts) {
|
|
14033
14033
|
if (opts && opts.sampleSize) {
|
|
14034
|
-
var fd =
|
|
14035
|
-
|
|
14036
|
-
|
|
14034
|
+
var fd = fs48.openSync(filepath, "r"), sample2 = Buffer.allocUnsafe(opts.sampleSize);
|
|
14035
|
+
fs48.readSync(fd, sample2, 0, opts.sampleSize);
|
|
14036
|
+
fs48.closeSync(fd);
|
|
14037
14037
|
return self.detect(sample2, opts);
|
|
14038
14038
|
}
|
|
14039
|
-
return self.detect(
|
|
14039
|
+
return self.detect(fs48.readFileSync(filepath), opts);
|
|
14040
14040
|
};
|
|
14041
14041
|
module2.exports.detectAll = function(buffer, opts) {
|
|
14042
14042
|
if (typeof opts !== "object") {
|
|
@@ -17501,16 +17501,16 @@ var require_os_tmpdir = __commonJS({
|
|
|
17501
17501
|
var isWindows = process.platform === "win32";
|
|
17502
17502
|
var trailingSlashRe = isWindows ? /[^:]\\$/ : /.\/$/;
|
|
17503
17503
|
module2.exports = function() {
|
|
17504
|
-
var
|
|
17504
|
+
var path57;
|
|
17505
17505
|
if (isWindows) {
|
|
17506
|
-
|
|
17506
|
+
path57 = process.env.TEMP || process.env.TMP || (process.env.SystemRoot || process.env.windir) + "\\temp";
|
|
17507
17507
|
} else {
|
|
17508
|
-
|
|
17508
|
+
path57 = process.env.TMPDIR || process.env.TMP || process.env.TEMP || "/tmp";
|
|
17509
17509
|
}
|
|
17510
|
-
if (trailingSlashRe.test(
|
|
17511
|
-
|
|
17510
|
+
if (trailingSlashRe.test(path57)) {
|
|
17511
|
+
path57 = path57.slice(0, -1);
|
|
17512
17512
|
}
|
|
17513
|
-
return
|
|
17513
|
+
return path57;
|
|
17514
17514
|
};
|
|
17515
17515
|
}
|
|
17516
17516
|
});
|
|
@@ -17518,8 +17518,8 @@ var require_os_tmpdir = __commonJS({
|
|
|
17518
17518
|
// node_modules/tmp/lib/tmp.js
|
|
17519
17519
|
var require_tmp = __commonJS({
|
|
17520
17520
|
"node_modules/tmp/lib/tmp.js"(exports2, module2) {
|
|
17521
|
-
var
|
|
17522
|
-
var
|
|
17521
|
+
var fs48 = require("fs");
|
|
17522
|
+
var path57 = require("path");
|
|
17523
17523
|
var crypto6 = require("crypto");
|
|
17524
17524
|
var osTmpDir = require_os_tmpdir();
|
|
17525
17525
|
var _c2 = process.binding("constants");
|
|
@@ -17561,7 +17561,7 @@ var require_tmp = __commonJS({
|
|
|
17561
17561
|
}
|
|
17562
17562
|
function _generateTmpName(opts) {
|
|
17563
17563
|
if (opts.name) {
|
|
17564
|
-
return
|
|
17564
|
+
return path57.join(opts.dir || tmpDir, opts.name);
|
|
17565
17565
|
}
|
|
17566
17566
|
if (opts.template) {
|
|
17567
17567
|
return opts.template.replace(TEMPLATE_PATTERN, _randomChars(6));
|
|
@@ -17572,7 +17572,7 @@ var require_tmp = __commonJS({
|
|
|
17572
17572
|
_randomChars(12),
|
|
17573
17573
|
opts.postfix || ""
|
|
17574
17574
|
].join("");
|
|
17575
|
-
return
|
|
17575
|
+
return path57.join(opts.dir || tmpDir, name);
|
|
17576
17576
|
}
|
|
17577
17577
|
function tmpName(options, callback) {
|
|
17578
17578
|
var args = _parseArguments(options, callback), opts = args[0], cb = args[1], tries = opts.name ? 1 : opts.tries || DEFAULT_TRIES;
|
|
@@ -17582,7 +17582,7 @@ var require_tmp = __commonJS({
|
|
|
17582
17582
|
return cb(new Error("Invalid template provided"));
|
|
17583
17583
|
(function _getUniqueName() {
|
|
17584
17584
|
const name = _generateTmpName(opts);
|
|
17585
|
-
|
|
17585
|
+
fs48.stat(name, function(err) {
|
|
17586
17586
|
if (!err) {
|
|
17587
17587
|
if (tries-- > 0) return _getUniqueName();
|
|
17588
17588
|
return cb(new Error("Could not get a unique tmp filename, max tries reached " + name));
|
|
@@ -17600,7 +17600,7 @@ var require_tmp = __commonJS({
|
|
|
17600
17600
|
do {
|
|
17601
17601
|
const name = _generateTmpName(opts);
|
|
17602
17602
|
try {
|
|
17603
|
-
|
|
17603
|
+
fs48.statSync(name);
|
|
17604
17604
|
} catch (e2) {
|
|
17605
17605
|
return name;
|
|
17606
17606
|
}
|
|
@@ -17612,13 +17612,13 @@ var require_tmp = __commonJS({
|
|
|
17612
17612
|
opts.postfix = _isUndefined(opts.postfix) ? ".tmp" : opts.postfix;
|
|
17613
17613
|
tmpName(opts, function _tmpNameCreated(err, name) {
|
|
17614
17614
|
if (err) return cb(err);
|
|
17615
|
-
|
|
17615
|
+
fs48.open(name, CREATE_FLAGS, opts.mode || FILE_MODE, function _fileCreated(err2, fd) {
|
|
17616
17616
|
if (err2) return cb(err2);
|
|
17617
17617
|
if (opts.discardDescriptor) {
|
|
17618
|
-
return
|
|
17618
|
+
return fs48.close(fd, function _discardCallback(err3) {
|
|
17619
17619
|
if (err3) {
|
|
17620
17620
|
try {
|
|
17621
|
-
|
|
17621
|
+
fs48.unlinkSync(name);
|
|
17622
17622
|
} catch (e2) {
|
|
17623
17623
|
if (!isENOENT(e2)) {
|
|
17624
17624
|
err3 = e2;
|
|
@@ -17641,9 +17641,9 @@ var require_tmp = __commonJS({
|
|
|
17641
17641
|
opts.postfix = opts.postfix || ".tmp";
|
|
17642
17642
|
const discardOrDetachDescriptor = opts.discardDescriptor || opts.detachDescriptor;
|
|
17643
17643
|
const name = tmpNameSync(opts);
|
|
17644
|
-
var fd =
|
|
17644
|
+
var fd = fs48.openSync(name, CREATE_FLAGS, opts.mode || FILE_MODE);
|
|
17645
17645
|
if (opts.discardDescriptor) {
|
|
17646
|
-
|
|
17646
|
+
fs48.closeSync(fd);
|
|
17647
17647
|
fd = void 0;
|
|
17648
17648
|
}
|
|
17649
17649
|
return {
|
|
@@ -17655,9 +17655,9 @@ var require_tmp = __commonJS({
|
|
|
17655
17655
|
function _rmdirRecursiveSync(root) {
|
|
17656
17656
|
const dirs = [root];
|
|
17657
17657
|
do {
|
|
17658
|
-
var dir2 = dirs.pop(), deferred = false, files =
|
|
17658
|
+
var dir2 = dirs.pop(), deferred = false, files = fs48.readdirSync(dir2);
|
|
17659
17659
|
for (var i2 = 0, length = files.length; i2 < length; i2++) {
|
|
17660
|
-
var file2 =
|
|
17660
|
+
var file2 = path57.join(dir2, files[i2]), stat = fs48.lstatSync(file2);
|
|
17661
17661
|
if (stat.isDirectory()) {
|
|
17662
17662
|
if (!deferred) {
|
|
17663
17663
|
deferred = true;
|
|
@@ -17665,11 +17665,11 @@ var require_tmp = __commonJS({
|
|
|
17665
17665
|
}
|
|
17666
17666
|
dirs.push(file2);
|
|
17667
17667
|
} else {
|
|
17668
|
-
|
|
17668
|
+
fs48.unlinkSync(file2);
|
|
17669
17669
|
}
|
|
17670
17670
|
}
|
|
17671
17671
|
if (!deferred) {
|
|
17672
|
-
|
|
17672
|
+
fs48.rmdirSync(dir2);
|
|
17673
17673
|
}
|
|
17674
17674
|
} while (dirs.length !== 0);
|
|
17675
17675
|
}
|
|
@@ -17677,7 +17677,7 @@ var require_tmp = __commonJS({
|
|
|
17677
17677
|
var args = _parseArguments(options, callback), opts = args[0], cb = args[1];
|
|
17678
17678
|
tmpName(opts, function _tmpNameCreated(err, name) {
|
|
17679
17679
|
if (err) return cb(err);
|
|
17680
|
-
|
|
17680
|
+
fs48.mkdir(name, opts.mode || DIR_MODE, function _dirCreated(err2) {
|
|
17681
17681
|
if (err2) return cb(err2);
|
|
17682
17682
|
cb(null, name, _prepareTmpDirRemoveCallback(name, opts));
|
|
17683
17683
|
});
|
|
@@ -17686,7 +17686,7 @@ var require_tmp = __commonJS({
|
|
|
17686
17686
|
function dirSync(options) {
|
|
17687
17687
|
var args = _parseArguments(options), opts = args[0];
|
|
17688
17688
|
const name = tmpNameSync(opts);
|
|
17689
|
-
|
|
17689
|
+
fs48.mkdirSync(name, opts.mode || DIR_MODE);
|
|
17690
17690
|
return {
|
|
17691
17691
|
name,
|
|
17692
17692
|
removeCallback: _prepareTmpDirRemoveCallback(name, opts)
|
|
@@ -17696,7 +17696,7 @@ var require_tmp = __commonJS({
|
|
|
17696
17696
|
const removeCallback = _prepareRemoveCallback(function _removeCallback(fdPath) {
|
|
17697
17697
|
try {
|
|
17698
17698
|
if (0 <= fdPath[0]) {
|
|
17699
|
-
|
|
17699
|
+
fs48.closeSync(fdPath[0]);
|
|
17700
17700
|
}
|
|
17701
17701
|
} catch (e2) {
|
|
17702
17702
|
if (!isEBADF(e2) && !isENOENT(e2)) {
|
|
@@ -17704,7 +17704,7 @@ var require_tmp = __commonJS({
|
|
|
17704
17704
|
}
|
|
17705
17705
|
}
|
|
17706
17706
|
try {
|
|
17707
|
-
|
|
17707
|
+
fs48.unlinkSync(fdPath[1]);
|
|
17708
17708
|
} catch (e2) {
|
|
17709
17709
|
if (!isENOENT(e2)) {
|
|
17710
17710
|
throw e2;
|
|
@@ -17717,7 +17717,7 @@ var require_tmp = __commonJS({
|
|
|
17717
17717
|
return removeCallback;
|
|
17718
17718
|
}
|
|
17719
17719
|
function _prepareTmpDirRemoveCallback(name, opts) {
|
|
17720
|
-
const removeFunction = opts.unsafeCleanup ? _rmdirRecursiveSync :
|
|
17720
|
+
const removeFunction = opts.unsafeCleanup ? _rmdirRecursiveSync : fs48.rmdirSync.bind(fs48);
|
|
17721
17721
|
const removeCallback = _prepareRemoveCallback(removeFunction, name);
|
|
17722
17722
|
if (!opts.keep) {
|
|
17723
17723
|
_removeObjects.unshift(removeCallback);
|
|
@@ -18868,7 +18868,7 @@ var require_Observable = __commonJS({
|
|
|
18868
18868
|
Observable2.prototype.forEach = function(next, promiseCtor) {
|
|
18869
18869
|
var _this = this;
|
|
18870
18870
|
promiseCtor = getPromiseCtor(promiseCtor);
|
|
18871
|
-
return new promiseCtor(function(
|
|
18871
|
+
return new promiseCtor(function(resolve41, reject) {
|
|
18872
18872
|
var subscriber = new Subscriber_1.SafeSubscriber({
|
|
18873
18873
|
next: function(value) {
|
|
18874
18874
|
try {
|
|
@@ -18879,7 +18879,7 @@ var require_Observable = __commonJS({
|
|
|
18879
18879
|
}
|
|
18880
18880
|
},
|
|
18881
18881
|
error: reject,
|
|
18882
|
-
complete:
|
|
18882
|
+
complete: resolve41
|
|
18883
18883
|
});
|
|
18884
18884
|
_this.subscribe(subscriber);
|
|
18885
18885
|
});
|
|
@@ -18901,14 +18901,14 @@ var require_Observable = __commonJS({
|
|
|
18901
18901
|
Observable2.prototype.toPromise = function(promiseCtor) {
|
|
18902
18902
|
var _this = this;
|
|
18903
18903
|
promiseCtor = getPromiseCtor(promiseCtor);
|
|
18904
|
-
return new promiseCtor(function(
|
|
18904
|
+
return new promiseCtor(function(resolve41, reject) {
|
|
18905
18905
|
var value;
|
|
18906
18906
|
_this.subscribe(function(x2) {
|
|
18907
18907
|
return value = x2;
|
|
18908
18908
|
}, function(err) {
|
|
18909
18909
|
return reject(err);
|
|
18910
18910
|
}, function() {
|
|
18911
|
-
return
|
|
18911
|
+
return resolve41(value);
|
|
18912
18912
|
});
|
|
18913
18913
|
});
|
|
18914
18914
|
};
|
|
@@ -21004,11 +21004,11 @@ var require_innerFrom = __commonJS({
|
|
|
21004
21004
|
"use strict";
|
|
21005
21005
|
var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P2, generator) {
|
|
21006
21006
|
function adopt(value) {
|
|
21007
|
-
return value instanceof P2 ? value : new P2(function(
|
|
21008
|
-
|
|
21007
|
+
return value instanceof P2 ? value : new P2(function(resolve41) {
|
|
21008
|
+
resolve41(value);
|
|
21009
21009
|
});
|
|
21010
21010
|
}
|
|
21011
|
-
return new (P2 || (P2 = Promise))(function(
|
|
21011
|
+
return new (P2 || (P2 = Promise))(function(resolve41, reject) {
|
|
21012
21012
|
function fulfilled(value) {
|
|
21013
21013
|
try {
|
|
21014
21014
|
step(generator.next(value));
|
|
@@ -21024,7 +21024,7 @@ var require_innerFrom = __commonJS({
|
|
|
21024
21024
|
}
|
|
21025
21025
|
}
|
|
21026
21026
|
function step(result) {
|
|
21027
|
-
result.done ?
|
|
21027
|
+
result.done ? resolve41(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
21028
21028
|
}
|
|
21029
21029
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
21030
21030
|
});
|
|
@@ -21106,14 +21106,14 @@ var require_innerFrom = __commonJS({
|
|
|
21106
21106
|
}, i2);
|
|
21107
21107
|
function verb(n2) {
|
|
21108
21108
|
i2[n2] = o2[n2] && function(v2) {
|
|
21109
|
-
return new Promise(function(
|
|
21110
|
-
v2 = o2[n2](v2), settle(
|
|
21109
|
+
return new Promise(function(resolve41, reject) {
|
|
21110
|
+
v2 = o2[n2](v2), settle(resolve41, reject, v2.done, v2.value);
|
|
21111
21111
|
});
|
|
21112
21112
|
};
|
|
21113
21113
|
}
|
|
21114
|
-
function settle(
|
|
21114
|
+
function settle(resolve41, reject, d2, v2) {
|
|
21115
21115
|
Promise.resolve(v2).then(function(v3) {
|
|
21116
|
-
|
|
21116
|
+
resolve41({ value: v3, done: d2 });
|
|
21117
21117
|
}, reject);
|
|
21118
21118
|
}
|
|
21119
21119
|
};
|
|
@@ -21732,7 +21732,7 @@ var require_lastValueFrom = __commonJS({
|
|
|
21732
21732
|
var EmptyError_1 = require_EmptyError();
|
|
21733
21733
|
function lastValueFrom2(source, config2) {
|
|
21734
21734
|
var hasConfig = typeof config2 === "object";
|
|
21735
|
-
return new Promise(function(
|
|
21735
|
+
return new Promise(function(resolve41, reject) {
|
|
21736
21736
|
var _hasValue = false;
|
|
21737
21737
|
var _value;
|
|
21738
21738
|
source.subscribe({
|
|
@@ -21743,9 +21743,9 @@ var require_lastValueFrom = __commonJS({
|
|
|
21743
21743
|
error: reject,
|
|
21744
21744
|
complete: function() {
|
|
21745
21745
|
if (_hasValue) {
|
|
21746
|
-
|
|
21746
|
+
resolve41(_value);
|
|
21747
21747
|
} else if (hasConfig) {
|
|
21748
|
-
|
|
21748
|
+
resolve41(config2.defaultValue);
|
|
21749
21749
|
} else {
|
|
21750
21750
|
reject(new EmptyError_1.EmptyError());
|
|
21751
21751
|
}
|
|
@@ -21767,16 +21767,16 @@ var require_firstValueFrom = __commonJS({
|
|
|
21767
21767
|
var Subscriber_1 = require_Subscriber();
|
|
21768
21768
|
function firstValueFrom(source, config2) {
|
|
21769
21769
|
var hasConfig = typeof config2 === "object";
|
|
21770
|
-
return new Promise(function(
|
|
21770
|
+
return new Promise(function(resolve41, reject) {
|
|
21771
21771
|
var subscriber = new Subscriber_1.SafeSubscriber({
|
|
21772
21772
|
next: function(value) {
|
|
21773
|
-
|
|
21773
|
+
resolve41(value);
|
|
21774
21774
|
subscriber.unsubscribe();
|
|
21775
21775
|
},
|
|
21776
21776
|
error: reject,
|
|
21777
21777
|
complete: function() {
|
|
21778
21778
|
if (hasConfig) {
|
|
21779
|
-
|
|
21779
|
+
resolve41(config2.defaultValue);
|
|
21780
21780
|
} else {
|
|
21781
21781
|
reject(new EmptyError_1.EmptyError());
|
|
21782
21782
|
}
|
|
@@ -27569,14 +27569,14 @@ var require_run_async = __commonJS({
|
|
|
27569
27569
|
return function() {
|
|
27570
27570
|
var args = arguments;
|
|
27571
27571
|
var originalThis = this;
|
|
27572
|
-
var promise = new Promise(function(
|
|
27572
|
+
var promise = new Promise(function(resolve41, reject) {
|
|
27573
27573
|
var resolved = false;
|
|
27574
27574
|
const wrappedResolve = function(value) {
|
|
27575
27575
|
if (resolved) {
|
|
27576
27576
|
console.warn("Run-async promise already resolved.");
|
|
27577
27577
|
}
|
|
27578
27578
|
resolved = true;
|
|
27579
|
-
|
|
27579
|
+
resolve41(value);
|
|
27580
27580
|
};
|
|
27581
27581
|
var rejected = false;
|
|
27582
27582
|
const wrappedReject = function(value) {
|
|
@@ -30605,7 +30605,7 @@ var require_compile = __commonJS({
|
|
|
30605
30605
|
const schOrFunc = root.refs[ref];
|
|
30606
30606
|
if (schOrFunc)
|
|
30607
30607
|
return schOrFunc;
|
|
30608
|
-
let _sch =
|
|
30608
|
+
let _sch = resolve41.call(this, root, ref);
|
|
30609
30609
|
if (_sch === void 0) {
|
|
30610
30610
|
const schema = (_a3 = root.localRefs) === null || _a3 === void 0 ? void 0 : _a3[ref];
|
|
30611
30611
|
const { schemaId } = this.opts;
|
|
@@ -30632,7 +30632,7 @@ var require_compile = __commonJS({
|
|
|
30632
30632
|
function sameSchemaEnv(s1, s2) {
|
|
30633
30633
|
return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
|
|
30634
30634
|
}
|
|
30635
|
-
function
|
|
30635
|
+
function resolve41(root, ref) {
|
|
30636
30636
|
let sch;
|
|
30637
30637
|
while (typeof (sch = this.refs[ref]) == "string")
|
|
30638
30638
|
ref = sch;
|
|
@@ -30850,8 +30850,8 @@ var require_utils2 = __commonJS({
|
|
|
30850
30850
|
}
|
|
30851
30851
|
return ind;
|
|
30852
30852
|
}
|
|
30853
|
-
function removeDotSegments(
|
|
30854
|
-
let input =
|
|
30853
|
+
function removeDotSegments(path57) {
|
|
30854
|
+
let input = path57;
|
|
30855
30855
|
const output = [];
|
|
30856
30856
|
let nextSlash = -1;
|
|
30857
30857
|
let len = 0;
|
|
@@ -31103,8 +31103,8 @@ var require_schemes = __commonJS({
|
|
|
31103
31103
|
wsComponent.secure = void 0;
|
|
31104
31104
|
}
|
|
31105
31105
|
if (wsComponent.resourceName) {
|
|
31106
|
-
const [
|
|
31107
|
-
wsComponent.path =
|
|
31106
|
+
const [path57, query] = wsComponent.resourceName.split("?");
|
|
31107
|
+
wsComponent.path = path57 && path57 !== "/" ? path57 : void 0;
|
|
31108
31108
|
wsComponent.query = query;
|
|
31109
31109
|
wsComponent.resourceName = void 0;
|
|
31110
31110
|
}
|
|
@@ -31263,7 +31263,7 @@ var require_fast_uri = __commonJS({
|
|
|
31263
31263
|
}
|
|
31264
31264
|
return uri;
|
|
31265
31265
|
}
|
|
31266
|
-
function
|
|
31266
|
+
function resolve41(baseURI, relativeURI, options) {
|
|
31267
31267
|
const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
|
|
31268
31268
|
const resolved = resolveComponent(parse4(baseURI, schemelessOptions), parse4(relativeURI, schemelessOptions), schemelessOptions, true);
|
|
31269
31269
|
schemelessOptions.skipEscape = true;
|
|
@@ -31521,7 +31521,7 @@ var require_fast_uri = __commonJS({
|
|
|
31521
31521
|
var fastUri = {
|
|
31522
31522
|
SCHEMES,
|
|
31523
31523
|
normalize: normalize3,
|
|
31524
|
-
resolve:
|
|
31524
|
+
resolve: resolve41,
|
|
31525
31525
|
resolveComponent,
|
|
31526
31526
|
equal,
|
|
31527
31527
|
serialize,
|
|
@@ -34497,12 +34497,12 @@ var require_dist = __commonJS({
|
|
|
34497
34497
|
throw new Error(`Unknown format "${name}"`);
|
|
34498
34498
|
return f2;
|
|
34499
34499
|
};
|
|
34500
|
-
function addFormats(ajv, list,
|
|
34500
|
+
function addFormats(ajv, list, fs48, exportName) {
|
|
34501
34501
|
var _a3;
|
|
34502
34502
|
var _b2;
|
|
34503
34503
|
(_a3 = (_b2 = ajv.opts.code).formats) !== null && _a3 !== void 0 ? _a3 : _b2.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
|
|
34504
34504
|
for (const f2 of list)
|
|
34505
|
-
ajv.addFormat(f2,
|
|
34505
|
+
ajv.addFormat(f2, fs48[f2]);
|
|
34506
34506
|
}
|
|
34507
34507
|
module2.exports = exports2 = formatsPlugin;
|
|
34508
34508
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
@@ -35786,11 +35786,11 @@ var parser = new YargsParser({
|
|
|
35786
35786
|
resolve: import_path2.resolve,
|
|
35787
35787
|
// TODO: figure out a way to combine ESM and CJS coverage, such that
|
|
35788
35788
|
// we can exercise all the lines below:
|
|
35789
|
-
require: (
|
|
35789
|
+
require: (path57) => {
|
|
35790
35790
|
if (typeof require !== "undefined") {
|
|
35791
|
-
return require(
|
|
35792
|
-
} else if (
|
|
35793
|
-
return JSON.parse((0, import_fs2.readFileSync)(
|
|
35791
|
+
return require(path57);
|
|
35792
|
+
} else if (path57.match(/\.json$/)) {
|
|
35793
|
+
return JSON.parse((0, import_fs2.readFileSync)(path57, "utf8"));
|
|
35794
35794
|
} else {
|
|
35795
35795
|
throw Error("only .json config files are supported in ESM");
|
|
35796
35796
|
}
|
|
@@ -38316,12 +38316,12 @@ var YargsInstance = class {
|
|
|
38316
38316
|
async getCompletion(args, done) {
|
|
38317
38317
|
argsert("<array> [function]", [args, done], arguments.length);
|
|
38318
38318
|
if (!done) {
|
|
38319
|
-
return new Promise((
|
|
38319
|
+
return new Promise((resolve41, reject) => {
|
|
38320
38320
|
__classPrivateFieldGet(this, _YargsInstance_completion, "f").getCompletion(args, (err, completions) => {
|
|
38321
38321
|
if (err)
|
|
38322
38322
|
reject(err);
|
|
38323
38323
|
else
|
|
38324
|
-
|
|
38324
|
+
resolve41(completions);
|
|
38325
38325
|
});
|
|
38326
38326
|
});
|
|
38327
38327
|
} else {
|
|
@@ -40474,8 +40474,8 @@ function getErrorMap() {
|
|
|
40474
40474
|
|
|
40475
40475
|
// node_modules/zod/v3/helpers/parseUtil.js
|
|
40476
40476
|
var makeIssue = (params) => {
|
|
40477
|
-
const { data, path:
|
|
40478
|
-
const fullPath = [...
|
|
40477
|
+
const { data, path: path57, errorMaps, issueData } = params;
|
|
40478
|
+
const fullPath = [...path57, ...issueData.path || []];
|
|
40479
40479
|
const fullIssue = {
|
|
40480
40480
|
...issueData,
|
|
40481
40481
|
path: fullPath
|
|
@@ -40591,11 +40591,11 @@ var errorUtil;
|
|
|
40591
40591
|
|
|
40592
40592
|
// node_modules/zod/v3/types.js
|
|
40593
40593
|
var ParseInputLazyPath = class {
|
|
40594
|
-
constructor(parent, value,
|
|
40594
|
+
constructor(parent, value, path57, key) {
|
|
40595
40595
|
this._cachedPath = [];
|
|
40596
40596
|
this.parent = parent;
|
|
40597
40597
|
this.data = value;
|
|
40598
|
-
this._path =
|
|
40598
|
+
this._path = path57;
|
|
40599
40599
|
this._key = key;
|
|
40600
40600
|
}
|
|
40601
40601
|
get path() {
|
|
@@ -44734,16 +44734,16 @@ async function handleAgentSkills(options) {
|
|
|
44734
44734
|
}
|
|
44735
44735
|
async function askYesNo(question) {
|
|
44736
44736
|
const rl = readline.createInterface({ input: process.stdin, output: process.stderr });
|
|
44737
|
-
return new Promise((
|
|
44737
|
+
return new Promise((resolve41) => {
|
|
44738
44738
|
process.stderr.write(`${question} `);
|
|
44739
44739
|
rl.once("line", (answer) => {
|
|
44740
44740
|
rl.close();
|
|
44741
44741
|
const trimmed = answer.trim();
|
|
44742
44742
|
if (trimmed === "") {
|
|
44743
|
-
|
|
44743
|
+
resolve41(true);
|
|
44744
44744
|
return;
|
|
44745
44745
|
}
|
|
44746
|
-
|
|
44746
|
+
resolve41(/^y(es)?$/i.test(trimmed));
|
|
44747
44747
|
});
|
|
44748
44748
|
});
|
|
44749
44749
|
}
|
|
@@ -44822,7 +44822,7 @@ function handleRemove(argv) {
|
|
|
44822
44822
|
}
|
|
44823
44823
|
|
|
44824
44824
|
// src/cli/commands/env.ts
|
|
44825
|
-
var
|
|
44825
|
+
var path49 = __toESM(require("path"));
|
|
44826
44826
|
|
|
44827
44827
|
// src/core/harness.ts
|
|
44828
44828
|
var fs21 = __toESM(require("fs"));
|
|
@@ -45601,13 +45601,13 @@ var MultipartBody = class {
|
|
|
45601
45601
|
// node_modules/@anthropic-ai/sdk/_shims/node-runtime.mjs
|
|
45602
45602
|
var import_web = require("node:stream/web");
|
|
45603
45603
|
var fileFromPathWarned = false;
|
|
45604
|
-
async function fileFromPath3(
|
|
45604
|
+
async function fileFromPath3(path57, ...args) {
|
|
45605
45605
|
const { fileFromPath: _fileFromPath } = await Promise.resolve().then(() => (init_fileFromPath(), fileFromPath_exports));
|
|
45606
45606
|
if (!fileFromPathWarned) {
|
|
45607
|
-
console.warn(`fileFromPath is deprecated; use fs.createReadStream(${JSON.stringify(
|
|
45607
|
+
console.warn(`fileFromPath is deprecated; use fs.createReadStream(${JSON.stringify(path57)}) instead`);
|
|
45608
45608
|
fileFromPathWarned = true;
|
|
45609
45609
|
}
|
|
45610
|
-
return await _fileFromPath(
|
|
45610
|
+
return await _fileFromPath(path57, ...args);
|
|
45611
45611
|
}
|
|
45612
45612
|
var defaultHttpAgent = new import_agentkeepalive.default({ keepAlive: true, timeout: 5 * 60 * 1e3 });
|
|
45613
45613
|
var defaultHttpsAgent = new import_agentkeepalive.default.HttpsAgent({ keepAlive: true, timeout: 5 * 60 * 1e3 });
|
|
@@ -46103,8 +46103,8 @@ async function defaultParseResponse(props) {
|
|
|
46103
46103
|
}
|
|
46104
46104
|
var APIPromise = class _APIPromise extends Promise {
|
|
46105
46105
|
constructor(responsePromise, parseResponse = defaultParseResponse) {
|
|
46106
|
-
super((
|
|
46107
|
-
|
|
46106
|
+
super((resolve41) => {
|
|
46107
|
+
resolve41(null);
|
|
46108
46108
|
});
|
|
46109
46109
|
this.responsePromise = responsePromise;
|
|
46110
46110
|
this.parseResponse = parseResponse;
|
|
@@ -46204,29 +46204,29 @@ var APIClient = class {
|
|
|
46204
46204
|
defaultIdempotencyKey() {
|
|
46205
46205
|
return `stainless-node-retry-${uuid4()}`;
|
|
46206
46206
|
}
|
|
46207
|
-
get(
|
|
46208
|
-
return this.methodRequest("get",
|
|
46207
|
+
get(path57, opts) {
|
|
46208
|
+
return this.methodRequest("get", path57, opts);
|
|
46209
46209
|
}
|
|
46210
|
-
post(
|
|
46211
|
-
return this.methodRequest("post",
|
|
46210
|
+
post(path57, opts) {
|
|
46211
|
+
return this.methodRequest("post", path57, opts);
|
|
46212
46212
|
}
|
|
46213
|
-
patch(
|
|
46214
|
-
return this.methodRequest("patch",
|
|
46213
|
+
patch(path57, opts) {
|
|
46214
|
+
return this.methodRequest("patch", path57, opts);
|
|
46215
46215
|
}
|
|
46216
|
-
put(
|
|
46217
|
-
return this.methodRequest("put",
|
|
46216
|
+
put(path57, opts) {
|
|
46217
|
+
return this.methodRequest("put", path57, opts);
|
|
46218
46218
|
}
|
|
46219
|
-
delete(
|
|
46220
|
-
return this.methodRequest("delete",
|
|
46219
|
+
delete(path57, opts) {
|
|
46220
|
+
return this.methodRequest("delete", path57, opts);
|
|
46221
46221
|
}
|
|
46222
|
-
methodRequest(method,
|
|
46222
|
+
methodRequest(method, path57, opts) {
|
|
46223
46223
|
return this.request(Promise.resolve(opts).then(async (opts2) => {
|
|
46224
46224
|
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;
|
|
46225
|
-
return { method, path:
|
|
46225
|
+
return { method, path: path57, ...opts2, body };
|
|
46226
46226
|
}));
|
|
46227
46227
|
}
|
|
46228
|
-
getAPIList(
|
|
46229
|
-
return this.requestAPIList(Page, { method: "get", path:
|
|
46228
|
+
getAPIList(path57, Page, opts) {
|
|
46229
|
+
return this.requestAPIList(Page, { method: "get", path: path57, ...opts });
|
|
46230
46230
|
}
|
|
46231
46231
|
calculateContentLength(body) {
|
|
46232
46232
|
if (typeof body === "string") {
|
|
@@ -46244,10 +46244,10 @@ var APIClient = class {
|
|
|
46244
46244
|
return null;
|
|
46245
46245
|
}
|
|
46246
46246
|
buildRequest(options) {
|
|
46247
|
-
const { method, path:
|
|
46247
|
+
const { method, path: path57, query, headers = {} } = options;
|
|
46248
46248
|
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;
|
|
46249
46249
|
const contentLength = this.calculateContentLength(body);
|
|
46250
|
-
const url = this.buildURL(
|
|
46250
|
+
const url = this.buildURL(path57, query);
|
|
46251
46251
|
if ("timeout" in options)
|
|
46252
46252
|
validatePositiveInteger("timeout", options.timeout);
|
|
46253
46253
|
const timeout = options.timeout ?? this.timeout;
|
|
@@ -46356,8 +46356,8 @@ var APIClient = class {
|
|
|
46356
46356
|
const request = this.makeRequest(options, null);
|
|
46357
46357
|
return new PagePromise(this, request, Page);
|
|
46358
46358
|
}
|
|
46359
|
-
buildURL(
|
|
46360
|
-
const url = isAbsoluteURL(
|
|
46359
|
+
buildURL(path57, query) {
|
|
46360
|
+
const url = isAbsoluteURL(path57) ? new URL(path57) : new URL(this.baseURL + (this.baseURL.endsWith("/") && path57.startsWith("/") ? path57.slice(1) : path57));
|
|
46361
46361
|
const defaultQuery = this.defaultQuery();
|
|
46362
46362
|
if (!isEmptyObj(defaultQuery)) {
|
|
46363
46363
|
query = { ...defaultQuery, ...query };
|
|
@@ -46642,7 +46642,7 @@ var startsWithSchemeRegexp = new RegExp("^(?:[a-z]+:)?//", "i");
|
|
|
46642
46642
|
var isAbsoluteURL = (url) => {
|
|
46643
46643
|
return startsWithSchemeRegexp.test(url);
|
|
46644
46644
|
};
|
|
46645
|
-
var sleep = (ms) => new Promise((
|
|
46645
|
+
var sleep = (ms) => new Promise((resolve41) => setTimeout(resolve41, ms));
|
|
46646
46646
|
var validatePositiveInteger = (name, n2) => {
|
|
46647
46647
|
if (typeof n2 !== "number" || !Number.isInteger(n2)) {
|
|
46648
46648
|
throw new AnthropicError(`${name} must be an integer`);
|
|
@@ -47133,12 +47133,12 @@ var PromptCachingBetaMessageStream = class _PromptCachingBetaMessageStream {
|
|
|
47133
47133
|
}
|
|
47134
47134
|
return this._emit("error", new AnthropicError(String(error3)));
|
|
47135
47135
|
});
|
|
47136
|
-
__classPrivateFieldSet7(this, _PromptCachingBetaMessageStream_connectedPromise, new Promise((
|
|
47137
|
-
__classPrivateFieldSet7(this, _PromptCachingBetaMessageStream_resolveConnectedPromise,
|
|
47136
|
+
__classPrivateFieldSet7(this, _PromptCachingBetaMessageStream_connectedPromise, new Promise((resolve41, reject) => {
|
|
47137
|
+
__classPrivateFieldSet7(this, _PromptCachingBetaMessageStream_resolveConnectedPromise, resolve41, "f");
|
|
47138
47138
|
__classPrivateFieldSet7(this, _PromptCachingBetaMessageStream_rejectConnectedPromise, reject, "f");
|
|
47139
47139
|
}), "f");
|
|
47140
|
-
__classPrivateFieldSet7(this, _PromptCachingBetaMessageStream_endPromise, new Promise((
|
|
47141
|
-
__classPrivateFieldSet7(this, _PromptCachingBetaMessageStream_resolveEndPromise,
|
|
47140
|
+
__classPrivateFieldSet7(this, _PromptCachingBetaMessageStream_endPromise, new Promise((resolve41, reject) => {
|
|
47141
|
+
__classPrivateFieldSet7(this, _PromptCachingBetaMessageStream_resolveEndPromise, resolve41, "f");
|
|
47142
47142
|
__classPrivateFieldSet7(this, _PromptCachingBetaMessageStream_rejectEndPromise, reject, "f");
|
|
47143
47143
|
}), "f");
|
|
47144
47144
|
__classPrivateFieldGet8(this, _PromptCachingBetaMessageStream_connectedPromise, "f").catch(() => {
|
|
@@ -47267,11 +47267,11 @@ var PromptCachingBetaMessageStream = class _PromptCachingBetaMessageStream {
|
|
|
47267
47267
|
* const message = await stream.emitted('message') // rejects if the stream errors
|
|
47268
47268
|
*/
|
|
47269
47269
|
emitted(event) {
|
|
47270
|
-
return new Promise((
|
|
47270
|
+
return new Promise((resolve41, reject) => {
|
|
47271
47271
|
__classPrivateFieldSet7(this, _PromptCachingBetaMessageStream_catchingPromiseCreated, true, "f");
|
|
47272
47272
|
if (event !== "error")
|
|
47273
47273
|
this.once("error", reject);
|
|
47274
|
-
this.once(event,
|
|
47274
|
+
this.once(event, resolve41);
|
|
47275
47275
|
});
|
|
47276
47276
|
}
|
|
47277
47277
|
async done() {
|
|
@@ -47498,7 +47498,7 @@ var PromptCachingBetaMessageStream = class _PromptCachingBetaMessageStream {
|
|
|
47498
47498
|
if (done) {
|
|
47499
47499
|
return { value: void 0, done: true };
|
|
47500
47500
|
}
|
|
47501
|
-
return new Promise((
|
|
47501
|
+
return new Promise((resolve41, reject) => readQueue.push({ resolve: resolve41, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
|
|
47502
47502
|
}
|
|
47503
47503
|
const chunk = pushQueue.shift();
|
|
47504
47504
|
return { value: chunk, done: false };
|
|
@@ -47646,12 +47646,12 @@ var MessageStream = class _MessageStream {
|
|
|
47646
47646
|
}
|
|
47647
47647
|
return this._emit("error", new AnthropicError(String(error3)));
|
|
47648
47648
|
});
|
|
47649
|
-
__classPrivateFieldSet8(this, _MessageStream_connectedPromise, new Promise((
|
|
47650
|
-
__classPrivateFieldSet8(this, _MessageStream_resolveConnectedPromise,
|
|
47649
|
+
__classPrivateFieldSet8(this, _MessageStream_connectedPromise, new Promise((resolve41, reject) => {
|
|
47650
|
+
__classPrivateFieldSet8(this, _MessageStream_resolveConnectedPromise, resolve41, "f");
|
|
47651
47651
|
__classPrivateFieldSet8(this, _MessageStream_rejectConnectedPromise, reject, "f");
|
|
47652
47652
|
}), "f");
|
|
47653
|
-
__classPrivateFieldSet8(this, _MessageStream_endPromise, new Promise((
|
|
47654
|
-
__classPrivateFieldSet8(this, _MessageStream_resolveEndPromise,
|
|
47653
|
+
__classPrivateFieldSet8(this, _MessageStream_endPromise, new Promise((resolve41, reject) => {
|
|
47654
|
+
__classPrivateFieldSet8(this, _MessageStream_resolveEndPromise, resolve41, "f");
|
|
47655
47655
|
__classPrivateFieldSet8(this, _MessageStream_rejectEndPromise, reject, "f");
|
|
47656
47656
|
}), "f");
|
|
47657
47657
|
__classPrivateFieldGet9(this, _MessageStream_connectedPromise, "f").catch(() => {
|
|
@@ -47780,11 +47780,11 @@ var MessageStream = class _MessageStream {
|
|
|
47780
47780
|
* const message = await stream.emitted('message') // rejects if the stream errors
|
|
47781
47781
|
*/
|
|
47782
47782
|
emitted(event) {
|
|
47783
|
-
return new Promise((
|
|
47783
|
+
return new Promise((resolve41, reject) => {
|
|
47784
47784
|
__classPrivateFieldSet8(this, _MessageStream_catchingPromiseCreated, true, "f");
|
|
47785
47785
|
if (event !== "error")
|
|
47786
47786
|
this.once("error", reject);
|
|
47787
|
-
this.once(event,
|
|
47787
|
+
this.once(event, resolve41);
|
|
47788
47788
|
});
|
|
47789
47789
|
}
|
|
47790
47790
|
async done() {
|
|
@@ -48011,7 +48011,7 @@ var MessageStream = class _MessageStream {
|
|
|
48011
48011
|
if (done) {
|
|
48012
48012
|
return { value: void 0, done: true };
|
|
48013
48013
|
}
|
|
48014
|
-
return new Promise((
|
|
48014
|
+
return new Promise((resolve41, reject) => readQueue.push({ resolve: resolve41, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
|
|
48015
48015
|
}
|
|
48016
48016
|
const chunk = pushQueue.shift();
|
|
48017
48017
|
return { value: chunk, done: false };
|
|
@@ -48271,11 +48271,11 @@ async function promptApplyAgentMdProposal(repoPath) {
|
|
|
48271
48271
|
}
|
|
48272
48272
|
async function askYesNo2(question) {
|
|
48273
48273
|
const rl = readline2.createInterface({ input: process.stdin, output: process.stderr });
|
|
48274
|
-
return new Promise((
|
|
48274
|
+
return new Promise((resolve41) => {
|
|
48275
48275
|
process.stderr.write(`${question} `);
|
|
48276
48276
|
rl.once("line", (answer) => {
|
|
48277
48277
|
rl.close();
|
|
48278
|
-
|
|
48278
|
+
resolve41(/^y(es)?$/i.test(answer.trim()));
|
|
48279
48279
|
});
|
|
48280
48280
|
});
|
|
48281
48281
|
}
|
|
@@ -48505,7 +48505,7 @@ async function executeAuthoringToolCall(toolName, input, repoPath, harnessDir, c
|
|
|
48505
48505
|
}
|
|
48506
48506
|
async function askUser(question, options) {
|
|
48507
48507
|
const rl = readline3.createInterface({ input: process.stdin, output: process.stderr });
|
|
48508
|
-
return new Promise((
|
|
48508
|
+
return new Promise((resolve41) => {
|
|
48509
48509
|
process.stderr.write("\n");
|
|
48510
48510
|
process.stderr.write(`\u2753 ${question}
|
|
48511
48511
|
`);
|
|
@@ -48516,7 +48516,7 @@ async function askUser(question, options) {
|
|
|
48516
48516
|
process.stderr.write("> ");
|
|
48517
48517
|
rl.once("line", (answer) => {
|
|
48518
48518
|
rl.close();
|
|
48519
|
-
|
|
48519
|
+
resolve41(answer.trim());
|
|
48520
48520
|
});
|
|
48521
48521
|
});
|
|
48522
48522
|
}
|
|
@@ -48660,7 +48660,7 @@ function runScript(scriptPath, args = [], options = {}) {
|
|
|
48660
48660
|
function runScriptCapture(scriptPath, args = [], options = {}) {
|
|
48661
48661
|
const stream = options.stream ?? false;
|
|
48662
48662
|
const { stream: _stream, ...spawnOptions } = options;
|
|
48663
|
-
return new Promise((
|
|
48663
|
+
return new Promise((resolve41) => {
|
|
48664
48664
|
const proc = (0, import_child_process.spawn)("bash", [scriptPath, ...args], {
|
|
48665
48665
|
...spawnOptions,
|
|
48666
48666
|
stdio: ["inherit", "pipe", "pipe"]
|
|
@@ -48675,13 +48675,13 @@ function runScriptCapture(scriptPath, args = [], options = {}) {
|
|
|
48675
48675
|
stderr += d2;
|
|
48676
48676
|
if (stream) process.stderr.write(d2);
|
|
48677
48677
|
});
|
|
48678
|
-
proc.on("close", (code) =>
|
|
48678
|
+
proc.on("close", (code) => resolve41({ stdout, stderr, code: code ?? 0 }));
|
|
48679
48679
|
});
|
|
48680
48680
|
}
|
|
48681
48681
|
function runShellCommand(command2, options = {}) {
|
|
48682
48682
|
const stream = options.stream ?? false;
|
|
48683
48683
|
const { stream: _stream, ...spawnOptions } = options;
|
|
48684
|
-
return new Promise((
|
|
48684
|
+
return new Promise((resolve41) => {
|
|
48685
48685
|
const proc = (0, import_child_process.spawn)("bash", ["-lc", command2], {
|
|
48686
48686
|
...spawnOptions,
|
|
48687
48687
|
stdio: ["inherit", "pipe", "pipe"]
|
|
@@ -48696,7 +48696,7 @@ function runShellCommand(command2, options = {}) {
|
|
|
48696
48696
|
stderr += d2;
|
|
48697
48697
|
if (stream) process.stderr.write(d2);
|
|
48698
48698
|
});
|
|
48699
|
-
proc.on("close", (code) =>
|
|
48699
|
+
proc.on("close", (code) => resolve41({ stdout, stderr, code: code ?? 0 }));
|
|
48700
48700
|
});
|
|
48701
48701
|
}
|
|
48702
48702
|
|
|
@@ -49877,12 +49877,12 @@ function printAdaptationPrompt(content) {
|
|
|
49877
49877
|
}
|
|
49878
49878
|
function askYesNo3(question) {
|
|
49879
49879
|
const rl = readline4.createInterface({ input: process.stdin, output: process.stderr });
|
|
49880
|
-
return new Promise((
|
|
49880
|
+
return new Promise((resolve41) => {
|
|
49881
49881
|
process.stderr.write(`${question} `);
|
|
49882
49882
|
rl.once("line", (answer) => {
|
|
49883
49883
|
rl.close();
|
|
49884
49884
|
const trimmed = answer.trim();
|
|
49885
|
-
|
|
49885
|
+
resolve41(trimmed === "" || /^y(es)?$/i.test(trimmed));
|
|
49886
49886
|
});
|
|
49887
49887
|
});
|
|
49888
49888
|
}
|
|
@@ -49969,16 +49969,16 @@ async function promptScaffoldCursorRule(exists) {
|
|
|
49969
49969
|
}
|
|
49970
49970
|
async function askYesNo4(question) {
|
|
49971
49971
|
const rl = readline5.createInterface({ input: process.stdin, output: process.stderr });
|
|
49972
|
-
return new Promise((
|
|
49972
|
+
return new Promise((resolve41) => {
|
|
49973
49973
|
process.stderr.write(`${question} `);
|
|
49974
49974
|
rl.once("line", (answer) => {
|
|
49975
49975
|
rl.close();
|
|
49976
49976
|
const trimmed = answer.trim();
|
|
49977
49977
|
if (trimmed === "") {
|
|
49978
|
-
|
|
49978
|
+
resolve41(true);
|
|
49979
49979
|
return;
|
|
49980
49980
|
}
|
|
49981
|
-
|
|
49981
|
+
resolve41(/^y(es)?$/i.test(trimmed));
|
|
49982
49982
|
});
|
|
49983
49983
|
});
|
|
49984
49984
|
}
|
|
@@ -50288,7 +50288,7 @@ var LocalScriptExecutor = class {
|
|
|
50288
50288
|
var localScriptExecutor = new LocalScriptExecutor();
|
|
50289
50289
|
|
|
50290
50290
|
// src/core/control-sync.ts
|
|
50291
|
-
var
|
|
50291
|
+
var path43 = __toESM(require("path"));
|
|
50292
50292
|
init_control_config();
|
|
50293
50293
|
|
|
50294
50294
|
// src/core/control-registry.ts
|
|
@@ -52144,7 +52144,66 @@ function harvestEventsForSlot(slot) {
|
|
|
52144
52144
|
}
|
|
52145
52145
|
|
|
52146
52146
|
// src/core/control-persisted-usage.ts
|
|
52147
|
+
var path42 = __toESM(require("path"));
|
|
52148
|
+
|
|
52149
|
+
// src/core/portal-watermark.ts
|
|
52150
|
+
var fs41 = __toESM(require("fs"));
|
|
52151
|
+
var os13 = __toESM(require("os"));
|
|
52147
52152
|
var path41 = __toESM(require("path"));
|
|
52153
|
+
function getStatePath() {
|
|
52154
|
+
if (process.env.HAR_PORTAL_SYNC_STATE_PATH) {
|
|
52155
|
+
return path41.resolve(process.env.HAR_PORTAL_SYNC_STATE_PATH);
|
|
52156
|
+
}
|
|
52157
|
+
return path41.join(os13.homedir(), ".har", "portal-sync-state.json");
|
|
52158
|
+
}
|
|
52159
|
+
function readState() {
|
|
52160
|
+
const statePath = getStatePath();
|
|
52161
|
+
try {
|
|
52162
|
+
if (!fs41.existsSync(statePath)) return { states: [] };
|
|
52163
|
+
const parsed = JSON.parse(fs41.readFileSync(statePath, "utf8"));
|
|
52164
|
+
return Array.isArray(parsed.states) ? parsed : { states: [] };
|
|
52165
|
+
} catch {
|
|
52166
|
+
return { states: [] };
|
|
52167
|
+
}
|
|
52168
|
+
}
|
|
52169
|
+
function writeState(state) {
|
|
52170
|
+
const statePath = getStatePath();
|
|
52171
|
+
fs41.mkdirSync(path41.dirname(statePath), { recursive: true });
|
|
52172
|
+
fs41.writeFileSync(statePath, JSON.stringify(state, null, 2) + "\n");
|
|
52173
|
+
}
|
|
52174
|
+
function readPortalWatermark(repoPath, portalUrl) {
|
|
52175
|
+
const canonical = canonicalizeControlRepoPath(repoPath);
|
|
52176
|
+
const entry = readState().states.find(
|
|
52177
|
+
(state) => state.repoPath === canonical && state.portalUrl === portalUrl
|
|
52178
|
+
);
|
|
52179
|
+
return entry?.lastSyncedAt ?? null;
|
|
52180
|
+
}
|
|
52181
|
+
function writePortalWatermark(repoPath, portalUrl, lastSyncedAt) {
|
|
52182
|
+
const canonical = canonicalizeControlRepoPath(repoPath);
|
|
52183
|
+
const state = readState();
|
|
52184
|
+
const existing = state.states.find(
|
|
52185
|
+
(entry) => entry.repoPath === canonical && entry.portalUrl === portalUrl
|
|
52186
|
+
);
|
|
52187
|
+
if (existing) {
|
|
52188
|
+
existing.lastSyncedAt = lastSyncedAt;
|
|
52189
|
+
} else {
|
|
52190
|
+
state.states.push({ repoPath: canonical, portalUrl, lastSyncedAt });
|
|
52191
|
+
}
|
|
52192
|
+
writeState(state);
|
|
52193
|
+
}
|
|
52194
|
+
function selectSince(rows, since, getTimestamp) {
|
|
52195
|
+
let maxSyncedAt = null;
|
|
52196
|
+
const selected = [];
|
|
52197
|
+
for (const row of rows) {
|
|
52198
|
+
const ts = getTimestamp(row);
|
|
52199
|
+
if (since && ts && ts <= since) continue;
|
|
52200
|
+
selected.push(row);
|
|
52201
|
+
if (ts && (maxSyncedAt === null || ts > maxSyncedAt)) maxSyncedAt = ts;
|
|
52202
|
+
}
|
|
52203
|
+
return { selected, maxSyncedAt };
|
|
52204
|
+
}
|
|
52205
|
+
|
|
52206
|
+
// src/core/control-persisted-usage.ts
|
|
52148
52207
|
var FETCH_TIMEOUT_MS = 3e3;
|
|
52149
52208
|
async function getJson(url) {
|
|
52150
52209
|
try {
|
|
@@ -52161,8 +52220,8 @@ async function getJson(url) {
|
|
|
52161
52220
|
async function resolveControlRepoId(apiUrl, repoPath) {
|
|
52162
52221
|
const repos = await getJson(`${apiUrl}/api/repos`);
|
|
52163
52222
|
if (!Array.isArray(repos)) return null;
|
|
52164
|
-
const target =
|
|
52165
|
-
return repos.find((repo) =>
|
|
52223
|
+
const target = path42.resolve(repoPath);
|
|
52224
|
+
return repos.find((repo) => path42.resolve(repo.path) === target)?.id ?? null;
|
|
52166
52225
|
}
|
|
52167
52226
|
function optionalString(value) {
|
|
52168
52227
|
return value == null ? void 0 : value;
|
|
@@ -52210,16 +52269,25 @@ function normalizeEvent(row) {
|
|
|
52210
52269
|
source: row.source === "harvest" ? "harvest" : "otel"
|
|
52211
52270
|
};
|
|
52212
52271
|
}
|
|
52213
|
-
|
|
52272
|
+
function maxTimestamp(a2, b2) {
|
|
52273
|
+
if (a2 === null) return b2;
|
|
52274
|
+
if (b2 === null) return a2;
|
|
52275
|
+
return a2 > b2 ? a2 : b2;
|
|
52276
|
+
}
|
|
52277
|
+
async function fetchPersistedPortalTelemetry(repoPath, apiUrl, options) {
|
|
52214
52278
|
const repoId = await resolveControlRepoId(apiUrl, repoPath);
|
|
52215
|
-
if (!repoId) return { usage: [], events: [] };
|
|
52279
|
+
if (!repoId) return { usage: [], events: [], maxSyncedAt: null };
|
|
52280
|
+
const since = options?.since ?? null;
|
|
52216
52281
|
const [usageResponse, eventsResponse] = await Promise.all([
|
|
52217
52282
|
getJson(`${apiUrl}/api/repos/${repoId}/usage`),
|
|
52218
52283
|
getJson(`${apiUrl}/api/repos/${repoId}/events`)
|
|
52219
52284
|
]);
|
|
52285
|
+
const usage2 = selectSince(usageResponse?.usage ?? [], since, (row) => row.updatedAt ?? row.lastSeenAt);
|
|
52286
|
+
const events = selectSince(eventsResponse?.events ?? [], since, (row) => row.createdAt ?? row.timestamp);
|
|
52220
52287
|
return {
|
|
52221
|
-
usage:
|
|
52222
|
-
events:
|
|
52288
|
+
usage: usage2.selected.map(normalizeUsage),
|
|
52289
|
+
events: events.selected.map(normalizeEvent),
|
|
52290
|
+
maxSyncedAt: maxTimestamp(usage2.maxSyncedAt, events.maxSyncedAt)
|
|
52223
52291
|
};
|
|
52224
52292
|
}
|
|
52225
52293
|
|
|
@@ -52350,8 +52418,8 @@ function modelsFromBreakdown(breakdown) {
|
|
|
52350
52418
|
...totals && typeof totals === "object" ? totals : {}
|
|
52351
52419
|
}));
|
|
52352
52420
|
}
|
|
52353
|
-
async function collectPortalTelemetry(repoPath, slots, controlApiUrl) {
|
|
52354
|
-
if (!isTelemetryEnabled()) return { usage: [], events: [] };
|
|
52421
|
+
async function collectPortalTelemetry(repoPath, slots, controlApiUrl, since) {
|
|
52422
|
+
if (!isTelemetryEnabled()) return { usage: [], events: [], maxSyncedAt: null };
|
|
52355
52423
|
try {
|
|
52356
52424
|
const userEmail = resolvePortalUserEmail();
|
|
52357
52425
|
const liveUsage = slots.flatMap(
|
|
@@ -52390,7 +52458,7 @@ async function collectPortalTelemetry(repoPath, slots, controlApiUrl) {
|
|
|
52390
52458
|
attemptId: slot.attemptId ?? event.attemptId
|
|
52391
52459
|
}))
|
|
52392
52460
|
);
|
|
52393
|
-
const persisted = await fetchPersistedPortalTelemetry(repoPath, controlApiUrl);
|
|
52461
|
+
const persisted = await fetchPersistedPortalTelemetry(repoPath, controlApiUrl, { since });
|
|
52394
52462
|
const usage2 = mergePortalUsage(liveUsage, persisted.usage).map((row) => {
|
|
52395
52463
|
const models = modelsFromBreakdown(row.modelBreakdown);
|
|
52396
52464
|
return {
|
|
@@ -52402,12 +52470,12 @@ async function collectPortalTelemetry(repoPath, slots, controlApiUrl) {
|
|
|
52402
52470
|
const events = dedupePortalEvents(liveEvents, persisted.events).map(
|
|
52403
52471
|
(event) => dropNullFields({ ...event })
|
|
52404
52472
|
);
|
|
52405
|
-
return { usage: usage2, events };
|
|
52473
|
+
return { usage: usage2, events, maxSyncedAt: persisted.maxSyncedAt };
|
|
52406
52474
|
} catch {
|
|
52407
|
-
return { usage: [], events: [] };
|
|
52475
|
+
return { usage: [], events: [], maxSyncedAt: null };
|
|
52408
52476
|
}
|
|
52409
52477
|
}
|
|
52410
|
-
async function buildPortalPayload(repoPath, controlApiUrl) {
|
|
52478
|
+
async function buildPortalPayload(repoPath, controlApiUrl, since) {
|
|
52411
52479
|
const runs = listRuns(repoPath);
|
|
52412
52480
|
const status = collectEnvironmentStatus(repoPath);
|
|
52413
52481
|
const manifest = readManifest(repoPath);
|
|
@@ -52417,7 +52485,12 @@ async function buildPortalPayload(repoPath, controlApiUrl) {
|
|
|
52417
52485
|
const workUnits = listWorkUnits(harnessRoot);
|
|
52418
52486
|
const attempts = listWorkAttempts(harnessRoot);
|
|
52419
52487
|
const validationBindings = listValidationBindings(harnessRoot);
|
|
52420
|
-
const { usage: usage2, events } = await collectPortalTelemetry(
|
|
52488
|
+
const { usage: usage2, events, maxSyncedAt } = await collectPortalTelemetry(
|
|
52489
|
+
repoPath,
|
|
52490
|
+
status.slots,
|
|
52491
|
+
controlApiUrl,
|
|
52492
|
+
since
|
|
52493
|
+
);
|
|
52421
52494
|
const syncBody = {
|
|
52422
52495
|
path: repoPath,
|
|
52423
52496
|
...manifest ? { manifest } : {},
|
|
@@ -52431,7 +52504,7 @@ async function buildPortalPayload(repoPath, controlApiUrl) {
|
|
|
52431
52504
|
...validationBindings.length > 0 ? { validationBindings } : {},
|
|
52432
52505
|
...usage2.length > 0 ? { usage: usage2 } : {}
|
|
52433
52506
|
};
|
|
52434
|
-
return { syncBody, events };
|
|
52507
|
+
return { syncBody, events, maxSyncedAt };
|
|
52435
52508
|
}
|
|
52436
52509
|
async function isControlApiReachable(apiUrl = getControlApiUrl()) {
|
|
52437
52510
|
try {
|
|
@@ -52448,7 +52521,7 @@ async function waitForControlApi(apiUrl = getControlApiUrl(), timeoutMs = 6e4, i
|
|
|
52448
52521
|
const deadline = Date.now() + timeoutMs;
|
|
52449
52522
|
while (Date.now() < deadline) {
|
|
52450
52523
|
if (await isControlApiReachable(apiUrl)) return true;
|
|
52451
|
-
await new Promise((
|
|
52524
|
+
await new Promise((resolve41) => setTimeout(resolve41, intervalMs));
|
|
52452
52525
|
}
|
|
52453
52526
|
return false;
|
|
52454
52527
|
}
|
|
@@ -52480,7 +52553,7 @@ async function syncReposWithControl(options) {
|
|
|
52480
52553
|
for (const repoPath of options.repoPaths) {
|
|
52481
52554
|
try {
|
|
52482
52555
|
await withTimeout(
|
|
52483
|
-
syncRepoWithControl({ repoPath, apiUrl, dryRun: options.dryRun, cloud: options.cloud }),
|
|
52556
|
+
syncRepoWithControl({ repoPath, apiUrl, dryRun: options.dryRun, cloud: options.cloud, full: options.full }),
|
|
52484
52557
|
SYNC_TIMEOUT_MS,
|
|
52485
52558
|
"control sync"
|
|
52486
52559
|
);
|
|
@@ -52566,7 +52639,8 @@ async function syncRepoWithControl(options) {
|
|
|
52566
52639
|
}
|
|
52567
52640
|
const portal = getPortalTarget();
|
|
52568
52641
|
if (portal) {
|
|
52569
|
-
const
|
|
52642
|
+
const since = options.full ? null : readPortalWatermark(repoPath, portal.url);
|
|
52643
|
+
const { syncBody, events, maxSyncedAt } = await buildPortalPayload(repoPath, apiUrl, since);
|
|
52570
52644
|
await postPortal(portal, "/api/sync", syncBody, options.dryRun);
|
|
52571
52645
|
if (events.length > 0) {
|
|
52572
52646
|
await postPortal(
|
|
@@ -52576,6 +52650,9 @@ async function syncRepoWithControl(options) {
|
|
|
52576
52650
|
options.dryRun
|
|
52577
52651
|
);
|
|
52578
52652
|
}
|
|
52653
|
+
if (!options.dryRun && maxSyncedAt) {
|
|
52654
|
+
writePortalWatermark(repoPath, portal.url, maxSyncedAt);
|
|
52655
|
+
}
|
|
52579
52656
|
return;
|
|
52580
52657
|
}
|
|
52581
52658
|
const registerResult = await registerRepoWithControl({ ...options, repoPath });
|
|
@@ -52584,7 +52661,7 @@ async function syncRepoWithControl(options) {
|
|
|
52584
52661
|
const listResponse = await fetch(`${apiUrl}/api/repos`);
|
|
52585
52662
|
if (!listResponse.ok) throw new Error("Failed to list repos from Control API");
|
|
52586
52663
|
const repos = await listResponse.json();
|
|
52587
|
-
const existing = repos.find((r2) =>
|
|
52664
|
+
const existing = repos.find((r2) => path43.resolve(r2.path) === repoPath);
|
|
52588
52665
|
if (!existing) {
|
|
52589
52666
|
return;
|
|
52590
52667
|
}
|
|
@@ -52737,7 +52814,7 @@ init_control_config();
|
|
|
52737
52814
|
|
|
52738
52815
|
// src/core/control-lifecycle.ts
|
|
52739
52816
|
var import_child_process9 = require("child_process");
|
|
52740
|
-
var
|
|
52817
|
+
var path44 = __toESM(require("path"));
|
|
52741
52818
|
|
|
52742
52819
|
// src/core/control-image.ts
|
|
52743
52820
|
var DEFAULT_CONTROL_IMAGE = "theosfactory/har-control";
|
|
@@ -52761,10 +52838,10 @@ var CONTROL_DATA_VOLUME = "har_control_data";
|
|
|
52761
52838
|
var CONTROL_CONTAINER_PORT = 3847;
|
|
52762
52839
|
var CONTROL_DATA_DB_URL = "file:/data/har_control.db";
|
|
52763
52840
|
function resolveControlDir() {
|
|
52764
|
-
return
|
|
52841
|
+
return path44.resolve(__dirname, "..", "control");
|
|
52765
52842
|
}
|
|
52766
52843
|
function resolveControlBuildContext() {
|
|
52767
|
-
return
|
|
52844
|
+
return path44.resolve(resolveControlDir(), "..");
|
|
52768
52845
|
}
|
|
52769
52846
|
function buildDockerRunArgs(options) {
|
|
52770
52847
|
const name = options.containerName ?? CONTROL_CONTAINER_NAME;
|
|
@@ -52820,7 +52897,7 @@ async function startMissionControl(options) {
|
|
|
52820
52897
|
"-t",
|
|
52821
52898
|
imageRef,
|
|
52822
52899
|
"-f",
|
|
52823
|
-
|
|
52900
|
+
path44.join(resolveControlDir(), "Dockerfile"),
|
|
52824
52901
|
resolveControlBuildContext()
|
|
52825
52902
|
]);
|
|
52826
52903
|
if (buildCode !== 0) {
|
|
@@ -52965,7 +53042,7 @@ async function ensureTelemetryInfrastructure(options) {
|
|
|
52965
53042
|
|
|
52966
53043
|
// src/core/run-service.ts
|
|
52967
53044
|
init_telemetry_config();
|
|
52968
|
-
var
|
|
53045
|
+
var path46 = __toESM(require("path"));
|
|
52969
53046
|
function extractShellOutput(result) {
|
|
52970
53047
|
const stdout = result.logs?.find((log) => log.stream === "stdout")?.content ?? result.logs?.find((log) => !log.stream)?.content ?? "";
|
|
52971
53048
|
const stderr = result.logs?.find((log) => log.stream === "stderr")?.content ?? "";
|
|
@@ -53175,12 +53252,12 @@ Usage from Cursor / Claude / Codex (opentelemetry-hooks) will appear under Workt
|
|
|
53175
53252
|
suffix: session.suffix,
|
|
53176
53253
|
createdAt: session.createdAt
|
|
53177
53254
|
});
|
|
53178
|
-
const envFile =
|
|
53255
|
+
const envFile = path46.join(session.workDir, `.env.agent.${options.agentId}`);
|
|
53179
53256
|
try {
|
|
53180
53257
|
appendTelemetryEnvToFile(envFile, {
|
|
53181
53258
|
sessionKey,
|
|
53182
53259
|
agentId: options.agentId,
|
|
53183
|
-
repoPath:
|
|
53260
|
+
repoPath: path46.resolve(options.repoPath),
|
|
53184
53261
|
workDir: session.workDir,
|
|
53185
53262
|
branch: session.branch,
|
|
53186
53263
|
suffix: session.suffix,
|
|
@@ -53412,9 +53489,9 @@ var getEnvironmentLogs = defaultRunService.getEnvironmentLogs.bind(defaultRunSer
|
|
|
53412
53489
|
var readline6 = __toESM(require("readline"));
|
|
53413
53490
|
|
|
53414
53491
|
// src/core/hooks.ts
|
|
53415
|
-
var
|
|
53416
|
-
var
|
|
53417
|
-
var
|
|
53492
|
+
var fs43 = __toESM(require("fs"));
|
|
53493
|
+
var os15 = __toESM(require("os"));
|
|
53494
|
+
var path47 = __toESM(require("path"));
|
|
53418
53495
|
var MARKER_START = "# >>> har commit gate (managed by `har hooks`) >>>";
|
|
53419
53496
|
var MARKER_END = "# <<< har commit gate <<<";
|
|
53420
53497
|
var PRE_COMMIT_BLOCK = [
|
|
@@ -53439,7 +53516,7 @@ function resolveCheckoutRoot(cwd) {
|
|
|
53439
53516
|
function resolveHooksDir(checkoutDir) {
|
|
53440
53517
|
const hooksPath = tryGit3(checkoutDir, "rev-parse --git-path hooks");
|
|
53441
53518
|
if (!hooksPath) throw new Error(`Not a git checkout: ${checkoutDir}`);
|
|
53442
|
-
return
|
|
53519
|
+
return path47.resolve(checkoutDir, hooksPath);
|
|
53443
53520
|
}
|
|
53444
53521
|
function getConfiguredHooksPath(checkoutDir) {
|
|
53445
53522
|
return tryGit3(checkoutDir, "config core.hooksPath") || void 0;
|
|
@@ -53447,9 +53524,9 @@ function getConfiguredHooksPath(checkoutDir) {
|
|
|
53447
53524
|
function defaultHarInvocation() {
|
|
53448
53525
|
const entry = process.argv[1];
|
|
53449
53526
|
if (entry && entry.endsWith(".js")) {
|
|
53450
|
-
return `"${process.execPath}" "${
|
|
53527
|
+
return `"${process.execPath}" "${path47.resolve(entry)}"`;
|
|
53451
53528
|
}
|
|
53452
|
-
if (entry) return `"${
|
|
53529
|
+
if (entry) return `"${path47.resolve(entry)}"`;
|
|
53453
53530
|
return "har";
|
|
53454
53531
|
}
|
|
53455
53532
|
function buildHookScript(harInvocation, subcommand, failOpenNotice) {
|
|
@@ -53470,40 +53547,40 @@ exit 0
|
|
|
53470
53547
|
`;
|
|
53471
53548
|
}
|
|
53472
53549
|
function upsertMarkedBlock(filePath, block) {
|
|
53473
|
-
if (!
|
|
53474
|
-
|
|
53550
|
+
if (!fs43.existsSync(filePath)) {
|
|
53551
|
+
fs43.writeFileSync(filePath, `#!/bin/sh
|
|
53475
53552
|
${block}
|
|
53476
53553
|
`, { mode: 493 });
|
|
53477
53554
|
return "created";
|
|
53478
53555
|
}
|
|
53479
|
-
const content =
|
|
53556
|
+
const content = fs43.readFileSync(filePath, "utf8");
|
|
53480
53557
|
if (content.includes(MARKER_START)) {
|
|
53481
53558
|
const pattern = new RegExp(
|
|
53482
53559
|
`${escapeRegExp(MARKER_START)}[\\s\\S]*?${escapeRegExp(MARKER_END)}`
|
|
53483
53560
|
);
|
|
53484
|
-
|
|
53485
|
-
|
|
53561
|
+
fs43.writeFileSync(filePath, content.replace(pattern, block));
|
|
53562
|
+
fs43.chmodSync(filePath, 493);
|
|
53486
53563
|
return "updated";
|
|
53487
53564
|
}
|
|
53488
53565
|
const suffix = content.endsWith("\n") ? "" : "\n";
|
|
53489
|
-
|
|
53566
|
+
fs43.writeFileSync(filePath, `${content}${suffix}
|
|
53490
53567
|
${block}
|
|
53491
53568
|
`);
|
|
53492
|
-
|
|
53569
|
+
fs43.chmodSync(filePath, 493);
|
|
53493
53570
|
return "appended";
|
|
53494
53571
|
}
|
|
53495
53572
|
function removeMarkedBlock(filePath) {
|
|
53496
|
-
if (!
|
|
53497
|
-
const content =
|
|
53573
|
+
if (!fs43.existsSync(filePath)) return false;
|
|
53574
|
+
const content = fs43.readFileSync(filePath, "utf8");
|
|
53498
53575
|
if (!content.includes(MARKER_START)) return false;
|
|
53499
53576
|
const pattern = new RegExp(
|
|
53500
53577
|
`\\n?${escapeRegExp(MARKER_START)}[\\s\\S]*?${escapeRegExp(MARKER_END)}\\n?`
|
|
53501
53578
|
);
|
|
53502
53579
|
const stripped = content.replace(pattern, "\n");
|
|
53503
53580
|
if (stripped.replace(/^#!\/bin\/sh\n?/, "").trim() === "") {
|
|
53504
|
-
|
|
53581
|
+
fs43.rmSync(filePath);
|
|
53505
53582
|
} else {
|
|
53506
|
-
|
|
53583
|
+
fs43.writeFileSync(filePath, stripped);
|
|
53507
53584
|
}
|
|
53508
53585
|
return true;
|
|
53509
53586
|
}
|
|
@@ -53525,20 +53602,20 @@ Or re-run with --force to write into that directory anyway.`
|
|
|
53525
53602
|
);
|
|
53526
53603
|
}
|
|
53527
53604
|
const hooksDir = resolveHooksDir(checkout);
|
|
53528
|
-
|
|
53605
|
+
fs43.mkdirSync(hooksDir, { recursive: true });
|
|
53529
53606
|
const invocation = options.harInvocation ?? defaultHarInvocation();
|
|
53530
|
-
|
|
53531
|
-
|
|
53607
|
+
fs43.writeFileSync(
|
|
53608
|
+
path47.join(hooksDir, "har-pre-commit"),
|
|
53532
53609
|
buildHookScript(invocation, "check", "har: binary not found; skipping commit gate (reinstall with har hooks install)"),
|
|
53533
53610
|
{ mode: 493 }
|
|
53534
53611
|
);
|
|
53535
|
-
|
|
53536
|
-
|
|
53612
|
+
fs43.writeFileSync(
|
|
53613
|
+
path47.join(hooksDir, "har-post-commit"),
|
|
53537
53614
|
buildHookScript(invocation, "record-commit", "har: binary not found; skipping commit association"),
|
|
53538
53615
|
{ mode: 493 }
|
|
53539
53616
|
);
|
|
53540
|
-
const preCommit = upsertMarkedBlock(
|
|
53541
|
-
const postCommit = upsertMarkedBlock(
|
|
53617
|
+
const preCommit = upsertMarkedBlock(path47.join(hooksDir, "pre-commit"), PRE_COMMIT_BLOCK);
|
|
53618
|
+
const postCommit = upsertMarkedBlock(path47.join(hooksDir, "post-commit"), POST_COMMIT_BLOCK);
|
|
53542
53619
|
ensureValidationsIgnored(checkout);
|
|
53543
53620
|
return { hooksDir, preCommit, postCommit };
|
|
53544
53621
|
}
|
|
@@ -53547,12 +53624,12 @@ function uninstallHooks(repoPath) {
|
|
|
53547
53624
|
if (!checkout) throw new Error(`Not a git repository: ${repoPath}`);
|
|
53548
53625
|
const hooksDir = resolveHooksDir(checkout);
|
|
53549
53626
|
let removed = false;
|
|
53550
|
-
removed = removeMarkedBlock(
|
|
53551
|
-
removed = removeMarkedBlock(
|
|
53627
|
+
removed = removeMarkedBlock(path47.join(hooksDir, "pre-commit")) || removed;
|
|
53628
|
+
removed = removeMarkedBlock(path47.join(hooksDir, "post-commit")) || removed;
|
|
53552
53629
|
for (const file of ["har-pre-commit", "har-post-commit"]) {
|
|
53553
|
-
const full =
|
|
53554
|
-
if (
|
|
53555
|
-
|
|
53630
|
+
const full = path47.join(hooksDir, file);
|
|
53631
|
+
if (fs43.existsSync(full)) {
|
|
53632
|
+
fs43.rmSync(full);
|
|
53556
53633
|
removed = true;
|
|
53557
53634
|
}
|
|
53558
53635
|
}
|
|
@@ -53571,10 +53648,10 @@ function isAgentWorktree(checkoutDir) {
|
|
|
53571
53648
|
if (branch && (/^har-agent-\d+$/.test(branch) || /-har-agent-\d+-[a-z0-9]+$/.test(branch))) {
|
|
53572
53649
|
return true;
|
|
53573
53650
|
}
|
|
53574
|
-
const worktreesRoot =
|
|
53575
|
-
const resolved =
|
|
53576
|
-
const name =
|
|
53577
|
-
return resolved.startsWith(`${worktreesRoot}${
|
|
53651
|
+
const worktreesRoot = path47.join(os15.homedir(), "worktrees");
|
|
53652
|
+
const resolved = path47.resolve(checkoutDir);
|
|
53653
|
+
const name = path47.basename(resolved);
|
|
53654
|
+
return resolved.startsWith(`${worktreesRoot}${path47.sep}`) && (/-agent-\d+$/.test(name) || /-har-agent-\d+-[a-z0-9]+$/.test(name));
|
|
53578
53655
|
}
|
|
53579
53656
|
function resolveEffectiveMode(checkoutDir, gate) {
|
|
53580
53657
|
if (!gate.enabled) return "off";
|
|
@@ -53587,15 +53664,15 @@ function getHooksStatus(repoPath) {
|
|
|
53587
53664
|
const hooksDir = resolveHooksDir(checkout);
|
|
53588
53665
|
const gate = getCommitGateConfig(checkout);
|
|
53589
53666
|
const hasBlock = (name) => {
|
|
53590
|
-
const file =
|
|
53591
|
-
return
|
|
53667
|
+
const file = path47.join(hooksDir, name);
|
|
53668
|
+
return fs43.existsSync(file) && fs43.readFileSync(file, "utf8").includes(MARKER_START);
|
|
53592
53669
|
};
|
|
53593
53670
|
return {
|
|
53594
53671
|
checkout,
|
|
53595
53672
|
hooksDir,
|
|
53596
53673
|
configuredHooksPath: getConfiguredHooksPath(checkout),
|
|
53597
|
-
preCommitInstalled: hasBlock("pre-commit") &&
|
|
53598
|
-
postCommitInstalled: hasBlock("post-commit") &&
|
|
53674
|
+
preCommitInstalled: hasBlock("pre-commit") && fs43.existsSync(path47.join(hooksDir, "har-pre-commit")),
|
|
53675
|
+
postCommitInstalled: hasBlock("post-commit") && fs43.existsSync(path47.join(hooksDir, "har-post-commit")),
|
|
53599
53676
|
gate,
|
|
53600
53677
|
effectiveMode: resolveEffectiveMode(checkout, gate)
|
|
53601
53678
|
};
|
|
@@ -53606,7 +53683,7 @@ function checkCommitGate(cwd) {
|
|
|
53606
53683
|
}
|
|
53607
53684
|
const checkout = resolveCheckoutRoot(cwd);
|
|
53608
53685
|
if (!checkout) return { exitCode: 0, messages: [] };
|
|
53609
|
-
if (!
|
|
53686
|
+
if (!fs43.existsSync(path47.join(checkout, ".har", "stages.json"))) {
|
|
53610
53687
|
return { exitCode: 0, messages: [] };
|
|
53611
53688
|
}
|
|
53612
53689
|
const gate = getCommitGateConfig(checkout);
|
|
@@ -53679,12 +53756,12 @@ async function recordCommitAssociation(cwd) {
|
|
|
53679
53756
|
// src/core/commit-gate-onboarding.ts
|
|
53680
53757
|
function askYesNo5(question) {
|
|
53681
53758
|
const rl = readline6.createInterface({ input: process.stdin, output: process.stderr });
|
|
53682
|
-
return new Promise((
|
|
53759
|
+
return new Promise((resolve41) => {
|
|
53683
53760
|
process.stderr.write(`${question} `);
|
|
53684
53761
|
rl.once("line", (answer) => {
|
|
53685
53762
|
rl.close();
|
|
53686
53763
|
const trimmed = answer.trim();
|
|
53687
|
-
|
|
53764
|
+
resolve41(trimmed === "" || /^y(es)?$/i.test(trimmed));
|
|
53688
53765
|
});
|
|
53689
53766
|
});
|
|
53690
53767
|
}
|
|
@@ -53726,20 +53803,20 @@ async function handleCommitGateOnboarding(options) {
|
|
|
53726
53803
|
}
|
|
53727
53804
|
|
|
53728
53805
|
// src/core/onboarding-preferences.ts
|
|
53729
|
-
var
|
|
53730
|
-
var
|
|
53731
|
-
var
|
|
53806
|
+
var fs44 = __toESM(require("fs"));
|
|
53807
|
+
var os16 = __toESM(require("os"));
|
|
53808
|
+
var path48 = __toESM(require("path"));
|
|
53732
53809
|
function getOnboardingPreferencesPath() {
|
|
53733
53810
|
if (process.env.HAR_PREFERENCES_PATH) {
|
|
53734
|
-
return
|
|
53811
|
+
return path48.resolve(process.env.HAR_PREFERENCES_PATH);
|
|
53735
53812
|
}
|
|
53736
|
-
return
|
|
53813
|
+
return path48.join(os16.homedir(), ".har", "preferences.json");
|
|
53737
53814
|
}
|
|
53738
53815
|
function readOnboardingPreferences() {
|
|
53739
53816
|
const preferencePath = getOnboardingPreferencesPath();
|
|
53740
53817
|
try {
|
|
53741
|
-
if (!
|
|
53742
|
-
return OnboardingPreferencesSchema.parse(JSON.parse(
|
|
53818
|
+
if (!fs44.existsSync(preferencePath)) return OnboardingPreferencesSchema.parse({});
|
|
53819
|
+
return OnboardingPreferencesSchema.parse(JSON.parse(fs44.readFileSync(preferencePath, "utf8")));
|
|
53743
53820
|
} catch {
|
|
53744
53821
|
return OnboardingPreferencesSchema.parse({});
|
|
53745
53822
|
}
|
|
@@ -53764,8 +53841,8 @@ function writeOnboardingPreferences(overrides) {
|
|
|
53764
53841
|
};
|
|
53765
53842
|
const parsed = OnboardingPreferencesSchema.parse(preference);
|
|
53766
53843
|
const preferencePath = getOnboardingPreferencesPath();
|
|
53767
|
-
|
|
53768
|
-
|
|
53844
|
+
fs44.mkdirSync(path48.dirname(preferencePath), { recursive: true });
|
|
53845
|
+
fs44.writeFileSync(preferencePath, `${JSON.stringify(parsed, null, 2)}
|
|
53769
53846
|
`);
|
|
53770
53847
|
return parsed;
|
|
53771
53848
|
}
|
|
@@ -54065,7 +54142,7 @@ var envCommand = {
|
|
|
54065
54142
|
}
|
|
54066
54143
|
};
|
|
54067
54144
|
async function handleInit(argv) {
|
|
54068
|
-
const repoPath =
|
|
54145
|
+
const repoPath = path49.resolve(argv.repo);
|
|
54069
54146
|
const onboarding = resolveOnboardingOptions(argv);
|
|
54070
54147
|
header("har env init");
|
|
54071
54148
|
info(`Repository: ${repoPath}`);
|
|
@@ -54129,7 +54206,7 @@ async function handleInit(argv) {
|
|
|
54129
54206
|
}
|
|
54130
54207
|
}
|
|
54131
54208
|
async function handleMaintain(argv) {
|
|
54132
|
-
const repoPath =
|
|
54209
|
+
const repoPath = path49.resolve(argv.repo);
|
|
54133
54210
|
const onboarding = resolveOnboardingOptions(argv);
|
|
54134
54211
|
header("har env maintain");
|
|
54135
54212
|
info(`Repository: ${repoPath}`);
|
|
@@ -54251,7 +54328,7 @@ async function handleAgentMdProposal(repoPath, autoYes) {
|
|
|
54251
54328
|
if (autoYes) {
|
|
54252
54329
|
const proposal = readAgentMdProposal(repoPath);
|
|
54253
54330
|
if (proposal) {
|
|
54254
|
-
writeFileSafe(
|
|
54331
|
+
writeFileSafe(path49.join(repoPath, "AGENT.md"), proposal.content);
|
|
54255
54332
|
clearAgentMdProposal(repoPath);
|
|
54256
54333
|
info("Applied AGENT.md proposal (--yes)");
|
|
54257
54334
|
}
|
|
@@ -54260,7 +54337,7 @@ async function handleAgentMdProposal(repoPath, autoYes) {
|
|
|
54260
54337
|
await promptApplyAgentMdProposal(repoPath);
|
|
54261
54338
|
}
|
|
54262
54339
|
async function handleAddPlugin(argv) {
|
|
54263
|
-
const repoPath =
|
|
54340
|
+
const repoPath = path49.resolve(argv.repo);
|
|
54264
54341
|
const available = listPluginIds();
|
|
54265
54342
|
if (argv.list) {
|
|
54266
54343
|
for (const id of available) {
|
|
@@ -54298,7 +54375,7 @@ async function handleAddPlugin(argv) {
|
|
|
54298
54375
|
}
|
|
54299
54376
|
}
|
|
54300
54377
|
async function handleAddStage(argv) {
|
|
54301
|
-
const repoPath =
|
|
54378
|
+
const repoPath = path49.resolve(argv.repo);
|
|
54302
54379
|
const available = listPluginIds();
|
|
54303
54380
|
if (argv.list) {
|
|
54304
54381
|
warn("har env add-stage --list is deprecated; prefer: har env add-plugin --list");
|
|
@@ -54364,7 +54441,7 @@ async function handleAddStage(argv) {
|
|
|
54364
54441
|
});
|
|
54365
54442
|
}
|
|
54366
54443
|
async function handlePreflight(argv) {
|
|
54367
|
-
const repo =
|
|
54444
|
+
const repo = path49.resolve(argv.repo);
|
|
54368
54445
|
const agentId = validateAgentId(argv.id, repo);
|
|
54369
54446
|
const result = await preflightEnvironment({
|
|
54370
54447
|
repoPath: repo,
|
|
@@ -54382,7 +54459,7 @@ async function handlePreflight(argv) {
|
|
|
54382
54459
|
process.exit(result.code);
|
|
54383
54460
|
}
|
|
54384
54461
|
async function handleLaunch(argv) {
|
|
54385
|
-
const repo =
|
|
54462
|
+
const repo = path49.resolve(argv.repo);
|
|
54386
54463
|
const agentId = validateAgentId(argv.id, repo);
|
|
54387
54464
|
let confirmReplace = argv.replace;
|
|
54388
54465
|
let force = argv.force;
|
|
@@ -54394,8 +54471,8 @@ async function handleLaunch(argv) {
|
|
|
54394
54471
|
console.error(guard.reason ?? "");
|
|
54395
54472
|
const readline10 = await import("readline");
|
|
54396
54473
|
const rl = readline10.createInterface({ input: process.stdin, output: process.stderr });
|
|
54397
|
-
const answer = await new Promise((
|
|
54398
|
-
rl.question("Replace this slot? [y/N] ",
|
|
54474
|
+
const answer = await new Promise((resolve41) => {
|
|
54475
|
+
rl.question("Replace this slot? [y/N] ", resolve41);
|
|
54399
54476
|
});
|
|
54400
54477
|
rl.close();
|
|
54401
54478
|
if (!/^[Yy]$/.test(answer.trim())) {
|
|
@@ -54411,8 +54488,8 @@ async function handleLaunch(argv) {
|
|
|
54411
54488
|
warn("Worktree has uncommitted changes.");
|
|
54412
54489
|
const readline10 = await import("readline");
|
|
54413
54490
|
const rl = readline10.createInterface({ input: process.stdin, output: process.stderr });
|
|
54414
|
-
const answer = await new Promise((
|
|
54415
|
-
rl.question("Discard uncommitted changes? [y/N] ",
|
|
54491
|
+
const answer = await new Promise((resolve41) => {
|
|
54492
|
+
rl.question("Discard uncommitted changes? [y/N] ", resolve41);
|
|
54416
54493
|
});
|
|
54417
54494
|
rl.close();
|
|
54418
54495
|
if (!/^[Yy]$/.test(answer.trim())) {
|
|
@@ -54476,7 +54553,7 @@ async function handleRecover(argv) {
|
|
|
54476
54553
|
});
|
|
54477
54554
|
}
|
|
54478
54555
|
async function handleVerify(argv) {
|
|
54479
|
-
const repo =
|
|
54556
|
+
const repo = path49.resolve(argv.repo);
|
|
54480
54557
|
const agentId = validateAgentId(argv.id, repo);
|
|
54481
54558
|
const result = await runVerification({
|
|
54482
54559
|
repoPath: repo,
|
|
@@ -54488,7 +54565,7 @@ async function handleVerify(argv) {
|
|
|
54488
54565
|
process.exit(result.code);
|
|
54489
54566
|
}
|
|
54490
54567
|
async function handleTeardown(argv) {
|
|
54491
|
-
const repo =
|
|
54568
|
+
const repo = path49.resolve(argv.repo);
|
|
54492
54569
|
const agentId = validateAgentId(argv.id, repo);
|
|
54493
54570
|
const result = await teardownEnvironment({
|
|
54494
54571
|
repoPath: repo,
|
|
@@ -54499,7 +54576,7 @@ async function handleTeardown(argv) {
|
|
|
54499
54576
|
process.exit(result.code);
|
|
54500
54577
|
}
|
|
54501
54578
|
async function handleComplete(argv) {
|
|
54502
|
-
const repo =
|
|
54579
|
+
const repo = path49.resolve(argv.repo);
|
|
54503
54580
|
const agentId = validateAgentId(argv.id, repo);
|
|
54504
54581
|
const result = await completeEnvironment({
|
|
54505
54582
|
repoPath: repo,
|
|
@@ -54520,7 +54597,7 @@ async function handleComplete(argv) {
|
|
|
54520
54597
|
process.exit(result.code);
|
|
54521
54598
|
}
|
|
54522
54599
|
async function handleStatus(argv) {
|
|
54523
|
-
const repoPath =
|
|
54600
|
+
const repoPath = path49.resolve(argv.repo);
|
|
54524
54601
|
if (argv.json) {
|
|
54525
54602
|
const status = collectEnvironmentStatus(repoPath);
|
|
54526
54603
|
const output = EnvironmentStatusSchema.parse(status);
|
|
@@ -54533,7 +54610,7 @@ async function handleStatus(argv) {
|
|
|
54533
54610
|
});
|
|
54534
54611
|
}
|
|
54535
54612
|
async function handleRunsList(argv) {
|
|
54536
|
-
const repoPath =
|
|
54613
|
+
const repoPath = path49.resolve(argv.repo);
|
|
54537
54614
|
const runs = listRuns(repoPath, { stageId: argv.stage, limit: argv.limit });
|
|
54538
54615
|
if (argv.json) {
|
|
54539
54616
|
process.stdout.write(JSON.stringify({ runs }, null, 2) + "\n");
|
|
@@ -54550,7 +54627,7 @@ async function handleRunsList(argv) {
|
|
|
54550
54627
|
}
|
|
54551
54628
|
}
|
|
54552
54629
|
async function handleRunsGet(argv) {
|
|
54553
|
-
const run2 = getRun(
|
|
54630
|
+
const run2 = getRun(path49.resolve(argv.repo), argv.runId);
|
|
54554
54631
|
if (!run2) {
|
|
54555
54632
|
error(`Run not found: ${argv.runId}`);
|
|
54556
54633
|
process.exit(1);
|
|
@@ -54629,7 +54706,7 @@ function printNextSteps(auto2) {
|
|
|
54629
54706
|
}
|
|
54630
54707
|
|
|
54631
54708
|
// src/cli/commands/control.ts
|
|
54632
|
-
var
|
|
54709
|
+
var path52 = __toESM(require("path"));
|
|
54633
54710
|
|
|
54634
54711
|
// node_modules/@inquirer/core/dist/esm/lib/key.mjs
|
|
54635
54712
|
var isUpKey = (key) => (
|
|
@@ -55649,13 +55726,13 @@ var PromisePolyfill = class extends Promise {
|
|
|
55649
55726
|
// Available starting from Node 22
|
|
55650
55727
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/withResolvers
|
|
55651
55728
|
static withResolver() {
|
|
55652
|
-
let
|
|
55729
|
+
let resolve41;
|
|
55653
55730
|
let reject;
|
|
55654
55731
|
const promise = new Promise((res, rej) => {
|
|
55655
|
-
|
|
55732
|
+
resolve41 = res;
|
|
55656
55733
|
reject = rej;
|
|
55657
55734
|
});
|
|
55658
|
-
return { promise, resolve:
|
|
55735
|
+
return { promise, resolve: resolve41, reject };
|
|
55659
55736
|
}
|
|
55660
55737
|
};
|
|
55661
55738
|
|
|
@@ -55672,7 +55749,7 @@ function createPrompt(view) {
|
|
|
55672
55749
|
output
|
|
55673
55750
|
});
|
|
55674
55751
|
const screen = new ScreenManager(rl);
|
|
55675
|
-
const { promise, resolve:
|
|
55752
|
+
const { promise, resolve: resolve41, reject } = PromisePolyfill.withResolver();
|
|
55676
55753
|
const cancel = () => reject(new CancelPromptError());
|
|
55677
55754
|
if (signal) {
|
|
55678
55755
|
const abort = () => reject(new AbortPromptError({ cause: signal.reason }));
|
|
@@ -55696,7 +55773,7 @@ function createPrompt(view) {
|
|
|
55696
55773
|
cycle(() => {
|
|
55697
55774
|
try {
|
|
55698
55775
|
const nextView = view(config2, (value) => {
|
|
55699
|
-
setImmediate(() =>
|
|
55776
|
+
setImmediate(() => resolve41(value));
|
|
55700
55777
|
});
|
|
55701
55778
|
const [content, bottomContent] = typeof nextView === "string" ? [nextView] : nextView;
|
|
55702
55779
|
screen.render(content, bottomContent);
|
|
@@ -56683,9 +56760,9 @@ var import_run_async = __toESM(require_run_async(), 1);
|
|
|
56683
56760
|
var import_mute_stream2 = __toESM(require_lib3(), 1);
|
|
56684
56761
|
var import_ansi_escapes5 = __toESM(require_ansi_escapes(), 1);
|
|
56685
56762
|
var _2 = {
|
|
56686
|
-
set: (obj,
|
|
56763
|
+
set: (obj, path57 = "", value) => {
|
|
56687
56764
|
let pointer = obj;
|
|
56688
|
-
|
|
56765
|
+
path57.split(".").forEach((key, index, arr) => {
|
|
56689
56766
|
if (key === "__proto__" || key === "constructor")
|
|
56690
56767
|
return;
|
|
56691
56768
|
if (index === arr.length - 1) {
|
|
@@ -56696,8 +56773,8 @@ var _2 = {
|
|
|
56696
56773
|
pointer = pointer[key];
|
|
56697
56774
|
});
|
|
56698
56775
|
},
|
|
56699
|
-
get: (obj,
|
|
56700
|
-
const travel = (regexp) => String.prototype.split.call(
|
|
56776
|
+
get: (obj, path57 = "", defaultValue) => {
|
|
56777
|
+
const travel = (regexp) => String.prototype.split.call(path57, regexp).filter(Boolean).reduce(
|
|
56701
56778
|
// @ts-expect-error implicit any on res[key]
|
|
56702
56779
|
(res, key) => res !== null && res !== void 0 ? res[key] : res,
|
|
56703
56780
|
obj
|
|
@@ -56811,7 +56888,7 @@ var PromptsRunner = class {
|
|
|
56811
56888
|
throw new Error(`Prompt for type ${question.type} not found`);
|
|
56812
56889
|
}
|
|
56813
56890
|
let cleanupSignal;
|
|
56814
|
-
const promptFn = isPromptConstructor(prompt2) ? (q2, { signal: signal2 } = {}) => new Promise((
|
|
56891
|
+
const promptFn = isPromptConstructor(prompt2) ? (q2, { signal: signal2 } = {}) => new Promise((resolve41, reject) => {
|
|
56815
56892
|
const rl = import_node_readline.default.createInterface(setupReadlineOptions(this.opt));
|
|
56816
56893
|
rl.resume();
|
|
56817
56894
|
const onClose = () => {
|
|
@@ -56847,7 +56924,7 @@ var PromptsRunner = class {
|
|
|
56847
56924
|
cleanupSignal = void 0;
|
|
56848
56925
|
};
|
|
56849
56926
|
}
|
|
56850
|
-
activePrompt.run().then(
|
|
56927
|
+
activePrompt.run().then(resolve41, reject).finally(cleanup);
|
|
56851
56928
|
}) : prompt2;
|
|
56852
56929
|
const { signal: moduleSignal } = this.opt;
|
|
56853
56930
|
if (moduleSignal?.aborted) {
|
|
@@ -56949,20 +57026,20 @@ var esm_default13 = inquirer;
|
|
|
56949
57026
|
init_control_config();
|
|
56950
57027
|
|
|
56951
57028
|
// src/core/control-sync-selection.ts
|
|
56952
|
-
var
|
|
56953
|
-
var
|
|
56954
|
-
var
|
|
57029
|
+
var fs45 = __toESM(require("fs"));
|
|
57030
|
+
var os17 = __toESM(require("os"));
|
|
57031
|
+
var path50 = __toESM(require("path"));
|
|
56955
57032
|
function getSelectionPath() {
|
|
56956
57033
|
if (process.env.HAR_CONTROL_SYNC_SELECTION_PATH) {
|
|
56957
|
-
return
|
|
57034
|
+
return path50.resolve(process.env.HAR_CONTROL_SYNC_SELECTION_PATH);
|
|
56958
57035
|
}
|
|
56959
|
-
return
|
|
57036
|
+
return path50.join(os17.homedir(), ".har", "sync-selection.json");
|
|
56960
57037
|
}
|
|
56961
57038
|
function readSyncSelection() {
|
|
56962
57039
|
const selectionPath = getSelectionPath();
|
|
56963
57040
|
try {
|
|
56964
|
-
if (!
|
|
56965
|
-
const parsed = JSON.parse(
|
|
57041
|
+
if (!fs45.existsSync(selectionPath)) return null;
|
|
57042
|
+
const parsed = JSON.parse(fs45.readFileSync(selectionPath, "utf8"));
|
|
56966
57043
|
if (!Array.isArray(parsed.repos)) return null;
|
|
56967
57044
|
return parsed.repos.map((repoPath) => canonicalizeControlRepoPath(repoPath));
|
|
56968
57045
|
} catch {
|
|
@@ -56972,8 +57049,8 @@ function readSyncSelection() {
|
|
|
56972
57049
|
function writeSyncSelection(repos) {
|
|
56973
57050
|
const selectionPath = getSelectionPath();
|
|
56974
57051
|
const canonical = Array.from(new Set(repos.map((repoPath) => canonicalizeControlRepoPath(repoPath))));
|
|
56975
|
-
|
|
56976
|
-
|
|
57052
|
+
fs45.mkdirSync(path50.dirname(selectionPath), { recursive: true });
|
|
57053
|
+
fs45.writeFileSync(selectionPath, JSON.stringify({ repos: canonical }, null, 2) + "\n");
|
|
56977
57054
|
}
|
|
56978
57055
|
function resolveSyncSelection(input) {
|
|
56979
57056
|
const { discovered, stored, forceSelect, isTTY } = input;
|
|
@@ -57020,7 +57097,7 @@ function openBrowser(url) {
|
|
|
57020
57097
|
}
|
|
57021
57098
|
async function loginViaBrowser(portalUrl, openUrl = openBrowser) {
|
|
57022
57099
|
const state = (0, import_crypto.randomUUID)();
|
|
57023
|
-
return new Promise((
|
|
57100
|
+
return new Promise((resolve41, reject) => {
|
|
57024
57101
|
let timer;
|
|
57025
57102
|
const server = http.createServer((req, res) => {
|
|
57026
57103
|
const requestUrl = new URL(req.url ?? "", "http://127.0.0.1");
|
|
@@ -57043,7 +57120,7 @@ async function loginViaBrowser(portalUrl, openUrl = openBrowser) {
|
|
|
57043
57120
|
res.writeHead(200, { "Content-Type": "text/html" });
|
|
57044
57121
|
res.end("<h1>Logged in</h1><p>You can close this tab and return to the terminal.</p>");
|
|
57045
57122
|
cleanup();
|
|
57046
|
-
|
|
57123
|
+
resolve41({ portalUrl, token, workspace, email: email2, createdAt: (/* @__PURE__ */ new Date()).toISOString() });
|
|
57047
57124
|
});
|
|
57048
57125
|
const cleanup = () => {
|
|
57049
57126
|
clearTimeout(timer);
|
|
@@ -57070,16 +57147,16 @@ If your browser did not open, paste that URL.
|
|
|
57070
57147
|
}
|
|
57071
57148
|
|
|
57072
57149
|
// src/core/control-unregister.ts
|
|
57073
|
-
var
|
|
57074
|
-
var
|
|
57150
|
+
var fs46 = __toESM(require("fs"));
|
|
57151
|
+
var path51 = __toESM(require("path"));
|
|
57075
57152
|
init_control_config();
|
|
57076
57153
|
function listUnregisterWorktreeCandidates(repoPath) {
|
|
57077
57154
|
const harnessRoot = canonicalizeControlRepoPath(repoPath);
|
|
57078
57155
|
const byPath = /* @__PURE__ */ new Map();
|
|
57079
57156
|
const add = (partial2) => {
|
|
57080
|
-
const resolved =
|
|
57157
|
+
const resolved = path51.resolve(partial2.worktreePath);
|
|
57081
57158
|
if (!resolved || resolved === harnessRoot) return;
|
|
57082
|
-
const exists = partial2.exists ??
|
|
57159
|
+
const exists = partial2.exists ?? fs46.existsSync(resolved);
|
|
57083
57160
|
const prev = byPath.get(resolved);
|
|
57084
57161
|
if (prev) {
|
|
57085
57162
|
byPath.set(resolved, {
|
|
@@ -57130,8 +57207,8 @@ async function askYesNo6(question) {
|
|
|
57130
57207
|
if (!process.stdin.isTTY || !process.stdout.isTTY) return false;
|
|
57131
57208
|
const readline10 = await import("readline");
|
|
57132
57209
|
const rl = readline10.createInterface({ input: process.stdin, output: process.stderr });
|
|
57133
|
-
const answer = await new Promise((
|
|
57134
|
-
rl.question(question,
|
|
57210
|
+
const answer = await new Promise((resolve41) => {
|
|
57211
|
+
rl.question(question, resolve41);
|
|
57135
57212
|
});
|
|
57136
57213
|
rl.close();
|
|
57137
57214
|
return /^[Yy]$/.test(answer.trim());
|
|
@@ -57193,28 +57270,28 @@ async function teardownWorktrees(repoPath, candidates, dryRun) {
|
|
|
57193
57270
|
trigger: "cli"
|
|
57194
57271
|
});
|
|
57195
57272
|
if (result.code !== 0) {
|
|
57196
|
-
if (
|
|
57197
|
-
|
|
57273
|
+
if (fs46.existsSync(candidate.worktreePath)) {
|
|
57274
|
+
fs46.rmSync(candidate.worktreePath, { recursive: true, force: true });
|
|
57198
57275
|
}
|
|
57199
57276
|
}
|
|
57200
57277
|
outcomes.push({
|
|
57201
57278
|
path: candidate.worktreePath,
|
|
57202
57279
|
agentId: candidate.agentId,
|
|
57203
|
-
deleted: !
|
|
57204
|
-
error: result.code !== 0 &&
|
|
57280
|
+
deleted: !fs46.existsSync(candidate.worktreePath),
|
|
57281
|
+
error: result.code !== 0 && fs46.existsSync(candidate.worktreePath) ? result.stderr : void 0
|
|
57205
57282
|
});
|
|
57206
57283
|
} catch (err) {
|
|
57207
57284
|
const message = err instanceof Error ? err.message : String(err);
|
|
57208
57285
|
try {
|
|
57209
|
-
if (
|
|
57210
|
-
|
|
57286
|
+
if (fs46.existsSync(candidate.worktreePath)) {
|
|
57287
|
+
fs46.rmSync(candidate.worktreePath, { recursive: true, force: true });
|
|
57211
57288
|
}
|
|
57212
57289
|
} catch {
|
|
57213
57290
|
}
|
|
57214
57291
|
outcomes.push({
|
|
57215
57292
|
path: candidate.worktreePath,
|
|
57216
57293
|
agentId: candidate.agentId,
|
|
57217
|
-
deleted: !
|
|
57294
|
+
deleted: !fs46.existsSync(candidate.worktreePath),
|
|
57218
57295
|
error: message
|
|
57219
57296
|
});
|
|
57220
57297
|
}
|
|
@@ -57325,6 +57402,10 @@ var controlCommand = {
|
|
|
57325
57402
|
type: "boolean",
|
|
57326
57403
|
default: false,
|
|
57327
57404
|
describe: "Sync to HAR Cloud instead of local Mission Control"
|
|
57405
|
+
}).option("full", {
|
|
57406
|
+
type: "boolean",
|
|
57407
|
+
default: false,
|
|
57408
|
+
describe: "Ignore the portal watermark and resend the complete payload"
|
|
57328
57409
|
}),
|
|
57329
57410
|
handleSync
|
|
57330
57411
|
).command(
|
|
@@ -57403,7 +57484,7 @@ async function handleDown() {
|
|
|
57403
57484
|
process.exit(code);
|
|
57404
57485
|
}
|
|
57405
57486
|
async function handleRegister(argv) {
|
|
57406
|
-
const repoPath =
|
|
57487
|
+
const repoPath = path52.resolve(argv.repo);
|
|
57407
57488
|
header("har control register");
|
|
57408
57489
|
info(`Repository: ${repoPath}`);
|
|
57409
57490
|
try {
|
|
@@ -57427,7 +57508,7 @@ async function handleRegister(argv) {
|
|
|
57427
57508
|
}
|
|
57428
57509
|
}
|
|
57429
57510
|
async function handleUnregister(argv) {
|
|
57430
|
-
const repoPath =
|
|
57511
|
+
const repoPath = path52.resolve(argv.repo);
|
|
57431
57512
|
const worktrees = listUnregisterWorktreeCandidates(repoPath);
|
|
57432
57513
|
try {
|
|
57433
57514
|
let deleteWorktrees = argv.deleteWorktrees;
|
|
@@ -57551,7 +57632,8 @@ async function handleSync(argv) {
|
|
|
57551
57632
|
repoPaths,
|
|
57552
57633
|
apiUrl: argv.apiUrl,
|
|
57553
57634
|
dryRun: argv.dryRun,
|
|
57554
|
-
cloud: argv.cloud
|
|
57635
|
+
cloud: argv.cloud,
|
|
57636
|
+
full: argv.full
|
|
57555
57637
|
});
|
|
57556
57638
|
if (argv.json) {
|
|
57557
57639
|
process.stdout.write(JSON.stringify({ ok: failed === 0, synced, failed, results }, null, 2) + "\n");
|
|
@@ -57587,7 +57669,7 @@ async function handleWatch(argv) {
|
|
|
57587
57669
|
};
|
|
57588
57670
|
const tick = async () => {
|
|
57589
57671
|
if (argv.repo) {
|
|
57590
|
-
await syncOne(
|
|
57672
|
+
await syncOne(path52.resolve(argv.repo));
|
|
57591
57673
|
return;
|
|
57592
57674
|
}
|
|
57593
57675
|
try {
|
|
@@ -57637,11 +57719,11 @@ async function handleLogin(argv) {
|
|
|
57637
57719
|
}
|
|
57638
57720
|
|
|
57639
57721
|
// src/cli/commands/hooks.ts
|
|
57640
|
-
var
|
|
57722
|
+
var path54 = __toESM(require("path"));
|
|
57641
57723
|
|
|
57642
57724
|
// src/core/claude-hooks.ts
|
|
57643
|
-
var
|
|
57644
|
-
var
|
|
57725
|
+
var fs47 = __toESM(require("fs"));
|
|
57726
|
+
var path53 = __toESM(require("path"));
|
|
57645
57727
|
var CLAUDE_GUARD_RELATIVE_PATH = ".har/hooks/claude-worktree-guard.sh";
|
|
57646
57728
|
var CLAUDE_SETTINGS_RELATIVE_PATH = ".claude/settings.json";
|
|
57647
57729
|
var GUARD_MATCHER = "Edit|Write|MultiEdit|NotebookEdit";
|
|
@@ -57652,8 +57734,8 @@ function isHarGuardEntry(entry) {
|
|
|
57652
57734
|
);
|
|
57653
57735
|
}
|
|
57654
57736
|
function readSettings(settingsPath) {
|
|
57655
|
-
if (!
|
|
57656
|
-
const raw =
|
|
57737
|
+
if (!fs47.existsSync(settingsPath)) return {};
|
|
57738
|
+
const raw = fs47.readFileSync(settingsPath, "utf8").trim();
|
|
57657
57739
|
if (raw === "") return {};
|
|
57658
57740
|
const parsed = JSON.parse(raw);
|
|
57659
57741
|
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
@@ -57662,19 +57744,19 @@ function readSettings(settingsPath) {
|
|
|
57662
57744
|
return parsed;
|
|
57663
57745
|
}
|
|
57664
57746
|
function writeSettings(settingsPath, settings) {
|
|
57665
|
-
|
|
57666
|
-
|
|
57747
|
+
fs47.mkdirSync(path53.dirname(settingsPath), { recursive: true });
|
|
57748
|
+
fs47.writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + "\n");
|
|
57667
57749
|
}
|
|
57668
57750
|
function installClaudeGuard(repoPath) {
|
|
57669
57751
|
const templatePath = resolveTemplateFile("claude-worktree-guard.sh.template");
|
|
57670
57752
|
if (!templatePath) {
|
|
57671
57753
|
throw new Error("Guard template not found (claude-worktree-guard.sh.template). Run npm run build.");
|
|
57672
57754
|
}
|
|
57673
|
-
const guardScript =
|
|
57674
|
-
|
|
57675
|
-
|
|
57676
|
-
|
|
57677
|
-
const settingsPath =
|
|
57755
|
+
const guardScript = path53.join(repoPath, CLAUDE_GUARD_RELATIVE_PATH);
|
|
57756
|
+
fs47.mkdirSync(path53.dirname(guardScript), { recursive: true });
|
|
57757
|
+
fs47.copyFileSync(templatePath, guardScript);
|
|
57758
|
+
fs47.chmodSync(guardScript, 493);
|
|
57759
|
+
const settingsPath = path53.join(repoPath, CLAUDE_SETTINGS_RELATIVE_PATH);
|
|
57678
57760
|
const settings = readSettings(settingsPath);
|
|
57679
57761
|
const hooks = settings.hooks ?? {};
|
|
57680
57762
|
const preToolUse = (hooks.PreToolUse ?? []).filter((entry) => !isHarGuardEntry(entry));
|
|
@@ -57688,15 +57770,15 @@ function installClaudeGuard(repoPath) {
|
|
|
57688
57770
|
}
|
|
57689
57771
|
function uninstallClaudeGuard(repoPath) {
|
|
57690
57772
|
let removed = false;
|
|
57691
|
-
const guardScript =
|
|
57692
|
-
if (
|
|
57693
|
-
|
|
57773
|
+
const guardScript = path53.join(repoPath, CLAUDE_GUARD_RELATIVE_PATH);
|
|
57774
|
+
if (fs47.existsSync(guardScript)) {
|
|
57775
|
+
fs47.rmSync(guardScript);
|
|
57694
57776
|
removed = true;
|
|
57695
|
-
const parent =
|
|
57696
|
-
if (
|
|
57777
|
+
const parent = path53.dirname(guardScript);
|
|
57778
|
+
if (fs47.existsSync(parent) && fs47.readdirSync(parent).length === 0) fs47.rmdirSync(parent);
|
|
57697
57779
|
}
|
|
57698
|
-
const settingsPath =
|
|
57699
|
-
if (
|
|
57780
|
+
const settingsPath = path53.join(repoPath, CLAUDE_SETTINGS_RELATIVE_PATH);
|
|
57781
|
+
if (fs47.existsSync(settingsPath)) {
|
|
57700
57782
|
const settings = readSettings(settingsPath);
|
|
57701
57783
|
const preToolUse = settings.hooks?.PreToolUse;
|
|
57702
57784
|
if (preToolUse) {
|
|
@@ -57721,8 +57803,8 @@ function uninstallClaudeGuard(repoPath) {
|
|
|
57721
57803
|
return { removed };
|
|
57722
57804
|
}
|
|
57723
57805
|
function claudeGuardInstalled(repoPath) {
|
|
57724
|
-
const settingsPath =
|
|
57725
|
-
if (!
|
|
57806
|
+
const settingsPath = path53.join(repoPath, CLAUDE_SETTINGS_RELATIVE_PATH);
|
|
57807
|
+
if (!fs47.existsSync(settingsPath)) return false;
|
|
57726
57808
|
try {
|
|
57727
57809
|
const settings = readSettings(settingsPath);
|
|
57728
57810
|
return (settings.hooks?.PreToolUse ?? []).some(isHarGuardEntry);
|
|
@@ -57738,7 +57820,7 @@ function repoOption(y2) {
|
|
|
57738
57820
|
function handleInstall2(argv) {
|
|
57739
57821
|
try {
|
|
57740
57822
|
if (argv.claude) {
|
|
57741
|
-
const result2 = installClaudeGuard(
|
|
57823
|
+
const result2 = installClaudeGuard(path54.resolve(argv.repo));
|
|
57742
57824
|
success("Claude Code worktree guard installed.");
|
|
57743
57825
|
info(`Guard script: ${result2.guardScript}`);
|
|
57744
57826
|
info(`Settings: ${result2.settingsPath} (PreToolUse: Edit|Write|MultiEdit|NotebookEdit)`);
|
|
@@ -57746,7 +57828,7 @@ function handleInstall2(argv) {
|
|
|
57746
57828
|
info("Commit both files so the guard travels with the repo.");
|
|
57747
57829
|
return;
|
|
57748
57830
|
}
|
|
57749
|
-
const result = installHooks({ repoPath:
|
|
57831
|
+
const result = installHooks({ repoPath: path54.resolve(argv.repo), force: argv.force });
|
|
57750
57832
|
success(`Commit gate installed in ${result.hooksDir}`);
|
|
57751
57833
|
info(`pre-commit: ${result.preCommit}, post-commit: ${result.postCommit}`);
|
|
57752
57834
|
info("Commits of unverified change batches will be blocked in agent worktrees.");
|
|
@@ -57759,7 +57841,7 @@ function handleInstall2(argv) {
|
|
|
57759
57841
|
function handleUninstall(argv) {
|
|
57760
57842
|
try {
|
|
57761
57843
|
if (argv.claude) {
|
|
57762
|
-
const result2 = uninstallClaudeGuard(
|
|
57844
|
+
const result2 = uninstallClaudeGuard(path54.resolve(argv.repo));
|
|
57763
57845
|
if (result2.removed) {
|
|
57764
57846
|
success("Claude Code worktree guard removed.");
|
|
57765
57847
|
} else {
|
|
@@ -57767,7 +57849,7 @@ function handleUninstall(argv) {
|
|
|
57767
57849
|
}
|
|
57768
57850
|
return;
|
|
57769
57851
|
}
|
|
57770
|
-
const result = uninstallHooks(
|
|
57852
|
+
const result = uninstallHooks(path54.resolve(argv.repo));
|
|
57771
57853
|
if (result.removed) {
|
|
57772
57854
|
success(`Commit gate removed from ${result.hooksDir}`);
|
|
57773
57855
|
} else {
|
|
@@ -57780,7 +57862,7 @@ function handleUninstall(argv) {
|
|
|
57780
57862
|
}
|
|
57781
57863
|
function handleStatus2(argv) {
|
|
57782
57864
|
try {
|
|
57783
|
-
const status = getHooksStatus(
|
|
57865
|
+
const status = getHooksStatus(path54.resolve(argv.repo));
|
|
57784
57866
|
if (argv.json) {
|
|
57785
57867
|
process.stdout.write(`${JSON.stringify(status, null, 2)}
|
|
57786
57868
|
`);
|
|
@@ -57798,7 +57880,7 @@ function handleStatus2(argv) {
|
|
|
57798
57880
|
);
|
|
57799
57881
|
info(`Effective: ${status.effectiveMode} (in this checkout)`);
|
|
57800
57882
|
info(
|
|
57801
|
-
`Claude guard: ${claudeGuardInstalled(
|
|
57883
|
+
`Claude guard: ${claudeGuardInstalled(path54.resolve(argv.repo)) ? `installed (${CLAUDE_GUARD_RELATIVE_PATH})` : "not installed"}`
|
|
57802
57884
|
);
|
|
57803
57885
|
} catch (err) {
|
|
57804
57886
|
error(err instanceof Error ? err.message : String(err));
|
|
@@ -58059,10 +58141,10 @@ function assignProp(target, prop, value) {
|
|
|
58059
58141
|
configurable: true
|
|
58060
58142
|
});
|
|
58061
58143
|
}
|
|
58062
|
-
function getElementAtPath(obj,
|
|
58063
|
-
if (!
|
|
58144
|
+
function getElementAtPath(obj, path57) {
|
|
58145
|
+
if (!path57)
|
|
58064
58146
|
return obj;
|
|
58065
|
-
return
|
|
58147
|
+
return path57.reduce((acc, key) => acc?.[key], obj);
|
|
58066
58148
|
}
|
|
58067
58149
|
function promiseAllObject(promisesObj) {
|
|
58068
58150
|
const keys = Object.keys(promisesObj);
|
|
@@ -58382,11 +58464,11 @@ function aborted(x2, startIndex = 0) {
|
|
|
58382
58464
|
}
|
|
58383
58465
|
return false;
|
|
58384
58466
|
}
|
|
58385
|
-
function prefixIssues(
|
|
58467
|
+
function prefixIssues(path57, issues) {
|
|
58386
58468
|
return issues.map((iss) => {
|
|
58387
58469
|
var _a3;
|
|
58388
58470
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
58389
|
-
iss.path.unshift(
|
|
58471
|
+
iss.path.unshift(path57);
|
|
58390
58472
|
return iss;
|
|
58391
58473
|
});
|
|
58392
58474
|
}
|
|
@@ -63709,7 +63791,7 @@ var Protocol = class {
|
|
|
63709
63791
|
return;
|
|
63710
63792
|
}
|
|
63711
63793
|
const pollInterval = task2.pollInterval ?? this._options?.defaultTaskPollInterval ?? 1e3;
|
|
63712
|
-
await new Promise((
|
|
63794
|
+
await new Promise((resolve41) => setTimeout(resolve41, pollInterval));
|
|
63713
63795
|
options?.signal?.throwIfAborted();
|
|
63714
63796
|
}
|
|
63715
63797
|
} catch (error3) {
|
|
@@ -63726,7 +63808,7 @@ var Protocol = class {
|
|
|
63726
63808
|
*/
|
|
63727
63809
|
request(request, resultSchema, options) {
|
|
63728
63810
|
const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
|
|
63729
|
-
return new Promise((
|
|
63811
|
+
return new Promise((resolve41, reject) => {
|
|
63730
63812
|
const earlyReject = (error3) => {
|
|
63731
63813
|
reject(error3);
|
|
63732
63814
|
};
|
|
@@ -63804,7 +63886,7 @@ var Protocol = class {
|
|
|
63804
63886
|
if (!parseResult.success) {
|
|
63805
63887
|
reject(parseResult.error);
|
|
63806
63888
|
} else {
|
|
63807
|
-
|
|
63889
|
+
resolve41(parseResult.data);
|
|
63808
63890
|
}
|
|
63809
63891
|
} catch (error3) {
|
|
63810
63892
|
reject(error3);
|
|
@@ -64065,12 +64147,12 @@ var Protocol = class {
|
|
|
64065
64147
|
}
|
|
64066
64148
|
} catch {
|
|
64067
64149
|
}
|
|
64068
|
-
return new Promise((
|
|
64150
|
+
return new Promise((resolve41, reject) => {
|
|
64069
64151
|
if (signal.aborted) {
|
|
64070
64152
|
reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
64071
64153
|
return;
|
|
64072
64154
|
}
|
|
64073
|
-
const timeoutId = setTimeout(
|
|
64155
|
+
const timeoutId = setTimeout(resolve41, interval);
|
|
64074
64156
|
signal.addEventListener("abort", () => {
|
|
64075
64157
|
clearTimeout(timeoutId);
|
|
64076
64158
|
reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
@@ -64860,7 +64942,7 @@ var Server = class extends Protocol {
|
|
|
64860
64942
|
};
|
|
64861
64943
|
|
|
64862
64944
|
// src/mcp/server.ts
|
|
64863
|
-
var
|
|
64945
|
+
var path55 = __toESM(require("path"));
|
|
64864
64946
|
|
|
64865
64947
|
// node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
|
|
64866
64948
|
var import_node_process3 = __toESM(require("node:process"), 1);
|
|
@@ -64943,12 +65025,12 @@ var StdioServerTransport = class {
|
|
|
64943
65025
|
this.onclose?.();
|
|
64944
65026
|
}
|
|
64945
65027
|
send(message) {
|
|
64946
|
-
return new Promise((
|
|
65028
|
+
return new Promise((resolve41) => {
|
|
64947
65029
|
const json = serializeMessage(message);
|
|
64948
65030
|
if (this._stdout.write(json)) {
|
|
64949
|
-
|
|
65031
|
+
resolve41();
|
|
64950
65032
|
} else {
|
|
64951
|
-
this._stdout.once("drain",
|
|
65033
|
+
this._stdout.once("drain", resolve41);
|
|
64952
65034
|
}
|
|
64953
65035
|
});
|
|
64954
65036
|
}
|
|
@@ -65523,7 +65605,7 @@ async function handleMcpToolCall(toolName, args, defaultRepo = ".") {
|
|
|
65523
65605
|
const input = ControlUpInputSchema.parse({ ...args, repo });
|
|
65524
65606
|
const result = await startControlAndSync({
|
|
65525
65607
|
detach: input.detach,
|
|
65526
|
-
cwd:
|
|
65608
|
+
cwd: path55.resolve(input.repo)
|
|
65527
65609
|
});
|
|
65528
65610
|
if (result.code !== 0) {
|
|
65529
65611
|
return {
|
|
@@ -65702,7 +65784,7 @@ var preferencesCommand = {
|
|
|
65702
65784
|
};
|
|
65703
65785
|
|
|
65704
65786
|
// src/cli/commands/telemetry.ts
|
|
65705
|
-
var
|
|
65787
|
+
var path56 = __toESM(require("path"));
|
|
65706
65788
|
init_control_config();
|
|
65707
65789
|
init_otel_hooks();
|
|
65708
65790
|
init_telemetry_config();
|
|
@@ -65789,7 +65871,7 @@ async function handleOff() {
|
|
|
65789
65871
|
info("Mission Control will not auto-start. Existing usage rows are kept.");
|
|
65790
65872
|
}
|
|
65791
65873
|
async function handleWriteEnv(argv) {
|
|
65792
|
-
const repoPath =
|
|
65874
|
+
const repoPath = path56.resolve(argv.repo);
|
|
65793
65875
|
const harnessRoot = resolveHarnessRoot(repoPath);
|
|
65794
65876
|
const session = readSlotRegistry(harnessRoot, argv.agentId);
|
|
65795
65877
|
const workDir = argv.workDir ?? session?.workDir ?? repoPath;
|
|
@@ -65801,7 +65883,7 @@ async function handleWriteEnv(argv) {
|
|
|
65801
65883
|
suffix,
|
|
65802
65884
|
createdAt: session?.createdAt
|
|
65803
65885
|
});
|
|
65804
|
-
const envFile = argv.envFile ??
|
|
65886
|
+
const envFile = argv.envFile ?? path56.join(workDir, `.env.agent.${argv.agentId}`);
|
|
65805
65887
|
const attrs = {
|
|
65806
65888
|
sessionKey,
|
|
65807
65889
|
agentId: argv.agentId,
|
|
@@ -65820,7 +65902,7 @@ async function handleWriteEnv(argv) {
|
|
|
65820
65902
|
success(`Wrote session attribution to ${envFile}`);
|
|
65821
65903
|
}
|
|
65822
65904
|
function handlePrintEnv(argv) {
|
|
65823
|
-
const repoPath =
|
|
65905
|
+
const repoPath = path56.resolve(argv.repo);
|
|
65824
65906
|
const workDir = argv.workDir ?? repoPath;
|
|
65825
65907
|
const sessionKey = buildSessionKey({
|
|
65826
65908
|
branch: argv.branch,
|