packs: ship python deps with the pack
A pack now owns the python deps its skills/bridge need, at packs/<name>/requirements.txt (standard pip format). SkillPack.requirements_file resolves it; the install plan lists the selected/enabled packs that ship one (setup.build_plan / plan_from_config -> pack_requirements); bootstrap installs each into .runtime/venv, so a host that never enables a pack installs nothing for it. Move the browser deps (Playwright) out of the agent repo's requirements/ into packs/browser/requirements.txt; the Playwright binary download stays a browser-specific bootstrap stage. --browser force-adds the pack's deps. Docs (PACKGEN.md, AGENTS.md, README.md) describe the pattern; tests keep every pack requirements.txt pinned and consistent with the manifest's requires.
This commit is contained in:
1 parent
bf071ee529
commit
b1a7bfd272
12 files changed
+180
-59
No files matched your search
@@ -32,7 +32,9 @@ truth and this skill is only the workflow.
|
|||||||
`packs/<name>/pack.json` with `name`, `title`, `concern`, `categories`,
|
`packs/<name>/pack.json` with `name`, `title`, `concern`, `categories`,
|
||||||
`bridges`, `requires`, `enabled_by_default`, and the `config` schema. Model
|
`bridges`, `requires`, `enabled_by_default`, and the `config` schema. Model
|
||||||
it on `packs/essentials/pack.json` (bridge-less) or
|
it on `packs/essentials/pack.json` (bridge-less) or
|
||||||
`packs/simplex/pack.json` (bridge-backed).
|
`packs/simplex/pack.json` (bridge-backed). If the pack needs python deps,
|
||||||
|
ship them at `packs/<name>/requirements.txt` (pinned, pip format) — never in
|
||||||
|
the agent repo's `requirements/` (see `PACKGEN.md`, "Pack python deps").
|
||||||
5. **Add each leaf** under `skills/<category>/<leaf>/` — `skill.py`,
|
5. **Add each leaf** under `skills/<category>/<leaf>/` — `skill.py`,
|
||||||
`manifest.json`, `contract.json`, `skill.test.py` — following `CODEGEN.md`
|
`manifest.json`, `contract.json`, `skill.test.py` — following `CODEGEN.md`
|
||||||
and `TESTGEN.md`. Do not restate those rules; follow them. Ship each bridge
|
and `TESTGEN.md`. Do not restate those rules; follow them. Ship each bridge
|
||||||
|
|||||||
@@ -877,7 +877,8 @@ CLI, unit tests (24) + integration tests (2).
|
|||||||
`--reconfigure` re-runs the interview and rewrites `config/` + `secrets.json`.
|
`--reconfigure` re-runs the interview and rewrites `config/` + `secrets.json`.
|
||||||
`--voice` / `--browser` additionally install those optional stacks
|
`--voice` / `--browser` additionally install those optional stacks
|
||||||
(`requirements/voice.txt` + system `libportaudio2` + `alsa-utils`;
|
(`requirements/voice.txt` + system `libportaudio2` + `alsa-utils`;
|
||||||
`requirements/browser.txt` + a browser) even when the plan did not pick them.
|
`packs/browser/requirements.txt` + a browser) even when the plan did not pick
|
||||||
|
them.
|
||||||
The script must be run from a checkout — it reads pins from that checkout's
|
The script must be run from a checkout — it reads pins from that checkout's
|
||||||
`pins.json` and never re-clones the agent repo (only the pack index, the
|
`pins.json` and never re-clones the agent repo (only the pack index, the
|
||||||
selected packs, the SemIf engine, and the simplex-chat binary). Idempotent and
|
selected packs, the SemIf engine, and the simplex-chat binary). Idempotent and
|
||||||
@@ -905,9 +906,13 @@ CLI, unit tests (24) + integration tests (2).
|
|||||||
`simplex_chat` ports/display names stay in `config.json`. The python dep pins
|
`simplex_chat` ports/display names stay in `config.json`. The python dep pins
|
||||||
live in `requirements/` split by concern (committed): `core.txt` (the test
|
live in `requirements/` split by concern (committed): `core.txt` (the test
|
||||||
runner, always), `engine.txt` (the local decision engine), `transports.txt`
|
runner, always), `engine.txt` (the local decision engine), `transports.txt`
|
||||||
(websockets/lxmf), plus the optional `voice.txt`/`browser.txt`; `staging.txt`
|
(websockets/lxmf), plus the optional `voice.txt`; `staging.txt`
|
||||||
is the union of the non-hardware files. Bootstrap installs only the subset the
|
is the union of the non-hardware files. A pack owns the deps its skills/bridge
|
||||||
plan requires. The agent reads `engine.source`/`revision` from
|
need, shipped at `packs/<name>/requirements.txt` (e.g. the browser pack's
|
||||||
|
Playwright pin); the install plan lists the selected/enabled packs that ship
|
||||||
|
one (`plan["pack_requirements"]`) and bootstrap pip-installs each, so a host
|
||||||
|
that never enables a pack installs nothing for it. Bootstrap installs only the
|
||||||
|
subset the plan requires. The agent reads `engine.source`/`revision` from
|
||||||
`pins.json` and derives the GGUF path from `engine.gguf_url` under
|
`pins.json` and derives the GGUF path from `engine.gguf_url` under
|
||||||
`.runtime/models/` (an explicit `engine.gguf` in `config.json` overrides it).
|
`.runtime/models/` (an explicit `engine.gguf` in `config.json` overrides it).
|
||||||
**Maintenance**: bump the pins in `pins.json` / `requirements/`,
|
**Maintenance**: bump the pins in `pins.json` / `requirements/`,
|
||||||
@@ -1540,6 +1545,14 @@ CLI, unit tests (24) + integration tests (2).
|
|||||||
scans the `skill_packs` roots for `*/pack.json`; a root with no manifest is one
|
scans the `skill_packs` roots for `*/pack.json`; a root with no manifest is one
|
||||||
implicit pack, so a plain skills directory works) and `merge_packs` loads every
|
implicit pack, so a plain skills directory works) and `merge_packs` loads every
|
||||||
**enabled** pack at startup.
|
**enabled** pack at startup.
|
||||||
|
- **Deps are pack-owned.** A pack ships the python deps its skills/bridge need at
|
||||||
|
`packs/<name>/requirements.txt` (pip format, pinned) — never in the agent
|
||||||
|
repo's `requirements/`. `SkillPack.requirements_file` resolves it; the install
|
||||||
|
plan lists the selected/enabled packs that ship one (`setup.build_plan` /
|
||||||
|
`plan_from_config` -> `pack_requirements`), and `scripts/bootstrap.sh`
|
||||||
|
pip-installs each into `.runtime/venv` (so a host that never enables a pack
|
||||||
|
installs nothing for it). Heavy deps are lazy-imported and a missing one is a
|
||||||
|
per-call `503`, never a crash. See `PACKGEN.md`, "Pack python deps".
|
||||||
- **Enable is one switch.** `pack_enabled` resolves: an explicit
|
- **Enable is one switch.** `pack_enabled` resolves: an explicit
|
||||||
`packs.<name>.enabled`, else a bridge pack follows its
|
`packs.<name>.enabled`, else a bridge pack follows its
|
||||||
`bridges.<bridge>.enabled`, else `enabled_by_default`. Disabling a pack drops
|
`bridges.<bridge>.enabled`, else `enabled_by_default`. Disabling a pack drops
|
||||||
@@ -1707,7 +1720,8 @@ CLI, unit tests (24) + integration tests (2).
|
|||||||
behind one uniform JSON surface, so a body never bundles a browser stack. It is
|
behind one uniform JSON surface, so a body never bundles a browser stack. It is
|
||||||
the first bridge with a heavy optional dependency, so it is **disabled by
|
the first bridge with a heavy optional dependency, so it is **disabled by
|
||||||
default** and installed with `scripts/bootstrap.sh --browser`
|
default** and installed with `scripts/bootstrap.sh --browser`
|
||||||
(`requirements/browser.txt` pins Playwright; the Chromium binary is downloaded
|
(`packs/browser/requirements.txt` pins Playwright — the pack owns its deps; the
|
||||||
|
Chromium binary is downloaded
|
||||||
into the checkout's `.runtime/browser`, and the bridge sets
|
into the checkout's `.runtime/browser`, and the bridge sets
|
||||||
`PLAYWRIGHT_BROWSERS_PATH` there at launch). Unlike Nextcloud/Outlook it owns a
|
`PLAYWRIGHT_BROWSERS_PATH` there at launch). Unlike Nextcloud/Outlook it owns a
|
||||||
browser and keeps a **persistent profile** (`.runtime/browser/profile`), so a
|
browser and keeps a **persistent profile** (`.runtime/browser/profile`), so a
|
||||||
@@ -1807,8 +1821,8 @@ covered. Deferred follow-ups:
|
|||||||
`browser_client.py`). Shipped: `BrowserBridge` exposes open/read
|
`browser_client.py`). Shipped: `BrowserBridge` exposes open/read
|
||||||
(text/links/screenshot) and act (goto/click/fill/press/select/wait/back/
|
(text/links/screenshot) and act (goto/click/fill/press/select/wait/back/
|
||||||
forward/reset) over one JSON surface in front of a real Playwright browser
|
forward/reset) over one JSON surface in front of a real Playwright browser
|
||||||
with a persistent profile; optional heavy dep installed via
|
with a persistent profile; optional heavy dep installed via the pack's own
|
||||||
`requirements/browser.txt` + `bootstrap.sh --browser`, lazy so a missing
|
`packs/browser/requirements.txt` + `bootstrap.sh --browser`, lazy so a missing
|
||||||
browser is a per-call 503 and never aborts the other bridges; the async API
|
browser is a per-call 503 and never aborts the other bridges; the async API
|
||||||
runs on one dedicated event-loop thread. Three `packs/browser/skills/browser/*` skills
|
runs on one dedicated event-loop thread. Three `packs/browser/skills/browser/*` skills
|
||||||
(`open_page`, `read_page`, `screenshot`). Deferred: arbitrary JS `evaluate`,
|
(`open_page`, `read_page`, `screenshot`). Deferred: arbitrary JS `evaluate`,
|
||||||
|
|||||||
+46
-5
@@ -54,6 +54,7 @@ Three boundaries must stay crisp:
|
|||||||
```
|
```
|
||||||
packs/<name>/
|
packs/<name>/
|
||||||
pack.json # the manifest (this file's subject)
|
pack.json # the manifest (this file's subject)
|
||||||
|
requirements.txt # optional: the pack's own python deps (pip format)
|
||||||
skills/<category>/<leaf>/
|
skills/<category>/<leaf>/
|
||||||
skill.py # the body — CODEGEN.md
|
skill.py # the body — CODEGEN.md
|
||||||
manifest.json # {"description": "..."} navigation text
|
manifest.json # {"description": "..."} navigation text
|
||||||
@@ -77,6 +78,8 @@ packs/<name>/
|
|||||||
- `bridge/` ships the pack's bridge (one module per name in `bridges`, plus
|
- `bridge/` ships the pack's bridge (one module per name in `bridges`, plus
|
||||||
optional sibling modules it imports relatively). It is absent for a
|
optional sibling modules it imports relatively). It is absent for a
|
||||||
bridge-less pack. See "Authoring a new bridge".
|
bridge-less pack. See "Authoring a new bridge".
|
||||||
|
- `requirements.txt` is the pack's own optional python deps (standard pip
|
||||||
|
format); it is absent for a stdlib-only pack. See "Pack python deps".
|
||||||
- `manifest.json` holds a single non-empty `description` — the navigation text
|
- `manifest.json` holds a single non-empty `description` — the navigation text
|
||||||
SemIf routes on. It is the seed analog of the registry entry a generated
|
SemIf routes on. It is the seed analog of the registry entry a generated
|
||||||
skill gets from the `llm` provider.
|
skill gets from the `llm` provider.
|
||||||
@@ -99,7 +102,7 @@ A single JSON object. Fields (from `packs._parse_pack`):
|
|||||||
| `concern` | string | **yes** | One- to two-sentence statement of the product/job the pack serves. (`description` is accepted as a legacy alias.) |
|
| `concern` | string | **yes** | One- to two-sentence statement of the product/job the pack serves. (`description` is accepted as a legacy alias.) |
|
||||||
| `categories` | object | **yes** | `{category_id: scope_description}` — the tree buckets this pack owns. |
|
| `categories` | object | **yes** | `{category_id: scope_description}` — the tree buckets this pack owns. |
|
||||||
| `bridges` | array of string | no | Bridge names this pack ships and talks to. Each name is a `bridge/<name>.py` module in the pack; `simplex`/`llm`/`nextcloud`/`outlook`/`browser` are the shipped names. Empty for a bridge-less pack. |
|
| `bridges` | array of string | no | Bridge names this pack ships and talks to. Each name is a `bridge/<name>.py` module in the pack; `simplex`/`llm`/`nextcloud`/`outlook`/`browser` are the shipped names. Empty for a bridge-less pack. |
|
||||||
| `requires` | array of string | no | Optional heavy deps (e.g. `playwright`). Informational; the code's `check_requirements` is what enforces them. |
|
| `requires` | array of string | no | Optional heavy deps named at a glance (e.g. `playwright`). Informational — the pinned install list is the pack's own `requirements.txt` (see "Pack python deps"), and the code's `check_requirements` is what enforces them at runtime. |
|
||||||
| `enabled_by_default` | bool | no | Default `true`. Whether the pack loads when nothing else decides. |
|
| `enabled_by_default` | bool | no | Default `true`. Whether the pack loads when nothing else decides. |
|
||||||
| `config` | object | no | The pack's config schema (see below). |
|
| `config` | object | no | The pack's config schema (see below). |
|
||||||
|
|
||||||
@@ -183,6 +186,39 @@ python -m semif_agent.cli check-config
|
|||||||
it once, only when `config.json` is absent); afterwards only a human edits it.
|
it once, only when `config.json` is absent); afterwards only a human edits it.
|
||||||
The generated example and the live config are never hand-edited.
|
The generated example and the live config are never hand-edited.
|
||||||
|
|
||||||
|
## Pack python deps
|
||||||
|
|
||||||
|
A pack owns the python packages its skills and bridge need. Put them in
|
||||||
|
`packs/<name>/requirements.txt` (standard pip requirements format, pinned) —
|
||||||
|
**not** in the agent repo's `requirements/`. A pack that is stdlib-only ships no
|
||||||
|
file.
|
||||||
|
|
||||||
|
How the injection works:
|
||||||
|
|
||||||
|
- `SkillPack.requirements_file` (`semif_agent/packs.py`) resolves
|
||||||
|
`packs/<name>/requirements.txt` when it exists.
|
||||||
|
- The install plan lists those packs: `setup.build_plan` /
|
||||||
|
`setup.plan_from_config` set `pack_requirements` to the selected/enabled packs
|
||||||
|
that ship one (`scripts/bootstrap.sh` reads the plan).
|
||||||
|
- Bootstrap installs each listed pack's file into `.runtime/venv` **after**
|
||||||
|
cloning the selected packs and creating the venv, and only for packs the host
|
||||||
|
actually selected (a host that never enables the pack installs nothing). The
|
||||||
|
`--browser` flag force-adds the browser pack's deps.
|
||||||
|
|
||||||
|
Rules:
|
||||||
|
|
||||||
|
- **Lazy-import** every heavy dep in the pack's bridge/skills so a host without
|
||||||
|
the pack still runs — the core stays stdlib-only. A missing dep is a per-call
|
||||||
|
`503` with an install hint (see "Authoring a new bridge"), never a crash.
|
||||||
|
- **Pin** the versions (this is a shipped integration, not an app you upgrade in
|
||||||
|
place). If a dep needs a non-pip step (a downloaded binary, a system package),
|
||||||
|
ship a helper under `scripts/` and document it in the pack's
|
||||||
|
`requirements.txt` header — the browser pack's Chromium download is the model.
|
||||||
|
- `requires` in the manifest is the human-readable summary of the heavy deps;
|
||||||
|
`requirements.txt` is the authoritative install list. Keep them consistent.
|
||||||
|
- Never put a credential or a per-machine value in `requirements.txt`; it is
|
||||||
|
committed structure like the rest of the pack.
|
||||||
|
|
||||||
## The enable switch
|
## The enable switch
|
||||||
|
|
||||||
One switch governs the pack's skills **and** its bridge, so a host never offers
|
One switch governs the pack's skills **and** its bridge, so a host never offers
|
||||||
@@ -340,10 +376,14 @@ A new pack is accepted only if:
|
|||||||
path, local model name) appears in any committed file —
|
path, local model name) appears in any committed file —
|
||||||
`tests/test_no_env_leaks.py` enforces this for the agent repo; keep a pack
|
`tests/test_no_env_leaks.py` enforces this for the agent repo; keep a pack
|
||||||
repo clean too. Secrets live in `secrets.json`.
|
repo clean too. Secrets live in `secrets.json`.
|
||||||
|
8. If the pack ships a `requirements.txt`, it is pinned, lives with the pack (not
|
||||||
|
the agent repo's `requirements/`), and its deps are lazy-imported so a host
|
||||||
|
without the pack is unaffected.
|
||||||
|
|
||||||
`tests/test_packs.py` enforces items 1–6 mechanically for every shipped pack
|
`tests/test_packs.py` enforces items 1–6 and 8 mechanically for every shipped
|
||||||
(valid manifest, concern + categories, integration matches code, contract flat
|
pack (valid manifest, concern + categories, integration matches code, contract
|
||||||
and mirrored, manifest description, hermetic skill test, hermetic bridge test)
|
flat and mirrored, manifest description, hermetic skill test, hermetic bridge
|
||||||
|
test, pinned pack requirements)
|
||||||
and keeps the shipped pack ids present.
|
and keeps the shipped pack ids present.
|
||||||
|
|
||||||
## Worked example — a minimal bridge-less pack
|
## Worked example — a minimal bridge-less pack
|
||||||
@@ -407,7 +447,8 @@ HTTP). For a bridge with top-level fallbacks, see `packs/nextcloud/` (its
|
|||||||
HTTP API needs no bridge — the skill calls it directly.
|
HTTP API needs no bridge — the skill calls it directly.
|
||||||
3. Create the pack (its own repository, `pack.<name>`): `packs/<name>/pack.json`
|
3. Create the pack (its own repository, `pack.<name>`): `packs/<name>/pack.json`
|
||||||
with `name`, `title`, `concern`, `categories`, `bridges` (if any), `requires`,
|
with `name`, `title`, `concern`, `categories`, `bridges` (if any), `requires`,
|
||||||
`enabled_by_default`, and the `config` schema.
|
`enabled_by_default`, and the `config` schema. If the pack needs python deps,
|
||||||
|
ship them pinned at `packs/<name>/requirements.txt` (see "Pack python deps").
|
||||||
4. Add each leaf under `skills/<category>/<leaf>/` following `CODEGEN.md` and
|
4. Add each leaf under `skills/<category>/<leaf>/` following `CODEGEN.md` and
|
||||||
`TESTGEN.md` (`skill.py`, `manifest.json`, `contract.json`, `skill.test.py`),
|
`TESTGEN.md` (`skill.py`, `manifest.json`, `contract.json`, `skill.test.py`),
|
||||||
and each bridge under `bridge/<name>.py` with its `bridge/test_<name>_bridge.py`.
|
and each bridge under `bridge/<name>.py` with its `bridge/test_<name>_bridge.py`.
|
||||||
|
|||||||
@@ -410,8 +410,10 @@ packs/ skill packs, each cloned from its own repo (pack.<name>)
|
|||||||
pack list lives in the semif-packs index repo (see PACKGEN.md)
|
pack list lives in the semif-packs index repo (see PACKGEN.md)
|
||||||
scripts/ bootstrap.sh, config_merge.py, voice-*.py, systemd/*.in
|
scripts/ bootstrap.sh, config_merge.py, voice-*.py, systemd/*.in
|
||||||
requirements/ core.txt (test runner), engine.txt (local decision engine),
|
requirements/ core.txt (test runner), engine.txt (local decision engine),
|
||||||
transports.txt (websockets/lxmf), voice.txt, browser.txt
|
transports.txt (websockets/lxmf), voice.txt
|
||||||
(staging.txt = the union of the non-hardware files)
|
(staging.txt = the union of the non-hardware files);
|
||||||
|
a pack's own deps live with the pack at
|
||||||
|
packs/<name>/requirements.txt
|
||||||
tests/ stdlib unit tests + tests/integration (real engine + LLM)
|
tests/ stdlib unit tests + tests/integration (real engine + LLM)
|
||||||
CODEGEN.md the contract fed to the skill-body codegen model
|
CODEGEN.md the contract fed to the skill-body codegen model
|
||||||
TESTGEN.md the contract fed to the test/contract codegen model
|
TESTGEN.md the contract fed to the test/contract codegen model
|
||||||
@@ -506,8 +508,9 @@ The script:
|
|||||||
SemIf engine;
|
SemIf engine;
|
||||||
4. creates `.runtime/venv` and installs only the needed dep files:
|
4. creates `.runtime/venv` and installs only the needed dep files:
|
||||||
`requirements/core.txt` always, `engine.txt` for a local engine,
|
`requirements/core.txt` always, `engine.txt` for a local engine,
|
||||||
`transports.txt` when a SimpleX/LXMF transport is selected (`voice.txt` /
|
`transports.txt` when a SimpleX/LXMF transport is selected (`voice.txt` for
|
||||||
`browser.txt` for those stacks);
|
the voice stack, and each selected pack's own `packs/<name>/requirements.txt`
|
||||||
|
— e.g. the browser pack's Playwright deps);
|
||||||
5. for a local engine, downloads/sha256-verifies the GGUF into `.runtime/models/`
|
5. for a local engine, downloads/sha256-verifies the GGUF into `.runtime/models/`
|
||||||
and pre-fetches the HF tokenizer into `.runtime/hf/`;
|
and pre-fetches the HF tokenizer into `.runtime/hf/`;
|
||||||
6. downloads/sha256-verifies the pinned `simplex-chat` binary **only** when a
|
6. downloads/sha256-verifies the pinned `simplex-chat` binary **only** when a
|
||||||
|
|||||||
@@ -1,21 +0,0 @@
|
|||||||
# Browser bridge deps (optional).
|
|
||||||
#
|
|
||||||
# Only needed on a host that runs the browser bridge (browser automation skills).
|
|
||||||
# Lazy-imported by packs/browser/bridge/browser_client.py, so the core stays
|
|
||||||
# stdlib-only and every other bridge keeps running without it. Install with
|
|
||||||
# scripts/bootstrap.sh --browser, or:
|
|
||||||
# .runtime/venv/bin/pip install -r requirements/browser.txt
|
|
||||||
# PLAYWRIGHT_BROWSERS_PATH=.runtime/browser \
|
|
||||||
# .runtime/venv/bin/python -m playwright install chromium
|
|
||||||
#
|
|
||||||
# The browser binaries are NOT shipped in the wheel: `playwright install`
|
|
||||||
# downloads Chromium into PLAYWRIGHT_BROWSERS_PATH. bootstrap.sh points that at
|
|
||||||
# the checkout's .runtime/browser (the containment rule); the bridge sets the
|
|
||||||
# same env var at launch, so the binaries live with the rest of the stack. Add
|
|
||||||
# `--with-deps` to the install command on a bare host to fetch the system
|
|
||||||
# libraries Chromium needs (needs sudo).
|
|
||||||
#
|
|
||||||
# Only `chromium` is installed by default; switch bridges.browser.engine to
|
|
||||||
# firefox/webkit and run `python -m playwright install firefox`/`webkit` for
|
|
||||||
# those.
|
|
||||||
playwright==1.63.0
|
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
# Core agent deps (the agent itself is stdlib-only; this is the test runner).
|
# Core agent deps (the agent itself is stdlib-only; this is the test runner).
|
||||||
#
|
#
|
||||||
# Every host installs this. The decision engine, messaging transports, voice,
|
# Every host installs this. The decision engine and messaging transports are
|
||||||
# and browser stacks are separate, optional files (engine.txt, transports.txt,
|
# separate, optional files (engine.txt, transports.txt) so a host installs only
|
||||||
# voice.txt, browser.txt) so a host installs only what its answers require.
|
# what its answers require. The voice stack (voice.txt) is hardware-dependent,
|
||||||
# `staging.txt` includes all of them for a full provision.
|
# and the browser stack ships WITH its pack (packs/browser/requirements.txt) —
|
||||||
|
# bootstrap installs each selected pack's own requirements.txt.
|
||||||
|
# `staging.txt` includes the repo-level files for a full provision.
|
||||||
pytest
|
pytest
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
# Full provision: every dependency this repo can need, for a host that runs the
|
# Full provision: every repo-level dependency this checkout can need, for a host
|
||||||
# local decision engine, all messaging transports, the voice gateway, and the
|
# that runs the local decision engine and all messaging transports. This is the
|
||||||
# browser bridge. This is the union of the per-concern files below; a
|
# union of the per-concern files below; a `scripts/bootstrap.sh` run installs
|
||||||
# `scripts/bootstrap.sh` run installs only the subset its answers require, so
|
# only the subset its answers require, so prefer those files (engine.txt,
|
||||||
# prefer those files (engine.txt, transports.txt, voice.txt, browser.txt) when
|
# transports.txt) when provisioning by hand.
|
||||||
# provisioning by hand.
|
|
||||||
#
|
#
|
||||||
# Voice and browser stacks are hardware/optional and are NOT included here —
|
# Voice (voice.txt) and browser (packs/browser/requirements.txt) stacks are
|
||||||
# install them with `scripts/bootstrap.sh --voice` / `--browser` (or
|
# hardware/optional. Voice is a repo file installed with
|
||||||
# `pip install -r requirements/voice.txt` / `browser.txt`).
|
# `scripts/bootstrap.sh --voice`; the browser deps live WITH their pack and are
|
||||||
|
# installed by bootstrap when that pack is selected.
|
||||||
-r core.txt
|
-r core.txt
|
||||||
-r engine.txt
|
-r engine.txt
|
||||||
-r transports.txt
|
-r transports.txt
|
||||||
+37
-8
@@ -305,7 +305,8 @@ fi
|
|||||||
# the fields after it.
|
# the fields after it.
|
||||||
IFS=$'\x1f' read -r PLAN_ENGINE PLAN_AUTHORING PLAN_PACKS PLAN_GATEWAYS \
|
IFS=$'\x1f' read -r PLAN_ENGINE PLAN_AUTHORING PLAN_PACKS PLAN_GATEWAYS \
|
||||||
PLAN_GATEWAY_PLATFORMS PLAN_BRIDGE_PACKS PLAN_INSTALL_ENGINE PLAN_BRIDGE_SVC \
|
PLAN_GATEWAY_PLATFORMS PLAN_BRIDGE_PACKS PLAN_INSTALL_ENGINE PLAN_BRIDGE_SVC \
|
||||||
PLAN_GATEWAY_SVC PLAN_SIMPLEX_BIN PLAN_SIMPLEX_FWD PLAN_BROWSER PLAN_VOICE < <(
|
PLAN_GATEWAY_SVC PLAN_SIMPLEX_BIN PLAN_SIMPLEX_FWD PLAN_BROWSER PLAN_VOICE \
|
||||||
|
PLAN_PACK_REQS < <(
|
||||||
python3 - "$PLAN" <<'PY'
|
python3 - "$PLAN" <<'PY'
|
||||||
import json, sys
|
import json, sys
|
||||||
p = json.load(open(sys.argv[1]))
|
p = json.load(open(sys.argv[1]))
|
||||||
@@ -325,6 +326,7 @@ print("\x1f".join([
|
|||||||
flag("install_simplex_forward"),
|
flag("install_simplex_forward"),
|
||||||
flag("install_browser"),
|
flag("install_browser"),
|
||||||
flag("install_voice"),
|
flag("install_voice"),
|
||||||
|
",".join(p.get("pack_requirements", [])),
|
||||||
]))
|
]))
|
||||||
PY
|
PY
|
||||||
)
|
)
|
||||||
@@ -333,6 +335,13 @@ PY
|
|||||||
# (e.g. a scripted pre-seed); enabling it in config is still the operator's call.
|
# (e.g. a scripted pre-seed); enabling it in config is still the operator's call.
|
||||||
[[ "$VOICE" = 1 ]] && PLAN_VOICE=1
|
[[ "$VOICE" = 1 ]] && PLAN_VOICE=1
|
||||||
[[ "$BROWSER" = 1 ]] && PLAN_BROWSER=1
|
[[ "$BROWSER" = 1 ]] && PLAN_BROWSER=1
|
||||||
|
# A forced optional stack also pulls in that pack's own python deps.
|
||||||
|
if [[ "$BROWSER" = 1 ]]; then
|
||||||
|
case ",$PLAN_PACK_REQS," in
|
||||||
|
*,browser,*) ;;
|
||||||
|
*) PLAN_PACK_REQS="${PLAN_PACK_REQS:+$PLAN_PACK_REQS,}browser" ;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
# Messaging transports (websockets / lxmf) are needed by the SimpleX gateway or
|
# Messaging transports (websockets / lxmf) are needed by the SimpleX gateway or
|
||||||
# bridge and the LXMF gateway.
|
# bridge and the LXMF gateway.
|
||||||
@@ -342,6 +351,7 @@ NEED_TRANSPORTS=0
|
|||||||
|
|
||||||
echo "== plan: engine=$PLAN_ENGINE | authoring=$PLAN_AUTHORING | packs=$PLAN_PACKS"
|
echo "== plan: engine=$PLAN_ENGINE | authoring=$PLAN_AUTHORING | packs=$PLAN_PACKS"
|
||||||
echo " gateways=${PLAN_GATEWAYS:-none} | install: engine=$PLAN_INSTALL_ENGINE transports=$NEED_TRANSPORTS bridge=$PLAN_BRIDGE_SVC gateway=$PLAN_GATEWAY_SVC browser=$PLAN_BROWSER voice=$PLAN_VOICE"
|
echo " gateways=${PLAN_GATEWAYS:-none} | install: engine=$PLAN_INSTALL_ENGINE transports=$NEED_TRANSPORTS bridge=$PLAN_BRIDGE_SVC gateway=$PLAN_GATEWAY_SVC browser=$PLAN_BROWSER voice=$PLAN_VOICE"
|
||||||
|
echo " pack deps=${PLAN_PACK_REQS:-none}"
|
||||||
|
|
||||||
# The live config may be split (config.json includes config/*.json); merge it so
|
# The live config may be split (config.json includes config/*.json); merge it so
|
||||||
# the reads below see one flat object. Stdlib-only, so it works before the venv.
|
# the reads below see one flat object. Stdlib-only, so it works before the venv.
|
||||||
@@ -630,14 +640,33 @@ if [[ "$PLAN_VOICE" = 1 ]]; then
|
|||||||
"$PIP" install --no-deps openwakeword==0.6.0
|
"$PIP" install --no-deps openwakeword==0.6.0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# --- stage 3c: optional browser-bridge stack -----------------------------------
|
# --- stage 3c: pack-declared python deps ---------------------------------------
|
||||||
# Playwright + its Chromium binaries. Optional: lazy-imported, so a host without
|
# A pack owns the python deps its skills/bridge need, shipped as
|
||||||
# it still runs every other bridge. Browsers go under the checkout's
|
# packs/<name>/requirements.txt (standard pip format). The install plan lists the
|
||||||
# .runtime/browser (the containment rule); the bridge sets PLAYWRIGHT_BROWSERS_PATH
|
# packs this host selected/enabled that ship one; a pack that does not enable
|
||||||
# to the same path at launch.
|
# installs nothing. Deps are lazy-imported by the pack's bridge/skills, so a host
|
||||||
|
# without them still runs every other pack. See PACKGEN.md, "Pack python deps".
|
||||||
|
if [[ -n "$PLAN_PACK_REQS" ]]; then
|
||||||
|
IFS=',' read -ra PACK_REQ_LIST <<< "$PLAN_PACK_REQS"
|
||||||
|
for pack_name in "${PACK_REQ_LIST[@]}"; do
|
||||||
|
[[ -z "$pack_name" ]] && continue
|
||||||
|
PACK_REQ="$REPO_ROOT/packs/$pack_name/requirements.txt"
|
||||||
|
if [[ -f "$PACK_REQ" ]]; then
|
||||||
|
echo "== installing deps for pack '$pack_name' ($PACK_REQ)"
|
||||||
|
"$PIP" install -r "$PACK_REQ"
|
||||||
|
else
|
||||||
|
echo " WARN: pack '$pack_name' has no requirements.txt (not cloned?); skipping" >&2
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
# --- stage 3d: optional browser-bridge binaries --------------------------------
|
||||||
|
# The browser pack's python deps (Playwright) come from
|
||||||
|
# packs/browser/requirements.txt in stage 3c; this stage downloads the browser
|
||||||
|
# binary. Optional: lazy-imported, so a host without it still runs every other
|
||||||
|
# bridge. Browsers go under the checkout's .runtime/browser (the containment
|
||||||
|
# rule); the bridge sets PLAYWRIGHT_BROWSERS_PATH to the same path at launch.
|
||||||
if [[ "$PLAN_BROWSER" = 1 ]]; then
|
if [[ "$PLAN_BROWSER" = 1 ]]; then
|
||||||
echo "== installing browser-bridge deps into $VENV"
|
|
||||||
"$PIP" install -r "$REPO_ROOT/requirements/browser.txt"
|
|
||||||
BROWSER_ENGINE="$("$PYTHON" - "$MERGED_CONFIG" <<'PY' 2>/dev/null || true
|
BROWSER_ENGINE="$("$PYTHON" - "$MERGED_CONFIG" <<'PY' 2>/dev/null || true
|
||||||
import json, sys
|
import json, sys
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -50,6 +50,17 @@ class SkillPack:
|
|||||||
{category for category, _ in self.store.list_skills()}
|
{category for category, _ in self.store.list_skills()}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def requirements_file(self) -> Path | None:
|
||||||
|
"""The pack's optional pip requirements file, if it ships one.
|
||||||
|
|
||||||
|
A pack owns its python deps: ``packs/<name>/requirements.txt`` (standard
|
||||||
|
pip format) is installed by ``scripts/bootstrap.sh`` when the pack is
|
||||||
|
selected (see ``setup.build_plan``). Returns ``None`` when absent.
|
||||||
|
"""
|
||||||
|
path = self.path / "requirements.txt"
|
||||||
|
return path if path.is_file() else None
|
||||||
|
|
||||||
|
|
||||||
def _parse_pack(manifest_path: Path) -> SkillPack:
|
def _parse_pack(manifest_path: Path) -> SkillPack:
|
||||||
data = json.loads(manifest_path.read_text())
|
data = json.loads(manifest_path.read_text())
|
||||||
|
|||||||
@@ -616,6 +616,11 @@ def build_plan(answers: Answers, packs: Sequence[SkillPack]) -> dict:
|
|||||||
"authoring": answers.new_skill_creation,
|
"authoring": answers.new_skill_creation,
|
||||||
"packs": list(answers.packs),
|
"packs": list(answers.packs),
|
||||||
"bridge_packs": bridge_packs,
|
"bridge_packs": bridge_packs,
|
||||||
|
# Packs that ship their own python deps (packs/<name>/requirements.txt);
|
||||||
|
# bootstrap pip-installs each. See PACKGEN.md, "Pack python deps".
|
||||||
|
"pack_requirements": [
|
||||||
|
p.name for p in packs if p.name in answers.packs and p.requirements_file
|
||||||
|
],
|
||||||
"gateways": list(answers.gateways),
|
"gateways": list(answers.gateways),
|
||||||
# Platforms the systemd gateway unit runs (voice is foreground-only).
|
# Platforms the systemd gateway unit runs (voice is foreground-only).
|
||||||
"gateway_platforms": daemon_gateways,
|
"gateway_platforms": daemon_gateways,
|
||||||
@@ -648,6 +653,9 @@ def plan_from_config(config: dict, packs: Sequence[SkillPack]) -> dict:
|
|||||||
"authoring": str(config.get("new_skill_creation", "deny") or "deny"),
|
"authoring": str(config.get("new_skill_creation", "deny") or "deny"),
|
||||||
"packs": enabled,
|
"packs": enabled,
|
||||||
"bridge_packs": bridge_packs,
|
"bridge_packs": bridge_packs,
|
||||||
|
"pack_requirements": [
|
||||||
|
p.name for p in packs if p.name in enabled and p.requirements_file
|
||||||
|
],
|
||||||
"gateways": gateways,
|
"gateways": gateways,
|
||||||
"gateway_platforms": daemon_gateways,
|
"gateway_platforms": daemon_gateways,
|
||||||
"install_engine": engine_provider == "semif",
|
"install_engine": engine_provider == "semif",
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ from semif_agent.packs import (
|
|||||||
PACKS = Path(__file__).resolve().parent.parent / "packs"
|
PACKS = Path(__file__).resolve().parent.parent / "packs"
|
||||||
SKILL_DIRS = sorted(path.parent for path in PACKS.glob("*/skills/*/*/skill.py"))
|
SKILL_DIRS = sorted(path.parent for path in PACKS.glob("*/skills/*/*/skill.py"))
|
||||||
BRIDGE_TESTS = sorted(PACKS.glob("*/bridge/test_*.py"))
|
BRIDGE_TESTS = sorted(PACKS.glob("*/bridge/test_*.py"))
|
||||||
|
PACK_REQUIREMENTS = sorted(PACKS.glob("*/requirements.txt"))
|
||||||
|
|
||||||
|
|
||||||
def seed_id(seed: Path) -> str:
|
def seed_id(seed: Path) -> str:
|
||||||
@@ -88,6 +89,34 @@ def test_merge_packs_loads_enabled_and_skips_disabled():
|
|||||||
assert tree["nextcloud"][0].category_description
|
assert tree["nextcloud"][0].category_description
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"req_file",
|
||||||
|
PACK_REQUIREMENTS,
|
||||||
|
ids=[f"{p.parent.name}/{p.name}" for p in PACK_REQUIREMENTS],
|
||||||
|
)
|
||||||
|
def test_pack_requirements_are_pinned_and_consistent(req_file):
|
||||||
|
"""A pack owns its python deps: `packs/<name>/requirements.txt`.
|
||||||
|
|
||||||
|
Every line is pinned (a shipped integration installs exact versions) and the
|
||||||
|
manifest's human-readable `requires` summary stays consistent with the file.
|
||||||
|
"""
|
||||||
|
packs = {p.name: p for p in load_packs({"skill_packs": str(PACKS)})}
|
||||||
|
pack = packs[req_file.parent.name]
|
||||||
|
assert pack.requirements_file == req_file
|
||||||
|
lines = [
|
||||||
|
line.strip()
|
||||||
|
for line in req_file.read_text().splitlines()
|
||||||
|
if line.strip() and not line.strip().startswith("#")
|
||||||
|
]
|
||||||
|
assert lines, f"{req_file} declares no requirements"
|
||||||
|
for line in lines:
|
||||||
|
assert "==" in line, f"{req_file}: pin the version ({line!r})"
|
||||||
|
for dep in pack.requires:
|
||||||
|
assert any(dep.lower() in line.lower() for line in lines), (
|
||||||
|
f"{req_file}: manifest requires {dep!r} but requirements.txt omits it"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_manifestless_pack_root_is_one_implicit_pack(tmp_path):
|
def test_manifestless_pack_root_is_one_implicit_pack(tmp_path):
|
||||||
directory = tmp_path / "my_skills" / "widgets" / "frobnicate"
|
directory = tmp_path / "my_skills" / "widgets" / "frobnicate"
|
||||||
directory.mkdir(parents=True)
|
directory.mkdir(parents=True)
|
||||||
|
|||||||
@@ -88,6 +88,7 @@ def test_minimum_plan_installs_nothing_heavy():
|
|||||||
assert plan["install_browser"] is False
|
assert plan["install_browser"] is False
|
||||||
assert plan["install_voice"] is False
|
assert plan["install_voice"] is False
|
||||||
assert plan["packs"] == ["essentials"]
|
assert plan["packs"] == ["essentials"]
|
||||||
|
assert plan["pack_requirements"] == []
|
||||||
|
|
||||||
|
|
||||||
# --------------------------------------------------------------------------- #
|
# --------------------------------------------------------------------------- #
|
||||||
@@ -139,6 +140,8 @@ def test_maximum_config_enables_everything():
|
|||||||
assert plan["install_voice"] is True
|
assert plan["install_voice"] is True
|
||||||
assert plan["install_bridge_service"] is True
|
assert plan["install_bridge_service"] is True
|
||||||
assert plan["install_gateway_service"] is True
|
assert plan["install_gateway_service"] is True
|
||||||
|
# The browser pack ships its own python deps; the plan names it for bootstrap.
|
||||||
|
assert plan["pack_requirements"] == ["browser"]
|
||||||
|
|
||||||
secrets = build_secrets(answers)
|
secrets = build_secrets(answers)
|
||||||
assert secrets["engine_winnow_api_key"] == "wk"
|
assert secrets["engine_winnow_api_key"] == "wk"
|
||||||
|
|||||||
Reference in new issue
Block a user