Files
deepseek-harness/packages/util/launch-environment
Turtle 38c7a9fbf4 feat(release): publish package source, declaration maps, and documentation (#5884)
* feat(release): publish package source, declaration maps, and documentation

Every release member publishes its TypeScript source and the declaration
maps that resolve into it, and @deepseek-ai/dsh publishes the repository
Markdown documentation staged from docs/ at prepack time.

The ./src/* export most members already declared now resolves for an
installed consumer, and a consumer editor follows a declaration to the
implementation. Bundled JavaScript maps stay unpublished; the vendored
family and the Desktop runtime file policy are unchanged.

Rationale: .agents/notes/implemented/process/2026-10-08-published-source-and-docs.md

* feat(release): publish JavaScript maps and compress bundles

Every emitted JavaScript map ships beside the bundle it describes, and the
workspace build and the client preset compress bundles without mangling
identifiers.

The documentation payload now mirrors the website publication manifest and
is removed again by `postpack`; Desktop and the Python executable exclude
the published source, documentation, and maps; `clean` removes a staged
copy. Typert's publication contract gains the Remote declaration map.

* fix(release): keep node bundles readable for the worker image

The browser worker image lowers `yield*` only as a whole statement and
rewrites `for await` loops by their source layout, so compressed node-side
entries either fail that lowering or lower to unparseable code. Only the
browser bundles keep compression, which removes about a third of their text.

The bundle-purity assertion now matches the module-loader call regardless of
the quote style compression picks, and the release-pack fixture exercises
the installed package's new documentation requirement.

* feat(release): publish the whole documentation tree

`@deepseek-ai/dsh` copies `docs/` in full instead of the website's page
set: the maintainer documents, the generated migration records, the
translation guidelines, and the `*.i18n.yaml` consistency records ship
with the installed package, so the documentation's own links resolve
without a checkout.

* feat(release): publish the upgrade guides with the documentation

The staged documentation keeps the website's page set and adds every
`docs/upgrade-guide/` document, which is what an installed reader consults
when a released change breaks something. The rest of the maintainer tree
stays out.

* test(release): expect source and maps in master's new payload cases

* feat(release): keep installed docs and source readable in Desktop

Desktop keeps the published src/ and docs/ trees inside app.asar, and
every model shell call receives DSH_INSTALL_DIR and DSH_NODE_EXECUTABLE
so an agent can read them through Electron's Node mode. Staging also
generates docs/upgrade-guide/README.md, an index of the upgrade guides
grouped by the release they upgrade from.

Minified client bundles print string literals with backticks: the
worker image packer now recognizes those chunk requests, client license
banners are prepended after minification so their text survives, and
the affected artifact tests accept either quote.

* test(desktop): read archived docs through the Windows PowerShell form

Regenerate the config catalog for the shifted shell-env source line.

* test(desktop): wait for the GUI-subsystem Electron process from PowerShell

* build(release): publish source and maps from the message-quotes package

* build(release): publish source and maps from packages new on master

* build(release): publish source and maps from the tool-office package
2026-11-05 00:22:36 +08:00
..

description, kind
description kind
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. package-library

@deepseek-ai/dsh-launch-environment

English | 中文

Summary

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.

Table of Contents


Use this package

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.

Resolving a value

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.

How layers rank

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.

When no launcher booted the tree

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.


Understand the implementation

Implementation internals — click to expand

The snapshot is built on one separation: the launcher owns which files exist, and the snapshot owns how values rank.

Source map

File Role
src/index.ts createLaunchEnvironmentSnapshot, launchEnvironmentOf, and the ctx.launchEnvironment slot

How the snapshot stays frozen

createLaunchEnvironmentSnapshot copies every layer's values at construction, so a later mutation of the source object cannot change the snapshot. Lookups walk a canonical trust order regardless of construction order; on Windows, names are folded to uppercase before storage so case variants cannot split precedence.

What omission means

getFrom filters by the canonical order, never by the caller's list order. Omitting a layer is a refusal: the value is unreachable through that call, which is the mechanism a caller uses when a layer must never influence a specific decision.


Further Exploration

Read these pages when you need the launcher that builds the snapshot or the consumers that resolve through it.

  • Boot package — the launcher that fills ctx.launchEnvironment before any config entry mounts.
  • Credentials store — resolves stored credentials against the snapshot's layers.
  • DeepSeek provider — reads provider configuration through the launch environment.

Known Limitations and Deferred Work

These limits define when the snapshot is not a security boundary. They are current package constraints, not a task backlog.

  • The snapshot is not a subprocess boundary — every layer is also materialized into 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.
  • No per-workspace layer — the project layer is the invoking directory, fixed at launch; a workspace selected later in the Web UI contributes nothing, deliberately, because following it would let a model's own workspace change the harness environment mid-session.

Dev Note

Working context for maintainers — click to expand

None.