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

ipc.ts

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