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

ipc.ts

1,456 lines51.5 KB

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