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

ipc.ts

1,305 lines43.9 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​
443/**
444 * A file returned by the desktop theme-file picker. Oversized files carry an
445 * empty text so the renderer can reject them by size without the main
446 * process ever holding their contents.
447 */
448export interface PickedThemeFile {
449 name: string;
450 size: number;
451 text: string;
453​
454export const PickedThemeFileSchema = Schema.Struct({
455 name: Schema.String,
456 size: Schema.Number,
457 text: Schema.String,
458});
459​
460export interface DesktopWslDistro {
461 name: string;
462 isDefault: boolean;
463 version: 1 | 2;
465​
466export const DesktopWslDistroSchema = Schema.Struct({
467 name: Schema.String,
468 isDefault: Schema.Boolean,
469 version: Schema.Literals([1, 2]),
470});
471​
472export interface DesktopWslState {
473 // True when the user has opted the WSL backend in; the actual backend
474 // process is registered with the desktop pool independently of this
475 // flag and may take a moment to come up after the user enables it.
476 enabled: boolean;
477 // null means "track the current WSL default distro".
478 distro: string | null;
479 available: boolean;
480 // When true (and `enabled` is also true) the desktop runs only the
481 // WSL backend as the primary; the Windows-side Node backend is not
482 // started. Toggling this requires an app restart because the
483 // primary backend's spec is captured once at layer init.
484 wslOnly: boolean;
485 distros: readonly DesktopWslDistro[];
486 // Reason the dual-mode WSL backend last failed preflight (no node, wrong
487 // version, missing build tools), or null. Surfaced inline in Connections
488 // settings. Always null in wsl-only mode — that path shows a dialog and
489 // falls back to Windows instead.
490 preflightError: string | null;
492​
493export const DesktopWslStateSchema = Schema.Struct({
494 enabled: Schema.Boolean,
495 distro: Schema.NullOr(Schema.String),
496 available: Schema.Boolean,
497 wslOnly: Schema.Boolean,
498 distros: Schema.Array(DesktopWslDistroSchema),
499 preflightError: Schema.NullOr(Schema.String),
500});
501​
502/**
503 * Renderer-facing snapshot of a desktop preview tab. Mirrors the main-process
504 * PreviewTabState shape but uses serialisable primitives only.
505 */
506export type DesktopPreviewNavStatus =
507 | { kind: "Idle" }
508 | { kind: "Loading"; url: string; title: string }
509 | { kind: "Success"; url: string; title: string }
510 | {
511 kind: "LoadFailed";
512 url: string;
513 title: string;
514 code: number;
515 description: string;
516 };
517​
518/**
519 * Emulated `prefers-color-scheme` for the guest page. "system" clears the
520 * override so the page follows the OS appearance.
521 */
522export type DesktopPreviewColorScheme = "system" | "light" | "dark";
523​
524export const DesktopPreviewColorSchemeSchema: Schema.Codec<DesktopPreviewColorScheme> =
525 Schema.Literals(["system", "light", "dark"]);
526​
527export interface DesktopPreviewTabState {
528 tabId: string;
529 webContentsId: number | null;
530 navStatus: DesktopPreviewNavStatus;
531 canGoBack: boolean;
532 canGoForward: boolean;
533 /** Current zoom factor (1.0 = 100%). */
534 zoomFactor: number;
535 /** Whether this tab is currently mirrored into a desktop picture-in-picture window. */
536 pictureInPicture: boolean;
537 colorScheme: DesktopPreviewColorScheme;
538 controller: "human" | "agent" | "none";
539 updatedAt: string;
541​
542export const DesktopPreviewTabIdSchema = Schema.String.check(Schema.isTrimmed()).check(
543 Schema.isNonEmpty(),
544);
545​
546export const DesktopPreviewNavStatusSchema = Schema.Union([
547 Schema.Struct({ kind: Schema.Literal("Idle") }),
548 Schema.Struct({
549 kind: Schema.Literal("Loading"),
550 url: Schema.String,
551 title: Schema.String,
552 }),
553 Schema.Struct({
554 kind: Schema.Literal("Success"),
555 url: Schema.String,
556 title: Schema.String,
557 }),
558 Schema.Struct({
559 kind: Schema.Literal("LoadFailed"),
560 url: Schema.String,
561 title: Schema.String,
562 code: Schema.Number,
563 description: Schema.String,
564 }),
565]);
566​
567export const DesktopPreviewTabStateSchema: Schema.Codec<DesktopPreviewTabState> = Schema.Struct({
568 tabId: DesktopPreviewTabIdSchema,
569 webContentsId: Schema.NullOr(Schema.Int),
570 navStatus: DesktopPreviewNavStatusSchema,
571 canGoBack: Schema.Boolean,
572 canGoForward: Schema.Boolean,
573 zoomFactor: Schema.Number,
574 pictureInPicture: Schema.Boolean,
575 colorScheme: DesktopPreviewColorSchemeSchema,
576 controller: Schema.Literals(["human", "agent", "none"]),
577 updatedAt: Schema.String,
578});
579​
580export interface DesktopPreviewPointerEvent {
581 tabId: string;
582 phase: "move" | "click";
583 x: number;
584 y: number;
585 sequence: number;
586 createdAt: string;
588​
589export const DesktopPreviewPointerEventSchema: Schema.Codec<DesktopPreviewPointerEvent> =
590 Schema.Struct({
591 tabId: DesktopPreviewTabIdSchema,
592 phase: Schema.Literals(["move", "click"]),
593 x: Schema.Number,
594 y: Schema.Number,
595 sequence: Schema.Int,
596 createdAt: Schema.String,
597 });
598​
599/**
600 * Static config a renderer needs to mount a preview `<webview>`. Returned
601 * atomically by `DesktopPreviewBridge.getPreviewConfig()` so the renderer
602 * doesn't have to wait on three separate IPC round-trips before the webview
603 * can attach.
604 */
605export interface DesktopPreviewWebviewConfig {
606 /** `persist:t3code-preview` (or whatever the desktop chose). */
607 partition: string;
608 /**
609 * Canonical `<webview webpreferences="...">` string. Encodes the security
610 * posture (sandboxed but contextIsolation off so the picker preload can
611 * read the page's React DevTools hook). Always present.
612 */
613 webPreferences: string;
614 /**
615 * Absolute `file://`-style URL to the picker preload bundle. Set to null
616 * when the bundle isn't present (older builds, broken install) — the
617 * renderer must then disable element-pick affordances.
618 */
619 preloadUrl: string | null;
621​
622export const DesktopPreviewWebviewConfigSchema: Schema.Codec<DesktopPreviewWebviewConfig> =
623 Schema.Struct({
624 partition: Schema.String,
625 webPreferences: Schema.String,
626 preloadUrl: Schema.NullOr(Schema.String),
627 });
628​
629export interface DesktopPreviewAnnotationTheme {
630 colorScheme: "light" | "dark";
631 radius: string;
632 background: string;
633 foreground: string;
634 popover: string;
635 popoverForeground: string;
636 primary: string;
637 primaryForeground: string;
638 muted: string;
639 mutedForeground: string;
640 accent: string;
641 accentForeground: string;
642 border: string;
643 input: string;
644 ring: string;
645 fontSans: string;
646 fontMono: string;
648​
649export const DesktopPreviewAnnotationThemeSchema: Schema.Codec<DesktopPreviewAnnotationTheme> =
650 Schema.Struct({
651 colorScheme: Schema.Literals(["light", "dark"]),
652 radius: Schema.String,
653 background: Schema.String,
654 foreground: Schema.String,
655 popover: Schema.String,
656 popoverForeground: Schema.String,
657 primary: Schema.String,
658 primaryForeground: Schema.String,
659 muted: Schema.String,
660 mutedForeground: Schema.String,
661 accent: Schema.String,
662 accentForeground: Schema.String,
663 border: Schema.String,
664 input: Schema.String,
665 ring: Schema.String,
666 fontSans: Schema.String,
667 fontMono: Schema.String,
668 });
669​
670export interface DesktopPreviewRecordingFrame {
671 tabId: string;
672 data: string;
673 width: number;
674 height: number;
675 receivedAt: string;
677​
678export const DesktopPreviewRecordingFrameSchema: Schema.Codec<DesktopPreviewRecordingFrame> =
679 Schema.Struct({
680 tabId: DesktopPreviewTabIdSchema,
681 data: Schema.String,
682 width: Schema.Number,
683 height: Schema.Number,
684 receivedAt: Schema.String,
685 });
686​
687export interface DesktopPreviewRecordingArtifact {
688 id: string;
689 tabId: string;
690 path: string;
691 mimeType: string;
692 sizeBytes: number;
693 createdAt: string;
695​
696export const DesktopPreviewRecordingArtifactSchema: Schema.Codec<DesktopPreviewRecordingArtifact> =
697 Schema.Struct({
698 id: Schema.String,
699 tabId: DesktopPreviewTabIdSchema,
700 path: Schema.String,
701 mimeType: Schema.String,
702 sizeBytes: Schema.Int,
703 createdAt: Schema.String,
704 });
705​
706export interface DesktopPreviewScreenshotArtifact {
707 id: string;
708 tabId: string;
709 path: string;
710 mimeType: "image/png";
711 sizeBytes: number;
712 createdAt: string;
714​
715export const DesktopPreviewScreenshotArtifactSchema: Schema.Codec<DesktopPreviewScreenshotArtifact> =
716 Schema.Struct({
717 id: Schema.String,
718 tabId: DesktopPreviewTabIdSchema,
719 path: Schema.String,
720 mimeType: Schema.Literal("image/png"),
721 sizeBytes: Schema.Int,
722 createdAt: Schema.String,
723 });
724​
725/**
726 * Single stack frame captured by react-grab's `getElementContext`. We surface
727 * the source file/line so coding agents can jump straight to the JSX that
728 * produced the picked DOM node.
729 */
730export interface PickedElementStackFrame {
731 functionName: string | null;
732 fileName: string | null;
733 lineNumber: number | null;
734 columnNumber: number | null;
736​
737export const PickedElementStackFrameSchema: Schema.Codec<PickedElementStackFrame> = Schema.Struct({
738 functionName: Schema.NullOr(Schema.String),
739 fileName: Schema.NullOr(Schema.String),
740 lineNumber: Schema.NullOr(Schema.Number),
741 columnNumber: Schema.NullOr(Schema.Number),
742});
743​
744/**
745 * A successful element pick from the preview webview. All fields are
746 * best-effort — pages that don't ship a React fiber tree (or aren't running
747 * in dev) will still produce a usable payload (selector + html preview),
748 * just without component / source attribution.
749 */
750export interface PickedElementPayload {
751 /** URL of the page the element was picked on. */
752 pageUrl: string;
753 /** Optional `<title>` of that page (best-effort). */
754 pageTitle: string | null;
755 /** Lowercase tag name, e.g. `"button"`. */
756 tagName: string;
757 /** CSS selector resolving back to the element on a re-render. */
758 selector: string | null;
759 /** Truncated outer-HTML preview (matches react-grab's `htmlPreview`). */
760 htmlPreview: string;
761 /** Nearest React component display name, or null when unavailable. */
762 componentName: string | null;
763 /** First source-mapped stack frame (file + line of the JSX source). */
764 source: PickedElementStackFrame | null;
765 /** Full owner-stack frames; can be empty. Useful for richer context. */
766 stack: ReadonlyArray<PickedElementStackFrame>;
767 /** Author CSS only (UA defaults stripped) — react-grab's `styles`. */
768 styles: string;
769 /** Wall-clock pick time as ISO-8601 string. */
770 pickedAt: string;
772​
773export const PickedElementPayloadSchema: Schema.Codec<PickedElementPayload> = Schema.Struct({
774 pageUrl: Schema.String,
775 pageTitle: Schema.NullOr(Schema.String),
776 tagName: Schema.String,
777 selector: Schema.NullOr(Schema.String),
778 htmlPreview: Schema.String,
779 componentName: Schema.NullOr(Schema.String),
780 source: Schema.NullOr(PickedElementStackFrameSchema),
781 stack: Schema.Array(PickedElementStackFrameSchema),
782 styles: Schema.String,
783 pickedAt: Schema.String,
784});
785​
786export interface PreviewAnnotationRect {
787 x: number;
788 y: number;
789 width: number;
790 height: number;
792​
793export const PreviewAnnotationRectSchema: Schema.Codec<PreviewAnnotationRect> = Schema.Struct({
794 x: Schema.Number,
795 y: Schema.Number,
796 width: Schema.Number,
797 height: Schema.Number,
798});
799​
800export interface PreviewAnnotationPoint {
801 x: number;
802 y: number;
804​
805export const PreviewAnnotationPointSchema: Schema.Codec<PreviewAnnotationPoint> = Schema.Struct({
806 x: Schema.Number,
807 y: Schema.Number,
808});
809​
810export interface PreviewAnnotationElementTarget {
811 id: string;
812 element: PickedElementPayload;
813 rect: PreviewAnnotationRect;
815​
816export const PreviewAnnotationElementTargetSchema: Schema.Codec<PreviewAnnotationElementTarget> =
817 Schema.Struct({
818 id: Schema.String,
819 element: PickedElementPayloadSchema,
820 rect: PreviewAnnotationRectSchema,
821 });
822​
823export interface PreviewAnnotationRegionTarget {
824 id: string;
825 rect: PreviewAnnotationRect;
827​
828export const PreviewAnnotationRegionTargetSchema: Schema.Codec<PreviewAnnotationRegionTarget> =
829 Schema.Struct({
830 id: Schema.String,
831 rect: PreviewAnnotationRectSchema,
832 });
833​
834export interface PreviewAnnotationStrokeTarget {
835 id: string;
836 color: string;
837 width: number;
838 points: ReadonlyArray<PreviewAnnotationPoint>;
839 bounds: PreviewAnnotationRect;
841​
842export const PreviewAnnotationStrokeTargetSchema: Schema.Codec<PreviewAnnotationStrokeTarget> =
843 Schema.Struct({
844 id: Schema.String,
845 color: Schema.String,
846 width: Schema.Number,
847 points: Schema.Array(PreviewAnnotationPointSchema),
848 bounds: PreviewAnnotationRectSchema,
849 });
850​
851export interface PreviewAnnotationStyleChange {
852 targetId: string;
853 selector: string | null;
854 property: string;
855 previousValue: string;
856 value: string;
858​
859export const PreviewAnnotationStyleChangeSchema: Schema.Codec<PreviewAnnotationStyleChange> =
860 Schema.Struct({
861 targetId: Schema.String,
862 selector: Schema.NullOr(Schema.String),
863 property: Schema.String,
864 previousValue: Schema.String,
865 value: Schema.String,
866 });
867​
868export interface PreviewAnnotationScreenshot {
869 dataUrl: string;
870 width: number;
871 height: number;
872 cropRect: PreviewAnnotationRect;
874​
875export const PreviewAnnotationScreenshotSchema: Schema.Codec<PreviewAnnotationScreenshot> =
876 Schema.Struct({
877 dataUrl: Schema.String,
878 width: Schema.Number,
879 height: Schema.Number,
880 cropRect: PreviewAnnotationRectSchema,
881 });
882​
883/**
884 * A submitted preview annotation. One annotation may reference multiple DOM
885 * elements, freeform regions, and ink strokes. The desktop main process adds
886 * the screenshot after the guest preload submits the structured draft.
887 */
888export interface PreviewAnnotationPayload {
889 id: string;
890 pageUrl: string;
891 pageTitle: string | null;
892 comment: string;
893 elements: ReadonlyArray<PreviewAnnotationElementTarget>;
894 regions: ReadonlyArray<PreviewAnnotationRegionTarget>;
895 strokes: ReadonlyArray<PreviewAnnotationStrokeTarget>;
896 styleChanges: ReadonlyArray<PreviewAnnotationStyleChange>;
897 screenshot: PreviewAnnotationScreenshot | null;
898 createdAt: string;
900​
901export const PreviewAnnotationPayloadSchema: Schema.Codec<PreviewAnnotationPayload> = Schema.Struct(
902 {
903 id: Schema.String,
904 pageUrl: Schema.String,
905 pageTitle: Schema.NullOr(Schema.String),
906 comment: Schema.String,
907 elements: Schema.Array(PreviewAnnotationElementTargetSchema),
908 regions: Schema.Array(PreviewAnnotationRegionTargetSchema),
909 strokes: Schema.Array(PreviewAnnotationStrokeTargetSchema),
910 styleChanges: Schema.Array(PreviewAnnotationStyleChangeSchema),
911 screenshot: Schema.NullOr(PreviewAnnotationScreenshotSchema),
912 createdAt: Schema.String,
913 },
914);
915​
916export type PreviewAnnotationSubmission = "attach" | "send";
917export const PreviewAnnotationSubmissionSchema: Schema.Codec<PreviewAnnotationSubmission> =
918 Schema.Literals(["attach", "send"]);
919​
920export interface PreviewAnnotationSubmissionResult {
921 annotation: PreviewAnnotationPayload;
922 submission: PreviewAnnotationSubmission;
924export const PreviewAnnotationSubmissionResultSchema: Schema.Codec<PreviewAnnotationSubmissionResult> =
925 Schema.Struct({
926 annotation: PreviewAnnotationPayloadSchema,
927 submission: PreviewAnnotationSubmissionSchema,
928 });
929​
930export const DesktopPreviewTabInputSchema = Schema.Struct({
931 tabId: DesktopPreviewTabIdSchema,
932});
933​
934export const DesktopPreviewRegisterWebviewInputSchema = Schema.Struct({
935 tabId: DesktopPreviewTabIdSchema,
936 webContentsId: Schema.Int.check(Schema.isGreaterThan(0)),
937});
938​
939export const DesktopPreviewNavigateInputSchema = Schema.Struct({
940 tabId: DesktopPreviewTabIdSchema,
941 url: Schema.String,
942});
943​
944export const DesktopPreviewConfigInputSchema = Schema.Struct({
945 environmentId: EnvironmentId,
946});
947​
948export const DesktopPreviewSetColorSchemeInputSchema = Schema.Struct({
949 tabId: DesktopPreviewTabIdSchema,
950 colorScheme: DesktopPreviewColorSchemeSchema,
951});
952​
953export const DesktopPreviewAnnotationThemeInputSchema = Schema.Struct({
954 theme: DesktopPreviewAnnotationThemeSchema,
955});
956​
957export const DesktopPreviewArtifactInputSchema = Schema.Struct({
958 path: Schema.String.check(Schema.isTrimmed()).check(Schema.isNonEmpty()),
959});
960​
961export const DesktopPreviewRecordingSaveInputSchema = Schema.Struct({
962 tabId: DesktopPreviewTabIdSchema,
963 mimeType: Schema.String.check(Schema.isTrimmed()).check(Schema.isNonEmpty()),
964 data: Schema.Uint8Array,
965});
966​
967export const DesktopPreviewAutomationClickInputSchema = Schema.Struct({
968 tabId: DesktopPreviewTabIdSchema,
969 input: PreviewAutomationClickInput,
970});
971​
972export const DesktopPreviewAutomationTypeInputSchema = Schema.Struct({
973 tabId: DesktopPreviewTabIdSchema,
974 input: PreviewAutomationTypeInput,
975});
976​
977export const DesktopPreviewAutomationPressInputSchema = Schema.Struct({
978 tabId: DesktopPreviewTabIdSchema,
979 input: PreviewAutomationPressInput,
980});
981​
982export const DesktopPreviewAutomationScrollInputSchema = Schema.Struct({
983 tabId: DesktopPreviewTabIdSchema,
984 input: PreviewAutomationScrollInput,
985});
986​
987export const DesktopPreviewAutomationEvaluateInputSchema = Schema.Struct({
988 tabId: DesktopPreviewTabIdSchema,
989 input: PreviewAutomationEvaluateInput,
990});
991​
992export const DesktopPreviewAutomationWaitForInputSchema = Schema.Struct({
993 tabId: DesktopPreviewTabIdSchema,
994 input: PreviewAutomationWaitForInput,
995});
996​
997export interface DesktopBridge {
998 getAppBranding: () => DesktopAppBranding | null;
999 // One bootstrap per pool instance currently registered with bootstrap
1000 // info (omits instances whose backend hasn't produced a config yet).
1001 // The primary backend is identified by id === PRIMARY_LOCAL_ENVIRONMENT_ID.
1002 getLocalEnvironmentBootstraps: () => readonly DesktopEnvironmentBootstrap[];
1003 getLocalEnvironmentBearerToken: () => Promise<string>;
1004 getClientSettings: () => Promise<ClientSettings | null>;
1005 setClientSettings: (settings: ClientSettings) => Promise<void>;
1006 getConnectionCatalog?: () => Promise<string | null>;
1007 setConnectionCatalog?: (catalog: string) => Promise<boolean>;
1008 clearConnectionCatalog?: () => Promise<void>;
1009 discoverSshHosts: () => Promise<readonly DesktopDiscoveredSshHost[]>;
1010 ensureSshEnvironment: (
1011 target: DesktopSshEnvironmentTarget,
1012 options?: { issuePairingToken?: boolean },
1013 ) => Promise<DesktopSshEnvironmentBootstrap>;
1014 disconnectSshEnvironment: (target: DesktopSshEnvironmentTarget) => Promise<void>;
1015 fetchSshEnvironmentDescriptor: (httpBaseUrl: string) => Promise<ExecutionEnvironmentDescriptor>;
1016 bootstrapSshBearerSession: (
1017 httpBaseUrl: string,
1018 credential: string,
1019 ) => Promise<AuthAccessTokenResult>;
1020 fetchSshSessionState: (httpBaseUrl: string, bearerToken: string) => Promise<AuthSessionState>;
1021 issueSshWebSocketTicket: (
1022 httpBaseUrl: string,
1023 bearerToken: string,
1024 ) => Promise<AuthWebSocketTicketResult>;
1025 onSshPasswordPrompt: (listener: (request: DesktopSshPasswordPromptRequest) => void) => () => void;
1026 resolveSshPasswordPrompt: (requestId: string, password: string | null) => Promise<void>;
1027 getServerExposureState: () => Promise<DesktopServerExposureState>;
1028 setServerExposureMode: (mode: DesktopServerExposureMode) => Promise<DesktopServerExposureState>;
1029 setTailscaleServeEnabled: (input: {
1030 readonly enabled: boolean;
1031 readonly port?: number;
1032 }) => Promise<DesktopServerExposureState>;
1033 getAdvertisedEndpoints: () => Promise<readonly AdvertisedEndpoint[]>;
1034 getWslState: () => Promise<DesktopWslState>;
1035 setWslBackendEnabled: (enabled: boolean) => Promise<DesktopWslState>;
1036 setWslDistro: (distro: string | null) => Promise<DesktopWslState>;
1037 setWslOnly: (enabled: boolean) => Promise<DesktopWslState>;
1038 pickFolder: (options?: PickFolderOptions) => Promise<string | null>;
1039 /**
1040 * Multi-select JSON file picker that opens in the VS Code extensions
1041 * directory when one exists. Optional: older desktop builds lack it, and
1042 * web callers fall back to a plain file input.
1043 */
1044 pickThemeFiles?: () => Promise<readonly PickedThemeFile[] | null>;
1045 setTheme: (theme: DesktopTheme) => Promise<void>;
1046 showContextMenu: <T extends string>(
1047 items: readonly ContextMenuItem<T>[],
1048 position?: { x: number; y: number },
1049 ) => Promise<T | null>;
1050 openExternal: (url: string) => Promise<boolean>;
1051 onMenuAction: (listener: (action: string) => void) => () => void;
1052 getWindowFullscreenState: () => boolean;
1053 onWindowFullscreenStateChange: (listener: (fullscreen: boolean) => void) => () => void;
1054 getUpdateState: () => Promise<DesktopUpdateState>;
1055 setUpdateChannel: (channel: DesktopUpdateChannel) => Promise<DesktopUpdateState>;
1056 checkForUpdate: () => Promise<DesktopUpdateCheckResult>;
1057 downloadUpdate: () => Promise<DesktopUpdateActionResult>;
1058 installUpdate: () => Promise<DesktopUpdateActionResult>;
1059 onUpdateState: (listener: (state: DesktopUpdateState) => void) => () => void;
1060 /**
1061 * Desktop-only preview surface. Present iff the renderer is hosted by the
1062 * Electron desktop build; web builds have `preview === undefined`.
1063 */
1064 preview?: DesktopPreviewBridge;
1066​
1067export interface DesktopPreviewBridge {
1068 createTab: (tabId: string) => Promise<void>;
1069 closeTab: (tabId: string) => Promise<void>;
1070 registerWebview: (tabId: string, webContentsId: number) => Promise<void>;
1071 navigate: (tabId: string, url: string) => Promise<void>;
1072 goBack: (tabId: string) => Promise<void>;
1073 goForward: (tabId: string) => Promise<void>;
1074 refresh: (tabId: string) => Promise<void>;
1075 zoomIn: (tabId: string) => Promise<void>;
1076 zoomOut: (tabId: string) => Promise<void>;
1077 resetZoom: (tabId: string) => Promise<void>;
1078 /** Reload bypassing the HTTP cache. */
1079 hardReload: (tabId: string) => Promise<void>;
1080 /**
1081 * Emulate `prefers-color-scheme` on the guest page ("system" clears the
1082 * override). Persists per tab and is re-applied across webview swaps.
1083 */
1084 setColorScheme: (tabId: string, colorScheme: DesktopPreviewColorScheme) => Promise<void>;
1085 /** Open the guest webview's DevTools (detached). */
1086 openDevTools: (tabId: string) => Promise<void>;
1087 /** Drop cookies + storage data for the preview partition (all tabs). */
1088 clearCookies: () => Promise<void>;
1089 /** Drop the HTTP cache for the preview partition (all tabs). */
1090 clearCache: () => Promise<void>;
1091 /**
1092 * One-shot config for mounting a preview `<webview>`. Replaces three
1093 * earlier round-trip calls (`getBrowserPartition`, `getWebviewPreferences`,
1094 * `getPickPreloadPath`) so adding a new field here only requires touching
1095 * the contract + main, not the renderer's mount logic.
1096 */
1097 getPreviewConfig: (environmentId: EnvironmentId) => Promise<DesktopPreviewWebviewConfig>;
1098 setAnnotationTheme: (theme: DesktopPreviewAnnotationTheme) => Promise<void>;
1099 /**
1100 * Activate the in-page element picker for the given tab. Resolves with
1101 * the picked annotation and its attach/send intent, or `null` when the
1102 * user cancels (Escape / nav). The promise rejects if the picker can't be
1103 * activated (no webview, etc.).
1104 */
1105 pickElement: (tabId: string) => Promise<PreviewAnnotationSubmissionResult | null>;
1106 /** Cancel an in-flight preview annotation session. */
1107 cancelPickElement: (tabId: string) => Promise<void>;
1108 captureScreenshot: (tabId: string) => Promise<DesktopPreviewScreenshotArtifact>;
1109 revealArtifact: (path: string) => Promise<void>;
1110 copyArtifactToClipboard: (path: string) => Promise<void>;
1111 pictureInPicture: {
1112 open: (tabId: string) => Promise<void>;
1113 close: (tabId: string) => Promise<void>;
1114 };
1115 recording: {
1116 startScreencast: (tabId: string) => Promise<void>;
1117 stopScreencast: (tabId: string) => Promise<void>;
1118 save: (
1119 tabId: string,
1120 mimeType: string,
1121 data: Uint8Array,
1122 ) => Promise<DesktopPreviewRecordingArtifact>;
1123 onFrame: (listener: (frame: DesktopPreviewRecordingFrame) => void) => () => void;
1124 };
1125 automation: {
1126 status: (tabId: string) => Promise<PreviewAutomationStatus>;
1127 snapshot: (tabId: string) => Promise<PreviewAutomationSnapshot>;
1128 click: (tabId: string, input: PreviewAutomationClickInput) => Promise<void>;
1129 type: (tabId: string, input: PreviewAutomationTypeInput) => Promise<void>;
1130 press: (tabId: string, input: PreviewAutomationPressInput) => Promise<void>;
1131 scroll: (tabId: string, input: PreviewAutomationScrollInput) => Promise<void>;
1132 evaluate: (tabId: string, input: PreviewAutomationEvaluateInput) => Promise<unknown>;
1133 waitFor: (tabId: string, input: PreviewAutomationWaitForInput) => Promise<void>;
1134 };
1135 onStateChange: (listener: (tabId: string, state: DesktopPreviewTabState) => void) => () => void;
1136 onPointerEvent: (listener: (event: DesktopPreviewPointerEvent) => void) => () => void;
1138​
1139export type ConfirmDialogVariant = "default" | "destructive";
1140​
1141export interface ConfirmDialogOptions {
1142 readonly variant?: ConfirmDialogVariant;
1144​
1145/**
1146 * APIs bound to the local app shell, not to any particular backend environment.
1148 * These capabilities describe the desktop/browser host that the user is
1149 * currently running: dialogs, external-link opening, context menus, and
1150 * app-level settings/config access. They must not be used as a proxy for
1151 * "whatever environment the user is targeting", because in a multi-environment
1152 * world the local shell and a selected backend environment are distinct
1153 * concepts.
1154 */
1155export interface LocalApi {
1156 dialogs: {
1157 pickFolder: (options?: PickFolderOptions) => Promise<string | null>;
1158 confirm: (message: string, options?: ConfirmDialogOptions) => Promise<boolean>;
1159 };
1160 shell: {
1161 openExternal: (url: string) => Promise<void>;
1162 };
1163 contextMenu: {
1164 show: <T extends string>(
1165 items: readonly ContextMenuItem<T>[],
1166 position?: { x: number; y: number },
1167 ) => Promise<T | null>;
1168 };
1169 persistence: {
1170 getClientSettings: () => Promise<ClientSettings | null>;
1171 setClientSettings: (settings: ClientSettings) => Promise<void>;
1172 };
1174​
1175/**
1176 * APIs bound to a specific backend environment connection.
1178 * These operations must always be routed with explicit environment context.
1179 * They represent remote stateful capabilities such as orchestration, terminal,
1180 * project, VCS, and provider operations. In multi-environment mode, each environment gets
1181 * its own instance of this surface, and callers should resolve it by
1182 * `environmentId` rather than reaching through the local desktop bridge.
1183 */
1184export interface EnvironmentApi {
1185 terminal: {
1186 open: (input: typeof TerminalOpenInput.Encoded) => Promise<TerminalSessionSnapshot>;
1187 attach: (
1188 input: typeof TerminalAttachInput.Encoded,
1189 callback: (event: TerminalAttachStreamEvent) => void,
1190 options?: {
1191 onResubscribe?: () => void;
1192 },
1193 ) => () => void;
1194 write: (input: typeof TerminalWriteInput.Encoded) => Promise<void>;
1195 resize: (input: typeof TerminalResizeInput.Encoded) => Promise<void>;
1196 clear: (input: typeof TerminalClearInput.Encoded) => Promise<void>;
1197 restart: (input: typeof TerminalRestartInput.Encoded) => Promise<TerminalSessionSnapshot>;
1198 close: (input: typeof TerminalCloseInput.Encoded) => Promise<void>;
1199 onMetadata: (
1200 callback: (event: TerminalMetadataStreamEvent) => void,
1201 options?: {
1202 onResubscribe?: () => void;
1203 },
1204 ) => () => void;
1205 };
1206 projects: {
1207 listEntries: (input: ProjectListEntriesInput) => Promise<ProjectListEntriesResult>;
1208 readFile: (input: ProjectReadFileInput) => Promise<ProjectReadFileResult>;
1209 searchEntries: (input: ProjectSearchEntriesInput) => Promise<ProjectSearchEntriesResult>;
1210 writeFile: (input: ProjectWriteFileInput) => Promise<ProjectWriteFileResult>;
1211 };
1212 filesystem: {
1213 browse: (input: FilesystemBrowseInput) => Promise<FilesystemBrowseResult>;
1214 };
1215 assets: {
1216 createUrl: (input: AssetCreateUrlInput) => Promise<AssetCreateUrlResult>;
1217 };
1218 sourceControl: {
1219 lookupRepository: (
1220 input: SourceControlRepositoryLookupInput,
1221 ) => Promise<SourceControlRepositoryInfo>;
1222 cloneRepository: (
1223 input: SourceControlCloneRepositoryInput,
1224 ) => Promise<SourceControlCloneRepositoryResult>;
1225 publishRepository: (
1226 input: SourceControlPublishRepositoryInput,
1227 ) => Promise<SourceControlPublishRepositoryResult>;
1228 };
1229 vcs: {
1230 listRefs: (input: VcsListRefsInput) => Promise<VcsListRefsResult>;
1231 createWorktree: (input: VcsCreateWorktreeInput) => Promise<VcsCreateWorktreeResult>;
1232 removeWorktree: (input: VcsRemoveWorktreeInput) => Promise<void>;
1233 createRef: (input: VcsCreateRefInput) => Promise<VcsCreateRefResult>;
1234 switchRef: (input: VcsSwitchRefInput) => Promise<VcsSwitchRefResult>;
1235 init: (input: VcsInitInput) => Promise<void>;
1236 pull: (input: VcsPullInput) => Promise<VcsPullResult>;
1237 refreshStatus: (input: VcsStatusInput) => Promise<VcsStatusResult>;
1238 onStatus: (
1239 input: VcsStatusInput,
1240 callback: (status: VcsStatusResult) => void,
1241 options?: {
1242 onResubscribe?: () => void;
1243 },
1244 ) => () => void;
1245 };
1246 git: {
1247 resolvePullRequest: (input: GitPullRequestRefInput) => Promise<GitResolvePullRequestResult>;
1248 preparePullRequestThread: (
1249 input: GitPreparePullRequestThreadInput,
1250 ) => Promise<GitPreparePullRequestThreadResult>;
1251 };
1252 review: {
1253 getDiffPreview: (input: ReviewDiffPreviewInput) => Promise<ReviewDiffPreviewResult>;
1254 getDiffFileContents: (
1255 input: ReviewDiffFileContentsInput,
1256 ) => Promise<ReviewDiffFileContentsResult>;
1257 };
1258 orchestration: {
1259 dispatchCommand: (command: ClientOrchestrationCommand) => Promise<{ sequence: number }>;
1260 getTurnDiff: (input: OrchestrationGetTurnDiffInput) => Promise<OrchestrationGetTurnDiffResult>;
1261 getFullThreadDiff: (
1262 input: OrchestrationGetFullThreadDiffInput,
1263 ) => Promise<OrchestrationGetFullThreadDiffResult>;
1264 getArchivedShellSnapshot: () => Promise<OrchestrationShellSnapshot>;
1265 subscribeShell: (
1266 callback: (event: OrchestrationShellStreamItem) => void,
1267 options?: {
1268 onResubscribe?: () => void;
1269 },
1270 ) => () => void;
1271 subscribeThread: (
1272 input: OrchestrationSubscribeThreadInput,
1273 callback: (event: OrchestrationThreadStreamItem) => void,
1274 options?: {
1275 onResubscribe?: () => void;
1276 },
1277 ) => () => void;
1278 };
1279 preview: {
1280 open: (input: typeof PreviewOpenInput.Encoded) => Promise<PreviewSessionSnapshot>;
1281 navigate: (input: typeof PreviewNavigateInput.Encoded) => Promise<PreviewSessionSnapshot>;
1282 resize: (input: typeof PreviewResizeInput.Encoded) => Promise<PreviewSessionSnapshot>;
1283 refresh: (input: typeof PreviewRefreshInput.Encoded) => Promise<void>;
1284 close: (input: typeof PreviewCloseInput.Encoded) => Promise<void>;
1285 list: (input: typeof PreviewListInput.Encoded) => Promise<PreviewListResult>;
1286 reportStatus: (input: typeof PreviewReportStatusInput.Encoded) => Promise<void>;
1287 automation: {
1288 connect: (
1289 input: PreviewAutomationHost,
1290 callback: (event: PreviewAutomationStreamEvent) => void,
1291 options?: { onResubscribe?: () => void },
1292 ) => () => void;
1293 respond: (response: PreviewAutomationResponse) => Promise<void>;
1294 focusHost: (input: PreviewAutomationHostFocus) => Promise<void>;
1295 };
1296 onEvent: (
1297 callback: (event: PreviewEvent) => void,
1298 options?: { onResubscribe?: () => void },
1299 ) => () => void;
1300 subscribePorts: (
1301 callback: (servers: DiscoveredLocalServerList) => void,
1302 options?: { onResubscribe?: () => void },
1303 ) => () => void;
1304 };