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