Open History to see the last commit
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]);
16export type DesktopBrowserEvent = typeof DesktopBrowserEvent.Type;
17
18export const DesktopBrowserCommand = Schema.Union([
19 Schema.Struct({ type: Schema.Literal("cdp"), ...TabKey, message: Schema.String }),
20 Schema.Struct({ type: Schema.Literal("release"), ...TabKey }),
21 Schema.Struct({
22 type: Schema.Literal("pointer"),
23 ...TabKey,
24 phase: Schema.Literals(["move", "click"]),
25 x: Schema.Finite,
26 y: Schema.Finite,
27 }),
28 /** Whether an agent turn runs on the thread, so the tabs it uses stay focused between steps. */
29 Schema.Struct({
30 type: Schema.Literal("turn"),
31 threadId: TrimmedNonEmptyString,
32 active: Schema.Boolean,
33 }),
34]);
35export type DesktopBrowserCommand = typeof DesktopBrowserCommand.Type;