feat(gateway): sync gateway token and update agent models on provider… (#168)

This commit is contained in:
Haze
2026-02-25 18:56:04 +08:00
committed by GitHub
Unverified
parent 2804b6da73
commit e8c11887d0
3 changed files with 185 additions and 0 deletions

View File

@@ -29,6 +29,7 @@ import {
buildDeviceAuthPayload,
type DeviceIdentity,
} from '../utils/device-identity';
import { syncGatewayTokenToConfig } from '../utils/openclaw-auth';
/**
* Gateway connection status
@@ -559,6 +560,17 @@ export class GatewayManager extends EventEmitter {
// Get or generate gateway token
const gatewayToken = await getSetting('gatewayToken');
// Write our token into openclaw.json before starting the process.
// Without --dev the gateway authenticates using the token in
// openclaw.json; if that file has a stale token (e.g. left by the
// system-managed launchctl service) the WebSocket handshake will fail
// with "token mismatch" even though we pass --token on the CLI.
try {
syncGatewayTokenToConfig(gatewayToken);
} catch (err) {
logger.warn('Failed to sync gateway token to openclaw.json:', err);
}
let command: string;
let args: string[];