@mcp-b/extension-tools 0.3.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -29,7 +29,7 @@ import{z as e}from"zod";import{SMART_DOM_READER_BUNDLE as t}from"@mcp-b/smart-do
|
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
31
|
})();
|
|
32
|
-
`}],runAt:`document_idle`,world:`USER_SCRIPT`,allFrames:n}]),await chrome.tabs.reload(e);let o=await Promise.race([a,new Promise(e=>setTimeout(()=>e({timeout:!0}),5e3))]);return await chrome.userScripts.unregister({ids:[i]}),o.timeout?this.formatError(Error(`Script execution timed out`)):this.formatJson(o)}catch(e){return this.formatError(e)}})}registerInsertCSS(){this.server.registerTool(`extension_tool_insert_css`,{description:`Insert CSS into a tab. If no tabId is specified, operates on the currently active tab`,inputSchema:{tabId:e.number().optional().describe(`Tab ID to insert CSS into (defaults to active tab)`),css:e.string().describe(`CSS code to inject`),allFrames:e.boolean().optional().describe(`Inject in all frames (default: false)`)}},async({tabId:e,css:t,allFrames:n=!1})=>{try{if(e===void 0){let[t]=await chrome.tabs.query({active:!0,currentWindow:!0});if(!t||!t.id)return this.formatError(Error(`No active tab found`));e=t.id}return await chrome.scripting.insertCSS({target:{tabId:e,allFrames:n},css:t}),this.formatSuccess(`CSS injected into tab ${e}`)}catch(e){return this.formatError(e)}})}registerRemoveCSS(){if(typeof chrome.scripting.removeCSS!=`function`){console.warn(` ✗ removeCSS not available - Chrome 90+ required`);return}this.server.registerTool(`extension_tool_remove_css`,{description:`Remove previously injected CSS from a tab. If no tabId is specified, operates on the currently active tab`,inputSchema:{tabId:e.number().optional().describe(`Tab ID to remove CSS from (defaults to active tab)`),css:e.string().describe(`CSS code to remove (must match exactly)`),allFrames:e.boolean().optional().describe(`Remove from all frames (default: false)`)}},async({tabId:e,css:t,allFrames:n=!1})=>{try{if(e===void 0){let[t]=await chrome.tabs.query({active:!0,currentWindow:!0});if(!t||!t.id)return this.formatError(Error(`No active tab found`));e=t.id}return await chrome.scripting.removeCSS({target:{tabId:e,allFrames:n},css:t}),this.formatSuccess(`CSS removed from tab ${e}`)}catch(e){return this.formatError(e)}})}},_e=class extends n{apiName=`Search`;constructor(e,t={}){super(e,t)}checkAvailability(){try{return chrome.search?typeof chrome.search.query==`function`?{available:!0,message:`Search API is fully available`}:{available:!1,message:`chrome.search.query is not available`,details:`The search API appears to be partially available. Check manifest permissions.`}:{available:!1,message:`chrome.search API is not defined`,details:`This extension needs the "search" permission in its manifest.json`}}catch(e){return{available:!1,message:`Failed to access chrome.search API`,details:e instanceof Error?e.message:`Unknown error occurred`}}}registerTools(){this.shouldRegisterTool(`query`)&&this.registerQuery()}registerQuery(){this.server.registerTool(`extension_tool_search_query`,{description:`Search using the default search provider`,inputSchema:{text:e.string().describe(`String to query with the default search provider`),disposition:e.enum([`CURRENT_TAB`,`NEW_TAB`,`NEW_WINDOW`]).optional().describe(`Location where search results should be displayed. CURRENT_TAB is the default`),tabId:e.number().optional().describe(`Tab ID where search results should be displayed. Cannot be used with disposition`)}},async({text:e,disposition:t,tabId:n})=>{try{if(t!==void 0&&n!==void 0)return this.formatError(`Cannot specify both disposition and tabId. Use one or the other`);let r={text:e};return t!==void 0&&(r.disposition=t),n!==void 0&&(r.tabId=n),await new Promise((e,t)=>{chrome.search.query(r,()=>{chrome.runtime.lastError?t(Error(chrome.runtime.lastError.message)):e()})}),this.formatSuccess(`Search query executed successfully`,{text:e,disposition:t||`CURRENT_TAB`,tabId:n})}catch(e){return this.formatError(e)}})}},ve=class extends n{apiName=`Sessions`;constructor(e,t={}){super(e,t)}checkAvailability(){try{return chrome.sessions?typeof chrome.sessions.getRecentlyClosed==`function`?(chrome.sessions.getRecentlyClosed(e=>{if(chrome.runtime.lastError)throw Error(chrome.runtime.lastError.message)}),{available:!0,message:`Sessions API is fully available`}):{available:!1,message:`chrome.sessions.getRecentlyClosed is not available`,details:`The sessions API appears to be partially available. Check manifest permissions.`}:{available:!1,message:`chrome.sessions API is not defined`,details:`This extension needs the "sessions" permission in its manifest.json`}}catch(e){return{available:!1,message:`Failed to access chrome.sessions API`,details:e instanceof Error?e.message:`Unknown error occurred`}}}registerTools(){this.shouldRegisterTool(`getDevices`)&&this.registerGetDevices(),this.shouldRegisterTool(`getRecentlyClosed`)&&this.registerGetRecentlyClosed(),this.shouldRegisterTool(`restore`)&&this.registerRestore()}registerGetDevices(){this.server.registerTool(`extension_tool_get_devices`,{description:`Retrieve all devices with synced sessions`,inputSchema:{maxResults:e.number().min(1).max(25).optional().describe(`The maximum number of entries to be fetched. Omit to fetch the maximum number of entries (25)`)}},async({maxResults:e})=>{try{let t={};e!==void 0&&(t.maxResults=e);let n=await new Promise((e,n)=>{chrome.sessions.getDevices(t,t=>{chrome.runtime.lastError?n(Error(chrome.runtime.lastError.message)):e(t)})});return this.formatJson({count:n.length,devices:n.map(e=>({deviceName:e.deviceName,sessionCount:e.sessions.length,sessions:e.sessions.map(e=>({lastModified:e.lastModified,lastModifiedFormatted:new Date(e.lastModified*1e3).toISOString(),tab:e.tab?{id:e.tab.id,url:e.tab.url,title:e.tab.title,sessionId:e.tab.sessionId}:void 0,window:e.window?{id:e.window.id,sessionId:e.window.sessionId,tabCount:e.window.tabs?.length||0}:void 0}))}))})}catch(e){return this.formatError(e)}})}registerGetRecentlyClosed(){this.server.registerTool(`extension_tool_get_recently_closed`,{description:`Get the list of recently closed tabs and/or windows`,inputSchema:{maxResults:e.number().min(1).max(25).optional().describe(`The maximum number of entries to be fetched. Omit to fetch the maximum number of entries (25)`)}},async({maxResults:e})=>{try{let t={};e!==void 0&&(t.maxResults=e);let n=await new Promise((e,n)=>{chrome.sessions.getRecentlyClosed(t,t=>{chrome.runtime.lastError?n(Error(chrome.runtime.lastError.message)):e(t)})});return this.formatJson({count:n.length,sessions:n.map(e=>({lastModified:e.lastModified,lastModifiedFormatted:new Date(e.lastModified*1e3).toISOString(),tab:e.tab?{id:e.tab.id,url:e.tab.url,title:e.tab.title,sessionId:e.tab.sessionId,favIconUrl:e.tab.favIconUrl}:void 0,window:e.window?{id:e.window.id,sessionId:e.window.sessionId,tabCount:e.window.tabs?.length||0,incognito:e.window.incognito,type:e.window.type}:void 0}))})}catch(e){return this.formatError(e)}})}registerRestore(){this.server.registerTool(`extension_tool_restore_session`,{description:`Reopen a recently closed window or tab`,inputSchema:{sessionId:e.string().optional().describe(`The sessionId of the window or tab to restore. If not specified, the most recently closed session is restored`)}},async({sessionId:e})=>{try{let t=await new Promise((t,n)=>{e?chrome.sessions.restore(e,e=>{chrome.runtime.lastError?n(Error(chrome.runtime.lastError.message)):t(e)}):chrome.sessions.restore(e=>{chrome.runtime.lastError?n(Error(chrome.runtime.lastError.message)):t(e)})});return this.formatSuccess(`Session restored successfully`,{lastModified:t.lastModified,lastModifiedFormatted:new Date(t.lastModified*1e3).toISOString(),tab:t.tab?{id:t.tab.id,url:t.tab.url,title:t.tab.title,sessionId:t.tab.sessionId}:void 0,window:t.window?{id:t.window.id,sessionId:t.window.sessionId,tabCount:t.window.tabs?.length||0,incognito:t.window.incognito,type:t.window.type}:void 0})}catch(e){return this.formatError(e)}})}},ye=class extends n{apiName=`SidePanel`;constructor(e,t={}){super(e,t)}checkAvailability(){try{return chrome.sidePanel?typeof chrome.sidePanel.getOptions==`function`?(chrome.sidePanel.getOptions({},e=>{if(chrome.runtime.lastError)throw Error(chrome.runtime.lastError.message)}),{available:!0,message:`SidePanel API is fully available`}):{available:!1,message:`chrome.sidePanel.getOptions is not available`,details:`The sidePanel API appears to be partially available. Check manifest permissions.`}:{available:!1,message:`chrome.sidePanel API is not defined`,details:`This extension needs the "sidePanel" permission in its manifest.json`}}catch(e){return{available:!1,message:`Failed to access chrome.sidePanel API`,details:e instanceof Error?e.message:`Unknown error occurred`}}}registerTools(){this.shouldRegisterTool(`getOptions`)&&this.registerGetOptions(),this.shouldRegisterTool(`setOptions`)&&this.registerSetOptions(),this.shouldRegisterTool(`getPanelBehavior`)&&this.registerGetPanelBehavior(),this.shouldRegisterTool(`setPanelBehavior`)&&this.registerSetPanelBehavior(),this.shouldRegisterTool(`open`)&&this.registerOpen()}registerGetOptions(){this.server.registerTool(`extension_tool_get_side_panel_options`,{description:`Get the active side panel configuration for a specific tab or default settings`,inputSchema:{tabId:e.number().optional().describe(`If specified, the side panel options for the given tab will be returned. Otherwise, returns the default side panel options`)}},async({tabId:e})=>{try{let t=await new Promise((t,n)=>{let r={};e!==void 0&&(r.tabId=e),chrome.sidePanel.getOptions(r,e=>{chrome.runtime.lastError?n(Error(chrome.runtime.lastError.message)):t(e)})});return this.formatJson({tabId:e||`default`,enabled:t.enabled,path:t.path})}catch(e){return this.formatError(e)}})}registerSetOptions(){this.server.registerTool(`extension_tool_set_side_panel_options`,{description:`Configure the side panel settings for a specific tab or default behavior`,inputSchema:{enabled:e.boolean().optional().describe(`Whether the side panel should be enabled. Defaults to true`),path:e.string().optional().describe(`The path to the side panel HTML file to use. Must be a local resource within the extension package`),tabId:e.number().optional().describe(`If specified, the side panel options will only apply to the tab with this id. If omitted, these options set the default behavior`)}},async({enabled:e,path:t,tabId:n})=>{try{let r={};return e!==void 0&&(r.enabled=e),t!==void 0&&(r.path=t),n!==void 0&&(r.tabId=n),await new Promise((e,t)=>{chrome.sidePanel.setOptions(r,()=>{chrome.runtime.lastError?t(Error(chrome.runtime.lastError.message)):e()})}),this.formatSuccess(`Side panel options configured successfully`,{tabId:n||`default`,enabled:e,path:t})}catch(e){return this.formatError(e)}})}registerGetPanelBehavior(){this.server.registerTool(`extension_tool_get_side_panel_behavior`,{description:`Get the current side panel behavior configuration`,inputSchema:{}},async()=>{try{let e=await new Promise((e,t)=>{chrome.sidePanel.getPanelBehavior(n=>{chrome.runtime.lastError?t(Error(chrome.runtime.lastError.message)):e(n)})});return this.formatJson({openPanelOnActionClick:e.openPanelOnActionClick})}catch(e){return this.formatError(e)}})}registerSetPanelBehavior(){this.server.registerTool(`extension_tool_set_side_panel_behavior`,{description:`Configure the side panel behavior, such as opening when the action icon is clicked`,inputSchema:{openPanelOnActionClick:e.boolean().optional().describe(`Whether clicking the extension action icon will toggle showing the extension entry in the side panel. Defaults to false`)}},async({openPanelOnActionClick:e})=>{try{let t={};return e!==void 0&&(t.openPanelOnActionClick=e),await new Promise((e,n)=>{chrome.sidePanel.setPanelBehavior(t,()=>{chrome.runtime.lastError?n(Error(chrome.runtime.lastError.message)):e()})}),this.formatSuccess(`Side panel behavior configured successfully`,{openPanelOnActionClick:e})}catch(e){return this.formatError(e)}})}registerOpen(){this.server.registerTool(`extension_tool_open_side_panel`,{description:`Open the side panel for the extension. This may only be called in response to a user action`,inputSchema:{tabId:e.number().optional().describe(`The tab in which to open the side panel. If there is a tab-specific panel, it will only open for that tab. At least one of tabId or windowId must be provided`),windowId:e.number().optional().describe(`The window in which to open the side panel. This is only applicable if the extension has a global side panel or tabId is also specified. At least one of tabId or windowId must be provided`)}},async({tabId:e,windowId:t})=>{try{if(e===void 0&&t===void 0)return this.formatError(`Either tabId or windowId must be specified to open the side panel`);let n={};return e!==void 0&&(n.tabId=e),t!==void 0&&(n.windowId=t),await new Promise((e,t)=>{chrome.sidePanel.open(n,()=>{chrome.runtime.lastError?t(Error(chrome.runtime.lastError.message)):e()})}),this.formatSuccess(`Side panel opened successfully`,{tabId:e,windowId:t})}catch(e){return this.formatError(e)}})}};const z=[`getStorage`,`setStorage`,`removeStorage`,`clearStorage`,`getBytesInUse`],B=e.enum(z);var be=class extends n{apiName=`Storage`;constructor(e,t={}){super(e,t)}checkAvailability(){try{if(!chrome.storage)return{available:!1,message:`chrome.storage API is not defined`,details:`This extension needs the "storage" permission in its manifest.json to access storage`};let e=[];return chrome.storage.local&&e.push(`local`),chrome.storage.sync&&e.push(`sync`),chrome.storage.session&&e.push(`session`),chrome.storage.managed&&e.push(`managed`),e.length===0?{available:!1,message:`No storage areas are available`,details:`The storage API is present but no storage areas can be accessed`}:(chrome.storage.local.get(null,()=>{if(chrome.runtime.lastError)throw Error(chrome.runtime.lastError.message)}),{available:!0,message:`Storage API is available with areas: ${e.join(`, `)}`})}catch(e){return{available:!1,message:`Failed to access chrome.storage API`,details:e instanceof Error?e.message:`Unknown error occurred`}}}registerTools(){this.server.registerTool(`extension_tool_storage_operations`,{description:`Perform operations on Chrome storage API`,inputSchema:{action:B,params:e.record(e.string(),e.any()).optional().describe(`Parameters for the chosen action`)}},async({action:e,params:t={}})=>{try{if(!this.shouldRegisterTool(e))return this.formatError(Error(`Action "${e}" is not supported`));switch(e){case`getStorage`:return await this.handleGetStorage(t);case`setStorage`:return await this.handleSetStorage(t);case`removeStorage`:return await this.handleRemoveStorage(t);case`clearStorage`:return await this.handleClearStorage(t);case`getBytesInUse`:return await this.handleGetBytesInUse(t);default:return this.formatError(Error(`Action "${e}" is not supported`))}}catch(e){return this.formatError(e)}}),this.server.registerTool(`extension_tool_storage_parameters_description`,{description:`Get the parameters for extension_tool_storage_operations tool and the description for the associated action, this tool should be used first before extension_tool_storage_operations`,inputSchema:{action:B}},async({action:t})=>{try{if(!this.shouldRegisterTool(t))return this.formatError(Error(`Action "${t}" is not supported`));let n=(t,n)=>e.toJSONSchema(t),r={tool:`extension_tool_storage_operations`,action:t,note:`Use the description to double check if the correct action is chosen. Use this JSON Schema for the params field when calling the tool. The top-level tool input is { action, params }.`};switch(t){case`getStorage`:{let e={params:n(this.getStorageSchema,`GetStorageParams`),description:`Get data from extension storage`};return this.formatJson({...r,...e})}case`setStorage`:{let e={params:n(this.setStorageSchema,`SetStorageParams`),description:`Set data in extension storage`};return this.formatJson({...r,...e})}case`removeStorage`:{let e={params:n(this.removeStorageSchema,`RemoveStorageParams`),description:`Remove specific keys from extension storage`};return this.formatJson({...r,...e})}case`clearStorage`:{let e={params:n(this.clearStorageSchema,`ClearStorageParams`),description:`Clear all data from a storage area`};return this.formatJson({...r,...e})}case`getBytesInUse`:{let e={params:n(this.getBytesInUseSchema,`GetBytesInUseParams`),description:`Get the amount of storage space used`};return this.formatJson({...r,...e})}default:return this.formatError(Error(`Action "${t}" is not supported`))}}catch(e){return this.formatError(e)}})}getAvailableAreas(){let e=[];return chrome.storage.sync&&e.push(`sync`),chrome.storage.local&&e.push(`local`),chrome.storage.session&&e.push(`session`),e}async handleGetStorage(e){let{keys:t,area:n=`local`}=this.getStorageSchema.parse(e),r=chrome.storage[n];if(!r||typeof r.get!=`function`)return this.formatError(Error(`Storage area '${n}' is not available`));let i=await r.get(t||null),a={area:n,data:i,keyCount:Object.keys(i).length};return this.formatJson(a)}async handleSetStorage(e){let{data:t,area:n=`local`}=this.setStorageSchema.parse(e),r=chrome.storage[n];return!r||typeof r.set!=`function`?this.formatError(Error(`Storage area '${n}' is not available`)):(await r.set(t),this.formatSuccess(`Stored ${Object.keys(t).length} key(s) in ${n} storage`,{keys:Object.keys(t)}))}async handleRemoveStorage(e){let{keys:t,area:n=`local`}=this.removeStorageSchema.parse(e),r=chrome.storage[n];return!r||typeof r.remove!=`function`?this.formatError(Error(`Storage area '${n}' is not available`)):(await r.remove(t),this.formatSuccess(`Removed ${t.length} key(s) from ${n} storage`,{keys:t}))}async handleClearStorage(e){let{area:t,confirm:n}=this.clearStorageSchema.parse(e);if(!n)return this.formatError(Error(`Clear operation requires confirm=true to prevent accidental data loss`));let r=chrome.storage[t];return!r||typeof r.clear!=`function`?this.formatError(Error(`Storage area '${t}' is not available`)):(await r.clear(),this.formatSuccess(`Cleared all data from ${t} storage`))}async handleGetBytesInUse(e){let{keys:t,area:n=`local`}=this.getBytesInUseSchema.parse(e),r=chrome.storage[n];if(!r)return this.formatError(Error(`Storage area '${n}' is not available`));if(typeof r.getBytesInUse!=`function`)return this.formatError(Error(`getBytesInUse is not supported for ${n} storage area`));let i=await r.getBytesInUse(t||null),a=null;return n===`sync`&&chrome.storage.sync.QUOTA_BYTES?a={quotaBytes:chrome.storage.sync.QUOTA_BYTES,quotaBytesPerItem:chrome.storage.sync.QUOTA_BYTES_PER_ITEM,maxItems:chrome.storage.sync.MAX_ITEMS,maxWriteOperationsPerHour:chrome.storage.sync.MAX_WRITE_OPERATIONS_PER_HOUR,maxWriteOperationsPerMinute:chrome.storage.sync.MAX_WRITE_OPERATIONS_PER_MINUTE}:n===`local`&&chrome.storage.local.QUOTA_BYTES&&(a={quotaBytes:chrome.storage.local.QUOTA_BYTES}),this.formatJson({area:n,bytesInUse:i,humanReadable:this.formatBytes(i),quota:a,percentageUsed:a?.quotaBytes?`${(i/a.quotaBytes*100).toFixed(2)}%`:null})}getStorageSchema=e.object({keys:e.array(e.string()).optional().describe(`Specific keys to retrieve (omit for all)`),area:e.enum(this.getAvailableAreas()).optional().describe(`Storage area to use. Available: ${this.getAvailableAreas().join(`, `)} (default: local)`)});setStorageSchema=e.object({data:e.record(e.string(),e.any()).describe(`Key-value pairs to store`),area:e.enum(this.getAvailableAreas()).optional().describe(`Storage area to use. Available: ${this.getAvailableAreas().join(`, `)} (default: local)`)});removeStorageSchema=e.object({keys:e.array(e.string()).describe(`Keys to remove from storage`),area:e.enum(this.getAvailableAreas()).optional().describe(`Storage area to use. Available: ${this.getAvailableAreas().join(`, `)} (default: local)`)});clearStorageSchema=e.object({area:e.enum(this.getAvailableAreas()).describe(`Storage area to clear. Available: ${this.getAvailableAreas().join(`, `)}`),confirm:e.boolean().describe(`Confirmation flag - must be true to clear storage`)});getBytesInUseSchema=e.object({keys:e.array(e.string()).optional().describe(`Specific keys to check (omit for total)`),area:e.enum(this.getAvailableAreas()).optional().describe(`Storage area to check. Available: ${this.getAvailableAreas().join(`, `)} (default: local)`)});formatBytes(e){if(e===0)return`0 Bytes`;let t=1024,n=[`Bytes`,`KB`,`MB`,`GB`],r=Math.floor(Math.log(e)/Math.log(t));return`${Number.parseFloat((e/t**r).toFixed(2))} ${n[r]}`}},xe=class extends n{apiName=`System.cpu`;constructor(e,t={}){super(e,t)}checkAvailability(){try{return!chrome.system||!chrome.system.cpu?{available:!1,message:`chrome.system.cpu API is not defined`,details:`This extension needs the "system.cpu" permission in its manifest.json`}:typeof chrome.system.cpu.getInfo==`function`?(chrome.system.cpu.getInfo(e=>{if(chrome.runtime.lastError)throw Error(chrome.runtime.lastError.message)}),{available:!0,message:`System.cpu API is fully available`}):{available:!1,message:`chrome.system.cpu.getInfo is not available`,details:`The system.cpu API appears to be partially available. Check manifest permissions.`}}catch(e){return{available:!1,message:`Failed to access chrome.system.cpu API`,details:e instanceof Error?e.message:`Unknown error occurred`}}}registerTools(){this.shouldRegisterTool(`getInfo`)&&this.registerGetInfo()}registerGetInfo(){this.server.registerTool(`extension_tool_get_cpu_info`,{description:`Get information about the CPU including number of processors, architecture, model, and features`,inputSchema:{}},async()=>{try{let e=await new Promise((e,t)=>{chrome.system.cpu.getInfo(n=>{chrome.runtime.lastError?t(Error(chrome.runtime.lastError.message)):e(n)})});return this.formatJson({numOfProcessors:e.numOfProcessors,archName:e.archName,modelName:e.modelName,features:e.features,processors:e.processors.map(e=>({usage:{kernel:e.usage.kernel,user:e.usage.user,idle:e.usage.idle,total:e.usage.total}}))})}catch(e){return this.formatError(e)}})}},Se=class extends n{apiName=`SystemLog`;constructor(e,t={}){super(e,t)}checkAvailability(){try{return chrome.systemLog?typeof chrome.systemLog.add==`function`?{available:!0,message:`SystemLog API is fully available`}:{available:!1,message:`chrome.systemLog.add is not available`,details:`The systemLog API appears to be partially available. Check manifest permissions and ensure running on ChromeOS.`}:{available:!1,message:`chrome.systemLog API is not defined`,details:`This extension needs the "systemLog" permission in its manifest.json and must run on ChromeOS`}}catch(e){return{available:!1,message:`Failed to access chrome.systemLog API`,details:e instanceof Error?e.message:`Unknown error occurred`}}}registerTools(){this.shouldRegisterTool(`addLog`)&&this.registerAddLog()}registerAddLog(){this.server.registerTool(`extension_tool_add_log`,{description:`Add a new log record to the Chrome system logs`,inputSchema:{message:e.string().describe(`The log message to record in the system logs`)}},async({message:e})=>{try{let t={message:e};return await new Promise((e,n)=>{chrome.systemLog.add(t,()=>{chrome.runtime.lastError?n(Error(chrome.runtime.lastError.message)):e()})}),this.formatSuccess(`Log record added successfully`,{message:e,timestamp:new Date().toISOString()})}catch(e){return this.formatError(e)}})}},Ce=class extends n{apiName=`System.memory`;constructor(e,t={}){super(e,t)}checkAvailability(){try{return!chrome.system||!chrome.system.memory?{available:!1,message:`chrome.system.memory API is not defined`,details:`This extension needs the "system.memory" permission in its manifest.json`}:typeof chrome.system.memory.getInfo==`function`?(chrome.system.memory.getInfo(e=>{if(chrome.runtime.lastError)throw Error(chrome.runtime.lastError.message)}),{available:!0,message:`System.memory API is fully available`}):{available:!1,message:`chrome.system.memory.getInfo is not available`,details:`The system.memory API appears to be partially available. Check manifest permissions.`}}catch(e){return{available:!1,message:`Failed to access chrome.system.memory API`,details:e instanceof Error?e.message:`Unknown error occurred`}}}registerTools(){this.shouldRegisterTool(`getInfo`)&&this.registerGetInfo()}registerGetInfo(){this.server.registerTool(`extension_tool_get_memory_info`,{description:`Get information about the system memory`,inputSchema:{}},async()=>{try{let e=await new Promise((e,t)=>{chrome.system.memory.getInfo(n=>{chrome.runtime.lastError?t(Error(chrome.runtime.lastError.message)):e(n)})});return this.formatJson({capacity:e.capacity,capacityGB:Math.round(e.capacity/(1024*1024*1024)*100)/100,availableCapacity:e.availableCapacity,availableCapacityGB:Math.round(e.availableCapacity/(1024*1024*1024)*100)/100,usedCapacity:e.capacity-e.availableCapacity,usedCapacityGB:Math.round((e.capacity-e.availableCapacity)/(1024*1024*1024)*100)/100,usagePercentage:Math.round((e.capacity-e.availableCapacity)/e.capacity*1e4)/100})}catch(e){return this.formatError(e)}})}},we=class extends n{apiName=`System.storage`;constructor(e,t={}){super(e,t)}checkAvailability(){try{return!chrome.system||!chrome.system.storage?{available:!1,message:`chrome.system.storage API is not defined`,details:`This extension needs the "system.storage" permission in its manifest.json`}:typeof chrome.system.storage.getInfo==`function`?(chrome.system.storage.getInfo(e=>{if(chrome.runtime.lastError)throw Error(chrome.runtime.lastError.message)}),{available:!0,message:`System.storage API is fully available`}):{available:!1,message:`chrome.system.storage.getInfo is not available`,details:`The system.storage API appears to be partially available. Check manifest permissions.`}}catch(e){return{available:!1,message:`Failed to access chrome.system.storage API`,details:e instanceof Error?e.message:`Unknown error occurred`}}}registerTools(){this.shouldRegisterTool(`getInfo`)&&this.registerGetInfo(),this.shouldRegisterTool(`ejectDevice`)&&this.registerEjectDevice(),this.shouldRegisterTool(`getAvailableCapacity`)&&this.registerGetAvailableCapacity()}registerGetInfo(){this.server.registerTool(`extension_tool_get_storage_info`,{description:`Get information about all attached storage devices`,inputSchema:{}},async()=>{try{let e=await new Promise((e,t)=>{chrome.system.storage.getInfo(n=>{chrome.runtime.lastError?t(Error(chrome.runtime.lastError.message)):e(n)})});return this.formatJson({count:e.length,devices:e.map(e=>({id:e.id,name:e.name,type:e.type,capacity:e.capacity,capacityFormatted:this.formatBytes(e.capacity)}))})}catch(e){return this.formatError(e)}})}registerEjectDevice(){this.server.registerTool(`extension_tool_eject_storage_device`,{description:`Eject a removable storage device`,inputSchema:{id:e.string().describe(`The transient device ID from getInfo`)}},async({id:e})=>{try{let t=await new Promise((t,n)=>{chrome.system.storage.ejectDevice(e,e=>{chrome.runtime.lastError?n(Error(chrome.runtime.lastError.message)):t(e)})}),n=t===`success`,r=this.getEjectResultMessage(t);return n?this.formatSuccess(`Device ejected successfully`,{deviceId:e,result:t,message:r}):this.formatError(`Failed to eject device: ${r}`)}catch(e){return this.formatError(e)}})}registerGetAvailableCapacity(){this.server.registerTool(`extension_tool_get_available_capacity`,{description:`Get the available capacity of a specified storage device`,inputSchema:{id:e.string().describe(`The transient device ID from getInfo`)}},async({id:e})=>{try{let t=await new Promise((t,n)=>{chrome.system.storage.getAvailableCapacity(e,e=>{chrome.runtime.lastError?n(Error(chrome.runtime.lastError.message)):t(e)})});return this.formatJson({deviceId:e,availableCapacity:t.availableCapacity,availableCapacityFormatted:this.formatBytes(t.availableCapacity)})}catch(e){return this.formatError(e)}})}getEjectResultMessage(e){switch(e){case`success`:return`Device ejected successfully`;case`in_use`:return`Device is currently in use and cannot be ejected`;case`no_such_device`:return`No such device found`;case`failure`:return`Failed to eject device due to unknown error`;default:return`Unknown result: ${e}`}}formatBytes(e){if(e===0)return`0 Bytes`;let t=1024,n=[`Bytes`,`KB`,`MB`,`GB`,`TB`,`PB`],r=Math.floor(Math.log(e)/Math.log(t));return`${Number.parseFloat((e/t**r).toFixed(2))} ${n[r]}`}},Te=class extends n{apiName=`TabCapture`;constructor(e,t={}){super(e,t)}checkAvailability(){try{return chrome.tabCapture?typeof chrome.tabCapture.getCapturedTabs==`function`?(chrome.tabCapture.getCapturedTabs(e=>{if(chrome.runtime.lastError)throw Error(chrome.runtime.lastError.message)}),{available:!0,message:`TabCapture API is fully available`}):{available:!1,message:`chrome.tabCapture.getCapturedTabs is not available`,details:`The tabCapture API appears to be partially available. Check manifest permissions.`}:{available:!1,message:`chrome.tabCapture API is not defined`,details:`This extension needs the "tabCapture" permission in its manifest.json`}}catch(e){return{available:!1,message:`Failed to access chrome.tabCapture API`,details:e instanceof Error?e.message:`Unknown error occurred`}}}registerTools(){this.shouldRegisterTool(`capture`)&&this.registerCapture(),this.shouldRegisterTool(`getCapturedTabs`)&&this.registerGetCapturedTabs(),this.shouldRegisterTool(`getMediaStreamId`)&&this.registerGetMediaStreamId()}registerCapture(){this.server.registerTool(`extension_tool_capture_tab`,{description:`Captures the visible area of the currently active tab. Can only be started on the currently active tab after the extension has been invoked.`,inputSchema:{audio:e.boolean().optional().describe(`Whether to capture audio from the tab`),video:e.boolean().optional().describe(`Whether to capture video from the tab`),audioConstraints:e.object({mandatory:e.record(e.string(),e.any()).optional(),optional:e.record(e.string(),e.any()).optional()}).optional().describe(`Audio constraints for the media stream`),videoConstraints:e.object({mandatory:e.record(e.string(),e.any()).optional(),optional:e.record(e.string(),e.any()).optional()}).optional().describe(`Video constraints for the media stream`)}},async({audio:e,video:t,audioConstraints:n,videoConstraints:r})=>{try{let i={};e!==void 0&&(i.audio=e),t!==void 0&&(i.video=t),n!==void 0&&(i.audioConstraints=n),r!==void 0&&(i.videoConstraints=r);let a=await new Promise((e,t)=>{chrome.tabCapture.capture(i,n=>{chrome.runtime.lastError?t(Error(chrome.runtime.lastError.message)):n?e(n):t(Error(`Failed to capture tab - no stream returned`))})}),o=a.getAudioTracks(),s=a.getVideoTracks();return this.formatSuccess(`Tab capture started successfully`,{streamId:a.id,audioTracks:o.length,videoTracks:s.length,audioTrackLabels:o.map(e=>e.label),videoTrackLabels:s.map(e=>e.label)})}catch(e){return this.formatError(e)}})}registerGetCapturedTabs(){this.server.registerTool(`extension_tool_get_captured_tabs`,{description:`Returns a list of tabs that have requested capture or are being captured`,inputSchema:{}},async()=>{try{let e=await new Promise((e,t)=>{chrome.tabCapture.getCapturedTabs(n=>{chrome.runtime.lastError?t(Error(chrome.runtime.lastError.message)):e(n)})});return this.formatJson({count:e.length,capturedTabs:e.map(e=>({tabId:e.tabId,status:e.status,fullscreen:e.fullscreen}))})}catch(e){return this.formatError(e)}})}registerGetMediaStreamId(){this.server.registerTool(`extension_tool_get_media_stream_id`,{description:`Creates a stream ID to capture the target tab. Returns a media stream ID instead of a media stream.`,inputSchema:{targetTabId:e.number().optional().describe(`Optional tab id of the tab which will be captured. If not specified then the current active tab will be selected.`),consumerTabId:e.number().optional().describe(`Optional tab id of the tab which will later invoke getUserMedia() to consume the stream. If not specified then the resulting stream can be used only by the calling extension.`)}},async({targetTabId:e,consumerTabId:t})=>{try{let n={};e!==void 0&&(n.targetTabId=e),t!==void 0&&(n.consumerTabId=t);let r=await new Promise((e,t)=>{chrome.tabCapture.getMediaStreamId(n,n=>{chrome.runtime.lastError?t(Error(chrome.runtime.lastError.message)):n?e(n):t(Error(`Failed to get media stream ID`))})});return this.formatSuccess(`Media stream ID created successfully`,{streamId:r,targetTabId:e||`current active tab`,consumerTabId:t||`calling extension only`,usage:`Use this ID with navigator.mediaDevices.getUserMedia() with chromeMediaSource: "tab" and chromeMediaSourceId: streamId`})}catch(e){return this.formatError(e)}})}};const V=[`get`,`query`,`update`,`move`],H=e.enum(V);var Ee=class extends n{apiName=`TabGroups`;constructor(e,t={}){super(e,t)}checkAvailability(){try{return chrome.tabGroups?typeof chrome.tabGroups.query==`function`?(chrome.tabGroups.query({},()=>{if(chrome.runtime.lastError)throw Error(chrome.runtime.lastError.message)}),{available:!0,message:`TabGroups API is fully available`}):{available:!1,message:`chrome.tabGroups.query is not available`,details:`The tabGroups API appears to be partially available. Check manifest permissions.`}:{available:!1,message:`chrome.tabGroups API is not defined`,details:`This extension needs the "tabGroups" permission in its manifest.json and requires Chrome 89+ with Manifest V3`}}catch(e){return{available:!1,message:`Failed to access chrome.tabGroups API`,details:e instanceof Error?e.message:`Unknown error occurred`}}}registerTools(){this.server.registerTool(`extension_tool_tab_group_operations`,{description:`Perform operations on tab groups using Chrome TabGroups API`,inputSchema:{action:H,params:e.record(e.string(),e.any()).optional().describe(`Parameters for the chosen action`)}},async({action:e,params:t={}})=>{try{if(!this.shouldRegisterTool(e))return this.formatError(Error(`Action "${e}" is not supported`));switch(e){case`get`:return await this.handleGetTabGroup(t);case`query`:return await this.handleQueryTabGroups(t);case`update`:return await this.handleUpdateTabGroup(t);case`move`:return await this.handleMoveTabGroup(t);default:return this.formatError(Error(`Action "${e}" is not supported`))}}catch(e){return this.formatError(e)}}),this.server.registerTool(`extension_tool_tab_group_parameters_description`,{description:`Get the parameters for extension_tool_tab_group_operations tool and the description for the associated action, this tool should be used first before extension_tool_tab_group_operations`,inputSchema:{action:H}},async({action:t})=>{try{if(!this.shouldRegisterTool(t))return this.formatError(Error(`Action "${t}" is not supported`));let n=(t,n)=>e.toJSONSchema(t),r={tool:`extension_tool_tab_group_operations`,action:t,note:`Use the description to double check if the correct action is chosen. Use this JSON Schema for the params field when calling the tool. The top-level tool input is { action, params }.`};switch(t){case`get`:{let e={params:n(this.getSchema,`GetTabGroupParams`),description:`Retrieve a tab group by its ID`};return this.formatJson({...r,...e})}case`query`:{let e={params:n(this.querySchema,`QueryTabGroupsParams`),description:`Search for tab groups that match specified criteria`};return this.formatJson({...r,...e})}case`update`:{let e={params:n(this.updateSchema,`UpdateTabGroupParams`),description:`Modify properties of a tab group`};return this.formatJson({...r,...e})}case`move`:{let e={params:n(this.moveSchema,`MoveTabGroupParams`),description:`Move a tab group within its window or to a new window`};return this.formatJson({...r,...e})}default:return this.formatError(Error(`Action "${t}" is not supported`))}}catch(e){return this.formatError(e)}})}async handleGetTabGroup(e){let{groupId:t}=this.getSchema.parse(e),n=await new Promise((e,n)=>{chrome.tabGroups.get(t,t=>{chrome.runtime.lastError?n(Error(chrome.runtime.lastError.message)):e(t)})});return this.formatJson({id:n.id,title:n.title,color:n.color,collapsed:n.collapsed,shared:n.shared,windowId:n.windowId})}async handleQueryTabGroups(e){let{collapsed:t,color:n,shared:r,title:i,windowId:a}=this.querySchema.parse(e),o={};t!==void 0&&(o.collapsed=t),n!==void 0&&(o.color=n),r!==void 0&&(o.shared=r),i!==void 0&&(o.title=i),a!==void 0&&(o.windowId=a===-2?chrome.windows.WINDOW_ID_CURRENT:a);let s=await new Promise((e,t)=>{chrome.tabGroups.query(o,n=>{chrome.runtime.lastError?t(Error(chrome.runtime.lastError.message)):e(n)})});return this.formatJson({count:s.length,groups:s.map(e=>({id:e.id,title:e.title,color:e.color,collapsed:e.collapsed,shared:e.shared,windowId:e.windowId}))})}async handleUpdateTabGroup(e){let{groupId:t,collapsed:n,color:r,title:i}=this.updateSchema.parse(e),a={};n!==void 0&&(a.collapsed=n),r!==void 0&&(a.color=r),i!==void 0&&(a.title=i);let o=await new Promise((e,n)=>{chrome.tabGroups.update(t,a,t=>{chrome.runtime.lastError?n(Error(chrome.runtime.lastError.message)):e(t)})});return o?this.formatSuccess(`Tab group updated successfully`,{id:o.id,title:o.title,color:o.color,collapsed:o.collapsed,shared:o.shared,windowId:o.windowId}):this.formatError(`Failed to update tab group`)}async handleMoveTabGroup(e){let{groupId:t,index:n,windowId:r}=this.moveSchema.parse(e),i={index:n};r!==void 0&&(i.windowId=r);let a=await new Promise((e,n)=>{chrome.tabGroups.move(t,i,t=>{chrome.runtime.lastError?n(Error(chrome.runtime.lastError.message)):e(t)})});return a?this.formatSuccess(`Tab group moved successfully`,{id:a.id,title:a.title,color:a.color,collapsed:a.collapsed,shared:a.shared,windowId:a.windowId,newIndex:n}):this.formatError(`Failed to move tab group`)}getSchema=e.object({groupId:e.number().describe(`The ID of the tab group to retrieve`)});querySchema=e.object({collapsed:e.boolean().optional().describe(`Whether the groups are collapsed`),color:e.enum([`grey`,`blue`,`red`,`yellow`,`green`,`pink`,`purple`,`cyan`,`orange`]).optional().describe(`The color of the groups`),shared:e.boolean().optional().describe(`Whether the group is shared (Chrome 137+)`),title:e.string().optional().describe(`Pattern to match group titles against`),windowId:e.number().optional().describe(`The ID of the parent window, or use -2 for the current window`)});updateSchema=e.object({groupId:e.number().describe(`The ID of the group to modify`),collapsed:e.boolean().optional().describe(`Whether the group should be collapsed`),color:e.enum([`grey`,`blue`,`red`,`yellow`,`green`,`pink`,`purple`,`cyan`,`orange`]).optional().describe(`The color of the group`),title:e.string().optional().describe(`The title of the group`)});moveSchema=e.object({groupId:e.number().describe(`The ID of the group to move`),index:e.number().describe(`The position to move the group to. Use -1 to place at the end`),windowId:e.number().optional().describe(`The window to move the group to. Defaults to current window`)})};const U=[`listActiveTabs`,`createTab`,`updateTab`,`closeTabs`,`getAllTabs`,`navigateHistory`,`reloadTab`,`captureVisibleTab`,`detectLanguage`,`discardTab`,`duplicateTab`,`getTab`,`getZoom`,`getZoomSettings`,`setZoom`,`setZoomSettings`,`groupTabs`,`ungroupTabs`,`highlightTabs`,`moveTabs`,`sendMessage`],W=e.enum(U);var De=class extends n{apiName=`Tabs`;constructor(e,t={}){super(e,t)}checkAvailability(){try{return chrome.tabs?typeof chrome.tabs.query==`function`?{available:!0,message:`Tabs API is fully available`}:{available:!1,message:`chrome.tabs.query is not available`,details:`The tabs API appears to be partially available. Check manifest permissions.`}:{available:!1,message:`chrome.tabs API is not defined`,details:`This extension may not have the "tabs" permission in its manifest`}}catch(e){return{available:!1,message:`Failed to access chrome.tabs API`,details:e instanceof Error?e.message:`Unknown error occurred`}}}registerTools(){this.server.registerTool(`extension_tool_tab_operations`,{description:`Perform various tab operations using the Chrome Tabs API`,inputSchema:{action:W,params:e.record(e.string(),e.any()).optional().describe(`Parameters for the chosen action`)}},async({action:e,params:t={}})=>{try{if(!this.shouldRegisterTool(e))return this.formatError(Error(`Action "${e}" is not supported`));switch(e){case`listActiveTabs`:return await this.handleListActiveTabs();case`createTab`:return await this.handleCreateTab(t);case`updateTab`:return await this.handleUpdateTab(t);case`closeTabs`:return await this.handleCloseTabs(t);case`getAllTabs`:return await this.handleGetAllTabs(t);case`navigateHistory`:return await this.handleNavigateHistory(t);case`reloadTab`:return await this.handleReloadTab(t);case`captureVisibleTab`:return await this.handleCaptureVisibleTab(t);case`detectLanguage`:return await this.handleDetectLanguage(t);case`discardTab`:return await this.handleDiscardTab(t);case`duplicateTab`:return await this.handleDuplicateTab(t);case`getTab`:return await this.handleGetTab(t);case`getZoom`:return await this.handleGetZoom(t);case`getZoomSettings`:return await this.handleGetZoomSettings(t);case`setZoom`:return await this.handleSetZoom(t);case`setZoomSettings`:return await this.handleSetZoomSettings(t);case`groupTabs`:return await this.handleGroupTabs(t);case`ungroupTabs`:return await this.handleUngroupTabs(t);case`highlightTabs`:return await this.handleHighlightTabs(t);case`moveTabs`:return await this.handleMoveTabs(t);case`sendMessage`:return await this.handleSendMessage(t);default:return this.formatError(Error(`Action "${e}" is not supported`))}}catch(e){return this.formatError(e)}}),this.server.registerTool(`extension_tool_tab_parameters_description`,{description:`Get the parameters for extension_tool_tab_operations tool and the description for the associated action, this tool should be used first before extension_tool_tab_operations`,inputSchema:{action:W}},async({action:t})=>{try{if(!this.shouldRegisterTool(t))return this.formatError(Error(`Action "${t}" is not supported`));let n=(t,n)=>e.toJSONSchema(t),r={tool:`extension_tool_tab_operations`,action:t,note:`Use the description to double check if the correct action is chosen. Use this JSON Schema for the params field when calling the tool. The top-level tool input is { action, params }.`};switch(t){case`listActiveTabs`:{let e={params:n(this.listActiveTabsSchema,`ListActiveTabsParams`),description:`Lists all tabs grouped by domain`};return this.formatJson({...r,...e})}case`createTab`:{let e={params:n(this.createTabSchema,`CreateTabParams`),description:`Create a new browser tab`};return this.formatJson({...r,...e})}case`updateTab`:{let e={params:n(this.updateTabSchema,`UpdateTabParams`),description:`Update properties of an existing tab. If no tabId is specified, operates on the currently active tab`};return this.formatJson({...r,...e})}case`closeTabs`:{let e={params:n(this.closeTabsSchema,`CloseTabsParams`),description:`Close one or more tabs`};return this.formatJson({...r,...e})}case`getAllTabs`:{let e={params:n(this.getAllTabsSchema,`GetAllTabsParams`),description:`Get information about all open tabs`};return this.formatJson({...r,...e})}case`navigateHistory`:{let e={params:n(this.navigateHistorySchema,`NavigateHistoryParams`),description:`Navigate forward or backward in a tab's history. If no tabId is specified, operates on the currently active tab`};return this.formatJson({...r,...e})}case`reloadTab`:{let e={params:n(this.reloadTabSchema,`ReloadTabParams`),description:`Reload a tab. If no tabId is specified, operates on the currently active tab`};return this.formatJson({...r,...e})}case`captureVisibleTab`:{let e={params:n(this.captureVisibleTabSchema,`CaptureVisibleTabParams`),description:`Take a screenshot of the visible area of the currently active tab in a window. Once the screenshot is captured`};return this.formatJson({...r,...e})}case`detectLanguage`:{let e={params:n(this.detectLanguageSchema,`DetectLanguageParams`),description:`Detect the primary language of the content in a tab`};return this.formatJson({...r,...e})}case`discardTab`:{let e={params:n(this.discardTabSchema,`DiscardTabParams`),description:`Discards a tab from memory. Discarded tabs are still visible but need to reload when activated`};return this.formatJson({...r,...e})}case`duplicateTab`:{let e={params:n(this.duplicateTabSchema,`DuplicateTabParams`),description:`Duplicate a tab`};return this.formatJson({...r,...e})}case`getTab`:{let e={params:n(this.getTabSchema,`GetTabParams`),description:`Retrieves details about a specific tab`};return this.formatJson({...r,...e})}case`getZoom`:{let e={params:n(this.getZoomSchema,`GetZoomParams`),description:`Retrieves the current zoom level of a tab`};return this.formatJson({...r,...e})}case`getZoomSettings`:{let e={params:n(this.getZoomSettingsSchema,`GetZoomSettingsParams`),description:`Gets the current zoom settings of a tab`};return this.formatJson({...r,...e})}case`setZoom`:{let e={params:n(this.setZoomSchema,`SetZoomParams`),description:`Sets the zoom factor of a tab`};return this.formatJson({...r,...e})}case`setZoomSettings`:{let e={params:n(this.setZoomSettingsSchema,`SetZoomSettingsParams`),description:`Sets zoom settings for a tab (how zoom changes are handled)`};return this.formatJson({...r,...e})}case`groupTabs`:{let e={params:n(this.groupTabsSchema,`GroupTabsParams`),description:`Groups one or more tabs together`};return this.formatJson({...r,...e})}case`ungroupTabs`:{let e={params:n(this.ungroupTabsSchema,`UngroupTabsParams`),description:`Removes tabs from their groups`};return this.formatJson({...r,...e})}case`highlightTabs`:{let e={params:n(this.highlightTabsSchema,`HighlightTabsParams`),description:`Highlights the given tabs and focuses on the first one`};return this.formatJson({...r,...e})}case`moveTabs`:{let e={params:n(this.moveTabsSchema,`MoveTabsParams`),description:`Moves tabs to a new position within their window or to another window`};return this.formatJson({...r,...e})}case`sendMessage`:{let e={params:n(this.sendMessageSchema,`SendMessageParams`),description:`Sends a message to content scripts in a specific tab`};return this.formatJson({...r,...e})}default:return this.formatError(Error(`Action "${t}" is not supported`))}}catch(e){return this.formatError(e)}})}async handleListActiveTabs(){let e=(await chrome.tabs.query({})).map(e=>{let t=`unknown`;if(e.url)try{t=new URL(e.url).hostname}catch{}return{tabId:e.id,domain:t,url:e.url,title:e.title,isActive:e.active,windowId:e.windowId,index:e.index,pinned:e.pinned,audible:e.audible,mutedInfo:e.mutedInfo,status:e.status}}).reduce((e,t)=>{let n=t.domain||`unknown`;return e[n]||(e[n]=[]),e[n].push(t),e},{});for(let t of Object.values(e))t.sort((e,t)=>e.windowId===t.windowId?(e.index||0)-(t.index||0):(e.windowId||0)-(t.windowId||0));return this.formatJson(e)}async handleCreateTab(e){let{url:t,active:n,pinned:r}=this.createTabSchema.parse(e),i=await chrome.tabs.create({url:t,active:n,pinned:r});return this.formatSuccess(`Created tab ${i.id} with URL: ${i.url||`about:blank`}`)}async handleUpdateTab(e){let{tabId:t,url:n,active:r,pinned:i,muted:a}=this.updateTabSchema.parse(e);if(t===void 0){let[e]=await chrome.tabs.query({active:!0,currentWindow:!0});if(!e||!e.id)return this.formatError(Error(`No active tab found`));t=e.id}let o={};n!==void 0&&(o.url=n),r!==void 0&&(o.active=r),i!==void 0&&(o.pinned=i),a!==void 0&&(o.muted=a);let s=await chrome.tabs.update(t,o);return s?this.formatSuccess(`Updated tab ${s.id}`,o):this.formatError(Error(`Tab does not exist`))}async handleCloseTabs(e){let{tabIds:t}=this.closeTabsSchema.parse(e);return await chrome.tabs.remove(t),this.formatSuccess(`Closed ${t.length} tab(s): ${t.join(`, `)}`)}async handleGetAllTabs(e){let{currentWindow:t}=this.getAllTabsSchema.parse(e),n=(await chrome.tabs.query(t?{currentWindow:!0}:{})).map(e=>({id:e.id,title:e.title,url:e.url,active:e.active,pinned:e.pinned,windowId:e.windowId,index:e.index}));return this.formatJson(n)}async handleNavigateHistory(e){if(typeof chrome.tabs.goBack!=`function`||typeof chrome.tabs.goForward!=`function`)return this.formatError(Error(`✗ Navigation methods not available - Chrome 72+ required`));let{tabId:t,direction:n}=this.navigateHistorySchema.parse(e);if(t===void 0){let[e]=await chrome.tabs.query({active:!0,currentWindow:!0});if(!e||!e.id)return this.formatError(Error(`No active tab found`));t=e.id}return n===`back`?await chrome.tabs.goBack(t):await chrome.tabs.goForward(t),this.formatSuccess(`Navigated ${n} in tab ${t}`)}async handleReloadTab(e){let{tabId:t,bypassCache:n}=this.reloadTabSchema.parse(e);if(t===void 0){let[e]=await chrome.tabs.query({active:!0,currentWindow:!0});if(!e||!e.id)return this.formatError(Error(`No active tab found`));t=e.id}return await chrome.tabs.reload(t,{bypassCache:n}),this.formatSuccess(`Reloaded tab ${t}${n?` (bypassed cache)`:``}`)}async handleCaptureVisibleTab(e){if(typeof chrome.tabs.captureVisibleTab!=`function`)return this.formatError(Error(`✗ Screenshot capture not available - requires "activeTab" or "<all_urls>" permission`));let{windowId:t}=this.captureVisibleTabSchema.parse(e),n=t?await chrome.tabs.captureVisibleTab(t,{}):await chrome.tabs.captureVisibleTab();return chrome.tabs.create({url:n}),this.formatSuccess(`Screenshot captured (data URL length: ${n.length} characters)`)}async handleDetectLanguage(e){let{tabId:t}=this.detectLanguageSchema.parse(e),n=await chrome.tabs.detectLanguage(t);return this.formatSuccess(`Tab language detected: ${n}`,{language:n})}async handleDiscardTab(e){let{tabId:t}=this.discardTabSchema.parse(e),n=await chrome.tabs.discard(t);return n?this.formatSuccess(`Discarded tab ${n.id}`,{tab:n}):this.formatError(Error(`Failed to discard tab`))}async handleDuplicateTab(e){let{tabId:t}=this.duplicateTabSchema.parse(e),n=await chrome.tabs.duplicate(t);return n?this.formatSuccess(`Duplicated tab ${n.id}`,{tab:n}):this.formatError(Error(`Failed to duplicate tab`))}async handleGetTab(e){let{tabId:t}=this.getTabSchema.parse(e),n=await chrome.tabs.get(t);return this.formatJson(n)}async handleGetZoom(e){let{tabId:t}=this.getZoomSchema.parse(e),n=await chrome.tabs.getZoom(t);return this.formatSuccess(`Zoom factor: ${n}`,{zoomFactor:n})}async handleGetZoomSettings(e){let{tabId:t}=this.getZoomSettingsSchema.parse(e),n=await chrome.tabs.getZoomSettings(t);return this.formatJson(n)}async handleSetZoom(e){let{tabId:t,zoomFactor:n}=this.setZoomSchema.parse(e);return await chrome.tabs.setZoom(t,n),this.formatSuccess(`Set zoom factor to ${n===0?`default`:n}`)}async handleSetZoomSettings(e){let{tabId:t,mode:n,scope:r}=this.setZoomSettingsSchema.parse(e),i={};return n&&(i.mode=n),r&&(i.scope=r),await chrome.tabs.setZoomSettings(t,i),this.formatSuccess(`Updated zoom settings`,i)}async handleGroupTabs(e){let{tabIds:t,groupId:n,createProperties:r}=this.groupTabsSchema.parse(e),i={tabIds:t.length===1?t[0]:t};n===void 0?r&&(i.createProperties=r):i.groupId=n;let a=await chrome.tabs.group(i);return this.formatSuccess(`Grouped ${t.length} tabs into group ${a}`,{groupId:a})}async handleUngroupTabs(e){let{tabIds:t}=this.ungroupTabsSchema.parse(e);return await chrome.tabs.ungroup(t.length===1?t[0]:t),this.formatSuccess(`Ungrouped ${t.length} tab(s)`)}async handleHighlightTabs(e){let{tabs:t,windowId:n}=this.highlightTabsSchema.parse(e),r={tabs:t.length===1?t[0]:t};n!==void 0&&(r.windowId=n);let i=await chrome.tabs.highlight(r);return this.formatSuccess(`Highlighted ${t.length} tab(s)`,{window:i})}async handleMoveTabs(e){let{tabIds:t,index:n,windowId:r}=this.moveTabsSchema.parse(e),i={index:n};r!==void 0&&(i.windowId=r);let a=chrome.tabs.move(t.length===1?t[0]:t,i);return this.formatSuccess(`Moved ${t.length} tab(s) to index ${n}`,{tabs:a})}async handleSendMessage(e){let{tabId:t,message:n,frameId:r,documentId:i}=this.sendMessageSchema.parse(e),a={};r!==void 0&&(a.frameId=r),i!==void 0&&(a.documentId=i);let o=await chrome.tabs.sendMessage(t,n,a);return this.formatSuccess(`Message sent successfully`,{response:o})}listActiveTabsSchema=e.object({});createTabSchema=e.object({url:e.string().optional().describe(`URL to open in the new tab. Fully-qualified URLs must include a scheme (i.e., 'http://www.google.com', not 'www.google.com'). Relative URLs are relative to the current page within the extension. Defaults to the New Tab Page.`),active:e.boolean().optional().describe(`Whether the tab should be active`),pinned:e.boolean().optional().describe(`Whether the tab should be pinned`)});updateTabSchema=e.object({tabId:e.number().optional().describe(`ID of the tab to update (defaults to active tab)`),url:e.string().optional().describe(`New URL for the tab`),active:e.boolean().optional().describe(`Whether to make the tab active`),pinned:e.boolean().optional().describe(`Whether to pin/unpin the tab`),muted:e.boolean().optional().describe(`Whether to mute/unmute the tab`)});closeTabsSchema=e.object({tabIds:e.array(e.number()).describe(`Array of tab IDs to close`)});getAllTabsSchema=e.object({currentWindow:e.boolean().optional().describe(`Only get tabs from current window`)});navigateHistorySchema=e.object({tabId:e.number().optional().describe(`Tab ID to navigate (defaults to active tab)`),direction:e.enum([`back`,`forward`]).describe(`Navigation direction`)});reloadTabSchema=e.object({tabId:e.number().optional().describe(`Tab ID to reload (defaults to active tab)`),bypassCache:e.boolean().optional().describe(`Bypass the cache when reloading`)});captureVisibleTabSchema=e.object({windowId:e.number().optional().describe(`Window ID (defaults to current window)`)});detectLanguageSchema=e.object({tabId:e.number().optional().describe(`Tab ID (defaults to active tab)`)});discardTabSchema=e.object({tabId:e.number().optional().describe(`Tab ID to discard (if omitted, browser picks least important tab)`)});duplicateTabSchema=e.object({tabId:e.number().describe(`ID of the tab to duplicate`)});getTabSchema=e.object({tabId:e.number().describe(`Tab ID`)});getZoomSchema=e.object({tabId:e.number().optional().describe(`Tab ID (defaults to active tab)`)});getZoomSettingsSchema=e.object({tabId:e.number().optional().describe(`Tab ID (defaults to active tab)`)});setZoomSchema=e.object({tabId:e.number().optional().describe(`Tab ID (defaults to active tab)`),zoomFactor:e.number().describe(`New zoom factor (0 resets to default, >0 sets specific zoom)`)});setZoomSettingsSchema=e.object({tabId:e.number().optional().describe(`Tab ID (defaults to active tab)`),mode:e.enum([`automatic`,`manual`,`disabled`]).optional().describe(`How zoom changes are handled`),scope:e.enum([`per-origin`,`per-tab`]).optional().describe(`Whether zoom persists across pages`)});groupTabsSchema=e.object({tabIds:e.array(e.number()).min(1).describe(`Tab IDs to group`),groupId:e.number().optional().describe(`Existing group ID to add tabs to`),createProperties:e.object({windowId:e.number().optional().describe(`Window ID for new group`)}).optional().describe(`Properties for creating a new group`)});ungroupTabsSchema=e.object({tabIds:e.array(e.number()).min(1).describe(`Tab IDs to ungroup`)});highlightTabsSchema=e.object({tabs:e.array(e.number()).min(1).describe(`Tab indices to highlight`),windowId:e.number().optional().describe(`Window ID containing the tabs`)});moveTabsSchema=e.object({tabIds:e.array(e.number()).min(1).describe(`Tab IDs to move`),index:e.number().describe(`Position to move tabs to (-1 for end)`),windowId:e.number().optional().describe(`Target window ID`)});sendMessageSchema=e.object({tabId:e.number().describe(`Tab ID to send message to`),message:e.any().describe(`Message to send (must be JSON-serializable)`),frameId:e.number().optional().describe(`Specific frame ID to target`),documentId:e.string().optional().describe(`Specific document ID to target`)})},Oe=class extends n{apiName=`TopSites`;constructor(e,t={}){super(e,t)}checkAvailability(){try{return chrome.topSites?typeof chrome.topSites.get==`function`?(chrome.topSites.get(e=>{if(chrome.runtime.lastError)throw Error(chrome.runtime.lastError.message)}),{available:!0,message:`TopSites API is fully available`}):{available:!1,message:`chrome.topSites.get is not available`,details:`The topSites API appears to be partially available. Check manifest permissions.`}:{available:!1,message:`chrome.topSites API is not defined`,details:`This extension needs the "topSites" permission in its manifest.json`}}catch(e){return{available:!1,message:`Failed to access chrome.topSites API`,details:e instanceof Error?e.message:`Unknown error occurred`}}}registerTools(){this.shouldRegisterTool(`getTopSites`)&&this.registerGetTopSites()}registerGetTopSites(){this.server.registerTool(`extension_tool_get_top_sites`,{description:`Get a list of top sites (most visited sites) that are displayed on the new tab page`,inputSchema:{}},async()=>{try{let e=await new Promise((e,t)=>{chrome.topSites.get(n=>{chrome.runtime.lastError?t(Error(chrome.runtime.lastError.message)):e(n)})});return this.formatJson({count:e.length,topSites:e.map(e=>({title:e.title,url:e.url}))})}catch(e){return this.formatError(e)}})}},ke=class extends n{apiName=`Tts`;constructor(e,t={}){super(e,t)}checkAvailability(){try{return chrome.tts?typeof chrome.tts.getVoices==`function`?(chrome.tts.getVoices(e=>{if(chrome.runtime.lastError)throw Error(chrome.runtime.lastError.message)}),{available:!0,message:`TTS API is fully available`}):{available:!1,message:`chrome.tts.getVoices is not available`,details:`The tts API appears to be partially available. Check manifest permissions.`}:{available:!1,message:`chrome.tts API is not defined`,details:`This extension needs the "tts" permission in its manifest.json`}}catch(e){return{available:!1,message:`Failed to access chrome.tts API`,details:e instanceof Error?e.message:`Unknown error occurred`}}}registerTools(){this.shouldRegisterTool(`speak`)&&this.registerSpeak(),this.shouldRegisterTool(`stop`)&&this.registerStop(),this.shouldRegisterTool(`pause`)&&this.registerPause(),this.shouldRegisterTool(`resume`)&&this.registerResume(),this.shouldRegisterTool(`isSpeaking`)&&this.registerIsSpeaking(),this.shouldRegisterTool(`getVoices`)&&this.registerGetVoices()}registerSpeak(){this.server.registerTool(`extension_tool_speak_text`,{description:`Speaks text using text-to-speech synthesis`,inputSchema:{utterance:e.string().max(32768).describe(`The text to speak, either plain text or a complete SSML document. Maximum length is 32,768 characters`),lang:e.string().optional().describe(`The language to be used for synthesis, in the form language-region. Examples: "en", "en-US", "en-GB", "zh-CN"`),voiceName:e.string().optional().describe(`The name of the voice to use for synthesis. If empty, uses any available voice`),rate:e.number().min(.1).max(10).optional().describe(`Speaking rate relative to the default rate. 1.0 is default, 2.0 is twice as fast, 0.5 is half as fast`),pitch:e.number().min(0).max(2).optional().describe(`Speaking pitch between 0 and 2 inclusive, with 0 being lowest and 2 being highest. 1.0 is default`),volume:e.number().min(0).max(1).optional().describe(`Speaking volume between 0 and 1 inclusive, with 0 being lowest and 1 being highest. Default is 1.0`),enqueue:e.boolean().optional().describe(`If true, enqueues this utterance if TTS is already in progress. If false (default), interrupts current speech`),extensionId:e.string().optional().describe(`The extension ID of the speech engine to use, if known`),requiredEventTypes:e.array(e.string()).optional().describe(`The TTS event types the voice must support`),desiredEventTypes:e.array(e.string()).optional().describe(`The TTS event types that you are interested in listening to`)}},async({utterance:e,lang:t,voiceName:n,rate:r,pitch:i,volume:a,enqueue:o,extensionId:s,requiredEventTypes:c,desiredEventTypes:l})=>{try{let u={};t!==void 0&&(u.lang=t),n!==void 0&&(u.voiceName=n),r!==void 0&&(u.rate=r),i!==void 0&&(u.pitch=i),a!==void 0&&(u.volume=a),o!==void 0&&(u.enqueue=o),s!==void 0&&(u.extensionId=s),c!==void 0&&(u.requiredEventTypes=c),l!==void 0&&(u.desiredEventTypes=l);let d=[];return u.onEvent=e=>{d.push(e)},await new Promise((t,n)=>{chrome.tts.speak(e,u,()=>{chrome.runtime.lastError?n(Error(chrome.runtime.lastError.message)):t()})}),this.formatSuccess(`Text-to-speech started successfully`,{utterance:e.substring(0,100)+(e.length>100?`...`:``),options:{lang:u.lang,voiceName:u.voiceName,rate:u.rate,pitch:u.pitch,volume:u.volume,enqueue:u.enqueue}})}catch(e){return this.formatError(e)}})}registerStop(){this.server.registerTool(`extension_tool_stop_speech`,{description:`Stops any current speech and flushes the queue of pending utterances`,inputSchema:{}},async()=>{try{return chrome.tts.stop(),this.formatSuccess(`Speech stopped and queue cleared`)}catch(e){return this.formatError(e)}})}registerPause(){this.server.registerTool(`extension_tool_pause_speech`,{description:`Pauses speech synthesis, potentially in the middle of an utterance`,inputSchema:{}},async()=>{try{return chrome.tts.pause(),this.formatSuccess(`Speech paused`)}catch(e){return this.formatError(e)}})}registerResume(){this.server.registerTool(`extension_tool_resume_speech`,{description:`If speech was paused, resumes speaking where it left off`,inputSchema:{}},async()=>{try{return chrome.tts.resume(),this.formatSuccess(`Speech resumed`)}catch(e){return this.formatError(e)}})}registerIsSpeaking(){this.server.registerTool(`extension_tool_is_speaking`,{description:`Checks whether the engine is currently speaking`,inputSchema:{}},async()=>{try{let e=await new Promise((e,t)=>{chrome.tts.isSpeaking(n=>{chrome.runtime.lastError?t(Error(chrome.runtime.lastError.message)):e(n)})});return this.formatJson({speaking:e,status:e?`TTS engine is currently speaking`:`TTS engine is not speaking`})}catch(e){return this.formatError(e)}})}registerGetVoices(){this.server.registerTool(`extension_tool_get_voices`,{description:`Gets an array of all available voices for speech synthesis`,inputSchema:{}},async()=>{try{let e=await new Promise((e,t)=>{chrome.tts.getVoices(n=>{chrome.runtime.lastError?t(Error(chrome.runtime.lastError.message)):e(n)})});return this.formatJson({count:e.length,voices:e.map(e=>({voiceName:e.voiceName,lang:e.lang,extensionId:e.extensionId,eventTypes:e.eventTypes,remote:e.remote}))})}catch(e){return this.formatError(e)}})}},Ae=class extends n{apiName=`TtsEngine`;constructor(e,t={}){super(e,t)}checkAvailability(){try{return chrome.ttsEngine?typeof chrome.ttsEngine.updateVoices==`function`?!chrome.ttsEngine.onSpeak||!chrome.ttsEngine.onStop?{available:!1,message:`chrome.ttsEngine events are not available`,details:`The ttsEngine API requires event listeners to be available.`}:{available:!0,message:`TtsEngine API is fully available`}:{available:!1,message:`chrome.ttsEngine.updateVoices is not available`,details:`The ttsEngine API appears to be partially available. Check manifest permissions.`}:{available:!1,message:`chrome.ttsEngine API is not defined`,details:`This extension needs the "ttsEngine" permission in its manifest.json`}}catch(e){return{available:!1,message:`Failed to access chrome.ttsEngine API`,details:e instanceof Error?e.message:`Unknown error occurred`}}}registerTools(){this.shouldRegisterTool(`updateVoices`)&&this.registerUpdateVoices(),this.shouldRegisterTool(`updateLanguage`)&&this.registerUpdateLanguage(),this.shouldRegisterTool(`onSpeak`)&&this.registerOnSpeak(),this.shouldRegisterTool(`onStop`)&&this.registerOnStop(),this.shouldRegisterTool(`onPause`)&&this.registerOnPause(),this.shouldRegisterTool(`onResume`)&&this.registerOnResume(),this.shouldRegisterTool(`onSpeakWithAudioStream`)&&this.registerOnSpeakWithAudioStream(),this.shouldRegisterTool(`onInstallLanguageRequest`)&&this.registerOnInstallLanguageRequest(),this.shouldRegisterTool(`onLanguageStatusRequest`)&&this.registerOnLanguageStatusRequest(),this.shouldRegisterTool(`onUninstallLanguageRequest`)&&this.registerOnUninstallLanguageRequest()}registerUpdateVoices(){this.server.registerTool(`extension_tool_update_voices`,{description:`Update the list of voices available for speech synthesis`,inputSchema:{voices:e.array(e.object({voiceName:e.string().describe(`The name of the voice`),lang:e.string().optional().describe(`Language code (e.g., en-US)`),gender:e.enum([`male`,`female`]).optional().describe(`Voice gender (deprecated)`),remote:e.boolean().optional().describe(`Whether the voice is remote`),extensionId:e.string().optional().describe(`Extension ID providing the voice`),eventTypes:e.array(e.string()).optional().describe(`Supported event types`)})).describe(`Array of voice objects to register`)}},async({voices:e})=>{try{return chrome.ttsEngine.updateVoices(e),this.formatSuccess(`Voices updated successfully`,{voiceCount:e.length,voices:e.map(e=>({name:e.voiceName,lang:e.lang,eventTypes:e.eventTypes}))})}catch(e){return this.formatError(e)}})}registerUpdateLanguage(){this.server.registerTool(`extension_tool_update_language`,{description:`Update the installation status of a language`,inputSchema:{lang:e.string().describe(`Language code (e.g., en-US)`),installStatus:e.enum([`notInstalled`,`installing`,`installed`,`failed`]).describe(`Installation status`),error:e.string().optional().describe(`Error message if installation failed`)}},async({lang:e,installStatus:t,error:n})=>{try{let r={lang:e,installStatus:t};return n!==void 0&&(r.error=n),chrome.ttsEngine.updateLanguage(r),this.formatSuccess(`Language status updated successfully`,{lang:e,installStatus:t,error:n})}catch(e){return this.formatError(e)}})}registerOnSpeak(){this.server.registerTool(`extension_tool_register_speak_listener`,{description:`Register a listener for speak events from the TTS engine`,inputSchema:{}},async()=>{try{return chrome.ttsEngine.onSpeak.addListener((e,t,n)=>{n({type:`start`,charIndex:0}),setTimeout(()=>{n({type:`end`,charIndex:e.length})},1e3)}),this.formatSuccess(`Speak listener registered successfully`)}catch(e){return this.formatError(e)}})}registerOnStop(){this.server.registerTool(`extension_tool_register_stop_listener`,{description:`Register a listener for stop events from the TTS engine`,inputSchema:{}},async()=>{try{return chrome.ttsEngine.onStop.addListener(()=>{}),this.formatSuccess(`Stop listener registered successfully`)}catch(e){return this.formatError(e)}})}registerOnPause(){this.server.registerTool(`extension_tool_register_pause_listener`,{description:`Register a listener for pause events from the TTS engine`,inputSchema:{}},async()=>{try{return chrome.ttsEngine.onPause.addListener(()=>{}),this.formatSuccess(`Pause listener registered successfully`)}catch(e){return this.formatError(e)}})}registerOnResume(){this.server.registerTool(`extension_tool_register_resume_listener`,{description:`Register a listener for resume events from the TTS engine`,inputSchema:{}},async()=>{try{return chrome.ttsEngine.onResume.addListener(()=>{}),this.formatSuccess(`Resume listener registered successfully`)}catch(e){return this.formatError(e)}})}registerOnSpeakWithAudioStream(){this.server.registerTool(`extension_tool_register_speak_audio_stream_listener`,{description:`Register a listener for speak events with audio stream support`,inputSchema:{}},async()=>{try{return chrome.ttsEngine.onSpeakWithAudioStream.addListener((e,t,n,r,i)=>{try{let e=n.bufferSize;r({audioBuffer:new ArrayBuffer(e*4),charIndex:0,isLastBuffer:!0})}catch(e){i(e instanceof Error?e.message:`Unknown error`)}}),this.formatSuccess(`Speak with audio stream listener registered successfully`)}catch(e){return this.formatError(e)}})}registerOnInstallLanguageRequest(){this.server.registerTool(`extension_tool_register_install_language_listener`,{description:`Register a listener for language installation requests`,inputSchema:{}},async()=>{try{return chrome.ttsEngine.onInstallLanguageRequest.addListener((e,t)=>{chrome.ttsEngine.updateLanguage({lang:t,installStatus:`installing`})}),this.formatSuccess(`Install language listener registered successfully`)}catch(e){return this.formatError(e)}})}registerOnLanguageStatusRequest(){this.server.registerTool(`extension_tool_register_language_status_listener`,{description:`Register a listener for language status requests`,inputSchema:{}},async()=>{try{return chrome.ttsEngine.onLanguageStatusRequest.addListener((e,t)=>{chrome.ttsEngine.updateLanguage({lang:t,installStatus:`installed`})}),this.formatSuccess(`Language status listener registered successfully`)}catch(e){return this.formatError(e)}})}registerOnUninstallLanguageRequest(){this.server.registerTool(`extension_tool_register_uninstall_language_listener`,{description:`Register a listener for language uninstallation requests`,inputSchema:{}},async()=>{try{return chrome.ttsEngine.onUninstallLanguageRequest.addListener((e,t,n)=>{n.uninstallImmediately&&chrome.ttsEngine.updateLanguage({lang:t,installStatus:`notInstalled`})}),this.formatSuccess(`Uninstall language listener registered successfully`)}catch(e){return this.formatError(e)}})}},je=class extends n{apiName=`UserScripts`;constructor(e,t={}){super(e,t)}checkAvailability(){try{return chrome.userScripts?typeof chrome.userScripts.getScripts==`function`?(chrome.userScripts.getScripts({},()=>{if(chrome.runtime.lastError)throw Error(chrome.runtime.lastError.message)}),{available:!0,message:`UserScripts API is fully available`}):{available:!1,message:`chrome.userScripts.getScripts is not available`,details:`The userScripts API appears to be partially available. Check manifest permissions and user toggle settings.`}:{available:!1,message:`chrome.userScripts API is not defined`,details:`This extension needs the "userScripts" permission in its manifest.json and users must enable the appropriate toggle (Developer mode for Chrome <138 or Allow User Scripts for Chrome 138+)`}}catch(e){return{available:!1,message:`Failed to access chrome.userScripts API`,details:e instanceof Error?e.message:`Unknown error occurred`}}}registerTools(){this.shouldRegisterTool(`register`)&&this.registerRegister(),this.shouldRegisterTool(`getScripts`)&&this.registerGetScripts(),this.shouldRegisterTool(`update`)&&this.registerUpdate(),this.shouldRegisterTool(`unregister`)&&this.registerUnregister(),this.shouldRegisterTool(`configureWorld`)&&this.registerConfigureWorld(),this.shouldRegisterTool(`getWorldConfigurations`)&&this.registerGetWorldConfigurations(),this.shouldRegisterTool(`resetWorldConfiguration`)&&this.registerResetWorldConfiguration(),this.shouldRegisterTool(`execute`)&&this.registerExecute()}registerRegister(){this.server.registerTool(`extension_tool_register_user_scripts`,{description:`Register one or more user scripts for this extension`,inputSchema:{scripts:e.array(e.object({id:e.string().describe(`The ID of the user script. Must not start with underscore`),matches:e.array(e.string()).describe(`Match patterns for pages this script will be injected into`),js:e.array(e.object({code:e.string().optional().describe(`JavaScript code to inject`),file:e.string().optional().describe(`Path to JavaScript file relative to extension root`)})).optional().describe(`List of script sources to inject`),allFrames:e.boolean().optional().describe(`Whether to inject into all frames (default: false)`),excludeMatches:e.array(e.string()).optional().describe(`Pages to exclude from injection`),includeGlobs:e.array(e.string()).optional().describe(`Wildcard patterns for pages to include`),excludeGlobs:e.array(e.string()).optional().describe(`Wildcard patterns for pages to exclude`),runAt:e.enum([`document_start`,`document_end`,`document_idle`]).optional().describe(`When to inject the script (default: document_idle)`),world:e.enum([`MAIN`,`USER_SCRIPT`]).optional().describe(`JavaScript execution environment (default: USER_SCRIPT)`),worldId:e.string().optional().describe(`User script world ID to execute in`)})).describe(`Array of user scripts to register`)}},async({scripts:e})=>{try{for(let t of e){if(t.id.startsWith(`_`))return this.formatError(`Script ID cannot start with underscore: ${t.id}`);if(t.js){for(let e of t.js)if(e.code!==void 0==(e.file!==void 0))return this.formatError(`Exactly one of code or file must be specified for each script source`)}}return await new Promise((t,n)=>{chrome.userScripts.register(e,()=>{chrome.runtime.lastError?n(Error(chrome.runtime.lastError.message)):t()})}),this.formatSuccess(`User scripts registered successfully`,{registeredCount:e.length,scriptIds:e.map(e=>e.id)})}catch(e){return this.formatError(e)}})}registerGetScripts(){this.server.registerTool(`extension_tool_get_user_scripts`,{description:`Get all dynamically-registered user scripts for this extension`,inputSchema:{ids:e.array(e.string()).optional().describe(`Filter to only return scripts with these IDs`)}},async({ids:e})=>{try{let t={};e!==void 0&&(t.ids=e);let n=await new Promise((e,n)=>{chrome.userScripts.getScripts(t,t=>{chrome.runtime.lastError?n(Error(chrome.runtime.lastError.message)):e(t)})});return this.formatJson({count:n.length,scripts:n.map(e=>({id:e.id,matches:e.matches,allFrames:e.allFrames,excludeMatches:e.excludeMatches,includeGlobs:e.includeGlobs,excludeGlobs:e.excludeGlobs,runAt:e.runAt,world:e.world,worldId:e.worldId,jsSourcesCount:e.js?.length||0}))})}catch(e){return this.formatError(e)}})}registerUpdate(){this.server.registerTool(`extension_tool_update_user_scripts`,{description:`Update one or more user scripts for this extension`,inputSchema:{scripts:e.array(e.object({id:e.string().describe(`The ID of the user script to update`),matches:e.array(e.string()).optional().describe(`Match patterns for pages this script will be injected into`),js:e.array(e.object({code:e.string().optional().describe(`JavaScript code to inject`),file:e.string().optional().describe(`Path to JavaScript file relative to extension root`)})).optional().describe(`List of script sources to inject`),allFrames:e.boolean().optional().describe(`Whether to inject into all frames`),excludeMatches:e.array(e.string()).optional().describe(`Pages to exclude from injection`),includeGlobs:e.array(e.string()).optional().describe(`Wildcard patterns for pages to include`),excludeGlobs:e.array(e.string()).optional().describe(`Wildcard patterns for pages to exclude`),runAt:e.enum([`document_start`,`document_end`,`document_idle`]).optional().describe(`When to inject the script`),world:e.enum([`MAIN`,`USER_SCRIPT`]).optional().describe(`JavaScript execution environment`),worldId:e.string().optional().describe(`User script world ID to execute in`)})).describe(`Array of user scripts to update`)}},async({scripts:e})=>{try{for(let t of e)if(t.js){for(let e of t.js)if(e.code!==void 0==(e.file!==void 0))return this.formatError(`Exactly one of code or file must be specified for each script source`)}return await new Promise((t,n)=>{chrome.userScripts.update(e,()=>{chrome.runtime.lastError?n(Error(chrome.runtime.lastError.message)):t()})}),this.formatSuccess(`User scripts updated successfully`,{updatedCount:e.length,scriptIds:e.map(e=>e.id)})}catch(e){return this.formatError(e)}})}registerUnregister(){this.server.registerTool(`extension_tool_unregister_user_scripts`,{description:`Unregister dynamically-registered user scripts for this extension`,inputSchema:{ids:e.array(e.string()).optional().describe(`Filter to only unregister scripts with these IDs. If not specified, all scripts are unregistered`)}},async({ids:e})=>{try{let t={};e!==void 0&&(t.ids=e);let n=await new Promise((e,n)=>{chrome.userScripts.getScripts(t,t=>{chrome.runtime.lastError?n(Error(chrome.runtime.lastError.message)):e(t)})});return await new Promise((e,n)=>{chrome.userScripts.unregister(t,()=>{chrome.runtime.lastError?n(Error(chrome.runtime.lastError.message)):e()})}),this.formatSuccess(`User scripts unregistered successfully`,{unregisteredCount:n.length,unregisteredScriptIds:n.map(e=>e.id)})}catch(e){return this.formatError(e)}})}registerConfigureWorld(){this.server.registerTool(`extension_tool_configure_user_script_world`,{description:`Configure the USER_SCRIPT execution environment`,inputSchema:{csp:e.string().optional().describe(`Content Security Policy for the world`),messaging:e.boolean().optional().describe(`Whether messaging APIs are exposed (default: false)`),worldId:e.string().optional().describe(`ID of the specific user script world to update`)}},async({csp:e,messaging:t,worldId:n})=>{try{let r={};return e!==void 0&&(r.csp=e),t!==void 0&&(r.messaging=t),n!==void 0&&(r.worldId=n),await new Promise((e,t)=>{chrome.userScripts.configureWorld(r,()=>{chrome.runtime.lastError?t(Error(chrome.runtime.lastError.message)):e()})}),this.formatSuccess(`User script world configured successfully`,{worldId:n||`default`,csp:e,messaging:t})}catch(e){return this.formatError(e)}})}registerGetWorldConfigurations(){this.server.registerTool(`extension_tool_get_world_configurations`,{description:`Retrieve all registered world configurations`,inputSchema:{}},async()=>{try{let e=await new Promise((e,t)=>{chrome.userScripts.getWorldConfigurations(n=>{chrome.runtime.lastError?t(Error(chrome.runtime.lastError.message)):e(n)})});return this.formatJson({count:e.length,worlds:e.map(e=>({worldId:e.worldId,csp:e.csp,messaging:e.messaging}))})}catch(e){return this.formatError(e)}})}registerResetWorldConfiguration(){this.server.registerTool(`extension_tool_reset_world_configuration`,{description:`Reset the configuration for a user script world to defaults`,inputSchema:{worldId:e.string().optional().describe(`ID of the user script world to reset. If omitted, resets the default world`)}},async({worldId:e=`default`})=>{try{return await new Promise((t,n)=>{chrome.userScripts.resetWorldConfiguration(e,()=>{chrome.runtime.lastError?n(Error(chrome.runtime.lastError.message)):t()})}),this.formatSuccess(`World configuration reset successfully`,{worldId:e||`default`})}catch(e){return this.formatError(e)}})}registerExecute(){this.server.registerTool(`extension_tool_execute_user_script`,{description:`Inject a script into a target context`,inputSchema:{target:e.object({tabId:e.number().describe(`The ID of the tab to inject into`),frameIds:e.array(e.number()).optional().describe(`IDs of specific frames to inject into`),documentIds:e.array(e.string()).optional().describe(`IDs of specific documents to inject into`),allFrames:e.boolean().optional().describe(`Whether to inject into all frames (default: false)`)}).describe(`Target specification for injection`),js:e.array(e.object({code:e.string().optional().describe(`JavaScript code to inject`),file:e.string().optional().describe(`Path to JavaScript file relative to extension root`)})).describe(`List of script sources to inject`),world:e.enum([`MAIN`,`USER_SCRIPT`]).optional().describe(`JavaScript execution environment (default: USER_SCRIPT)`),worldId:e.string().optional().describe(`User script world ID to execute in`),injectImmediately:e.boolean().optional().describe(`Whether to inject immediately without waiting (default: false)`)}},async({target:e,js:t,world:n,worldId:r,injectImmediately:i})=>{try{for(let e of t)if(e.code!==void 0==(e.file!==void 0))return this.formatError(`Exactly one of code or file must be specified for each script source`);let a={target:e,js:t};n!==void 0&&(a.world=n),r!==void 0&&(a.worldId=r),i!==void 0&&(a.injectImmediately=i);let o=await new Promise((e,t)=>{chrome.userScripts.execute(a,n=>{chrome.runtime.lastError?t(Error(chrome.runtime.lastError.message)):e(n)})});return this.formatJson({injectionCount:o.length,results:o.map(e=>({frameId:e.frameId,documentId:e.documentId,error:e.error,hasResult:e.result!==void 0}))})}catch(e){return this.formatError(e)}})}},Me=class extends n{apiName=`VpnProvider`;constructor(e,t={}){super(e,t)}checkAvailability(){try{return chrome.vpnProvider?typeof chrome.vpnProvider.createConfig==`function`?{available:!0,message:`VpnProvider API is fully available`}:{available:!1,message:`chrome.vpnProvider.createConfig is not available`,details:`The vpnProvider API appears to be partially available. Check manifest permissions and ensure this is running on ChromeOS.`}:{available:!1,message:`chrome.vpnProvider API is not defined`,details:`This extension needs the "vpnProvider" permission in its manifest.json and only works on ChromeOS`}}catch(e){return{available:!1,message:`Failed to access chrome.vpnProvider API`,details:e instanceof Error?e.message:`Unknown error occurred`}}}registerTools(){this.shouldRegisterTool(`createConfig`)&&this.registerCreateConfig(),this.shouldRegisterTool(`destroyConfig`)&&this.registerDestroyConfig(),this.shouldRegisterTool(`setParameters`)&&this.registerSetParameters(),this.shouldRegisterTool(`notifyConnectionStateChanged`)&&this.registerNotifyConnectionStateChanged(),this.shouldRegisterTool(`sendPacket`)&&this.registerSendPacket()}registerCreateConfig(){this.server.registerTool(`extension_tool_create_vpn_config`,{description:`Create a new VPN configuration that persists across multiple login sessions`,inputSchema:{name:e.string().describe(`The name of the VPN configuration`)}},async({name:e})=>{try{let t=await new Promise((t,n)=>{chrome.vpnProvider.createConfig(e,e=>{chrome.runtime.lastError?n(Error(chrome.runtime.lastError.message)):e?t(e):n(Error(`Failed to create VPN configuration`))})});return this.formatSuccess(`VPN configuration created successfully`,{id:t,name:e})}catch(e){return this.formatError(e)}})}registerDestroyConfig(){this.server.registerTool(`extension_tool_destroy_vpn_config`,{description:`Destroy a VPN configuration created by the extension`,inputSchema:{id:e.string().describe(`ID of the VPN configuration to destroy`)}},async({id:e})=>{try{return await new Promise((t,n)=>{chrome.vpnProvider.destroyConfig(e,()=>{chrome.runtime.lastError?n(Error(chrome.runtime.lastError.message)):t()})}),this.formatSuccess(`VPN configuration destroyed successfully`,{id:e})}catch(e){return this.formatError(e)}})}registerSetParameters(){this.server.registerTool(`extension_tool_set_vpn_parameters`,{description:`Set the parameters for the VPN session. Should be called immediately after "connected" is received`,inputSchema:{address:e.string().describe(`IP address for the VPN interface in CIDR notation. IPv4 is currently the only supported mode`),dnsServer:e.array(e.string()).describe(`A list of IPs for the DNS servers`),inclusionList:e.array(e.string()).describe(`Include network traffic to the list of IP blocks in CIDR notation to the tunnel`),exclusionList:e.array(e.string()).describe(`Exclude network traffic to the list of IP blocks in CIDR notation from the tunnel`),broadcastAddress:e.string().optional().describe(`Broadcast address for the VPN interface (default: deduced from IP address and mask)`),domainSearch:e.array(e.string()).optional().describe(`A list of search domains (default: no search domain)`),mtu:e.string().optional().describe(`MTU setting for the VPN interface (default: 1500 bytes)`)}},async({address:e,dnsServer:t,inclusionList:n,exclusionList:r,broadcastAddress:i,domainSearch:a,mtu:o})=>{try{let s={address:e,dnsServer:t,inclusionList:n,exclusionList:r};return i!==void 0&&(s.broadcastAddress=i),a!==void 0&&(s.domainSearch=a),o!==void 0&&(s.mtu=o),await new Promise((e,t)=>{chrome.vpnProvider.setParameters(s,()=>{chrome.runtime.lastError?t(Error(chrome.runtime.lastError.message)):e()})}),this.formatSuccess(`VPN parameters set successfully`,{parameters:s})}catch(e){return this.formatError(e)}})}registerNotifyConnectionStateChanged(){this.server.registerTool(`extension_tool_notify_vpn_connection_state`,{description:`Notify the VPN session state to the platform. This will succeed only when the VPN session is owned by the extension`,inputSchema:{state:e.enum([`connected`,`failure`]).describe(`The VPN session state of the VPN client`)}},async({state:e})=>{try{return await new Promise((t,n)=>{chrome.vpnProvider.notifyConnectionStateChanged(e,()=>{chrome.runtime.lastError?n(Error(chrome.runtime.lastError.message)):t()})}),this.formatSuccess(`VPN connection state notified successfully`,{state:e})}catch(e){return this.formatError(e)}})}registerSendPacket(){this.server.registerTool(`extension_tool_send_vpn_packet`,{description:`Send an IP packet through the tunnel created for the VPN session. This will succeed only when the VPN session is owned by the extension`,inputSchema:{data:e.string().describe(`The IP packet data as a base64 encoded string`)}},async({data:e})=>{try{let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);let r=n.buffer;return await new Promise((e,t)=>{chrome.vpnProvider.sendPacket(r,()=>{chrome.runtime.lastError?t(Error(chrome.runtime.lastError.message)):e()})}),this.formatSuccess(`VPN packet sent successfully`,{packetSize:r.byteLength})}catch(e){return this.formatError(e)}})}},Ne=class extends n{apiName=`Wallpaper`;constructor(e,t={}){super(e,t)}checkAvailability(){try{return chrome.wallpaper?typeof chrome.wallpaper.setWallpaper==`function`?{available:!0,message:`Wallpaper API is fully available`}:{available:!1,message:`chrome.wallpaper.setWallpaper is not available`,details:`The wallpaper API appears to be partially available. Check manifest permissions and ensure you are running on ChromeOS.`}:{available:!1,message:`chrome.wallpaper API is not defined`,details:`This extension needs the "wallpaper" permission in its manifest.json and only works on ChromeOS`}}catch(e){return{available:!1,message:`Failed to access chrome.wallpaper API`,details:e instanceof Error?e.message:`Unknown error occurred`}}}registerTools(){this.shouldRegisterTool(`setWallpaper`)&&this.registerSetWallpaper()}registerSetWallpaper(){this.server.registerTool(`extension_tool_set_wallpaper`,{description:`Set the ChromeOS wallpaper to an image from a URL or data`,inputSchema:{filename:e.string().describe(`The file name of the saved wallpaper`),layout:e.enum([`STRETCH`,`CENTER`,`CENTER_CROPPED`]).describe(`The wallpaper layout`),url:e.string().optional().describe(`The URL of the wallpaper to be set (can be relative)`),data:e.string().optional().describe(`Base64 encoded jpeg or png wallpaper image data`),thumbnail:e.boolean().optional().describe(`True if a 128x60 thumbnail should be generated`)}},async({filename:e,layout:t,url:n,data:r,thumbnail:i})=>{try{if(!n&&!r)return this.formatError(`Either url or data must be specified to set wallpaper`);if(n&&r)return this.formatError(`Cannot specify both url and data. Choose one method to set wallpaper`);let a={filename:e,layout:t};if(n&&(a.url=n),r)try{let e=atob(r),t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);a.data=t.buffer}catch{return this.formatError(`Invalid base64 data provided`)}i!==void 0&&(a.thumbnail=i);let o=await new Promise((e,t)=>{chrome.wallpaper.setWallpaper(a,n=>{chrome.runtime.lastError?t(Error(chrome.runtime.lastError.message)):e(n)})}),s={filename:e,layout:t,success:!0};if(n&&(s.url=n),o){let e=new Uint8Array(o),t=``;for(let n=0;n<e.byteLength;n++)t+=String.fromCharCode(e[n]);s.thumbnail=btoa(t),s.thumbnailSize=o.byteLength}return this.formatSuccess(`Wallpaper set successfully`,s)}catch(e){return this.formatError(e)}})}},Pe=class extends n{apiName=`WebAuthenticationProxy`;constructor(e,t={}){super(e,t)}checkAvailability(){try{return chrome.webAuthenticationProxy?typeof chrome.webAuthenticationProxy.attach==`function`?{available:!0,message:`WebAuthenticationProxy API is fully available`}:{available:!1,message:`chrome.webAuthenticationProxy.attach is not available`,details:`The webAuthenticationProxy API appears to be partially available. Check manifest permissions.`}:{available:!1,message:`chrome.webAuthenticationProxy API is not defined`,details:`This extension needs the "webAuthenticationProxy" permission in its manifest.json`}}catch(e){return{available:!1,message:`Failed to access chrome.webAuthenticationProxy API`,details:e instanceof Error?e.message:`Unknown error occurred`}}}registerTools(){this.shouldRegisterTool(`attach`)&&this.registerAttach(),this.shouldRegisterTool(`detach`)&&this.registerDetach(),this.shouldRegisterTool(`completeCreateRequest`)&&this.registerCompleteCreateRequest(),this.shouldRegisterTool(`completeGetRequest`)&&this.registerCompleteGetRequest(),this.shouldRegisterTool(`completeIsUvpaaRequest`)&&this.registerCompleteIsUvpaaRequest(),this.shouldRegisterTool(`onCreateRequest`)&&this.registerOnCreateRequest(),this.shouldRegisterTool(`onGetRequest`)&&this.registerOnGetRequest(),this.shouldRegisterTool(`onIsUvpaaRequest`)&&this.registerOnIsUvpaaRequest(),this.shouldRegisterTool(`onRemoteSessionStateChange`)&&this.registerOnRemoteSessionStateChange(),this.shouldRegisterTool(`onRequestCanceled`)&&this.registerOnRequestCanceled()}registerAttach(){this.server.registerTool(`extension_tool_attach_web_authentication_proxy`,{description:`Makes this extension the active Web Authentication API request proxy`,inputSchema:{}},async()=>{try{let e=await new Promise((e,t)=>{chrome.webAuthenticationProxy.attach(n=>{chrome.runtime.lastError?t(Error(chrome.runtime.lastError.message)):e(n)})});return e?this.formatError(e):this.formatSuccess(`Successfully attached as Web Authentication API request proxy`)}catch(e){return this.formatError(e)}})}registerDetach(){this.server.registerTool(`extension_tool_detach_web_authentication_proxy`,{description:`Removes this extension from being the active Web Authentication API request proxy`,inputSchema:{}},async()=>{try{let e=await new Promise((e,t)=>{chrome.webAuthenticationProxy.detach(n=>{chrome.runtime.lastError?t(Error(chrome.runtime.lastError.message)):e(n)})});return e?this.formatError(e):this.formatSuccess(`Successfully detached from Web Authentication API request proxy`)}catch(e){return this.formatError(e)}})}registerCompleteCreateRequest(){this.server.registerTool(`extension_tool_complete_create_request`,{description:`Reports the result of a navigator.credentials.create() call`,inputSchema:{requestId:e.number().describe(`The requestId of the CreateRequest`),responseJson:e.string().optional().describe(`The PublicKeyCredential serialized as JSON`),error:e.object({name:e.string().describe(`The DOMException name`),message:e.string().describe(`The DOMException message`)}).optional().describe(`The DOMException yielded by the remote request, if any`)}},async({requestId:e,responseJson:t,error:n})=>{try{let r={requestId:e};return t!==void 0&&(r.responseJson=t),n!==void 0&&(r.error=n),await new Promise((e,t)=>{chrome.webAuthenticationProxy.completeCreateRequest(r,()=>{chrome.runtime.lastError?t(Error(chrome.runtime.lastError.message)):e()})}),this.formatSuccess(`Create request completed successfully`,{requestId:e})}catch(e){return this.formatError(e)}})}registerCompleteGetRequest(){this.server.registerTool(`extension_tool_complete_get_request`,{description:`Reports the result of a navigator.credentials.get() call`,inputSchema:{requestId:e.number().describe(`The requestId of the GetRequest`),responseJson:e.string().optional().describe(`The PublicKeyCredential serialized as JSON`),error:e.object({name:e.string().describe(`The DOMException name`),message:e.string().describe(`The DOMException message`)}).optional().describe(`The DOMException yielded by the remote request, if any`)}},async({requestId:e,responseJson:t,error:n})=>{try{let r={requestId:e};return t!==void 0&&(r.responseJson=t),n!==void 0&&(r.error=n),await new Promise((e,t)=>{chrome.webAuthenticationProxy.completeGetRequest(r,()=>{chrome.runtime.lastError?t(Error(chrome.runtime.lastError.message)):e()})}),this.formatSuccess(`Get request completed successfully`,{requestId:e})}catch(e){return this.formatError(e)}})}registerCompleteIsUvpaaRequest(){this.server.registerTool(`extension_tool_complete_is_uvpaa_request`,{description:`Reports the result of a PublicKeyCredential.isUserVerifyingPlatformAuthenticator() call`,inputSchema:{requestId:e.number().describe(`The requestId of the IsUvpaaRequest`),isUvpaa:e.boolean().describe(`Whether user verifying platform authenticator is available`)}},async({requestId:e,isUvpaa:t})=>{try{let n={requestId:e,isUvpaa:t};return await new Promise((e,t)=>{chrome.webAuthenticationProxy.completeIsUvpaaRequest(n,()=>{chrome.runtime.lastError?t(Error(chrome.runtime.lastError.message)):e()})}),this.formatSuccess(`IsUvpaa request completed successfully`,{requestId:e,isUvpaa:t})}catch(e){return this.formatError(e)}})}registerOnCreateRequest(){this.server.registerTool(`extension_tool_listen_create_requests`,{description:`Start listening for WebAuthn navigator.credentials.create() calls`,inputSchema:{}},async()=>{try{return chrome.webAuthenticationProxy.onCreateRequest.addListener(e=>{console.log(`WebAuthn create request received:`,{requestId:e.requestId,requestDetailsJson:e.requestDetailsJson})}),this.formatSuccess(`Started listening for WebAuthn create requests`)}catch(e){return this.formatError(e)}})}registerOnGetRequest(){this.server.registerTool(`extension_tool_listen_get_requests`,{description:`Start listening for WebAuthn navigator.credentials.get() calls`,inputSchema:{}},async()=>{try{return chrome.webAuthenticationProxy.onGetRequest.addListener(e=>{console.log(`WebAuthn get request received:`,{requestId:e.requestId,requestDetailsJson:e.requestDetailsJson})}),this.formatSuccess(`Started listening for WebAuthn get requests`)}catch(e){return this.formatError(e)}})}registerOnIsUvpaaRequest(){this.server.registerTool(`extension_tool_listen_is_uvpaa_requests`,{description:`Start listening for PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable() calls`,inputSchema:{}},async()=>{try{return chrome.webAuthenticationProxy.onIsUvpaaRequest.addListener(e=>{console.log(`WebAuthn isUvpaa request received:`,{requestId:e.requestId})}),this.formatSuccess(`Started listening for WebAuthn isUvpaa requests`)}catch(e){return this.formatError(e)}})}registerOnRemoteSessionStateChange(){this.server.registerTool(`extension_tool_listen_remote_session_state_changes`,{description:`Start listening for remote session state changes`,inputSchema:{}},async()=>{try{return chrome.webAuthenticationProxy.onRemoteSessionStateChange.addListener(()=>{console.log(`Remote session state change detected`)}),this.formatSuccess(`Started listening for remote session state changes`)}catch(e){return this.formatError(e)}})}registerOnRequestCanceled(){this.server.registerTool(`extension_tool_listen_request_canceled`,{description:`Start listening for canceled WebAuthn requests`,inputSchema:{}},async()=>{try{return chrome.webAuthenticationProxy.onRequestCanceled.addListener(e=>{console.log(`WebAuthn request canceled:`,{requestId:e})}),this.formatSuccess(`Started listening for canceled WebAuthn requests`)}catch(e){return this.formatError(e)}})}},Fe=class extends n{apiName=`WebNavigation`;constructor(e,t={}){super(e,t)}checkAvailability(){try{return chrome.webNavigation?typeof chrome.webNavigation.getAllFrames==`function`?{available:!0,message:`WebNavigation API is fully available`}:{available:!1,message:`chrome.webNavigation.getAllFrames is not available`,details:`The webNavigation API appears to be partially available. Check manifest permissions.`}:{available:!1,message:`chrome.webNavigation API is not defined`,details:`This extension needs the "webNavigation" permission in its manifest.json`}}catch(e){return{available:!1,message:`Failed to access chrome.webNavigation API`,details:e instanceof Error?e.message:`Unknown error occurred`}}}registerTools(){this.shouldRegisterTool(`getAllFrames`)&&this.registerGetAllFrames(),this.shouldRegisterTool(`getFrame`)&&this.registerGetFrame(),this.shouldRegisterTool(`onBeforeNavigate`)&&this.registerOnBeforeNavigate(),this.shouldRegisterTool(`onCommitted`)&&this.registerOnCommitted(),this.shouldRegisterTool(`onCompleted`)&&this.registerOnCompleted(),this.shouldRegisterTool(`onCreatedNavigationTarget`)&&this.registerOnCreatedNavigationTarget(),this.shouldRegisterTool(`onDOMContentLoaded`)&&this.registerOnDOMContentLoaded(),this.shouldRegisterTool(`onErrorOccurred`)&&this.registerOnErrorOccurred(),this.shouldRegisterTool(`onHistoryStateUpdated`)&&this.registerOnHistoryStateUpdated(),this.shouldRegisterTool(`onReferenceFragmentUpdated`)&&this.registerOnReferenceFragmentUpdated(),this.shouldRegisterTool(`onTabReplaced`)&&this.registerOnTabReplaced()}registerGetAllFrames(){this.server.registerTool(`extension_tool_get_all_frames`,{description:`Retrieves information about all frames of a given tab`,inputSchema:{tabId:e.number().describe(`The ID of the tab to retrieve all frames from`)}},async({tabId:e})=>{try{let t=await new Promise((t,n)=>{chrome.webNavigation.getAllFrames({tabId:e},e=>{chrome.runtime.lastError?n(Error(chrome.runtime.lastError.message)):t(e??void 0)})});return t?this.formatJson({tabId:e,frameCount:t.length,frames:t.map(e=>({frameId:e.frameId,parentFrameId:e.parentFrameId,processId:e.processId,url:e.url,errorOccurred:e.errorOccurred,documentId:e.documentId,documentLifecycle:e.documentLifecycle,frameType:e.frameType,parentDocumentId:e.parentDocumentId}))}):this.formatError(`Invalid tab ID or no frames found`)}catch(e){return this.formatError(e)}})}registerGetFrame(){this.server.registerTool(`extension_tool_get_frame`,{description:`Retrieves information about the given frame. A frame refers to an iframe or frame of a web page`,inputSchema:{tabId:e.number().optional().describe(`The ID of the tab in which the frame is`),frameId:e.number().optional().describe(`The ID of the frame in the given tab`)}},async({tabId:e,frameId:t})=>{try{let n={};e!==void 0&&(n.tabId=e),t!==void 0&&(n.frameId=t);let r=await new Promise((e,t)=>{chrome.webNavigation.getFrame(n,n=>{chrome.runtime.lastError?t(Error(chrome.runtime.lastError.message)):e(n??void 0)})});return r?this.formatJson({parentFrameId:r.parentFrameId,url:r.url,errorOccurred:r.errorOccurred,documentId:r.documentId,documentLifecycle:r.documentLifecycle,frameType:r.frameType,parentDocumentId:r.parentDocumentId}):this.formatSuccess(`No frame found with the specified parameters`)}catch(e){return this.formatError(e)}})}registerOnBeforeNavigate(){this.server.registerTool(`extension_tool_on_before_navigate`,{description:`Sets up a listener for navigation events that are about to occur. Returns immediately after setting up the listener`,inputSchema:{urlFilters:e.array(e.string()).optional().describe(`URL patterns to filter navigation events. If not provided, listens to all navigations`)}},async({urlFilters:e})=>{try{let t=e?{url:e.map(e=>({urlMatches:e}))}:void 0;return chrome.webNavigation.onBeforeNavigate.addListener(e=>{console.log(`Navigation about to occur:`,{tabId:e.tabId,frameId:e.frameId,parentFrameId:e.parentFrameId,url:e.url,timeStamp:e.timeStamp,processId:e.processId,documentLifecycle:e.documentLifecycle,frameType:e.frameType,parentDocumentId:e.parentDocumentId})},t),this.formatSuccess(`onBeforeNavigate listener registered successfully`,{hasFilters:!!t,filterCount:e?.length||0})}catch(e){return this.formatError(e)}})}registerOnCommitted(){this.server.registerTool(`extension_tool_on_committed`,{description:`Sets up a listener for navigation committed events. Fired when a navigation is committed`,inputSchema:{urlFilters:e.array(e.string()).optional().describe(`URL patterns to filter navigation events. If not provided, listens to all navigations`)}},async({urlFilters:e})=>{try{let t=e?{url:e.map(e=>({urlMatches:e}))}:void 0;return chrome.webNavigation.onCommitted.addListener(e=>{console.log(`Navigation committed:`,{tabId:e.tabId,frameId:e.frameId,url:e.url,timeStamp:e.timeStamp,processId:e.processId,transitionType:e.transitionType,transitionQualifiers:e.transitionQualifiers,documentId:e.documentId,documentLifecycle:e.documentLifecycle,frameType:e.frameType,parentDocumentId:e.parentDocumentId})},t),this.formatSuccess(`onCommitted listener registered successfully`,{hasFilters:!!t,filterCount:e?.length||0})}catch(e){return this.formatError(e)}})}registerOnCompleted(){this.server.registerTool(`extension_tool_on_completed`,{description:`Sets up a listener for navigation completed events. Fired when a document and its resources are completely loaded`,inputSchema:{urlFilters:e.array(e.string()).optional().describe(`URL patterns to filter navigation events. If not provided, listens to all navigations`)}},async({urlFilters:e})=>{try{let t=e?{url:e.map(e=>({urlMatches:e}))}:void 0;return chrome.webNavigation.onCompleted.addListener(e=>{console.log(`Navigation completed:`,{tabId:e.tabId,frameId:e.frameId,url:e.url,timeStamp:e.timeStamp,processId:e.processId,documentId:e.documentId,documentLifecycle:e.documentLifecycle,frameType:e.frameType,parentDocumentId:e.parentDocumentId})},t),this.formatSuccess(`onCompleted listener registered successfully`,{hasFilters:!!t,filterCount:e?.length||0})}catch(e){return this.formatError(e)}})}registerOnCreatedNavigationTarget(){this.server.registerTool(`extension_tool_on_created_navigation_target`,{description:`Sets up a listener for new navigation target creation events. Fired when a new window or tab is created to host a navigation`,inputSchema:{urlFilters:e.array(e.string()).optional().describe(`URL patterns to filter navigation events. If not provided, listens to all navigations`)}},async({urlFilters:e})=>{try{let t=e?{url:e.map(e=>({urlMatches:e}))}:void 0;return chrome.webNavigation.onCreatedNavigationTarget.addListener(e=>{console.log(`Navigation target created:`,{sourceTabId:e.sourceTabId,sourceFrameId:e.sourceFrameId,sourceProcessId:e.sourceProcessId,tabId:e.tabId,url:e.url,timeStamp:e.timeStamp})},t),this.formatSuccess(`onCreatedNavigationTarget listener registered successfully`,{hasFilters:!!t,filterCount:e?.length||0})}catch(e){return this.formatError(e)}})}registerOnDOMContentLoaded(){this.server.registerTool(`extension_tool_on_dom_content_loaded`,{description:`Sets up a listener for DOM content loaded events. Fired when the page DOM is fully constructed`,inputSchema:{urlFilters:e.array(e.string()).optional().describe(`URL patterns to filter navigation events. If not provided, listens to all navigations`)}},async({urlFilters:e})=>{try{let t=e?{url:e.map(e=>({urlMatches:e}))}:void 0;return chrome.webNavigation.onDOMContentLoaded.addListener(e=>{console.log(`DOM content loaded:`,{tabId:e.tabId,frameId:e.frameId,url:e.url,timeStamp:e.timeStamp,processId:e.processId,documentId:e.documentId,documentLifecycle:e.documentLifecycle,frameType:e.frameType,parentDocumentId:e.parentDocumentId})},t),this.formatSuccess(`onDOMContentLoaded listener registered successfully`,{hasFilters:!!t,filterCount:e?.length||0})}catch(e){return this.formatError(e)}})}registerOnErrorOccurred(){this.server.registerTool(`extension_tool_on_error_occurred`,{description:`Sets up a listener for navigation error events. Fired when an error occurs and navigation is aborted`,inputSchema:{urlFilters:e.array(e.string()).optional().describe(`URL patterns to filter navigation events. If not provided, listens to all navigations`)}},async({urlFilters:e})=>{try{let t=e?{url:e.map(e=>({urlMatches:e}))}:void 0;return chrome.webNavigation.onErrorOccurred.addListener(e=>{console.log(`Navigation error occurred:`,{tabId:e.tabId,frameId:e.frameId,url:e.url,error:e.error,timeStamp:e.timeStamp,processId:e.processId,documentId:e.documentId,documentLifecycle:e.documentLifecycle,frameType:e.frameType,parentDocumentId:e.parentDocumentId})},t),this.formatSuccess(`onErrorOccurred listener registered successfully`,{hasFilters:!!t,filterCount:e?.length||0})}catch(e){return this.formatError(e)}})}registerOnHistoryStateUpdated(){this.server.registerTool(`extension_tool_on_history_state_updated`,{description:`Sets up a listener for history state update events. Fired when the frame history was updated to a new URL`,inputSchema:{urlFilters:e.array(e.string()).optional().describe(`URL patterns to filter navigation events. If not provided, listens to all navigations`)}},async({urlFilters:e})=>{try{let t=e?{url:e.map(e=>({urlMatches:e}))}:void 0;return chrome.webNavigation.onHistoryStateUpdated.addListener(e=>{console.log(`History state updated:`,{tabId:e.tabId,frameId:e.frameId,url:e.url,timeStamp:e.timeStamp,processId:e.processId,transitionType:e.transitionType,transitionQualifiers:e.transitionQualifiers,documentId:e.documentId,documentLifecycle:e.documentLifecycle,frameType:e.frameType,parentDocumentId:e.parentDocumentId})},t),this.formatSuccess(`onHistoryStateUpdated listener registered successfully`,{hasFilters:!!t,filterCount:e?.length||0})}catch(e){return this.formatError(e)}})}registerOnReferenceFragmentUpdated(){this.server.registerTool(`extension_tool_on_reference_fragment_updated`,{description:`Sets up a listener for reference fragment update events. Fired when the reference fragment of a frame was updated`,inputSchema:{urlFilters:e.array(e.string()).optional().describe(`URL patterns to filter navigation events. If not provided, listens to all navigations`)}},async({urlFilters:e})=>{try{let t=e?{url:e.map(e=>({urlMatches:e}))}:void 0;return chrome.webNavigation.onReferenceFragmentUpdated.addListener(e=>{console.log(`Reference fragment updated:`,{tabId:e.tabId,frameId:e.frameId,url:e.url,timeStamp:e.timeStamp,processId:e.processId,transitionType:e.transitionType,transitionQualifiers:e.transitionQualifiers,documentId:e.documentId,documentLifecycle:e.documentLifecycle,frameType:e.frameType,parentDocumentId:e.parentDocumentId})},t),this.formatSuccess(`onReferenceFragmentUpdated listener registered successfully`,{hasFilters:!!t,filterCount:e?.length||0})}catch(e){return this.formatError(e)}})}registerOnTabReplaced(){this.server.registerTool(`extension_tool_on_tab_replaced`,{description:`Sets up a listener for tab replacement events. Fired when the contents of a tab is replaced by a different tab`,inputSchema:{}},async()=>{try{return chrome.webNavigation.onTabReplaced.addListener(e=>{console.log(`Tab replaced:`,{replacedTabId:e.replacedTabId,tabId:e.tabId,timeStamp:e.timeStamp})}),this.formatSuccess(`onTabReplaced listener registered successfully`)}catch(e){return this.formatError(e)}})}},G=class extends n{apiName=`WebRequest`;constructor(e,t={}){super(e,t)}checkAvailability(){try{return chrome.webRequest?typeof chrome.webRequest.handlerBehaviorChanged==`function`?chrome.webRequest.onBeforeRequest?{available:!0,message:`WebRequest API is fully available`}:{available:!1,message:`chrome.webRequest events are not available`,details:`WebRequest events are required for this API to function properly.`}:{available:!1,message:`chrome.webRequest.handlerBehaviorChanged is not available`,details:`The webRequest API appears to be partially available. Check manifest permissions.`}:{available:!1,message:`chrome.webRequest API is not defined`,details:`This extension needs the "webRequest" permission in its manifest.json`}}catch(e){return{available:!1,message:`Failed to access chrome.webRequest API`,details:e instanceof Error?e.message:`Unknown error occurred`}}}registerTools(){this.shouldRegisterTool(`addListener`)&&this.registerAddListener(),this.shouldRegisterTool(`removeListener`)&&this.registerRemoveListener(),this.shouldRegisterTool(`hasListener`)&&this.registerHasListener(),this.shouldRegisterTool(`handlerBehaviorChanged`)&&this.registerHandlerBehaviorChanged(),this.shouldRegisterTool(`getActiveListeners`)&&this.registerGetActiveListeners()}registerAddListener(){this.server.registerTool(`extension_tool_add_webrequest_listener`,{description:`Add a listener to a webRequest event to monitor or modify network requests`,inputSchema:{event:e.enum([`onBeforeRequest`,`onBeforeSendHeaders`,`onSendHeaders`,`onHeadersReceived`,`onAuthRequired`,`onBeforeRedirect`,`onResponseStarted`,`onCompleted`,`onErrorOccurred`]).describe(`The webRequest event to listen to`),urls:e.array(e.string()).describe(`Array of URL patterns to match (e.g., ["<all_urls>", "*://example.com/*"])`),types:e.array(e.enum([`main_frame`,`sub_frame`,`stylesheet`,`script`,`image`,`font`,`object`,`xmlhttprequest`,`ping`,`csp_report`,`media`,`websocket`,`webbundle`,`other`])).optional().describe(`Array of resource types to filter`),tabId:e.number().optional().describe(`Specific tab ID to monitor`),windowId:e.number().optional().describe(`Specific window ID to monitor`),extraInfoSpec:e.array(e.enum([`blocking`,`requestHeaders`,`responseHeaders`,`requestBody`,`extraHeaders`,`asyncBlocking`])).optional().describe(`Additional information to include in the event`),blocking:e.boolean().optional().describe(`Whether to block requests for modification (requires webRequestBlocking permission)`)}},async({event:e,urls:t,types:n,tabId:r,windowId:i,extraInfoSpec:a,blocking:o})=>{try{let s={urls:t};n&&(s.types=n),r!==void 0&&(s.tabId=r),i!==void 0&&(s.windowId=i);let c=a||[];o&&!c.includes(`blocking`)&&c.push(`blocking`);let l=t=>(console.log(`WebRequest ${e}:`,{requestId:t.requestId,url:t.url,method:t.method,type:t.type,tabId:t.tabId,timeStamp:t.timeStamp}),o?{}:t),u=chrome.webRequest[e];return u&&typeof u.addListener==`function`?(c.length>0?u.addListener(l,s,c):u.addListener(l,s),this.formatSuccess(`WebRequest listener added successfully`,{event:e,filter:s,extraInfoSpec:c,blocking:o||!1})):this.formatError(`Invalid webRequest event: ${e}`)}catch(e){return this.formatError(e)}})}registerRemoveListener(){this.server.registerTool(`extension_tool_remove_webrequest_listener`,{description:`Remove a webRequest event listener`,inputSchema:{event:e.enum([`onBeforeRequest`,`onBeforeSendHeaders`,`onSendHeaders`,`onHeadersReceived`,`onAuthRequired`,`onBeforeRedirect`,`onResponseStarted`,`onCompleted`,`onErrorOccurred`]).describe(`The webRequest event to remove listener from`)}},async({event:e})=>{try{let t=chrome.webRequest[e];return t&&typeof t.removeListener==`function`?this.formatSuccess(`WebRequest listener removal attempted`,{event:e,note:`All listeners for this event type have been targeted for removal`}):this.formatError(`Invalid webRequest event: ${e}`)}catch(e){return this.formatError(e)}})}registerHasListener(){this.server.registerTool(`extension_tool_has_webrequest_listener`,{description:`Check if a webRequest event has any listeners`,inputSchema:{event:e.enum([`onBeforeRequest`,`onBeforeSendHeaders`,`onSendHeaders`,`onHeadersReceived`,`onAuthRequired`,`onBeforeRedirect`,`onResponseStarted`,`onCompleted`,`onErrorOccurred`]).describe(`The webRequest event to check`)}},async({event:e})=>{try{let t=chrome.webRequest[e];if(t&&typeof t.hasListener==`function`){let n=t.hasListener();return this.formatJson({event:e,hasListener:n})}return this.formatError(`Invalid webRequest event: ${e}`)}catch(e){return this.formatError(e)}})}registerHandlerBehaviorChanged(){this.server.registerTool(`extension_tool_handler_behavior_changed`,{description:`Notify that webRequest handler behavior has changed to prevent incorrect caching`,inputSchema:{}},async()=>{try{return await new Promise((e,t)=>{chrome.webRequest.handlerBehaviorChanged(()=>{chrome.runtime.lastError?t(Error(chrome.runtime.lastError.message)):e()})}),this.formatSuccess(`Handler behavior change notification sent`,{note:`This flushes the in-memory cache to ensure behavior changes take effect`,warning:`This is an expensive operation and should not be called frequently`})}catch(e){return this.formatError(e)}})}registerGetActiveListeners(){this.server.registerTool(`extension_tool_get_active_webrequest_listeners`,{description:`Get information about currently active webRequest listeners`,inputSchema:{}},async()=>{try{let e=[`onBeforeRequest`,`onBeforeSendHeaders`,`onSendHeaders`,`onHeadersReceived`,`onAuthRequired`,`onBeforeRedirect`,`onResponseStarted`,`onCompleted`,`onErrorOccurred`],t=e.map(e=>{let t=chrome.webRequest[e];return{event:e,hasListener:t&&typeof t.hasListener==`function`?t.hasListener():!1}}),n=t.filter(e=>e.hasListener).length;return this.formatJson({totalEvents:e.length,activeListeners:n,listeners:t,maxHandlerCalls:chrome.webRequest.MAX_HANDLER_BEHAVIOR_CHANGED_CALLS_PER_10_MINUTES||20})}catch(e){return this.formatError(e)}})}};const K=[`create`,`get`,`getAll`,`getCurrent`,`getLastFocused`,`remove`,`update`],q=e.enum(K);var Ie=class extends n{apiName=`Windows`;constructor(e,t={}){super(e,t)}checkAvailability(){try{return chrome.windows?typeof chrome.windows.getAll==`function`?(chrome.windows.getAll(e=>{if(chrome.runtime.lastError)throw Error(chrome.runtime.lastError.message)}),{available:!0,message:`Windows API is fully available`}):{available:!1,message:`chrome.windows.getAll is not available`,details:`The windows API appears to be partially available. Check manifest permissions.`}:{available:!1,message:`chrome.windows API is not defined`,details:`This extension needs the "windows" permission in its manifest.json`}}catch(e){return{available:!1,message:`Failed to access chrome.windows API`,details:e instanceof Error?e.message:`Unknown error occurred`}}}registerTools(){this.server.registerTool(`extension_tool_window_operations`,{description:`Perform operations on browser windows`,inputSchema:{action:q,params:e.record(e.string(),e.any()).optional().describe(`Parameters for the chosen action`)}},async({action:e,params:t={}})=>{try{if(!this.shouldRegisterTool(e))return this.formatError(Error(`Action "${e}" is not supported`));switch(e){case`create`:return await this.handleCreate(t);case`get`:return await this.handleGet(t);case`getAll`:return await this.handleGetAll(t);case`getCurrent`:return await this.handleGetCurrent(t);case`getLastFocused`:return await this.handleGetLastFocused(t);case`remove`:return await this.handleRemove(t);case`update`:return await this.handleUpdate(t);default:return this.formatError(`Unknown action: ${String(e)}`)}}catch(e){return this.formatError(e)}}),this.server.registerTool(`extension_tool_window_parameters_description`,{description:`Get the parameters for extension_tool_window_operations tool and the description for the associated action, this tool should be used first before extension_tool_window_operations`,inputSchema:{action:q}},async({action:t})=>{try{let n=(t,n)=>e.toJSONSchema(t),r={tool:`extension_tool_window_operations`,action:t,note:`Use the description to double check if the correct action is chosen. Use this JSON Schema for the params field when calling the tool. The top-level tool input is { action, params }.`};switch(t){case`create`:{let e={params:n(this.createSchema,`CreateWindowSchema`),description:`Create a new browser window with optional sizing, position, or default URL`};return this.formatJson({...r,...e})}case`get`:{let e={params:n(this.getSchema,`GetWindowSchema`),description:`Get details about a specific window`};return this.formatJson({...r,...e})}case`getAll`:{let e={params:n(this.getAllSchema,`GetAllWindowsSchema`),description:`Get all browser windows`};return this.formatJson({...r,...e})}case`getCurrent`:{let e={params:n(this.getCurrentSchema,`GetCurrentWindowSchema`),description:`Get the current window`};return this.formatJson({...r,...e})}case`getLastFocused`:{let e={params:n(this.getLastFocusedSchema,`GetLastFocusedWindowSchema`),description:`Get the window that was most recently focused`};return this.formatJson({...r,...e})}case`remove`:{let e={params:n(this.removeSchema,`RemoveWindowSchema`),description:`Remove (close) a window and all the tabs inside it`};return this.formatJson({...r,...e})}case`update`:{let e={params:n(this.updateSchema,`UpdateWindowSchema`),description:`Update the properties of a window`};return this.formatJson({...r,...e})}default:return this.formatError(`Unknown action: ${String(t)}`)}}catch(e){return this.formatError(e)}})}createSchema=e.object({url:e.union([e.string(),e.array(e.string())]).optional().describe(`A URL or array of URLs to open as tabs in the window`),focused:e.boolean().optional().describe(`If true, opens an active window. If false, opens an inactive window`),height:e.number().optional().describe(`The height in pixels of the new window, including the frame`),incognito:e.boolean().optional().describe(`Whether the new window should be an incognito window`),left:e.number().optional().describe(`The number of pixels to position the new window from the left edge of the screen`),setSelfAsOpener:e.boolean().optional().describe(`If true, the newly-created window's 'window.opener' is set to the caller`),state:e.enum([`normal`,`minimized`,`maximized`,`fullscreen`,`locked-fullscreen`]).optional().describe(`The initial state of the window`),tabId:e.number().optional().describe(`The ID of the tab to add to the new window`),top:e.number().optional().describe(`The number of pixels to position the new window from the top edge of the screen`),type:e.enum([`normal`,`popup`,`panel`]).optional().describe(`Specifies what type of browser window to create`),width:e.number().optional().describe(`The width in pixels of the new window, including the frame`)});getSchema=e.object({windowId:e.number().describe(`The ID of the window to get`),populate:e.boolean().optional().describe(`If true, the window object will include a tabs property with tab details`),windowTypes:e.array(e.enum([`normal`,`popup`,`panel`,`app`,`devtools`])).optional().describe(`Filter the window based on its type`)});getAllSchema=e.object({populate:e.boolean().optional().describe(`If true, each window object will include a tabs property with tab details`),windowTypes:e.array(e.enum([`normal`,`popup`,`panel`,`app`,`devtools`])).optional().describe(`Filter windows based on their type`)});getCurrentSchema=e.object({populate:e.boolean().optional().describe(`If true, the window object will include a tabs property with tab details`),windowTypes:e.array(e.enum([`normal`,`popup`,`panel`,`app`,`devtools`])).optional().describe(`Filter the window based on its type`)});getLastFocusedSchema=e.object({populate:e.boolean().optional().describe(`If true, the window object will include a tabs property with tab details`),windowTypes:e.array(e.enum([`normal`,`popup`,`panel`,`app`,`devtools`])).optional().describe(`Filter the window based on its type`)});removeSchema=e.object({windowId:e.number().describe(`The ID of the window to remove`)});updateSchema=e.object({windowId:e.number().describe(`The ID of the window to update`),drawAttention:e.boolean().optional().describe(`If true, causes the window to be displayed in a manner that draws the user's attention`),focused:e.boolean().optional().describe(`If true, brings the window to the front`),height:e.number().optional().describe(`The height to resize the window to in pixels`),left:e.number().optional().describe(`The offset from the left edge of the screen to move the window to in pixels`),state:e.enum([`normal`,`minimized`,`maximized`,`fullscreen`,`locked-fullscreen`]).optional().describe(`The new state of the window`),top:e.number().optional().describe(`The offset from the top edge of the screen to move the window to in pixels`),width:e.number().optional().describe(`The width to resize the window to in pixels`)});async handleCreate(e){let{url:t,focused:n,height:r,incognito:i,left:a,setSelfAsOpener:o,state:s,tabId:c,top:l,type:u,width:d}=this.createSchema.parse(e),f={};t!==void 0&&(f.url=t),n!==void 0&&(f.focused=n),r!==void 0&&(f.height=r),i!==void 0&&(f.incognito=i),a!==void 0&&(f.left=a),o!==void 0&&(f.setSelfAsOpener=o),s!==void 0&&(f.state=s),c!==void 0&&(f.tabId=c),l!==void 0&&(f.top=l),u!==void 0&&(f.type=u),d!==void 0&&(f.width=d);let p=await new Promise((e,t)=>{chrome.windows.create(f,n=>{chrome.runtime.lastError?t(Error(chrome.runtime.lastError.message)):e(n)})});return this.formatJson({id:p.id,focused:p.focused,incognito:p.incognito,alwaysOnTop:p.alwaysOnTop,state:p.state,type:p.type,left:p.left,top:p.top,width:p.width,height:p.height,tabs:p.tabs?.map(e=>({id:e.id,url:e.url,title:e.title,active:e.active}))})}async handleGet(e){let{windowId:t,populate:n,windowTypes:r}=this.getSchema.parse(e),i={};n!==void 0&&(i.populate=n),r!==void 0&&(i.windowTypes=r);let a=await new Promise((e,n)=>{chrome.windows.get(t,i,t=>{chrome.runtime.lastError?n(Error(chrome.runtime.lastError.message)):e(t)})});return this.formatJson({id:a.id,focused:a.focused,incognito:a.incognito,alwaysOnTop:a.alwaysOnTop,state:a.state,type:a.type,left:a.left,top:a.top,width:a.width,height:a.height,sessionId:a.sessionId,tabs:a.tabs?.map(e=>({id:e.id,url:e.url,title:e.title,active:e.active,index:e.index}))})}async handleGetAll(e){let{populate:t,windowTypes:n}=this.getAllSchema.parse(e),r={};t!==void 0&&(r.populate=t),n!==void 0&&(r.windowTypes=n);let i=await new Promise((e,t)=>{chrome.windows.getAll(r,n=>{chrome.runtime.lastError?t(Error(chrome.runtime.lastError.message)):e(n)})});return this.formatJson({count:i.length,windows:i.map(e=>({id:e.id,focused:e.focused,incognito:e.incognito,alwaysOnTop:e.alwaysOnTop,state:e.state,type:e.type,left:e.left,top:e.top,width:e.width,height:e.height,sessionId:e.sessionId,tabs:e.tabs?.map(e=>({id:e.id,url:e.url,title:e.title,active:e.active,index:e.index}))}))})}async handleGetCurrent(e){let{populate:t,windowTypes:n}=this.getCurrentSchema.parse(e),r={};t!==void 0&&(r.populate=t),n!==void 0&&(r.windowTypes=n);let i=await new Promise((e,t)=>{chrome.windows.getCurrent(r,n=>{chrome.runtime.lastError?t(Error(chrome.runtime.lastError.message)):e(n)})});return this.formatJson({id:i.id,focused:i.focused,incognito:i.incognito,alwaysOnTop:i.alwaysOnTop,state:i.state,type:i.type,left:i.left,top:i.top,width:i.width,height:i.height,sessionId:i.sessionId,tabs:i.tabs?.map(e=>({id:e.id,url:e.url,title:e.title,active:e.active,index:e.index}))})}async handleGetLastFocused(e){let{populate:t,windowTypes:n}=this.getLastFocusedSchema.parse(e),r={};t!==void 0&&(r.populate=t),n!==void 0&&(r.windowTypes=n);let i=await new Promise((e,t)=>{chrome.windows.getLastFocused(r,n=>{chrome.runtime.lastError?t(Error(chrome.runtime.lastError.message)):e(n)})});return this.formatJson({id:i.id,focused:i.focused,incognito:i.incognito,alwaysOnTop:i.alwaysOnTop,state:i.state,type:i.type,left:i.left,top:i.top,width:i.width,height:i.height,sessionId:i.sessionId,tabs:i.tabs?.map(e=>({id:e.id,url:e.url,title:e.title,active:e.active,index:e.index}))})}async handleRemove(e){let{windowId:t}=this.removeSchema.parse(e);return await new Promise((e,n)=>{chrome.windows.remove(t,()=>{chrome.runtime.lastError?n(Error(chrome.runtime.lastError.message)):e()})}),this.formatSuccess(`Window removed successfully`,{windowId:t})}async handleUpdate(e){let{windowId:t,drawAttention:n,focused:r,height:i,left:a,state:o,top:s,width:c}=this.updateSchema.parse(e),l={};n!==void 0&&(l.drawAttention=n),r!==void 0&&(l.focused=r),i!==void 0&&(l.height=i),a!==void 0&&(l.left=a),o!==void 0&&(l.state=o),s!==void 0&&(l.top=s),c!==void 0&&(l.width=c);let u=await new Promise((e,n)=>{chrome.windows.update(t,l,t=>{chrome.runtime.lastError?n(Error(chrome.runtime.lastError.message)):e(t)})});return this.formatJson({id:u.id,focused:u.focused,incognito:u.incognito,alwaysOnTop:u.alwaysOnTop,state:u.state,type:u.type,left:u.left,top:u.top,width:u.width,height:u.height,sessionId:u.sessionId})}};let J=function(e){return e.ACCESSIBILITY_FEATURES=`accessibilityFeatures`,e.ACTION=`action`,e.ALARMS=`alarms`,e.AUDIO=`audio`,e.BOOKMARKS=`bookmarks`,e.BROWSING_DATA=`browsingData`,e.CERTIFICATE_PROVIDER=`certificateProvider`,e.COMMANDS=`commands`,e.CONTENT_SETTINGS=`contentSettings`,e.CONTEXT_MENUS=`contextMenus`,e.COOKIES=`cookies`,e.DEBUGGER=`debugger`,e.DECLARATIVE_CONTENT=`declarativeContent`,e.DECLARATIVE_NET_REQUEST=`declarativeNetRequest`,e.DESKTOP_CAPTURE=`desktopCapture`,e.DEVTOOLS_INSPECTED_WINDOW=`devtools.inspectedWindow`,e.DEVTOOLS_NETWORK=`devtools.network`,e.DEVTOOLS_PANELS=`devtools.panels`,e.DEVTOOLS_PERFORMANCE=`devtools.performance`,e.DEVTOOLS_RECORDER=`devtools.recorder`,e.DNS=`dns`,e.DOCUMENT_SCAN=`documentScan`,e.DOM=`dom`,e.DOWNLOADS=`downloads`,e.ENTERPRISE_DEVICE_ATTRIBUTES=`enterprise.deviceAttributes`,e.ENTERPRISE_HARDWARE_PLATFORM=`enterprise.hardwarePlatform`,e.ENTERPRISE_NETWORKING_ATTRIBUTES=`enterprise.networkingAttributes`,e.ENTERPRISE_PLATFORM_KEYS=`enterprise.platformKeys`,e.EVENTS=`events`,e.EXTENSION=`extension`,e.EXTENSION_TYPES=`extensionTypes`,e.FILE_BROWSER_HANDLER=`fileBrowserHandler`,e.FILE_SYSTEM_PROVIDER=`fileSystemProvider`,e.FONT_SETTINGS=`fontSettings`,e.GCM=`gcm`,e.HISTORY=`history`,e.I18N=`i18n`,e.IDENTITY=`identity`,e.IDLE=`idle`,e.INPUT_IME=`input.ime`,e.INSTANCE_ID=`instanceID`,e.LOGIN_STATE=`loginState`,e.MANAGEMENT=`management`,e.NOTIFICATIONS=`notifications`,e.OFFSCREEN=`offscreen`,e.OMNIBOX=`omnibox`,e.PAGE_CAPTURE=`pageCapture`,e.PERMISSIONS=`permissions`,e.PLATFORM_KEYS=`platformKeys`,e.POWER=`power`,e.PRINTER_PROVIDER=`printerProvider`,e.PRINTING=`printing`,e.PRINTING_METRICS=`printingMetrics`,e.PRIVACY=`privacy`,e.PROCESSES=`processes`,e.PROXY=`proxy`,e.READING_LIST=`readingList`,e.RUNTIME=`runtime`,e.SCRIPTING=`scripting`,e.SEARCH=`search`,e.SMART_DOM_READER=`smartDomReader`,e.SESSIONS=`sessions`,e.SIDE_PANEL=`sidePanel`,e.STORAGE=`storage`,e.SYSTEM_CPU=`system.cpu`,e.SYSTEM_DISPLAY=`system.display`,e.SYSTEM_MEMORY=`system.memory`,e.SYSTEM_STORAGE=`system.storage`,e.SYSTEM_LOG=`systemLog`,e.TAB_CAPTURE=`tabCapture`,e.TAB_GROUPS=`tabGroups`,e.TABS=`tabs`,e.TOP_SITES=`topSites`,e.TTS=`tts`,e.TTS_ENGINE=`ttsEngine`,e.TYPES=`types`,e.USER_SCRIPTS=`userScripts`,e.VPN_PROVIDER=`vpnProvider`,e.WALLPAPER=`wallpaper`,e.WEB_AUTHENTICATION_PROXY=`webAuthenticationProxy`,e.WEB_NAVIGATION=`webNavigation`,e.WEB_REQUEST=`webRequest`,e.WINDOWS=`windows`,e}({});const Y=e.enum([`all`,`chromeos`]),X=e.enum([`stable`,`dev`]),Z=e.enum([`background`,`content`,`devtools`,`all`]),Le=e.object({minChromeVersion:e.number().optional(),platform:Y,channel:X,manifestVersions:e.array(e.literal(2).or(e.literal(3))),requiresPolicy:e.boolean(),foregroundOnly:e.boolean(),contexts:e.array(Z),namespace:e.string()}),Q={[J.ACCESSIBILITY_FEATURES]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`accessibilityFeatures`},[J.ACTION]:{minChromeVersion:88,platform:`all`,channel:`stable`,manifestVersions:[3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`action`},[J.ALARMS]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`alarms`},[J.AUDIO]:{minChromeVersion:59,platform:`chromeos`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`audio`},[J.BOOKMARKS]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`,`content`],namespace:`bookmarks`},[J.BROWSING_DATA]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`browsingData`},[J.CERTIFICATE_PROVIDER]:{minChromeVersion:46,platform:`chromeos`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`certificateProvider`},[J.COMMANDS]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`commands`},[J.CONTENT_SETTINGS]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`contentSettings`},[J.CONTEXT_MENUS]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`contextMenus`},[J.COOKIES]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`,`content`],namespace:`cookies`},[J.DEBUGGER]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`debugger`},[J.DECLARATIVE_CONTENT]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`declarativeContent`},[J.DECLARATIVE_NET_REQUEST]:{minChromeVersion:84,platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`declarativeNetRequest`},[J.DESKTOP_CAPTURE]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`desktopCapture`},[J.DEVTOOLS_INSPECTED_WINDOW]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`devtools`],namespace:`devtools.inspectedWindow`},[J.DEVTOOLS_NETWORK]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`devtools`],namespace:`devtools.network`},[J.DEVTOOLS_PANELS]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`devtools`],namespace:`devtools.panels`},[J.DEVTOOLS_PERFORMANCE]:{minChromeVersion:129,platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`devtools`],namespace:`devtools.performance`},[J.DEVTOOLS_RECORDER]:{minChromeVersion:105,platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`devtools`],namespace:`devtools.recorder`},[J.DNS]:{platform:`all`,channel:`dev`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`dns`},[J.DOCUMENT_SCAN]:{minChromeVersion:44,platform:`chromeos`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`documentScan`},[J.DOM]:{minChromeVersion:88,platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`content`],namespace:`dom`},[J.DOWNLOADS]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`downloads`},[J.ENTERPRISE_DEVICE_ATTRIBUTES]:{minChromeVersion:46,platform:`chromeos`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!0,foregroundOnly:!1,contexts:[`background`],namespace:`enterprise.deviceAttributes`},[J.ENTERPRISE_HARDWARE_PLATFORM]:{minChromeVersion:71,platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!0,foregroundOnly:!1,contexts:[`background`],namespace:`enterprise.hardwarePlatform`},[J.ENTERPRISE_NETWORKING_ATTRIBUTES]:{minChromeVersion:85,platform:`chromeos`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!0,foregroundOnly:!1,contexts:[`background`],namespace:`enterprise.networkingAttributes`},[J.ENTERPRISE_PLATFORM_KEYS]:{platform:`chromeos`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!0,foregroundOnly:!1,contexts:[`background`],namespace:`enterprise.platformKeys`},[J.EVENTS]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`all`],namespace:`events`},[J.EXTENSION]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`all`],namespace:`extension`},[J.EXTENSION_TYPES]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`all`],namespace:`extensionTypes`},[J.FILE_BROWSER_HANDLER]:{platform:`chromeos`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!0,contexts:[`background`],namespace:`fileBrowserHandler`},[J.FILE_SYSTEM_PROVIDER]:{platform:`chromeos`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`fileSystemProvider`},[J.FONT_SETTINGS]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`fontSettings`},[J.GCM]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`gcm`},[J.HISTORY]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`,`content`],namespace:`history`},[J.I18N]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`all`],namespace:`i18n`},[J.IDENTITY]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`identity`},[J.IDLE]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`idle`},[J.INPUT_IME]:{platform:`chromeos`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`input.ime`},[J.INSTANCE_ID]:{minChromeVersion:44,platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`instanceID`},[J.LOGIN_STATE]:{minChromeVersion:78,platform:`chromeos`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`loginState`},[J.MANAGEMENT]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`management`},[J.NOTIFICATIONS]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`notifications`},[J.OFFSCREEN]:{minChromeVersion:109,platform:`all`,channel:`stable`,manifestVersions:[3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`offscreen`},[J.OMNIBOX]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`omnibox`},[J.PAGE_CAPTURE]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`pageCapture`},[J.PERMISSIONS]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`,`content`],namespace:`permissions`},[J.PLATFORM_KEYS]:{minChromeVersion:45,platform:`chromeos`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`platformKeys`},[J.POWER]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`power`},[J.PRINTER_PROVIDER]:{minChromeVersion:44,platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`printerProvider`},[J.PRINTING]:{minChromeVersion:81,platform:`chromeos`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`printing`},[J.PRINTING_METRICS]:{minChromeVersion:79,platform:`chromeos`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!0,foregroundOnly:!1,contexts:[`background`],namespace:`printingMetrics`},[J.PRIVACY]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`privacy`},[J.PROCESSES]:{platform:`all`,channel:`dev`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`processes`},[J.PROXY]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`proxy`},[J.READING_LIST]:{minChromeVersion:120,platform:`all`,channel:`stable`,manifestVersions:[3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`readingList`},[J.RUNTIME]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`all`],namespace:`runtime`},[J.SCRIPTING]:{minChromeVersion:88,platform:`all`,channel:`stable`,manifestVersions:[3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`scripting`},[J.SEARCH]:{minChromeVersion:87,platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`search`},[J.SMART_DOM_READER]:{minChromeVersion:88,platform:`all`,channel:`stable`,manifestVersions:[3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`smartDomReader`},[J.SESSIONS]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`sessions`},[J.SIDE_PANEL]:{minChromeVersion:114,platform:`all`,channel:`stable`,manifestVersions:[3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`sidePanel`},[J.STORAGE]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`all`],namespace:`storage`},[J.SYSTEM_CPU]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`system.cpu`},[J.SYSTEM_DISPLAY]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`system.display`},[J.SYSTEM_MEMORY]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`system.memory`},[J.SYSTEM_STORAGE]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`system.storage`},[J.SYSTEM_LOG]:{minChromeVersion:125,platform:`chromeos`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!0,foregroundOnly:!1,contexts:[`background`],namespace:`systemLog`},[J.TAB_CAPTURE]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`tabCapture`},[J.TAB_GROUPS]:{minChromeVersion:89,platform:`all`,channel:`stable`,manifestVersions:[3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`tabGroups`},[J.TABS]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`,`content`],namespace:`tabs`},[J.TOP_SITES]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`topSites`},[J.TTS]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`tts`},[J.TTS_ENGINE]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`ttsEngine`},[J.TYPES]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`all`],namespace:`types`},[J.USER_SCRIPTS]:{minChromeVersion:120,platform:`all`,channel:`stable`,manifestVersions:[3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`userScripts`},[J.VPN_PROVIDER]:{minChromeVersion:43,platform:`chromeos`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`vpnProvider`},[J.WALLPAPER]:{minChromeVersion:43,platform:`chromeos`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`wallpaper`},[J.WEB_AUTHENTICATION_PROXY]:{minChromeVersion:115,platform:`all`,channel:`stable`,manifestVersions:[3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`webAuthenticationProxy`},[J.WEB_NAVIGATION]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`webNavigation`},[J.WEB_REQUEST]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`webRequest`},[J.WINDOWS]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`windows`}};function $(e,t,n,r=`all`,i){let a=Q[e];return!(!a.contexts.includes(t)&&!a.contexts.includes(`all`)||!a.manifestVersions.includes(n)||a.platform!==`all`&&a.platform!==r||a.minChromeVersion&&i&&i<a.minChromeVersion)}function Re(e){let t=Q[e].namespace.split(`.`),n=chrome;for(let e of t){let t=n?.[e];if(!t)return;n=t}return n}function ze(e,t,n=`all`,r){return Object.values(J).filter(i=>$(i,e,t,n,r))}var Be=class extends n{apiName=`DomExtraction`;bundleScript=t;userScriptsSupport=null;constructor(e,t={}){super(e,t)}getBundleScript(){return this.bundleScript}async resolveTabId(e){if(e!==void 0)return e;let[t]=await chrome.tabs.query({active:!0,currentWindow:!0});if(!t?.id)throw Error(`No active tab found`);return t.id}async canUseUserScripts(){if(!chrome.userScripts?.execute||typeof chrome.userScripts.getScripts!=`function`)return!1;if(this.userScriptsSupport!==null)return this.userScriptsSupport;try{await chrome.userScripts.getScripts(),this.userScriptsSupport=!0}catch{this.userScriptsSupport=!1}return this.userScriptsSupport}isExtractionError(e){return typeof e==`object`&&!!e&&`error`in e}async ensureUserScriptsEnabled(){if(!await this.canUseUserScripts())throw Error(`User Scripts API is not enabled. Please grant the "userScripts" permission and enable the Allow User Scripts toggle for this extension.`)}serializeArgs(e){return JSON.stringify(e)}async executeExtraction(e,t,n){let r=`
|
|
32
|
+
`}],runAt:`document_idle`,world:`USER_SCRIPT`,allFrames:n}]),await chrome.tabs.reload(e);let o=await Promise.race([a,new Promise(e=>setTimeout(()=>e({timeout:!0}),5e3))]);return await chrome.userScripts.unregister({ids:[i]}),o.timeout?this.formatError(Error(`Script execution timed out`)):this.formatJson(o)}catch(e){return this.formatError(e)}})}registerInsertCSS(){this.server.registerTool(`extension_tool_insert_css`,{description:`Insert CSS into a tab. If no tabId is specified, operates on the currently active tab`,inputSchema:{tabId:e.number().optional().describe(`Tab ID to insert CSS into (defaults to active tab)`),css:e.string().describe(`CSS code to inject`),allFrames:e.boolean().optional().describe(`Inject in all frames (default: false)`)}},async({tabId:e,css:t,allFrames:n=!1})=>{try{if(e===void 0){let[t]=await chrome.tabs.query({active:!0,currentWindow:!0});if(!t||!t.id)return this.formatError(Error(`No active tab found`));e=t.id}return await chrome.scripting.insertCSS({target:{tabId:e,allFrames:n},css:t}),this.formatSuccess(`CSS injected into tab ${e}`)}catch(e){return this.formatError(e)}})}registerRemoveCSS(){if(typeof chrome.scripting.removeCSS!=`function`){console.warn(` ✗ removeCSS not available - Chrome 90+ required`);return}this.server.registerTool(`extension_tool_remove_css`,{description:`Remove previously injected CSS from a tab. If no tabId is specified, operates on the currently active tab`,inputSchema:{tabId:e.number().optional().describe(`Tab ID to remove CSS from (defaults to active tab)`),css:e.string().describe(`CSS code to remove (must match exactly)`),allFrames:e.boolean().optional().describe(`Remove from all frames (default: false)`)}},async({tabId:e,css:t,allFrames:n=!1})=>{try{if(e===void 0){let[t]=await chrome.tabs.query({active:!0,currentWindow:!0});if(!t||!t.id)return this.formatError(Error(`No active tab found`));e=t.id}return await chrome.scripting.removeCSS({target:{tabId:e,allFrames:n},css:t}),this.formatSuccess(`CSS removed from tab ${e}`)}catch(e){return this.formatError(e)}})}},_e=class extends n{apiName=`Search`;constructor(e,t={}){super(e,t)}checkAvailability(){try{return chrome.search?typeof chrome.search.query==`function`?{available:!0,message:`Search API is fully available`}:{available:!1,message:`chrome.search.query is not available`,details:`The search API appears to be partially available. Check manifest permissions.`}:{available:!1,message:`chrome.search API is not defined`,details:`This extension needs the "search" permission in its manifest.json`}}catch(e){return{available:!1,message:`Failed to access chrome.search API`,details:e instanceof Error?e.message:`Unknown error occurred`}}}registerTools(){this.shouldRegisterTool(`query`)&&this.registerQuery()}registerQuery(){this.server.registerTool(`extension_tool_search_query`,{description:`Search using the default search provider`,inputSchema:{text:e.string().describe(`String to query with the default search provider`),disposition:e.enum([`CURRENT_TAB`,`NEW_TAB`,`NEW_WINDOW`]).optional().describe(`Location where search results should be displayed. CURRENT_TAB is the default`),tabId:e.number().optional().describe(`Tab ID where search results should be displayed. Cannot be used with disposition`)}},async({text:e,disposition:t,tabId:n})=>{try{if(t!==void 0&&n!==void 0)return this.formatError(`Cannot specify both disposition and tabId. Use one or the other`);let r={text:e};return t!==void 0&&(r.disposition=t),n!==void 0&&(r.tabId=n),await new Promise((e,t)=>{chrome.search.query(r,()=>{chrome.runtime.lastError?t(Error(chrome.runtime.lastError.message)):e()})}),this.formatSuccess(`Search query executed successfully`,{text:e,disposition:t||`CURRENT_TAB`,tabId:n})}catch(e){return this.formatError(e)}})}},ve=class extends n{apiName=`Sessions`;constructor(e,t={}){super(e,t)}checkAvailability(){try{return chrome.sessions?typeof chrome.sessions.getRecentlyClosed==`function`?(chrome.sessions.getRecentlyClosed(e=>{if(chrome.runtime.lastError)throw Error(chrome.runtime.lastError.message)}),{available:!0,message:`Sessions API is fully available`}):{available:!1,message:`chrome.sessions.getRecentlyClosed is not available`,details:`The sessions API appears to be partially available. Check manifest permissions.`}:{available:!1,message:`chrome.sessions API is not defined`,details:`This extension needs the "sessions" permission in its manifest.json`}}catch(e){return{available:!1,message:`Failed to access chrome.sessions API`,details:e instanceof Error?e.message:`Unknown error occurred`}}}registerTools(){this.shouldRegisterTool(`getDevices`)&&this.registerGetDevices(),this.shouldRegisterTool(`getRecentlyClosed`)&&this.registerGetRecentlyClosed(),this.shouldRegisterTool(`restore`)&&this.registerRestore()}registerGetDevices(){this.server.registerTool(`extension_tool_get_devices`,{description:`Retrieve all devices with synced sessions`,inputSchema:{maxResults:e.number().min(1).max(25).optional().describe(`The maximum number of entries to be fetched. Omit to fetch the maximum number of entries (25)`)}},async({maxResults:e})=>{try{let t={};e!==void 0&&(t.maxResults=e);let n=await new Promise((e,n)=>{chrome.sessions.getDevices(t,t=>{chrome.runtime.lastError?n(Error(chrome.runtime.lastError.message)):e(t)})});return this.formatJson({count:n.length,devices:n.map(e=>({deviceName:e.deviceName,sessionCount:e.sessions.length,sessions:e.sessions.map(e=>({lastModified:e.lastModified,lastModifiedFormatted:new Date(e.lastModified*1e3).toISOString(),tab:e.tab?{id:e.tab.id,url:e.tab.url,title:e.tab.title,sessionId:e.tab.sessionId}:void 0,window:e.window?{id:e.window.id,sessionId:e.window.sessionId,tabCount:e.window.tabs?.length||0}:void 0}))}))})}catch(e){return this.formatError(e)}})}registerGetRecentlyClosed(){this.server.registerTool(`extension_tool_get_recently_closed`,{description:`Get the list of recently closed tabs and/or windows`,inputSchema:{maxResults:e.number().min(1).max(25).optional().describe(`The maximum number of entries to be fetched. Omit to fetch the maximum number of entries (25)`)}},async({maxResults:e})=>{try{let t={};e!==void 0&&(t.maxResults=e);let n=await new Promise((e,n)=>{chrome.sessions.getRecentlyClosed(t,t=>{chrome.runtime.lastError?n(Error(chrome.runtime.lastError.message)):e(t)})});return this.formatJson({count:n.length,sessions:n.map(e=>({lastModified:e.lastModified,lastModifiedFormatted:new Date(e.lastModified*1e3).toISOString(),tab:e.tab?{id:e.tab.id,url:e.tab.url,title:e.tab.title,sessionId:e.tab.sessionId,favIconUrl:e.tab.favIconUrl}:void 0,window:e.window?{id:e.window.id,sessionId:e.window.sessionId,tabCount:e.window.tabs?.length||0,incognito:e.window.incognito,type:e.window.type}:void 0}))})}catch(e){return this.formatError(e)}})}registerRestore(){this.server.registerTool(`extension_tool_restore_session`,{description:`Reopen a recently closed window or tab`,inputSchema:{sessionId:e.string().optional().describe(`The sessionId of the window or tab to restore. If not specified, the most recently closed session is restored`)}},async({sessionId:e})=>{try{let t=await new Promise((t,n)=>{e?chrome.sessions.restore(e,e=>{chrome.runtime.lastError?n(Error(chrome.runtime.lastError.message)):t(e)}):chrome.sessions.restore(e=>{chrome.runtime.lastError?n(Error(chrome.runtime.lastError.message)):t(e)})});return this.formatSuccess(`Session restored successfully`,{lastModified:t.lastModified,lastModifiedFormatted:new Date(t.lastModified*1e3).toISOString(),tab:t.tab?{id:t.tab.id,url:t.tab.url,title:t.tab.title,sessionId:t.tab.sessionId}:void 0,window:t.window?{id:t.window.id,sessionId:t.window.sessionId,tabCount:t.window.tabs?.length||0,incognito:t.window.incognito,type:t.window.type}:void 0})}catch(e){return this.formatError(e)}})}},ye=class extends n{apiName=`SidePanel`;constructor(e,t={}){super(e,t)}checkAvailability(){try{return chrome.sidePanel?typeof chrome.sidePanel.getOptions==`function`?(chrome.sidePanel.getOptions({},e=>{if(chrome.runtime.lastError)throw Error(chrome.runtime.lastError.message)}),{available:!0,message:`SidePanel API is fully available`}):{available:!1,message:`chrome.sidePanel.getOptions is not available`,details:`The sidePanel API appears to be partially available. Check manifest permissions.`}:{available:!1,message:`chrome.sidePanel API is not defined`,details:`This extension needs the "sidePanel" permission in its manifest.json`}}catch(e){return{available:!1,message:`Failed to access chrome.sidePanel API`,details:e instanceof Error?e.message:`Unknown error occurred`}}}registerTools(){this.shouldRegisterTool(`getOptions`)&&this.registerGetOptions(),this.shouldRegisterTool(`setOptions`)&&this.registerSetOptions(),this.shouldRegisterTool(`getPanelBehavior`)&&this.registerGetPanelBehavior(),this.shouldRegisterTool(`setPanelBehavior`)&&this.registerSetPanelBehavior(),this.shouldRegisterTool(`open`)&&this.registerOpen()}registerGetOptions(){this.server.registerTool(`extension_tool_get_side_panel_options`,{description:`Get the active side panel configuration for a specific tab or default settings`,inputSchema:{tabId:e.number().optional().describe(`If specified, the side panel options for the given tab will be returned. Otherwise, returns the default side panel options`)}},async({tabId:e})=>{try{let t=await new Promise((t,n)=>{let r={};e!==void 0&&(r.tabId=e),chrome.sidePanel.getOptions(r,e=>{chrome.runtime.lastError?n(Error(chrome.runtime.lastError.message)):t(e)})});return this.formatJson({tabId:e||`default`,enabled:t.enabled,path:t.path})}catch(e){return this.formatError(e)}})}registerSetOptions(){this.server.registerTool(`extension_tool_set_side_panel_options`,{description:`Configure the side panel settings for a specific tab or default behavior`,inputSchema:{enabled:e.boolean().optional().describe(`Whether the side panel should be enabled. Defaults to true`),path:e.string().optional().describe(`The path to the side panel HTML file to use. Must be a local resource within the extension package`),tabId:e.number().optional().describe(`If specified, the side panel options will only apply to the tab with this id. If omitted, these options set the default behavior`)}},async({enabled:e,path:t,tabId:n})=>{try{let r={};return e!==void 0&&(r.enabled=e),t!==void 0&&(r.path=t),n!==void 0&&(r.tabId=n),await new Promise((e,t)=>{chrome.sidePanel.setOptions(r,()=>{chrome.runtime.lastError?t(Error(chrome.runtime.lastError.message)):e()})}),this.formatSuccess(`Side panel options configured successfully`,{tabId:n||`default`,enabled:e,path:t})}catch(e){return this.formatError(e)}})}registerGetPanelBehavior(){this.server.registerTool(`extension_tool_get_side_panel_behavior`,{description:`Get the current side panel behavior configuration`,inputSchema:{}},async()=>{try{let e=await new Promise((e,t)=>{chrome.sidePanel.getPanelBehavior(n=>{chrome.runtime.lastError?t(Error(chrome.runtime.lastError.message)):e(n)})});return this.formatJson({openPanelOnActionClick:e.openPanelOnActionClick})}catch(e){return this.formatError(e)}})}registerSetPanelBehavior(){this.server.registerTool(`extension_tool_set_side_panel_behavior`,{description:`Configure the side panel behavior, such as opening when the action icon is clicked`,inputSchema:{openPanelOnActionClick:e.boolean().optional().describe(`Whether clicking the extension action icon will toggle showing the extension entry in the side panel. Defaults to false`)}},async({openPanelOnActionClick:e})=>{try{let t={};return e!==void 0&&(t.openPanelOnActionClick=e),await new Promise((e,n)=>{chrome.sidePanel.setPanelBehavior(t,()=>{chrome.runtime.lastError?n(Error(chrome.runtime.lastError.message)):e()})}),this.formatSuccess(`Side panel behavior configured successfully`,{openPanelOnActionClick:e})}catch(e){return this.formatError(e)}})}registerOpen(){this.server.registerTool(`extension_tool_open_side_panel`,{description:`Open the side panel for the extension. This may only be called in response to a user action`,inputSchema:{tabId:e.number().optional().describe(`The tab in which to open the side panel. If there is a tab-specific panel, it will only open for that tab. At least one of tabId or windowId must be provided`),windowId:e.number().optional().describe(`The window in which to open the side panel. This is only applicable if the extension has a global side panel or tabId is also specified. At least one of tabId or windowId must be provided`)}},async({tabId:e,windowId:t})=>{try{if(e===void 0&&t===void 0)return this.formatError(`Either tabId or windowId must be specified to open the side panel`);let n={};return e!==void 0&&(n.tabId=e),t!==void 0&&(n.windowId=t),await new Promise((e,t)=>{chrome.sidePanel.open(n,()=>{chrome.runtime.lastError?t(Error(chrome.runtime.lastError.message)):e()})}),this.formatSuccess(`Side panel opened successfully`,{tabId:e,windowId:t})}catch(e){return this.formatError(e)}})}};const z=[`getStorage`,`setStorage`,`removeStorage`,`clearStorage`,`getBytesInUse`],B=e.enum(z);var be=class extends n{apiName=`Storage`;constructor(e,t={}){super(e,t)}checkAvailability(){try{if(!chrome.storage)return{available:!1,message:`chrome.storage API is not defined`,details:`This extension needs the "storage" permission in its manifest.json to access storage`};let e=[];return chrome.storage.local&&e.push(`local`),chrome.storage.sync&&e.push(`sync`),chrome.storage.session&&e.push(`session`),chrome.storage.managed&&e.push(`managed`),e.length===0?{available:!1,message:`No storage areas are available`,details:`The storage API is present but no storage areas can be accessed`}:(chrome.storage.local.get(null,()=>{if(chrome.runtime.lastError)throw Error(chrome.runtime.lastError.message)}),{available:!0,message:`Storage API is available with areas: ${e.join(`, `)}`})}catch(e){return{available:!1,message:`Failed to access chrome.storage API`,details:e instanceof Error?e.message:`Unknown error occurred`}}}registerTools(){this.server.registerTool(`extension_tool_storage_operations`,{description:`Perform operations on Chrome storage API`,inputSchema:{action:B,params:e.record(e.string(),e.any()).optional().describe(`Parameters for the chosen action`)}},async({action:e,params:t={}})=>{try{if(!this.shouldRegisterTool(e))return this.formatError(Error(`Action "${e}" is not supported`));switch(e){case`getStorage`:return await this.handleGetStorage(t);case`setStorage`:return await this.handleSetStorage(t);case`removeStorage`:return await this.handleRemoveStorage(t);case`clearStorage`:return await this.handleClearStorage(t);case`getBytesInUse`:return await this.handleGetBytesInUse(t);default:return this.formatError(Error(`Action "${e}" is not supported`))}}catch(e){return this.formatError(e)}}),this.server.registerTool(`extension_tool_storage_parameters_description`,{description:`Get the parameters for extension_tool_storage_operations tool and the description for the associated action, this tool should be used first before extension_tool_storage_operations`,inputSchema:{action:B}},async({action:t})=>{try{if(!this.shouldRegisterTool(t))return this.formatError(Error(`Action "${t}" is not supported`));let n=(t,n)=>e.toJSONSchema(t),r={tool:`extension_tool_storage_operations`,action:t,note:`Use the description to double check if the correct action is chosen. Use this JSON Schema for the params field when calling the tool. The top-level tool input is { action, params }.`};switch(t){case`getStorage`:{let e={params:n(this.getStorageSchema,`GetStorageParams`),description:`Get data from extension storage`};return this.formatJson({...r,...e})}case`setStorage`:{let e={params:n(this.setStorageSchema,`SetStorageParams`),description:`Set data in extension storage`};return this.formatJson({...r,...e})}case`removeStorage`:{let e={params:n(this.removeStorageSchema,`RemoveStorageParams`),description:`Remove specific keys from extension storage`};return this.formatJson({...r,...e})}case`clearStorage`:{let e={params:n(this.clearStorageSchema,`ClearStorageParams`),description:`Clear all data from a storage area`};return this.formatJson({...r,...e})}case`getBytesInUse`:{let e={params:n(this.getBytesInUseSchema,`GetBytesInUseParams`),description:`Get the amount of storage space used`};return this.formatJson({...r,...e})}default:return this.formatError(Error(`Action "${t}" is not supported`))}}catch(e){return this.formatError(e)}})}getAvailableAreas(){let e=[];return chrome.storage.sync&&e.push(`sync`),chrome.storage.local&&e.push(`local`),chrome.storage.session&&e.push(`session`),e}async handleGetStorage(e){let{keys:t,area:n=`local`}=this.getStorageSchema.parse(e),r=chrome.storage[n];if(!r||typeof r.get!=`function`)return this.formatError(Error(`Storage area '${n}' is not available`));let i=await r.get(t||null),a={area:n,data:i,keyCount:Object.keys(i).length};return this.formatJson(a)}async handleSetStorage(e){let{data:t,area:n=`local`}=this.setStorageSchema.parse(e),r=chrome.storage[n];return!r||typeof r.set!=`function`?this.formatError(Error(`Storage area '${n}' is not available`)):(await r.set(t),this.formatSuccess(`Stored ${Object.keys(t).length} key(s) in ${n} storage`,{keys:Object.keys(t)}))}async handleRemoveStorage(e){let{keys:t,area:n=`local`}=this.removeStorageSchema.parse(e),r=chrome.storage[n];return!r||typeof r.remove!=`function`?this.formatError(Error(`Storage area '${n}' is not available`)):(await r.remove(t),this.formatSuccess(`Removed ${t.length} key(s) from ${n} storage`,{keys:t}))}async handleClearStorage(e){let{area:t,confirm:n}=this.clearStorageSchema.parse(e);if(!n)return this.formatError(Error(`Clear operation requires confirm=true to prevent accidental data loss`));let r=chrome.storage[t];return!r||typeof r.clear!=`function`?this.formatError(Error(`Storage area '${t}' is not available`)):(await r.clear(),this.formatSuccess(`Cleared all data from ${t} storage`))}async handleGetBytesInUse(e){let{keys:t,area:n=`local`}=this.getBytesInUseSchema.parse(e),r=chrome.storage[n];if(!r)return this.formatError(Error(`Storage area '${n}' is not available`));if(typeof r.getBytesInUse!=`function`)return this.formatError(Error(`getBytesInUse is not supported for ${n} storage area`));let i=await r.getBytesInUse(t||null),a=null;return n===`sync`&&chrome.storage.sync.QUOTA_BYTES?a={quotaBytes:chrome.storage.sync.QUOTA_BYTES,quotaBytesPerItem:chrome.storage.sync.QUOTA_BYTES_PER_ITEM,maxItems:chrome.storage.sync.MAX_ITEMS,maxWriteOperationsPerHour:chrome.storage.sync.MAX_WRITE_OPERATIONS_PER_HOUR,maxWriteOperationsPerMinute:chrome.storage.sync.MAX_WRITE_OPERATIONS_PER_MINUTE}:n===`local`&&chrome.storage.local.QUOTA_BYTES&&(a={quotaBytes:chrome.storage.local.QUOTA_BYTES}),this.formatJson({area:n,bytesInUse:i,humanReadable:this.formatBytes(i),quota:a,percentageUsed:a?.quotaBytes?`${(i/a.quotaBytes*100).toFixed(2)}%`:null})}getStorageSchema=e.object({keys:e.array(e.string()).optional().describe(`Specific keys to retrieve (omit for all)`),area:e.enum(this.getAvailableAreas()).optional().describe(`Storage area to use. Available: ${this.getAvailableAreas().join(`, `)} (default: local)`)});setStorageSchema=e.object({data:e.record(e.string(),e.any()).describe(`Key-value pairs to store`),area:e.enum(this.getAvailableAreas()).optional().describe(`Storage area to use. Available: ${this.getAvailableAreas().join(`, `)} (default: local)`)});removeStorageSchema=e.object({keys:e.array(e.string()).describe(`Keys to remove from storage`),area:e.enum(this.getAvailableAreas()).optional().describe(`Storage area to use. Available: ${this.getAvailableAreas().join(`, `)} (default: local)`)});clearStorageSchema=e.object({area:e.enum(this.getAvailableAreas()).describe(`Storage area to clear. Available: ${this.getAvailableAreas().join(`, `)}`),confirm:e.boolean().describe(`Confirmation flag - must be true to clear storage`)});getBytesInUseSchema=e.object({keys:e.array(e.string()).optional().describe(`Specific keys to check (omit for total)`),area:e.enum(this.getAvailableAreas()).optional().describe(`Storage area to check. Available: ${this.getAvailableAreas().join(`, `)} (default: local)`)});formatBytes(e){if(e===0)return`0 Bytes`;let t=1024,n=[`Bytes`,`KB`,`MB`,`GB`],r=Math.floor(Math.log(e)/Math.log(t));return`${Number.parseFloat((e/t**r).toFixed(2))} ${n[r]}`}},xe=class extends n{apiName=`System.cpu`;constructor(e,t={}){super(e,t)}checkAvailability(){try{return!chrome.system||!chrome.system.cpu?{available:!1,message:`chrome.system.cpu API is not defined`,details:`This extension needs the "system.cpu" permission in its manifest.json`}:typeof chrome.system.cpu.getInfo==`function`?(chrome.system.cpu.getInfo(e=>{if(chrome.runtime.lastError)throw Error(chrome.runtime.lastError.message)}),{available:!0,message:`System.cpu API is fully available`}):{available:!1,message:`chrome.system.cpu.getInfo is not available`,details:`The system.cpu API appears to be partially available. Check manifest permissions.`}}catch(e){return{available:!1,message:`Failed to access chrome.system.cpu API`,details:e instanceof Error?e.message:`Unknown error occurred`}}}registerTools(){this.shouldRegisterTool(`getInfo`)&&this.registerGetInfo()}registerGetInfo(){this.server.registerTool(`extension_tool_get_cpu_info`,{description:`Get information about the CPU including number of processors, architecture, model, and features`,inputSchema:{}},async()=>{try{let e=await new Promise((e,t)=>{chrome.system.cpu.getInfo(n=>{chrome.runtime.lastError?t(Error(chrome.runtime.lastError.message)):e(n)})});return this.formatJson({numOfProcessors:e.numOfProcessors,archName:e.archName,modelName:e.modelName,features:e.features,processors:e.processors.map(e=>({usage:{kernel:e.usage.kernel,user:e.usage.user,idle:e.usage.idle,total:e.usage.total}}))})}catch(e){return this.formatError(e)}})}},Se=class extends n{apiName=`SystemLog`;constructor(e,t={}){super(e,t)}checkAvailability(){try{return chrome.systemLog?typeof chrome.systemLog.add==`function`?{available:!0,message:`SystemLog API is fully available`}:{available:!1,message:`chrome.systemLog.add is not available`,details:`The systemLog API appears to be partially available. Check manifest permissions and ensure running on ChromeOS.`}:{available:!1,message:`chrome.systemLog API is not defined`,details:`This extension needs the "systemLog" permission in its manifest.json and must run on ChromeOS`}}catch(e){return{available:!1,message:`Failed to access chrome.systemLog API`,details:e instanceof Error?e.message:`Unknown error occurred`}}}registerTools(){this.shouldRegisterTool(`addLog`)&&this.registerAddLog()}registerAddLog(){this.server.registerTool(`extension_tool_add_log`,{description:`Add a new log record to the Chrome system logs`,inputSchema:{message:e.string().describe(`The log message to record in the system logs`)}},async({message:e})=>{try{let t={message:e};return await new Promise((e,n)=>{chrome.systemLog.add(t,()=>{chrome.runtime.lastError?n(Error(chrome.runtime.lastError.message)):e()})}),this.formatSuccess(`Log record added successfully`,{message:e,timestamp:new Date().toISOString()})}catch(e){return this.formatError(e)}})}},Ce=class extends n{apiName=`System.memory`;constructor(e,t={}){super(e,t)}checkAvailability(){try{return!chrome.system||!chrome.system.memory?{available:!1,message:`chrome.system.memory API is not defined`,details:`This extension needs the "system.memory" permission in its manifest.json`}:typeof chrome.system.memory.getInfo==`function`?(chrome.system.memory.getInfo(e=>{if(chrome.runtime.lastError)throw Error(chrome.runtime.lastError.message)}),{available:!0,message:`System.memory API is fully available`}):{available:!1,message:`chrome.system.memory.getInfo is not available`,details:`The system.memory API appears to be partially available. Check manifest permissions.`}}catch(e){return{available:!1,message:`Failed to access chrome.system.memory API`,details:e instanceof Error?e.message:`Unknown error occurred`}}}registerTools(){this.shouldRegisterTool(`getInfo`)&&this.registerGetInfo()}registerGetInfo(){this.server.registerTool(`extension_tool_get_memory_info`,{description:`Get information about the system memory`,inputSchema:{}},async()=>{try{let e=await new Promise((e,t)=>{chrome.system.memory.getInfo(n=>{chrome.runtime.lastError?t(Error(chrome.runtime.lastError.message)):e(n)})});return this.formatJson({capacity:e.capacity,capacityGB:Math.round(e.capacity/(1024*1024*1024)*100)/100,availableCapacity:e.availableCapacity,availableCapacityGB:Math.round(e.availableCapacity/(1024*1024*1024)*100)/100,usedCapacity:e.capacity-e.availableCapacity,usedCapacityGB:Math.round((e.capacity-e.availableCapacity)/(1024*1024*1024)*100)/100,usagePercentage:Math.round((e.capacity-e.availableCapacity)/e.capacity*1e4)/100})}catch(e){return this.formatError(e)}})}},we=class extends n{apiName=`System.storage`;constructor(e,t={}){super(e,t)}checkAvailability(){try{return!chrome.system||!chrome.system.storage?{available:!1,message:`chrome.system.storage API is not defined`,details:`This extension needs the "system.storage" permission in its manifest.json`}:typeof chrome.system.storage.getInfo==`function`?(chrome.system.storage.getInfo(e=>{if(chrome.runtime.lastError)throw Error(chrome.runtime.lastError.message)}),{available:!0,message:`System.storage API is fully available`}):{available:!1,message:`chrome.system.storage.getInfo is not available`,details:`The system.storage API appears to be partially available. Check manifest permissions.`}}catch(e){return{available:!1,message:`Failed to access chrome.system.storage API`,details:e instanceof Error?e.message:`Unknown error occurred`}}}registerTools(){this.shouldRegisterTool(`getInfo`)&&this.registerGetInfo(),this.shouldRegisterTool(`ejectDevice`)&&this.registerEjectDevice(),this.shouldRegisterTool(`getAvailableCapacity`)&&this.registerGetAvailableCapacity()}registerGetInfo(){this.server.registerTool(`extension_tool_get_storage_info`,{description:`Get information about all attached storage devices`,inputSchema:{}},async()=>{try{let e=await new Promise((e,t)=>{chrome.system.storage.getInfo(n=>{chrome.runtime.lastError?t(Error(chrome.runtime.lastError.message)):e(n)})});return this.formatJson({count:e.length,devices:e.map(e=>({id:e.id,name:e.name,type:e.type,capacity:e.capacity,capacityFormatted:this.formatBytes(e.capacity)}))})}catch(e){return this.formatError(e)}})}registerEjectDevice(){this.server.registerTool(`extension_tool_eject_storage_device`,{description:`Eject a removable storage device`,inputSchema:{id:e.string().describe(`The transient device ID from getInfo`)}},async({id:e})=>{try{let t=await new Promise((t,n)=>{chrome.system.storage.ejectDevice(e,e=>{chrome.runtime.lastError?n(Error(chrome.runtime.lastError.message)):t(e)})}),n=t===`success`,r=this.getEjectResultMessage(t);return n?this.formatSuccess(`Device ejected successfully`,{deviceId:e,result:t,message:r}):this.formatError(`Failed to eject device: ${r}`)}catch(e){return this.formatError(e)}})}registerGetAvailableCapacity(){this.server.registerTool(`extension_tool_get_available_capacity`,{description:`Get the available capacity of a specified storage device`,inputSchema:{id:e.string().describe(`The transient device ID from getInfo`)}},async({id:e})=>{try{let t=await new Promise((t,n)=>{chrome.system.storage.getAvailableCapacity(e,e=>{chrome.runtime.lastError?n(Error(chrome.runtime.lastError.message)):t(e)})});return this.formatJson({deviceId:e,availableCapacity:t.availableCapacity,availableCapacityFormatted:this.formatBytes(t.availableCapacity)})}catch(e){return this.formatError(e)}})}getEjectResultMessage(e){switch(e){case`success`:return`Device ejected successfully`;case`in_use`:return`Device is currently in use and cannot be ejected`;case`no_such_device`:return`No such device found`;case`failure`:return`Failed to eject device due to unknown error`;default:return`Unknown result: ${e}`}}formatBytes(e){if(e===0)return`0 Bytes`;let t=1024,n=[`Bytes`,`KB`,`MB`,`GB`,`TB`,`PB`],r=Math.floor(Math.log(e)/Math.log(t));return`${Number.parseFloat((e/t**r).toFixed(2))} ${n[r]}`}},Te=class extends n{apiName=`TabCapture`;constructor(e,t={}){super(e,t)}checkAvailability(){try{return chrome.tabCapture?typeof chrome.tabCapture.getCapturedTabs==`function`?(chrome.tabCapture.getCapturedTabs(e=>{if(chrome.runtime.lastError)throw Error(chrome.runtime.lastError.message)}),{available:!0,message:`TabCapture API is fully available`}):{available:!1,message:`chrome.tabCapture.getCapturedTabs is not available`,details:`The tabCapture API appears to be partially available. Check manifest permissions.`}:{available:!1,message:`chrome.tabCapture API is not defined`,details:`This extension needs the "tabCapture" permission in its manifest.json`}}catch(e){return{available:!1,message:`Failed to access chrome.tabCapture API`,details:e instanceof Error?e.message:`Unknown error occurred`}}}registerTools(){this.shouldRegisterTool(`capture`)&&this.registerCapture(),this.shouldRegisterTool(`getCapturedTabs`)&&this.registerGetCapturedTabs(),this.shouldRegisterTool(`getMediaStreamId`)&&this.registerGetMediaStreamId()}registerCapture(){this.server.registerTool(`extension_tool_capture_tab`,{description:`Captures the visible area of the currently active tab. Can only be started on the currently active tab after the extension has been invoked.`,inputSchema:{audio:e.boolean().optional().describe(`Whether to capture audio from the tab`),video:e.boolean().optional().describe(`Whether to capture video from the tab`),audioConstraints:e.object({mandatory:e.record(e.string(),e.any()).optional(),optional:e.record(e.string(),e.any()).optional()}).optional().describe(`Audio constraints for the media stream`),videoConstraints:e.object({mandatory:e.record(e.string(),e.any()).optional(),optional:e.record(e.string(),e.any()).optional()}).optional().describe(`Video constraints for the media stream`)}},async({audio:e,video:t,audioConstraints:n,videoConstraints:r})=>{try{let i={};e!==void 0&&(i.audio=e),t!==void 0&&(i.video=t);let a=e=>{if(e)return e},o=a(n);o!==void 0&&(i.audioConstraints=o);let s=a(r);s!==void 0&&(i.videoConstraints=s);let c=await new Promise((e,t)=>{chrome.tabCapture.capture(i,n=>{chrome.runtime.lastError?t(Error(chrome.runtime.lastError.message)):n?e(n):t(Error(`Failed to capture tab - no stream returned`))})}),l=c.getAudioTracks(),u=c.getVideoTracks();return this.formatSuccess(`Tab capture started successfully`,{streamId:c.id,audioTracks:l.length,videoTracks:u.length,audioTrackLabels:l.map(e=>e.label),videoTrackLabels:u.map(e=>e.label)})}catch(e){return this.formatError(e)}})}registerGetCapturedTabs(){this.server.registerTool(`extension_tool_get_captured_tabs`,{description:`Returns a list of tabs that have requested capture or are being captured`,inputSchema:{}},async()=>{try{let e=await new Promise((e,t)=>{chrome.tabCapture.getCapturedTabs(n=>{chrome.runtime.lastError?t(Error(chrome.runtime.lastError.message)):e(n)})});return this.formatJson({count:e.length,capturedTabs:e.map(e=>({tabId:e.tabId,status:e.status,fullscreen:e.fullscreen}))})}catch(e){return this.formatError(e)}})}registerGetMediaStreamId(){this.server.registerTool(`extension_tool_get_media_stream_id`,{description:`Creates a stream ID to capture the target tab. Returns a media stream ID instead of a media stream.`,inputSchema:{targetTabId:e.number().optional().describe(`Optional tab id of the tab which will be captured. If not specified then the current active tab will be selected.`),consumerTabId:e.number().optional().describe(`Optional tab id of the tab which will later invoke getUserMedia() to consume the stream. If not specified then the resulting stream can be used only by the calling extension.`)}},async({targetTabId:e,consumerTabId:t})=>{try{let n={};e!==void 0&&(n.targetTabId=e),t!==void 0&&(n.consumerTabId=t);let r=await new Promise((e,t)=>{chrome.tabCapture.getMediaStreamId(n,n=>{chrome.runtime.lastError?t(Error(chrome.runtime.lastError.message)):n?e(n):t(Error(`Failed to get media stream ID`))})});return this.formatSuccess(`Media stream ID created successfully`,{streamId:r,targetTabId:e||`current active tab`,consumerTabId:t||`calling extension only`,usage:`Use this ID with navigator.mediaDevices.getUserMedia() with chromeMediaSource: "tab" and chromeMediaSourceId: streamId`})}catch(e){return this.formatError(e)}})}};const V=[`get`,`query`,`update`,`move`],H=e.enum(V);var Ee=class extends n{apiName=`TabGroups`;constructor(e,t={}){super(e,t)}checkAvailability(){try{return chrome.tabGroups?typeof chrome.tabGroups.query==`function`?(chrome.tabGroups.query({},()=>{if(chrome.runtime.lastError)throw Error(chrome.runtime.lastError.message)}),{available:!0,message:`TabGroups API is fully available`}):{available:!1,message:`chrome.tabGroups.query is not available`,details:`The tabGroups API appears to be partially available. Check manifest permissions.`}:{available:!1,message:`chrome.tabGroups API is not defined`,details:`This extension needs the "tabGroups" permission in its manifest.json and requires Chrome 89+ with Manifest V3`}}catch(e){return{available:!1,message:`Failed to access chrome.tabGroups API`,details:e instanceof Error?e.message:`Unknown error occurred`}}}registerTools(){this.server.registerTool(`extension_tool_tab_group_operations`,{description:`Perform operations on tab groups using Chrome TabGroups API`,inputSchema:{action:H,params:e.record(e.string(),e.any()).optional().describe(`Parameters for the chosen action`)}},async({action:e,params:t={}})=>{try{if(!this.shouldRegisterTool(e))return this.formatError(Error(`Action "${e}" is not supported`));switch(e){case`get`:return await this.handleGetTabGroup(t);case`query`:return await this.handleQueryTabGroups(t);case`update`:return await this.handleUpdateTabGroup(t);case`move`:return await this.handleMoveTabGroup(t);default:return this.formatError(Error(`Action "${e}" is not supported`))}}catch(e){return this.formatError(e)}}),this.server.registerTool(`extension_tool_tab_group_parameters_description`,{description:`Get the parameters for extension_tool_tab_group_operations tool and the description for the associated action, this tool should be used first before extension_tool_tab_group_operations`,inputSchema:{action:H}},async({action:t})=>{try{if(!this.shouldRegisterTool(t))return this.formatError(Error(`Action "${t}" is not supported`));let n=(t,n)=>e.toJSONSchema(t),r={tool:`extension_tool_tab_group_operations`,action:t,note:`Use the description to double check if the correct action is chosen. Use this JSON Schema for the params field when calling the tool. The top-level tool input is { action, params }.`};switch(t){case`get`:{let e={params:n(this.getSchema,`GetTabGroupParams`),description:`Retrieve a tab group by its ID`};return this.formatJson({...r,...e})}case`query`:{let e={params:n(this.querySchema,`QueryTabGroupsParams`),description:`Search for tab groups that match specified criteria`};return this.formatJson({...r,...e})}case`update`:{let e={params:n(this.updateSchema,`UpdateTabGroupParams`),description:`Modify properties of a tab group`};return this.formatJson({...r,...e})}case`move`:{let e={params:n(this.moveSchema,`MoveTabGroupParams`),description:`Move a tab group within its window or to a new window`};return this.formatJson({...r,...e})}default:return this.formatError(Error(`Action "${t}" is not supported`))}}catch(e){return this.formatError(e)}})}async handleGetTabGroup(e){let{groupId:t}=this.getSchema.parse(e),n=await new Promise((e,n)=>{chrome.tabGroups.get(t,t=>{chrome.runtime.lastError?n(Error(chrome.runtime.lastError.message)):e(t)})});return this.formatJson({id:n.id,title:n.title,color:n.color,collapsed:n.collapsed,shared:n.shared,windowId:n.windowId})}async handleQueryTabGroups(e){let{collapsed:t,color:n,shared:r,title:i,windowId:a}=this.querySchema.parse(e),o={};t!==void 0&&(o.collapsed=t),n!==void 0&&(o.color=n),r!==void 0&&(o.shared=r),i!==void 0&&(o.title=i),a!==void 0&&(o.windowId=a===-2?chrome.windows.WINDOW_ID_CURRENT:a);let s=await new Promise((e,t)=>{chrome.tabGroups.query(o,n=>{chrome.runtime.lastError?t(Error(chrome.runtime.lastError.message)):e(n)})});return this.formatJson({count:s.length,groups:s.map(e=>({id:e.id,title:e.title,color:e.color,collapsed:e.collapsed,shared:e.shared,windowId:e.windowId}))})}async handleUpdateTabGroup(e){let{groupId:t,collapsed:n,color:r,title:i}=this.updateSchema.parse(e),a={};n!==void 0&&(a.collapsed=n),r!==void 0&&(a.color=r),i!==void 0&&(a.title=i);let o=await new Promise((e,n)=>{chrome.tabGroups.update(t,a,t=>{chrome.runtime.lastError?n(Error(chrome.runtime.lastError.message)):e(t)})});return o?this.formatSuccess(`Tab group updated successfully`,{id:o.id,title:o.title,color:o.color,collapsed:o.collapsed,shared:o.shared,windowId:o.windowId}):this.formatError(`Failed to update tab group`)}async handleMoveTabGroup(e){let{groupId:t,index:n,windowId:r}=this.moveSchema.parse(e),i={index:n};r!==void 0&&(i.windowId=r);let a=await new Promise((e,n)=>{chrome.tabGroups.move(t,i,t=>{chrome.runtime.lastError?n(Error(chrome.runtime.lastError.message)):e(t)})});return a?this.formatSuccess(`Tab group moved successfully`,{id:a.id,title:a.title,color:a.color,collapsed:a.collapsed,shared:a.shared,windowId:a.windowId,newIndex:n}):this.formatError(`Failed to move tab group`)}getSchema=e.object({groupId:e.number().describe(`The ID of the tab group to retrieve`)});querySchema=e.object({collapsed:e.boolean().optional().describe(`Whether the groups are collapsed`),color:e.enum([`grey`,`blue`,`red`,`yellow`,`green`,`pink`,`purple`,`cyan`,`orange`]).optional().describe(`The color of the groups`),shared:e.boolean().optional().describe(`Whether the group is shared (Chrome 137+)`),title:e.string().optional().describe(`Pattern to match group titles against`),windowId:e.number().optional().describe(`The ID of the parent window, or use -2 for the current window`)});updateSchema=e.object({groupId:e.number().describe(`The ID of the group to modify`),collapsed:e.boolean().optional().describe(`Whether the group should be collapsed`),color:e.enum([`grey`,`blue`,`red`,`yellow`,`green`,`pink`,`purple`,`cyan`,`orange`]).optional().describe(`The color of the group`),title:e.string().optional().describe(`The title of the group`)});moveSchema=e.object({groupId:e.number().describe(`The ID of the group to move`),index:e.number().describe(`The position to move the group to. Use -1 to place at the end`),windowId:e.number().optional().describe(`The window to move the group to. Defaults to current window`)})};const U=[`listActiveTabs`,`createTab`,`updateTab`,`closeTabs`,`getAllTabs`,`navigateHistory`,`reloadTab`,`captureVisibleTab`,`detectLanguage`,`discardTab`,`duplicateTab`,`getTab`,`getZoom`,`getZoomSettings`,`setZoom`,`setZoomSettings`,`groupTabs`,`ungroupTabs`,`highlightTabs`,`moveTabs`,`sendMessage`],W=e.enum(U);var De=class extends n{apiName=`Tabs`;constructor(e,t={}){super(e,t)}checkAvailability(){try{return chrome.tabs?typeof chrome.tabs.query==`function`?{available:!0,message:`Tabs API is fully available`}:{available:!1,message:`chrome.tabs.query is not available`,details:`The tabs API appears to be partially available. Check manifest permissions.`}:{available:!1,message:`chrome.tabs API is not defined`,details:`This extension may not have the "tabs" permission in its manifest`}}catch(e){return{available:!1,message:`Failed to access chrome.tabs API`,details:e instanceof Error?e.message:`Unknown error occurred`}}}registerTools(){this.server.registerTool(`extension_tool_tab_operations`,{description:`Perform various tab operations using the Chrome Tabs API`,inputSchema:{action:W,params:e.record(e.string(),e.any()).optional().describe(`Parameters for the chosen action`)}},async({action:e,params:t={}})=>{try{if(!this.shouldRegisterTool(e))return this.formatError(Error(`Action "${e}" is not supported`));switch(e){case`listActiveTabs`:return await this.handleListActiveTabs();case`createTab`:return await this.handleCreateTab(t);case`updateTab`:return await this.handleUpdateTab(t);case`closeTabs`:return await this.handleCloseTabs(t);case`getAllTabs`:return await this.handleGetAllTabs(t);case`navigateHistory`:return await this.handleNavigateHistory(t);case`reloadTab`:return await this.handleReloadTab(t);case`captureVisibleTab`:return await this.handleCaptureVisibleTab(t);case`detectLanguage`:return await this.handleDetectLanguage(t);case`discardTab`:return await this.handleDiscardTab(t);case`duplicateTab`:return await this.handleDuplicateTab(t);case`getTab`:return await this.handleGetTab(t);case`getZoom`:return await this.handleGetZoom(t);case`getZoomSettings`:return await this.handleGetZoomSettings(t);case`setZoom`:return await this.handleSetZoom(t);case`setZoomSettings`:return await this.handleSetZoomSettings(t);case`groupTabs`:return await this.handleGroupTabs(t);case`ungroupTabs`:return await this.handleUngroupTabs(t);case`highlightTabs`:return await this.handleHighlightTabs(t);case`moveTabs`:return await this.handleMoveTabs(t);case`sendMessage`:return await this.handleSendMessage(t);default:return this.formatError(Error(`Action "${e}" is not supported`))}}catch(e){return this.formatError(e)}}),this.server.registerTool(`extension_tool_tab_parameters_description`,{description:`Get the parameters for extension_tool_tab_operations tool and the description for the associated action, this tool should be used first before extension_tool_tab_operations`,inputSchema:{action:W}},async({action:t})=>{try{if(!this.shouldRegisterTool(t))return this.formatError(Error(`Action "${t}" is not supported`));let n=(t,n)=>e.toJSONSchema(t),r={tool:`extension_tool_tab_operations`,action:t,note:`Use the description to double check if the correct action is chosen. Use this JSON Schema for the params field when calling the tool. The top-level tool input is { action, params }.`};switch(t){case`listActiveTabs`:{let e={params:n(this.listActiveTabsSchema,`ListActiveTabsParams`),description:`Lists all tabs grouped by domain`};return this.formatJson({...r,...e})}case`createTab`:{let e={params:n(this.createTabSchema,`CreateTabParams`),description:`Create a new browser tab`};return this.formatJson({...r,...e})}case`updateTab`:{let e={params:n(this.updateTabSchema,`UpdateTabParams`),description:`Update properties of an existing tab. If no tabId is specified, operates on the currently active tab`};return this.formatJson({...r,...e})}case`closeTabs`:{let e={params:n(this.closeTabsSchema,`CloseTabsParams`),description:`Close one or more tabs`};return this.formatJson({...r,...e})}case`getAllTabs`:{let e={params:n(this.getAllTabsSchema,`GetAllTabsParams`),description:`Get information about all open tabs`};return this.formatJson({...r,...e})}case`navigateHistory`:{let e={params:n(this.navigateHistorySchema,`NavigateHistoryParams`),description:`Navigate forward or backward in a tab's history. If no tabId is specified, operates on the currently active tab`};return this.formatJson({...r,...e})}case`reloadTab`:{let e={params:n(this.reloadTabSchema,`ReloadTabParams`),description:`Reload a tab. If no tabId is specified, operates on the currently active tab`};return this.formatJson({...r,...e})}case`captureVisibleTab`:{let e={params:n(this.captureVisibleTabSchema,`CaptureVisibleTabParams`),description:`Take a screenshot of the visible area of the currently active tab in a window. Once the screenshot is captured`};return this.formatJson({...r,...e})}case`detectLanguage`:{let e={params:n(this.detectLanguageSchema,`DetectLanguageParams`),description:`Detect the primary language of the content in a tab`};return this.formatJson({...r,...e})}case`discardTab`:{let e={params:n(this.discardTabSchema,`DiscardTabParams`),description:`Discards a tab from memory. Discarded tabs are still visible but need to reload when activated`};return this.formatJson({...r,...e})}case`duplicateTab`:{let e={params:n(this.duplicateTabSchema,`DuplicateTabParams`),description:`Duplicate a tab`};return this.formatJson({...r,...e})}case`getTab`:{let e={params:n(this.getTabSchema,`GetTabParams`),description:`Retrieves details about a specific tab`};return this.formatJson({...r,...e})}case`getZoom`:{let e={params:n(this.getZoomSchema,`GetZoomParams`),description:`Retrieves the current zoom level of a tab`};return this.formatJson({...r,...e})}case`getZoomSettings`:{let e={params:n(this.getZoomSettingsSchema,`GetZoomSettingsParams`),description:`Gets the current zoom settings of a tab`};return this.formatJson({...r,...e})}case`setZoom`:{let e={params:n(this.setZoomSchema,`SetZoomParams`),description:`Sets the zoom factor of a tab`};return this.formatJson({...r,...e})}case`setZoomSettings`:{let e={params:n(this.setZoomSettingsSchema,`SetZoomSettingsParams`),description:`Sets zoom settings for a tab (how zoom changes are handled)`};return this.formatJson({...r,...e})}case`groupTabs`:{let e={params:n(this.groupTabsSchema,`GroupTabsParams`),description:`Groups one or more tabs together`};return this.formatJson({...r,...e})}case`ungroupTabs`:{let e={params:n(this.ungroupTabsSchema,`UngroupTabsParams`),description:`Removes tabs from their groups`};return this.formatJson({...r,...e})}case`highlightTabs`:{let e={params:n(this.highlightTabsSchema,`HighlightTabsParams`),description:`Highlights the given tabs and focuses on the first one`};return this.formatJson({...r,...e})}case`moveTabs`:{let e={params:n(this.moveTabsSchema,`MoveTabsParams`),description:`Moves tabs to a new position within their window or to another window`};return this.formatJson({...r,...e})}case`sendMessage`:{let e={params:n(this.sendMessageSchema,`SendMessageParams`),description:`Sends a message to content scripts in a specific tab`};return this.formatJson({...r,...e})}default:return this.formatError(Error(`Action "${t}" is not supported`))}}catch(e){return this.formatError(e)}})}async handleListActiveTabs(){let e=(await chrome.tabs.query({})).map(e=>{let t=`unknown`;if(e.url)try{t=new URL(e.url).hostname}catch{}return{tabId:e.id,domain:t,url:e.url,title:e.title,isActive:e.active,windowId:e.windowId,index:e.index,pinned:e.pinned,audible:e.audible,mutedInfo:e.mutedInfo,status:e.status}}).reduce((e,t)=>{let n=t.domain||`unknown`;return e[n]||(e[n]=[]),e[n].push(t),e},{});for(let t of Object.values(e))t.sort((e,t)=>e.windowId===t.windowId?(e.index||0)-(t.index||0):(e.windowId||0)-(t.windowId||0));return this.formatJson(e)}async handleCreateTab(e){let{url:t,active:n,pinned:r}=this.createTabSchema.parse(e),i=await chrome.tabs.create({url:t,active:n,pinned:r});return this.formatSuccess(`Created tab ${i.id} with URL: ${i.url||`about:blank`}`)}async handleUpdateTab(e){let{tabId:t,url:n,active:r,pinned:i,muted:a}=this.updateTabSchema.parse(e);if(t===void 0){let[e]=await chrome.tabs.query({active:!0,currentWindow:!0});if(!e||!e.id)return this.formatError(Error(`No active tab found`));t=e.id}let o={};n!==void 0&&(o.url=n),r!==void 0&&(o.active=r),i!==void 0&&(o.pinned=i),a!==void 0&&(o.muted=a);let s=await chrome.tabs.update(t,o);return s?this.formatSuccess(`Updated tab ${s.id}`,o):this.formatError(Error(`Tab does not exist`))}async handleCloseTabs(e){let{tabIds:t}=this.closeTabsSchema.parse(e);return await chrome.tabs.remove(t),this.formatSuccess(`Closed ${t.length} tab(s): ${t.join(`, `)}`)}async handleGetAllTabs(e){let{currentWindow:t}=this.getAllTabsSchema.parse(e),n=(await chrome.tabs.query(t?{currentWindow:!0}:{})).map(e=>({id:e.id,title:e.title,url:e.url,active:e.active,pinned:e.pinned,windowId:e.windowId,index:e.index}));return this.formatJson(n)}async handleNavigateHistory(e){if(typeof chrome.tabs.goBack!=`function`||typeof chrome.tabs.goForward!=`function`)return this.formatError(Error(`✗ Navigation methods not available - Chrome 72+ required`));let{tabId:t,direction:n}=this.navigateHistorySchema.parse(e);if(t===void 0){let[e]=await chrome.tabs.query({active:!0,currentWindow:!0});if(!e||!e.id)return this.formatError(Error(`No active tab found`));t=e.id}return n===`back`?await chrome.tabs.goBack(t):await chrome.tabs.goForward(t),this.formatSuccess(`Navigated ${n} in tab ${t}`)}async handleReloadTab(e){let{tabId:t,bypassCache:n}=this.reloadTabSchema.parse(e);if(t===void 0){let[e]=await chrome.tabs.query({active:!0,currentWindow:!0});if(!e||!e.id)return this.formatError(Error(`No active tab found`));t=e.id}return await chrome.tabs.reload(t,{bypassCache:n}),this.formatSuccess(`Reloaded tab ${t}${n?` (bypassed cache)`:``}`)}async handleCaptureVisibleTab(e){if(typeof chrome.tabs.captureVisibleTab!=`function`)return this.formatError(Error(`✗ Screenshot capture not available - requires "activeTab" or "<all_urls>" permission`));let{windowId:t}=this.captureVisibleTabSchema.parse(e),n=t?await chrome.tabs.captureVisibleTab(t,{}):await chrome.tabs.captureVisibleTab();return chrome.tabs.create({url:n}),this.formatSuccess(`Screenshot captured (data URL length: ${n.length} characters)`)}async handleDetectLanguage(e){let{tabId:t}=this.detectLanguageSchema.parse(e),n=await chrome.tabs.detectLanguage(t);return this.formatSuccess(`Tab language detected: ${n}`,{language:n})}async handleDiscardTab(e){let{tabId:t}=this.discardTabSchema.parse(e),n=await chrome.tabs.discard(t);return n?this.formatSuccess(`Discarded tab ${n.id}`,{tab:n}):this.formatError(Error(`Failed to discard tab`))}async handleDuplicateTab(e){let{tabId:t}=this.duplicateTabSchema.parse(e),n=await chrome.tabs.duplicate(t);return n?this.formatSuccess(`Duplicated tab ${n.id}`,{tab:n}):this.formatError(Error(`Failed to duplicate tab`))}async handleGetTab(e){let{tabId:t}=this.getTabSchema.parse(e),n=await chrome.tabs.get(t);return this.formatJson(n)}async handleGetZoom(e){let{tabId:t}=this.getZoomSchema.parse(e),n=await chrome.tabs.getZoom(t);return this.formatSuccess(`Zoom factor: ${n}`,{zoomFactor:n})}async handleGetZoomSettings(e){let{tabId:t}=this.getZoomSettingsSchema.parse(e),n=await chrome.tabs.getZoomSettings(t);return this.formatJson(n)}async handleSetZoom(e){let{tabId:t,zoomFactor:n}=this.setZoomSchema.parse(e);return await chrome.tabs.setZoom(t,n),this.formatSuccess(`Set zoom factor to ${n===0?`default`:n}`)}async handleSetZoomSettings(e){let{tabId:t,mode:n,scope:r}=this.setZoomSettingsSchema.parse(e),i={};return n&&(i.mode=n),r&&(i.scope=r),await chrome.tabs.setZoomSettings(t,i),this.formatSuccess(`Updated zoom settings`,i)}async handleGroupTabs(e){let{tabIds:t,groupId:n,createProperties:r}=this.groupTabsSchema.parse(e),i={tabIds:t.length===1?t[0]:t};n===void 0?r&&(i.createProperties=r):i.groupId=n;let a=await chrome.tabs.group(i);return this.formatSuccess(`Grouped ${t.length} tabs into group ${a}`,{groupId:a})}async handleUngroupTabs(e){let{tabIds:t}=this.ungroupTabsSchema.parse(e);return await chrome.tabs.ungroup(t.length===1?t[0]:t),this.formatSuccess(`Ungrouped ${t.length} tab(s)`)}async handleHighlightTabs(e){let{tabs:t,windowId:n}=this.highlightTabsSchema.parse(e),r={tabs:t.length===1?t[0]:t};n!==void 0&&(r.windowId=n);let i=await chrome.tabs.highlight(r);return this.formatSuccess(`Highlighted ${t.length} tab(s)`,{window:i})}async handleMoveTabs(e){let{tabIds:t,index:n,windowId:r}=this.moveTabsSchema.parse(e),i={index:n};r!==void 0&&(i.windowId=r);let a=chrome.tabs.move(t.length===1?t[0]:t,i);return this.formatSuccess(`Moved ${t.length} tab(s) to index ${n}`,{tabs:a})}async handleSendMessage(e){let{tabId:t,message:n,frameId:r,documentId:i}=this.sendMessageSchema.parse(e),a={};r!==void 0&&(a.frameId=r),i!==void 0&&(a.documentId=i);let o=await chrome.tabs.sendMessage(t,n,a);return this.formatSuccess(`Message sent successfully`,{response:o})}listActiveTabsSchema=e.object({});createTabSchema=e.object({url:e.string().optional().describe(`URL to open in the new tab. Fully-qualified URLs must include a scheme (i.e., 'http://www.google.com', not 'www.google.com'). Relative URLs are relative to the current page within the extension. Defaults to the New Tab Page.`),active:e.boolean().optional().describe(`Whether the tab should be active`),pinned:e.boolean().optional().describe(`Whether the tab should be pinned`)});updateTabSchema=e.object({tabId:e.number().optional().describe(`ID of the tab to update (defaults to active tab)`),url:e.string().optional().describe(`New URL for the tab`),active:e.boolean().optional().describe(`Whether to make the tab active`),pinned:e.boolean().optional().describe(`Whether to pin/unpin the tab`),muted:e.boolean().optional().describe(`Whether to mute/unmute the tab`)});closeTabsSchema=e.object({tabIds:e.array(e.number()).describe(`Array of tab IDs to close`)});getAllTabsSchema=e.object({currentWindow:e.boolean().optional().describe(`Only get tabs from current window`)});navigateHistorySchema=e.object({tabId:e.number().optional().describe(`Tab ID to navigate (defaults to active tab)`),direction:e.enum([`back`,`forward`]).describe(`Navigation direction`)});reloadTabSchema=e.object({tabId:e.number().optional().describe(`Tab ID to reload (defaults to active tab)`),bypassCache:e.boolean().optional().describe(`Bypass the cache when reloading`)});captureVisibleTabSchema=e.object({windowId:e.number().optional().describe(`Window ID (defaults to current window)`)});detectLanguageSchema=e.object({tabId:e.number().optional().describe(`Tab ID (defaults to active tab)`)});discardTabSchema=e.object({tabId:e.number().optional().describe(`Tab ID to discard (if omitted, browser picks least important tab)`)});duplicateTabSchema=e.object({tabId:e.number().describe(`ID of the tab to duplicate`)});getTabSchema=e.object({tabId:e.number().describe(`Tab ID`)});getZoomSchema=e.object({tabId:e.number().optional().describe(`Tab ID (defaults to active tab)`)});getZoomSettingsSchema=e.object({tabId:e.number().optional().describe(`Tab ID (defaults to active tab)`)});setZoomSchema=e.object({tabId:e.number().optional().describe(`Tab ID (defaults to active tab)`),zoomFactor:e.number().describe(`New zoom factor (0 resets to default, >0 sets specific zoom)`)});setZoomSettingsSchema=e.object({tabId:e.number().optional().describe(`Tab ID (defaults to active tab)`),mode:e.enum([`automatic`,`manual`,`disabled`]).optional().describe(`How zoom changes are handled`),scope:e.enum([`per-origin`,`per-tab`]).optional().describe(`Whether zoom persists across pages`)});groupTabsSchema=e.object({tabIds:e.array(e.number()).min(1).describe(`Tab IDs to group`),groupId:e.number().optional().describe(`Existing group ID to add tabs to`),createProperties:e.object({windowId:e.number().optional().describe(`Window ID for new group`)}).optional().describe(`Properties for creating a new group`)});ungroupTabsSchema=e.object({tabIds:e.array(e.number()).min(1).describe(`Tab IDs to ungroup`)});highlightTabsSchema=e.object({tabs:e.array(e.number()).min(1).describe(`Tab indices to highlight`),windowId:e.number().optional().describe(`Window ID containing the tabs`)});moveTabsSchema=e.object({tabIds:e.array(e.number()).min(1).describe(`Tab IDs to move`),index:e.number().describe(`Position to move tabs to (-1 for end)`),windowId:e.number().optional().describe(`Target window ID`)});sendMessageSchema=e.object({tabId:e.number().describe(`Tab ID to send message to`),message:e.any().describe(`Message to send (must be JSON-serializable)`),frameId:e.number().optional().describe(`Specific frame ID to target`),documentId:e.string().optional().describe(`Specific document ID to target`)})},Oe=class extends n{apiName=`TopSites`;constructor(e,t={}){super(e,t)}checkAvailability(){try{return chrome.topSites?typeof chrome.topSites.get==`function`?(chrome.topSites.get(e=>{if(chrome.runtime.lastError)throw Error(chrome.runtime.lastError.message)}),{available:!0,message:`TopSites API is fully available`}):{available:!1,message:`chrome.topSites.get is not available`,details:`The topSites API appears to be partially available. Check manifest permissions.`}:{available:!1,message:`chrome.topSites API is not defined`,details:`This extension needs the "topSites" permission in its manifest.json`}}catch(e){return{available:!1,message:`Failed to access chrome.topSites API`,details:e instanceof Error?e.message:`Unknown error occurred`}}}registerTools(){this.shouldRegisterTool(`getTopSites`)&&this.registerGetTopSites()}registerGetTopSites(){this.server.registerTool(`extension_tool_get_top_sites`,{description:`Get a list of top sites (most visited sites) that are displayed on the new tab page`,inputSchema:{}},async()=>{try{let e=await new Promise((e,t)=>{chrome.topSites.get(n=>{chrome.runtime.lastError?t(Error(chrome.runtime.lastError.message)):e(n)})});return this.formatJson({count:e.length,topSites:e.map(e=>({title:e.title,url:e.url}))})}catch(e){return this.formatError(e)}})}},ke=class extends n{apiName=`Tts`;constructor(e,t={}){super(e,t)}checkAvailability(){try{return chrome.tts?typeof chrome.tts.getVoices==`function`?(chrome.tts.getVoices(e=>{if(chrome.runtime.lastError)throw Error(chrome.runtime.lastError.message)}),{available:!0,message:`TTS API is fully available`}):{available:!1,message:`chrome.tts.getVoices is not available`,details:`The tts API appears to be partially available. Check manifest permissions.`}:{available:!1,message:`chrome.tts API is not defined`,details:`This extension needs the "tts" permission in its manifest.json`}}catch(e){return{available:!1,message:`Failed to access chrome.tts API`,details:e instanceof Error?e.message:`Unknown error occurred`}}}registerTools(){this.shouldRegisterTool(`speak`)&&this.registerSpeak(),this.shouldRegisterTool(`stop`)&&this.registerStop(),this.shouldRegisterTool(`pause`)&&this.registerPause(),this.shouldRegisterTool(`resume`)&&this.registerResume(),this.shouldRegisterTool(`isSpeaking`)&&this.registerIsSpeaking(),this.shouldRegisterTool(`getVoices`)&&this.registerGetVoices()}registerSpeak(){this.server.registerTool(`extension_tool_speak_text`,{description:`Speaks text using text-to-speech synthesis`,inputSchema:{utterance:e.string().max(32768).describe(`The text to speak, either plain text or a complete SSML document. Maximum length is 32,768 characters`),lang:e.string().optional().describe(`The language to be used for synthesis, in the form language-region. Examples: "en", "en-US", "en-GB", "zh-CN"`),voiceName:e.string().optional().describe(`The name of the voice to use for synthesis. If empty, uses any available voice`),rate:e.number().min(.1).max(10).optional().describe(`Speaking rate relative to the default rate. 1.0 is default, 2.0 is twice as fast, 0.5 is half as fast`),pitch:e.number().min(0).max(2).optional().describe(`Speaking pitch between 0 and 2 inclusive, with 0 being lowest and 2 being highest. 1.0 is default`),volume:e.number().min(0).max(1).optional().describe(`Speaking volume between 0 and 1 inclusive, with 0 being lowest and 1 being highest. Default is 1.0`),enqueue:e.boolean().optional().describe(`If true, enqueues this utterance if TTS is already in progress. If false (default), interrupts current speech`),extensionId:e.string().optional().describe(`The extension ID of the speech engine to use, if known`),requiredEventTypes:e.array(e.string()).optional().describe(`The TTS event types the voice must support`),desiredEventTypes:e.array(e.string()).optional().describe(`The TTS event types that you are interested in listening to`)}},async({utterance:e,lang:t,voiceName:n,rate:r,pitch:i,volume:a,enqueue:o,extensionId:s,requiredEventTypes:c,desiredEventTypes:l})=>{try{let u={};t!==void 0&&(u.lang=t),n!==void 0&&(u.voiceName=n),r!==void 0&&(u.rate=r),i!==void 0&&(u.pitch=i),a!==void 0&&(u.volume=a),o!==void 0&&(u.enqueue=o),s!==void 0&&(u.extensionId=s),c!==void 0&&(u.requiredEventTypes=c),l!==void 0&&(u.desiredEventTypes=l);let d=[];return u.onEvent=e=>{d.push(e)},await new Promise((t,n)=>{chrome.tts.speak(e,u,()=>{chrome.runtime.lastError?n(Error(chrome.runtime.lastError.message)):t()})}),this.formatSuccess(`Text-to-speech started successfully`,{utterance:e.substring(0,100)+(e.length>100?`...`:``),options:{lang:u.lang,voiceName:u.voiceName,rate:u.rate,pitch:u.pitch,volume:u.volume,enqueue:u.enqueue}})}catch(e){return this.formatError(e)}})}registerStop(){this.server.registerTool(`extension_tool_stop_speech`,{description:`Stops any current speech and flushes the queue of pending utterances`,inputSchema:{}},async()=>{try{return chrome.tts.stop(),this.formatSuccess(`Speech stopped and queue cleared`)}catch(e){return this.formatError(e)}})}registerPause(){this.server.registerTool(`extension_tool_pause_speech`,{description:`Pauses speech synthesis, potentially in the middle of an utterance`,inputSchema:{}},async()=>{try{return chrome.tts.pause(),this.formatSuccess(`Speech paused`)}catch(e){return this.formatError(e)}})}registerResume(){this.server.registerTool(`extension_tool_resume_speech`,{description:`If speech was paused, resumes speaking where it left off`,inputSchema:{}},async()=>{try{return chrome.tts.resume(),this.formatSuccess(`Speech resumed`)}catch(e){return this.formatError(e)}})}registerIsSpeaking(){this.server.registerTool(`extension_tool_is_speaking`,{description:`Checks whether the engine is currently speaking`,inputSchema:{}},async()=>{try{let e=await new Promise((e,t)=>{chrome.tts.isSpeaking(n=>{chrome.runtime.lastError?t(Error(chrome.runtime.lastError.message)):e(n)})});return this.formatJson({speaking:e,status:e?`TTS engine is currently speaking`:`TTS engine is not speaking`})}catch(e){return this.formatError(e)}})}registerGetVoices(){this.server.registerTool(`extension_tool_get_voices`,{description:`Gets an array of all available voices for speech synthesis`,inputSchema:{}},async()=>{try{let e=await new Promise((e,t)=>{chrome.tts.getVoices(n=>{chrome.runtime.lastError?t(Error(chrome.runtime.lastError.message)):e(n)})});return this.formatJson({count:e.length,voices:e.map(e=>({voiceName:e.voiceName,lang:e.lang,extensionId:e.extensionId,eventTypes:e.eventTypes,remote:e.remote}))})}catch(e){return this.formatError(e)}})}},Ae=class extends n{apiName=`TtsEngine`;constructor(e,t={}){super(e,t)}checkAvailability(){try{return chrome.ttsEngine?typeof chrome.ttsEngine.updateVoices==`function`?!chrome.ttsEngine.onSpeak||!chrome.ttsEngine.onStop?{available:!1,message:`chrome.ttsEngine events are not available`,details:`The ttsEngine API requires event listeners to be available.`}:{available:!0,message:`TtsEngine API is fully available`}:{available:!1,message:`chrome.ttsEngine.updateVoices is not available`,details:`The ttsEngine API appears to be partially available. Check manifest permissions.`}:{available:!1,message:`chrome.ttsEngine API is not defined`,details:`This extension needs the "ttsEngine" permission in its manifest.json`}}catch(e){return{available:!1,message:`Failed to access chrome.ttsEngine API`,details:e instanceof Error?e.message:`Unknown error occurred`}}}registerTools(){this.shouldRegisterTool(`updateVoices`)&&this.registerUpdateVoices(),this.shouldRegisterTool(`updateLanguage`)&&this.registerUpdateLanguage(),this.shouldRegisterTool(`onSpeak`)&&this.registerOnSpeak(),this.shouldRegisterTool(`onStop`)&&this.registerOnStop(),this.shouldRegisterTool(`onPause`)&&this.registerOnPause(),this.shouldRegisterTool(`onResume`)&&this.registerOnResume(),this.shouldRegisterTool(`onSpeakWithAudioStream`)&&this.registerOnSpeakWithAudioStream(),this.shouldRegisterTool(`onInstallLanguageRequest`)&&this.registerOnInstallLanguageRequest(),this.shouldRegisterTool(`onLanguageStatusRequest`)&&this.registerOnLanguageStatusRequest(),this.shouldRegisterTool(`onUninstallLanguageRequest`)&&this.registerOnUninstallLanguageRequest()}registerUpdateVoices(){this.server.registerTool(`extension_tool_update_voices`,{description:`Update the list of voices available for speech synthesis`,inputSchema:{voices:e.array(e.object({voiceName:e.string().describe(`The name of the voice`),lang:e.string().optional().describe(`Language code (e.g., en-US)`),gender:e.enum([`male`,`female`]).optional().describe(`Voice gender (deprecated)`),remote:e.boolean().optional().describe(`Whether the voice is remote`),extensionId:e.string().optional().describe(`Extension ID providing the voice`),eventTypes:e.array(e.string()).optional().describe(`Supported event types`)})).describe(`Array of voice objects to register`)}},async({voices:e})=>{try{return chrome.ttsEngine.updateVoices(e),this.formatSuccess(`Voices updated successfully`,{voiceCount:e.length,voices:e.map(e=>({name:e.voiceName,lang:e.lang,eventTypes:e.eventTypes}))})}catch(e){return this.formatError(e)}})}registerUpdateLanguage(){this.server.registerTool(`extension_tool_update_language`,{description:`Update the installation status of a language`,inputSchema:{lang:e.string().describe(`Language code (e.g., en-US)`),installStatus:e.enum([`notInstalled`,`installing`,`installed`,`failed`]).describe(`Installation status`),error:e.string().optional().describe(`Error message if installation failed`)}},async({lang:e,installStatus:t,error:n})=>{try{let r={lang:e,installStatus:t};return n!==void 0&&(r.error=n),chrome.ttsEngine.updateLanguage(r),this.formatSuccess(`Language status updated successfully`,{lang:e,installStatus:t,error:n})}catch(e){return this.formatError(e)}})}registerOnSpeak(){this.server.registerTool(`extension_tool_register_speak_listener`,{description:`Register a listener for speak events from the TTS engine`,inputSchema:{}},async()=>{try{return chrome.ttsEngine.onSpeak.addListener((e,t,n)=>{n({type:`start`,charIndex:0}),setTimeout(()=>{n({type:`end`,charIndex:e.length})},1e3)}),this.formatSuccess(`Speak listener registered successfully`)}catch(e){return this.formatError(e)}})}registerOnStop(){this.server.registerTool(`extension_tool_register_stop_listener`,{description:`Register a listener for stop events from the TTS engine`,inputSchema:{}},async()=>{try{return chrome.ttsEngine.onStop.addListener(()=>{}),this.formatSuccess(`Stop listener registered successfully`)}catch(e){return this.formatError(e)}})}registerOnPause(){this.server.registerTool(`extension_tool_register_pause_listener`,{description:`Register a listener for pause events from the TTS engine`,inputSchema:{}},async()=>{try{return chrome.ttsEngine.onPause.addListener(()=>{}),this.formatSuccess(`Pause listener registered successfully`)}catch(e){return this.formatError(e)}})}registerOnResume(){this.server.registerTool(`extension_tool_register_resume_listener`,{description:`Register a listener for resume events from the TTS engine`,inputSchema:{}},async()=>{try{return chrome.ttsEngine.onResume.addListener(()=>{}),this.formatSuccess(`Resume listener registered successfully`)}catch(e){return this.formatError(e)}})}registerOnSpeakWithAudioStream(){this.server.registerTool(`extension_tool_register_speak_audio_stream_listener`,{description:`Register a listener for speak events with audio stream support`,inputSchema:{}},async()=>{try{return chrome.ttsEngine.onSpeakWithAudioStream.addListener((e,t,n,r,i)=>{try{let e=n.bufferSize;r({audioBuffer:new ArrayBuffer(e*4),charIndex:0,isLastBuffer:!0})}catch(e){i(e instanceof Error?e.message:`Unknown error`)}}),this.formatSuccess(`Speak with audio stream listener registered successfully`)}catch(e){return this.formatError(e)}})}registerOnInstallLanguageRequest(){this.server.registerTool(`extension_tool_register_install_language_listener`,{description:`Register a listener for language installation requests`,inputSchema:{}},async()=>{try{return chrome.ttsEngine.onInstallLanguageRequest.addListener((e,t)=>{chrome.ttsEngine.updateLanguage({lang:t,installStatus:`installing`})}),this.formatSuccess(`Install language listener registered successfully`)}catch(e){return this.formatError(e)}})}registerOnLanguageStatusRequest(){this.server.registerTool(`extension_tool_register_language_status_listener`,{description:`Register a listener for language status requests`,inputSchema:{}},async()=>{try{return chrome.ttsEngine.onLanguageStatusRequest.addListener((e,t)=>{chrome.ttsEngine.updateLanguage({lang:t,installStatus:`installed`})}),this.formatSuccess(`Language status listener registered successfully`)}catch(e){return this.formatError(e)}})}registerOnUninstallLanguageRequest(){this.server.registerTool(`extension_tool_register_uninstall_language_listener`,{description:`Register a listener for language uninstallation requests`,inputSchema:{}},async()=>{try{return chrome.ttsEngine.onUninstallLanguageRequest.addListener((e,t,n)=>{n.uninstallImmediately&&chrome.ttsEngine.updateLanguage({lang:t,installStatus:`notInstalled`})}),this.formatSuccess(`Uninstall language listener registered successfully`)}catch(e){return this.formatError(e)}})}},je=class extends n{apiName=`UserScripts`;constructor(e,t={}){super(e,t)}checkAvailability(){try{return chrome.userScripts?typeof chrome.userScripts.getScripts==`function`?(chrome.userScripts.getScripts({},()=>{if(chrome.runtime.lastError)throw Error(chrome.runtime.lastError.message)}),{available:!0,message:`UserScripts API is fully available`}):{available:!1,message:`chrome.userScripts.getScripts is not available`,details:`The userScripts API appears to be partially available. Check manifest permissions and user toggle settings.`}:{available:!1,message:`chrome.userScripts API is not defined`,details:`This extension needs the "userScripts" permission in its manifest.json and users must enable the appropriate toggle (Developer mode for Chrome <138 or Allow User Scripts for Chrome 138+)`}}catch(e){return{available:!1,message:`Failed to access chrome.userScripts API`,details:e instanceof Error?e.message:`Unknown error occurred`}}}registerTools(){this.shouldRegisterTool(`register`)&&this.registerRegister(),this.shouldRegisterTool(`getScripts`)&&this.registerGetScripts(),this.shouldRegisterTool(`update`)&&this.registerUpdate(),this.shouldRegisterTool(`unregister`)&&this.registerUnregister(),this.shouldRegisterTool(`configureWorld`)&&this.registerConfigureWorld(),this.shouldRegisterTool(`getWorldConfigurations`)&&this.registerGetWorldConfigurations(),this.shouldRegisterTool(`resetWorldConfiguration`)&&this.registerResetWorldConfiguration(),this.shouldRegisterTool(`execute`)&&this.registerExecute()}registerRegister(){this.server.registerTool(`extension_tool_register_user_scripts`,{description:`Register one or more user scripts for this extension`,inputSchema:{scripts:e.array(e.object({id:e.string().describe(`The ID of the user script. Must not start with underscore`),matches:e.array(e.string()).describe(`Match patterns for pages this script will be injected into`),js:e.array(e.object({code:e.string().optional().describe(`JavaScript code to inject`),file:e.string().optional().describe(`Path to JavaScript file relative to extension root`)})).optional().describe(`List of script sources to inject`),allFrames:e.boolean().optional().describe(`Whether to inject into all frames (default: false)`),excludeMatches:e.array(e.string()).optional().describe(`Pages to exclude from injection`),includeGlobs:e.array(e.string()).optional().describe(`Wildcard patterns for pages to include`),excludeGlobs:e.array(e.string()).optional().describe(`Wildcard patterns for pages to exclude`),runAt:e.enum([`document_start`,`document_end`,`document_idle`]).optional().describe(`When to inject the script (default: document_idle)`),world:e.enum([`MAIN`,`USER_SCRIPT`]).optional().describe(`JavaScript execution environment (default: USER_SCRIPT)`),worldId:e.string().optional().describe(`User script world ID to execute in`)})).describe(`Array of user scripts to register`)}},async({scripts:e})=>{try{for(let t of e){if(t.id.startsWith(`_`))return this.formatError(`Script ID cannot start with underscore: ${t.id}`);if(t.js){for(let e of t.js)if(e.code!==void 0==(e.file!==void 0))return this.formatError(`Exactly one of code or file must be specified for each script source`)}}return await new Promise((t,n)=>{chrome.userScripts.register(e,()=>{chrome.runtime.lastError?n(Error(chrome.runtime.lastError.message)):t()})}),this.formatSuccess(`User scripts registered successfully`,{registeredCount:e.length,scriptIds:e.map(e=>e.id)})}catch(e){return this.formatError(e)}})}registerGetScripts(){this.server.registerTool(`extension_tool_get_user_scripts`,{description:`Get all dynamically-registered user scripts for this extension`,inputSchema:{ids:e.array(e.string()).optional().describe(`Filter to only return scripts with these IDs`)}},async({ids:e})=>{try{let t={};e!==void 0&&(t.ids=e);let n=await new Promise((e,n)=>{chrome.userScripts.getScripts(t,t=>{chrome.runtime.lastError?n(Error(chrome.runtime.lastError.message)):e(t)})});return this.formatJson({count:n.length,scripts:n.map(e=>({id:e.id,matches:e.matches,allFrames:e.allFrames,excludeMatches:e.excludeMatches,includeGlobs:e.includeGlobs,excludeGlobs:e.excludeGlobs,runAt:e.runAt,world:e.world,worldId:e.worldId,jsSourcesCount:e.js?.length||0}))})}catch(e){return this.formatError(e)}})}registerUpdate(){this.server.registerTool(`extension_tool_update_user_scripts`,{description:`Update one or more user scripts for this extension`,inputSchema:{scripts:e.array(e.object({id:e.string().describe(`The ID of the user script to update`),matches:e.array(e.string()).optional().describe(`Match patterns for pages this script will be injected into`),js:e.array(e.object({code:e.string().optional().describe(`JavaScript code to inject`),file:e.string().optional().describe(`Path to JavaScript file relative to extension root`)})).optional().describe(`List of script sources to inject`),allFrames:e.boolean().optional().describe(`Whether to inject into all frames`),excludeMatches:e.array(e.string()).optional().describe(`Pages to exclude from injection`),includeGlobs:e.array(e.string()).optional().describe(`Wildcard patterns for pages to include`),excludeGlobs:e.array(e.string()).optional().describe(`Wildcard patterns for pages to exclude`),runAt:e.enum([`document_start`,`document_end`,`document_idle`]).optional().describe(`When to inject the script`),world:e.enum([`MAIN`,`USER_SCRIPT`]).optional().describe(`JavaScript execution environment`),worldId:e.string().optional().describe(`User script world ID to execute in`)})).describe(`Array of user scripts to update`)}},async({scripts:e})=>{try{for(let t of e)if(t.js){for(let e of t.js)if(e.code!==void 0==(e.file!==void 0))return this.formatError(`Exactly one of code or file must be specified for each script source`)}return await new Promise((t,n)=>{chrome.userScripts.update(e,()=>{chrome.runtime.lastError?n(Error(chrome.runtime.lastError.message)):t()})}),this.formatSuccess(`User scripts updated successfully`,{updatedCount:e.length,scriptIds:e.map(e=>e.id)})}catch(e){return this.formatError(e)}})}registerUnregister(){this.server.registerTool(`extension_tool_unregister_user_scripts`,{description:`Unregister dynamically-registered user scripts for this extension`,inputSchema:{ids:e.array(e.string()).optional().describe(`Filter to only unregister scripts with these IDs. If not specified, all scripts are unregistered`)}},async({ids:e})=>{try{let t={};e!==void 0&&(t.ids=e);let n=await new Promise((e,n)=>{chrome.userScripts.getScripts(t,t=>{chrome.runtime.lastError?n(Error(chrome.runtime.lastError.message)):e(t)})});return await new Promise((e,n)=>{chrome.userScripts.unregister(t,()=>{chrome.runtime.lastError?n(Error(chrome.runtime.lastError.message)):e()})}),this.formatSuccess(`User scripts unregistered successfully`,{unregisteredCount:n.length,unregisteredScriptIds:n.map(e=>e.id)})}catch(e){return this.formatError(e)}})}registerConfigureWorld(){this.server.registerTool(`extension_tool_configure_user_script_world`,{description:`Configure the USER_SCRIPT execution environment`,inputSchema:{csp:e.string().optional().describe(`Content Security Policy for the world`),messaging:e.boolean().optional().describe(`Whether messaging APIs are exposed (default: false)`),worldId:e.string().optional().describe(`ID of the specific user script world to update`)}},async({csp:e,messaging:t,worldId:n})=>{try{let r={};return e!==void 0&&(r.csp=e),t!==void 0&&(r.messaging=t),n!==void 0&&(r.worldId=n),await new Promise((e,t)=>{chrome.userScripts.configureWorld(r,()=>{chrome.runtime.lastError?t(Error(chrome.runtime.lastError.message)):e()})}),this.formatSuccess(`User script world configured successfully`,{worldId:n||`default`,csp:e,messaging:t})}catch(e){return this.formatError(e)}})}registerGetWorldConfigurations(){this.server.registerTool(`extension_tool_get_world_configurations`,{description:`Retrieve all registered world configurations`,inputSchema:{}},async()=>{try{let e=await new Promise((e,t)=>{chrome.userScripts.getWorldConfigurations(n=>{chrome.runtime.lastError?t(Error(chrome.runtime.lastError.message)):e(n)})});return this.formatJson({count:e.length,worlds:e.map(e=>({worldId:e.worldId,csp:e.csp,messaging:e.messaging}))})}catch(e){return this.formatError(e)}})}registerResetWorldConfiguration(){this.server.registerTool(`extension_tool_reset_world_configuration`,{description:`Reset the configuration for a user script world to defaults`,inputSchema:{worldId:e.string().optional().describe(`ID of the user script world to reset. If omitted, resets the default world`)}},async({worldId:e=`default`})=>{try{return await new Promise((t,n)=>{chrome.userScripts.resetWorldConfiguration(e,()=>{chrome.runtime.lastError?n(Error(chrome.runtime.lastError.message)):t()})}),this.formatSuccess(`World configuration reset successfully`,{worldId:e||`default`})}catch(e){return this.formatError(e)}})}registerExecute(){this.server.registerTool(`extension_tool_execute_user_script`,{description:`Inject a script into a target context`,inputSchema:{target:e.object({tabId:e.number().describe(`The ID of the tab to inject into`),frameIds:e.array(e.number()).optional().describe(`IDs of specific frames to inject into`),documentIds:e.array(e.string()).optional().describe(`IDs of specific documents to inject into`),allFrames:e.boolean().optional().describe(`Whether to inject into all frames (default: false)`)}).describe(`Target specification for injection`),js:e.array(e.object({code:e.string().optional().describe(`JavaScript code to inject`),file:e.string().optional().describe(`Path to JavaScript file relative to extension root`)})).describe(`List of script sources to inject`),world:e.enum([`MAIN`,`USER_SCRIPT`]).optional().describe(`JavaScript execution environment (default: USER_SCRIPT)`),worldId:e.string().optional().describe(`User script world ID to execute in`),injectImmediately:e.boolean().optional().describe(`Whether to inject immediately without waiting (default: false)`)}},async({target:e,js:t,world:n,worldId:r,injectImmediately:i})=>{try{for(let e of t)if(e.code!==void 0==(e.file!==void 0))return this.formatError(`Exactly one of code or file must be specified for each script source`);let a={target:e,js:t};n!==void 0&&(a.world=n),r!==void 0&&(a.worldId=r),i!==void 0&&(a.injectImmediately=i);let o=await new Promise((e,t)=>{chrome.userScripts.execute(a,n=>{chrome.runtime.lastError?t(Error(chrome.runtime.lastError.message)):e(n)})});return this.formatJson({injectionCount:o.length,results:o.map(e=>({frameId:e.frameId,documentId:e.documentId,error:e.error,hasResult:e.result!==void 0}))})}catch(e){return this.formatError(e)}})}},Me=class extends n{apiName=`VpnProvider`;constructor(e,t={}){super(e,t)}checkAvailability(){try{return chrome.vpnProvider?typeof chrome.vpnProvider.createConfig==`function`?{available:!0,message:`VpnProvider API is fully available`}:{available:!1,message:`chrome.vpnProvider.createConfig is not available`,details:`The vpnProvider API appears to be partially available. Check manifest permissions and ensure this is running on ChromeOS.`}:{available:!1,message:`chrome.vpnProvider API is not defined`,details:`This extension needs the "vpnProvider" permission in its manifest.json and only works on ChromeOS`}}catch(e){return{available:!1,message:`Failed to access chrome.vpnProvider API`,details:e instanceof Error?e.message:`Unknown error occurred`}}}registerTools(){this.shouldRegisterTool(`createConfig`)&&this.registerCreateConfig(),this.shouldRegisterTool(`destroyConfig`)&&this.registerDestroyConfig(),this.shouldRegisterTool(`setParameters`)&&this.registerSetParameters(),this.shouldRegisterTool(`notifyConnectionStateChanged`)&&this.registerNotifyConnectionStateChanged(),this.shouldRegisterTool(`sendPacket`)&&this.registerSendPacket()}registerCreateConfig(){this.server.registerTool(`extension_tool_create_vpn_config`,{description:`Create a new VPN configuration that persists across multiple login sessions`,inputSchema:{name:e.string().describe(`The name of the VPN configuration`)}},async({name:e})=>{try{let t=await new Promise((t,n)=>{chrome.vpnProvider.createConfig(e,e=>{chrome.runtime.lastError?n(Error(chrome.runtime.lastError.message)):e?t(e):n(Error(`Failed to create VPN configuration`))})});return this.formatSuccess(`VPN configuration created successfully`,{id:t,name:e})}catch(e){return this.formatError(e)}})}registerDestroyConfig(){this.server.registerTool(`extension_tool_destroy_vpn_config`,{description:`Destroy a VPN configuration created by the extension`,inputSchema:{id:e.string().describe(`ID of the VPN configuration to destroy`)}},async({id:e})=>{try{return await new Promise((t,n)=>{chrome.vpnProvider.destroyConfig(e,()=>{chrome.runtime.lastError?n(Error(chrome.runtime.lastError.message)):t()})}),this.formatSuccess(`VPN configuration destroyed successfully`,{id:e})}catch(e){return this.formatError(e)}})}registerSetParameters(){this.server.registerTool(`extension_tool_set_vpn_parameters`,{description:`Set the parameters for the VPN session. Should be called immediately after "connected" is received`,inputSchema:{address:e.string().describe(`IP address for the VPN interface in CIDR notation. IPv4 is currently the only supported mode`),dnsServer:e.array(e.string()).describe(`A list of IPs for the DNS servers`),inclusionList:e.array(e.string()).describe(`Include network traffic to the list of IP blocks in CIDR notation to the tunnel`),exclusionList:e.array(e.string()).describe(`Exclude network traffic to the list of IP blocks in CIDR notation from the tunnel`),broadcastAddress:e.string().optional().describe(`Broadcast address for the VPN interface (default: deduced from IP address and mask)`),domainSearch:e.array(e.string()).optional().describe(`A list of search domains (default: no search domain)`),mtu:e.string().optional().describe(`MTU setting for the VPN interface (default: 1500 bytes)`)}},async({address:e,dnsServer:t,inclusionList:n,exclusionList:r,broadcastAddress:i,domainSearch:a,mtu:o})=>{try{let s={address:e,dnsServer:t,inclusionList:n,exclusionList:r};return i!==void 0&&(s.broadcastAddress=i),a!==void 0&&(s.domainSearch=a),o!==void 0&&(s.mtu=o),await new Promise((e,t)=>{chrome.vpnProvider.setParameters(s,()=>{chrome.runtime.lastError?t(Error(chrome.runtime.lastError.message)):e()})}),this.formatSuccess(`VPN parameters set successfully`,{parameters:s})}catch(e){return this.formatError(e)}})}registerNotifyConnectionStateChanged(){this.server.registerTool(`extension_tool_notify_vpn_connection_state`,{description:`Notify the VPN session state to the platform. This will succeed only when the VPN session is owned by the extension`,inputSchema:{state:e.enum([`connected`,`failure`]).describe(`The VPN session state of the VPN client`)}},async({state:e})=>{try{return await new Promise((t,n)=>{chrome.vpnProvider.notifyConnectionStateChanged(e,()=>{chrome.runtime.lastError?n(Error(chrome.runtime.lastError.message)):t()})}),this.formatSuccess(`VPN connection state notified successfully`,{state:e})}catch(e){return this.formatError(e)}})}registerSendPacket(){this.server.registerTool(`extension_tool_send_vpn_packet`,{description:`Send an IP packet through the tunnel created for the VPN session. This will succeed only when the VPN session is owned by the extension`,inputSchema:{data:e.string().describe(`The IP packet data as a base64 encoded string`)}},async({data:e})=>{try{let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);let r=n.buffer;return await new Promise((e,t)=>{chrome.vpnProvider.sendPacket(r,()=>{chrome.runtime.lastError?t(Error(chrome.runtime.lastError.message)):e()})}),this.formatSuccess(`VPN packet sent successfully`,{packetSize:r.byteLength})}catch(e){return this.formatError(e)}})}},Ne=class extends n{apiName=`Wallpaper`;constructor(e,t={}){super(e,t)}checkAvailability(){try{return chrome.wallpaper?typeof chrome.wallpaper.setWallpaper==`function`?{available:!0,message:`Wallpaper API is fully available`}:{available:!1,message:`chrome.wallpaper.setWallpaper is not available`,details:`The wallpaper API appears to be partially available. Check manifest permissions and ensure you are running on ChromeOS.`}:{available:!1,message:`chrome.wallpaper API is not defined`,details:`This extension needs the "wallpaper" permission in its manifest.json and only works on ChromeOS`}}catch(e){return{available:!1,message:`Failed to access chrome.wallpaper API`,details:e instanceof Error?e.message:`Unknown error occurred`}}}registerTools(){this.shouldRegisterTool(`setWallpaper`)&&this.registerSetWallpaper()}registerSetWallpaper(){this.server.registerTool(`extension_tool_set_wallpaper`,{description:`Set the ChromeOS wallpaper to an image from a URL or data`,inputSchema:{filename:e.string().describe(`The file name of the saved wallpaper`),layout:e.enum([`STRETCH`,`CENTER`,`CENTER_CROPPED`]).describe(`The wallpaper layout`),url:e.string().optional().describe(`The URL of the wallpaper to be set (can be relative)`),data:e.string().optional().describe(`Base64 encoded jpeg or png wallpaper image data`),thumbnail:e.boolean().optional().describe(`True if a 128x60 thumbnail should be generated`)}},async({filename:e,layout:t,url:n,data:r,thumbnail:i})=>{try{if(!n&&!r)return this.formatError(`Either url or data must be specified to set wallpaper`);if(n&&r)return this.formatError(`Cannot specify both url and data. Choose one method to set wallpaper`);let a={filename:e,layout:t};if(n&&(a.url=n),r)try{let e=atob(r),t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);a.data=t.buffer}catch{return this.formatError(`Invalid base64 data provided`)}i!==void 0&&(a.thumbnail=i);let o=await new Promise((e,t)=>{chrome.wallpaper.setWallpaper(a,n=>{chrome.runtime.lastError?t(Error(chrome.runtime.lastError.message)):e(n)})}),s={filename:e,layout:t,success:!0};if(n&&(s.url=n),o){let e=new Uint8Array(o),t=``;for(let n=0;n<e.byteLength;n++)t+=String.fromCharCode(e[n]);s.thumbnail=btoa(t),s.thumbnailSize=o.byteLength}return this.formatSuccess(`Wallpaper set successfully`,s)}catch(e){return this.formatError(e)}})}},Pe=class extends n{apiName=`WebAuthenticationProxy`;constructor(e,t={}){super(e,t)}checkAvailability(){try{return chrome.webAuthenticationProxy?typeof chrome.webAuthenticationProxy.attach==`function`?{available:!0,message:`WebAuthenticationProxy API is fully available`}:{available:!1,message:`chrome.webAuthenticationProxy.attach is not available`,details:`The webAuthenticationProxy API appears to be partially available. Check manifest permissions.`}:{available:!1,message:`chrome.webAuthenticationProxy API is not defined`,details:`This extension needs the "webAuthenticationProxy" permission in its manifest.json`}}catch(e){return{available:!1,message:`Failed to access chrome.webAuthenticationProxy API`,details:e instanceof Error?e.message:`Unknown error occurred`}}}registerTools(){this.shouldRegisterTool(`attach`)&&this.registerAttach(),this.shouldRegisterTool(`detach`)&&this.registerDetach(),this.shouldRegisterTool(`completeCreateRequest`)&&this.registerCompleteCreateRequest(),this.shouldRegisterTool(`completeGetRequest`)&&this.registerCompleteGetRequest(),this.shouldRegisterTool(`completeIsUvpaaRequest`)&&this.registerCompleteIsUvpaaRequest(),this.shouldRegisterTool(`onCreateRequest`)&&this.registerOnCreateRequest(),this.shouldRegisterTool(`onGetRequest`)&&this.registerOnGetRequest(),this.shouldRegisterTool(`onIsUvpaaRequest`)&&this.registerOnIsUvpaaRequest(),this.shouldRegisterTool(`onRemoteSessionStateChange`)&&this.registerOnRemoteSessionStateChange(),this.shouldRegisterTool(`onRequestCanceled`)&&this.registerOnRequestCanceled()}registerAttach(){this.server.registerTool(`extension_tool_attach_web_authentication_proxy`,{description:`Makes this extension the active Web Authentication API request proxy`,inputSchema:{}},async()=>{try{let e=await new Promise((e,t)=>{chrome.webAuthenticationProxy.attach(n=>{chrome.runtime.lastError?t(Error(chrome.runtime.lastError.message)):e(n)})});return e?this.formatError(e):this.formatSuccess(`Successfully attached as Web Authentication API request proxy`)}catch(e){return this.formatError(e)}})}registerDetach(){this.server.registerTool(`extension_tool_detach_web_authentication_proxy`,{description:`Removes this extension from being the active Web Authentication API request proxy`,inputSchema:{}},async()=>{try{let e=await new Promise((e,t)=>{chrome.webAuthenticationProxy.detach(n=>{chrome.runtime.lastError?t(Error(chrome.runtime.lastError.message)):e(n)})});return e?this.formatError(e):this.formatSuccess(`Successfully detached from Web Authentication API request proxy`)}catch(e){return this.formatError(e)}})}registerCompleteCreateRequest(){this.server.registerTool(`extension_tool_complete_create_request`,{description:`Reports the result of a navigator.credentials.create() call`,inputSchema:{requestId:e.number().describe(`The requestId of the CreateRequest`),responseJson:e.string().optional().describe(`The PublicKeyCredential serialized as JSON`),error:e.object({name:e.string().describe(`The DOMException name`),message:e.string().describe(`The DOMException message`)}).optional().describe(`The DOMException yielded by the remote request, if any`)}},async({requestId:e,responseJson:t,error:n})=>{try{let r={requestId:e};return t!==void 0&&(r.responseJson=t),n!==void 0&&(r.error=n),await new Promise((e,t)=>{chrome.webAuthenticationProxy.completeCreateRequest(r,()=>{chrome.runtime.lastError?t(Error(chrome.runtime.lastError.message)):e()})}),this.formatSuccess(`Create request completed successfully`,{requestId:e})}catch(e){return this.formatError(e)}})}registerCompleteGetRequest(){this.server.registerTool(`extension_tool_complete_get_request`,{description:`Reports the result of a navigator.credentials.get() call`,inputSchema:{requestId:e.number().describe(`The requestId of the GetRequest`),responseJson:e.string().optional().describe(`The PublicKeyCredential serialized as JSON`),error:e.object({name:e.string().describe(`The DOMException name`),message:e.string().describe(`The DOMException message`)}).optional().describe(`The DOMException yielded by the remote request, if any`)}},async({requestId:e,responseJson:t,error:n})=>{try{let r={requestId:e};return t!==void 0&&(r.responseJson=t),n!==void 0&&(r.error=n),await new Promise((e,t)=>{chrome.webAuthenticationProxy.completeGetRequest(r,()=>{chrome.runtime.lastError?t(Error(chrome.runtime.lastError.message)):e()})}),this.formatSuccess(`Get request completed successfully`,{requestId:e})}catch(e){return this.formatError(e)}})}registerCompleteIsUvpaaRequest(){this.server.registerTool(`extension_tool_complete_is_uvpaa_request`,{description:`Reports the result of a PublicKeyCredential.isUserVerifyingPlatformAuthenticator() call`,inputSchema:{requestId:e.number().describe(`The requestId of the IsUvpaaRequest`),isUvpaa:e.boolean().describe(`Whether user verifying platform authenticator is available`)}},async({requestId:e,isUvpaa:t})=>{try{let n={requestId:e,isUvpaa:t};return await new Promise((e,t)=>{chrome.webAuthenticationProxy.completeIsUvpaaRequest(n,()=>{chrome.runtime.lastError?t(Error(chrome.runtime.lastError.message)):e()})}),this.formatSuccess(`IsUvpaa request completed successfully`,{requestId:e,isUvpaa:t})}catch(e){return this.formatError(e)}})}registerOnCreateRequest(){this.server.registerTool(`extension_tool_listen_create_requests`,{description:`Start listening for WebAuthn navigator.credentials.create() calls`,inputSchema:{}},async()=>{try{return chrome.webAuthenticationProxy.onCreateRequest.addListener(e=>{console.log(`WebAuthn create request received:`,{requestId:e.requestId,requestDetailsJson:e.requestDetailsJson})}),this.formatSuccess(`Started listening for WebAuthn create requests`)}catch(e){return this.formatError(e)}})}registerOnGetRequest(){this.server.registerTool(`extension_tool_listen_get_requests`,{description:`Start listening for WebAuthn navigator.credentials.get() calls`,inputSchema:{}},async()=>{try{return chrome.webAuthenticationProxy.onGetRequest.addListener(e=>{console.log(`WebAuthn get request received:`,{requestId:e.requestId,requestDetailsJson:e.requestDetailsJson})}),this.formatSuccess(`Started listening for WebAuthn get requests`)}catch(e){return this.formatError(e)}})}registerOnIsUvpaaRequest(){this.server.registerTool(`extension_tool_listen_is_uvpaa_requests`,{description:`Start listening for PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable() calls`,inputSchema:{}},async()=>{try{return chrome.webAuthenticationProxy.onIsUvpaaRequest.addListener(e=>{console.log(`WebAuthn isUvpaa request received:`,{requestId:e.requestId})}),this.formatSuccess(`Started listening for WebAuthn isUvpaa requests`)}catch(e){return this.formatError(e)}})}registerOnRemoteSessionStateChange(){this.server.registerTool(`extension_tool_listen_remote_session_state_changes`,{description:`Start listening for remote session state changes`,inputSchema:{}},async()=>{try{return chrome.webAuthenticationProxy.onRemoteSessionStateChange.addListener(()=>{console.log(`Remote session state change detected`)}),this.formatSuccess(`Started listening for remote session state changes`)}catch(e){return this.formatError(e)}})}registerOnRequestCanceled(){this.server.registerTool(`extension_tool_listen_request_canceled`,{description:`Start listening for canceled WebAuthn requests`,inputSchema:{}},async()=>{try{return chrome.webAuthenticationProxy.onRequestCanceled.addListener(e=>{console.log(`WebAuthn request canceled:`,{requestId:e})}),this.formatSuccess(`Started listening for canceled WebAuthn requests`)}catch(e){return this.formatError(e)}})}},Fe=class extends n{apiName=`WebNavigation`;constructor(e,t={}){super(e,t)}checkAvailability(){try{return chrome.webNavigation?typeof chrome.webNavigation.getAllFrames==`function`?{available:!0,message:`WebNavigation API is fully available`}:{available:!1,message:`chrome.webNavigation.getAllFrames is not available`,details:`The webNavigation API appears to be partially available. Check manifest permissions.`}:{available:!1,message:`chrome.webNavigation API is not defined`,details:`This extension needs the "webNavigation" permission in its manifest.json`}}catch(e){return{available:!1,message:`Failed to access chrome.webNavigation API`,details:e instanceof Error?e.message:`Unknown error occurred`}}}registerTools(){this.shouldRegisterTool(`getAllFrames`)&&this.registerGetAllFrames(),this.shouldRegisterTool(`getFrame`)&&this.registerGetFrame(),this.shouldRegisterTool(`onBeforeNavigate`)&&this.registerOnBeforeNavigate(),this.shouldRegisterTool(`onCommitted`)&&this.registerOnCommitted(),this.shouldRegisterTool(`onCompleted`)&&this.registerOnCompleted(),this.shouldRegisterTool(`onCreatedNavigationTarget`)&&this.registerOnCreatedNavigationTarget(),this.shouldRegisterTool(`onDOMContentLoaded`)&&this.registerOnDOMContentLoaded(),this.shouldRegisterTool(`onErrorOccurred`)&&this.registerOnErrorOccurred(),this.shouldRegisterTool(`onHistoryStateUpdated`)&&this.registerOnHistoryStateUpdated(),this.shouldRegisterTool(`onReferenceFragmentUpdated`)&&this.registerOnReferenceFragmentUpdated(),this.shouldRegisterTool(`onTabReplaced`)&&this.registerOnTabReplaced()}registerGetAllFrames(){this.server.registerTool(`extension_tool_get_all_frames`,{description:`Retrieves information about all frames of a given tab`,inputSchema:{tabId:e.number().describe(`The ID of the tab to retrieve all frames from`)}},async({tabId:e})=>{try{let t=await new Promise((t,n)=>{chrome.webNavigation.getAllFrames({tabId:e},e=>{chrome.runtime.lastError?n(Error(chrome.runtime.lastError.message)):t(e??void 0)})});return t?this.formatJson({tabId:e,frameCount:t.length,frames:t.map(e=>({frameId:e.frameId,parentFrameId:e.parentFrameId,processId:e.processId,url:e.url,errorOccurred:e.errorOccurred,documentId:e.documentId,documentLifecycle:e.documentLifecycle,frameType:e.frameType,parentDocumentId:e.parentDocumentId}))}):this.formatError(`Invalid tab ID or no frames found`)}catch(e){return this.formatError(e)}})}registerGetFrame(){this.server.registerTool(`extension_tool_get_frame`,{description:`Retrieves information about the given frame. A frame refers to an iframe or frame of a web page`,inputSchema:{tabId:e.number().optional().describe(`The ID of the tab in which the frame is`),frameId:e.number().optional().describe(`The ID of the frame in the given tab`)}},async({tabId:e,frameId:t})=>{try{let n={};e!==void 0&&(n.tabId=e),t!==void 0&&(n.frameId=t);let r=await new Promise((e,t)=>{chrome.webNavigation.getFrame(n,n=>{chrome.runtime.lastError?t(Error(chrome.runtime.lastError.message)):e(n??void 0)})});return r?this.formatJson({parentFrameId:r.parentFrameId,url:r.url,errorOccurred:r.errorOccurred,documentId:r.documentId,documentLifecycle:r.documentLifecycle,frameType:r.frameType,parentDocumentId:r.parentDocumentId}):this.formatSuccess(`No frame found with the specified parameters`)}catch(e){return this.formatError(e)}})}registerOnBeforeNavigate(){this.server.registerTool(`extension_tool_on_before_navigate`,{description:`Sets up a listener for navigation events that are about to occur. Returns immediately after setting up the listener`,inputSchema:{urlFilters:e.array(e.string()).optional().describe(`URL patterns to filter navigation events. If not provided, listens to all navigations`)}},async({urlFilters:e})=>{try{let t=e?{url:e.map(e=>({urlMatches:e}))}:void 0;return chrome.webNavigation.onBeforeNavigate.addListener(e=>{console.log(`Navigation about to occur:`,{tabId:e.tabId,frameId:e.frameId,parentFrameId:e.parentFrameId,url:e.url,timeStamp:e.timeStamp,processId:e.processId,documentLifecycle:e.documentLifecycle,frameType:e.frameType,parentDocumentId:e.parentDocumentId})},t),this.formatSuccess(`onBeforeNavigate listener registered successfully`,{hasFilters:!!t,filterCount:e?.length||0})}catch(e){return this.formatError(e)}})}registerOnCommitted(){this.server.registerTool(`extension_tool_on_committed`,{description:`Sets up a listener for navigation committed events. Fired when a navigation is committed`,inputSchema:{urlFilters:e.array(e.string()).optional().describe(`URL patterns to filter navigation events. If not provided, listens to all navigations`)}},async({urlFilters:e})=>{try{let t=e?{url:e.map(e=>({urlMatches:e}))}:void 0;return chrome.webNavigation.onCommitted.addListener(e=>{console.log(`Navigation committed:`,{tabId:e.tabId,frameId:e.frameId,url:e.url,timeStamp:e.timeStamp,processId:e.processId,transitionType:e.transitionType,transitionQualifiers:e.transitionQualifiers,documentId:e.documentId,documentLifecycle:e.documentLifecycle,frameType:e.frameType,parentDocumentId:e.parentDocumentId})},t),this.formatSuccess(`onCommitted listener registered successfully`,{hasFilters:!!t,filterCount:e?.length||0})}catch(e){return this.formatError(e)}})}registerOnCompleted(){this.server.registerTool(`extension_tool_on_completed`,{description:`Sets up a listener for navigation completed events. Fired when a document and its resources are completely loaded`,inputSchema:{urlFilters:e.array(e.string()).optional().describe(`URL patterns to filter navigation events. If not provided, listens to all navigations`)}},async({urlFilters:e})=>{try{let t=e?{url:e.map(e=>({urlMatches:e}))}:void 0;return chrome.webNavigation.onCompleted.addListener(e=>{console.log(`Navigation completed:`,{tabId:e.tabId,frameId:e.frameId,url:e.url,timeStamp:e.timeStamp,processId:e.processId,documentId:e.documentId,documentLifecycle:e.documentLifecycle,frameType:e.frameType,parentDocumentId:e.parentDocumentId})},t),this.formatSuccess(`onCompleted listener registered successfully`,{hasFilters:!!t,filterCount:e?.length||0})}catch(e){return this.formatError(e)}})}registerOnCreatedNavigationTarget(){this.server.registerTool(`extension_tool_on_created_navigation_target`,{description:`Sets up a listener for new navigation target creation events. Fired when a new window or tab is created to host a navigation`,inputSchema:{urlFilters:e.array(e.string()).optional().describe(`URL patterns to filter navigation events. If not provided, listens to all navigations`)}},async({urlFilters:e})=>{try{let t=e?{url:e.map(e=>({urlMatches:e}))}:void 0;return chrome.webNavigation.onCreatedNavigationTarget.addListener(e=>{console.log(`Navigation target created:`,{sourceTabId:e.sourceTabId,sourceFrameId:e.sourceFrameId,sourceProcessId:e.sourceProcessId,tabId:e.tabId,url:e.url,timeStamp:e.timeStamp})},t),this.formatSuccess(`onCreatedNavigationTarget listener registered successfully`,{hasFilters:!!t,filterCount:e?.length||0})}catch(e){return this.formatError(e)}})}registerOnDOMContentLoaded(){this.server.registerTool(`extension_tool_on_dom_content_loaded`,{description:`Sets up a listener for DOM content loaded events. Fired when the page DOM is fully constructed`,inputSchema:{urlFilters:e.array(e.string()).optional().describe(`URL patterns to filter navigation events. If not provided, listens to all navigations`)}},async({urlFilters:e})=>{try{let t=e?{url:e.map(e=>({urlMatches:e}))}:void 0;return chrome.webNavigation.onDOMContentLoaded.addListener(e=>{console.log(`DOM content loaded:`,{tabId:e.tabId,frameId:e.frameId,url:e.url,timeStamp:e.timeStamp,processId:e.processId,documentId:e.documentId,documentLifecycle:e.documentLifecycle,frameType:e.frameType,parentDocumentId:e.parentDocumentId})},t),this.formatSuccess(`onDOMContentLoaded listener registered successfully`,{hasFilters:!!t,filterCount:e?.length||0})}catch(e){return this.formatError(e)}})}registerOnErrorOccurred(){this.server.registerTool(`extension_tool_on_error_occurred`,{description:`Sets up a listener for navigation error events. Fired when an error occurs and navigation is aborted`,inputSchema:{urlFilters:e.array(e.string()).optional().describe(`URL patterns to filter navigation events. If not provided, listens to all navigations`)}},async({urlFilters:e})=>{try{let t=e?{url:e.map(e=>({urlMatches:e}))}:void 0;return chrome.webNavigation.onErrorOccurred.addListener(e=>{console.log(`Navigation error occurred:`,{tabId:e.tabId,frameId:e.frameId,url:e.url,error:e.error,timeStamp:e.timeStamp,processId:e.processId,documentId:e.documentId,documentLifecycle:e.documentLifecycle,frameType:e.frameType,parentDocumentId:e.parentDocumentId})},t),this.formatSuccess(`onErrorOccurred listener registered successfully`,{hasFilters:!!t,filterCount:e?.length||0})}catch(e){return this.formatError(e)}})}registerOnHistoryStateUpdated(){this.server.registerTool(`extension_tool_on_history_state_updated`,{description:`Sets up a listener for history state update events. Fired when the frame history was updated to a new URL`,inputSchema:{urlFilters:e.array(e.string()).optional().describe(`URL patterns to filter navigation events. If not provided, listens to all navigations`)}},async({urlFilters:e})=>{try{let t=e?{url:e.map(e=>({urlMatches:e}))}:void 0;return chrome.webNavigation.onHistoryStateUpdated.addListener(e=>{console.log(`History state updated:`,{tabId:e.tabId,frameId:e.frameId,url:e.url,timeStamp:e.timeStamp,processId:e.processId,transitionType:e.transitionType,transitionQualifiers:e.transitionQualifiers,documentId:e.documentId,documentLifecycle:e.documentLifecycle,frameType:e.frameType,parentDocumentId:e.parentDocumentId})},t),this.formatSuccess(`onHistoryStateUpdated listener registered successfully`,{hasFilters:!!t,filterCount:e?.length||0})}catch(e){return this.formatError(e)}})}registerOnReferenceFragmentUpdated(){this.server.registerTool(`extension_tool_on_reference_fragment_updated`,{description:`Sets up a listener for reference fragment update events. Fired when the reference fragment of a frame was updated`,inputSchema:{urlFilters:e.array(e.string()).optional().describe(`URL patterns to filter navigation events. If not provided, listens to all navigations`)}},async({urlFilters:e})=>{try{let t=e?{url:e.map(e=>({urlMatches:e}))}:void 0;return chrome.webNavigation.onReferenceFragmentUpdated.addListener(e=>{console.log(`Reference fragment updated:`,{tabId:e.tabId,frameId:e.frameId,url:e.url,timeStamp:e.timeStamp,processId:e.processId,transitionType:e.transitionType,transitionQualifiers:e.transitionQualifiers,documentId:e.documentId,documentLifecycle:e.documentLifecycle,frameType:e.frameType,parentDocumentId:e.parentDocumentId})},t),this.formatSuccess(`onReferenceFragmentUpdated listener registered successfully`,{hasFilters:!!t,filterCount:e?.length||0})}catch(e){return this.formatError(e)}})}registerOnTabReplaced(){this.server.registerTool(`extension_tool_on_tab_replaced`,{description:`Sets up a listener for tab replacement events. Fired when the contents of a tab is replaced by a different tab`,inputSchema:{}},async()=>{try{return chrome.webNavigation.onTabReplaced.addListener(e=>{console.log(`Tab replaced:`,{replacedTabId:e.replacedTabId,tabId:e.tabId,timeStamp:e.timeStamp})}),this.formatSuccess(`onTabReplaced listener registered successfully`)}catch(e){return this.formatError(e)}})}},G=class extends n{apiName=`WebRequest`;constructor(e,t={}){super(e,t)}checkAvailability(){try{return chrome.webRequest?typeof chrome.webRequest.handlerBehaviorChanged==`function`?chrome.webRequest.onBeforeRequest?{available:!0,message:`WebRequest API is fully available`}:{available:!1,message:`chrome.webRequest events are not available`,details:`WebRequest events are required for this API to function properly.`}:{available:!1,message:`chrome.webRequest.handlerBehaviorChanged is not available`,details:`The webRequest API appears to be partially available. Check manifest permissions.`}:{available:!1,message:`chrome.webRequest API is not defined`,details:`This extension needs the "webRequest" permission in its manifest.json`}}catch(e){return{available:!1,message:`Failed to access chrome.webRequest API`,details:e instanceof Error?e.message:`Unknown error occurred`}}}registerTools(){this.shouldRegisterTool(`addListener`)&&this.registerAddListener(),this.shouldRegisterTool(`removeListener`)&&this.registerRemoveListener(),this.shouldRegisterTool(`hasListener`)&&this.registerHasListener(),this.shouldRegisterTool(`handlerBehaviorChanged`)&&this.registerHandlerBehaviorChanged(),this.shouldRegisterTool(`getActiveListeners`)&&this.registerGetActiveListeners()}registerAddListener(){this.server.registerTool(`extension_tool_add_webrequest_listener`,{description:`Add a listener to a webRequest event to monitor or modify network requests`,inputSchema:{event:e.enum([`onBeforeRequest`,`onBeforeSendHeaders`,`onSendHeaders`,`onHeadersReceived`,`onAuthRequired`,`onBeforeRedirect`,`onResponseStarted`,`onCompleted`,`onErrorOccurred`]).describe(`The webRequest event to listen to`),urls:e.array(e.string()).describe(`Array of URL patterns to match (e.g., ["<all_urls>", "*://example.com/*"])`),types:e.array(e.enum([`main_frame`,`sub_frame`,`stylesheet`,`script`,`image`,`font`,`object`,`xmlhttprequest`,`ping`,`csp_report`,`media`,`websocket`,`webbundle`,`other`])).optional().describe(`Array of resource types to filter`),tabId:e.number().optional().describe(`Specific tab ID to monitor`),windowId:e.number().optional().describe(`Specific window ID to monitor`),extraInfoSpec:e.array(e.enum([`blocking`,`requestHeaders`,`responseHeaders`,`requestBody`,`extraHeaders`,`asyncBlocking`])).optional().describe(`Additional information to include in the event`),blocking:e.boolean().optional().describe(`Whether to block requests for modification (requires webRequestBlocking permission)`)}},async({event:e,urls:t,types:n,tabId:r,windowId:i,extraInfoSpec:a,blocking:o})=>{try{let s={urls:t};n&&(s.types=n),r!==void 0&&(s.tabId=r),i!==void 0&&(s.windowId=i);let c=a||[];o&&!c.includes(`blocking`)&&c.push(`blocking`);let l=t=>(console.log(`WebRequest ${e}:`,{requestId:t.requestId,url:t.url,method:t.method,type:t.type,tabId:t.tabId,timeStamp:t.timeStamp}),o?{}:t),u=chrome.webRequest[e];return u&&typeof u.addListener==`function`?(c.length>0?u.addListener(l,s,c):u.addListener(l,s),this.formatSuccess(`WebRequest listener added successfully`,{event:e,filter:s,extraInfoSpec:c,blocking:o||!1})):this.formatError(`Invalid webRequest event: ${e}`)}catch(e){return this.formatError(e)}})}registerRemoveListener(){this.server.registerTool(`extension_tool_remove_webrequest_listener`,{description:`Remove a webRequest event listener`,inputSchema:{event:e.enum([`onBeforeRequest`,`onBeforeSendHeaders`,`onSendHeaders`,`onHeadersReceived`,`onAuthRequired`,`onBeforeRedirect`,`onResponseStarted`,`onCompleted`,`onErrorOccurred`]).describe(`The webRequest event to remove listener from`)}},async({event:e})=>{try{let t=chrome.webRequest[e];return t&&typeof t.removeListener==`function`?this.formatSuccess(`WebRequest listener removal attempted`,{event:e,note:`All listeners for this event type have been targeted for removal`}):this.formatError(`Invalid webRequest event: ${e}`)}catch(e){return this.formatError(e)}})}registerHasListener(){this.server.registerTool(`extension_tool_has_webrequest_listener`,{description:`Check if a webRequest event has any listeners`,inputSchema:{event:e.enum([`onBeforeRequest`,`onBeforeSendHeaders`,`onSendHeaders`,`onHeadersReceived`,`onAuthRequired`,`onBeforeRedirect`,`onResponseStarted`,`onCompleted`,`onErrorOccurred`]).describe(`The webRequest event to check`)}},async({event:e})=>{try{let t=chrome.webRequest[e];if(t&&typeof t.hasListener==`function`){let n=t.hasListener();return this.formatJson({event:e,hasListener:n})}return this.formatError(`Invalid webRequest event: ${e}`)}catch(e){return this.formatError(e)}})}registerHandlerBehaviorChanged(){this.server.registerTool(`extension_tool_handler_behavior_changed`,{description:`Notify that webRequest handler behavior has changed to prevent incorrect caching`,inputSchema:{}},async()=>{try{return await new Promise((e,t)=>{chrome.webRequest.handlerBehaviorChanged(()=>{chrome.runtime.lastError?t(Error(chrome.runtime.lastError.message)):e()})}),this.formatSuccess(`Handler behavior change notification sent`,{note:`This flushes the in-memory cache to ensure behavior changes take effect`,warning:`This is an expensive operation and should not be called frequently`})}catch(e){return this.formatError(e)}})}registerGetActiveListeners(){this.server.registerTool(`extension_tool_get_active_webrequest_listeners`,{description:`Get information about currently active webRequest listeners`,inputSchema:{}},async()=>{try{let e=[`onBeforeRequest`,`onBeforeSendHeaders`,`onSendHeaders`,`onHeadersReceived`,`onAuthRequired`,`onBeforeRedirect`,`onResponseStarted`,`onCompleted`,`onErrorOccurred`],t=e.map(e=>{let t=chrome.webRequest[e];return{event:e,hasListener:t&&typeof t.hasListener==`function`?t.hasListener():!1}}),n=t.filter(e=>e.hasListener).length;return this.formatJson({totalEvents:e.length,activeListeners:n,listeners:t,maxHandlerCalls:chrome.webRequest.MAX_HANDLER_BEHAVIOR_CHANGED_CALLS_PER_10_MINUTES||20})}catch(e){return this.formatError(e)}})}};const K=[`create`,`get`,`getAll`,`getCurrent`,`getLastFocused`,`remove`,`update`],q=e.enum(K);var Ie=class extends n{apiName=`Windows`;constructor(e,t={}){super(e,t)}checkAvailability(){try{return chrome.windows?typeof chrome.windows.getAll==`function`?(chrome.windows.getAll(e=>{if(chrome.runtime.lastError)throw Error(chrome.runtime.lastError.message)}),{available:!0,message:`Windows API is fully available`}):{available:!1,message:`chrome.windows.getAll is not available`,details:`The windows API appears to be partially available. Check manifest permissions.`}:{available:!1,message:`chrome.windows API is not defined`,details:`This extension needs the "windows" permission in its manifest.json`}}catch(e){return{available:!1,message:`Failed to access chrome.windows API`,details:e instanceof Error?e.message:`Unknown error occurred`}}}registerTools(){this.server.registerTool(`extension_tool_window_operations`,{description:`Perform operations on browser windows`,inputSchema:{action:q,params:e.record(e.string(),e.any()).optional().describe(`Parameters for the chosen action`)}},async({action:e,params:t={}})=>{try{if(!this.shouldRegisterTool(e))return this.formatError(Error(`Action "${e}" is not supported`));switch(e){case`create`:return await this.handleCreate(t);case`get`:return await this.handleGet(t);case`getAll`:return await this.handleGetAll(t);case`getCurrent`:return await this.handleGetCurrent(t);case`getLastFocused`:return await this.handleGetLastFocused(t);case`remove`:return await this.handleRemove(t);case`update`:return await this.handleUpdate(t);default:return this.formatError(`Unknown action: ${String(e)}`)}}catch(e){return this.formatError(e)}}),this.server.registerTool(`extension_tool_window_parameters_description`,{description:`Get the parameters for extension_tool_window_operations tool and the description for the associated action, this tool should be used first before extension_tool_window_operations`,inputSchema:{action:q}},async({action:t})=>{try{let n=(t,n)=>e.toJSONSchema(t),r={tool:`extension_tool_window_operations`,action:t,note:`Use the description to double check if the correct action is chosen. Use this JSON Schema for the params field when calling the tool. The top-level tool input is { action, params }.`};switch(t){case`create`:{let e={params:n(this.createSchema,`CreateWindowSchema`),description:`Create a new browser window with optional sizing, position, or default URL`};return this.formatJson({...r,...e})}case`get`:{let e={params:n(this.getSchema,`GetWindowSchema`),description:`Get details about a specific window`};return this.formatJson({...r,...e})}case`getAll`:{let e={params:n(this.getAllSchema,`GetAllWindowsSchema`),description:`Get all browser windows`};return this.formatJson({...r,...e})}case`getCurrent`:{let e={params:n(this.getCurrentSchema,`GetCurrentWindowSchema`),description:`Get the current window`};return this.formatJson({...r,...e})}case`getLastFocused`:{let e={params:n(this.getLastFocusedSchema,`GetLastFocusedWindowSchema`),description:`Get the window that was most recently focused`};return this.formatJson({...r,...e})}case`remove`:{let e={params:n(this.removeSchema,`RemoveWindowSchema`),description:`Remove (close) a window and all the tabs inside it`};return this.formatJson({...r,...e})}case`update`:{let e={params:n(this.updateSchema,`UpdateWindowSchema`),description:`Update the properties of a window`};return this.formatJson({...r,...e})}default:return this.formatError(`Unknown action: ${String(t)}`)}}catch(e){return this.formatError(e)}})}createSchema=e.object({url:e.union([e.string(),e.array(e.string())]).optional().describe(`A URL or array of URLs to open as tabs in the window`),focused:e.boolean().optional().describe(`If true, opens an active window. If false, opens an inactive window`),height:e.number().optional().describe(`The height in pixels of the new window, including the frame`),incognito:e.boolean().optional().describe(`Whether the new window should be an incognito window`),left:e.number().optional().describe(`The number of pixels to position the new window from the left edge of the screen`),setSelfAsOpener:e.boolean().optional().describe(`If true, the newly-created window's 'window.opener' is set to the caller`),state:e.enum([`normal`,`minimized`,`maximized`,`fullscreen`,`locked-fullscreen`]).optional().describe(`The initial state of the window`),tabId:e.number().optional().describe(`The ID of the tab to add to the new window`),top:e.number().optional().describe(`The number of pixels to position the new window from the top edge of the screen`),type:e.enum([`normal`,`popup`,`panel`]).optional().describe(`Specifies what type of browser window to create`),width:e.number().optional().describe(`The width in pixels of the new window, including the frame`)});getSchema=e.object({windowId:e.number().describe(`The ID of the window to get`),populate:e.boolean().optional().describe(`If true, the window object will include a tabs property with tab details`),windowTypes:e.array(e.enum([`normal`,`popup`,`panel`,`app`,`devtools`])).optional().describe(`Filter the window based on its type`)});getAllSchema=e.object({populate:e.boolean().optional().describe(`If true, each window object will include a tabs property with tab details`),windowTypes:e.array(e.enum([`normal`,`popup`,`panel`,`app`,`devtools`])).optional().describe(`Filter windows based on their type`)});getCurrentSchema=e.object({populate:e.boolean().optional().describe(`If true, the window object will include a tabs property with tab details`),windowTypes:e.array(e.enum([`normal`,`popup`,`panel`,`app`,`devtools`])).optional().describe(`Filter the window based on its type`)});getLastFocusedSchema=e.object({populate:e.boolean().optional().describe(`If true, the window object will include a tabs property with tab details`),windowTypes:e.array(e.enum([`normal`,`popup`,`panel`,`app`,`devtools`])).optional().describe(`Filter the window based on its type`)});removeSchema=e.object({windowId:e.number().describe(`The ID of the window to remove`)});updateSchema=e.object({windowId:e.number().describe(`The ID of the window to update`),drawAttention:e.boolean().optional().describe(`If true, causes the window to be displayed in a manner that draws the user's attention`),focused:e.boolean().optional().describe(`If true, brings the window to the front`),height:e.number().optional().describe(`The height to resize the window to in pixels`),left:e.number().optional().describe(`The offset from the left edge of the screen to move the window to in pixels`),state:e.enum([`normal`,`minimized`,`maximized`,`fullscreen`,`locked-fullscreen`]).optional().describe(`The new state of the window`),top:e.number().optional().describe(`The offset from the top edge of the screen to move the window to in pixels`),width:e.number().optional().describe(`The width to resize the window to in pixels`)});async handleCreate(e){let{url:t,focused:n,height:r,incognito:i,left:a,setSelfAsOpener:o,state:s,tabId:c,top:l,type:u,width:d}=this.createSchema.parse(e),f={};t!==void 0&&(f.url=t),n!==void 0&&(f.focused=n),r!==void 0&&(f.height=r),i!==void 0&&(f.incognito=i),a!==void 0&&(f.left=a),o!==void 0&&(f.setSelfAsOpener=o),s!==void 0&&(f.state=s),c!==void 0&&(f.tabId=c),l!==void 0&&(f.top=l),u!==void 0&&(f.type=u),d!==void 0&&(f.width=d);let p=await new Promise((e,t)=>{chrome.windows.create(f,n=>{chrome.runtime.lastError?t(Error(chrome.runtime.lastError.message)):e(n)})});return this.formatJson({id:p.id,focused:p.focused,incognito:p.incognito,alwaysOnTop:p.alwaysOnTop,state:p.state,type:p.type,left:p.left,top:p.top,width:p.width,height:p.height,tabs:p.tabs?.map(e=>({id:e.id,url:e.url,title:e.title,active:e.active}))})}async handleGet(e){let{windowId:t,populate:n,windowTypes:r}=this.getSchema.parse(e),i={};n!==void 0&&(i.populate=n),r!==void 0&&(i.windowTypes=r);let a=await new Promise((e,n)=>{chrome.windows.get(t,i,t=>{chrome.runtime.lastError?n(Error(chrome.runtime.lastError.message)):e(t)})});return this.formatJson({id:a.id,focused:a.focused,incognito:a.incognito,alwaysOnTop:a.alwaysOnTop,state:a.state,type:a.type,left:a.left,top:a.top,width:a.width,height:a.height,sessionId:a.sessionId,tabs:a.tabs?.map(e=>({id:e.id,url:e.url,title:e.title,active:e.active,index:e.index}))})}async handleGetAll(e){let{populate:t,windowTypes:n}=this.getAllSchema.parse(e),r={};t!==void 0&&(r.populate=t),n!==void 0&&(r.windowTypes=n);let i=await new Promise((e,t)=>{chrome.windows.getAll(r,n=>{chrome.runtime.lastError?t(Error(chrome.runtime.lastError.message)):e(n)})});return this.formatJson({count:i.length,windows:i.map(e=>({id:e.id,focused:e.focused,incognito:e.incognito,alwaysOnTop:e.alwaysOnTop,state:e.state,type:e.type,left:e.left,top:e.top,width:e.width,height:e.height,sessionId:e.sessionId,tabs:e.tabs?.map(e=>({id:e.id,url:e.url,title:e.title,active:e.active,index:e.index}))}))})}async handleGetCurrent(e){let{populate:t,windowTypes:n}=this.getCurrentSchema.parse(e),r={};t!==void 0&&(r.populate=t),n!==void 0&&(r.windowTypes=n);let i=await new Promise((e,t)=>{chrome.windows.getCurrent(r,n=>{chrome.runtime.lastError?t(Error(chrome.runtime.lastError.message)):e(n)})});return this.formatJson({id:i.id,focused:i.focused,incognito:i.incognito,alwaysOnTop:i.alwaysOnTop,state:i.state,type:i.type,left:i.left,top:i.top,width:i.width,height:i.height,sessionId:i.sessionId,tabs:i.tabs?.map(e=>({id:e.id,url:e.url,title:e.title,active:e.active,index:e.index}))})}async handleGetLastFocused(e){let{populate:t,windowTypes:n}=this.getLastFocusedSchema.parse(e),r={};t!==void 0&&(r.populate=t),n!==void 0&&(r.windowTypes=n);let i=await new Promise((e,t)=>{chrome.windows.getLastFocused(r,n=>{chrome.runtime.lastError?t(Error(chrome.runtime.lastError.message)):e(n)})});return this.formatJson({id:i.id,focused:i.focused,incognito:i.incognito,alwaysOnTop:i.alwaysOnTop,state:i.state,type:i.type,left:i.left,top:i.top,width:i.width,height:i.height,sessionId:i.sessionId,tabs:i.tabs?.map(e=>({id:e.id,url:e.url,title:e.title,active:e.active,index:e.index}))})}async handleRemove(e){let{windowId:t}=this.removeSchema.parse(e);return await new Promise((e,n)=>{chrome.windows.remove(t,()=>{chrome.runtime.lastError?n(Error(chrome.runtime.lastError.message)):e()})}),this.formatSuccess(`Window removed successfully`,{windowId:t})}async handleUpdate(e){let{windowId:t,drawAttention:n,focused:r,height:i,left:a,state:o,top:s,width:c}=this.updateSchema.parse(e),l={};n!==void 0&&(l.drawAttention=n),r!==void 0&&(l.focused=r),i!==void 0&&(l.height=i),a!==void 0&&(l.left=a),o!==void 0&&(l.state=o),s!==void 0&&(l.top=s),c!==void 0&&(l.width=c);let u=await new Promise((e,n)=>{chrome.windows.update(t,l,t=>{chrome.runtime.lastError?n(Error(chrome.runtime.lastError.message)):e(t)})});return this.formatJson({id:u.id,focused:u.focused,incognito:u.incognito,alwaysOnTop:u.alwaysOnTop,state:u.state,type:u.type,left:u.left,top:u.top,width:u.width,height:u.height,sessionId:u.sessionId})}};let J=function(e){return e.ACCESSIBILITY_FEATURES=`accessibilityFeatures`,e.ACTION=`action`,e.ALARMS=`alarms`,e.AUDIO=`audio`,e.BOOKMARKS=`bookmarks`,e.BROWSING_DATA=`browsingData`,e.CERTIFICATE_PROVIDER=`certificateProvider`,e.COMMANDS=`commands`,e.CONTENT_SETTINGS=`contentSettings`,e.CONTEXT_MENUS=`contextMenus`,e.COOKIES=`cookies`,e.DEBUGGER=`debugger`,e.DECLARATIVE_CONTENT=`declarativeContent`,e.DECLARATIVE_NET_REQUEST=`declarativeNetRequest`,e.DESKTOP_CAPTURE=`desktopCapture`,e.DEVTOOLS_INSPECTED_WINDOW=`devtools.inspectedWindow`,e.DEVTOOLS_NETWORK=`devtools.network`,e.DEVTOOLS_PANELS=`devtools.panels`,e.DEVTOOLS_PERFORMANCE=`devtools.performance`,e.DEVTOOLS_RECORDER=`devtools.recorder`,e.DNS=`dns`,e.DOCUMENT_SCAN=`documentScan`,e.DOM=`dom`,e.DOWNLOADS=`downloads`,e.ENTERPRISE_DEVICE_ATTRIBUTES=`enterprise.deviceAttributes`,e.ENTERPRISE_HARDWARE_PLATFORM=`enterprise.hardwarePlatform`,e.ENTERPRISE_NETWORKING_ATTRIBUTES=`enterprise.networkingAttributes`,e.ENTERPRISE_PLATFORM_KEYS=`enterprise.platformKeys`,e.EVENTS=`events`,e.EXTENSION=`extension`,e.EXTENSION_TYPES=`extensionTypes`,e.FILE_BROWSER_HANDLER=`fileBrowserHandler`,e.FILE_SYSTEM_PROVIDER=`fileSystemProvider`,e.FONT_SETTINGS=`fontSettings`,e.GCM=`gcm`,e.HISTORY=`history`,e.I18N=`i18n`,e.IDENTITY=`identity`,e.IDLE=`idle`,e.INPUT_IME=`input.ime`,e.INSTANCE_ID=`instanceID`,e.LOGIN_STATE=`loginState`,e.MANAGEMENT=`management`,e.NOTIFICATIONS=`notifications`,e.OFFSCREEN=`offscreen`,e.OMNIBOX=`omnibox`,e.PAGE_CAPTURE=`pageCapture`,e.PERMISSIONS=`permissions`,e.PLATFORM_KEYS=`platformKeys`,e.POWER=`power`,e.PRINTER_PROVIDER=`printerProvider`,e.PRINTING=`printing`,e.PRINTING_METRICS=`printingMetrics`,e.PRIVACY=`privacy`,e.PROCESSES=`processes`,e.PROXY=`proxy`,e.READING_LIST=`readingList`,e.RUNTIME=`runtime`,e.SCRIPTING=`scripting`,e.SEARCH=`search`,e.SMART_DOM_READER=`smartDomReader`,e.SESSIONS=`sessions`,e.SIDE_PANEL=`sidePanel`,e.STORAGE=`storage`,e.SYSTEM_CPU=`system.cpu`,e.SYSTEM_DISPLAY=`system.display`,e.SYSTEM_MEMORY=`system.memory`,e.SYSTEM_STORAGE=`system.storage`,e.SYSTEM_LOG=`systemLog`,e.TAB_CAPTURE=`tabCapture`,e.TAB_GROUPS=`tabGroups`,e.TABS=`tabs`,e.TOP_SITES=`topSites`,e.TTS=`tts`,e.TTS_ENGINE=`ttsEngine`,e.TYPES=`types`,e.USER_SCRIPTS=`userScripts`,e.VPN_PROVIDER=`vpnProvider`,e.WALLPAPER=`wallpaper`,e.WEB_AUTHENTICATION_PROXY=`webAuthenticationProxy`,e.WEB_NAVIGATION=`webNavigation`,e.WEB_REQUEST=`webRequest`,e.WINDOWS=`windows`,e}({});const Y=e.enum([`all`,`chromeos`]),X=e.enum([`stable`,`dev`]),Z=e.enum([`background`,`content`,`devtools`,`all`]),Le=e.object({minChromeVersion:e.number().optional(),platform:Y,channel:X,manifestVersions:e.array(e.literal(2).or(e.literal(3))),requiresPolicy:e.boolean(),foregroundOnly:e.boolean(),contexts:e.array(Z),namespace:e.string()}),Q={[J.ACCESSIBILITY_FEATURES]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`accessibilityFeatures`},[J.ACTION]:{minChromeVersion:88,platform:`all`,channel:`stable`,manifestVersions:[3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`action`},[J.ALARMS]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`alarms`},[J.AUDIO]:{minChromeVersion:59,platform:`chromeos`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`audio`},[J.BOOKMARKS]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`,`content`],namespace:`bookmarks`},[J.BROWSING_DATA]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`browsingData`},[J.CERTIFICATE_PROVIDER]:{minChromeVersion:46,platform:`chromeos`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`certificateProvider`},[J.COMMANDS]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`commands`},[J.CONTENT_SETTINGS]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`contentSettings`},[J.CONTEXT_MENUS]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`contextMenus`},[J.COOKIES]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`,`content`],namespace:`cookies`},[J.DEBUGGER]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`debugger`},[J.DECLARATIVE_CONTENT]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`declarativeContent`},[J.DECLARATIVE_NET_REQUEST]:{minChromeVersion:84,platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`declarativeNetRequest`},[J.DESKTOP_CAPTURE]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`desktopCapture`},[J.DEVTOOLS_INSPECTED_WINDOW]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`devtools`],namespace:`devtools.inspectedWindow`},[J.DEVTOOLS_NETWORK]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`devtools`],namespace:`devtools.network`},[J.DEVTOOLS_PANELS]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`devtools`],namespace:`devtools.panels`},[J.DEVTOOLS_PERFORMANCE]:{minChromeVersion:129,platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`devtools`],namespace:`devtools.performance`},[J.DEVTOOLS_RECORDER]:{minChromeVersion:105,platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`devtools`],namespace:`devtools.recorder`},[J.DNS]:{platform:`all`,channel:`dev`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`dns`},[J.DOCUMENT_SCAN]:{minChromeVersion:44,platform:`chromeos`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`documentScan`},[J.DOM]:{minChromeVersion:88,platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`content`],namespace:`dom`},[J.DOWNLOADS]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`downloads`},[J.ENTERPRISE_DEVICE_ATTRIBUTES]:{minChromeVersion:46,platform:`chromeos`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!0,foregroundOnly:!1,contexts:[`background`],namespace:`enterprise.deviceAttributes`},[J.ENTERPRISE_HARDWARE_PLATFORM]:{minChromeVersion:71,platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!0,foregroundOnly:!1,contexts:[`background`],namespace:`enterprise.hardwarePlatform`},[J.ENTERPRISE_NETWORKING_ATTRIBUTES]:{minChromeVersion:85,platform:`chromeos`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!0,foregroundOnly:!1,contexts:[`background`],namespace:`enterprise.networkingAttributes`},[J.ENTERPRISE_PLATFORM_KEYS]:{platform:`chromeos`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!0,foregroundOnly:!1,contexts:[`background`],namespace:`enterprise.platformKeys`},[J.EVENTS]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`all`],namespace:`events`},[J.EXTENSION]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`all`],namespace:`extension`},[J.EXTENSION_TYPES]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`all`],namespace:`extensionTypes`},[J.FILE_BROWSER_HANDLER]:{platform:`chromeos`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!0,contexts:[`background`],namespace:`fileBrowserHandler`},[J.FILE_SYSTEM_PROVIDER]:{platform:`chromeos`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`fileSystemProvider`},[J.FONT_SETTINGS]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`fontSettings`},[J.GCM]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`gcm`},[J.HISTORY]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`,`content`],namespace:`history`},[J.I18N]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`all`],namespace:`i18n`},[J.IDENTITY]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`identity`},[J.IDLE]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`idle`},[J.INPUT_IME]:{platform:`chromeos`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`input.ime`},[J.INSTANCE_ID]:{minChromeVersion:44,platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`instanceID`},[J.LOGIN_STATE]:{minChromeVersion:78,platform:`chromeos`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`loginState`},[J.MANAGEMENT]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`management`},[J.NOTIFICATIONS]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`notifications`},[J.OFFSCREEN]:{minChromeVersion:109,platform:`all`,channel:`stable`,manifestVersions:[3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`offscreen`},[J.OMNIBOX]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`omnibox`},[J.PAGE_CAPTURE]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`pageCapture`},[J.PERMISSIONS]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`,`content`],namespace:`permissions`},[J.PLATFORM_KEYS]:{minChromeVersion:45,platform:`chromeos`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`platformKeys`},[J.POWER]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`power`},[J.PRINTER_PROVIDER]:{minChromeVersion:44,platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`printerProvider`},[J.PRINTING]:{minChromeVersion:81,platform:`chromeos`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`printing`},[J.PRINTING_METRICS]:{minChromeVersion:79,platform:`chromeos`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!0,foregroundOnly:!1,contexts:[`background`],namespace:`printingMetrics`},[J.PRIVACY]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`privacy`},[J.PROCESSES]:{platform:`all`,channel:`dev`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`processes`},[J.PROXY]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`proxy`},[J.READING_LIST]:{minChromeVersion:120,platform:`all`,channel:`stable`,manifestVersions:[3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`readingList`},[J.RUNTIME]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`all`],namespace:`runtime`},[J.SCRIPTING]:{minChromeVersion:88,platform:`all`,channel:`stable`,manifestVersions:[3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`scripting`},[J.SEARCH]:{minChromeVersion:87,platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`search`},[J.SMART_DOM_READER]:{minChromeVersion:88,platform:`all`,channel:`stable`,manifestVersions:[3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`smartDomReader`},[J.SESSIONS]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`sessions`},[J.SIDE_PANEL]:{minChromeVersion:114,platform:`all`,channel:`stable`,manifestVersions:[3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`sidePanel`},[J.STORAGE]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`all`],namespace:`storage`},[J.SYSTEM_CPU]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`system.cpu`},[J.SYSTEM_DISPLAY]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`system.display`},[J.SYSTEM_MEMORY]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`system.memory`},[J.SYSTEM_STORAGE]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`system.storage`},[J.SYSTEM_LOG]:{minChromeVersion:125,platform:`chromeos`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!0,foregroundOnly:!1,contexts:[`background`],namespace:`systemLog`},[J.TAB_CAPTURE]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`tabCapture`},[J.TAB_GROUPS]:{minChromeVersion:89,platform:`all`,channel:`stable`,manifestVersions:[3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`tabGroups`},[J.TABS]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`,`content`],namespace:`tabs`},[J.TOP_SITES]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`topSites`},[J.TTS]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`tts`},[J.TTS_ENGINE]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`ttsEngine`},[J.TYPES]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`all`],namespace:`types`},[J.USER_SCRIPTS]:{minChromeVersion:120,platform:`all`,channel:`stable`,manifestVersions:[3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`userScripts`},[J.VPN_PROVIDER]:{minChromeVersion:43,platform:`chromeos`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`vpnProvider`},[J.WALLPAPER]:{minChromeVersion:43,platform:`chromeos`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`wallpaper`},[J.WEB_AUTHENTICATION_PROXY]:{minChromeVersion:115,platform:`all`,channel:`stable`,manifestVersions:[3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`webAuthenticationProxy`},[J.WEB_NAVIGATION]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`webNavigation`},[J.WEB_REQUEST]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`webRequest`},[J.WINDOWS]:{platform:`all`,channel:`stable`,manifestVersions:[2,3],requiresPolicy:!1,foregroundOnly:!1,contexts:[`background`],namespace:`windows`}};function $(e,t,n,r=`all`,i){let a=Q[e];return!(!a.contexts.includes(t)&&!a.contexts.includes(`all`)||!a.manifestVersions.includes(n)||a.platform!==`all`&&a.platform!==r||a.minChromeVersion&&i&&i<a.minChromeVersion)}function Re(e){let t=Q[e].namespace.split(`.`),n=chrome;for(let e of t){let t=n?.[e];if(!t)return;n=t}return n}function ze(e,t,n=`all`,r){return Object.values(J).filter(i=>$(i,e,t,n,r))}var Be=class extends n{apiName=`DomExtraction`;bundleScript=t;userScriptsSupport=null;constructor(e,t={}){super(e,t)}getBundleScript(){return this.bundleScript}async resolveTabId(e){if(e!==void 0)return e;let[t]=await chrome.tabs.query({active:!0,currentWindow:!0});if(!t?.id)throw Error(`No active tab found`);return t.id}async canUseUserScripts(){if(!chrome.userScripts?.execute||typeof chrome.userScripts.getScripts!=`function`)return!1;if(this.userScriptsSupport!==null)return this.userScriptsSupport;try{await chrome.userScripts.getScripts(),this.userScriptsSupport=!0}catch{this.userScriptsSupport=!1}return this.userScriptsSupport}isExtractionError(e){return typeof e==`object`&&!!e&&`error`in e}async ensureUserScriptsEnabled(){if(!await this.canUseUserScripts())throw Error(`User Scripts API is not enabled. Please grant the "userScripts" permission and enable the Allow User Scripts toggle for this extension.`)}serializeArgs(e){return JSON.stringify(e)}async executeExtraction(e,t,n){let r=`
|
|
33
33
|
(() => {
|
|
34
34
|
// Inject the bundle
|
|
35
35
|
${this.getBundleScript()}
|