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

ipc.ts

1,372 lines47.4 KB

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