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, })); };