From a7d541dcc019eae2f0e2edcbaaa025b38ef43d4b Mon Sep 17 00:00:00 2001 From: operator Date: Sun, 19 Apr 2026 05:36:08 +0000 Subject: [PATCH] fix: pass gateway auth token in WebSocket hello Read gateway.auth.token from config via api.runtime.config.loadConfig() and include it in the hello handshake. Co-Authored-By: Claude Opus 4.6 (1M context) --- plugin/index.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/plugin/index.ts b/plugin/index.ts index 7300abb..6fb1c6e 100644 --- a/plugin/index.ts +++ b/plugin/index.ts @@ -200,8 +200,11 @@ export default { try { // Connect to gateway via WebSocket and trigger an agent turn. // Uses the same gateway RPC that sessions_spawn and cron use internally. - const gatewayUrl = 'ws://127.0.0.1:18789'; - const WS = (globalThis as any).WebSocket ?? (await import('node:http')).default; + const cfg = api.runtime?.config?.loadConfig?.() ?? {}; + const gwCfg = cfg.gateway ?? {}; + const gwPort = gwCfg.port ?? 18789; + const gwToken = gwCfg.auth?.token ?? ''; + const gatewayUrl = `ws://127.0.0.1:${gwPort}`; const result = await new Promise<{ sessionId?: string; error?: string }>((resolve, reject) => { const timeout = setTimeout(() => { @@ -220,7 +223,11 @@ export default { client.send(JSON.stringify({ jsonrpc: '2.0', method: 'hello', - params: { clientName: 'harbor-forge-calendar', mode: 'backend' }, + params: { + clientName: 'harbor-forge-calendar', + mode: 'backend', + ...(gwToken ? { token: gwToken } : {}), + }, id: 1, })); };