import { ProxyPropertyType } from 'electron-ipc-cat/common'; import { AgentChannel } from '@/constants/channels'; import { TabCloseDirection } from '@/pages/Agent/store/tabStore/types'; import { BehaviorSubject } from 'rxjs'; import { TabItem } from '../../pages/Agent/types/tab'; /** * Agent Browser Service interface * Handles persistent tab management for the agent browser */ export interface IAgentBrowserService { tabs$: BehaviorSubject; updateTabsObservable(): Promise; /** * Initialize the service on application startup */ initialize(): Promise; /** * Get all tabs * @returns List of all tabs */ getAllTabs(): Promise; /** * Get active tab ID * @returns The active tab ID or null if no active tab */ getActiveTabId(): Promise; /** * Set active tab * @param tabId The ID of the tab to activate */ setActiveTab(tabId: string): Promise; /** * Add new tab * @param tab Tab data * @param position Optional position to insert the tab */ addTab(tab: TabItem, position?: number): Promise; /** * Update tab data * @param tabId Tab ID * @param data Partial tab data to update */ updateTab(tabId: string, data: Partial): Promise; /** * Close tab by ID * @param tabId Tab ID to close */ closeTab(tabId: string): Promise; /** * Close multiple tabs based on direction * @param direction Direction to close tabs * @param fromTabId Reference tab ID */ closeTabs(direction: TabCloseDirection, fromTabId: string): Promise; /** * Pin or unpin tab * @param tabId Tab ID * @param isPinned Whether tab should be pinned */ pinTab(tabId: string, isPinned: boolean): Promise; /** * Get recently closed tabs * @param limit Maximum number of closed tabs to return */ getClosedTabs(limit?: number): Promise; /** * Restore the most recently closed tab * @returns The restored tab or null if no closed tabs */ restoreClosedTab(): Promise; } /** * IPC descriptor for AgentBrowser service * Defines which methods are exposed to the renderer process */ export const AgentBrowserServiceIPCDescriptor = { channel: AgentChannel.browser, properties: { tabs$: ProxyPropertyType.Value$, updateTabsObservable: ProxyPropertyType.Function, getAllTabs: ProxyPropertyType.Function, getActiveTabId: ProxyPropertyType.Function, setActiveTab: ProxyPropertyType.Function, addTab: ProxyPropertyType.Function, updateTab: ProxyPropertyType.Function, closeTab: ProxyPropertyType.Function, closeTabs: ProxyPropertyType.Function, pinTab: ProxyPropertyType.Function, getClosedTabs: ProxyPropertyType.Function, restoreClosedTab: ProxyPropertyType.Function, }, };