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

ipc.ts

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