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