(appPath: string, config?: LaunchConfig)
| 19 | } |
| 20 | |
| 21 | export const launch = async (appPath: string, config?: LaunchConfig): Promise<LaunchResult> => { |
| 22 | if (!appPath) { |
| 23 | throw new Error('appPath is required'); |
| 24 | } |
| 25 | |
| 26 | try { |
| 27 | // Agent.run() returns the parsed LaunchAgentResult via postProcessor |
| 28 | const agentResult = (await createLaunchAgent().run( |
| 29 | launchAgentInstruction({ |
| 30 | appPath, |
| 31 | skipDependencyInstall: config?.skipDependencyInstall, |
| 32 | }) |
| 33 | )) as LaunchAgentResult; |
| 34 | |
| 35 | // If agent explicitly failed, return the error |
| 36 | if (agentResult.success === false) { |
| 37 | return { |
| 38 | success: false, |
| 39 | error: agentResult.error ?? 'Launch agent failed without error message', |
| 40 | }; |
| 41 | } |
| 42 | |
| 43 | // postProcessor already validates serverKey, url, port are present when success=true |
| 44 | // So we can safely return them here |
| 45 | return { |
| 46 | success: true, |
| 47 | message: agentResult.message ?? 'Launch and quality assurance completed', |
| 48 | serverKey: agentResult.serverKey, |
| 49 | url: agentResult.url, |
| 50 | port: agentResult.port, |
| 51 | }; |
| 52 | } catch (error) { |
| 53 | return { |
| 54 | success: false, |
| 55 | error: error instanceof Error ? error.message : String(error), |
| 56 | }; |
| 57 | } |
| 58 | }; |
no test coverage detected