mirror of
https://github.com/stablyai/orca.git
synced 2026-11-15 10:27:33 +00:00
fix(browser): wait for the Orca agent-browser config before the startup sweep
This commit is contained in:
@@ -46,7 +46,7 @@ export function createAgentBrowserProcessEnvironment(options: {
|
||||
return { env, ownsSocketDirectory: true }
|
||||
}
|
||||
|
||||
/** Until this lands, agent-browser reads the user's config files; a missing file would fail every command. */
|
||||
/** Until this lands, agent-browser reads the user's ~/.agent-browser/config.json and ./agent-browser.json. */
|
||||
export async function pointAtEmptyAgentBrowserConfig(
|
||||
env: NodeJS.ProcessEnv,
|
||||
userDataPath: string
|
||||
|
||||
@@ -5,6 +5,7 @@ import type { AgentBrowserCleanupOptions } from './agent-browser-cleanup-options
|
||||
|
||||
export abstract class AgentBrowserBridgeShutdown extends AgentBrowserBridgeLifecycle {
|
||||
async sweepOrphanedSessions(): Promise<string[]> {
|
||||
await this.agentBrowserConfigReady
|
||||
return sweepOrphanedAgentBrowserSessions({
|
||||
binaryPath: this.agentBrowserBin,
|
||||
env: this.agentBrowserEnv,
|
||||
|
||||
@@ -25,6 +25,8 @@ export abstract class AgentBrowserBridgeState {
|
||||
protected readonly processingQueues = new Set<string>()
|
||||
protected readonly agentBrowserBin: string
|
||||
protected readonly agentBrowserEnv: NodeJS.ProcessEnv
|
||||
// Startup spawns await it; agent commands come long after it lands.
|
||||
protected readonly agentBrowserConfigReady: Promise<void>
|
||||
protected readonly ownsAgentBrowserSocketDirectory: boolean
|
||||
// Null disables idle-replacement detection when daemon lifetime is unbounded.
|
||||
protected readonly agentBrowserIdleTimeoutMs: number | null
|
||||
@@ -48,8 +50,11 @@ export abstract class AgentBrowserBridgeState {
|
||||
userDataPath
|
||||
})
|
||||
this.agentBrowserEnv = processEnvironment.env
|
||||
// Lands long before an agent's first command; a failed write keeps agent-browser's own lookup.
|
||||
void pointAtEmptyAgentBrowserConfig(this.agentBrowserEnv, userDataPath).catch(() => {})
|
||||
// A failed write keeps agent-browser's own lookup; a missing file would fail every command.
|
||||
this.agentBrowserConfigReady = pointAtEmptyAgentBrowserConfig(
|
||||
this.agentBrowserEnv,
|
||||
userDataPath
|
||||
).catch(() => {})
|
||||
this.ownsAgentBrowserSocketDirectory = processEnvironment.ownsSocketDirectory
|
||||
const idleTimeoutMs = Number(this.agentBrowserEnv.AGENT_BROWSER_IDLE_TIMEOUT_MS)
|
||||
this.agentBrowserIdleTimeoutMs = idleTimeoutMs > 0 ? idleTimeoutMs : null
|
||||
|
||||
Reference in New Issue
Block a user