Air-gapped architecture
How `@pleach/core` enforces an outbound URL allowlist at the runtime boundary, and what you provide for a fully offline install.
This page covers the air-gapped enforcement @pleach/core ships in
v1, where it applies, and what you provide for a fully offline install.
The general story lives at Air-gapped deployment. This page is the government-procurement detail.
v1 enforcement substrate
The air-gapped option is a two-field mixin on SessionRuntimeConfig,
exported as AirGappedRuntimeOption from @pleach/core/runtime/AirGappedRuntimeOption:
export interface AirGappedRuntimeOption {
airGapped: boolean
airGappedAllowedHosts?: string[]
}The default is airGapped: false. Operators opt in by setting both
fields.
Allowlist semantics
checkAirGappedHost(url, opts) runs the check. A URL is permitted
when its host matches an allowlist entry exactly or is a subdomain of
one. Matching is case-insensitive, and a leading . on an entry is
ignored.
import { checkAirGappedHost } from "@pleach/core/runtime/AirGappedRuntimeOption"
// No-op in legacy mode.
checkAirGappedHost("https://api.openai.com/v1/...", { airGapped: false })
// Throws AirGappedHostRejectedError — empty allowlist rejects everything.
checkAirGappedHost("https://api.openai.com/v1/...", { airGapped: true })
// Permitted — host matches an allowlist entry.
checkAirGappedHost("https://llm.corp.local/v1/...", {
airGapped: true,
airGappedAllowedHosts: ["llm.corp.local"],
})
// Permitted — subdomain match on `.corp.local`.
checkAirGappedHost("https://gateway.corp.local/v1/...", {
airGapped: true,
airGappedAllowedHosts: ["corp.local"],
})Fail-closed by design
With airGapped: true, an empty airGappedAllowedHosts rejects
every URL. Turning on air-gapped mode without naming the proxy,
gateway or mirror you intend to reach is a misconfiguration, and it
surfaces on the first call rather than leaking quietly.
The governmentAgent recipe passes airGappedAllowedHosts straight
through to @pleach/core and adds no validation of its own. The first
outbound URL resolution throws AirGappedHostRejectedError, so a
misconfigured deployment fails during smoke test.
Malformed URLs
A URL that new URL(...) rejects throws AirGappedHostRejectedError
unconditionally. There's no host to check, so the runtime refuses the
call.
Error shape
export class AirGappedHostRejectedError extends Error {
public readonly url: string
public readonly allowedHosts: readonly string[]
// .cause carries the rejected URL string
}Hosts can catch the error and read the structured fields without re-parsing the message.
Where the check runs
The check runs in the runtime wherever a provider URL is resolved, so a host doesn't have to wire it at the edge.
The OpenRouter base URL can be overridden with either of these:
PLEACH_OPENROUTER_BASE_URL(process env)SessionRuntimeConfig.openrouterBaseURL(per-runtime config)
In air-gapped deployments, point the override at an on-prem proxy that
speaks the OpenRouter protocol, and add that proxy's host to
airGappedAllowedHosts.
What you provide for an offline install
The runtime allowlist covers the call boundary. The install-time supply chain is yours.
1. Dependency vendoring
Point npm at a private registry inside the perimeter, or vendor
a snapshot of node_modules and install from that snapshot.
2. SBOM
The @pleach/* release workflow packs a CycloneDX and an SPDX SBOM
(sbom.cdx.json, sbom.spdx.json) into each package tarball except
the transport packages. No @pleach/* package is on npm yet, so none
has been published. The governmentAgent recipe accepts
sbomFormat: "cyclonedx-1.5" | "spdx-2.3" and stamps it on the
runtime as procurement-visible metadata. Generate the SBOM for your
own deployment in your build.
3. Signed artifacts
Releases publish through npm's trusted publisher with npm provenance. Sign the artifacts you build and deploy (Sigstore, SLSA provenance) in your own pipeline. See Supply-chain risk & SBOM.
Reference architecture
Three perimeter boundaries:
- Outbound LLM calls.
checkAirGappedHost()checks them in the runtime, and the allowlist is the only list of permitted hosts. - Install-time dependencies. Yours today, through a private registry or vendored snapshot. A runbook is v1.x scope.
- Observability destinations.
@pleach/observeships data where the host configures it to. In air-gapped deployments, point it at a private SIEM or log aggregator inside the perimeter. See Observability.
Verifying enforcement
Run a negative test:
import { governmentAgent } from "@pleach/recipes"
import { AirGappedHostRejectedError } from "@pleach/core/runtime/AirGappedRuntimeOption"
const bot = governmentAgent({
agencyId: "test",
airGapped: true,
airGappedAllowedHosts: ["llm.internal.example.gov"],
onPremProvider: {
kind: "ollama",
endpoint: "https://llm.internal.example.gov",
},
})
// In a smoke test, point the provider at a public URL and verify
// the runtime rejects it:
try {
await bot.ask("hello") // routes through a public endpoint
throw new Error("air-gapped enforcement bypassed")
} catch (err) {
if (err instanceof AirGappedHostRejectedError) {
// Expected — the allowlist is doing its job.
} else {
throw err
}
}Related
License compatibility for procurement
FSL-1.1-Apache-2.0 across all 16 publishable SKUs, with a written future-license clause to Apache-2.0 at the 2-year mark.
Supply-chain risk & SBOM
Vendor-neutrality at the SKU boundary, the SBOMs and npm provenance the release workflow produces, and what you provide for your own supply-chain review.