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

desktopBootstrap.ts

44 lines2.1 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 // Set only when the desktop already merged the user's shell environment into
21 // the environment it hands this backend. Absent means the backend hydrates
22 // PATH itself, which WSL and older desktops rely on.
23 shellEnvironmentPrepared: Schema.optionalKey(Schema.Boolean),
24 tailscaleServeEnabled: Schema.Boolean,
25 tailscaleServePort: PortSchema,
26 otlpTracesUrl: Schema.optional(Schema.String),
27 otlpMetricsUrl: Schema.optional(Schema.String),
28 otlpLogsUrl: Schema.optional(Schema.String),
29 desktopTelemetryFd: Schema.optionalKey(PositiveInt),
30 desktopTelemetryControlFd: Schema.optionalKey(PositiveInt),
31 /** Desktop -> server: the desktop's browser tabs, as newline-delimited JSON. */
32 desktopBrowserFd: Schema.optionalKey(PositiveInt),
33 /** Server -> desktop: commands for those tabs. */
34 desktopBrowserControlFd: Schema.optionalKey(PositiveInt),
35 resourceMonitorPath: Schema.optionalKey(TrimmedNonEmptyString),
36});
37​
38export type DesktopBackendBootstrap = typeof DesktopBackendBootstrap.Type;
39​
40/** Written to `<t3Home>/runtime` just before the desktop app stops its
41 backend to install an update. The updated app starts a new backend right
42 away, so a backend that sees a fresh marker at shutdown keeps its managed
43 tunnel. */
44export const DESKTOP_UPDATE_RESTART_MARKER_FILE = "desktop-update-restart";