The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import * as Schema from "effect/Schema"; |
| 2 | |
| 3 | import { PortSchema, PositiveInt, TrimmedNonEmptyString } from "./baseSchemas.ts"; |
| 4 | |
| 5 | // A supervisor must not restart a server refused by the state-directory owner. |
| 6 | export const SERVER_EXIT_CODE_STATE_DIR_OWNED = 78; |
| 7 | // A server the managed policy refused, so the desktop app blames the policy rather than the release. |
| 8 | export const SERVER_EXIT_CODE_MANAGED_POLICY = 77; |
| 9 | |
| 10 | export const DesktopBackendBootstrap = Schema.Struct({ |
| 11 | mode: Schema.Literal("desktop"), |
| 12 | noBrowser: Schema.Boolean, |
| 13 | port: PortSchema, |
| 14 | // Omit in WSL to use the Linux home instead of the mapped Windows directory. |
| 15 | t3Home: Schema.optional(Schema.String), |
| 16 | host: Schema.String, |
| 17 | desktopBootstrapToken: Schema.String, |
| 18 | // Derives rotating tokens instead of trusting desktopBootstrapToken indefinitely; see @t3tools/shared/desktopBootstrapToken. |
| 19 | desktopBootstrapSecret: Schema.optionalKey(Schema.String), |
| 20 | // Absent means the backend must hydrate PATH, as WSL and older desktops require. |
| 21 | shellEnvironmentPrepared: Schema.optionalKey(Schema.Boolean), |
| 22 | tailscaleServeEnabled: Schema.Boolean, |
| 23 | tailscaleServePort: PortSchema, |
| 24 | otlpTracesUrl: Schema.optional(Schema.String), |
| 25 | otlpMetricsUrl: Schema.optional(Schema.String), |
| 26 | otlpLogsUrl: Schema.optional(Schema.String), |
| 27 | desktopTelemetryFd: Schema.optionalKey(PositiveInt), |
| 28 | desktopTelemetryControlFd: Schema.optionalKey(PositiveInt), |
| 29 | // Whether the spawning desktop app can install updates when the server requests one. |
| 30 | desktopAppUpdate: Schema.optionalKey(Schema.Boolean), |
| 31 | desktopBrowserFd: Schema.optionalKey(PositiveInt), |
| 32 | desktopBrowserControlFd: Schema.optionalKey(PositiveInt), |
| 33 | resourceMonitorPath: Schema.optionalKey(TrimmedNonEmptyString), |
| 34 | }); |
| 35 | |
| 36 | export type DesktopBackendBootstrap = typeof DesktopBackendBootstrap.Type; |
| 37 | |
| 38 | /** Written to `<t3Home>/runtime` before update shutdown so the backend retains its managed tunnel. */ |
| 39 | export const DESKTOP_UPDATE_RESTART_MARKER_FILE = "desktop-update-restart"; |
| 40 | |
| 41 | export const DESKTOP_UPDATE_IN_PROGRESS_MARKER_FILE = "desktop-update-in-progress"; |
| 42 | export const DESKTOP_UPDATE_IN_PROGRESS_TTL_MS = 60_000; |