| 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 | browserToggleDevTools: "reasonix:browser:toggle-devtools", |
| 40 | browserResume: "reasonix:browser:resume", |
| 41 | browserUserTakeover: "reasonix:browser:user-takeover", |
| 42 | browserSetLayout: "reasonix:browser:set-layout", |
| 43 | browserSetOverlay: "reasonix:browser:set-overlay", |
| 44 | browserTabs: "reasonix:browser:tabs", |
| 45 | browserDownload: "reasonix:browser:download", |
| 46 | browserTakeover: "reasonix:browser:takeover", |
| 47 | } as const; |
| 48 | |
| 49 | export type ServicePhase = "starting" | "ready" | "restarting" | "stopping" | "failed" | "exited"; |
| 50 | |
| 51 | export interface ServiceState { |
| 52 | phase: ServicePhase; |
| 53 | generation: string; |
| 54 | error?: string; |
| 55 | } |
| 56 | |
| 57 | export interface ContractInfo { |
| 58 | protocolVersion: number; |
| 59 | digest: string; |
| 60 | commands: readonly string[]; |
| 61 | } |
| 62 | |
| 63 | export interface EventFrame { |
| 64 | seq: number; |
| 65 | generation: string; |
| 66 | name: string; |
| 67 | args: unknown[]; |
| 68 | } |
| 69 | |
| 70 | export type IpcResult = { ok: true; value: unknown } | { ok: false; message: string }; |
| 71 | |
| 72 | export interface WindowBounds { |
| 73 | x: number; |
| 74 | y: number; |
| 75 | width: number; |
| 76 | height: number; |
| 77 | maximised: boolean; |
| 78 | } |
| 79 | |
| 80 | export type WindowTheme = "system" | "light" | "dark"; |
| 81 | |
| 82 | export type HostOS = "darwin" | "windows" | "linux"; |
| 83 | |
| 84 | export type BrowserControlWarning = "invalid-config" | "unreadable-config" | "unsupported-version"; |
| 85 | |
| 86 | export interface BrowserControlState { |
| 87 | controlEnabled: boolean; |
| 88 | ignoreCertificateErrors: boolean; |
| 89 | writable: boolean; |
| 90 | warning: BrowserControlWarning | null; |
| 91 | } |
| 92 | |
| 93 | export type ChromeImportFailure = |
| 94 | | "chrome-missing" |
| 95 | | "profile-not-found" |
| 96 | | "cookies-unreadable" |
| 97 | | "safe-storage-denied" |
| 98 | | "safe-storage-unavailable" |
| 99 | | "unsupported-platform"; |
| 100 | |
| 101 | export type ChromeImportOutcome = |
| 102 | | { ok: true; profile: string; cookies: number; skipped: number } |
| 103 | | { ok: false; reason: ChromeImportFailure }; |
| 104 | |
| 105 | export function hostOS(platform: string): HostOS { |
| 106 | if (platform === "darwin") return "darwin"; |
| 107 | if (platform === "win32") return "windows"; |
| 108 | return "linux"; |
| 109 | } |
| 110 | |
| 111 | export type BrowserTabMode = "agent" | "human"; |
| 112 | |
| 113 | export interface BrowserTabView { |
| 114 | id: string; |
| 115 | taskId: string; |
| 116 | url: string; |
| 117 | title: string; |
| 118 | loading: boolean; |
| 119 | canGoBack: boolean; |
| 120 | canGoForward: boolean; |
| 121 | temporary: boolean; |
| 122 | mode: BrowserTabMode; |
| 123 | epoch: number; |
| 124 | zoom: number; |
| 125 | active: boolean; |
| 126 | error: { code: number; description: string } | null; |
| 127 | } |
| 128 | |
| 129 | export type BrowserDownloadState = "progressing" | "completed" | "cancelled" | "interrupted"; |
| 130 | |
| 131 | export interface BrowserDownloadView { |
| 132 | id: string; |
| 133 | tabId: string; |
| 134 | url: string; |
| 135 | filename: string; |
| 136 | path: string; |
| 137 | state: BrowserDownloadState; |
| 138 | received: number; |
| 139 | total: number; |
| 140 | } |
| 141 | |
| 142 | export interface BrowserLayoutRect { |
| 143 | x: number; |
| 144 | y: number; |
| 145 | width: number; |
| 146 | height: number; |
| 147 | } |
| 148 | |
| 149 | export interface BrowserOpenOptions { |
| 150 | temporary?: boolean; |
| 151 | taskId?: string; |
| 152 | } |
| 153 | |
| 154 | export type BrowserNavigateAction = "back" | "forward" | "reload" | "stop"; |
| 155 | |
| 156 | export interface BrowserNavigateTarget { |
| 157 | url?: string; |
| 158 | action?: BrowserNavigateAction; |
| 159 | } |
| 160 | |
| 161 | export type BrowserTakeoverKind = "mousedown" | "keydown" | "wheel" | "touchstart" | "pointerdown"; |
| 162 |