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

ipc.ts

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