description: "An immutable snapshot of this run's environment that remembers which layer supplied each value, for packages that must resolve user-facing values without trusting a flattened process.env."
English | 中文
Use @deepseek-ai/dsh-launch-environment to resolve launch-time environment values without trusting the flattened process.env. It freezes inherited process values, the invocation directory's .env, and the Harness home's .env, then returns the winning value and its source in a fixed trust order. Callers can exclude layers for sensitive lookups; an omitted layer stays unreachable regardless of later ordering changes. The snapshot is immutable, but every layer is still copied into process.env, so it does not isolate subprocesses. Import it as a library; it cannot be mounted from cordis.yml.
Resolve user-facing values through the snapshot instead of process.env whenever the layers are not equally trusted — for example a credential override a caller must never take from a project directory.
import { launchEnvironmentOf } from '@deepseek-ai/dsh-launch-environment'
declare const ctx: import('@deepseek-ai/cordis').Context
const endpoint = launchEnvironmentOf(ctx).get('DEEPSEEK_BASE_URL')?.value
get(name) searches every layer, most trusted first. getFrom(name, sources) searches only the named layers without changing that trust order — a caller that must never accept a layer leaves it out of the list, so no future reordering can let it back in.
launchedThroughSsh(snapshot) returns true only for a non-empty SSH_CONNECTION or SSH_TTY in the inherited process layer. Web browser handoff, the adaptive directory picker, and Open In share this predicate; project and user .env values never establish an SSH session.
| Layer | What it is |
|---|---|
| Inherited process environment | What the launching shell, CI job, or container passed in — this run's explicit intent |
<invocation cwd>/.env |
The project the harness was launched in, which the product trusts to configure its own agent |
$DSH_HOME/.env |
The user's own machine-level defaults |
Names match the way the platform matches them: exactly on POSIX, case-insensitively on Windows. A case-sensitive lookup on Windows would rank the wrong layer — a shell's deepseek_api_key and a project .env's DEEPSEEK_API_KEY are one variable to the OS.
launchEnvironmentOf(ctx) returns the launcher's snapshot when the product CLI booted the tree, and otherwise the inherited environment as the only layer. The fallback does not weaken the rules: an SDK host or a bare cordis.yml discovered no files, so everything it has is the environment it was launched with.
Read these pages when you need the launcher that builds the snapshot or the consumers that resolve through it.
ctx.launchEnvironment before any config entry mounts.These limits define when the snapshot is not a security boundary. They are current package constraints, not a task backlog.
process.env, so ordinary project variables reach child processes under dsh-subprocess's scrub; the product launcher's .env contract rejects bootstrap variables before materialization.