@mcp-b/extension-tools 0.0.1
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/LICENSE +21 -0
- package/README.md +399 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/index.d.ts +1255 -0
- package/dist/index.js +35 -0
- package/dist/index.js.map +1 -0
- package/package.json +61 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import {z as z$1}from'zod';var h=class{constructor(e,r={}){this.server=e;this.options=r;}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,r){return {content:[{type:"text",text:r?`${e}
|
|
2
|
+
${JSON.stringify(r,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 N=class extends h{apiName="Tabs";constructor(e,r={}){super(e,r);}checkAvailability(){try{return chrome.tabs?typeof chrome.tabs.query!="function"?{available:!1,message:"chrome.tabs.query is not available",details:"The tabs API appears to be partially available. Check manifest permissions."}:{available:!0,message:"Tabs API is fully available"}:{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:false,message:"Failed to access chrome.tabs API",details:e instanceof Error?e.message:"Unknown error occurred"}}}registerTools(){this.shouldRegisterTool("listActiveTabs")&&this.registerListActiveTabs(),this.shouldRegisterTool("createTab")&&this.registerCreateTab(),this.shouldRegisterTool("updateTab")&&this.registerUpdateTab(),this.shouldRegisterTool("closeTabs")&&this.registerCloseTabs(),this.shouldRegisterTool("getAllTabs")&&this.registerGetAllTabs(),this.shouldRegisterTool("navigateHistory")&&this.checkAndRegisterNavigationTools(),this.shouldRegisterTool("reloadTab")&&this.registerReloadTab(),this.shouldRegisterTool("captureVisibleTab")&&this.checkAndRegisterScreenshotTool(),this.shouldRegisterTool("detectLanguage")&&this.registerDetectLanguage(),this.shouldRegisterTool("discardTab")&&this.registerDiscardTab(),this.shouldRegisterTool("duplicateTab")&&this.registerDuplicateTab(),this.shouldRegisterTool("getTab")&&this.registerGetTab(),this.shouldRegisterTool("getZoom")&&(this.registerGetZoom(),this.registerGetZoomSettings()),this.shouldRegisterTool("setZoom")&&(this.registerSetZoom(),this.registerSetZoomSettings()),this.shouldRegisterTool("groupTabs")&&this.registerGroupTabs(),this.shouldRegisterTool("ungroupTabs")&&this.registerUngroupTabs(),this.shouldRegisterTool("highlightTabs")&&this.registerHighlightTabs(),this.shouldRegisterTool("moveTabs")&&this.registerMoveTabs(),this.shouldRegisterTool("sendMessage")&&this.registerSendMessage();}checkAndRegisterNavigationTools(){try{typeof chrome.tabs.goBack=="function"&&typeof chrome.tabs.goForward=="function"?(this.registerNavigateHistory(),console.log(" \u2713 Navigation methods (goBack/goForward) available")):console.warn(" \u2717 Navigation methods not available - Chrome 72+ required");}catch{console.warn(" \u2717 Failed to check navigation methods availability");}}checkAndRegisterScreenshotTool(){try{typeof chrome.tabs.captureVisibleTab=="function"?(this.registerCaptureVisibleTab(),console.log(" \u2713 Screenshot capture available")):console.warn(' \u2717 Screenshot capture not available - requires "activeTab" or "<all_urls>" permission');}catch{console.warn(" \u2717 Failed to check screenshot capture availability");}}registerListActiveTabs(){this.server.registerTool("list_active_tabs",{description:"Lists all tabs grouped by domain",inputSchema:{}},async()=>{let o=(await chrome.tabs.query({})).map(t=>{let s="unknown";if(t.url)try{s=new URL(t.url).hostname;}catch{}return {tabId:t.id,domain:s,url:t.url,title:t.title,isActive:t.active,windowId:t.windowId,index:t.index,pinned:t.pinned,audible:t.audible,mutedInfo:t.mutedInfo,status:t.status}}).reduce((t,s)=>{let i=s.domain||"unknown";return t[i]||(t[i]=[]),t[i].push(s),t},{});for(let t of Object.values(o))t.sort((s,i)=>s.windowId!==i.windowId?(s.windowId||0)-(i.windowId||0):(s.index||0)-(i.index||0));return this.formatJson(o)});}registerCreateTab(){this.server.registerTool("create_tab",{description:"Create a new browser tab",inputSchema:{url:z$1.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:z$1.boolean().optional().describe("Whether the tab should be active"),pinned:z$1.boolean().optional().describe("Whether the tab should be pinned")}},async({url:e,active:r,pinned:o})=>{try{let t=await chrome.tabs.create({url:e,active:r,pinned:o});return this.formatSuccess(`Created tab ${t.id} with URL: ${t.url||"about:blank"}`)}catch(t){return this.formatError(t)}});}registerUpdateTab(){this.server.registerTool("update_tab",{description:"Update properties of an existing tab. If no tabId is specified, operates on the currently active tab",inputSchema:{tabId:z$1.number().optional().describe("ID of the tab to update (defaults to active tab)"),url:z$1.string().optional().describe("New URL for the tab"),active:z$1.boolean().optional().describe("Whether to make the tab active"),pinned:z$1.boolean().optional().describe("Whether to pin/unpin the tab"),muted:z$1.boolean().optional().describe("Whether to mute/unmute the tab")}},async({tabId:e,url:r,active:o,pinned:t,muted:s})=>{try{if(e===void 0){let[a]=await chrome.tabs.query({active:!0,currentWindow:!0});if(!a||!a.id)return this.formatError(new Error("No active tab found"));e=a.id;}let i={};r!==void 0&&(i.url=r),o!==void 0&&(i.active=o),t!==void 0&&(i.pinned=t),s!==void 0&&(i.muted=s);let l=await chrome.tabs.update(e,i);return l?this.formatSuccess(`Updated tab ${l.id}`,i):this.formatError(new Error("Tab does not exist"))}catch(i){return this.formatError(i)}});}registerCloseTabs(){this.server.registerTool("close_tabs",{description:"Close one or more tabs",inputSchema:{tabIds:z$1.array(z$1.number()).describe("Array of tab IDs to close")}},async({tabIds:e})=>{try{return await chrome.tabs.remove(e),this.formatSuccess(`Closed ${e.length} tab(s): ${e.join(", ")}`)}catch(r){return this.formatError(r)}});}registerGetAllTabs(){this.server.registerTool("get_all_tabs",{description:"Get information about all open tabs",inputSchema:{currentWindow:z$1.boolean().optional().describe("Only get tabs from current window")}},async({currentWindow:e})=>{try{let o=(await chrome.tabs.query(e?{currentWindow:!0}:{})).map(t=>({id:t.id,title:t.title,url:t.url,active:t.active,pinned:t.pinned,windowId:t.windowId,index:t.index}));return this.formatJson(o)}catch(r){return this.formatError(r)}});}registerNavigateHistory(){this.server.registerTool("navigate_tab_history",{description:"Navigate forward or backward in a tab's history. If no tabId is specified, operates on the currently active tab",inputSchema:{tabId:z$1.number().optional().describe("Tab ID to navigate (defaults to active tab)"),direction:z$1.enum(["back","forward"]).describe("Navigation direction")}},async({tabId:e,direction:r})=>{try{if(e===void 0){let[o]=await chrome.tabs.query({active:!0,currentWindow:!0});if(!o||!o.id)return this.formatError(new Error("No active tab found"));e=o.id;}return r==="back"?await chrome.tabs.goBack(e):await chrome.tabs.goForward(e),this.formatSuccess(`Navigated ${r} in tab ${e}`)}catch(o){return this.formatError(o)}});}registerReloadTab(){this.server.registerTool("reload_tab",{description:"Reload a tab. If no tabId is specified, operates on the currently active tab",inputSchema:{tabId:z$1.number().optional().describe("Tab ID to reload (defaults to active tab)"),bypassCache:z$1.boolean().optional().describe("Bypass the cache when reloading")}},async({tabId:e,bypassCache:r})=>{try{if(e===void 0){let[o]=await chrome.tabs.query({active:!0,currentWindow:!0});if(!o||!o.id)return this.formatError(new Error("No active tab found"));e=o.id;}return await chrome.tabs.reload(e,{bypassCache:r}),this.formatSuccess(`Reloaded tab ${e}${r?" (bypassed cache)":""}`)}catch(o){return this.formatError(o)}});}registerCaptureVisibleTab(){this.server.registerTool("capture_visible_tab",{description:"Take a screenshot of the visible area of the currently active tab in a window",inputSchema:{windowId:z$1.number().optional().describe("Window ID (defaults to current window)")}},async({windowId:e})=>{try{let r=e?await chrome.tabs.captureVisibleTab(e,{}):await chrome.tabs.captureVisibleTab();return this.formatSuccess(`Screenshot captured (data URL length: ${r.length} characters)`)}catch(r){return this.formatError(r)}});}registerDetectLanguage(){this.server.registerTool("detect_tab_language",{description:"Detects the primary language of the content in a tab",inputSchema:{tabId:z$1.number().optional().describe("Tab ID (defaults to active tab)")}},async({tabId:e})=>{try{let r=await chrome.tabs.detectLanguage(e);return this.formatSuccess(`Tab language detected: ${r}`,{language:r})}catch(r){return this.formatError(r)}});}registerDiscardTab(){this.server.registerTool("discard_tab",{description:"Discards a tab from memory. Discarded tabs are still visible but need to reload when activated",inputSchema:{tabId:z$1.number().optional().describe("Tab ID to discard (if omitted, browser picks least important tab)")}},async({tabId:e})=>{try{let r=await chrome.tabs.discard(e);return r?this.formatSuccess(`Discarded tab ${r.id}`,{tab:r}):this.formatError(new Error("Failed to discard tab"))}catch(r){return this.formatError(r)}});}registerDuplicateTab(){this.server.registerTool("duplicate_tab",{description:"Duplicates a tab",inputSchema:{tabId:z$1.number().describe("ID of the tab to duplicate")}},async({tabId:e})=>{try{let r=await chrome.tabs.duplicate(e);return r?this.formatSuccess(`Duplicated tab ${e} to new tab ${r.id}`,{tab:r}):this.formatError(new Error("Failed to duplicate tab"))}catch(r){return this.formatError(r)}});}registerGetTab(){this.server.registerTool("get_tab",{description:"Retrieves details about a specific tab",inputSchema:{tabId:z$1.number().describe("Tab ID")}},async({tabId:e})=>{try{let r=await chrome.tabs.get(e);return this.formatJson(r)}catch(r){return this.formatError(r)}});}registerGetZoom(){this.server.registerTool("get_tab_zoom",{description:"Gets the current zoom factor of a tab",inputSchema:{tabId:z$1.number().optional().describe("Tab ID (defaults to active tab)")}},async({tabId:e})=>{try{let r=await chrome.tabs.getZoom(e);return this.formatSuccess(`Zoom factor: ${r}`,{zoomFactor:r})}catch(r){return this.formatError(r)}});}registerSetZoom(){this.server.registerTool("set_tab_zoom",{description:"Sets the zoom factor for a tab",inputSchema:{tabId:z$1.number().optional().describe("Tab ID (defaults to active tab)"),zoomFactor:z$1.number().describe("New zoom factor (0 resets to default, >0 sets specific zoom)")}},async({tabId:e,zoomFactor:r})=>{try{return await chrome.tabs.setZoom(e,r),this.formatSuccess(`Set zoom factor to ${r===0?"default":r}`)}catch(o){return this.formatError(o)}});}registerGetZoomSettings(){this.server.registerTool("get_tab_zoom_settings",{description:"Gets the current zoom settings of a tab",inputSchema:{tabId:z$1.number().optional().describe("Tab ID (defaults to active tab)")}},async({tabId:e})=>{try{let r=await chrome.tabs.getZoomSettings(e);return this.formatJson(r)}catch(r){return this.formatError(r)}});}registerSetZoomSettings(){this.server.registerTool("set_tab_zoom_settings",{description:"Sets zoom settings for a tab (how zoom changes are handled)",inputSchema:{tabId:z$1.number().optional().describe("Tab ID (defaults to active tab)"),mode:z$1.enum(["automatic","manual","disabled"]).optional().describe("How zoom changes are handled"),scope:z$1.enum(["per-origin","per-tab"]).optional().describe("Whether zoom persists across pages")}},async({tabId:e,mode:r,scope:o})=>{try{let t={};return r&&(t.mode=r),o&&(t.scope=o),await chrome.tabs.setZoomSettings(e,t),this.formatSuccess("Updated zoom settings",t)}catch(t){return this.formatError(t)}});}registerGroupTabs(){this.server.registerTool("group_tabs",{description:"Groups one or more tabs together",inputSchema:{tabIds:z$1.array(z$1.number()).min(1).describe("Tab IDs to group"),groupId:z$1.number().optional().describe("Existing group ID to add tabs to"),createProperties:z$1.object({windowId:z$1.number().optional().describe("Window ID for new group")}).optional().describe("Properties for creating a new group")}},async({tabIds:e,groupId:r,createProperties:o})=>{try{let t={tabIds:e.length===1?e[0]:e};r!==void 0?t.groupId=r:o&&(t.createProperties=o);let s=await chrome.tabs.group(t);return this.formatSuccess(`Grouped ${e.length} tabs into group ${s}`,{groupId:s})}catch(t){return this.formatError(t)}});}registerUngroupTabs(){this.server.registerTool("ungroup_tabs",{description:"Removes tabs from their groups",inputSchema:{tabIds:z$1.array(z$1.number()).min(1).describe("Tab IDs to ungroup")}},async({tabIds:e})=>{try{return await chrome.tabs.ungroup(e.length===1?e[0]:e),this.formatSuccess(`Ungrouped ${e.length} tab(s)`)}catch(r){return this.formatError(r)}});}registerHighlightTabs(){this.server.registerTool("highlight_tabs",{description:"Highlights the given tabs and focuses on the first one",inputSchema:{tabs:z$1.array(z$1.number()).min(1).describe("Tab indices to highlight"),windowId:z$1.number().optional().describe("Window ID containing the tabs")}},async({tabs:e,windowId:r})=>{try{let o={tabs:e.length===1?e[0]:e};r!==void 0&&(o.windowId=r);let t=await chrome.tabs.highlight(o);return this.formatSuccess(`Highlighted ${e.length} tab(s)`,{window:t})}catch(o){return this.formatError(o)}});}registerMoveTabs(){this.server.registerTool("move_tabs",{description:"Moves tabs to a new position within their window or to another window",inputSchema:{tabIds:z$1.array(z$1.number()).min(1).describe("Tab IDs to move"),index:z$1.number().describe("Position to move tabs to (-1 for end)"),windowId:z$1.number().optional().describe("Target window ID")}},async({tabIds:e,index:r,windowId:o})=>{try{let t={index:r};o!==void 0&&(t.windowId=o);let s=chrome.tabs.move(e.length===1?e[0]:e,t);return this.formatSuccess(`Moved ${e.length} tab(s) to index ${r}`,{tabs:s})}catch(t){return this.formatError(t)}});}registerSendMessage(){this.server.registerTool("send_message_to_tab",{description:"Sends a message to content scripts in a specific tab",inputSchema:{tabId:z$1.number().describe("Tab ID to send message to"),message:z$1.any().describe("Message to send (must be JSON-serializable)"),frameId:z$1.number().optional().describe("Specific frame ID to target"),documentId:z$1.string().optional().describe("Specific document ID to target")}},async({tabId:e,message:r,frameId:o,documentId:t})=>{try{let s={};o!==void 0&&(s.frameId=o),t!==void 0&&(s.documentId=t);let i=await chrome.tabs.sendMessage(e,r,s);return this.formatSuccess("Message sent successfully",{response:i})}catch(s){return this.formatError(s)}});}};var D=class extends h{apiName="Windows";constructor(e,r={}){super(e,r);}checkAvailability(){try{return chrome.windows?typeof chrome.windows.getAll!="function"?{available:!1,message:"chrome.windows.getAll is not available",details:"The windows API appears to be partially available. This may be a restricted environment."}:(chrome.windows.getCurrent({},()=>{if(chrome.runtime.lastError)throw new Error(chrome.runtime.lastError.message)}),{available:!0,message:"Windows API is fully available"}):{available:!1,message:"chrome.windows API is not defined",details:"This extension may not have access to the windows API. Some browser environments do not support this API."}}catch(e){return {available:false,message:"Failed to access chrome.windows API",details:e instanceof Error?e.message:"Unknown error occurred"}}}registerTools(){this.shouldRegisterTool("getAllWindows")&&this.registerGetAllWindows(),this.shouldRegisterTool("createWindow")&&this.registerCreateWindow(),this.shouldRegisterTool("updateWindow")&&this.registerUpdateWindow(),this.shouldRegisterTool("removeWindow")&&this.registerRemoveWindow();}registerGetAllWindows(){this.server.registerTool("get_all_windows",{description:"Get information about all browser windows",inputSchema:{populate:z$1.boolean().optional().describe("Include tabs information")}},async({populate:e})=>{try{let r=await chrome.windows.getAll({populate:e});return this.formatJson(r)}catch(r){return this.formatError(r)}});}registerCreateWindow(){this.server.registerTool("create_window",{description:"Create a new browser window",inputSchema:{url:z$1.union([z$1.string(),z$1.array(z$1.string())]).optional().describe("URL(s) to open in the new window"),incognito:z$1.boolean().optional().describe("Open as incognito window"),focused:z$1.boolean().optional().describe("Whether window should be focused"),width:z$1.number().optional().describe("Window width in pixels"),height:z$1.number().optional().describe("Window height in pixels"),left:z$1.number().optional().describe("Left position of the window"),top:z$1.number().optional().describe("Top position of the window"),type:z$1.enum(["normal","popup","panel","devtools"]).optional().describe("Window type")}},async({url:e,incognito:r,focused:o,width:t,height:s,left:i,top:l,type:a})=>{try{let u={};e!==void 0&&(u.url=e),r!==void 0&&(u.incognito=r),o!==void 0&&(u.focused=o),t!==void 0&&(u.width=t),s!==void 0&&(u.height=s),i!==void 0&&(u.left=i),l!==void 0&&(u.top=l),a!==void 0&&(u.type=a);let S=await chrome.windows.create(u);return this.formatSuccess(`Created window ${S.id} with ${S.tabs?.length||0} tab(s)`)}catch(u){return this.formatError(u)}});}registerUpdateWindow(){this.server.registerTool("update_window",{description:"Update properties of an existing window",inputSchema:{windowId:z$1.number().describe("ID of the window to update"),focused:z$1.boolean().optional().describe("Whether to bring the window to the front"),width:z$1.number().optional().describe("New width in pixels"),height:z$1.number().optional().describe("New height in pixels"),left:z$1.number().optional().describe("New left position"),top:z$1.number().optional().describe("New top position"),state:z$1.enum(["normal","minimized","maximized","fullscreen"]).optional().describe("Window state")}},async({windowId:e,focused:r,width:o,height:t,left:s,top:i,state:l})=>{try{let a={};r!==void 0&&(a.focused=r),o!==void 0&&(a.width=o),t!==void 0&&(a.height=t),s!==void 0&&(a.left=s),i!==void 0&&(a.top=i),l!==void 0&&(a.state=l);let u=await chrome.windows.update(e,a);return this.formatSuccess(`Updated window ${u.id}`,a)}catch(a){return this.formatError(a)}});}registerRemoveWindow(){this.server.registerTool("remove_window",{description:"Close a browser window",inputSchema:{windowId:z$1.number().describe("ID of the window to close")}},async({windowId:e})=>{try{return await chrome.windows.remove(e),this.formatSuccess(`Closed window ${e}`)}catch(r){return this.formatError(r)}});}};var U=class extends h{apiName="Bookmarks";constructor(e,r={}){super(e,r);}checkAvailability(){try{return chrome.bookmarks?(chrome.bookmarks.getTree(()=>{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 to access bookmarks'}}catch(e){return {available:false,message:"Failed to access chrome.bookmarks API",details:e instanceof Error?e.message:'Missing "bookmarks" permission in manifest.json'}}}registerTools(){this.shouldRegisterTool("getBookmarks")&&this.registerGetBookmarks(),this.shouldRegisterTool("createBookmark")&&this.registerCreateBookmark(),this.shouldRegisterTool("updateBookmark")&&this.registerUpdateBookmark(),this.shouldRegisterTool("removeBookmark")&&this.registerRemoveBookmark(),this.shouldRegisterTool("moveBookmark")&&this.registerMoveBookmark();}registerGetBookmarks(){this.server.registerTool("get_bookmarks",{description:"Get bookmarks from the browser",inputSchema:{query:z$1.string().optional().describe("Search query for bookmarks"),folderId:z$1.string().optional().describe("Get bookmarks from a specific folder")}},async({query:e,folderId:r})=>{try{let o;return e?o=await chrome.bookmarks.search(e):r?o=await chrome.bookmarks.getSubTree(r):o=await chrome.bookmarks.getTree(),this.formatJson(o)}catch(o){return this.formatError(o)}});}registerCreateBookmark(){this.server.registerTool("create_bookmark",{description:"Create a new bookmark",inputSchema:{title:z$1.string().describe("Bookmark title"),url:z$1.string().describe("Bookmark URL"),parentId:z$1.string().optional().describe('Parent folder ID (defaults to "Other Bookmarks")'),index:z$1.number().optional().describe("Position within parent folder")}},async({title:e,url:r,parentId:o,index:t})=>{try{let s={title:e,url:r};o!==void 0&&(s.parentId=o),t!==void 0&&(s.index=t);let i=await chrome.bookmarks.create(s);return this.formatSuccess(`Created bookmark: ${i.title} (${i.url})`,i)}catch(s){return this.formatError(s)}});}registerUpdateBookmark(){this.server.registerTool("update_bookmark",{description:"Update an existing bookmark",inputSchema:{id:z$1.string().describe("Bookmark ID to update"),title:z$1.string().optional().describe("New title"),url:z$1.string().optional().describe("New URL")}},async({id:e,title:r,url:o})=>{try{let t={};r!==void 0&&(t.title=r),o!==void 0&&(t.url=o);let s=await chrome.bookmarks.update(e,t);return this.formatSuccess(`Updated bookmark ${e}`,s)}catch(t){return this.formatError(t)}});}registerRemoveBookmark(){this.server.registerTool("remove_bookmark",{description:"Remove a bookmark or bookmark folder",inputSchema:{id:z$1.string().describe("Bookmark ID to remove")}},async({id:e})=>{try{return await chrome.bookmarks.remove(e),this.formatSuccess(`Removed bookmark ${e}`)}catch(r){return this.formatError(r)}});}registerMoveBookmark(){this.server.registerTool("move_bookmark",{description:"Move a bookmark to a different folder",inputSchema:{id:z$1.string().describe("Bookmark ID to move"),parentId:z$1.string().describe("New parent folder ID"),index:z$1.number().optional().describe("Position within new parent folder")}},async({id:e,parentId:r,index:o})=>{try{let t={parentId:r};o!==void 0&&(t.index=o);let s=await chrome.bookmarks.move(e,t);return this.formatSuccess(`Moved bookmark ${e} to parent ${r}`,s)}catch(t){return this.formatError(t)}});}};var V=class extends h{apiName="Storage";constructor(e,r={}){super(e,r);}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 new Error(chrome.runtime.lastError.message)}),{available:!0,message:`Storage API is available with areas: ${e.join(", ")}`})}catch(e){return {available:false,message:"Failed to access chrome.storage API",details:e instanceof Error?e.message:"Unknown error occurred"}}}registerTools(){this.shouldRegisterTool("getStorage")&&this.registerGetStorage(),this.shouldRegisterTool("setStorage")&&this.registerSetStorage(),this.shouldRegisterTool("removeStorage")&&this.registerRemoveStorage(),this.shouldRegisterTool("clearStorage")&&this.registerClearStorage(),this.shouldRegisterTool("getBytesInUse")&&this.registerGetBytesInUse();}getAvailableAreas(){let e=[];return chrome.storage.sync&&e.push("sync"),chrome.storage.local&&e.push("local"),chrome.storage.session&&e.push("session"),e}registerGetStorage(){let e=this.getAvailableAreas();this.server.registerTool("get_storage",{description:"Get data from extension storage",inputSchema:{keys:z$1.array(z$1.string()).optional().describe("Specific keys to retrieve (omit for all)"),area:z$1.enum(e).optional().describe(`Storage area to use. Available: ${e.join(", ")} (default: local)`)}},async({keys:r,area:o="local"})=>{try{let t=chrome.storage[o];if(!t||typeof t.get!="function")return this.formatError(new Error(`Storage area '${o}' is not available`));let s=await t.get(r||null),i={area:o,data:s,keyCount:Object.keys(s).length};return this.formatJson(i)}catch(t){return this.formatError(t)}});}registerSetStorage(){let e=this.getAvailableAreas();this.server.registerTool("set_storage",{description:"Set data in extension storage",inputSchema:{data:z$1.record(z$1.any()).describe("Key-value pairs to store"),area:z$1.enum(e).optional().describe(`Storage area to use. Available: ${e.join(", ")} (default: local)`)}},async({data:r,area:o="local"})=>{try{let t=chrome.storage[o];return !t||typeof t.set!="function"?this.formatError(new Error(`Storage area '${o}' is not available`)):(await t.set(r),this.formatSuccess(`Stored ${Object.keys(r).length} key(s) in ${o} storage`,{keys:Object.keys(r)}))}catch(t){return this.formatError(t)}});}registerRemoveStorage(){let e=this.getAvailableAreas();this.server.registerTool("remove_storage",{description:"Remove specific keys from extension storage",inputSchema:{keys:z$1.array(z$1.string()).describe("Keys to remove from storage"),area:z$1.enum(e).optional().describe(`Storage area to use. Available: ${e.join(", ")} (default: local)`)}},async({keys:r,area:o="local"})=>{try{let t=chrome.storage[o];return !t||typeof t.remove!="function"?this.formatError(new Error(`Storage area '${o}' is not available`)):(await t.remove(r),this.formatSuccess(`Removed ${r.length} key(s) from ${o} storage`,{keys:r}))}catch(t){return this.formatError(t)}});}registerClearStorage(){let e=this.getAvailableAreas();this.server.registerTool("clear_storage",{description:"Clear all data from a storage area",inputSchema:{area:z$1.enum(e).describe(`Storage area to clear. Available: ${e.join(", ")}`),confirm:z$1.boolean().describe("Confirmation flag - must be true to clear storage")}},async({area:r,confirm:o})=>{try{if(!o)return this.formatError(new Error("Clear operation requires confirm=true to prevent accidental data loss"));let t=chrome.storage[r];return !t||typeof t.clear!="function"?this.formatError(new Error(`Storage area '${r}' is not available`)):(await t.clear(),this.formatSuccess(`Cleared all data from ${r} storage`))}catch(t){return this.formatError(t)}});}registerGetBytesInUse(){let e=this.getAvailableAreas();this.server.registerTool("get_storage_bytes_in_use",{description:"Get the amount of storage space used",inputSchema:{keys:z$1.array(z$1.string()).optional().describe("Specific keys to check (omit for total)"),area:z$1.enum(e).optional().describe(`Storage area to check. Available: ${e.join(", ")} (default: local)`)}},async({keys:r,area:o="local"})=>{try{let t=chrome.storage[o];if(!t)return this.formatError(new Error(`Storage area '${o}' is not available`));if(typeof t.getBytesInUse!="function")return this.formatError(new Error(`getBytesInUse is not supported for ${o} storage area`));let s=await t.getBytesInUse(r||null),i=null;return o==="sync"&&chrome.storage.sync.QUOTA_BYTES?i={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}:o==="local"&&chrome.storage.local.QUOTA_BYTES&&(i={quotaBytes:chrome.storage.local.QUOTA_BYTES}),this.formatJson({area:o,bytesInUse:s,humanReadable:this.formatBytes(s),quota:i,percentageUsed:i?.quotaBytes?(s/i.quotaBytes*100).toFixed(2)+"%":null})}catch(t){return this.formatError(t)}});}formatBytes(e){if(e===0)return "0 Bytes";let r=1024,o=["Bytes","KB","MB","GB"],t=Math.floor(Math.log(e)/Math.log(r));return parseFloat((e/Math.pow(r,t)).toFixed(2))+" "+o[t]}};var M=class extends h{apiName="History";constructor(e,r={}){super(e,r);}checkAvailability(){try{return chrome.history?(chrome.history.search({text:"",maxResults:1},()=>{if(chrome.runtime.lastError)throw new Error(chrome.runtime.lastError.message)}),{available:!0,message:"History API is fully available"}):{available:!1,message:"chrome.history API is not defined",details:'This extension needs the "history" permission in its manifest.json to access browsing history'}}catch(e){return {available:false,message:"Failed to access chrome.history API",details:e instanceof Error?e.message:'Missing "history" permission in manifest.json'}}}registerTools(){this.shouldRegisterTool("searchHistory")&&this.registerSearchHistory(),this.shouldRegisterTool("addToHistory")&&this.registerAddToHistory(),this.shouldRegisterTool("deleteFromHistory")&&this.registerDeleteFromHistory(),this.shouldRegisterTool("deleteHistoryRange")&&this.registerDeleteHistoryRange(),this.shouldRegisterTool("getVisits")&&this.registerGetVisits();}registerSearchHistory(){this.server.registerTool("search_history",{description:"Search browser history",inputSchema:{text:z$1.string().describe("Text to search for in history (empty string returns all)"),maxResults:z$1.number().optional().default(100).describe("Maximum number of results (default: 100)"),startTime:z$1.number().optional().describe("Start time in milliseconds since epoch"),endTime:z$1.number().optional().describe("End time in milliseconds since epoch")}},async({text:e,maxResults:r=100,startTime:o,endTime:t})=>{try{let s={text:e,maxResults:r};o!==void 0&&(s.startTime=o),t!==void 0&&(s.endTime=t);let i=await chrome.history.search(s),l=i.map(a=>({title:a.title,url:a.url,lastVisitTime:a.lastVisitTime?new Date(a.lastVisitTime).toISOString():null,visitCount:a.visitCount,typedCount:a.typedCount}));return this.formatJson({query:{text:e,maxResults:r,startTime:o,endTime:t},resultCount:i.length,results:l})}catch(s){return this.formatError(s)}});}registerAddToHistory(){this.server.registerTool("add_to_history",{description:"Add a URL to browser history",inputSchema:{url:z$1.string().url().describe("URL to add to history")}},async({url:e})=>{try{return await chrome.history.addUrl({url:e}),this.formatSuccess(`Added ${e} to browser history`)}catch(r){return this.formatError(r)}});}registerDeleteFromHistory(){this.server.registerTool("delete_from_history",{description:"Delete a specific URL from browser history",inputSchema:{url:z$1.string().url().describe("URL to delete from history")}},async({url:e})=>{try{return await chrome.history.deleteUrl({url:e}),this.formatSuccess(`Deleted ${e} from browser history`)}catch(r){return this.formatError(r)}});}registerDeleteHistoryRange(){this.server.registerTool("delete_history_range",{description:"Delete all history within a time range",inputSchema:{startTime:z$1.number().describe("Start time in milliseconds since epoch"),endTime:z$1.number().describe("End time in milliseconds since epoch")}},async({startTime:e,endTime:r})=>{try{await chrome.history.deleteRange({startTime:e,endTime:r});let o=new Date(e).toISOString(),t=new Date(r).toISOString();return this.formatSuccess(`Deleted history from ${o} to ${t}`)}catch(o){return this.formatError(o)}});}registerGetVisits(){this.server.registerTool("get_visits",{description:"Get detailed visit information for a specific URL",inputSchema:{url:z$1.string().url().describe("URL to get visit details for")}},async({url:e})=>{try{let r=await chrome.history.getVisits({url:e}),o=r.map(s=>({visitId:s.visitId,visitTime:s.visitTime?new Date(s.visitTime).toISOString():null,referringVisitId:s.referringVisitId,transition:s.transition})),[t]=await chrome.history.search({text:e,maxResults:1});return this.formatJson({url:e,pageInfo:t?{title:t.title,visitCount:t.visitCount,typedCount:t.typedCount}:null,visits:o,visitCount:r.length})}catch(r){return this.formatError(r)}});}};var L=class extends h{apiName="Notifications";constructor(e,r={}){super(e,r);}checkAvailability(){try{return chrome.notifications?typeof chrome.notifications.create!="function"?{available:!1,message:"chrome.notifications.create is not available",details:"The notifications API appears to be partially available. Check manifest permissions."}:(chrome.notifications.getPermissionLevel(e=>{if(chrome.runtime.lastError)throw new Error(chrome.runtime.lastError.message)}),{available:!0,message:"Notifications API is fully available"}):{available:!1,message:"chrome.notifications API is not defined",details:'This extension needs the "notifications" permission in its manifest.json'}}catch(e){return {available:false,message:"Failed to access chrome.notifications API",details:e instanceof Error?e.message:'Missing "notifications" permission in manifest.json'}}}registerTools(){this.shouldRegisterTool("createNotification")&&this.registerCreateNotification(),this.shouldRegisterTool("updateNotification")&&this.registerUpdateNotification(),this.shouldRegisterTool("clearNotification")&&this.registerClearNotification(),this.shouldRegisterTool("getAll")&&this.registerGetAll();}registerCreateNotification(){this.server.registerTool("create_notification",{description:"Create a browser notification",inputSchema:{title:z$1.string().describe("Notification title"),message:z$1.string().describe("Notification message"),type:z$1.enum(["basic","image","list","progress"]).optional().default("basic").describe("Notification type"),iconUrl:z$1.string().optional().describe("Icon URL (defaults to extension icon)"),imageUrl:z$1.string().optional().describe("Image URL (for image type notifications)"),items:z$1.array(z$1.object({title:z$1.string(),message:z$1.string()})).optional().describe("List items (for list type notifications)"),progress:z$1.number().min(0).max(100).optional().describe("Progress percentage (for progress type notifications)"),buttons:z$1.array(z$1.object({title:z$1.string(),iconUrl:z$1.string().optional()})).max(2).optional().describe("Action buttons (max 2)"),priority:z$1.number().min(-2).max(2).optional().describe("Priority level (-2 to 2)"),requireInteraction:z$1.boolean().optional().describe("Keep notification until user interacts"),notificationId:z$1.string().optional().describe("Custom notification ID (auto-generated if not provided)")}},async({title:e,message:r,type:o="basic",iconUrl:t,imageUrl:s,items:i,progress:l,buttons:a,priority:u,requireInteraction:S,notificationId:d})=>{try{let g=d||`notification_${Date.now()}`,C={type:o,title:e,message:r,iconUrl:t||chrome.runtime.getURL("icon/128.png"),priority:u,requireInteraction:S};return o==="image"&&s&&(C.imageUrl=s),o==="list"&&i&&(C.items=i),o==="progress"&&l!==void 0&&(C.progress=l),a&&(C.buttons=a),await new Promise((E,O)=>{chrome.notifications.create(g,C,re=>{chrome.runtime.lastError?O(new Error(chrome.runtime.lastError.message)):E();});}),this.formatSuccess(`Created notification: ${g}`,{notificationId:g,options:C})}catch(g){return this.formatError(g)}});}registerUpdateNotification(){this.server.registerTool("update_notification",{description:"Update an existing notification",inputSchema:{notificationId:z$1.string().describe("ID of the notification to update"),title:z$1.string().optional().describe("New title"),message:z$1.string().optional().describe("New message"),progress:z$1.number().min(0).max(100).optional().describe("New progress (for progress type notifications)"),buttons:z$1.array(z$1.object({title:z$1.string(),iconUrl:z$1.string().optional()})).max(2).optional().describe("New buttons")}},async({notificationId:e,title:r,message:o,progress:t,buttons:s})=>{try{let i={};return r!==void 0&&(i.title=r),o!==void 0&&(i.message=o),t!==void 0&&(i.progress=t),s!==void 0&&(i.buttons=s),await chrome.notifications.update(e,i)?this.formatSuccess(`Updated notification: ${e}`,{options:i}):this.formatError(new Error(`Notification ${e} not found or could not be updated`))}catch(i){return this.formatError(i)}});}registerClearNotification(){this.server.registerTool("clear_notification",{description:"Clear a specific notification",inputSchema:{notificationId:z$1.string().describe("ID of the notification to clear")}},async({notificationId:e})=>{try{return await chrome.notifications.clear(e)?this.formatSuccess(`Cleared notification: ${e}`):this.formatError(new Error(`Notification ${e} not found or already cleared`))}catch(r){return this.formatError(r)}});}registerGetAll(){this.server.registerTool("get_all_notifications",{description:"Get all active notifications",inputSchema:{}},async()=>{try{let e=await chrome.notifications.getAll(),r=Object.entries(e).map(([o,t])=>({id:o,...t}));return this.formatJson({count:r.length,notifications:r})}catch(e){return this.formatError(e)}});}};var G=class extends h{apiName="Scripting";constructor(e,r={}){super(e,r);}checkAvailability(){try{return chrome.scripting?typeof chrome.scripting.executeScript!="function"?{available:!1,message:"chrome.scripting.executeScript is not available",details:'The scripting API appears to be partially available. Ensure you have Chrome 88+ and the "scripting" permission.'}:{available:!0,message:"Scripting API is available"}:{available:!1,message:"chrome.scripting API is not defined",details:'This extension needs the "scripting" permission in its manifest.json. This API is available in Chrome 88+.'}}catch(e){return {available:false,message:"Failed to access chrome.scripting API",details:e instanceof Error?e.message:"Unknown error occurred"}}}registerTools(){this.shouldRegisterTool("executeScript")&&this.registerExecuteScript(),this.shouldRegisterTool("executeUserScript")&&this.checkAndRegisterUserScripts(),this.shouldRegisterTool("insertCSS")&&this.registerInsertCSS(),this.shouldRegisterTool("removeCSS")&&this.registerRemoveCSS();}checkAndRegisterUserScripts(){if(!chrome.userScripts){console.warn(" \u2717 UserScripts API not available - Chrome 120+ required");return}try{chrome.userScripts.getScripts(),this.getChromeVersion()>=135?(console.log(" \u2713 UserScripts execute() method available (Chrome 135+)"),this.registerUserScriptExecute()):(console.log(" \u2713 UserScripts API available (legacy mode)"),this.registerUserScriptLegacy());}catch{console.warn(' \u2717 UserScripts API not enabled. Users need to enable developer mode and "User Scripts" toggle in chrome://extensions');}}getChromeVersion(){let e=navigator.userAgent.match(/(Chrome|Chromium)\/([0-9]+)/);return e?Number(e[2]):0}registerExecuteScript(){this.server.registerTool("execute_script",{description:"Execute JavaScript code in a specific tab using chrome.scripting API. Limited by CSP restrictions. If no tabId is specified, operates on the currently active tab",inputSchema:{tabId:z$1.number().optional().describe("Tab ID to execute script in (defaults to active tab)"),code:z$1.string().describe("JavaScript code to execute"),allFrames:z$1.boolean().optional().describe("Execute in all frames (default: false)"),world:z$1.enum(["MAIN","ISOLATED"]).optional().default("MAIN").describe("Execution world - MAIN runs in page context, ISOLATED runs in extension context")}},async({tabId:e,code:r,allFrames:o=false,world:t="MAIN"})=>{try{if(e===void 0){let[l]=await chrome.tabs.query({active:!0,currentWindow:!0});if(!l||!l.id)return this.formatError(new Error("No active tab found"));e=l.id;}let s=l=>{try{let a=document.createElement("script");a.textContent=`
|
|
3
|
+
(function() {
|
|
4
|
+
try {
|
|
5
|
+
const __result = (function() { ${l} })();
|
|
6
|
+
window.__extensionScriptResult = { success: true, result: __result };
|
|
7
|
+
} catch (error) {
|
|
8
|
+
window.__extensionScriptResult = {
|
|
9
|
+
success: false,
|
|
10
|
+
error: error.message || String(error)
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
})();
|
|
14
|
+
`,document.documentElement.appendChild(a),a.remove();let u=window.__extensionScriptResult;return delete window.__extensionScriptResult,u||{success:!1,error:"No result returned"}}catch(a){return {success:!1,error:a instanceof Error?a.message:String(a)}}},i=await chrome.scripting.executeScript({target:{tabId:e,allFrames:o},func:s,args:[r],world:t});return this.formatJson(i)}catch(s){return this.formatError(s)}});}registerUserScriptExecute(){this.server.registerTool("execute_user_script",{description:"Execute JavaScript using User Scripts API with no CSP restrictions (Chrome 135+). Requires user to enable developer mode. If no tabId is specified, operates on the currently active tab",inputSchema:{tabId:z$1.number().optional().describe("Tab ID to execute script in (defaults to active tab)"),code:z$1.string().describe("JavaScript code to execute"),allFrames:z$1.boolean().optional().describe("Execute in all frames (default: false)"),world:z$1.enum(["USER_SCRIPT","MAIN"]).optional().default("USER_SCRIPT").describe("Execution world (default: USER_SCRIPT for no CSP restrictions)")}},async({tabId:e,code:r,allFrames:o=false,world:t="USER_SCRIPT"})=>{try{if(e===void 0){let[i]=await chrome.tabs.query({active:!0,currentWindow:!0});if(!i||!i.id)return this.formatError(new Error("No active tab found"));e=i.id;}chrome.userScripts.configureWorld({messaging:!0,csp:"script-src 'self' 'unsafe-eval'; object-src 'self';"});let s=await chrome.userScripts.execute({target:{tabId:e,allFrames:o},world:t,js:[{code:r}],injectImmediately:!0});return this.formatJson(s)}catch(s){return s instanceof Error&&s.message.includes("User Scripts")?this.formatError(new Error('User Scripts API is not enabled. Enable developer mode and the "User Scripts" toggle in chrome://extensions/?id='+chrome.runtime.id)):this.formatError(s)}});}registerUserScriptLegacy(){this.server.registerTool("execute_user_script_legacy",{description:"Execute JavaScript using User Scripts API (legacy method for Chrome < 135). No CSP restrictions. If no tabId is specified, operates on the currently active tab",inputSchema:{tabId:z$1.number().optional().describe("Tab ID to execute script in (defaults to active tab)"),code:z$1.string().describe("JavaScript code to execute"),allFrames:z$1.boolean().optional().describe("Execute in all frames (default: false)")}},async({tabId:e,code:r,allFrames:o=false})=>{try{if(e===void 0){let[a]=await chrome.tabs.query({active:!0,currentWindow:!0});if(!a||!a.id)return this.formatError(new Error("No active tab found"));e=a.id;}let t=await chrome.tabs.get(e);if(!t.url)return this.formatError(new Error("Tab URL not available"));let s=`temp_${Date.now()}`;await chrome.userScripts.configureWorld({messaging:!0});let i=new Promise(a=>{let u=(S,d)=>{S.type==="SCRIPT_RESULT"&&S.scriptId===s&&(chrome.runtime.onUserScriptMessage.removeListener(u),a(S));};chrome.runtime.onUserScriptMessage.addListener(u);});await chrome.userScripts.register([{id:s,matches:[new URL(t.url).origin+"/*"],js:[{code:`
|
|
15
|
+
(async () => {
|
|
16
|
+
try {
|
|
17
|
+
const result = await (async () => { ${r} })();
|
|
18
|
+
chrome.runtime.sendMessage({
|
|
19
|
+
type: 'SCRIPT_RESULT',
|
|
20
|
+
scriptId: '${s}',
|
|
21
|
+
success: true,
|
|
22
|
+
result
|
|
23
|
+
});
|
|
24
|
+
} catch (error) {
|
|
25
|
+
chrome.runtime.sendMessage({
|
|
26
|
+
type: 'SCRIPT_RESULT',
|
|
27
|
+
scriptId: '${s}',
|
|
28
|
+
success: false,
|
|
29
|
+
error: error.message
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
})();
|
|
33
|
+
`}],runAt:"document_idle",world:"USER_SCRIPT",allFrames:o}]),await chrome.tabs.reload(e);let l=await Promise.race([i,new Promise(a=>setTimeout(()=>a({timeout:!0}),5e3))]);return await chrome.userScripts.unregister({ids:[s]}),l.timeout?this.formatError(new Error("Script execution timed out")):this.formatJson(l)}catch(t){return this.formatError(t)}});}registerInsertCSS(){this.server.registerTool("insert_css",{description:"Insert CSS into a tab. If no tabId is specified, operates on the currently active tab",inputSchema:{tabId:z$1.number().optional().describe("Tab ID to insert CSS into (defaults to active tab)"),css:z$1.string().describe("CSS code to inject"),allFrames:z$1.boolean().optional().describe("Inject in all frames (default: false)")}},async({tabId:e,css:r,allFrames:o=false})=>{try{if(e===void 0){let[t]=await chrome.tabs.query({active:!0,currentWindow:!0});if(!t||!t.id)return this.formatError(new Error("No active tab found"));e=t.id;}return await chrome.scripting.insertCSS({target:{tabId:e,allFrames:o},css:r}),this.formatSuccess(`CSS injected into tab ${e}`)}catch(t){return this.formatError(t)}});}registerRemoveCSS(){if(typeof chrome.scripting.removeCSS!="function"){console.warn(" \u2717 removeCSS not available - Chrome 90+ required");return}this.server.registerTool("remove_css",{description:"Remove previously injected CSS from a tab. If no tabId is specified, operates on the currently active tab",inputSchema:{tabId:z$1.number().optional().describe("Tab ID to remove CSS from (defaults to active tab)"),css:z$1.string().describe("CSS code to remove (must match exactly)"),allFrames:z$1.boolean().optional().describe("Remove from all frames (default: false)")}},async({tabId:e,css:r,allFrames:o=false})=>{try{if(e===void 0){let[t]=await chrome.tabs.query({active:!0,currentWindow:!0});if(!t||!t.id)return this.formatError(new Error("No active tab found"));e=t.id;}return await chrome.scripting.removeCSS({target:{tabId:e,allFrames:o},css:r}),this.formatSuccess(`CSS removed from tab ${e}`)}catch(t){return this.formatError(t)}});}};var q=class extends h{apiName="Cookies";constructor(e,r={}){super(e,r);}checkAvailability(){try{return chrome.cookies?typeof chrome.cookies.getAll!="function"?{available:!1,message:"chrome.cookies.getAll is not available",details:"The cookies API appears to be partially available. Check manifest permissions."}:(chrome.cookies.getAll({},()=>{if(chrome.runtime.lastError)throw new Error(chrome.runtime.lastError.message)}),{available:!0,message:"Cookies API is fully available"}):{available:!1,message:"chrome.cookies API is not defined",details:'This extension needs the "cookies" permission in its manifest.json. Also requires host permissions for the domains you want to access.'}}catch(e){return {available:false,message:"Failed to access chrome.cookies API",details:e instanceof Error?e.message:'Missing "cookies" permission or host permissions in manifest.json'}}}registerTools(){this.shouldRegisterTool("getCookies")&&this.registerGetCookies(),this.shouldRegisterTool("setCookie")&&this.registerSetCookie(),this.shouldRegisterTool("removeCookie")&&this.registerRemoveCookie(),this.shouldRegisterTool("getAllCookieStores")&&this.registerGetAllCookieStores();}registerGetCookies(){this.server.registerTool("get_cookies",{description:"Get cookies for a specific URL or domain",inputSchema:{url:z$1.string().optional().describe("URL to get cookies for"),domain:z$1.string().optional().describe("Domain to get cookies for"),name:z$1.string().optional().describe("Specific cookie name"),storeId:z$1.string().optional().describe("Cookie store ID (for different profiles/containers)"),session:z$1.boolean().optional().describe("Filter by session cookies"),secure:z$1.boolean().optional().describe("Filter by secure cookies"),httpOnly:z$1.boolean().optional().describe("Filter by httpOnly cookies")}},async({url:e,domain:r,name:o,storeId:t,session:s,secure:i,httpOnly:l})=>{try{let a={};e&&(a.url=e),r&&(a.domain=r),o&&(a.name=o),t&&(a.storeId=t),s!==void 0&&(a.session=s),i!==void 0&&(a.secure=i),l!==void 0&&(a.httpOnly=l);let u=await chrome.cookies.getAll(a),S=u.map(d=>({name:d.name,value:d.value,domain:d.domain,path:d.path,secure:d.secure,httpOnly:d.httpOnly,sameSite:d.sameSite,session:d.session,expirationDate:d.expirationDate?new Date(d.expirationDate*1e3).toISOString():null,storeId:d.storeId}));return this.formatJson({count:u.length,filters:a,cookies:S})}catch(a){return this.formatError(a)}});}registerSetCookie(){this.server.registerTool("set_cookie",{description:"Set a cookie",inputSchema:{url:z$1.string().describe("URL for the cookie (required to determine domain)"),name:z$1.string().describe("Cookie name"),value:z$1.string().describe("Cookie value"),domain:z$1.string().optional().describe("Cookie domain (defaults from URL)"),path:z$1.string().optional().default("/").describe("Cookie path"),secure:z$1.boolean().optional().describe("Secure cookie (HTTPS only)"),httpOnly:z$1.boolean().optional().describe("HTTP only cookie (not accessible to JavaScript)"),sameSite:z$1.enum(["no_restriction","lax","strict"]).optional().describe("SameSite attribute"),expirationDate:z$1.number().optional().describe("Expiration date in seconds since epoch"),storeId:z$1.string().optional().describe("Cookie store ID")}},async({url:e,name:r,value:o,domain:t,path:s="/",secure:i,httpOnly:l,sameSite:a,expirationDate:u,storeId:S})=>{try{let d={url:e,name:r,value:o};t!==void 0&&(d.domain=t),s!==void 0&&(d.path=s),i!==void 0&&(d.secure=i),l!==void 0&&(d.httpOnly=l),a!==void 0&&(d.sameSite=a),u!==void 0&&(d.expirationDate=u),S!==void 0&&(d.storeId=S);let g=await chrome.cookies.set(d);return g?this.formatSuccess(`Set cookie: ${g.name} for domain ${g.domain}`,{cookie:{name:g.name,value:g.value,domain:g.domain,path:g.path,secure:g.secure,httpOnly:g.httpOnly,sameSite:g.sameSite,session:g.session,expirationDate:g.expirationDate?new Date(g.expirationDate*1e3).toISOString():null}}):this.formatError(new Error("Failed to set cookie. Check permissions and cookie attributes."))}catch(d){return this.formatError(d)}});}registerRemoveCookie(){this.server.registerTool("remove_cookie",{description:"Remove a specific cookie",inputSchema:{url:z$1.string().describe("URL of the cookie"),name:z$1.string().describe("Name of the cookie to remove"),storeId:z$1.string().optional().describe("Cookie store ID")}},async({url:e,name:r,storeId:o})=>{try{let t={url:e,name:r};o&&(t.storeId=o);let s=await chrome.cookies.remove(t);return s?this.formatSuccess(`Removed cookie: ${r} from ${s.url}`,s):this.formatError(new Error(`Cookie "${r}" not found for URL: ${e}`))}catch(t){return this.formatError(t)}});}registerGetAllCookieStores(){this.server.registerTool("get_all_cookie_stores",{description:"Get all cookie stores (profiles/containers)",inputSchema:{}},async()=>{try{let e=await chrome.cookies.getAllCookieStores(),r=e.map(o=>({id:o.id,tabIds:o.tabIds,incognito:o.incognito}));return this.formatJson({count:e.length,stores:r})}catch(e){return this.formatError(e)}});}};var B=class extends h{apiName="Alarms";constructor(e,r={}){super(e,r);}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("create_alarm",{description:"Create an alarm that fires at a specific time or periodically",inputSchema:{name:z$1.string().optional().describe("Optional name to identify this alarm"),delayInMinutes:z$1.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$1.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$1.number().optional().describe("Time at which the alarm should fire, in milliseconds past the epoch (e.g. Date.now() + n)")}},async({name:e,delayInMinutes:r,periodInMinutes:o,when:t})=>{try{if(r===void 0&&t===void 0)return this.formatError("Either delayInMinutes or when must be specified to create an alarm");let s={};r!==void 0&&(s.delayInMinutes=r),o!==void 0&&(s.periodInMinutes=o),t!==void 0&&(s.when=t),await new Promise((l,a)=>{e?chrome.alarms.create(e,s,()=>{chrome.runtime.lastError?a(new Error(chrome.runtime.lastError.message)):l();}):chrome.alarms.create(s,()=>{chrome.runtime.lastError?a(new Error(chrome.runtime.lastError.message)):l();});});let i=await new Promise((l,a)=>{chrome.alarms.get(e||"",u=>{chrome.runtime.lastError?a(new Error(chrome.runtime.lastError.message)):l(u);});});return this.formatSuccess("Alarm created successfully",{name:i?.name||e||"unnamed",scheduledTime:i?.scheduledTime,periodInMinutes:i?.periodInMinutes})}catch(s){return this.formatError(s)}});}registerGetAlarm(){this.server.registerTool("get_alarm",{description:"Get details about a specific alarm",inputSchema:{name:z$1.string().optional().describe("Name of the alarm to retrieve. If not specified, gets the default unnamed alarm")}},async({name:e})=>{try{let r=await new Promise((o,t)=>{e?chrome.alarms.get(e,s=>{chrome.runtime.lastError?t(new Error(chrome.runtime.lastError.message)):o(s);}):chrome.alarms.get(s=>{chrome.runtime.lastError?t(new Error(chrome.runtime.lastError.message)):o(s);});});return r?this.formatJson({name:r.name,scheduledTime:r.scheduledTime,scheduledTimeFormatted:new Date(r.scheduledTime).toISOString(),periodInMinutes:r.periodInMinutes}):this.formatSuccess("No alarm found",{name:e||"unnamed"})}catch(r){return this.formatError(r)}});}registerGetAllAlarms(){this.server.registerTool("get_all_alarms",{description:"Get all active alarms",inputSchema:{}},async()=>{try{let e=await new Promise((r,o)=>{chrome.alarms.getAll(t=>{chrome.runtime.lastError?o(new Error(chrome.runtime.lastError.message)):r(t);});});return this.formatJson({count:e.length,alarms:e.map(r=>({name:r.name,scheduledTime:r.scheduledTime,scheduledTimeFormatted:new Date(r.scheduledTime).toISOString(),periodInMinutes:r.periodInMinutes}))})}catch(e){return this.formatError(e)}});}registerClearAlarm(){this.server.registerTool("clear_alarm",{description:"Clear a specific alarm",inputSchema:{name:z$1.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((o,t)=>{e?chrome.alarms.clear(e,s=>{chrome.runtime.lastError?t(new Error(chrome.runtime.lastError.message)):o(s);}):chrome.alarms.clear(s=>{chrome.runtime.lastError?t(new Error(chrome.runtime.lastError.message)):o(s);});})?this.formatSuccess("Alarm cleared successfully",{name:e||"unnamed"}):this.formatSuccess("No alarm found to clear",{name:e||"unnamed"})}catch(r){return this.formatError(r)}});}registerClearAllAlarms(){this.server.registerTool("clear_all_alarms",{description:"Clear all alarms",inputSchema:{}},async()=>{try{let e=await new Promise((o,t)=>{chrome.alarms.getAll(s=>{chrome.runtime.lastError?t(new Error(chrome.runtime.lastError.message)):o(s);});});return await new Promise((o,t)=>{chrome.alarms.clearAll(s=>{chrome.runtime.lastError?t(new Error(chrome.runtime.lastError.message)):o(s);});})?this.formatSuccess("All alarms cleared successfully",{clearedCount:e.length,clearedAlarms:e.map(o=>o.name)}):this.formatSuccess("No alarms to clear")}catch(e){return this.formatError(e)}});}};var z=z$1.enum(["in_progress","interrupted","complete"]),Y=z$1.enum(["file","url","content","uncommon","host","unwanted","safe","accepted"]);z$1.enum(["FILE_FAILED","FILE_ACCESS_DENIED","FILE_NO_SPACE","FILE_NAME_TOO_LONG","FILE_TOO_LARGE","FILE_VIRUS_INFECTED","FILE_TRANSIENT_ERROR","FILE_BLOCKED","FILE_SECURITY_CHECK_FAILED","FILE_TOO_SHORT","FILE_HASH_MISMATCH","FILE_SAME_AS_SOURCE","NETWORK_FAILED","NETWORK_TIMEOUT","NETWORK_DISCONNECTED","NETWORK_SERVER_DOWN","NETWORK_INVALID_REQUEST","SERVER_FAILED","SERVER_NO_RANGE","SERVER_BAD_CONTENT","SERVER_UNAUTHORIZED","SERVER_CERT_PROBLEM","SERVER_FORBIDDEN","SERVER_UNREACHABLE","SERVER_CONTENT_LENGTH_MISMATCH","SERVER_CROSS_ORIGIN_REDIRECT","USER_CANCELED","USER_SHUTDOWN","CRASH"]);var F=class extends h{apiName="Downloads";constructor(e,r={}){super(e,r);}checkAvailability(){try{return chrome.downloads?typeof chrome.downloads.search!="function"?{available:!1,message:"chrome.downloads.search is not available",details:"The downloads API appears to be partially available. Check manifest permissions."}:(chrome.downloads.search({},()=>{if(chrome.runtime.lastError)throw new Error(chrome.runtime.lastError.message)}),{available:!0,message:"Downloads API is fully available"}):{available:!1,message:"chrome.downloads API is not defined",details:'This extension needs the "downloads" permission in its manifest.json'}}catch(e){return {available:false,message:"Failed to access chrome.downloads API",details:e instanceof Error?e.message:"Unknown error occurred"}}}registerTools(){this.shouldRegisterTool("download")&&this.registerDownload(),this.shouldRegisterTool("search")&&this.registerSearch(),this.shouldRegisterTool("pause")&&this.registerPause(),this.shouldRegisterTool("resume")&&this.registerResume(),this.shouldRegisterTool("cancel")&&this.registerCancel(),this.shouldRegisterTool("getFileIcon")&&this.registerGetFileIcon(),this.shouldRegisterTool("open")&&this.checkAndRegisterOpen(),this.shouldRegisterTool("show")&&this.registerShow(),this.shouldRegisterTool("erase")&&this.registerErase(),this.shouldRegisterTool("removeFile")&&this.registerRemoveFile(),this.shouldRegisterTool("acceptDanger")&&this.registerAcceptDanger();}checkAndRegisterOpen(){try{typeof chrome.downloads.open=="function"?(this.registerOpen(),console.log(" \u2713 Open download method available")):console.warn(' \u2717 Open download method not available - requires "downloads.open" permission');}catch{console.warn(" \u2717 Failed to check open download availability");}}registerDownload(){this.server.registerTool("download_file",{description:"Initiate a file download from a specified URL",inputSchema:{url:z$1.string().url().describe("The URL to download from"),filename:z$1.string().optional().describe("A file path relative to the Downloads directory. If specified, the file will be saved at this path"),conflictAction:z$1.enum(["uniquify","overwrite","prompt"]).optional().describe("Action to take if filename already exists. uniquify: append number to make unique, overwrite: replace existing file, prompt: ask user"),saveAs:z$1.boolean().optional().describe("Use a file chooser dialog to allow the user to select a filename"),headers:z$1.array(z$1.object({name:z$1.string().describe("HTTP header name"),value:z$1.string().describe("HTTP header value")})).optional().describe("Extra HTTP headers to send with the request"),method:z$1.enum(["GET","POST"]).optional().describe("HTTP method (defaults to GET)"),body:z$1.string().optional().describe("Request body (for POST requests)")}},async({url:e,filename:r,conflictAction:o,saveAs:t,headers:s,method:i,body:l})=>{try{let a={url:e};r!==void 0&&(a.filename=r),o!==void 0&&(a.conflictAction=o),t!==void 0&&(a.saveAs=t),s!==void 0&&(a.headers=s),i!==void 0&&(a.method=i),l!==void 0&&(a.body=l);let u=await chrome.downloads.download(a);return this.formatSuccess(`Download initiated with ID: ${u}`,{downloadId:u,url:e,filename:r||"auto-generated"})}catch(a){return this.formatError(a)}});}registerSearch(){this.server.registerTool("search_downloads",{description:"Search for downloaded files with various filters",inputSchema:{query:z$1.array(z$1.string()).optional().describe("Array of search terms. Downloads must contain all terms to match"),startedBefore:z$1.string().optional().describe("Limit results to downloads started before this date (ISO string)"),startedAfter:z$1.string().optional().describe("Limit results to downloads started after this date (ISO string)"),endedBefore:z$1.string().optional().describe("Limit results to downloads ended before this date (ISO string)"),endedAfter:z$1.string().optional().describe("Limit results to downloads ended after this date (ISO string)"),totalBytesGreater:z$1.number().optional().describe("Limit results to downloads larger than this many bytes"),totalBytesLess:z$1.number().optional().describe("Limit results to downloads smaller than this many bytes"),filenameRegex:z$1.string().optional().describe("Regular expression to match against download filenames"),urlRegex:z$1.string().optional().describe("Regular expression to match against download URLs"),limit:z$1.number().optional().describe("Maximum number of results to return"),orderBy:z$1.array(z$1.string()).optional().describe('Order results by these fields. Prefix with "-" for descending order. Fields: startTime, endTime, totalBytes, filename, url, state'),id:z$1.number().optional().describe("Specific download ID to search for"),state:z.optional().describe("Download state to filter by"),paused:z$1.boolean().optional().describe("Filter by paused state"),danger:Y.optional().describe("Filter by danger type"),mime:z$1.string().optional().describe("MIME type to filter by"),exists:z$1.boolean().optional().describe("Filter by whether the downloaded file still exists")}},async e=>{try{let r={};e.query!==void 0&&(r.query=e.query),e.startedBefore!==void 0&&(r.startedBefore=e.startedBefore),e.startedAfter!==void 0&&(r.startedAfter=e.startedAfter),e.endedBefore!==void 0&&(r.endedBefore=e.endedBefore),e.endedAfter!==void 0&&(r.endedAfter=e.endedAfter),e.totalBytesGreater!==void 0&&(r.totalBytesGreater=e.totalBytesGreater),e.totalBytesLess!==void 0&&(r.totalBytesLess=e.totalBytesLess),e.filenameRegex!==void 0&&(r.filenameRegex=e.filenameRegex),e.urlRegex!==void 0&&(r.urlRegex=e.urlRegex),e.limit!==void 0&&(r.limit=e.limit),e.orderBy!==void 0&&(r.orderBy=e.orderBy),e.id!==void 0&&(r.id=e.id),e.state!==void 0&&(r.state=e.state),e.paused!==void 0&&(r.paused=e.paused),e.danger!==void 0&&(r.danger=e.danger),e.mime!==void 0&&(r.mime=e.mime),e.exists!==void 0&&(r.exists=e.exists);let o=await chrome.downloads.search(r),t=o.map(s=>({id:s.id,url:s.url,finalUrl:s.finalUrl,filename:s.filename,state:s.state,paused:s.paused,danger:s.danger,mime:s.mime,startTime:s.startTime,endTime:s.endTime,bytesReceived:s.bytesReceived,totalBytes:s.totalBytes,fileSize:s.fileSize,exists:s.exists,error:s.error,canResume:s.canResume}));return this.formatJson({count:o.length,downloads:t})}catch(r){return this.formatError(r)}});}registerPause(){this.server.registerTool("pause_download",{description:"Pause an active download",inputSchema:{downloadId:z$1.number().describe("The ID of the download to pause")}},async({downloadId:e})=>{try{return await chrome.downloads.pause(e),this.formatSuccess(`Download ${e} paused successfully`)}catch(r){return this.formatError(r)}});}registerResume(){this.server.registerTool("resume_download",{description:"Resume a paused download",inputSchema:{downloadId:z$1.number().describe("The ID of the download to resume")}},async({downloadId:e})=>{try{return await chrome.downloads.resume(e),this.formatSuccess(`Download ${e} resumed successfully`)}catch(r){return this.formatError(r)}});}registerCancel(){this.server.registerTool("cancel_download",{description:"Cancel an ongoing download",inputSchema:{downloadId:z$1.number().describe("The ID of the download to cancel")}},async({downloadId:e})=>{try{return await chrome.downloads.cancel(e),this.formatSuccess(`Download ${e} cancelled successfully`)}catch(r){return this.formatError(r)}});}registerGetFileIcon(){this.server.registerTool("get_download_file_icon",{description:"Get the icon for a downloaded file",inputSchema:{downloadId:z$1.number().describe("The ID of the download"),size:z$1.number().optional().describe("Icon size in pixels (16 or 32). Defaults to 32")}},async({downloadId:e,size:r})=>{try{let o={};r!==void 0&&(o.size=r);let t=await chrome.downloads.getFileIcon(e,o);return this.formatSuccess("File icon retrieved",{downloadId:e,iconUrl:t,size:r||32})}catch(o){return this.formatError(o)}});}registerOpen(){this.server.registerTool("open_download",{description:'Open a completed downloaded file. Requires "downloads.open" permission',inputSchema:{downloadId:z$1.number().describe("The ID of the download to open")}},async({downloadId:e})=>{try{return await chrome.downloads.open(e),this.formatSuccess(`Download ${e} opened successfully`)}catch(r){return this.formatError(r)}});}registerShow(){this.server.registerTool("show_download_in_folder",{description:"Show the downloaded file in its folder in the file manager",inputSchema:{downloadId:z$1.number().describe("The ID of the download to show")}},async({downloadId:e})=>{try{return await chrome.downloads.show(e),this.formatSuccess(`Download ${e} shown in file manager`)}catch(r){return this.formatError(r)}});}registerErase(){this.server.registerTool("erase_download_history",{description:"Remove download entries from the browser history without deleting the files",inputSchema:{query:z$1.object({id:z$1.number().optional().describe("Specific download ID to erase"),state:z.optional().describe("Erase downloads in this state"),paused:z$1.boolean().optional().describe("Erase paused downloads"),danger:Y.optional().describe("Erase downloads with this danger type"),urlRegex:z$1.string().optional().describe("Erase downloads matching this URL regex"),filenameRegex:z$1.string().optional().describe("Erase downloads matching this filename regex"),query:z$1.array(z$1.string()).optional().describe("Search terms to match")}).describe("Query to identify downloads to erase from history")}},async({query:e})=>{try{let r={};e.id!==void 0&&(r.id=e.id),e.state!==void 0&&(r.state=e.state),e.paused!==void 0&&(r.paused=e.paused),e.danger!==void 0&&(r.danger=e.danger),e.urlRegex!==void 0&&(r.urlRegex=e.urlRegex),e.filenameRegex!==void 0&&(r.filenameRegex=e.filenameRegex),e.query!==void 0&&(r.query=e.query);let o=await chrome.downloads.erase(r);return this.formatSuccess(`Erased ${o.length} download(s) from history`,{erasedIds:o})}catch(r){return this.formatError(r)}});}registerRemoveFile(){this.server.registerTool("remove_downloaded_file",{description:"Remove a downloaded file from disk and erase it from history",inputSchema:{downloadId:z$1.number().describe("The ID of the download to remove")}},async({downloadId:e})=>{try{return await chrome.downloads.removeFile(e),this.formatSuccess(`Download ${e} file removed from disk`)}catch(r){return this.formatError(r)}});}registerAcceptDanger(){this.server.registerTool("accept_dangerous_download",{description:"Accept a dangerous download that was blocked",inputSchema:{downloadId:z$1.number().describe("The ID of the dangerous download to accept")}},async({downloadId:e})=>{try{return await chrome.downloads.acceptDanger(e),this.formatSuccess(`Dangerous download ${e} accepted and will continue`)}catch(r){return this.formatError(r)}});}};var W=class extends h{apiName="Runtime";constructor(e,r={}){super(e,r);}checkAvailability(){try{if(!chrome.runtime)return {available:!1,message:"chrome.runtime API is not defined",details:"The runtime API should always be available in extension contexts"};if(typeof chrome.runtime.getManifest!="function")return {available:!1,message:"chrome.runtime.getManifest is not available",details:"The runtime API appears to be partially available. This is unexpected."};try{let e=chrome.runtime.getManifest();if(!e||typeof e!="object")throw new Error("Invalid manifest returned")}catch(e){return {available:!1,message:"Failed to access runtime API methods",details:e instanceof Error?e.message:"Unknown error occurred"}}return {available:!0,message:"Runtime API is fully available"}}catch(e){return {available:false,message:"Failed to access chrome.runtime API",details:e instanceof Error?e.message:"Unknown error occurred"}}}registerTools(){this.shouldRegisterTool("getExtensionInfo")&&this.registerGetExtensionInfo(),this.shouldRegisterTool("sendMessage")&&this.registerSendMessage(),this.shouldRegisterTool("connect")&&this.registerConnect(),this.shouldRegisterTool("openOptionsPage")&&this.registerOpenOptionsPage(),this.shouldRegisterTool("reload")&&this.registerReload(),this.shouldRegisterTool("setUninstallURL")&&this.registerSetUninstallURL(),this.shouldRegisterTool("getContexts")&&this.checkAndRegisterGetContexts(),this.shouldRegisterTool("getPlatformInfo")&&this.registerGetPlatformInfo();}checkAndRegisterGetContexts(){try{typeof chrome.runtime.getContexts=="function"?(this.registerGetContexts(),console.log(" \u2713 getContexts method available (MV3)")):console.warn(" \u2717 getContexts method not available - requires Manifest V3");}catch{console.warn(" \u2717 Failed to check getContexts availability");}}registerGetExtensionInfo(){this.server.registerTool("get_extension_info",{description:"Get detailed information about the extension including manifest, URLs, and installation details",inputSchema:{}},async()=>{try{let e=chrome.runtime.getManifest(),r=chrome.runtime.id,o={extension:chrome.runtime.getURL(""),optionsPage:e.options_page?chrome.runtime.getURL(e.options_page):null,optionsUI:e.options_ui?.page?chrome.runtime.getURL(e.options_ui.page):null},t=null;try{chrome.management&&typeof chrome.management.getSelf=="function"&&(t=(await chrome.management.getSelf()).installType);}catch{}let s={id:r,name:e.name,version:e.version,manifestVersion:e.manifest_version,description:e.description,permissions:e.permissions||[],optionalPermissions:e.optional_permissions||[],hostPermissions:e.host_permissions||[],urls:o,installType:t,shortName:e.short_name,author:e.author,homepageUrl:e.homepage_url,updateUrl:e.update_url,icons:e.icons,action:e.action,background:e.background,contentScripts:e.content_scripts};return this.formatJson(s)}catch(e){return this.formatError(e)}});}registerSendMessage(){this.server.registerTool("send_runtime_message",{description:"Send a message to the extension or another extension. Messages can be sent to content scripts, the service worker, or other extension contexts.",inputSchema:{message:z$1.any().describe("The message to send. Can be any JSON-serializable value"),extensionId:z$1.string().optional().describe("Target extension ID. Omit to send within the same extension"),options:z$1.object({includeTlsChannelId:z$1.boolean().optional().describe("Whether to include TLS channel ID")}).optional().describe("Message sending options")}},async({message:e,extensionId:r,options:o})=>{try{let t;return r?t=await chrome.runtime.sendMessage(r,e,o||{}):t=await chrome.runtime.sendMessage(e,o||{}),this.formatSuccess("Message sent successfully",{response:t})}catch(t){return this.formatError(t)}});}registerConnect(){this.server.registerTool("create_runtime_port",{description:"Create a long-lived connection port for continuous message passing between extension contexts",inputSchema:{name:z$1.string().optional().describe("Name for the port to help identify it"),extensionId:z$1.string().optional().describe("Target extension ID. Omit to connect within the same extension")}},async({name:e,extensionId:r})=>{try{let o=e?{name:e}:void 0,t=r?chrome.runtime.connect(r,o):chrome.runtime.connect(o),s={name:t.name,sender:t.sender,disconnected:!1};return t.onDisconnect.addListener(()=>{s.disconnected=!0;}),setTimeout(()=>t.disconnect(),100),this.formatSuccess("Port created successfully (auto-disconnected after 100ms)",s)}catch(o){return this.formatError(o)}});}registerOpenOptionsPage(){this.server.registerTool("open_options_page",{description:"Open the extension's options page. The options page will be opened in a new tab if it's an HTML page, or in the extensions management page if using embedded options.",inputSchema:{}},async()=>{try{return await chrome.runtime.openOptionsPage(),this.formatSuccess("Options page opened successfully")}catch(e){return this.formatError(e)}});}registerReload(){this.server.registerTool("reload_extension",{description:"Reload the extension. This will restart the extension, including the service worker and all content scripts. Use with caution as it will disconnect all active connections.",inputSchema:{confirm:z$1.boolean().describe("Confirmation flag - must be true to reload the extension")}},async({confirm:e})=>{try{return e?(chrome.runtime.reload(),this.formatSuccess("Extension reload initiated")):this.formatError(new Error("Reload operation requires confirm=true to prevent accidental reloads"))}catch(r){return this.formatError(r)}});}registerSetUninstallURL(){this.server.registerTool("set_uninstall_url",{description:"Set a URL to be opened when the extension is uninstalled. This can be used for feedback forms or cleanup instructions.",inputSchema:{url:z$1.string().url().describe("The URL to open when the extension is uninstalled. Must be a valid HTTP or HTTPS URL.")}},async({url:e})=>{try{return chrome.runtime.setUninstallURL(e),this.formatSuccess("Uninstall URL set successfully",{url:e})}catch(r){return this.formatError(r)}});}registerGetContexts(){this.server.registerTool("get_extension_contexts",{description:"Get information about all contexts (pages, tabs, workers) associated with the extension (Manifest V3 only)",inputSchema:{filter:z$1.object({contextTypes:z$1.array(z$1.enum(["TAB","POPUP","BACKGROUND","OFFSCREEN_DOCUMENT","SIDE_PANEL"])).optional().describe("Filter by context types"),documentIds:z$1.array(z$1.string()).optional().describe("Filter by document IDs"),documentOrigins:z$1.array(z$1.string()).optional().describe("Filter by document origins"),documentUrls:z$1.array(z$1.string()).optional().describe("Filter by document URLs"),frameIds:z$1.array(z$1.number()).optional().describe("Filter by frame IDs"),incognito:z$1.boolean().optional().describe("Filter by incognito state"),tabIds:z$1.array(z$1.number()).optional().describe("Filter by tab IDs"),windowIds:z$1.array(z$1.number()).optional().describe("Filter by window IDs")}).optional().describe("Filter criteria for contexts")}},async({filter:e})=>{try{let r=await chrome.runtime.getContexts(e||{});return this.formatJson({count:r.length,contexts:r.map(o=>({contextId:o.contextId,contextType:o.contextType,documentId:o.documentId,documentOrigin:o.documentOrigin,documentUrl:o.documentUrl,frameId:o.frameId,incognito:o.incognito,tabId:o.tabId,windowId:o.windowId}))})}catch(r){return this.formatError(r)}});}registerGetPlatformInfo(){this.server.registerTool("get_platform_info",{description:"Get information about the current platform/operating system",inputSchema:{}},async()=>{try{let e=await chrome.runtime.getPlatformInfo();return this.formatJson({os:e.os,arch:e.arch,nacl_arch:e.nacl_arch})}catch(e){return this.formatError(e)}});}};var $=class extends h{apiName="Commands";constructor(e,r={}){super(e,r);}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. This may indicate a compatibility issue."}:!chrome.commands.onCommand||typeof chrome.commands.onCommand.addListener!="function"?{available:!1,message:"chrome.commands.onCommand is not available",details:"Command event handling is not available. This is required for the commands API to function properly."}:(chrome.commands.getAll(()=>{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:"The commands API is available to all extensions by default. This error suggests a critical issue with the extension environment."}}catch(e){return {available:false,message:"Failed to access chrome.commands API",details:e instanceof Error?e.message:"Unknown error occurred"}}}registerTools(){this.shouldRegisterTool("getAllCommands")&&this.registerGetAllCommands(),this.shouldRegisterTool("getCommand")&&this.registerGetCommand(),this.shouldRegisterTool("updateCommandShortcut")&&this.registerUpdateCommandShortcut(),this.shouldRegisterTool("resetCommandShortcut")&&this.registerResetCommandShortcut(),this.shouldRegisterTool("onCommandListener")&&this.registerOnCommandListener();}registerGetAllCommands(){this.server.registerTool("get_all_commands",{description:"Get all registered commands for the extension with their current keyboard shortcuts",inputSchema:{}},async()=>{try{let r=(await chrome.commands.getAll()).map(s=>({name:s.name||"unnamed",description:s.description||"No description",shortcut:s.shortcut||"Not assigned",hasShortcut:!!s.shortcut})),o=r.filter(s=>s.name.startsWith("_")),t=r.filter(s=>!s.name.startsWith("_"));return this.formatJson({totalCommands:r.length,specialCommands:{count:o.length,commands:o},customCommands:{count:t.length,commands:t},allCommands:r})}catch(e){return this.formatError(e)}});}registerGetCommand(){this.server.registerTool("get_command",{description:"Get information about a specific command by name",inputSchema:{name:z$1.string().describe('The name of the command to retrieve (e.g., "toggle-feature", "_execute_action")')}},async({name:e})=>{try{let o=(await chrome.commands.getAll()).find(t=>t.name===e);return o?this.formatJson({name:o.name||"unnamed",description:o.description||"No description",shortcut:o.shortcut||"Not assigned",hasShortcut:!!o.shortcut,isSpecialCommand:o.name?.startsWith("_")||!1}):this.formatError(new Error(`Command "${e}" not found. Use get_all_commands to see available commands.`))}catch(r){return this.formatError(r)}});}registerUpdateCommandShortcut(){this.server.registerTool("update_command_shortcut",{description:"Get instructions for updating a command keyboard shortcut. Note: Chrome extension API does not support programmatic shortcut updates - users must update manually.",inputSchema:{name:z$1.string().describe("The name of the command to update"),shortcut:z$1.string().describe('The new keyboard shortcut (e.g., "Ctrl+Shift+Y", "Alt+Shift+P"). Use empty string to remove the shortcut.')}},async({name:e,shortcut:r})=>{try{return r&&!this.isValidShortcut(r)?this.formatError(new Error('Invalid shortcut format. Shortcuts must include Ctrl or Alt, and can optionally include Shift. Examples: "Ctrl+Shift+Y", "Alt+P", "Ctrl+Alt+1"')):this.formatSuccess("Command shortcut update requested",{name:e,requestedShortcut:r||"None",note:"Users can manually update keyboard shortcuts in chrome://extensions/shortcuts",instructions:["1. Open chrome://extensions/shortcuts in a new tab","2. Find this extension",`3. Set the shortcut for "${e}" to "${r||"None"}"`]})}catch(o){return this.formatError(o)}});}registerResetCommandShortcut(){this.server.registerTool("reset_command_shortcut",{description:"Get instructions for resetting a command shortcut to its default value defined in manifest.json",inputSchema:{name:z$1.string().describe("The name of the command to reset")}},async({name:e})=>{try{return this.formatSuccess("Command shortcut reset requested",{name:e,note:"Users can manually reset keyboard shortcuts in chrome://extensions/shortcuts",instructions:["1. Open chrome://extensions/shortcuts in a new tab","2. Find this extension",`3. Click the X button next to the "${e}" command to reset it to default`,"4. Or set it back to the default value defined in manifest.json"]})}catch(r){return this.formatError(r)}});}registerOnCommandListener(){this.server.registerTool("listen_for_commands",{description:"Get information about the command event listener. Note: Actual command handling is implemented in the extension background script.",inputSchema:{action:z$1.enum(["status","info"]).describe('Action to perform: "status" checks if listener is active, "info" provides details about command handling')}},async({action:e})=>{try{if(e==="status"){let r=chrome.commands.onCommand.hasListeners();return this.formatJson({listenerActive:r,message:r?"Command listener is active and ready to handle keyboard shortcuts":"No command listener is currently registered",recommendation:r?null:"The extension should register a listener using chrome.commands.onCommand.addListener() in the background script"})}else {let o=(await chrome.commands.getAll()).filter(t=>t.shortcut);return this.formatJson({info:"Command handling in Chrome extensions",howItWorks:["1. Define commands in manifest.json with suggested keyboard shortcuts","2. Register an onCommand listener in the background script","3. When user presses a shortcut, the listener receives the command name","4. The extension executes the corresponding action"],activeCommands:{count:o.length,commands:o.map(t=>({name:t.name,shortcut:t.shortcut,description:t.description}))},exampleListener:"chrome.commands.onCommand.addListener((command, tab) => { /* handle command */ });"})}}catch(r){return this.formatError(r)}});}isValidShortcut(e){let r=e.split("+").map(i=>i.trim());if(r.length<2||!r.some(i=>/^(Ctrl|Alt|Command|MacCtrl)$/i.test(i)))return false;let t=r[r.length-1];return /^[A-Z0-9]$/.test(t)||/^(Up|Down|Left|Right|Home|End|PageUp|PageDown|Space|Tab|Insert|Delete)$/i.test(t)||/^F([1-9]|1[0-2])$/i.test(t)}};var H=class extends h{apiName="Tts";constructor(e,r={}){super(e,r);}checkAvailability(){try{return chrome.tts?typeof chrome.tts.getVoices!="function"?{available:!1,message:"chrome.tts.getVoices is not available",details:"The tts API appears to be partially available. Check manifest permissions."}:(chrome.tts.getVoices(()=>{if(chrome.runtime.lastError)throw new Error(chrome.runtime.lastError.message)}),{available:!0,message:"TTS API is fully available"}):{available:!1,message:"chrome.tts API is not defined",details:'This extension needs the "tts" permission in its manifest.json'}}catch(e){return {available:false,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("tts_speak",{description:"Speak text using a text-to-speech engine",inputSchema:{utterance:z$1.string().describe("The text to speak, either plain text or a complete SSML document. Maximum length is 32,768 characters"),lang:z$1.string().optional().describe('The language to use for synthesis (e.g. "en", "en-US", "en-GB", "zh-CN")'),voiceName:z$1.string().optional().describe("The name of the voice to use for synthesis"),rate:z$1.number().min(.1).max(10).optional().describe("Speaking rate relative to default (1.0 is default, 2.0 is twice as fast, 0.5 is half as fast)"),pitch:z$1.number().min(0).max(2).optional().describe("Speaking pitch between 0 and 2 inclusive (1.0 is default)"),volume:z$1.number().min(0).max(1).optional().describe("Speaking volume between 0 and 1 inclusive (1.0 is default)"),enqueue:z$1.boolean().optional().describe("If true, enqueues this utterance. If false (default), interrupts current speech"),extensionId:z$1.string().optional().describe("The extension ID of the speech engine to use"),requiredEventTypes:z$1.array(z$1.string()).optional().describe("TTS event types the voice must support"),desiredEventTypes:z$1.array(z$1.string()).optional().describe("TTS event types to listen to")}},async({utterance:e,lang:r,voiceName:o,rate:t,pitch:s,volume:i,enqueue:l,extensionId:a,requiredEventTypes:u,desiredEventTypes:S})=>{try{let d={};r!==void 0&&(d.lang=r),o!==void 0&&(d.voiceName=o),t!==void 0&&(d.rate=t),s!==void 0&&(d.pitch=s),i!==void 0&&(d.volume=i),l!==void 0&&(d.enqueue=l),a!==void 0&&(d.extensionId=a),u!==void 0&&(d.requiredEventTypes=u),S!==void 0&&(d.desiredEventTypes=S);let g=[],C=null;return d.onEvent=E=>{g.push({type:E.type,charIndex:E.charIndex,errorMessage:E.errorMessage,length:E.length}),E.type==="error"&&(C=E.errorMessage||"Unknown error");},await new Promise((E,O)=>{chrome.tts.speak(e,d,()=>{chrome.runtime.lastError?O(new Error(chrome.runtime.lastError.message)):setTimeout(()=>{C?O(new Error(C)):E();},100);});}),this.formatSuccess("Text-to-speech initiated successfully",{utterance:e.substring(0,100)+(e.length>100?"...":""),options:Object.keys(d).filter(E=>E!=="onEvent"&&d[E]!==void 0),events:g})}catch(d){return this.formatError(d)}});}registerStop(){this.server.registerTool("tts_stop",{description:"Stop any current speech and flush the queue of pending utterances",inputSchema:{}},async()=>{try{return chrome.tts.stop(),this.formatSuccess("Speech stopped successfully")}catch(e){return this.formatError(e)}});}registerPause(){this.server.registerTool("tts_pause",{description:"Pause speech synthesis, potentially in the middle of an utterance",inputSchema:{}},async()=>{try{return chrome.tts.pause(),this.formatSuccess("Speech paused successfully")}catch(e){return this.formatError(e)}});}registerResume(){this.server.registerTool("tts_resume",{description:"Resume speaking where it left off if speech was paused",inputSchema:{}},async()=>{try{return chrome.tts.resume(),this.formatSuccess("Speech resumed successfully")}catch(e){return this.formatError(e)}});}registerIsSpeaking(){this.server.registerTool("tts_is_speaking",{description:"Check whether the engine is currently speaking",inputSchema:{}},async()=>{try{let e=await new Promise((r,o)=>{chrome.tts.isSpeaking(t=>{chrome.runtime.lastError?o(new Error(chrome.runtime.lastError.message)):r(t);});});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("tts_get_voices",{description:"Get all available voices for speech synthesis",inputSchema:{lang:z$1.string().optional().describe('Filter voices by language (e.g. "en", "en-US")')}},async({lang:e})=>{try{let r=await new Promise((t,s)=>{chrome.tts.getVoices(i=>{chrome.runtime.lastError?s(new Error(chrome.runtime.lastError.message)):t(i);});}),o=r;return e&&(o=r.filter(t=>t.lang&&(t.lang===e||t.lang.startsWith(e+"-")||e.startsWith(t.lang+"-")))),this.formatJson({count:o.length,totalAvailable:r.length,voices:o.map(t=>({voiceName:t.voiceName,lang:t.lang,remote:t.remote,extensionId:t.extensionId,eventTypes:t.eventTypes}))})}catch(r){return this.formatError(r)}});}};var j=class extends h{apiName="TabGroups";constructor(e,r={}){super(e,r);}checkAvailability(){try{return chrome.tabGroups?typeof chrome.tabGroups.query!="function"?{available:!1,message:"chrome.tabGroups.query is not available",details:"The tabGroups API appears to be partially available. Check manifest permissions."}:(chrome.tabGroups.query({},()=>{if(chrome.runtime.lastError)throw new Error(chrome.runtime.lastError.message)}),{available:!0,message:"TabGroups API is fully available"}):{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:false,message:"Failed to access chrome.tabGroups API",details:e instanceof Error?e.message:"Unknown error occurred"}}}registerTools(){this.shouldRegisterTool("get")&&this.registerGet(),this.shouldRegisterTool("query")&&this.registerQuery(),this.shouldRegisterTool("update")&&this.registerUpdate(),this.shouldRegisterTool("move")&&this.registerMove();}registerGet(){this.server.registerTool("get_tab_group",{description:"Get details about a specific tab group",inputSchema:{groupId:z$1.number().describe("The ID of the tab group to retrieve")}},async({groupId:e})=>{try{let r=await new Promise((o,t)=>{chrome.tabGroups.get(e,s=>{chrome.runtime.lastError?t(new Error(chrome.runtime.lastError.message)):o(s);});});return this.formatJson({id:r.id,title:r.title,color:r.color,collapsed:r.collapsed,shared:r.shared,windowId:r.windowId})}catch(r){return this.formatError(r)}});}registerQuery(){this.server.registerTool("query_tab_groups",{description:"Search for tab groups that match specified criteria",inputSchema:{collapsed:z$1.boolean().optional().describe("Whether the groups are collapsed"),color:z$1.enum(["grey","blue","red","yellow","green","pink","purple","cyan","orange"]).optional().describe("The color of the groups"),shared:z$1.boolean().optional().describe("Whether the group is shared (Chrome 137+)"),title:z$1.string().optional().describe("Pattern to match group titles against"),windowId:z$1.number().optional().describe("The ID of the parent window, or use -2 for the current window")}},async({collapsed:e,color:r,shared:o,title:t,windowId:s})=>{try{let i={};e!==void 0&&(i.collapsed=e),r!==void 0&&(i.color=r),o!==void 0&&(i.shared=o),t!==void 0&&(i.title=t),s!==void 0&&(i.windowId=s===-2?chrome.windows.WINDOW_ID_CURRENT:s);let l=await new Promise((a,u)=>{chrome.tabGroups.query(i,S=>{chrome.runtime.lastError?u(new Error(chrome.runtime.lastError.message)):a(S);});});return this.formatJson({count:l.length,groups:l.map(a=>({id:a.id,title:a.title,color:a.color,collapsed:a.collapsed,shared:a.shared,windowId:a.windowId}))})}catch(i){return this.formatError(i)}});}registerUpdate(){this.server.registerTool("update_tab_group",{description:"Modify properties of a tab group",inputSchema:{groupId:z$1.number().describe("The ID of the group to modify"),collapsed:z$1.boolean().optional().describe("Whether the group should be collapsed"),color:z$1.enum(["grey","blue","red","yellow","green","pink","purple","cyan","orange"]).optional().describe("The color of the group"),title:z$1.string().optional().describe("The title of the group")}},async({groupId:e,collapsed:r,color:o,title:t})=>{try{let s={};r!==void 0&&(s.collapsed=r),o!==void 0&&(s.color=o),t!==void 0&&(s.title=t);let i=await new Promise((l,a)=>{chrome.tabGroups.update(e,s,u=>{chrome.runtime.lastError?a(new Error(chrome.runtime.lastError.message)):l(u);});});return i?this.formatSuccess("Tab group updated successfully",{id:i.id,title:i.title,color:i.color,collapsed:i.collapsed,shared:i.shared,windowId:i.windowId}):this.formatError("Failed to update tab group")}catch(s){return this.formatError(s)}});}registerMove(){this.server.registerTool("move_tab_group",{description:"Move a tab group within its window or to a new window",inputSchema:{groupId:z$1.number().describe("The ID of the group to move"),index:z$1.number().describe("The position to move the group to. Use -1 to place at the end"),windowId:z$1.number().optional().describe("The window to move the group to. Defaults to current window")}},async({groupId:e,index:r,windowId:o})=>{try{let t={index:r};o!==void 0&&(t.windowId=o);let s=await new Promise((i,l)=>{chrome.tabGroups.move(e,t,a=>{chrome.runtime.lastError?l(new Error(chrome.runtime.lastError.message)):i(a);});});return s?this.formatSuccess("Tab group moved successfully",{id:s.id,title:s.title,color:s.color,collapsed:s.collapsed,shared:s.shared,windowId:s.windowId,newIndex:r}):this.formatError("Failed to move tab group")}catch(t){return this.formatError(t)}});}};var J=(n=>(n.ACCESSIBILITY_FEATURES="accessibilityFeatures",n.ACTION="action",n.ALARMS="alarms",n.AUDIO="audio",n.BOOKMARKS="bookmarks",n.BROWSING_DATA="browsingData",n.CERTIFICATE_PROVIDER="certificateProvider",n.COMMANDS="commands",n.CONTENT_SETTINGS="contentSettings",n.CONTEXT_MENUS="contextMenus",n.COOKIES="cookies",n.DEBUGGER="debugger",n.DECLARATIVE_CONTENT="declarativeContent",n.DECLARATIVE_NET_REQUEST="declarativeNetRequest",n.DESKTOP_CAPTURE="desktopCapture",n.DEVTOOLS_INSPECTED_WINDOW="devtools.inspectedWindow",n.DEVTOOLS_NETWORK="devtools.network",n.DEVTOOLS_PANELS="devtools.panels",n.DEVTOOLS_PERFORMANCE="devtools.performance",n.DEVTOOLS_RECORDER="devtools.recorder",n.DNS="dns",n.DOCUMENT_SCAN="documentScan",n.DOM="dom",n.DOWNLOADS="downloads",n.ENTERPRISE_DEVICE_ATTRIBUTES="enterprise.deviceAttributes",n.ENTERPRISE_HARDWARE_PLATFORM="enterprise.hardwarePlatform",n.ENTERPRISE_NETWORKING_ATTRIBUTES="enterprise.networkingAttributes",n.ENTERPRISE_PLATFORM_KEYS="enterprise.platformKeys",n.EVENTS="events",n.EXTENSION="extension",n.EXTENSION_TYPES="extensionTypes",n.FILE_BROWSER_HANDLER="fileBrowserHandler",n.FILE_SYSTEM_PROVIDER="fileSystemProvider",n.FONT_SETTINGS="fontSettings",n.GCM="gcm",n.HISTORY="history",n.I18N="i18n",n.IDENTITY="identity",n.IDLE="idle",n.INPUT_IME="input.ime",n.INSTANCE_ID="instanceID",n.LOGIN_STATE="loginState",n.MANAGEMENT="management",n.NOTIFICATIONS="notifications",n.OFFSCREEN="offscreen",n.OMNIBOX="omnibox",n.PAGE_CAPTURE="pageCapture",n.PERMISSIONS="permissions",n.PLATFORM_KEYS="platformKeys",n.POWER="power",n.PRINTER_PROVIDER="printerProvider",n.PRINTING="printing",n.PRINTING_METRICS="printingMetrics",n.PRIVACY="privacy",n.PROCESSES="processes",n.PROXY="proxy",n.READING_LIST="readingList",n.RUNTIME="runtime",n.SCRIPTING="scripting",n.SEARCH="search",n.SESSIONS="sessions",n.SIDE_PANEL="sidePanel",n.STORAGE="storage",n.SYSTEM_CPU="system.cpu",n.SYSTEM_DISPLAY="system.display",n.SYSTEM_MEMORY="system.memory",n.SYSTEM_STORAGE="system.storage",n.SYSTEM_LOG="systemLog",n.TAB_CAPTURE="tabCapture",n.TAB_GROUPS="tabGroups",n.TABS="tabs",n.TOP_SITES="topSites",n.TTS="tts",n.TTS_ENGINE="ttsEngine",n.TYPES="types",n.USER_SCRIPTS="userScripts",n.VPN_PROVIDER="vpnProvider",n.WALLPAPER="wallpaper",n.WEB_AUTHENTICATION_PROXY="webAuthenticationProxy",n.WEB_NAVIGATION="webNavigation",n.WEB_REQUEST="webRequest",n.WINDOWS="windows",n))(J||{}),Z=z$1.enum(["all","chromeos"]),Q=z$1.enum(["stable","dev"]),X=z$1.enum(["background","content","devtools","all"]),wr=z$1.object({minChromeVersion:z$1.number().optional(),platform:Z,channel:Q,manifestVersions:z$1.array(z$1.literal(2).or(z$1.literal(3))),requiresPolicy:z$1.boolean(),foregroundOnly:z$1.boolean(),contexts:z$1.array(X),namespace:z$1.string()}),K={accessibilityFeatures:{platform:"all",channel:"stable",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:false,contexts:["background"],namespace:"accessibilityFeatures"},action:{minChromeVersion:88,platform:"all",channel:"stable",manifestVersions:[3],requiresPolicy:false,foregroundOnly:false,contexts:["background"],namespace:"action"},alarms:{platform:"all",channel:"stable",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:false,contexts:["background"],namespace:"alarms"},audio:{minChromeVersion:59,platform:"chromeos",channel:"stable",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:false,contexts:["background"],namespace:"audio"},bookmarks:{platform:"all",channel:"stable",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:false,contexts:["background","content"],namespace:"bookmarks"},browsingData:{platform:"all",channel:"stable",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:false,contexts:["background"],namespace:"browsingData"},certificateProvider:{minChromeVersion:46,platform:"chromeos",channel:"stable",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:false,contexts:["background"],namespace:"certificateProvider"},commands:{platform:"all",channel:"stable",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:false,contexts:["background"],namespace:"commands"},contentSettings:{platform:"all",channel:"stable",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:false,contexts:["background"],namespace:"contentSettings"},contextMenus:{platform:"all",channel:"stable",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:false,contexts:["background"],namespace:"contextMenus"},cookies:{platform:"all",channel:"stable",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:false,contexts:["background","content"],namespace:"cookies"},debugger:{platform:"all",channel:"stable",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:false,contexts:["background"],namespace:"debugger"},declarativeContent:{platform:"all",channel:"stable",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:false,contexts:["background"],namespace:"declarativeContent"},declarativeNetRequest:{minChromeVersion:84,platform:"all",channel:"stable",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:false,contexts:["background"],namespace:"declarativeNetRequest"},desktopCapture:{platform:"all",channel:"stable",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:false,contexts:["background"],namespace:"desktopCapture"},"devtools.inspectedWindow":{platform:"all",channel:"stable",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:false,contexts:["devtools"],namespace:"devtools.inspectedWindow"},"devtools.network":{platform:"all",channel:"stable",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:false,contexts:["devtools"],namespace:"devtools.network"},"devtools.panels":{platform:"all",channel:"stable",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:false,contexts:["devtools"],namespace:"devtools.panels"},"devtools.performance":{minChromeVersion:129,platform:"all",channel:"stable",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:false,contexts:["devtools"],namespace:"devtools.performance"},"devtools.recorder":{minChromeVersion:105,platform:"all",channel:"stable",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:false,contexts:["devtools"],namespace:"devtools.recorder"},dns:{platform:"all",channel:"dev",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:false,contexts:["background"],namespace:"dns"},documentScan:{minChromeVersion:44,platform:"chromeos",channel:"stable",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:false,contexts:["background"],namespace:"documentScan"},dom:{minChromeVersion:88,platform:"all",channel:"stable",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:false,contexts:["content"],namespace:"dom"},downloads:{platform:"all",channel:"stable",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:false,contexts:["background"],namespace:"downloads"},"enterprise.deviceAttributes":{minChromeVersion:46,platform:"chromeos",channel:"stable",manifestVersions:[2,3],requiresPolicy:true,foregroundOnly:false,contexts:["background"],namespace:"enterprise.deviceAttributes"},"enterprise.hardwarePlatform":{minChromeVersion:71,platform:"all",channel:"stable",manifestVersions:[2,3],requiresPolicy:true,foregroundOnly:false,contexts:["background"],namespace:"enterprise.hardwarePlatform"},"enterprise.networkingAttributes":{minChromeVersion:85,platform:"chromeos",channel:"stable",manifestVersions:[2,3],requiresPolicy:true,foregroundOnly:false,contexts:["background"],namespace:"enterprise.networkingAttributes"},"enterprise.platformKeys":{platform:"chromeos",channel:"stable",manifestVersions:[2,3],requiresPolicy:true,foregroundOnly:false,contexts:["background"],namespace:"enterprise.platformKeys"},events:{platform:"all",channel:"stable",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:false,contexts:["all"],namespace:"events"},extension:{platform:"all",channel:"stable",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:false,contexts:["all"],namespace:"extension"},extensionTypes:{platform:"all",channel:"stable",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:false,contexts:["all"],namespace:"extensionTypes"},fileBrowserHandler:{platform:"chromeos",channel:"stable",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:true,contexts:["background"],namespace:"fileBrowserHandler"},fileSystemProvider:{platform:"chromeos",channel:"stable",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:false,contexts:["background"],namespace:"fileSystemProvider"},fontSettings:{platform:"all",channel:"stable",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:false,contexts:["background"],namespace:"fontSettings"},gcm:{platform:"all",channel:"stable",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:false,contexts:["background"],namespace:"gcm"},history:{platform:"all",channel:"stable",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:false,contexts:["background","content"],namespace:"history"},i18n:{platform:"all",channel:"stable",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:false,contexts:["all"],namespace:"i18n"},identity:{platform:"all",channel:"stable",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:false,contexts:["background"],namespace:"identity"},idle:{platform:"all",channel:"stable",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:false,contexts:["background"],namespace:"idle"},"input.ime":{platform:"chromeos",channel:"stable",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:false,contexts:["background"],namespace:"input.ime"},instanceID:{minChromeVersion:44,platform:"all",channel:"stable",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:false,contexts:["background"],namespace:"instanceID"},loginState:{minChromeVersion:78,platform:"chromeos",channel:"stable",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:false,contexts:["background"],namespace:"loginState"},management:{platform:"all",channel:"stable",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:false,contexts:["background"],namespace:"management"},notifications:{platform:"all",channel:"stable",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:false,contexts:["background"],namespace:"notifications"},offscreen:{minChromeVersion:109,platform:"all",channel:"stable",manifestVersions:[3],requiresPolicy:false,foregroundOnly:false,contexts:["background"],namespace:"offscreen"},omnibox:{platform:"all",channel:"stable",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:false,contexts:["background"],namespace:"omnibox"},pageCapture:{platform:"all",channel:"stable",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:false,contexts:["background"],namespace:"pageCapture"},permissions:{platform:"all",channel:"stable",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:false,contexts:["background","content"],namespace:"permissions"},platformKeys:{minChromeVersion:45,platform:"chromeos",channel:"stable",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:false,contexts:["background"],namespace:"platformKeys"},power:{platform:"all",channel:"stable",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:false,contexts:["background"],namespace:"power"},printerProvider:{minChromeVersion:44,platform:"all",channel:"stable",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:false,contexts:["background"],namespace:"printerProvider"},printing:{minChromeVersion:81,platform:"chromeos",channel:"stable",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:false,contexts:["background"],namespace:"printing"},printingMetrics:{minChromeVersion:79,platform:"chromeos",channel:"stable",manifestVersions:[2,3],requiresPolicy:true,foregroundOnly:false,contexts:["background"],namespace:"printingMetrics"},privacy:{platform:"all",channel:"stable",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:false,contexts:["background"],namespace:"privacy"},processes:{platform:"all",channel:"dev",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:false,contexts:["background"],namespace:"processes"},proxy:{platform:"all",channel:"stable",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:false,contexts:["background"],namespace:"proxy"},readingList:{minChromeVersion:120,platform:"all",channel:"stable",manifestVersions:[3],requiresPolicy:false,foregroundOnly:false,contexts:["background"],namespace:"readingList"},runtime:{platform:"all",channel:"stable",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:false,contexts:["all"],namespace:"runtime"},scripting:{minChromeVersion:88,platform:"all",channel:"stable",manifestVersions:[3],requiresPolicy:false,foregroundOnly:false,contexts:["background"],namespace:"scripting"},search:{minChromeVersion:87,platform:"all",channel:"stable",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:false,contexts:["background"],namespace:"search"},sessions:{platform:"all",channel:"stable",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:false,contexts:["background"],namespace:"sessions"},sidePanel:{minChromeVersion:114,platform:"all",channel:"stable",manifestVersions:[3],requiresPolicy:false,foregroundOnly:false,contexts:["background"],namespace:"sidePanel"},storage:{platform:"all",channel:"stable",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:false,contexts:["all"],namespace:"storage"},"system.cpu":{platform:"all",channel:"stable",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:false,contexts:["background"],namespace:"system.cpu"},"system.display":{platform:"all",channel:"stable",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:false,contexts:["background"],namespace:"system.display"},"system.memory":{platform:"all",channel:"stable",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:false,contexts:["background"],namespace:"system.memory"},"system.storage":{platform:"all",channel:"stable",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:false,contexts:["background"],namespace:"system.storage"},systemLog:{minChromeVersion:125,platform:"chromeos",channel:"stable",manifestVersions:[2,3],requiresPolicy:true,foregroundOnly:false,contexts:["background"],namespace:"systemLog"},tabCapture:{platform:"all",channel:"stable",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:false,contexts:["background"],namespace:"tabCapture"},tabGroups:{minChromeVersion:89,platform:"all",channel:"stable",manifestVersions:[3],requiresPolicy:false,foregroundOnly:false,contexts:["background"],namespace:"tabGroups"},tabs:{platform:"all",channel:"stable",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:false,contexts:["background","content"],namespace:"tabs"},topSites:{platform:"all",channel:"stable",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:false,contexts:["background"],namespace:"topSites"},tts:{platform:"all",channel:"stable",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:false,contexts:["background"],namespace:"tts"},ttsEngine:{platform:"all",channel:"stable",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:false,contexts:["background"],namespace:"ttsEngine"},types:{platform:"all",channel:"stable",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:false,contexts:["all"],namespace:"types"},userScripts:{minChromeVersion:120,platform:"all",channel:"stable",manifestVersions:[3],requiresPolicy:false,foregroundOnly:false,contexts:["background"],namespace:"userScripts"},vpnProvider:{minChromeVersion:43,platform:"chromeos",channel:"stable",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:false,contexts:["background"],namespace:"vpnProvider"},wallpaper:{minChromeVersion:43,platform:"chromeos",channel:"stable",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:false,contexts:["background"],namespace:"wallpaper"},webAuthenticationProxy:{minChromeVersion:115,platform:"all",channel:"stable",manifestVersions:[3],requiresPolicy:false,foregroundOnly:false,contexts:["background"],namespace:"webAuthenticationProxy"},webNavigation:{platform:"all",channel:"stable",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:false,contexts:["background"],namespace:"webNavigation"},webRequest:{platform:"all",channel:"stable",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:false,contexts:["background"],namespace:"webRequest"},windows:{platform:"all",channel:"stable",manifestVersions:[2,3],requiresPolicy:false,foregroundOnly:false,contexts:["background"],namespace:"windows"}};function ee(b,e,r,o="all",t){let s=K[b];return !(!s.contexts.includes(e)&&!s.contexts.includes("all")||!s.manifestVersions.includes(r)||s.platform!=="all"&&s.platform!==o||s.minChromeVersion&&t&&t<s.minChromeVersion)}function Er(b){let r=K[b].namespace.split("."),o=chrome;for(let t of r)if(o=o?.[t],!o)return;return o}function Ir(b,e,r="all",o){return Object.values(J).filter(t=>ee(t,b,e,r,o))}
|
|
34
|
+
export{B as AlarmsApiTools,h as BaseApiTools,U as BookmarksApiTools,K as CHROME_API_REGISTRY,J as ChromeApi,wr as ChromeApiMetadataSchema,Q as ChromeChannelSchema,X as ChromeContextSchema,Z as ChromePlatformSchema,$ as CommandsApiTools,q as CookiesApiTools,F as DownloadsApiTools,M as HistoryApiTools,L as NotificationsApiTools,W as RuntimeApiTools,G as ScriptingApiTools,V as StorageApiTools,j as TabGroupsApiTools,N as TabsApiTools,H as TtsApiTools,D as WindowsApiTools,Ir as getAvailableApis,Er as getChromeApiReference,ee as isApiAvailable};//# sourceMappingURL=index.js.map
|
|
35
|
+
//# sourceMappingURL=index.js.map
|