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

ipc.ts

1,267 lines43.2 KB

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