cli-remote-agent 1.0.12 → 1.0.14
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/cli.js +53 -20
- package/dist/cli.js.map +1 -1
- package/dist/index.js +40 -15
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -527,6 +527,36 @@ var init_single_instance = __esm({
|
|
|
527
527
|
}
|
|
528
528
|
});
|
|
529
529
|
|
|
530
|
+
// src/keep-awake.ts
|
|
531
|
+
function keepAwake() {
|
|
532
|
+
if (process.platform !== "darwin") return;
|
|
533
|
+
if (process.env.CRC_ALLOW_SLEEP === "1") return;
|
|
534
|
+
try {
|
|
535
|
+
const child = (0, import_child_process2.spawn)("caffeinate", ["-i", "-w", String(process.pid)], {
|
|
536
|
+
detached: true,
|
|
537
|
+
stdio: "ignore"
|
|
538
|
+
});
|
|
539
|
+
child.on("error", (err) => {
|
|
540
|
+
logger.warn(
|
|
541
|
+
{ error: err.message },
|
|
542
|
+
"Could not start caffeinate \u2014 the Mac may idle-sleep and drop the connection"
|
|
543
|
+
);
|
|
544
|
+
});
|
|
545
|
+
child.unref();
|
|
546
|
+
logger.info("Preventing idle sleep while the agent runs (caffeinate -i)");
|
|
547
|
+
} catch (err) {
|
|
548
|
+
logger.warn({ error: err?.message }, "Could not prevent idle sleep");
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
var import_child_process2;
|
|
552
|
+
var init_keep_awake = __esm({
|
|
553
|
+
"src/keep-awake.ts"() {
|
|
554
|
+
"use strict";
|
|
555
|
+
import_child_process2 = require("child_process");
|
|
556
|
+
init_logger();
|
|
557
|
+
}
|
|
558
|
+
});
|
|
559
|
+
|
|
530
560
|
// src/claude-live.ts
|
|
531
561
|
function isAlive(pid) {
|
|
532
562
|
try {
|
|
@@ -591,16 +621,16 @@ async function findClaudeSessionForPtyPid(ptyPid) {
|
|
|
591
621
|
}
|
|
592
622
|
return null;
|
|
593
623
|
}
|
|
594
|
-
var import_fs6, import_path5, import_os2,
|
|
624
|
+
var import_fs6, import_path5, import_os2, import_child_process3, import_util, execFileAsync, LIVE_SESSIONS_DIR;
|
|
595
625
|
var init_claude_live = __esm({
|
|
596
626
|
"src/claude-live.ts"() {
|
|
597
627
|
"use strict";
|
|
598
628
|
import_fs6 = __toESM(require("fs"));
|
|
599
629
|
import_path5 = __toESM(require("path"));
|
|
600
630
|
import_os2 = __toESM(require("os"));
|
|
601
|
-
|
|
631
|
+
import_child_process3 = require("child_process");
|
|
602
632
|
import_util = require("util");
|
|
603
|
-
execFileAsync = (0, import_util.promisify)(
|
|
633
|
+
execFileAsync = (0, import_util.promisify)(import_child_process3.execFile);
|
|
604
634
|
LIVE_SESSIONS_DIR = import_path5.default.join(import_os2.default.homedir(), ".claude", "sessions");
|
|
605
635
|
}
|
|
606
636
|
});
|
|
@@ -658,9 +688,10 @@ async function killTmuxSession(name) {
|
|
|
658
688
|
return { ok: false, error: msg };
|
|
659
689
|
}
|
|
660
690
|
}
|
|
661
|
-
async function scrollTmux(name, direction) {
|
|
691
|
+
async function scrollTmux(name, direction, lines = 12) {
|
|
662
692
|
const bin = resolveTmuxPath();
|
|
663
693
|
if (!bin) return { inCopyMode: false };
|
|
694
|
+
const n = Math.max(1, Math.min(200, Math.round(lines)));
|
|
664
695
|
const target = name;
|
|
665
696
|
const run = (args) => execFileAsync2(bin, args, { timeout: 4e3 }).catch(() => {
|
|
666
697
|
});
|
|
@@ -678,11 +709,11 @@ async function scrollTmux(name, direction) {
|
|
|
678
709
|
}
|
|
679
710
|
if (direction === "up") {
|
|
680
711
|
if (!await inMode()) await run(["copy-mode", "-t", target]);
|
|
681
|
-
await run(["send-keys", "-t", target, "-X", "
|
|
712
|
+
await run(["send-keys", "-t", target, "-N", String(n), "-X", "scroll-up"]);
|
|
682
713
|
return { inCopyMode: true };
|
|
683
714
|
}
|
|
684
715
|
if (!await inMode()) return { inCopyMode: false };
|
|
685
|
-
await run(["send-keys", "-t", target, "-X", "
|
|
716
|
+
await run(["send-keys", "-t", target, "-N", String(n), "-X", "scroll-down"]);
|
|
686
717
|
try {
|
|
687
718
|
const { stdout } = await execFileAsync2(bin, ["display-message", "-t", target, "-p", "#{scroll_position}"], { timeout: 3e3 });
|
|
688
719
|
if ((parseInt(stdout.trim(), 10) || 0) === 0) {
|
|
@@ -740,16 +771,16 @@ function buildTmuxLaunch(name, launch) {
|
|
|
740
771
|
if (trimmed) args.push(trimmed);
|
|
741
772
|
return { file: tmuxBin, args };
|
|
742
773
|
}
|
|
743
|
-
var
|
|
774
|
+
var import_child_process4, import_util2, import_fs7, import_path6, execFileAsync2, IS_WIN, cachedTmuxPath;
|
|
744
775
|
var init_tmux = __esm({
|
|
745
776
|
"src/tmux.ts"() {
|
|
746
777
|
"use strict";
|
|
747
|
-
|
|
778
|
+
import_child_process4 = require("child_process");
|
|
748
779
|
import_util2 = require("util");
|
|
749
780
|
import_fs7 = __toESM(require("fs"));
|
|
750
781
|
import_path6 = __toESM(require("path"));
|
|
751
782
|
init_claude_live();
|
|
752
|
-
execFileAsync2 = (0, import_util2.promisify)(
|
|
783
|
+
execFileAsync2 = (0, import_util2.promisify)(import_child_process4.execFile);
|
|
753
784
|
IS_WIN = process.platform === "win32";
|
|
754
785
|
}
|
|
755
786
|
});
|
|
@@ -759,7 +790,7 @@ function detectShell(preference) {
|
|
|
759
790
|
if (preference !== "auto") return preference;
|
|
760
791
|
if (process.platform === "win32") {
|
|
761
792
|
try {
|
|
762
|
-
(0,
|
|
793
|
+
(0, import_child_process5.execSync)("where pwsh", { stdio: "ignore" });
|
|
763
794
|
return "pwsh.exe";
|
|
764
795
|
} catch {
|
|
765
796
|
return "powershell.exe";
|
|
@@ -767,11 +798,11 @@ function detectShell(preference) {
|
|
|
767
798
|
}
|
|
768
799
|
return process.env.SHELL || "/bin/bash";
|
|
769
800
|
}
|
|
770
|
-
var
|
|
801
|
+
var import_child_process5;
|
|
771
802
|
var init_shell = __esm({
|
|
772
803
|
"src/shell.ts"() {
|
|
773
804
|
"use strict";
|
|
774
|
-
|
|
805
|
+
import_child_process5 = require("child_process");
|
|
775
806
|
}
|
|
776
807
|
});
|
|
777
808
|
|
|
@@ -1059,7 +1090,7 @@ function getCpuUsage() {
|
|
|
1059
1090
|
function getRootPaths() {
|
|
1060
1091
|
if (process.platform === "win32") {
|
|
1061
1092
|
try {
|
|
1062
|
-
const output = (0,
|
|
1093
|
+
const output = (0, import_child_process6.execSync)("wmic logicaldisk get name", { encoding: "utf-8" });
|
|
1063
1094
|
return output.split("\n").map((l) => l.trim()).filter((l) => /^[A-Z]:$/.test(l)).map((l) => l + "\\");
|
|
1064
1095
|
} catch {
|
|
1065
1096
|
return ["C:\\"];
|
|
@@ -1084,13 +1115,13 @@ function buildHeartbeat(homeDir) {
|
|
|
1084
1115
|
capabilities: { terminal: true, fileTransfer: false }
|
|
1085
1116
|
};
|
|
1086
1117
|
}
|
|
1087
|
-
var import_os4, import_path8,
|
|
1118
|
+
var import_os4, import_path8, import_child_process6, prevCpu;
|
|
1088
1119
|
var init_heartbeat = __esm({
|
|
1089
1120
|
"src/heartbeat.ts"() {
|
|
1090
1121
|
"use strict";
|
|
1091
1122
|
import_os4 = __toESM(require("os"));
|
|
1092
1123
|
import_path8 = __toESM(require("path"));
|
|
1093
|
-
|
|
1124
|
+
import_child_process6 = require("child_process");
|
|
1094
1125
|
init_terminal_manager();
|
|
1095
1126
|
prevCpu = null;
|
|
1096
1127
|
}
|
|
@@ -1516,17 +1547,17 @@ async function disconnectVpn(configs, profileId) {
|
|
|
1516
1547
|
}
|
|
1517
1548
|
return profiles;
|
|
1518
1549
|
}
|
|
1519
|
-
var
|
|
1550
|
+
var import_child_process7, import_util3, import_fs10, import_path10, import_os6, execAsync, isWindows, VPN_DIR;
|
|
1520
1551
|
var init_vpn_manager = __esm({
|
|
1521
1552
|
"src/vpn-manager.ts"() {
|
|
1522
1553
|
"use strict";
|
|
1523
|
-
|
|
1554
|
+
import_child_process7 = require("child_process");
|
|
1524
1555
|
import_util3 = require("util");
|
|
1525
1556
|
import_fs10 = __toESM(require("fs"));
|
|
1526
1557
|
import_path10 = __toESM(require("path"));
|
|
1527
1558
|
import_os6 = __toESM(require("os"));
|
|
1528
1559
|
init_logger();
|
|
1529
|
-
execAsync = (0, import_util3.promisify)(
|
|
1560
|
+
execAsync = (0, import_util3.promisify)(import_child_process7.exec);
|
|
1530
1561
|
isWindows = process.platform === "win32";
|
|
1531
1562
|
VPN_DIR = import_path10.default.join(import_os6.default.homedir(), ".crc-agent", "vpn");
|
|
1532
1563
|
}
|
|
@@ -1869,6 +1900,7 @@ var init_index = __esm({
|
|
|
1869
1900
|
init_local_control();
|
|
1870
1901
|
init_pty_helper_fix();
|
|
1871
1902
|
init_single_instance();
|
|
1903
|
+
init_keep_awake();
|
|
1872
1904
|
init_tmux();
|
|
1873
1905
|
init_heartbeat();
|
|
1874
1906
|
init_file_explorer();
|
|
@@ -1891,6 +1923,7 @@ var init_index = __esm({
|
|
|
1891
1923
|
process.exit(1);
|
|
1892
1924
|
}
|
|
1893
1925
|
ensurePtyHelperExecutable();
|
|
1926
|
+
keepAwake();
|
|
1894
1927
|
process.on("unhandledRejection", (reason) => {
|
|
1895
1928
|
logger.error({ reason }, "Unhandled promise rejection (agent kept alive)");
|
|
1896
1929
|
});
|
|
@@ -2000,10 +2033,10 @@ var init_index = __esm({
|
|
|
2000
2033
|
socket.emit(TMUX_KILL_RESULT, { requestId, name, ok: result.ok, error: result.error });
|
|
2001
2034
|
});
|
|
2002
2035
|
socket.on(TMUX_SCROLL, async (payload) => {
|
|
2003
|
-
const { sessionId, direction } = payload;
|
|
2036
|
+
const { sessionId, direction, lines } = payload;
|
|
2004
2037
|
const name = sessionId && sessionTmuxName.get(sessionId);
|
|
2005
2038
|
if (!name) return;
|
|
2006
|
-
const { inCopyMode } = await scrollTmux(name, direction);
|
|
2039
|
+
const { inCopyMode } = await scrollTmux(name, direction, lines);
|
|
2007
2040
|
sessionInCopyMode.set(sessionId, inCopyMode);
|
|
2008
2041
|
});
|
|
2009
2042
|
socket.on(TERMINAL_INPUT, (payload) => {
|