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