Compare commits

...
4 Commits
Author SHA1 Message Date
gabby 0b02a3feac spec: skills may call a plain HTTP API directly; bridges are opt-in
Reframe bridges as a deliberate choice rather than the mandatory path to
any third-party system. A skill body may call a service's own HTTP API
directly with a stdlib transport; a bridge is warranted only when a
simple, repeatable skill file would be inconsistent, inconvenient, or
unsafe — state (especially auth state), sanitized connectivity, or a
native/heavy protocol. When a bridge fronts a service, the body calls the
bridge and must never reach around it.

Updates CODEGEN.md, PACKGEN.md, TESTGEN.md, README.md, AGENTS.md, the
bridges/__init__.py docstring, the codegen BODY_DIRECTIVES + describe_
bridges() prompt strings, and the tests pinning their wording.
2026-10-13 18:13:24 +00:00
gabby f379c0a746 packs: add PACKGEN.md contract + packgen skill
PACKGEN.md is the authoritative spec for a new pack, the sibling of
CODEGEN.md (body) and TESTGEN.md (test): the pack.json manifest, its
config schema and how it maps onto bridges.<name>/packs.<name>, the
enable switch, referencing a bridge by name, authoring a new bridge
(BridgeService + CATALOG + build_bridge + the optional-dep 503 rule),
acceptance criteria, a worked example, and a checklist.

Add a thin OpenCode skill (.opencode/skills/packgen/SKILL.md) that walks
the workflow and points at PACKGEN.md, and cross-link the contract from
AGENTS.md, README.md, CODEGEN.md, and TESTGEN.md.
2026-10-13 15:25:42 +00:00
gabby 711dba2f03 new-skill creation: deny by default, refuse silently
A host now leans on the committed packs: `new_skill_creation` defaults to
`deny` (core schema, generated config.example.json, and the scheduler's unset
fallback), so a fresh bootstrap does not author skills at runtime. A host with
the resources opts in with `allow` (or `ask`).

Under deny, an unmatched request no longer exposes the authoring machinery:
`_blocked_create` answers with a plain refusal (`skills.UNABLE_MESSAGE`, "I'm
sorry, I'm not able to help with that.") instead of an error naming
`new_skill_creation`/`config.json`, and a leftover empty/in-progress leaf in a
denied category refuses the same way rather than telling the user to `restart`
the body write. The block is still traced (`category_create_blocked` /
`skill_create_blocked`) for operators. Routing, decision logging, and the
allow/ask paths are unchanged.

Tests: authoring-mechanics helpers opt in explicitly; the default-deny and
silent-refusal cases are asserted.
2026-10-13 15:01:12 +00:00
gabby 78b4621ba0 Abstract seeds into modular skill packs + split config
Group committed starter skills into packs (semif_agent/packs.py) that bind a
concern to its categories, bridge(s), requirements, and config schema:

- seeds/ -> packs/<name>/ with a pack.json manifest + skills/<category>/<leaf>/.
  Shipped: nextcloud, simplex, outlook, browser (each owning its bridge) and
  essentials (time + calculator, no bridge).
- PackRegistry discovers packs (a root with no manifest is one implicit pack);
  merge_packs loads every enabled pack. Pack enable is one switch
  (packs.<name>.enabled -> bridges.<bridge>.enabled -> enabled_by_default);
  disabling a pack drops its categories (incl. generated bodies) and its bridge.
- CATEGORY_DESCRIPTIONS now comes from the pack manifests (built-ins stay).

Adopt a Home-Assistant-style layered config (semif_agent/config.py):

- config.json is a thin index ({"include": [...]}) over config/core.json,
  config/gateway.json, config/bridges.json, config/packs/*.json, deep-merged.
- Secrets live in the gitignored secrets.json, referenced as "!secret <key>";
  api_key_env is removed.
- CORE_SCHEMA + each pack's config schema own defaults and GENERATE the
  committed config.example.json; new `check-config` (validate + --write-example)
  and `config-init` (seed the split layout) commands.
- scripts/config_merge.py (stdlib) lets bootstrap read the merged config.

Tests: tests/test_packs.py (renamed from test_seed_skills, +enable/merge),
new tests/test_config.py. All unit tests pass (772).
2026-10-13 14:20:35 +00:00
123 changed files with 2413 additions and 506 deletions

No files matched your search

+2
View File
@@ -12,6 +12,8 @@ data/skills/
data/drafts/ data/drafts/
.pytest_cache/ .pytest_cache/
config.json config.json
config/
secrets.json
*.log *.log
# Machine-specific material: deployment notes (hostnames, addresses, SSH, # Machine-specific material: deployment notes (hostnames, addresses, SSH,
# model choices), GPU offload probe, benchmark harness. Deliberately not part # model choices), GPU offload probe, benchmark harness. Deliberately not part
+56
View File
@@ -0,0 +1,56 @@
---
name: Pack Generation
description: Author a new semif-agent skill pack (packs/<name>/) — the pack.json manifest, its skill leaves, its bridge reference, and its config schema. Use when adding a new concern/product bundle under packs/, or when adding a new bridge service to back one.
---
# Pack Generation
This skill walks you through adding a **pack** to semif-agent. The full contract
is the repository file `PACKGEN.md` (at the repo root, i.e. `../../../PACKGEN.md`
relative to this skill). Read it before making changes — it is the source of
truth and this skill is only the workflow.
## When to use
- The user wants a new concern/product bundle under `packs/<name>/`.
- The user wants a new third-party service backed by a bridge in
`semif_agent/bridges/`.
- The user is adding skills that should ship as committed seeds rather than be
authored at runtime.
## Workflow
1. **Read `PACKGEN.md`** in full.
2. **Decide the concern and categories.** Write one- to two-sentence,
navigation-grade category descriptions — SemIf routes on them.
3. **Bridge check.** If the pack talks to a third-party system, confirm a bridge
already fronts it in `semif_agent/bridges/registry.py` `CATALOG`. If not,
author the bridge first (see the "Authoring a new bridge" section of
`PACKGEN.md`), register it in `CATALOG`, and give it a pack config block.
4. **Create `packs/<name>/pack.json`** with `name`, `title`, `concern`,
`categories`, `bridges`, `requires`, `enabled_by_default`, and the `config`
schema. Model it on `packs/essentials/pack.json` (bridge-less) or
`packs/simplex/pack.json` (bridge-backed).
5. **Add each leaf** under `skills/<category>/<leaf>/` — `skill.py`,
`manifest.json`, `contract.json`, `skill.test.py` — following `CODEGEN.md`
and `TESTGEN.md`. Do not restate those rules; follow them.
6. **Regenerate and validate config:**
`python -m semif_agent.cli check-config --write-example config.example.json`
then `python -m semif_agent.cli check-config`.
7. **Run the tests:**
`python3 -m pytest tests/test_packs.py tests/test_codegen.py -q`
(plus `tests/test_<name>_bridge.py` if you added a bridge).
8. **Cross-link** the pack/bridge in `AGENTS.md` (and `README.md` for a shipped
pack).
9. **Verify a real run** against the user's actual service — a passing hermetic
test proves mechanics only, never the live integration.
## Guardrails
- A pack is declarative and committed; never put a credential in it (secrets
live in the gitignored `secrets.json`).
- Bridge *code* stays in `semif_agent/bridges/`; a pack only references a bridge
by name. Never widen the gateway.
- `concern` and `categories` are required; every category needs a description.
- Regenerate `config.example.json` from the schema after any schema change; the
example and the live config are never hand-edited.
+190 -72
View File
@@ -10,8 +10,11 @@ basic task in plain language, and it does it:
1. The user asks for a task ("check my email", "message Sam on SimpleX", "put 1. The user asks for a task ("check my email", "message Sam on SimpleX", "put
lunch with Dana on my Nextcloud calendar"). lunch with Dana on my Nextcloud calendar").
2. If the skill tree already knows how, the agent does it. 2. If the skill tree already knows how, the agent does it.
3. If it does not, the agent asks the user a few questions about what they want 3. If it does not, the agent says it cannot help — unless the host has opted in
and how it should connect, generates a new skill, and then does it. to live skill authoring (the default is **deny**; see "New-skill creation
mode" below), in which case it asks a few questions and generates a new skill.
The primary way to extend the agent is the committed **skill packs**
(`packs/`), not runtime authoring.
4. It performs the task for real, against the user's actual service. If the 4. It performs the task for real, against the user's actual service. If the
real attempt fails, it says so and offers to fix/learn. It never pretends a real attempt fails, it says so and offers to fix/learn. It never pretends a
task succeeded. task succeeded.
@@ -64,7 +67,20 @@ capability is a new bridge, not a gateway feature.
``` ```
cli.py argparse: run (REPL / --script), dream, skills, status, relabel, cli.py argparse: run (REPL / --script), dream, skills, status, relabel,
dashboard, gateway (command intake), bridge (standalone dashboard, gateway (command intake), bridge (standalone
third-party API bridges) third-party API bridges), check-config (validate config/
against the core + pack schemas), config-init (seed the split
config/ + secrets.json)
config.py layered per-machine config: config.json is a thin index
(`{"include": [...]}`) over config/core.json + config/gateway.json
+ config/bridges.json + config/packs/<name>.json, deep-merged in
order; `"!secret <key>"` resolves from the gitignored
secrets.json; the core schema owns defaults and, with each
pack's `config` schema, GENERATES config.example.json
(check-config --write-example) and validates a live config
packs.py SkillPack + PackRegistry: discovers packs/ (a `pack.json`
manifest + skills/<category>/<leaf>/), binds a concern to its
categories, bridge(s), requirements, and config schema;
merge_packs loads every enabled pack into the tree
scheduler.py no up-front gate: every input is dispatched scheduler.py no up-front gate: every input is dispatched
-> FIFO queue when busy; a skill run paused for input -> FIFO queue when busy; a skill run paused for input
(needs_input) keeps `current` busy; `answer` routes straight to (needs_input) keeps `current` busy; `answer` routes straight to
@@ -100,7 +116,8 @@ scheduler.py no up-front gate: every input is dispatched
monotonic-progress guard; monotonic-progress guard;
housekeeping meta skills (delete/clear-config/regen/cancel-build) housekeeping meta skills (delete/clear-config/regen/cancel-build)
operate on the tree via `ctx.admin`; new-skill creation is gated by operate on the tree via `ctx.admin`; new-skill creation is gated by
a tri-state mode (`new_skill_creation`: allow/deny/ask) with a a tri-state mode (`new_skill_creation`: deny/allow/ask, **deny by
default**) with a
per-category override in the category config, with per-category override in the category config, with
`housekeeping`/`response` always denied in code; front ends get a `housekeeping`/`response` always denied in code; front ends get a
structured `SchedulerReply` (status, text, run_id, skill_ref, structured `SchedulerReply` (status, text, run_id, skill_ref,
@@ -122,8 +139,10 @@ skills.py tree + registry (hardcoded built-ins: the closed `response` canned
(skill.py, skill.test.py, contract.json, config.json) and (skill.py, skill.test.py, contract.json, config.json) and
materialize_skill / merge_skill_store materialize_skill / merge_skill_store
hot-load runnable skills from data/skills/; hot-load runnable skills from data/skills/;
merge_seed_store loads committed starter skills from seeds/ with merge_packs (semif_agent/packs.py) loads committed pack skills
their recorded config read from data/skills/; from packs/<name>/skills/ with their recorded config read from
data/skills/ (each pack bundles its concern, category scope,
bridge, and config schema);
ActionResult.needs_input pauses a run for human input; ActionResult.needs_input pauses a run for human input;
Skill.integration / integration_source read the body's Skill.integration / integration_source read the body's
INTEGRATION declaration (or infer it); Skill.contract is read INTEGRATION declaration (or infer it); Skill.contract is read
@@ -291,7 +310,7 @@ bridges/ standalone third-party API bridges (SimpleX, the LLM bridge,
and Notes (OCS) behind one JSON surface, so bodies never speak and Notes (OCS) behind one JSON surface, so bodies never speak
DAV/OCS; no service daemon (stdlib-only), connection from DAV/OCS; no service daemon (stdlib-only), connection from
`bridges.nextcloud` with a fallback to the top-level `bridges.nextcloud` with a fallback to the top-level
`nextcloud_*` values the nextcloud seeds use. `nextcloud_*` values the nextcloud pack skills use.
outlook.py + outlook_client.py: OutlookBridge — the user's outlook.py + outlook_client.py: OutlookBridge — the user's
Microsoft account (Outlook / Microsoft 365) over Microsoft Graph: Microsoft account (Outlook / Microsoft 365) over Microsoft Graph:
mail, calendar events, Microsoft To Do tasks, contacts, and mail, calendar events, Microsoft To Do tasks, contacts, and
@@ -359,11 +378,20 @@ values are yours to choose.
## Git / sync ## Git / sync
- Push/pull from your git remote — never rsync/tar the code. - Push/pull from your git remote — never rsync/tar the code.
- **`config.json` is gitignored, per-machine, and required** (hosts use - **`config.json` (a thin index), the `config/` fragments, and `secrets.json` are
different LLM/codegen endpoints and models). `scripts/bootstrap.sh` seeds it gitignored, per-machine, and required** (hosts use different LLM/codegen
from `config.example.json` once (only when absent) and **nothing writes it endpoints and models). `config.json` is an index (`{"include": [...]}`);
afterwards — only a human edits `config.json`**. `data/decisions.jsonl`, `config/core.json` + `config/gateway.json` + `config/bridges.json` +
`data/runs.jsonl`, and `data/drafts/` are runtime artifacts and gitignored too. `config/packs/<name>.json` hold the values, and `secrets.json` holds
credentials referenced as `"!secret <key>"`. `scripts/bootstrap.sh` seeds the
split config once (via `config-init`, only when `config.json` is absent) and
**nothing writes it afterwards — only a human edits it**. The committed
`config.example.json` is GENERATED from the core schema
(`semif_agent/config.py`) and each pack's `config` schema — regenerate it with
`python -m semif_agent.cli check-config --write-example config.example.json`
after changing a schema; validate a live config with `check-config`.
`data/decisions.jsonl`, `data/runs.jsonl`, and `data/drafts/` are runtime
artifacts and gitignored too.
- **`pins.json` is committed and code-owned** — the single home for every - **`pins.json` is committed and code-owned** — the single home for every
external ref (SemIf commit, GGUF url+sha256, HF tokenizer revision, external ref (SemIf commit, GGUF url+sha256, HF tokenizer revision,
simplex-chat version/url+sha256). These are bumped by a git change and picked simplex-chat version/url+sha256). These are bumped by a git change and picked
@@ -455,7 +483,10 @@ CLI, unit tests (24) + integration tests (2).
softmax), and the scope guard is deliberately permissive. A request no skill softmax), and the scope guard is deliberately permissive. A request no skill
covers (e.g. "what is 255 * 12?") authors instead of getting a canned reply, covers (e.g. "what is 255 * 12?") authors instead of getting a canned reply,
while a stray statement (e.g. "1+1=2") or a vague fragment (e.g. "what") still while a stray statement (e.g. "1+1=2") or a vague fragment (e.g. "what") still
gets one. All three taus are gets one — **unless new-skill creation is denied** (see the tri-state mode
below), in which case an unservable request gets a plain refusal
(`skills.UNABLE_MESSAGE`, "I'm sorry, I'm not able to help with that.") and is
never told that authoring exists. All three taus are
separate from the top-level `tau`, so tuning reuse-vs-create or actionability separate from the top-level `tau`, so tuning reuse-vs-create or actionability
does not move assessment/fidelity. The guards are deliberately permissive does not move assessment/fidelity. The guards are deliberately permissive
(in-scope scores 0.9–1.0): a borderline over-cover routes into a plausible (in-scope scores 0.9–1.0): a borderline over-cover routes into a plausible
@@ -473,24 +504,31 @@ CLI, unit tests (24) + integration tests (2).
runs at the top of navigation and sends a request to authoring (this is what runs at the top of navigation and sends a request to authoring (this is what
keeps "what is 255 * 12?" out of the tree; the old keeps "what is 255 * 12?" out of the tree; the old
`response.unable` canned refusal is gone — an unsupported request authors a `response.unable` canned refusal is gone — an unsupported request authors a
skill, it is not refused). A fragment too vague/incomplete to act on (e.g. skill, it is not refused, **except under `new_skill_creation: deny`, where it
"what") is non-action, so it lands on the catchall `response.clarify` rather gets the plain `UNABLE_MESSAGE` refusal**). A fragment too vague/incomplete to
than authoring a redundant clarify skill. `response` is a `CANNED_CATEGORIES` member: act on (e.g. "what") is non-action, so it lands on the catchall
`response.clarify` rather than authoring a redundant clarify skill. `response`
is a `CANNED_CATEGORIES` member:
`navigate` never offers `create_skill` there (the intent guard is skipped `navigate` never offers `create_skill` there (the intent guard is skipped
too), `Scheduler._dispatch_skill`/`restart_skill` refuse to author it, and the too), `Scheduler._dispatch_skill`/`restart_skill` refuse to author it, and the
runner skips `assess:outcome`/repair for it — a canned line has no side effect runner skips `assess:outcome`/repair for it — a canned line has no side effect
to assess. The leaf choice logs phase `navigate:response` and traces to assess. The leaf choice logs phase `navigate:response` and traces
`response_selected`. `response.reject` (a stub that never ran) is gone. `response_selected`. `response.reject` (a stub that never ran) is gone.
- **New-skill creation mode: allow / deny / ask** (Oct 2026; tri-state Oct 2026): - **New-skill creation mode: deny / allow / ask** (Oct 2026; tri-state Oct 2026;
one setting governs whether the agent may author new skills/categories, as a deny-by-default Oct 2026): one setting governs whether the agent may author new
three-way mode. **Global default** is the top-level `new_skill_creation` skills/categories, as a three-way mode. **Global default** is the top-level
(`"allow"` default, `"deny"`, or `"ask"`); a category overrides it with its `new_skill_creation` — **`"deny"` by default** (the agent leans on the
own `new_skill_creation` in `data/skills/<category>/config.json` (absent = committed packs, the primary way to extend functionality), with `"allow"` an
inherit the global). `allow` authors immediately; `deny` blocks authoring explicit opt-in for a host with the resources, or `"ask"`; a category overrides
it with its own `new_skill_creation` in `data/skills/<category>/config.json`
(absent = inherit the global). `allow` authors immediately; `deny` blocks authoring
outright (`Scheduler._blocked_create`, traced `skill_create_blocked` / outright (`Scheduler._blocked_create`, traced `skill_create_blocked` /
`category_create_blocked`); `ask` authors only after the human approves the `category_create_blocked`) **and answers the request with a plain refusal**
proposal. The `ask` path is the old approval gate: the single-slot `llm` draft (`skills.UNABLE_MESSAGE`) that never names a category, skill, or config — a
worker blocks after it authors a proposal and before anything is registered; denied deployment gives no hint that authoring exists; `ask` authors only
after the human approves the proposal. The `ask` path is the old approval
gate: the single-slot `llm` draft worker blocks after it authors a proposal
and before anything is registered;
the human approves/denies via the REPL prompt, the dashboard approvals panel the human approves/denies via the REPL prompt, the dashboard approvals panel
(`GET/POST /api/approvals`), or a gateway chat reply (`yes`/`no`). One prompt (`GET/POST /api/approvals`), or a gateway chat reply (`yes`/`no`). One prompt
per creation request — a new category's chained skill is covered by the per creation request — a new category's chained skill is covered by the
@@ -762,6 +800,29 @@ CLI, unit tests (24) + integration tests (2).
into `.runtime/models/` by bootstrap. Load ~34s; score ~0.9s/decision on CPU into `.runtime/models/` by bootstrap. Load ~34s; score ~0.9s/decision on CPU
at 8 threads. at 8 threads.
### configuration (split + secrets)
- **Three layers, mirroring Home Assistant.** Declarative structure is committed
(`pack.json` manifests + the core schema); per-machine values are the split
config; secrets are a separate gitignored file. `config.json` is a **thin
index** (`{"include": ["config/core.json", "config/gateway.json",
"config/bridges.json", "config/packs/<name>.json", ...]}`); fragments are
deep-merged in order (later wins). `semif_agent/config.py` owns the loader.
- **Secrets.** A value written as `"!secret <key>"` resolves from the gitignored
`secrets.json` at load (the analog of HA's `!secret`). A missing key resolves
to `""` at load (so startup never hard-fails) and is reported by `check-config`.
**`api_key_env` is gone** — `secrets.json` is the one place credentials live.
- **Schema owns defaults.** `semif_agent/config.py` `CORE_SCHEMA` (core sections)
plus each pack's `config` schema (bridge blocks) own every default. The
committed `config.example.json` is GENERATED from them
(`check-config --write-example config.example.json`); secret keys are emitted
as `"!secret <name>"`, never a real value. `check-config` validates a live
config (type mismatches and missing secrets are errors; unknown keys warn).
- **Seeding.** `config-init` writes the split layout + an empty `secrets.json`
from the schemas (bootstrap calls it once, only when `config.json` is absent);
afterwards only a human edits it. `scripts/config_merge.py` is the stdlib-only
merger bootstrap uses before the venv exists.
### ollama ### ollama
- `bootstrap.sh` installs **no ollama**: it expects the target host to already - `bootstrap.sh` installs **no ollama**: it expects the target host to already
run one for `llm` (and pulls `llm.model` into it), while `codegen` may be run one for `llm` (and pulls `llm.model` into it), while `codegen` may be
@@ -787,10 +848,13 @@ CLI, unit tests (24) + integration tests (2).
- Provision a fresh Ubuntu machine into a running host: clone `semif-agent` to - Provision a fresh Ubuntu machine into a running host: clone `semif-agent` to
a checkout (register its SSH key on your git host first), then run a checkout (register its SSH key on your git host first), then run
`scripts/bootstrap.sh`. With no `config.json` yet it seeds one from `scripts/bootstrap.sh`. With no `config.json` yet it seeds the split config
`config.example.json`; edit that to set `llm.model`/`codegen.model` and the (`config-init` writes `config/core.json`, `config/gateway.json`,
endpoints. Flags (`--llm-url`, `--codegen-url`, `--llm-model`, `config/bridges.json`, `config/packs/*.json`, the `config.json` index, and an
`--codegen-model`) override the values read from `config.json` **for that run empty `secrets.json`); edit those to set `llm.model`/`codegen.model` and the
endpoints, and put credentials in `secrets.json`. Flags (`--llm-url`,
`--codegen-url`, `--llm-model`,
`--codegen-model`) override the values read from the merged config **for that run
only** and are never written back. `--voice` additionally installs the only** and are never written back. `--voice` additionally installs the
optional voice-gateway stack (`requirements/voice.txt` + system optional voice-gateway stack (`requirements/voice.txt` + system
`libportaudio2` + `alsa-utils`) and downloads its models into `.runtime/voice/` via `libportaudio2` + `alsa-utils`) and downloads its models into `.runtime/voice/` via
@@ -828,9 +892,12 @@ CLI, unit tests (24) + integration tests (2).
that we intentionally do not install — the llama.cpp CPU path doesn't need that we intentionally do not install — the llama.cpp CPU path doesn't need
them; numpy 2.3.5 is deliberate, 2.2.6 has no cp314 wheel). Do not "fix" them them; numpy 2.3.5 is deliberate, 2.2.6 has no cp314 wheel). Do not "fix" them
by installing torch. by installing torch.
- Seeds `config.json` from `config.example.json` (only when absent) and **never - Seeds the split config (`config-init`: `config/core.json`,
writes it again** — only a human edits `config.json`. `config.example.json` `config/gateway.json`, `config/bridges.json`, `config/packs/*.json`, the
ships the provisioned defaults, so a seeded `config.json` already has `config.json` index, and an empty `secrets.json`) only when `config.json` is
absent, and **never writes it again** — only a human edits it. The committed
`config.example.json` is GENERATED from the core + pack schemas and ships the
provisioned defaults, so a seeded config already has
`codegen.timeout: 3600`, the SimpleX gateway enabled `codegen.timeout: 3600`, the SimpleX gateway enabled
(`gateway.simplex.enabled = true`, `ws_url` from `simplex_chat.port`) and the (`gateway.simplex.enabled = true`, `ws_url` from `simplex_chat.port`) and the
standalone forwarding bridge enabled (`bridges.simplex.enabled = true`, standalone forwarding bridge enabled (`bridges.simplex.enabled = true`,
@@ -838,7 +905,7 @@ CLI, unit tests (24) + integration tests (2).
the LLM bridge enabled (`bridges.llm.enabled = true`; it reuses the `llm` the LLM bridge enabled (`bridges.llm.enabled = true`; it reuses the `llm`
model); model);
the operator sets `llm.model`/`llm.base_url` and `codegen.model`/ the operator sets `llm.model`/`llm.base_url` and `codegen.model`/
`codegen.base_url`. Bootstrap renders/enables four user services: `codegen.base_url`, and puts credentials in `secrets.json`. Bootstrap renders/enables four user services:
`semif-simplex.service` (the command `simplex-chat` bot daemon, `semif-simplex.service` (the command `simplex-chat` bot daemon,
`--create-bot-display-name` on `simplex_chat.port`), `semif-gateway.service` `--create-bot-display-name` on `simplex_chat.port`), `semif-gateway.service`
(`.runtime/venv/bin/python -m semif_agent.cli gateway`), (`.runtime/venv/bin/python -m semif_agent.cli gateway`),
@@ -881,8 +948,8 @@ CLI, unit tests (24) + integration tests (2).
inference API instead of local ollama: set `llm.provider` / `codegen.provider` inference API instead of local ollama: set `llm.provider` / `codegen.provider`
to `"opencode"` (default `"ollama"`), set `model` to a **Chat Completions** to `"opencode"` (default `"ollama"`), set `model` to a **Chat Completions**
family id (`kimi-k2.7-code`, `glm-5.3`, `deepseek-v4.1-flash`, `qwen3.8-max`, family id (`kimi-k2.7-code`, `glm-5.3`, `deepseek-v4.1-flash`, `qwen3.8-max`,
the free models, …), and give `api_key` (literal) or `api_key_env` (env var the free models, …), and set `api_key` to `"!secret <key>"` with the key in
name — preferred). `build_scheduler` maps `"opencode"` → `ConsoleLLMClient` / `secrets.json` (a literal `api_key` also works). `build_scheduler` maps `"opencode"` → `ConsoleLLMClient` /
`ConsoleCodegenClient`, which keep the existing error contracts `ConsoleCodegenClient`, which keep the existing error contracts
(`LLMError` / `CodegenError` / `DegenerationError`) and the same opt-in (`LLMError` / `CodegenError` / `DegenerationError`) and the same opt-in
sampler behavior (none sent unless configured). The `OpenAICompatClient` sampler behavior (none sent unless configured). The `OpenAICompatClient`
@@ -922,39 +989,49 @@ CLI, unit tests (24) + integration tests (2).
check** (inline fixtures, loopback `http.server` for HTTP bodies, no external check** (inline fixtures, loopback `http.server` for HTTP bodies, no external
network) that never certifies the live integration — only a real run does. network) that never certifies the live integration — only a real run does.
The body owns no data; everything comes from the runner via `ctx.config`. The body owns no data; everything comes from the runner via `ctx.config`.
- **Seed skills.** `seeds/<category>/<name>/` ships a real starter integration in - **Skill packs.** `packs/<name>/` bundles a concern with its skills: a
the exact generated-skill folder format (`skill.py`, `contract.json`, `pack.json` manifest (name, concern, `categories` → descriptions, `bridges`
`skill.test.py`, plus `manifest.json` with the description). `merge_seed_store` referenced by name, `requires`, and a `config` schema) plus
loads them into every tree at startup; recorded config (credentials collected `skills/<category>/<name>/` in the exact generated-skill folder format
at first fire) is written to the runtime store `data/skills/`, so the committed (`skill.py`, `contract.json`, `skill.test.py`, plus `manifest.json` with the
seed never holds secrets, and a generated body with the same name replaces the description). `semif_agent/packs.py` discovers them (`PackRegistry`, scanning
seed. `nextcloud.create_event` is the authoritative worked example (CalDAV PUT; `skill_packs` roots for `*/pack.json`; a root with no manifest is one implicit
derives the title/date/time from the query, asks for missing fields and pack), and `merge_packs` loads every **enabled** pack into the tree at startup.
resumes, resolves the target calendar with a SemIf choice over the owned Pack enable is one switch: an explicit `packs.<name>.enabled`, else a bridge
calendars — a strong winner is used, otherwise the configured default); pack follows `bridges.<bridge>.enabled`, else `enabled_by_default`. Disabling a
`nextcloud.next_event` is the read counterpart (Nextcloud CalDAV, recurring pack drops its categories entirely (including generated bodies authored into
events expanded server-side); `nextcloud.create_task` one) and stops its bridge. Recorded config (credentials collected at first
fire) is written to the runtime store `data/skills/`, so the committed pack
never holds secrets, and a generated body with the same name replaces the pack
skill. The shipped packs: `nextcloud`, `simplex`, `outlook`, `browser` (each
owning its bridge), and `essentials` (the built-in local utilities `time` +
`calculator`; no bridge). `nextcloud.create_event` is the authoritative worked
example (CalDAV PUT; derives the title/date/time from the query, asks for
missing fields and resumes, resolves the target calendar with a SemIf choice
over the owned calendars — a strong winner is used, otherwise the configured
default); `nextcloud.next_event` is the read counterpart (Nextcloud CalDAV,
recurring events expanded server-side); `nextcloud.create_task`
adds a task to a Nextcloud task list through the Nextcloud bridge (`GET adds a task to a Nextcloud task list through the Nextcloud bridge (`GET
/tasklists` for a VTODO-capable target, `POST /tasks` to create it, the LLM /tasklists` for a VTODO-capable target, `POST /tasks` to create it, the LLM
bridge to phrase the summary/description); `simplex.next_message` (read via the bridge to phrase the summary/description); `simplex.next_message` (read via the
forwarding bridge), `simplex.send_message` (send to a contact resolved over the forwarding bridge), `simplex.send_message` (send to a contact resolved over the
bridge's contact list), and `simplex.connect_link` (show/create the forwarding bridge's contact list), and `simplex.connect_link` (show/create the forwarding
bot's contact link) are the messenger seeds; `time.now`, `time.date`, `time.set_timer`, and bot's contact link) are the messenger pack skills; `time.now`, `time.date`,
`time.set_alarm` are the local time utilities (`compute` transport, empty `time.set_timer`, and `time.set_alarm` are the local time utilities (`compute`
contract) — they read the host clock and schedule on `ctx.timers`. Local time transport, empty contract) — they read the host clock and schedule on
is the top-level `timezone` config value (an IANA name such as `ctx.timers`. Local time is the top-level `timezone` config value (an IANA name
`America/Chicago`; `timers.local_now`/`resolve_timezone` resolve it via such as `America/Chicago`; `timers.local_now`/`resolve_timezone` resolve it via
`zoneinfo`), falling back to the host's own timezone when it is empty or `zoneinfo`), falling back to the host's own timezone when it is empty or
unknown; `TimerService` formats due/fired times in that zone too. The nextcloud unknown; `TimerService` formats due/fired times in that zone too. The nextcloud
seeds derive "now" the same way, so a request time is parsed in the user's pack skills derive "now" the same way, so a request time is parsed in the
zone rather than the host's; `calculator.calculate` is the local-arithmetic user's zone rather than the host's; `calculator.calculate` is the
seed (`compute` transport, empty contract): bounded to two operands and one local-arithmetic skill (`compute` transport, empty contract): bounded to two
operator, the operator is a SemIf choice over addition/subtraction/ operands and one operator, the operator is a SemIf choice over addition/
multiplication/division/exponents/squares/cubes/square roots/cube roots/ subtraction/multiplication/division/exponents/squares/cubes/square roots/cube
fractions/percentages, SemIf picks the operands when the request offers more roots/fractions/percentages, SemIf picks the operands when the request offers
numbers than the operator consumes, and the answer is spelled out in words for more numbers than the operator consumes, and the answer is spelled out in words
the ear (an inexact result is announced as "approximately ..."); for the ear (an inexact result is announced as "approximately ...");
`tests/test_seed_skills.py` keeps them honest. `tests/test_packs.py` keeps every pack skill honest.
- **Contract provenance.** Each authored body records the CODEGEN.md revision it - **Contract provenance.** Each authored body records the CODEGEN.md revision it
was written against. `skill_contract_ref()` (`codegen.py`) returns was written against. `skill_contract_ref()` (`codegen.py`) returns
`{"ref", "dirty"}`: `ref` is the short git commit sha the contract was read `{"ref", "dirty"}`: `ref` is the short git commit sha the contract was read
@@ -1377,8 +1454,8 @@ CLI, unit tests (24) + integration tests (2).
exercises `SimplexBridge` over a real loopback server (peek/pop, recipient exercises `SimplexBridge` over a real loopback server (peek/pop, recipient
resolution, outbound routing, token/body validation, `/address` success/503/502, resolution, outbound routing, token/body validation, `/address` success/503/502,
daemon close on stop, catalog/`describe_bridges()`). daemon close on stop, catalog/`describe_bridges()`).
`tests/test_seed_skills.py` hermetically tests every `tests/test_packs.py` hermetically tests every
`seeds/<category>/<name>/` package, including `simplex.next_message`, `packs/<name>/skills/<category>/<leaf>/` package, including `simplex.next_message`,
`simplex.send_message`, and `simplex.send_message`, and
`simplex.connect_link`. `tests/test_voice_gateway.py` drives the voice loop `simplex.connect_link`. `tests/test_voice_gateway.py` drives the voice loop
with injected fake engines (wake gating, endpointing, half-duplex, with injected fake engines (wake gating, endpointing, half-duplex,
@@ -1399,13 +1476,54 @@ CLI, unit tests (24) + integration tests (2).
installs it and downloads the models (openWakeWord into the venv package dir, installs it and downloads the models (openWakeWord into the venv package dir,
the Piper voice into `.runtime/voice/tts`, faster-whisper into `.runtime/hf`). the Piper voice into `.runtime/voice/tts`, faster-whisper into `.runtime/hf`).
### skill packs (bundles)
- **The contract.** `PACKGEN.md` is the authoritative spec for a new pack —
`pack.json`, its `config` schema, its bridge reference, and how to author a
new bridge to back one. It is the sibling of `CODEGEN.md`/`TESTGEN.md`; read it
before adding anything under `packs/`.
- **What they are.** A pack bundles a concern/product with the skills that serve
it, in `packs/<name>/`: a `pack.json` manifest plus
`skills/<category>/<leaf>/` folders (the exact generated-skill format). The
manifest binds the pieces that used to be scattered by convention:
`concern`/`title`, `categories` (id -> scope description, feeding
`CATEGORY_DESCRIPTIONS`), `bridges` (names referencing `bridges/registry.py`
`CATALOG` — bridge *code* stays in `bridges/`, isolation is non-negotiable),
`requires` (optional deps like `playwright`), `enabled_by_default`, and a
`config` schema. `semif_agent/packs.py` discovers them (`PackRegistry`, which
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
**enabled** pack at startup.
- **Enable is one switch.** `pack_enabled` resolves: an explicit
`packs.<name>.enabled`, else a bridge pack follows its
`bridges.<bridge>.enabled`, else `enabled_by_default`. Disabling a pack drops
its categories entirely (including any generated body authored into one) and
stops its bridge — a host never offers a skill whose bridge is off. The switch
lives in the pack's `config/packs/<name>.json` fragment.
- **Config is pack-owned.** A pack's `config` schema (key -> `type`/`default`/
`doc`/`secret`) owns its defaults and drives both `config.example.json`
generation and `check-config` validation. Bridge packs map the schema onto
`bridges.<name>`; a bridge-less pack (e.g. `essentials`) maps onto
`packs.<name>`. Shared, skill-less bridges (the LLM bridge) live in
`semif_agent/config.py` `SHARED_BRIDGE_SCHEMA`.
- **Shipped packs.** `nextcloud`, `simplex`, `outlook`, `browser` (each owning
its bridge) and `essentials` (the built-in local utilities `time` +
`calculator`; no bridge). Adding a concern means adding a pack, not editing
`skills.py`.
### bridges (third-party API services) ### bridges (third-party API services)
- **What they are.** A bridge service is a standalone process that stands up a - **What they are.** A bridge service is a standalone process that stands up a
simple, secure localhost HTTP layer in front of one third-party system so a simple, secure localhost HTTP layer in front of one third-party system,
codegen-authored skill body never speaks that system's native protocol. warranted when the system needs state (especially auth state), a native or
heavy protocol, or one sanitized surface; a system with a plain HTTP API needs
no bridge — its skill calls the API directly. When a bridge fronts a service, a
codegen-authored skill body calls the bridge and never speaks that system's
native protocol.
SimpleX is the first; adding a service means adding a class to SimpleX is the first; adding a service means adding a class to
`bridges/registry.py` `CATALOG` and a `config.example.json` block. The catalog `bridges/registry.py` `CATALOG`, a `pack.json` whose `config` schema carries
its block (see `semif_agent/packs.py`; a shared, skill-less bridge like the
LLM bridge goes in the core `SHARED_BRIDGE_SCHEMA` instead). The catalog
(`BridgeInfo`: name, service, description, URL config var, other config vars (`BridgeInfo`: name, service, description, URL config var, other config vars
with one-line docs, auth header + token config var, and endpoints with with one-line docs, auth header + token config var, and endpoints with
request/response/error shapes) is injected into every codegen prompt request/response/error shapes) is injected into every codegen prompt
@@ -1454,7 +1572,7 @@ CLI, unit tests (24) + integration tests (2).
skill config. Skills reach a bridge with the ordinary `http` skill config. Skills reach a bridge with the ordinary `http`
transport, so their hermetic tests are loopback HTTP like any other HTTP body. transport, so their hermetic tests are loopback HTTP like any other HTTP body.
`simplex.next_message`, `simplex.send_message`, and `simplex.connect_link` are `simplex.next_message`, `simplex.send_message`, and `simplex.connect_link` are
the seeds. the pack skills.
- **LLM bridge** (`bridges/llm.py`). A generic `POST /chat` - **LLM bridge** (`bridges/llm.py`). A generic `POST /chat`
`{"messages": [{"role","content"}, ...], "max_tokens"?: int}` -> `{"messages": [{"role","content"}, ...], "max_tokens"?: int}` ->
`{"text": "<model reply>"}` (plus `GET /health`, `400` bad body, `502` model `{"text": "<model reply>"}` (plus `GET /health`, `400` bad body, `502` model
@@ -1482,7 +1600,7 @@ CLI, unit tests (24) + integration tests (2).
and `verify_tls`/`timeout`); `build_bridge` passes the top-level and `verify_tls`/`timeout`); `build_bridge` passes the top-level
`nextcloud_url`/`nextcloud_username`/`nextcloud_app_password`/ `nextcloud_url`/`nextcloud_username`/`nextcloud_app_password`/
`nextcloud_default_calendar`/`nextcloud_default_addressbook` as a fallback, so `nextcloud_default_calendar`/`nextcloud_default_addressbook` as a fallback, so
the same account the nextcloud seeds collect is configured once and a block value the same account the nextcloud pack skills collect is configured once and a block value
wins. Bodies reach it via the derived `nextcloud_bridge_url` (+ optional wins. Bodies reach it via the derived `nextcloud_bridge_url` (+ optional
`nextcloud_bridge_token`); the `BridgeInfo` declares only those two config vars. `nextcloud_bridge_token`); the `BridgeInfo` declares only those two config vars.
Routes (reads `GET`, mutations `POST`): files (`/files`, `/files/stat`, Routes (reads `GET`, mutations `POST`): files (`/files`, `/files/stat`,
@@ -1569,7 +1687,7 @@ CLI, unit tests (24) + integration tests (2).
`/goto`, `/click` (selector or visible text), `/fill`, `/press`, `/select`, `/goto`, `/click` (selector or visible text), `/fill`, `/press`, `/select`,
`/wait`, `/back`, `/forward`, `/reset`. Bodies reach it via the derived `/wait`, `/back`, `/forward`, `/reset`. Bodies reach it via the derived
`browser_bridge_url` (+ optional `browser_bridge_token`). Three `browser_bridge_url` (+ optional `browser_bridge_token`). Three
`seeds/browser/*` skills ship (`open_page`, `read_page`, `screenshot`). `packs/browser/skills/browser/*` skills ship (`open_page`, `read_page`, `screenshot`).
`tests/test_browser_bridge.py` exercises the routes over a loopback HTTP server `tests/test_browser_bridge.py` exercises the routes over a loopback HTTP server
with an injected fake driver (no browser, no Playwright needed). with an injected fake driver (no browser, no Playwright needed).
@@ -1605,7 +1723,7 @@ covered. Deferred follow-ups:
pinned v7.0.3 **does** have `/_read chat @<id>`, `/_read chat items @<id> pinned v7.0.3 **does** have `/_read chat @<id>`, `/_read chat items @<id>
<ids>`, and `/_read user <uid>`; an earlier note claiming v7 had no mark-read <ids>`, and `/_read user <uid>`; an earlier note claiming v7 had no mark-read
command was wrong.) command was wrong.)
- [x] **3. `simplex.send_message` seed** (`seeds/simplex/send_message/`). The - [x] **3. `simplex.send_message` pack skill** (`packs/simplex/skills/simplex/send_message/`). The
outbound counterpart to `simplex.next_message`: resolves the recipient with a outbound counterpart to `simplex.next_message`: resolves the recipient with a
SemIf sub-decision over the bridge's `/contacts` (falling back to the SemIf sub-decision over the bridge's `/contacts` (falling back to the
configured default contact), writes the message from the request or the LLM configured default contact), writes the message from the request or the LLM
@@ -1626,7 +1744,7 @@ covered. Deferred follow-ups:
`bridges/outlook_client.py`). Shipped: the `OutlookBridge` exposes mail, `bridges/outlook_client.py`). Shipped: the `OutlookBridge` exposes mail,
calendar, Microsoft To Do, contacts, and OneDrive over one JSON surface in calendar, Microsoft To Do, contacts, and OneDrive over one JSON surface in
front of Graph; OAuth2 device-code + refresh (`scripts/outlook-auth.py`, tokens front of Graph; OAuth2 device-code + refresh (`scripts/outlook-auth.py`, tokens
under `.runtime/outlook/token.json`); seven `seeds/outlook/*` skills under `.runtime/outlook/token.json`); seven `packs/outlook/skills/outlook/*` skills
(`next_message`, `send_message` confirm-gated, `next_event`, `create_event`, (`next_message`, `send_message` confirm-gated, `next_event`, `create_event`,
`create_task`, `list_contacts`, `list_files`). Deferred: writing/reusing `create_task`, `list_contacts`, `list_files`). Deferred: writing/reusing
Outlook app-registration guidance in the docs, and a mail-send seed that Outlook app-registration guidance in the docs, and a mail-send seed that
@@ -1638,7 +1756,7 @@ covered. Deferred follow-ups:
with a persistent profile; optional heavy dep installed via with a persistent profile; optional heavy dep installed via
`requirements/browser.txt` + `bootstrap.sh --browser`, lazy so a missing `requirements/browser.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 `seeds/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`,
file upload/download, multiple tabs/contexts, and a per-URL allowlist. file upload/download, multiple tabs/contexts, and a per-URL allowlist.
+60 -20
View File
@@ -6,10 +6,19 @@ body must be written.
The mocking/testing side of a skill is NOT specified here — it has its own The mocking/testing side of a skill is NOT specified here — it has its own
contract, `TESTGEN.md`. This file is about the runnable body only. contract, `TESTGEN.md`. This file is about the runnable body only.
A skill that ships as a committed starter lives inside a **pack**; how a pack
bundles skills, references a bridge, and declares its settings is the separate
contract `PACKGEN.md`.
## What a skill is ## What a skill is
Semif-agent is an end-user application: an everyday person asks it to do a task, Semif-agent is an end-user application: an everyday person asks it to do a task,
and it does that task using a combination of native python modules, user-provided data and a catalog of basic services known as bridges. A skill is the thing that performs one of those tasks: it is the leaf in the skill tree that the agent navigates to when it has resolved a request to a single, concrete action. Navigation is performed by an llm-based decision engine known as SemIf. and it does that task using native python modules — including direct HTTP
requests to a service's own API — user-provided data, and, where warranted, a
catalog of basic services known as bridges. A skill is the thing that performs
one of those tasks: it is the leaf in the skill tree that the agent navigates to
when it has resolved a request to a single, concrete action. Navigation is
performed by an llm-based decision engine known as SemIf.
A skill is three things: A skill is three things:
@@ -21,7 +30,7 @@ A skill is three things:
talks to and how) and the `CONTRACT` constant (the values the runner must talks to and how) and the `CONTRACT` constant (the values the runner must
provide). provide).
The committed seed `seeds/nextcloud/create_event/` is the **authoritative worked The committed seed `packs/nextcloud/skills/nextcloud/create_event/` is the **authoritative worked
example** of all three. Read its `manifest.json`, its `skill.py` (which declares example** of all three. Read its `manifest.json`, its `skill.py` (which declares
`INTEGRATION` and `CONTRACT`), and its `skill.test.py` alongside this file; a new `INTEGRATION` and `CONTRACT`), and its `skill.test.py` alongside this file; a new
body should look and behave like it. body should look and behave like it.
@@ -176,6 +185,14 @@ Rules:
hand; a title is generated by the LLM, not assembled by string concatenation hand; a title is generated by the LLM, not assembled by string concatenation
when it should be written; a date is parsed by code, not asked of a model. when it should be written; a date is parsed by code, not asked of a model.
**Connectivity is separate from these three sources.** The table is about
*values*, not about how a body reaches a service. A body calls a **plain HTTP
API directly** with a stdlib transport (endpoint and credentials read from
`ctx.config`); a bridge is only for a service that needs state (especially auth
state), a native or heavy protocol, or one sanitized surface. See "Bridge
services" below for when to use one — and the hard rule for a service a bridge
already fronts.
## The registry entry ## The registry entry
The body writer does **not** author a manifest. The `llm` provider authors the The body writer does **not** author a manifest. The `llm` provider authors the
@@ -553,29 +570,44 @@ therefore run as a later step of a chain.
- **Keep the body small — it is ingested whole.** The fidelity decision reads - **Keep the body small — it is ingested whole.** The fidelity decision reads
the *entire* body, so a body that exceeds the engine's context budget is the *entire* body, so a body that exceeds the engine's context budget is
rejected outright (the pipeline retries once with a "make it shorter" rejected outright (the pipeline retries once with a "make it shorter"
instruction). Delegate protocol details to a bridge instead of hand-rolling a instruction). Delegate **complex** protocol details to a bridge instead of
client, and keep `act` to one purpose; a long body is a signal that the hand-rolling a client (a simple HTTP call needs no bridge), and keep `act` to
integration belongs in a bridge. one purpose; a long body is a signal that the integration belongs in a bridge.
- **The function is `act` exactly.** The module is imported under its registered - **The function is `act` exactly.** The module is imported under its registered
leaf name; the entry point is a module-level `act(ctx, request)`. leaf name; the entry point is a module-level `act(ctx, request)`.
## Bridge services ## Bridge services
Some real systems are reached through a **bridge service**: a standalone local A body reaches a real service with a stdlib transport. A **plain HTTP API** is
process that stands up a small, token-guarded HTTP API in front of the system called directly — `urllib.request` / `http.client`, endpoint and credentials read
and owns its native protocol and credentials. The concrete catalog of bridges — from `ctx.config` — and needs no bridge. Some systems, however, are reached
which services exist, their base-URL config var, auth, config vars, and the through a **bridge service**: a standalone local process that stands up a small,
exact endpoints with their request/response/error shapes — is injected into the token-guarded HTTP API in front of the system and owns its native protocol,
prompt at authoring time (render it with credentials, and connection state. Reach for a bridge only when a simple,
repeatable skill file would otherwise be inconsistent, inconvenient, or unsafe:
- **State, especially auth state.** The service needs an OAuth token, a session
cookie, a live daemon connection, a read cursor, or other state a stateless,
re-run-from-the-top `act` cannot own.
- **Sanitized connectivity.** You want one narrow, token-guarded, audited
surface instead of arbitrary bodies speaking the service's raw protocol.
- **A native or heavy protocol.** The service speaks WebSocket/DAV/OCS or needs
a third-party dependency (a browser, a mail client) a one-file stdlib body
must not carry.
When a bridge **does** front a service, the body calls the bridge and must never
reach around it to the service's native protocol — no WebSocket to
`simplex-chat`, no direct daemon access, no DAV/OCS hand-rolling. It calls the
bridge's HTTP API with the base URL from the bridge's config variable, exactly
like any other HTTP integration:
The concrete catalog of bridges — which services exist, their base-URL config
var, auth, config vars, and the exact endpoints with their request/response/error
shapes — is injected into the prompt at authoring time (render it with
`semif_agent.bridges.describe_bridges()`); read it rather than guessing. This `semif_agent.bridges.describe_bridges()`); read it rather than guessing. This
section is only the generic pattern; the catalog is the source of truth for the section is only the generic pattern; the catalog is the source of truth for the
bridge-specific details. bridge-specific details.
A body must never speak a service's native protocol directly — no WebSocket to
`simplex-chat`, no direct daemon access. It calls the bridge's HTTP API with the
base URL from the bridge's config variable, exactly like any other HTTP
integration:
```python ```python
INTEGRATION = { INTEGRATION = {
"service": "<the bridge's service id, from the catalog>", "service": "<the bridge's service id, from the catalog>",
@@ -586,6 +618,9 @@ INTEGRATION = {
Rules: Rules:
- **A plain HTTP service needs no bridge.** If the service exposes a normal HTTP
API and needs none of the three triggers above, call it directly with a stdlib
transport; declare its endpoint in `CONTRACT` and read it from `ctx.config`.
- **Read every value from `ctx.config`.** The base URL, any token, and any - **Read every value from `ctx.config`.** The base URL, any token, and any
default (recipient/contact/target) come from the config vars the catalog default (recipient/contact/target) come from the config vars the catalog
lists. Never hardcode a host, port, or bridge address in the body. lists. Never hardcode a host, port, or bridge address in the body.
@@ -613,6 +648,9 @@ Rules:
- Single purpose, single file, single module. - Single purpose, single file, single module.
- Avoid duplicating an existing skill in the same category. - Avoid duplicating an existing skill in the same category.
- Reach a plain HTTP API directly; use a bridge only for a service that needs
state/auth, a native or heavy protocol, or one sanitized surface — and never
reach around a bridge that fronts the service.
- `act` resolves ambiguity (arguments, recipients, targets) with SemIf - `act` resolves ambiguity (arguments, recipients, targets) with SemIf
sub-decisions, mirroring how `nextcloud.create_event` resolves which calendar sub-decisions, mirroring how `nextcloud.create_event` resolves which calendar
to write to. to write to.
@@ -654,12 +692,14 @@ A generated skill is accepted only if:
11. `INTEGRATION` is present, flat, string-valued, uses the transport vocabulary, 11. `INTEGRATION` is present, flat, string-valued, uses the transport vocabulary,
and is consistent with the body's `ctx.config` reads and behavior. and is consistent with the body's `ctx.config` reads and behavior.
12. It does no network, file, or engine work at import time. 12. It does no network, file, or engine work at import time.
13. If it is a messaging skill, it uses a bridge service over HTTP (never a 13. If the service it targets is fronted by a bridge, it calls that bridge over
service's native protocol), resolves recipients with a SemIf sub-decision, HTTP (never the service's native protocol); otherwise it may call the
and sends only on explicit user intent. service's HTTP API directly. A messaging skill resolves recipients with a
SemIf sub-decision and sends only on explicit user intent.
14. It is small enough to be ingested whole by the fidelity decision (a body 14. It is small enough to be ingested whole by the fidelity decision (a body
over the engine's artifact budget is rejected as too long) — delegate over the engine's artifact budget is rejected as too long) — delegate
protocol details to a bridge rather than hand-rolling them. complex protocol details to a bridge rather than hand-rolling them (a simple
HTTP call needs no bridge).
Items 1 and 7 are hard checks in the parser (`parse_skill_body`) and reject the Items 1 and 7 are hard checks in the parser (`parse_skill_body`) and reject the
body outright. The rest are not statically rejected: a missing or inconsistent body outright. The rest are not statically rejected: a missing or inconsistent
+388
View File
@@ -0,0 +1,388 @@
# PACKGEN.md — the contract for new packs
This file is the authoritative spec for what a **pack** is and how to author a
new one. It is the third sibling of the skill contracts: `CODEGEN.md` governs a
skill's runnable **body**, `TESTGEN.md` governs its **test**, and this file
governs the **pack** that bundles a concern, its skills, its bridge reference,
and its settings into one thing.
Read this before adding anything under `packs/`. A pack is what makes a new
product/concern a first-class part of the agent instead of scattered edits to
`skills.py` and `config.py`.
## What a pack is
Semif-agent ships a set of starter integrations. Each is a **pack**: a folder
`packs/<name>/` holding a `pack.json` manifest plus a `skills/` store of leaves
in the exact generated-skill format. The manifest binds the pieces that would
otherwise be scattered by convention:
- the **concern** (what product/job this is) and its **title**;
- its **categories** (the tree buckets it owns, each with a scope description);
- the **bridge(s)** it talks to, referenced by name (bridge *code* stays in
`semif_agent/bridges` — see "Authoring a new bridge");
- its **runtime requirements** (optional heavy deps);
- its **enable flag**; and
- its **config schema** (the defaults and validation for its settings).
A pack is loaded by `semif_agent/packs.py` (`PackRegistry` discovers packs,
`merge_packs` loads every **enabled** pack into the tree at startup) and its
`config` schema is read by `semif_agent/config.py` to generate
`config.example.json` and to validate a live config.
Three boundaries must stay crisp:
- A **skill** is one leaf action (`packs/<name>/skills/<category>/<leaf>/`),
governed by `CODEGEN.md`/`TESTGEN.md`. A pack contains skills; it is not one.
- A **bridge** is a standalone process in front of a third-party system
(`semif_agent/bridges/`), warranted when the system needs state (especially
auth state), a native or heavy protocol, or one sanitized surface; a system
with a plain HTTP API needs no bridge — its skill calls the API directly. A
pack *references* a bridge by name; it never contains bridge code.
- A pack is **declarative structure** and is committed. Per-machine values are
the split config; credentials live in `secrets.json`. A committed pack never
holds a secret.
## Folder layout
```
packs/<name>/
pack.json # the manifest (this file's subject)
skills/<category>/<leaf>/
skill.py # the body — CODEGEN.md
manifest.json # {"description": "..."} navigation text
contract.json # mirror of the body's CONTRACT — TESTGEN.md
skill.test.py # hermetic mechanics test — TESTGEN.md
```
- The `<category>` directory name is the tree bucket; the `<leaf>` directory
name is the leaf's `name`. The runner joins them as `category.name` only in
run summaries.
- Every leaf carries the four artifacts above. Their contents are governed by
`CODEGEN.md` (body + `CONTRACT` + `INTEGRATION`) and `TESTGEN.md`
(test + `contract.json` mirror); do not restate those rules here.
- `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
skill gets from the `llm` provider.
- A root with no `pack.json` is treated as **one implicit, manifest-less pack**
whose store is the root itself (a plain skills directory still works), but a
committed pack should always have a manifest.
The committed `packs/` are the authoritative worked examples: `essentials` is
the minimal bridge-less pack; `nextcloud`, `simplex`, `outlook`, and `browser`
are bridge-backed packs.
## `pack.json` — the manifest
A single JSON object. Fields (from `packs._parse_pack`):
| Field | Type | Required | Meaning |
| -------------------- | --------------- | -------- | ------- |
| `name` | string | no\* | Pack id (snake_case). Defaults to the folder name. |
| `title` | string | no | Human display name. Defaults to `name`. |
| `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. |
| `bridges` | array of string | no | Bridge names this pack talks to, referencing `bridges/registry.py` `CATALOG`. 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. |
| `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). |
\* `name` is optional in the parser but should always be set explicitly.
Rules:
- **`concern` and `categories` are required** (`tests/test_packs.py` fails
without them). A pack with no declared concern is not a pack.
- **Category ids are the tree keys.** They are the same ids the leaf folders
live under (`skills/<category>/<leaf>/`). When `categories` is omitted, the
pack's categories are inferred from the `skills/` subdirectories — but declare
them, because the description is load-bearing.
- **A category description is navigation-critical.** It is what SemIf reads to
route a request into the bucket; a bare id with no description routes badly.
Write one to two sentences naming the concrete jobs the category does.
- **`bridges[0]` owns the config block.** For a bridge pack, the pack's `config`
schema maps onto `bridges.<bridges[0]>`; only the first bridge gets the block
(a pack normally fronts one bridge).
- Keep the manifest minimal: it binds metadata and settings, nothing executable.
## The config schema
`config` is a nested schema. A **leaf** is a dict with a `default`; a **block**
is a dict without one (recurse). Each leaf spec:
| Key | Type | Meaning |
| --------- | ------ | ------- |
| `type` | string | `bool` \| `int` \| `float` \| `str` \| `list` \| `dict`. Checked by `check-config` (`int`/`float` are interchangeable). |
| `default` | any | The value shipped in `config.example.json` and seeded by `config-init`. Required on a leaf. |
| `doc` | string | One-line plain-language description. Shown in the generated example. |
| `secret` | bool | `true` marks a credential: the example emits `"!secret <pack>_<key>"` instead of a value. |
Example (a bridge-backed pack, mirroring `packs/simplex/pack.json`):
```json
"config": {
"enabled": {"type": "bool", "default": true, "doc": "Load this pack's skills and run its bridge."},
"host": {"type": "str", "default": "127.0.0.1", "doc": "Bridge bind address (localhost only)."},
"port": {"type": "int", "default": 5227, "doc": "Bridge listen port."},
"token": {"type": "str", "default": "", "secret": true, "doc": "Shared secret required in the X-Semif-Token header when set."},
"reconnect": {
"initial": {"type": "float", "default": 1.0, "doc": "Initial reconnect delay (seconds)."},
"max": {"type": "float", "default": 60.0, "doc": "Maximum reconnect delay (seconds)."}
}
}
```
How the schema maps onto the live config (`config.default_config` /
`generate_example_config`):
- A **bridge pack** (`bridges` non-empty) maps its whole `config` schema onto
the `bridges.<bridges[0]>` block.
- A **bridge-less pack** maps only its `enabled` flag onto
`packs.<name>.enabled`; its other keys are not carried (a bridge-less pack is
configured through its skills' own config, not a pack block).
- Secret leaves become `"!secret <pack>_<key>"` in `config.example.json`, where
`<pack>_` is the pack name prefix (nested keys are prefixed with their path,
e.g. `simplex_reconnect_initial`). Never write a real credential into the
manifest.
Rules:
- Every leaf needs a `default` and a `doc`. A key with no `default` is treated
as a nested block.
- Put **operational** settings here (endpoints, accounts, defaults, timeouts) —
the values a skill body reads from `ctx.config`. Per-request arguments never
belong in config (see `CODEGEN.md`).
- `config.json`, `config/`, and `secrets.json` are gitignored and per-machine.
The manifest is committed structure only.
After changing a schema, regenerate and validate:
```sh
python -m semif_agent.cli check-config --write-example config.example.json
python -m semif_agent.cli check-config
```
`config-init` seeds the split `config/` layout from the schemas (bootstrap runs
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 enable switch
One switch governs the pack's skills **and** its bridge, so a host never offers
a skill whose bridge is off. `packs.pack_enabled` resolves in order:
1. an explicit `packs.<name>.enabled` in config (wins);
2. else, for a bridge pack, `bridges.<bridges[0]>.enabled` (the historical
switch);
3. else `enabled_by_default`.
Disabling a pack drops its categories entirely — including any generated body
authored into one — and stops its bridge. The switch lives in the pack's
`config/packs/<name>.json` fragment (written by `config-init`/`check-config`).
## Referencing a bridge by name
A pack whose skills talk to a third-party system lists that bridge in
`bridges` and carries its config block in `config`. (A pack whose skills reach a
plain HTTP API directly needs no bridge: `bridges` stays empty and each leaf
declares the endpoint in its own `CONTRACT`.) The bridge itself is a
class in `semif_agent/bridges/` registered in `bridges/registry.py` `CATALOG`.
Its `BridgeInfo` (name, service, description, URL config var, other config
vars, auth header, endpoints) is injected into every codegen prompt via
`describe_bridges()`, so bodies learn how to reach it without the pack
restating protocol details.
Skill-facing config is **derived**, never duplicated: `derived_config_vars`
turns the bridge's `bridges.<name>` block (`host`/`port`/`token`) into the
`<url_config_var>` and `<auth_config_var>` values a body reads from
`ctx.config` (e.g. `simplex_bridge_url`, `simplex_bridge_token`). Bodies call
the bridge over the ordinary `http` transport; their hermetic tests are
loopback HTTP like any other HTTP body.
Rules:
- The bridge block's `enabled`/`host`/`port`/`token` are the pack's config
schema; the URL/token config vars are derived and must not be declared again.
- A pack references a bridge; it never imports or edits bridge code. Gateway
isolation is non-negotiable — read/send/address capability is a bridge, never
a gateway feature.
## Authoring a new bridge
A **bridge** is a standalone process that stands up a simple, secure localhost
HTTP layer in front of one third-party system. Author one when a skill body
cannot sanely talk to the system itself — because it holds auth/session state,
needs a native or heavy protocol, or should be reached through one sanitized
surface. A system with a plain HTTP API needs no bridge: its skill calls the API
directly. Adding a bridge means:
1. **Write the bridge class** in `semif_agent/bridges/<name>.py`, subclassing
`BridgeService` (`semif_agent/bridges/base.py`). Set the `name` attribute and
a module-level/class `INFO = BridgeInfo(...)`:
```python
from .base import BridgeInfo, BridgeService
class WidgetBridge(BridgeService):
name = "widget"
INFO = BridgeInfo(
name="widget",
service="widget_service",
description="The user's Widget account: widgets and their status.",
url_config_var="widget_bridge_url",
endpoints=(
"GET /widgets — list widgets",
"POST /widgets — create a widget",
),
config_vars=("widget_bridge_token",),
config_var_docs=(("widget_bridge_token", "Shared secret for the X-Semif-Token header."),),
auth_header="X-Semif-Token",
auth_config_var="widget_bridge_token",
)
def check_requirements(self) -> tuple[bool, str | None]:
return True, None # stdlib-only
def handle_get(self, path, query): ...
def handle_post(self, path, payload): ...
```
The base class owns the HTTP/JSON/auth plumbing (`start`/`stop`, the
`X-Semif-Token` guard); a subclass implements only its routes. Override
`start`/`stop`/`_stop_transport` only if the bridge owns a service daemon.
2. **Register it** in `bridges/registry.py` `CATALOG` (tuple order is
presentation order). That is what makes it discoverable, describable to
codegen, and runnable via `python -m semif_agent.cli bridge`.
3. **Give it a pack** whose `bridges` lists its name and whose `config` schema
carries its block (`enabled`/`host`/`port`/`token` plus service vars). The
schema is what gives the bridge its config defaults and validation.
4. **`build_bridge` special-casing** is needed only when the bridge requires the
scheduler's configured `llm` client (pass `client=`) or top-level fallback
values (like Nextcloud's `nextcloud_*`). A plain bridge needs no branch.
5. **Heavy/optional deps:** `check_requirements()` must **never raise** and must
return `(ok, install_hint)`. `run_bridges` aborts **all** bridges when one
reports `ok=False`, so a bridge with an optional dependency (like the
browser) must return `(True, None)` and surface a per-call `503` with an
install hint instead — a missing browser must not take down simplex/llm/
nextcloud. Lazy-import every heavy dep so the core stays stdlib-only.
6. **Report real failures:** a transport/HTTP/bad-reply failure is a `502`, a
missing connection/dep is a `503`, bad input a `400` — never a fabricated
success. The bridge owns its own state (cursors, daemons); bodies keep none.
7. **Test it hermetically:** add `tests/test_<name>_bridge.py` driving the real
routes over a loopback `http.server` (inject a fake driver where a real
service would be needed). No external network, no real daemon. `describe_
bridges()` picks the new bridge up automatically.
8. **Regenerate** `config.example.json` and run `check-config` (see above), and
document the bridge in `AGENTS.md` (bridges section). Never widen the
gateway for a new capability.
## Acceptance criteria
A new pack is accepted only if:
1. `packs/<name>/pack.json` parses as JSON, declares a non-empty `concern` and
a non-empty `categories` map, and every `bridges` name exists in
`bridges/registry.py` `CATALOG`.
2. Every leaf under `skills/<category>/<leaf>/` is a complete skill folder
(`skill.py`, `manifest.json`, `contract.json`, `skill.test.py`) satisfying
`CODEGEN.md` and `TESTGEN.md`: a module-level `act`, a flat `CONTRACT` whose
every key is read from `ctx.config`, an `INTEGRATION` consistent with the
code, a non-empty `manifest.json` `description`, and `contract.json` an exact
mirror of the body's `CONTRACT`.
3. The leaf's hermetic mechanics test passes
(`python skill.test.py` from the leaf folder). This proves mechanics only —
only a real run against the user's service proves the integration.
4. Each category id in the manifest is the id its leaves live under, and each
category has a navigation-grade scope description.
5. The `config` schema is well-formed (every leaf has `default` + `doc`; secrets
marked `secret`), maps onto `bridges.<bridges[0]>` (or `packs.<name>` for a
bridge-less pack), and the regenerated `config.example.json` + `check-config`
are clean.
6. Nothing deployment-specific (hostname, address, username, absolute home
path, local model name) appears in any committed file —
`tests/test_no_env_leaks.py` enforces this. Secrets live in `secrets.json`.
`tests/test_packs.py` enforces items 1–3 mechanically for every committed pack
(valid manifest, concern + categories, integration matches code, contract flat
and mirrored, manifest description, hermetic test passes) and keeps the shipped
pack ids present.
## Worked example — a minimal bridge-less pack
The smallest complete pack needs a manifest and one leaf. `packs/essentials/`
is the committed model; a hypothetical `packs/hello/`:
```
packs/hello/
pack.json
skills/hello/greet/
skill.py
manifest.json
contract.json
skill.test.py
```
`pack.json`:
```json
{
"name": "hello",
"title": "Hello",
"concern": "A trivial local greeting utility that needs no account, network, or bridge.",
"categories": {
"hello": "Greetings: producing a friendly greeting for the user."
},
"bridges": [],
"requires": [],
"enabled_by_default": true,
"config": {
"enabled": {"type": "bool", "default": true, "doc": "Load the hello skills."}
}
}
```
`skills/hello/greet/manifest.json`:
```json
{ "description": "Produce a friendly greeting." }
```
The leaf's `skill.py` (a `compute`-transport body — no external action, empty
`CONTRACT`) and `skill.test.py` follow `CODEGEN.md`/`TESTGEN.md`; the committed
`packs/essentials/skills/time/now/` is the reference for exactly this shape.
For a bridge-backed pack, start from `packs/simplex/pack.json` (bridge
reference + `host`/`port`/`token` + service vars) and
`packs/simplex/skills/simplex/send_message/` (a body that calls the bridge over
HTTP). For a bridge with top-level fallbacks, see `packs/nextcloud/`.
## Checklist
1. Decide the concern and the category ids; write navigation-grade category
descriptions.
2. If a third-party system is involved and it needs state/auth, a native or
heavy protocol, or one sanitized surface, author a bridge first (see
"Authoring a new bridge") and register it in `CATALOG`. A system with a plain
HTTP API needs no bridge — the skill calls it directly.
3. Create `packs/<name>/pack.json` with `name`, `title`, `concern`,
`categories`, `bridges` (if any), `requires`, `enabled_by_default`, and the
`config` schema.
4. Add each leaf under `skills/<category>/<leaf>/` following `CODEGEN.md` and
`TESTGEN.md` (`skill.py`, `manifest.json`, `contract.json`, `skill.test.py`).
5. Regenerate and validate config:
`python -m semif_agent.cli check-config --write-example config.example.json`
then `python -m semif_agent.cli check-config`.
6. Run the tests:
`python3 -m pytest tests/test_packs.py tests/test_codegen.py -q`
(plus `tests/test_<name>_bridge.py` if you added a bridge).
7. Cross-link the pack/bridge in `AGENTS.md` (and `README.md` for a shipped
pack).
8. Verify a real run against the user's actual service — the only proof the
integration works.
+58 -29
View File
@@ -354,8 +354,9 @@ fine-tuning loop — it is not yet the fine-tune itself.
- **Messenger command gateway (SimpleX + LXMF)** — take commands and reply over DM. - **Messenger command gateway (SimpleX + LXMF)** — take commands and reply over DM.
- **Voice gateway** — a local microphone front end: wake word + speech-to-text + - **Voice gateway** — a local microphone front end: wake word + speech-to-text +
text-to-speech, all local (openWakeWord / faster-whisper / Piper). text-to-speech, all local (openWakeWord / faster-whisper / Piper).
- **Standalone bridge services** — a token-guarded localhost HTTP layer in front - **Standalone bridge services** — an optional token-guarded localhost HTTP
of third-party systems, so generated bodies never speak native protocols. layer for third-party systems that need state/auth, a native protocol, or a
sanitized surface; a plain HTTP API is called directly.
- **Seeds** — shipped real starter skills: `nextcloud.create_event` (the - **Seeds** — shipped real starter skills: `nextcloud.create_event` (the
authoritative worked example), `nextcloud.next_event` (Nextcloud CalDAV), authoritative worked example), `nextcloud.next_event` (Nextcloud CalDAV),
`nextcloud.create_task` (Nextcloud task list), `nextcloud.create_task` (Nextcloud task list),
@@ -401,14 +402,21 @@ semif_agent/
gateway/ messenger COMMAND intake/reply (SimpleX, LXMF, voice) gateway/ messenger COMMAND intake/reply (SimpleX, LXMF, voice)
bridges/ standalone third-party API bridges (SimpleX, LLM, Nextcloud, bridges/ standalone third-party API bridges (SimpleX, LLM, Nextcloud,
Outlook, browser) Outlook, browser)
seeds/ committed starter skills (nextcloud, simplex, outlook, browser) config.py layered config: index includes + !secret + schema/example
packs.py SkillPack + PackRegistry (bundles skills by concern/bridge)
packs/ committed skill packs: nextcloud, simplex, outlook, browser,
essentials (a pack.json manifest + skills/<category>/<leaf>/)
scripts/ bootstrap.sh, simplex-address.py, systemd/*.in scripts/ bootstrap.sh, simplex-address.py, systemd/*.in
requirements/ staging.txt — the pinned engine deps requirements/ staging.txt — the pinned engine deps
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
PACKGEN.md the contract for authoring a skill pack (packs/<name>/)
AGENTS.md the operational guide (read this before touching code) AGENTS.md the operational guide (read this before touching code)
config.example.json per-machine config template (seeded to config.json once) config.json per-machine config INDEX ({"include": [...]}); seeded once
config/ split config fragments (core, gateway, bridges, packs/*)
secrets.json gitignored credentials, referenced as "!secret <key>"
config.example.json GENERATED per-machine config reference (from the schemas)
pins.json committed pins: engine/GGUF/tokenizer/simplex-chat refs pins.json committed pins: engine/GGUF/tokenizer/simplex-chat refs
local/ gitignored: this deployment's notes (hosts, addresses, models) local/ gitignored: this deployment's notes (hosts, addresses, models)
``` ```
@@ -451,10 +459,13 @@ On a fresh Ubuntu machine, from a checkout of this repo:
scripts/bootstrap.sh scripts/bootstrap.sh
``` ```
With no `config.json` yet, the script seeds one from `config.example.json`; edit With no `config.json` yet, the script seeds the split config (`config-init`
it to set `llm.model`/`codegen.model` (and the endpoints). Flags override those writes `config/core.json`, `config/gateway.json`, `config/bridges.json`,
`config/packs/*.json`, the `config.json` index, and an empty `secrets.json`);
edit those to set `llm.model`/`codegen.model` (and the endpoints), and put
credentials in `secrets.json`. Flags override those
values for the run only — `--llm-url`, `--codegen-url`, `--llm-model`, values for the run only — `--llm-url`, `--codegen-url`, `--llm-model`,
`--codegen-model` — and are never written back to `config.json`. `--codegen-model` — and are never written back to the config.
The script is idempotent (every stage no-ops on existing state) and: The script is idempotent (every stage no-ops on existing state) and:
@@ -466,8 +477,8 @@ The script is idempotent (every stage no-ops on existing state) and:
4. downloads and sha256-verifies the pinned GGUF into `.runtime/models/`; 4. downloads and sha256-verifies the pinned GGUF into `.runtime/models/`;
5. pre-fetches the HF tokenizer into `.runtime/hf/`; 5. pre-fetches the HF tokenizer into `.runtime/hf/`;
6. downloads and sha256-verifies the pinned `simplex-chat` binary; 6. downloads and sha256-verifies the pinned `simplex-chat` binary;
7. seeds `config.json` from `config.example.json` **only if it does not already 7. seeds the split config (`config-init`) **only if `config.json` does not
exist** — it never rewrites `config.json` (only a human edits that file); already exist** — it never rewrites it (only a human edits it);
8. renders and enables systemd **user** units: 8. renders and enables systemd **user** units:
`semif-simplex` (bot daemon), `semif-gateway` (agent gateway), `semif-simplex` (bot daemon), `semif-gateway` (agent gateway),
`semif-simplex-forward` (the bridge's own daemon), `semif-bridge`; `semif-simplex-forward` (the bridge's own daemon), `semif-bridge`;
@@ -497,24 +508,38 @@ python3 -m pytest tests/ -q --ignore=tests/integration
For a full install on a machine you manage, follow the same steps bootstrap For a full install on a machine you manage, follow the same steps bootstrap
performs (venv, `semif-phase1 --no-deps`, `requirements/staging.txt`, GGUF, performs (venv, `semif-phase1 --no-deps`, `requirements/staging.txt`, GGUF,
tokenizer cache), then create `config.json` from the template and adjust paths: tokenizer cache), then seed the split config and adjust paths:
```sh ```sh
cp config.example.json config.json python -m semif_agent.cli config-init # writes config/ + secrets.json
``` ```
### Configuration ### Configuration
`config.json` is **gitignored, per-machine, and required** — the agent refuses The per-machine config is **gitignored, per-machine, and required** — the agent
to start without it. `scripts/bootstrap.sh` seeds it from `config.example.json` refuses to start without it. `config.json` is a thin **index**
once; afterwards only a human edits it (nothing writes `config.json`). Pinned (`{"include": ["config/core.json", "config/gateway.json", ...]}`); the fragments
external refs live in the committed `pins.json`, so `config.json` holds only under `config/` hold the values and are deep-merged in order. Credentials live in
per-machine settings: the gitignored `secrets.json` and are referenced from any fragment as
`"!secret <key>"` (there is no `api_key_env`). `scripts/bootstrap.sh` seeds the
split config once via `config-init`; afterwards only a human edits it.
```sh ```sh
cp config.example.json config.json # if not already created by bootstrap python -m semif_agent.cli config-init # seed config/ + secrets.json (once)
python -m semif_agent.cli check-config # validate against the schemas
``` ```
The committed `config.example.json` is **generated** from the core schema
(`semif_agent/config.py`) and each pack's `config` schema; regenerate it after
changing a schema:
```sh
python -m semif_agent.cli check-config --write-example config.example.json
```
Pinned external refs live in the committed `pins.json`, so the config holds only
per-machine settings.
Key blocks: Key blocks:
| Block | What it controls | | Block | What it controls |
@@ -525,7 +550,7 @@ Key blocks:
| `navigation` | two-stage guards: leaf `intent_tau`, category `category_tau` | | `navigation` | two-stage guards: leaf `intent_tau`, category `category_tau` |
| `tau` | decision threshold; `max_reentries` requeue bound | | `tau` | decision threshold; `max_reentries` requeue bound |
| `queue` | `max_size` | | `queue` | `max_size` |
| `skill_bodies` / `skill_seeds` / `log` / `trace` / `category_registry` | runtime paths (anchored to the checkout) | | `skill_bodies` / `skill_packs` / `log` / `trace` / `category_registry` | runtime paths (anchored to the checkout) |
| `gateway.simplex` | command gateway: ws_url, allowlist, batching | | `gateway.simplex` | command gateway: ws_url, allowlist, batching |
| `gateway.voice` | voice gateway: wake/STT/TTS engines + models, audio devices, VAD | | `gateway.voice` | voice gateway: wake/STT/TTS engines + models, audio devices, VAD |
| `bridges.simplex` | forwarding bridge: host/port/token/ws_url | | `bridges.simplex` | forwarding bridge: host/port/token/ws_url |
@@ -724,9 +749,11 @@ python -m semif_agent.cli gateway --platform voice
`cli bridge` runs standalone bridges: each is a process that stands up a small, `cli bridge` runs standalone bridges: each is a process that stands up a small,
token-guarded localhost HTTP API in front of one third-party system (and, where token-guarded localhost HTTP API in front of one third-party system (and, where
the system needs one, owns its own daemon/profile). Generated skill bodies call the system needs one, owns its own daemon/profile). A bridge is a deliberate
them like any HTTP service (base URL from a config var), so they never speak a choice for a system that needs state (especially auth state), a native or heavy
native protocol directly. protocol, or one sanitized surface — a skill may call a plain HTTP API directly.
When a bridge fronts a service, generated skill bodies call it like any HTTP
service (base URL from a config var) and never speak the native protocol.
The first bridge is **SimpleX** (`semif_agent/bridges/simplex.py`), with its own The first bridge is **SimpleX** (`semif_agent/bridges/simplex.py`), with its own
simplex-chat daemon separate from the gateway's. Its HTTP surface: simplex-chat daemon separate from the gateway's. Its HTTP surface:
@@ -777,7 +804,7 @@ plain HTTPS) and is stdlib-only (`urllib` + `xml.etree`), so it starts instantly
in the same `semif-bridge` process. The connection (base URL, username, app in the same `semif-bridge` process. The connection (base URL, username, app
password) is configured in `bridges.nextcloud` and falls back to the top-level password) is configured in `bridges.nextcloud` and falls back to the top-level
`nextcloud_url` / `nextcloud_username` / `nextcloud_app_password` / `nextcloud_url` / `nextcloud_username` / `nextcloud_app_password` /
`nextcloud_default_calendar` the nextcloud seeds use, so the account is `nextcloud_default_calendar` the nextcloud pack skills use, so the account is
configured once. Skills call it at the address derived from `bridges.nextcloud` configured once. Skills call it at the address derived from `bridges.nextcloud`
(`nextcloud_bridge_url`, + optional `nextcloud_bridge_token`). Its HTTP surface: (`nextcloud_bridge_url`, + optional `nextcloud_bridge_token`). Its HTTP surface:
@@ -843,7 +870,7 @@ POST /files/write {"path","content","encoding"?,"overwrite"?}
A missing `client_id` or an unauthorized bridge is `503`; a real Graph failure A missing `client_id` or an unauthorized bridge is `503`; a real Graph failure
(transport, HTTP error, or a bad reply) is `502` — never a fabricated success. (transport, HTTP error, or a bad reply) is `502` — never a fabricated success.
Seven `seeds/outlook/*` skills ship (`next_message`, `send_message`, Seven `packs/outlook/skills/outlook/*` skills ship (`next_message`, `send_message`,
`next_event`, `create_event`, `create_task`, `list_contacts`, `list_files`); `next_event`, `create_event`, `create_task`, `list_contacts`, `list_files`);
`send_message` composes the message through the LLM bridge and asks for `send_message` composes the message through the LLM bridge and asks for
confirmation before it sends. confirmation before it sends.
@@ -890,7 +917,7 @@ POST /back | /forward {"timeout"?}
POST /reset {"purge"?} # close; purge deletes the profile POST /reset {"purge"?} # close; purge deletes the profile
``` ```
Three `seeds/browser/*` skills ship (`open_page`, `read_page`, `screenshot`). Three `packs/browser/skills/browser/*` skills ship (`open_page`, `read_page`, `screenshot`).
### Dream report ### Dream report
@@ -927,10 +954,12 @@ bodies, no external network, no `mock_data.json`. Passing it proves the code
runs, not that the live integration works. That is what the real run and the runs, not that the live integration works. That is what the real run and the
repair loop are for. repair loop are for.
**Seeds** (`seeds/`) ship real starter integrations in the exact generated **Packs** (`packs/<name>/`) ship real starter integrations in the exact generated
folder format, plus a `manifest.json`. `merge_seed_store` loads them into every folder format, plus a `manifest.json` and a `pack.json` manifest binding the
tree at startup; recorded config is written to the runtime store, so the concern to its categories, bridge, and config schema. `merge_packs` loads every
committed seed never holds secrets. enabled pack into the tree at startup; recorded config is written to the runtime
store, so the committed pack never holds secrets. `PACKGEN.md` is the
authoritative contract for authoring a new pack (and a new bridge to back one).
- `nextcloud.create_event` — create an event on Nextcloud CalDAV (the - `nextcloud.create_event` — create an event on Nextcloud CalDAV (the
authoritative worked example); resolves the target calendar with a SemIf authoritative worked example); resolves the target calendar with a SemIf
@@ -993,7 +1022,7 @@ logging, `dream` cost pass, REPL + JSONL CLI; live `create_category` /
contract → test → auto-run → re-dispatch); tiered config + first-fire contract → test → auto-run → re-dispatch); tiered config + first-fire
collection; runtime repair loop; the closed `response` canned tree; real collection; runtime repair loop; the closed `response` canned tree; real
integrations with `INTEGRATION` declarations; the SimpleX command gateway and the integrations with `INTEGRATION` declarations; the SimpleX command gateway and the
standalone SimpleX bridge + seeds (contact-list refresh, daemon-backed message standalone SimpleX bridge + pack skills (contact-list refresh, daemon-backed message
history / true unread); the LXMF gateway; and the voice gateway (wake word + history / true unread); the LXMF gateway; and the voice gateway (wake word +
speech-to-text + text-to-speech). speech-to-text + text-to-speech).
+10 -6
View File
@@ -6,6 +6,9 @@ test artifact. The runnable body contract lives in `CODEGEN.md`; this file is
deliberately separate so the body writer never embeds test data and the test is deliberately separate so the body writer never embeds test data and the test is
generated from the finished body rather than the other way around. generated from the finished body rather than the other way around.
The pack that ships a skill as a committed starter — its manifest, categories,
bridge reference, and config schema — is the separate contract `PACKGEN.md`.
A finished skill leaf is a folder A finished skill leaf is a folder
`data/skills/<category>/<name>/` containing (among others) two artifacts: `data/skills/<category>/<name>/` containing (among others) two artifacts:
@@ -84,12 +87,13 @@ A stdlib-only Python script that:
Assert the server actually received the expected request (method, path, Assert the server actually received the expected request (method, path,
headers, body) where practical. The loopback address exists only in the test; headers, body) where practical. The loopback address exists only in the test;
the body must read its endpoint from config. the body must read its endpoint from config.
- For a messaging skill (a body that talks to a bridge service), stand up a - For a body that talks to a bridge service (or any fixed HTTP API), stand up a
loopback server implementing the bridge endpoints the body uses (the bridge loopback server implementing the endpoints the body uses (the bridge catalog
catalog injected into this prompt lists them) and assert the body built the injected into this prompt lists a bridge's; for a direct HTTP API, mirror the
real requests. If the catalog names an auth header, set the fixture token in routes the body calls) and assert the body built the real requests. If the
the fixture config and assert the body sent that header. Never connect to a catalog names an auth header, set the fixture token in the fixture config and
real service daemon or a live bridge. assert the body sent that header. Never connect to a real service daemon or a
live bridge.
- For non-HTTP transports (IMAP, SMTP, subprocess, ...), exercise config - For non-HTTP transports (IMAP, SMTP, subprocess, ...), exercise config
resolution, argument construction, and error paths (missing or misconfigured resolution, argument construction, and error paths (missing or misconfigured
values) without performing the real I/O. values) without performing the real I/O.
+104 -111
View File
@@ -1,35 +1,27 @@
{ {
"_comment": "Per-machine config. config.json is gitignored. bootstrap.sh seeds config.json from this file only when config.json does not exist, and NOTHING writes config.json afterwards — only a human edits it. Pinned engine/tokenizer/GGUF/simplex-chat refs live in the committed pins.json, not here. Every machine keeps its own config.json. Top-level `timezone` is the IANA zone (e.g. America/Chicago) the agent reports local time in; empty means the host's local timezone.",
"tau": 0.6, "tau": 0.6,
"max_reentries": 3, "max_reentries": 3,
"query_recall_window": 30, "query_recall_window": 30,
"_query_recall_window_comment": "Seconds a completed run stays recallable to a follow-up request in the same chat/source. A follow-up within the window is given the previous run's ledger as 'previous request' context (and bodies can reuse its result via last_result), so a reference like \"send it to Sam\" resolves against what the agent just did. 0 disables recall entirely. Measured from the previous run's completion; only the last completed real skill run per source is remembered (canned responses and housekeeping meta skills are never recalled).", "new_skill_creation": "deny",
"new_skill_creation": "allow",
"_new_skill_creation_comment": "Global new-skill creation mode: \"allow\" (create without asking), \"deny\" (never author new skills/categories), or \"ask\" (author only after the human approves the proposal). A category can override this in data/skills/<category>/config.json with its own \"new_skill_creation\" value; the built-in housekeeping and response categories are always denied in code.",
"verbosity": "result", "verbosity": "result",
"_verbosity_comment": "How much of a completed request to surface. \"result\" (default): only the final answer — an end user does not care which skills ran or which decisions were made. \"query\": also show each intermediate step of a chained request (its query + run-ledger entry). \"decision\": also show every SemIf decision (phase + selected option + probabilities) for a step — a debugging view.",
"chain": { "chain": {
"_comment": "Chained multi-step completion. When a run's outcome assessment says more work is needed, the request is re-dispatched with a compact run ledger and routed to the logical next skill, until the request is satisfied, fails into repair, or the chain is capped by max_reentries. result_chars is the ONE shared speakable budget applied to every skill's output (its result string and its ledger entry): a result is read in a chat message or heard as speech, so it is truncated to this many characters at a word boundary. A long product of a skill belongs in a file I/O side effect, not the result string (see CODEGEN.md/TESTGEN.md). The voice front end (gateway.voice.max_speak_chars) and the humanizer (gateway.humanize.max_chars) are downstream caps and should not exceed it.",
"result_chars": 300 "result_chars": 300
}, },
"assess": { "assess": {
"_comment": "Thresholds for the three-way assess:outcome decision (is there additional work to be done to satisfy the request?): done (request satisfied), continue (the step worked but more work is needed; route the next step), failed (the step errored; offer repair). Verdict precedence is failed > done > continue, so a confident success/failure is honored and continue — the over-trigger — only wins when the model is genuinely unsure. Separate from the top-level tau so completion tuning does not move assessment/fidelity.",
"done_tau": 0.5, "done_tau": 0.5,
"fail_tau": 0.5 "fail_tau": 0.5
}, },
"timezone": "", "timezone": "",
"navigation": { "navigation": {
"_comment": "Navigation is two-stage at BOTH levels and the guards are the create doors (no threshold gate). Category: the softmax offers each existing category WITH its description (bare names carried no signal) plus create_category; confirm_category_fit then confirms the winner's scope (phase navigate:category_scope, P(covers) >= category_tau) and a rejected winner authors a new category. The `response` catchall and create_category share a boundary arbitrated by the actionability guard confirm_non_action (phase navigate:actionability, P(non_action) >= action_tau): the closed response tree is reached ONLY when the input is not a request, so a request no skill covers (e.g. \"what is 255 * 12?\") authors instead of getting a canned reply. Leaf: the softmax offers only existing skills; confirm_skill_fit then decides what the winner does for the request — same (it performs the next action the request needs), part (the request needs more than one action and this skill performs one required part), or different (a new leaf is authored) (phase navigate:intent, P(same)+P(part) >= intent_tau). All three taus are separate from the top-level tau so tuning reuse-vs-create or actionability does not move run assessment/fidelity. The category check is deliberately permissive: with real descriptions in-scope requests score 0.9-1.0, so a borderline over-cover routes into a plausible category and the leaf guard catches it. A **category** softmax winner at or above `softmax_bypass_tau` (default 0.5) skips the scope confirm (traced `category_scope_bypassed`) — `create_category` is one of its options, so a confident winner really did beat authoring a category. The **leaf** intent guard is never bypassed: the leaf softmax offers only existing skills, so a confident winner is \"best of the wrong lot\", not a match, and the guard is the only leaf-level create door.",
"intent_tau": 0.6, "intent_tau": 0.6,
"category_tau": 0.75, "category_tau": 0.75,
"action_tau": 0.5, "action_tau": 0.5,
"softmax_bypass_tau": 0.5 "softmax_bypass_tau": 0.5
}, },
"queue": {"max_size": 100}, "queue": {
"max_size": 100
},
"engine": { "engine": {
"_comment": "Per-machine engine settings only. The pinned engine/tokenizer/GGUF refs (semif_repo, semif_ref, gguf_url, gguf_sha256, source, revision) live in the committed pins.json — bumped on update, never per-machine config. The GGUF path is derived from pins.json's engine.gguf_url under .runtime/models/; set `gguf` here only to override it with a custom path.",
"_gpu_comment": "gpu_layers: 0 keeps the CPU-only default, -1 offloads every layer, a positive count offloads that many. Requires a llama-cpp-python built with a GPU backend (bootstrap detects Vulkan/ROCm/CUDA). gpu_device picks the llama.cpp device index and gpu_split sets its split mode (0 = none).",
"_provider_comment": "provider selects the decision engine, exactly like llm.provider/codegen.provider: \"semif\" (default) is the local llama.cpp GGUF described below; \"winnow\" is a remote /v1/systemone typed-decision API configured by the `winnow` block (a different model, e.g. Winnow-12B on a ROCm host). The engine is always real: a provider that cannot be reached raises EngineUnavailable, which is fatal — there is no fallback model. The decision log and `dream` cost work unchanged either way.",
"provider": "semif", "provider": "semif",
"backend": "llamacpp", "backend": "llamacpp",
"context_tokens": 4096, "context_tokens": 4096,
@@ -38,25 +30,22 @@
"gpu_device": null, "gpu_device": null,
"gpu_split": 0, "gpu_split": 0,
"winnow": { "winnow": {
"_comment": "Settings for provider == \"winnow\": a remote Winnow typed-decision server (`winnow-server`, ROCm/HIP on a dedicated GPU host) exposing POST /v1/systemone (choice questions) and /v1/chat/completions (text, used by llm.provider == \"semif\"). base_url is the server root; model is required (no default). context_tokens must mirror the server's --ctx-size: generated skill bodies are sized from the active engine's context so a fidelity decision can always ingest one whole. timeout bounds each request; retries is the number of transient-failure retries before the engine is declared unavailable (0 = a single attempt; an unreachable engine is fatal by contract). api_key/api_key_env add a bearer token (usually unset on a LAN); extra_headers/user_agent pass through for custom setups. The Winnow model holds the whole GPU, so it cannot be resident alongside a large codegen model — stop one before starting the other.",
"base_url": "http://127.0.0.1:8091", "base_url": "http://127.0.0.1:8091",
"model": "", "model": "",
"context_tokens": 32768, "context_tokens": 32768,
"api_key": "", "api_key": "!secret engine_winnow_api_key",
"api_key_env": "",
"timeout": 120, "timeout": 120,
"retries": 0, "retries": 0,
"user_agent": "semif-agent", "user_agent": "semif-agent",
"extra_headers": {} "extra_headers": {}
} },
"gguf": ""
}, },
"llm": { "llm": {
"_comment": "Small OpenAI-compatible model that authors a new category/skill title + description (never the runnable body — that is `codegen` below). Deliberately its own endpoint/model, so it can be local and fast even when codegen is remote. Runs on THIS machine's local ollama; bootstrap reads base_url/model from here (a --llm-url/--llm-model flag overrides for that run only) and pulls `model` if it is missing. `model` is required (no default): set it to a model the endpoint serves. Uses the same provider machinery as codegen (real SSE stream, token budget, idle watchdog); short JSON replies. Sampler params (temperature/top_p/presence_penalty/frequency_penalty) are opt-in: an unset value is omitted from the request so the server's model default applies — set them here only when you know the right values for the model. The draft is authored asynchronously by a single-slot worker and the request re-runs when it lands; an unreachable endpoint is graceful (traced, user notified), not fatal. disable_thinking sends reasoning_effort:none so a reasoning model answers the short JSON directly instead of spending the reply budget on hidden chain-of-thought (set false only for an endpoint that rejects the parameter). provider selects the transport: \"ollama\" (default; a local OpenAI-compatible server, context auto-detected via /api/show), \"opencode\" (the hosted OpenCode Console inference API at https://opencode.ai/inference/openai/v1 — set model to a Chat Completions family id such as kimi-k2.7-code or glm-5.3, and provide api_key or api_key_env; the ollama probe is skipped), or \"semif\" (the loaded SemIf decision GGUF generates in-process via SemIfEngine.generate — no endpoint/model/api_key is used; see the `semif` block below).",
"provider": "ollama", "provider": "ollama",
"base_url": "http://localhost:11434/v1", "base_url": "http://localhost:11434/v1",
"model": "", "model": "",
"api_key": "", "api_key": "!secret llm_api_key",
"api_key_env": "",
"user_agent": "", "user_agent": "",
"timeout": 600, "timeout": 600,
"stream": false, "stream": false,
@@ -69,18 +58,15 @@
"frequency_penalty": 0.0, "frequency_penalty": 0.0,
"disable_thinking": true, "disable_thinking": true,
"semif": { "semif": {
"_comment": "Settings for provider == \"semif\": the already-loaded SemIf engine model generates the text in-process (the same GGUF the decision engine scored with), so no base_url/model/api_key is used and `model` above is not required. temperature 0 = greedy decoding; max_tokens bounds the reply length (callers may override per call). Generation shares the engine's lock with decision scoring, so a reply briefly serializes against routing/assessment.",
"temperature": 0.0, "temperature": 0.0,
"max_tokens": 256 "max_tokens": 256
} }
}, },
"codegen": { "codegen": {
"_comment": "OpenAI-compatible model that writes runnable skill bodies. Runs on a REMOTE ollama host (bootstrap reads base_url/model from here; a --codegen-url/--codegen-model flag overrides for that run only); the local small model is `llm` above. `model` is required (no default): set it to a code-capable model the endpoint serves. Bodies perform real actions against the user's configured services via stdlib transports, read every operational value from ctx.config, and declare their integration (INTEGRATION: service/transport/config_vars). Larger/slower than the decision or title/description model. The transport always streams so the client-side token budget (output cap / peak total fill) can abort a runaway in real time; stream only toggles console echo of tokens. timeout is total seconds; idle_warn/idle_timeout surface a silent (wedged) stream. The context window is auto-detected via ollama /api/show; context_window is the manual fallback (0 = auto/default 100000). smart_limit/warn_limit and max_fill_ratio/warn_fill_ratio bound total fill; max_output caps streamed output (>=1 absolute tokens, 0<x<1 fraction of window); chars_per_token converts chars to the token estimate. temperature/top_p/presence_penalty/frequency_penalty are opt-in: an unset value is omitted from the request so the server's model/Modelfile default applies; set them here only when you know the right values for the model. A rejected body retries with a fresh short prompt (max_attempts attempts), reusing the same sampler params. PRIVACY: codegen is the primarily-cloud model, so it is shown ONLY a de-identified, reusable spec authored by the local `llm` (goal + generic service/transport) — never the user's request text, question answers, or any run output. After the body lands it is reviewed for real-action fidelity, then the data contract (contract.json) is derived in a separate call, then skill.test.py (hermetic mechanics test: loopback http.server for HTTP bodies, fixtures inline, no external network) in a shared-context call, and the test is auto-run as a subprocess (test_timeout seconds); on failure a 3-option SemIf decision (code/contract/test) regenerates the failing piece, bounded by test_max_attempts. contract_search.enabled auto-populates the skill config.json via SemIf against the global + category config. provider selects the transport: \"ollama\" (default; local OpenAI-compatible server, context auto-detected via /api/show) or \"opencode\" (the hosted OpenCode Console inference API at https://opencode.ai/inference/openai/v1 — set model to a Chat Completions family id such as kimi-k2.7-code, glm-5.3, or deepseek-v4.1-flash, and provide api_key or api_key_env; the ollama probe is skipped).",
"provider": "ollama", "provider": "ollama",
"base_url": "http://localhost:11434/v1", "base_url": "http://localhost:11434/v1",
"model": "", "model": "",
"api_key": "", "api_key": "!secret codegen_api_key",
"api_key_env": "",
"user_agent": "", "user_agent": "",
"timeout": 3600, "timeout": 3600,
"stream": true, "stream": true,
@@ -99,32 +85,26 @@
"frequency_penalty": 1, "frequency_penalty": 1,
"max_attempts": 3, "max_attempts": 3,
"approval": { "approval": {
"_comment": "The optional creation-approval gate (new_skill_creation == \"ask\"): the single-slot draft worker blocks after it authors a proposal and before anything is registered, waiting up to wait_timeout seconds for a human approve/deny. Denial or timeout aborts creation. Set 0 to wait forever.",
"wait_timeout": 900 "wait_timeout": 900
}, },
"fidelity": { "fidelity": {
"_comment": "After the body lands, an authoring:fidelity SemIf decision (accept/reconsider, P(reconsider) >= tau or any static finding) checks whether it really performs the action vs simulates it (canned result, fabricated data, draft-by-default). The state carries the WHOLE body (never a prefix) plus a deterministic operation inventory and the de-identified goal, and asks the positive question (is there a concrete operation that realizes the goal?). tau is this gate's own threshold, separate from the top-level tau. Static INTEGRATION checks (declaration vs code) run alongside. The gate never diagnoses: a rejected body is regenerated with the raw evidence bundle (inventory + findings included), bounded by max_attempts; a still-fake body is accepted but traced, never a hard authoring failure.",
"enabled": true, "enabled": true,
"max_attempts": 1, "max_attempts": 1,
"tau": 0.6 "tau": 0.6
}, },
"repair": { "repair": {
"_comment": "A failed real run triggers a logged SemIf repair choice (retry / repair_skill / ask_user / no_repair) surfaced in the REPL and dashboard. Executing a repair is user-confirmed (a codegen write is slow); body repairs are bounded by max_attempts per skill and carry the observed failure into the regeneration.",
"enabled": true, "enabled": true,
"max_attempts": 1 "max_attempts": 1
}, },
"test_timeout": 30, "test_timeout": 30,
"test_max_attempts": 3, "test_max_attempts": 3,
"_artifact_budget_comment": "Generated artifacts are ingested WHOLE by a decision (the fidelity gate reads the entire skill body), so each is size-bounded. max_body_tokens/max_test_tokens are hard ceilings; 0 derives each from the ACTIVE decision engine's context (engine.context_tokens for the local GGUF, engine.winnow.context_tokens for Winnow) minus decision_reserve_tokens — the headroom for everything else in the fidelity state (goal, description, integration, findings, operation inventory, question, options, engine prefill margin). A positive value overrides the derivation: lower it if you don't want to wait on a long fidelity evaluation, raise it if your engine has a larger window. chars_per_token above converts the token budget to the char limit the parser enforces; a body over budget is rejected (ArtifactTooLong) and the codegen retry ladder asks for a shorter one.",
"max_body_tokens": 0, "max_body_tokens": 0,
"max_test_tokens": 0, "max_test_tokens": 0,
"decision_reserve_tokens": 1024, "decision_reserve_tokens": 1024,
"contract_search": { "contract_search": {
"_comment": "After the data contract lands, run a SemIf choice per variable to auto-populate the skill config.json from the global config and the category config (data/skills/<category>/config.json). Logged as phase config:search.",
"enabled": true "enabled": true
}, },
"degeneration": { "degeneration": {
"_comment": "SemIf degeneration watchdog: while the body streams, a 2-option SemIf decision (continue/stop) is made every `interval` chars against the last `window` chars of content+reasoning (once `min_chars` have accumulated); P(stop) >= threshold aborts the write with a graceful stub. Recorded trace-only (kind `codegen`), never in the decision log. Disabled when no engine is available.",
"enabled": true, "enabled": true,
"threshold": 0.9, "threshold": 0.9,
"interval": 8000, "interval": 8000,
@@ -133,96 +113,23 @@
} }
}, },
"skill_bodies": "data/skills", "skill_bodies": "data/skills",
"skill_seeds": "seeds",
"log": "data/decisions.jsonl", "log": "data/decisions.jsonl",
"trace": "data/runs.jsonl", "trace": "data/runs.jsonl",
"category_registry": "data/categories.json", "category_registry": "data/categories.json",
"simplex_chat": { "simplex_chat": {
"_comment": "Per-machine simplex-chat daemon settings. The pinned binary (version/bin_url/sha256) lives in the committed pins.json, not here. The command gateway talks to the daemon on `port` (profile .runtime/simplex/, unit semif-simplex.service). The SimpleX forwarding bridge owns its OWN daemon/profile on `forward_port` (profile .runtime/simplex-forward/, unit semif-simplex-forward.service) so messaging UX never shares the command bot's identity. bootstrap.sh renders both units from these values. gateway.simplex.ws_url must match `port`; bridges.simplex.ws_url must match `forward_port`.",
"port": 5226, "port": 5226,
"display_name": "semif", "display_name": "semif",
"forward_port": 5228, "forward_port": 5228,
"forward_display_name": "semif-forward" "forward_display_name": "semif-forward"
}, },
"bridges": {
"_comment": "Standalone third-party API bridges: a simple, secure local HTTP layer between codegen-authored skill bodies and real system services. Each bridge runs as its own process (`python -m semif_agent.cli bridge [--name NAME]`), one process per service daemon, and never runs inside the command gateway — gateway isolation is non-negotiable (see AGENTS.md). The bridge catalog (names, endpoints, config vars) is injected into the code-generation prompts via `semif_agent.bridges.describe_bridges()`.",
"simplex": {
"_comment": "SimpleX forwarding bridge: buffers every inbound DM (no allowlist — the point is to see who reached the bot through its invite link), and serves invite-link / read / send over HTTP. It owns its own simplex-chat daemon/profile (`ws_url`, `forward_port` above), separate from the command gateway's. Skills call it at http://host:port (derived from this block; no top-level duplicate). Binds localhost only; an optional `token` is required in the X-Semif-Token header when set.",
"enabled": true,
"host": "127.0.0.1",
"port": 5227,
"token": "",
"max_inbox": 100,
"ws_url": "ws://127.0.0.1:5228",
"user_id": 1,
"auto_accept": true,
"reconnect": {"initial": 1.0, "max": 60.0, "jitter": 0.2}
},
"llm": {
"_comment": "LLM bridge: a generic `POST /chat` in front of the agent's configured `llm` model, so skill bodies can ask for short generated text (e.g. an event title + description) over HTTP instead of speaking the OpenAI-compatible protocol. It reuses the top-level `llm` client (endpoint/model/sampler configured once there); this block only carries the local listener. Skills call it at http://host:port (derived from this block; no top-level duplicate). Binds localhost only; an optional `token` is required in the X-Semif-Token header when set. It runs inside the same `semif-bridge.service` process as the other enabled bridges.",
"enabled": true,
"host": "127.0.0.1",
"port": 5229,
"token": ""
},
"nextcloud": {
"_comment": "Nextcloud bridge: files (WebDAV), calendar events and tasks (CalDAV), contacts (CardDAV), and Notes (the Notes app) over one uniform local JSON API, so skill bodies never speak the native DAV/OCS protocols. It has no service daemon (Nextcloud is plain HTTPS) and runs inside the same `semif-bridge` process as the other enabled bridges. The connection is configured HERE (url/username/app_password); when a value is blank the bridge falls back to the top-level nextcloud_url/nextcloud_username/nextcloud_app_password/nextcloud_default_calendar the nextcloud seeds already use, so the account is configured once. `app_password` is a Nextcloud app password (Settings > Security > Devices & sessions), not the account password. `default_calendar`/`default_task_calendar`/`default_addressbook` are used when a request names none and the account has several; task operations only ever target a VTODO-capable task list (GET /tasklists), never an event-only calendar. `verify_tls` false skips certificate verification (self-signed hosts). Skills call it at http://host:port (derived from this block; no top-level duplicate). Binds localhost only; an optional `token` is required in the X-Semif-Token header when set.",
"enabled": true,
"host": "127.0.0.1",
"port": 5230,
"token": "",
"url": "",
"username": "",
"app_password": "",
"default_calendar": "",
"default_task_calendar": "",
"default_addressbook": "",
"verify_tls": true,
"timeout": 30
},
"outlook": {
"_comment": "Outlook bridge: the user's Microsoft account (Outlook / Microsoft 365) through Microsoft Graph — mail, calendar events, Microsoft To Do tasks, contacts, and OneDrive files — over one uniform local JSON API, so skill bodies never speak Graph or OAuth. No service daemon and no extra dependency (Graph is plain HTTPS); it runs inside the same `semif-bridge` process as the other enabled bridges. Authorization is the OAuth2 device code flow: register an Entra ID public-client app, put its `client_id` here, run `scripts/outlook-auth.py` once, and the tokens are stored (0600) under `.runtime/outlook/token.json` (override with `token_path`). `tenant` is usually `common` (personal + work accounts). `default_calendar`/`default_task_list`/`default_mail_folder` are used when a request names none; `default_timezone` (IANA name) labels created events/tasks whose start has no offset. `verify_tls` false skips certificate verification. Skills call it at http://host:port (derived from this block; no top-level duplicate). Binds localhost only; an optional `token` is required in the X-Semif-Token header when set. Disabled by default because it needs a client id + an authorization run first.",
"enabled": false,
"host": "127.0.0.1",
"port": 5231,
"token": "",
"client_id": "",
"tenant": "common",
"default_calendar": "",
"default_task_list": "",
"default_mail_folder": "inbox",
"default_timezone": "UTC",
"verify_tls": true,
"timeout": 30
},
"browser": {
"_comment": "Browser bridge: real browser automation via Playwright — open a URL, read a page's text/links, take a screenshot, and click/fill/press/select to complete a flow — behind one uniform local JSON API, so skill bodies never bundle a browser stack. Disabled by default because it needs the optional Playwright deps + browser binaries: install with `scripts/bootstrap.sh --browser` (browsers land under .runtime/browser). The bridge keeps a PERSISTENT profile under .runtime/browser/profile, so logins/cookies survive across calls and restarts (POST /reset with purge=true wipes it); `engine` is chromium|firefox|webkit and `headless` false shows the window. Skills call it at http://host:port (derived from this block; no top-level duplicate). Binds localhost only; an optional `token` is required in the X-Semif-Token header when set. A missing Playwright/browser is a 503 install hint, never a startup failure (the other bridges keep running). Set `channel` (e.g. chrome/msedge) or `executable_path` (a browser binary) to use an already-installed browser and skip Playwright's managed download entirely; `executable_path` wins if both are set.",
"enabled": false,
"host": "127.0.0.1",
"port": 5232,
"token": "",
"engine": "chromium",
"headless": true,
"channel": "",
"executable_path": "",
"profile_dir": "",
"browsers_path": "",
"screenshot_dir": "",
"default_timeout": 30,
"max_text_chars": 20000
}
},
"gateway": { "gateway": {
"_comment": "Messenger COMMAND intake — and nothing else. `python -m semif_agent.cli gateway` runs one or more platforms (`--platform simplex,lxmf` or `all`) in a SINGLE process sharing one scheduler/skill store — never run two gateway processes over one store. Each platform feeds authorized DM text through the normal gate/score/queue/dispatch pipeline; results, authoring questions, and repair offers are sent back to the originating chat. It must never read a contact's history, show/create invite links, or compose on the user's behalf — that is the independent bridge services' job (`bridges`). home_channel receives messages whose origin chat is unknown (e.g. a background repair offer). reply_prefix is prepended to every reply. text_batch_delay concatenates rapid-fire messages from one contact.",
"humanize": { "humanize": {
"_comment": "Optional LLM cleanup of a skill's result line for chat replies. Off by default. When enabled, a completed result is unwrapped from the scheduler's `<skill>: <ok|failed> — <detail>` bookkeeping and rewritten by the scheduler's `llm` client into one grounded, friendly sentence; it never decides success/failure and always falls back to the raw result on any error. `timeout`/`max_tokens`/`max_chars` bound the auxiliary call (a slow cleanup must not hold the gateway). A platform turns it on/off with its own `humanize` key (bool or `{enabled: ...}`), overriding this global default; `timeout`/`max_tokens`/`max_chars` are global. Only result lines are cleaned — questions, repair/approval notices, and status chatter are untouched.",
"enabled": true, "enabled": true,
"timeout": 20.0, "timeout": 20.0,
"max_tokens": 200, "max_tokens": 200,
"max_chars": 600 "max_chars": 600
}, },
"simplex": { "simplex": {
"_comment": "SimpleX command adapter. Connects to the command simplex-chat daemon (`simplex_chat.port`) over its JSON WebSocket API. Requires the optional `websockets` package (lazy-imported; the gateway refuses to start without it). allowed_users entries match either a numeric contactId or a display name; default is deny-all unless allow_all_users is set. Groups/attachments are not supported.",
"enabled": true, "enabled": true,
"ws_url": "ws://127.0.0.1:5226", "ws_url": "ws://127.0.0.1:5226",
"allowed_users": [], "allowed_users": [],
@@ -231,10 +138,13 @@
"home_channel": "", "home_channel": "",
"reply_prefix": "", "reply_prefix": "",
"text_batch_delay": 0.8, "text_batch_delay": 0.8,
"reconnect": {"initial": 1.0, "max": 60.0, "jitter": 0.2} "reconnect": {
"initial": 1.0,
"max": 60.0,
"jitter": 0.2
}
}, },
"lxmf": { "lxmf": {
"_comment": "LXMF (Reticulum) command adapter. Runs IN-PROCESS — there is no external daemon; `pip install lxmf` provides the transport (optional, lazy-imported; the gateway refuses to start with an install hint). The bot's reachable address is its LXMF delivery destination hash (32 hex chars), printed on connect. config_dir/storage_path hold Reticulum's config and the persisted identity under .runtime/lxmf/ so the address is stable across restarts (empty = the .runtime/lxmf defaults). allowed_users entries match the peer's LXMF address (32 hex chars) or a best-effort display name; default is deny-all unless allow_all_users is set. desired_method is 'direct' (reliable link) or 'opportunistic' (single packet). propagation_node is an optional LXMF propagation-node address (hex) for store-and-forward.",
"enabled": false, "enabled": false,
"allowed_users": [], "allowed_users": [],
"allow_all_users": false, "allow_all_users": false,
@@ -250,7 +160,6 @@
"text_batch_delay": 0.8 "text_batch_delay": 0.8
}, },
"voice": { "voice": {
"_comment": "Voice command adapter: a local microphone front end with wake word + speech-to-text + text-to-speech. Requires the optional voice stack (requirements/voice.txt; sounddevice + openwakeword + faster-whisper + piper-tts + onnxruntime; the system needs libportaudio2). Lazy-imported; the gateway refuses to start with an install hint. Runs best in the user's audio session (foreground `gateway --platform voice`), not a headless systemd user service. Audio is 16 kHz mono int16; capture/playback run at the device's native rate and are resampled to/from 16 kHz (capture_sample_rate/output_sample_rate override it; 0 = the device default). wake.model is an openWakeWord model name or path (official models download into the venv and resolve by name; a pinned community model such as the default 'hey_computer' is fetched into model_dir, .runtime/voice/wake); stt.model is a faster-whisper size/path (cached under .runtime/hf); tts.voice is a Piper voice id or path (bootstrap downloads it under .runtime/voice/tts). After the wake word, listen_timeout_s is how long to wait for the command to start before giving up, so a pause before speaking does not truncate it. The wake word is required before every command and is held while the scheduler is still running the current request, so a new command cannot start until it reaches a result. result_only speaks just the skill's result line (dropping queue/urgency bookkeeping and the `<skill>: ok —` wrapper) instead of the full scheduler output; set false for the complete text. max_speak_chars truncates long replies before speaking. chat_id identifies the single local session; home_channel defaults to it so timers/repair offers are spoken too. A stalled capture stream (the PortAudio callback stops delivering frames) is detected via audio.read_timeout_s and recovered by closing and reopening the input after audio.stall_timeout_s, so the front end no longer hangs silently. Utterances run on a worker thread (not the audio thread), so a slow or failing task neither stops the mic being read nor kills the front end.",
"enabled": false, "enabled": false,
"chat_id": "voice", "chat_id": "voice",
"display_name": "voice", "display_name": "voice",
@@ -260,18 +169,25 @@
"max_speak_chars": 600, "max_speak_chars": 600,
"listen_timeout_s": 3.0, "listen_timeout_s": 3.0,
"cue": { "cue": {
"_comment": "Audible feedback. A short sine beep plays when the wake word fires so you know you're being heard; submit_notes is a short multi-note 'bling' played once the utterance is transcribed (each entry [frequency_hz, duration_ms], separated by note_gap_ms of silence). Set submit_notes to [] and submit_frequency > 0 for the older single submit beep, or leave both empty/0 for no submit sound. volume is 0..1.",
"enabled": true, "enabled": true,
"frequency": 880, "frequency": 880,
"duration_ms": 120, "duration_ms": 120,
"volume": 0.9, "volume": 0.9,
"submit_frequency": 0, "submit_frequency": 0,
"submit_duration_ms": 100, "submit_duration_ms": 100,
"submit_notes": [[1046.5, 70], [1568.0, 90]], "submit_notes": [
[
1046.5,
70
],
[
1568.0,
90
]
],
"note_gap_ms": 20 "note_gap_ms": 20
}, },
"wake": { "wake": {
"_comment": "model is an openWakeWord name/path. The default 'hey_computer' is a pinned community model whose scores run lower than the official models (measured ~0.26-0.82 on the phrase, <0.02 on negatives), so threshold 0.2 is tuned for it; the official models (e.g. hey_mycroft) score ~0.99 and are fine at 0.5.",
"model": "hey_computer", "model": "hey_computer",
"threshold": 0.2, "threshold": 0.2,
"inference_framework": "onnx", "inference_framework": "onnx",
@@ -291,7 +207,6 @@
"volume": 1.0 "volume": 1.0
}, },
"audio": { "audio": {
"_comment": "Capture-stream watchdog: read_timeout_s is how long a frame read waits before it counts as a stall; when the stream stalls continuously for stall_timeout_s (a wedged PortAudio/ALSA callback stops delivering frames) the input is closed and reopened so the voice front end recovers instead of hanging forever. 0 for either restores the old blocking read with no recovery.",
"input_device": "", "input_device": "",
"output_device": "", "output_device": "",
"sample_rate": 16000, "sample_rate": 16000,
@@ -303,7 +218,6 @@
"stall_timeout_s": 5.0 "stall_timeout_s": 5.0
}, },
"vad": { "vad": {
"_comment": "Endpointing. silence_ms is the trailing-silence endpoint once a command is underway. The wake detector can fire inside the wake phrase (and the cue beep follows), so the first speech captured is the phrase's tail, not the command: until min_command_ms of speech is in hand the endpoint uses initial_silence_ms instead, so a natural pause before the command does not end the capture. min_speech_ms rejects a blip; max_utterance_s caps a runaway.",
"silence_ms": 500, "silence_ms": 500,
"min_speech_ms": 120, "min_speech_ms": 120,
"max_utterance_s": 30, "max_utterance_s": 30,
@@ -311,8 +225,87 @@
"initial_silence_ms": 1500, "initial_silence_ms": 1500,
"aggressiveness": 2, "aggressiveness": 2,
"energy_threshold": 200.0 "energy_threshold": 200.0
},
"follow_up_window_s": 0.0
}
},
"dashboard": {
"port": 8765,
"host": "127.0.0.1"
},
"skill_packs": "packs",
"secrets_file": "secrets.json",
"_comment": "GENERATED from the core schema (semif_agent/config.py) and each pack's pack.json `config` schema \u2014 do not hand-edit; edit a pack's schema or the core schema. This is the reference example; the live per-machine config is split under config/ (see config.json's include list) and secrets live in the gitignored secrets.json, referenced as '!secret <key>'.",
"bridges": {
"llm": {
"enabled": true,
"host": "127.0.0.1",
"port": 5229,
"token": "!secret llm_token"
},
"browser": {
"enabled": false,
"host": "127.0.0.1",
"port": 5232,
"token": "!secret browser_token",
"engine": "chromium",
"headless": true,
"channel": "",
"executable_path": "",
"profile_dir": "",
"browsers_path": "",
"screenshot_dir": "",
"default_timeout": 30.0,
"max_text_chars": 20000
},
"nextcloud": {
"enabled": true,
"host": "127.0.0.1",
"port": 5230,
"token": "!secret nextcloud_token",
"url": "",
"username": "",
"app_password": "!secret nextcloud_app_password",
"default_calendar": "",
"default_task_calendar": "",
"default_addressbook": "",
"verify_tls": true,
"timeout": 30
},
"outlook": {
"enabled": false,
"host": "127.0.0.1",
"port": 5231,
"token": "!secret outlook_token",
"client_id": "",
"tenant": "common",
"token_path": ".runtime/outlook/token.json",
"default_calendar": "",
"default_task_list": "",
"default_mail_folder": "inbox",
"default_timezone": "UTC",
"verify_tls": true,
"timeout": 30
},
"simplex": {
"enabled": true,
"host": "127.0.0.1",
"port": 5227,
"token": "!secret simplex_token",
"max_inbox": 100,
"ws_url": "ws://127.0.0.1:5228",
"user_id": 1,
"auto_accept": true,
"reconnect": {
"initial": 1.0,
"max": 60.0,
"jitter": 0.2
} }
} }
}, },
"dashboard": {"port": 8765, "host": "127.0.0.1"} "packs": {
"essentials": {
"enabled": true
}
}
} }
+2 -1
View File
@@ -216,6 +216,7 @@ confirm is skipped; the **leaf** intent guard is never bypassed (the leaf softma
has no create option, so a confident winner is only the closest existing skill, has no create option, so a confident winner is only the closest existing skill,
never a match) — it always runs and can reject into create. never a match) — it always runs and can reject into create.
New-skill creation is gated deterministically by the tri-state New-skill creation is gated deterministically by the tri-state
`new_skill_creation` mode — global default (`allow` / `deny` / `ask`) with a `new_skill_creation` mode — global default `deny` (opt in with `allow`, or
`ask` for approval-gated authoring) with a
per-category override in `data/skills/<category>/config.json`; the per-category override in `data/skills/<category>/config.json`; the
`housekeeping` and `response` categories are always `deny` in code. `housekeeping` and `response` categories are always `deny` in code.
+26
View File
@@ -0,0 +1,26 @@
{
"name": "browser",
"title": "Browser",
"concern": "Real browser automation (Playwright): open a web page, read its text or links, take a screenshot, and click, type, or fill forms to carry out a task on a website.",
"categories": {
"browser": "Browser automation: opening a web page, reading its text or links, taking a screenshot, and clicking, typing, or filling forms to carry out a task on a website."
},
"bridges": ["browser"],
"requires": ["playwright"],
"enabled_by_default": false,
"config": {
"enabled": {"type": "bool", "default": false, "doc": "Load this pack's skills and run its bridge. Disabled by default: it needs the optional Playwright deps + browser binaries (scripts/bootstrap.sh --browser)."},
"host": {"type": "str", "default": "127.0.0.1", "doc": "Bridge bind address (localhost only)."},
"port": {"type": "int", "default": 5232, "doc": "Bridge listen port."},
"token": {"type": "str", "default": "", "secret": true, "doc": "Shared secret required in the X-Semif-Token header when set."},
"engine": {"type": "str", "default": "chromium", "doc": "chromium | firefox | webkit."},
"headless": {"type": "bool", "default": true, "doc": "false shows the browser window (to sign in once)."},
"channel": {"type": "str", "default": "", "doc": "Use an already-installed browser channel (chrome/msedge) and skip Playwright's download."},
"executable_path": {"type": "str", "default": "", "doc": "Use a specific browser binary; wins over channel."},
"profile_dir": {"type": "str", "default": "", "doc": "Persistent profile directory (logins survive across calls)."},
"browsers_path": {"type": "str", "default": "", "doc": "PLAYWRIGHT_BROWSERS_PATH override."},
"screenshot_dir": {"type": "str", "default": "", "doc": "Where screenshots are saved."},
"default_timeout": {"type": "float", "default": 30.0, "doc": "Default navigation/action timeout (seconds)."},
"max_text_chars": {"type": "int", "default": 20000, "doc": "Bound on returned page text."}
}
}
+15
View File
@@ -0,0 +1,15 @@
{
"name": "essentials",
"title": "Essentials",
"concern": "The built-in local utilities the agent ships with that need no account, network, or bridge: time and date, timers and alarms, and arithmetic.",
"categories": {
"time": "Time and date utilities: telling the current time or date, setting countdown timers, and setting alarms.",
"calculator": "Arithmetic: evaluating a numeric expression the user asks for — addition, subtraction, multiplication, division, powers and exponents, squares, cubes, square roots, cube roots, fractions, and percentages."
},
"bridges": [],
"requires": [],
"enabled_by_default": true,
"config": {
"enabled": {"type": "bool", "default": true, "doc": "Load the built-in local utility skills (time, calculator)."}
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+25
View File
@@ -0,0 +1,25 @@
{
"name": "nextcloud",
"title": "Nextcloud",
"concern": "The user's Nextcloud account: calendar events and scheduling, to-do tasks, files, contacts, and notes.",
"categories": {
"nextcloud": "Nextcloud productivity: the user's calendar events and scheduling (reading or changing events and reminders) and the user's to-do tasks and task lists."
},
"bridges": ["nextcloud"],
"requires": [],
"enabled_by_default": true,
"config": {
"enabled": {"type": "bool", "default": true, "doc": "Load this pack's skills and run its bridge."},
"host": {"type": "str", "default": "127.0.0.1", "doc": "Bridge bind address (localhost only)."},
"port": {"type": "int", "default": 5230, "doc": "Bridge listen port."},
"token": {"type": "str", "default": "", "secret": true, "doc": "Shared secret required in the X-Semif-Token header when set."},
"url": {"type": "str", "default": "", "doc": "Nextcloud base URL, e.g. https://cloud.example.com."},
"username": {"type": "str", "default": "", "doc": "Nextcloud username."},
"app_password": {"type": "str", "default": "", "secret": true, "doc": "Nextcloud app password (Settings > Security > Devices & sessions), not the account password."},
"default_calendar": {"type": "str", "default": "", "doc": "Calendar used when a request names none and the account has several."},
"default_task_calendar": {"type": "str", "default": "", "doc": "VTODO-capable task list used when a request names none."},
"default_addressbook": {"type": "str", "default": "", "doc": "Addressbook used when a request names none."},
"verify_tls": {"type": "bool", "default": true, "doc": "false skips certificate verification (self-signed hosts)."},
"timeout": {"type": "int", "default": 30, "doc": "Per-request timeout in seconds."}
}
}
+26
View File
@@ -0,0 +1,26 @@
{
"name": "outlook",
"title": "Outlook",
"concern": "The user's Microsoft account (Outlook / Microsoft 365) through Microsoft Graph: mail, calendar events, Microsoft To Do tasks, contacts, and OneDrive files.",
"categories": {
"outlook": "Outlook / Microsoft 365: the user's mail, calendar events, Microsoft To Do tasks, contacts, and OneDrive files."
},
"bridges": ["outlook"],
"requires": [],
"enabled_by_default": false,
"config": {
"enabled": {"type": "bool", "default": false, "doc": "Load this pack's skills and run its bridge. Disabled by default: it needs an Entra ID client id and an authorization run first."},
"host": {"type": "str", "default": "127.0.0.1", "doc": "Bridge bind address (localhost only)."},
"port": {"type": "int", "default": 5231, "doc": "Bridge listen port."},
"token": {"type": "str", "default": "", "secret": true, "doc": "Shared secret required in the X-Semif-Token header when set."},
"client_id": {"type": "str", "default": "", "doc": "Entra ID public-client app id (not a secret)."},
"tenant": {"type": "str", "default": "common", "doc": "Entra tenant: common | organizations | consumers | a tenant id."},
"token_path": {"type": "str", "default": ".runtime/outlook/token.json", "doc": "Where scripts/outlook-auth.py stores the tokens (0600)."},
"default_calendar": {"type": "str", "default": "", "doc": "Calendar used when a request names none."},
"default_task_list": {"type": "str", "default": "", "doc": "Microsoft To Do list used when a request names none."},
"default_mail_folder": {"type": "str", "default": "inbox", "doc": "Mail folder read by default."},
"default_timezone": {"type": "str", "default": "UTC", "doc": "IANA zone for created events/tasks whose start has no offset."},
"verify_tls": {"type": "bool", "default": true, "doc": "false skips certificate verification."},
"timeout": {"type": "int", "default": 30, "doc": "Per-request timeout in seconds."}
}
}
+26
View File
@@ -0,0 +1,26 @@
{
"name": "simplex",
"title": "SimpleX",
"concern": "SimpleX messaging through the forwarding bridge: reading incoming messages, sending messages to contacts, and showing the user's contact link.",
"categories": {
"simplex": "SimpleX messaging: reading incoming messages, sending messages to contacts, and showing the user's contact link."
},
"bridges": ["simplex"],
"requires": [],
"enabled_by_default": true,
"config": {
"enabled": {"type": "bool", "default": true, "doc": "Load this pack's skills and run its bridge."},
"host": {"type": "str", "default": "127.0.0.1", "doc": "Bridge bind address (localhost only)."},
"port": {"type": "int", "default": 5227, "doc": "Bridge listen port."},
"token": {"type": "str", "default": "", "secret": true, "doc": "Shared secret required in the X-Semif-Token header when set."},
"max_inbox": {"type": "int", "default": 100, "doc": "Bound on the in-memory inbound-message buffer."},
"ws_url": {"type": "str", "default": "ws://127.0.0.1:5228", "doc": "The bridge's OWN simplex-chat daemon WebSocket URL (must match simplex_chat.forward_port)."},
"user_id": {"type": "int", "default": 1, "doc": "Daemon user id the bridge acts as."},
"auto_accept": {"type": "bool", "default": true, "doc": "Auto-accept inbound contact requests."},
"reconnect": {
"initial": {"type": "float", "default": 1.0, "doc": "Initial reconnect delay (seconds)."},
"max": {"type": "float", "default": 60.0, "doc": "Maximum reconnect delay (seconds)."},
"jitter": {"type": "float", "default": 0.2, "doc": "Reconnect jitter fraction."}
}
}
}
+34 -20
View File
@@ -10,10 +10,12 @@
# re-cloned — only the SemIf engine and the simplex-chat binary are fetched. # re-cloned — only the SemIf engine and the simplex-chat binary are fetched.
# Clone the agent repo first (its SSH key must be registered on your git host). # Clone the agent repo first (its SSH key must be registered on your git host).
# #
# config.json is the per-machine USER config and this script NEVER writes it. It # config.json is the per-machine USER config (a thin index over config/*.json)
# seeds config.json from config.example.json only when config.json is absent, # and this script NEVER rewrites it. It seeds the split config via `config-init`
# then reads every per-machine value from config.json; only a human edits # (config/core.json, config/gateway.json, config/bridges.json, config/packs/*.json,
# config.json afterwards. Pinned external refs (SemIf commit, GGUF url+sha256, # the config.json index, and an empty secrets.json) only when config.json is
# absent, then reads every per-machine value from the merged config; only a human
# edits it afterwards. Pinned external refs (SemIf commit, GGUF url+sha256,
# HF tokenizer revision, simplex-chat version/url+sha256) live in the committed # HF tokenizer revision, simplex-chat version/url+sha256) live in the committed
# pins.json and the python dep pins in requirements/staging.txt — bump those # pins.json and the python dep pins in requirements/staging.txt — bump those
# (via git) and rerun to upgrade. # (via git) and rerun to upgrade.
@@ -27,8 +29,8 @@
# Only artifacts that operationally must live elsewhere are outside: the SSH # Only artifacts that operationally must live elsewhere are outside: the SSH
# key (~/.ssh) and the real systemd user dir/linger. # key (~/.ssh) and the real systemd user dir/linger.
# #
# Flags override the values read from config.json FOR THIS RUN ONLY; nothing is # Flags override the values read from the merged config FOR THIS RUN ONLY;
# written back to config.json. # nothing is written back to the config.
# #
# Usage: # Usage:
# scripts/bootstrap.sh [--llm-url URL] [--codegen-url URL] [--llm-model MODEL] # scripts/bootstrap.sh [--llm-url URL] [--codegen-url URL] [--llm-model MODEL]
@@ -104,13 +106,23 @@ if [[ ! -f "$PINS" ]]; then
exit 1 exit 1
fi fi
# config.json is per-machine USER config. Seed it once from the template, then # config.json is per-machine USER config. Seed it once (as a thin index plus the
# never write it again — only a human edits config.json. # split config/ fragments + secrets.json), then never write it again — only a
# human edits it. The committed config.example.json is GENERATED from the pack +
# core schemas; see `python -m semif_agent.cli check-config --write-example`.
if [[ ! -f "$CONFIG" ]]; then if [[ ! -f "$CONFIG" ]]; then
echo "== seeding config.json from config.example.json (edit it to configure this machine)" echo "== seeding config/ + secrets.json (edit them to configure this machine)"
cp "$EXAMPLE" "$CONFIG" PYTHONPATH="$REPO_ROOT${PYTHONPATH:+:$PYTHONPATH}" python3 -m semif_agent.cli config-init --path "$CONFIG" \
|| { echo "config-init failed; falling back to a flat config.json from the example" >&2; cp "$EXAMPLE" "$CONFIG"; }
fi fi
# 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.
MERGED_CONFIG="$RUNTIME/config.merged.json"
mkdir -p "$RUNTIME"
python3 "$REPO_ROOT/scripts/config_merge.py" "$CONFIG" > "$MERGED_CONFIG" \
|| { echo "could not read $CONFIG" >&2; exit 1; }
# --- read pins from the committed pins.json --------------------------------- # --- read pins from the committed pins.json ---------------------------------
# The ASCII unit separator (\x1f) delimits fields so an empty value never # The ASCII unit separator (\x1f) delimits fields so an empty value never
# shifts the fields after it (space-splitting collapses runs of whitespace). # shifts the fields after it (space-splitting collapses runs of whitespace).
@@ -154,7 +166,7 @@ fi
# --- read per-machine values from config.json (flags override for this run) -- # --- read per-machine values from config.json (flags override for this run) --
IFS=$'\x1f' read -r CFG_LLM_URL CFG_LLM_MODEL CFG_LLM_PROVIDER CFG_CODEGEN_URL CFG_CODEGEN_MODEL \ IFS=$'\x1f' read -r CFG_LLM_URL CFG_LLM_MODEL CFG_LLM_PROVIDER CFG_CODEGEN_URL CFG_CODEGEN_MODEL \
SIMPLEX_PORT SIMPLEX_DISPLAY SIMPLEX_FORWARD_PORT SIMPLEX_FORWARD_DISPLAY < <( SIMPLEX_PORT SIMPLEX_DISPLAY SIMPLEX_FORWARD_PORT SIMPLEX_FORWARD_DISPLAY < <(
python3 - "$CONFIG" <<'PY' python3 - "$MERGED_CONFIG" <<'PY'
import json, sys import json, sys
cfg = json.load(open(sys.argv[1])) cfg = json.load(open(sys.argv[1]))
s = cfg.get("simplex_chat", {}) s = cfg.get("simplex_chat", {})
@@ -263,7 +275,7 @@ fi
# host must not get one. `--gpu <backend>` forces a build; `--gpu auto` (the # host must not get one. `--gpu <backend>` forces a build; `--gpu auto` (the
# default) builds a GPU backend only when config.json asks for offload # default) builds a GPU backend only when config.json asks for offload
# (`engine.gpu_layers` nonzero). # (`engine.gpu_layers` nonzero).
CONFIG_GPU_LAYERS="$(python3 - "$CONFIG" <<'PY' CONFIG_GPU_LAYERS="$(python3 - "$MERGED_CONFIG" <<'PY'
import json, sys import json, sys
try: try:
print(int(json.load(open(sys.argv[1])).get("engine", {}).get("gpu_layers", 0) or 0)) print(int(json.load(open(sys.argv[1])).get("engine", {}).get("gpu_layers", 0) or 0))
@@ -373,7 +385,7 @@ fi
if [[ "$BROWSER" = 1 ]]; then if [[ "$BROWSER" = 1 ]]; then
echo "== installing browser-bridge deps into $VENV" echo "== installing browser-bridge deps into $VENV"
"$PIP" install -r "$REPO_ROOT/requirements/browser.txt" "$PIP" install -r "$REPO_ROOT/requirements/browser.txt"
BROWSER_ENGINE="$("$PYTHON" - "$CONFIG" <<'PY' 2>/dev/null || true BROWSER_ENGINE="$("$PYTHON" - "$MERGED_CONFIG" <<'PY' 2>/dev/null || true
import json, sys import json, sys
try: try:
cfg = json.load(open(sys.argv[1])) cfg = json.load(open(sys.argv[1]))
@@ -433,7 +445,7 @@ PY
# warns (the gateway reports the missing model at startup) rather than aborting. # warns (the gateway reports the missing model at startup) rather than aborting.
if [[ "$VOICE" = 1 ]]; then if [[ "$VOICE" = 1 ]]; then
echo "== downloading voice models (openWakeWord + Piper + faster-whisper)" echo "== downloading voice models (openWakeWord + Piper + faster-whisper)"
HF_HOME="$HF_CACHE" "$PYTHON" "$REPO_ROOT/scripts/voice-models.py" --config "$CONFIG" \ HF_HOME="$HF_CACHE" "$PYTHON" "$REPO_ROOT/scripts/voice-models.py" --config "$MERGED_CONFIG" \
|| echo "WARN: voice model download failed; re-run scripts/voice-models.py" >&2 || echo "WARN: voice model download failed; re-run scripts/voice-models.py" >&2
fi fi
@@ -527,7 +539,7 @@ fi
# --- stage 8c: forwarding bridge contact address -------------------------------------- # --- stage 8c: forwarding bridge contact address --------------------------------------
# The forwarding bridge owns a second daemon/profile; its own contact link is the # The forwarding bridge owns a second daemon/profile; its own contact link is the
# one `simplex.connect_link` shows. Print it too so the user can share it. # one `simplex.connect_link` shows. Print it too so the user can share it.
BRIDGE_FORWARD_WS="$("$PYTHON" - "$REPO_ROOT/config.json" <<'PY' 2>/dev/null || true BRIDGE_FORWARD_WS="$("$PYTHON" - "$MERGED_CONFIG" <<'PY' 2>/dev/null || true
import json, sys import json, sys
try: try:
cfg = json.load(open(sys.argv[1])) cfg = json.load(open(sys.argv[1]))
@@ -625,9 +637,11 @@ fi
cat <<EOF cat <<EOF
Done. Next steps: Done. Next steps:
1. Edit config.json — set llm.model/llm.base_url and codegen.model/codegen.base_url. 1. Edit the split config (config/core.json, config/gateway.json,
bootstrap.sh seeded config.json from config.example.json (if it was absent) config/packs/*.json) — set llm.model/llm.base_url and
and NEVER rewrites it; only you edit config.json. codegen.model/codegen.base_url; put credentials in secrets.json.
bootstrap.sh seeded the config via config-init (if it was absent)
and NEVER rewrites it; only you edit it.
cd "$REPO_ROOT" cd "$REPO_ROOT"
HF_HOME="$HF_CACHE" "$PYTHON" -m semif_agent.cli run HF_HOME="$HF_CACHE" "$PYTHON" -m semif_agent.cli run
HF_HOME="$HF_CACHE" "$PYTHON" -m pytest tests/integration -q -s (needs real engine+LLM) HF_HOME="$HF_CACHE" "$PYTHON" -m pytest tests/integration -q -s (needs real engine+LLM)
@@ -679,7 +693,7 @@ Nextcloud bridge (files/calendar/tasks/contacts/notes for skills):
- Runs inside the same 'semif-bridge' process (Nextcloud is plain HTTPS, so - Runs inside the same 'semif-bridge' process (Nextcloud is plain HTTPS, so
there is no separate daemon). Configure the account once in config.json under there is no separate daemon). Configure the account once in config.json under
bridges.nextcloud (url/username/app_password) — or reuse the top-level bridges.nextcloud (url/username/app_password) — or reuse the top-level
nextcloud_* values the nextcloud seeds collect. Skills call it at the address nextcloud_* values the nextcloud pack skills collect. Skills call it at the address
derived from bridges.nextcloud (default http://127.0.0.1:5230). derived from bridges.nextcloud (default http://127.0.0.1:5230).
Browser bridge (browser automation for skills): Browser bridge (browser automation for skills):
@@ -727,7 +741,7 @@ Browser bridge (browser automation for skills):
(useful the first time you sign in to a site); POST /reset with purge=true (useful the first time you sign in to a site); POST /reset with purge=true
wipes the stored profile. wipes the stored profile.
- Skills call it at the address derived from bridges.browser (host/port, - Skills call it at the address derived from bridges.browser (host/port,
default http://127.0.0.1:5232); the shipped seeds are browser.open_page, default http://127.0.0.1:5232); the shipped pack skills are browser.open_page,
browser.read_page, and browser.screenshot. browser.read_page, and browser.screenshot.
- If the bridge reports 503, the browser failed to launch — run: - If the bridge reports 503, the browser failed to launch — run:
PLAYWRIGHT_BROWSERS_PATH=$BROWSERS "$PYTHON" -m playwright install $BROWSER_ENGINE PLAYWRIGHT_BROWSERS_PATH=$BROWSERS "$PYTHON" -m playwright install $BROWSER_ENGINE
+49
View File
@@ -0,0 +1,49 @@
#!/usr/bin/env python3
"""Print the merged config.json as JSON, following its `include` list.
Stdlib-only on purpose: bootstrap.sh reads per-machine values from the config
before the venv exists, so it cannot import `semif_agent.config`. This is the
same include/deep-merge semantics (`semif_agent/config.py`), reduced to the
minimum bootstrap needs (secrets are not resolved — bootstrap only reads
non-secret values like ports and endpoints).
Usage: python3 scripts/config_merge.py [config.json]
"""
from __future__ import annotations
import json
import sys
from pathlib import Path
def _deep_merge(base: dict, extra: dict) -> dict:
for key, value in extra.items():
if isinstance(value, dict) and isinstance(base.get(key), dict):
_deep_merge(base[key], value)
else:
base[key] = value
return base
def merge(path: Path, seen: set[Path] | None = None) -> dict:
seen = seen if seen is not None else set()
resolved = path.resolve()
if resolved in seen:
raise SystemExit(f"config include cycle at {path}")
seen.add(resolved)
data = json.loads(path.read_text())
includes = data.pop("include", None)
merged: dict = {}
if includes:
for entry in includes:
inc = Path(entry)
if not inc.is_absolute():
inc = path.parent / inc
_deep_merge(merged, merge(inc, seen))
return _deep_merge(merged, data)
if __name__ == "__main__":
source = Path(sys.argv[1] if len(sys.argv) > 1 else "config.json")
print(json.dumps(merge(source)))
Loaded 100 of 123 files, more files were not shown because too many files have changed in this diff. Show more