Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
refactor(hub): rename Device ID to Hub ID in console layer
yusheneb4ce85602c9
diff --git a/src/console/app.controller.ts b/src/console/app.controller.tsindex 999878edfd..0fbf2e2de1 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.htmlindex 567b1ac268..bcabc2fecd 100644--- a/src/console/public/index.html+++ b/src/console/public/index.html@@ -335,7 +335,7 @@<!-- Stats --><div class="stats" id="stats"><div class="stat-card">- <div class="stat-label">Device ID</div>+ <div class="stat-label">Hub ID</div><div class="stat-value" id="stat-device">—</div></div><div class="stat-card">@@ -425,7 +425,7 @@]);// Stats- const deviceId = hubRes.deviceId || '—';+ const deviceId = hubRes.hubId || '—';document.getElementById('stat-device').innerHTML =`<span title="${deviceId}">${truncateId(deviceId)}</span>` +(deviceId !== '—' ? `<button class="copy-btn" onclick="copyText('${deviceId}', this)">${copyIcon()}</button>` : '');diff --git a/src/hub/device.ts b/src/hub/hub-identity.tssimilarity index 52%rename from src/hub/device.tsrename to src/hub/hub-identity.tsindex 4e637b6259..75067eb57f 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.tsindex 77607d0d55..68a2d454b3 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.tsindex 4ea50bc637..fa55270860 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";