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