Skip to content

@usine/gateway/node

The gateway set an Anthropic API key and a subscription token at once; only one can be sent.

  • Schema.Class

new ConflictingAnthropicCredentials(…args): ConflictingAnthropicCredentials

Parameter Type
…args [props: object, options?: MakeOptions]

ConflictingAnthropicCredentials

readonly message: string


The forward proxy could not listen on its address.

  • Schema.Class

new EgressProxyListenError(…args): EgressProxyListenError

Parameter Type
…args [props: object, options?: MakeOptions]

EgressProxyListenError

readonly host: string

readonly message: string

readonly port: number


The addresses the gateway’s three servers are bound to, with any port 0 replaced by the port the system chose.

  • Context.ServiceClass

readonly Service: object

The service’s operations: what yield* GatewayAddresses returns.

readonly admin: Listener

readonly egress: Listener

readonly proxy: Listener

The three listeners: the reverse proxy Workers reach for GitHub and the LLMs, the forward proxy for allowlisted hosts, and the admin API for the executor.

readonly admin: Listener

readonly egress: Listener

readonly proxy: Listener


An address and port a gateway server listens on.

readonly host: string

readonly port: number

const DEFAULT_EGRESS_ALLOWLIST_PATH: "/etc/usine-gateway/egress-allowlist" = "/etc/usine-gateway/egress-allowlist"

Where the gateway reads its egress allowlist when USINE_GATEWAY_EGRESS_ALLOWLIST is not set.


const gatewayFromEnvironment: Layer.Layer<Attachments | CallerTokens | GatewayAddresses, ConfigError | ConflictingAnthropicCredentials | EgressAllowlistError | EgressProxyListenError | PlatformError | ServeError, FileSystem>

The gateway configured from the environment and its allowlist file, as the usine-gateway command runs it.


const gatewayLayer: (listeners) => Layer.Layer<Attachments | CallerTokens | GatewayAddresses, EgressProxyListenError | ServeError, GatewaySettings>

The gateway on Node: the reverse proxy, the forward proxy, and the admin API on their listeners, sharing one attachment store and caller token signer. Upstream requests use undici, which leaves content-encoding alone, so compressed bodies pass through byte for byte.

Parameter Type
listeners GatewayListeners

Layer.Layer<Attachments | CallerTokens | GatewayAddresses, EgressProxyListenError | ServeError, GatewaySettings>


const listenersFromEnvironment: Config.Config<{ admin: { host: string; port: number; }; egress: { host: string; port: number; }; proxy: { host: string; port: number; }; }>

Listeners from the environment. The proxies default to loopback so that a gateway started without configuration is reachable from nowhere; the VM’s unit sets them to its private address.


const settingsFromEnvironment: Layer.Layer<GatewaySettings, Config.ConfigError | ConflictingAnthropicCredentials | EgressAllowlistError | PlatformError, FileSystem.FileSystem>

Reads the gateway’s settings once at startup: the domain and secrets from the environment, and the egress allowlist from its file. A missing secret, an invalid value, or an unreadable allowlist stops the gateway before it listens.