@osfactory/har 1.15.0 → 1.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +58 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -40502,12 +40502,11 @@ function listPm2Processes() {
|
|
|
40502
40502
|
return void 0;
|
|
40503
40503
|
}
|
|
40504
40504
|
}
|
|
40505
|
-
function detectForeignPm2(
|
|
40505
|
+
function detectForeignPm2(_projectName, agentId, procs) {
|
|
40506
40506
|
if (!procs) return void 0;
|
|
40507
|
-
const slotPrefix = `har-${projectName}-agent-${agentId}-`;
|
|
40508
40507
|
const legacyPrefix = `agent-${agentId}-`;
|
|
40509
40508
|
const foreign = procs.filter(
|
|
40510
|
-
(p) => p.name &&
|
|
40509
|
+
(p) => p.name && p.name.startsWith(legacyPrefix) && !p.name.startsWith("har-")
|
|
40511
40510
|
);
|
|
40512
40511
|
if (foreign.length === 0) return void 0;
|
|
40513
40512
|
return {
|
|
@@ -40517,6 +40516,48 @@ function detectForeignPm2(projectName, agentId, procs) {
|
|
|
40517
40516
|
}))
|
|
40518
40517
|
};
|
|
40519
40518
|
}
|
|
40519
|
+
function freeAgentSlots(harnessRoot, projectName, agentId, procs) {
|
|
40520
|
+
let ids = [];
|
|
40521
|
+
let range;
|
|
40522
|
+
try {
|
|
40523
|
+
range = getAgentSlotRange(harnessRoot);
|
|
40524
|
+
ids = getAgentSlotIds(harnessRoot);
|
|
40525
|
+
} catch {
|
|
40526
|
+
return { free: [] };
|
|
40527
|
+
}
|
|
40528
|
+
const free = ids.filter((id) => {
|
|
40529
|
+
if (id === agentId) return false;
|
|
40530
|
+
const session = readSlotRegistry(harnessRoot, id);
|
|
40531
|
+
if (session !== void 0 && session.status !== "completed") return false;
|
|
40532
|
+
return detectForeignPm2(projectName, id, procs) === void 0;
|
|
40533
|
+
});
|
|
40534
|
+
return { free, range };
|
|
40535
|
+
}
|
|
40536
|
+
function foreignPm2Advice(agentId, processes, free, range) {
|
|
40537
|
+
const cwds = [
|
|
40538
|
+
...new Set(processes.map((p) => p.cwd).filter((cwd) => Boolean(cwd)))
|
|
40539
|
+
];
|
|
40540
|
+
const rangeLabel = range ? `agentSlots ${range.min}\u2013${range.max}` : "agentSlots in .har/stages.json";
|
|
40541
|
+
const higher = free.filter((id) => id > agentId);
|
|
40542
|
+
const suggested = higher[0] ?? free[0];
|
|
40543
|
+
const lines = [];
|
|
40544
|
+
if (suggested !== void 0) {
|
|
40545
|
+
const kind = higher.length > 0 ? "higher slot" : "slot";
|
|
40546
|
+
lines.push(
|
|
40547
|
+
`Use a free ${kind}: har env launch ${suggested} (free: ${free.join(", ")}; ${rangeLabel}).`
|
|
40548
|
+
);
|
|
40549
|
+
} else if (range) {
|
|
40550
|
+
lines.push(`No free slot in ${rangeLabel}. Raise agentSlots.max in .har/stages.json.`);
|
|
40551
|
+
} else {
|
|
40552
|
+
lines.push("Use a different agent slot (see agentSlots in .har/stages.json).");
|
|
40553
|
+
}
|
|
40554
|
+
lines.push(
|
|
40555
|
+
"These processes belong to another project and must not be deleted from this checkout."
|
|
40556
|
+
);
|
|
40557
|
+
const where = cwds.length === 0 ? "that project checkout (cwd unknown)" : cwds.join(", ");
|
|
40558
|
+
lines.push(`To stop that other session, run \`har env teardown ${agentId}\` in ${where}.`);
|
|
40559
|
+
return { lines, suggested };
|
|
40560
|
+
}
|
|
40520
40561
|
function infraEnabled2(env3, service) {
|
|
40521
40562
|
return ` ${env3.HARNESS_INFRA_SERVICES ?? ""} `.includes(` ${service} `);
|
|
40522
40563
|
}
|
|
@@ -40570,12 +40611,17 @@ function inspectSlotReadiness(repoPath, agentId, options = {}) {
|
|
|
40570
40611
|
const foreign = usesPm2 ? detectForeignPm2(projectName, agentId, pm2Procs) : void 0;
|
|
40571
40612
|
if (foreign) {
|
|
40572
40613
|
const names = foreign.processes.map((p) => p.name).join(", ");
|
|
40614
|
+
const slots = freeAgentSlots(harnessRoot, projectName, agentId, pm2Procs);
|
|
40615
|
+
const advice = foreignPm2Advice(agentId, foreign.processes, slots.free, slots.range);
|
|
40573
40616
|
blockers.push({
|
|
40574
40617
|
code: "foreign_pm2",
|
|
40575
40618
|
message: `Foreign PM2 processes match agent ${agentId}: ${names}`,
|
|
40576
|
-
remediation: "
|
|
40577
|
-
details: { processes: foreign.processes }
|
|
40619
|
+
remediation: advice.lines.join(" "),
|
|
40620
|
+
details: { processes: foreign.processes, adviceLines: advice.lines }
|
|
40578
40621
|
});
|
|
40622
|
+
if (advice.suggested !== void 0) {
|
|
40623
|
+
remediations.push(`har env launch ${advice.suggested}`);
|
|
40624
|
+
}
|
|
40579
40625
|
remediations.push(`Inspect with: ${packageRunner()} pm2 jlist | grep agent-${agentId}`);
|
|
40580
40626
|
}
|
|
40581
40627
|
if (usesPm2 && pm2Procs) {
|
|
@@ -40728,10 +40774,14 @@ function bashBlockerLines(agentId, b2) {
|
|
|
40728
40774
|
switch (b2.code) {
|
|
40729
40775
|
case "foreign_pm2": {
|
|
40730
40776
|
const procs = details.processes ?? [];
|
|
40777
|
+
const advice = Array.isArray(details.adviceLines) ? details.adviceLines : [
|
|
40778
|
+
"Use a different agent slot.",
|
|
40779
|
+
"These processes belong to another project and must not be deleted from this checkout."
|
|
40780
|
+
];
|
|
40731
40781
|
return [
|
|
40732
40782
|
`ERROR: foreign PM2 processes match agent ${agentId}:`,
|
|
40733
40783
|
...procs.map((p) => ` ${p.name} cwd=${p.cwd ?? "unknown"}`),
|
|
40734
|
-
|
|
40784
|
+
...advice.map((line) => ` ${line}`)
|
|
40735
40785
|
];
|
|
40736
40786
|
}
|
|
40737
40787
|
case "control_port_conflict":
|
|
@@ -40834,6 +40884,7 @@ var init_slot_preflight = __esm({
|
|
|
40834
40884
|
init_slot_launch_guard_occupied();
|
|
40835
40885
|
init_slot_ports();
|
|
40836
40886
|
init_capabilities();
|
|
40887
|
+
init_stages();
|
|
40837
40888
|
init_slot_registry();
|
|
40838
40889
|
init_worktree_untracked();
|
|
40839
40890
|
import_child_process11 = require("child_process");
|
|
@@ -42500,7 +42551,7 @@ function detectPm2Issue(projectName, agentId, session, procs) {
|
|
|
42500
42551
|
const legacyPrefix = `agent-${agentId}-`;
|
|
42501
42552
|
const owned = procs.filter((p) => p.name?.startsWith(slotPrefix));
|
|
42502
42553
|
const foreign = procs.filter(
|
|
42503
|
-
(p) => p.name &&
|
|
42554
|
+
(p) => p.name && p.name.startsWith(legacyPrefix) && !p.name.startsWith("har-")
|
|
42504
42555
|
);
|
|
42505
42556
|
if (foreign.length > 0) return "foreign_pm2";
|
|
42506
42557
|
if (owned.length > 0) {
|