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

ipc.ts

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