small gleam coding and persistent agent daemon with a detachable cli and a canvas ui forked from okami.mom/albedo
albedo robot-docs kernel.md
42 kB · 686 lines
Markdown

# The detached kernel A session's Python kernel runs cells in a process separate from the daemon. The daemon opens or reattaches to it through [`kernel.open`](../apps/albedo/src/albedo/kernel.gleam). The Python entry point is [`albedo_kernel.py`](../python/albedo_kernel.py), which starts [`albedo_cells.main`](../python/albedo_cells.py). Kernel namespace snapshots are described in [Python kernel state](kernel-state.md). ## Kernel Python environment The [kernel project](../python/pyproject.toml) declares the Python version and package requirements. Its [lockfile](../python/uv.lock) pins their resolution. Outside Nix, run `uv sync --locked --project python` after pulling changes to the lockfile. Local launches use the absolute interpreter in `ALBEDO_KERNEL_PYTHON` when set, then the kernel project's `.venv/bin/python` when present, otherwise `python3` on `PATH`. Packaged launches set the interpreter. The [Nix development shell](../nix/devShells.nix) defaults to its built kernel environment. [Local launch selection](../apps/albedo/src/albedo/kernel/python_tree.gleam) also supplies the interpreter for the kernel's local helpers. The project owns every package a cell may rely on: `dill` and Pydantic v2 (`pydantic>=2,<3`, with its `pydantic-core`, `annotated-types`, `typing-extensions`, and `typing-inspection` dependencies) are declared in that project and pinned in its lockfile, so agent cells can `import pydantic` and use `BaseModel`, validation, and serialisation without installing anything or relying on host site-packages. Do not add a cell dependency anywhere else, and do not vendor it: change the project, re-lock with `uv lock --project python`, and let both launch paths pick it up. The [Nix package](../python/package.nix) builds the same locked set as a virtual environment (Python 3.11 there) and exposes its wheels as `testWheels` for the offline loopback SSH tests. The Python floor stays at 3.11; the lock also resolves on newer interpreters the project already supports, including 3.15 where the pinned `dill`…