| 361 | * {@link PREVIEW_PORT}; the agent just binds the dev server and shares it. |
| 362 | */ |
| 363 | export function previewGuidance(previewUrl: string | undefined): string { |
| 364 | if (!previewUrl) { |
| 365 | return [ |
| 366 | `PREVIEW: start the app's dev server bound to 0.0.0.0 on port ${PREVIEW_PORT}`, |
| 367 | '(bind all interfaces + allow all hosts in the dev-server config first — for', |
| 368 | 'Vite: `server: { host: true, allowedHosts: true }`). The host exposes that', |
| 369 | 'port as a public preview URL; share it with the user once the server is up.', |
| 370 | ].join('\n') |
| 371 | } |
| 372 | return [ |
| 373 | `PREVIEW: this sandbox's port ${PREVIEW_PORT} is already wired to the public URL`, |
| 374 | `${previewUrl} . Start the app's dev server bound to 0.0.0.0 on port ${PREVIEW_PORT}`, |
| 375 | '(bind all interfaces + allow all hosts first — for Vite:', |
| 376 | '`server: { host: true, allowedHosts: true }`). Once it is listening, share this', |
| 377 | `exact preview URL with the user as a markdown link: [Open preview](${previewUrl}).`, |
| 378 | ].join('\n') |
| 379 | } |
| 380 | |
| 381 | // --------------------------------------------------------------------------- |
| 382 | // The sandbox definition (harness × provider) |