mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-05 16:04:43 +00:00
* Add opt-in browser tools for desktop tabs Adds the daemon opt-in, desktop tab routing, MCP tools, and real browser automation surfaces for Paseo desktop browser tabs. * Fix browser tools CI expectations * Address browser tools review findings * Restrict browser file automation paths * Fix browser upload test on Windows * Harden browser navigation inputs * Make browser tools create usable tabs * Update browser MCP empty-state test * Fail browser tab creation when registration times out * Fix browser screenshots for agents * Hide disabled browser tools from agents * Address browser tools architecture review * Replace browser tools review tests * Wrap browser tab registration errors * Mock Expo Router in app unit tests * Handle invalid browser automation requests * Return browser failure on desktop disconnect * Update browser disconnect websocket test * Relax browser timeout polling test * Handle invalid browser responses * Return browser failure when send fails * Remove local diagnostics and fixture paths * Fix dev service home fallback * Use worktree home for dev services * Use managed daemon in desktop dev * fix(browser): keep agent tabs addressable Track agent-active browser targets separately from human-focused tabs and keep resident webviews alive for automation. Browser tool visibility now comes from registration while the broker reports disabled execution. * refactor(browser): register tools through catalog Move browser tool registration onto the shared Paseo tool catalog so the MCP server remains only the transport adapter. * fix(settings): translate browser tools host error
193 lines
5.4 KiB
TypeScript
193 lines
5.4 KiB
TypeScript
import { Platform } from "react-native";
|
|
import { getElectronHost } from "@/desktop/electron/host";
|
|
import type { SessionInboundMessage, SessionOutboundMessage } from "@getpaseo/protocol/messages";
|
|
|
|
type BrowserAutomationExecuteRequest = Extract<
|
|
SessionOutboundMessage,
|
|
{ type: "browser.automation.execute.request" }
|
|
>;
|
|
type BrowserAutomationExecuteResponse = Extract<
|
|
SessionInboundMessage,
|
|
{ type: "browser.automation.execute.response" }
|
|
>;
|
|
|
|
export type DesktopNotificationPermission = "granted" | "denied" | "default";
|
|
|
|
export interface DesktopDialogAskOptions {
|
|
title?: string;
|
|
okLabel?: string;
|
|
cancelLabel?: string;
|
|
kind?: "info" | "warning" | "error";
|
|
}
|
|
|
|
export interface DesktopDialogOpenOptions {
|
|
title?: string;
|
|
defaultPath?: string;
|
|
directory?: boolean;
|
|
multiple?: boolean;
|
|
filters?: Array<{
|
|
name: string;
|
|
extensions: string[];
|
|
}>;
|
|
}
|
|
|
|
export interface DesktopDialogAskWithCheckboxOptions extends DesktopDialogAskOptions {
|
|
checkboxLabel: string;
|
|
checkboxChecked?: boolean;
|
|
}
|
|
|
|
export interface DesktopDialogAskWithCheckboxResult {
|
|
confirmed: boolean;
|
|
dontAskAgain: boolean;
|
|
}
|
|
|
|
export interface DesktopDialogBridge {
|
|
ask?: (message: string, options?: DesktopDialogAskOptions) => Promise<boolean>;
|
|
askWithCheckbox?: (
|
|
message: string,
|
|
options: DesktopDialogAskWithCheckboxOptions,
|
|
) => Promise<DesktopDialogAskWithCheckboxResult>;
|
|
open?: (options?: DesktopDialogOpenOptions) => Promise<string | string[] | null>;
|
|
}
|
|
|
|
export interface DesktopNotificationBridge {
|
|
isSupported?: () => Promise<boolean>;
|
|
sendNotification?: (
|
|
payload: string | { title: string; body?: string; data?: Record<string, unknown> },
|
|
) => Promise<boolean>;
|
|
}
|
|
|
|
export interface DesktopOpenerBridge {
|
|
openUrl?: (url: string) => Promise<void>;
|
|
}
|
|
|
|
export interface DesktopEditorTargetDescriptor {
|
|
id: string;
|
|
label: string;
|
|
kind: "editor" | "file-manager";
|
|
}
|
|
|
|
export interface DesktopEditorOpenTargetInput {
|
|
editorId: string;
|
|
path: string;
|
|
cwd?: string;
|
|
mode?: "open" | "reveal";
|
|
}
|
|
|
|
export interface DesktopEditorBridge {
|
|
listTargets?: () => Promise<DesktopEditorTargetDescriptor[]>;
|
|
openTarget?: (input: DesktopEditorOpenTargetInput) => Promise<void>;
|
|
}
|
|
|
|
export interface DesktopWebUtilsBridge {
|
|
getPathForFile?: (file: File) => string;
|
|
}
|
|
|
|
export interface DesktopMenuBridge {
|
|
showContextMenu?: (input?: { kind?: "terminal"; hasSelection?: boolean }) => Promise<void>;
|
|
}
|
|
|
|
export interface DesktopWindowControlsOverlayUpdate {
|
|
height?: number;
|
|
backgroundColor?: string;
|
|
foregroundColor?: string;
|
|
}
|
|
|
|
export interface DesktopWindowBridge {
|
|
label?: string;
|
|
toggleMaximize?: () => Promise<void>;
|
|
isFullscreen?: () => Promise<boolean>;
|
|
updateWindowControls?: (update: DesktopWindowControlsOverlayUpdate) => Promise<void>;
|
|
onResized?: <TEvent = unknown>(
|
|
handler: (event: TEvent) => void,
|
|
) => Promise<() => void> | (() => void);
|
|
setBadgeCount?: (count?: number) => Promise<void>;
|
|
onDragDropEvent?: <TEvent = unknown>(
|
|
handler: (event: TEvent) => void,
|
|
) => Promise<() => void> | (() => void);
|
|
}
|
|
|
|
export interface DesktopWindowModuleBridge {
|
|
openNew?: (options?: { pendingOpenProjectPath?: string | null }) => Promise<void>;
|
|
getCurrentWindow?: () => DesktopWindowBridge;
|
|
}
|
|
|
|
export interface DesktopEventsBridge {
|
|
on?: (event: string, handler: (payload: unknown) => void) => Promise<() => void> | (() => void);
|
|
}
|
|
|
|
export interface DesktopBrowserShortcutEvent {
|
|
browserId?: string;
|
|
action: "focus-url";
|
|
}
|
|
|
|
export interface DesktopBrowserNewTabRequestEvent {
|
|
sourceBrowserId: string;
|
|
url: string;
|
|
}
|
|
|
|
export interface DesktopBrowserBridge {
|
|
registerWorkspaceBrowser?: (input: { browserId: string; workspaceId: string }) => Promise<void>;
|
|
setWorkspaceActiveBrowser?: (input: {
|
|
workspaceId: string;
|
|
browserId: string | null;
|
|
}) => Promise<void>;
|
|
setAgentActiveBrowser?: (input: { agentId: string; browserId: string | null }) => Promise<void>;
|
|
openDevTools?: (browserId: string) => Promise<unknown>;
|
|
clearPartition?: (browserId: string) => Promise<void>;
|
|
executeAutomationCommand?: (
|
|
request: BrowserAutomationExecuteRequest,
|
|
) => Promise<BrowserAutomationExecuteResponse["payload"]>;
|
|
}
|
|
|
|
export interface DesktopInvokeBridge {
|
|
invoke?: (command: string, args?: Record<string, unknown>) => Promise<unknown>;
|
|
}
|
|
|
|
export interface DesktopHostBridge {
|
|
platform?: string;
|
|
invoke?: DesktopInvokeBridge["invoke"];
|
|
getPendingOpenProject?: () => Promise<string | null>;
|
|
events?: DesktopEventsBridge;
|
|
window?: DesktopWindowModuleBridge;
|
|
dialog?: DesktopDialogBridge;
|
|
notification?: DesktopNotificationBridge;
|
|
opener?: DesktopOpenerBridge;
|
|
editor?: DesktopEditorBridge;
|
|
webUtils?: DesktopWebUtilsBridge;
|
|
menu?: DesktopMenuBridge;
|
|
browser?: DesktopBrowserBridge;
|
|
}
|
|
|
|
declare global {
|
|
interface Window {
|
|
paseoDesktop?: DesktopHostBridge;
|
|
}
|
|
}
|
|
|
|
export function getDesktopHost(): DesktopHostBridge | null {
|
|
if (Platform.OS !== "web") {
|
|
return null;
|
|
}
|
|
return getElectronHost();
|
|
}
|
|
|
|
export function isElectronRuntime(): boolean {
|
|
return getDesktopHost() !== null;
|
|
}
|
|
|
|
export function isElectronRuntimeMac(): boolean {
|
|
if (!isElectronRuntime()) {
|
|
return false;
|
|
}
|
|
if (typeof navigator === "undefined") {
|
|
return false;
|
|
}
|
|
const hostPlatform = getDesktopHost()?.platform?.toLowerCase();
|
|
if (hostPlatform === "darwin" || hostPlatform === "mac" || hostPlatform === "macos") {
|
|
return true;
|
|
}
|
|
const ua = navigator.userAgent;
|
|
return ua.includes("Mac OS") || ua.includes("Macintosh");
|
|
}
|