@@ -8,6 +8,32 @@ import {
88} from "../../shared/ExtensionMessage"
99import { formatResponse } from "../prompts/responses"
1010
11+ function toStringlyTyped_kilocode ( value : string | number [ ] | object | null | undefined ) : string | undefined {
12+ if ( typeof value === "string" ) {
13+ console . debug ( "toStringlyTyped: returning string as-is" , value )
14+ return value
15+ }
16+ if ( Array . isArray ( value ) ) {
17+ console . debug (
18+ "toStringlyTyped: model returned an array, this is not allowed by either the XML or JSON tool." ,
19+ value ,
20+ )
21+ return value . join ( "," )
22+ }
23+ if ( value && typeof value === "object" ) {
24+ if ( "x" in value && "y" in value ) {
25+ console . debug ( "toStringlyTyped: x,y object" , value )
26+ return `${ value . x } ,${ value . y } `
27+ }
28+ if ( "width" in value && "height" in value ) {
29+ console . debug ( "toStringlyTyped: width,height object" , value )
30+ return `${ value . width } ,${ value . height } `
31+ }
32+ }
33+ console . debug ( "toStringlyTyped: returning undefined" , value )
34+ return undefined
35+ }
36+
1137export async function browserActionTool (
1238 cline : Task ,
1339 block : ToolUse ,
@@ -18,9 +44,9 @@ export async function browserActionTool(
1844) {
1945 const action : BrowserAction | undefined = block . params . action as BrowserAction
2046 const url : string | undefined = block . params . url
21- const coordinate : string | undefined = block . params . coordinate
47+ const coordinate : string | undefined = toStringlyTyped_kilocode ( block . params . coordinate )
2248 const text : string | undefined = block . params . text
23- const size : string | undefined = block . params . size
49+ const size : string | undefined = toStringlyTyped_kilocode ( block . params . size )
2450
2551 if ( ! action || ! browserActions . includes ( action ) ) {
2652 // checking for action to ensure it is complete and valid
0 commit comments