@zqagent/core 0.2.7 → 0.2.8

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.
@@ -11413,7 +11413,7 @@ function buildNodeInfo(store, opts) {
11413
11413
  nodeId: opts.nodeId ?? ensureNodeId(store),
11414
11414
  platform: process.platform,
11415
11415
  mode: process.env.NODE_MODE ?? "standalone",
11416
- version: "0.2.7",
11416
+ version: "0.2.8",
11417
11417
  admin: opts.admin,
11418
11418
  projects: opts.projects
11419
11419
  };
@@ -12406,7 +12406,7 @@ function buildNodeHost(store, manager, diskPath) {
12406
12406
  arch: process.arch,
12407
12407
  release: os6.release(),
12408
12408
  uptimeSec: Math.round(os6.uptime()),
12409
- version: "0.2.7",
12409
+ version: "0.2.8",
12410
12410
  mode: process.env.NODE_MODE ?? "standalone",
12411
12411
  cpu: {
12412
12412
  count: cpus2.length,
@@ -13958,7 +13958,7 @@ function createApp(store, manager, opts = {}) {
13958
13958
  json(res, 200, {
13959
13959
  status: "ok",
13960
13960
  // 版本让运维/探针能确认线上跑的是哪个构建(更新与回滚据此判断)
13961
- version: "0.2.7",
13961
+ version: "0.2.8",
13962
13962
  features: { mcp: hasServerMcpConfig() }
13963
13963
  });
13964
13964
  return;
@@ -15661,7 +15661,7 @@ var FleetNodeBridge = class {
15661
15661
  label: this.opts.deps.store.loadNodeLabel() ?? void 0,
15662
15662
  platform: process.platform,
15663
15663
  mode: process.env.NODE_MODE ?? "standalone",
15664
- version: "0.2.7",
15664
+ version: "0.2.8",
15665
15665
  ip: primaryIp()
15666
15666
  };
15667
15667
  }
@@ -15716,7 +15716,7 @@ var FleetNodeBridge = class {
15716
15716
  label: this.opts.deps.store.loadNodeLabel() ?? void 0,
15717
15717
  platform: process.platform,
15718
15718
  mode: process.env.NODE_MODE ?? "standalone",
15719
- version: "0.2.7",
15719
+ version: "0.2.8",
15720
15720
  ip: primaryIp(),
15721
15721
  projects,
15722
15722
  totals,
@@ -17434,9 +17434,10 @@ function selfCheck(binPath, expectedVersion) {
17434
17434
  init_cjs_shims();
17435
17435
  var fs25 = __toESM(require("fs"), 1);
17436
17436
  var path29 = __toESM(require("path"), 1);
17437
+ var import_node_child_process5 = require("child_process");
17437
17438
  var import_node_module3 = require("module");
17438
17439
  function currentVersion() {
17439
- const injected = "0.2.7"?.trim();
17440
+ const injected = "0.2.8"?.trim();
17440
17441
  if (injected) return injected;
17441
17442
  try {
17442
17443
  const req2 = (0, import_node_module3.createRequire)(importMetaUrl);
@@ -17479,6 +17480,35 @@ function serviceManager() {
17479
17480
  if (v === "systemd" || v === "launchd") return v;
17480
17481
  return detectServiceManager();
17481
17482
  }
17483
+ function parseServiceEnvironment(raw) {
17484
+ const out = {};
17485
+ for (const token of raw.trim().split(/\s+/)) {
17486
+ const idx = token.indexOf("=");
17487
+ if (idx > 0) out[token.slice(0, idx)] = token.slice(idx + 1);
17488
+ }
17489
+ return out;
17490
+ }
17491
+ var cachedServiceEnv = null;
17492
+ function readServiceEnvironment() {
17493
+ const serviceName = process.env.ZQAGENT_SERVICE_NAME?.trim() || DEFAULT_SERVICE_NAME;
17494
+ try {
17495
+ const res = (0, import_node_child_process5.spawnSync)(
17496
+ "systemctl",
17497
+ ["show", serviceName, "--property=Environment", "--value", "--no-pager"],
17498
+ { encoding: "utf8", timeout: 3e3 }
17499
+ );
17500
+ if (res.status !== 0 || !res.stdout) return {};
17501
+ return parseServiceEnvironment(res.stdout);
17502
+ } catch {
17503
+ return {};
17504
+ }
17505
+ }
17506
+ function serviceEnvValue(key) {
17507
+ if (process.platform !== "linux") return void 0;
17508
+ if (serviceManager() !== "systemd") return void 0;
17509
+ cachedServiceEnv ??= readServiceEnvironment();
17510
+ return cachedServiceEnv[key];
17511
+ }
17482
17512
  function selfUpdateCapability(hasPublicKey) {
17483
17513
  if (!isSeaRuntime()) {
17484
17514
  return {
@@ -17631,7 +17661,9 @@ function readRollbackTarget(dataDir) {
17631
17661
  var DEFAULT_BASE = "https://agent.cd-zq.com/downloads/zqagent";
17632
17662
  function env(key) {
17633
17663
  const v = process.env[key]?.trim();
17634
- return v ? v : void 0;
17664
+ if (v) return v;
17665
+ const fromService = serviceEnvValue(key)?.trim();
17666
+ return fromService ? fromService : void 0;
17635
17667
  }
17636
17668
  function num(key, fallback) {
17637
17669
  const n = Number(env(key));
@@ -17668,7 +17700,7 @@ var UpdateController = class {
17668
17700
  return parsePublicKey(env("ZQAGENT_UPDATE_PUBKEY") ?? "");
17669
17701
  }
17670
17702
  get autoUpdateOff() {
17671
- return process.env.ZQAGENT_AUTO_UPDATE?.trim() === "0";
17703
+ return env("ZQAGENT_AUTO_UPDATE") === "0";
17672
17704
  }
17673
17705
  get enabled() {
17674
17706
  return !this.autoUpdateOff && selfUpdateCapability(Boolean(this.publicKey)).ok;