diff --git a/src/console/app.controller.ts b/src/console/app.controller.ts
index 999878ed..0fbf2e2d 100644
--- a/src/console/app.controller.ts
+++ b/src/console/app.controller.ts
@@ -17,7 +17,7 @@ export class AppController {
@Get("hub")
getHub() {
return {
- deviceId: this.hub.deviceId,
+ hubId: this.hub.hubId,
url: this.hub.url,
connectionState: this.hub.connectionState,
agentCount: this.hub.listAgents().length,
diff --git a/src/console/public/index.html b/src/console/public/index.html
index 567b1ac2..bcabc2fe 100644
--- a/src/console/public/index.html
+++ b/src/console/public/index.html
@@ -335,7 +335,7 @@
@@ -425,7 +425,7 @@
]);
// Stats
- const deviceId = hubRes.deviceId || '—';
+ const deviceId = hubRes.hubId || '—';
document.getElementById('stat-device').innerHTML =
`${truncateId(deviceId)}` +
(deviceId !== '—' ? `` : '');
diff --git a/src/hub/device.ts b/src/hub/hub-identity.ts
similarity index 52%
rename from src/hub/device.ts
rename to src/hub/hub-identity.ts
index 4e637b62..75067eb5 100644
--- a/src/hub/device.ts
+++ b/src/hub/hub-identity.ts
@@ -3,20 +3,20 @@ import { join } from "node:path";
import { v7 as uuidv7 } from "uuid";
import { DATA_DIR } from "../shared/index.js";
-const DEVICE_ID_FILE = join(DATA_DIR, "device-id");
+const HUB_ID_FILE = join(DATA_DIR, "hub-id");
/**
- * 获取当前设备的 ID。
- * 首次调用时生成 UUIDv7 并持久化到 ~/.multica/device-id,
+ * 获取当前 Hub 的 ID。
+ * 首次调用时生成 UUIDv7 并持久化到 ~/.super-multica/hub-id,
* 后续调用直接读取。
*/
-export function getDeviceId(): string {
+export function getHubId(): string {
try {
- return readFileSync(DEVICE_ID_FILE, "utf-8").trim();
+ return readFileSync(HUB_ID_FILE, "utf-8").trim();
} catch {
const id = uuidv7();
mkdirSync(DATA_DIR, { recursive: true });
- writeFileSync(DEVICE_ID_FILE, id, "utf-8");
+ writeFileSync(HUB_ID_FILE, id, "utf-8");
return id;
}
}
diff --git a/src/hub/hub.ts b/src/hub/hub.ts
index 77607d0d..68a2d454 100644
--- a/src/hub/hub.ts
+++ b/src/hub/hub.ts
@@ -1,7 +1,7 @@
import type { HubOptions } from "./types.js";
import type { ConnectionState } from "../shared/gateway-sdk/types.js";
import { AsyncAgent } from "../agent/async-agent.js";
-import { getDeviceId } from "./device.js";
+import { getHubId } from "./hub-identity.js";
import { GatewayClient } from "../shared/gateway-sdk/client.js";
import { loadAgentRecords, addAgentRecord, removeAgentRecord } from "./agent-store.js";
@@ -11,7 +11,7 @@ export class Hub {
private client: GatewayClient;
url: string;
readonly path: string;
- readonly deviceId: string;
+ readonly hubId: string;
/** Current Gateway connection state */
get connectionState(): ConnectionState {
@@ -21,7 +21,7 @@ export class Hub {
constructor(url: string, path?: string) {
this.url = url;
this.path = path ?? "/ws";
- this.deviceId = getDeviceId();
+ this.hubId = getHubId();
this.client = this.createClient(this.url);
this.client.connect();
this.restoreAgents();
@@ -42,7 +42,7 @@ export class Hub {
const client = new GatewayClient({
url,
path: this.path,
- deviceId: this.deviceId,
+ deviceId: this.hubId,
deviceType: "client",
autoReconnect: true,
reconnectDelay: 1000,
diff --git a/src/hub/index.ts b/src/hub/index.ts
index 4ea50bc6..fa552708 100644
--- a/src/hub/index.ts
+++ b/src/hub/index.ts
@@ -1,3 +1,3 @@
export { Hub } from "./hub.js";
-export { getDeviceId } from "./device.js";
+export { getHubId } from "./hub-identity.js";
export type { HubOptions } from "./types.js";