@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.
@@ -11396,7 +11396,7 @@ function buildNodeInfo(store, opts) {
11396
11396
  nodeId: opts.nodeId ?? ensureNodeId(store),
11397
11397
  platform: process.platform,
11398
11398
  mode: process.env.NODE_MODE ?? "standalone",
11399
- version: "0.2.7",
11399
+ version: "0.2.8",
11400
11400
  admin: opts.admin,
11401
11401
  projects: opts.projects
11402
11402
  };
@@ -12389,7 +12389,7 @@ function buildNodeHost(store, manager, diskPath) {
12389
12389
  arch: process.arch,
12390
12390
  release: os6.release(),
12391
12391
  uptimeSec: Math.round(os6.uptime()),
12392
- version: "0.2.7",
12392
+ version: "0.2.8",
12393
12393
  mode: process.env.NODE_MODE ?? "standalone",
12394
12394
  cpu: {
12395
12395
  count: cpus2.length,
@@ -13941,7 +13941,7 @@ function createApp(store, manager, opts = {}) {
13941
13941
  json(res, 200, {
13942
13942
  status: "ok",
13943
13943
  // 版本让运维/探针能确认线上跑的是哪个构建(更新与回滚据此判断)
13944
- version: "0.2.7",
13944
+ version: "0.2.8",
13945
13945
  features: { mcp: hasServerMcpConfig() }
13946
13946
  });
13947
13947
  return;
@@ -15644,7 +15644,7 @@ var FleetNodeBridge = class {
15644
15644
  label: this.opts.deps.store.loadNodeLabel() ?? void 0,
15645
15645
  platform: process.platform,
15646
15646
  mode: process.env.NODE_MODE ?? "standalone",
15647
- version: "0.2.7",
15647
+ version: "0.2.8",
15648
15648
  ip: primaryIp()
15649
15649
  };
15650
15650
  }
@@ -15699,7 +15699,7 @@ var FleetNodeBridge = class {
15699
15699
  label: this.opts.deps.store.loadNodeLabel() ?? void 0,
15700
15700
  platform: process.platform,
15701
15701
  mode: process.env.NODE_MODE ?? "standalone",
15702
- version: "0.2.7",
15702
+ version: "0.2.8",
15703
15703
  ip: primaryIp(),
15704
15704
  projects,
15705
15705
  totals,
@@ -17417,9 +17417,10 @@ function selfCheck(binPath, expectedVersion) {
17417
17417
  init_esm_shims();
17418
17418
  import * as fs25 from "fs";
17419
17419
  import * as path30 from "path";
17420
+ import { spawnSync as spawnSync3 } from "child_process";
17420
17421
  import { createRequire as createRequire3 } from "module";
17421
17422
  function currentVersion() {
17422
- const injected = "0.2.7"?.trim();
17423
+ const injected = "0.2.8"?.trim();
17423
17424
  if (injected) return injected;
17424
17425
  try {
17425
17426
  const req2 = createRequire3(import.meta.url);
@@ -17462,6 +17463,35 @@ function serviceManager() {
17462
17463
  if (v === "systemd" || v === "launchd") return v;
17463
17464
  return detectServiceManager();
17464
17465
  }
17466
+ function parseServiceEnvironment(raw) {
17467
+ const out = {};
17468
+ for (const token of raw.trim().split(/\s+/)) {
17469
+ const idx = token.indexOf("=");
17470
+ if (idx > 0) out[token.slice(0, idx)] = token.slice(idx + 1);
17471
+ }
17472
+ return out;
17473
+ }
17474
+ var cachedServiceEnv = null;
17475
+ function readServiceEnvironment() {
17476
+ const serviceName = process.env.ZQAGENT_SERVICE_NAME?.trim() || DEFAULT_SERVICE_NAME;
17477
+ try {
17478
+ const res = spawnSync3(
17479
+ "systemctl",
17480
+ ["show", serviceName, "--property=Environment", "--value", "--no-pager"],
17481
+ { encoding: "utf8", timeout: 3e3 }
17482
+ );
17483
+ if (res.status !== 0 || !res.stdout) return {};
17484
+ return parseServiceEnvironment(res.stdout);
17485
+ } catch {
17486
+ return {};
17487
+ }
17488
+ }
17489
+ function serviceEnvValue(key) {
17490
+ if (process.platform !== "linux") return void 0;
17491
+ if (serviceManager() !== "systemd") return void 0;
17492
+ cachedServiceEnv ??= readServiceEnvironment();
17493
+ return cachedServiceEnv[key];
17494
+ }
17465
17495
  function selfUpdateCapability(hasPublicKey) {
17466
17496
  if (!isSeaRuntime()) {
17467
17497
  return {
@@ -17614,7 +17644,9 @@ function readRollbackTarget(dataDir) {
17614
17644
  var DEFAULT_BASE = "https://agent.cd-zq.com/downloads/zqagent";
17615
17645
  function env(key) {
17616
17646
  const v = process.env[key]?.trim();
17617
- return v ? v : void 0;
17647
+ if (v) return v;
17648
+ const fromService = serviceEnvValue(key)?.trim();
17649
+ return fromService ? fromService : void 0;
17618
17650
  }
17619
17651
  function num(key, fallback) {
17620
17652
  const n = Number(env(key));
@@ -17651,7 +17683,7 @@ var UpdateController = class {
17651
17683
  return parsePublicKey(env("ZQAGENT_UPDATE_PUBKEY") ?? "");
17652
17684
  }
17653
17685
  get autoUpdateOff() {
17654
- return process.env.ZQAGENT_AUTO_UPDATE?.trim() === "0";
17686
+ return env("ZQAGENT_AUTO_UPDATE") === "0";
17655
17687
  }
17656
17688
  get enabled() {
17657
17689
  return !this.autoUpdateOff && selfUpdateCapability(Boolean(this.publicKey)).ok;