Humans-in-the-loop can access in-progress invocations to observe browser-based automations in real-time, resolve errors, or take unscripted actions.
To access Live View, print the browser_live_view_url
to the console after you’ve invoked your app:
Typescript/Javascript
Python
import { Kernel } from '@onkernel/sdk' ;
import { chromium } from 'playwright' ;
const kernel = new Kernel ( ) ;
const app = kernel. app ( 'browser-automation' ) ;
const playwrightScript = async ( runtimeContext, payload) => {
const kernelBrowser = await kernel. browsers. create ( { invocation_id: runtime_context. invocation_id } ) ;
console . log ( kernelBrowser. browser_live_view_url) ;
const browser = await chromium. connectOverCDP ( kernelBrowser. cdp_ws_url) ;
try {
const context = await browser. newContext ( ) ;
const page = await context. newPage ( ) ;
await page. waitForTimeout ( 15000 ) ;
await page. goto ( "https://www.google.com" ) ;
const title = await page. title ( ) ;
} catch ( error) {
console . error ( error) ;
} finally {
await browser. close ( ) ;
}
} ;
app. action ( "my-action-name" , playwrightScript) ;
In a separate terminal, tail the logs to print the live view URL:
There currently isn’t a way to end a invocation from the live view.
Browser persistence
If you marked a browser for persistence, browser_live_view_url
remains active after the invocation ends. It remains active until you terminate the browser .
For browsers not marked for persistence, browser_live_view_url
becomes invalid once the invocation’s status reaches a terminal state (SUCCEEDED
or FAILED
).