feat: implement OpenClaw process owner and runtime path utilities
- Add OpenClawProcessOwner class to manage the lifecycle of the OpenClaw process. - Introduce utility functions for managing OpenClaw runtime paths. - Update session store to normalize agent session keys and migrate existing keys. - Refactor main process to handle local provider API routing through a new dispatch function. - Enhance token usage writer to utilize a new session key parsing function. - Create agents management store to handle agent data and interactions. - Update chat store to integrate agent selection and session management. - Introduce AgentsSection component for displaying agent information in the UI. - Refactor HomePage to support agent selection and display current agent. - Update routing to reflect new agents page structure.
This commit is contained in:
@@ -7,14 +7,60 @@ import * as providerHandlers from './handlers/provider';
|
||||
|
||||
class GatewayManager {
|
||||
private initialized = false;
|
||||
private status: 'connected' | 'disconnected' | 'reconnecting' = 'disconnected';
|
||||
|
||||
private setStatus(status: 'connected' | 'disconnected' | 'reconnecting'): void {
|
||||
this.status = status;
|
||||
this.broadcast({ type: 'gateway:status', status });
|
||||
}
|
||||
|
||||
async init(): Promise<void> {
|
||||
if (this.initialized) return;
|
||||
this.initialized = true;
|
||||
this.status = 'connected';
|
||||
logManager.info('GatewayManager initialized');
|
||||
this.broadcast({ type: 'gateway:status', status: 'connected' });
|
||||
}
|
||||
|
||||
async start(): Promise<void> {
|
||||
await this.init();
|
||||
}
|
||||
|
||||
async stop(): Promise<void> {
|
||||
this.initialized = false;
|
||||
this.setStatus('disconnected');
|
||||
}
|
||||
|
||||
async restart(): Promise<void> {
|
||||
this.initialized = false;
|
||||
this.setStatus('reconnecting');
|
||||
await this.init();
|
||||
}
|
||||
|
||||
getStatus(): {
|
||||
status: 'connected' | 'disconnected' | 'reconnecting';
|
||||
initialized: boolean;
|
||||
mode: 'in-process';
|
||||
} {
|
||||
return {
|
||||
status: this.status,
|
||||
initialized: this.initialized,
|
||||
mode: 'in-process',
|
||||
};
|
||||
}
|
||||
|
||||
async checkHealth(): Promise<{
|
||||
ok: boolean;
|
||||
status: 'connected' | 'disconnected' | 'reconnecting';
|
||||
initialized: boolean;
|
||||
mode: 'in-process';
|
||||
}> {
|
||||
return {
|
||||
ok: this.initialized && this.status === 'connected',
|
||||
...this.getStatus(),
|
||||
};
|
||||
}
|
||||
|
||||
async rpc(method: string, params: any): Promise<any> {
|
||||
if (!this.initialized) {
|
||||
await this.init();
|
||||
|
||||
Reference in New Issue
Block a user