auvezy-terminal-remote 0.7.2 → 0.7.3
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 +170 -49
- package/frontend-dist/assets/{eruda-3AA1luxn.js → eruda-D1P5Ouj7.js} +1 -1
- package/frontend-dist/assets/index-C4eh00Gk.js +359 -0
- package/frontend-dist/assets/{index-jLMclWkI.css → index-D1Dp0iBu.css} +1 -1
- package/frontend-dist/assets/zxing_reader-9hFayGnH.wasm +0 -0
- package/frontend-dist/index.html +2 -2
- package/frontend-dist/sw.js +1 -1
- package/package.json +1 -1
- package/frontend-dist/assets/index-B3ycRkAn.js +0 -359
package/dist/cli.js
CHANGED
|
@@ -14,7 +14,7 @@ var DEFAULT_PORT, DEFAULT_SESSION_TTL_MS, DEFAULT_AUTH_RATE_LIMIT, DEFAULT_MAX_B
|
|
|
14
14
|
var init_constants = __esm({
|
|
15
15
|
"shared/dist/constants.js"() {
|
|
16
16
|
"use strict";
|
|
17
|
-
DEFAULT_PORT =
|
|
17
|
+
DEFAULT_PORT = 3737;
|
|
18
18
|
DEFAULT_SESSION_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
19
19
|
DEFAULT_AUTH_RATE_LIMIT = 20;
|
|
20
20
|
DEFAULT_MAX_BUFFER_LINES = 1e4;
|
|
@@ -608,6 +608,9 @@ function assignFlag(out, key, value) {
|
|
|
608
608
|
case "--strict-port":
|
|
609
609
|
out.strictPort = value === true || value === "true";
|
|
610
610
|
return;
|
|
611
|
+
case "--foreground":
|
|
612
|
+
out.foreground = value === true || value === "true";
|
|
613
|
+
return;
|
|
611
614
|
case "--help":
|
|
612
615
|
out.help = true;
|
|
613
616
|
return;
|
|
@@ -719,7 +722,8 @@ var init_cli_utils = __esm({
|
|
|
719
722
|
"--version",
|
|
720
723
|
"--no-open",
|
|
721
724
|
"--wait-confirm",
|
|
722
|
-
"--strict-port"
|
|
725
|
+
"--strict-port",
|
|
726
|
+
"--foreground"
|
|
723
727
|
]);
|
|
724
728
|
KNOWN_FLAGS_VALUE = /* @__PURE__ */ new Set([
|
|
725
729
|
"--port",
|
|
@@ -774,8 +778,9 @@ Usage:
|
|
|
774
778
|
atr <subcommand> [...] manage the broker / instances (see below)
|
|
775
779
|
|
|
776
780
|
Subcommands:
|
|
777
|
-
start [--port n] [--host ip] start the background service (broker)
|
|
778
|
-
|
|
781
|
+
start [--port n] [--host ip] start the background service (broker); the command
|
|
782
|
+
returns immediately once the broker is healthy.
|
|
783
|
+
add --foreground to keep it attached (systemd / Docker).
|
|
779
784
|
stop stop the background service
|
|
780
785
|
status one-shot view: process, token, entry URLs, instances
|
|
781
786
|
list list all live instances
|
|
@@ -804,7 +809,7 @@ Strict argument order:
|
|
|
804
809
|
atr -- --weird '--' forces split; default shell with '--weird'
|
|
805
810
|
|
|
806
811
|
Run options (for atr [program]):
|
|
807
|
-
-p, --port <n> Background service (broker) port (default
|
|
812
|
+
-p, --port <n> Background service (broker) port (default 3737). If broker is
|
|
808
813
|
already running and on a different port, atr will refuse to
|
|
809
814
|
start \u2014 run 'atr stop' first if you want to switch.
|
|
810
815
|
Worker ports are internal and auto-assigned; you don't set them.
|
|
@@ -842,7 +847,7 @@ Run options (for atr [program]):
|
|
|
842
847
|
passes through automatically)
|
|
843
848
|
|
|
844
849
|
Multi-instance:
|
|
845
|
-
The background service (broker) runs once on port
|
|
850
|
+
The background service (broker) runs once on port 3737 and is shared by all
|
|
846
851
|
instances. Running atr [program] in different terminals all connect to the
|
|
847
852
|
same service; PTY children are independent. Click the tab bar in the browser
|
|
848
853
|
to switch between them. If the service isn't running, the first atr will
|
|
@@ -4437,7 +4442,7 @@ async function renderQrCode(url, opts = {}) {
|
|
|
4437
4442
|
try {
|
|
4438
4443
|
return await QRCode.toString(url, {
|
|
4439
4444
|
type: "utf8",
|
|
4440
|
-
errorCorrectionLevel: opts.errorCorrectionLevel ?? "
|
|
4445
|
+
errorCorrectionLevel: opts.errorCorrectionLevel ?? "M",
|
|
4441
4446
|
// utf8 模式本身就是半字符垂直压缩,体积约 qrcode-terminal small=true 的 1/2。
|
|
4442
4447
|
// margin: utf8 渲染器在 margin=1 时有"Invalid array length" bug,避开它;
|
|
4443
4448
|
// margin=2 视觉上仍然紧凑,且扫码识别率更高
|
|
@@ -5512,7 +5517,7 @@ var init_broker_server = __esm({
|
|
|
5512
5517
|
init_instance_router();
|
|
5513
5518
|
init_router();
|
|
5514
5519
|
init_port_finder();
|
|
5515
|
-
DEFAULT_BROKER_PORT =
|
|
5520
|
+
DEFAULT_BROKER_PORT = 3737;
|
|
5516
5521
|
DEFAULT_BROKER_HOST = "0.0.0.0";
|
|
5517
5522
|
}
|
|
5518
5523
|
});
|
|
@@ -5691,6 +5696,41 @@ var init_broker = __esm({
|
|
|
5691
5696
|
}
|
|
5692
5697
|
});
|
|
5693
5698
|
|
|
5699
|
+
// backend/dist/utils/wsl-detect.js
|
|
5700
|
+
import { readFileSync as readFileSync9 } from "node:fs";
|
|
5701
|
+
function isWsl(deps) {
|
|
5702
|
+
if (cached !== void 0 && deps === void 0)
|
|
5703
|
+
return cached;
|
|
5704
|
+
const platform2 = deps?.platform ?? process.platform;
|
|
5705
|
+
if (platform2 !== "linux") {
|
|
5706
|
+
if (deps === void 0)
|
|
5707
|
+
cached = false;
|
|
5708
|
+
return false;
|
|
5709
|
+
}
|
|
5710
|
+
let content;
|
|
5711
|
+
try {
|
|
5712
|
+
content = (deps?.readProcVersion ?? defaultReadProcVersion)();
|
|
5713
|
+
} catch {
|
|
5714
|
+
if (deps === void 0)
|
|
5715
|
+
cached = false;
|
|
5716
|
+
return false;
|
|
5717
|
+
}
|
|
5718
|
+
const lower = content.toLowerCase();
|
|
5719
|
+
const result = lower.includes("microsoft") || lower.includes("wsl");
|
|
5720
|
+
if (deps === void 0)
|
|
5721
|
+
cached = result;
|
|
5722
|
+
return result;
|
|
5723
|
+
}
|
|
5724
|
+
function defaultReadProcVersion() {
|
|
5725
|
+
return readFileSync9("/proc/version", "utf-8");
|
|
5726
|
+
}
|
|
5727
|
+
var cached;
|
|
5728
|
+
var init_wsl_detect = __esm({
|
|
5729
|
+
"backend/dist/utils/wsl-detect.js"() {
|
|
5730
|
+
"use strict";
|
|
5731
|
+
}
|
|
5732
|
+
});
|
|
5733
|
+
|
|
5694
5734
|
// backend/dist/broker/entry-discovery.js
|
|
5695
5735
|
var entry_discovery_exports = {};
|
|
5696
5736
|
__export(entry_discovery_exports, {
|
|
@@ -5737,13 +5777,8 @@ function discoverEntries(opts) {
|
|
|
5737
5777
|
url: buildEntryUrl("127.0.0.1", brokerPort, instanceId, urlOpts)
|
|
5738
5778
|
});
|
|
5739
5779
|
}
|
|
5740
|
-
const
|
|
5741
|
-
|
|
5742
|
-
lan: 1,
|
|
5743
|
-
ipv6: 2,
|
|
5744
|
-
other: 3,
|
|
5745
|
-
loopback: 4
|
|
5746
|
-
};
|
|
5780
|
+
const wsl = isWsl();
|
|
5781
|
+
const order = wsl ? { lan: 0, ipv6: 1, tailscale: 2, other: 3, loopback: 4 } : { tailscale: 0, lan: 1, ipv6: 2, other: 3, loopback: 4 };
|
|
5747
5782
|
out.sort((a, b) => {
|
|
5748
5783
|
if (a.kind !== b.kind)
|
|
5749
5784
|
return order[a.kind] - order[b.kind];
|
|
@@ -5804,6 +5839,7 @@ var init_entry_discovery = __esm({
|
|
|
5804
5839
|
"backend/dist/broker/entry-discovery.js"() {
|
|
5805
5840
|
"use strict";
|
|
5806
5841
|
init_network();
|
|
5842
|
+
init_wsl_detect();
|
|
5807
5843
|
}
|
|
5808
5844
|
});
|
|
5809
5845
|
|
|
@@ -6301,17 +6337,17 @@ hint: check whether ~/.atr/broker.json is held by a stale process; set ATR_DEBUG
|
|
|
6301
6337
|
setTimeout(() => triggerSpawn("timeout"), cfg.spawnTimeoutSec * 1e3).unref();
|
|
6302
6338
|
}
|
|
6303
6339
|
}
|
|
6340
|
+
const brokerHost = brokerState.host === "0.0.0.0" || brokerState.host === "::" ? displayIp : brokerState.host;
|
|
6304
6341
|
void registry.register({
|
|
6305
6342
|
instanceId,
|
|
6306
6343
|
name: cfg.instanceName,
|
|
6307
|
-
// 0.7.0:host 改为 worker 实际监听地址(loopback)。broker 阶段 3 反代时
|
|
6308
|
-
// 直接用这个 host:port 连 worker。displayIp 已不参与 worker 注册
|
|
6309
6344
|
host: "127.0.0.1",
|
|
6310
6345
|
port: cfg.port,
|
|
6311
6346
|
pid: process.pid,
|
|
6312
6347
|
cwd: cfg.claudeCwd,
|
|
6313
6348
|
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
6314
|
-
headless: cfg.noTerminal
|
|
6349
|
+
headless: cfg.noTerminal,
|
|
6350
|
+
...brokerHost ? { brokerHost } : {}
|
|
6315
6351
|
}).catch((err) => logger.warn({ err }, "\u6CE8\u518C\u5B9E\u4F8B\u5931\u8D25"));
|
|
6316
6352
|
logger.info({
|
|
6317
6353
|
port: cfg.port,
|
|
@@ -7386,7 +7422,7 @@ __export(service_installer_exports, {
|
|
|
7386
7422
|
renderSystemdUnit: () => renderSystemdUnit,
|
|
7387
7423
|
uninstall: () => uninstall
|
|
7388
7424
|
});
|
|
7389
|
-
import { existsSync as existsSync15, mkdirSync as mkdirSync12, readFileSync as
|
|
7425
|
+
import { existsSync as existsSync15, mkdirSync as mkdirSync12, readFileSync as readFileSync10, rmSync as rmSync3, writeFileSync as writeFileSync5 } from "node:fs";
|
|
7390
7426
|
import { resolve as resolve15, dirname as dirname8 } from "node:path";
|
|
7391
7427
|
import { homedir as homedir9, platform } from "node:os";
|
|
7392
7428
|
function detectPlatform(env = process.env, plat = platform()) {
|
|
@@ -7408,7 +7444,7 @@ After=network.target
|
|
|
7408
7444
|
|
|
7409
7445
|
[Service]
|
|
7410
7446
|
Type=simple
|
|
7411
|
-
ExecStart=${opts.nodeBin} ${opts.cliPath} start
|
|
7447
|
+
ExecStart=${opts.nodeBin} ${opts.cliPath} start --foreground
|
|
7412
7448
|
Restart=on-failure
|
|
7413
7449
|
RestartSec=5s
|
|
7414
7450
|
${portEnv}[Install]
|
|
@@ -7433,6 +7469,7 @@ function renderLaunchdPlist(opts) {
|
|
|
7433
7469
|
<string>${opts.nodeBin}</string>
|
|
7434
7470
|
<string>${opts.cliPath}</string>
|
|
7435
7471
|
<string>start</string>
|
|
7472
|
+
<string>--foreground</string>
|
|
7436
7473
|
</array>
|
|
7437
7474
|
<key>RunAtLoad</key><true/>
|
|
7438
7475
|
<key>KeepAlive</key><true/>
|
|
@@ -7548,7 +7585,7 @@ var init_service_installer = __esm({
|
|
|
7548
7585
|
mkdirSync12(p, o);
|
|
7549
7586
|
},
|
|
7550
7587
|
writeFileSync: (p, d, o) => writeFileSync5(p, d, { encoding: "utf-8", ...o ?? {} }),
|
|
7551
|
-
readFileSync: (p) =>
|
|
7588
|
+
readFileSync: (p) => readFileSync10(p, "utf-8"),
|
|
7552
7589
|
rmSync: rmSync3
|
|
7553
7590
|
};
|
|
7554
7591
|
ServicePlatformUnsupportedError = class extends AppError {
|
|
@@ -7605,8 +7642,8 @@ var cli_exports = {};
|
|
|
7605
7642
|
__export(cli_exports, {
|
|
7606
7643
|
runServiceCli: () => runServiceCli
|
|
7607
7644
|
});
|
|
7608
|
-
import { execSync as execSync2 } from "node:child_process";
|
|
7609
|
-
import { readFileSync as
|
|
7645
|
+
import { execSync as execSync2, spawn as spawn4 } from "node:child_process";
|
|
7646
|
+
import { existsSync as existsSync16, openSync as openSync3, readFileSync as readFileSync11 } from "node:fs";
|
|
7610
7647
|
import { resolve as resolve16, dirname as dirname9 } from "node:path";
|
|
7611
7648
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
7612
7649
|
import { homedir as homedir10 } from "node:os";
|
|
@@ -7619,7 +7656,7 @@ function getBrokerVersion() {
|
|
|
7619
7656
|
];
|
|
7620
7657
|
for (const pkgPath of candidates) {
|
|
7621
7658
|
try {
|
|
7622
|
-
const pkg = JSON.parse(
|
|
7659
|
+
const pkg = JSON.parse(readFileSync11(pkgPath, "utf-8"));
|
|
7623
7660
|
if (pkg.name === "auvezy-terminal-remote" && typeof pkg.version === "string") {
|
|
7624
7661
|
return pkg.version;
|
|
7625
7662
|
}
|
|
@@ -7631,18 +7668,19 @@ function getBrokerVersion() {
|
|
|
7631
7668
|
}
|
|
7632
7669
|
function getCliPath() {
|
|
7633
7670
|
const __dirname2 = dirname9(fileURLToPath3(import.meta.url));
|
|
7634
|
-
const
|
|
7635
|
-
|
|
7636
|
-
|
|
7637
|
-
|
|
7638
|
-
|
|
7639
|
-
|
|
7640
|
-
readFileSync10(p);
|
|
7641
|
-
return p;
|
|
7642
|
-
} catch {
|
|
7643
|
-
}
|
|
7671
|
+
const parentDir = resolve16(__dirname2, "..", "cli.js");
|
|
7672
|
+
const sameDir = resolve16(__dirname2, "cli.js");
|
|
7673
|
+
try {
|
|
7674
|
+
readFileSync11(parentDir);
|
|
7675
|
+
return parentDir;
|
|
7676
|
+
} catch {
|
|
7644
7677
|
}
|
|
7645
|
-
|
|
7678
|
+
try {
|
|
7679
|
+
readFileSync11(sameDir);
|
|
7680
|
+
return sameDir;
|
|
7681
|
+
} catch {
|
|
7682
|
+
}
|
|
7683
|
+
return parentDir;
|
|
7646
7684
|
}
|
|
7647
7685
|
async function runServiceCli(action, cli) {
|
|
7648
7686
|
switch (action) {
|
|
@@ -7663,6 +7701,10 @@ async function runServiceCli(action, cli) {
|
|
|
7663
7701
|
}
|
|
7664
7702
|
}
|
|
7665
7703
|
async function runBrokerStart(cli) {
|
|
7704
|
+
const wantForeground = cli.foreground === true || process.env["ATR_BROKER_FOREGROUND"] === "1";
|
|
7705
|
+
if (!wantForeground) {
|
|
7706
|
+
return runBrokerStartDaemonize(cli);
|
|
7707
|
+
}
|
|
7666
7708
|
const port = cli.port ?? parseEnvPort(process.env["ATR_BROKER_PORT"]) ?? DEFAULT_BROKER_PORT;
|
|
7667
7709
|
const host = cli.host ?? process.env["ATR_BROKER_HOST"] ?? DEFAULT_BROKER_HOST;
|
|
7668
7710
|
const brokerVersion = getBrokerVersion();
|
|
@@ -7705,7 +7747,7 @@ async function runBrokerStart(cli) {
|
|
|
7705
7747
|
const pushService = new PushService();
|
|
7706
7748
|
await pushService.init();
|
|
7707
7749
|
startInstanceWatcher(registry.filePath);
|
|
7708
|
-
const cliJsPath =
|
|
7750
|
+
const cliJsPath = getCliPath();
|
|
7709
7751
|
const workdirAllow = currentUserConfig.workdirAllow;
|
|
7710
7752
|
const workdirDeny = currentUserConfig.workdirDeny;
|
|
7711
7753
|
const spawner = new DefaultInstanceSpawner({
|
|
@@ -7780,6 +7822,83 @@ function installBrokerLogRotator() {
|
|
|
7780
7822
|
});
|
|
7781
7823
|
return rotator;
|
|
7782
7824
|
}
|
|
7825
|
+
async function runBrokerStartDaemonize(cli) {
|
|
7826
|
+
const tag = c.cyan("[atr]");
|
|
7827
|
+
const port = cli.port ?? parseEnvPort(process.env["ATR_BROKER_PORT"]) ?? DEFAULT_BROKER_PORT;
|
|
7828
|
+
const existing = readBrokerState();
|
|
7829
|
+
if (existing && isBrokerAlive(existing)) {
|
|
7830
|
+
process.stderr.write(`${tag} broker already running on ${existing.host}:${existing.port} (pid=${existing.pid})
|
|
7831
|
+
`);
|
|
7832
|
+
return 0;
|
|
7833
|
+
}
|
|
7834
|
+
const cliJsPath = getCliPath();
|
|
7835
|
+
const entry = resolveDaemonEntry(cliJsPath);
|
|
7836
|
+
const logFd = process.env["ATR_DEBUG_SPAWN"] ? openSync3(`/tmp/atr-broker-${Date.now()}.log`, "a") : "ignore";
|
|
7837
|
+
const childEnv = {
|
|
7838
|
+
...process.env,
|
|
7839
|
+
ATR_BROKER_FOREGROUND: "1"
|
|
7840
|
+
};
|
|
7841
|
+
if (cli.port !== void 0)
|
|
7842
|
+
childEnv["ATR_BROKER_PORT"] = String(cli.port);
|
|
7843
|
+
if (cli.host !== void 0)
|
|
7844
|
+
childEnv["ATR_BROKER_HOST"] = cli.host;
|
|
7845
|
+
if (cli.strictPort)
|
|
7846
|
+
childEnv["ATR_BROKER_STRICT_PORT"] = "1";
|
|
7847
|
+
const child = spawn4(entry.execPath, [...entry.args, "start", "--foreground"], {
|
|
7848
|
+
env: childEnv,
|
|
7849
|
+
detached: true,
|
|
7850
|
+
stdio: ["ignore", logFd, logFd]
|
|
7851
|
+
});
|
|
7852
|
+
if (typeof child.pid !== "number") {
|
|
7853
|
+
process.stderr.write(`${tag} failed to spawn broker subprocess (no pid)
|
|
7854
|
+
`);
|
|
7855
|
+
return 1;
|
|
7856
|
+
}
|
|
7857
|
+
const earlyExit = [];
|
|
7858
|
+
const earlyError = [];
|
|
7859
|
+
child.once("error", (e) => {
|
|
7860
|
+
earlyError.push(e);
|
|
7861
|
+
});
|
|
7862
|
+
child.once("exit", (code, signal) => {
|
|
7863
|
+
earlyExit.push({ code, signal });
|
|
7864
|
+
});
|
|
7865
|
+
child.unref();
|
|
7866
|
+
const t0 = Date.now();
|
|
7867
|
+
const statePath = defaultBrokerStatePath();
|
|
7868
|
+
while (Date.now() - t0 < DAEMONIZE_TIMEOUT_MS) {
|
|
7869
|
+
const st = readBrokerState(statePath);
|
|
7870
|
+
if (st && isBrokerAlive(st) && st.pid === child.pid) {
|
|
7871
|
+
process.stdout.write(`${tag} broker started on ${c.green(`${st.host}:${st.port}`)} (pid=${st.pid})
|
|
7872
|
+
`);
|
|
7873
|
+
return 0;
|
|
7874
|
+
}
|
|
7875
|
+
await sleep4(DAEMONIZE_POLL_INTERVAL_MS);
|
|
7876
|
+
}
|
|
7877
|
+
let detail = "";
|
|
7878
|
+
if (earlyError[0]) {
|
|
7879
|
+
detail = `
|
|
7880
|
+
- spawn error: ${earlyError[0].message}`;
|
|
7881
|
+
} else if (earlyExit[0]) {
|
|
7882
|
+
detail = `
|
|
7883
|
+
- child exited early (code=${earlyExit[0].code}, signal=${earlyExit[0].signal})`;
|
|
7884
|
+
}
|
|
7885
|
+
process.stderr.write(`${tag} broker did not become ready within ${DAEMONIZE_TIMEOUT_MS}ms.${detail}
|
|
7886
|
+
- check ~/.auvezy/terminal-remote/broker-*.log for errors
|
|
7887
|
+
- or set ATR_DEBUG_SPAWN=1 and retry to capture /tmp/atr-broker-*.log
|
|
7888
|
+
- port ${port} may be busy; try '--port <other>' or '--strict-port' to fail fast
|
|
7889
|
+
`);
|
|
7890
|
+
return 1;
|
|
7891
|
+
}
|
|
7892
|
+
function resolveDaemonEntry(cliJsPath) {
|
|
7893
|
+
if (existsSync16(cliJsPath)) {
|
|
7894
|
+
return { execPath: process.execPath, args: [cliJsPath] };
|
|
7895
|
+
}
|
|
7896
|
+
const tsPath = cliJsPath.replace(/\.js$/, ".ts");
|
|
7897
|
+
if (existsSync16(tsPath)) {
|
|
7898
|
+
return { execPath: process.execPath, args: ["--import", "tsx", tsPath] };
|
|
7899
|
+
}
|
|
7900
|
+
return { execPath: process.execPath, args: [cliJsPath] };
|
|
7901
|
+
}
|
|
7783
7902
|
async function runBrokerStop() {
|
|
7784
7903
|
const tag = c.cyan("[atr]");
|
|
7785
7904
|
const state = readBrokerState();
|
|
@@ -7937,12 +8056,12 @@ function writeServiceInstallSection() {
|
|
|
7937
8056
|
async function writeTokenSection() {
|
|
7938
8057
|
process.stdout.write(c.bold("=== Token ===\n"));
|
|
7939
8058
|
try {
|
|
7940
|
-
const { readFileSync:
|
|
8059
|
+
const { readFileSync: readFileSync12, statSync: statSync6 } = await import("node:fs");
|
|
7941
8060
|
const { resolve: pathResolve2 } = await import("node:path");
|
|
7942
8061
|
const { homedir: homedir11 } = await import("node:os");
|
|
7943
8062
|
const path = pathResolve2(homedir11(), ".atrrc");
|
|
7944
8063
|
const stat = statSync6(path);
|
|
7945
|
-
const cfg = JSON.parse(
|
|
8064
|
+
const cfg = JSON.parse(readFileSync12(path, "utf-8"));
|
|
7946
8065
|
if (typeof cfg.token === "string" && cfg.token.length > 0) {
|
|
7947
8066
|
process.stdout.write(` token: ${cfg.token}
|
|
7948
8067
|
`);
|
|
@@ -7964,10 +8083,10 @@ async function writeEntriesSection(brokerPort) {
|
|
|
7964
8083
|
const { discoverEntries: discoverEntries2, kindLabel: kindLabel2 } = await Promise.resolve().then(() => (init_entry_discovery(), entry_discovery_exports));
|
|
7965
8084
|
let token;
|
|
7966
8085
|
try {
|
|
7967
|
-
const { readFileSync:
|
|
8086
|
+
const { readFileSync: readFileSync12 } = await import("node:fs");
|
|
7968
8087
|
const { resolve: pathResolve2 } = await import("node:path");
|
|
7969
8088
|
const { homedir: homedir11 } = await import("node:os");
|
|
7970
|
-
const cfg = JSON.parse(
|
|
8089
|
+
const cfg = JSON.parse(readFileSync12(pathResolve2(homedir11(), ".atrrc"), "utf-8"));
|
|
7971
8090
|
if (typeof cfg.token === "string" && cfg.token.length > 0)
|
|
7972
8091
|
token = cfg.token;
|
|
7973
8092
|
} catch {
|
|
@@ -8026,12 +8145,12 @@ async function runListInstances() {
|
|
|
8026
8145
|
async function runShowLogs() {
|
|
8027
8146
|
const { homedir: homedir11 } = await import("node:os");
|
|
8028
8147
|
const { resolve: pathResolve2 } = await import("node:path");
|
|
8029
|
-
const { existsSync:
|
|
8030
|
-
const { spawn:
|
|
8148
|
+
const { existsSync: existsSync17 } = await import("node:fs");
|
|
8149
|
+
const { spawn: spawn5 } = await import("node:child_process");
|
|
8031
8150
|
const today = /* @__PURE__ */ new Date();
|
|
8032
8151
|
const day = `${today.getFullYear()}-${String(today.getMonth() + 1).padStart(2, "0")}-${String(today.getDate()).padStart(2, "0")}`;
|
|
8033
8152
|
const logPath = pathResolve2(homedir11(), ".atr", `broker-${day}.log`);
|
|
8034
|
-
if (!
|
|
8153
|
+
if (!existsSync17(logPath)) {
|
|
8035
8154
|
process.stderr.write(`[atr] today's log not found: ${logPath}
|
|
8036
8155
|
hint: is the service running? try atr status, or atr start to launch.
|
|
8037
8156
|
`);
|
|
@@ -8039,14 +8158,14 @@ hint: is the service running? try atr status, or atr start to launch.
|
|
|
8039
8158
|
}
|
|
8040
8159
|
process.stderr.write(`[atr] tail -F ${logPath} (Ctrl+C to quit)
|
|
8041
8160
|
`);
|
|
8042
|
-
const tail =
|
|
8161
|
+
const tail = spawn5("tail", ["-F", logPath], { stdio: "inherit" });
|
|
8043
8162
|
return new Promise((resolveExit) => {
|
|
8044
8163
|
tail.on("error", (err) => {
|
|
8045
8164
|
process.stderr.write(`[atr] cannot spawn tail (${err.message}); falling back to one-shot output:
|
|
8046
8165
|
`);
|
|
8047
|
-
void import("node:fs").then(({ readFileSync:
|
|
8166
|
+
void import("node:fs").then(({ readFileSync: readFileSync12 }) => {
|
|
8048
8167
|
try {
|
|
8049
|
-
process.stdout.write(
|
|
8168
|
+
process.stdout.write(readFileSync12(logPath, "utf-8"));
|
|
8050
8169
|
resolveExit(0);
|
|
8051
8170
|
} catch (e) {
|
|
8052
8171
|
process.stderr.write(`[atr] failed to read log: ${e.message}
|
|
@@ -8132,7 +8251,7 @@ function parseEnvPort(raw) {
|
|
|
8132
8251
|
function sleep4(ms) {
|
|
8133
8252
|
return new Promise((r) => setTimeout(r, ms));
|
|
8134
8253
|
}
|
|
8135
|
-
var STOP_GRACE_MS, STOP_POLL_INTERVAL_MS;
|
|
8254
|
+
var DAEMONIZE_TIMEOUT_MS, DAEMONIZE_POLL_INTERVAL_MS, STOP_GRACE_MS, STOP_POLL_INTERVAL_MS;
|
|
8136
8255
|
var init_cli = __esm({
|
|
8137
8256
|
"backend/dist/broker/cli.js"() {
|
|
8138
8257
|
"use strict";
|
|
@@ -8154,6 +8273,8 @@ var init_cli = __esm({
|
|
|
8154
8273
|
init_broker_state();
|
|
8155
8274
|
init_service_installer();
|
|
8156
8275
|
init_colors();
|
|
8276
|
+
DAEMONIZE_TIMEOUT_MS = 8e3;
|
|
8277
|
+
DAEMONIZE_POLL_INTERVAL_MS = 100;
|
|
8157
8278
|
STOP_GRACE_MS = 5e3;
|
|
8158
8279
|
STOP_POLL_INTERVAL_MS = 100;
|
|
8159
8280
|
}
|
|
@@ -8222,11 +8343,11 @@ void (async () => {
|
|
|
8222
8343
|
process.exit(0);
|
|
8223
8344
|
}
|
|
8224
8345
|
if (cli.version) {
|
|
8225
|
-
const { readFileSync:
|
|
8346
|
+
const { readFileSync: readFileSync12 } = await import("node:fs");
|
|
8226
8347
|
const { resolve: resolve17, dirname: dirname10 } = await import("node:path");
|
|
8227
8348
|
const { fileURLToPath: fileURLToPath4 } = await import("node:url");
|
|
8228
8349
|
const __dirname2 = dirname10(fileURLToPath4(import.meta.url));
|
|
8229
|
-
const pkg = JSON.parse(
|
|
8350
|
+
const pkg = JSON.parse(readFileSync12(resolve17(__dirname2, "..", "package.json"), "utf-8"));
|
|
8230
8351
|
process.stdout.write(`${pkg.version}
|
|
8231
8352
|
`);
|
|
8232
8353
|
process.exit(0);
|