Open History to see the last commit
1import * as Schema from "effect/Schema";
2import type { PreviewCaptureFailureEncoded } from "./previewCapture.ts";
3
4import { SnapShotSource } from "./chatAttachment.ts";
5import { EnvironmentId, TrimmedNonEmptyString } from "./baseSchemas.ts";
6import { BrowserProfileId } from "./browserProfile.ts";
7import type {
8 BrowserImportResult,
9 BrowserImportSource,
10 BrowserImportSourceId,
11} from "./browserImport.ts";
12import { AuthAccessTokenResult, AuthSessionState } from "./auth.ts";
13import { AdvertisedEndpoint } from "./remoteAccess.ts";
14import { ExecutionEnvironmentDescriptor } from "./environment.ts";
15import { type ClientSettings, type QuitConfirmationMode, SnapShotShortcut } from "./settings.ts";
16import type { EditorId } from "./editor.ts";
17import type { PreviewForwardedShortcut } from "./keybindings.ts";
18
19import type {
20 DesktopAppActivationRequest,
21 DesktopAppActivationResponse,
22} from "./desktopAppActivation.ts";
23
24export interface ContextMenuItem<T extends string = string> {
25 id: T;
26 label: string;
27 destructive?: boolean;
28 disabled?: boolean;
29 header?: boolean;
30 icon?: string;
31 separatorBefore?: boolean;
32 checked?: boolean;
33 children?: readonly ContextMenuItem<T>[];
34}
35
36export type QuitShortcutHintEvent =
37 | { readonly state: "down"; readonly mode: Exclude<QuitConfirmationMode, "direct"> }
38 | { readonly state: "up" };
39
40export interface ContextMenuItemSchemaType {
41 readonly id: string;
42 readonly label: string;
43 readonly destructive?: boolean;
44 readonly disabled?: boolean;
45 readonly header?: boolean;
46 readonly icon?: string;
47 readonly separatorBefore?: boolean;
48 readonly checked?: boolean;
49 readonly children?: readonly ContextMenuItemSchemaType[];
50}
51
52export const ContextMenuItemSchema: Schema.Codec<ContextMenuItemSchemaType> = Schema.Struct({
53 id: Schema.String,
54 label: Schema.String,
55 destructive: Schema.optionalKey(Schema.Boolean),
56 disabled: Schema.optionalKey(Schema.Boolean),
57 header: Schema.optionalKey(Schema.Boolean),
58 icon: Schema.optionalKey(Schema.String),
59 separatorBefore: Schema.optionalKey(Schema.Boolean),
60 checked: Schema.optionalKey(Schema.Boolean),
61 children: Schema.optionalKey(
62 Schema.Array(
63 Schema.suspend((): Schema.Codec<ContextMenuItemSchemaType> => ContextMenuItemSchema),
64 ),
65 ),
66});
67
68export type DesktopUpdateStatus =
69 | "disabled"
70 | "idle"
71 | "checking"
72 | "up-to-date"
73 | "available"
74 | "downloading"
75 | "downloaded"
76 | "error";
77
78export type DesktopRuntimeArch = "arm64" | "x64" | "other";
79export type DesktopTheme = "light" | "dark" | "system";
80export type DesktopUpdateChannel = "latest" | "nightly";
81export type DesktopAppStageLabel = "Alpha" | "Beta" | "Dev" | "Nightly";
82
83export const DesktopUpdateStatusSchema = Schema.Literals([
84 "disabled",
85 "idle",
86 "checking",
87 "up-to-date",
88 "available",
89 "downloading",
90 "downloaded",
91 "error",
92]);
93export const DesktopRuntimeArchSchema = Schema.Literals(["arm64", "x64", "other"]);
94export const DesktopThemeSchema = Schema.Literals(["light", "dark", "system"]);
95export const DesktopUpdateChannelSchema = Schema.Literals(["latest", "nightly"]);
96export const DesktopAppStageLabelSchema = Schema.Literals(["Alpha", "Beta", "Dev", "Nightly"]);
97
98export interface DesktopAppBranding {
99 baseName: string;
100 stageLabel: DesktopAppStageLabel;
101 displayName: string;
102}
103
104export const DesktopAppBrandingSchema = Schema.Struct({
105 baseName: Schema.String,
106 stageLabel: DesktopAppStageLabelSchema,
107 displayName: Schema.String,
108});
109
110export const DesktopSnapShotMode = Schema.Literals(["direct", "portal", "unavailable"]);
111export type DesktopSnapShotMode = typeof DesktopSnapShotMode.Type;
112
113export const DesktopCaptureExtensionState = Schema.Struct({
114 status: Schema.Literals([
115 "not-installed",
116 "disabled",
117 "enabled",
118 "restart-required",
119 "update-required",
120 "extensions-disabled",
121 "unsupported",
122 "error",
123 ]),
124 message: Schema.String,
125});
126export type DesktopCaptureExtensionState = typeof DesktopCaptureExtensionState.Type;
127
128export const DesktopCaptureHelperState = Schema.Struct({
129 status: Schema.Literals(["not-installed", "update-required", "ready", "error"]),
130 message: Schema.String,
131 feedbackAvailable: Schema.optional(Schema.Boolean),
132});
133export type DesktopCaptureHelperState = typeof DesktopCaptureHelperState.Type;
134
135export const DesktopSnapShotSetupAction = Schema.Literals([
136 "install-extension",
137 "enable-extension",
138 "disable-extension",
139 "install-kde-helper",
140 "remove-kde-helper",
141 "install-hyprland-helper",
142 "remove-hyprland-helper",
143 "test-mac-capture",
144 "allow-screen-recording",
145 "allow-accessibility",
146 "retry-shortcut",
147]);
148export type DesktopSnapShotSetupAction = typeof DesktopSnapShotSetupAction.Type;
149
150export const DesktopCaptureConfigRequest = Schema.Struct({
151 operation: Schema.Literals(["install", "remove"]),
152 chooseFile: Schema.Boolean,
153 shortcut: Schema.optional(Schema.String.check(Schema.isMaxLength(80))),
154});
155export type DesktopCaptureConfigRequest = typeof DesktopCaptureConfigRequest.Type;
156
157export const DesktopCaptureConfigPreview = Schema.Struct({
158 id: Schema.String,
159 path: Schema.String,
160 resolvedPath: Schema.String,
161 before: Schema.String,
162 after: Schema.String,
163 shortcut: Schema.String,
164 operation: Schema.Literals(["install", "remove"]),
165});
166export type DesktopCaptureConfigPreview = typeof DesktopCaptureConfigPreview.Type;
167
168export const DesktopCaptureConfigApplied = Schema.Struct({
169 backupPath: Schema.NullOr(Schema.String),
170 warning: Schema.NullOr(Schema.String),
171});
172export type DesktopCaptureConfigApplied = typeof DesktopCaptureConfigApplied.Type;
173
174export const DesktopSnapShotState = Schema.Struct({
175 mode: DesktopSnapShotMode,
176 windows: Schema.optional(Schema.Boolean),
177 linuxDesktop: Schema.optional(Schema.Literals(["gnome", "kde", "niri", "hyprland"])),
178 linuxBackend: Schema.optional(
179 Schema.Literals(["screenshot-portal", "gnome-extension", "niri", "kde", "hyprland", "picker"]),
180 ),
181 linuxFeedbackAvailable: Schema.optional(Schema.Boolean),
182 shortcut: SnapShotShortcut,
183 shortcutRegistered: Schema.Boolean,
184 shortcutPending: Schema.optional(Schema.Boolean),
185 shortcutCanRetry: Schema.optional(Schema.Boolean),
186 shortcutLabel: Schema.optional(Schema.String),
187 shortcutMessage: Schema.NullOr(Schema.String),
188 shortcutBinding: Schema.optional(Schema.String),
189 shortcutConfigPath: Schema.optional(Schema.String),
190 shortcutActionRegistered: Schema.optional(Schema.Boolean),
191 gnomeExtension: Schema.optional(DesktopCaptureExtensionState),
192 kdeHelper: Schema.optional(DesktopCaptureHelperState),
193 hyprlandHelper: Schema.optional(DesktopCaptureHelperState),
194 macPermissions: Schema.optional(
195 Schema.Struct({ screenRecording: Schema.Boolean, accessibility: Schema.Boolean }),
196 ),
197 shortcutVerified: Schema.optional(Schema.Boolean),
198 message: Schema.NullOr(Schema.String),
199});
200export type DesktopSnapShotState = typeof DesktopSnapShotState.Type;
201
202export const DesktopSnapShotShortcutAvailability = Schema.Struct({
203 available: Schema.Boolean,
204 message: Schema.NullOr(Schema.String),
205});
206export type DesktopSnapShotShortcutAvailability = typeof DesktopSnapShotShortcutAvailability.Type;
207
208export const DesktopSnapShotId = TrimmedNonEmptyString.check(
209 Schema.isMaxLength(64),
210 Schema.isPattern(/^[a-f0-9-]+$/i),
211);
212export type DesktopSnapShotId = typeof DesktopSnapShotId.Type;
213
214/** `id` is absent for failures before a capture exists. */
215export const DesktopSnapShotEvent = Schema.Union([
216 Schema.Struct({ type: Schema.Literal("requested"), id: DesktopSnapShotId }),
217 Schema.Struct({ type: Schema.Literal("started"), id: DesktopSnapShotId }),
218 Schema.Struct({ type: Schema.Literal("ready"), id: DesktopSnapShotId }),
219 Schema.Struct({ type: Schema.Literal("failed"), id: Schema.optional(DesktopSnapShotId) }),
220 Schema.Struct({ type: Schema.Literal("shortcut-changed") }),
221]);
222export type DesktopSnapShotEvent = typeof DesktopSnapShotEvent.Type;
223
224export const DesktopPendingSnapShot = Schema.Struct({
225 id: DesktopSnapShotId,
226 name: Schema.String,
227 mimeType: Schema.Literal("image/png"),
228 sizeBytes: Schema.Int,
229 source: SnapShotSource,
230});
231export type DesktopPendingSnapShot = typeof DesktopPendingSnapShot.Type;
232
233export const DesktopSnapShot = Schema.Struct({
234 ...DesktopPendingSnapShot.fields,
235 dataUrl: Schema.String,
236});
237export type DesktopSnapShot = typeof DesktopSnapShot.Type;
238
239export const DesktopSnapShotAnimationDestination = Schema.Struct({
240 id: DesktopSnapShotId,
241 viewportFrame: Schema.Struct({
242 x: Schema.Number,
243 y: Schema.Number,
244 width: Schema.Number,
245 height: Schema.Number,
246 }),
247 backgroundColor: Schema.String,
248 borderColor: Schema.String,
249 borderWidth: Schema.Number,
250 cornerRadius: Schema.Number,
251 details: Schema.optional(
252 Schema.Struct({
253 appName: SnapShotSource.fields.appName,
254 windowTitle: SnapShotSource.fields.windowTitle,
255 appIconDataUrl: SnapShotSource.fields.appIconDataUrl,
256 }),
257 ),
258});
259export type DesktopSnapShotAnimationDestination = typeof DesktopSnapShotAnimationDestination.Type;
260
261export interface DesktopRuntimeInfo {
262 hostArch: DesktopRuntimeArch;
263 appArch: DesktopRuntimeArch;
264 runningUnderArm64Translation: boolean;
265}
266
267export interface DesktopUpdateState {
268 enabled: boolean;
269 status: DesktopUpdateStatus;
270 channel: DesktopUpdateChannel;
271 currentVersion: string;
272 hostArch: DesktopRuntimeArch;
273 appArch: DesktopRuntimeArch;
274 runningUnderArm64Translation: boolean;
275 availableVersion: string | null;
276 downloadedVersion: string | null;
277 releaseNotes: ReadonlyArray<DesktopUpdateReleaseNote>;
278 omittedReleaseCount: number;
279 downloadPercent: number | null;
280 checkedAt: string | null;
281 message: string | null;
282 errorContext: "check" | "download" | "install" | null;
283 canRetry: boolean;
284 notAppliedVersion?: string;
285}
286
287export interface DesktopUpdateReleaseNote {
288 version: string;
289 items: ReadonlyArray<string>;
290 totalItems: number;
291 /** ISO time from the update feed for the offered version, else `YYYY-MM-DD` from a prerelease version. */
292 releasedAt?: string;
293 /** Generated summaries only: the highlights paragraph. `items` then holds the fixes. */
294 intro?: string;
295 /** Generated summaries only, for example "275 changes from 22 contributors". */
296 stats?: string;
297}
298
299export const DesktopUpdateReleaseNoteSchema = Schema.Struct({
300 version: Schema.String,
301 items: Schema.Array(Schema.String),
302 totalItems: Schema.Number,
303 releasedAt: Schema.optionalKey(Schema.String),
304 intro: Schema.optionalKey(Schema.String),
305 stats: Schema.optionalKey(Schema.String),
306});
307
308export const DesktopUpdateStateSchema = Schema.Struct({
309 enabled: Schema.Boolean,
310 status: DesktopUpdateStatusSchema,
311 channel: DesktopUpdateChannelSchema,
312 currentVersion: Schema.String,
313 hostArch: DesktopRuntimeArchSchema,
314 appArch: DesktopRuntimeArchSchema,
315 runningUnderArm64Translation: Schema.Boolean,
316 availableVersion: Schema.NullOr(Schema.String),
317 downloadedVersion: Schema.NullOr(Schema.String),
318 releaseNotes: Schema.Array(DesktopUpdateReleaseNoteSchema),
319 omittedReleaseCount: Schema.Number,
320 downloadPercent: Schema.NullOr(Schema.Number),
321 checkedAt: Schema.NullOr(Schema.String),
322 message: Schema.NullOr(Schema.String),
323 errorContext: Schema.NullOr(Schema.Literals(["check", "download", "install"])),
324 canRetry: Schema.Boolean,
325 notAppliedVersion: Schema.optionalKey(Schema.String),
326});
327
328export const DesktopCliCommandStateSchema = Schema.Struct({
329 supported: Schema.Boolean,
330 installedPath: Schema.NullOr(Schema.String),
331 onPath: Schema.Boolean,
332 shadowedBy: Schema.optionalKey(Schema.String),
333 /** The app's bundled `t3` launcher, which runs without Node or a PATH entry. */
334 launcherPath: Schema.NullOr(Schema.String),
335});
336export type DesktopCliCommandState = typeof DesktopCliCommandStateSchema.Type;
337
338export interface DesktopUpdateActionResult {
339 accepted: boolean;
340 completed: boolean;
341 state: DesktopUpdateState;
342}
343
344export const DesktopUpdateActionResultSchema = Schema.Struct({
345 accepted: Schema.Boolean,
346 completed: Schema.Boolean,
347 state: DesktopUpdateStateSchema,
348});
349
350export interface DesktopUpdateCheckResult {
351 checked: boolean;
352 state: DesktopUpdateState;
353}
354
355export const DesktopUpdateCheckResultSchema = Schema.Struct({
356 checked: Schema.Boolean,
357 state: DesktopUpdateStateSchema,
358});
359
360export const PRIMARY_LOCAL_ENVIRONMENT_ID = "primary";
361
362export interface DesktopEnvironmentBootstrap {
363 // Stable backend identity used to reopen routed projects.
364 id: string;
365 label: string;
366 // Actual distro for this run; id stays wsl:default when tracking the default.
367 runningDistro?: string | null;
368 httpBaseUrl: string | null;
369 wsBaseUrl: string | null;
370 bootstrapToken?: string;
371}
372
373export const DesktopEnvironmentBootstrapSchema = Schema.Struct({
374 id: Schema.String,
375 label: Schema.String,
376 runningDistro: Schema.optionalKey(Schema.NullOr(Schema.String)),
377 httpBaseUrl: Schema.NullOr(Schema.String),
378 wsBaseUrl: Schema.NullOr(Schema.String),
379 bootstrapToken: Schema.optionalKey(Schema.String),
380});
381
382export const DesktopSshEnvironmentTargetSchema = Schema.Struct({
383 alias: Schema.String,
384 hostname: Schema.String,
385 username: Schema.NullOr(Schema.String),
386 port: Schema.NullOr(Schema.Number),
387});
388export type DesktopSshEnvironmentTarget = typeof DesktopSshEnvironmentTargetSchema.Type;
389
390export type DesktopSshHostSource = "ssh-config" | "known-hosts";
391export const DesktopSshHostSourceSchema = Schema.Literals(["ssh-config", "known-hosts"]);
392
393export interface DesktopDiscoveredSshHost extends DesktopSshEnvironmentTarget {
394 source: DesktopSshHostSource;
395}
396
397export const DesktopDiscoveredSshHostSchema = Schema.Struct({
398 alias: Schema.String,
399 hostname: Schema.String,
400 username: Schema.NullOr(Schema.String),
401 port: Schema.NullOr(Schema.Number),
402 source: DesktopSshHostSourceSchema,
403});
404
405export interface DesktopSshEnvironmentBootstrap {
406 target: DesktopSshEnvironmentTarget;
407 httpBaseUrl: string;
408 wsBaseUrl: string;
409 pairingToken: string | null;
410 remotePort?: number;
411 remoteServerKind?: "external" | "managed";
412}
413
414export const DesktopSshEnvironmentBootstrapSchema = Schema.Struct({
415 target: DesktopSshEnvironmentTargetSchema,
416 httpBaseUrl: Schema.String,
417 wsBaseUrl: Schema.String,
418 pairingToken: Schema.NullOr(Schema.String),
419 remotePort: Schema.optionalKey(Schema.Number),
420 remoteServerKind: Schema.optionalKey(Schema.Literals(["external", "managed"])),
421});
422
423export interface DesktopSshPasswordPromptRequest {
424 requestId: string;
425 destination: string;
426 username: string | null;
427 prompt: string;
428 expiresAt: string;
429}
430
431export const DesktopSshPasswordPromptCancelledType = "ssh-password-prompt-cancelled" as const;
432
433export const DesktopSshPasswordPromptCancelledResultSchema = Schema.Struct({
434 type: Schema.Literal(DesktopSshPasswordPromptCancelledType),
435 message: Schema.String,
436});
437
438export const DesktopSshEnvironmentEnsureOptionsSchema = Schema.Struct({
439 issuePairingToken: Schema.optionalKey(Schema.Boolean),
440});
441
442export const DesktopSshEnvironmentEnsureInputSchema = Schema.Struct({
443 target: DesktopSshEnvironmentTargetSchema,
444 options: Schema.optionalKey(DesktopSshEnvironmentEnsureOptionsSchema),
445});
446
447export const DesktopSshEnvironmentEnsureResultSchema = Schema.Union([
448 DesktopSshEnvironmentBootstrapSchema,
449 DesktopSshPasswordPromptCancelledResultSchema,
450]);
451
452export const DesktopSshHttpBaseUrlInputSchema = Schema.Struct({
453 httpBaseUrl: Schema.String,
454});
455
456export const DesktopSshBearerRequestInputSchema = Schema.Struct({
457 httpBaseUrl: Schema.String,
458 bearerToken: Schema.String,
459});
460
461export const DesktopSshBearerBootstrapInputSchema = Schema.Struct({
462 httpBaseUrl: Schema.String,
463 credential: Schema.String,
464});
465
466export const DesktopSshPasswordPromptResolutionInputSchema = Schema.Struct({
467 requestId: Schema.String,
468 password: Schema.NullOr(Schema.String),
469});
470
471export const PersistedSavedEnvironmentRecordSchema = Schema.Struct({
472 environmentId: EnvironmentId,
473 label: Schema.String,
474 wsBaseUrl: Schema.String,
475 httpBaseUrl: Schema.String,
476 createdAt: Schema.String,
477 lastConnectedAt: Schema.NullOr(Schema.String),
478 desktopSsh: Schema.optionalKey(DesktopSshEnvironmentTargetSchema),
479 relayManaged: Schema.optionalKey(
480 Schema.Struct({
481 relayUrl: Schema.String,
482 }),
483 ),
484});
485export type PersistedSavedEnvironmentRecord = typeof PersistedSavedEnvironmentRecordSchema.Type;
486
487export type DesktopServerExposureMode = "local-only" | "network-accessible";
488
489export const DesktopServerExposureModeSchema = Schema.Literals([
490 "local-only",
491 "network-accessible",
492]);
493
494export interface DesktopServerExposureState {
495 mode: DesktopServerExposureMode;
496 endpointUrl: string | null;
497 advertisedHost: string | null;
498 tailscaleServeEnabled: boolean;
499 tailscaleServePort: number;
500}
501
502export const DesktopServerExposureStateSchema = Schema.Struct({
503 mode: DesktopServerExposureModeSchema,
504 endpointUrl: Schema.NullOr(Schema.String),
505 advertisedHost: Schema.NullOr(Schema.String),
506 tailscaleServeEnabled: Schema.Boolean,
507 tailscaleServePort: Schema.Number,
508});
509
510export interface PickFolderOptions {
511 initialPath?: string | null;
512 targetEnvironmentId?: string;
513}
514
515export const PickFolderOptionsSchema = Schema.Struct({
516 initialPath: Schema.optionalKey(Schema.NullOr(Schema.String)),
517 targetEnvironmentId: Schema.optionalKey(Schema.String),
518});
519
520/** Oversized files have empty text so the main process never loads their contents. */
521export interface PickedThemeFile {
522 name: string;
523 size: number;
524 text: string;
525}
526
527export const PickedThemeFileSchema = Schema.Struct({
528 name: Schema.String,
529 size: Schema.Number,
530 text: Schema.String,
531});
532
533export interface DesktopWslDistro {
534 name: string;
535 isDefault: boolean;
536 version: 1 | 2;
537}
538
539export const DesktopWslDistroSchema = Schema.Struct({
540 name: Schema.String,
541 isDefault: Schema.Boolean,
542 version: Schema.Literals([1, 2]),
543});
544
545export interface DesktopWslState {
546 enabled: boolean;
547 // null means "track the current WSL default distro".
548 distro: string | null;
549 available: boolean;
550 wslOnly: boolean;
551 distros: readonly DesktopWslDistro[];
552 // Always null in wsl-only mode, which falls back to Windows with a dialog.
553 preflightError: string | null;
554}
555
556export const DesktopWslStateSchema = Schema.Struct({
557 enabled: Schema.Boolean,
558 distro: Schema.NullOr(Schema.String),
559 available: Schema.Boolean,
560 wslOnly: Schema.Boolean,
561 distros: Schema.Array(DesktopWslDistroSchema),
562 preflightError: Schema.NullOr(Schema.String),
563});
564
565export type DesktopPreviewNavStatus =
566 | { kind: "Idle" }
567 | { kind: "Loading"; url: string; title: string }
568 | { kind: "Success"; url: string; title: string }
569 | {
570 kind: "LoadFailed";
571 url: string;
572 title: string;
573 code: number;
574 description: string;
575 };
576
577export type DesktopPreviewColorScheme = "system" | "light" | "dark";
578
579export const DesktopPreviewColorSchemeSchema: Schema.Codec<DesktopPreviewColorScheme> =
580 Schema.Literals(["system", "light", "dark"]);
581
582export const FAVICON_DATA_URL_MAX_LENGTH = 8192;
583export const FAVICON_CAPTURED_AT_MAX = 8_640_000_000_000_000;
584
585export interface DesktopPreviewFavicon {
586 dataUrl: string;
587 pageUrl: string;
588 capturedAt: number;
589}
590
591export interface DesktopPreviewTabState {
592 tabId: string;
593 webContentsId: number | null;
594 navStatus: DesktopPreviewNavStatus;
595 canGoBack: boolean;
596 canGoForward: boolean;
597 zoomFactor: number;
598 pictureInPicture: boolean;
599 colorScheme: DesktopPreviewColorScheme;
600 audioMuted: boolean;
601 /** Chromium reports playback even when audioMuted is true. */
602 audible: boolean;
603 controller: "human" | "agent" | "none";
604 /** A screenshot or stream of the guest is pending, so the client keeps it painting while hidden. */
605 capturing: boolean;
606 favicon?: DesktopPreviewFavicon;
607 updatedAt: string;
608}
609
610export const DesktopPreviewTabIdSchema = Schema.String.check(Schema.isTrimmed()).check(
611 Schema.isNonEmpty(),
612);
613
614export interface DesktopPreviewPointerEvent {
615 tabId: string;
616 phase: "move" | "click";
617 x: number;
618 y: number;
619 sequence: number;
620 createdAt: string;
621}
622
623export interface DesktopPreviewOpenLinkEvent {
624 tabId: string;
625 url: string;
626 background: boolean;
627}
628
629export const DesktopPreviewRecordingInputSchema = Schema.Union([
630 Schema.Struct({
631 type: Schema.Literal("pointer"),
632 phase: Schema.Literals(["move", "down", "up", "click"]),
633 x: Schema.Finite,
634 y: Schema.Finite,
635 width: Schema.Finite.check(Schema.isGreaterThan(0)),
636 height: Schema.Finite.check(Schema.isGreaterThan(0)),
637 }),
638 Schema.Struct({
639 type: Schema.Literal("key"),
640 label: Schema.NullOr(Schema.String.check(Schema.isMaxLength(100))),
641 held: Schema.Boolean,
642 width: Schema.Finite.check(Schema.isGreaterThan(0)),
643 }),
644 Schema.Struct({ type: Schema.Literal("clear") }),
645]);
646export type DesktopPreviewRecordingInput = typeof DesktopPreviewRecordingInputSchema.Type;
647export interface DesktopPreviewRecordingInputEvent {
648 readonly tabId: string;
649 readonly input: DesktopPreviewRecordingInput;
650}
651
652export interface DesktopPreviewWebviewConfig {
653 partition: string;
654 /** Sandboxed with contextIsolation off so the picker preload can read the React DevTools hook. */
655 webPreferences: string;
656 /** Absolute file:// preload URL; null requires disabling element picking. */
657 preloadUrl: string | null;
658}
659
660export const DesktopPreviewWebviewConfigSchema: Schema.Codec<DesktopPreviewWebviewConfig> =
661 Schema.Struct({
662 partition: Schema.String,
663 webPreferences: Schema.String,
664 preloadUrl: Schema.NullOr(Schema.String),
665 });
666
667export interface DesktopPreviewAnnotationTheme {
668 colorScheme: "light" | "dark";
669 radius: string;
670 background: string;
671 foreground: string;
672 popover: string;
673 popoverForeground: string;
674 primary: string;
675 primaryForeground: string;
676 muted: string;
677 mutedForeground: string;
678 accent: string;
679 accentForeground: string;
680 border: string;
681 input: string;
682 ring: string;
683 fontSans: string;
684 fontMono: string;
685}
686
687export const DesktopPreviewAnnotationThemeSchema: Schema.Codec<DesktopPreviewAnnotationTheme> =
688 Schema.Struct({
689 colorScheme: Schema.Literals(["light", "dark"]),
690 radius: Schema.String,
691 background: Schema.String,
692 foreground: Schema.String,
693 popover: Schema.String,
694 popoverForeground: Schema.String,
695 primary: Schema.String,
696 primaryForeground: Schema.String,
697 muted: Schema.String,
698 mutedForeground: Schema.String,
699 accent: Schema.String,
700 accentForeground: Schema.String,
701 border: Schema.String,
702 input: Schema.String,
703 ring: Schema.String,
704 fontSans: Schema.String,
705 fontMono: Schema.String,
706 });
707
708export interface DesktopPreviewRecordingFrame {
709 tabId: string;
710 data: string;
711 width: number;
712 height: number;
713 receivedAt: string;
714}
715
716export interface DesktopPreviewRecordingArtifact {
717 id: string;
718 tabId: string;
719 path: string;
720 mimeType: string;
721 sizeBytes: number;
722 createdAt: string;
723}
724
725export const DesktopPreviewRecordingArtifactSchema: Schema.Codec<DesktopPreviewRecordingArtifact> =
726 Schema.Struct({
727 id: Schema.String,
728 tabId: DesktopPreviewTabIdSchema,
729 path: Schema.String,
730 mimeType: Schema.String,
731 sizeBytes: Schema.Int,
732 createdAt: Schema.String,
733 });
734
735export interface DesktopPreviewScreenshotArtifact {
736 id: string;
737 tabId: string;
738 path: string;
739 mimeType: "image/png";
740 sizeBytes: number;
741 createdAt: string;
742}
743
744export const DesktopPreviewScreenshotArtifactSchema: Schema.Codec<DesktopPreviewScreenshotArtifact> =
745 Schema.Struct({
746 id: Schema.String,
747 tabId: DesktopPreviewTabIdSchema,
748 path: Schema.String,
749 mimeType: Schema.Literal("image/png"),
750 sizeBytes: Schema.Int,
751 createdAt: Schema.String,
752 });
753
754export interface PickedElementStackFrame {
755 functionName: string | null;
756 fileName: string | null;
757 lineNumber: number | null;
758 columnNumber: number | null;
759}
760
761export const PickedElementStackFrameSchema: Schema.Codec<PickedElementStackFrame> = Schema.Struct({
762 functionName: Schema.NullOr(Schema.String),
763 fileName: Schema.NullOr(Schema.String),
764 lineNumber: Schema.NullOr(Schema.Number),
765 columnNumber: Schema.NullOr(Schema.Number),
766});
767
768export interface PickedElementPayload {
769 pageUrl: string;
770 pageTitle: string | null;
771 tagName: string;
772 selector: string | null;
773 htmlPreview: string;
774 componentName: string | null;
775 source: PickedElementStackFrame | null;
776 stack: ReadonlyArray<PickedElementStackFrame>;
777 styles: string;
778 pickedAt: string;
779}
780
781export const PickedElementPayloadSchema: Schema.Codec<PickedElementPayload> = Schema.Struct({
782 pageUrl: Schema.String,
783 pageTitle: Schema.NullOr(Schema.String),
784 tagName: Schema.String,
785 selector: Schema.NullOr(Schema.String),
786 htmlPreview: Schema.String,
787 componentName: Schema.NullOr(Schema.String),
788 source: Schema.NullOr(PickedElementStackFrameSchema),
789 stack: Schema.Array(PickedElementStackFrameSchema),
790 styles: Schema.String,
791 pickedAt: Schema.String,
792});
793
794export interface PreviewAnnotationRect {
795 x: number;
796 y: number;
797 width: number;
798 height: number;
799}
800
801export const PreviewAnnotationRectSchema: Schema.Codec<PreviewAnnotationRect> = Schema.Struct({
802 x: Schema.Number,
803 y: Schema.Number,
804 width: Schema.Number,
805 height: Schema.Number,
806});
807
808export interface PreviewAnnotationPoint {
809 x: number;
810 y: number;
811}
812
813export const PreviewAnnotationPointSchema: Schema.Codec<PreviewAnnotationPoint> = Schema.Struct({
814 x: Schema.Number,
815 y: Schema.Number,
816});
817
818export interface PreviewAnnotationElementTarget {
819 id: string;
820 element: PickedElementPayload;
821 rect: PreviewAnnotationRect;
822}
823
824export const PreviewAnnotationElementTargetSchema: Schema.Codec<PreviewAnnotationElementTarget> =
825 Schema.Struct({
826 id: Schema.String,
827 element: PickedElementPayloadSchema,
828 rect: PreviewAnnotationRectSchema,
829 });
830
831export interface PreviewAnnotationRegionTarget {
832 id: string;
833 rect: PreviewAnnotationRect;
834}
835
836export const PreviewAnnotationRegionTargetSchema: Schema.Codec<PreviewAnnotationRegionTarget> =
837 Schema.Struct({
838 id: Schema.String,
839 rect: PreviewAnnotationRectSchema,
840 });
841
842export interface PreviewAnnotationStrokeTarget {
843 id: string;
844 color: string;
845 width: number;
846 points: ReadonlyArray<PreviewAnnotationPoint>;
847 bounds: PreviewAnnotationRect;
848}
849
850export const PreviewAnnotationStrokeTargetSchema: Schema.Codec<PreviewAnnotationStrokeTarget> =
851 Schema.Struct({
852 id: Schema.String,
853 color: Schema.String,
854 width: Schema.Number,
855 points: Schema.Array(PreviewAnnotationPointSchema),
856 bounds: PreviewAnnotationRectSchema,
857 });
858
859export interface PreviewAnnotationStyleChange {
860 targetId: string;
861 selector: string | null;
862 property: string;
863 previousValue: string;
864 value: string;
865}
866
867export const PreviewAnnotationStyleChangeSchema: Schema.Codec<PreviewAnnotationStyleChange> =
868 Schema.Struct({
869 targetId: Schema.String,
870 selector: Schema.NullOr(Schema.String),
871 property: Schema.String,
872 previousValue: Schema.String,
873 value: Schema.String,
874 });
875
876export interface PreviewAnnotationScreenshot {
877 dataUrl: string;
878 width: number;
879 height: number;
880 cropRect: PreviewAnnotationRect;
881}
882
883export const PreviewAnnotationScreenshotSchema: Schema.Codec<PreviewAnnotationScreenshot> =
884 Schema.Struct({
885 dataUrl: Schema.String,
886 width: Schema.Number,
887 height: Schema.Number,
888 cropRect: PreviewAnnotationRectSchema,
889 });
890
891export interface PreviewAnnotationPayload {
892 id: string;
893 pageUrl: string;
894 pageTitle: string | null;
895 comment: string;
896 elements: ReadonlyArray<PreviewAnnotationElementTarget>;
897 regions: ReadonlyArray<PreviewAnnotationRegionTarget>;
898 strokes: ReadonlyArray<PreviewAnnotationStrokeTarget>;
899 styleChanges: ReadonlyArray<PreviewAnnotationStyleChange>;
900 screenshot: PreviewAnnotationScreenshot | null;
901 createdAt: string;
902}
903
904export const PreviewAnnotationPayloadSchema: Schema.Codec<PreviewAnnotationPayload> = Schema.Struct(
905 {
906 id: Schema.String,
907 pageUrl: Schema.String,
908 pageTitle: Schema.NullOr(Schema.String),
909 comment: Schema.String,
910 elements: Schema.Array(PreviewAnnotationElementTargetSchema),
911 regions: Schema.Array(PreviewAnnotationRegionTargetSchema),
912 strokes: Schema.Array(PreviewAnnotationStrokeTargetSchema),
913 styleChanges: Schema.Array(PreviewAnnotationStyleChangeSchema),
914 screenshot: Schema.NullOr(PreviewAnnotationScreenshotSchema),
915 createdAt: Schema.String,
916 },
917);
918
919export type PreviewAnnotationSubmission = "attach" | "send";
920export const PreviewAnnotationSubmissionSchema: Schema.Codec<PreviewAnnotationSubmission> =
921 Schema.Literals(["attach", "send"]);
922
923export interface PreviewAnnotationSubmissionResult {
924 annotation: PreviewAnnotationPayload;
925 submission: PreviewAnnotationSubmission;
926 screenshotFailed?: boolean;
927}
928export const PreviewAnnotationSubmissionResultSchema: Schema.Codec<PreviewAnnotationSubmissionResult> =
929 Schema.Struct({
930 annotation: PreviewAnnotationPayloadSchema,
931 submission: PreviewAnnotationSubmissionSchema,
932 screenshotFailed: Schema.optionalKey(Schema.Boolean),
933 });
934
935export const DesktopPreviewTabInputSchema = Schema.Struct({
936 tabId: DesktopPreviewTabIdSchema,
937});
938
939/** Apply zoom and color scheme at creation to avoid flashing browser defaults. */
940export const DesktopPreviewCreateTabInputSchema = Schema.Struct({
941 tabId: DesktopPreviewTabIdSchema,
942 zoomFactor: Schema.optional(Schema.Number.check(Schema.isGreaterThan(0))),
943 colorScheme: Schema.optional(DesktopPreviewColorSchemeSchema),
944 serverTab: Schema.optional(
945 Schema.Struct({ threadId: TrimmedNonEmptyString, tabId: TrimmedNonEmptyString }),
946 ),
947});
948
949export interface DesktopPreviewTabDefaults {
950 readonly zoomFactor?: number | undefined;
951 readonly colorScheme?: DesktopPreviewColorScheme | undefined;
952 readonly serverTab?: { readonly threadId: string; readonly tabId: string } | undefined;
953}
954
955export const DesktopPreviewRegisterWebviewInputSchema = Schema.Struct({
956 tabId: DesktopPreviewTabIdSchema,
957 webContentsId: Schema.Int.check(Schema.isGreaterThan(0)),
958});
959
960export const DesktopPreviewNavigateInputSchema = Schema.Struct({
961 tabId: DesktopPreviewTabIdSchema,
962 url: Schema.String,
963});
964
965export const DesktopPreviewConfigInputSchema = Schema.Struct({
966 environmentId: EnvironmentId,
967 /** Main must derive the partition to ensure its session has UA rewrites and permission handlers. */
968 profileId: Schema.optional(BrowserProfileId),
969});
970
971export const DesktopPreviewClearDataInputSchema = Schema.Struct({
972 environmentId: EnvironmentId,
973 /** Omit to clear every profile; otherwise only this profile's partition. */
974 profileId: Schema.optional(BrowserProfileId),
975});
976
977export const DesktopPreviewSetColorSchemeInputSchema = Schema.Struct({
978 tabId: DesktopPreviewTabIdSchema,
979 colorScheme: DesktopPreviewColorSchemeSchema,
980});
981
982export const DesktopPreviewSetZoomFactorInputSchema = Schema.Struct({
983 tabId: DesktopPreviewTabIdSchema,
984 zoomFactor: Schema.Number.check(Schema.isGreaterThan(0)),
985});
986
987export const DesktopPreviewSetAudioMutedInputSchema = Schema.Struct({
988 tabId: DesktopPreviewTabIdSchema,
989 audioMuted: Schema.Boolean,
990});
991
992export const DesktopPreviewAnnotationThemeInputSchema = Schema.Struct({
993 theme: DesktopPreviewAnnotationThemeSchema,
994});
995
996export const DesktopPreviewAnnotationSendEnabledInputSchema = Schema.Struct({
997 tabId: DesktopPreviewTabIdSchema,
998 enabled: Schema.Boolean,
999});
1000
1001export const DesktopPreviewArtifactInputSchema = Schema.Struct({
1002 path: Schema.String.check(Schema.isTrimmed()).check(Schema.isNonEmpty()),
1003});
1004
1005export const DesktopPreviewRecordingSaveInputSchema = Schema.Struct({
1006 tabId: DesktopPreviewTabIdSchema,
1007 mimeType: Schema.String.check(Schema.isTrimmed()).check(Schema.isNonEmpty()),
1008 data: Schema.Uint8Array,
1009});
1010
1011export const SystemSettingsPaneSchema = Schema.Literals(["full-disk-access"]);
1012export type SystemSettingsPane = typeof SystemSettingsPaneSchema.Type;
1013
1014export interface DesktopBridge {
1015 getAppBranding: () => DesktopAppBranding | null;
1016 getRelayTelemetryEnabled: () => boolean;
1017 getPathForFile: (file: File) => string;
1018 getClientPlatform: () => string;
1019 setNotificationBadge: (badge: { count: number; image: string | null }) => Promise<void>;
1020 onNotificationBadgeClear: (listener: () => void) => () => void;
1021 onTrackpadScrollBegin: (listener: () => void) => () => void;
1022 onTrackpadScrollEnd: (listener: () => void) => () => void;
1023 /**
1024 * Renderer `window.focus()` cannot raise an Electron window, and on Wayland
1025 * only the main process can spend a notification click's activation token.
1026 */
1027 revealWindow: () => Promise<void>;
1028 /**
1029 * The OS locale as a BCP-47 tag, which the renderer cannot read for itself:
1030 * the packaged app ships only the `en-US` Chromium locale pak, so
1031 * `navigator.language` and the default `Intl` locale are pinned to `en-US`
1032 * regardless of OS settings.
1033 */
1034 getSystemLocale: () => string | null;
1035 getLocalEnvironmentBootstraps: () => readonly DesktopEnvironmentBootstrap[];
1036 getLocalEnvironmentEnabled: () => boolean;
1037 setLocalEnvironmentEnabled: (enabled: boolean) => Promise<void>;
1038 getLocalEnvironmentBearerToken: () => Promise<string>;
1039 getClientSettings: () => Promise<ClientSettings | null>;
1040 setClientSettings: (settings: ClientSettings) => Promise<void>;
1041 getConnectionCatalog: () => Promise<string | null>;
1042 setConnectionCatalog: (catalog: string) => Promise<boolean>;
1043 discoverSshHosts: () => Promise<readonly DesktopDiscoveredSshHost[]>;
1044 resolveSshHost: (alias: string) => Promise<DesktopSshEnvironmentTarget>;
1045 requestSnapShotPermissions: (includeAccessibility: boolean) => Promise<void>;
1046 getSnapShotState: () => Promise<DesktopSnapShotState>;
1047 setupSnapShot: (action: DesktopSnapShotSetupAction) => Promise<void>;
1048 previewSnapShotConfig: (
1049 request: DesktopCaptureConfigRequest,
1050 ) => Promise<DesktopCaptureConfigPreview | null>;
1051 applySnapShotConfig: (previewId: string) => Promise<DesktopCaptureConfigApplied>;
1052 checkSnapShotShortcut: (
1053 shortcut: SnapShotShortcut,
1054 ) => Promise<DesktopSnapShotShortcutAvailability>;
1055 setSnapShotShortcutSuppressed: (suppressed: boolean) => Promise<void>;
1056 listPendingSnapShots: () => Promise<readonly DesktopPendingSnapShot[]>;
1057 readSnapShot: (id: string) => Promise<DesktopSnapShot>;
1058 setSnapShotAnimationDestination: (
1059 destination: DesktopSnapShotAnimationDestination,
1060 ) => Promise<void>;
1061 dismissSnapShotAnimation: (id: DesktopSnapShotId) => Promise<void>;
1062 acknowledgeSnapShot: (id: string) => Promise<void>;
1063 ensureSshEnvironment: (
1064 target: DesktopSshEnvironmentTarget,
1065 options?: { issuePairingToken?: boolean },
1066 ) => Promise<DesktopSshEnvironmentBootstrap>;
1067 disconnectSshEnvironment: (target: DesktopSshEnvironmentTarget) => Promise<void>;
1068 fetchSshEnvironmentDescriptor: (httpBaseUrl: string) => Promise<ExecutionEnvironmentDescriptor>;
1069 bootstrapSshBearerSession: (
1070 httpBaseUrl: string,
1071 credential: string,
1072 ) => Promise<AuthAccessTokenResult>;
1073 fetchSshSessionState: (httpBaseUrl: string, bearerToken: string) => Promise<AuthSessionState>;
1074 onSshPasswordPrompt: (listener: (request: DesktopSshPasswordPromptRequest) => void) => () => void;
1075 resolveSshPasswordPrompt: (requestId: string, password: string | null) => Promise<void>;
1076 getServerExposureState: () => Promise<DesktopServerExposureState>;
1077 setServerExposureMode: (mode: DesktopServerExposureMode) => Promise<DesktopServerExposureState>;
1078 setTailscaleServeEnabled: (input: {
1079 readonly enabled: boolean;
1080 readonly port?: number;
1081 }) => Promise<DesktopServerExposureState>;
1082 getAdvertisedEndpoints: () => Promise<readonly AdvertisedEndpoint[]>;
1083 getWslState: () => Promise<DesktopWslState>;
1084 setWslBackendEnabled: (enabled: boolean) => Promise<DesktopWslState>;
1085 setWslDistro: (distro: string | null) => Promise<DesktopWslState>;
1086 setWslOnly: (enabled: boolean) => Promise<DesktopWslState>;
1087 pickFolder: (options?: PickFolderOptions) => Promise<string | null>;
1088 pickProjectFavicon: (initialPath?: string) => Promise<string | null>;
1089 pickThemeFiles: () => Promise<readonly PickedThemeFile[] | null>;
1090 setTheme: (theme: DesktopTheme) => Promise<void>;
1091 showContextMenu: <T extends string>(
1092 items: readonly ContextMenuItem<T>[],
1093 position?: { x: number; y: number },
1094 ) => Promise<T | null>;
1095 receiveProviderAuthCallback: (authorizationUrl: string) => Promise<string>;
1096 cancelProviderAuthCallback: (authorizationUrl: string) => Promise<void>;
1097 openExternal: (url: string) => Promise<boolean>;
1098 openSystemSettings: (pane: SystemSettingsPane) => Promise<boolean>;
1099 checkSystemPermission: (pane: SystemSettingsPane) => Promise<boolean>;
1100 probeRemoteEditors: () => Promise<readonly EditorId[]>;
1101 pasteAsText: () => Promise<void>;
1102 onMenuAction: (listener: (action: string) => void) => () => void;
1103 onSnapShotEvent: (listener: (event: DesktopSnapShotEvent) => void) => () => void;
1104 onQuitShortcut: (listener: (event: QuitShortcutHintEvent) => void) => () => void;
1105 getWindowFullscreenState: () => boolean;
1106 onWindowFullscreenStateChange: (listener: (fullscreen: boolean) => void) => () => void;
1107 getWindowZoomFactor: () => number;
1108 getUpdateState: () => Promise<DesktopUpdateState>;
1109 /** `minimumVersion` is a track switch's checked release; nothing older is offered after. */
1110 setUpdateChannel: (
1111 channel: DesktopUpdateChannel,
1112 minimumVersion?: string,
1113 ) => Promise<DesktopUpdateState>;
1114 checkForUpdate: () => Promise<DesktopUpdateCheckResult>;
1115 downloadUpdate: () => Promise<DesktopUpdateActionResult>;
1116 /** With a version, installs only that downloaded build. */
1117 installUpdate: (expectedVersion?: string) => Promise<DesktopUpdateActionResult>;
1118 onUpdateState: (listener: (state: DesktopUpdateState) => void) => () => void;
1119 cliCommand: {
1120 getState: () => Promise<DesktopCliCommandState>;
1121 install: () => Promise<DesktopCliCommandState>;
1122 uninstall: () => Promise<DesktopCliCommandState>;
1123 };
1124 webLinks: {
1125 setReady: (ready: boolean) => Promise<void>;
1126 onOpen: (listener: (url: string) => void) => () => void;
1127 };
1128 appActivation: {
1129 setReady: (ready: boolean) => Promise<void>;
1130 complete: (response: DesktopAppActivationResponse) => Promise<void>;
1131 onRequest: (listener: (request: DesktopAppActivationRequest) => void) => () => void;
1132 };
1133 preview: DesktopPreviewBridge;
1134}
1135
1136/** Renderer callback invoked by Electron with a fresh user gesture before display-media capture. */
1137export const DESKTOP_PREVIEW_RECORDING_CAPTURE_TRIGGER = "__t3DesktopPreviewRecordingCapture";
1138
1139export interface DesktopPreviewBridge {
1140 setForwardedShortcuts: (shortcuts: ReadonlyArray<PreviewForwardedShortcut>) => Promise<void>;
1141 createTab: (tabId: string, defaults?: DesktopPreviewTabDefaults) => Promise<void>;
1142 closeTab: (tabId: string) => Promise<void>;
1143 registerWebview: (tabId: string, webContentsId: number) => Promise<void>;
1144 navigate: (tabId: string, url: string) => Promise<void>;
1145 goBack: (tabId: string) => Promise<void>;
1146 goForward: (tabId: string) => Promise<void>;
1147 refresh: (tabId: string) => Promise<void>;
1148 zoomIn: (tabId: string) => Promise<void>;
1149 zoomOut: (tabId: string) => Promise<void>;
1150 resetZoom: (tabId: string) => Promise<void>;
1151 setZoomFactor: (tabId: string, zoomFactor: number) => Promise<void>;
1152 hardReload: (tabId: string) => Promise<void>;
1153 setColorScheme: (tabId: string, colorScheme: DesktopPreviewColorScheme) => Promise<void>;
1154 setAudioMuted: (tabId: string, audioMuted: boolean) => Promise<void>;
1155 openDevTools: (tabId: string) => Promise<void>;
1156 clearCookies: (environmentId: EnvironmentId, profileId?: string) => Promise<void>;
1157 clearCache: (environmentId: EnvironmentId, profileId?: string) => Promise<void>;
1158 getPreviewConfig: (
1159 environmentId: EnvironmentId,
1160 profileId?: string,
1161 ) => Promise<DesktopPreviewWebviewConfig>;
1162 listBrowserImportSources: () => Promise<ReadonlyArray<BrowserImportSource>>;
1163 importBrowserCookies: (input: {
1164 readonly environmentId: EnvironmentId;
1165 readonly sourceId: BrowserImportSourceId;
1166 readonly sourceProfileDirectory: string;
1167 readonly targetProfileId: string;
1168 }) => Promise<BrowserImportResult>;
1169 setAnnotationTheme: (theme: DesktopPreviewAnnotationTheme) => Promise<void>;
1170 setAnnotationSendEnabled: (tabId: string, enabled: boolean) => Promise<void>;
1171 /** Resolves with the annotation and attach/send intent, or null on cancellation. Rejects if activation fails. */
1172 pickElement: (tabId: string) => Promise<PreviewAnnotationSubmissionResult | null>;
1173 cancelPickElement: (tabId: string) => Promise<void>;
1174 captureScreenshot: (
1175 tabId: string,
1176 ) => Promise<DesktopPreviewScreenshotArtifact | PreviewCaptureFailureEncoded>;
1177 revealArtifact: (path: string) => Promise<void>;
1178 copyArtifactToClipboard: (path: string) => Promise<void>;
1179 pictureInPicture: {
1180 open: (tabId: string) => Promise<void>;
1181 close: (tabId: string) => Promise<void>;
1182 };
1183 recording: {
1184 onInput: (listener: (event: DesktopPreviewRecordingInputEvent) => void) => () => void;
1185 startScreencast: (tabId: string) => Promise<void | PreviewCaptureFailureEncoded>;
1186 stopScreencast: (tabId: string) => Promise<void>;
1187 save: (
1188 tabId: string,
1189 mimeType: string,
1190 data: Uint8Array,
1191 ) => Promise<DesktopPreviewRecordingArtifact>;
1192 };
1193 onStateChange: (listener: (tabId: string, state: DesktopPreviewTabState) => void) => () => void;
1194 onPointerEvent: (listener: (event: DesktopPreviewPointerEvent) => void) => () => void;
1195 onOpenLink: (listener: (event: DesktopPreviewOpenLinkEvent) => void) => () => void;
1196}
1197
1198export type ConfirmDialogVariant = "default" | "destructive";
1199
1200export interface ConfirmDialogOptions {
1201 readonly variant?: ConfirmDialogVariant;
1202}
1203
1204export interface LocalApi {
1205 dialogs: {
1206 pickFolder: (options?: PickFolderOptions) => Promise<string | null>;
1207 confirm: (message: string, options?: ConfirmDialogOptions) => Promise<boolean>;
1208 };
1209 shell: {
1210 openExternal: (url: string) => Promise<void>;
1211 openSystemSettings: (pane: SystemSettingsPane) => Promise<void>;
1212 };
1213 contextMenu: {
1214 show: <T extends string>(
1215 items: readonly ContextMenuItem<T>[],
1216 position?: { x: number; y: number },
1217 ) => Promise<T | null>;
1218 close: () => Promise<void>;
1219 };
1220 persistence: {
1221 getClientSettings: () => Promise<ClientSettings | null>;
1222 setClientSettings: (settings: ClientSettings) => Promise<void>;
1223 };
1224}