1import * as Schema from "effect/Schema";
2
3import { ProjectId, ThreadId, TrimmedNonEmptyString } from "./baseSchemas.ts";
4
5export const DESKTOP_APP_ACTIVATION_PROTOCOL_VERSION = 1 as const;
6
7export const DesktopAppActivationPlatform = Schema.Literals(["darwin", "linux", "win32"]);
8export type DesktopAppActivationPlatform = typeof DesktopAppActivationPlatform.Type;
9
10export 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});
17export type DesktopAppActivationRequest = typeof DesktopAppActivationRequest.Type;
18
19export 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]);
29export type DesktopAppActivationErrorCode = typeof DesktopAppActivationErrorCode.Type;
30
31export 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});
38export type DesktopAppActivationSuccess = typeof DesktopAppActivationSuccess.Type;
39
40export 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});
47export type DesktopAppActivationFailure = typeof DesktopAppActivationFailure.Type;
48
49export const DesktopAppActivationResponse = Schema.Union([
50 DesktopAppActivationSuccess,
51 DesktopAppActivationFailure,
52]);
53export type DesktopAppActivationResponse = typeof DesktopAppActivationResponse.Type;