Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

feat(env): adopt every DODAIOS_ option in the programs that run before the package (#603)

Ruben Lütke029cdc04b44a
diff --git a/docs/architecture-overview.md b/docs/architecture-overview.md
index 5efb3c20f3..8d81f15d82 100644
--- a/docs/architecture-overview.md
+++ b/docs/architecture-overview.md
@@ -90,6 +90,8 @@ Plugins live under `jarvis/plugins/<group>/<name>.py`, register via `pyproject.t
Every group has two names. `dodaios.<group>` is the one to register a new plugin under; `jarvis.<group>` is the name plugins were published under before, and it stays valid: both are read in one scan of the installed distributions (`jarvis/core/entry_points.py`), and the first-party tables in `pyproject.toml` still use it. A name registered under both loads once, and if the two registrations point at different objects the `dodaios.<group>` one loads.
+**Environment variables, for a plugin and for any program the app starts.** A person may set a variable under either prefix: `DODAIOS_<NAME>` or `JARVIS_<NAME>` (`DODAIOS__<SECTION>__<KEY>` or `JARVIS__<SECTION>__<KEY>` for a config override, `DODAIOSCTL_<NAME>` or `JARVISCTL_<NAME>` for the command-line client). Inside the app and in every child process only the `JARVIS_` spelling is present: on its first import the `jarvis` package moves each `DODAIOS_` variable to its `JARVIS_` name and removes the `DODAIOS_` one (`jarvis/core/env_prefix.py`; when both were set to different values the `DODAIOS_` value is the one kept). So a plugin reads `os.environ["JARVIS_<NAME>"]` and never looks for a `DODAIOS_` variable. One spelling is kept on purpose: code that starts an external tool removes credentials from the child's environment by name, and a second copy under another name would pass it. A program that runs before the package is imported does the same move itself for the names it reads: the frozen runtime hook, `install.sh` / `install.ps1`, the uninstallers and the AppImage's `AppRun`.
+
Groups (frozen in `PLUGIN_GROUPS`): `jarvis.wakeword`, `jarvis.stt`, `jarvis.tts`, `jarvis.brain`, `jarvis.harness`, `jarvis.tool`, `jarvis.channel`.
### Streaming first
diff --git a/docs/jarvis-cli.md b/docs/jarvis-cli.md
index 1097699564..44b11166db 100644
--- a/docs/jarvis-cli.md
+++ b/docs/jarvis-cli.md
@@ -68,6 +68,15 @@ Resolution order (highest first): explicit `--url` / `--key` → `JARVISCTL_BASE
/ `JARVISCTL_CONTROL_KEY` env → saved profile (`dodaios auth login`) → the live
session file → the local control key + default `127.0.0.1:47821`.
+**Environment variables: set either prefix.** Every variable the CLI and the app
+read may be written as `DODAIOS_…` or `JARVIS_…`: `DODAIOSCTL_BASE_URL` or
+`JARVISCTL_BASE_URL`, `DODAIOS_CLI_ASSUME_YES` or `JARVIS_CLI_ASSUME_YES`,
+`DODAIOS__SECTION__KEY` or `JARVIS__SECTION__KEY`. If both are set to different
+values, the `DODAIOS_` one is used and one log line names the variable. Inside
+the app and in child processes the `JARVIS_` spelling is what is present: the
+`DODAIOS_` name is moved to it at start and then removed, so a script or plugin
+the app starts reads `JARVIS_…`.
+
**Remote / VPS.** Tunnel the loopback port and the CLI treats it as local:
```bash
diff --git a/install/README.md b/install/README.md
index c2c57a68c8..73dbb949b1 100644
--- a/install/README.md
+++ b/install/README.md
@@ -194,10 +194,10 @@ on macOS at all:
| `JARVIS_PYTHON` | Use one explicit Python interpreter; the pin is authoritative. |
| `JARVIS_INSTALL_NO_PIP` | Skip the pip steps (re-run only prefetch / launch). |
-Each `JARVIS_INSTALL_*` option also answers to `DODAIOS_INSTALL_*`
-(`DODAIOS_INSTALL_DIR`, `DODAIOS_INSTALL_REF`, ...). When both spellings are set
-to different values, the `DODAIOS_` one is used and the installer names the
-option.
+Each variable in this table also answers to its `DODAIOS_` spelling
+(`DODAIOS_INSTALL_DIR`, `DODAIOS_INSTALL_REF`, `DODAIOS_PYTHON`, ...). When both
+spellings are set to different values, the `DODAIOS_` one is used and the
+installer names the option.
## Local development of the installer
diff --git a/install/install.ps1 b/install/install.ps1
index b2f46dc331..1d1e8c1067 100644
--- a/install/install.ps1
+++ b/install/install.ps1
@@ -195,14 +195,17 @@ function Write-Err([string]$Text) { Write-Host "$Gut $Red$Crs $Text$Rst" }
Write-Banner
# ----------------------------------------------------------------- config
-# Every JARVIS_INSTALL_* option also answers to DODAIOS_INSTALL_*. When both
-# are set to different values the DODAIOS_ one wins, and the clash is named,
-# never its values. The rest of this script, and installer.py after it, read
-# the JARVIS_ spelling (jarvis/core/env_prefix.py does the same for the app).
+# Every JARVIS_ option this script reads also answers to its DODAIOS_
+# spelling. When both are set to different values the DODAIOS_ one wins, and
+# the clash is named, never its values. The rest of this script, and
+# installer.py after it, read the JARVIS_ spelling (jarvis/core/env_prefix.py
+# does the same for the app). JARVIS_PAYLOAD_COMMIT is not an option: it is
+# the signed commit the verifying installer hands over, and no second name
+# may override it.
function Use-InstallOptionNames {
- foreach ($Option in 'REPO', 'REF', 'DIR', 'PREREQS') {
- $NewName = "DODAIOS_INSTALL_$Option"
- $OldName = "JARVIS_INSTALL_$Option"
+ foreach ($Option in 'INSTALL_REPO', 'INSTALL_REF', 'INSTALL_DIR', 'INSTALL_PREREQS', 'OFFICIAL_REPO_SLUG', 'PYTHON') {
+ $NewName = "DODAIOS_$Option"
+ $OldName = "JARVIS_$Option"
$NewValue = [Environment]::GetEnvironmentVariable($NewName)
if (-not $NewValue) { continue }
$OldValue = [Environment]::GetEnvironmentVariable($OldName)
diff --git a/install/install.sh b/install/install.sh
index 56880140bd..1d48367a1e 100755
--- a/install/install.sh
+++ b/install/install.sh
@@ -18,15 +18,19 @@
set -euo pipefail
# --- install-option-names begin
-# Every JARVIS_INSTALL_* option also answers to DODAIOS_INSTALL_*. When both
-# are set to different values the DODAIOS_ one wins, and the clash is named,
-# never its values. The rest of this script, and installer.py after it, read
-# the JARVIS_ spelling (jarvis/core/env_prefix.py does the same for the app).
+# Every JARVIS_ option this script reads also answers to its DODAIOS_
+# spelling. When both are set to different values the DODAIOS_ one wins, and
+# the clash is named, never its values. The rest of this script, and
+# installer.py after it, read the JARVIS_ spelling (jarvis/core/env_prefix.py
+# does the same for the app). JARVIS_PAYLOAD_COMMIT is not an option: it is
+# the signed commit the verifying installer hands over, and no second name
+# may override it.
adopt_install_option_names() {
local option new_name old_name new_value old_value
- for option in REPO REF DIR PREREQS YES; do
- new_name="DODAIOS_INSTALL_$option"
- old_name="JARVIS_INSTALL_$option"
+ for option in INSTALL_REPO INSTALL_REF INSTALL_DIR INSTALL_PREREQS INSTALL_YES \
+ OFFICIAL_REPO_SLUG PYTHON PYTHON_SEARCH_DIRS NO_PYTHON_BOOTSTRAP; do
+ new_name="DODAIOS_$option"
+ old_name="JARVIS_$option"
new_value="${!new_name:-}"
old_value="${!old_name:-}"
[ -n "$new_value" ] || continue
diff --git a/jarvis/core/env_prefix.py b/jarvis/core/env_prefix.py
index 55f243a6f6..fc0f4ce42b 100644
--- a/jarvis/core/env_prefix.py
+++ b/jarvis/core/env_prefix.py
@@ -35,9 +35,24 @@ So a child process and a plugin read the ``JARVIS_`` name; they never see a
``DODAIOS_`` one, whoever set it.
Standard library only and no I/O besides the environment: this runs before
-logging exists and on every process start. ``packaging/pyinstaller_rthook_frozen.py``
-cannot import the package and carries a copy of :func:`_adopt`;
-``tests/unit/core/test_env_prefix.py`` holds the two copies identical.
+logging exists and on every process start.
+
+Programs that read a variable before the package is imported
+-------------------------------------------------------------
+They cannot rely on this module, so each does the same move for the names it
+reads, with the same precedence:
+
+* ``packaging/pyinstaller_rthook_frozen.py`` carries a copy of :func:`_adopt`;
+ ``tests/unit/core/test_env_prefix.py`` holds the two copies identical.
+* ``install/install.sh`` and ``install/install.ps1`` adopt every option they
+ read, the uninstallers their one; ``tests/unit/install/test_install_option_names.py``
+ fails when a script reads a ``JARVIS_`` variable it does not adopt.
+* ``packaging/linux/AppRun`` reads its one switch under both names.
+
+Everything else is Python inside the package, and importing any ``jarvis.*``
+module runs the package's ``__init__`` first. A helper the app starts by file
+path (``jarvis/agentic_ide/claude_session_hook.py``) reads only variables the
+app itself sets, which are ``JARVIS_`` ones.
"""
from __future__ import annotations
diff --git a/packaging/linux/AppRun b/packaging/linux/AppRun
index 86e8499685..fcbf16c0cb 100755
--- a/packaging/linux/AppRun
+++ b/packaging/linux/AppRun
@@ -99,7 +99,7 @@ _open_ui_when_ready() {
if [ -f "${BROWSER_UI_MARKER}" ] \
&& [ -n "${DISPLAY:-}${WAYLAND_DISPLAY:-}" ] \
- && [ "${JARVIS_APPIMAGE_NO_BROWSER:-0}" != "1" ]; then
+ && [ "${DODAIOS_APPIMAGE_NO_BROWSER:-${JARVIS_APPIMAGE_NO_BROWSER:-0}}" != "1" ]; then
# $$ is this shell's pid, which `exec` below hands to the app - so the poller
# watches the app itself, not a shell that no longer exists.
_open_ui_when_ready "$$" "${JARVIS_UI_URL}" &
diff --git a/packaging/linux/README.md b/packaging/linux/README.md
index f95dfee2c9..e37d2eda3a 100644
--- a/packaging/linux/README.md
+++ b/packaging/linux/README.md
@@ -70,7 +70,8 @@ closes the gap: with no arguments and a graphical session it waits for
`/api/health` to answer and then opens the address with `xdg-open` (falling
back through `gio`, `x-www-browser`, `sensible-browser`, and the common browser
binaries). It never opens a tab it has not confirmed first, and it stops
-waiting as soon as the app exits. `JARVIS_APPIMAGE_NO_BROWSER=1` turns it off.
+waiting as soon as the app exits. `DODAIOS_APPIMAGE_NO_BROWSER=1` (or the earlier `JARVIS_APPIMAGE_NO_BROWSER=1`)
+turns it off.
Whether to do this at all is decided at build time, not guessed: `build.sh`
inspects the freeze for PyGObject and writes
diff --git a/tests/unit/install/test_install_option_names.py b/tests/unit/install/test_install_option_names.py
index 5ea1de327f..a1df1082f4 100644
--- a/tests/unit/install/test_install_option_names.py
+++ b/tests/unit/install/test_install_option_names.py
@@ -1,4 +1,4 @@
-"""The shell installers answer to ``DODAIOS_INSTALL_*`` as well as ``JARVIS_INSTALL_*``.
+"""The shell installers answer to the ``DODAIOS_`` spelling of every option they read.
``install.sh`` and ``install.ps1`` run before Python exists, so they cannot use
``jarvis.core.env_prefix``. Each carries one small block that folds the new
@@ -27,14 +27,34 @@ UNINSTALL_PS1 = _ROOT / "install" / "uninstall.ps1"
BLOCK_BEGIN = "# --- install-option-names begin"
BLOCK_END = "# --- install-option-names end"
-SH_OPTIONS = ("REPO", "REF", "DIR", "PREREQS", "YES")
-PS_OPTIONS = ("REPO", "REF", "DIR", "PREREQS")
+SH_OPTIONS = (
+ "INSTALL_REPO",
+ "INSTALL_REF",
+ "INSTALL_DIR",
+ "INSTALL_PREREQS",
+ "INSTALL_YES",
+ "OFFICIAL_REPO_SLUG",
+ "PYTHON",
+ "PYTHON_SEARCH_DIRS",
+ "NO_PYTHON_BOOTSTRAP",
+)
+PS_OPTIONS = (
+ "INSTALL_REPO",
+ "INSTALL_REF",
+ "INSTALL_DIR",
+ "INSTALL_PREREQS",
+ "OFFICIAL_REPO_SLUG",
+ "PYTHON",
+)
+# Read by the scripts but never adopted from a second name: the signed commit
+# the verifying installer hands over.
+NOT_AN_OPTION = {"PAYLOAD_COMMIT"}
SH_DRIVER = """#!/usr/bin/env bash
set -euo pipefail
source "$BLOCK_FILE"
-for option in REPO REF DIR PREREQS YES; do
- name="JARVIS_INSTALL_$option"
+for option in $TEST_OPTIONS; do
+ name="JARVIS_$option"
printf 'VALUE|%s|%s\\n' "$option" "${!name:-}"
done
bash -c 'printf "CHILD|%s\\n" "${JARVIS_INSTALL_DIR:-}"'
@@ -44,8 +64,8 @@ PS_DRIVER = """$ErrorActionPreference = 'Stop'
function Write-Note([string]$Text) { Write-Host "NOTE|$Text" }
. $env:TEST_FUNCTION_FILE
Use-InstallOptionNames
-foreach ($Option in 'REPO', 'REF', 'DIR', 'PREREQS') {
- $Value = [Environment]::GetEnvironmentVariable("JARVIS_INSTALL_$Option")
+foreach ($Option in $env:TEST_OPTIONS.Split(' ')) {
+ $Value = [Environment]::GetEnvironmentVariable("JARVIS_$Option")
Write-Host "VALUE|$Option|$Value"
}
"""
@@ -114,7 +134,12 @@ def _run_sh(tmp_path: Path, **variables: str) -> subprocess.CompletedProcess[str
)
driver = tmp_path / "driver.sh"
driver.write_text(SH_DRIVER, encoding="utf-8", newline="\n")
- env = {**_base_env(), "BLOCK_FILE": str(block).replace("\\", "/"), **variables}
+ env = {
+ **_base_env(),
+ "BLOCK_FILE": str(block).replace("\\", "/"),
+ "TEST_OPTIONS": " ".join(SH_OPTIONS),
+ **variables,
+ }
result = _run([BASH, str(driver)], env)
assert result.returncode == 0, result.stderr
return result
@@ -129,7 +154,12 @@ def _run_ps(tmp_path: Path, **variables: str) -> subprocess.CompletedProcess[str
function_file.write_text(match.group(0), encoding="utf-8")
driver = tmp_path / "driver.ps1"
driver.write_text(PS_DRIVER, encoding="utf-8")
- env = {**_base_env(), "TEST_FUNCTION_FILE": str(function_file), **variables}
+ env = {
+ **_base_env(),
+ "TEST_FUNCTION_FILE": str(function_file),
+ "TEST_OPTIONS": " ".join(PS_OPTIONS),
+ **variables,
+ }
result = _run(
[
POWERSHELL,
@@ -154,12 +184,12 @@ def _run_ps(tmp_path: Path, **variables: str) -> subprocess.CompletedProcess[str
@needs_bash
def test_install_sh_reads_every_option_under_the_new_prefix(tmp_path: Path) -> None:
result = _run_sh(
- tmp_path, **{f"DODAIOS_INSTALL_{option}": f"new-{option}" for option in SH_OPTIONS}
+ tmp_path, **{f"DODAIOS_{option}": f"new-{option}" for option in SH_OPTIONS}
)
assert _values(result.stdout) == {option: f"new-{option}" for option in SH_OPTIONS}
# installer.py and every other child read the old spelling too.
- assert "CHILD|new-DIR" in result.stdout
+ assert "CHILD|new-INSTALL_DIR" in result.stdout
assert result.stderr == ""
@@ -168,8 +198,8 @@ def test_install_sh_keeps_reading_the_old_prefix(tmp_path: Path) -> None:
result = _run_sh(tmp_path, JARVIS_INSTALL_DIR="old-dir", JARVIS_INSTALL_REF="old-ref")
values = _values(result.stdout)
- assert values["DIR"] == "old-dir" and values["REF"] == "old-ref"
- assert values["REPO"] == "" and result.stderr == ""
+ assert values["INSTALL_DIR"] == "old-dir" and values["INSTALL_REF"] == "old-ref"
+ assert values["INSTALL_REPO"] == "" and result.stderr == ""
@needs_bash
@@ -178,7 +208,7 @@ def test_install_sh_lets_the_new_name_win_and_names_the_clash(tmp_path: Path) ->
tmp_path, JARVIS_INSTALL_DIR="old-secret-dir", DODAIOS_INSTALL_DIR="new-secret-dir"
)
- assert _values(result.stdout)["DIR"] == "new-secret-dir"
+ assert _values(result.stdout)["INSTALL_DIR"] == "new-secret-dir"
assert "DODAIOS_INSTALL_DIR" in result.stderr and "JARVIS_INSTALL_DIR" in result.stderr
assert "secret" not in result.stderr
@@ -192,7 +222,7 @@ def test_install_sh_lets_the_new_name_win_and_names_the_clash(tmp_path: Path) ->
@needs_powershell
def test_install_ps1_reads_every_option_under_the_new_prefix(tmp_path: Path) -> None:
result = _run_ps(
- tmp_path, **{f"DODAIOS_INSTALL_{option}": f"new-{option}" for option in PS_OPTIONS}
+ tmp_path, **{f"DODAIOS_{option}": f"new-{option}" for option in PS_OPTIONS}
)
assert _values(result.stdout) == {option: f"new-{option}" for option in PS_OPTIONS}
@@ -203,7 +233,7 @@ def test_install_ps1_reads_every_option_under_the_new_prefix(tmp_path: Path) ->
def test_install_ps1_keeps_reading_the_old_prefix(tmp_path: Path) -> None:
result = _run_ps(tmp_path, JARVIS_INSTALL_DIR="old-dir")
- assert _values(result.stdout)["DIR"] == "old-dir"
+ assert _values(result.stdout)["INSTALL_DIR"] == "old-dir"
assert "NOTE|" not in result.stdout
@@ -213,7 +243,7 @@ def test_install_ps1_lets_the_new_name_win_and_names_the_clash(tmp_path: Path) -
tmp_path, JARVIS_INSTALL_DIR="old-secret-dir", DODAIOS_INSTALL_DIR="new-secret-dir"
)
- assert _values(result.stdout)["DIR"] == "new-secret-dir"
+ assert _values(result.stdout)["INSTALL_DIR"] == "new-secret-dir"
notes = [line for line in result.stdout.splitlines() if line.startswith("NOTE|")]
assert len(notes) == 1
assert "DODAIOS_INSTALL_DIR" in notes[0] and "JARVIS_INSTALL_DIR" in notes[0]
@@ -229,20 +259,23 @@ def test_install_ps1_lets_the_new_name_win_and_names_the_clash(tmp_path: Path) -
def test_the_two_installers_adopt_the_options_each_one_reads() -> None:
shell = INSTALL_SH.read_text(encoding="utf-8")
powershell = INSTALL_PS1.read_text(encoding="utf-8")
- assert f"for option in {' '.join(SH_OPTIONS)}; do" in shell
+ listed = re.search(r"for option in ([A-Z_ \\\n]+); do", shell)
+ assert listed is not None and tuple(listed.group(1).replace("\\", " ").split()) == SH_OPTIONS
assert "foreach ($Option in " + ", ".join(f"'{o}'" for o in PS_OPTIONS) + ")" in powershell
- # Every JARVIS_INSTALL_* option a script reads is one it also adopts.
+ # Every JARVIS_ variable a script reads is an option it also adopts. The
+ # scripts run before Python exists, so nothing else would carry the
+ # DODAIOS_ spelling over for them.
for source, adopted in ((shell, SH_OPTIONS), (powershell, PS_OPTIONS)):
- read = set(re.findall(r"JARVIS_INSTALL_([A-Z_]+)", source))
- assert read <= set(adopted), sorted(read - set(adopted))
+ read = set(re.findall(r"JARVIS_([A-Z][A-Z_]*[A-Z])", source)) - NOT_AN_OPTION
+ assert read == set(adopted), sorted(read ^ set(adopted))
@pytest.mark.parametrize("path", [INSTALL_SH, INSTALL_PS1, UNINSTALL_SH, UNINSTALL_PS1])
def test_the_scripts_spell_the_prefixes_the_app_uses(path: Path) -> None:
new_prefix, old_prefix = env_prefix._PREFIXES[0]
source = path.read_text(encoding="utf-8")
- assert f"{new_prefix}INSTALL_" in source
- assert f"{old_prefix}INSTALL_" in source
+ assert new_prefix in source
+ assert old_prefix in source
@needs_bash
@@ -278,3 +311,40 @@ def test_the_shell_uninstaller_targets_the_directory_either_name_gives(
assert result.returncode == 0, result.stderr
assert result.stdout.strip() == expected
+
+
+def test_the_appimage_launcher_reads_its_switch_under_both_prefixes() -> None:
+ # AppRun is POSIX sh and runs before the app: the new spelling first, the
+ # earlier one as its fallback.
+ source = (_ROOT / "packaging" / "linux" / "AppRun").read_text(encoding="utf-8")
+ assert '"${DODAIOS_APPIMAGE_NO_BROWSER:-${JARVIS_APPIMAGE_NO_BROWSER:-0}}" != "1"' in source
+ assert len(re.findall(r"JARVIS_[A-Z_]*[A-Z]", source.replace("JARVIS_UI_URL", ""))) == 1
+
+
+@needs_bash
+ ("variables", "opens"),
+ [
+ ({}, True),
+ ({"JARVIS_APPIMAGE_NO_BROWSER": "1"}, False),
+ ({"DODAIOS_APPIMAGE_NO_BROWSER": "1"}, False),
+ ({"DODAIOS_APPIMAGE_NO_BROWSER": "0", "JARVIS_APPIMAGE_NO_BROWSER": "1"}, True),
+ ],
+)
+def test_the_appimage_switch_turns_the_browser_hand_off_off(
+ tmp_path: Path, variables: dict[str, str], opens: bool
+) -> None:
+ source = (_ROOT / "packaging" / "linux" / "AppRun").read_text(encoding="utf-8")
+ match = re.search(r'\[ "\$\{DODAIOS_APPIMAGE_NO_BROWSER[^\]]*\]', source)
+ assert match is not None
+ script = tmp_path / "switch.sh"
+ script.write_text(
+ "set -u\nif " + match.group(0) + "; then echo OPEN; else echo SKIP; fi\n",
+ encoding="utf-8",
+ newline="\n",
+ )
+
+ result = _run([BASH, str(script)], {**_base_env(), **variables})
+
+ assert result.returncode == 0, result.stderr
+ assert result.stdout.strip() == ("OPEN" if opens else "SKIP")