@@ -15,18 +15,18 @@ if (!process.env.OPENAI_API_KEY) throw new Error('OPENAI_API_KEY is not set');
1515 * Example app that run an agent using openai CUA
1616 * Args:
1717 * ctx: Kernel context containing invocation information
18- * payload: An object with a `query ` property
18+ * payload: An object with a `task ` property
1919 * Returns:
20- * An answer to the query , elapsed time and optionally the messages stack
20+ * An answer to the task , elapsed time and optionally the messages stack
2121 * Invoke this via CLI:
2222 * export KERNEL_API_KEY=<your_api_key>
2323 * kernel deploy index.ts -e OPENAI_API_KEY=XXXXX --force
24- * kernel invoke ts-cua cua-task -p "{\"query \":\"current market price range for a used dreamcast\"}"
24+ * kernel invoke ts-cua cua-task -p "{\"task \":\"current market price range for a used dreamcast\"}"
2525 * kernel logs ts-cua -f # Open in separate tab
2626 */
2727
2828interface CuaInput {
29- query : string ;
29+ task : string ;
3030}
3131
3232interface CuaOutput {
@@ -47,28 +47,28 @@ app.action<CuaInput, CuaOutput>(
4747 kernelBrowser . browser_live_view_url ,
4848 ) ;
4949
50- if ( ! payload ?. query ) {
51- throw new Error ( 'query is required' ) ;
50+ if ( ! payload ?. task ) {
51+ throw new Error ( 'task is required' ) ;
5252 }
5353
5454 try {
5555
5656 // kernel browser
5757 const { computer } = await computers . create ( {
58- type : "kernel" ,
58+ type : "kernel" , // for local testing before deploying to Kernel, you can use type: "local"
5959 cdp_ws_url : kernelBrowser . cdp_ws_url ,
6060 } ) ;
6161
6262 // setup agent
63- const agent = new Agent (
64- "computer-use-preview" ,
63+ const agent = new Agent ( {
64+ model : "computer-use-preview" ,
6565 computer,
66- [ ] , // additional tools
67- ( message : string ) => {
66+ tools : [ ] , // additional function_call tools to provide to the llm
67+ acknowledge_safety_check_callback : ( message : string ) => {
6868 console . log ( `> safety check: ${ message } ` ) ;
6969 return true ; // Auto-acknowledge all safety checks for testing
7070 } ,
71- ) ;
71+ } ) ;
7272
7373 // start agent run
7474 const response = await agent . runFullTurn ( {
@@ -83,7 +83,7 @@ app.action<CuaInput, CuaOutput>(
8383 content : [
8484 {
8585 type : "input_text" ,
86- text : payload . query ,
86+ text : payload . task ,
8787 // text: "go to https://news.ycombinator.com , open top article , describe the target website design (in yaml format)"
8888 } ,
8989 ] ,
0 commit comments