@lingyao037/openclaw-lingyao-cli 1.3.4 → 1.3.6

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/cli.mjs CHANGED
@@ -37,23 +37,8 @@ const NC = '\x1b[0m';
37
37
  */
38
38
  function getMachineId() {
39
39
  try {
40
- const interfaces = os.networkInterfaces();
41
- const macSet = new Set();
42
-
43
- for (const iface of Object.values(interfaces)) {
44
- if (!iface) continue;
45
- for (const alias of iface) {
46
- if (!alias.internal && alias.mac && alias.mac !== '00:00:00:00:00:00') {
47
- macSet.add(alias.mac);
48
- }
49
- }
50
- }
51
-
52
- if (macSet.size > 0) {
53
- const macStr = [...macSet].sort().join('');
54
- // MD5 哈希,与 orchestrator.ts 保持一致
55
- return createHash('md5').update(macStr).digest('hex').substring(0, 8);
56
- }
40
+ // hostname 在单台机器上跨重启稳定
41
+ return createHash('md5').update(os.hostname()).digest('hex').substring(0, 8);
57
42
  } catch (e) {
58
43
  // ignore
59
44
  }
package/dist/index.js CHANGED
@@ -412,7 +412,7 @@ function createSetupAdapter() {
412
412
  }
413
413
 
414
414
  // src/orchestrator.ts
415
- import { hostname, networkInterfaces } from "os";
415
+ import { hostname } from "os";
416
416
  import { createHash } from "crypto";
417
417
 
418
418
  // src/types.ts
@@ -2233,20 +2233,8 @@ var ErrorHandler = class {
2233
2233
  // src/orchestrator.ts
2234
2234
  function getMachineId() {
2235
2235
  try {
2236
- const interfaces = networkInterfaces();
2237
- const macSet = /* @__PURE__ */ new Set();
2238
- for (const iface of Object.values(interfaces)) {
2239
- if (!iface) continue;
2240
- for (const alias of iface) {
2241
- if (!alias.internal && alias.mac && alias.mac !== "00:00:00:00:00:00") {
2242
- macSet.add(alias.mac);
2243
- }
2244
- }
2245
- }
2246
- const macs = [...macSet].sort();
2247
- if (macs.length > 0) {
2248
- return createHash("md5").update(macs.join("")).digest("hex").substring(0, 8);
2249
- }
2236
+ const host = hostname();
2237
+ return createHash("md5").update(host).digest("hex").substring(0, 8);
2250
2238
  } catch (e) {
2251
2239
  }
2252
2240
  return Math.random().toString(36).substring(2, 10);
@@ -2273,8 +2261,30 @@ var MultiAccountOrchestrator = class {
2273
2261
  return;
2274
2262
  }
2275
2263
  this.runtime.logger.info(`Starting account "${accountId}"`);
2276
- const gatewayId = account.gatewayId ?? generateGatewayId(accountId);
2277
2264
  const storagePrefix = `lingyao:${accountId}`;
2265
+ const gatewayIdKey = `${storagePrefix}:persistedGatewayId`;
2266
+ let gatewayId = account.gatewayId;
2267
+ if (!gatewayId) {
2268
+ try {
2269
+ const stored = await this.runtime.storage.get(gatewayIdKey);
2270
+ if (stored && typeof stored === "string") {
2271
+ gatewayId = stored;
2272
+ this.runtime.logger.info(`Using persisted gatewayId: ${gatewayId}`);
2273
+ }
2274
+ } catch (e) {
2275
+ this.runtime.logger.warn(`Failed to read persisted gatewayId`, e);
2276
+ }
2277
+ }
2278
+ if (!gatewayId) {
2279
+ gatewayId = generateGatewayId(accountId);
2280
+ this.runtime.logger.info(`Generated new gatewayId: ${gatewayId}`);
2281
+ try {
2282
+ await this.runtime.storage.set(gatewayIdKey, gatewayId);
2283
+ this.runtime.logger.info(`Persisted gatewayId: ${gatewayId}`);
2284
+ } catch (e) {
2285
+ this.runtime.logger.warn(`Failed to persist gatewayId`, e);
2286
+ }
2287
+ }
2278
2288
  const accountManager = new AccountManager(this.runtime);
2279
2289
  const probe = new Probe(this.runtime);
2280
2290
  const monitor = new Monitor(this.runtime);