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

ipc.ts

1,360 lines46.7 KB

1import * as Schema from "effect/Schema";
2import type { PreviewCaptureFailureEncoded } from "./previewCapture.ts";
3​
4import { SnapShotSource } from "./chatAttachment.ts";
5import { EnvironmentId, TrimmedNonEmptyString } from "./baseSchemas.ts";
6import { BrowserProfileId } from "./browserProfile.ts";
7import type {
8 BrowserImportResult,
9 BrowserImportSource,
10 BrowserImportSourceId,
11} from "./browserImport.ts";
12import { AuthAccessTokenResult, AuthSessionState } from "./auth.ts";
13import { AdvertisedEndpoint } from "./remoteAccess.ts";
14import { ExecutionEnvironmentDescriptor } from "./environment.ts";
15import { type ClientSettings, type QuitConfirmationMode, SnapShotShortcut } from "./settings.ts";
16import type { EditorId } from "./editor.ts";
17import { 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>[];
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[];
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;
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;
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;
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;
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;
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;
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;
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;
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";
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;
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;
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;
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;
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;
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;
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;
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;
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;
631​
632export interface DesktopPreviewOpenLinkEvent {
633 tabId: string;
634 url: string;
635 background: boolean;
637​
638export interface DesktopPreviewFindResultEvent {
639 tabId: string;
640 activeMatchOrdinal: number;
641 matches: number;
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;
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;
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;
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;
730​
731export interface DesktopPreviewRecordingArtifact {
732 id: string;
733 tabId: string;
734 path: string;
735 mimeType: string;
736 sizeBytes: number;
737 createdAt: string;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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 getLocalEnvironmentBootstraps: () => readonly DesktopEnvironmentBootstrap[];
1072 getLocalEnvironmentEnabled: () => boolean;
1073 setLocalEnvironmentEnabled: (enabled: boolean) => Promise<void>;
1074 /** The environment ID recorded in this app's T3 home, such as its own machine's background service. */
1075 getHostEnvironmentId?: () => Promise<string | null>;
1076 getLocalEnvironmentBearerToken: () => Promise<string>;
1077 getClientSettings: () => Promise<ClientSettings | null>;
1078 setClientSettings: (settings: ClientSettings) => Promise<void>;
1079 getConnectionCatalog: () => Promise<string | null>;
1080 setConnectionCatalog: (catalog: string) => Promise<boolean>;
1081 discoverSshHosts: () => Promise<readonly DesktopDiscoveredSshHost[]>;
1082 resolveSshHost: (alias: string) => Promise<DesktopSshEnvironmentTarget>;
1083 requestSnapShotPermissions: (includeAccessibility: boolean) => Promise<void>;
1084 getSnapShotState: () => Promise<DesktopSnapShotState>;
1085 setupSnapShot: (action: DesktopSnapShotSetupAction) => Promise<void>;
1086 previewSnapShotConfig: (
1087 request: DesktopCaptureConfigRequest,
1088 ) => Promise<DesktopCaptureConfigPreview | null>;
1089 applySnapShotConfig: (previewId: string) => Promise<DesktopCaptureConfigApplied>;
1090 checkSnapShotShortcut: (
1091 shortcut: SnapShotShortcut,
1092 ) => Promise<DesktopSnapShotShortcutAvailability>;
1093 setSnapShotShortcutSuppressed: (suppressed: boolean) => Promise<void>;
1094 listPendingSnapShots: () => Promise<readonly DesktopPendingSnapShot[]>;
1095 readSnapShot: (id: string) => Promise<DesktopSnapShot>;
1096 setSnapShotAnimationDestination: (
1097 destination: DesktopSnapShotAnimationDestination,
1098 ) => Promise<void>;
1099 dismissSnapShotAnimation: (id: DesktopSnapShotId) => Promise<void>;
1100 acknowledgeSnapShot: (id: string) => Promise<void>;
1101 ensureSshEnvironment: (
1102 target: DesktopSshEnvironmentTarget,
1103 options?: { issuePairingToken?: boolean },
1104 ) => Promise<DesktopSshEnvironmentBootstrap>;
1105 disconnectSshEnvironment: (target: DesktopSshEnvironmentTarget) => Promise<void>;
1106 fetchSshEnvironmentDescriptor: (httpBaseUrl: string) => Promise<ExecutionEnvironmentDescriptor>;
1107 bootstrapSshBearerSession: (
1108 httpBaseUrl: string,
1109 credential: string,
1110 ) => Promise<AuthAccessTokenResult>;
1111 fetchSshSessionState: (httpBaseUrl: string, bearerToken: string) => Promise<AuthSessionState>;
1112 onSshPasswordPrompt: (listener: (request: DesktopSshPasswordPromptRequest) => void) => () => void;
1113 /** Fires with a prompt's request id once it is answered, cancelled, expired or abandoned. */
1114 onSshPasswordPromptSettled: (listener: (requestId: string) => void) => () => void;
1115 resolveSshPasswordPrompt: (requestId: string, password: string | null) => Promise<void>;
1116 getServerExposureState: () => Promise<DesktopServerExposureState>;
1117 setServerExposureMode: (mode: DesktopServerExposureMode) => Promise<DesktopServerExposureState>;
1118 setTailscaleServeEnabled: (input: {
1119 readonly enabled: boolean;
1120 readonly port?: number;
1121 }) => Promise<DesktopServerExposureState>;
1122 getAdvertisedEndpoints: () => Promise<readonly AdvertisedEndpoint[]>;
1123 getWslState: () => Promise<DesktopWslState>;
1124 setWslBackendEnabled: (enabled: boolean) => Promise<DesktopWslState>;
1125 setWslDistro: (distro: string | null) => Promise<DesktopWslState>;
1126 setWslOnly: (enabled: boolean) => Promise<DesktopWslState>;
1127 pickFolder: (options?: PickFolderOptions) => Promise<string | null>;
1128 pickProjectFavicon: (initialPath?: string) => Promise<string | null>;
1129 pickThemeFiles: () => Promise<readonly PickedThemeFile[] | null>;
1130 setTheme: (theme: DesktopTheme) => Promise<void>;
1131 showContextMenu: <T extends string>(
1132 items: readonly ContextMenuItem<T>[],
1133 position?: { x: number; y: number },
1134 ) => Promise<T | null>;
1135 receiveProviderAuthCallback: (authorizationUrl: string) => Promise<string>;
1136 cancelProviderAuthCallback: (authorizationUrl: string) => Promise<void>;
1137 openExternal: (url: string) => Promise<boolean>;
1138 /** Reads http(s) media in the main process, outside renderer CORS and CSP; null on network failure. */
1139 readMedia: (url: string) => Promise<DesktopMediaRead | null>;
1140 openSystemSettings: (pane: SystemSettingsPane) => Promise<boolean>;
1141 checkSystemPermission: (pane: SystemSettingsPane) => Promise<boolean>;
1142 probeRemoteEditors: () => Promise<readonly EditorId[]>;
1143 pasteAsText: () => Promise<void>;
1144 onMenuAction: (listener: (action: string) => void) => () => void;
1145 onSnapShotEvent: (listener: (event: DesktopSnapShotEvent) => void) => () => void;
1146 onQuitShortcut: (listener: (event: QuitShortcutHintEvent) => void) => () => void;
1147 getWindowFullscreenState: () => boolean;
1148 onWindowFullscreenStateChange: (listener: (fullscreen: boolean) => void) => () => void;
1149 getWindowZoomFactor: () => number;
1150 getUpdateState: () => Promise<DesktopUpdateState>;
1151 /** `minimumVersion` is a track switch's checked release; nothing older is offered after. */
1152 setUpdateChannel: (
1153 channel: DesktopUpdateChannel,
1154 minimumVersion?: string,
1155 ) => Promise<DesktopUpdateState>;
1156 checkForUpdate: () => Promise<DesktopUpdateCheckResult>;
1157 downloadUpdate: () => Promise<DesktopUpdateActionResult>;
1158 /** With a version, installs only that downloaded build. */
1159 installUpdate: (expectedVersion?: string) => Promise<DesktopUpdateActionResult>;
1160 onUpdateState: (listener: (state: DesktopUpdateState) => void) => () => void;
1161 cliCommand: {
1162 getState: () => Promise<DesktopCliCommandState>;
1163 install: () => Promise<DesktopCliCommandState>;
1164 uninstall: () => Promise<DesktopCliCommandState>;
1165 addToPath: () => Promise<DesktopCliCommandState>;
1166 };
1167 webLinks: {
1168 setReady: (ready: boolean) => Promise<void>;
1169 onOpen: (listener: (url: string) => void) => () => void;
1170 };
1171 appActivation: {
1172 setReady: (ready: boolean) => Promise<void>;
1173 complete: (response: DesktopAppActivationResponse) => Promise<void>;
1174 onRequest: (listener: (request: DesktopAppActivationRequest) => void) => () => void;
1175 };
1176 preview: DesktopPreviewBridge;
1178​
1179/** Renderer callback invoked by Electron with a fresh user gesture before display-media capture. */
1180export const DESKTOP_PREVIEW_RECORDING_CAPTURE_TRIGGER = "__t3DesktopPreviewRecordingCapture";
1181​
1182/**
1183 * Dictation for the annotation editor drawn inside a preview guest. The guest only shows
1184 * controls and forwards trusted user gestures; the renderer records, with its consent
1185 * checks, and publishes state back. `shortcuts` are the dictation chords in effect.
1186 */
1187export const DesktopPreviewAnnotationVoiceConfigSchema = Schema.Struct({
1188 sessionId: Schema.String.check(Schema.isMaxLength(64)),
1189 shortcuts: Schema.Array(KeybindingShortcut).check(Schema.isMaxLength(16)),
1190});
1191export type DesktopPreviewAnnotationVoiceConfig =
1192 typeof DesktopPreviewAnnotationVoiceConfigSchema.Type;
1193​
1194export const DesktopPreviewAnnotationVoiceEventSchema = Schema.Struct({
1195 sessionId: Schema.String.check(Schema.isMaxLength(64)),
1196 text: Schema.String.check(Schema.isMaxLength(100_000)),
1197 cursor: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),
1198 selectionEnd: Schema.optional(Schema.Int.check(Schema.isGreaterThanOrEqualTo(0))),
1199 action: Schema.Literals([
1200 "sync",
1201 "start",
1202 "stop",
1203 "cancel",
1204 "skip",
1205 "settings",
1206 "key",
1207 "focus",
1208 "blur",
1209 ]),
1210 keyboard: Schema.optional(
1211 Schema.Struct({
1212 type: Schema.Literals(["keydown", "keyup"]),
1213 key: Schema.String.check(Schema.isMaxLength(32)),
1214 code: Schema.String.check(Schema.isMaxLength(64)),
1215 metaKey: Schema.Boolean,
1216 ctrlKey: Schema.Boolean,
1217 shiftKey: Schema.Boolean,
1218 altKey: Schema.Boolean,
1219 repeat: Schema.Boolean,
1220 }),
1221 ),
1222});
1223export type DesktopPreviewAnnotationVoiceEvent =
1224 typeof DesktopPreviewAnnotationVoiceEventSchema.Type;
1225​
1226export const DesktopPreviewAnnotationVoiceStateSchema = Schema.Struct({
1227 tabId: DesktopPreviewTabIdSchema,
1228 sessionId: Schema.String.check(Schema.isMaxLength(64)),
1229 available: Schema.Boolean,
1230 phase: Schema.Literals([
1231 "idle",
1232 "preparing",
1233 "recording",
1234 "transcribing",
1235 "post-processing",
1236 "error",
1237 ]),
1238 status: Schema.NullOr(Schema.String),
1239 errorAction: Schema.NullOr(Schema.Literals(["retry", "settings"])),
1240 preview: Schema.NullOr(Schema.String),
1241 level: Schema.Number,
1242 shortcutLabel: Schema.NullOr(Schema.String),
1243 freezesEditor: Schema.Boolean,
1244 blocksSubmission: Schema.Boolean,
1245 draft: Schema.NullOr(Schema.Struct({ text: Schema.String, cursor: Schema.Int })),
1246});
1247export type DesktopPreviewAnnotationVoiceState =
1248 typeof DesktopPreviewAnnotationVoiceStateSchema.Type;
1249​
1250export const DesktopPreviewPickElementInputSchema = Schema.Struct({
1251 tabId: DesktopPreviewTabIdSchema,
1252 voice: Schema.optional(DesktopPreviewAnnotationVoiceConfigSchema),
1253});
1254​
1255export interface DesktopPreviewBridge {
1256 setForwardedShortcuts: (shortcuts: ReadonlyArray<PreviewForwardedShortcut>) => Promise<void>;
1257 createTab: (tabId: string, defaults?: DesktopPreviewTabDefaults) => Promise<void>;
1258 closeTab: (tabId: string) => Promise<void>;
1259 registerWebview: (tabId: string, webContentsId: number) => Promise<void>;
1260 navigate: (tabId: string, url: string) => Promise<void>;
1261 goBack: (tabId: string) => Promise<void>;
1262 goForward: (tabId: string) => Promise<void>;
1263 refresh: (tabId: string) => Promise<void>;
1264 zoomIn: (tabId: string) => Promise<void>;
1265 zoomOut: (tabId: string) => Promise<void>;
1266 resetZoom: (tabId: string) => Promise<void>;
1267 setZoomFactor: (tabId: string, zoomFactor: number) => Promise<void>;
1268 hardReload: (tabId: string) => Promise<void>;
1269 setColorScheme: (tabId: string, colorScheme: DesktopPreviewColorScheme) => Promise<void>;
1270 setAudioMuted: (tabId: string, audioMuted: boolean) => Promise<void>;
1271 findInPage: (
1272 tabId: string,
1273 text: string,
1274 options: { forward: boolean; newSession: boolean },
1275 ) => Promise<void>;
1276 stopFindInPage: (tabId: string) => Promise<void>;
1277 /** Tells the tab's server whether its webview is on screen. */
1278 setShown: (tabId: string, shown: boolean) => Promise<void>;
1279 openDevTools: (tabId: string) => Promise<void>;
1280 clearCookies: (environmentId: EnvironmentId, profileId?: string) => Promise<void>;
1281 clearCache: (environmentId: EnvironmentId, profileId?: string) => Promise<void>;
1282 getPreviewConfig: (
1283 environmentId: EnvironmentId,
1284 profileId?: string,
1285 ) => Promise<DesktopPreviewWebviewConfig>;
1286 listBrowserImportSources: () => Promise<ReadonlyArray<BrowserImportSource>>;
1287 importBrowserCookies: (input: {
1288 readonly environmentId: EnvironmentId;
1289 readonly sourceId: BrowserImportSourceId;
1290 readonly sourceProfileDirectory: string;
1291 readonly targetProfileId: string;
1292 }) => Promise<BrowserImportResult>;
1293 setAnnotationTheme: (theme: DesktopPreviewAnnotationTheme) => Promise<void>;
1294 setAnnotationSendEnabled: (tabId: string, enabled: boolean) => Promise<void>;
1295 annotationVoice: {
1296 onEvent: (
1297 listener: (tabId: string, event: DesktopPreviewAnnotationVoiceEvent) => void,
1298 ) => () => void;
1299 update: (state: DesktopPreviewAnnotationVoiceState) => Promise<void>;
1300 };
1301 /** Resolves with the annotation and attach/send intent, or null on cancellation. Rejects if activation fails. */
1302 pickElement: (
1303 tabId: string,
1304 voice?: DesktopPreviewAnnotationVoiceConfig,
1305 ) => Promise<PreviewAnnotationSubmissionResult | null>;
1306 cancelPickElement: (tabId: string) => Promise<void>;
1307 captureScreenshot: (
1308 tabId: string,
1309 ) => Promise<DesktopPreviewScreenshotArtifact | PreviewCaptureFailureEncoded>;
1310 revealArtifact: (path: string) => Promise<void>;
1311 copyArtifactToClipboard: (path: string) => Promise<void>;
1312 pictureInPicture: {
1313 open: (tabId: string) => Promise<void>;
1314 close: (tabId: string) => Promise<void>;
1315 };
1316 recording: {
1317 onInput: (listener: (event: DesktopPreviewRecordingInputEvent) => void) => () => void;
1318 startScreencast: (tabId: string) => Promise<void | PreviewCaptureFailureEncoded>;
1319 stopScreencast: (tabId: string) => Promise<void>;
1320 save: (
1321 tabId: string,
1322 mimeType: string,
1323 data: Uint8Array,
1324 ) => Promise<DesktopPreviewRecordingArtifact>;
1325 };
1326 onStateChange: (listener: (tabId: string, state: DesktopPreviewTabState) => void) => () => void;
1327 onPointerEvent: (listener: (event: DesktopPreviewPointerEvent) => void) => () => void;
1328 onOpenLink: (listener: (event: DesktopPreviewOpenLinkEvent) => void) => () => void;
1329 onFindResult: (listener: (event: DesktopPreviewFindResultEvent) => void) => () => void;
1331​
1332export type ConfirmDialogVariant = "default" | "destructive";
1333​
1334export interface ConfirmDialogOptions {
1335 readonly variant?: ConfirmDialogVariant;
1336 /** Which button takes focus on open. Defaults to Cancel; destructive confirms always keep Cancel. */
1337 readonly initialFocus?: "confirm" | "cancel";
1339​
1340export interface LocalApi {
1341 dialogs: {
1342 pickFolder: (options?: PickFolderOptions) => Promise<string | null>;
1343 confirm: (message: string, options?: ConfirmDialogOptions) => Promise<boolean>;
1344 };
1345 shell: {
1346 openExternal: (url: string) => Promise<void>;
1347 openSystemSettings: (pane: SystemSettingsPane) => Promise<void>;
1348 };
1349 contextMenu: {
1350 show: <T extends string>(
1351 items: readonly ContextMenuItem<T>[],
1352 position?: { x: number; y: number },
1353 ) => Promise<T | null>;
1354 close: () => Promise<void>;
1355 };
1356 persistence: {
1357 getClientSettings: () => Promise<ClientSettings | null>;
1358 setClientSettings: (settings: ClientSettings) => Promise<void>;
1359 };