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) <noreply@anthropic.com>
This commit is contained in:
@@ -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,
|
||||
}));
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user