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