hermes-agent/scripts/releases/bundle_env.py
alt-glitch 303b70f75b chore(release): retire HERMES_GUEST_ONBOARDING from bundles, build tooling and the updater
The Microsoft Store variant forced HERMES_GUEST_ONBOARDING=1 into its bundle env,
and commit/channel builds could bake it with --bundle-env. Nothing reads it now.

- scripts/bundles/desktop_inputs.py: the Store bundle env is just the request's.
- bundle_env.py / bundle-env.mjs: the key is no longer allowed for new builds.
- channel-protocol.ts: the key moves to RETIRED_BUNDLE_ENV_KEYS, so preview
  manifests already published with it still decode (the HERMES_SKIP_INTRO
  precedent).
- BUILDING.md example uses HERMES_PREVIEW_FULL_CONNECTORS.
- Build tests use another allowed key as their sample; both validators reject the
  retired key and the decoder drops it.
- msix-virtualization.test.mjs: every generated MSIX manifest (store, release,
  canary, channel) keeps filesystem and registry write virtualisation disabled,
  and the builder config declares unvirtualizedResources. The machine marker and
  the shared %LOCALAPPDATA%\hermes root depend on that.
2026-10-14 00:32:21 +05:30

43 lines
1.6 KiB
Python

"""Non-secret environment defaults and explicit clears carried by a desktop bundle."""
from __future__ import annotations
from collections.abc import Sequence
import json
# Keep this list aligned with the Desktop bundle banner and channel decoder.
_ALLOWED = frozenset({
"HERMES_HOME", "HERMES_DATA_DIR_SUFFIX", "HERMES_DESKTOP_USER_DATA_DIR",
"HERMES_SHARED_AUTH_DIR", "HERMES_PREVIEW_FULL_CONNECTORS",
})
def validate(values: object) -> dict[str, str | None]:
if not isinstance(values, dict):
raise ValueError("Bundle environment must be a JSON object")
for key, value in values.items():
if not isinstance(key, str) or key not in _ALLOWED:
raise ValueError(f"Bundle environment name is not permitted: {key}")
if value is not None and (not isinstance(value, str) or "\0" in value):
raise ValueError(f"Bundle environment value for {key} must be a string without NUL or null")
return values
def parse_assignments(assignments: list[str], unset: Sequence[str] = ()) -> dict[str, str | None]:
values: dict[str, str | None] = {}
for assignment in assignments:
key, separator, value = assignment.partition("=")
if not separator:
raise ValueError("--bundle-env requires NAME=VALUE")
if key in values:
raise ValueError(f"Duplicate bundle environment name: {key}")
values[key] = value
for key in unset:
if key in values:
raise ValueError(f"Duplicate bundle environment name: {key}")
values[key] = None
return validate(values)
def decode(raw: str) -> dict[str, str | None]:
return validate(json.loads(raw or "{}"))