@prismshadow/penguin-server · packages/server/src/hmr/capabilities.ts:384

Config

interface

What the runtime publishes, as the tree sees it. The runtime registers live objects in the resource registry; the platform claims them once and hands each to a node of its own (RuntimeDb, RuntimeChannels, …) that provides it under an interface declared here. Every other node reaches the runtime only through these — @Use() db!: Db — so what a bundle needs from its host is written down and checked, not assumed.

The process configuration object — one per process; the listen callback writes the real port into it.

API

@Interface()
export abstract class Config {
  abstract root: string;
  abstract host: string;
  abstract port: number;
  abstract devAppPort?: number;
  abstract dbPath: string;
  abstract webDist: string;
  abstract previewOrigin: string | null;
  abstract penguinGoOrigin?: string;
  abstract modelscopeBridgeUrl?: string;
  abstract seedAdminPassword: string | null;
  abstract authSessionTtlMs: number;
  abstract authSessionRenewMs: number;
  abstract desktopToken: string | null;
  abstract portFile: string | null;
  abstract trustProxy: boolean;
  abstract pluginMarketUrl?: string | null;
  abstract cliEntry?: string | null;
  abstract cliLaunch?: Omit<CliLaunch, "entry">;
}

Contract Topology

Static AST wiring across @Module / @Provide / @Use

Members (18)

root

root: string

Local data root directory (shared with the SDK/CLI).

host

host: string

HTTP listen address and port (defaults to 127.0.0.1:7364, deliberately avoiding common ports like 3000/8080).

port

port: number

Listen port. 0 asks the OS for an ephemeral port (the desktop shell always does), in which case the value is only a request: index.ts writes the ACTUAL bound port back here once listening, because preview URLs are built from the server's own port rather than the browser's (dev serves the SPA on a different port; see resolvePreviewTarget).

devAppPort

devAppPort?: number

Port the first-login link points at instead of port (PENGUIN_DEV_APP_PORT). pnpm dev sets it to Vite's 7365: there the App is served by Vite, while this server only answers the API, so a link on this server's own port lands on a page that does not exist. Only that link uses it — previews and the Agents' API URL must keep reaching this server.

OPTIONAL like cliEntry, and left out of HMR_INTERFACES: only index.ts reads it.

dbPath

dbPath: string

SQLite database path; ":memory:" for test injection.

webDist

webDist: string

Frontend static assets directory; whether it's enabled is decided by checking existence when the app is assembled.

previewOrigin

previewOrigin: string | null

Origin that serves Workspace HTML previews (PENGUIN_PREVIEW_ORIGIN), e.g. https://preview.example.com. It must differ from the App origin by hostname — cookies ignore ports, so a second port would still share the session cookie. Unset is the norm locally: the loopback counterpart (127.0.0.1 <-> localhost) is derived per request instead.

penguinGoOrigin

penguinGoOrigin?: string

Trusted Penguin Go origin (PENGUIN_GO_ORIGIN); never supplied by a browser request.

OPTIONAL like cliEntry: a runtime older than this field publishes none, and a pushed platform must still boot there — authorization and balance consumers then use the default normalizePenguinGoOrigin(undefined) returns.

modelscopeBridgeUrl

modelscopeBridgeUrl?: string

Base URL of the ModelScope authorization bridge (MODELSCOPE_BRIDGE_URL), without a trailing slash — e.g. https://go.penguin.ooo/modelscope. The harness sends the start/poll exchange here and never to ModelScope itself: the bridge holds the OAuth client secret. Unlike penguinGoOrigin this value carries a path prefix in production, because the bridge is mounted under one and strips it from the incoming request.

OPTIONAL for the same reason as penguinGoOrigin; ModelScopeAuthProvider defaults it.

seedAdminPassword

seedAdminPassword: string | null

Fixed initial password for the seeded built-in admin (PENGUIN_SEED_ADMIN_PASSWORD), used by automated tests and e2e. Null is the norm: the seed then generates a random password that is hashed and discarded unseen, and the account is claimed through the first-login link instead.

authSessionTtlMs

authSessionTtlMs: number

Login session validity period (30 days).

authSessionRenewMs

authSessionRenewMs: number

Sliding renewal threshold: a session validated with less than this much left is renewed to the full TTL. Set one day below the TTL, so any session used at least a day after it was issued renews — in practice a session in regular use never expires, and the TTL is the idle timeout.

desktopToken

desktopToken: string | null

Desktop mode (PENGUIN_DESKTOP_TOKEN): the per-launch token minted by the desktop shell. Non-null enables the one-shot claim link and the Bearer-token shutdown endpoints and requires a loopback HOST — desktop mode passes the token through a URL, which must never leave the machine.

portFile

portFile: string | null

Port announcement file (PENGUIN_PORT_FILE): once the App is up, the actual bound port is written here — the supervising process's way to learn the port when it starts the server with PORT=0.

trustProxy

trustProxy: boolean

Trust x-forwarded-proto and x-forwarded-host from the request (PENGUIN_TRUST_PROXY=1), each only as a single value (@prismshadow/penguin-library-http/public-origin). Off by default: the headers are caller-supplied, so on a non-loopback bind an untrusted caller could set the scheme to https to walk through the hot-update network gate (hmr/routes.ts) while actually speaking plaintext, get session cookies stamped Secure over plain HTTP, which the browser then never sends back (a sign-in that never takes), or choose where a provider's authorization redirects. Enable this only behind a reverse proxy that terminates TLS, keeps Host, overwrites x-forwarded-proto with one value and overwrites or strips x-forwarded-host before the request reaches this process. The origin check reads the scheme alone, with the raw Host. An HTTPS deployment that leaves it off issues session cookies WITHOUT the Secure flag (auth/middleware.ts cookieOptions). The desktop shell always sets it.

pluginMarketUrl

pluginMarketUrl?: string | null

The published plugin market document this deployment reads (PENGUIN_PLUGIN_MARKET), or null for the one embedded in the build alone. Unset = the community repository's; off = no outbound request for the market, its document or its pictures; any other value replaces the URL, and the pictures are read beside it (plugin/market.ts).

OPTIONAL like pluginIndexUrl: a runtime older than this field publishes none, and the market then reads the variable from its own process environment (http/routes/plugin-market.ts).

cliEntry

cliEntry?: string | null

The CLI entry script this harness offers as penguin to the Agents it runs and in its terminals — the file the <root>/bin/penguin shim runs (see services/cli-shim.ts). PENGUIN_CLI_ENTRY when set: penguin server|web exports its own entry there, and the desktop shell passes the bundled one to the server it forks. Otherwise, on a server running from a checkout, that checkout's CLI: its source while the server runs from source, else its build (offeredCli). Null = no CLI to offer; see cliLaunch for why.

Related to but wider than the self-update endpoint's use of the same variable (http/routes/version.ts), which accepts only an INSTALLED entry it can re-run as penguin update: a checkout has no release to update to, but its CLI is exactly the one an Agent working on that checkout should be running.

OPTIONAL for the same reason: absent — a runtime older than this field — reads as null, no CLI to offer and no shim written.

cliLaunch

cliLaunch?: Omit<CliLaunch, "entry">

How the shim runs cliEntry and where it came from: the interpreter options before it (the TypeScript loader for a source run), the checkout this server runs from, the origin, and — when cliEntry is null on a checkout — why its CLI cannot run, which the shim and the terminals then say instead of falling through to another installation's penguin.

OPTIONAL like cliEntry, and for the same reason: a runtime older than this field publishes none, which reads as a plain entry from an installation — no options, no checkout, nothing to report.