UNPKG

@mcp-b/extension-tools

Version:

Chrome Extension API tools for Model Context Protocol (MCP) - provides MCP-compatible wrappers for browser extension APIs

2 lines 456 kB
import {z}from'zod';var d=class{constructor(e,t={}){this.server=e;this.options=t;}shouldRegisterTool(e){return this.options[e]!==false}formatError(e){return {content:[{type:"text",text:`Error: ${e instanceof Error?e.message:String(e)}`}],isError:true}}formatSuccess(e,t){return {content:[{type:"text",text:t?`${e} ${JSON.stringify(t,null,2)}`:e}]}}formatJson(e){return {content:[{type:"text",text:JSON.stringify(e,null,2)}]}}register(){let e=this.checkAvailability();if(!e.available){console.warn(`\u2717 ${this.apiName} API not available: ${e.message}`),e.details&&console.warn(` Details: ${e.details}`);return}console.log(`\u2713 ${this.apiName} API available`),this.registerTools();}};var Ae=class extends d{apiName="Alarms";constructor(e,t={}){super(e,t);}checkAvailability(){try{return chrome.alarms?typeof chrome.alarms.getAll!="function"?{available:!1,message:"chrome.alarms.getAll is not available",details:"The alarms API appears to be partially available. Check manifest permissions."}:(chrome.alarms.getAll(e=>{if(chrome.runtime.lastError)throw new Error(chrome.runtime.lastError.message)}),{available:!0,message:"Alarms API is fully available"}):{available:!1,message:"chrome.alarms API is not defined",details:'This extension needs the "alarms" permission in its manifest.json'}}catch(e){return {available:false,message:"Failed to access chrome.alarms API",details:e instanceof Error?e.message:"Unknown error occurred"}}}registerTools(){this.shouldRegisterTool("createAlarm")&&this.registerCreateAlarm(),this.shouldRegisterTool("getAlarm")&&this.registerGetAlarm(),this.shouldRegisterTool("getAllAlarms")&&this.registerGetAllAlarms(),this.shouldRegisterTool("clearAlarm")&&this.registerClearAlarm(),this.shouldRegisterTool("clearAllAlarms")&&this.registerClearAllAlarms();}registerCreateAlarm(){this.server.registerTool("extension_tool_create_alarm",{description:"Create an alarm that fires at a specific time or periodically",inputSchema:{name:z.string().optional().describe("Optional name to identify this alarm"),delayInMinutes:z.number().min(.5).optional().describe("Time in minutes from now when the alarm should first fire. Minimum is 0.5 minutes (30 seconds)"),periodInMinutes:z.number().min(.5).optional().describe("If set, the alarm will repeat every periodInMinutes minutes after the initial event. Minimum is 0.5 minutes (30 seconds)"),when:z.number().optional().describe("Time at which the alarm should fire, in milliseconds past the epoch (e.g. Date.now() + n)")}},async({name:e,delayInMinutes:t,periodInMinutes:r,when:o})=>{try{if(t===void 0&&o===void 0)return this.formatError("Either delayInMinutes or when must be specified to create an alarm");let i={};t!==void 0&&(i.delayInMinutes=t),r!==void 0&&(i.periodInMinutes=r),o!==void 0&&(i.when=o),await new Promise((n,a)=>{e?chrome.alarms.create(e,i,()=>{chrome.runtime.lastError?a(new Error(chrome.runtime.lastError.message)):n();}):chrome.alarms.create(i,()=>{chrome.runtime.lastError?a(new Error(chrome.runtime.lastError.message)):n();});});let s=await new Promise((n,a)=>{chrome.alarms.get(e||"",c=>{chrome.runtime.lastError?a(new Error(chrome.runtime.lastError.message)):n(c);});});return this.formatSuccess("Alarm created successfully",{name:s?.name||e||"unnamed",scheduledTime:s?.scheduledTime,periodInMinutes:s?.periodInMinutes})}catch(i){return this.formatError(i)}});}registerGetAlarm(){this.server.registerTool("extension_tool_get_alarm",{description:"Get details about a specific alarm",inputSchema:{name:z.string().optional().describe("Name of the alarm to retrieve. If not specified, gets the default unnamed alarm")}},async({name:e})=>{try{let t=await new Promise((r,o)=>{e?chrome.alarms.get(e,i=>{chrome.runtime.lastError?o(new Error(chrome.runtime.lastError.message)):r(i);}):chrome.alarms.get(i=>{chrome.runtime.lastError?o(new Error(chrome.runtime.lastError.message)):r(i);});});return t?this.formatJson({name:t.name,scheduledTime:t.scheduledTime,scheduledTimeFormatted:new Date(t.scheduledTime).toISOString(),periodInMinutes:t.periodInMinutes}):this.formatSuccess("No alarm found",{name:e||"unnamed"})}catch(t){return this.formatError(t)}});}registerGetAllAlarms(){this.server.registerTool("extension_tool_get_all_alarms",{description:"Get all active alarms",inputSchema:{}},async()=>{try{let e=await new Promise((t,r)=>{chrome.alarms.getAll(o=>{chrome.runtime.lastError?r(new Error(chrome.runtime.lastError.message)):t(o);});});return this.formatJson({count:e.length,alarms:e.map(t=>({name:t.name,scheduledTime:t.scheduledTime,scheduledTimeFormatted:new Date(t.scheduledTime).toISOString(),periodInMinutes:t.periodInMinutes}))})}catch(e){return this.formatError(e)}});}registerClearAlarm(){this.server.registerTool("extension_tool_clear_alarm",{description:"Clear a specific alarm",inputSchema:{name:z.string().optional().describe("Name of the alarm to clear. If not specified, clears the default unnamed alarm")}},async({name:e})=>{try{return await new Promise((r,o)=>{e?chrome.alarms.clear(e,i=>{chrome.runtime.lastError?o(new Error(chrome.runtime.lastError.message)):r(i);}):chrome.alarms.clear(i=>{chrome.runtime.lastError?o(new Error(chrome.runtime.lastError.message)):r(i);});})?this.formatSuccess("Alarm cleared successfully",{name:e||"unnamed"}):this.formatSuccess("No alarm found to clear",{name:e||"unnamed"})}catch(t){return this.formatError(t)}});}registerClearAllAlarms(){this.server.registerTool("extension_tool_clear_all_alarms",{description:"Clear all alarms",inputSchema:{}},async()=>{try{let e=await new Promise((r,o)=>{chrome.alarms.getAll(i=>{chrome.runtime.lastError?o(new Error(chrome.runtime.lastError.message)):r(i);});});return await new Promise((r,o)=>{chrome.alarms.clearAll(i=>{chrome.runtime.lastError?o(new Error(chrome.runtime.lastError.message)):r(i);});})?this.formatSuccess("All alarms cleared successfully",{clearedCount:e.length,clearedAlarms:e.map(r=>r.name)}):this.formatSuccess("No alarms to clear")}catch(e){return this.formatError(e)}});}};var Ie=class extends d{apiName="Audio";constructor(e,t={}){super(e,t);}checkAvailability(){try{return chrome.audio?typeof chrome.audio.getDevices!="function"?{available:!1,message:"chrome.audio.getDevices is not available",details:"The audio API appears to be partially available. Check manifest permissions and ensure you are on ChromeOS."}:(chrome.audio.getDevices({},e=>{if(chrome.runtime.lastError)throw new Error(chrome.runtime.lastError.message)}),{available:!0,message:"Audio API is fully available"}):{available:!1,message:"chrome.audio API is not defined",details:'This extension needs the "audio" permission in its manifest.json and only works on ChromeOS'}}catch(e){return {available:false,message:"Failed to access chrome.audio API",details:e instanceof Error?e.message:"Unknown error occurred"}}}registerTools(){this.shouldRegisterTool("getDevices")&&this.registerGetDevices(),this.shouldRegisterTool("getMute")&&this.registerGetMute(),this.shouldRegisterTool("setActiveDevices")&&this.registerSetActiveDevices(),this.shouldRegisterTool("setMute")&&this.registerSetMute(),this.shouldRegisterTool("setProperties")&&this.registerSetProperties();}registerGetDevices(){this.server.registerTool("extension_tool_get_audio_devices",{description:"Get a list of audio devices filtered based on criteria",inputSchema:{isActive:z.boolean().optional().describe("If set, only audio devices whose active state matches this value will be returned"),streamTypes:z.array(z.enum(["INPUT","OUTPUT"])).optional().describe("If set, only audio devices whose stream type is included in this list will be returned")}},async({isActive:e,streamTypes:t})=>{try{let r={};e!==void 0&&(r.isActive=e),t!==void 0&&(r.streamTypes=t);let o=await new Promise((i,s)=>{chrome.audio.getDevices(r,n=>{chrome.runtime.lastError?s(new Error(chrome.runtime.lastError.message)):i(n);});});return this.formatJson({count:o.length,devices:o.map(i=>({id:i.id,deviceName:i.deviceName,deviceType:i.deviceType,displayName:i.displayName,isActive:i.isActive,level:i.level,stableDeviceId:i.stableDeviceId,streamType:i.streamType}))})}catch(r){return this.formatError(r)}});}registerGetMute(){this.server.registerTool("extension_tool_get_audio_mute",{description:"Get the system-wide mute state for the specified stream type",inputSchema:{streamType:z.enum(["INPUT","OUTPUT"]).describe("Stream type for which mute state should be fetched")}},async({streamType:e})=>{try{let t=await new Promise((r,o)=>{chrome.audio.getMute(e,i=>{chrome.runtime.lastError?o(new Error(chrome.runtime.lastError.message)):r(i);});});return this.formatJson({streamType:e,isMuted:t})}catch(t){return this.formatError(t)}});}registerSetActiveDevices(){this.server.registerTool("extension_tool_set_active_audio_devices",{description:"Set lists of active input and/or output devices",inputSchema:{input:z.array(z.string()).optional().describe("List of input device IDs that should be active. Leave unset to not affect input devices"),output:z.array(z.string()).optional().describe("List of output device IDs that should be active. Leave unset to not affect output devices")}},async({input:e,output:t})=>{try{if(e===void 0&&t===void 0)return this.formatError("At least one of input or output device lists must be specified");let r={};return e!==void 0&&(r.input=e),t!==void 0&&(r.output=t),await new Promise((o,i)=>{chrome.audio.setActiveDevices(r,()=>{chrome.runtime.lastError?i(new Error(chrome.runtime.lastError.message)):o();});}),this.formatSuccess("Active audio devices set successfully",{inputDevices:e,outputDevices:t})}catch(r){return this.formatError(r)}});}registerSetMute(){this.server.registerTool("extension_tool_set_audio_mute",{description:"Set mute state for a stream type. The mute state will apply to all audio devices with the specified audio stream type",inputSchema:{streamType:z.enum(["INPUT","OUTPUT"]).describe("Stream type for which mute state should be set"),isMuted:z.boolean().describe("New mute value")}},async({streamType:e,isMuted:t})=>{try{return await new Promise((r,o)=>{chrome.audio.setMute(e,t,()=>{chrome.runtime.lastError?o(new Error(chrome.runtime.lastError.message)):r();});}),this.formatSuccess("Audio mute state set successfully",{streamType:e,isMuted:t})}catch(r){return this.formatError(r)}});}registerSetProperties(){this.server.registerTool("extension_tool_set_audio_device_properties",{description:"Set the properties for the input or output device",inputSchema:{id:z.string().describe("ID of the audio device to modify"),level:z.number().min(0).max(100).optional().describe("The audio device's desired sound level. For input devices, represents gain. For output devices, represents volume")}},async({id:e,level:t})=>{try{let r={};return t!==void 0&&(r.level=t),await new Promise((o,i)=>{chrome.audio.setProperties(e,r,()=>{chrome.runtime.lastError?i(new Error(chrome.runtime.lastError.message)):o();});}),this.formatSuccess("Audio device properties set successfully",{deviceId:e,level:t})}catch(r){return this.formatError(r)}});}};var Re=class extends d{apiName="Bookmarks";constructor(e,t={}){super(e,t);}checkAvailability(){try{return chrome.bookmarks?typeof chrome.bookmarks.getTree!="function"?{available:!1,message:"chrome.bookmarks.getTree is not available",details:"The bookmarks API appears to be partially available. Check manifest permissions."}:(chrome.bookmarks.getTree(e=>{if(chrome.runtime.lastError)throw new Error(chrome.runtime.lastError.message)}),{available:!0,message:"Bookmarks API is fully available"}):{available:!1,message:"chrome.bookmarks API is not defined",details:'This extension needs the "bookmarks" permission in its manifest.json'}}catch(e){return {available:false,message:"Failed to access chrome.bookmarks API",details:e instanceof Error?e.message:"Unknown error occurred"}}}registerTools(){this.shouldRegisterTool("create")&&this.registerCreate(),this.shouldRegisterTool("get")&&this.registerGet(),this.shouldRegisterTool("getChildren")&&this.registerGetChildren(),this.shouldRegisterTool("getRecent")&&this.registerGetRecent(),this.shouldRegisterTool("getSubTree")&&this.registerGetSubTree(),this.shouldRegisterTool("getTree")&&this.registerGetTree(),this.shouldRegisterTool("move")&&this.registerMove(),this.shouldRegisterTool("remove")&&this.registerRemove(),this.shouldRegisterTool("removeTree")&&this.registerRemoveTree(),this.shouldRegisterTool("search")&&this.registerSearch(),this.shouldRegisterTool("update")&&this.registerUpdate();}registerCreate(){this.server.registerTool("extension_tool_create_bookmark",{description:"Create a bookmark or folder under the specified parent. If url is not provided, it will be a folder",inputSchema:{parentId:z.string().optional().describe("Parent folder ID. Defaults to the Other Bookmarks folder"),title:z.string().optional().describe("The title of the bookmark or folder"),url:z.string().optional().describe("The URL for the bookmark. Omit for folders"),index:z.number().optional().describe("The position within the parent folder")}},async({parentId:e,title:t,url:r,index:o})=>{try{let i={};e!==void 0&&(i.parentId=e),t!==void 0&&(i.title=t),r!==void 0&&(i.url=r),o!==void 0&&(i.index=o);let s=await new Promise((n,a)=>{chrome.bookmarks.create(i,c=>{chrome.runtime.lastError?a(new Error(chrome.runtime.lastError.message)):n(c);});});return this.formatJson({id:s.id,title:s.title,url:s.url,parentId:s.parentId,index:s.index,dateAdded:s.dateAdded,type:s.url?"bookmark":"folder"})}catch(i){return this.formatError(i)}});}registerGet(){this.server.registerTool("extension_tool_get_bookmark",{description:"Retrieve the specified bookmark(s) by ID",inputSchema:{idOrIdList:z.union([z.string(),z.array(z.string())]).describe("A single bookmark ID or array of bookmark IDs")}},async({idOrIdList:e})=>{try{let t=await new Promise((r,o)=>{chrome.bookmarks.get(e,i=>{chrome.runtime.lastError?o(new Error(chrome.runtime.lastError.message)):r(i);});});return this.formatJson({count:t.length,bookmarks:t.map(r=>({id:r.id,title:r.title,url:r.url,parentId:r.parentId,index:r.index,dateAdded:r.dateAdded,dateAddedFormatted:r.dateAdded?new Date(r.dateAdded).toISOString():void 0,type:r.url?"bookmark":"folder"}))})}catch(t){return this.formatError(t)}});}registerGetChildren(){this.server.registerTool("extension_tool_get_bookmark_children",{description:"Retrieve the children of the specified bookmark folder",inputSchema:{id:z.string().describe("The ID of the folder to get children from")}},async({id:e})=>{try{let t=await new Promise((r,o)=>{chrome.bookmarks.getChildren(e,i=>{chrome.runtime.lastError?o(new Error(chrome.runtime.lastError.message)):r(i);});});return this.formatJson({parentId:e,count:t.length,children:t.map(r=>({id:r.id,title:r.title,url:r.url,parentId:r.parentId,index:r.index,dateAdded:r.dateAdded,dateAddedFormatted:r.dateAdded?new Date(r.dateAdded).toISOString():void 0,type:r.url?"bookmark":"folder"}))})}catch(t){return this.formatError(t)}});}registerGetRecent(){this.server.registerTool("extension_tool_get_recent_bookmarks",{description:"Retrieve the recently added bookmarks",inputSchema:{numberOfItems:z.number().min(1).describe("The maximum number of items to return")}},async({numberOfItems:e})=>{try{let t=await new Promise((r,o)=>{chrome.bookmarks.getRecent(e,i=>{chrome.runtime.lastError?o(new Error(chrome.runtime.lastError.message)):r(i);});});return this.formatJson({count:t.length,recentBookmarks:t.map(r=>({id:r.id,title:r.title,url:r.url,parentId:r.parentId,index:r.index,dateAdded:r.dateAdded,dateAddedFormatted:r.dateAdded?new Date(r.dateAdded).toISOString():void 0}))})}catch(t){return this.formatError(t)}});}registerGetSubTree(){this.server.registerTool("extension_tool_get_bookmark_subtree",{description:"Retrieve part of the bookmarks hierarchy, starting at the specified node",inputSchema:{id:z.string().describe("The ID of the root of the subtree to retrieve")}},async({id:e})=>{try{let t=await new Promise((o,i)=>{chrome.bookmarks.getSubTree(e,s=>{chrome.runtime.lastError?i(new Error(chrome.runtime.lastError.message)):o(s);});}),r=o=>({id:o.id,title:o.title,url:o.url,parentId:o.parentId,index:o.index,dateAdded:o.dateAdded,dateAddedFormatted:o.dateAdded?new Date(o.dateAdded).toISOString():void 0,type:o.url?"bookmark":"folder",children:o.children?o.children.map(r):void 0});return this.formatJson({rootId:e,subtree:t.map(r)})}catch(t){return this.formatError(t)}});}registerGetTree(){this.server.registerTool("extension_tool_get_bookmark_tree",{description:"Retrieve the entire bookmarks hierarchy",inputSchema:{}},async()=>{try{let e=await new Promise((r,o)=>{chrome.bookmarks.getTree(i=>{chrome.runtime.lastError?o(new Error(chrome.runtime.lastError.message)):r(i);});}),t=r=>({id:r.id,title:r.title,url:r.url,parentId:r.parentId,index:r.index,dateAdded:r.dateAdded,dateAddedFormatted:r.dateAdded?new Date(r.dateAdded).toISOString():void 0,type:r.url?"bookmark":"folder",children:r.children?r.children.map(t):void 0});return this.formatJson({tree:e.map(t)})}catch(e){return this.formatError(e)}});}registerMove(){this.server.registerTool("extension_tool_move_bookmark",{description:"Move the specified bookmark or folder to a new location",inputSchema:{id:z.string().describe("The ID of the bookmark or folder to move"),parentId:z.string().optional().describe("The new parent folder ID"),index:z.number().optional().describe("The new position within the parent folder")}},async({id:e,parentId:t,index:r})=>{try{let o={};t!==void 0&&(o.parentId=t),r!==void 0&&(o.index=r);let i=await new Promise((s,n)=>{chrome.bookmarks.move(e,o,a=>{chrome.runtime.lastError?n(new Error(chrome.runtime.lastError.message)):s(a);});});return this.formatSuccess("Bookmark moved successfully",{id:i.id,title:i.title,url:i.url,parentId:i.parentId,index:i.index,type:i.url?"bookmark":"folder"})}catch(o){return this.formatError(o)}});}registerRemove(){this.server.registerTool("extension_tool_remove_bookmark",{description:"Remove a bookmark or an empty bookmark folder",inputSchema:{id:z.string().describe("The ID of the bookmark or empty folder to remove")}},async({id:e})=>{try{return await new Promise((t,r)=>{chrome.bookmarks.remove(e,()=>{chrome.runtime.lastError?r(new Error(chrome.runtime.lastError.message)):t();});}),this.formatSuccess("Bookmark removed successfully",{id:e})}catch(t){return this.formatError(t)}});}registerRemoveTree(){this.server.registerTool("extension_tool_remove_bookmark_tree",{description:"Recursively remove a bookmark folder and all its contents",inputSchema:{id:z.string().describe("The ID of the folder to remove recursively")}},async({id:e})=>{try{return await new Promise((t,r)=>{chrome.bookmarks.removeTree(e,()=>{chrome.runtime.lastError?r(new Error(chrome.runtime.lastError.message)):t();});}),this.formatSuccess("Bookmark folder and all contents removed successfully",{id:e})}catch(t){return this.formatError(t)}});}registerSearch(){this.server.registerTool("extension_tool_search_bookmarks",{description:"Search for bookmarks matching the given query",inputSchema:{query:z.union([z.string(),z.object({query:z.string().optional().describe("Words and phrases to match against URLs and titles"),url:z.string().optional().describe("URL to match exactly"),title:z.string().optional().describe("Title to match exactly")})]).describe("Search query string or object with specific search criteria")}},async({query:e})=>{try{let t=await new Promise((r,o)=>{chrome.bookmarks.search(e,i=>{chrome.runtime.lastError?o(new Error(chrome.runtime.lastError.message)):r(i);});});return this.formatJson({query:typeof e=="string"?e:JSON.stringify(e),count:t.length,results:t.map(r=>({id:r.id,title:r.title,url:r.url,parentId:r.parentId,index:r.index,dateAdded:r.dateAdded,dateAddedFormatted:r.dateAdded?new Date(r.dateAdded).toISOString():void 0,type:r.url?"bookmark":"folder"}))})}catch(t){return this.formatError(t)}});}registerUpdate(){this.server.registerTool("extension_tool_update_bookmark",{description:"Update the properties of a bookmark or folder. Only title and url can be changed",inputSchema:{id:z.string().describe("The ID of the bookmark or folder to update"),title:z.string().optional().describe("The new title"),url:z.string().optional().describe("The new URL (bookmarks only)")}},async({id:e,title:t,url:r})=>{try{let o={};if(t!==void 0&&(o.title=t),r!==void 0&&(o.url=r),Object.keys(o).length===0)return this.formatError("At least one property (title or url) must be specified to update");let i=await new Promise((s,n)=>{chrome.bookmarks.update(e,o,a=>{chrome.runtime.lastError?n(new Error(chrome.runtime.lastError.message)):s(a);});});return this.formatSuccess("Bookmark updated successfully",{id:i.id,title:i.title,url:i.url,parentId:i.parentId,index:i.index,type:i.url?"bookmark":"folder",changes:o})}catch(o){return this.formatError(o)}});}};var Pe=class extends d{apiName="BrowsingData";constructor(e,t={}){super(e,t);}checkAvailability(){try{return chrome.browsingData?typeof chrome.browsingData.settings!="function"?{available:!1,message:"chrome.browsingData.settings is not available",details:"The browsingData API appears to be partially available. Check manifest permissions."}:(chrome.browsingData.settings(e=>{if(chrome.runtime.lastError)throw new Error(chrome.runtime.lastError.message)}),{available:!0,message:"BrowsingData API is fully available"}):{available:!1,message:"chrome.browsingData API is not defined",details:'This extension needs the "browsingData" permission in its manifest.json'}}catch(e){return {available:false,message:"Failed to access chrome.browsingData API",details:e instanceof Error?e.message:"Unknown error occurred"}}}registerTools(){this.shouldRegisterTool("remove")&&this.registerRemove(),this.shouldRegisterTool("removeAppcache")&&this.registerRemoveAppcache(),this.shouldRegisterTool("removeCache")&&this.registerRemoveCache(),this.shouldRegisterTool("removeCacheStorage")&&this.registerRemoveCacheStorage(),this.shouldRegisterTool("removeCookies")&&this.registerRemoveCookies(),this.shouldRegisterTool("removeDownloads")&&this.registerRemoveDownloads(),this.shouldRegisterTool("removeFileSystems")&&this.registerRemoveFileSystems(),this.shouldRegisterTool("removeFormData")&&this.registerRemoveFormData(),this.shouldRegisterTool("removeHistory")&&this.registerRemoveHistory(),this.shouldRegisterTool("removeIndexedDB")&&this.registerRemoveIndexedDB(),this.shouldRegisterTool("removeLocalStorage")&&this.registerRemoveLocalStorage(),this.shouldRegisterTool("removePasswords")&&this.registerRemovePasswords(),this.shouldRegisterTool("removeServiceWorkers")&&this.registerRemoveServiceWorkers(),this.shouldRegisterTool("removeWebSQL")&&this.registerRemoveWebSQL(),this.shouldRegisterTool("settings")&&this.registerSettings();}registerRemove(){this.server.registerTool("extension_tool_remove_browsing_data",{description:"Remove various types of browsing data from the user's profile",inputSchema:{since:z.number().optional().describe("Remove data accumulated on or after this date (milliseconds since epoch)"),origins:z.array(z.string()).optional().describe("Only remove data for these origins (cookies, storage, cache only)"),excludeOrigins:z.array(z.string()).optional().describe("Exclude data for these origins from deletion"),originTypes:z.object({unprotectedWeb:z.boolean().optional(),protectedWeb:z.boolean().optional(),extension:z.boolean().optional()}).optional().describe("Types of origins to clear"),appcache:z.boolean().optional().describe("Remove websites' appcaches"),cache:z.boolean().optional().describe("Remove browser cache"),cacheStorage:z.boolean().optional().describe("Remove cache storage"),cookies:z.boolean().optional().describe("Remove cookies"),downloads:z.boolean().optional().describe("Remove download list"),fileSystems:z.boolean().optional().describe("Remove websites' file systems"),formData:z.boolean().optional().describe("Remove stored form data"),history:z.boolean().optional().describe("Remove browser history"),indexedDB:z.boolean().optional().describe("Remove IndexedDB data"),localStorage:z.boolean().optional().describe("Remove local storage data"),passwords:z.boolean().optional().describe("Remove stored passwords"),serviceWorkers:z.boolean().optional().describe("Remove service workers"),webSQL:z.boolean().optional().describe("Remove WebSQL data")}},async({since:e,origins:t,excludeOrigins:r,originTypes:o,appcache:i,cache:s,cacheStorage:n,cookies:a,downloads:c,fileSystems:u,formData:m,history:g,indexedDB:w,localStorage:k,passwords:R,serviceWorkers:D,webSQL:ce})=>{try{let V={};e!==void 0&&(V.since=e),t!==void 0&&(V.origins=t),r!==void 0&&(V.excludeOrigins=r),o!==void 0&&(V.originTypes=o);let L={};return i!==void 0&&(L.appcache=i),s!==void 0&&(L.cache=s),n!==void 0&&(L.cacheStorage=n),a!==void 0&&(L.cookies=a),c!==void 0&&(L.downloads=c),u!==void 0&&(L.fileSystems=u),m!==void 0&&(L.formData=m),g!==void 0&&(L.history=g),w!==void 0&&(L.indexedDB=w),k!==void 0&&(L.localStorage=k),R!==void 0&&(L.passwords=R),D!==void 0&&(L.serviceWorkers=D),ce!==void 0&&(L.webSQL=ce),await new Promise((se,Se)=>{chrome.browsingData.remove(V,L,()=>{chrome.runtime.lastError?Se(new Error(chrome.runtime.lastError.message)):se();});}),this.formatSuccess("Browsing data removed successfully",{options:V,dataTypes:Object.keys(L).filter(se=>L[se])})}catch(V){return this.formatError(V)}});}registerRemoveAppcache(){this.server.registerTool("extension_tool_remove_appcache",{description:"Remove websites' appcache data",inputSchema:{since:z.number().optional().describe("Remove data accumulated on or after this date (milliseconds since epoch)"),origins:z.array(z.string()).optional().describe("Only remove data for these origins"),excludeOrigins:z.array(z.string()).optional().describe("Exclude data for these origins from deletion"),originTypes:z.object({unprotectedWeb:z.boolean().optional(),protectedWeb:z.boolean().optional(),extension:z.boolean().optional()}).optional().describe("Types of origins to clear")}},async({since:e,origins:t,excludeOrigins:r,originTypes:o})=>{try{let i={};return e!==void 0&&(i.since=e),t!==void 0&&(i.origins=t),r!==void 0&&(i.excludeOrigins=r),o!==void 0&&(i.originTypes=o),await new Promise((s,n)=>{chrome.browsingData.removeAppcache(i,()=>{chrome.runtime.lastError?n(new Error(chrome.runtime.lastError.message)):s();});}),this.formatSuccess("Appcache data removed successfully",{options:i})}catch(i){return this.formatError(i)}});}registerRemoveCache(){this.server.registerTool("extension_tool_remove_cache",{description:"Remove browser cache",inputSchema:{since:z.number().optional().describe("Remove data accumulated on or after this date (milliseconds since epoch)"),origins:z.array(z.string()).optional().describe("Only remove data for these origins"),excludeOrigins:z.array(z.string()).optional().describe("Exclude data for these origins from deletion"),originTypes:z.object({unprotectedWeb:z.boolean().optional(),protectedWeb:z.boolean().optional(),extension:z.boolean().optional()}).optional().describe("Types of origins to clear")}},async({since:e,origins:t,excludeOrigins:r,originTypes:o})=>{try{let i={};return e!==void 0&&(i.since=e),t!==void 0&&(i.origins=t),r!==void 0&&(i.excludeOrigins=r),o!==void 0&&(i.originTypes=o),await new Promise((s,n)=>{chrome.browsingData.removeCache(i,()=>{chrome.runtime.lastError?n(new Error(chrome.runtime.lastError.message)):s();});}),this.formatSuccess("Cache removed successfully",{options:i})}catch(i){return this.formatError(i)}});}registerRemoveCacheStorage(){this.server.registerTool("extension_tool_remove_cache_storage",{description:"Remove websites' cache storage data",inputSchema:{since:z.number().optional().describe("Remove data accumulated on or after this date (milliseconds since epoch)"),origins:z.array(z.string()).optional().describe("Only remove data for these origins"),excludeOrigins:z.array(z.string()).optional().describe("Exclude data for these origins from deletion"),originTypes:z.object({unprotectedWeb:z.boolean().optional(),protectedWeb:z.boolean().optional(),extension:z.boolean().optional()}).optional().describe("Types of origins to clear")}},async({since:e,origins:t,excludeOrigins:r,originTypes:o})=>{try{let i={};return e!==void 0&&(i.since=e),t!==void 0&&(i.origins=t),r!==void 0&&(i.excludeOrigins=r),o!==void 0&&(i.originTypes=o),await new Promise((s,n)=>{chrome.browsingData.removeCacheStorage(i,()=>{chrome.runtime.lastError?n(new Error(chrome.runtime.lastError.message)):s();});}),this.formatSuccess("Cache storage removed successfully",{options:i})}catch(i){return this.formatError(i)}});}registerRemoveCookies(){this.server.registerTool("extension_tool_remove_cookies",{description:"Remove browser cookies and server-bound certificates",inputSchema:{since:z.number().optional().describe("Remove data accumulated on or after this date (milliseconds since epoch)"),origins:z.array(z.string()).optional().describe("Only remove data for these origins"),excludeOrigins:z.array(z.string()).optional().describe("Exclude data for these origins from deletion"),originTypes:z.object({unprotectedWeb:z.boolean().optional(),protectedWeb:z.boolean().optional(),extension:z.boolean().optional()}).optional().describe("Types of origins to clear")}},async({since:e,origins:t,excludeOrigins:r,originTypes:o})=>{try{let i={};return e!==void 0&&(i.since=e),t!==void 0&&(i.origins=t),r!==void 0&&(i.excludeOrigins=r),o!==void 0&&(i.originTypes=o),await new Promise((s,n)=>{chrome.browsingData.removeCookies(i,()=>{chrome.runtime.lastError?n(new Error(chrome.runtime.lastError.message)):s();});}),this.formatSuccess("Cookies removed successfully",{options:i})}catch(i){return this.formatError(i)}});}registerRemoveDownloads(){this.server.registerTool("extension_tool_remove_downloads",{description:"Remove browser download list (not the downloaded files themselves)",inputSchema:{since:z.number().optional().describe("Remove data accumulated on or after this date (milliseconds since epoch)"),originTypes:z.object({unprotectedWeb:z.boolean().optional(),protectedWeb:z.boolean().optional(),extension:z.boolean().optional()}).optional().describe("Types of origins to clear")}},async({since:e,originTypes:t})=>{try{let r={};return e!==void 0&&(r.since=e),t!==void 0&&(r.originTypes=t),await new Promise((o,i)=>{chrome.browsingData.removeDownloads(r,()=>{chrome.runtime.lastError?i(new Error(chrome.runtime.lastError.message)):o();});}),this.formatSuccess("Download list removed successfully",{options:r})}catch(r){return this.formatError(r)}});}registerRemoveFileSystems(){this.server.registerTool("extension_tool_remove_file_systems",{description:"Remove websites' file system data",inputSchema:{since:z.number().optional().describe("Remove data accumulated on or after this date (milliseconds since epoch)"),origins:z.array(z.string()).optional().describe("Only remove data for these origins"),excludeOrigins:z.array(z.string()).optional().describe("Exclude data for these origins from deletion"),originTypes:z.object({unprotectedWeb:z.boolean().optional(),protectedWeb:z.boolean().optional(),extension:z.boolean().optional()}).optional().describe("Types of origins to clear")}},async({since:e,origins:t,excludeOrigins:r,originTypes:o})=>{try{let i={};return e!==void 0&&(i.since=e),t!==void 0&&(i.origins=t),r!==void 0&&(i.excludeOrigins=r),o!==void 0&&(i.originTypes=o),await new Promise((s,n)=>{chrome.browsingData.removeFileSystems(i,()=>{chrome.runtime.lastError?n(new Error(chrome.runtime.lastError.message)):s();});}),this.formatSuccess("File systems removed successfully",{options:i})}catch(i){return this.formatError(i)}});}registerRemoveFormData(){this.server.registerTool("extension_tool_remove_form_data",{description:"Remove browser stored form data (autofill)",inputSchema:{since:z.number().optional().describe("Remove data accumulated on or after this date (milliseconds since epoch)"),originTypes:z.object({unprotectedWeb:z.boolean().optional(),protectedWeb:z.boolean().optional(),extension:z.boolean().optional()}).optional().describe("Types of origins to clear")}},async({since:e,originTypes:t})=>{try{let r={};return e!==void 0&&(r.since=e),t!==void 0&&(r.originTypes=t),await new Promise((o,i)=>{chrome.browsingData.removeFormData(r,()=>{chrome.runtime.lastError?i(new Error(chrome.runtime.lastError.message)):o();});}),this.formatSuccess("Form data removed successfully",{options:r})}catch(r){return this.formatError(r)}});}registerRemoveHistory(){this.server.registerTool("extension_tool_remove_history",{description:"Remove browser history",inputSchema:{since:z.number().optional().describe("Remove data accumulated on or after this date (milliseconds since epoch)"),originTypes:z.object({unprotectedWeb:z.boolean().optional(),protectedWeb:z.boolean().optional(),extension:z.boolean().optional()}).optional().describe("Types of origins to clear")}},async({since:e,originTypes:t})=>{try{let r={};return e!==void 0&&(r.since=e),t!==void 0&&(r.originTypes=t),await new Promise((o,i)=>{chrome.browsingData.removeHistory(r,()=>{chrome.runtime.lastError?i(new Error(chrome.runtime.lastError.message)):o();});}),this.formatSuccess("History removed successfully",{options:r})}catch(r){return this.formatError(r)}});}registerRemoveIndexedDB(){this.server.registerTool("extension_tool_remove_indexed_db",{description:"Remove websites' IndexedDB data",inputSchema:{since:z.number().optional().describe("Remove data accumulated on or after this date (milliseconds since epoch)"),origins:z.array(z.string()).optional().describe("Only remove data for these origins"),excludeOrigins:z.array(z.string()).optional().describe("Exclude data for these origins from deletion"),originTypes:z.object({unprotectedWeb:z.boolean().optional(),protectedWeb:z.boolean().optional(),extension:z.boolean().optional()}).optional().describe("Types of origins to clear")}},async({since:e,origins:t,excludeOrigins:r,originTypes:o})=>{try{let i={};return e!==void 0&&(i.since=e),t!==void 0&&(i.origins=t),r!==void 0&&(i.excludeOrigins=r),o!==void 0&&(i.originTypes=o),await new Promise((s,n)=>{chrome.browsingData.removeIndexedDB(i,()=>{chrome.runtime.lastError?n(new Error(chrome.runtime.lastError.message)):s();});}),this.formatSuccess("IndexedDB data removed successfully",{options:i})}catch(i){return this.formatError(i)}});}registerRemoveLocalStorage(){this.server.registerTool("extension_tool_remove_local_storage",{description:"Remove websites' local storage data",inputSchema:{since:z.number().optional().describe("Remove data accumulated on or after this date (milliseconds since epoch)"),origins:z.array(z.string()).optional().describe("Only remove data for these origins"),excludeOrigins:z.array(z.string()).optional().describe("Exclude data for these origins from deletion"),originTypes:z.object({unprotectedWeb:z.boolean().optional(),protectedWeb:z.boolean().optional(),extension:z.boolean().optional()}).optional().describe("Types of origins to clear")}},async({since:e,origins:t,excludeOrigins:r,originTypes:o})=>{try{let i={};return e!==void 0&&(i.since=e),t!==void 0&&(i.origins=t),r!==void 0&&(i.excludeOrigins=r),o!==void 0&&(i.originTypes=o),await new Promise((s,n)=>{chrome.browsingData.removeLocalStorage(i,()=>{chrome.runtime.lastError?n(new Error(chrome.runtime.lastError.message)):s();});}),this.formatSuccess("Local storage removed successfully",{options:i})}catch(i){return this.formatError(i)}});}registerRemovePasswords(){this.server.registerTool("extension_tool_remove_passwords",{description:"Remove browser stored passwords",inputSchema:{since:z.number().optional().describe("Remove data accumulated on or after this date (milliseconds since epoch)"),originTypes:z.object({unprotectedWeb:z.boolean().optional(),protectedWeb:z.boolean().optional(),extension:z.boolean().optional()}).optional().describe("Types of origins to clear")}},async({since:e,originTypes:t})=>{try{let r={};return e!==void 0&&(r.since=e),t!==void 0&&(r.originTypes=t),await new Promise((o,i)=>{chrome.browsingData.removePasswords(r,()=>{chrome.runtime.lastError?i(new Error(chrome.runtime.lastError.message)):o();});}),this.formatSuccess("Passwords removed successfully",{options:r})}catch(r){return this.formatError(r)}});}registerRemoveServiceWorkers(){this.server.registerTool("extension_tool_remove_service_workers",{description:"Remove websites' service workers",inputSchema:{since:z.number().optional().describe("Remove data accumulated on or after this date (milliseconds since epoch)"),origins:z.array(z.string()).optional().describe("Only remove data for these origins"),excludeOrigins:z.array(z.string()).optional().describe("Exclude data for these origins from deletion"),originTypes:z.object({unprotectedWeb:z.boolean().optional(),protectedWeb:z.boolean().optional(),extension:z.boolean().optional()}).optional().describe("Types of origins to clear")}},async({since:e,origins:t,excludeOrigins:r,originTypes:o})=>{try{let i={};return e!==void 0&&(i.since=e),t!==void 0&&(i.origins=t),r!==void 0&&(i.excludeOrigins=r),o!==void 0&&(i.originTypes=o),await new Promise((s,n)=>{chrome.browsingData.removeServiceWorkers(i,()=>{chrome.runtime.lastError?n(new Error(chrome.runtime.lastError.message)):s();});}),this.formatSuccess("Service workers removed successfully",{options:i})}catch(i){return this.formatError(i)}});}registerRemoveWebSQL(){this.server.registerTool("extension_tool_remove_web_sql",{description:"Remove websites' WebSQL data",inputSchema:{since:z.number().optional().describe("Remove data accumulated on or after this date (milliseconds since epoch)"),origins:z.array(z.string()).optional().describe("Only remove data for these origins"),excludeOrigins:z.array(z.string()).optional().describe("Exclude data for these origins from deletion"),originTypes:z.object({unprotectedWeb:z.boolean().optional(),protectedWeb:z.boolean().optional(),extension:z.boolean().optional()}).optional().describe("Types of origins to clear")}},async({since:e,origins:t,excludeOrigins:r,originTypes:o})=>{try{let i={};return e!==void 0&&(i.since=e),t!==void 0&&(i.origins=t),r!==void 0&&(i.excludeOrigins=r),o!==void 0&&(i.originTypes=o),await new Promise((s,n)=>{chrome.browsingData.removeWebSQL(i,()=>{chrome.runtime.lastError?n(new Error(chrome.runtime.lastError.message)):s();});}),this.formatSuccess("WebSQL data removed successfully",{options:i})}catch(i){return this.formatError(i)}});}registerSettings(){this.server.registerTool("extension_tool_get_browsing_data_settings",{description:"Get current browsing data settings from the Clear browsing data UI",inputSchema:{}},async()=>{try{let e=await new Promise((t,r)=>{chrome.browsingData.settings(o=>{chrome.runtime.lastError?r(new Error(chrome.runtime.lastError.message)):t(o);});});return this.formatJson({dataRemovalPermitted:e.dataRemovalPermitted,dataToRemove:e.dataToRemove,options:e.options})}catch(e){return this.formatError(e)}});}};var Ce=class extends d{apiName="CertificateProvider";constructor(e,t={}){super(e,t);}checkAvailability(){try{return chrome.certificateProvider?typeof chrome.certificateProvider.setCertificates!="function"?{available:!1,message:"chrome.certificateProvider.setCertificates is not available",details:"The certificateProvider API appears to be partially available. Check manifest permissions and ensure running on ChromeOS."}:{available:!0,message:"CertificateProvider API is fully available"}:{available:!1,message:"chrome.certificateProvider API is not defined",details:'This extension needs the "certificateProvider" permission in its manifest.json and only works on ChromeOS'}}catch(e){return {available:false,message:"Failed to access chrome.certificateProvider API",details:e instanceof Error?e.message:"Unknown error occurred"}}}registerTools(){this.shouldRegisterTool("setCertificates")&&this.registerSetCertificates(),this.shouldRegisterTool("reportSignature")&&this.registerReportSignature(),this.shouldRegisterTool("requestPin")&&this.registerRequestPin(),this.shouldRegisterTool("stopPinRequest")&&this.registerStopPinRequest(),this.shouldRegisterTool("onCertificatesUpdateRequested")&&this.registerOnCertificatesUpdateRequested(),this.shouldRegisterTool("onSignatureRequested")&&this.registerOnSignatureRequested();}registerSetCertificates(){this.server.registerTool("extension_tool_set_certificates",{description:"Sets a list of certificates to use in the browser for TLS client authentication",inputSchema:{certificatesRequestId:z.number().optional().describe("Request ID when responding to onCertificatesUpdateRequested event"),clientCertificates:z.array(z.object({certificateChain:z.array(z.string()).describe("Array of base64-encoded DER certificates, with client cert first"),supportedAlgorithms:z.array(z.string()).describe("Supported signature algorithms for this certificate")})).describe("List of client certificates to provide"),error:z.enum(["GENERAL_ERROR"]).optional().describe("Error that occurred while extracting certificates")}},async({certificatesRequestId:e,clientCertificates:t,error:r})=>{try{let o={clientCertificates:t.map(i=>({certificateChain:i.certificateChain.map(s=>{let n=atob(s),a=new Uint8Array(n.length);for(let c=0;c<n.length;c++)a[c]=n.charCodeAt(c);return a.buffer}),supportedAlgorithms:i.supportedAlgorithms}))};return e!==void 0&&(o.certificatesRequestId=e),r!==void 0&&(o.error=r),await new Promise((i,s)=>{chrome.certificateProvider.setCertificates(o,()=>{chrome.runtime.lastError?s(new Error(chrome.runtime.lastError.message)):i();});}),this.formatSuccess("Certificates set successfully",{certificateCount:t.length,requestId:e})}catch(o){return this.formatError(o)}});}registerReportSignature(){this.server.registerTool("extension_tool_report_signature",{description:"Reports the signature for a signing request from the browser",inputSchema:{signRequestId:z.number().describe("Request identifier from onSignatureRequested event"),signature:z.string().optional().describe("Base64-encoded signature data, if successfully generated"),error:z.enum(["GENERAL_ERROR"]).optional().describe("Error that occurred while generating the signature")}},async({signRequestId:e,signature:t,error:r})=>{try{let o={signRequestId:e};if(t!==void 0){let i=atob(t),s=new Uint8Array(i.length);for(let n=0;n<i.length;n++)s[n]=i.charCodeAt(n);o.signature=s.buffer;}return r!==void 0&&(o.error=r),await new Promise((i,s)=>{chrome.certificateProvider.reportSignature(o,()=>{chrome.runtime.lastError?s(new Error(chrome.runtime.lastError.message)):i();});}),this.formatSuccess("Signature reported successfully",{signRequestId:e,hasSignature:t!==void 0,hasError:r!==void 0})}catch(o){return this.formatError(o)}});}registerRequestPin(){this.server.registerTool("extension_tool_request_pin",{description:"Requests PIN or PUK from the user for certificate operations",inputSchema:{signRequestId:z.number().describe("The ID from SignRequest"),requestType:z.enum(["PIN","PUK"]).optional().describe("Type of code being requested (default: PIN)"),errorType:z.enum(["INVALID_PIN","INVALID_PUK","MAX_ATTEMPTS_EXCEEDED","UNKNOWN_ERROR"]).optional().describe("Error from previous request to show to user"),attemptsLeft:z.number().optional().describe("Number of attempts remaining for user information")}},async({signRequestId:e,requestType:t,errorType:r,attemptsLeft:o})=>{try{let i={signRequestId:e};t!==void 0&&(i.requestType=t),r!==void 0&&(i.errorType=r),o!==void 0&&(i.attemptsLeft=o);let s=await new Promise((n,a)=>{chrome.certificateProvider.requestPin(i,c=>{chrome.runtime.lastError?a(new Error(chrome.runtime.lastError.message)):n(c);});});return this.formatJson({signRequestId:e,userInput:s?.userInput||null,success:!!s?.userInput})}catch(i){return this.formatError(i)}});}registerStopPinRequest(){this.server.registerTool("extension_tool_stop_pin_request",{description:"Stops an ongoing PIN request flow",inputSchema:{signRequestId:z.number().describe("The ID from SignRequest"),errorType:z.enum(["INVALID_PIN","INVALID_PUK","MAX_ATTEMPTS_EXCEEDED","UNKNOWN_ERROR"]).optional().describe("Error reason for stopping the flow")}},async({signRequestId:e,errorType:t})=>{try{let r={signRequestId:e};return t!==void 0&&(r.errorType=t),await new Promise((o,i)=>{chrome.certificateProvider.stopPinRequest(r,()=>{chrome.runtime.lastError?i(new Error(chrome.runtime.lastError.message)):o();});}),this.formatSuccess("PIN request stopped successfully",{signRequestId:e,errorType:t})}catch(r){return this.formatError(r)}});}registerOnCertificatesUpdateRequested(){this.server.registerTool("extension_tool_listen_certificates_update_requested",{description:"Sets up listener for certificate update requests from the browser",inputSchema:{}},async()=>{try{return chrome.certificateProvider.onCertificatesUpdateRequested.hasListeners()&&chrome.certificateProvider.onCertificatesUpdateRequested.removeListener(this.handleCertificatesUpdateRequested),chrome.certificateProvider.onCertificatesUpdateRequested.addListener(this.handleCertificatesUpdateRequested),this.formatSuccess("Certificate update request listener registered",{event:"onCertificatesUpdateRequested",hasListeners:chrome.certificateProvider.onCertificatesUpdateRequested.hasListeners()})}catch(e){return this.formatError(e)}});}registerOnSignatureRequested(){this.server.registerTool("extension_tool_listen_signature_requested",{description:"Sets up listener for signature requests from the browser",inputSchema:{}},async()=>{try{return chrome.certificateProvider.onSignatureRequested.hasListeners()&&chrome.certificateProvider.onSignatureRequested.removeListener(this.handleSignatureRequested),chrome.certificateProvider.onSignatureRequested.addListener(this.handleSignatureRequested),this.formatSuccess("Signature request listener registered",{event:"onSignatureRequested",hasListeners:chrome.certificateProvider.onSignatureRequested.hasListeners()})}catch(e){return this.formatError(e)}});}handleCertificatesUpdateRequested=e=>{console.log("Certificate update requested:",{certificatesRequestId:e.certificatesRequestId,timestamp:new Date().toISOString()});};handleSignatureRequested=e=>{let t=new Uint8Array(e.certificate),r=new Uint8Array(e.input);console.log("Signature requested:",{signRequestId:e.signRequestId,algorithm:e.algorithm,certificateLength:t.length,inputLength:r.length,timestamp:new Date().toISOString()});}};var ke=class extends d{apiName="Commands";constructor(e,t={}){super(e,t);}checkAvailability(){try{return chrome.commands?typeof chrome.commands.getAll!="function"?{available:!1,message:"chrome.commands.getAll is not available",details:"The commands API appears to be partially available. Check manifest permissions."}:(chrome.commands.getAll(e=>{if(chrome.runtime.lastError)throw new Error(chrome.runtime.lastError.message)}),{available:!0,message:"Commands API is fully available"}):{available:!1,message:"chrome.commands API is not defined",details:'This extension needs the "commands" permission in its manifest.json'}}catch(e){return {available:false,message:"Failed to access chrome.commands API",details:e instanceof Error?e.message:"Unknown error occurred"}}}registerTools(){this.shouldRegisterTool("getAll")&&this.registerGetAll();}registerGetAll(){this.server.registerTool("extension_tool_get_all_commands",{description:"Get all registered extension commands and their keyboard shortcuts",inputSchema:{}},async()=>{try{let e=await new Promise((t,r)=>{chrome.commands.getAll(o=>{chrome.runtime.lastError?r(new Error(chrome.runtime.lastError.message)):t(o);});});return this.formatJson({count:e.length,commands:e.map(t=>({name:t.name,description:t.description,shortcut:t.shortcut||"Not assigned",isActive:!!t.shortcut}))})}catch(e){return this.formatError(e)}});}};var De=class extends d{apiName="ContentSettings";constructor(e,t={}){super(e,t);}checkAvailability(){try{return chrome.contentSettings?!chrome.contentSettings.cookies||typeof chrome.contentSettings.cookies.get!="function"?{available:!1,message:"chrome.contentSettings.cookies.get is not available",details:"The contentSettings API appears to be partially available. Check manifest permissions."}:(chrome.contentSettings.cookies.get({primaryUrl:"https://example.com"},e=>{if(chrome.runtime.lastError)throw new Error(chrome.runtime.lastError.message)}),{available:!0,message:"ContentSettings API is fully available"}):{available:!1,message:"chrome.contentSettings API is not defined",details:'This extension needs the "contentSettings" permission in its manifest.json'}}catch(e){return {available:false,message:"Failed to access chrome.contentSettings API",details:e instanceof Error?e.message:"Unknown error occurred"}}}registerTools(){this.shouldRegisterTool("getCookiesSetting")&&this.registerGetCookiesSetting(),this.shouldRegisterTool("setCookiesSetting")&&this.registerSetCookiesSetting(),this.shouldRegisterTool("clearCookiesSetting")&&this.registerClearCookiesSetting(),this.shouldRegisterTool("getJavascriptSetting")&&this.registerGetJavascriptSetting(),this.shouldRegisterTool("setJavascriptSetting")&&this.registerSetJavascriptSetting(),this.shouldRegisterTool("clearJavascriptSetting")&&this.registerClearJavascriptSetting(),this.shouldRegisterTool("getImagesSetting")&&this.registerGetImagesSetting(),this.shouldRegisterTool("setImagesSetting")&&this.registerSetImagesSetting(),this.shouldRegisterTool("clearImagesSetting")&&this.registerClearImagesSetting(),this.shouldRegisterTool("getLocationSetting")&&this.registerGetLocationSetting(),this.shouldRegisterTool("setLocationSetting")&&this.registerSetLocationSetting(),this.shouldRegisterTool("clearLocationSetting")&&this.registerClearLocationSetting(),this.shouldRegisterTool("getNotificationsSetting")&&this.registerGetNotificationsSetting(),this.shouldRegisterTool("setNotificationsSetting")&&this.registerSetNotificationsSetting(),this.shouldRegisterTool("clearNotificationsSetting")&&this.registerClearNotificationsSetting(),this.shouldRegisterTool("getPopupsSetting")&&this.registerGetPopupsSetting(),this.shouldRegisterTool("setPopupsSetting")&&this.registerSetPopupsSetting(),this.shouldRegisterTool("clearPopupsSetting")&&this.registerClearPopupsSetting(),this.shouldRegisterTool("getCam