feat: add uv mirror detection and python bootstrap (#24)
Co-authored-by: chatgpt-codex-connector[bot] <199175422+chatgpt-codex-connector[bot]@users.noreply.github.com>
This commit is contained in:
@@ -20,6 +20,8 @@ import { getApiKey } from '../utils/secure-storage';
|
||||
import { getProviderEnvVar } from '../utils/openclaw-auth';
|
||||
import { GatewayEventType, JsonRpcNotification, isNotification, isResponse } from './protocol';
|
||||
import { logger } from '../utils/logger';
|
||||
import { getUvMirrorEnv } from '../utils/uv-env';
|
||||
import { isPythonReady, setupManagedPython } from '../utils/uv-setup';
|
||||
|
||||
/**
|
||||
* Gateway connection status
|
||||
@@ -149,6 +151,17 @@ export class GatewayManager extends EventEmitter {
|
||||
this.setStatus({ state: 'starting', reconnectAttempts: 0 });
|
||||
|
||||
try {
|
||||
// Check if Python environment is ready (self-healing)
|
||||
const pythonReady = await isPythonReady();
|
||||
if (!pythonReady) {
|
||||
logger.info('Python environment missing or incomplete, attempting background repair...');
|
||||
// We don't await this to avoid blocking Gateway startup,
|
||||
// as uv run will handle it if needed, but this pre-warms it.
|
||||
void setupManagedPython().catch(err => {
|
||||
logger.error('Background Python repair failed:', err);
|
||||
});
|
||||
}
|
||||
|
||||
// Check if Gateway is already running
|
||||
logger.info('Checking for existing Gateway...');
|
||||
const existing = await this.findExistingGateway();
|
||||
@@ -470,12 +483,15 @@ export class GatewayManager extends EventEmitter {
|
||||
logger.warn(`Failed to load API key for ${providerType}:`, err);
|
||||
}
|
||||
}
|
||||
|
||||
const uvEnv = await getUvMirrorEnv();
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
const spawnEnv: Record<string, string | undefined> = {
|
||||
...process.env,
|
||||
PATH: finalPath,
|
||||
...providerEnv,
|
||||
...uvEnv,
|
||||
OPENCLAW_GATEWAY_TOKEN: gatewayToken,
|
||||
OPENCLAW_SKIP_CHANNELS: '',
|
||||
CLAWDBOT_SKIP_CHANNELS: '',
|
||||
|
||||
Reference in New Issue
Block a user