| 1 | import * as Schema from "effect/Schema"; |
| 2 | |
| 3 | import { ProjectId, ThreadId, TrimmedNonEmptyString } from "./baseSchemas.ts"; |
| 4 | |
| 5 | export const DESKTOP_APP_ACTIVATION_PROTOCOL_VERSION = 1 as const; |
| 6 | |
| 7 | export const DesktopAppActivationPlatform = Schema.Literals(["darwin", "linux", "win32"]); |
| 8 | export type DesktopAppActivationPlatform = typeof DesktopAppActivationPlatform.Type; |
| 9 | |
| 10 | export const DesktopAppActivationRequest = Schema.Struct({ |
| 11 | version: Schema.Literal(DESKTOP_APP_ACTIVATION_PROTOCOL_VERSION), |
| 12 | requestId: TrimmedNonEmptyString, |
| 13 | type: Schema.Literal("open-workspace"), |
| 14 | workspaceRoot: TrimmedNonEmptyString, |
| 15 | platform: DesktopAppActivationPlatform, |
| 16 | }); |
| 17 | export type DesktopAppActivationRequest = typeof DesktopAppActivationRequest.Type; |
| 18 | |
| 19 | export const DesktopAppActivationErrorCode = Schema.Literals([ |
| 20 | "invalid-request", |
| 21 | "renderer-unavailable", |
| 22 | "environment-unavailable", |
| 23 | "platform-mismatch", |
| 24 | "project-create-failed", |
| 25 | "thread-open-failed", |
| 26 | "request-timeout", |
| 27 | "internal-error", |
| 28 | ]); |
| 29 | export type DesktopAppActivationErrorCode = typeof DesktopAppActivationErrorCode.Type; |
| 30 | |
| 31 | export const DesktopAppActivationSuccess = Schema.Struct({ |
| 32 | version: Schema.Literal(DESKTOP_APP_ACTIVATION_PROTOCOL_VERSION), |
| 33 | requestId: TrimmedNonEmptyString, |
| 34 | ok: Schema.Literal(true), |
| 35 | projectId: ProjectId, |
| 36 | threadId: ThreadId, |
| 37 | }); |
| 38 | export type DesktopAppActivationSuccess = typeof DesktopAppActivationSuccess.Type; |
| 39 | |
| 40 | export const DesktopAppActivationFailure = Schema.Struct({ |
| 41 | version: Schema.Literal(DESKTOP_APP_ACTIVATION_PROTOCOL_VERSION), |
| 42 | requestId: TrimmedNonEmptyString, |
| 43 | ok: Schema.Literal(false), |
| 44 | code: DesktopAppActivationErrorCode, |
| 45 | message: TrimmedNonEmptyString, |
| 46 | }); |
| 47 | export type DesktopAppActivationFailure = typeof DesktopAppActivationFailure.Type; |
| 48 | |
| 49 | export const DesktopAppActivationResponse = Schema.Union([ |
| 50 | DesktopAppActivationSuccess, |
| 51 | DesktopAppActivationFailure, |
| 52 | ]); |
| 53 | export type DesktopAppActivationResponse = typeof DesktopAppActivationResponse.Type; |