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

ipc.ts

1,454 lines51.4 KB

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