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

ipc.ts

1,254 lines42.3 KB

1import type {
2 VcsCreateRefInput,
3 VcsCreateRefResult,
4 VcsCreateWorktreeInput,
5 VcsCreateWorktreeResult,
6 VcsInitInput,
7 VcsListRefsInput,
8 VcsListRefsResult,
9 VcsPullInput,
10 VcsPullResult,
11 VcsRemoveWorktreeInput,
12 VcsSwitchRefInput,
13 VcsSwitchRefResult,
14 GitPreparePullRequestThreadInput,
15 GitPreparePullRequestThreadResult,
16 GitPullRequestRefInput,
17 GitResolvePullRequestResult,
18 VcsStatusInput,
19 VcsStatusResult,
20} from "./git.ts";
21import type { ReviewDiffPreviewInput, ReviewDiffPreviewResult } from "./review.ts";
22import type { FilesystemBrowseInput, FilesystemBrowseResult } from "./filesystem.ts";
23import type { AssetCreateUrlInput, AssetCreateUrlResult } from "./assets.ts";
24import type {
25 ProjectListEntriesInput,
26 ProjectListEntriesResult,
27 ProjectReadFileInput,
28 ProjectReadFileResult,
29 ProjectSearchEntriesInput,
30 ProjectSearchEntriesResult,
31 ProjectWriteFileInput,
32 ProjectWriteFileResult,
33} from "./project.ts";
34import type {
35 TerminalAttachInput,
36 TerminalAttachStreamEvent,
37 TerminalClearInput,
38 TerminalCloseInput,
39 TerminalMetadataStreamEvent,
40 TerminalOpenInput,
41 TerminalResizeInput,
42 TerminalRestartInput,
43 TerminalSessionSnapshot,
44 TerminalWriteInput,
45} from "./terminal.ts";
46import * as Schema from "effect/Schema";
47import type {
48 DiscoveredLocalServerList,
49 PreviewCloseInput,
50 PreviewEvent,
51 PreviewListInput,
52 PreviewListResult,
53 PreviewNavigateInput,
54 PreviewOpenInput,
55 PreviewRefreshInput,
56 PreviewReportStatusInput,
57 PreviewResizeInput,
58 PreviewSessionSnapshot,
59} from "./preview.ts";
60import {
61 PreviewAutomationClickInput,
62 PreviewAutomationEvaluateInput,
63 PreviewAutomationHost,
64 PreviewAutomationHostFocus,
65 PreviewAutomationPressInput,
66 PreviewAutomationResponse,
67 PreviewAutomationScrollInput,
68 PreviewAutomationSnapshot,
69 PreviewAutomationStatus,
70 PreviewAutomationStreamEvent,
71 PreviewAutomationTypeInput,
72 PreviewAutomationWaitForInput,
73} from "./previewAutomation.ts";
74import type {
75 OrchestrationV2Command,
76 OrchestrationV2DispatchCommandResult,
77 OrchestrationV2GetThreadProjectionInput,
78 OrchestrationV2ShellStreamItem,
79 OrchestrationV2ThreadProjection,
80 OrchestrationV2ThreadStreamItem,
81} from "./orchestrationV2.ts";
82import { EnvironmentId } from "./baseSchemas.ts";
83import { AuthAccessTokenResult, AuthSessionState, AuthWebSocketTicketResult } from "./auth.ts";
84import { AdvertisedEndpoint } from "./remoteAccess.ts";
85import { ExecutionEnvironmentDescriptor } from "./environment.ts";
86import type { ClientSettings } from "./settings.ts";
87import type {
88 SourceControlCloneRepositoryInput,
89 SourceControlCloneRepositoryResult,
90 SourceControlPublishRepositoryInput,
91 SourceControlPublishRepositoryResult,
92 SourceControlRepositoryInfo,
93 SourceControlRepositoryLookupInput,
94} from "./sourceControl.ts";
95​
96export interface ContextMenuItem<T extends string = string> {
97 id: T;
98 label: string;
99 destructive?: boolean;
100 disabled?: boolean;
101 /** Renders as a non-interactive section header label. Web fallback only — stripped on desktop native menus. */
102 header?: boolean;
103 /** Icon keyword resolved by the web fallback. Stripped on desktop native menus. */
104 icon?: string;
105 children?: readonly ContextMenuItem<T>[];
107​
108export interface ContextMenuItemSchemaType {
109 readonly id: string;
110 readonly label: string;
111 readonly destructive?: boolean;
112 readonly disabled?: boolean;
113 readonly header?: boolean;
114 readonly icon?: string;
115 readonly children?: readonly ContextMenuItemSchemaType[];
117​
118export const ContextMenuItemSchema: Schema.Codec<ContextMenuItemSchemaType> = Schema.Struct({
119 id: Schema.String,
120 label: Schema.String,
121 destructive: Schema.optionalKey(Schema.Boolean),
122 disabled: Schema.optionalKey(Schema.Boolean),
123 header: Schema.optionalKey(Schema.Boolean),
124 icon: Schema.optionalKey(Schema.String),
125 children: Schema.optionalKey(
126 Schema.Array(
127 Schema.suspend((): Schema.Codec<ContextMenuItemSchemaType> => ContextMenuItemSchema),
128 ),
129 ),
130});
131​
132export type DesktopUpdateStatus =
133 | "disabled"
134 | "idle"
135 | "checking"
136 | "up-to-date"
137 | "available"
138 | "downloading"
139 | "downloaded"
140 | "error";
141​
142export type DesktopRuntimeArch = "arm64" | "x64" | "other";
143export type DesktopTheme = "light" | "dark" | "system";
144export type DesktopUpdateChannel = "latest" | "nightly";
145export type DesktopAppStageLabel = "Alpha" | "Dev" | "Nightly";
146​
147export const DesktopUpdateStatusSchema = Schema.Literals([
148 "disabled",
149 "idle",
150 "checking",
151 "up-to-date",
152 "available",
153 "downloading",
154 "downloaded",
155 "error",
156]);
157export const DesktopRuntimeArchSchema = Schema.Literals(["arm64", "x64", "other"]);
158export const DesktopThemeSchema = Schema.Literals(["light", "dark", "system"]);
159export const DesktopUpdateChannelSchema = Schema.Literals(["latest", "nightly"]);
160export const DesktopAppStageLabelSchema = Schema.Literals(["Alpha", "Dev", "Nightly"]);
161​
162export interface DesktopAppBranding {
163 baseName: string;
164 stageLabel: DesktopAppStageLabel;
165 displayName: string;
167​
168export const DesktopAppBrandingSchema = Schema.Struct({
169 baseName: Schema.String,
170 stageLabel: DesktopAppStageLabelSchema,
171 displayName: Schema.String,
172});
173​
174export interface DesktopRuntimeInfo {
175 hostArch: DesktopRuntimeArch;
176 appArch: DesktopRuntimeArch;
177 runningUnderArm64Translation: boolean;
179​
180export const DesktopRuntimeInfoSchema = Schema.Struct({
181 hostArch: DesktopRuntimeArchSchema,
182 appArch: DesktopRuntimeArchSchema,
183 runningUnderArm64Translation: Schema.Boolean,
184});
185​
186export interface DesktopUpdateState {
187 enabled: boolean;
188 status: DesktopUpdateStatus;
189 channel: DesktopUpdateChannel;
190 currentVersion: string;
191 hostArch: DesktopRuntimeArch;
192 appArch: DesktopRuntimeArch;
193 runningUnderArm64Translation: boolean;
194 availableVersion: string | null;
195 downloadedVersion: string | null;
196 releaseNotes: ReadonlyArray<DesktopUpdateReleaseNote>;
197 downloadPercent: number | null;
198 checkedAt: string | null;
199 message: string | null;
200 errorContext: "check" | "download" | "install" | null;
201 canRetry: boolean;
203​
204export interface DesktopUpdateReleaseNote {
205 version: string;
206 items: ReadonlyArray<string>;
208​
209export const DesktopUpdateReleaseNoteSchema = Schema.Struct({
210 version: Schema.String,
211 items: Schema.Array(Schema.String),
212});
213​
214export const DesktopUpdateStateSchema = Schema.Struct({
215 enabled: Schema.Boolean,
216 status: DesktopUpdateStatusSchema,
217 channel: DesktopUpdateChannelSchema,
218 currentVersion: Schema.String,
219 hostArch: DesktopRuntimeArchSchema,
220 appArch: DesktopRuntimeArchSchema,
221 runningUnderArm64Translation: Schema.Boolean,
222 availableVersion: Schema.NullOr(Schema.String),
223 downloadedVersion: Schema.NullOr(Schema.String),
224 releaseNotes: Schema.Array(DesktopUpdateReleaseNoteSchema),
225 downloadPercent: Schema.NullOr(Schema.Number),
226 checkedAt: Schema.NullOr(Schema.String),
227 message: Schema.NullOr(Schema.String),
228 errorContext: Schema.NullOr(Schema.Literals(["check", "download", "install"])),
229 canRetry: Schema.Boolean,
230});
231​
232export interface DesktopUpdateActionResult {
233 accepted: boolean;
234 completed: boolean;
235 state: DesktopUpdateState;
237​
238export const DesktopUpdateActionResultSchema = Schema.Struct({
239 accepted: Schema.Boolean,
240 completed: Schema.Boolean,
241 state: DesktopUpdateStateSchema,
242});
243​
244export interface DesktopUpdateCheckResult {
245 checked: boolean;
246 state: DesktopUpdateState;
248​
249export const DesktopUpdateCheckResultSchema = Schema.Struct({
250 checked: Schema.Boolean,
251 state: DesktopUpdateStateSchema,
252});
253​
254// Stable id for the Windows-native primary backend. Desktop side wraps
255// this with a brand inside DesktopBackendManager; web side keeps it as
256// a plain string so the env-runtime can compare against it without
257// importing brand machinery from the desktop package.
258export const PRIMARY_LOCAL_ENVIRONMENT_ID = "primary";
259​
260export interface DesktopEnvironmentBootstrap {
261 // Stable backend instance id (e.g. "primary" or "wsl:ubuntu"). The
262 // web env runtime keys local environments off this so projects
263 // routed to a specific backend reopen against the same one.
264 id: string;
265 label: string;
266 // Concrete WSL distro used by the current backend run. This stays separate
267 // from id because a default-tracking instance keeps the stable
268 // "wsl:default" IPC target while each run launches a specific distro.
269 runningDistro?: string | null;
270 httpBaseUrl: string | null;
271 wsBaseUrl: string | null;
272 bootstrapToken?: string;
274​
275export const DesktopEnvironmentBootstrapSchema = Schema.Struct({
276 id: Schema.String,
277 label: Schema.String,
278 runningDistro: Schema.optionalKey(Schema.NullOr(Schema.String)),
279 httpBaseUrl: Schema.NullOr(Schema.String),
280 wsBaseUrl: Schema.NullOr(Schema.String),
281 bootstrapToken: Schema.optionalKey(Schema.String),
282});
283​
284export const DesktopSshEnvironmentTargetSchema = Schema.Struct({
285 alias: Schema.String,
286 hostname: Schema.String,
287 username: Schema.NullOr(Schema.String),
288 port: Schema.NullOr(Schema.Number),
289});
290export type DesktopSshEnvironmentTarget = typeof DesktopSshEnvironmentTargetSchema.Type;
291​
292export type DesktopSshHostSource = "ssh-config" | "known-hosts";
293export const DesktopSshHostSourceSchema = Schema.Literals(["ssh-config", "known-hosts"]);
294​
295export interface DesktopDiscoveredSshHost extends DesktopSshEnvironmentTarget {
296 source: DesktopSshHostSource;
298​
299export const DesktopDiscoveredSshHostSchema = Schema.Struct({
300 alias: Schema.String,
301 hostname: Schema.String,
302 username: Schema.NullOr(Schema.String),
303 port: Schema.NullOr(Schema.Number),
304 source: DesktopSshHostSourceSchema,
305});
306​
307export interface DesktopSshEnvironmentBootstrap {
308 target: DesktopSshEnvironmentTarget;
309 httpBaseUrl: string;
310 wsBaseUrl: string;
311 pairingToken: string | null;
312 remotePort?: number;
313 remoteServerKind?: "external" | "managed";
315​
316export const DesktopSshEnvironmentBootstrapSchema = Schema.Struct({
317 target: DesktopSshEnvironmentTargetSchema,
318 httpBaseUrl: Schema.String,
319 wsBaseUrl: Schema.String,
320 pairingToken: Schema.NullOr(Schema.String),
321 remotePort: Schema.optionalKey(Schema.Number),
322 remoteServerKind: Schema.optionalKey(Schema.Literals(["external", "managed"])),
323});
324​
325export interface DesktopSshPasswordPromptRequest {
326 requestId: string;
327 destination: string;
328 username: string | null;
329 prompt: string;
330 expiresAt: string;
332​
333export const DesktopSshPasswordPromptRequestSchema = Schema.Struct({
334 requestId: Schema.String,
335 destination: Schema.String,
336 username: Schema.NullOr(Schema.String),
337 prompt: Schema.String,
338 expiresAt: Schema.String,
339});
340​
341export const DesktopSshPasswordPromptCancelledType = "ssh-password-prompt-cancelled" as const;
342​
343export const DesktopSshPasswordPromptCancelledResultSchema = Schema.Struct({
344 type: Schema.Literal(DesktopSshPasswordPromptCancelledType),
345 message: Schema.String,
346});
347​
348export const DesktopSshEnvironmentEnsureOptionsSchema = Schema.Struct({
349 issuePairingToken: Schema.optionalKey(Schema.Boolean),
350});
351​
352export const DesktopSshEnvironmentEnsureInputSchema = Schema.Struct({
353 target: DesktopSshEnvironmentTargetSchema,
354 options: Schema.optionalKey(DesktopSshEnvironmentEnsureOptionsSchema),
355});
356​
357export const DesktopSshEnvironmentEnsureResultSchema = Schema.Union([
358 DesktopSshEnvironmentBootstrapSchema,
359 DesktopSshPasswordPromptCancelledResultSchema,
360]);
361​
362export const DesktopSshHttpBaseUrlInputSchema = Schema.Struct({
363 httpBaseUrl: Schema.String,
364});
365​
366export const DesktopSshBearerRequestInputSchema = Schema.Struct({
367 httpBaseUrl: Schema.String,
368 bearerToken: Schema.String,
369});
370​
371export const DesktopSshBearerBootstrapInputSchema = Schema.Struct({
372 httpBaseUrl: Schema.String,
373 credential: Schema.String,
374});
375​
376export const DesktopSshPasswordPromptResolutionInputSchema = Schema.Struct({
377 requestId: Schema.String,
378 password: Schema.NullOr(Schema.String),
379});
380​
381export const PersistedSavedEnvironmentRecordSchema = Schema.Struct({
382 environmentId: EnvironmentId,
383 label: Schema.String,
384 wsBaseUrl: Schema.String,
385 httpBaseUrl: Schema.String,
386 createdAt: Schema.String,
387 lastConnectedAt: Schema.NullOr(Schema.String),
388 desktopSsh: Schema.optionalKey(DesktopSshEnvironmentTargetSchema),
389 relayManaged: Schema.optionalKey(
390 Schema.Struct({
391 relayUrl: Schema.String,
392 }),
393 ),
394});
395export type PersistedSavedEnvironmentRecord = typeof PersistedSavedEnvironmentRecordSchema.Type;
396​
397export type DesktopServerExposureMode = "local-only" | "network-accessible";
398​
399export const DesktopServerExposureModeSchema = Schema.Literals([
400 "local-only",
401 "network-accessible",
402]);
403​
404export interface DesktopServerExposureState {
405 mode: DesktopServerExposureMode;
406 endpointUrl: string | null;
407 advertisedHost: string | null;
408 tailscaleServeEnabled: boolean;
409 tailscaleServePort: number;
411​
412export const DesktopServerExposureStateSchema = Schema.Struct({
413 mode: DesktopServerExposureModeSchema,
414 endpointUrl: Schema.NullOr(Schema.String),
415 advertisedHost: Schema.NullOr(Schema.String),
416 tailscaleServeEnabled: Schema.Boolean,
417 tailscaleServePort: Schema.Number,
418});
419​
420export interface PickFolderOptions {
421 initialPath?: string | null;
422 // When set, the desktop dialog opens against the named backend's
423 // filesystem instead of the primary's. Used by callers that already
424 // know which local environment they're targeting (e.g. opening a
425 // project that lives inside WSL). Omitting it keeps the historical
426 // behavior so non-WSL users never see a different picker.
427 targetEnvironmentId?: string;
429​
430export const PickFolderOptionsSchema = Schema.Struct({
431 initialPath: Schema.optionalKey(Schema.NullOr(Schema.String)),
432 targetEnvironmentId: Schema.optionalKey(Schema.String),
433});
434​
435export interface DesktopWslDistro {
436 name: string;
437 isDefault: boolean;
438 version: 1 | 2;
440​
441export const DesktopWslDistroSchema = Schema.Struct({
442 name: Schema.String,
443 isDefault: Schema.Boolean,
444 version: Schema.Literals([1, 2]),
445});
446​
447export interface DesktopWslState {
448 // True when the user has opted the WSL backend in; the actual backend
449 // process is registered with the desktop pool independently of this
450 // flag and may take a moment to come up after the user enables it.
451 enabled: boolean;
452 // null means "track the current WSL default distro".
453 distro: string | null;
454 available: boolean;
455 // When true (and `enabled` is also true) the desktop runs only the
456 // WSL backend as the primary; the Windows-side Node backend is not
457 // started. Toggling this requires an app restart because the
458 // primary backend's spec is captured once at layer init.
459 wslOnly: boolean;
460 distros: readonly DesktopWslDistro[];
461 // Reason the dual-mode WSL backend last failed preflight (no node, wrong
462 // version, missing build tools), or null. Surfaced inline in Connections
463 // settings. Always null in wsl-only mode — that path shows a dialog and
464 // falls back to Windows instead.
465 preflightError: string | null;
467​
468export const DesktopWslStateSchema = Schema.Struct({
469 enabled: Schema.Boolean,
470 distro: Schema.NullOr(Schema.String),
471 available: Schema.Boolean,
472 wslOnly: Schema.Boolean,
473 distros: Schema.Array(DesktopWslDistroSchema),
474 preflightError: Schema.NullOr(Schema.String),
475});
476​
477/**
478 * Renderer-facing snapshot of a desktop preview tab. Mirrors the main-process
479 * PreviewTabState shape but uses serialisable primitives only.
480 */
481export type DesktopPreviewNavStatus =
482 | { kind: "Idle" }
483 | { kind: "Loading"; url: string; title: string }
484 | { kind: "Success"; url: string; title: string }
485 | {
486 kind: "LoadFailed";
487 url: string;
488 title: string;
489 code: number;
490 description: string;
491 };
492​
493/**
494 * Emulated `prefers-color-scheme` for the guest page. "system" clears the
495 * override so the page follows the OS appearance.
496 */
497export type DesktopPreviewColorScheme = "system" | "light" | "dark";
498​
499export const DesktopPreviewColorSchemeSchema: Schema.Codec<DesktopPreviewColorScheme> =
500 Schema.Literals(["system", "light", "dark"]);
501​
502export interface DesktopPreviewTabState {
503 tabId: string;
504 webContentsId: number | null;
505 navStatus: DesktopPreviewNavStatus;
506 canGoBack: boolean;
507 canGoForward: boolean;
508 /** Current zoom factor (1.0 = 100%). */
509 zoomFactor: number;
510 /** Whether this tab is currently mirrored into a desktop picture-in-picture window. */
511 pictureInPicture: boolean;
512 colorScheme: DesktopPreviewColorScheme;
513 controller: "human" | "agent" | "none";
514 updatedAt: string;
516​
517export const DesktopPreviewTabIdSchema = Schema.String.check(Schema.isTrimmed()).check(
518 Schema.isNonEmpty(),
519);
520​
521export const DesktopPreviewNavStatusSchema = Schema.Union([
522 Schema.Struct({ kind: Schema.Literal("Idle") }),
523 Schema.Struct({
524 kind: Schema.Literal("Loading"),
525 url: Schema.String,
526 title: Schema.String,
527 }),
528 Schema.Struct({
529 kind: Schema.Literal("Success"),
530 url: Schema.String,
531 title: Schema.String,
532 }),
533 Schema.Struct({
534 kind: Schema.Literal("LoadFailed"),
535 url: Schema.String,
536 title: Schema.String,
537 code: Schema.Number,
538 description: Schema.String,
539 }),
540]);
541​
542export const DesktopPreviewTabStateSchema: Schema.Codec<DesktopPreviewTabState> = Schema.Struct({
543 tabId: DesktopPreviewTabIdSchema,
544 webContentsId: Schema.NullOr(Schema.Int),
545 navStatus: DesktopPreviewNavStatusSchema,
546 canGoBack: Schema.Boolean,
547 canGoForward: Schema.Boolean,
548 zoomFactor: Schema.Number,
549 pictureInPicture: Schema.Boolean,
550 colorScheme: DesktopPreviewColorSchemeSchema,
551 controller: Schema.Literals(["human", "agent", "none"]),
552 updatedAt: Schema.String,
553});
554​
555export interface DesktopPreviewPointerEvent {
556 tabId: string;
557 phase: "move" | "click";
558 x: number;
559 y: number;
560 sequence: number;
561 createdAt: string;
563​
564export const DesktopPreviewPointerEventSchema: Schema.Codec<DesktopPreviewPointerEvent> =
565 Schema.Struct({
566 tabId: DesktopPreviewTabIdSchema,
567 phase: Schema.Literals(["move", "click"]),
568 x: Schema.Number,
569 y: Schema.Number,
570 sequence: Schema.Int,
571 createdAt: Schema.String,
572 });
573​
574/**
575 * Static config a renderer needs to mount a preview `<webview>`. Returned
576 * atomically by `DesktopPreviewBridge.getPreviewConfig()` so the renderer
577 * doesn't have to wait on three separate IPC round-trips before the webview
578 * can attach.
579 */
580export interface DesktopPreviewWebviewConfig {
581 /** `persist:t3code-preview` (or whatever the desktop chose). */
582 partition: string;
583 /**
584 * Canonical `<webview webpreferences="...">` string. Encodes the security
585 * posture (sandboxed but contextIsolation off so the picker preload can
586 * read the page's React DevTools hook). Always present.
587 */
588 webPreferences: string;
589 /**
590 * Absolute `file://`-style URL to the picker preload bundle. Set to null
591 * when the bundle isn't present (older builds, broken install) — the
592 * renderer must then disable element-pick affordances.
593 */
594 preloadUrl: string | null;
596​
597export const DesktopPreviewWebviewConfigSchema: Schema.Codec<DesktopPreviewWebviewConfig> =
598 Schema.Struct({
599 partition: Schema.String,
600 webPreferences: Schema.String,
601 preloadUrl: Schema.NullOr(Schema.String),
602 });
603​
604export interface DesktopPreviewAnnotationTheme {
605 colorScheme: "light" | "dark";
606 radius: string;
607 background: string;
608 foreground: string;
609 popover: string;
610 popoverForeground: string;
611 primary: string;
612 primaryForeground: string;
613 muted: string;
614 mutedForeground: string;
615 accent: string;
616 accentForeground: string;
617 border: string;
618 input: string;
619 ring: string;
620 fontSans: string;
621 fontMono: string;
623​
624export const DesktopPreviewAnnotationThemeSchema: Schema.Codec<DesktopPreviewAnnotationTheme> =
625 Schema.Struct({
626 colorScheme: Schema.Literals(["light", "dark"]),
627 radius: Schema.String,
628 background: Schema.String,
629 foreground: Schema.String,
630 popover: Schema.String,
631 popoverForeground: Schema.String,
632 primary: Schema.String,
633 primaryForeground: Schema.String,
634 muted: Schema.String,
635 mutedForeground: Schema.String,
636 accent: Schema.String,
637 accentForeground: Schema.String,
638 border: Schema.String,
639 input: Schema.String,
640 ring: Schema.String,
641 fontSans: Schema.String,
642 fontMono: Schema.String,
643 });
644​
645export interface DesktopPreviewRecordingFrame {
646 tabId: string;
647 data: string;
648 width: number;
649 height: number;
650 receivedAt: string;
652​
653export const DesktopPreviewRecordingFrameSchema: Schema.Codec<DesktopPreviewRecordingFrame> =
654 Schema.Struct({
655 tabId: DesktopPreviewTabIdSchema,
656 data: Schema.String,
657 width: Schema.Number,
658 height: Schema.Number,
659 receivedAt: Schema.String,
660 });
661​
662export interface DesktopPreviewRecordingArtifact {
663 id: string;
664 tabId: string;
665 path: string;
666 mimeType: string;
667 sizeBytes: number;
668 createdAt: string;
670​
671export const DesktopPreviewRecordingArtifactSchema: Schema.Codec<DesktopPreviewRecordingArtifact> =
672 Schema.Struct({
673 id: Schema.String,
674 tabId: DesktopPreviewTabIdSchema,
675 path: Schema.String,
676 mimeType: Schema.String,
677 sizeBytes: Schema.Int,
678 createdAt: Schema.String,
679 });
680​
681export interface DesktopPreviewScreenshotArtifact {
682 id: string;
683 tabId: string;
684 path: string;
685 mimeType: "image/png";
686 sizeBytes: number;
687 createdAt: string;
689​
690export const DesktopPreviewScreenshotArtifactSchema: Schema.Codec<DesktopPreviewScreenshotArtifact> =
691 Schema.Struct({
692 id: Schema.String,
693 tabId: DesktopPreviewTabIdSchema,
694 path: Schema.String,
695 mimeType: Schema.Literal("image/png"),
696 sizeBytes: Schema.Int,
697 createdAt: Schema.String,
698 });
699​
700/**
701 * Single stack frame captured by react-grab's `getElementContext`. We surface
702 * the source file/line so coding agents can jump straight to the JSX that
703 * produced the picked DOM node.
704 */
705export interface PickedElementStackFrame {
706 functionName: string | null;
707 fileName: string | null;
708 lineNumber: number | null;
709 columnNumber: number | null;
711​
712export const PickedElementStackFrameSchema: Schema.Codec<PickedElementStackFrame> = Schema.Struct({
713 functionName: Schema.NullOr(Schema.String),
714 fileName: Schema.NullOr(Schema.String),
715 lineNumber: Schema.NullOr(Schema.Number),
716 columnNumber: Schema.NullOr(Schema.Number),
717});
718​
719/**
720 * A successful element pick from the preview webview. All fields are
721 * best-effort — pages that don't ship a React fiber tree (or aren't running
722 * in dev) will still produce a usable payload (selector + html preview),
723 * just without component / source attribution.
724 */
725export interface PickedElementPayload {
726 /** URL of the page the element was picked on. */
727 pageUrl: string;
728 /** Optional `<title>` of that page (best-effort). */
729 pageTitle: string | null;
730 /** Lowercase tag name, e.g. `"button"`. */
731 tagName: string;
732 /** CSS selector resolving back to the element on a re-render. */
733 selector: string | null;
734 /** Truncated outer-HTML preview (matches react-grab's `htmlPreview`). */
735 htmlPreview: string;
736 /** Nearest React component display name, or null when unavailable. */
737 componentName: string | null;
738 /** First source-mapped stack frame (file + line of the JSX source). */
739 source: PickedElementStackFrame | null;
740 /** Full owner-stack frames; can be empty. Useful for richer context. */
741 stack: ReadonlyArray<PickedElementStackFrame>;
742 /** Author CSS only (UA defaults stripped) — react-grab's `styles`. */
743 styles: string;
744 /** Wall-clock pick time as ISO-8601 string. */
745 pickedAt: string;
747​
748export const PickedElementPayloadSchema: Schema.Codec<PickedElementPayload> = Schema.Struct({
749 pageUrl: Schema.String,
750 pageTitle: Schema.NullOr(Schema.String),
751 tagName: Schema.String,
752 selector: Schema.NullOr(Schema.String),
753 htmlPreview: Schema.String,
754 componentName: Schema.NullOr(Schema.String),
755 source: Schema.NullOr(PickedElementStackFrameSchema),
756 stack: Schema.Array(PickedElementStackFrameSchema),
757 styles: Schema.String,
758 pickedAt: Schema.String,
759});
760​
761export interface PreviewAnnotationRect {
762 x: number;
763 y: number;
764 width: number;
765 height: number;
767​
768export const PreviewAnnotationRectSchema: Schema.Codec<PreviewAnnotationRect> = Schema.Struct({
769 x: Schema.Number,
770 y: Schema.Number,
771 width: Schema.Number,
772 height: Schema.Number,
773});
774​
775export interface PreviewAnnotationPoint {
776 x: number;
777 y: number;
779​
780export const PreviewAnnotationPointSchema: Schema.Codec<PreviewAnnotationPoint> = Schema.Struct({
781 x: Schema.Number,
782 y: Schema.Number,
783});
784​
785export interface PreviewAnnotationElementTarget {
786 id: string;
787 element: PickedElementPayload;
788 rect: PreviewAnnotationRect;
790​
791export const PreviewAnnotationElementTargetSchema: Schema.Codec<PreviewAnnotationElementTarget> =
792 Schema.Struct({
793 id: Schema.String,
794 element: PickedElementPayloadSchema,
795 rect: PreviewAnnotationRectSchema,
796 });
797​
798export interface PreviewAnnotationRegionTarget {
799 id: string;
800 rect: PreviewAnnotationRect;
802​
803export const PreviewAnnotationRegionTargetSchema: Schema.Codec<PreviewAnnotationRegionTarget> =
804 Schema.Struct({
805 id: Schema.String,
806 rect: PreviewAnnotationRectSchema,
807 });
808​
809export interface PreviewAnnotationStrokeTarget {
810 id: string;
811 color: string;
812 width: number;
813 points: ReadonlyArray<PreviewAnnotationPoint>;
814 bounds: PreviewAnnotationRect;
816​
817export const PreviewAnnotationStrokeTargetSchema: Schema.Codec<PreviewAnnotationStrokeTarget> =
818 Schema.Struct({
819 id: Schema.String,
820 color: Schema.String,
821 width: Schema.Number,
822 points: Schema.Array(PreviewAnnotationPointSchema),
823 bounds: PreviewAnnotationRectSchema,
824 });
825​
826export interface PreviewAnnotationStyleChange {
827 targetId: string;
828 selector: string | null;
829 property: string;
830 previousValue: string;
831 value: string;
833​
834export const PreviewAnnotationStyleChangeSchema: Schema.Codec<PreviewAnnotationStyleChange> =
835 Schema.Struct({
836 targetId: Schema.String,
837 selector: Schema.NullOr(Schema.String),
838 property: Schema.String,
839 previousValue: Schema.String,
840 value: Schema.String,
841 });
842​
843export interface PreviewAnnotationScreenshot {
844 dataUrl: string;
845 width: number;
846 height: number;
847 cropRect: PreviewAnnotationRect;
849​
850export const PreviewAnnotationScreenshotSchema: Schema.Codec<PreviewAnnotationScreenshot> =
851 Schema.Struct({
852 dataUrl: Schema.String,
853 width: Schema.Number,
854 height: Schema.Number,
855 cropRect: PreviewAnnotationRectSchema,
856 });
857​
858/**
859 * A submitted preview annotation. One annotation may reference multiple DOM
860 * elements, freeform regions, and ink strokes. The desktop main process adds
861 * the screenshot after the guest preload submits the structured draft.
862 */
863export interface PreviewAnnotationPayload {
864 id: string;
865 pageUrl: string;
866 pageTitle: string | null;
867 comment: string;
868 elements: ReadonlyArray<PreviewAnnotationElementTarget>;
869 regions: ReadonlyArray<PreviewAnnotationRegionTarget>;
870 strokes: ReadonlyArray<PreviewAnnotationStrokeTarget>;
871 styleChanges: ReadonlyArray<PreviewAnnotationStyleChange>;
872 screenshot: PreviewAnnotationScreenshot | null;
873 createdAt: string;
875​
876export const PreviewAnnotationPayloadSchema: Schema.Codec<PreviewAnnotationPayload> = Schema.Struct(
877 {
878 id: Schema.String,
879 pageUrl: Schema.String,
880 pageTitle: Schema.NullOr(Schema.String),
881 comment: Schema.String,
882 elements: Schema.Array(PreviewAnnotationElementTargetSchema),
883 regions: Schema.Array(PreviewAnnotationRegionTargetSchema),
884 strokes: Schema.Array(PreviewAnnotationStrokeTargetSchema),
885 styleChanges: Schema.Array(PreviewAnnotationStyleChangeSchema),
886 screenshot: Schema.NullOr(PreviewAnnotationScreenshotSchema),
887 createdAt: Schema.String,
888 },
889);
890​
891export const DesktopPreviewTabInputSchema = Schema.Struct({
892 tabId: DesktopPreviewTabIdSchema,
893});
894​
895export const DesktopPreviewRegisterWebviewInputSchema = Schema.Struct({
896 tabId: DesktopPreviewTabIdSchema,
897 webContentsId: Schema.Int.check(Schema.isGreaterThan(0)),
898});
899​
900export const DesktopPreviewNavigateInputSchema = Schema.Struct({
901 tabId: DesktopPreviewTabIdSchema,
902 url: Schema.String,
903});
904​
905export const DesktopPreviewConfigInputSchema = Schema.Struct({
906 environmentId: EnvironmentId,
907});
908​
909export const DesktopPreviewSetColorSchemeInputSchema = Schema.Struct({
910 tabId: DesktopPreviewTabIdSchema,
911 colorScheme: DesktopPreviewColorSchemeSchema,
912});
913​
914export const DesktopPreviewAnnotationThemeInputSchema = Schema.Struct({
915 theme: DesktopPreviewAnnotationThemeSchema,
916});
917​
918export const DesktopPreviewArtifactInputSchema = Schema.Struct({
919 path: Schema.String.check(Schema.isTrimmed()).check(Schema.isNonEmpty()),
920});
921​
922export const DesktopPreviewRecordingSaveInputSchema = Schema.Struct({
923 tabId: DesktopPreviewTabIdSchema,
924 mimeType: Schema.String.check(Schema.isTrimmed()).check(Schema.isNonEmpty()),
925 data: Schema.Uint8Array,
926});
927​
928export const DesktopPreviewAutomationClickInputSchema = Schema.Struct({
929 tabId: DesktopPreviewTabIdSchema,
930 input: PreviewAutomationClickInput,
931});
932​
933export const DesktopPreviewAutomationTypeInputSchema = Schema.Struct({
934 tabId: DesktopPreviewTabIdSchema,
935 input: PreviewAutomationTypeInput,
936});
937​
938export const DesktopPreviewAutomationPressInputSchema = Schema.Struct({
939 tabId: DesktopPreviewTabIdSchema,
940 input: PreviewAutomationPressInput,
941});
942​
943export const DesktopPreviewAutomationScrollInputSchema = Schema.Struct({
944 tabId: DesktopPreviewTabIdSchema,
945 input: PreviewAutomationScrollInput,
946});
947​
948export const DesktopPreviewAutomationEvaluateInputSchema = Schema.Struct({
949 tabId: DesktopPreviewTabIdSchema,
950 input: PreviewAutomationEvaluateInput,
951});
952​
953export const DesktopPreviewAutomationWaitForInputSchema = Schema.Struct({
954 tabId: DesktopPreviewTabIdSchema,
955 input: PreviewAutomationWaitForInput,
956});
957​
958export interface DesktopBridge {
959 getAppBranding: () => DesktopAppBranding | null;
960 // One bootstrap per pool instance currently registered with bootstrap
961 // info (omits instances whose backend hasn't produced a config yet).
962 // The primary backend is identified by id === PRIMARY_LOCAL_ENVIRONMENT_ID.
963 getLocalEnvironmentBootstraps: () => readonly DesktopEnvironmentBootstrap[];
964 getLocalEnvironmentBearerToken: () => Promise<string>;
965 getClientSettings: () => Promise<ClientSettings | null>;
966 setClientSettings: (settings: ClientSettings) => Promise<void>;
967 getConnectionCatalog?: () => Promise<string | null>;
968 setConnectionCatalog?: (catalog: string) => Promise<boolean>;
969 clearConnectionCatalog?: () => Promise<void>;
970 discoverSshHosts: () => Promise<readonly DesktopDiscoveredSshHost[]>;
971 ensureSshEnvironment: (
972 target: DesktopSshEnvironmentTarget,
973 options?: { issuePairingToken?: boolean },
974 ) => Promise<DesktopSshEnvironmentBootstrap>;
975 disconnectSshEnvironment: (target: DesktopSshEnvironmentTarget) => Promise<void>;
976 fetchSshEnvironmentDescriptor: (httpBaseUrl: string) => Promise<ExecutionEnvironmentDescriptor>;
977 bootstrapSshBearerSession: (
978 httpBaseUrl: string,
979 credential: string,
980 ) => Promise<AuthAccessTokenResult>;
981 fetchSshSessionState: (httpBaseUrl: string, bearerToken: string) => Promise<AuthSessionState>;
982 issueSshWebSocketTicket: (
983 httpBaseUrl: string,
984 bearerToken: string,
985 ) => Promise<AuthWebSocketTicketResult>;
986 onSshPasswordPrompt: (listener: (request: DesktopSshPasswordPromptRequest) => void) => () => void;
987 resolveSshPasswordPrompt: (requestId: string, password: string | null) => Promise<void>;
988 getServerExposureState: () => Promise<DesktopServerExposureState>;
989 setServerExposureMode: (mode: DesktopServerExposureMode) => Promise<DesktopServerExposureState>;
990 setTailscaleServeEnabled: (input: {
991 readonly enabled: boolean;
992 readonly port?: number;
993 }) => Promise<DesktopServerExposureState>;
994 getAdvertisedEndpoints: () => Promise<readonly AdvertisedEndpoint[]>;
995 getWslState: () => Promise<DesktopWslState>;
996 setWslBackendEnabled: (enabled: boolean) => Promise<DesktopWslState>;
997 setWslDistro: (distro: string | null) => Promise<DesktopWslState>;
998 setWslOnly: (enabled: boolean) => Promise<DesktopWslState>;
999 pickFolder: (options?: PickFolderOptions) => Promise<string | null>;
1000 confirm: (message: string) => Promise<boolean>;
1001 setTheme: (theme: DesktopTheme) => Promise<void>;
1002 showContextMenu: <T extends string>(
1003 items: readonly ContextMenuItem<T>[],
1004 position?: { x: number; y: number },
1005 ) => Promise<T | null>;
1006 openExternal: (url: string) => Promise<boolean>;
1007 onMenuAction: (listener: (action: string) => void) => () => void;
1008 getWindowFullscreenState: () => boolean;
1009 onWindowFullscreenStateChange: (listener: (fullscreen: boolean) => void) => () => void;
1010 getUpdateState: () => Promise<DesktopUpdateState>;
1011 setUpdateChannel: (channel: DesktopUpdateChannel) => Promise<DesktopUpdateState>;
1012 checkForUpdate: () => Promise<DesktopUpdateCheckResult>;
1013 downloadUpdate: () => Promise<DesktopUpdateActionResult>;
1014 installUpdate: () => Promise<DesktopUpdateActionResult>;
1015 onUpdateState: (listener: (state: DesktopUpdateState) => void) => () => void;
1016 /**
1017 * Desktop-only preview surface. Present iff the renderer is hosted by the
1018 * Electron desktop build; web builds have `preview === undefined`.
1019 */
1020 preview?: DesktopPreviewBridge;
1022​
1023export interface DesktopPreviewBridge {
1024 createTab: (tabId: string) => Promise<void>;
1025 closeTab: (tabId: string) => Promise<void>;
1026 registerWebview: (tabId: string, webContentsId: number) => Promise<void>;
1027 navigate: (tabId: string, url: string) => Promise<void>;
1028 goBack: (tabId: string) => Promise<void>;
1029 goForward: (tabId: string) => Promise<void>;
1030 refresh: (tabId: string) => Promise<void>;
1031 zoomIn: (tabId: string) => Promise<void>;
1032 zoomOut: (tabId: string) => Promise<void>;
1033 resetZoom: (tabId: string) => Promise<void>;
1034 /** Reload bypassing the HTTP cache. */
1035 hardReload: (tabId: string) => Promise<void>;
1036 /**
1037 * Emulate `prefers-color-scheme` on the guest page ("system" clears the
1038 * override). Persists per tab and is re-applied across webview swaps.
1039 */
1040 setColorScheme: (tabId: string, colorScheme: DesktopPreviewColorScheme) => Promise<void>;
1041 /** Open the guest webview's DevTools (detached). */
1042 openDevTools: (tabId: string) => Promise<void>;
1043 /** Drop cookies + storage data for the preview partition (all tabs). */
1044 clearCookies: () => Promise<void>;
1045 /** Drop the HTTP cache for the preview partition (all tabs). */
1046 clearCache: () => Promise<void>;
1047 /**
1048 * One-shot config for mounting a preview `<webview>`. Replaces three
1049 * earlier round-trip calls (`getBrowserPartition`, `getWebviewPreferences`,
1050 * `getPickPreloadPath`) so adding a new field here only requires touching
1051 * the contract + main, not the renderer's mount logic.
1052 */
1053 getPreviewConfig: (environmentId: EnvironmentId) => Promise<DesktopPreviewWebviewConfig>;
1054 setAnnotationTheme: (theme: DesktopPreviewAnnotationTheme) => Promise<void>;
1055 /**
1056 * Activate the in-page element picker for the given tab. Resolves with
1057 * the picked payload, or `null` when the user cancels (Escape / nav). The
1058 * promise rejects if the picker can't be activated (no webview, etc.).
1059 */
1060 pickElement: (tabId: string) => Promise<PreviewAnnotationPayload | null>;
1061 /** Cancel an in-flight preview annotation session. */
1062 cancelPickElement: (tabId: string) => Promise<void>;
1063 captureScreenshot: (tabId: string) => Promise<DesktopPreviewScreenshotArtifact>;
1064 revealArtifact: (path: string) => Promise<void>;
1065 copyArtifactToClipboard: (path: string) => Promise<void>;
1066 pictureInPicture: {
1067 open: (tabId: string) => Promise<void>;
1068 close: (tabId: string) => Promise<void>;
1069 };
1070 recording: {
1071 startScreencast: (tabId: string) => Promise<void>;
1072 stopScreencast: (tabId: string) => Promise<void>;
1073 save: (
1074 tabId: string,
1075 mimeType: string,
1076 data: Uint8Array,
1077 ) => Promise<DesktopPreviewRecordingArtifact>;
1078 onFrame: (listener: (frame: DesktopPreviewRecordingFrame) => void) => () => void;
1079 };
1080 automation: {
1081 status: (tabId: string) => Promise<PreviewAutomationStatus>;
1082 snapshot: (tabId: string) => Promise<PreviewAutomationSnapshot>;
1083 click: (tabId: string, input: PreviewAutomationClickInput) => Promise<void>;
1084 type: (tabId: string, input: PreviewAutomationTypeInput) => Promise<void>;
1085 press: (tabId: string, input: PreviewAutomationPressInput) => Promise<void>;
1086 scroll: (tabId: string, input: PreviewAutomationScrollInput) => Promise<void>;
1087 evaluate: (tabId: string, input: PreviewAutomationEvaluateInput) => Promise<unknown>;
1088 waitFor: (tabId: string, input: PreviewAutomationWaitForInput) => Promise<void>;
1089 };
1090 onStateChange: (listener: (tabId: string, state: DesktopPreviewTabState) => void) => () => void;
1091 onPointerEvent: (listener: (event: DesktopPreviewPointerEvent) => void) => () => void;
1093​
1094/**
1095 * APIs bound to the local app shell, not to any particular backend environment.
1097 * These capabilities describe the desktop/browser host that the user is
1098 * currently running: dialogs, external-link opening, context menus, and
1099 * app-level settings/config access. They must not be used as a proxy for
1100 * "whatever environment the user is targeting", because in a multi-environment
1101 * world the local shell and a selected backend environment are distinct
1102 * concepts.
1103 */
1104export interface LocalApi {
1105 dialogs: {
1106 pickFolder: (options?: PickFolderOptions) => Promise<string | null>;
1107 confirm: (message: string) => Promise<boolean>;
1108 };
1109 shell: {
1110 openExternal: (url: string) => Promise<void>;
1111 };
1112 contextMenu: {
1113 show: <T extends string>(
1114 items: readonly ContextMenuItem<T>[],
1115 position?: { x: number; y: number },
1116 ) => Promise<T | null>;
1117 };
1118 persistence: {
1119 getClientSettings: () => Promise<ClientSettings | null>;
1120 setClientSettings: (settings: ClientSettings) => Promise<void>;
1121 };
1123​
1124/**
1125 * APIs bound to a specific backend environment connection.
1127 * These operations must always be routed with explicit environment context.
1128 * They represent remote stateful capabilities such as orchestration, terminal,
1129 * project, VCS, and provider operations. In multi-environment mode, each environment gets
1130 * its own instance of this surface, and callers should resolve it by
1131 * `environmentId` rather than reaching through the local desktop bridge.
1132 */
1133export interface EnvironmentApi {
1134 terminal: {
1135 open: (input: typeof TerminalOpenInput.Encoded) => Promise<TerminalSessionSnapshot>;
1136 attach: (
1137 input: typeof TerminalAttachInput.Encoded,
1138 callback: (event: TerminalAttachStreamEvent) => void,
1139 options?: {
1140 onResubscribe?: () => void;
1141 },
1142 ) => () => void;
1143 write: (input: typeof TerminalWriteInput.Encoded) => Promise<void>;
1144 resize: (input: typeof TerminalResizeInput.Encoded) => Promise<void>;
1145 clear: (input: typeof TerminalClearInput.Encoded) => Promise<void>;
1146 restart: (input: typeof TerminalRestartInput.Encoded) => Promise<TerminalSessionSnapshot>;
1147 close: (input: typeof TerminalCloseInput.Encoded) => Promise<void>;
1148 onMetadata: (
1149 callback: (event: TerminalMetadataStreamEvent) => void,
1150 options?: {
1151 onResubscribe?: () => void;
1152 },
1153 ) => () => void;
1154 };
1155 projects: {
1156 listEntries: (input: ProjectListEntriesInput) => Promise<ProjectListEntriesResult>;
1157 readFile: (input: ProjectReadFileInput) => Promise<ProjectReadFileResult>;
1158 searchEntries: (input: ProjectSearchEntriesInput) => Promise<ProjectSearchEntriesResult>;
1159 writeFile: (input: ProjectWriteFileInput) => Promise<ProjectWriteFileResult>;
1160 };
1161 filesystem: {
1162 browse: (input: FilesystemBrowseInput) => Promise<FilesystemBrowseResult>;
1163 };
1164 assets: {
1165 createUrl: (input: AssetCreateUrlInput) => Promise<AssetCreateUrlResult>;
1166 };
1167 sourceControl: {
1168 lookupRepository: (
1169 input: SourceControlRepositoryLookupInput,
1170 ) => Promise<SourceControlRepositoryInfo>;
1171 cloneRepository: (
1172 input: SourceControlCloneRepositoryInput,
1173 ) => Promise<SourceControlCloneRepositoryResult>;
1174 publishRepository: (
1175 input: SourceControlPublishRepositoryInput,
1176 ) => Promise<SourceControlPublishRepositoryResult>;
1177 };
1178 vcs: {
1179 listRefs: (input: VcsListRefsInput) => Promise<VcsListRefsResult>;
1180 createWorktree: (input: VcsCreateWorktreeInput) => Promise<VcsCreateWorktreeResult>;
1181 removeWorktree: (input: VcsRemoveWorktreeInput) => Promise<void>;
1182 createRef: (input: VcsCreateRefInput) => Promise<VcsCreateRefResult>;
1183 switchRef: (input: VcsSwitchRefInput) => Promise<VcsSwitchRefResult>;
1184 init: (input: VcsInitInput) => Promise<void>;
1185 pull: (input: VcsPullInput) => Promise<VcsPullResult>;
1186 refreshStatus: (input: VcsStatusInput) => Promise<VcsStatusResult>;
1187 onStatus: (
1188 input: VcsStatusInput,
1189 callback: (status: VcsStatusResult) => void,
1190 options?: {
1191 onResubscribe?: () => void;
1192 onError?: (message: string) => void;
1193 },
1194 ) => () => void;
1195 };
1196 git: {
1197 resolvePullRequest: (input: GitPullRequestRefInput) => Promise<GitResolvePullRequestResult>;
1198 preparePullRequestThread: (
1199 input: GitPreparePullRequestThreadInput,
1200 ) => Promise<GitPreparePullRequestThreadResult>;
1201 };
1202 review: {
1203 getDiffPreview: (input: ReviewDiffPreviewInput) => Promise<ReviewDiffPreviewResult>;
1204 };
1205 orchestrationV2: {
1206 dispatchCommand: (
1207 command: OrchestrationV2Command,
1208 ) => Promise<OrchestrationV2DispatchCommandResult>;
1209 getThreadProjection: (
1210 input: OrchestrationV2GetThreadProjectionInput,
1211 ) => Promise<OrchestrationV2ThreadProjection>;
1212 subscribeShell: (
1213 callback: (event: OrchestrationV2ShellStreamItem) => void,
1214 options?: {
1215 onResubscribe?: () => void;
1216 onError?: (message: string) => void;
1217 },
1218 ) => () => void;
1219 subscribeThread: (
1220 input: OrchestrationV2GetThreadProjectionInput,
1221 callback: (event: OrchestrationV2ThreadStreamItem) => void,
1222 options?: {
1223 onResubscribe?: () => void;
1224 onError?: (message: string) => void;
1225 },
1226 ) => () => void;
1227 };
1228 preview: {
1229 open: (input: typeof PreviewOpenInput.Encoded) => Promise<PreviewSessionSnapshot>;
1230 navigate: (input: typeof PreviewNavigateInput.Encoded) => Promise<PreviewSessionSnapshot>;
1231 resize: (input: typeof PreviewResizeInput.Encoded) => Promise<PreviewSessionSnapshot>;
1232 refresh: (input: typeof PreviewRefreshInput.Encoded) => Promise<void>;
1233 close: (input: typeof PreviewCloseInput.Encoded) => Promise<void>;
1234 list: (input: typeof PreviewListInput.Encoded) => Promise<PreviewListResult>;
1235 reportStatus: (input: typeof PreviewReportStatusInput.Encoded) => Promise<void>;
1236 automation: {
1237 connect: (
1238 input: PreviewAutomationHost,
1239 callback: (event: PreviewAutomationStreamEvent) => void,
1240 options?: { onResubscribe?: () => void },
1241 ) => () => void;
1242 respond: (response: PreviewAutomationResponse) => Promise<void>;
1243 focusHost: (input: PreviewAutomationHostFocus) => Promise<void>;
1244 };
1245 onEvent: (
1246 callback: (event: PreviewEvent) => void,
1247 options?: { onResubscribe?: () => void },
1248 ) => () => void;
1249 subscribePorts: (
1250 callback: (servers: DiscoveredLocalServerList) => void,
1251 options?: { onResubscribe?: () => void },
1252 ) => () => void;
1253 };