| 1 | export const IPC = { |
| 2 | contract: "reasonix:contract", |
| 3 | invoke: "reasonix:invoke", |
| 4 | event: "reasonix:event", |
| 5 | serviceState: "reasonix:service-state", |
| 6 | serviceStateGet: "reasonix:service-state:get", |
| 7 | processDiagnostics: "reasonix:native:process-diagnostics", |
| 8 | captureRendererProfile: "reasonix:native:capture-renderer-profile", |
| 9 | cancelRendererProfile: "reasonix:native:cancel-renderer-profile", |
| 10 | exportHeapSnapshot: "reasonix:native:export-heap-snapshot", |
| 11 | rendererDiagnostic: "reasonix:native:renderer-diagnostic", |
| 12 | openExternal: "reasonix:native:open-external", |
| 13 | clipboardWrite: "reasonix:native:clipboard-write", |
| 14 | clipboardRead: "reasonix:native:clipboard-read", |
| 15 | windowMinimise: "reasonix:native:window-minimise", |
| 16 | windowToggleMaximise: "reasonix:native:window-toggle-maximise", |
| 17 | windowIsMaximised: "reasonix:native:window-is-maximised", |
| 18 | windowClose: "reasonix:native:window-close", |
| 19 | windowGetBounds: "reasonix:native:window-get-bounds", |
| 20 | windowSetTheme: "reasonix:native:window-set-theme", |
| 21 | windowSetBackground: "reasonix:native:window-set-background", |
| 22 | appZoomGet: "reasonix:native:app-zoom-get", |
| 23 | appZoomSet: "reasonix:native:app-zoom-set", |
| 24 | appZoomReset: "reasonix:native:app-zoom-reset", |
| 25 | graphicsGet: "reasonix:native:graphics-get", |
| 26 | graphicsSet: "reasonix:native:graphics-set", |
| 27 | browserControlGet: "reasonix:native:browser-control-get", |
| 28 | browserControlSetEnabled: "reasonix:native:browser-control-set-enabled", |
| 29 | browserControlSetIgnoreCertificateErrors: "reasonix:native:browser-control-set-ignore-certificate-errors", |
| 30 | browserControlClearCache: "reasonix:native:browser-control-clear-cache", |
| 31 | browserControlClearAll: "reasonix:native:browser-control-clear-all", |
| 32 | browserControlImportChrome: "reasonix:native:browser-control-import-chrome", |
| 33 | browserList: "reasonix:browser:list", |
| 34 | browserOpen: "reasonix:browser:open", |
| 35 | browserClose: "reasonix:browser:close", |
| 36 | browserActivate: "reasonix:browser:activate", |
| 37 | browserNavigate: "reasonix:browser:navigate", |
| 38 | browserSetZoom: "reasonix:browser:set-zoom", |
| 39 | browserSetViewport: "reasonix:browser:set-viewport", |
| 40 | browserPickElement: "reasonix:browser:pick-element", |
| 41 | browserRecord: "reasonix:browser:record", |
| 42 | browserDiagnostics: "reasonix:browser:diagnostics", |
| 43 | browserScreenshot: "reasonix:browser:screenshot", |
| 44 | browserRestorePreview: "reasonix:browser:restore-preview", |
| 45 | browserToggleDevTools: "reasonix:browser:toggle-devtools", |
| 46 | browserResume: "reasonix:browser:resume", |
| 47 | browserUserTakeover: "reasonix:browser:user-takeover", |
| 48 | browserSetLayout: "reasonix:browser:set-layout", |
| 49 | browserSetOverlay: "reasonix:browser:set-overlay", |
| 50 | browserTabs: "reasonix:browser:tabs", |
| 51 | browserDownload: "reasonix:browser:download", |
| 52 | browserTakeover: "reasonix:browser:takeover", |
| 53 | } as const; |
| 54 | |
| 55 | export type ServicePhase = "starting" | "ready" | "restarting" | "stopping" | "failed" | "exited"; |
| 56 | |
| 57 | export interface ServiceState { |
| 58 | phase: ServicePhase; |
| 59 | generation: string; |
| 60 | error?: string; |
| 61 | } |
| 62 | |
| 63 | export interface ContractInfo { |
| 64 | protocolVersion: number; |
| 65 | digest: string; |
| 66 | commands: readonly string[]; |
| 67 | } |
| 68 | |
| 69 | export interface EventFrame { |
| 70 | seq: number; |
| 71 | generation: string; |
| 72 | name: string; |
| 73 | args: unknown[]; |
| 74 | } |
| 75 | |
| 76 | export type IpcResult = { ok: true; value: unknown } | { ok: false; message: string; code?:number; data?:unknown }; |
| 77 | |
| 78 | export interface WindowBounds { |
| 79 | x: number; |
| 80 | y: number; |
| 81 | width: number; |
| 82 | height: number; |
| 83 | maximised: boolean; |
| 84 | } |
| 85 | |
| 86 | export type WindowTheme = "system" | "light" | "dark"; |
| 87 | |
| 88 | export type HostOS = "darwin" | "windows" | "linux"; |
| 89 | |
| 90 | export type BrowserControlWarning = "invalid-config" | "unreadable-config" | "unsupported-version"; |
| 91 | |
| 92 | export interface BrowserControlState { |
| 93 | controlEnabled: boolean; |
| 94 | ignoreCertificateErrors: boolean; |
| 95 | writable: boolean; |
| 96 | warning: BrowserControlWarning | null; |
| 97 | } |
| 98 | |
| 99 | export type ChromeImportFailure = |
| 100 | | "chrome-missing" |
| 101 | | "profile-not-found" |
| 102 | | "cookies-unreadable" |
| 103 | | "safe-storage-denied" |
| 104 | | "safe-storage-unavailable" |
| 105 | | "unsupported-platform"; |
| 106 | |
| 107 | export type ChromeImportOutcome = |
| 108 | | { ok: true; profile: string; cookies: number; skipped: number } |
| 109 | | { ok: false; reason: ChromeImportFailure }; |
| 110 | |
| 111 | export function hostOS(platform: string): HostOS { |
| 112 | if (platform === "darwin") return "darwin"; |
| 113 | if (platform === "win32") return "windows"; |
| 114 | return "linux"; |
| 115 | } |
| 116 | |
| 117 | export type BrowserTabMode = "agent" | "human"; |
| 118 | |
| 119 | export interface BrowserTabView { |
| 120 | restorePreview?: boolean; |
| 121 | sessionId?: string; |
| 122 | id: string; |
| 123 | taskId: string; |
| 124 | url: string; |
| 125 | title: string; |
| 126 | loading: boolean; |
| 127 | canGoBack: boolean; |
| 128 | canGoForward: boolean; |
| 129 | temporary: boolean; |
| 130 | mode: BrowserTabMode; |
| 131 | epoch: number; |
| 132 | zoom: number; |
| 133 | viewport?: { width: number; height: number; scale: "fit" | number } | null; |
| 134 | operation?: { id: string; phase: string; message?: string }; |
| 135 | active: boolean; |
| 136 | error: { code: number; description: string } | null; |
| 137 | } |
| 138 | |
| 139 | export type BrowserDownloadState = "progressing" | "completed" | "cancelled" | "interrupted"; |
| 140 | |
| 141 | export interface BrowserDownloadView { |
| 142 | id: string; |
| 143 | tabId: string; |
| 144 | url: string; |
| 145 | filename: string; |
| 146 | path: string; |
| 147 | state: BrowserDownloadState; |
| 148 | received: number; |
| 149 | total: number; |
| 150 | } |
| 151 | |
| 152 | export interface BrowserLayoutRect { |
| 153 | x: number; |
| 154 | y: number; |
| 155 | width: number; |
| 156 | height: number; |
| 157 | } |
| 158 | |
| 159 | export interface BrowserOpenOptions { |
| 160 | temporary?: boolean; |
| 161 | taskId?: string; |
| 162 | } |
| 163 | |
| 164 | export type BrowserNavigateAction = "back" | "forward" | "reload" | "stop"; |
| 165 | |
| 166 | export interface BrowserNavigateTarget { |
| 167 | url?: string; |
| 168 | action?: BrowserNavigateAction; |
| 169 | } |
| 170 | |
| 171 | export type BrowserTakeoverKind = "mousedown" | "keydown" | "wheel" | "touchstart" | "pointerdown"; |
| 172 |