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

ipc.ts

1,237 lines42.0 KB

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>[];
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[];
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;
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;
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 /** Off only because a managed policy rules out this channel; switching channels turns it on. */
286 channelBlockedByPolicy?: true;
288​
289export interface DesktopUpdateReleaseNote {
290 version: string;
291 items: ReadonlyArray<string>;
292 totalItems: number;
293 /** ISO time from the update feed for the offered version, else `YYYY-MM-DD` from a prerelease version. */
294 releasedAt?: string;
295 /** Paragraph-style summaries from older releases keep their fixes in `items`. */
296 intro?: string;
297 /** Generated summaries only, for example "275 changes from 22 contributors". */
298 stats?: string;
299 footer?: string;
301​
302export const DesktopUpdateReleaseNoteSchema = Schema.Struct({
303 version: Schema.String,
304 items: Schema.Array(Schema.String),
305 totalItems: Schema.Number,
306 releasedAt: Schema.optionalKey(Schema.String),
307 intro: Schema.optionalKey(Schema.String),
308 stats: Schema.optionalKey(Schema.String),
309 footer: Schema.optionalKey(Schema.String),
310});
311​
312export const DesktopUpdateStateSchema = Schema.Struct({
313 enabled: Schema.Boolean,
314 status: DesktopUpdateStatusSchema,
315 channel: DesktopUpdateChannelSchema,
316 currentVersion: Schema.String,
317 hostArch: DesktopRuntimeArchSchema,
318 appArch: DesktopRuntimeArchSchema,
319 runningUnderArm64Translation: Schema.Boolean,
320 availableVersion: Schema.NullOr(Schema.String),
321 downloadedVersion: Schema.NullOr(Schema.String),
322 releaseNotes: Schema.Array(DesktopUpdateReleaseNoteSchema),
323 omittedReleaseCount: Schema.Number,
324 downloadPercent: Schema.NullOr(Schema.Number),
325 checkedAt: Schema.NullOr(Schema.String),
326 message: Schema.NullOr(Schema.String),
327 errorContext: Schema.NullOr(Schema.Literals(["check", "download", "install"])),
328 canRetry: Schema.Boolean,
329 notAppliedVersion: Schema.optionalKey(Schema.String),
330});
331​
332export const DesktopCliCommandStateSchema = Schema.Struct({
333 supported: Schema.Boolean,
334 installedPath: Schema.NullOr(Schema.String),
335 onPath: Schema.Boolean,
336 shadowedBy: Schema.optionalKey(Schema.String),
337 /** The app's bundled `t3` launcher, which runs without Node or a PATH entry. */
338 launcherPath: Schema.NullOr(Schema.String),
339});
340export type DesktopCliCommandState = typeof DesktopCliCommandStateSchema.Type;
341​
342export interface DesktopUpdateActionResult {
343 accepted: boolean;
344 completed: boolean;
345 state: DesktopUpdateState;
347​
348export const DesktopUpdateActionResultSchema = Schema.Struct({
349 accepted: Schema.Boolean,
350 completed: Schema.Boolean,
351 state: DesktopUpdateStateSchema,
352});
353​
354export interface DesktopUpdateCheckResult {
355 checked: boolean;
356 state: DesktopUpdateState;
358​
359export const DesktopUpdateCheckResultSchema = Schema.Struct({
360 checked: Schema.Boolean,
361 state: DesktopUpdateStateSchema,
362});
363​
364export const PRIMARY_LOCAL_ENVIRONMENT_ID = "primary";
365​
366export interface DesktopEnvironmentBootstrap {
367 // Stable backend identity used to reopen routed projects.
368 id: string;
369 label: string;
370 // Actual distro for this run; id stays wsl:default when tracking the default.
371 runningDistro?: string | null;
372 httpBaseUrl: string | null;
373 wsBaseUrl: string | null;
374 bootstrapToken?: string;
376​
377export const DesktopEnvironmentBootstrapSchema = Schema.Struct({
378 id: Schema.String,
379 label: Schema.String,
380 runningDistro: Schema.optionalKey(Schema.NullOr(Schema.String)),
381 httpBaseUrl: Schema.NullOr(Schema.String),
382 wsBaseUrl: Schema.NullOr(Schema.String),
383 bootstrapToken: Schema.optionalKey(Schema.String),
384});
385​
386export const DesktopSshEnvironmentTargetSchema = Schema.Struct({
387 alias: Schema.String,
388 hostname: Schema.String,
389 username: Schema.NullOr(Schema.String),
390 port: Schema.NullOr(Schema.Number),
391});
392export type DesktopSshEnvironmentTarget = typeof DesktopSshEnvironmentTargetSchema.Type;
393​
394export type DesktopSshHostSource = "ssh-config" | "known-hosts";
395export const DesktopSshHostSourceSchema = Schema.Literals(["ssh-config", "known-hosts"]);
396​
397export interface DesktopDiscoveredSshHost extends DesktopSshEnvironmentTarget {
398 source: DesktopSshHostSource;
400​
401export const DesktopDiscoveredSshHostSchema = Schema.Struct({
402 alias: Schema.String,
403 hostname: Schema.String,
404 username: Schema.NullOr(Schema.String),
405 port: Schema.NullOr(Schema.Number),
406 source: DesktopSshHostSourceSchema,
407});
408​
409export interface DesktopSshEnvironmentBootstrap {
410 target: DesktopSshEnvironmentTarget;
411 httpBaseUrl: string;
412 wsBaseUrl: string;
413 pairingToken: string | null;
414 remotePort?: number;
415 remoteServerKind?: "external" | "managed";
417​
418export const DesktopSshEnvironmentBootstrapSchema = Schema.Struct({
419 target: DesktopSshEnvironmentTargetSchema,
420 httpBaseUrl: Schema.String,
421 wsBaseUrl: Schema.String,
422 pairingToken: Schema.NullOr(Schema.String),
423 remotePort: Schema.optionalKey(Schema.Number),
424 remoteServerKind: Schema.optionalKey(Schema.Literals(["external", "managed"])),
425});
426​
427export interface DesktopSshPasswordPromptRequest {
428 requestId: string;
429 destination: string;
430 username: string | null;
431 prompt: string;
432 expiresAt: string;
434​
435export const DesktopSshPasswordPromptCancelledType = "ssh-password-prompt-cancelled" as const;
436​
437export const DesktopSshPasswordPromptCancelledResultSchema = Schema.Struct({
438 type: Schema.Literal(DesktopSshPasswordPromptCancelledType),
439 message: Schema.String,
440});
441​
442export const DesktopSshEnvironmentEnsureOptionsSchema = Schema.Struct({
443 issuePairingToken: Schema.optionalKey(Schema.Boolean),
444});
445​
446export const DesktopSshEnvironmentEnsureInputSchema = Schema.Struct({
447 target: DesktopSshEnvironmentTargetSchema,
448 options: Schema.optionalKey(DesktopSshEnvironmentEnsureOptionsSchema),
449});
450​
451export const DesktopSshEnvironmentEnsureResultSchema = Schema.Union([
452 DesktopSshEnvironmentBootstrapSchema,
453 DesktopSshPasswordPromptCancelledResultSchema,
454]);
455​
456export const DesktopSshHttpBaseUrlInputSchema = Schema.Struct({
457 httpBaseUrl: Schema.String,
458});
459​
460export const DesktopSshBearerRequestInputSchema = Schema.Struct({
461 httpBaseUrl: Schema.String,
462 bearerToken: Schema.String,
463});
464​
465export const DesktopSshBearerBootstrapInputSchema = Schema.Struct({
466 httpBaseUrl: Schema.String,
467 credential: Schema.String,
468});
469​
470export const DesktopSshPasswordPromptResolutionInputSchema = Schema.Struct({
471 requestId: Schema.String,
472 password: Schema.NullOr(Schema.String),
473});
474​
475export const PersistedSavedEnvironmentRecordSchema = Schema.Struct({
476 environmentId: EnvironmentId,
477 label: Schema.String,
478 wsBaseUrl: Schema.String,
479 httpBaseUrl: Schema.String,
480 createdAt: Schema.String,
481 lastConnectedAt: Schema.NullOr(Schema.String),
482 desktopSsh: Schema.optionalKey(DesktopSshEnvironmentTargetSchema),
483 relayManaged: Schema.optionalKey(
484 Schema.Struct({
485 relayUrl: Schema.String,
486 }),
487 ),
488});
489export type PersistedSavedEnvironmentRecord = typeof PersistedSavedEnvironmentRecordSchema.Type;
490​
491export type DesktopServerExposureMode = "local-only" | "network-accessible";
492​
493export const DesktopServerExposureModeSchema = Schema.Literals([
494 "local-only",
495 "network-accessible",
496]);
497​
498export interface DesktopServerExposureState {
499 mode: DesktopServerExposureMode;
500 endpointUrl: string | null;
501 advertisedHost: string | null;
502 tailscaleServeEnabled: boolean;
503 tailscaleServePort: number;
505​
506export const DesktopServerExposureStateSchema = Schema.Struct({
507 mode: DesktopServerExposureModeSchema,
508 endpointUrl: Schema.NullOr(Schema.String),
509 advertisedHost: Schema.NullOr(Schema.String),
510 tailscaleServeEnabled: Schema.Boolean,
511 tailscaleServePort: Schema.Number,
512});
513​
514export interface PickFolderOptions {
515 initialPath?: string | null;
516 targetEnvironmentId?: string;
518​
519export const PickFolderOptionsSchema = Schema.Struct({
520 initialPath: Schema.optionalKey(Schema.NullOr(Schema.String)),
521 targetEnvironmentId: Schema.optionalKey(Schema.String),
522});
523​
524/** Oversized files have empty text so the main process never loads their contents. */
525export interface PickedThemeFile {
526 name: string;
527 size: number;
528 text: string;
530​
531export const PickedThemeFileSchema = Schema.Struct({
532 name: Schema.String,
533 size: Schema.Number,
534 text: Schema.String,
535});
536​
537export interface DesktopWslDistro {
538 name: string;
539 isDefault: boolean;
540 version: 1 | 2;
542​
543export const DesktopWslDistroSchema = Schema.Struct({
544 name: Schema.String,
545 isDefault: Schema.Boolean,
546 version: Schema.Literals([1, 2]),
547});
548​
549export interface DesktopWslState {
550 enabled: boolean;
551 // null means "track the current WSL default distro".
552 distro: string | null;
553 available: boolean;
554 wslOnly: boolean;
555 distros: readonly DesktopWslDistro[];
556 // Always null in wsl-only mode, which falls back to Windows with a dialog.
557 preflightError: string | null;
559​
560export const DesktopWslStateSchema = Schema.Struct({
561 enabled: Schema.Boolean,
562 distro: Schema.NullOr(Schema.String),
563 available: Schema.Boolean,
564 wslOnly: Schema.Boolean,
565 distros: Schema.Array(DesktopWslDistroSchema),
566 preflightError: Schema.NullOr(Schema.String),
567});
568​
569export type DesktopPreviewNavStatus =
570 | { kind: "Idle" }
571 | { kind: "Loading"; url: string; title: string }
572 | { kind: "Success"; url: string; title: string }
573 | {
574 kind: "LoadFailed";
575 url: string;
576 title: string;
577 code: number;
578 description: string;
579 };
580​
581export type DesktopPreviewColorScheme = "system" | "light" | "dark";
582​
583export const DesktopPreviewColorSchemeSchema: Schema.Codec<DesktopPreviewColorScheme> =
584 Schema.Literals(["system", "light", "dark"]);
585​
586export const FAVICON_DATA_URL_MAX_LENGTH = 8192;
587export const FAVICON_CAPTURED_AT_MAX = 8_640_000_000_000_000;
588​
589export interface DesktopPreviewFavicon {
590 dataUrl: string;
591 pageUrl: string;
592 capturedAt: number;
594​
595export interface DesktopPreviewTabState {
596 tabId: string;
597 webContentsId: number | null;
598 navStatus: DesktopPreviewNavStatus;
599 canGoBack: boolean;
600 canGoForward: boolean;
601 zoomFactor: number;
602 pictureInPicture: boolean;
603 colorScheme: DesktopPreviewColorScheme;
604 audioMuted: boolean;
605 /** Chromium reports playback even when audioMuted is true. */
606 audible: boolean;
607 controller: "human" | "agent" | "none";
608 /** A screenshot or stream of the guest is pending, so the client keeps it painting while hidden. */
609 capturing: boolean;
610 favicon?: DesktopPreviewFavicon;
611 updatedAt: string;
613​
614export const DesktopPreviewTabIdSchema = Schema.String.check(Schema.isTrimmed()).check(
615 Schema.isNonEmpty(),
616);
617​
618export interface DesktopPreviewPointerEvent {
619 tabId: string;
620 phase: "move" | "click";
621 x: number;
622 y: number;
623 sequence: number;
624 createdAt: string;
626​
627export interface DesktopPreviewOpenLinkEvent {
628 tabId: string;
629 url: string;
630 background: boolean;
632​
633export const DesktopPreviewRecordingInputSchema = Schema.Union([
634 Schema.Struct({
635 type: Schema.Literal("pointer"),
636 phase: Schema.Literals(["move", "down", "up", "click"]),
637 x: Schema.Finite,
638 y: Schema.Finite,
639 width: Schema.Finite.check(Schema.isGreaterThan(0)),
640 height: Schema.Finite.check(Schema.isGreaterThan(0)),
641 }),
642 Schema.Struct({
643 type: Schema.Literal("key"),
644 label: Schema.NullOr(Schema.String.check(Schema.isMaxLength(100))),
645 held: Schema.Boolean,
646 width: Schema.Finite.check(Schema.isGreaterThan(0)),
647 }),
648 Schema.Struct({ type: Schema.Literal("clear") }),
649]);
650export type DesktopPreviewRecordingInput = typeof DesktopPreviewRecordingInputSchema.Type;
651export interface DesktopPreviewRecordingInputEvent {
652 readonly tabId: string;
653 readonly input: DesktopPreviewRecordingInput;
655​
656export interface DesktopPreviewWebviewConfig {
657 partition: string;
658 /** Sandboxed with contextIsolation off so the picker preload can read the React DevTools hook. */
659 webPreferences: string;
660 /** Absolute file:// preload URL; null requires disabling element picking. */
661 preloadUrl: string | null;
663​
664export const DesktopPreviewWebviewConfigSchema: Schema.Codec<DesktopPreviewWebviewConfig> =
665 Schema.Struct({
666 partition: Schema.String,
667 webPreferences: Schema.String,
668 preloadUrl: Schema.NullOr(Schema.String),
669 });
670​
671export interface DesktopPreviewAnnotationTheme {
672 colorScheme: "light" | "dark";
673 radius: string;
674 background: string;
675 foreground: string;
676 popover: string;
677 popoverForeground: string;
678 primary: string;
679 primaryForeground: string;
680 muted: string;
681 mutedForeground: string;
682 accent: string;
683 accentForeground: string;
684 border: string;
685 input: string;
686 ring: string;
687 fontSans: string;
688 fontMono: string;
690​
691export const DesktopPreviewAnnotationThemeSchema: Schema.Codec<DesktopPreviewAnnotationTheme> =
692 Schema.Struct({
693 colorScheme: Schema.Literals(["light", "dark"]),
694 radius: Schema.String,
695 background: Schema.String,
696 foreground: Schema.String,
697 popover: Schema.String,
698 popoverForeground: Schema.String,
699 primary: Schema.String,
700 primaryForeground: Schema.String,
701 muted: Schema.String,
702 mutedForeground: Schema.String,
703 accent: Schema.String,
704 accentForeground: Schema.String,
705 border: Schema.String,
706 input: Schema.String,
707 ring: Schema.String,
708 fontSans: Schema.String,
709 fontMono: Schema.String,
710 });
711​
712export interface DesktopPreviewRecordingFrame {
713 tabId: string;
714 data: string;
715 width: number;
716 height: number;
717 receivedAt: string;
719​
720export interface DesktopPreviewRecordingArtifact {
721 id: string;
722 tabId: string;
723 path: string;
724 mimeType: string;
725 sizeBytes: number;
726 createdAt: string;
728​
729export const DesktopPreviewRecordingArtifactSchema: Schema.Codec<DesktopPreviewRecordingArtifact> =
730 Schema.Struct({
731 id: Schema.String,
732 tabId: DesktopPreviewTabIdSchema,
733 path: Schema.String,
734 mimeType: Schema.String,
735 sizeBytes: Schema.Int,
736 createdAt: Schema.String,
737 });
738​
739export interface DesktopPreviewScreenshotArtifact {
740 id: string;
741 tabId: string;
742 path: string;
743 mimeType: "image/png";
744 sizeBytes: number;
745 createdAt: string;
747​
748export const DesktopPreviewScreenshotArtifactSchema: Schema.Codec<DesktopPreviewScreenshotArtifact> =
749 Schema.Struct({
750 id: Schema.String,
751 tabId: DesktopPreviewTabIdSchema,
752 path: Schema.String,
753 mimeType: Schema.Literal("image/png"),
754 sizeBytes: Schema.Int,
755 createdAt: Schema.String,
756 });
757​
758export interface PickedElementStackFrame {
759 functionName: string | null;
760 fileName: string | null;
761 lineNumber: number | null;
762 columnNumber: number | null;
764​
765export const PickedElementStackFrameSchema: Schema.Codec<PickedElementStackFrame> = Schema.Struct({
766 functionName: Schema.NullOr(Schema.String),
767 fileName: Schema.NullOr(Schema.String),
768 lineNumber: Schema.NullOr(Schema.Number),
769 columnNumber: Schema.NullOr(Schema.Number),
770});
771​
772export interface PickedElementPayload {
773 pageUrl: string;
774 pageTitle: string | null;
775 tagName: string;
776 selector: string | null;
777 htmlPreview: string;
778 componentName: string | null;
779 source: PickedElementStackFrame | null;
780 stack: ReadonlyArray<PickedElementStackFrame>;
781 styles: string;
782 pickedAt: string;
784​
785export const PickedElementPayloadSchema: Schema.Codec<PickedElementPayload> = Schema.Struct({
786 pageUrl: Schema.String,
787 pageTitle: Schema.NullOr(Schema.String),
788 tagName: Schema.String,
789 selector: Schema.NullOr(Schema.String),
790 htmlPreview: Schema.String,
791 componentName: Schema.NullOr(Schema.String),
792 source: Schema.NullOr(PickedElementStackFrameSchema),
793 stack: Schema.Array(PickedElementStackFrameSchema),
794 styles: Schema.String,
795 pickedAt: Schema.String,
796});
797​
798export interface PreviewAnnotationRect {
799 x: number;
800 y: number;
801 width: number;
802 height: number;
804​
805export const PreviewAnnotationRectSchema: Schema.Codec<PreviewAnnotationRect> = Schema.Struct({
806 x: Schema.Number,
807 y: Schema.Number,
808 width: Schema.Number,
809 height: Schema.Number,
810});
811​
812export interface PreviewAnnotationPoint {
813 x: number;
814 y: number;
816​
817export const PreviewAnnotationPointSchema: Schema.Codec<PreviewAnnotationPoint> = Schema.Struct({
818 x: Schema.Number,
819 y: Schema.Number,
820});
821​
822export interface PreviewAnnotationElementTarget {
823 id: string;
824 element: PickedElementPayload;
825 rect: PreviewAnnotationRect;
827​
828export const PreviewAnnotationElementTargetSchema: Schema.Codec<PreviewAnnotationElementTarget> =
829 Schema.Struct({
830 id: Schema.String,
831 element: PickedElementPayloadSchema,
832 rect: PreviewAnnotationRectSchema,
833 });
834​
835export interface PreviewAnnotationRegionTarget {
836 id: string;
837 rect: PreviewAnnotationRect;
839​
840export const PreviewAnnotationRegionTargetSchema: Schema.Codec<PreviewAnnotationRegionTarget> =
841 Schema.Struct({
842 id: Schema.String,
843 rect: PreviewAnnotationRectSchema,
844 });
845​
846export interface PreviewAnnotationStrokeTarget {
847 id: string;
848 color: string;
849 width: number;
850 points: ReadonlyArray<PreviewAnnotationPoint>;
851 bounds: PreviewAnnotationRect;
853​
854export const PreviewAnnotationStrokeTargetSchema: Schema.Codec<PreviewAnnotationStrokeTarget> =
855 Schema.Struct({
856 id: Schema.String,
857 color: Schema.String,
858 width: Schema.Number,
859 points: Schema.Array(PreviewAnnotationPointSchema),
860 bounds: PreviewAnnotationRectSchema,
861 });
862​
863export interface PreviewAnnotationStyleChange {
864 targetId: string;
865 selector: string | null;
866 property: string;
867 previousValue: string;
868 value: string;
870​
871export const PreviewAnnotationStyleChangeSchema: Schema.Codec<PreviewAnnotationStyleChange> =
872 Schema.Struct({
873 targetId: Schema.String,
874 selector: Schema.NullOr(Schema.String),
875 property: Schema.String,
876 previousValue: Schema.String,
877 value: Schema.String,
878 });
879​
880export interface PreviewAnnotationScreenshot {
881 dataUrl: string;
882 width: number;
883 height: number;
884 cropRect: PreviewAnnotationRect;
886​
887export const PreviewAnnotationScreenshotSchema: Schema.Codec<PreviewAnnotationScreenshot> =
888 Schema.Struct({
889 dataUrl: Schema.String,
890 width: Schema.Number,
891 height: Schema.Number,
892 cropRect: PreviewAnnotationRectSchema,
893 });
894​
895export interface PreviewAnnotationPayload {
896 id: string;
897 pageUrl: string;
898 pageTitle: string | null;
899 comment: string;
900 elements: ReadonlyArray<PreviewAnnotationElementTarget>;
901 regions: ReadonlyArray<PreviewAnnotationRegionTarget>;
902 strokes: ReadonlyArray<PreviewAnnotationStrokeTarget>;
903 styleChanges: ReadonlyArray<PreviewAnnotationStyleChange>;
904 screenshot: PreviewAnnotationScreenshot | null;
905 createdAt: string;
907​
908export const PreviewAnnotationPayloadSchema: Schema.Codec<PreviewAnnotationPayload> = Schema.Struct(
909 {
910 id: Schema.String,
911 pageUrl: Schema.String,
912 pageTitle: Schema.NullOr(Schema.String),
913 comment: Schema.String,
914 elements: Schema.Array(PreviewAnnotationElementTargetSchema),
915 regions: Schema.Array(PreviewAnnotationRegionTargetSchema),
916 strokes: Schema.Array(PreviewAnnotationStrokeTargetSchema),
917 styleChanges: Schema.Array(PreviewAnnotationStyleChangeSchema),
918 screenshot: Schema.NullOr(PreviewAnnotationScreenshotSchema),
919 createdAt: Schema.String,
920 },
921);
922​
923export type PreviewAnnotationSubmission = "attach" | "send";
924export const PreviewAnnotationSubmissionSchema: Schema.Codec<PreviewAnnotationSubmission> =
925 Schema.Literals(["attach", "send"]);
926​
927export interface PreviewAnnotationSubmissionResult {
928 annotation: PreviewAnnotationPayload;
929 submission: PreviewAnnotationSubmission;
930 screenshotFailed?: boolean;
932export const PreviewAnnotationSubmissionResultSchema: Schema.Codec<PreviewAnnotationSubmissionResult> =
933 Schema.Struct({
934 annotation: PreviewAnnotationPayloadSchema,
935 submission: PreviewAnnotationSubmissionSchema,
936 screenshotFailed: Schema.optionalKey(Schema.Boolean),
937 });
938​
939export const DesktopPreviewTabInputSchema = Schema.Struct({
940 tabId: DesktopPreviewTabIdSchema,
941});
942​
943/** Apply zoom and color scheme at creation to avoid flashing browser defaults. */
944export const DesktopPreviewCreateTabInputSchema = Schema.Struct({
945 tabId: DesktopPreviewTabIdSchema,
946 zoomFactor: Schema.optional(Schema.Number.check(Schema.isGreaterThan(0))),
947 colorScheme: Schema.optional(DesktopPreviewColorSchemeSchema),
948 serverTab: Schema.optional(
949 Schema.Struct({ threadId: TrimmedNonEmptyString, tabId: TrimmedNonEmptyString }),
950 ),
951});
952​
953export interface DesktopPreviewTabDefaults {
954 readonly zoomFactor?: number | undefined;
955 readonly colorScheme?: DesktopPreviewColorScheme | undefined;
956 readonly serverTab?: { readonly threadId: string; readonly tabId: string } | undefined;
958​
959export const DesktopPreviewRegisterWebviewInputSchema = Schema.Struct({
960 tabId: DesktopPreviewTabIdSchema,
961 webContentsId: Schema.Int.check(Schema.isGreaterThan(0)),
962});
963​
964export const DesktopPreviewNavigateInputSchema = Schema.Struct({
965 tabId: DesktopPreviewTabIdSchema,
966 url: Schema.String,
967});
968​
969export const DesktopPreviewConfigInputSchema = Schema.Struct({
970 environmentId: EnvironmentId,
971 /** Main must derive the partition to ensure its session has UA rewrites and permission handlers. */
972 profileId: Schema.optional(BrowserProfileId),
973});
974​
975export const DesktopPreviewClearDataInputSchema = Schema.Struct({
976 environmentId: EnvironmentId,
977 /** Omit to clear every profile; otherwise only this profile's partition. */
978 profileId: Schema.optional(BrowserProfileId),
979});
980​
981export const DesktopPreviewSetColorSchemeInputSchema = Schema.Struct({
982 tabId: DesktopPreviewTabIdSchema,
983 colorScheme: DesktopPreviewColorSchemeSchema,
984});
985​
986export const DesktopPreviewSetZoomFactorInputSchema = Schema.Struct({
987 tabId: DesktopPreviewTabIdSchema,
988 zoomFactor: Schema.Number.check(Schema.isGreaterThan(0)),
989});
990​
991export const DesktopPreviewSetAudioMutedInputSchema = Schema.Struct({
992 tabId: DesktopPreviewTabIdSchema,
993 audioMuted: Schema.Boolean,
994});
995​
996export const DesktopPreviewAnnotationThemeInputSchema = Schema.Struct({
997 theme: DesktopPreviewAnnotationThemeSchema,
998});
999​
1000export const DesktopPreviewAnnotationSendEnabledInputSchema = Schema.Struct({
1001 tabId: DesktopPreviewTabIdSchema,
1002 enabled: Schema.Boolean,
1003});
1004​
1005export const DesktopPreviewArtifactInputSchema = Schema.Struct({
1006 path: Schema.String.check(Schema.isTrimmed()).check(Schema.isNonEmpty()),
1007});
1008​
1009export const DesktopPreviewRecordingSaveInputSchema = Schema.Struct({
1010 tabId: DesktopPreviewTabIdSchema,
1011 mimeType: Schema.String.check(Schema.isTrimmed()).check(Schema.isNonEmpty()),
1012 data: Schema.Uint8Array,
1013});
1014​
1015export const DesktopMediaReadSchema = Schema.Struct({
1016 status: Schema.Number,
1017 mimeType: Schema.String,
1018 data: Schema.Uint8Array,
1019});
1020export type DesktopMediaRead = typeof DesktopMediaReadSchema.Type;
1021​
1022export const SystemSettingsPaneSchema = Schema.Literals(["full-disk-access"]);
1023export type SystemSettingsPane = typeof SystemSettingsPaneSchema.Type;
1024​
1025export interface DesktopBridge {
1026 getAppBranding: () => DesktopAppBranding | null;
1027 getRelayTelemetryEnabled: () => boolean;
1028 getPathForFile: (file: File) => string;
1029 getClientPlatform: () => string;
1030 setNotificationBadge: (badge: { count: number; image: string | null }) => Promise<void>;
1031 onNotificationBadgeClear: (listener: () => void) => () => void;
1032 onTrackpadScrollBegin: (listener: () => void) => () => void;
1033 onTrackpadScrollEnd: (listener: () => void) => () => void;
1034 /**
1035 * Renderer `window.focus()` cannot raise an Electron window, and on Wayland
1036 * only the main process can spend a notification click's activation token.
1037 */
1038 revealWindow: () => Promise<void>;
1039 /**
1040 * The OS locale as a BCP-47 tag, which the renderer cannot read for itself:
1041 * the packaged app ships only the `en-US` Chromium locale pak, so
1042 * `navigator.language` and the default `Intl` locale are pinned to `en-US`
1043 * regardless of OS settings.
1044 */
1045 getSystemLocale: () => string | null;
1046 getLocalEnvironmentBootstraps: () => readonly DesktopEnvironmentBootstrap[];
1047 getLocalEnvironmentEnabled: () => boolean;
1048 setLocalEnvironmentEnabled: (enabled: boolean) => Promise<void>;
1049 getLocalEnvironmentBearerToken: () => Promise<string>;
1050 getClientSettings: () => Promise<ClientSettings | null>;
1051 setClientSettings: (settings: ClientSettings) => Promise<void>;
1052 getConnectionCatalog: () => Promise<string | null>;
1053 setConnectionCatalog: (catalog: string) => Promise<boolean>;
1054 discoverSshHosts: () => Promise<readonly DesktopDiscoveredSshHost[]>;
1055 resolveSshHost: (alias: string) => Promise<DesktopSshEnvironmentTarget>;
1056 requestSnapShotPermissions: (includeAccessibility: boolean) => Promise<void>;
1057 getSnapShotState: () => Promise<DesktopSnapShotState>;
1058 setupSnapShot: (action: DesktopSnapShotSetupAction) => Promise<void>;
1059 previewSnapShotConfig: (
1060 request: DesktopCaptureConfigRequest,
1061 ) => Promise<DesktopCaptureConfigPreview | null>;
1062 applySnapShotConfig: (previewId: string) => Promise<DesktopCaptureConfigApplied>;
1063 checkSnapShotShortcut: (
1064 shortcut: SnapShotShortcut,
1065 ) => Promise<DesktopSnapShotShortcutAvailability>;
1066 setSnapShotShortcutSuppressed: (suppressed: boolean) => Promise<void>;
1067 listPendingSnapShots: () => Promise<readonly DesktopPendingSnapShot[]>;
1068 readSnapShot: (id: string) => Promise<DesktopSnapShot>;
1069 setSnapShotAnimationDestination: (
1070 destination: DesktopSnapShotAnimationDestination,
1071 ) => Promise<void>;
1072 dismissSnapShotAnimation: (id: DesktopSnapShotId) => Promise<void>;
1073 acknowledgeSnapShot: (id: string) => Promise<void>;
1074 ensureSshEnvironment: (
1075 target: DesktopSshEnvironmentTarget,
1076 options?: { issuePairingToken?: boolean },
1077 ) => Promise<DesktopSshEnvironmentBootstrap>;
1078 disconnectSshEnvironment: (target: DesktopSshEnvironmentTarget) => Promise<void>;
1079 fetchSshEnvironmentDescriptor: (httpBaseUrl: string) => Promise<ExecutionEnvironmentDescriptor>;
1080 bootstrapSshBearerSession: (
1081 httpBaseUrl: string,
1082 credential: string,
1083 ) => Promise<AuthAccessTokenResult>;
1084 fetchSshSessionState: (httpBaseUrl: string, bearerToken: string) => Promise<AuthSessionState>;
1085 onSshPasswordPrompt: (listener: (request: DesktopSshPasswordPromptRequest) => void) => () => void;
1086 resolveSshPasswordPrompt: (requestId: string, password: string | null) => Promise<void>;
1087 getServerExposureState: () => Promise<DesktopServerExposureState>;
1088 setServerExposureMode: (mode: DesktopServerExposureMode) => Promise<DesktopServerExposureState>;
1089 setTailscaleServeEnabled: (input: {
1090 readonly enabled: boolean;
1091 readonly port?: number;
1092 }) => Promise<DesktopServerExposureState>;
1093 getAdvertisedEndpoints: () => Promise<readonly AdvertisedEndpoint[]>;
1094 getWslState: () => Promise<DesktopWslState>;
1095 setWslBackendEnabled: (enabled: boolean) => Promise<DesktopWslState>;
1096 setWslDistro: (distro: string | null) => Promise<DesktopWslState>;
1097 setWslOnly: (enabled: boolean) => Promise<DesktopWslState>;
1098 pickFolder: (options?: PickFolderOptions) => Promise<string | null>;
1099 pickProjectFavicon: (initialPath?: string) => Promise<string | null>;
1100 pickThemeFiles: () => Promise<readonly PickedThemeFile[] | null>;
1101 setTheme: (theme: DesktopTheme) => Promise<void>;
1102 showContextMenu: <T extends string>(
1103 items: readonly ContextMenuItem<T>[],
1104 position?: { x: number; y: number },
1105 ) => Promise<T | null>;
1106 receiveProviderAuthCallback: (authorizationUrl: string) => Promise<string>;
1107 cancelProviderAuthCallback: (authorizationUrl: string) => Promise<void>;
1108 openExternal: (url: string) => Promise<boolean>;
1109 /** Reads http(s) media in the main process, outside renderer CORS and CSP; null on network failure. */
1110 readMedia: (url: string) => Promise<DesktopMediaRead | null>;
1111 openSystemSettings: (pane: SystemSettingsPane) => Promise<boolean>;
1112 checkSystemPermission: (pane: SystemSettingsPane) => Promise<boolean>;
1113 probeRemoteEditors: () => Promise<readonly EditorId[]>;
1114 pasteAsText: () => Promise<void>;
1115 onMenuAction: (listener: (action: string) => void) => () => void;
1116 onSnapShotEvent: (listener: (event: DesktopSnapShotEvent) => void) => () => void;
1117 onQuitShortcut: (listener: (event: QuitShortcutHintEvent) => void) => () => void;
1118 getWindowFullscreenState: () => boolean;
1119 onWindowFullscreenStateChange: (listener: (fullscreen: boolean) => void) => () => void;
1120 getWindowZoomFactor: () => number;
1121 getUpdateState: () => Promise<DesktopUpdateState>;
1122 /** `minimumVersion` is a track switch's checked release; nothing older is offered after. */
1123 setUpdateChannel: (
1124 channel: DesktopUpdateChannel,
1125 minimumVersion?: string,
1126 ) => Promise<DesktopUpdateState>;
1127 checkForUpdate: () => Promise<DesktopUpdateCheckResult>;
1128 downloadUpdate: () => Promise<DesktopUpdateActionResult>;
1129 /** With a version, installs only that downloaded build. */
1130 installUpdate: (expectedVersion?: string) => Promise<DesktopUpdateActionResult>;
1131 onUpdateState: (listener: (state: DesktopUpdateState) => void) => () => void;
1132 cliCommand: {
1133 getState: () => Promise<DesktopCliCommandState>;
1134 install: () => Promise<DesktopCliCommandState>;
1135 uninstall: () => Promise<DesktopCliCommandState>;
1136 };
1137 webLinks: {
1138 setReady: (ready: boolean) => Promise<void>;
1139 onOpen: (listener: (url: string) => void) => () => void;
1140 };
1141 appActivation: {
1142 setReady: (ready: boolean) => Promise<void>;
1143 complete: (response: DesktopAppActivationResponse) => Promise<void>;
1144 onRequest: (listener: (request: DesktopAppActivationRequest) => void) => () => void;
1145 };
1146 preview: DesktopPreviewBridge;
1148​
1149/** Renderer callback invoked by Electron with a fresh user gesture before display-media capture. */
1150export const DESKTOP_PREVIEW_RECORDING_CAPTURE_TRIGGER = "__t3DesktopPreviewRecordingCapture";
1151​
1152export interface DesktopPreviewBridge {
1153 setForwardedShortcuts: (shortcuts: ReadonlyArray<PreviewForwardedShortcut>) => Promise<void>;
1154 createTab: (tabId: string, defaults?: DesktopPreviewTabDefaults) => Promise<void>;
1155 closeTab: (tabId: string) => Promise<void>;
1156 registerWebview: (tabId: string, webContentsId: number) => Promise<void>;
1157 navigate: (tabId: string, url: string) => Promise<void>;
1158 goBack: (tabId: string) => Promise<void>;
1159 goForward: (tabId: string) => Promise<void>;
1160 refresh: (tabId: string) => Promise<void>;
1161 zoomIn: (tabId: string) => Promise<void>;
1162 zoomOut: (tabId: string) => Promise<void>;
1163 resetZoom: (tabId: string) => Promise<void>;
1164 setZoomFactor: (tabId: string, zoomFactor: number) => Promise<void>;
1165 hardReload: (tabId: string) => Promise<void>;
1166 setColorScheme: (tabId: string, colorScheme: DesktopPreviewColorScheme) => Promise<void>;
1167 setAudioMuted: (tabId: string, audioMuted: boolean) => Promise<void>;
1168 openDevTools: (tabId: string) => Promise<void>;
1169 clearCookies: (environmentId: EnvironmentId, profileId?: string) => Promise<void>;
1170 clearCache: (environmentId: EnvironmentId, profileId?: string) => Promise<void>;
1171 getPreviewConfig: (
1172 environmentId: EnvironmentId,
1173 profileId?: string,
1174 ) => Promise<DesktopPreviewWebviewConfig>;
1175 listBrowserImportSources: () => Promise<ReadonlyArray<BrowserImportSource>>;
1176 importBrowserCookies: (input: {
1177 readonly environmentId: EnvironmentId;
1178 readonly sourceId: BrowserImportSourceId;
1179 readonly sourceProfileDirectory: string;
1180 readonly targetProfileId: string;
1181 }) => Promise<BrowserImportResult>;
1182 setAnnotationTheme: (theme: DesktopPreviewAnnotationTheme) => Promise<void>;
1183 setAnnotationSendEnabled: (tabId: string, enabled: boolean) => Promise<void>;
1184 /** Resolves with the annotation and attach/send intent, or null on cancellation. Rejects if activation fails. */
1185 pickElement: (tabId: string) => Promise<PreviewAnnotationSubmissionResult | null>;
1186 cancelPickElement: (tabId: string) => Promise<void>;
1187 captureScreenshot: (
1188 tabId: string,
1189 ) => Promise<DesktopPreviewScreenshotArtifact | PreviewCaptureFailureEncoded>;
1190 revealArtifact: (path: string) => Promise<void>;
1191 copyArtifactToClipboard: (path: string) => Promise<void>;
1192 pictureInPicture: {
1193 open: (tabId: string) => Promise<void>;
1194 close: (tabId: string) => Promise<void>;
1195 };
1196 recording: {
1197 onInput: (listener: (event: DesktopPreviewRecordingInputEvent) => void) => () => void;
1198 startScreencast: (tabId: string) => Promise<void | PreviewCaptureFailureEncoded>;
1199 stopScreencast: (tabId: string) => Promise<void>;
1200 save: (
1201 tabId: string,
1202 mimeType: string,
1203 data: Uint8Array,
1204 ) => Promise<DesktopPreviewRecordingArtifact>;
1205 };
1206 onStateChange: (listener: (tabId: string, state: DesktopPreviewTabState) => void) => () => void;
1207 onPointerEvent: (listener: (event: DesktopPreviewPointerEvent) => void) => () => void;
1208 onOpenLink: (listener: (event: DesktopPreviewOpenLinkEvent) => void) => () => void;
1210​
1211export type ConfirmDialogVariant = "default" | "destructive";
1212​
1213export interface ConfirmDialogOptions {
1214 readonly variant?: ConfirmDialogVariant;
1216​
1217export interface LocalApi {
1218 dialogs: {
1219 pickFolder: (options?: PickFolderOptions) => Promise<string | null>;
1220 confirm: (message: string, options?: ConfirmDialogOptions) => Promise<boolean>;
1221 };
1222 shell: {
1223 openExternal: (url: string) => Promise<void>;
1224 openSystemSettings: (pane: SystemSettingsPane) => Promise<void>;
1225 };
1226 contextMenu: {
1227 show: <T extends string>(
1228 items: readonly ContextMenuItem<T>[],
1229 position?: { x: number; y: number },
1230 ) => Promise<T | null>;
1231 close: () => Promise<void>;
1232 };
1233 persistence: {
1234 getClientSettings: () => Promise<ClientSettings | null>;
1235 setClientSettings: (settings: ClientSettings) => Promise<void>;
1236 };