@@ -5,10 +5,8 @@ export const EXECUTE_SCRIPT_DEFINITION: ToolDefinition = {
55 name : "execute_script" ,
66 description :
77 "Execute JavaScript code. " +
8- "target='page': run in a browser tab with DOM access. world param (page only): " +
9- "ISOLATED (default) — extension-isolated context, can fetch extension blob URLs (blob:chrome-extension://...) AND manipulate page DOM, ideal for bridging OPFS files to page operations; " +
10- "MAIN — shares page's window/globals (access page JS variables, call page functions), but cannot access extension URLs. " +
11- "target='sandbox': isolated computation environment, no DOM, no world param." ,
8+ "target='page': run in a browser tab with DOM access, shares page's window/globals (can access page JS variables, call page functions). " +
9+ "target='sandbox': isolated computation environment, no DOM." ,
1210 parameters : {
1311 type : "object" ,
1412 properties : {
@@ -22,12 +20,6 @@ export const EXECUTE_SCRIPT_DEFINITION: ToolDefinition = {
2220 type : "number" ,
2321 description : "Target tab ID for page execution. Defaults to active tab. Ignored for sandbox." ,
2422 } ,
25- world : {
26- type : "string" ,
27- enum : [ "MAIN" , "ISOLATED" ] ,
28- description :
29- "JS execution world for page target. MAIN shares page globals, ISOLATED is extension-isolated. Default: ISOLATED. Ignored for sandbox." ,
30- } ,
3123 } ,
3224 required : [ "code" , "target" ] ,
3325 } ,
@@ -47,7 +39,7 @@ function withTimeout<T>(promise: Promise<T>, ms: number): Promise<T> {
4739export type ExecuteScriptDeps = {
4840 executeInPage : (
4941 code : string ,
50- options ?: { tabId ?: number ; world ?: "MAIN" | "ISOLATED" }
42+ options ?: { tabId ?: number }
5143 ) => Promise < { result : unknown ; tabId : number } > ;
5244 executeInSandbox : ( code : string ) => Promise < unknown > ;
5345 timeoutMs ?: number ; // 可选超时(ms),默认 30s,测试用
@@ -76,8 +68,7 @@ export function createExecuteScriptTool(deps: ExecuteScriptDeps): {
7668
7769 if ( target === "page" ) {
7870 const tabId = args . tab_id as number | undefined ;
79- const world = ( args . world as "MAIN" | "ISOLATED" | undefined ) || undefined ;
80- const { result, tabId : actualTabId } = await withTimeout ( deps . executeInPage ( code , { tabId, world } ) , timeoutMs ) ;
71+ const { result, tabId : actualTabId } = await withTimeout ( deps . executeInPage ( code , { tabId } ) , timeoutMs ) ;
8172 return JSON . stringify ( { result : result ?? null , target : "page" , tab_id : actualTabId } ) ;
8273 }
8374
0 commit comments