Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
feat(hub): integrate ChannelManager into Hub lifecycle
Naiyuan Qing9922355d0c55
diff --git a/package.json b/package.jsonindex 38c7ec1ac5..e5d4d86356 100644--- a/package.json+++ b/package.json@@ -30,7 +30,10 @@"license": "ISC","packageManager": "[email protected]","pnpm": {- "onlyBuiltDependencies": ["electron", "esbuild"]+ "onlyBuiltDependencies": [+ "electron",+ "esbuild"+ ]},"devDependencies": {"@types/node": "catalog:",@@ -58,6 +61,7 @@"@nestjs/websockets": "^11.1.12","@sinclair/typebox": "^0.34.41","fast-glob": "^3.3.3",+ "grammy": "^1.39.3","json5": "^2.2.3","linkedom": "^0.18.12","nestjs-pino": "^4.5.0",diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 4e60a83f1c..a63c92f072 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -71,6 +71,9 @@ importers:fast-glob:specifier: ^3.3.3version: 3.3.3+ grammy:+ specifier: ^1.39.3+ version: 1.39.3json5:specifier: ^2.2.3version: 2.2.3@@ -1829,6 +1832,9 @@ packages:'@modelcontextprotocol/sdk':optional: true+ '@grammyjs/[email protected]':+ resolution: {integrity: sha512-D3jQ4UWERPsyR3op/YFudMMIPNTU47vy7L51uO9/73tMELmjO/+LX5N36/Y0CG5IQfIsz43MxiHI5rgsK0/k+g==}+'@hono/[email protected]':resolution: {integrity: sha512-vHL6w3ecZsky+8P5MD+eFfaGTyCeOHUIFYMGpQGbrBTSmNNoxv0if69rEZ5giu36weC5saFuznL411gRX7bJDw==}engines: {node: '>=18.14.1'}@@ -5741,6 +5747,10 @@ packages:resolution: {integrity: sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==}+ resolution: {integrity: sha512-7arRRoOtOh9UwMwANZ475kJrWV6P3/EGNooeHlY0/SwZv4t3ZZ3Uiz9cAXK8Zg9xSdgmm8T21kx6n7SZaWvOcw==}+ engines: {node: ^12.20.0 || >=14.13.1}+resolution: {integrity: sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==}@@ -11181,6 +11191,8 @@ snapshots:- supports-color- utf-8-validate+ '@grammyjs/[email protected]': {}+'@hono/[email protected]([email protected])':dependencies:hono: 4.11.7@@ -14935,7 +14947,7 @@ snapshots:transitivePeerDependencies:- supports-color- [email protected](@typescript-eslint/[email protected]([email protected]([email protected]))([email protected]))([email protected])([email protected])([email protected]([email protected])):+ [email protected](@typescript-eslint/[email protected]([email protected]([email protected]))([email protected]))([email protected])([email protected]([email protected])([email protected]([email protected])))([email protected]([email protected])):dependencies:debug: 3.2.7optionalDependencies:@@ -14966,7 +14978,7 @@ snapshots:doctrine: 2.1.0eslint: 9.39.2([email protected])eslint-import-resolver-node: 0.3.9- eslint-module-utils: 2.12.1(@typescript-eslint/[email protected]([email protected]([email protected]))([email protected]))([email protected])([email protected])([email protected]([email protected]))+ eslint-module-utils: 2.12.1(@typescript-eslint/[email protected]([email protected]([email protected]))([email protected]))([email protected])([email protected]([email protected])([email protected]([email protected])))([email protected]([email protected]))hasown: 2.0.2is-core-module: 2.16.1is-glob: 4.0.3@@ -15881,6 +15893,16 @@ snapshots:+ dependencies:+ '@grammyjs/types': 3.23.0+ abort-controller: 3.0.0+ debug: 4.4.3+ node-fetch: 2.7.0+ transitivePeerDependencies:+ - encoding+ - supports-color+diff --git a/src/hub/hub.ts b/src/hub/hub.tsindex 8ba68d64a6..2bee8078a8 100644--- a/src/hub/hub.ts+++ b/src/hub/hub.ts@@ -30,6 +30,7 @@ import { evaluateCommandSafety, requiresApproval } from "../agent/tools/exec-safimport { addAllowlistEntry, recordAllowlistUse, matchAllowlist } from "../agent/tools/exec-allowlist.js";import type { ExecApprovalCallback, ExecApprovalConfig, ApprovalResult, ExecApprovalRequest } from "../agent/tools/exec-approval-types.js";import { readProfileConfig, writeProfileConfig } from "../agent/profile/storage.js";+import { ChannelManager, initChannels } from "../channels/index.js";export class Hub {private readonly agents = new Map<string, AsyncAgent>();@@ -43,6 +44,7 @@ export class Hub {readonly deviceStore: DeviceStore;private _onConfirmDevice: ((deviceId: string, agentId: string, meta?: DeviceMeta) => Promise<boolean>) | null = null;private _stateChangeListeners: ((state: ConnectionState) => void)[] = [];+ readonly channelManager: ChannelManager;url: string;readonly path: string;readonly hubId: string;@@ -103,6 +105,14 @@ export class Hub {this.client = this.createClient(this.url);this.client.connect();this.restoreAgents();++ // Initialize channel plugin system+ console.log("[Hub] Initializing channel system...");+ initChannels();+ this.channelManager = new ChannelManager(this);+ void this.channelManager.startAll().then(() => {+ console.log("[Hub] Channel system started");+ });}/** Restore agents from persistent storage */@@ -508,6 +518,9 @@ export class Hub {}shutdown(): void {+ // Stop all channel connections+ this.channelManager.stopAll();+// Finalize subagent registry before closing agentsshutdownSubagentRegistry();