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