The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import * as Schema from "effect/Schema"; |
| 2 | |
| 3 | import { TrimmedNonEmptyString } from "./baseSchemas.ts"; |
| 4 | |
| 5 | const TabKey = { |
| 6 | threadId: TrimmedNonEmptyString, |
| 7 | tabId: TrimmedNonEmptyString, |
| 8 | }; |
| 9 | |
| 10 | export const DesktopBrowserEvent = Schema.Union([ |
| 11 | Schema.Struct({ type: Schema.Literal("attached"), ...TabKey }), |
| 12 | /** Its `<webview>` went away: closed, crashed, swapped, or devtools took the debugger. */ |
| 13 | Schema.Struct({ type: Schema.Literal("detached"), ...TabKey }), |
| 14 | Schema.Struct({ type: Schema.Literal("cdp"), ...TabKey, message: Schema.String }), |
| 15 | /** |
| 16 | * The tab's page failed to load. The desktop starts a tab's first load before |
| 17 | * the server connects, so the server cannot always observe the failure itself. |
| 18 | */ |
| 19 | Schema.Struct({ |
| 20 | type: Schema.Literal("loadFailed"), |
| 21 | ...TabKey, |
| 22 | url: Schema.String, |
| 23 | code: Schema.Int, |
| 24 | description: Schema.String, |
| 25 | }), |
| 26 | /** Its `<webview>` started or stopped being on screen in a desktop window. */ |
| 27 | Schema.Struct({ type: Schema.Literal("shown"), ...TabKey, shown: Schema.Boolean }), |
| 28 | ]); |
| 29 | export type DesktopBrowserEvent = typeof DesktopBrowserEvent.Type; |
| 30 | |
| 31 | export const DesktopBrowserCommand = Schema.Union([ |
| 32 | Schema.Struct({ type: Schema.Literal("cdp"), ...TabKey, message: Schema.String }), |
| 33 | Schema.Struct({ type: Schema.Literal("release"), ...TabKey }), |
| 34 | Schema.Struct({ |
| 35 | type: Schema.Literal("pointer"), |
| 36 | ...TabKey, |
| 37 | phase: Schema.Literals(["move", "click"]), |
| 38 | x: Schema.Finite, |
| 39 | y: Schema.Finite, |
| 40 | }), |
| 41 | /** Whether an agent turn runs on the thread, so the tabs it uses stay focused between steps. */ |
| 42 | Schema.Struct({ |
| 43 | type: Schema.Literal("turn"), |
| 44 | threadId: TrimmedNonEmptyString, |
| 45 | active: Schema.Boolean, |
| 46 | }), |
| 47 | ]); |
| 48 | export type DesktopBrowserCommand = typeof DesktopBrowserCommand.Type; |