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

ipc.ts

1,402 lines48.8 KB

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