Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

desktopBrowser.ts

37 lines1.4 KB

1import * as Schema from "effect/Schema";
2​
3import { TrimmedNonEmptyString } from "./baseSchemas.ts";
4​
5const TabKey = {
6 threadId: TrimmedNonEmptyString,
7 tabId: TrimmedNonEmptyString,
8};
9​
10export 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 /** Its `<webview>` started or stopped being on screen in a desktop window. */
16 Schema.Struct({ type: Schema.Literal("shown"), ...TabKey, shown: Schema.Boolean }),
17]);
18export type DesktopBrowserEvent = typeof DesktopBrowserEvent.Type;
19​
20export const DesktopBrowserCommand = Schema.Union([
21 Schema.Struct({ type: Schema.Literal("cdp"), ...TabKey, message: Schema.String }),
22 Schema.Struct({ type: Schema.Literal("release"), ...TabKey }),
23 Schema.Struct({
24 type: Schema.Literal("pointer"),
25 ...TabKey,
26 phase: Schema.Literals(["move", "click"]),
27 x: Schema.Finite,
28 y: Schema.Finite,
29 }),
30 /** Whether an agent turn runs on the thread, so the tabs it uses stay focused between steps. */
31 Schema.Struct({
32 type: Schema.Literal("turn"),
33 threadId: TrimmedNonEmptyString,
34 active: Schema.Boolean,
35 }),
36]);
37export type DesktopBrowserCommand = typeof DesktopBrowserCommand.Type;