CI : Update agent from web
This commit is contained in:
@@ -21,9 +21,12 @@ import { loadConfig, persistIdentity, type AgentConfig } from './config.ts';
|
||||
import { runDiagnostics } from './doctor.ts';
|
||||
import { ObsController } from './obs.ts';
|
||||
import { StreamWatcher } from './watcher.ts';
|
||||
import { currentBuildId, runningBundlePath, selfUpdate } from './updater.ts';
|
||||
import { cpuUsagePercent, diskUsage, memoryUsage } from './system.ts';
|
||||
|
||||
const AGENT_VERSION = '0.1.0';
|
||||
/** Empreinte du bundle courant, calculée une fois au démarrage. */
|
||||
const BUILD_ID = currentBuildId();
|
||||
const RECONNECT_MIN_MS = 1000;
|
||||
const RECONNECT_MAX_MS = 30_000;
|
||||
|
||||
@@ -194,6 +197,14 @@ async function runAction(action: AgentAction, params: Record<string, unknown>):
|
||||
return watcher.checkNow();
|
||||
case 'hotkey.fullscreen':
|
||||
return watcher.restoreFullscreen();
|
||||
case 'agent.update':
|
||||
return selfUpdate(
|
||||
typeof params.url === 'string' && params.url ? params.url : config.packageUrl,
|
||||
{
|
||||
recordState: () => obs.recordState(),
|
||||
log: (level, message) => report(level, message),
|
||||
},
|
||||
);
|
||||
default:
|
||||
return obs.execute(action, params);
|
||||
}
|
||||
@@ -214,6 +225,8 @@ async function buildStatus(): Promise<AgentStatus> {
|
||||
...emptyStatus(),
|
||||
...snapshot,
|
||||
watch: watcher.snapshot,
|
||||
buildId: BUILD_ID,
|
||||
canSelfUpdate: Boolean(runningBundlePath() && config.packageUrl),
|
||||
lastRecordingPath: obs.recordingPath,
|
||||
systemCpu: cpuUsagePercent(),
|
||||
systemMemoryUsed: memory.used,
|
||||
|
||||
Reference in New Issue
Block a user