(
positionals: string[],
options: { flags: CliFlags; stateDir: string },
)
| 6 | type PublicAgentBrowserToolStatus = Omit<AgentBrowserToolStatus, 'socketDir'>; |
| 7 | |
| 8 | export async function runWebCommand( |
| 9 | positionals: string[], |
| 10 | options: { flags: CliFlags; stateDir: string }, |
| 11 | ): Promise<number> { |
| 12 | const action = positionals[0]; |
| 13 | switch (action) { |
| 14 | case 'setup': { |
| 15 | printWebSetupStart(options.flags.json); |
| 16 | const { setupManagedAgentBrowser } = |
| 17 | await import('../../platforms/web/agent-browser-tool.ts'); |
| 18 | const status = await setupManagedAgentBrowser({ |
| 19 | stateDir: options.stateDir, |
| 20 | }); |
| 21 | printWebSetupResult(options.flags.json, status); |
| 22 | return 0; |
| 23 | } |
| 24 | case 'doctor': { |
| 25 | const { doctorManagedAgentBrowser } = |
| 26 | await import('../../platforms/web/agent-browser-tool.ts'); |
| 27 | const result = await doctorManagedAgentBrowser({ |
| 28 | stateDir: options.stateDir, |
| 29 | }); |
| 30 | printWebResult( |
| 31 | options.flags.json, |
| 32 | result.exitCode === 0 ? 'Web backend is healthy.' : 'Web backend doctor reported issues.', |
| 33 | result, |
| 34 | ); |
| 35 | return result.exitCode; |
| 36 | } |
| 37 | default: |
| 38 | throw new AppError('INVALID_ARGS', 'web requires setup or doctor'); |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | function printWebSetupStart(json: boolean | undefined): void { |
| 43 | if (json) return; |
no test coverage detected