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

desktopBootstrap.ts

40 lines1.9 KB

1import * as Schema from "effect/Schema";
2​
3import { PortSchema, PositiveInt, TrimmedNonEmptyString } from "./baseSchemas.ts";
4​
5export const DesktopBackendBootstrap = Schema.Struct({
6 mode: Schema.Literal("desktop"),
7 noBrowser: Schema.Boolean,
8 port: PortSchema,
9 // Omitted when the desktop launches the backend inside WSL, since the
10 // Windows-side baseDir maps to /mnt/c/... and the Linux side should use its
11 // own home directory instead.
12 t3Home: Schema.optional(Schema.String),
13 host: Schema.String,
14 desktopBootstrapToken: Schema.String,
15 // Present when the desktop rotates the renderer's bootstrap token: the
16 // backend derives the accepted tokens from this secret instead of trusting
17 // `desktopBootstrapToken` for its whole run. See
18 // `@t3tools/shared/desktopBootstrapToken`.
19 desktopBootstrapSecret: Schema.optionalKey(Schema.String),
20 tailscaleServeEnabled: Schema.Boolean,
21 tailscaleServePort: PortSchema,
22 otlpTracesUrl: Schema.optional(Schema.String),
23 otlpMetricsUrl: Schema.optional(Schema.String),
24 otlpLogsUrl: Schema.optional(Schema.String),
25 desktopTelemetryFd: Schema.optionalKey(PositiveInt),
26 desktopTelemetryControlFd: Schema.optionalKey(PositiveInt),
27 /** Desktop -> server: the desktop's browser tabs, as newline-delimited JSON. */
28 desktopBrowserFd: Schema.optionalKey(PositiveInt),
29 /** Server -> desktop: commands for those tabs. */
30 desktopBrowserControlFd: Schema.optionalKey(PositiveInt),
31 resourceMonitorPath: Schema.optionalKey(TrimmedNonEmptyString),
32});
33​
34export type DesktopBackendBootstrap = typeof DesktopBackendBootstrap.Type;
35​
36/** Written to `<t3Home>/runtime` just before the desktop app stops its
37 backend to install an update. The updated app starts a new backend right
38 away, so a backend that sees a fresh marker at shutdown keeps its managed
39 tunnel. */
40export const DESKTOP_UPDATE_RESTART_MARKER_FILE = "desktop-update-restart";