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