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

ipc.ts

1,330 lines44.7 KB

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