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

ipc.ts

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